You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by tv...@apache.org on 2009/10/30 19:45:25 UTC

svn commit: r831420 - in /incubator/pivot/trunk: tools/src/org/apache/pivot/tools/wtk/ wtk/src/org/apache/pivot/wtk/ wtk/src/org/apache/pivot/wtk/content/ wtk/src/org/apache/pivot/wtk/skin/ wtk/src/org/apache/pivot/wtk/skin/terra/

Author: tvolkert
Date: Fri Oct 30 18:45:24 2009
New Revision: 831420

URL: http://svn.apache.org/viewvc?rev=831420&view=rev
Log:
PIVOT-77 :: Fixed bug in TerraColorChooserSkin, added ColorChooserButton and associated classes, changed component inspector to use ColorChooserButton instead of ColorChooser to inspect color properties

Added:
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ColorChooserButton.java
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ColorChooserButtonListener.java
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ColorChooserButtonSelectionListener.java
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ColorChooserButtonSkin.java
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraColorChooserButtonSkin.java
Modified:
    incubator/pivot/trunk/tools/src/org/apache/pivot/tools/wtk/ComponentInspectorSkin.java
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Theme.java
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/ListButtonColorItemRenderer.java
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraColorChooserSkin.java
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTheme.java

Modified: incubator/pivot/trunk/tools/src/org/apache/pivot/tools/wtk/ComponentInspectorSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/tools/src/org/apache/pivot/tools/wtk/ComponentInspectorSkin.java?rev=831420&r1=831419&r2=831420&view=diff
==============================================================================
--- incubator/pivot/trunk/tools/src/org/apache/pivot/tools/wtk/ComponentInspectorSkin.java (original)
+++ incubator/pivot/trunk/tools/src/org/apache/pivot/tools/wtk/ComponentInspectorSkin.java Fri Oct 30 18:45:24 2009
@@ -25,8 +25,8 @@
 import org.apache.pivot.wtk.Button;
 import org.apache.pivot.wtk.ButtonStateListener;
 import org.apache.pivot.wtk.Checkbox;
-import org.apache.pivot.wtk.ColorChooser;
-import org.apache.pivot.wtk.ColorChooserSelectionListener;
+import org.apache.pivot.wtk.ColorChooserButton;
+import org.apache.pivot.wtk.ColorChooserButtonSelectionListener;
 import org.apache.pivot.wtk.Component;
 import org.apache.pivot.wtk.ComponentStateListener;
 import org.apache.pivot.wtk.CornerRadii;
