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/28 18:11:32 UTC

svn commit: r830675 [1/2] - in /incubator/pivot/trunk/tools/src/org/apache/pivot/tools/wtk: ComponentInspectorSkin.java ComponentPropertyInspectorSkin.java ComponentStyleInspectorSkin.java

Author: tvolkert
Date: Wed Oct 28 17:11:32 2009
New Revision: 830675

URL: http://svn.apache.org/viewvc?rev=830675&view=rev
Log:
Refactored common code in ComponentStyleInspectorSkin and ComponentPropertyInspectorSkin into abstract base ComponentInspectorSkin

Added:
    incubator/pivot/trunk/tools/src/org/apache/pivot/tools/wtk/ComponentInspectorSkin.java
Modified:
    incubator/pivot/trunk/tools/src/org/apache/pivot/tools/wtk/ComponentPropertyInspectorSkin.java
    incubator/pivot/trunk/tools/src/org/apache/pivot/tools/wtk/ComponentStyleInspectorSkin.java

Added: 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=830675&view=auto
==============================================================================
--- incubator/pivot/trunk/tools/src/org/apache/pivot/tools/wtk/ComponentInspectorSkin.java (added)
+++ incubator/pivot/trunk/tools/src/org/apache/pivot/tools/wtk/ComponentInspectorSkin.java Wed Oct 28 17:11:32 2009
@@ -0,0 +1,954 @@
+/*
+ * 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.tools.wtk;
+
+import org.apache.pivot.collections.Dictionary;
+import org.apache.pivot.collections.EnumList;
+import org.apache.pivot.collections.HashMap;
+import org.apache.pivot.wtk.BoxPane;
+import org.apache.pivot.wtk.Button;
+import org.apache.pivot.wtk.ButtonStateListener;
+import org.apache.pivot.wtk.Checkbox;
+import org.apache.pivot.wtk.Component;
+import org.apache.pivot.wtk.ComponentStateListener;
+import org.apache.pivot.wtk.CornerRadii;
+import org.apache.pivot.wtk.Dimensions;
+import org.apache.pivot.wtk.FlowPane;
+import org.apache.pivot.wtk.Form;
+import org.apache.pivot.wtk.Insets;
+import org.apache.pivot.wtk.Label;
+import org.apache.pivot.wtk.Limits;
+import org.apache.pivot.wtk.ListButton;
+import org.apache.pivot.wtk.ListButtonSelectionListener;
+import org.apache.pivot.wtk.Orientation;
+import org.apache.pivot.wtk.Point;
+import org.apache.pivot.wtk.TextInput;
+import org.apache.pivot.wtk.skin.ContainerSkin;
+import org.apache.pivot.wtk.text.validation.IntValidator;
+import org.apache.pivot.wtk.text.validation.FloatValidator;
+
+abstract class ComponentInspectorSkin extends ContainerSkin implements ComponentInspectorListener {
+    // Container for the control components
+    protected Form form = new Form();
+
+    // Maps key to corresponding control component
+    private HashMap<String, Component> controls = new HashMap<String, Component>();
+
+    public ComponentInspectorSkin() {
+        form.getStyles().put("rightAlignLabels", true);
+    }
+
+    @Override
+    public void install(Component component) {
+        super.install(component);
+
+        ComponentInspector componentInspector = (ComponentInspector)component;
+
+        componentInspector.getComponentInspectorListeners().add(this);
+        componentInspector.add(form);
+
+        sourceChanged(componentInspector, null);
+    }
+
+    @Override
+    public int getPreferredWidth(int height) {
+        return form.getPreferredWidth(height);
+    }
+
+    @Override
+    public int getPreferredHeight(int width) {
+        return form.getPreferredHeight(width);
+    }
+
+    @Override
+    public Dimensions getPreferredSize() {
+        return form.getPreferredSize();
+    }
+
+    @Override
+    public void layout() {
+        form.setLocation(0, 0);
+        form.setSize(getWidth(), getHeight());
+    }
+
+    @Override
+    public void sourceChanged(ComponentInspector componentInspector, Component previousSource) {
+        // No-op
+    }
+
+    /**
+     * Adds a new control component to the specified form section. The component
+     * will control the specified property.
+     *
+     * @param dictionary
+     * The property dictionary
+     *
+     * @param key
+     * The property key
+     *
+     * @param type
+     * The type of the property
+     *
+     * @param section
+     * The form section
+     *
+     * @throws IllegalArgumentException
+     * If the form section does not belong to this skin's form
+     */
+    @SuppressWarnings("unchecked")
+    protected void addControl(Dictionary<String, Object> dictionary, String key,
+        Class<?> type, Form.Section section) {
+        if (section.getForm() != form) {
+            throw new IllegalArgumentException("section does not belong to form.");
+        }
+
+        Component control = null;
+
+        if (type == Boolean.TYPE) {
+            control = addBooleanControl(dictionary, key, section);
+        } else if (type == Integer.TYPE) {
+            control = addIntControl(dictionary, key, section);
+        } else if (type == Float.TYPE) {
+            control = addFloatControl(dictionary, key, section);
+        } else if (type == String.class) {
+            control = addStringControl(dictionary, key, section);
+        } else if (type.isEnum()) {
+            control = addEnumControl(dictionary, key, (Class<? extends Enum<?>>)type, section);
+        } else if (type == Point.class) {
+            control = addPointControl(dictionary, key, section);
+        } else if (type == Dimensions.class) {
+            control = addDimensionsControl(dictionary, key, section);
+        } else if (type == Limits.class) {
+            control = addLimitsControl(dictionary, key, section);
+        } else if (type == Insets.class) {
+            control = addInsetsControl(dictionary, key, section);
+        } else if (type == CornerRadii.class) {
+            control = addCornerRadiiControl(dictionary, key, section);
+        }
+
+        if (control != null) {
+            controls.put(key, control);
+        }
+    }
+
+    /**
+     * Removes all control components from this skin's form.
+     */
+    protected void clearControls() {
+        for (Form.Section section : form.getSections()) {
+            section.remove(0, section.getLength());
+        }
+
+        controls.clear();
+    }
+
+    /**
+     * Updates the control component associated with the specified property to
+     * the appropriate state based on the property value.
+     *
+     * @param dictionary
+     * The property dictionary
+     *
+     * @param key
+     * The property key
+     *
+     * @param type
+     * The type of the property
+     */
+    protected void updateControl(Dictionary<String, Object> dictionary, String key, Class<?> type) {
+        if (type == Boolean.TYPE) {
+            updateBooleanControl(dictionary, key);
+        } else if (type == Integer.TYPE) {
+            updateIntControl(dictionary, key);
+        } else if (type == Float.TYPE) {
+            updateFloatControl(dictionary, key);
+        } else if (type == String.class) {
+            updateStringControl(dictionary, key);
+        } else if (type.isEnum()) {
+            updateEnumControl(dictionary, key);
+        } else if (type == Point.class) {
+            updatePointControl(dictionary, key);
+        } else if (type == Dimensions.class) {
+            updateDimensionsControl(dictionary, key);
+        } else if (type == Limits.class) {
+            updateLimitsControl(dictionary, key);
+        }
+    }
+
+    private Component addBooleanControl(final Dictionary<String, Object> dictionary,
+        final String key, Form.Section section) {
+        boolean value = (Boolean)dictionary.get(key);
+
+        Checkbox checkbox = new Checkbox();
+        checkbox.setSelected(value);
+        section.add(checkbox);
+        Form.setLabel(checkbox, key);
+
+        checkbox.getButtonStateListeners().add(new ButtonStateListener() {
+            private boolean updating = false;
+
+            @Override
+            public void stateChanged(Button button, Button.State previousState) {
+                if (!updating) {
+                    updating = true;
+                    try {
+                        dictionary.put(key, button.isSelected());
+                    } catch (Exception exception) {
+                        button.setState(previousState);
+                    } finally {
+                        updating = false;
+                    }
+                }
+            }
+        });
+
+        return checkbox;
+    }
+
+    private void updateBooleanControl(Dictionary<String, Object> dictionary, String key) {
+        Checkbox checkbox = (Checkbox)controls.get(key);
+
+        if (checkbox != null) {
+            boolean value = (Boolean)dictionary.get(key);
+            checkbox.setSelected(value);
+        }
+    }
+
+    private Component addIntControl(final Dictionary<String, Object> dictionary,
+        final String key, Form.Section section) {
+        int value = (Integer)dictionary.get(key);
+
+        TextInput textInput = new TextInput();
+        textInput.setTextSize(10);
+        textInput.setMaximumLength(10);
+        textInput.setValidator(new IntValidator());
+        textInput.setText(String.valueOf(value));
+        section.add(textInput);
+        Form.setLabel(textInput, key);
+
+        textInput.getComponentStateListeners().add(new ComponentStateListener.Adapter() {
+            @Override
+            public void focusedChanged(Component component, Component obverseComponent) {
+                if (!component.isFocused()) {
+                    TextInput textInput = (TextInput)component;
+
+                    try {
+                        dictionary.put(key, Integer.parseInt(textInput.getText()));
+                    } catch (Exception exception) {
+                        int value = (Integer)dictionary.get(key);
+                        textInput.setText(String.valueOf(value));
+                    }
+                }
+            }
+        });
+
+        return textInput;
+    }
+
+    private void updateIntControl(Dictionary<String, Object> dictionary, String key) {
+        TextInput textInput = (TextInput)controls.get(key);
+
+        if (textInput != null) {
+            int value = (Integer)dictionary.get(key);
+            textInput.setText(String.valueOf(value));
+        }
+    }
+
+    private Component addFloatControl(final Dictionary<String, Object> dictionary,
+        final String key, Form.Section section) {
+        float value = (Float)dictionary.get(key);
+
+        TextInput textInput = new TextInput();
+        textInput.setTextSize(10);
+        textInput.setValidator(new FloatValidator());
+        textInput.setText(String.valueOf(value));
+        section.add(textInput);
+        Form.setLabel(textInput, key);
+
+        textInput.getComponentStateListeners().add(new ComponentStateListener.Adapter() {
+            @Override
+            public void focusedChanged(Component component, Component obverseComponent) {
+                if (!component.isFocused()) {
+                    TextInput textInput = (TextInput)component;
+
+                    try {
+                        dictionary.put(key, Float.parseFloat(textInput.getText()));
+                    } catch (Exception exception) {
+                        float value = (Float)dictionary.get(key);
+                        textInput.setText(String.valueOf(value));
+                    }
+                }
+            }
+        });
+
+        return textInput;
+    }
+
+    private void updateFloatControl(Dictionary<String, Object> dictionary, String key) {
+        TextInput textInput = (TextInput)controls.get(key);
+
+        if (textInput != null) {
+            float value = (Float)dictionary.get(key);
+            textInput.setText(String.valueOf(value));
+        }
+    }
+
+    private Component addStringControl(final Dictionary<String, Object> dictionary,
+        final String key, Form.Section section) {
+        String value = (String)dictionary.get(key);
+
+        TextInput textInput = new TextInput();
+        textInput.setText(value == null ? "" : value);
+        section.add(textInput);
+        Form.setLabel(textInput, key);
+
+        textInput.getComponentStateListeners().add(new ComponentStateListener.Adapter() {
+            @Override
+            public void focusedChanged(Component component, Component obverseComponent) {
+                if (!component.isFocused()) {
+                    TextInput textInput = (TextInput)component;
+
+                    try {
+                        dictionary.put(key, textInput.getText());
+                    } catch (Exception exception) {
+                        String value = (String)dictionary.get(key);
+                        textInput.setText(value == null ? "" : value);
+                    }
+                }
+            }
+        });
+
+        return textInput;
+    }
+
+    private void updateStringControl(Dictionary<String, Object> dictionary, String key) {
+        TextInput textInput = (TextInput)controls.get(key);
+
+        if (textInput != null) {
+            String value = (String)dictionary.get(key);
+            textInput.setText(value == null ? "" : value);
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    private Component addEnumControl(final Dictionary<String, Object> dictionary,
+        final String key, Class<? extends Enum<?>> type, Form.Section section) {
+        Enum<?> value = (Enum<?>)dictionary.get(key);
+
+        ListButton listButton = new ListButton();
+        listButton.setListData(new EnumList(type));
+        listButton.setSelectedItem(value);
+        section.add(listButton);
+        Form.setLabel(listButton, key);
+
+        listButton.getListButtonSelectionListeners().add(new ListButtonSelectionListener() {
+            private boolean updating = false;
+
+            @Override
+            public void selectedIndexChanged(ListButton listButton, int previousSelectedIndex) {
+                if (!updating) {
+                    updating = true;
+                    try {
+                        dictionary.put(key, listButton.getSelectedItem());
+                    } catch (Exception exception) {
+                        listButton.setSelectedIndex(previousSelectedIndex);
+                    } finally {
+                        updating = false;
+                    }
+                }
+            }
+        });
+
+        return listButton;
+    }
+
+    private void updateEnumControl(Dictionary<String, Object> dictionary, String key) {
+        ListButton listButton = (ListButton)controls.get(key);
+
+        if (listButton != null) {
+            Enum<?> value = (Enum<?>)dictionary.get(key);
+            listButton.setSelectedItem(value);
+        }
+    }
+
+    private Component addPointControl(final Dictionary<String, Object> dictionary,
+        final String key, Form.Section section) {
+        Point point = (Point)dictionary.get(key);
+
+        BoxPane boxPane = new BoxPane(Orientation.VERTICAL);
+        section.add(boxPane);
+        Form.setLabel(boxPane, key);
+
+        FlowPane flowPane = new FlowPane();
+        flowPane.getStyles().put("alignToBaseline", true);
+        flowPane.getStyles().put("horizontalSpacing", 5);
+        boxPane.add(flowPane);
+
+        TextInput textInput = new TextInput();
+        textInput.setTextSize(3);
+        textInput.setMaximumLength(4);
+        textInput.setValidator(new IntValidator());
+        textInput.setText(String.valueOf(point.x));
+        flowPane.add(textInput);
+
+        textInput.getComponentStateListeners().add(new ComponentStateListener.Adapter() {
+            @Override
+            public void focusedChanged(Component component, Component obverseComponent) {
+                if (!component.isFocused()) {
+                    TextInput textInput = (TextInput)component;
+                    Point point = (Point)dictionary.get(key);
+
+                    try {
+                        int x = Integer.parseInt(textInput.getText());
+                        dictionary.put(key, new Point(x, point.y));
+                    } catch (Exception exception) {
+                        textInput.setText(String.valueOf(point.x));
+                    }
+                }
+            }
+        });
+
+        Label label = new Label("x");
+        label.getStyles().put("font", "{italic:true}");
+        flowPane.add(label);
+
+        flowPane = new FlowPane();
+        flowPane.getStyles().put("alignToBaseline", true);
+        flowPane.getStyles().put("horizontalSpacing", 5);
+        boxPane.add(flowPane);
+
+        textInput = new TextInput();
+        textInput.setTextSize(3);
+        textInput.setMaximumLength(4);
+        textInput.setValidator(new IntValidator());
+        textInput.setText(String.valueOf(point.y));
+        flowPane.add(textInput);
+
+        textInput.getComponentStateListeners().add(new ComponentStateListener.Adapter() {
+            @Override
+            public void focusedChanged(Component component, Component obverseComponent) {
+                if (!component.isFocused()) {
+                    TextInput textInput = (TextInput)component;
+                    Point point = (Point)dictionary.get(key);
+
+                    try {
+                        int y = Integer.parseInt(textInput.getText());
+                        dictionary.put(key, new Point(point.x, y));
+                    } catch (Exception exception) {
+                        textInput.setText(String.valueOf(point.y));
+                    }
+                }
+            }
+        });
+
+        label = new Label("y");
+        label.getStyles().put("font", "{italic:true}");
+        flowPane.add(label);
+
+        return boxPane;
+    }
+
+    private void updatePointControl(Dictionary<String, Object> dictionary, String key) {
+        BoxPane boxPane = (BoxPane)controls.get(key);
+
+        if (boxPane != null) {
+            Point point = (Point)dictionary.get(key);
+
+            TextInput xTextInput = (TextInput)((FlowPane)boxPane.get(0)).get(0);
+            TextInput yTextInput = (TextInput)((FlowPane)boxPane.get(1)).get(0);
+
+            xTextInput.setText(String.valueOf(point.x));
+            yTextInput.setText(String.valueOf(point.y));
+        }
+    }
+
+    private Component addDimensionsControl(final Dictionary<String, Object> dictionary,
+        final String key, Form.Section section) {
+        Dimensions dimensions = (Dimensions)dictionary.get(key);
+
+        BoxPane boxPane = new BoxPane(Orientation.VERTICAL);
+        section.add(boxPane);
+        Form.setLabel(boxPane, key);
+
+        FlowPane flowPane = new FlowPane();
+        flowPane.getStyles().put("alignToBaseline", true);
+        flowPane.getStyles().put("horizontalSpacing", 5);
+        boxPane.add(flowPane);
+
+        TextInput textInput = new TextInput();
+        textInput.setTextSize(3);
+        textInput.setMaximumLength(4);
+        textInput.setValidator(new IntValidator());
+        textInput.setText(String.valueOf(dimensions.width));
+        flowPane.add(textInput);
+
+        textInput.getComponentStateListeners().add(new ComponentStateListener.Adapter() {
+            @Override
+            public void focusedChanged(Component component, Component obverseComponent) {
+                if (!component.isFocused()) {
+                    TextInput textInput = (TextInput)component;
+                    Dimensions dimensions = (Dimensions)dictionary.get(key);
+
+                    try {
+                        int width = Integer.parseInt(textInput.getText());
+                        dictionary.put(key, new Dimensions(width, dimensions.height));
+                    } catch (Exception exception) {
+                        textInput.setText(String.valueOf(dimensions.width));
+                    }
+                }
+            }
+        });
+
+        Label label = new Label("width");
+        label.getStyles().put("font", "{italic:true}");
+        flowPane.add(label);
+
+        flowPane = new FlowPane();
+        flowPane.getStyles().put("alignToBaseline", true);
+        flowPane.getStyles().put("horizontalSpacing", 5);
+        boxPane.add(flowPane);
+
+        textInput = new TextInput();
+        textInput.setTextSize(3);
+        textInput.setMaximumLength(4);
+        textInput.setValidator(new IntValidator());
+        textInput.setText(String.valueOf(dimensions.height));
+        flowPane.add(textInput);
+
+        textInput.getComponentStateListeners().add(new ComponentStateListener.Adapter() {
+            @Override
+            public void focusedChanged(Component component, Component obverseComponent) {
+                if (!component.isFocused()) {
+                    TextInput textInput = (TextInput)component;
+                    Dimensions dimensions = (Dimensions)dictionary.get(key);
+
+                    try {
+                        int height = Integer.parseInt(textInput.getText());
+                        dictionary.put(key, new Dimensions(dimensions.width, height));
+                    } catch (Exception exception) {
+                        textInput.setText(String.valueOf(dimensions.height));
+                    }
+                }
+            }
+        });
+
+        label = new Label("height");
+        label.getStyles().put("font", "{italic:true}");
+        flowPane.add(label);
+
+        return boxPane;
+    }
+
+    private void updateDimensionsControl(Dictionary<String, Object> dictionary, String key) {
+        BoxPane boxPane = (BoxPane)controls.get(key);
+
+        if (boxPane != null) {
+            Dimensions dimensions = (Dimensions)dictionary.get(key);
+
+            TextInput widthTextInput = (TextInput)((FlowPane)boxPane.get(0)).get(0);
+            TextInput heightTextInput = (TextInput)((FlowPane)boxPane.get(1)).get(0);
+
+            widthTextInput.setText(String.valueOf(dimensions.width));
+            heightTextInput.setText(String.valueOf(dimensions.height));
+        }
+    }
+
+    private Component addLimitsControl(final Dictionary<String, Object> dictionary,
+        final String key, Form.Section section) {
+        Limits limits = (Limits)dictionary.get(key);
+
+        BoxPane boxPane = new BoxPane(Orientation.VERTICAL);
+        section.add(boxPane);
+        Form.setLabel(boxPane, key);
+
+        FlowPane flowPane = new FlowPane();
+        flowPane.getStyles().put("alignToBaseline", true);
+        flowPane.getStyles().put("horizontalSpacing", 5);
+        boxPane.add(flowPane);
+
+        TextInput textInput = new TextInput();
+        textInput.setTextSize(10);
+        textInput.setMaximumLength(10);
+        textInput.setValidator(new IntValidator());
+        textInput.setText(String.valueOf(limits.min));
+        flowPane.add(textInput);
+
+        textInput.getComponentStateListeners().add(new ComponentStateListener.Adapter() {
+            @Override
+            public void focusedChanged(Component component, Component obverseComponent) {
+                if (!component.isFocused()) {
+                    TextInput textInput = (TextInput)component;
+                    Limits limits = (Limits)dictionary.get(key);
+
+                    try {
+                        int min = Integer.parseInt(textInput.getText());
+                        dictionary.put(key, new Limits(min, limits.max));
+                    } catch (Exception exception) {
+                        textInput.setText(String.valueOf(limits.min));
+                    }
+                }
+            }
+        });
+
+        Label label = new Label("min");
+        label.getStyles().put("font", "{italic:true}");
+        flowPane.add(label);
+
+        flowPane = new FlowPane();
+        flowPane.getStyles().put("alignToBaseline", true);
+        flowPane.getStyles().put("horizontalSpacing", 5);
+        boxPane.add(flowPane);
+
+        textInput = new TextInput();
+        textInput.setTextSize(10);
+        textInput.setMaximumLength(10);
+        textInput.setValidator(new IntValidator());
+        textInput.setText(String.valueOf(limits.max));
+        flowPane.add(textInput);
+
+        textInput.getComponentStateListeners().add(new ComponentStateListener.Adapter() {
+            @Override
+            public void focusedChanged(Component component, Component obverseComponent) {
+                if (!component.isFocused()) {
+                    TextInput textInput = (TextInput)component;
+                    Limits limits = (Limits)dictionary.get(key);
+
+                    try {
+                        int max = Integer.parseInt(textInput.getText());
+                        dictionary.put(key, new Limits(limits.min, max));
+                    } catch (Exception exception) {
+                        textInput.setText(String.valueOf(limits.max));
+                    }
+                }
+            }
+        });
+
+        label = new Label("max");
+        label.getStyles().put("font", "{italic:true}");
+        flowPane.add(label);
+
+        return boxPane;
+    }
+
+    private void updateLimitsControl(Dictionary<String, Object> dictionary, String key) {
+        BoxPane boxPane = (BoxPane)controls.get(key);
+
+        if (boxPane != null) {
+            Limits limits = (Limits)dictionary.get(key);
+
+            TextInput minTextInput = (TextInput)((FlowPane)boxPane.get(0)).get(0);
+            TextInput maxTextInput = (TextInput)((FlowPane)boxPane.get(1)).get(0);
+
+            minTextInput.setText(String.valueOf(limits.min));
+            maxTextInput.setText(String.valueOf(limits.max));
+        }
+    }
+
+    private Component addInsetsControl(final Dictionary<String, Object> dictionary,
+        final String key, Form.Section section) {
+        Insets insets = (Insets)dictionary.get(key);
+
+        BoxPane boxPane = new BoxPane(Orientation.VERTICAL);
+        section.add(boxPane);
+        Form.setLabel(boxPane, key);
+
+        FlowPane flowPane = new FlowPane();
+        flowPane.getStyles().put("alignToBaseline", true);
+        flowPane.getStyles().put("horizontalSpacing", 5);
+        boxPane.add(flowPane);
+
+        TextInput textInput = new TextInput();
+        textInput.setTextSize(4);
+        textInput.setMaximumLength(4);
+        textInput.setValidator(new IntValidator());
+        textInput.setText(String.valueOf(insets.top));
+        flowPane.add(textInput);
+
+        textInput.getComponentStateListeners().add(new ComponentStateListener.Adapter() {
+            @Override
+            public void focusedChanged(Component component, Component obverseComponent) {
+                if (!component.isFocused()) {
+                    TextInput textInput = (TextInput)component;
+                    Insets insets = (Insets)dictionary.get(key);
+
+                    try {
+                        int top = Integer.parseInt(textInput.getText());
+                        dictionary.put(key, new Insets(top, insets.left, insets.bottom,
+                            insets.right));
+                    } catch (Exception exception) {
+                        textInput.setText(String.valueOf(insets.top));
+                    }
+                }
+            }
+        });
+
+        Label label = new Label("top");
+        label.getStyles().put("font", "{italic:true}");
+        flowPane.add(label);
+
+        flowPane = new FlowPane();
+        flowPane.getStyles().put("alignToBaseline", true);
+        flowPane.getStyles().put("horizontalSpacing", 5);
+        boxPane.add(flowPane);
+
+        textInput = new TextInput();
+        textInput.setTextSize(4);
+        textInput.setMaximumLength(4);
+        textInput.setValidator(new IntValidator());
+        textInput.setText(String.valueOf(insets.left));
+        flowPane.add(textInput);
+
+        textInput.getComponentStateListeners().add(new ComponentStateListener.Adapter() {
+            @Override
+            public void focusedChanged(Component component, Component obverseComponent) {
+                if (!component.isFocused()) {
+                    TextInput textInput = (TextInput)component;
+                    Insets insets = (Insets)dictionary.get(key);
+
+                    try {
+                        int left = Integer.parseInt(textInput.getText());
+                        dictionary.put(key, new Insets(insets.top, left, insets.bottom,
+                            insets.right));
+                    } catch (Exception exception) {
+                        textInput.setText(String.valueOf(insets.left));
+                    }
+                }
+            }
+        });
+
+        label = new Label("left");
+        label.getStyles().put("font", "{italic:true}");
+        flowPane.add(label);
+
+        flowPane = new FlowPane();
+        flowPane.getStyles().put("alignToBaseline", true);
+        flowPane.getStyles().put("horizontalSpacing", 5);
+        boxPane.add(flowPane);
+
+        textInput = new TextInput();
+        textInput.setTextSize(4);
+        textInput.setMaximumLength(4);
+        textInput.setValidator(new IntValidator());
+        textInput.setText(String.valueOf(insets.bottom));
+        flowPane.add(textInput);
+
+        textInput.getComponentStateListeners().add(new ComponentStateListener.Adapter() {
+            @Override
+            public void focusedChanged(Component component, Component obverseComponent) {
+                if (!component.isFocused()) {
+                    TextInput textInput = (TextInput)component;
+                    Insets insets = (Insets)dictionary.get(key);
+
+                    try {
+                        int bottom = Integer.parseInt(textInput.getText());
+                        dictionary.put(key, new Insets(insets.top, insets.left, bottom,
+                            insets.right));
+                    } catch (Exception exception) {
+                        textInput.setText(String.valueOf(insets.bottom));
+                    }
+                }
+            }
+        });
+
+        label = new Label("bottom");
+        label.getStyles().put("font", "{italic:true}");
+        flowPane.add(label);
+
+        flowPane = new FlowPane();
+        flowPane.getStyles().put("alignToBaseline", true);
+        flowPane.getStyles().put("horizontalSpacing", 5);
+        boxPane.add(flowPane);
+
+        textInput = new TextInput();
+        textInput.setTextSize(4);
+        textInput.setMaximumLength(4);
+        textInput.setValidator(new IntValidator());
+        textInput.setText(String.valueOf(insets.right));
+        flowPane.add(textInput);
+
+        textInput.getComponentStateListeners().add(new ComponentStateListener.Adapter() {
+            @Override
+            public void focusedChanged(Component component, Component obverseComponent) {
+                if (!component.isFocused()) {
+                    TextInput textInput = (TextInput)component;
+                    Insets insets = (Insets)dictionary.get(key);
+
+                    try {
+                        int right = Integer.parseInt(textInput.getText());
+                        dictionary.put(key, new Insets(insets.top, insets.left, insets.bottom,
+                            right));
+                    } catch (Exception exception) {
+                        textInput.setText(String.valueOf(insets.right));
+                    }
+                }
+            }
+        });
+
+        label = new Label("right");
+        label.getStyles().put("font", "{italic:true}");
+        flowPane.add(label);
+
+        return boxPane;
+    }
+
+    private Component addCornerRadiiControl(final Dictionary<String, Object> dictionary,
+        final String key, Form.Section section) {
+        CornerRadii cornerRadii = (CornerRadii)dictionary.get(key);
+
+        BoxPane boxPane = new BoxPane(Orientation.VERTICAL);
+        section.add(boxPane);
+        Form.setLabel(boxPane, key);
+
+        FlowPane flowPane = new FlowPane();
+        flowPane.getStyles().put("alignToBaseline", true);
+        flowPane.getStyles().put("horizontalSpacing", 5);
+        boxPane.add(flowPane);
+
+        TextInput textInput = new TextInput();
+        textInput.setTextSize(4);
+        textInput.setMaximumLength(4);
+        textInput.setValidator(new IntValidator());
+        textInput.setText(String.valueOf(cornerRadii.topLeft));
+        flowPane.add(textInput);
+
+        textInput.getComponentStateListeners().add(new ComponentStateListener.Adapter() {
+            @Override
+            public void focusedChanged(Component component, Component obverseComponent) {
+                if (!component.isFocused()) {
+                    TextInput textInput = (TextInput)component;
+                    CornerRadii cornerRadii = (CornerRadii)dictionary.get(key);
+
+                    try {
+                        int topLeft = Integer.parseInt(textInput.getText());
+                        dictionary.put(key, new CornerRadii(topLeft, cornerRadii.topRight,
+                            cornerRadii.bottomLeft, cornerRadii.bottomRight));
+                    } catch (Exception exception) {
+                        textInput.setText(String.valueOf(cornerRadii.topLeft));
+                    }
+                }
+            }
+        });
+
+        Label label = new Label("topLeft");
+        label.getStyles().put("font", "{italic:true}");
+        flowPane.add(label);
+
+        flowPane = new FlowPane();
+        flowPane.getStyles().put("alignToBaseline", true);
+        flowPane.getStyles().put("horizontalSpacing", 5);
+        boxPane.add(flowPane);
+
+        textInput = new TextInput();
+        textInput.setTextSize(4);
+        textInput.setMaximumLength(4);
+        textInput.setValidator(new IntValidator());
+        textInput.setText(String.valueOf(cornerRadii.topRight));
+        flowPane.add(textInput);
+
+        textInput.getComponentStateListeners().add(new ComponentStateListener.Adapter() {
+            @Override
+            public void focusedChanged(Component component, Component obverseComponent) {
+                if (!component.isFocused()) {
+                    TextInput textInput = (TextInput)component;
+                    CornerRadii cornerRadii = (CornerRadii)dictionary.get(key);
+
+                    try {
+                        int topRight = Integer.parseInt(textInput.getText());
+                        dictionary.put(key, new CornerRadii(cornerRadii.topLeft, topRight,
+                            cornerRadii.bottomLeft, cornerRadii.bottomRight));
+                    } catch (Exception exception) {
+                        textInput.setText(String.valueOf(cornerRadii.topRight));
+                    }
+                }
+            }
+        });
+
+        label = new Label("topRight");
+        label.getStyles().put("font", "{italic:true}");
+        flowPane.add(label);
+
+        flowPane = new FlowPane();
+        flowPane.getStyles().put("alignToBaseline", true);
+        flowPane.getStyles().put("horizontalSpacing", 5);
+        boxPane.add(flowPane);
+
+        textInput = new TextInput();
+        textInput.setTextSize(4);
+        textInput.setMaximumLength(4);
+        textInput.setValidator(new IntValidator());
+        textInput.setText(String.valueOf(cornerRadii.bottomLeft));
+        flowPane.add(textInput);
+
+        textInput.getComponentStateListeners().add(new ComponentStateListener.Adapter() {
+            @Override
+            public void focusedChanged(Component component, Component obverseComponent) {
+                if (!component.isFocused()) {
+                    TextInput textInput = (TextInput)component;
+                    CornerRadii cornerRadii = (CornerRadii)dictionary.get(key);
+
+                    try {
+                        int bottomLeft = Integer.parseInt(textInput.getText());
+                        dictionary.put(key, new CornerRadii(cornerRadii.topLeft,
+                            cornerRadii.topRight, bottomLeft, cornerRadii.bottomRight));
+                    } catch (Exception exception) {
+                        textInput.setText(String.valueOf(cornerRadii.bottomLeft));
+                    }
+                }
+            }
+        });
+
+        label = new Label("bottomLeft");
+        label.getStyles().put("font", "{italic:true}");
+        flowPane.add(label);
+
+        flowPane = new FlowPane();
+        flowPane.getStyles().put("alignToBaseline", true);
+        flowPane.getStyles().put("horizontalSpacing", 5);
+        boxPane.add(flowPane);
+
+        textInput = new TextInput();
+        textInput.setTextSize(4);
+        textInput.setMaximumLength(4);
+        textInput.setValidator(new IntValidator());
+        textInput.setText(String.valueOf(cornerRadii.bottomRight));
+        flowPane.add(textInput);
+
+        textInput.getComponentStateListeners().add(new ComponentStateListener.Adapter() {
+            @Override
+            public void focusedChanged(Component component, Component obverseComponent) {
+                if (!component.isFocused()) {
+                    TextInput textInput = (TextInput)component;
+                    CornerRadii cornerRadii = (CornerRadii)dictionary.get(key);
+
+                    try {
+                        int bottomRight = Integer.parseInt(textInput.getText());
+                        dictionary.put(key, new CornerRadii(cornerRadii.topLeft,
+                            cornerRadii.topRight, cornerRadii.bottomLeft, bottomRight));
+                    } catch (Exception exception) {
+                        textInput.setText(String.valueOf(cornerRadii.bottomRight));
+                    }
+                }
+            }
+        });
+
+        label = new Label("bottomRight");
+        label.getStyles().put("font", "{italic:true}");
+        flowPane.add(label);
+
+        return boxPane;
+    }
+}

Modified: incubator/pivot/trunk/tools/src/org/apache/pivot/tools/wtk/ComponentPropertyInspectorSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/tools/src/org/apache/pivot/tools/wtk/ComponentPropertyInspectorSkin.java?rev=830675&r1=830674&r2=830675&view=diff
==============================================================================
--- incubator/pivot/trunk/tools/src/org/apache/pivot/tools/wtk/ComponentPropertyInspectorSkin.java (original)
+++ incubator/pivot/trunk/tools/src/org/apache/pivot/tools/wtk/ComponentPropertyInspectorSkin.java Wed Oct 28 17:11:32 2009
@@ -22,658 +22,97 @@
 import org.apache.pivot.beans.BeanDictionary;
 import org.apache.pivot.beans.BeanDictionaryListener;
 import org.apache.pivot.collections.ArrayList;
-import org.apache.pivot.collections.EnumList;
 import org.apache.pivot.collections.HashMap;
 import org.apache.pivot.collections.List;
-import org.apache.pivot.wtk.BoxPane;
-import org.apache.pivot.wtk.Button;
-import org.apache.pivot.wtk.ButtonStateListener;
-import org.apache.pivot.wtk.Checkbox;
 import org.apache.pivot.wtk.Component;
-import org.apache.pivot.wtk.ComponentStateListener;
-import org.apache.pivot.wtk.Dimensions;
-import org.apache.pivot.wtk.FlowPane;
 import org.apache.pivot.wtk.Form;
-import org.apache.pivot.wtk.Label;
-import org.apache.pivot.wtk.Limits;
-import org.apache.pivot.wtk.ListButton;
-import org.apache.pivot.wtk.ListButtonSelectionListener;
-import org.apache.pivot.wtk.Orientation;
-import org.apache.pivot.wtk.Point;
-import org.apache.pivot.wtk.TextInput;
-import org.apache.pivot.wtk.skin.ContainerSkin;
-import org.apache.pivot.wtk.text.validation.IntValidator;
-import org.apache.pivot.wtk.text.validation.FloatValidator;
-
-class ComponentPropertyInspectorSkin extends ContainerSkin
-    implements ComponentInspectorListener {
-    private static class PropertyNameComparator implements Comparator<String> {
+
+class ComponentPropertyInspectorSkin extends ComponentInspectorSkin {
+    private static class NameComparator implements Comparator<String> {
         @Override
         public int compare(String propertyName1, String propertyName2) {
             return propertyName1.compareTo(propertyName2);
         }
     }
 
-    private static class PropertySourceTypeComparator implements Comparator<Class<?>> {
+    private static class ClassComparator implements Comparator<Class<?>> {
         @Override
-        public int compare(Class<?> sourceType1, Class<?> sourceType2) {
+        public int compare(Class<?> class1, Class<?> class2) {
             int result = 0;
 
-            if (sourceType1.isAssignableFrom(sourceType2)) {
+            if (class1.isAssignableFrom(class2)) {
                 result = 1;
-            } else if (sourceType2.isAssignableFrom(sourceType1)) {
+            } else if (class2.isAssignableFrom(class1)) {
                 result = -1;
             } else {
-                result = sourceType1.getName().compareTo(sourceType2.getName());
+                result = class1.getName().compareTo(class2.getName());
             }
 
             return result;
         }
     }
 
-    private Form form = new Form();
-
     private BeanDictionary beanDictionary = new BeanDictionary();
 
-    private HashMap<String, Component> inspectorComponents = new HashMap<String, Component>();
-
-    private static PropertyNameComparator propertyNameComparator = new PropertyNameComparator();
-    private static PropertySourceTypeComparator propertySourceTypeComparator =
-        new PropertySourceTypeComparator();
+    private static NameComparator nameComparator = new NameComparator();
+    private static ClassComparator classComparator = new ClassComparator();
 
     public ComponentPropertyInspectorSkin() {
         beanDictionary.getBeanDictionaryListeners().add(new BeanDictionaryListener.Adapter() {
             @Override
             public void propertyChanged(BeanDictionary beanDictionary, String propertyName) {
-                Class<?> propertyType = beanDictionary.getType(propertyName);
-
-                if (propertyType == Boolean.TYPE) {
-                    updateBooleanControl(propertyName);
-                } else if (propertyType == Integer.TYPE) {
-                    updateIntControl(propertyName);
-                } else if (propertyType == Float.TYPE) {
-                    updateFloatControl(propertyName);
-                } else if (propertyType == String.class) {
-                    updateStringControl(propertyName);
-                } else if (propertyType.isEnum()) {
-                    updateEnumControl(propertyName);
-                } else if (propertyType == Point.class) {
-                    updatePointControl(propertyName);
-                } else if (propertyType == Dimensions.class) {
-                    updateDimensionsControl(propertyName);
-                } else if (propertyType == Limits.class) {
-                    updateLimitsControl(propertyName);
-                }
+                Class<?> type = beanDictionary.getType(propertyName);
+                updateControl(beanDictionary, propertyName, type);
             }
         });
 
-        form.getStyles().put("rightAlignLabels", true);
         form.getStyles().put("showFirstSectionHeading", true);
     }
 
     @Override
-    public void install(Component component) {
-        super.install(component);
-
-        ComponentPropertyInspector componentPropertyInspector =
-            (ComponentPropertyInspector)component;
-
-        componentPropertyInspector.getComponentInspectorListeners().add(this);
-        componentPropertyInspector.add(form);
-
-        sourceChanged(componentPropertyInspector, null);
-    }
-
-    @Override
-    public int getPreferredWidth(int height) {
-        return form.getPreferredWidth(height);
-    }
-
-    @Override
-    public int getPreferredHeight(int width) {
-        return form.getPreferredHeight(width);
-    }
-
-    @Override
-    public Dimensions getPreferredSize() {
-        return form.getPreferredSize();
-    }
-
-    @Override
-    public void layout() {
-        form.setLocation(0, 0);
-        form.setSize(getWidth(), getHeight());
-    }
-
-    @Override
     public void sourceChanged(ComponentInspector componentInspector, Component previousSource) {
+        Component source = componentInspector.getSource();
+
+        clearControls();
         Form.SectionSequence sections = form.getSections();
         sections.remove(0, sections.getLength());
 
-        Component source = componentInspector.getSource();
-
         beanDictionary.setBean(source);
 
         if (source != null) {
             Class<?> sourceType = source.getClass();
-            HashMap<Class<?>, List<String>> propertyBuckets =
-                new HashMap<Class<?>, List<String>>(propertySourceTypeComparator);
+            HashMap<Class<?>, List<String>> declaringClassPartitions =
+                new HashMap<Class<?>, List<String>>(classComparator);
 
+            // Partition the properties by their declaring class
             for (String propertyName : beanDictionary) {
                 if (beanDictionary.isNotifying(propertyName)
                     && !beanDictionary.isReadOnly(propertyName)) {
                     Method method = BeanDictionary.getGetterMethod(sourceType, propertyName);
                     Class<?> declaringClass = method.getDeclaringClass();
 
-                    List<String> propertyNames = propertyBuckets.get(declaringClass);
+                    List<String> propertyNames = declaringClassPartitions.get(declaringClass);
                     if (propertyNames == null) {
-                        propertyNames = new ArrayList<String>(propertyNameComparator);
-                        propertyBuckets.put(declaringClass, propertyNames);
+                        propertyNames = new ArrayList<String>(nameComparator);
+                        declaringClassPartitions.put(declaringClass, propertyNames);
                     }
 
                     propertyNames.add(propertyName);
                 }
             }
 
-            for (Class<?> declaringClass : propertyBuckets) {
+            // Add the controls
+            for (Class<?> declaringClass : declaringClassPartitions) {
                 Form.Section section = new Form.Section();
                 section.setHeading(declaringClass.getSimpleName());
                 sections.add(section);
 
-                for (String propertyName : propertyBuckets.get(declaringClass)) {
-                    addPropertyControl(propertyName, section);
-                }
-            }
-        }
-    }
-
-    private void addPropertyControl(String propertyName, Form.Section section) {
-        Class<?> propertyType = beanDictionary.getType(propertyName);
-
-        Component inspectorComponent = null;
-
-        if (propertyType == Boolean.TYPE) {
-            inspectorComponent = addBooleanControl(propertyName, section);
-        } else if (propertyType == Integer.TYPE) {
-            inspectorComponent = addIntControl(propertyName, section);
-        } else if (propertyType == Float.TYPE) {
-            inspectorComponent = addFloatControl(propertyName, section);
-        } else if (propertyType == String.class) {
-            inspectorComponent = addStringControl(propertyName, section);
-        } else if (propertyType.isEnum()) {
-            inspectorComponent = addEnumControl(propertyName, section);
-        } else if (propertyType == Point.class) {
-            inspectorComponent = addPointControl(propertyName, section);
-        } else if (propertyType == Dimensions.class) {
-            inspectorComponent = addDimensionsControl(propertyName, section);
-        } else if (propertyType == Limits.class) {
-            inspectorComponent = addLimitsControl(propertyName, section);
-        }
-
-        if (inspectorComponent != null) {
-            inspectorComponents.put(propertyName, inspectorComponent);
-        }
-    }
-
-    private Component addBooleanControl(final String propertyName, Form.Section section) {
-        boolean propertyValue = (Boolean)beanDictionary.get(propertyName);
-
-        Checkbox checkbox = new Checkbox();
-        checkbox.setSelected(propertyValue);
-        section.add(checkbox);
-        Form.setLabel(checkbox, propertyName);
-
-        checkbox.getButtonStateListeners().add(new ButtonStateListener() {
-            private boolean updating = false;
-
-            @Override
-            public void stateChanged(Button button, Button.State previousState) {
-                if (!updating) {
-                    updating = true;
-                    try {
-                        beanDictionary.put(propertyName, button.isSelected());
-                    } catch (Exception exception) {
-                        button.setState(previousState);
-                    } finally {
-                        updating = false;
-                    }
+                List<String> propertyNames = declaringClassPartitions.get(declaringClass);
+                for (String propertyName : propertyNames) {
+                    Class<?> type = beanDictionary.getType(propertyName);
+                    addControl(beanDictionary, propertyName, type, section);
                 }
             }
-        });
-
-        return checkbox;
-    }
-
-    private void updateBooleanControl(String propertyName) {
-        Checkbox checkbox = (Checkbox)inspectorComponents.get(propertyName);
-
-        if (checkbox != null) {
-            boolean propertyValue = (Boolean)beanDictionary.get(propertyName);
-            checkbox.setSelected(propertyValue);
-        }
-    }
-
-    private Component addIntControl(final String propertyName, Form.Section section) {
-        int propertyValue = (Integer)beanDictionary.get(propertyName);
-
-        TextInput textInput = new TextInput();
-        textInput.setTextSize(10);
-        textInput.setMaximumLength(10);
-        textInput.setValidator(new IntValidator());
-        textInput.setText(String.valueOf(propertyValue));
-        section.add(textInput);
-        Form.setLabel(textInput, propertyName);
-
-        textInput.getComponentStateListeners().add(new ComponentStateListener.Adapter() {
-            @Override
-            public void focusedChanged(Component component, Component obverseComponent) {
-                if (!component.isFocused()) {
-                    TextInput textInput = (TextInput)component;
-
-                    try {
-                        beanDictionary.put(propertyName, Integer.parseInt(textInput.getText()));
-                    } catch (Exception exception) {
-                        Object propertyValue = beanDictionary.get(propertyName);
-                        textInput.setText(String.valueOf(propertyValue));
-                    }
-                }
-            }
-        });
-
-        return textInput;
-    }
-
-    private void updateIntControl(String propertyName) {
-        TextInput textInput = (TextInput)inspectorComponents.get(propertyName);
-
-        if (textInput != null) {
-            int propertyValue = (Integer)beanDictionary.get(propertyName);
-            textInput.setText(String.valueOf(propertyValue));
-        }
-    }
-
-    private Component addFloatControl(final String propertyName, Form.Section section) {
-        float propertyValue = (Float)beanDictionary.get(propertyName);
-
-        TextInput textInput = new TextInput();
-        textInput.setTextSize(10);
-        textInput.setValidator(new FloatValidator());
-        textInput.setText(String.valueOf(propertyValue));
-        section.add(textInput);
-        Form.setLabel(textInput, propertyName);
-
-        textInput.getComponentStateListeners().add(new ComponentStateListener.Adapter() {
-            @Override
-            public void focusedChanged(Component component, Component obverseComponent) {
-                if (!component.isFocused()) {
-                    TextInput textInput = (TextInput)component;
-
-                    try {
-                        beanDictionary.put(propertyName, Float.parseFloat(textInput.getText()));
-                    } catch (Exception exception) {
-                        Object propertyValue = beanDictionary.get(propertyName);
-                        textInput.setText(String.valueOf(propertyValue));
-                    }
-                }
-            }
-        });
-
-        return textInput;
-    }
-
-    private void updateFloatControl(String propertyName) {
-        TextInput textInput = (TextInput)inspectorComponents.get(propertyName);
-
-        if (textInput != null) {
-            float propertyValue = (Float)beanDictionary.get(propertyName);
-            textInput.setText(String.valueOf(propertyValue));
-        }
-    }
-
-    private Component addStringControl(final String propertyName, Form.Section section) {
-        String propertyValue = (String)beanDictionary.get(propertyName);
-
-        TextInput textInput = new TextInput();
-        textInput.setText(propertyValue == null ? "" : propertyValue);
-        section.add(textInput);
-        Form.setLabel(textInput, propertyName);
-
-        textInput.getComponentStateListeners().add(new ComponentStateListener.Adapter() {
-            @Override
-            public void focusedChanged(Component component, Component obverseComponent) {
-                if (!component.isFocused()) {
-                    TextInput textInput = (TextInput)component;
-
-                    try {
-                        beanDictionary.put(propertyName, textInput.getText());
-                    } catch (Exception exception) {
-                        String propertyValue = (String)beanDictionary.get(propertyName);
-                        textInput.setText(propertyValue == null ? "" : propertyValue);
-                    }
-                }
-            }
-        });
-
-        return textInput;
-    }
-
-    private void updateStringControl(String propertyName) {
-        TextInput textInput = (TextInput)inspectorComponents.get(propertyName);
-
-        if (textInput != null) {
-            String propertyValue = (String)beanDictionary.get(propertyName);
-            textInput.setText(propertyValue == null ? "" : propertyValue);
-        }
-    }
-
-    @SuppressWarnings("unchecked")
-    private Component addEnumControl(final String propertyName, Form.Section section) {
-        Class<?> propertyType = beanDictionary.getType(propertyName);
-        Enum<?> propertyValue = (Enum<?>)beanDictionary.get(propertyName);
-
-        ListButton listButton = new ListButton();
-        listButton.setListData(new EnumList(propertyType));
-        listButton.setSelectedItem(propertyValue);
-        section.add(listButton);
-        Form.setLabel(listButton, propertyName);
-
-        listButton.getListButtonSelectionListeners().add(new ListButtonSelectionListener() {
-            private boolean updating = false;
-
-            @Override
-            public void selectedIndexChanged(ListButton listButton, int previousSelectedIndex) {
-                if (!updating) {
-                    updating = true;
-                    try {
-                        beanDictionary.put(propertyName, listButton.getSelectedItem());
-                    } catch (Exception exception) {
-                        listButton.setSelectedIndex(previousSelectedIndex);
-                    } finally {
-                        updating = false;
-                    }
-                }
-            }
-        });
-
-        return listButton;
-    }
-
-    private void updateEnumControl(String propertyName) {
-        ListButton listButton = (ListButton)inspectorComponents.get(propertyName);
-
-        if (listButton != null) {
-            Enum<?> propertyValue = (Enum<?>)beanDictionary.get(propertyName);
-            listButton.setSelectedItem(propertyValue);
-        }
-    }
-
-    private Component addPointControl(final String propertyName, Form.Section section) {
-        Point point = (Point)beanDictionary.get(propertyName);
-
-        BoxPane boxPane = new BoxPane(Orientation.VERTICAL);
-        section.add(boxPane);
-        Form.setLabel(boxPane, propertyName);
-
-        FlowPane flowPane = new FlowPane();
-        flowPane.getStyles().put("alignToBaseline", true);
-        flowPane.getStyles().put("horizontalSpacing", 5);
-        boxPane.add(flowPane);
-
-        TextInput textInput = new TextInput();
-        textInput.setTextSize(3);
-        textInput.setMaximumLength(4);
-        textInput.setValidator(new IntValidator());
-        textInput.setText(String.valueOf(point.x));
-        flowPane.add(textInput);
-
-        textInput.getComponentStateListeners().add(new ComponentStateListener.Adapter() {
-            @Override
-            public void focusedChanged(Component component, Component obverseComponent) {
-                if (!component.isFocused()) {
-                    TextInput textInput = (TextInput)component;
-                    Point point = (Point)beanDictionary.get(propertyName);
-
-                    try {
-                        int x = Integer.parseInt(textInput.getText());
-                        beanDictionary.put(propertyName, new Point(x, point.y));
-                    } catch (Exception exception) {
-                        textInput.setText(String.valueOf(point.x));
-                    }
-                }
-            }
-        });
-
-        Label label = new Label("x");
-        label.getStyles().put("font", "{italic:true}");
-        flowPane.add(label);
-
-        flowPane = new FlowPane();
-        flowPane.getStyles().put("alignToBaseline", true);
-        flowPane.getStyles().put("horizontalSpacing", 5);
-        boxPane.add(flowPane);
-
-        textInput = new TextInput();
-        textInput.setTextSize(3);
-        textInput.setMaximumLength(4);
-        textInput.setValidator(new IntValidator());
-        textInput.setText(String.valueOf(point.y));
-        flowPane.add(textInput);
-
-        textInput.getComponentStateListeners().add(new ComponentStateListener.Adapter() {
-            @Override
-            public void focusedChanged(Component component, Component obverseComponent) {
-                if (!component.isFocused()) {
-                    TextInput textInput = (TextInput)component;
-                    Point point = (Point)beanDictionary.get(propertyName);
-
-                    try {
-                        int y = Integer.parseInt(textInput.getText());
-                        beanDictionary.put(propertyName, new Point(point.x, y));
-                    } catch (Exception exception) {
-                        textInput.setText(String.valueOf(point.y));
-                    }
-                }
-            }
-        });
-
-        label = new Label("y");
-        label.getStyles().put("font", "{italic:true}");
-        flowPane.add(label);
-
-        return boxPane;
-    }
-
-    private void updatePointControl(String propertyName) {
-        BoxPane boxPane = (BoxPane)inspectorComponents.get(propertyName);
-
-        if (boxPane != null) {
-            Point point = (Point)beanDictionary.get(propertyName);
-
-            TextInput xTextInput = (TextInput)((FlowPane)boxPane.get(0)).get(0);
-            TextInput yTextInput = (TextInput)((FlowPane)boxPane.get(1)).get(0);
-
-            xTextInput.setText(String.valueOf(point.x));
-            yTextInput.setText(String.valueOf(point.y));
-        }
-    }
-
-    private Component addDimensionsControl(final String propertyName, Form.Section section) {
-        Dimensions dimensions = (Dimensions)beanDictionary.get(propertyName);
-
-        BoxPane boxPane = new BoxPane(Orientation.VERTICAL);
-        section.add(boxPane);
-        Form.setLabel(boxPane, propertyName);
-
-        FlowPane flowPane = new FlowPane();
-        flowPane.getStyles().put("alignToBaseline", true);
-        flowPane.getStyles().put("horizontalSpacing", 5);
-        boxPane.add(flowPane);
-
-        TextInput textInput = new TextInput();
-        textInput.setTextSize(3);
-        textInput.setMaximumLength(4);
-        textInput.setValidator(new IntValidator());
-        textInput.setText(String.valueOf(dimensions.width));
-        flowPane.add(textInput);
-
-        textInput.getComponentStateListeners().add(new ComponentStateListener.Adapter() {
-            @Override
-            public void focusedChanged(Component component, Component obverseComponent) {
-                if (!component.isFocused()) {
-                    TextInput textInput = (TextInput)component;
-                    Dimensions dimensions = (Dimensions)beanDictionary.get(propertyName);
-
-                    try {
-                        int width = Integer.parseInt(textInput.getText());
-                        beanDictionary.put(propertyName, new Dimensions(width, dimensions.height));
-                    } catch (Exception exception) {
-                        textInput.setText(String.valueOf(dimensions.width));
-                    }
-                }
-            }
-        });
-
-        Label label = new Label("width");
-        label.getStyles().put("font", "{italic:true}");
-        flowPane.add(label);
-
-        flowPane = new FlowPane();
-        flowPane.getStyles().put("alignToBaseline", true);
-        flowPane.getStyles().put("horizontalSpacing", 5);
-        boxPane.add(flowPane);
-
-        textInput = new TextInput();
-        textInput.setTextSize(3);
-        textInput.setMaximumLength(4);
-        textInput.setValidator(new IntValidator());
-        textInput.setText(String.valueOf(dimensions.height));
-        flowPane.add(textInput);
-
-        textInput.getComponentStateListeners().add(new ComponentStateListener.Adapter() {
-            @Override
-            public void focusedChanged(Component component, Component obverseComponent) {
-                if (!component.isFocused()) {
-                    TextInput textInput = (TextInput)component;
-                    Dimensions dimensions = (Dimensions)beanDictionary.get(propertyName);
-
-                    try {
-                        int height = Integer.parseInt(textInput.getText());
-                        beanDictionary.put(propertyName, new Dimensions(dimensions.width, height));
-                    } catch (Exception exception) {
-                        textInput.setText(String.valueOf(dimensions.height));
-                    }
-                }
-            }
-        });
-
-        label = new Label("height");
-        label.getStyles().put("font", "{italic:true}");
-        flowPane.add(label);
-
-        return boxPane;
-    }
-
-    private void updateDimensionsControl(String propertyName) {
-        BoxPane boxPane = (BoxPane)inspectorComponents.get(propertyName);
-
-        if (boxPane != null) {
-            Dimensions dimensions = (Dimensions)beanDictionary.get(propertyName);
-
-            TextInput widthTextInput = (TextInput)((FlowPane)boxPane.get(0)).get(0);
-            TextInput heightTextInput = (TextInput)((FlowPane)boxPane.get(1)).get(0);
-
-            widthTextInput.setText(String.valueOf(dimensions.width));
-            heightTextInput.setText(String.valueOf(dimensions.height));
-        }
-    }
-
-    private Component addLimitsControl(final String propertyName, Form.Section section) {
-        Limits limits = (Limits)beanDictionary.get(propertyName);
-
-        BoxPane boxPane = new BoxPane(Orientation.VERTICAL);
-        section.add(boxPane);
-        Form.setLabel(boxPane, propertyName);
-
-        FlowPane flowPane = new FlowPane();
-        flowPane.getStyles().put("alignToBaseline", true);
-        flowPane.getStyles().put("horizontalSpacing", 5);
-        boxPane.add(flowPane);
-
-        TextInput textInput = new TextInput();
-        textInput.setTextSize(10);
-        textInput.setMaximumLength(10);
-        textInput.setValidator(new IntValidator());
-        textInput.setText(String.valueOf(limits.min));
-        flowPane.add(textInput);
-
-        textInput.getComponentStateListeners().add(new ComponentStateListener.Adapter() {
-            @Override
-            public void focusedChanged(Component component, Component obverseComponent) {
-                if (!component.isFocused()) {
-                    TextInput textInput = (TextInput)component;
-                    Limits limits = (Limits)beanDictionary.get(propertyName);
-
-                    try {
-                        int min = Integer.parseInt(textInput.getText());
-                        beanDictionary.put(propertyName, new Limits(min, limits.max));
-                    } catch (Exception exception) {
-                        textInput.setText(String.valueOf(limits.min));
-                    }
-                }
-            }
-        });
-
-        Label label = new Label("min");
-        label.getStyles().put("font", "{italic:true}");
-        flowPane.add(label);
-
-        flowPane = new FlowPane();
-        flowPane.getStyles().put("alignToBaseline", true);
-        flowPane.getStyles().put("horizontalSpacing", 5);
-        boxPane.add(flowPane);
-
-        textInput = new TextInput();
-        textInput.setTextSize(10);
-        textInput.setMaximumLength(10);
-        textInput.setValidator(new IntValidator());
-        textInput.setText(String.valueOf(limits.max));
-        flowPane.add(textInput);
-
-        textInput.getComponentStateListeners().add(new ComponentStateListener.Adapter() {
-            @Override
-            public void focusedChanged(Component component, Component obverseComponent) {
-                if (!component.isFocused()) {
-                    TextInput textInput = (TextInput)component;
-                    Limits limits = (Limits)beanDictionary.get(propertyName);
-
-                    try {
-                        int max = Integer.parseInt(textInput.getText());
-                        beanDictionary.put(propertyName, new Limits(limits.min, max));
-                    } catch (Exception exception) {
-                        textInput.setText(String.valueOf(limits.max));
-                    }
-                }
-            }
-        });
-
-        label = new Label("max");
-        label.getStyles().put("font", "{italic:true}");
-        flowPane.add(label);
-
-        return boxPane;
-    }
-
-    private void updateLimitsControl(String propertyName) {
-        BoxPane boxPane = (BoxPane)inspectorComponents.get(propertyName);
-
-        if (boxPane != null) {
-            Limits limits = (Limits)beanDictionary.get(propertyName);
-
-            TextInput minTextInput = (TextInput)((FlowPane)boxPane.get(0)).get(0);
-            TextInput maxTextInput = (TextInput)((FlowPane)boxPane.get(1)).get(0);
-
-            minTextInput.setText(String.valueOf(limits.min));
-            maxTextInput.setText(String.valueOf(limits.max));
         }
     }
 }