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 16:51:34 UTC
svn commit: r983418 - in /pivot/trunk:
tutorials/src/org/apache/pivot/tutorials/navigation/
wtk-terra/src/org/apache/pivot/wtk/skin/terra/
wtk/src/org/apache/pivot/wtk/ wtk/src/org/apache/pivot/wtk/content/
wtk/src/org/apache/pivot/wtk/skin/
Author: gbrown
Date: Sun Aug 8 14:51:33 2010
New Revision: 983418
URL: http://svn.apache.org/viewvc?rev=983418&view=rev
Log:
Make tab removal event vetoable; eliminate vetoable support for window open event.
Modified:
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/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTabPaneSkin.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/Dialog.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/MenuPopup.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/Sheet.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/SuggestionPopup.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/TabPane.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/TabPaneListener.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/Window.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/WindowStateListener.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewRowEditor.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/WindowSkin.java
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=983418&r1=983417&r2=983418&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 14:51:33 2010
@@ -21,30 +21,76 @@ import java.net.URL;
import org.apache.pivot.beans.Bindable;
import org.apache.pivot.collections.Map;
import org.apache.pivot.util.Resources;
+import org.apache.pivot.util.Vote;
import org.apache.pivot.wtk.Button;
import org.apache.pivot.wtk.ButtonStateListener;
import org.apache.pivot.wtk.Checkbox;
import org.apache.pivot.wtk.BoxPane;
import org.apache.pivot.wtk.Orientation;
+import org.apache.pivot.wtk.Prompt;
import org.apache.pivot.wtk.RadioButton;
+import org.apache.pivot.wtk.Sheet;
+import org.apache.pivot.wtk.SheetCloseListener;
import org.apache.pivot.wtk.TabPane;
+import org.apache.pivot.wtk.TabPaneListener;
import org.apache.pivot.wtk.Window;
public class TabPanes extends Window implements Bindable {
+ private Prompt confirmCloseTabPrompt = null;
private TabPane tabPane = null;
+ private Checkbox closeableCheckbox = null;
private Checkbox collapsibleCheckbox = null;
private RadioButton horizontalRadioButton = null;
private RadioButton verticalRadioButton = null;
private BoxPane cornerBoxPane = null;
+ private boolean confirmCloseTab = true;
+
@Override
public void initialize(Map<String, Object> namespace, URL location, Resources resources) {
+ confirmCloseTabPrompt = (Prompt)namespace.get("confirmCloseTabPrompt");
tabPane = (TabPane)namespace.get("tabPane");
+ closeableCheckbox = (Checkbox)namespace.get("closeableCheckbox");
collapsibleCheckbox = (Checkbox)namespace.get("collapsibleCheckbox");
horizontalRadioButton = (RadioButton)namespace.get("horizontalRadioButton");
verticalRadioButton = (RadioButton)namespace.get("verticalRadioButton");
cornerBoxPane = (BoxPane)namespace.get("cornerBoxPane");
+ tabPane.getTabPaneListeners().add(new TabPaneListener.Adapter() {
+ @Override
+ public Vote previewRemoveTabs(final TabPane tabPane, final int index, final int count) {
+ Vote vote;
+ if (confirmCloseTab) {
+ confirmCloseTabPrompt.open(TabPanes.this, new SheetCloseListener() {
+ @Override
+ public void sheetClosed(Sheet sheet) {
+ if (confirmCloseTabPrompt.getResult()
+ && confirmCloseTabPrompt.getSelectedOption() == 1) {
+ confirmCloseTab = false;
+
+ int n = tabPane.getTabs().getLength();
+ if (index < n - 1) {
+ tabPane.setSelectedIndex(index + 1);
+ } else {
+ tabPane.setSelectedIndex(index - 1);
+ }
+
+ tabPane.getTabs().remove(index, count);
+
+ confirmCloseTab = true;
+ }
+ }
+ });
+
+ vote = Vote.DENY;
+ } else {
+ vote = Vote.APPROVE;
+ }
+
+ return vote;
+ }
+ });
+
ButtonStateListener checkboxStateListener = new ButtonStateListener() {
@Override
public void stateChanged(Button button, Button.State previousState) {
@@ -52,6 +98,7 @@ public class TabPanes extends Window imp
}
};
+ closeableCheckbox.getButtonStateListeners().add(checkboxStateListener);
collapsibleCheckbox.getButtonStateListeners().add(checkboxStateListener);
ButtonStateListener radioButtonStateListener = new ButtonStateListener() {
@@ -70,6 +117,7 @@ public class TabPanes extends Window imp
}
private void updateTabPane() {
+ tabPane.setCloseable(closeableCheckbox.isSelected());
tabPane.setCollapsible(collapsibleCheckbox.isSelected());
if (horizontalRadioButton.isSelected()) {
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=983418&r1=983417&r2=983418&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 14:51:33 2010
@@ -18,8 +18,15 @@ limitations under the License.
<navigation:TabPanes title="Tab Panes" maximized="true"
xmlns:bxml="http://pivot.apache.org/bxml"
+ xmlns:content="org.apache.pivot.wtk.content"
xmlns:navigation="org.apache.pivot.tutorials.navigation"
xmlns="org.apache.pivot.wtk">
+ <bxml:define>
+ <Prompt bxml:id="confirmCloseTabPrompt" title="Confirm Close Tab"
+ message="Really close this tab?"
+ options="['Cancel', 'OK']" selectedOption="1"/>
+ </bxml:define>
+
<TablePane styles="{padding:8, horizontalSpacing:6}">
<columns>
<TablePane.Column width="1*"/>
@@ -32,7 +39,7 @@ limitations under the License.
<TabPane bxml:id="tabPane">
<corner>
<BoxPane bxml:id="cornerBoxPane" styles="{horizontalAlignment:'right'}">
- <TextInput/>
+ <TextInput textSize="10"/>
</BoxPane>
</corner>
@@ -69,11 +76,16 @@ limitations under the License.
</Border>
</BoxPane>
- <BoxPane enabled="false">
+ <BoxPane enabled="true">
<TabPane.tabData>
<content:ButtonData icon="org/apache/pivot/tutorials/star.png"
text="Star"/>
</TabPane.tabData>
+
+ <Border styles="{padding:2}">
+ <Label text="480x360 (disabled)" preferredWidth="480" preferredHeight="360"
+ styles="{horizontalAlignment:'center', verticalAlignment:'center'}"/>
+ </Border>
</BoxPane>
</TabPane>
</BoxPane>
@@ -81,9 +93,10 @@ limitations under the License.
<Border styles="{padding:2}">
<BoxPane orientation="vertical" styles="{padding:4, spacing:6}">
- <Checkbox bxml:id="collapsibleCheckbox" buttonData="Collapsible"/>
- <Label text="Tab orientation:"/>
+ <Checkbox bxml:id="closeableCheckbox" buttonData="Closeable" selected="true"/>
+ <Checkbox bxml:id="collapsibleCheckbox" buttonData="Collapsible" selected="true"/>
+ <Label text="Tab orientation:"/>
<bxml:define>
<ButtonGroup bxml:id="tabOrientation"/>
</bxml:define>
Modified: pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTabPaneSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTabPaneSkin.java?rev=983418&r1=983417&r2=983418&view=diff
==============================================================================
--- pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTabPaneSkin.java (original)
+++ pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTabPaneSkin.java Sun Aug 8 14:51:33 2010
@@ -375,10 +375,11 @@ public class TerraTabPaneSkin extends Co
boolean consumed = super.mouseClick(component, button, x, y, count);
TabButton tabButton = (TabButton)getComponent();
+ TabPane tabPane = (TabPane)TerraTabPaneSkin.this.getComponent();
- if (tabButton.isSelected()
+ if (tabPane.isCloseable()
+ && tabButton.isSelected()
&& getCloseTriggerBounds().contains(x, y)) {
- TabPane tabPane = (TabPane)TerraTabPaneSkin.this.getComponent();
tabPane.getTabs().remove(tabButton.tab);
} else {
tabButton.press();
@@ -1011,16 +1012,42 @@ public class TerraTabPaneSkin extends Co
graphics.setPaint(borderColor);
- // Draw the left, right, and bottom borders
- graphics.draw(new Line2D.Double(left, top, left, bottom));
+ // Draw the right and bottom borders
graphics.draw(new Line2D.Double(right, top, right, bottom));
graphics.draw(new Line2D.Double(left, bottom, right, bottom));
- // Draw the top border
- Point selectedTabButtonLocation = selectedTabButton.mapPointToAncestor(tabPane, 0, 0);
- graphics.draw(new Line2D.Double(left, top, selectedTabButtonLocation.x + 0.5, top));
- graphics.draw(new Line2D.Double(selectedTabButtonLocation.x + selectedTabButton.getWidth() - 0.5,
- top, right, top));
+ // Draw the left and top borders
+ switch (tabOrientation) {
+ case HORIZONTAL: {
+ graphics.draw(new Line2D.Double(left, top, left, bottom));
+
+ if (selectedTabButton == null) {
+ graphics.draw(new Line2D.Double(left, top, right, top));
+ } else {
+ Point selectedTabButtonLocation = selectedTabButton.mapPointToAncestor(tabPane, 0, 0);
+ graphics.draw(new Line2D.Double(left, top, selectedTabButtonLocation.x + 0.5, top));
+ graphics.draw(new Line2D.Double(selectedTabButtonLocation.x + selectedTabButton.getWidth() - 0.5,
+ top, right, top));
+ }
+
+ break;
+ }
+
+ case VERTICAL: {
+ graphics.draw(new Line2D.Double(left, top, right, top));
+
+ if (selectedTabButton == null) {
+ graphics.draw(new Line2D.Double(left, top, left, bottom));
+ } else {
+ Point selectedTabButtonLocation = selectedTabButton.mapPointToAncestor(tabPane, 0, 0);
+ graphics.draw(new Line2D.Double(left, top, left, selectedTabButtonLocation.y + 0.5));
+ graphics.draw(new Line2D.Double(left, selectedTabButtonLocation.y + selectedTabButton.getHeight() - 0.5,
+ left, bottom));
+ }
+
+ break;
+ }
+ }
}
}
@@ -1375,6 +1402,16 @@ public class TerraTabPaneSkin extends Co
}
@Override
+ public Vote previewRemoveTabs(TabPane tabPane, int index, int count) {
+ return Vote.APPROVE;
+ }
+
+ @Override
+ public void removeTabsVetoed(TabPane tabPane, Vote vote) {
+ // No-op
+ }
+
+ @Override
public void tabsRemoved(TabPane tabPane, int index, Sequence<Component> removed) {
if (selectionChangeTransition != null) {
selectionChangeTransition.end();
@@ -1425,51 +1462,55 @@ public class TerraTabPaneSkin extends Co
public Vote previewSelectedIndexChange(TabPane tabPane, int selectedIndex) {
Vote vote;
- if (tabPane.isShowing()
- && selectionChangeTransition == null) {
- int previousSelectedIndex = tabPane.getSelectedIndex();
-
- if (selectedIndex == -1) {
- // Collapse
- Component tab = tabPane.getTabs().get(previousSelectedIndex);
- selectionChangeTransition = new SelectionChangeTransition(tab, false);
- } else {
- if (previousSelectedIndex == -1) {
- // Expand
- Component tab = tabPane.getTabs().get(selectedIndex);
- selectionChangeTransition = new SelectionChangeTransition(tab, true);
+ if (tabPane.isCollapsible()) {
+ if (tabPane.isShowing()
+ && selectionChangeTransition == null) {
+ int previousSelectedIndex = tabPane.getSelectedIndex();
+
+ if (selectedIndex == -1) {
+ // Collapse
+ Component tab = tabPane.getTabs().get(previousSelectedIndex);
+ selectionChangeTransition = new SelectionChangeTransition(tab, false);
+ } else {
+ if (previousSelectedIndex == -1) {
+ // Expand
+ Component tab = tabPane.getTabs().get(selectedIndex);
+ selectionChangeTransition = new SelectionChangeTransition(tab, true);
+ }
}
- }
- if (selectionChangeTransition != null) {
- selectionChangeTransition.start(new TransitionListener() {
- @Override
- public void transitionCompleted(Transition transition) {
- TabPane tabPane = (TabPane)getComponent();
-
- SelectionChangeTransition selectionChangeTransition =
- (SelectionChangeTransition)transition;
-
- int selectedIndex;
- if (selectionChangeTransition.expand) {
- selectedIndex = tabPane.getTabs().indexOf(selectionChangeTransition.tab);
- } else {
- selectedIndex = -1;
- }
+ if (selectionChangeTransition != null) {
+ selectionChangeTransition.start(new TransitionListener() {
+ @Override
+ public void transitionCompleted(Transition transition) {
+ TabPane tabPane = (TabPane)getComponent();
+
+ SelectionChangeTransition selectionChangeTransition =
+ (SelectionChangeTransition)transition;
+
+ int selectedIndex;
+ if (selectionChangeTransition.expand) {
+ selectedIndex = tabPane.getTabs().indexOf(selectionChangeTransition.tab);
+ } else {
+ selectedIndex = -1;
+ }
- tabPane.setSelectedIndex(selectedIndex);
+ tabPane.setSelectedIndex(selectedIndex);
- TerraTabPaneSkin.this.selectionChangeTransition = null;
- }
- });
+ TerraTabPaneSkin.this.selectionChangeTransition = null;
+ }
+ });
+ }
}
- }
- if (selectionChangeTransition == null
- || !selectionChangeTransition.isRunning()) {
- vote = Vote.APPROVE;
+ if (selectionChangeTransition == null
+ || !selectionChangeTransition.isRunning()) {
+ vote = Vote.APPROVE;
+ } else {
+ vote = Vote.DEFER;
+ }
} else {
- vote = Vote.DEFER;
+ vote = Vote.APPROVE;
}
return vote;
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/Dialog.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/Dialog.java?rev=983418&r1=983417&r2=983418&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/Dialog.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/Dialog.java Sun Aug 8 14:51:33 2010
@@ -184,10 +184,6 @@ public class Dialog extends Frame {
result = false;
super.open(display, owner);
-
- if (!isOpen()) {
- this.dialogCloseListener = null;
- }
}
@Override
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/MenuPopup.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/MenuPopup.java?rev=983418&r1=983417&r2=983418&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/MenuPopup.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/MenuPopup.java Sun Aug 8 14:51:33 2010
@@ -130,10 +130,6 @@ public class MenuPopup extends Window {
setLocation(x, y);
super.open(display, owner);
-
- if (!isOpen()) {
- contextMenu = false;
- }
}
@Override
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/Sheet.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/Sheet.java?rev=983418&r1=983417&r2=983418&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/Sheet.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/Sheet.java Sun Aug 8 14:51:33 2010
@@ -99,10 +99,6 @@ public class Sheet extends Window {
this.sheetCloseListener = sheetCloseListener;
super.open(display, owner);
-
- if (!isOpen()) {
- this.sheetCloseListener = null;
- }
}
@Override
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/SuggestionPopup.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/SuggestionPopup.java?rev=983418&r1=983417&r2=983418&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/SuggestionPopup.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/SuggestionPopup.java Sun Aug 8 14:51:33 2010
@@ -251,11 +251,6 @@ public class SuggestionPopup extends Win
result = false;
super.open(textInput.getWindow());
-
- if (!isOpen()) {
- this.textInput = null;
- this.suggestionPopupCloseListener = null;
- }
}
@Override
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/TabPane.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/TabPane.java?rev=983418&r1=983417&r2=983418&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/TabPane.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/TabPane.java Sun Aug 8 14:51:33 2010
@@ -29,8 +29,6 @@ import org.apache.pivot.wtk.content.Butt
/**
* Container that provides access to a set of components via selectable tabs,
* only one of which is visible at a time.
- * <p>
- * TODO Add a getTabAt() method that delegates to the skin.
*/
@DefaultProperty("tabs")
public class TabPane extends Container {
@@ -84,24 +82,32 @@ public class TabPane extends Container {
@Override
public Sequence<Component> remove(int index, int count) {
- // Remove the tabs from the tab list
- Sequence<Component> removed = tabs.remove(index, count);
+ Sequence<Component> removed;
- // Update the selection
- if (selectedIndex >= index) {
- if (selectedIndex < index + count) {
- selectedIndex = -1;
- } else {
- selectedIndex -= count;
+ Vote vote = tabPaneListeners.previewRemoveTabs(TabPane.this, index, count);
+ if (vote == Vote.APPROVE) {
+ // Remove the tabs from the tab list
+ removed = tabs.remove(index, count);
+
+ // Update the selection
+ if (selectedIndex >= index) {
+ if (selectedIndex < index + count) {
+ selectedIndex = -1;
+ } else {
+ selectedIndex -= count;
+ }
}
- }
- tabPaneListeners.tabsRemoved(TabPane.this, index, removed);
+ tabPaneListeners.tabsRemoved(TabPane.this, index, removed);
- // Remove the tabs from the component list
- for (int i = 0, n = removed.getLength(); i < n; i++) {
- Component tab = removed.get(i);
- TabPane.this.remove(tab);
+ // Remove the tabs from the component list
+ for (int i = 0, n = removed.getLength(); i < n; i++) {
+ Component tab = removed.get(i);
+ TabPane.this.remove(tab);
+ }
+ } else {
+ removed = null;
+ tabPaneListeners.removeTabsVetoed(TabPane.this, vote);
}
return removed;
@@ -143,6 +149,17 @@ public class TabPane extends Container {
}
@Override
+ public Vote previewRemoveTabs(TabPane tabPane, int index, int count) {
+ Vote vote = Vote.APPROVE;
+
+ for (TabPaneListener listener : this) {
+ vote = vote.tally(listener.previewRemoveTabs(tabPane, index, count));
+ }
+
+ return vote;
+ }
+
+ @Override
public void tabsRemoved(TabPane tabPane, int index, Sequence<Component> tabs) {
for (TabPaneListener listener : this) {
listener.tabsRemoved(tabPane, index, tabs);
@@ -150,6 +167,13 @@ public class TabPane extends Container {
}
@Override
+ public void removeTabsVetoed(TabPane tabPane, Vote reason) {
+ for (TabPaneListener listener : this) {
+ listener.removeTabsVetoed(tabPane, reason);
+ }
+ }
+
+ @Override
public void cornerChanged(TabPane tabPane, Component previousCorner) {
for (TabPaneListener listener : this) {
listener.cornerChanged(tabPane, previousCorner);
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/TabPaneListener.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/TabPaneListener.java?rev=983418&r1=983417&r2=983418&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/TabPaneListener.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/TabPaneListener.java Sun Aug 8 14:51:33 2010
@@ -17,6 +17,7 @@
package org.apache.pivot.wtk;
import org.apache.pivot.collections.Sequence;
+import org.apache.pivot.util.Vote;
/**
* Tab pane listener interface.
@@ -31,6 +32,15 @@ public interface TabPaneListener {
}
@Override
+ public Vote previewRemoveTabs(TabPane tabPane, int index, int count) {
+ return Vote.APPROVE;
+ }
+
+ @Override
+ public void removeTabsVetoed(TabPane tabPane, Vote vote) {
+ }
+
+ @Override
public void tabsRemoved(TabPane tabPane, int index, Sequence<Component> tabs) {
}
@@ -60,6 +70,23 @@ public interface TabPaneListener {
public void tabInserted(TabPane tabPane, int index);
/**
+ * Called to preview a tab removal.
+ *
+ * @param tabPane
+ * @param index
+ * @param count
+ */
+ public Vote previewRemoveTabs(TabPane tabPane, int index, int count);
+
+ /**
+ * Called when a tab removal has been vetoed.
+ *
+ * @param tabPane
+ * @param reason
+ */
+ public void removeTabsVetoed(TabPane tabPane, Vote reason);
+
+ /**
* Called when a tab has been removed from a tab pane's tab sequence.
*
* @param tabPane
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/Window.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/Window.java?rev=983418&r1=983417&r2=983418&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/Window.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/Window.java Sun Aug 8 14:51:33 2010
@@ -335,24 +335,6 @@ public class Window extends Container {
private static class WindowStateListenerList extends ListenerList<WindowStateListener>
implements WindowStateListener {
@Override
- public Vote previewWindowOpen(Window window, Display display) {
- Vote vote = Vote.APPROVE;
-
- for (WindowStateListener listener : this) {
- vote = vote.tally(listener.previewWindowOpen(window, display));
- }
-
- return vote;
- }
-
- @Override
- public void windowOpenVetoed(Window window, Vote reason) {
- for (WindowStateListener listener : this) {
- listener.windowOpenVetoed(window, reason);
- }
- }
-
- @Override
public void windowOpened(Window window) {
for (WindowStateListener listener : this) {
listener.windowOpened(window);
@@ -441,7 +423,6 @@ public class Window extends Container {
private Component content = null;
private Component focusDescendant = null;
- private boolean opening = false;
private boolean closing = false;
private Point restoreLocation = null;
@@ -573,16 +554,6 @@ public class Window extends Container {
}
/**
- * Returns this window's opening state.
- *
- * @return
- * <tt>true</tt> if the window is open; <tt>false</tt>, otherwise.
- */
- public boolean isOpening() {
- return opening;
- }
-
- /**
* Opens the window.
*
* @param display
@@ -640,32 +611,20 @@ public class Window extends Container {
}
if (!isOpen()) {
- opening = true;
- Vote vote = windowStateListeners.previewWindowOpen(this, display);
+ // Set the owner and add to the owner's owned window list
+ this.owner = owner;
- if (vote == Vote.APPROVE) {
- // Set the owner and add to the owner's owned window list
- this.owner = owner;
-
- if (owner != null) {
- owner.ownedWindows.add(this);
- }
+ if (owner != null) {
+ owner.ownedWindows.add(this);
+ }
- // Add the window to the display
- display.add(this);
+ // Add the window to the display
+ display.add(this);
- // Notify listeners
- opening = false;
- windowStateListeners.windowOpened(this);
+ // Notify listeners
+ windowStateListeners.windowOpened(this);
- moveToFront();
- } else {
- if (vote == Vote.DENY) {
- opening = false;
- }
-
- windowStateListeners.windowOpenVetoed(this, vote);
- }
+ moveToFront();
}
}
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/WindowStateListener.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/WindowStateListener.java?rev=983418&r1=983417&r2=983418&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/WindowStateListener.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/WindowStateListener.java Sun Aug 8 14:51:33 2010
@@ -27,15 +27,6 @@ public interface WindowStateListener {
*/
public static class Adapter implements WindowStateListener {
@Override
- public Vote previewWindowOpen(Window window, Display display) {
- return Vote.APPROVE;
- }
-
- @Override
- public void windowOpenVetoed(Window window, Vote reason) {
- }
-
- @Override
public void windowOpened(Window window) {
}
@@ -54,22 +45,6 @@ public interface WindowStateListener {
}
/**
- * Called to preview a window open event.
- *
- * @param window
- * @param display
- */
- public Vote previewWindowOpen(Window window, Display display);
-
- /**
- * Called when a window open event has been vetoed.
- *
- * @param window
- * @param reason
- */
- public void windowOpenVetoed(Window window, Vote reason);
-
- /**
* Called when a window has opened.
*
* @param window
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewRowEditor.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewRowEditor.java?rev=983418&r1=983417&r2=983418&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewRowEditor.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewRowEditor.java Sun Aug 8 14:51:33 2010
@@ -217,42 +217,40 @@ public class TableViewRowEditor implemen
if (!isOpen()) {
super.open(display, owner);
- if (isOpen()) {
- display.getContainerMouseListeners().add(this);
- tableView.getComponentListeners().add(this);
- tableView.getTableViewListeners().add(this);
- tableView.getTableViewRowListeners().add(this);
-
- // Scroll the editor to match that of the table view
- if (tableViewScrollPane != null) {
- scrollPane.setScrollLeft(tableViewScrollPane.getScrollLeft());
- }
+ display.getContainerMouseListeners().add(this);
+ tableView.getComponentListeners().add(this);
+ tableView.getTableViewListeners().add(this);
+ tableView.getTableViewRowListeners().add(this);
+
+ // Scroll the editor to match that of the table view
+ if (tableViewScrollPane != null) {
+ scrollPane.setScrollLeft(tableViewScrollPane.getScrollLeft());
+ }
- // Set the opening flag
- opening = true;
+ // Set the opening flag
+ opening = true;
- // Give the editor focus after the transition has completed.
- // When the transition starts, the row image is the selected
- // card. so we have to wait until the selected index changes
- // to give focus to the appropriate editor component
- cardPane.getCardPaneListeners().add(new CardPaneListener.Adapter() {
- @Override
- public void selectedIndexChanged(CardPane cardPane, int previousSelectedIndex) {
- // Clear the opening flag
- opening = false;
-
- // Focus the initial editor component
- Component focusComponent = tablePane.getCellComponent(0, columnIndex);
- focusComponent.requestFocus();
+ // Give the editor focus after the transition has completed.
+ // When the transition starts, the row image is the selected
+ // card. so we have to wait until the selected index changes
+ // to give focus to the appropriate editor component
+ cardPane.getCardPaneListeners().add(new CardPaneListener.Adapter() {
+ @Override
+ public void selectedIndexChanged(CardPane cardPane, int previousSelectedIndex) {
+ // Clear the opening flag
+ opening = false;
+
+ // Focus the initial editor component
+ Component focusComponent = tablePane.getCellComponent(0, columnIndex);
+ focusComponent.requestFocus();
- // Remove this listener
- cardPane.getCardPaneListeners().remove(this);
- }
- });
+ // Remove this listener
+ cardPane.getCardPaneListeners().remove(this);
+ }
+ });
- // Transition to the editor card
- cardPane.setSelectedIndex(EDITOR_CARD_INDEX);
- }
+ // Transition to the editor card
+ cardPane.setSelectedIndex(EDITOR_CARD_INDEX);
}
}
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/WindowSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/WindowSkin.java?rev=983418&r1=983417&r2=983418&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/WindowSkin.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/WindowSkin.java Sun Aug 8 14:51:33 2010
@@ -154,16 +154,6 @@ public class WindowSkin extends Containe
// Window state events
@Override
- public Vote previewWindowOpen(Window window, Display display) {
- return Vote.APPROVE;
- }
-
- @Override
- public void windowOpenVetoed(Window window, Vote reason) {
- // No-op
- }
-
- @Override
public void windowOpened(Window window) {
// No-op
}