@@ -962,23 +962,24 @@
         final String key, Form.Section section) {
         Color color = (Color)dictionary.get(key);
 
-        ColorChooser colorChooser = new ColorChooser();
-        colorChooser.setSelectedColor(color);
-        section.add(colorChooser);
-        Form.setLabel(colorChooser, key);
+        ColorChooserButton colorChooserButton = new ColorChooserButton();
+        colorChooserButton.setSelectedColor(color);
+        section.add(colorChooserButton);
+        Form.setLabel(colorChooserButton, key);
 
-        colorChooser.getColorChooserSelectionListeners().add(new ColorChooserSelectionListener() {
+        colorChooserButton.getColorChooserButtonSelectionListeners().add
+            (new ColorChooserButtonSelectionListener() {
             @Override
-            public void selectedColorChanged(ColorChooser colorChooser,
+            public void selectedColorChanged(ColorChooserButton colorChooserButton,
                 Color previousSelectedColor) {
                 try {
-                    dictionary.put(key, colorChooser.getSelectedColor());
+                    dictionary.put(key, colorChooserButton.getSelectedColor());
                 } catch (Exception exception) {
                     dictionary.put(key, previousSelectedColor);
                 }
             }
         });
 
-        return colorChooser;
+        return colorChooserButton;
     }
 }

Added: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ColorChooserButton.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ColorChooserButton.java?rev=831420&view=auto
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ColorChooserButton.java (added)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ColorChooserButton.java Fri Oct 30 18:45:24 2009
@@ -0,0 +1,213 @@
+/*
+ * 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 java.awt.Color;
+
+import org.apache.pivot.collections.Dictionary;
+import org.apache.pivot.serialization.JSONSerializer;
+import org.apache.pivot.util.ListenerList;
+import org.apache.pivot.wtk.content.ListButtonColorItemRenderer;
+
+/**
+ * A component that allows a user to select a color. The color chooser
+ * is hidden until the user pushes the button.
+ */
+public class ColorChooserButton extends Button {
+    /**
+     * Color chooser button listener list.
+     */
+    private static class ColorChooserButtonListenerList
+        extends ListenerList<ColorChooserButtonListener>
+        implements ColorChooserButtonListener {
+        @Override
+        public void selectedColorKeyChanged(ColorChooserButton colorChooserButton,
+            String previousSelectedColorKey) {
+            for (ColorChooserButtonListener listener : this) {
+                listener.selectedColorKeyChanged(colorChooserButton, previousSelectedColorKey);
+            }
+        }
+    }
+
+    /**
+     * ColorChooser button selection listener list.
+     */
+    private static class ColorChooserButtonSelectionListenerList
+        extends ListenerList<ColorChooserButtonSelectionListener>
+        implements ColorChooserButtonSelectionListener {
+
+        @Override
+        public void selectedColorChanged(ColorChooserButton colorChooserButton,
+            Color previousSelectedColor) {
+            for (ColorChooserButtonSelectionListener listener : this) {
+                listener.selectedColorChanged(colorChooserButton, previousSelectedColor);
+            }
+        }
+    }
+
+    private Color selectedColor = null;
+    private String selectedColorKey = null;
+
+    private ColorChooserButtonListenerList colorChooserButtonListeners =
+        new ColorChooserButtonListenerList();
+    private ColorChooserButtonSelectionListenerList colorChooserButtonSelectionListeners =
+        new ColorChooserButtonSelectionListenerList();
+
+    private static final Button.DataRenderer DEFAULT_DATA_RENDERER =
+        new ListButtonColorItemRenderer();
+
+    public ColorChooserButton() {
+        this(null);
+    }
+
+    public ColorChooserButton(Object buttonData) {
+        super(buttonData);
+
+        setDataRenderer(DEFAULT_DATA_RENDERER);
+        installThemeSkin(ColorChooserButton.class);
+    }
+
+    /**
+     * @throws UnsupportedOperationException
+     * This method is not supported by ColorChooserButton.
+     */
+    @Override
+    public void setToggleButton(boolean toggleButton) {
+        throw new UnsupportedOperationException("Color chooser buttons cannot be toggle buttons.");
+    }
+
+    /**
+     * Returns the currently selected color.
+     *
+     * @return
+     * The currently selected color, or <tt>null</tt> if nothing is selected.
+     */
+    public Color getSelectedColor() {
+        return selectedColor;
+    }
+
+    /**
+     * Sets the selected color.
+     *
+     * @param selectedColor
+     * The color to select, or <tt>null</tt> to clear the selection.
+     */
+    public void setSelectedColor(Color selectedColor) {
+        Color previousSelectedColor = this.selectedColor;
+
+        if (((previousSelectedColor == null) ^ (selectedColor == null))
+            || (previousSelectedColor != null
+                && !previousSelectedColor.equals(selectedColor))) {
+            this.selectedColor = selectedColor;
+            colorChooserButtonSelectionListeners.selectedColorChanged(this,
+                previousSelectedColor);
+        }
+    }
+
+    /**
+     * Sets the selected color to the color represented by the specified color
+     * string.
+     *
+     * @param selectedColor
+     * A string representing a color
+     */
+    public final void setSelectedColor(String selectedColor) {
+        if (selectedColor == null) {
+            throw new IllegalArgumentException("selectedColor is null.");
+        }
+
+        setSelectedColor(Color.decode(selectedColor));
+    }
+
+    /**
+     * Gets the data binding key that is set on this color chooser button.
+     */
+    public String getSelectedColorKey() {
+        return selectedColorKey;
+    }
+
+    /**
+     * Sets this color chooser button's data binding key.
+     */
+    public void setSelectedColorKey(String selectedColorKey) {
+        String previousSelectedColorKey = this.selectedColorKey;
+
+        if (previousSelectedColorKey != selectedColorKey) {
+            this.selectedColorKey = selectedColorKey;
+            colorChooserButtonListeners.selectedColorKeyChanged(this, previousSelectedColorKey);
+        }
+    }
+
+    /**
+     * Loads the selected color from the specified bind context using this color
+     * picker button's bind key, if one is set.
+     */
+    @Override
+    public void load(Dictionary<String, ?> context) {
+        String selectedColorKey = getSelectedColorKey();
+
+        if (selectedColorKey != null
+            && JSONSerializer.containsKey(context, selectedColorKey)) {
+            Object value = JSONSerializer.get(context, selectedColorKey);
+
+            if (value instanceof Color) {
+                setSelectedColor((Color)value);
+            } else if (value instanceof String) {
+                setSelectedColor((String)value);
+            } else {
+                throw new IllegalArgumentException("Invalid color type: " +
+                    value.getClass().getName());
+            }
+        }
+    }
+
+    /**
+     * Stores the selected color into the specified bind context using this color
+     * picker button's bind key, if one is set.
+     */
+    @Override
+    public void store(Dictionary<String, ?> context) {
+        if (isEnabled()
+            && selectedColorKey != null) {
+            JSONSerializer.put(context, selectedColorKey, selectedColor);
+        }
+    }
+
+    /**
+     * If a bind key is set, clears the selected color.
+     */
+    @Override
+    public void clear() {
+        if (selectedColorKey != null) {
+            setSelectedColor((Color)null);
+        }
+    }
+
+    /**
+     * Returns the color chooser button listener list.
+     */
+    public ListenerList<ColorChooserButtonListener> getColorChooserButtonListeners() {
+        return colorChooserButtonListeners;
+    }
+
+    /**
+     * Returns the color chooser button selection listener list.
+     */
+    public ListenerList<ColorChooserButtonSelectionListener> getColorChooserButtonSelectionListeners() {
+        return colorChooserButtonSelectionListeners;
+    }
+}

Added: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ColorChooserButtonListener.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ColorChooserButtonListener.java?rev=831420&view=auto
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ColorChooserButtonListener.java (added)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ColorChooserButtonListener.java Fri Oct 30 18:45:24 2009
@@ -0,0 +1,31 @@
+/*
+ * 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;
+
+/**
+ * Color chooser button listener interface.
+ */
+public interface ColorChooserButtonListener {
+    /**
+     * Called when a color chooser button's selected color key has changed.
+     *
+     * @param colorChooserButton
+     * @param previousSelectedColorKey
+     */
+    public void selectedColorKeyChanged(ColorChooserButton colorChooserButton,
+        String previousSelectedColorKey);
+}

Added: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ColorChooserButtonSelectionListener.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ColorChooserButtonSelectionListener.java?rev=831420&view=auto
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ColorChooserButtonSelectionListener.java (added)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ColorChooserButtonSelectionListener.java Fri Oct 30 18:45:24 2009
@@ -0,0 +1,33 @@
+/*
+ * 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 java.awt.Color;
+
+/**
+ * Color chooser button selection listener interface.
+ */
+public interface ColorChooserButtonSelectionListener {
+    /**
+     * Called when a color chooser button's selected color has changed.
+     *
+     * @param colorChooserButton
+     * @param previousSelectedColor
+     */
+    public void selectedColorChanged(ColorChooserButton colorChooserButton,
+        Color previousSelectedColor);
+}

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Theme.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Theme.java?rev=831420&r1=831419&r2=831420&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Theme.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Theme.java Fri Oct 30 18:45:24 2009
@@ -24,6 +24,7 @@
 import org.apache.pivot.wtk.media.Image;
 import org.apache.pivot.wtk.skin.BorderSkin;
 import org.apache.pivot.wtk.skin.CardPaneSkin;
+import org.apache.pivot.wtk.skin.ColorChooserButtonSkin;
 import org.apache.pivot.wtk.skin.BoxPaneSkin;
 import org.apache.pivot.wtk.skin.FlowPaneSkin;
 import org.apache.pivot.wtk.skin.ImageViewSkin;
@@ -79,6 +80,8 @@
         componentSkinMap.put(Border.class, BorderSkin.class);
         componentSkinMap.put(BoxPane.class, BoxPaneSkin.class);
         componentSkinMap.put(CardPane.class, CardPaneSkin.class);
+        componentSkinMap.put(ColorChooserButtonSkin.ColorChooserPopup.class,
+            ColorChooserButtonSkin.ColorChooserPopupSkin.class);
         componentSkinMap.put(FlowPane.class, FlowPaneSkin.class);
         componentSkinMap.put(ImageView.class, ImageViewSkin.class);
         componentSkinMap.put(Label.class, LabelSkin.class);

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/ListButtonColorItemRenderer.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/ListButtonColorItemRenderer.java?rev=831420&r1=831419&r2=831420&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/ListButtonColorItemRenderer.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/ListButtonColorItemRenderer.java Fri Oct 30 18:45:24 2009
@@ -45,14 +45,15 @@
 
     @Override
     public void render(Object data, Button button, boolean highlighted) {
-        Color color;
+        Color color = Color.WHITE;
+
         if (data instanceof ColorItem) {
             ColorItem colorItem = (ColorItem)data;
             color = colorItem.getColor();
         } else {
             if (data instanceof Color) {
                 color = (Color)data;
-            } else {
+            } else if (data != null) {
                 color = GraphicsUtilities.decodeColor(data.toString());
             }
         }

Added: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ColorChooserButtonSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ColorChooserButtonSkin.java?rev=831420&view=auto
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ColorChooserButtonSkin.java (added)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ColorChooserButtonSkin.java Fri Oct 30 18:45:24 2009
@@ -0,0 +1,286 @@
+/*
+ * 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.skin;
+
+import java.awt.Color;
+
+import org.apache.pivot.wtk.Component;
+import org.apache.pivot.wtk.ComponentKeyListener;
+import org.apache.pivot.wtk.Container;
+import org.apache.pivot.wtk.ContainerMouseListener;
+import org.apache.pivot.wtk.Direction;
+import org.apache.pivot.wtk.Display;
+import org.apache.pivot.wtk.Keyboard;
+import org.apache.pivot.wtk.ColorChooser;
+import org.apache.pivot.wtk.ColorChooserButton;
+import org.apache.pivot.wtk.ColorChooserButtonListener;
+import org.apache.pivot.wtk.ColorChooserButtonSelectionListener;
+import org.apache.pivot.wtk.Mouse;
+import org.apache.pivot.wtk.Window;
+import org.apache.pivot.wtk.WindowStateListener;
+
+/**
+ * Abstract base class for color chooser button skins.
+ */
+public abstract class ColorChooserButtonSkin extends ButtonSkin
+    implements ColorChooserButtonListener, ColorChooserButtonSelectionListener {
+    public final class ColorChooserPopup extends Window {
+        private ColorChooserPopup() {
+            setSkin(new ColorChooserPopupSkin());
+        }
+    }
+
+    public final class ColorChooserPopupSkin extends WindowSkin {
+        private ColorChooserPopupSkin() {
+        }
+
+        @Override
+        public boolean isFocusable() {
+            return true;
+        }
+
+        @Override
+        public boolean mouseClick(Component component, Mouse.Button button, int x, int y,
+            int count) {
+            component.requestFocus();
+            return super.mouseClick(component, button, x, y, count);
+        }
+    }
+
+    private ComponentKeyListener colorChooserPopupKeyListener = new ComponentKeyListener.Adapter() {
+        @Override
+        public boolean keyPressed(Component component, int keyCode,
+            Keyboard.KeyLocation keyLocation) {
+            ColorChooserButton colorChooserButton = (ColorChooserButton)getComponent();
+
+            switch (keyCode) {
+                case Keyboard.KeyCode.ESCAPE: {
+                    colorChooserPopup.close();
+                    break;
+                }
+
+                case Keyboard.KeyCode.TAB:
+                case Keyboard.KeyCode.ENTER: {
+                    colorChooserPopup.close();
+
+                    if (keyCode == Keyboard.KeyCode.TAB) {
+                        Direction direction = (Keyboard.isPressed(Keyboard.Modifier.SHIFT)) ?
+                            Direction.BACKWARD : Direction.FORWARD;
+                        colorChooserButton.transferFocus(direction);
+                    }
+
+                    Color color = colorChooser.getSelectedColor();
+                    colorChooserButton.setSelectedColor(color);
+
+                    break;
+                }
+            }
+
+            return false;
+        }
+    };
+
+    private WindowStateListener colorChooserPopupWindowStateListener =
+        new WindowStateListener.Adapter() {
+        @Override
+        public void windowOpened(Window window) {
+            Display display = window.getDisplay();
+            display.getContainerMouseListeners().add(displayMouseListener);
+        }
+
+        @Override
+        public void windowClosed(Window window, Display display, Window owner) {
+            display.getContainerMouseListeners().remove(displayMouseListener);
+
+            Window componentWindow = getComponent().getWindow();
+            if (componentWindow != null) {
+                // The color chooser button may have been detached from the
+                // component hierarchy while our transition was running
+                componentWindow.moveToFront();
+            }
+        }
+    };
+
+    private ContainerMouseListener displayMouseListener = new ContainerMouseListener.Adapter() {
+        @Override
+        public boolean mouseDown(Container container, Mouse.Button button, int x, int y) {
+            ColorChooserButton colorChooserButton = (ColorChooserButton)getComponent();
+
+            Display display = (Display)container;
+            Component descendant = display.getDescendantAt(x, y);
+
+            if (!colorChooserPopup.isAncestor(descendant)
+                && descendant != colorChooserButton) {
+                colorChooserPopup.close();
+
+                Color color = colorChooser.getSelectedColor();
+                colorChooserButton.setSelectedColor(color);
+            }
+
+            return false;
+        }
+
+        @Override
+        public boolean mouseWheel(Container container, Mouse.ScrollType scrollType,
+            int scrollAmount, int wheelRotation, int x, int y) {
+            return true;
+        }
+    };
+
+    protected ColorChooser colorChooser;
+    protected ColorChooserPopup colorChooserPopup;
+    protected boolean pressed = false;
+
+    public ColorChooserButtonSkin() {
+        colorChooser = new ColorChooser();
+
+        colorChooserPopup = new ColorChooserPopup();
+        colorChooserPopup.getComponentKeyListeners().add(colorChooserPopupKeyListener);
+        colorChooserPopup.getWindowStateListeners().add(colorChooserPopupWindowStateListener);
+    }
+
+    @Override
+    public void install(Component component) {
+        super.install(component);
+
+        ColorChooserButton colorChooserButton = (ColorChooserButton)component;
+        colorChooserButton.getColorChooserButtonListeners().add(this);
+        colorChooserButton.getColorChooserButtonSelectionListeners().add(this);
+    }
+
+    // ComponentStateListener methods
+
+    @Override
+    public void enabledChanged(Component component) {
+        super.enabledChanged(component);
+
+        colorChooserPopup.close();
+        pressed = false;
+    }
+
+    @Override
+    public void focusedChanged(Component component, Component obverseComponent) {
+        super.focusedChanged(component, obverseComponent);
+
+        // Close the popup if focus was transferred to a component whose
+        // window is not the popup
+        if (!component.isFocused()
+            && !colorChooserPopup.containsFocus()) {
+            colorChooserPopup.close();
+        }
+
+        pressed = false;
+    }
+
+    // ComponentMouseListener methods
+
+    @Override
+    public void mouseOut(Component component) {
+        super.mouseOut(component);
+
+        pressed = false;
+    }
+
+    // ComponentMouseButtonListener methods
+
+    @Override
+    public boolean mouseDown(Component component, Mouse.Button button, int x, int y) {
+        boolean consumed = super.mouseDown(component, button, x, y);
+
+        pressed = true;
+        repaintComponent();
+
+        return consumed;
+    }
+
+    @Override
+    public boolean mouseUp(Component component, Mouse.Button button, int x, int y) {
+        boolean consumed = super.mouseUp(component, button, x, y);
+
+        pressed = false;
+        repaintComponent();
+
+        return consumed;
+    }
+
+    @Override
+    public boolean mouseClick(Component component, Mouse.Button button, int x, int y, int count) {
+        boolean consumed = super.mouseClick(component, button, x, y, count);
+
+        ColorChooserButton colorChooserButton = (ColorChooserButton)getComponent();
+
+        colorChooserButton.requestFocus();
+        colorChooserButton.press();
+
+        return consumed;
+    }
+
+    // ComponentKeyListener methods
+
+    @Override
+    public boolean keyPressed(Component component, int keyCode, Keyboard.KeyLocation keyLocation) {
+        boolean consumed = false;
+
+        if (keyCode == Keyboard.KeyCode.SPACE) {
+            pressed = true;
+            repaintComponent();
+            consumed = true;
+        } else {
+            consumed = super.keyPressed(component, keyCode, keyLocation);
+        }
+
+        return consumed;
+    }
+
+    @Override
+    public boolean keyReleased(Component component, int keyCode, Keyboard.KeyLocation keyLocation) {
+        boolean consumed = false;
+
+        ColorChooserButton colorChooserButton = (ColorChooserButton)getComponent();
+
+        if (keyCode == Keyboard.KeyCode.SPACE) {
+            pressed = false;
+            repaintComponent();
+
+            colorChooserButton.press();
+        } else {
+            consumed = super.keyReleased(component, keyCode, keyLocation);
+        }
+
+        return consumed;
+    }
+
+    // ColorChooserButtonListener methods
+
+    @Override
+    public void selectedColorKeyChanged(ColorChooserButton colorChooserButton,
+        String previousSelectedColorKey) {
+        // No-op
+    }
+
+    // ColorChooserButtonSelectionListener methods
+
+    @Override
+    public void selectedColorChanged(ColorChooserButton colorChooserButton,
+        Color previousSelectedColor) {
+        // Set the selected color as the button data
+        Color selectedColor = colorChooserButton.getSelectedColor();
+
+        colorChooserButton.setButtonData(selectedColor);
+        colorChooser.setSelectedColor(selectedColor);
+    }
+}

Added: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraColorChooserButtonSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraColorChooserButtonSkin.java?rev=831420&view=auto
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraColorChooserButtonSkin.java (added)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraColorChooserButtonSkin.java Fri Oct 30 18:45:24 2009
@@ -0,0 +1,481 @@
+/*
+ * 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.skin.terra;
+
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.GradientPaint;
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+import java.awt.geom.GeneralPath;
+import java.awt.geom.Rectangle2D;
+
+import org.apache.pivot.collections.Dictionary;
+import org.apache.pivot.wtk.Border;
+import org.apache.pivot.wtk.Bounds;
+import org.apache.pivot.wtk.Button;
+import org.apache.pivot.wtk.Dimensions;
+import org.apache.pivot.wtk.Display;
+import org.apache.pivot.wtk.GraphicsUtilities;
+import org.apache.pivot.wtk.Insets;
+import org.apache.pivot.wtk.ColorChooserButton;
+import org.apache.pivot.wtk.Point;
+import org.apache.pivot.wtk.Theme;
+import org.apache.pivot.wtk.effects.DropShadowDecorator;
+import org.apache.pivot.wtk.skin.ColorChooserButtonSkin;
+
+/**
+ * Terra color chooser button skin.
+ */
+public class TerraColorChooserButtonSkin extends ColorChooserButtonSkin {
+    private Border colorChooserBorder;
+
+    private Font font;
+    private Color color;
+    private Color disabledColor;
+    private Color backgroundColor;
+    private Color disabledBackgroundColor;
+    private Color borderColor;
+    private Color disabledBorderColor;
+    private Insets padding;
+
+    // Derived colors
+    private Color bevelColor;
+    private Color pressedBevelColor;
+    private Color disabledBevelColor;
+
+    private DropShadowDecorator dropShadowDecorator = null;
+
+    private static final int TRIGGER_WIDTH = 14;
+
+    public TerraColorChooserButtonSkin() {
+        TerraTheme theme = (TerraTheme)Theme.getTheme();
+
+        font = theme.getFont();
+        color = theme.getColor(1);
+        disabledColor = theme.getColor(7);
+        backgroundColor = theme.getColor(10);
+        disabledBackgroundColor = theme.getColor(10);
+        borderColor = theme.getColor(7);
+        disabledBorderColor = theme.getColor(7);
+        padding = new Insets(2, 3, 2, 3);
+
+        // Set the derived colors
+        bevelColor = TerraTheme.brighten(backgroundColor);
+        pressedBevelColor = TerraTheme.darken(backgroundColor);
+        disabledBevelColor = disabledBackgroundColor;
+
+        // Create the border
+        colorChooserBorder = new Border(colorChooser);
+        colorChooserBorder.getStyles().put("color", borderColor);
+
+        // Set the popup content
+        colorChooserPopup.setContent(colorChooserBorder);
+
+        // Attach the drop-shadow decorator
+        dropShadowDecorator = new DropShadowDecorator(3, 3, 3);
+        colorChooserPopup.getDecorators().add(dropShadowDecorator);
+    }
+
+    @Override
+    public int getPreferredWidth(int height) {
+        ColorChooserButton colorChooserButton = (ColorChooserButton)getComponent();
+        Button.DataRenderer dataRenderer = colorChooserButton.getDataRenderer();
+
+        dataRenderer.render(colorChooserButton.getButtonData(), colorChooserButton, false);
+
+        int preferredWidth = dataRenderer.getPreferredWidth(-1) + TRIGGER_WIDTH + padding.left
+            + padding.right + 2;
+
+        return preferredWidth;
+    }
+
+    @Override
+    public int getPreferredHeight(int width) {
+        ColorChooserButton colorChooserButton = (ColorChooserButton)getComponent();
+        Button.DataRenderer dataRenderer = colorChooserButton.getDataRenderer();
+
+        dataRenderer.render(colorChooserButton.getButtonData(), colorChooserButton, false);
+
+        int preferredHeight = dataRenderer.getPreferredHeight(-1)
+            + padding.top + padding.bottom + 2;
+
+        return preferredHeight;
+    }
+
+    @Override
+    public int getBaseline(int width) {
+        ColorChooserButton colorChooserButton = (ColorChooserButton)getComponent();
+        Button.DataRenderer dataRenderer = colorChooserButton.getDataRenderer();
+
+        dataRenderer.render(colorChooserButton.getButtonData(), colorChooserButton, false);
+
+        int baseline = dataRenderer.getBaseline(width) + padding.top + 1;
+
+        return baseline;
+    }
+
+    @Override
+    public void layout() {
+        // No-op
+    }
+
+    @Override
+    public void paint(Graphics2D graphics) {
+        ColorChooserButton colorChooserButton = (ColorChooserButton)getComponent();
+
+        int width = getWidth();
+        int height = getHeight();
+
+        Color backgroundColor = null;
+        Color bevelColor = null;
+        Color borderColor = null;
+
+        if (colorChooserButton.isEnabled()) {
+            backgroundColor = this.backgroundColor;
+            bevelColor = (pressed || colorChooserPopup.isOpen())
+                ? pressedBevelColor : this.bevelColor;
+            borderColor = this.borderColor;
+        } else {
+            backgroundColor = disabledBackgroundColor;
+            bevelColor = disabledBevelColor;
+            borderColor = disabledBorderColor;
+        }
+
+        graphics.setStroke(new BasicStroke());
+
+        // Paint the background
+        graphics.setPaint(new GradientPaint(width / 2, 0, bevelColor,
+            width / 2, height / 2, backgroundColor));
+        graphics.fillRect(0, 0, width, height);
+
+        // Paint the border
+        graphics.setPaint(borderColor);
+
+        Bounds contentBounds = new Bounds(0, 0,
+            Math.max(width - TRIGGER_WIDTH - 1, 0), Math.max(height - 1, 0));
+        GraphicsUtilities.drawRect(graphics, contentBounds.x, contentBounds.y,
+            contentBounds.width + 1, contentBounds.height + 1);
+
+        Bounds triggerBounds = new Bounds(Math.max(width - TRIGGER_WIDTH - 1, 0), 0,
+            TRIGGER_WIDTH, Math.max(height - 1, 0));
+        GraphicsUtilities.drawRect(graphics, triggerBounds.x, triggerBounds.y,
+            triggerBounds.width + 1, triggerBounds.height + 1);
+
+        // Paint the content
+        Button.DataRenderer dataRenderer = colorChooserButton.getDataRenderer();
+        dataRenderer.render(colorChooserButton.getButtonData(), colorChooserButton, false);
+        dataRenderer.setSize(Math.max(contentBounds.width - (padding.left + padding.right + 2) + 1, 0),
+            Math.max(contentBounds.height - (padding.top + padding.bottom + 2) + 1, 0));
+
+        Graphics2D contentGraphics = (Graphics2D)graphics.create();
+        contentGraphics.translate(padding.left + 1, padding.top + 1);
+        contentGraphics.clipRect(0, 0, dataRenderer.getWidth(), dataRenderer.getHeight());
+        dataRenderer.paint(contentGraphics);
+        contentGraphics.dispose();
+
+        // Paint the focus state
+        if (colorChooserButton.isFocused()) {
+            BasicStroke dashStroke = new BasicStroke(1.0f, BasicStroke.CAP_ROUND,
+                BasicStroke.JOIN_ROUND, 1.0f, new float[] {0.0f, 2.0f}, 0.0f);
+
+            graphics.setStroke(dashStroke);
+            graphics.setColor(borderColor);
+
+            graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
+                RenderingHints.VALUE_ANTIALIAS_ON);
+
+            graphics.draw(new Rectangle2D.Double(2.5, 2.5, Math.max(contentBounds.width - 4, 0),
+                Math.max(contentBounds.height - 4, 0)));
+        }
+
+        // Paint the trigger
+        GeneralPath triggerIconShape = new GeneralPath(GeneralPath.WIND_EVEN_ODD);
+        triggerIconShape.moveTo(0, 0);
+        triggerIconShape.lineTo(3, 3);
+        triggerIconShape.lineTo(6, 0);
+        triggerIconShape.closePath();
+
+        Graphics2D triggerGraphics = (Graphics2D)graphics.create();
+        triggerGraphics.setStroke(new BasicStroke(0));
+        triggerGraphics.setPaint(color);
+
+        int tx = triggerBounds.x + Math.round((triggerBounds.width
+            - triggerIconShape.getBounds().width) / 2f);
+        int ty = triggerBounds.y + Math.round((triggerBounds.height
+            - triggerIconShape.getBounds().height) / 2f);
+        triggerGraphics.translate(tx, ty);
+
+        triggerGraphics.draw(triggerIconShape);
+        triggerGraphics.fill(triggerIconShape);
+
+        triggerGraphics.dispose();
+    }
+
+    public Font getFont() {
+        return font;
+    }
+
+    public void setFont(Font font) {
+        if (font == null) {
+            throw new IllegalArgumentException("font is null.");
+        }
+
+        this.font = font;
+        invalidateComponent();
+    }
+
+    public final void setFont(String font) {
+        if (font == null) {
+            throw new IllegalArgumentException("font is null.");
+        }
+
+        setFont(decodeFont(font));
+    }
+
+    public final void setFont(Dictionary<String, ?> font) {
+        if (font == null) {
+            throw new IllegalArgumentException("font is null.");
+        }
+
+        setFont(Theme.deriveFont(font));
+    }
+
+    public Color getColor() {
+        return color;
+    }
+
+    public void setColor(Color color) {
+        if (color == null) {
+            throw new IllegalArgumentException("color is null.");
+        }
+
+        this.color = color;
+        repaintComponent();
+    }
+
+    public final void setColor(String color) {
+        if (color == null) {
+            throw new IllegalArgumentException("color is null.");
+        }
+
+        setColor(GraphicsUtilities.decodeColor(color));
+    }
+
+    public Color getDisabledColor() {
+        return disabledColor;
+    }
+
+    public void setDisabledColor(Color disabledColor) {
+        if (disabledColor == null) {
+            throw new IllegalArgumentException("disabledColor is null.");
+        }
+
+        this.disabledColor = disabledColor;
+        repaintComponent();
+    }
+
+    public final void setDisabledColor(String disabledColor) {
+        if (disabledColor == null) {
+            throw new IllegalArgumentException("disabledColor is null.");
+        }
+
+        setDisabledColor(GraphicsUtilities.decodeColor(disabledColor));
+    }
+
+    public Color getBackgroundColor() {
+        return backgroundColor;
+    }
+
+    public void setBackgroundColor(Color backgroundColor) {
+        if (backgroundColor == null) {
+            throw new IllegalArgumentException("backgroundColor is null.");
+        }
+
+        this.backgroundColor = backgroundColor;
+        bevelColor = TerraTheme.brighten(backgroundColor);
+        pressedBevelColor = TerraTheme.darken(backgroundColor);
+        repaintComponent();
+    }
+
+    public final void setBackgroundColor(String backgroundColor) {
+        if (backgroundColor == null) {
+            throw new IllegalArgumentException("backgroundColor is null.");
+        }
+
+        setBackgroundColor(GraphicsUtilities.decodeColor(backgroundColor));
+    }
+
+    public Color getDisabledBackgroundColor() {
+        return disabledBackgroundColor;
+    }
+
+    public void setDisabledBackgroundColor(Color disabledBackgroundColor) {
+        if (disabledBackgroundColor == null) {
+            throw new IllegalArgumentException("disabledBackgroundColor is null.");
+        }
+
+        this.disabledBackgroundColor = disabledBackgroundColor;
+        disabledBevelColor = disabledBackgroundColor;
+        repaintComponent();
+    }
+
+    public final void setDisabledBackgroundColor(String disabledBackgroundColor) {
+        if (disabledBackgroundColor == null) {
+            throw new IllegalArgumentException("disabledBackgroundColor is null.");
+        }
+
+        setDisabledBackgroundColor(GraphicsUtilities.decodeColor(disabledBackgroundColor));
+    }
+
+    public Color getBorderColor() {
+        return borderColor;
+    }
+
+    public void setBorderColor(Color borderColor) {
+        if (borderColor == null) {
+            throw new IllegalArgumentException("borderColor is null.");
+        }
+
+        this.borderColor = borderColor;
+        colorChooserBorder.getStyles().put("color", borderColor);
+        repaintComponent();
+    }
+
+    public final void setBorderColor(String borderColor) {
+        if (borderColor == null) {
+            throw new IllegalArgumentException("borderColor is null.");
+        }
+
+        setBorderColor(GraphicsUtilities.decodeColor(borderColor));
+    }
+
+    public Color getDisabledBorderColor() {
+        return disabledBorderColor;
+    }
+
+    public void setDisabledBorderColor(Color disabledBorderColor) {
+        if (disabledBorderColor == null) {
+            throw new IllegalArgumentException("disabledBorderColor is null.");
+        }
+
+        this.disabledBorderColor = disabledBorderColor;
+        repaintComponent();
+    }
+
+    public final void setDisabledBorderColor(String disabledBorderColor) {
+        if (disabledBorderColor == null) {
+            throw new IllegalArgumentException("disabledBorderColor is null.");
+        }
+
+        setDisabledBorderColor(GraphicsUtilities.decodeColor(disabledBorderColor));
+    }
+
+    public Insets getPadding() {
+        return padding;
+    }
+
+    public void setPadding(Insets padding) {
+        if (padding == null) {
+            throw new IllegalArgumentException("padding is null.");
+        }
+
+        this.padding = padding;
+        invalidateComponent();
+    }
+
+    public final void setPadding(Dictionary<String, ?> padding) {
+        if (padding == null) {
+            throw new IllegalArgumentException("padding is null.");
+        }
+
+        setPadding(new Insets(padding));
+    }
+
+    public final void setPadding(int padding) {
+        setPadding(new Insets(padding));
+    }
+
+    public final void setPadding(Number padding) {
+        if (padding == null) {
+            throw new IllegalArgumentException("padding is null.");
+        }
+
+        setPadding(padding.intValue());
+    }
+
+    public final void setPadding(String padding) {
+        if (padding == null) {
+            throw new IllegalArgumentException("padding is null.");
+        }
+
+        setPadding(Insets.decode(padding));
+    }
+
+    // ButtonPressListener methods
+
+    @Override
+    public void buttonPressed(Button button) {
+        ColorChooserButton colorChooserButton = (ColorChooserButton)button;
+
+        if (colorChooserPopup.isOpen()) {
+            colorChooserPopup.close();
+
+            Color color = colorChooser.getSelectedColor();
+            colorChooserButton.setSelectedColor(color);
+        } else {
+                // Determine the popup's location and preferred size, relative
+                // to the button
+                Display display = colorChooserButton.getDisplay();
+
+                if (display != null) {
+                    int width = getWidth();
+                    int height = getHeight();
+
+                    // Ensure that the popup remains within the bounds of the display
+                    Point buttonLocation = colorChooserButton.mapPointToAncestor(display, 0, 0);
+
+                    Dimensions displaySize = display.getSize();
+
+                    colorChooserPopup.setPreferredSize(-1, -1);
+                    Dimensions popupSize = colorChooserPopup.getPreferredSize();
+                    int popupWidth = Math.max(popupSize.width,
+                        colorChooserButton.getWidth() - TRIGGER_WIDTH - 1);
+                    int popupHeight = popupSize.height;
+
+                    int x = buttonLocation.x;
+                    if (popupWidth > width
+                        && x + popupWidth > displaySize.width) {
+                        x = buttonLocation.x + width - popupWidth;
+                    }
+
+                    int y = buttonLocation.y + height - 1;
+                    if (y + popupSize.height > displaySize.height) {
+                        y = buttonLocation.y - popupSize.height + 1;
+                    }
+
+                    colorChooser.setSelectedColor(colorChooserButton.getSelectedColor());
+
+                    colorChooserPopup.setLocation(x, y);
+                    colorChooserPopup.setPreferredSize(popupWidth, popupHeight);
+                    colorChooserPopup.open(colorChooserButton.getWindow());
+                    colorChooserPopup.requestFocus();
+            }
+        }
+    }
+}

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraColorChooserSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraColorChooserSkin.java?rev=831420&r1=831419&r2=831420&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraColorChooserSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraColorChooserSkin.java Fri Oct 30 18:45:24 2009
@@ -19,13 +19,11 @@
 import java.awt.Color;
 import java.awt.Graphics2D;
 
-import org.apache.pivot.wtk.Border;
 import org.apache.pivot.wtk.ColorChooser;
 import org.apache.pivot.wtk.Component;
 import org.apache.pivot.wtk.Dimensions;
 import org.apache.pivot.wtk.Mouse;
 import org.apache.pivot.wtk.TablePane;
-import org.apache.pivot.wtk.Theme;
 import org.apache.pivot.wtk.skin.ColorChooserSkin;
 import org.apache.pivot.wtk.skin.ComponentSkin;
 
@@ -134,7 +132,14 @@
             float saturation = saturationValueChooser.getSaturation();
             float value = saturationValueChooser.getValue();
 
-            colorChooser.setSelectedColor(Color.getHSBColor(hue, saturation, value));
+            hueChooser.setHue(hue);
+
+            updating = true;
+            try {
+                colorChooser.setSelectedColor(Color.getHSBColor(hue, saturation, value));
+            } finally {
+                updating = false;
+            }
         }
     }
 
