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/17 17:55:08 UTC
svn commit: r986365 - in /pivot/trunk/wtk/src/org/apache/pivot/wtk:
ListButton.java ListButtonItemListener.java SpinnerItemListener.java
SuggestionPopup.java SuggestionPopupItemListener.java
Author: gbrown
Date: Tue Aug 17 15:55:08 2010
New Revision: 986365
URL: http://svn.apache.org/viewvc?rev=986365&view=rev
Log:
Add item listener interface to ListButton and SuggestionPopup.
Added:
pivot/trunk/wtk/src/org/apache/pivot/wtk/ListButtonItemListener.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/SuggestionPopupItemListener.java
Modified:
pivot/trunk/wtk/src/org/apache/pivot/wtk/ListButton.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/SpinnerItemListener.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/SuggestionPopup.java
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/ListButton.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/ListButton.java?rev=986365&r1=986364&r2=986365&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/ListButton.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/ListButton.java Tue Aug 17 15:55:08 2010
@@ -71,6 +71,44 @@ public class ListButton extends Button {
}
}
+ private static class ListButtonItemListenerList extends ListenerList<ListButtonItemListener>
+ implements ListButtonItemListener {
+ @Override
+ public void itemInserted(ListButton listButton, int index) {
+ for (ListButtonItemListener listener : this) {
+ listener.itemInserted(listButton, index);
+ }
+ }
+
+ @Override
+ public void itemsRemoved(ListButton listButton, int index, int count) {
+ for (ListButtonItemListener listener : this) {
+ listener.itemsRemoved(listButton, index, count);
+ }
+ }
+
+ @Override
+ public void itemUpdated(ListButton listButton, int index) {
+ for (ListButtonItemListener listener : this) {
+ listener.itemUpdated(listButton, index);
+ }
+ }
+
+ @Override
+ public void itemsCleared(ListButton listButton) {
+ for (ListButtonItemListener listener : this) {
+ listener.itemsCleared(listButton);
+ }
+ }
+
+ @Override
+ public void itemsSorted(ListButton listButton) {
+ for (ListButtonItemListener listener : this) {
+ listener.itemsSorted(listButton);
+ }
+ }
+ }
+
private static class ListButtonSelectionListenerList extends ListenerList<ListButtonSelectionListener>
implements ListButtonSelectionListener {
@Override
@@ -165,6 +203,8 @@ public class ListButton extends Button {
selectedIndex++;
}
+ listButtonItemListeners.itemInserted(ListButton.this, index);
+
if (selectedIndex != previousSelectedIndex) {
listButtonSelectionListeners.selectedIndexChanged(ListButton.this, selectedIndex);
}
@@ -185,6 +225,8 @@ public class ListButton extends Button {
}
}
+ listButtonItemListeners.itemsRemoved(ListButton.this, index, count);
+
if (selectedIndex != previousSelectedIndex) {
listButtonSelectionListeners.selectedIndexChanged(ListButton.this, selectedIndex);
}
@@ -197,7 +239,7 @@ public class ListButton extends Button {
@Override
public void itemUpdated(List<Object> list, int index, Object previousItem) {
- // No-op
+ listButtonItemListeners.itemUpdated(ListButton.this, index);
}
@Override
@@ -205,6 +247,8 @@ public class ListButton extends Button {
int previousSelectedIndex = selectedIndex;
selectedIndex = -1;
+ listButtonItemListeners.itemsCleared(ListButton.this);
+
if (previousSelectedIndex != selectedIndex) {
listButtonSelectionListeners.selectedIndexChanged(ListButton.this, selectedIndex);
listButtonSelectionListeners.selectedItemChanged(ListButton.this, getSelectedItem());
@@ -216,6 +260,8 @@ public class ListButton extends Button {
int previousSelectedIndex = selectedIndex;
selectedIndex = -1;
+ listButtonItemListeners.itemsSorted(ListButton.this);
+
if (previousSelectedIndex != selectedIndex) {
listButtonSelectionListeners.selectedIndexChanged(ListButton.this, selectedIndex);
listButtonSelectionListeners.selectedItemChanged(ListButton.this, getSelectedItem());
@@ -224,6 +270,7 @@ public class ListButton extends Button {
};
private ListButtonListenerList listButtonListeners = new ListButtonListenerList();
+ private ListButtonItemListenerList listButtonItemListeners = new ListButtonItemListenerList();
private ListButtonSelectionListenerList listButtonSelectionListeners = new ListButtonSelectionListenerList();
private ListButtonBindingListenerList listButtonBindingListeners = new ListButtonBindingListenerList();
@@ -715,6 +762,13 @@ public class ListButton extends Button {
}
/**
+ * Returns the list button item listener list.
+ */
+ public ListenerList<ListButtonItemListener> getListButtonItemListeners() {
+ return listButtonItemListeners;
+ }
+
+ /**
* Returns the list button selection listener list.
*/
public ListenerList<ListButtonSelectionListener> getListButtonSelectionListeners() {
Added: pivot/trunk/wtk/src/org/apache/pivot/wtk/ListButtonItemListener.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/ListButtonItemListener.java?rev=986365&view=auto
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/ListButtonItemListener.java (added)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/ListButtonItemListener.java Tue Aug 17 15:55:08 2010
@@ -0,0 +1,86 @@
+/*
+ * 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;
+
+/**
+ * List button item listener interface.
+ */
+public interface ListButtonItemListener {
+ /**
+ * List button item listener adapter.
+ */
+ public static class Adapter implements ListButtonItemListener {
+ @Override
+ public void itemInserted(ListButton listButton, int index) {
+ }
+
+ @Override
+ public void itemsRemoved(ListButton listButton, int index, int count) {
+ }
+
+ @Override
+ public void itemUpdated(ListButton listButton, int index) {
+ }
+
+ @Override
+ public void itemsCleared(ListButton listButton) {
+ }
+
+ @Override
+ public void itemsSorted(ListButton listButton) {
+ }
+ }
+
+ /**
+ * Called when an item is inserted into a list button's list data.
+ *
+ * @param listButton
+ * @param index
+ */
+ public void itemInserted(ListButton listButton, int index);
+
+ /**
+ * Called when items are removed from a list button's list data.
+ *
+ * @param listButton
+ * @param index
+ * @param count
+ */
+ public void itemsRemoved(ListButton listButton, int index, int count);
+
+ /**
+ * Called when an item is updated within a list button's list data.
+ *
+ * @param listButton
+ * @param index
+ */
+ public void itemUpdated(ListButton listButton, int index);
+
+ /**
+ * Called when a list button's list data has been cleared.
+ *
+ * @param listButton
+ */
+ public void itemsCleared(ListButton listButton);
+
+ /**
+ * Called when a list button's list data is sorted.
+ *
+ * @param listButton
+ */
+ public void itemsSorted(ListButton listButton);
+}
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/SpinnerItemListener.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/SpinnerItemListener.java?rev=986365&r1=986364&r2=986365&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/SpinnerItemListener.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/SpinnerItemListener.java Tue Aug 17 15:55:08 2010
@@ -46,7 +46,7 @@ public interface SpinnerItemListener {
}
/**
- * Called when an item is inserted into the spinner data.
+ * Called when an item is inserted into a spinner's data.
*
* @param spinner
* @param index
@@ -54,7 +54,7 @@ public interface SpinnerItemListener {
public void itemInserted(Spinner spinner, int index);
/**
- * Called when items are removed from the spinner data.
+ * Called when items are removed from a spinner's data.
*
* @param spinner
* @param index
@@ -63,7 +63,7 @@ public interface SpinnerItemListener {
public void itemsRemoved(Spinner spinner, int index, int count);
/**
- * Called when an item is updated within the spinner data.
+ * Called when an item is updated within a spinner's data.
*
* @param spinner
* @param index
@@ -71,14 +71,14 @@ public interface SpinnerItemListener {
public void itemUpdated(Spinner spinner, int index);
/**
- * Called when the spinner data has been cleared.
+ * Called when a spinner's data has been cleared.
*
* @param spinner
*/
public void itemsCleared(Spinner spinner);
/**
- * Called when the spinner data is sorted.
+ * Called when a spinner's data is sorted.
*
* @param spinner
*/
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=986365&r1=986364&r2=986365&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/SuggestionPopup.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/SuggestionPopup.java Tue Aug 17 15:55:08 2010
@@ -57,6 +57,44 @@ public class SuggestionPopup extends Win
}
}
+ private static class SuggestionPopupItemListenerList extends ListenerList<SuggestionPopupItemListener>
+ implements SuggestionPopupItemListener {
+ @Override
+ public void itemInserted(SuggestionPopup suggestionPopup, int index) {
+ for (SuggestionPopupItemListener listener : this) {
+ listener.itemInserted(suggestionPopup, index);
+ }
+ }
+
+ @Override
+ public void itemsRemoved(SuggestionPopup suggestionPopup, int index, int count) {
+ for (SuggestionPopupItemListener listener : this) {
+ listener.itemsRemoved(suggestionPopup, index, count);
+ }
+ }
+
+ @Override
+ public void itemUpdated(SuggestionPopup suggestionPopup, int index) {
+ for (SuggestionPopupItemListener listener : this) {
+ listener.itemUpdated(suggestionPopup, index);
+ }
+ }
+
+ @Override
+ public void itemsCleared(SuggestionPopup suggestionPopup) {
+ for (SuggestionPopupItemListener listener : this) {
+ listener.itemsCleared(suggestionPopup);
+ }
+ }
+
+ @Override
+ public void itemsSorted(SuggestionPopup suggestionPopup) {
+ for (SuggestionPopupItemListener listener : this) {
+ listener.itemsSorted(suggestionPopup);
+ }
+ }
+ }
+
private static class SuggestionPopupStateListenerList extends ListenerList<SuggestionPopupStateListener>
implements SuggestionPopupStateListener {
@Override
@@ -105,6 +143,8 @@ public class SuggestionPopup extends Win
selectedIndex++;
}
+ suggestionPopupItemListeners.itemInserted(SuggestionPopup.this, index);
+
if (selectedIndex != previousSelectedIndex) {
suggestionPopupListeners.selectedIndexChanged(SuggestionPopup.this, selectedIndex);
}
@@ -121,6 +161,8 @@ public class SuggestionPopup extends Win
selectedIndex = -1;
}
+ suggestionPopupItemListeners.itemsRemoved(SuggestionPopup.this, index, count);
+
if (selectedIndex != previousSelectedIndex) {
suggestionPopupListeners.selectedIndexChanged(SuggestionPopup.this, selectedIndex);
}
@@ -128,25 +170,26 @@ public class SuggestionPopup extends Win
@Override
public void itemUpdated(List<Object> list, int index, Object previousItem) {
- // No-op
+ suggestionPopupItemListeners.itemUpdated(SuggestionPopup.this, index);
}
@Override
public void listCleared(List<Object> list) {
- // All items were removed; clear the selection and notify
- // listeners
selectedIndex = -1;
+ suggestionPopupItemListeners.itemsCleared(SuggestionPopup.this);
suggestionPopupListeners.selectedIndexChanged(SuggestionPopup.this, selectedIndex);
}
@Override
public void comparatorChanged(List<Object> list, Comparator<Object> previousComparator) {
selectedIndex = -1;
+ suggestionPopupItemListeners.itemsSorted(SuggestionPopup.this);
suggestionPopupListeners.selectedIndexChanged(SuggestionPopup.this, selectedIndex);
}
};
private SuggestionPopupListenerList suggestionPopupListeners = new SuggestionPopupListenerList();
+ private SuggestionPopupItemListenerList suggestionPopupItemListeners = new SuggestionPopupItemListenerList();
private SuggestionPopupStateListenerList suggestionPopupStateListeners = new SuggestionPopupStateListenerList();
private static final ListView.ItemRenderer DEFAULT_SUGGESTION_RENDERER = new ListViewItemRenderer();
@@ -377,6 +420,10 @@ public class SuggestionPopup extends Win
return suggestionPopupListeners;
}
+ public ListenerList<SuggestionPopupItemListener> getSuggestionPopupItemListeners() {
+ return suggestionPopupItemListeners;
+ }
+
public ListenerList<SuggestionPopupStateListener> getSuggestionPopupStateListeners() {
return suggestionPopupStateListeners;
}
Added: pivot/trunk/wtk/src/org/apache/pivot/wtk/SuggestionPopupItemListener.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/SuggestionPopupItemListener.java?rev=986365&view=auto
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/SuggestionPopupItemListener.java (added)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/SuggestionPopupItemListener.java Tue Aug 17 15:55:08 2010
@@ -0,0 +1,86 @@
+/*
+ * 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;
+
+/**
+ * Suggestion popup item listener interface.
+ */
+public interface SuggestionPopupItemListener {
+ /**
+ * Suggestion popup item listener adapter.
+ */
+ public static class Adapter implements SuggestionPopupItemListener {
+ @Override
+ public void itemInserted(SuggestionPopup suggestionPopup, int index) {
+ }
+
+ @Override
+ public void itemsRemoved(SuggestionPopup suggestionPopup, int index, int count) {
+ }
+
+ @Override
+ public void itemUpdated(SuggestionPopup suggestionPopup, int index) {
+ }
+
+ @Override
+ public void itemsCleared(SuggestionPopup suggestionPopup) {
+ }
+
+ @Override
+ public void itemsSorted(SuggestionPopup suggestionPopup) {
+ }
+ }
+
+ /**
+ * Called when an item is inserted into a list button's list data.
+ *
+ * @param suggestionPopup
+ * @param index
+ */
+ public void itemInserted(SuggestionPopup suggestionPopup, int index);
+
+ /**
+ * Called when items are removed from a list button's list data.
+ *
+ * @param suggestionPopup
+ * @param index
+ * @param count
+ */
+ public void itemsRemoved(SuggestionPopup suggestionPopup, int index, int count);
+
+ /**
+ * Called when an item is updated within a list button's list data.
+ *
+ * @param suggestionPopup
+ * @param index
+ */
+ public void itemUpdated(SuggestionPopup suggestionPopup, int index);
+
+ /**
+ * Called when a list button's list data has been cleared.
+ *
+ * @param suggestionPopup
+ */
+ public void itemsCleared(SuggestionPopup suggestionPopup);
+
+ /**
+ * Called when a list button's list data is sorted.
+ *
+ * @param suggestionPopup
+ */
+ public void itemsSorted(SuggestionPopup suggestionPopup);
+}