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/11/04 14:45:54 UTC

svn commit: r832737 - in /incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer: ComponentExplorer.java ComponentExplorer.json component_explorer.wtkx

Author: tvolkert
Date: Wed Nov  4 13:45:53 2009
New Revision: 832737

URL: http://svn.apache.org/viewvc?rev=832737&view=rev
Log:
Finishing touches to component explorer -- added a "WTKX Source" tab

Modified:
    incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/ComponentExplorer.java
    incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/ComponentExplorer.json
    incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/component_explorer.wtkx

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=832737&r1=832736&r2=832737&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 Wed Nov  4 13:45:53 2009
@@ -16,7 +16,10 @@
  */
 package org.apache.pivot.demos.explorer;
 
+import java.io.BufferedInputStream;
+import java.io.InputStream;
 import java.io.IOException;
+import java.net.URL;
 
 import org.apache.pivot.collections.List;
 import org.apache.pivot.collections.Map;
@@ -41,18 +44,20 @@
 import org.apache.pivot.wtk.Mouse;
 import org.apache.pivot.wtk.ScrollPane;
 import org.apache.pivot.wtk.ScrollPane.ScrollBarPolicy;
-import org.apache.pivot.wtk.TabPane;
+import org.apache.pivot.wtk.TextArea;
 import org.apache.pivot.wtk.TreeView;
 import org.apache.pivot.wtk.TreeViewSelectionListener;
 import org.apache.pivot.wtk.Window;