@@ -255,35 +260,34 @@
             float saturation = 1f - (Math.min(Math.max(y, 0), height - 1) / (float)height);
             float value = Math.min(Math.max(x, 0), width - 1) / (float)width;
 
-            colorChooser.setSelectedColor(Color.getHSBColor(hue, saturation, value));
+            saturationValueChooser.setSaturation(saturation);
+            saturationValueChooser.setValue(value);
+
+            updating = true;
+            try {
+                colorChooser.setSelectedColor(Color.getHSBColor(hue, saturation, value));
+            } finally {
+                updating = false;
+            }
         }
     }
 
     private TablePane tablePane = new TablePane();
-    private Border hueBorder = new Border();
-    private Border saturationValueBorder = new Border();
-
     private SaturationValueChooser saturationValueChooser = new SaturationValueChooser();
     private HueChooser hueChooser = new HueChooser();
 
-    public TerraColorChooserSkin() {
-        TerraTheme theme = (TerraTheme)Theme.getTheme();
+    private boolean updating = false;
 
-        tablePane.getStyles().put("horizontalSpacing", 4);
+    public TerraColorChooserSkin() {
+        tablePane.getStyles().put("horizontalSpacing", 6);
         tablePane.getColumns().add(new TablePane.Column(31, true));
         tablePane.getColumns().add(new TablePane.Column(4, true));
 
         TablePane.Row row = new TablePane.Row(1, true);
         tablePane.getRows().add(row);
 
-        row.add(saturationValueBorder);
-        row.add(hueBorder);
-
-        hueBorder.getStyles().put("color", theme.getColor(9));
-        saturationValueBorder.getStyles().put("color", theme.getColor(9));
-
-        hueBorder.setContent(hueChooser);
-        saturationValueBorder.setContent(saturationValueChooser);
+        row.add(saturationValueChooser);
+        row.add(hueChooser);
     }
 
     @Override
@@ -317,28 +321,6 @@
         tablePane.setLocation(0, 0);
     }
 
