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/02/10 15:20:16 UTC
svn commit: r908512 - in /pivot/trunk:
wtk-terra/src/org/apache/pivot/wtk/skin/terra/ wtk/src/org/apache/pivot/wtk/
Author: gbrown
Date: Wed Feb 10 14:20:15 2010
New Revision: 908512
URL: http://svn.apache.org/viewvc?rev=908512&view=rev
Log:
Add suggestion popup state listener interface so suggestion popup skins can pass correct result value to close().
Added:
pivot/trunk/wtk/src/org/apache/pivot/wtk/SuggestionPopupStateListener.java
Modified:
pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraMenuPopupSkin.java
pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraSuggestionPopupSkin.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/SuggestionPopup.java
Modified: pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraMenuPopupSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraMenuPopupSkin.java?rev=908512&r1=908511&r2=908512&view=diff
==============================================================================
--- pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraMenuPopupSkin.java (original)
+++ pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraMenuPopupSkin.java Wed Feb 10 14:20:15 2010
@@ -198,6 +198,7 @@
Display display = window.getDisplay();
display.getContainerMouseListeners().add(displayMouseListener);
+ display.reenterMouse();
MenuPopup menuPopup = (MenuPopup)window;
Menu menu = menuPopup.getMenu();
Modified: pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraSuggestionPopupSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraSuggestionPopupSkin.java?rev=908512&r1=908511&r2=908512&view=diff
==============================================================================
--- pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraSuggestionPopupSkin.java (original)
+++ pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraSuggestionPopupSkin.java Wed Feb 10 14:20:15 2010
@@ -39,6 +39,7 @@
import org.apache.pivot.wtk.Span;
import org.apache.pivot.wtk.SuggestionPopup;
import org.apache.pivot.wtk.SuggestionPopupListener;
+import org.apache.pivot.wtk.SuggestionPopupStateListener;
import org.apache.pivot.wtk.TextInput;
import org.apache.pivot.wtk.Theme;
import org.apache.pivot.wtk.Window;
@@ -50,7 +51,8 @@
/**
* Terra suggestion popup skin.
*/
-public class TerraSuggestionPopupSkin extends WindowSkin implements SuggestionPopupListener {
+public class TerraSuggestionPopupSkin extends WindowSkin
+ implements SuggestionPopupListener, SuggestionPopupStateListener {
private Border suggestionListViewBorder = new Border();
private ListView suggestionListView = new ListView();
@@ -130,6 +132,7 @@
SuggestionPopup suggestionPopup = (SuggestionPopup)component;
suggestionPopup.getSuggestionPopupListeners().add(this);
+ suggestionPopup.getSuggestionPopupStateListeners().add(this);
suggestionPopup.setContent(suggestionListViewBorder);
@@ -243,6 +246,9 @@
Display display = window.getDisplay();
display.getContainerMouseListeners().add(displayMouseListener);
+ display.reenterMouse();
+
+ dropShadowDecorator.setShadowOpacity(DropShadowDecorator.DEFAULT_SHADOW_OPACITY);
SuggestionPopup suggestionPopup = (SuggestionPopup)getComponent();
TextInput textInput = suggestionPopup.getTextInput();
@@ -255,27 +261,6 @@
}
@Override
- public Vote previewWindowClose(final Window window) {
- if (closeTransition == null) {
- suggestionListViewBorder.setEnabled(false);
-
- closeTransition = new FadeWindowTransition(window,
- CLOSE_TRANSITION_DURATION, CLOSE_TRANSITION_RATE,
- dropShadowDecorator);
-
- closeTransition.start(new TransitionListener() {
- @Override
- public void transitionCompleted(Transition transition) {
- window.close();
- }
- });
- }
-
- return (closeTransition != null
- && closeTransition.isRunning()) ? Vote.DEFER : Vote.APPROVE;
- }
-
- @Override
public void windowCloseVetoed(Window window, Vote reason) {
if (reason == Vote.DENY
&& closeTransition != null) {
@@ -296,9 +281,6 @@
TextInput textInput = suggestionPopup.getTextInput();
textInput.getComponentKeyListeners().remove(textInputKeyListener);
- suggestionListViewBorder.setEnabled(true);
- closeTransition = null;
-
super.windowClosed(window, display, owner);
textInput.requestFocus();
@@ -329,4 +311,42 @@
textInput.setText(suggestionRenderer.toString(suggestion));
}
}
+
+ @Override
+ public Vote previewSuggestionPopupClose(final SuggestionPopup suggestionPopup, final boolean result) {
+ if (closeTransition == null) {
+ suggestionListViewBorder.setEnabled(false);
+
+ closeTransition = new FadeWindowTransition(suggestionPopup,
+ CLOSE_TRANSITION_DURATION, CLOSE_TRANSITION_RATE,
+ dropShadowDecorator);
+
+ closeTransition.start(new TransitionListener() {
+ @Override
+ public void transitionCompleted(Transition transition) {
+ suggestionPopup.close(result);
+ }
+ });
+ }
+
+ return (closeTransition != null
+ && closeTransition.isRunning()) ? Vote.DEFER : Vote.APPROVE;
+ }
+
+ @Override
+ public void suggestionPopupCloseVetoed(SuggestionPopup suggestionPopup, Vote reason) {
+ if (reason == Vote.DENY
+ && closeTransition != null) {
+ closeTransition.stop();
+
+ suggestionListViewBorder.setEnabled(true);
+ closeTransition = null;
+ }
+ }
+
+ @Override
+ public void suggestionPopupClosed(SuggestionPopup suggestionPopup) {
+ suggestionListViewBorder.setEnabled(true);
+ closeTransition = null;
+ }
}
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=908512&r1=908511&r2=908512&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/SuggestionPopup.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/SuggestionPopup.java Wed Feb 10 14:20:15 2010
@@ -19,6 +19,7 @@
import org.apache.pivot.collections.ArrayList;
import org.apache.pivot.collections.List;
import org.apache.pivot.util.ListenerList;
+import org.apache.pivot.util.Vote;
import org.apache.pivot.wtk.content.SuggestionPopupItemRenderer;
/**
@@ -66,6 +67,34 @@
}
}
+ private static class SuggestionPopupStateListenerList extends ListenerList<SuggestionPopupStateListener>
+ implements SuggestionPopupStateListener {
+ @Override
+ public Vote previewSuggestionPopupClose(SuggestionPopup suggestionPopup, boolean result) {
+ Vote vote = Vote.APPROVE;
+
+ for (SuggestionPopupStateListener listener : this) {
+ vote = vote.tally(listener.previewSuggestionPopupClose(suggestionPopup, result));
+ }
+
+ return vote;
+ }
+
+ @Override
+ public void suggestionPopupCloseVetoed(SuggestionPopup suggestionPopup, Vote reason) {
+ for (SuggestionPopupStateListener listener : this) {
+ listener.suggestionPopupCloseVetoed(suggestionPopup, reason);
+ }
+ }
+
+ @Override
+ public void suggestionPopupClosed(SuggestionPopup suggestionPopup) {
+ for (SuggestionPopupStateListener listener : this) {
+ listener.suggestionPopupClosed(suggestionPopup);
+ }
+ }
+ }
+
private TextInput textInput = null;
private SuggestionPopupCloseListener suggestionPopupCloseListener = null;
@@ -75,7 +104,10 @@
private boolean result = false;
+ private boolean closing = false;
+
private SuggestionPopupListenerList suggestionPopupListeners = new SuggestionPopupListenerList();
+ private SuggestionPopupStateListenerList suggestionPopupStateListeners = new SuggestionPopupStateListenerList();
private static final SuggestionRenderer DEFAULT_SUGGESTION_RENDERER =
new SuggestionPopupItemRenderer();
@@ -240,23 +272,42 @@
}
@Override
+ public boolean isClosing() {
+ return closing;
+ }
+
+ @Override
public final void close() {
close(false);
}
public void close(boolean result) {
if (!isClosed()) {
- super.close();
+ closing = true;
+
+ Vote vote = suggestionPopupStateListeners.previewSuggestionPopupClose(this, result);
- if (isClosed()) {
- this.result = result;
+ if (vote == Vote.APPROVE) {
+ super.close();
- textInput = null;
+ closing = super.isClosing();
- if (suggestionPopupCloseListener != null) {
- suggestionPopupCloseListener.suggestionPopupClosed(this);
- suggestionPopupCloseListener = null;
+ if (isClosed()) {
+ this.result = result;
+
+ suggestionPopupStateListeners.suggestionPopupClosed(this);
+
+ if (suggestionPopupCloseListener != null) {
+ suggestionPopupCloseListener.suggestionPopupClosed(this);
+ suggestionPopupCloseListener = null;
+ }
+ }
+ } else {
+ if (vote == Vote.DENY) {
+ closing = false;
}
+
+ suggestionPopupStateListeners.suggestionPopupCloseVetoed(this, vote);
}
}
}
@@ -272,4 +323,8 @@
public ListenerList<SuggestionPopupListener> getSuggestionPopupListeners() {
return suggestionPopupListeners;
}
+
+ public ListenerList<SuggestionPopupStateListener> getSuggestionPopupStateListeners() {
+ return suggestionPopupStateListeners;
+ }
}
Added: pivot/trunk/wtk/src/org/apache/pivot/wtk/SuggestionPopupStateListener.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/SuggestionPopupStateListener.java?rev=908512&view=auto
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/SuggestionPopupStateListener.java (added)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/SuggestionPopupStateListener.java Wed Feb 10 14:20:15 2010
@@ -0,0 +1,58 @@
+/*
+ * 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.wtk;
+
+import org.apache.pivot.util.Vote;
+
+/**
+ * Suggestion popup state listener interface.
+ */
+public interface SuggestionPopupStateListener extends SuggestionPopupCloseListener {
+ /**
+ * Suggestion popup state listener adapter.
+ */
+ public static class Adapter implements SuggestionPopupStateListener {
+ @Override
+ public Vote previewSuggestionPopupClose(SuggestionPopup suggestionPopup, boolean result) {
+ return Vote.APPROVE;
+ }
+
+ @Override
+ public void suggestionPopupCloseVetoed(SuggestionPopup suggestionPopup, Vote reason) {
+ }
+
+ @Override
+ public void suggestionPopupClosed(SuggestionPopup suggestionPopup) {
+ }
+ }
+
+ /**
+ * Called to preview a suggestion popup close event.
+ *
+ * @param suggestionPopup
+ * @param result
+ */
+ public Vote previewSuggestionPopupClose(SuggestionPopup suggestionPopup, boolean result);
+
+ /**
+ * Called when a suggestion popup close event has been vetoed.
+ *
+ * @param suggestionPopup
+ * @param reason
+ */
+ public void suggestionPopupCloseVetoed(SuggestionPopup suggestionPopup, Vote reason);
+}