+import org.apache.pivot.wtk.text.Document;
+import org.apache.pivot.wtk.text.PlainTextSerializer;
 import org.apache.pivot.wtkx.WTKXSerializer;
 
 public class ComponentExplorer implements Application {
     private Window window = null;
     private TreeView treeView = null;
-    private Border contentTab = null;
     private ScrollPane contentScrollPane = null;
     private Border contentPane = null;
+    private TextArea sourceTextArea = null;
     private ComponentPropertyInspector componentPropertyInspector = null;
     private ComponentStyleInspector componentStyleInspector = null;
     private EventLogger eventLogger = null;
@@ -78,9 +83,9 @@
         window = (Window)wtkxSerializer.readObject(this, "component_explorer.wtkx");
 
         treeView = wtkxSerializer.getValue("treeView");
-        contentTab = wtkxSerializer.getValue("contentTab");
         contentScrollPane = wtkxSerializer.getValue("contentScrollPane");
         contentPane = wtkxSerializer.getValue("contentPane");
+        sourceTextArea = wtkxSerializer.getValue("sourceTextArea");
         componentPropertyInspector = wtkxSerializer.getValue("componentPropertyInspector");
         componentStyleInspector = wtkxSerializer.getValue("componentStyleInspector");
         eventLogger = wtkxSerializer.getValue("eventLogger");
@@ -101,16 +106,34 @@
             public void selectedPathsChanged(TreeView treeView,
                 Sequence<Path> previousSelectedPaths) {
                 Component component = null;
-                String tabLabel = null;
 
                 Object node = treeView.getSelectedNode();
                 if (node instanceof ComponentNode) {
                     ComponentNode componentNode = (ComponentNode)node;
-                    tabLabel = componentNode.getText();
+                    URL url = componentNode.getSrc();
+
+                    Document document = null;
+
+                    try {
+                        PlainTextSerializer plainTextSerializer = new PlainTextSerializer("UTF-8");
+                        InputStream inputStream = new BufferedInputStream(url.openStream());
+
+                        try {
+                            document = plainTextSerializer.readObject(inputStream);
+                        } finally {
+                            inputStream.close();
+                        }
+                    } catch (IOException exception) {
+                        throw new RuntimeException(exception);
+                    } catch (SerializationException exception) {
+                        throw new RuntimeException(exception);
+                    }
+
+                    sourceTextArea.setDocument(document);
 
                     WTKXSerializer wtkxSerializer = new WTKXSerializer();
                     try {
-                        component = (Component)wtkxSerializer.readObject(componentNode.getSrc());
+                        component = (Component)wtkxSerializer.readObject(url);
                     } catch (IOException exception) {
                         throw new RuntimeException(exception);
                     } catch (SerializationException exception) {
@@ -148,7 +171,6 @@
                     }
                 }
 
-                TabPane.setLabel(contentTab, tabLabel);
                 contentPane.setContent(component);
                 componentPropertyInspector.setSource(component);
                 componentStyleInspector.setSource(component);

Modified: incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/ComponentExplorer.json
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/ComponentExplorer.json?rev=832737&r1=832736&r2=832737&view=diff
==============================================================================
--- incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/ComponentExplorer.json (original)
+++ incubator/pivot/trunk/demos/src/org/apache/pivot/demos/explorer/ComponentExplorer.json Wed Nov  4 13:45:53 2009
@@ -1,5 +1,50 @@
 {
-    properties: "Properties",
-    styles: "Styles",
-    events: "Events"
+    title: "Apache Pivot Component Explorer",
+
+    explorerPane: {
+        label: "Component Explorer",
+
+        branches: {
+            basic: "Labels & Image Views",
+            buttons: "Buttons",
+            lists: "Lists",
+            text: "Text",
+            separators: "Separators",
+            layout: "Layout Containers",
+            navigation: "Navigation Containers",
+            viewports: "Viewports",
+            progress: "Progress Indicators",
+            boundedRange: "Bounded Range Components",
+            calendars: "Calendars",
+            colorChoosers: "Color Choosers",
+            menus: "Menus",
+            tables: "Tables",
+            trees: "Trees",
+            fileBrowsing: " File Browsing"
+        }
+    },
+
+    contentPane: {
+        visualizationLabel: "Visualization",
+        wtkxSourceLabel: "WTKX Source",
+
+        scrollBarPolicy: {
+            horizontal: "Horizontal Scroll Bar Policy",
+            vertical: "Vertical Scroll Bar Policy",
+            auto: "Auto",
+            fill: "Fill",
+            fillToCapacity: "Fill To Capacity",
+            never: "Never"
+        }
+    },
+
+    inspectorPane: {
+        propertiesLabel: "Properties",
+        stylesLabel: "Styles"
+    },
+
+    eventLoggerPane: {
+        label: "Event Log",
+        clear: "Clear Event Log"
+    }
 }

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=832737&r1=832736&r2=832737&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 Wed Nov  4 13:45:53 2009
@@ -16,7 +16,7 @@
 limitations under the License.
 -->
 
-<Window title="Apache Pivot Component Explorer" maximized="true"
+<Window title="%title" maximized="true"
     xmlns:wtkx="http://pivot.apache.org/wtkx"
     xmlns:content="org.apache.pivot.wtk.content"
     xmlns:tools="org.apache.pivot.tools.wtk"
@@ -28,7 +28,7 @@
                 <left>
                     <TabPane>
                         <tabs>
-                            <Border TabPane.label="Component Explorer">
+                            <Border TabPane.label="%explorerPane.label">
                                 <content>
                                     <ScrollPane horizontalScrollBarPolicy="fill_to_capacity">
                                         <view>
@@ -40,7 +40,7 @@
                                                 <treeData>
                                                     <content:TreeBranch>
                                                         <content:TreeBranch
-                                                            text="Labels &amp; Image Views"
+                                                            text="%explorerPane.branches.basic"
                                                             icon="@folder.png">
                                                             <explorer:ComponentNode
                                                                 text="Label"
@@ -55,7 +55,8 @@
                                                                 horizontalScrollBarPolicy="fill"
                                                                 verticalScrollBarPolicy="fill"/>
                                                         </content:TreeBranch>
-                                                        <content:TreeBranch text="Buttons"
+                                                        <content:TreeBranch
+                                                            text="%explorerPane.branches.buttons"
                                                             icon="@folder.png">
                                                             <explorer:ComponentNode
                                                                 text="PushButton"
@@ -82,7 +83,8 @@
                                                                 horizontalScrollBarPolicy="auto"
                                                                 verticalScrollBarPolicy="auto"/>
                                                         </content:TreeBranch>
-                                                        <content:TreeBranch text="Lists"
+                                                        <content:TreeBranch
+                                                            text="%explorerPane.branches.lists"
                                                             icon="@folder.png">
                                                             <explorer:ComponentNode
                                                                 text="ListView"
@@ -97,7 +99,8 @@
                                                                 horizontalScrollBarPolicy="auto"
                                                                 verticalScrollBarPolicy="auto"/>
                                                         </content:TreeBranch>
-                                                        <content:TreeBranch text="Text"
+                                                        <content:TreeBranch
+                                                            text="%explorerPane.branches.text"
                                                             icon="@folder.png">
                                                             <explorer:ComponentNode
                                                                 text="TextInput"
@@ -112,7 +115,8 @@
                                                                 horizontalScrollBarPolicy="fill"
                                                                 verticalScrollBarPolicy="fill_to_capacity"/>
                                                         </content:TreeBranch>
-                                                        <content:TreeBranch text="Separators"
+                                                        <content:TreeBranch
+                                                            text="%explorerPane.branches.separators"
                                                             icon="@folder.png">
                                                             <explorer:ComponentNode
                                                                 text="Separator"
@@ -121,7 +125,8 @@
                                                                 horizontalScrollBarPolicy="fill"
                                                                 verticalScrollBarPolicy="auto"/>
                                                         </content:TreeBranch>
-                                                        <content:TreeBranch text="Layout Containers"
+                                                        <content:TreeBranch
+                                                            text="%explorerPane.branches.layout"
                                                             icon="@folder.png">
                                                             <explorer:ComponentNode
                                                                 text="FlowPane"
@@ -173,7 +178,7 @@
                                                                 verticalScrollBarPolicy="fill"/>
                                                         </content:TreeBranch>
                                                         <content:TreeBranch
-                                                            text="Navigation Containers"
+                                                            text="%explorerPane.branches.navigation"
                                                             icon="@folder.png">
                                                             <explorer:ComponentNode
                                                                 text="CardPane"
@@ -206,7 +211,7 @@
                                                                 horizontalScrollBarPolicy="auto"
                                                                 verticalScrollBarPolicy="auto"/>
                                                             <content:TreeBranch
-                                                                text="Viewports"
+                                                                text="%explorerPane.branches.viewports"
                                                                 icon="@folder.png">
                                                                 <explorer:ComponentNode
                                                                     text="ScrollPane"
@@ -223,7 +228,7 @@
                                                             </content:TreeBranch>
                                                         </content:TreeBranch>
                                                         <content:TreeBranch
-                                                            text="Progress Indicators"
+                                                            text="%explorerPane.branches.progress"
                                                             icon="@folder.png">
                                                             <explorer:ComponentNode
                                                                 text="Meter"
@@ -239,7 +244,7 @@
                                                                 verticalScrollBarPolicy="auto"/>
                                                         </content:TreeBranch>
                                                         <content:TreeBranch
-                                                            text="Bounded Range Components"
+                                                            text="%explorerPane.branches.boundedRange"
                                                             icon="@folder.png">
                                                             <explorer:ComponentNode
                                                                 text="ScrollBar"
@@ -261,7 +266,7 @@
                                                                 verticalScrollBarPolicy="auto"/>
                                                         </content:TreeBranch>
                                                         <content:TreeBranch
-                                                            text="Calendars"
+                                                            text="%explorerPane.branches.calendars"
                                                             icon="@folder.png">
                                                             <explorer:ComponentNode
                                                                 text="Calendar"
@@ -277,7 +282,7 @@
                                                                 verticalScrollBarPolicy="auto"/>
                                                         </content:TreeBranch>
                                                         <content:TreeBranch
-                                                            text="Color Choosers"
+                                                            text="%explorerPane.branches.colorChoosers"
                                                             icon="@folder.png">
                                                             <explorer:ComponentNode
                                                                 text="ColorChooser"
@@ -293,7 +298,7 @@
                                                                 verticalScrollBarPolicy="auto"/>
                                                         </content:TreeBranch>
                                                         <content:TreeBranch
-                                                            text="Menus"
+                                                            text="%explorerPane.branches.menus"
                                                             icon="@folder.png">
                                                             <explorer:ComponentNode
                                                                 text="MenuBar"
@@ -309,7 +314,7 @@
                                                                 verticalScrollBarPolicy="auto"/>
                                                         </content:TreeBranch>
                                                         <content:TreeBranch
-                                                            text="Tables"
+                                                            text="%explorerPane.branches.tables"
                                                             icon="@folder.png">
                                                             <explorer:ComponentNode
                                                                 text="TableView"
@@ -319,7 +324,7 @@
                                                                 verticalScrollBarPolicy="auto"/>
                                                         </content:TreeBranch>
                                                         <content:TreeBranch
-                                                            text="Trees"
+                                                            text="%explorerPane.branches.trees"
                                                             icon="@folder.png">
                                                             <explorer:ComponentNode
                                                                 text="TreeView"
@@ -329,7 +334,7 @@
                                                                 verticalScrollBarPolicy="auto"/>
                                                         </content:TreeBranch>
                                                         <content:TreeBranch
-                                                            text="File Browsing"
+                                                            text="%explorerPane.branches.fileBrowsing"
                                                             icon="@folder.png">
                                                             <explorer:ComponentNode
                                                                 text="FileBrowser"
@@ -355,7 +360,7 @@
                                 <left>
                                     <TabPane>
                                         <tabs>
-                                            <Border wtkx:id="contentTab">
+                                            <Border TabPane.label="%contentPane.visualizationLabel">
                                                 <content>
                                                     <ScrollPane wtkx:id="contentScrollPane">
                                                         <view>
@@ -365,6 +370,17 @@
                                                     </ScrollPane>
                                                 </content>
                                             </Border>
+                                            <Border TabPane.label="%contentPane.wtkxSourceLabel">
+                                                <content>
+                                                    <ScrollPane horizontalScrollBarPolicy="fill">
+                                                        <view>
+                                                            <TextArea wtkx:id="sourceTextArea"
+                                                                editable="false"
+                                                                styles="{font:'Courier 10'}"/>
+                                                        </view>
+                                                    </ScrollPane>
+                                                </content>
+                                            </Border>
                                         </tabs>
                                         <corner>
                                             <BoxPane styles="{padding:{right:6},
@@ -382,7 +398,7 @@
                                                         <Menu>
                                                             <sections>
                                                                 <Menu.Section>
-                                                                    <Menu.Item buttonData="Horizontal Scroll Bar Policy">
+                                                                    <Menu.Item buttonData="%contentPane.scrollBarPolicy.horizontal">
                                                                         <menu>
                                                                             <Menu>
                                                                                 <sections>
@@ -390,25 +406,25 @@
                                                                                         <Menu.Item wtkx:id="horizontalAutoButton"
                                                                                             toggleButton="true"
                                                                                             buttonGroup="$horizontalScrollBarPolicyGroup"
-                                                                                            buttonData="Auto"/>
+                                                                                            buttonData="%contentPane.scrollBarPolicy.auto"/>
                                                                                         <Menu.Item wtkx:id="horizontalFillButton"
                                                                                             toggleButton="true"
                                                                                             buttonGroup="$horizontalScrollBarPolicyGroup"
-                                                                                            buttonData="Fill"/>
+                                                                                            buttonData="%contentPane.scrollBarPolicy.fill"/>
                                                                                         <Menu.Item wtkx:id="horizontalFillToCapacityButton"
                                                                                             toggleButton="true"
                                                                                             buttonGroup="$horizontalScrollBarPolicyGroup"
-                                                                                            buttonData="Fill To Capacity"/>
+                                                                                            buttonData="%contentPane.scrollBarPolicy.fillToCapacity"/>
                                                                                         <Menu.Item wtkx:id="horizontalNeverButton"
                                                                                             toggleButton="true"
                                                                                             buttonGroup="$horizontalScrollBarPolicyGroup"
-                                                                                            buttonData="Never"/>
+                                                                                            buttonData="%contentPane.scrollBarPolicy.never"/>
                                                                                     </Menu.Section>
                                                                                 </sections>
                                                                             </Menu>
                                                                         </menu>
                                                                     </Menu.Item>
-                                                                    <Menu.Item buttonData="Vertical Scroll Bar Policy">
+                                                                    <Menu.Item buttonData="%contentPane.scrollBarPolicy.vertical">
                                                                         <menu>
                                                                             <Menu>
                                                                                 <sections>
@@ -416,19 +432,19 @@
                                                                                         <Menu.Item wtkx:id="verticalAutoButton"
                                                                                             toggleButton="true"
                                                                                             buttonGroup="$verticalScrollBarPolicyGroup"
-                                                                                            buttonData="Auto"/>
+                                                                                            buttonData="%contentPane.scrollBarPolicy.auto"/>
                                                                                         <Menu.Item wtkx:id="verticalFillButton"
                                                                                             toggleButton="true"
                                                                                             buttonGroup="$verticalScrollBarPolicyGroup"
-                                                                                            buttonData="Fill"/>
+                                                                                            buttonData="%contentPane.scrollBarPolicy.fill"/>
                                                                                         <Menu.Item wtkx:id="verticalFillToCapacityButton"
                                                                                             toggleButton="true"
                                                                                             buttonGroup="$verticalScrollBarPolicyGroup"
-                                                                                            buttonData="Fill To Capacity"/>
+                                                                                            buttonData="%contentPane.scrollBarPolicy.fillToCapacity"/>
                                                                                         <Menu.Item wtkx:id="verticalNeverButton"
                                                                                             toggleButton="true"
                                                                                             buttonGroup="$verticalScrollBarPolicyGroup"
-                                                                                            buttonData="Never"/>
+                                                                                            buttonData="%contentPane.scrollBarPolicy.never"/>
                                                                                     </Menu.Section>
                                                                                 </sections>
                                                                             </Menu>
@@ -446,7 +462,7 @@
                                 <right>
                                     <TabPane wtkx:id="inspectorTabPane">
                                         <tabs>
-                                            <Border TabPane.label="%properties">
+                                            <Border TabPane.label="%inspectorPane.propertiesLabel">
                                                 <content>
                                                     <ScrollPane horizontalScrollBarPolicy="fill_to_capacity">
                                                         <view>
@@ -458,7 +474,7 @@
                                                     </ScrollPane>
                                                 </content>
                                             </Border>
-                                            <Border TabPane.label="%styles">
+                                            <Border TabPane.label="%inspectorPane.stylesLabel">
                                                 <content>
                                                     <ScrollPane horizontalScrollBarPolicy="fill_to_capacity">
                                                         <view>
@@ -479,7 +495,7 @@
                             <TabPane>
                                 <tabs>
                                     <tools:EventLogger wtkx:id="eventLogger"
-                                        TabPane.label="Event Log"/>
+                                        TabPane.label="%eventLoggerPane.label"/>
                                 </tabs>
                                 <corner>
                                     <BoxPane styles="{padding:{right:6},
@@ -493,7 +509,7 @@
                                                 <Menu>
                                                     <sections>
                                                         <Menu.Section>
-                                                            <Menu.Item buttonData="Clear Event Log"
+                                                            <Menu.Item buttonData="%eventLoggerPane.clear"
                                                                 ButtonPressListener.buttonPressed="eventLogger.clearLog();"/>
                                                         </Menu.Section>
                                                     </sections>