-    public Color getBorderColor() {
-        return (Color)hueBorder.getStyles().get("color");
-    }
-
-    public void setBorderColor(Color borderColor) {
-        if (borderColor == null) {
-            throw new IllegalArgumentException("borderColor is null.");
-        }
-
-        hueBorder.getStyles().put("color", borderColor);
-        saturationValueBorder.getStyles().put("color", borderColor);
-    }
-
-    public final void setBorderColor(String borderColor) {
-        if (borderColor == null) {
-            throw new IllegalArgumentException("borderColor is null.");
-        }
-
-        hueBorder.getStyles().put("color", borderColor);
-        saturationValueBorder.getStyles().put("color", borderColor);
-    }
-
     public int getSpacing() {
         return (Integer)tablePane.getStyles().get("horizontalSpacing");
     }
@@ -361,22 +343,25 @@
 
     @Override
     public void selectedColorChanged(ColorChooser colorChooser, Color previousSelectedColor) {
-        Color color = colorChooser.getSelectedColor();
+        if (!updating) {
+            Color color = colorChooser.getSelectedColor();
 
-        float hue = 0f;
-        float saturation = 0f;
-        float value = 0f;
-
-        if (color != null) {
-            float[] hsb = Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), null);
-            hue = hsb[0];
-            saturation = hsb[1];
-            value = hsb[2];
-        }
-
-        hueChooser.setHue(hue);
-        saturationValueChooser.setSaturation(saturation);
-        saturationValueChooser.setValue(value);
+            float hue = 0f;
+            float saturation = 0f;
+            float value = 0f;
+
+            if (color != null) {
+                float[] hsb = Color.RGBtoHSB(color.getRed(), color.getGreen(),
+                    color.getBlue(), null);
+                hue = hsb[0];
+                saturation = hsb[1];
+                value = hsb[2];
+            }
+
+            hueChooser.setHue(hue);
+            saturationValueChooser.setSaturation(saturation);
+            saturationValueChooser.setValue(value);
+        }
 
         repaintComponent();
     }

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTheme.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTheme.java?rev=831420&r1=831419&r2=831420&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTheme.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTheme.java Fri Oct 30 18:45:24 2009
@@ -37,6 +37,7 @@
 import org.apache.pivot.wtk.CalendarButton;
 import org.apache.pivot.wtk.Checkbox;
 import org.apache.pivot.wtk.ColorChooser;
+import org.apache.pivot.wtk.ColorChooserButton;
 import org.apache.pivot.wtk.Dialog;
 import org.apache.pivot.wtk.Expander;
 import org.apache.pivot.wtk.BoxPane;
@@ -96,6 +97,7 @@
         componentSkinMap.put(Calendar.class, TerraCalendarSkin.class);
         componentSkinMap.put(CalendarButton.class, TerraCalendarButtonSkin.class);
         componentSkinMap.put(ColorChooser.class, TerraColorChooserSkin.class);
+        componentSkinMap.put(ColorChooserButton.class, TerraColorChooserButtonSkin.class);
         componentSkinMap.put(Dialog.class, TerraDialogSkin.class);
         componentSkinMap.put(Expander.class, TerraExpanderSkin.class);
         componentSkinMap.put(FileBrowser.class, TerraFileBrowserSkin.class);