Author: noelgrandin
Date: Wed May 5 09:15:25 2010
New Revision: 941213
URL: http://svn.apache.org/viewvc?rev=941213&view=rev
Log:
PIVOT-377 Provide access to the window in popup button components
Modified:
pivot/trunk/tests/src/org/apache/pivot/tests/ColorListButtonTest.java
pivot/trunk/tests/src/org/apache/pivot/tests/color_list_button_test.wtkx
pivot/trunk/wtk/src/org/apache/pivot/wtk/CalendarButton.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/ColorChooserButton.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/ListButton.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/MenuButton.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/CalendarButtonSkin.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ColorChooserButtonSkin.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ListButtonSkin.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/MenuButtonSkin.java
Modified: pivot/trunk/tests/src/org/apache/pivot/tests/ColorListButtonTest.java
URL:
http://svn.apache.org/viewvc/pivot/trunk/tests/src/org/apache/pivot/tests/ColorListButtonTest.java?rev=941213&r1=941212&r2=941213&view=diff
==============================================================================
--- pivot/trunk/tests/src/org/apache/pivot/tests/ColorListButtonTest.java
(original)
+++ pivot/trunk/tests/src/org/apache/pivot/tests/ColorListButtonTest.java Wed
May 5 09:15:25 2010
@@ -18,20 +18,28 @@ package org.apache.pivot.tests;
import org.apache.pivot.collections.Map;
import org.apache.pivot.wtk.Application;
-import org.apache.pivot.wtk.Component;
+import org.apache.pivot.wtk.BoxPane;
import org.apache.pivot.wtk.DesktopApplicationContext;
import org.apache.pivot.wtk.Display;
import org.apache.pivot.wtk.Frame;
+import org.apache.pivot.wtk.ListButton;
+import org.apache.pivot.wtk.effects.ReflectionDecorator;
import org.apache.pivot.wtkx.WTKXSerializer;
public class ColorListButtonTest implements Application {
private Frame frame = null;
-
+ private ListButton listButton = null;
+
@Override
public void startup(Display display, Map<String, String> properties)
throws Exception {
WTKXSerializer wtkxSerializer = new WTKXSerializer();
- frame = new
Frame((Component)wtkxSerializer.readObject(getClass().getResource("color_list_button_test.wtkx")));
+ BoxPane boxPane = (BoxPane) wtkxSerializer.readObject(this,
"color_list_button_test.wtkx");
+ listButton = (ListButton)wtkxSerializer.get("listButton");
+ // test the getListPopup() method
+ listButton.getListPopup().getDecorators().add(new
ReflectionDecorator());
+
+ frame = new Frame(boxPane);
frame.setTitle("Color List Button Test");
frame.setPreferredSize(480, 360);
frame.open(display);
Modified:
pivot/trunk/tests/src/org/apache/pivot/tests/color_list_button_test.wtkx
URL:
http://svn.apache.org/viewvc/pivot/trunk/tests/src/org/apache/pivot/tests/color_list_button_test.wtkx?rev=941213&r1=941212&r2=941213&view=diff
==============================================================================
--- pivot/trunk/tests/src/org/apache/pivot/tests/color_list_button_test.wtkx
(original)
+++ pivot/trunk/tests/src/org/apache/pivot/tests/color_list_button_test.wtkx
Wed May 5 09:15:25 2010
@@ -19,7 +19,7 @@ limitations under the License.
<BoxPane xmlns:wtkx="http://pivot.apache.org/wtkx"
xmlns:collections="org.apache.pivot.collections"
xmlns:content="org.apache.pivot.wtk.content" xmlns="org.apache.pivot.wtk">
- <ListButton selectedIndex="0">
+ <ListButton wtkx:id="listButton" selectedIndex="0">
<listData>
<collections:ArrayList>
<content:ColorItem color="#000000" name="Black"/>
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/CalendarButton.java
URL:
http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/CalendarButton.java?rev=941213&r1=941212&r2=941213&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/CalendarButton.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/CalendarButton.java Wed May 5
09:15:25 2010
@@ -104,6 +104,15 @@ public class CalendarButton extends Butt
}
}
+ /**
+ * CalendarButton skin interface. CalendarButton skins must implement
+ * this interface to facilitate additional communication between the
+ * component and the skin.
+ */
+ public interface Skin {
+ public Window getListPopup();
+ }
+
private int year;
private int month;
@@ -146,6 +155,23 @@ public class CalendarButton extends Butt
setSelectedDate(new CalendarDate());
}
+ @Override
+ protected void setSkin(org.apache.pivot.wtk.Skin skin) {
+ if (!(skin instanceof CalendarButton.Skin)) {
+ throw new IllegalArgumentException("Skin class must implement "
+ + CalendarButton.Skin.class.getName());
+ }
+
+ super.setSkin(skin);
+ }
+
+ /**
+ * @return the popup window associated with this components skin
+ */
+ public Window getListPopup() {
+ return ((CalendarButton.Skin) getSkin()).getListPopup();
+ }
+
/**
* @throws UnsupportedOperationException
* This method is not supported by CalendarButton.
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/ColorChooserButton.java
URL:
http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/ColorChooserButton.java?rev=941213&r1=941212&r2=941213&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/ColorChooserButton.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/ColorChooserButton.java Wed May 5
09:15:25 2010
@@ -76,6 +76,15 @@ public class ColorChooserButton extends
}
}
+ /**
+ * ColorChooserButton skin interface. ColorChooserButton skins must
implement
+ * this interface to facilitate additional communication between the
+ * component and the skin.
+ */
+ public interface Skin {
+ public Window getListPopup();
+ }
+
private Color selectedColor = null;
private String selectedColorKey = null;
@@ -101,6 +110,23 @@ public class ColorChooserButton extends
installThemeSkin(ColorChooserButton.class);
}
+ @Override
+ protected void setSkin(org.apache.pivot.wtk.Skin skin) {
+ if (!(skin instanceof ColorChooserButton.Skin)) {
+ throw new IllegalArgumentException("Skin class must implement "
+ + ColorChooserButton.Skin.class.getName());
+ }
+
+ super.setSkin(skin);
+ }
+
+ /**
+ * @return the popup window associated with this components skin
+ */
+ public Window getListPopup() {
+ return ((ColorChooserButton.Skin) getSkin()).getListPopup();
+ }
+
/**
* @throws UnsupportedOperationException
* This method is not supported by ColorChooserButton.
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=941213&r1=941212&r2=941213&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/ListButton.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/ListButton.java Wed May 5
09:15:25 2010
@@ -119,6 +119,15 @@ public class ListButton extends Button {
}
}
+ /**
+ * ListButton skin interface. ListButton skins must implement
+ * this interface to facilitate additional communication between the
+ * component and the skin.
+ */
+ public interface Skin {
+ public Window getListPopup();
+ }
+
private List<?> listData;
private ListView.ItemRenderer itemRenderer;
private int selectedIndex = -1;
@@ -180,6 +189,23 @@ public class ListButton extends Button {
installThemeSkin(ListButton.class);
}
+ @Override
+ protected void setSkin(org.apache.pivot.wtk.Skin skin) {
+ if (!(skin instanceof ListButton.Skin)) {
+ throw new IllegalArgumentException("Skin class must implement "
+ + ListButton.Skin.class.getName());
+ }
+
+ super.setSkin(skin);
+ }
+
+ /**
+ * @return the popup window associated with this components skin
+ */
+ public Window getListPopup() {
+ return ((ListButton.Skin) getSkin()).getListPopup();
+ }
+
/**
* @throws UnsupportedOperationException
* This method is not supported by ListButton.
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/MenuButton.java
URL:
http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/MenuButton.java?rev=941213&r1=941212&r2=941213&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/MenuButton.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/MenuButton.java Wed May 5
09:15:25 2010
@@ -48,6 +48,15 @@ public class MenuButton extends Button {
}
}
+ /**
+ * MenuButton skin interface. MenuButton skins must implement
+ * this interface to facilitate additional communication between the
+ * component and the skin.
+ */
+ public interface Skin {
+ public Window getListPopup();
+ }
+
private Menu menu = null;
private boolean repeatable = false;
@@ -61,6 +70,23 @@ public class MenuButton extends Button {
}
@Override
+ protected void setSkin(org.apache.pivot.wtk.Skin skin) {
+ if (!(skin instanceof MenuButton.Skin)) {
+ throw new IllegalArgumentException("Skin class must implement "
+ + MenuButton.Skin.class.getName());
+ }
+
+ super.setSkin(skin);
+ }
+
+ /**
+ * @return the popup window associated with this components skin
+ */
+ public Window getListPopup() {
+ return ((MenuButton.Skin) getSkin()).getListPopup();
+ }
+
+ @Override
public void setToggleButton(boolean toggleButton) {
throw new UnsupportedOperationException("Menu buttons cannot be toggle
buttons.");
}
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/CalendarButtonSkin.java
URL:
http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/CalendarButtonSkin.java?rev=941213&r1=941212&r2=941213&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/CalendarButtonSkin.java
(original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/CalendarButtonSkin.java Wed
May 5 09:15:25 2010
@@ -47,7 +47,7 @@ import org.apache.pivot.wtk.WindowStateL
* concrete subclasses.
*/
public abstract class CalendarButtonSkin extends ButtonSkin
- implements CalendarButtonListener, CalendarButtonSelectionListener {
+ implements CalendarButton.Skin, CalendarButtonListener,
CalendarButtonSelectionListener {
protected Calendar calendar;
protected Window calendarPopup;
@@ -176,6 +176,12 @@ public abstract class CalendarButtonSkin
calendar.setLocale(calendarButton.getLocale());
}
+ // CalendarButton.Skin methods
+
+ public Window getListPopup() {
+ return calendarPopup;
+ }
+
// Component state events
@Override
public void enabledChanged(Component component) {
Modified:
pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ColorChooserButtonSkin.java
URL:
http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ColorChooserButtonSkin.java?rev=941213&r1=941212&r2=941213&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ColorChooserButtonSkin.java
(original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ColorChooserButtonSkin.java
Wed May 5 09:15:25 2010
@@ -37,7 +37,7 @@ import org.apache.pivot.wtk.WindowStateL
* Abstract base class for color chooser button skins.
*/
public abstract class ColorChooserButtonSkin extends ButtonSkin
- implements ColorChooserButtonSelectionListener {
+ implements ColorChooserButton.Skin, ColorChooserButtonSelectionListener {
/**
* A focusable window class used by color chooser button skins.
*/
@@ -187,6 +187,12 @@ public abstract class ColorChooserButton
colorChooserButton.getColorChooserButtonSelectionListeners().add(this);
}
+ // ColorChooserButton.Skin methods
+
+ public Window getListPopup() {
+ return colorChooserPopup;
+ }
+
// ComponentStateListener methods
@Override
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ListButtonSkin.java
URL:
http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ListButtonSkin.java?rev=941213&r1=941212&r2=941213&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ListButtonSkin.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ListButtonSkin.java Wed May
5 09:15:25 2010
@@ -44,7 +44,7 @@ import org.apache.pivot.wtk.WindowStateL
* concrete subclasses.
*/
public abstract class ListButtonSkin extends ButtonSkin
- implements ListButtonListener, ListButtonSelectionListener {
+ implements ListButton.Skin, ListButtonListener,
ListButtonSelectionListener {
protected ListView listView;
protected Window listViewPopup;
@@ -173,6 +173,12 @@ public abstract class ListButtonSkin ext
listView.setItemRenderer(listButton.getItemRenderer());
}
+ // ListButton.Skin methods
+
+ public Window getListPopup() {
+ return listViewPopup;
+ }
+
// Component state events
@Override
public void enabledChanged(Component component) {
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/MenuButtonSkin.java
URL:
http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/MenuButtonSkin.java?rev=941213&r1=941212&r2=941213&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/MenuButtonSkin.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/MenuButtonSkin.java Wed May
5 09:15:25 2010
@@ -33,7 +33,7 @@ import org.apache.pivot.wtk.WindowStateL
* Abstract base class for menu button skins.
*/
public abstract class MenuButtonSkin extends ButtonSkin
- implements MenuButtonListener {
+ implements MenuButton.Skin, MenuButtonListener {
protected boolean pressed = false;
protected MenuPopup menuPopup = new MenuPopup();
@@ -80,6 +80,12 @@ public abstract class MenuButtonSkin ext
menuPopup.getWindowStateListeners().add(menuPopupWindowStateListener);
}
+ // MenuButton.Skin methods
+
+ public Window getListPopup() {
+ return menuPopup;
+ }
+
// Component state events
@Override
public void enabledChanged(Component component) {