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/08/08 19:21:40 UTC
svn commit: r983451 - in /pivot/trunk: tests/src/org/apache/pivot/tests/
tutorials/src/org/apache/pivot/tutorials/
tutorials/src/org/apache/pivot/tutorials/layout/
tutorials/src/org/apache/pivot/tutorials/navigation/
tutorials/src/org/apache/pivot/tuto...
Author: gbrown
Date: Sun Aug 8 17:21:39 2010
New Revision: 983451
URL: http://svn.apache.org/viewvc?rev=983451&view=rev
Log:
Resolve PIVOT-523.
Modified:
pivot/trunk/tests/src/org/apache/pivot/tests/ShutdownTest.java
pivot/trunk/tutorials/src/org/apache/pivot/tutorials/KitchenSink.java
pivot/trunk/tutorials/src/org/apache/pivot/tutorials/layout/TablePanes.java
pivot/trunk/tutorials/src/org/apache/pivot/tutorials/navigation/TabPanes.java
pivot/trunk/tutorials/src/org/apache/pivot/tutorials/navigation/tab_panes.bxml
pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/ExpensesWindow.java
pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraAlertSkin.java
pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraPromptSkin.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/Alert.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/Prompt.java
Modified: pivot/trunk/tests/src/org/apache/pivot/tests/ShutdownTest.java
URL: http://svn.apache.org/viewvc/pivot/trunk/tests/src/org/apache/pivot/tests/ShutdownTest.java?rev=983451&r1=983450&r2=983451&view=diff
==============================================================================
--- pivot/trunk/tests/src/org/apache/pivot/tests/ShutdownTest.java (original)
+++ pivot/trunk/tests/src/org/apache/pivot/tests/ShutdownTest.java Sun Aug 8 17:21:39 2010
@@ -55,7 +55,7 @@ public class ShutdownTest implements App
Alert alert = (Alert)dialog;
if (alert.getResult()) {
- if (alert.getSelectedOption() == 1) {
+ if (alert.getSelectedOptionIndex() == 1) {
cancelShutdown = false;
DesktopApplicationContext.exit();
}
Modified: pivot/trunk/tutorials/src/org/apache/pivot/tutorials/KitchenSink.java
URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/KitchenSink.java?rev=983451&r1=983450&r2=983451&view=diff
==============================================================================
--- pivot/trunk/tutorials/src/org/apache/pivot/tutorials/KitchenSink.java (original)
+++ pivot/trunk/tutorials/src/org/apache/pivot/tutorials/KitchenSink.java Sun Aug 8 17:21:39 2010
@@ -861,7 +861,7 @@ public class KitchenSink implements Appl
Alert alert = new Alert(MessageType.QUESTION, "Please select your favorite icon:",
options, body);
alert.setTitle("Select Icon");
- alert.setSelectedOption(0);
+ alert.setSelectedOptionIndex(0);
alert.getDecorators().update(0, new ReflectionDecorator());
alert.open(window);
} else {
Modified: pivot/trunk/tutorials/src/org/apache/pivot/tutorials/layout/TablePanes.java
URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/layout/TablePanes.java?rev=983451&r1=983450&r2=983451&view=diff
==============================================================================
--- pivot/trunk/tutorials/src/org/apache/pivot/tutorials/layout/TablePanes.java (original)
+++ pivot/trunk/tutorials/src/org/apache/pivot/tutorials/layout/TablePanes.java Sun Aug 8 17:21:39 2010
@@ -188,7 +188,7 @@ public class TablePanes extends Window i
prompt.open(TablePanes.this, new SheetCloseListener() {
@Override
public void sheetClosed(Sheet sheet) {
- if (prompt.getResult() && prompt.getSelectedOption() == 0) {
+ if (prompt.getResult() && prompt.getSelectedOptionIndex() == 0) {
int rowIndex = tablePane.getRowAt(contextMenuHandler.getY());
tablePane.getRows().remove(rowIndex, 1);
}
@@ -271,7 +271,7 @@ public class TablePanes extends Window i
prompt.open(TablePanes.this, new SheetCloseListener() {
@Override
public void sheetClosed(Sheet sheet) {
- if (prompt.getResult() && prompt.getSelectedOption() == 0) {
+ if (prompt.getResult() && prompt.getSelectedOptionIndex() == 0) {
int columnIndex = tablePane.getColumnAt(contextMenuHandler.getX());
// Remove the component at that index from each row
Modified: pivot/trunk/tutorials/src/org/apache/pivot/tutorials/navigation/TabPanes.java
URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/navigation/TabPanes.java?rev=983451&r1=983450&r2=983451&view=diff
==============================================================================
--- pivot/trunk/tutorials/src/org/apache/pivot/tutorials/navigation/TabPanes.java (original)
+++ pivot/trunk/tutorials/src/org/apache/pivot/tutorials/navigation/TabPanes.java Sun Aug 8 17:21:39 2010
@@ -65,7 +65,7 @@ public class TabPanes extends Window imp
@Override
public void sheetClosed(Sheet sheet) {
if (confirmCloseTabPrompt.getResult()
- && confirmCloseTabPrompt.getSelectedOption() == 1) {
+ && confirmCloseTabPrompt.getSelectedOptionIndex() == 1) {
confirmCloseTab = false;
int n = tabPane.getTabs().getLength();
Modified: pivot/trunk/tutorials/src/org/apache/pivot/tutorials/navigation/tab_panes.bxml
URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/navigation/tab_panes.bxml?rev=983451&r1=983450&r2=983451&view=diff
==============================================================================
--- pivot/trunk/tutorials/src/org/apache/pivot/tutorials/navigation/tab_panes.bxml (original)
+++ pivot/trunk/tutorials/src/org/apache/pivot/tutorials/navigation/tab_panes.bxml Sun Aug 8 17:21:39 2010
@@ -24,7 +24,7 @@ limitations under the License.
<bxml:define>
<Prompt bxml:id="confirmCloseTabPrompt" title="Confirm Close Tab"
message="Really close this tab?"
- options="['Cancel', 'OK']" selectedOption="1"/>
+ options="['Cancel', 'OK']" selectedOptionIndex="1"/>
</bxml:define>
<TablePane styles="{padding:8, horizontalSpacing:6}">
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=983451&r1=983450&r2=983451&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 Sun Aug 8 17:21:39 2010
@@ -297,7 +297,7 @@ public class ExpensesWindow extends Wind
@Override
public void sheetClosed(Sheet sheet) {
if (sheet.getResult()
- && ((Prompt)sheet).getSelectedOption() == 1) {
+ && ((Prompt)sheet).getSelectedOptionIndex() == 1) {
// DELETE expense from server and then remove from table
Expenses expensesApplication = Expenses.getInstance();
DeleteQuery deleteExpenseQuery = new DeleteQuery(expensesApplication.getHostname(),
Modified: pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraAlertSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraAlertSkin.java?rev=983451&r1=983450&r2=983451&view=diff
==============================================================================
--- pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraAlertSkin.java (original)
+++ pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraAlertSkin.java Sun Aug 8 17:21:39 2010
@@ -48,7 +48,7 @@ public class TerraAlertSkin extends Terr
if (optionIndex >= 0) {
Alert alert = (Alert)getComponent();
- alert.setSelectedOption(optionIndex);
+ alert.setSelectedOptionIndex(optionIndex);
alert.close(true);
}
}
@@ -105,7 +105,7 @@ public class TerraAlertSkin extends Terr
super.windowOpened(window);
Alert alert = (Alert)window;
- int index = alert.getSelectedOption();
+ int index = alert.getSelectedOptionIndex();
if (index >= 0) {
optionButtonBoxPane.get(index).requestFocus();
@@ -156,7 +156,7 @@ public class TerraAlertSkin extends Terr
@Override
public void selectedOptionChanged(Alert alert, int previousSelectedOption) {
- int index = alert.getSelectedOption();
+ int index = alert.getSelectedOptionIndex();
if (alert.isOpen()
&& index >= 0) {
Modified: pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraPromptSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraPromptSkin.java?rev=983451&r1=983450&r2=983451&view=diff
==============================================================================
--- pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraPromptSkin.java (original)
+++ pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraPromptSkin.java Sun Aug 8 17:21:39 2010
@@ -98,7 +98,7 @@ public class TerraPromptSkin extends Ter
super.windowOpened(window);
Prompt prompt = (Prompt)window;
- int index = prompt.getSelectedOption();
+ int index = prompt.getSelectedOptionIndex();
if (index >= 0) {
optionButtonBoxPane.get(index).requestFocus();
@@ -149,7 +149,7 @@ public class TerraPromptSkin extends Ter
@Override
public void selectedOptionChanged(Prompt prompt, int previousSelectedOption) {
- int index = prompt.getSelectedOption();
+ int index = prompt.getSelectedOptionIndex();
if (prompt.isOpen()
&& index >= 0) {
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/Alert.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/Alert.java?rev=983451&r1=983450&r2=983451&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/Alert.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/Alert.java Sun Aug 8 17:21:39 2010
@@ -56,8 +56,8 @@ public class Alert extends Dialog {
options.insert(option, index);
- if (selectedOption >= index) {
- selectedOption++;
+ if (selectedOptionIndex >= index) {
+ selectedOptionIndex++;
}
alertListeners.optionInserted(Alert.this, index);
@@ -83,11 +83,11 @@ public class Alert extends Dialog {
Sequence<Object> removed = options.remove(index, count);
if (removed.getLength() > 0) {
- if (selectedOption >= index) {
- if (selectedOption < index + count) {
- selectedOption = -1;
+ if (selectedOptionIndex >= index) {
+ if (selectedOptionIndex < index + count) {
+ selectedOptionIndex = -1;
} else {
- selectedOption -= count;
+ selectedOptionIndex -= count;
}
}
@@ -169,7 +169,7 @@ public class Alert extends Dialog {
private ArrayList<Object> options = new ArrayList<Object>();
private OptionSequence optionSequence = new OptionSequence();
- private int selectedOption = -1;
+ private int selectedOptionIndex = -1;
private AlertListenerList alertListeners = new AlertListenerList();
@@ -216,7 +216,7 @@ public class Alert extends Dialog {
optionSequence.add(options.get(i));
}
- setSelectedOption(0);
+ setSelectedOptionIndex(0);
}
setTitle((String)resources.get("defaultTitle"));
@@ -280,24 +280,32 @@ public class Alert extends Dialog {
}
}
- public int getSelectedOption() {
- return selectedOption;
+ public int getSelectedOptionIndex() {
+ return selectedOptionIndex;
}
- public void setSelectedOption(int selectedOption) {
+ public void setSelectedOptionIndex(int selectedOption) {
if (selectedOption < -1
|| selectedOption > options.getLength() - 1) {
throw new IndexOutOfBoundsException();
}
- int previousSelectedOption = this.selectedOption;
+ int previousSelectedOption = this.selectedOptionIndex;
if (selectedOption != previousSelectedOption) {
- this.selectedOption = selectedOption;
+ this.selectedOptionIndex = selectedOption;
alertListeners.selectedOptionChanged(this, previousSelectedOption);
}
}
+ public Object getSelectedOption() {
+ return (selectedOptionIndex == -1) ? null : options.get(selectedOptionIndex);
+ }
+
+ public void setSelectedOption(Object selectedOption) {
+ setSelectedOptionIndex(options.indexOf(selectedOption));
+ }
+
public ListenerList<AlertListener> getAlertListeners() {
return alertListeners;
}
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/Prompt.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/Prompt.java?rev=983451&r1=983450&r2=983451&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/Prompt.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/Prompt.java Sun Aug 8 17:21:39 2010
@@ -56,8 +56,8 @@ public class Prompt extends Sheet {
options.insert(option, index);
- if (selectedOption >= index) {
- selectedOption++;
+ if (selectedOptionIndex >= index) {
+ selectedOptionIndex++;
}
promptListeners.optionInserted(Prompt.this, index);
@@ -83,11 +83,11 @@ public class Prompt extends Sheet {
Sequence<Object> removed = options.remove(index, count);
if (removed.getLength() > 0) {
- if (selectedOption >= index) {
- if (selectedOption < index + count) {
- selectedOption = -1;
+ if (selectedOptionIndex >= index) {
+ if (selectedOptionIndex < index + count) {
+ selectedOptionIndex = -1;
} else {
- selectedOption -= count;
+ selectedOptionIndex -= count;
}
}
@@ -169,7 +169,7 @@ public class Prompt extends Sheet {
private ArrayList<Object> options = new ArrayList<Object>();
private OptionSequence optionSequence = new OptionSequence();
- private int selectedOption = -1;
+ private int selectedOptionIndex = -1;
private PromptListenerList promptListeners = new PromptListenerList();
@@ -270,24 +270,32 @@ public class Prompt extends Sheet {
}
}
- public int getSelectedOption() {
- return selectedOption;
+ public int getSelectedOptionIndex() {
+ return selectedOptionIndex;
}
- public void setSelectedOption(int selectedOption) {
+ public void setSelectedOptionIndex(int selectedOption) {
if (selectedOption < -1
|| selectedOption > options.getLength() - 1) {
throw new IndexOutOfBoundsException();
}
- int previousSelectedOption = this.selectedOption;
+ int previousSelectedOption = this.selectedOptionIndex;
if (selectedOption != previousSelectedOption) {
- this.selectedOption = selectedOption;
+ this.selectedOptionIndex = selectedOption;
promptListeners.selectedOptionChanged(this, previousSelectedOption);
}
}
+ public Object getSelectedOption() {
+ return (selectedOptionIndex == -1) ? null : options.get(selectedOptionIndex);
+ }
+
+ public void setSelectedOption(Object selectedOption) {
+ setSelectedOptionIndex(options.indexOf(selectedOption));
+ }
+
public ListenerList<PromptListener> getPromptListeners() {
return promptListeners;
}