You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by sm...@apache.org on 2012/05/10 16:04:18 UTC
svn commit: r1336702 - in
/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries:
Expenses.java ExpensesWindow.java expense_sheet.bxml
Author: smartini
Date: Thu May 10 14:04:18 2012
New Revision: 1336702
URL: http://svn.apache.org/viewvc?rev=1336702&view=rev
Log:
fix warning from FindBugs, and little usability improvements
Modified:
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/expense_sheet.bxml
Modified: 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=1336702&r1=1336701&r2=1336702&view=diff
==============================================================================
--- pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/Expenses.java (original)
+++ pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/Expenses.java Thu May 10 14:04:18 2012
@@ -39,16 +39,24 @@ public class Expenses implements Applica
public static final String PORT_KEY = "port";
public static final String SECURE_KEY = "secure";
- private static Expenses instance = null;
-
public Expenses() {
- instance = this;
}
@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
// Get startup properties
URL origin = ApplicationContext.getOrigin();
+ if (origin == null) {
+ System.out.println("Warning: Origin null, so for this application to run you have to set the following properties: \n"
+ + SECURE_KEY + ", " + HOSTNAME_KEY + ", " + PORT_KEY + "\n"
+ );
+ }
+
+ if (properties.containsKey(SECURE_KEY)) {
+ secure = Boolean.parseBoolean(properties.get(SECURE_KEY));
+ } else {
+ secure = origin.getProtocol().equals("HTTPS");
+ }
if (properties.containsKey(HOSTNAME_KEY)) {
hostname = properties.get(HOSTNAME_KEY);
@@ -62,15 +70,10 @@ public class Expenses implements Applica
port = origin.getPort();
}
- if (properties.containsKey(SECURE_KEY)) {
- secure = Boolean.parseBoolean(properties.get(SECURE_KEY));
- } else {
- secure = origin.getProtocol().equals("HTTPS");
- }
-
BXMLSerializer bxmlSerializer = new BXMLSerializer();
expensesWindow = (ExpensesWindow)bxmlSerializer.readObject(ExpensesWindow.class,
"expenses_window.bxml", true);
+ expensesWindow.setExpensesApplication(this);
expensesWindow.open(display);
}
@@ -103,10 +106,6 @@ public class Expenses implements Applica
return secure;
}
- public static Expenses getInstance() {
- return instance;
- }
-
public static void main(String[] args) {
DesktopApplicationContext.main(Expenses.class, args);
}
Modified: 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=1336702&r1=1336701&r2=1336702&view=diff
==============================================================================
--- pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/ExpensesWindow.java (original)
+++ pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/ExpensesWindow.java Thu May 10 14:04:18 2012
@@ -52,6 +52,7 @@ import org.apache.pivot.wtk.Window;
* Main expense management window.
*/
public class ExpensesWindow extends Window implements Bindable {
+
private class RefreshExpenseListAction extends Action {
@Override
public void perform(Component source) {
@@ -88,6 +89,9 @@ public class ExpensesWindow extends Wind
}
}
+
+ private Expenses expensesApplication = null;
+
private RefreshExpenseListAction refreshExpenseListAction = new RefreshExpenseListAction();
private AddExpenseAction addExpenseAction = new AddExpenseAction();
private EditSelectedExpenseAction editSelectedExpenseAction = new EditSelectedExpenseAction();
@@ -131,7 +135,7 @@ public class ExpensesWindow extends Wind
}
// Create the delete confirmation prompt
- ArrayList<String> options = new ArrayList<String>((String) resources.get("cancel"), (String) resources.get("ok"));
+ ArrayList<String> options = new ArrayList<String>((String) resources.get("ok"), (String) resources.get("cancel"));
deleteConfirmationPrompt = new Prompt(MessageType.QUESTION, (String)resources.get("confirmDelete"),
options);
@@ -146,6 +150,16 @@ public class ExpensesWindow extends Wind
});
}
+
+ public Expenses getExpensesApplication() {
+ return expensesApplication;
+ }
+
+ public void setExpensesApplication(Expenses expensesApplication) {
+ this.expensesApplication = expensesApplication;
+ }
+
+
@Override
public void open(Display display, Window owner) {
super.open(display, owner);
@@ -155,10 +169,11 @@ public class ExpensesWindow extends Wind
}
private void refreshExpenseList() {
- Expenses expensesApplication = Expenses.getInstance();
+ Expenses expensesApplication = getExpensesApplication();
GetQuery expenseListQuery = new GetQuery(expensesApplication.getHostname(),
expensesApplication.getPort(), "/pivot-tutorials/expenses",
- expensesApplication.isSecure());
+ expensesApplication.isSecure()
+ );
activityIndicatorBoxPane.setVisible(true);
activityIndicator.setActive(true);
@@ -195,10 +210,11 @@ public class ExpensesWindow extends Wind
expenseSheet.store(expense);
// POST expense to server and then add to table
- Expenses expensesApplication = Expenses.getInstance();
+ Expenses expensesApplication = getExpensesApplication();
PostQuery addExpenseQuery = new PostQuery(expensesApplication.getHostname(),
expensesApplication.getPort(), "/pivot-tutorials/expenses",
- expensesApplication.isSecure());
+ expensesApplication.isSecure()
+ );
addExpenseQuery.setValue(expense);
activityIndicatorBoxPane.setVisible(true);
@@ -247,10 +263,11 @@ public class ExpensesWindow extends Wind
expenseSheet.store(expense);
// PUT expense to server and then update table
- Expenses expensesApplication = Expenses.getInstance();
+ Expenses expensesApplication = getExpensesApplication();
PutQuery updateExpenseQuery = new PutQuery(expensesApplication.getHostname(),
expensesApplication.getPort(), "/pivot-tutorials/expenses/" + JSON.get(expense, "id"),
- expensesApplication.isSecure());
+ expensesApplication.isSecure()
+ );
updateExpenseQuery.setValue(expense);
activityIndicatorBoxPane.setVisible(true);
@@ -296,10 +313,11 @@ public class ExpensesWindow extends Wind
if (sheet.getResult()
&& ((Prompt)sheet).getSelectedOptionIndex() == 1) {
// DELETE expense from server and then remove from table
- Expenses expensesApplication = Expenses.getInstance();
+ Expenses expensesApplication = getExpensesApplication();
DeleteQuery deleteExpenseQuery = new DeleteQuery(expensesApplication.getHostname(),
expensesApplication.getPort(), "/pivot-tutorials/expenses/" + id,
- expensesApplication.isSecure());
+ expensesApplication.isSecure()
+ );
activityIndicatorBoxPane.setVisible(true);
activityIndicator.setActive(true);
@@ -332,4 +350,5 @@ public class ExpensesWindow extends Wind
}
});
}
+
}
Modified: pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/expense_sheet.bxml
URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/expense_sheet.bxml?rev=1336702&r1=1336701&r2=1336702&view=diff
==============================================================================
--- pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/expense_sheet.bxml (original)
+++ pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/expense_sheet.bxml Thu May 10 14:04:18 2012
@@ -74,10 +74,10 @@ limitations under the License.
<TablePane.Row height="-1">
<BoxPane styles="{fill:true, horizontalAlignment:'right'}">
- <PushButton bxml:id="cancelButton" buttonData="%cancel"
- styleName="org.apache.pivot.wtk.skin.terra.commandButton"/>
<PushButton bxml:id="okButton" buttonData="%ok"
styleName="org.apache.pivot.wtk.skin.terra.commandButton"/>
+ <PushButton bxml:id="cancelButton" buttonData="%cancel"
+ styleName="org.apache.pivot.wtk.skin.terra.commandButton"/>
</BoxPane>
</TablePane.Row>
</TablePane>