You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by gb...@apache.org on 2010/06/08 18:26:35 UTC

svn commit: r952723 - in /pivot/trunk: tutorials-server/src/org/apache/pivot/tutorials/webqueries/server/ tutorials/src/org/apache/pivot/tutorials/webqueries/

Author: gbrown
Date: Tue Jun  8 16:26:34 2010
New Revision: 952723

URL: http://svn.apache.org/viewvc?rev=952723&view=rev
Log:
Continue development of QueryServlet tutorial.

Added:
    pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/AmountBindMapping.java
    pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/CurrencyValidator.java
    pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/ExpenseSheet.java
    pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/ExpenseSheet.json
    pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/Expenses.java
    pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/ExpensesWindow.java
    pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/ExpensesWindow.json
    pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/add.png   (with props)
    pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/delete.png   (with props)
    pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/expense_sheet.wtkx
    pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/expenses_window.wtkx
    pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/pencil.png   (with props)
    pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/pencil_add.png   (with props)
    pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/types.json
Modified:
    pivot/trunk/tutorials-server/src/org/apache/pivot/tutorials/webqueries/server/Expense.java
    pivot/trunk/tutorials-server/src/org/apache/pivot/tutorials/webqueries/server/ExpenseServlet.java

Modified: pivot/trunk/tutorials-server/src/org/apache/pivot/tutorials/webqueries/server/Expense.java
URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials-server/src/org/apache/pivot/tutorials/webqueries/server/Expense.java?rev=952723&r1=952722&r2=952723&view=diff
==============================================================================
--- pivot/trunk/tutorials-server/src/org/apache/pivot/tutorials/webqueries/server/Expense.java (original)
+++ pivot/trunk/tutorials-server/src/org/apache/pivot/tutorials/webqueries/server/Expense.java Tue Jun  8 16:26:34 2010
@@ -19,11 +19,20 @@ package org.apache.pivot.tutorials.webqu
 import org.apache.pivot.util.CalendarDate;
 
 public class Expense {
+    private int id = -1;
     private CalendarDate calendarDate = null;
     private String type = null;
     private double amount = 0;
     private String description = null;
 
+    public int getID() {
+        return id;
+    }
+
+    protected void setID(int id) {
+        this.id = id;
+    }
+
     public CalendarDate getDate() {
         return calendarDate;
     }

Modified: pivot/trunk/tutorials-server/src/org/apache/pivot/tutorials/webqueries/server/ExpenseServlet.java
URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials-server/src/org/apache/pivot/tutorials/webqueries/server/ExpenseServlet.java?rev=952723&r1=952722&r2=952723&view=diff
==============================================================================
--- pivot/trunk/tutorials-server/src/org/apache/pivot/tutorials/webqueries/server/ExpenseServlet.java (original)
+++ pivot/trunk/tutorials-server/src/org/apache/pivot/tutorials/webqueries/server/ExpenseServlet.java Tue Jun  8 16:26:34 2010
@@ -57,6 +57,8 @@ public class ExpenseServlet extends Quer
 
         try {
             expenses = (List<Expense>)csvSerializer.readObject(inputStream);
+
+            // TODO Set a comparator so expenses are sorted by date, then type
         } catch (IOException exception) {
             throw new ServletException(exception);
         } catch (SerializationException exception) {
@@ -65,7 +67,9 @@ public class ExpenseServlet extends Quer
 
         // Index the initial expenses
         for (Expense expense : expenses) {
-            expenseMap.put(nextID++, expense);
+            int id = nextID++;
+            expense.setID(id);
+            expenseMap.put(id, expense);
         }
     }
 
@@ -105,7 +109,7 @@ public class ExpenseServlet extends Quer
         int id;
         synchronized (this) {
             id = nextID++;
-
+            expense.setID(id);
             expenses.add(expense);
             expenseMap.put(id, expense);
         }
@@ -133,6 +137,7 @@ public class ExpenseServlet extends Quer
 
         // Create the new expense and bind the data to it
         Expense expense = JSON.bind(value, Expense.class);
+        expense.setID(id);
 
         // Update the list/map
         Expense previousExpense;

Added: pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/AmountBindMapping.java
URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/AmountBindMapping.java?rev=952723&view=auto
==============================================================================
--- pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/AmountBindMapping.java (added)
+++ pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/AmountBindMapping.java Tue Jun  8 16:26:34 2010
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pivot.tutorials.webqueries;
+
+import java.text.DecimalFormat;
+import java.text.NumberFormat;
+
+import org.apache.pivot.wtk.TextInput;
+
+public class AmountBindMapping implements TextInput.TextBindMapping {
+    private NumberFormat amountFormat = new DecimalFormat();
+
+    @Override
+    public String toString(Object value) {
+        return amountFormat.format(value);
+    }
+
+    @Override
+    public Object valueOf(String text) {
+        return Float.valueOf(text);
+    }
+
+    public NumberFormat getAmountFormat() {
+        return amountFormat;
+    }
+
+    public void setAmountFormat(NumberFormat amountFormat) {
+        if (amountFormat == null) {
+            throw new IllegalArgumentException("amountFormat is null.");
+        }
+
+        this.amountFormat = amountFormat;
+    }
+
+    public void setAmountFormat(String amountFormat) {
+        setAmountFormat(new DecimalFormat(amountFormat));
+    }
+}

Added: pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/CurrencyValidator.java
URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/CurrencyValidator.java?rev=952723&view=auto
==============================================================================
--- pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/CurrencyValidator.java (added)
+++ pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/CurrencyValidator.java Tue Jun  8 16:26:34 2010
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pivot.tutorials.webqueries;
+
+import java.math.BigDecimal;
+
+import org.apache.pivot.wtk.validation.Validator;
+
+/**
+ * Validates that text represents a valid dollar value.
+ */
+public class CurrencyValidator implements Validator {
+    @Override
+    public boolean isValid(String text) {
+        boolean valid = true;
+
+        if (text.length() > 0) {
+            try {
+                BigDecimal numericAmount = new BigDecimal(text);
+                valid = (numericAmount.scale() <= 2 && numericAmount.signum() >= 0);
+            } catch (NumberFormatException ex) {
+                valid = false;
+            }
+        }
+
+        return valid;
+    }
+}

Added: pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/ExpenseSheet.java
URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/ExpenseSheet.java?rev=952723&view=auto
==============================================================================
--- pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/ExpenseSheet.java (added)
+++ pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/ExpenseSheet.java Tue Jun  8 16:26:34 2010
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pivot.tutorials.webqueries;
+
+import org.apache.pivot.util.CalendarDate;
+import org.apache.pivot.util.Resources;
+import org.apache.pivot.wtk.Button;
+import org.apache.pivot.wtk.ButtonPressListener;
+import org.apache.pivot.wtk.Form;
+import org.apache.pivot.wtk.ListButton;
+import org.apache.pivot.wtk.MessageType;
+import org.apache.pivot.wtk.PushButton;
+import org.apache.pivot.wtk.Sheet;
+import org.apache.pivot.wtk.Spinner;
+import org.apache.pivot.wtk.TextInput;
+import org.apache.pivot.wtkx.Bindable;
+import org.apache.pivot.wtkx.WTKX;
+
+public class ExpenseSheet extends Sheet implements Bindable {
+    @WTKX private Spinner dateSpinner = null;
+    @WTKX private ListButton typeListButton = null;
+    @WTKX private TextInput amountTextInput = null;
+
+    @WTKX private PushButton cancelButton = null;
+    @WTKX private PushButton okButton = null;
+
+    private Resources resources = null;
+
+    @Override
+    public void initialize(Resources resource) {
+        this.resources = resource;
+
+        cancelButton.getButtonPressListeners().add(new ButtonPressListener() {
+            @Override
+            public void buttonPressed(Button button) {
+                close(false);
+            }
+        });
+
+        okButton.getButtonPressListeners().add(new ButtonPressListener() {
+            @Override
+            public void buttonPressed(Button button) {
+                close(true);
+            }
+        });
+    }
+
+    @Override
+    public void close(boolean result) {
+        int errorCount = 0;
+
+        if (result) {
+            // Validate the form contents
+            if (typeListButton.getSelectedIndex() == -1) {
+                Form.setFlag(typeListButton, new Form.Flag(MessageType.ERROR,
+                    resources.getString("typeRequired")));
+                errorCount++;
+            } else {
+                Form.setFlag(typeListButton, (Form.Flag)null);
+            }
+
+            if (amountTextInput.getTextLength() == 0) {
+                Form.setFlag(amountTextInput, new Form.Flag(MessageType.ERROR,
+                    resources.getString("amountRequired")));
+                errorCount++;
+            } else {
+                Form.setFlag(amountTextInput, (Form.Flag)null);
+            }
+        }
+
+        if (errorCount == 0) {
+            super.close(result);
+        }
+    }
+
+    @Override
+    public void clear() {
+        super.clear();
+
+        // Set date to today
+        dateSpinner.setSelectedItem(new CalendarDate());
+    }
+}

Added: pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/ExpenseSheet.json
URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/ExpenseSheet.json?rev=952723&view=auto
==============================================================================
--- pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/ExpenseSheet.json (added)
+++ pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/ExpenseSheet.json Tue Jun  8 16:26:34 2010
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ {  title: "Add/Edit Expense",
+    id: "ID",
+    date: "Date",
+    type: "Type",
+    amount: "Amount",
+    description: "Description",
+    amountFormat: "0.00",
+    cancel: "Cancel",
+    ok: "OK",
+    typeRequired: "Expense type is required.",
+    amountRequired: "Amount is required."
+}

Added: pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/Expenses.java
URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/Expenses.java?rev=952723&view=auto
==============================================================================
--- pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/Expenses.java (added)
+++ pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/Expenses.java Tue Jun  8 16:26:34 2010
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pivot.tutorials.webqueries;
+
+import org.apache.pivot.collections.Map;
+import org.apache.pivot.util.Resources;
+import org.apache.pivot.wtk.Application;
+import org.apache.pivot.wtk.DesktopApplicationContext;
+import org.apache.pivot.wtk.Display;
+import org.apache.pivot.wtkx.WTKXSerializer;
+
+public class Expenses implements Application {
+    private ExpensesWindow expensesWindow = null;
+
+    @Override
+    public void startup(Display display, Map<String, String> properties) throws Exception {
+        Resources resources = new Resources(ExpensesWindow.class.getName());
+        WTKXSerializer wtkxSerializer = new WTKXSerializer(resources);
+        expensesWindow = (ExpensesWindow)wtkxSerializer.readObject(this, "expenses_window.wtkx");
+        expensesWindow.open(display);
+    }
+
+    @Override
+    public boolean shutdown(boolean optional) {
+        if (expensesWindow != null) {
+            expensesWindow.close();
+        }
+
+        return false;
+    }
+
+    @Override
+    public void suspend() {
+    }
+
+    @Override
+    public void resume() {
+    }
+
+    public static void main(String[] args) {
+        DesktopApplicationContext.main(Expenses.class, args);
+    }
+}

Added: pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/ExpensesWindow.java
URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/ExpensesWindow.java?rev=952723&view=auto
==============================================================================
--- pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/ExpensesWindow.java (added)
+++ pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/ExpensesWindow.java Tue Jun  8 16:26:34 2010
@@ -0,0 +1,171 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pivot.tutorials.webqueries;
+
+import java.io.IOException;
+
+import org.apache.pivot.collections.HashMap;
+import org.apache.pivot.collections.List;
+import org.apache.pivot.collections.Sequence;
+import org.apache.pivot.serialization.SerializationException;
+import org.apache.pivot.util.Resources;
+import org.apache.pivot.wtk.Action;
+import org.apache.pivot.wtk.Display;
+import org.apache.pivot.wtk.Sheet;
+import org.apache.pivot.wtk.SheetCloseListener;
+import org.apache.pivot.wtk.Span;
+import org.apache.pivot.wtk.TableView;
+import org.apache.pivot.wtk.TableViewSelectionListener;
+import org.apache.pivot.wtk.Window;
+import org.apache.pivot.wtkx.Bindable;
+import org.apache.pivot.wtkx.WTKX;
+import org.apache.pivot.wtkx.WTKXSerializer;
+
+public class ExpensesWindow extends Window implements Bindable {
+    private class RefreshExpenseListAction extends Action {
+        @Override
+        public void perform() {
+            refreshExpenseList();
+        }
+    }
+
+    private class AddExpenseAction extends Action {
+        @Override
+        public void perform() {
+            addExpense();
+        }
+    }
+
+    private class EditSelectedExpenseAction extends Action {
+        public EditSelectedExpenseAction() {
+            super(false);
+        }
+
+        @Override
+        public void perform() {
+            updateSelectedExpense();
+        }
+    }
+
+    private class DeleteSelectedExpenseAction extends Action {
+        public DeleteSelectedExpenseAction() {
+            super(false);
+        }
+
+        @Override
+        public void perform() {
+            deleteSelectedExpense();
+        }
+    }
+
+    private RefreshExpenseListAction refreshExpenseListAction = new RefreshExpenseListAction();
+    private AddExpenseAction addExpenseAction = new AddExpenseAction();
+    private EditSelectedExpenseAction editSelectedExpenseAction = new EditSelectedExpenseAction();
+    private DeleteSelectedExpenseAction deleteSelectedExpenseAction = new DeleteSelectedExpenseAction();
+
+    @WTKX private TableView expenseTableView = null;
+
+    private ExpenseSheet expenseSheet = null;
+
+    public static final String REFRESH_EXPENSE_LIST_ACTION_ID = "refresh_expense_list";
+    public static final String ADD_EXPENSE_ACTION_ID = "add_expense";
+    public static final String EDIT_SELECTED_EXPENSE_ACTION_ID = "edit_selected_expense";
+    public static final String DELETE_SELECTED_EXPENSE_ACTION_ID = "delete_selected_expense";
+
+    public ExpensesWindow() {
+        // Add actions to global action dictionary
+        Action.getNamedActions().put(REFRESH_EXPENSE_LIST_ACTION_ID, refreshExpenseListAction);
+        Action.getNamedActions().put(ADD_EXPENSE_ACTION_ID, addExpenseAction);
+        Action.getNamedActions().put(EDIT_SELECTED_EXPENSE_ACTION_ID, editSelectedExpenseAction);
+        Action.getNamedActions().put(DELETE_SELECTED_EXPENSE_ACTION_ID, deleteSelectedExpenseAction);
+    }
+
+    @Override
+    public void initialize(Resources resource) {
+        // Load the add/edit sheet
+        try {
+            Resources resources = new Resources(ExpenseSheet.class.getName());
+            WTKXSerializer wtkxSerializer = new WTKXSerializer(resources);
+            expenseSheet = (ExpenseSheet)wtkxSerializer.readObject(this, "expense_sheet.wtkx");
+        } catch (IOException exception) {
+            throw new RuntimeException(exception);
+        } catch (SerializationException exception) {
+            throw new RuntimeException(exception);
+        }
+
+        // Attach event listener(s)
+        expenseTableView.getTableViewSelectionListeners().add(new TableViewSelectionListener.Adapter() {
+            @Override
+            public void selectedRangesChanged(TableView tableView, Sequence<Span> previousSelectedRanges) {
+                int selectedIndex = expenseTableView.getSelectedIndex();
+                editSelectedExpenseAction.setEnabled(selectedIndex != -1);
+                deleteSelectedExpenseAction.setEnabled(selectedIndex != -1);
+            }
+        });
+    }
+
+    @Override
+    public void open(Display display, Window owner) {
+        super.open(display, owner);
+
+        // Load the expense data
+        refreshExpenseList();
+    }
+
+    private void refreshExpenseList() {
+        // TODO Show activity indicator and load expenses
+    }
+
+    @SuppressWarnings("unchecked")
+    private void addExpense() {
+        expenseSheet.clear();
+        expenseSheet.open(ExpensesWindow.this, new SheetCloseListener() {
+            @Override
+            public void sheetClosed(Sheet sheet) {
+                if (sheet.getResult()) {
+                    // Add result to table
+                    HashMap<String, Object> expense = new HashMap<String, Object>();
+                    expenseSheet.store(expense);
+
+                    // TODO POST expense to server and then add to table
+
+                    List<Object> expenses = (List<Object>)expenseTableView.getTableData();
+                    expenses.add(expense);
+                }
+            }
+        });
+    }
+
+    private void updateSelectedExpense() {
+        expenseSheet.load(expenseTableView.getSelectedRow());
+        expenseSheet.open(ExpensesWindow.this, new SheetCloseListener() {
+            @Override
+            public void sheetClosed(Sheet sheet) {
+                if (sheet.getResult()) {
+                    HashMap<String, Object> expense = new HashMap<String, Object>();
+                    expenseSheet.store(expense);
+
+                    // TODO PUT expense to server and then update table
+                }
+            }
+        });
+    }
+
+    private void deleteSelectedExpense() {
+        // TODO DELETE expense from server and then remove from table
+    }
+}

Added: pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/ExpensesWindow.json
URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/ExpensesWindow.json?rev=952723&view=auto
==============================================================================
--- pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/ExpensesWindow.json (added)
+++ pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/ExpensesWindow.json Tue Jun  8 16:26:34 2010
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ {  title: "Expenses",
+    date: "Date",
+    type: "Type",
+    amount: "Amount",
+    description: "Description",
+    amountFormat: "$#,##0.00",
+    add: "Add",
+    edit: "Edit",
+    delete: "Delete"
+}

Added: pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/add.png
URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/add.png?rev=952723&view=auto
==============================================================================
Binary file - no diff available.

Propchange: pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/add.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/delete.png
URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/delete.png?rev=952723&view=auto
==============================================================================
Binary file - no diff available.

Propchange: pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/delete.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/expense_sheet.wtkx
URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/expense_sheet.wtkx?rev=952723&view=auto
==============================================================================
--- pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/expense_sheet.wtkx (added)
+++ pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/expense_sheet.wtkx Tue Jun  8 16:26:34 2010
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to you under the Apache License,
+Version 2.0 (the "License"); you may not use this file except in
+compliance with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+
+<webqueries:ExpenseSheet title="%title"
+    xmlns:wtkx="http://pivot.apache.org/wtkx"
+    xmlns:content="org.apache.pivot.wtk.content"
+    xmlns:webqueries="org.apache.pivot.tutorials.webqueries"
+    xmlns="org.apache.pivot.wtk">
+    <content>
+        <TablePane styles="{verticalSpacing:8}">
+            <columns>
+                <TablePane.Column width="1*"/>
+            </columns>
+            <rows>
+                <TablePane.Row height="-1">
+                    <BoxPane styles="{verticalAlignment:'center'}">
+                        <ImageView image="@pencil_add.png"/>
+                        <Label text="%title" styles="{color:12, font:{bold:true, size:'120%'}}"/>
+                    </BoxPane>
+                </TablePane.Row>
+
+                <TablePane.Row height="1*">
+                    <Border styles="{padding:6}">
+                        <content>
+                            <Form>
+                                <sections>
+                                    <Form.Section>
+                                        <Label Form.label="%id" textKey="id"/>
+
+                                        <Spinner wtkx:id="dateSpinner" Form.label="%date" selectedItemKey="date">
+                                            <spinnerData>
+                                                <content:CalendarDateSpinnerData/>
+                                            </spinnerData>
+                                        </Spinner>
+
+                                        <ListButton wtkx:id="typeListButton" Form.label="%type" listData="@types.json"
+                                            selectedItemKey="type"/>
+
+                                        <TextInput wtkx:id="amountTextInput" Form.label="%amount" strictValidation="true"
+                                            textKey="amount">
+                                            <validator>
+                                                <webqueries:CurrencyValidator/>
+                                            </validator>
+                                            <textBindMapping>
+                                                <webqueries:AmountBindMapping amountFormat="%amountFormat"/>
+                                            </textBindMapping>
+                                        </TextInput>
+
+                                        <TextInput Form.label="%description" textKey="description"/>
+                                    </Form.Section>
+                                </sections>
+                            </Form>
+                        </content>
+                    </Border>
+                </TablePane.Row>
+
+                <TablePane.Row height="-1">
+                    <BoxPane styles="{fill:true, horizontalAlignment:'right'}">
+                        <PushButton wtkx:id="cancelButton" buttonData="%cancel"
+                            styles="org/apache/pivot/wtk/skin/terra/command_button.json"/>
+                        <PushButton wtkx:id="okButton" buttonData="%ok"
+                            styles="org/apache/pivot/wtk/skin/terra/command_button.json"/>
+                    </BoxPane>
+                </TablePane.Row>
+            </rows>
+        </TablePane>
+    </content>
+</webqueries:ExpenseSheet>

Added: pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/expenses_window.wtkx
URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/expenses_window.wtkx?rev=952723&view=auto
==============================================================================
--- pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/expenses_window.wtkx (added)
+++ pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/expenses_window.wtkx Tue Jun  8 16:26:34 2010
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to you under the Apache License,
+Version 2.0 (the "License"); you may not use this file except in
+compliance with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+
+<webqueries:ExpensesWindow title="%title" maximized="true"
+    xmlns:wtkx="http://pivot.apache.org/wtkx"
+    xmlns:content="org.apache.pivot.wtk.content"
+    xmlns:webqueries="org.apache.pivot.tutorials.webqueries"
+    xmlns="org.apache.pivot.wtk">
+    <content>
+        <TablePane styles="{verticalSpacing:4}">
+            <columns>
+                <TablePane.Column width="1*"/>
+            </columns>
+            <rows>
+                <TablePane.Row height="1*">
+                    <Border styles="{color:7}">
+                        <content>
+                            <ScrollPane horizontalScrollBarPolicy="fill_to_capacity">
+                                <view>
+                                    <TableView wtkx:id="expenseTableView" selectMode="single">
+                                        <columns>
+                                            <TableView.Column name="date" width="87" headerData="%date"/>
+                                            <TableView.Column name="type" width="125" headerData="%type"/>
+                                            <TableView.Column name="amount" width="75" headerData="%amount">
+                                                <cellRenderer>
+                                                    <content:TableViewNumberCellRenderer numberFormat="%amountFormat"/>
+                                                </cellRenderer>
+                                            </TableView.Column>
+                                            <TableView.Column name="description" width="150" headerData="%description"/>
+                                        </columns>
+                                    </TableView>
+                                </view>
+                                <columnHeader>
+                                    <TableViewHeader tableView="$expenseTableView" styles="{headersPressable:false}"/>
+                                </columnHeader>
+                            </ScrollPane>
+                        </content>
+                    </Border>
+                </TablePane.Row>
+
+                <TablePane.Row height="-1">
+                    <BoxPane styles="{spacing:0, fill:true}">
+                        <PushButton action="add_expense" styles="{toolbar:true}">
+                            <buttonData>
+                                <content:ButtonData icon="@add.png" text="%add"/>
+                            </buttonData>
+                        </PushButton>
+                        <PushButton action="edit_selected_expense" styles="{toolbar:true}">
+                            <buttonData>
+                                <content:ButtonData icon="@pencil.png" text="%edit"/>
+                            </buttonData>
+                        </PushButton>
+                        <PushButton action="delete_selected_expense" styles="{toolbar:true}">
+                            <buttonData>
+                                <content:ButtonData icon="@delete.png" text="%delete"/>
+                            </buttonData>
+                        </PushButton>
+                    </BoxPane>
+                </TablePane.Row>
+            </rows>
+        </TablePane>
+    </content>
+</webqueries:ExpensesWindow>

Added: pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/pencil.png
URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/pencil.png?rev=952723&view=auto
==============================================================================
Binary file - no diff available.

Propchange: pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/pencil.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/pencil_add.png
URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/pencil_add.png?rev=952723&view=auto
==============================================================================
Binary file - no diff available.

Propchange: pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/pencil_add.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/types.json
URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/types.json?rev=952723&view=auto
==============================================================================
--- pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/types.json (added)
+++ pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/types.json Tue Jun  8 16:26:34 2010
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+[   "Hotel",
+    "Miscellaneous",
+    "Meals",
+    "Parking",
+    "Travel"
+]