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 21:16:36 UTC
svn commit: r831438 - in /incubator/pivot/trunk:
demos/src/org/apache/pivot/demos/explorer/
demos/src/org/apache/pivot/demos/explorer/lists/
demos/src/org/apache/pivot/demos/explorer/progress/
demos/src/org/apache/pivot/demos/explorer/text/ tools/src/o...
Author: tvolkert
Date: Fri Oct 30 20:16:35 2009
New Revision: 831438
URL: http://svn.apache.org/viewvc?rev=831438&view=rev
Log:
Updates to component explorer, added double support to the component inspector
Added:
incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/lists/
incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/lists/list_button.wtkx
incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/lists/list_view.wtkx
incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/page_white.png (with props)
incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/progress/
incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/progress/activity_indicator.wtkx
incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/progress/meter.wtkx
incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/text/
incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/text/text_area.wtkx
incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/text/text_input.wtkx
Removed:
incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/magnifier.png
Modified:
incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/ComponentExplorer.java
incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/component_explorer.wtkx
incubator/pivot/trunk/tools/src/org/apache/pivot/tools/wtk/ComponentInspectorSkin.java
Modified: incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/ComponentExplorer.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/ComponentExplorer.java?rev=831438&r1=831437&r2=831438&view=diff
==============================================================================
--- incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/ComponentExplorer.java (original)
+++ incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/ComponentExplorer.java Fri Oct 30 20:16:35 2009
@@ -29,6 +29,7 @@
import org.apache.pivot.tools.wtk.EventLogger;
import org.apache.pivot.util.Resources;
import org.apache.pivot.wtk.Application;
+import org.apache.pivot.wtk.ApplicationContext;
import org.apache.pivot.wtk.Border;
import org.apache.pivot.wtk.Component;
import org.apache.pivot.wtk.ComponentMouseButtonListener;
@@ -36,6 +37,7 @@
import org.apache.pivot.wtk.Display;
import org.apache.pivot.wtk.Mouse;
import org.apache.pivot.wtk.ScrollPane;
+import org.apache.pivot.wtk.TabPane;
import org.apache.pivot.wtk.TreeView;
import org.apache.pivot.wtk.TreeViewSelectionListener;
import org.apache.pivot.wtk.Window;
@@ -46,10 +48,13 @@
private TreeView treeView = null;
private ScrollPane scrollPane = null;
private Border contentPane = null;
+ private TabPane inspectorTabPane = null;
private ComponentPropertyInspector componentPropertyInspector = null;
private ComponentStyleInspector componentStyleInspector = null;
private EventLogger eventLogger = null;
+ public static final String CLASS_PROPERTY = "class";
+
@Override
public void startup(Display display, Map<String, String> properties)
throws Exception {
@@ -60,6 +65,7 @@
treeView = wtkxSerializer.getValue("treeView");
scrollPane = wtkxSerializer.getValue("scrollPane");
contentPane = wtkxSerializer.getValue("contentPane");
+ inspectorTabPane = wtkxSerializer.getValue("inspectorTabPane");
componentPropertyInspector = wtkxSerializer.getValue("componentPropertyInspector");
componentStyleInspector = wtkxSerializer.getValue("componentStyleInspector");
eventLogger = wtkxSerializer.getValue("eventLogger");
@@ -74,6 +80,8 @@
if (node instanceof ComponentNode) {
ComponentNode componentNode = (ComponentNode)node;
+ inspectorTabPane.setVisible(true);
+
WTKXSerializer wtkxSerializer = new WTKXSerializer();
try {
component = (Component)wtkxSerializer.readObject(componentNode.getSrc());
@@ -87,6 +95,8 @@
(componentNode.getHorizontalScrollBarPolicy());
scrollPane.setVerticalScrollBarPolicy
(componentNode.getVerticalScrollBarPolicy());
+ } else {
+ inspectorTabPane.setVisible(false);
}
contentPane.setContent(component);
@@ -117,17 +127,43 @@
}
});
- treeView.expandAll();
+ Path initialSelectedPath = null;
+ String classProperty = properties.get(CLASS_PROPERTY);
Tree.ItemIterator<?> itemIterator = Tree.depthFirstIterator(treeView.getTreeData());
while (itemIterator.hasNext()) {
Object node = itemIterator.next();
+
if (node instanceof ComponentNode) {
- treeView.setSelectedPath(itemIterator.getPath());
- break;
+ ComponentNode componentNode = (ComponentNode)node;
+
+ if (classProperty != null) {
+ if (componentNode.getText().equals(classProperty)) {
+ initialSelectedPath = itemIterator.getPath();
+ break;
+ }
+ } else {
+ initialSelectedPath = itemIterator.getPath();
+ break;
+ }
}
}
+ if (initialSelectedPath != null) {
+ treeView.setSelectedPath(initialSelectedPath);
+
+ Path branchPath = new Path(initialSelectedPath, initialSelectedPath.getLength() - 1);
+ treeView.expandBranch(branchPath);
+
+ final Path path = initialSelectedPath;
+ ApplicationContext.queueCallback(new Runnable() {
+ @Override
+ public void run() {
+ treeView.scrollAreaToVisible(treeView.getNodeBounds(path));
+ }
+ });
+ }
+
window.open(display);
treeView.requestFocus();
Modified: incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/component_explorer.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/component_explorer.wtkx?rev=831438&r1=831437&r2=831438&view=diff
==============================================================================
--- incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/component_explorer.wtkx (original)
+++ incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/component_explorer.wtkx Fri Oct 30 20:16:35 2009
@@ -38,71 +38,91 @@
<content:TreeBranch text="Buttons"
icon="@folder.png">
<explorer:ComponentNode text="PushButton"
- icon="@magnifier.png"
+ icon="@page_white.png"
src="@buttons/push_button.wtkx"
horizontalScrollBarPolicy="auto"
verticalScrollBarPolicy="auto"/>
<explorer:ComponentNode text="RadioButton"
- icon="@magnifier.png"
+ icon="@page_white.png"
src="@buttons/radio_button.wtkx"
horizontalScrollBarPolicy="auto"
verticalScrollBarPolicy="auto"/>
<explorer:ComponentNode text="Checkbox"
- icon="@magnifier.png"
+ icon="@page_white.png"
src="@buttons/checkbox.wtkx"
horizontalScrollBarPolicy="auto"
verticalScrollBarPolicy="auto"/>
<explorer:ComponentNode text="LinkButton"
- icon="@magnifier.png"
+ icon="@page_white.png"
src="@buttons/link_button.wtkx"
horizontalScrollBarPolicy="auto"
verticalScrollBarPolicy="auto"/>
</content:TreeBranch>
<content:TreeBranch text="Lists"
icon="@folder.png">
+ <explorer:ComponentNode text="ListView"
+ icon="@page_white.png"
+ src="@lists/list_view.wtkx"
+ horizontalScrollBarPolicy="fill_to_capacity"
+ verticalScrollBarPolicy="auto"/>
+ <explorer:ComponentNode text="ListButton"
+ icon="@page_white.png"
+ src="@lists/list_button.wtkx"
+ horizontalScrollBarPolicy="auto"
+ verticalScrollBarPolicy="auto"/>
</content:TreeBranch>
<content:TreeBranch text="Text"
icon="@folder.png">
+ <explorer:ComponentNode text="TextInput"
+ icon="@page_white.png"
+ src="@text/text_input.wtkx"
+ horizontalScrollBarPolicy="auto"
+ verticalScrollBarPolicy="auto"/>
+ <explorer:ComponentNode text="TextArea"
+ icon="@page_white.png"
+ src="@text/text_area.wtkx"
+ horizontalScrollBarPolicy="fill"
+ verticalScrollBarPolicy="fill_to_capacity"/>
</content:TreeBranch>
<content:TreeBranch text="Layout Containers"
icon="@folder.png">
<explorer:ComponentNode text="FlowPane"
- icon="@magnifier.png"
+ icon="@page_white.png"
src="@layout/flow_pane.wtkx"
horizontalScrollBarPolicy="fill"
verticalScrollBarPolicy="fill"/>
<explorer:ComponentNode text="BoxPane"
- icon="@magnifier.png"
+ icon="@page_white.png"
src="@layout/box_pane.wtkx"
horizontalScrollBarPolicy="fill"
verticalScrollBarPolicy="fill"/>
<explorer:ComponentNode text="TablePane"
- icon="@magnifier.png"
+ icon="@page_white.png"
src="@layout/table_pane.wtkx"
horizontalScrollBarPolicy="fill"
verticalScrollBarPolicy="fill"/>
<explorer:ComponentNode text="Border"
- icon="@magnifier.png"
+ icon="@page_white.png"
src="@layout/border.wtkx"
horizontalScrollBarPolicy="fill"
verticalScrollBarPolicy="fill"/>
<explorer:ComponentNode text="StackPane"
- icon="@magnifier.png"
+ icon="@page_white.png"
src="@layout/stack_pane.wtkx"
horizontalScrollBarPolicy="fill"
verticalScrollBarPolicy="fill"/>
<explorer:ComponentNode text="SplitPane"
- icon="@magnifier.png"
+ icon="@page_white.png"
src="@layout/split_pane.wtkx"
horizontalScrollBarPolicy="fill"
verticalScrollBarPolicy="fill"/>
<explorer:ComponentNode text="Form"
- icon="@magnifier.png"
+ icon="@page_white.png"
src="@layout/form.wtkx"
horizontalScrollBarPolicy="fill"
verticalScrollBarPolicy="auto"/>
<explorer:ComponentNode text="Panel"
- icon="@magnifier.png"
+ icon="@page_white.png"
src="@layout/panel.wtkx"
horizontalScrollBarPolicy="fill"
verticalScrollBarPolicy="fill"/>
@@ -110,39 +130,39 @@
<content:TreeBranch text="Navigation Containers"
icon="@folder.png">
<explorer:ComponentNode text="CardPane"
- icon="@magnifier.png"
+ icon="@page_white.png"
src="@navigation/card_pane.wtkx"
horizontalScrollBarPolicy="fill"
verticalScrollBarPolicy="fill"/>
<explorer:ComponentNode text="TabPane"
- icon="@magnifier.png"
+ icon="@page_white.png"
src="@navigation/tab_pane.wtkx"
horizontalScrollBarPolicy="auto"
verticalScrollBarPolicy="auto"/>
<explorer:ComponentNode text="Accordion"
- icon="@magnifier.png"
+ icon="@page_white.png"
src="@navigation/accordion.wtkx"
horizontalScrollBarPolicy="auto"
verticalScrollBarPolicy="auto"/>
<explorer:ComponentNode text="Expander"
- icon="@magnifier.png"
+ icon="@page_white.png"
src="@navigation/expander.wtkx"
horizontalScrollBarPolicy="auto"
verticalScrollBarPolicy="auto"/>
<explorer:ComponentNode text="Rollup"
- icon="@magnifier.png"
+ icon="@page_white.png"
src="@navigation/rollup.wtkx"
horizontalScrollBarPolicy="auto"
verticalScrollBarPolicy="auto"/>
<content:TreeBranch text="Viewports"
icon="@folder.png">
<explorer:ComponentNode text="ScrollPane"
- icon="@magnifier.png"
+ icon="@page_white.png"
src="@navigation/scroll_pane.wtkx"
horizontalScrollBarPolicy="fill"
verticalScrollBarPolicy="fill"/>
<explorer:ComponentNode text="Panorama"
- icon="@magnifier.png"
+ icon="@page_white.png"
src="@navigation/panorama.wtkx"
horizontalScrollBarPolicy="fill"
verticalScrollBarPolicy="fill"/>
@@ -150,11 +170,21 @@
</content:TreeBranch>
<content:TreeBranch text="Progress Indicators"
icon="@folder.png">
+ <explorer:ComponentNode text="Meter"
+ icon="@page_white.png"
+ src="@progress/meter.wtkx"
+ horizontalScrollBarPolicy="auto"
+ verticalScrollBarPolicy="auto"/>
+ <explorer:ComponentNode text="ActivityIndicator"
+ icon="@page_white.png"
+ src="@progress/activity_indicator.wtkx"
+ horizontalScrollBarPolicy="auto"
+ verticalScrollBarPolicy="auto"/>
</content:TreeBranch>
<content:TreeBranch text="Bounded Range Components"
icon="@folder.png">
<explorer:ComponentNode text="ScrollBar"
- icon="@magnifier.png"
+ icon="@page_white.png"
src="@boundedrange/scroll_bar.wtkx"
horizontalScrollBarPolicy="auto"
verticalScrollBarPolicy="auto"/>
@@ -171,7 +201,7 @@
<content:TreeBranch text="Tree Views"
icon="@folder.png">
<explorer:ComponentNode text="TreeView"
- icon="@magnifier.png"
+ icon="@page_white.png"
src="@treeview/tree_view.wtkx"
horizontalScrollBarPolicy="fill_to_capacity"
verticalScrollBarPolicy="auto"/>
@@ -204,7 +234,7 @@
</ScrollPane>
</content>
</Border>
- <TabPane selectedIndex="-1"
+ <TabPane wtkx:id="inspectorTabPane"
styles="{collapsible:true, tabOrientation:'vertical'}">
<tabs>
<Border TabPane.label="%properties">
Added: incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/lists/list_button.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/lists/list_button.wtkx?rev=831438&view=auto
==============================================================================
--- incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/lists/list_button.wtkx (added)
+++ incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/lists/list_button.wtkx Fri Oct 30 20:16:35 2009
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+
+<ListButton
+ listData="['One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten']"
+ xmlns:wtkx="http://pivot.apache.org/wtkx"
+ xmlns="org.apache.pivot.wtk"/>
Added: incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/lists/list_view.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/lists/list_view.wtkx?rev=831438&view=auto
==============================================================================
--- incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/lists/list_view.wtkx (added)
+++ incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/lists/list_view.wtkx Fri Oct 30 20:16:35 2009
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+
+<ListView selectMode="multi"
+ listData="['One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten']"
+ xmlns:wtkx="http://pivot.apache.org/wtkx"
+ xmlns="org.apache.pivot.wtk"/>
Added: incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/page_white.png
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/page_white.png?rev=831438&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/page_white.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/progress/activity_indicator.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/progress/activity_indicator.wtkx?rev=831438&view=auto
==============================================================================
--- incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/progress/activity_indicator.wtkx (added)
+++ incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/progress/activity_indicator.wtkx Fri Oct 30 20:16:35 2009
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+
+<ActivityIndicator preferredWidth="96" preferredHeight="96" active="true"
+ xmlns:wtkx="http://pivot.apache.org/wtkx"
+ xmlns="org.apache.pivot.wtk"/>
Added: incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/progress/meter.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/progress/meter.wtkx?rev=831438&view=auto
==============================================================================
--- incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/progress/meter.wtkx (added)
+++ incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/progress/meter.wtkx Fri Oct 30 20:16:35 2009
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+
+<Meter preferredWidth="200" preferredHeight="16" percentage="0.5"
+ xmlns:wtkx="http://pivot.apache.org/wtkx"
+ xmlns="org.apache.pivot.wtk"/>
Added: incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/text/text_area.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/text/text_area.wtkx?rev=831438&view=auto
==============================================================================
--- incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/text/text_area.wtkx (added)
+++ incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/text/text_area.wtkx Fri Oct 30 20:16:35 2009
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+
+<TextArea
+ xmlns:validation="org.apache.pivot.wtk.text.validation"
+ xmlns="org.apache.pivot.wtk"/>
Added: incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/text/text_input.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/text/text_input.wtkx?rev=831438&view=auto
==============================================================================
--- incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/text/text_input.wtkx (added)
+++ incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/text/text_input.wtkx Fri Oct 30 20:16:35 2009
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+
+<TextInput textSize="20"
+ xmlns:wtkx="http://pivot.apache.org/wtkx"
+ xmlns="org.apache.pivot.wtk"/>
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=831438&r1=831437&r2=831438&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 20:16:35 2009
@@ -42,6 +42,7 @@
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.DoubleValidator;
import org.apache.pivot.wtk.text.validation.IntValidator;
import org.apache.pivot.wtk.text.validation.FloatValidator;
@@ -128,6 +129,8 @@
control = addIntControl(dictionary, key, section);
} else if (type == Float.TYPE) {
control = addFloatControl(dictionary, key, section);
+ } else if (type == Double.TYPE) {
+ control = addDoubleControl(dictionary, key, section);
} else if (type == String.class) {
control = addStringControl(dictionary, key, section);
} else if (type.isEnum()) {
@@ -182,6 +185,8 @@
updateIntControl(dictionary, key);
} else if (type == Float.TYPE) {
updateFloatControl(dictionary, key);
+ } else if (type == Double.TYPE) {
+ updateDoubleControl(dictionary, key);
} else if (type == String.class) {
updateStringControl(dictionary, key);
} else if (type.isEnum()) {
@@ -313,6 +318,45 @@
}
}
+ private Component addDoubleControl(final Dictionary<String, Object> dictionary,
+ final String key, Form.Section section) {
+ double value = (Double)dictionary.get(key);
+
+ TextInput textInput = new TextInput();
+ textInput.setTextSize(14);
+ textInput.setValidator(new DoubleValidator());
+ 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, Double.parseDouble(textInput.getText()));
+ } catch (Exception exception) {
+ double value = (Double)dictionary.get(key);
+ textInput.setText(String.valueOf(value));
+ }
+ }
+ }
+ });
+
+ return textInput;
+ }
+
+ private void updateDoubleControl(Dictionary<String, Object> dictionary, String key) {
+ TextInput textInput = (TextInput)controls.get(key);
+
+ if (textInput != null) {
+ double value = (Double)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);