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/03/16 17:36:28 UTC
svn commit: r754936 [7/38] - in /incubator/pivot/tags/v1.0.1: ./
charts-test/ charts-test/src/ charts-test/src/pivot/
charts-test/src/pivot/charts/ charts-test/src/pivot/charts/test/ charts/
charts/lib/ charts/src/ charts/src/pivot/ charts/src/pivot/ch...
Added: incubator/pivot/tags/v1.0.1/tools/src/pivot/tools/explorer/Explorer.java
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0.1/tools/src/pivot/tools/explorer/Explorer.java?rev=754936&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0.1/tools/src/pivot/tools/explorer/Explorer.java (added)
+++ incubator/pivot/tags/v1.0.1/tools/src/pivot/tools/explorer/Explorer.java Mon Mar 16 16:36:10 2009
@@ -0,0 +1,244 @@
+package pivot.tools.explorer;
+
+import java.util.Locale;
+
+import pivot.collections.ArrayList;
+import pivot.collections.Dictionary;
+import pivot.collections.List;
+import pivot.collections.Sequence;
+import pivot.serialization.JSONSerializer;
+import pivot.tools.explorer.table.renderer.PropertyValueTableViewCellRenderer;
+import pivot.tools.explorer.tree.TreeNodePath;
+import pivot.tools.explorer.tree.renderer.ComponentNodeRenderer;
+import pivot.tools.explorer.utils.Collections;
+import pivot.util.Resources;
+import pivot.util.Vote;
+import pivot.wtk.Application;
+import pivot.wtk.Component;
+import pivot.wtk.ComponentKeyListener;
+import pivot.wtk.Container;
+import pivot.wtk.ContainerListener;
+import pivot.wtk.Dialog;
+import pivot.wtk.DialogStateListener;
+import pivot.wtk.Dimensions;
+import pivot.wtk.Display;
+import pivot.wtk.FocusTraversalPolicy;
+import pivot.wtk.Keyboard;
+import pivot.wtk.Label;
+import pivot.wtk.TableView;
+import pivot.wtk.TreeView;
+import pivot.wtk.TreeViewSelectionListener;
+import pivot.wtk.Keyboard.KeyCode;
+import pivot.wtk.Keyboard.KeyLocation;
+import pivot.wtkx.WTKXSerializer;
+
+public class Explorer implements Application, TreeViewSelectionListener {
+
+ private Resources resources;
+
+ private Display display;
+ private Dictionary<String, String> properties;
+ private Application application;
+
+ private Dialog dialog;
+ private TreeView componentTree;
+ private TableView propertiesTable, stylesTable, attributesTable;
+ private Label statusLabel;
+ private Component attributesTab;
+
+ public void startup(Display display, Dictionary<String, String> properties) throws Exception {
+
+ this.display = display;
+ this.properties = properties;
+
+ Application application = getSubjectApplication();
+ application.startup(display, properties);
+
+ // initialize Explorer
+ String className = getClass().getName().toLowerCase();
+ resources = new Resources(className, Locale.getDefault());
+ WTKXSerializer wtkxSerializer = new WTKXSerializer(resources);
+
+ String resourceName = String.format("%s.wtkx", className.replace('.', '/'));
+ dialog = createMainWindow( application, (Component) wtkxSerializer.readObject(resourceName));
+ dialog.getDialogStateListeners().add(new DialogStateListener() {
+ public Vote previewDialogClose(Dialog dialog, boolean result) {
+ dialog.moveToBack();
+ return Vote.DENY;
+ }
+
+ public void dialogCloseVetoed(Dialog dialog, Vote reason) {
+ // No-op
+ }
+
+ public void dialogClosed(Dialog dialog) {
+ // No-op
+ }
+ });
+
+ statusLabel = (Label) wtkxSerializer.getObjectByName("lbStatus");
+ componentTree = (TreeView) wtkxSerializer.getObjectByName("trComponents");
+ propertiesTable = (TableView) wtkxSerializer.getObjectByName("tbProperties");
+ stylesTable = (TableView) wtkxSerializer.getObjectByName("tbStyles");
+ attributesTable = (TableView) wtkxSerializer.getObjectByName("tbAttributes");
+ attributesTab = (Component)wtkxSerializer.getObjectByName("tabAttributes");
+
+ initComponentTree(componentTree, display);
+
+ display.getContainerListeners().add( new ContainerListener(){
+
+ public void componentInserted(Container container, int index) {
+ refreshComponentTree( Explorer.this.componentTree, Explorer.this.display );
+ }
+
+ public void componentsRemoved(Container container, int index, Sequence<Component> components) {
+ refreshComponentTree( Explorer.this.componentTree, Explorer.this.display );
+ }
+
+ public void contextKeyChanged(Container container, String previousContextKey) {
+ }
+
+ public void focusTraversalPolicyChanged(Container container,
+ FocusTraversalPolicy previousFocusTraversalPolicy) {
+ }});
+
+
+ dialog.open(display);
+
+ componentTree.requestFocus();
+ }
+
+ public boolean shutdown(boolean optional) throws Exception {
+ dialog.close();
+ return application != null? application.shutdown(optional): true;
+ }
+
+
+
+ public void resume() throws Exception {
+ if (application != null) application.resume();
+ }
+
+ public void suspend() throws Exception {
+ if (application != null) application.suspend();
+ }
+
+ /**
+ * Return the application subject to exploring
+ * @return
+ * @throws InstantiationException
+ * @throws IllegalAccessException
+ * @throws ClassNotFoundException
+ */
+ private Application getSubjectApplication() throws InstantiationException, IllegalAccessException, ClassNotFoundException {
+
+ String appClassName = properties.get("applicationClassName");
+ if ( appClassName == null ) {
+ throw new IllegalArgumentException("Application class name argument not found");
+ }
+
+ Object appObject = Class.forName(appClassName).newInstance();
+ if (!( appObject instanceof Application )) {
+ throw new IllegalArgumentException(String.format("'%s' is not an Application", appClassName));
+ }
+
+ return (Application)appObject;
+ }
+
+ /**
+ * Creates and sets up the main explorer window
+ * @param subjectApplication
+ * @param content
+ * @return
+ */
+ private Dialog createMainWindow(Application subjectApplication, Component content) {
+
+ final Dialog dialog = new Dialog(
+ String.format("Pivot Explorer ('%s')", subjectApplication.getClass().getName()),
+ content );
+ dialog.setPreferredSize( new Dimensions( 600, 400 ));
+
+ display.getComponentKeyListeners().add(new ComponentKeyListener() {
+ public boolean keyPressed(Component component, int keyCode, KeyLocation keyLocation) {
+ if (keyCode == KeyCode.E &&
+ Keyboard.isPressed(Keyboard.Modifier.CTRL) &&
+ Keyboard.isPressed(Keyboard.Modifier.ALT)) {
+ dialog.moveToFront();
+ }
+
+ return false;
+ }
+
+ public boolean keyReleased(Component component, int keyCode, KeyLocation keyLocation) {
+ return false;
+ }
+
+ public void keyTyped(Component component, char character) {
+ }
+ });
+
+ return dialog;
+
+ }
+
+
+ private void initComponentTree(final TreeView tree, Iterable<Component> components) {
+
+ tree.getTreeViewSelectionListeners().add(this);
+ //TODO: use preferences to toggle highlighting
+ tree.getComponentMouseListeners().add(new ComponentHighlighter(tree));
+ tree.setNodeRenderer( new ComponentNodeRenderer() );
+
+ }
+
+ private void refreshComponentTree(TreeView treeView, Iterable<Component> components) {
+ Sequence<Integer> selectedPath = treeView.getSelectedPath();
+
+ // build tree data
+ List<ComponentAdapter> componentList = new ArrayList<ComponentAdapter>();
+ for (Component c : components) {
+ if ( c != dialog ) {
+ componentList.add(c instanceof Container ?
+ new ContainerAdapter((Container)c) : new ComponentAdapter(c));
+ }
+ }
+
+ treeView.setTreeData(componentList);
+
+ // select and expand first node if there was no selection previosely
+ if (selectedPath == null
+ || selectedPath.getLength() == 0) {
+ selectedPath = new ArrayList<Integer>();
+ selectedPath.add(0);
+ }
+
+ treeView.setSelectedPath(selectedPath);
+ }
+
+ public void selectionChanged(TreeView treeView) {
+ Sequence<Integer> selectedPath = treeView.getSelectedPath();
+ statusLabel.setText(selectedPath.toString()); // TODO
+
+ if (selectedPath.getLength() > 0) {
+ ComponentAdapter node = (ComponentAdapter)Sequence.Tree.get(treeView.getTreeData(), selectedPath);
+
+ propertiesTable.setTableData(node.getProperties());
+ stylesTable.setTableData(node.getStyles());
+
+ List<TableEntryAdapter> attrs = node.getAttributes();
+ attributesTable.setTableData(attrs);
+ attributesTab.setDisplayable( attrs.getLength() > 0 );
+
+ } else {
+ List<TableEntryAdapter> emptyList = new ArrayList<TableEntryAdapter>(0);
+ propertiesTable.setTableData(emptyList);
+ stylesTable.setTableData(emptyList);
+ }
+
+ PropertyValueTableViewCellRenderer cellRenderer = new PropertyValueTableViewCellRenderer();
+ propertiesTable.getColumns().get(1).setCellRenderer( cellRenderer );
+ stylesTable.getColumns().get(1).setCellRenderer( cellRenderer );
+ attributesTable.getColumns().get(1).setCellRenderer( cellRenderer );
+ }
+
+}
Added: incubator/pivot/tags/v1.0.1/tools/src/pivot/tools/explorer/PropertySheet.java
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0.1/tools/src/pivot/tools/explorer/PropertySheet.java?rev=754936&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0.1/tools/src/pivot/tools/explorer/PropertySheet.java (added)
+++ incubator/pivot/tags/v1.0.1/tools/src/pivot/tools/explorer/PropertySheet.java Mon Mar 16 16:36:10 2009
@@ -0,0 +1,27 @@
+package pivot.tools.explorer;
+
+import pivot.collections.List;
+import pivot.wtk.TableView;
+
+public class PropertySheet extends TableView {
+
+ public PropertySheet() {
+ super();
+ }
+
+ public PropertySheet(List<?> tableData) {
+ super(tableData);
+ }
+
+ @Override
+ public ColumnSequence getColumns() {
+ ColumnSequence columns = super.getColumns();
+ if ( columns.getLength() == 0 ) {
+ columns.add( new Column("Name", "Name", 150 ));
+ columns.add( new Column("Value", "Value", 150, true ));
+ }
+ return columns;
+ }
+
+
+}
Added: incubator/pivot/tags/v1.0.1/tools/src/pivot/tools/explorer/PropertySheetColumn.java
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0.1/tools/src/pivot/tools/explorer/PropertySheetColumn.java?rev=754936&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0.1/tools/src/pivot/tools/explorer/PropertySheetColumn.java (added)
+++ incubator/pivot/tags/v1.0.1/tools/src/pivot/tools/explorer/PropertySheetColumn.java Mon Mar 16 16:36:10 2009
@@ -0,0 +1,9 @@
+/**
+ *
+ */
+package pivot.tools.explorer;
+
+public enum PropertySheetColumn {
+ NAME,
+ VALUE
+}
\ No newline at end of file
Added: incubator/pivot/tags/v1.0.1/tools/src/pivot/tools/explorer/TableEntryAdapter.java
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0.1/tools/src/pivot/tools/explorer/TableEntryAdapter.java?rev=754936&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0.1/tools/src/pivot/tools/explorer/TableEntryAdapter.java (added)
+++ incubator/pivot/tags/v1.0.1/tools/src/pivot/tools/explorer/TableEntryAdapter.java Mon Mar 16 16:36:10 2009
@@ -0,0 +1,89 @@
+package pivot.tools.explorer;
+
+import java.util.Comparator;
+
+import pivot.collections.Dictionary;
+
+/**
+ * Adapts dictionary entry (key/value pair) to be shown in the TableView
+ * TableView should have two columns: name and value
+ *
+ * @author Eugene Ryzhikov
+ * @date Aug 16, 2008
+ *
+ */
+public class TableEntryAdapter implements Dictionary<String, Object>{
+
+ private Dictionary<String, Object> dictionary;
+ private String entryName;
+
+ public static final Comparator<TableEntryAdapter> COMPARATOR = new Comparator<TableEntryAdapter>() {
+
+ public int compare(TableEntryAdapter o1, TableEntryAdapter o2) {
+
+ if ( o1 == o2 ) return 0;
+ if ( o1 == null ) return -1;
+ if ( o2 == null ) return 1;
+
+ return o1.getName().compareTo(o2.getName());
+
+ }
+
+ };
+
+
+ public TableEntryAdapter( Dictionary<String, Object> dictionary, String entryName ) {
+
+ if ( dictionary == null ) {
+ throw new IllegalArgumentException( "Dictionary is null");
+ }
+
+ if ( entryName == null || entryName.trim().length() == 0 ) {
+ throw new IllegalArgumentException( "Entry name is empty");
+ }
+
+ this.dictionary = dictionary;
+ this.entryName = entryName;
+
+ }
+
+ protected String getName() {
+ return entryName;
+ }
+
+ public Object get(String key) {
+
+ switch( asColumn( key )) {
+ case NAME : return getName();
+ case VALUE: return getValue();
+ default : return null;
+ }
+ }
+
+ public Object getValue() {
+ return dictionary.get(getName());
+ }
+
+ public Object put(String key, Object value) {
+ return PropertySheetColumn.VALUE == asColumn( key )? dictionary.put(getName(), value): null;
+ }
+
+
+
+ protected PropertySheetColumn asColumn( String key ) {
+ return PropertySheetColumn.valueOf( key == null? "": key.toUpperCase());
+ }
+
+ public boolean containsKey(String key) {
+ return asColumn( key ) != null;
+ }
+
+ public boolean isEmpty() {
+ return false;
+ }
+
+ public Object remove(String key) {
+ return null;
+ }
+
+}
\ No newline at end of file
Added: incubator/pivot/tags/v1.0.1/tools/src/pivot/tools/explorer/explorer.json
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0.1/tools/src/pivot/tools/explorer/explorer.json?rev=754936&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0.1/tools/src/pivot/tools/explorer/explorer.json (added)
+++ incubator/pivot/tags/v1.0.1/tools/src/pivot/tools/explorer/explorer.json Mon Mar 16 16:36:10 2009
@@ -0,0 +1,12 @@
+{ mainWindowName: "Pivot Explorer",
+ mainWindowComponentsTabName: "Components",
+ mainWindowPropertiesTabName: "Properties",
+ mainWindowStylesTabName: "Styles",
+ mainWindowAttrbutesTabName: "Attributes",
+ mainWindowSplitLocation: 150,
+ options: "Options",
+ commonBorderStyles: {
+ padding: 0,
+ color: "#cccac2"
+ }
+}
Added: incubator/pivot/tags/v1.0.1/tools/src/pivot/tools/explorer/explorer.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0.1/tools/src/pivot/tools/explorer/explorer.wtkx?rev=754936&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0.1/tools/src/pivot/tools/explorer/explorer.wtkx (added)
+++ incubator/pivot/tags/v1.0.1/tools/src/pivot/tools/explorer/explorer.wtkx Mon Mar 16 16:36:10 2009
@@ -0,0 +1,103 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2008 VMware, Inc.
+
+ Licensed 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.
+-->
+
+<TablePane styles="{padding:3, verticalSpacing:2}"
+ xmlns:wtkx="http://pivot-toolkit.org/wtkx/2008" xmlns="pivot.wtk"
+ xmlns:explorer="pivot.tools.explorer">
+ <columns>
+ <TablePane.Column width="1*" />
+ </columns>
+ <rows>
+ <TablePane.Row height="1*">
+ <SplitPane orientation="horizontal" splitLocation="180">
+ <left>
+ <TabPane tabOrientation="horizontal" selectedIndex="0">
+ <tabs>
+ <Border TabPane.name="%mainWindowComponentsTabName" styles="%commonBorderStyles">
+ <content>
+ <ScrollPane horizontalScrollBarPolicy="fillToCapacity">
+ <view>
+ <TreeView wtkx:id="trComponents"/>
+ </view>
+ </ScrollPane>
+ </content>
+ </Border>
+ </tabs>
+ </TabPane>
+ </left>
+ <right>
+ <TabPane tabOrientation="horizontal" selectedIndex="0">
+ <tabs>
+ <Border TabPane.name="%mainWindowPropertiesTabName" styles="%commonBorderStyles">
+ <content>
+ <ScrollPane horizontalScrollBarPolicy="fillToCapacity">
+ <view>
+ <explorer:PropertySheet wtkx:id="tbProperties" selectMode="single"/>
+ </view>
+ <columnHeader>
+ <TableViewHeader wtkx:id="tbPropertiesHeader" tableView="$tbProperties" />
+ </columnHeader>
+ </ScrollPane>
+ </content>
+ </Border>
+ <Border TabPane.name="%mainWindowStylesTabName" styles="%commonBorderStyles">
+ <content>
+ <ScrollPane horizontalScrollBarPolicy="fillToCapacity">
+ <view>
+ <explorer:PropertySheet wtkx:id="tbStyles" selectMode="single"/>
+ </view>
+ <columnHeader>
+ <TableViewHeader wtkx:id="tbStylesHeader" tableView="$tbStyles" />
+ </columnHeader>
+ </ScrollPane>
+ </content>
+ </Border>
+ <Border wtkx:id="tabAttributes" TabPane.name="%mainWindowAttrbutesTabName" styles="%commonBorderStyles">
+ <content>
+ <ScrollPane horizontalScrollBarPolicy="fillToCapacity">
+ <view>
+ <explorer:PropertySheet wtkx:id="tbAttributes" selectMode="single"/>
+ </view>
+ <columnHeader>
+ <TableViewHeader wtkx:id="tbAttributesHeader" tableView="$tbAttributes" />
+ </columnHeader>
+ </ScrollPane>
+ </content>
+ </Border>
+ </tabs>
+ </TabPane>
+ </right>
+ </SplitPane>
+ </TablePane.Row>
+
+ <TablePane.Row height="-1">
+ <TablePane>
+ <columns>
+ <TablePane.Column width="1*" />
+ <TablePane.Column width="-1" />
+ </columns>
+ <rows>
+ <TablePane.Row height="-1">
+ <Label wtkx:id="lbStatus"/>
+ <LinkButton wtkx:id="optionsButton" buttonData="%options"/>
+ </TablePane.Row>
+ </rows>
+ </TablePane>
+ </TablePane.Row>
+
+ </rows>
+</TablePane>
Added: incubator/pivot/tags/v1.0.1/tools/src/pivot/tools/explorer/table/renderer/AbstractFlowPaneTableViewCellRenderer.java
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0.1/tools/src/pivot/tools/explorer/table/renderer/AbstractFlowPaneTableViewCellRenderer.java?rev=754936&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0.1/tools/src/pivot/tools/explorer/table/renderer/AbstractFlowPaneTableViewCellRenderer.java (added)
+++ incubator/pivot/tags/v1.0.1/tools/src/pivot/tools/explorer/table/renderer/AbstractFlowPaneTableViewCellRenderer.java Mon Mar 16 16:36:10 2009
@@ -0,0 +1,94 @@
+package pivot.tools.explorer.table.renderer;
+
+import java.awt.Color;
+import java.awt.Font;
+
+import pivot.collections.Dictionary;
+import pivot.wtk.Component;
+import pivot.wtk.FlowPane;
+import pivot.wtk.HorizontalAlignment;
+import pivot.wtk.Insets;
+import pivot.wtk.TableView;
+import pivot.wtk.VerticalAlignment;
+import pivot.wtk.TableView.Column;
+
+/**
+ * Base for renderers which use FlowPane
+ *
+ * @author Eugene Ryzhikov
+ * @date Aug 19, 2008
+ *
+ */
+public abstract class AbstractFlowPaneTableViewCellRenderer extends FlowPane implements TableView.CellRenderer {
+
+ public AbstractFlowPaneTableViewCellRenderer() {
+ super();
+
+ StyleDictionary styles = getStyles();
+ styles.put("verticalAlignment", VerticalAlignment.CENTER);
+ styles.put("horizontalAlignment", HorizontalAlignment.LEFT);
+ styles.put("padding", new Insets(2));
+
+ }
+
+ @Override
+ public void setSize(int width, int height) {
+ super.setSize(width, height);
+
+ // Since this component doesn't have a parent, it won't be validated
+ // via layout; ensure that it is valid here
+ validate();
+ }
+
+ @SuppressWarnings("unchecked")
+ protected final Object getCellData( Object value, Column column ) {
+ String columnName = column.getName();
+ if (columnName != null && (value instanceof Dictionary)) {
+ return ((Dictionary<String, Object>)value).get(columnName);
+ } else {
+ return null;
+ }
+ }
+
+ protected Component getStyleComponent() {
+ return this;
+ }
+
+ public final void render(Object value, TableView tableView, Column column, boolean rowSelected, boolean rowHighlighted,
+ boolean rowDisabled) {
+
+ render(getCellData(value, column));
+ renderStyles( getStyleComponent(), tableView, rowSelected, rowDisabled);
+
+ }
+
+ protected abstract void render( Object cellData );
+
+ protected final void renderStyles( Component styleComponent, TableView tableView, boolean rowSelected, boolean rowDisabled) {
+ Component.StyleDictionary tableViewStyles = tableView.getStyles();
+ Component.StyleDictionary styles = styleComponent.getStyles();
+
+ Object font = tableViewStyles.get("font");
+
+ if (font instanceof Font) {
+ styles.put("font", font);
+ }
+
+
+ String styleKey = "disabledColor";
+ if (tableView.isEnabled() && !rowDisabled) {
+ if (rowSelected) {
+ styleKey = tableView.isFocused()? "selectionColor": "inactiveSelectionColor";
+ } else {
+ styleKey = "color";
+ }
+ }
+
+ Object color = tableViewStyles.get( styleKey );
+
+ if (color instanceof Color) {
+ styles.put("color", color);
+ }
+ }
+
+}
Added: incubator/pivot/tags/v1.0.1/tools/src/pivot/tools/explorer/table/renderer/BooleanPropertyCelRenderer.java
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0.1/tools/src/pivot/tools/explorer/table/renderer/BooleanPropertyCelRenderer.java?rev=754936&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0.1/tools/src/pivot/tools/explorer/table/renderer/BooleanPropertyCelRenderer.java (added)
+++ incubator/pivot/tags/v1.0.1/tools/src/pivot/tools/explorer/table/renderer/BooleanPropertyCelRenderer.java Mon Mar 16 16:36:10 2009
@@ -0,0 +1,30 @@
+/**
+ *
+ */
+package pivot.tools.explorer.table.renderer;
+
+import pivot.wtk.Checkbox;
+import pivot.wtk.Component;
+
+class BooleanPropertyCelRenderer extends AbstractFlowPaneTableViewCellRenderer {
+
+ private Checkbox checkbox = new Checkbox();
+
+ public BooleanPropertyCelRenderer() {
+ super();
+ add(checkbox);
+ }
+
+ protected Component getStyleComponent() {
+ return checkbox;
+ }
+
+ @Override
+ protected void render(Object cellData) {
+ if ( cellData instanceof Boolean ) {
+ checkbox.setSelected( ((Boolean)cellData).booleanValue());
+ }
+ }
+
+
+}
\ No newline at end of file
Added: incubator/pivot/tags/v1.0.1/tools/src/pivot/tools/explorer/table/renderer/ColorTableViewCellRenderer.java
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0.1/tools/src/pivot/tools/explorer/table/renderer/ColorTableViewCellRenderer.java?rev=754936&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0.1/tools/src/pivot/tools/explorer/table/renderer/ColorTableViewCellRenderer.java (added)
+++ incubator/pivot/tags/v1.0.1/tools/src/pivot/tools/explorer/table/renderer/ColorTableViewCellRenderer.java Mon Mar 16 16:36:10 2009
@@ -0,0 +1,69 @@
+package pivot.tools.explorer.table.renderer;
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+
+import pivot.wtk.Component;
+import pivot.wtk.ImageView;
+import pivot.wtk.Label;
+import pivot.wtk.media.Image;
+
+public class ColorTableViewCellRenderer extends AbstractFlowPaneTableViewCellRenderer {
+ private class ColorBadge extends Image {
+ private Color color = Color.BLACK;
+ public static final int SIZE = 14;
+
+ public int getWidth() {
+ return SIZE;
+ }
+
+ public int getHeight() {
+ return SIZE;
+ }
+
+ public Color getColor() {
+ return color;
+ }
+
+ public void setColor(Color color) {
+ this.color = color;
+ }
+
+ public void paint(Graphics2D graphics) {
+ graphics.setColor(color);
+ graphics.fillRect(0, 0, SIZE, SIZE);
+ graphics.setColor(Color.GRAY);
+ graphics.drawRect(0, 0, SIZE - 1, SIZE - 1);
+ graphics.setColor(Color.WHITE);
+ graphics.drawRect(1, 1, SIZE - 3, SIZE - 3);
+ graphics.dispose();
+ }
+ }
+
+ private ColorBadge colorBadge = new ColorBadge();
+ private Label label = new Label();
+
+ public ColorTableViewCellRenderer() {
+ super();
+ add(new ImageView(colorBadge));
+ add(label);
+ }
+
+ @Override
+ protected Component getStyleComponent() {
+ return label;
+ }
+
+ public void render(Object cellData) {
+ if (cellData instanceof Color) {
+ Color color = (Color)cellData;
+ colorBadge.setColor(color);
+ label.setText(colorToHex(color));
+ }
+ }
+
+ private String colorToHex(Color color) {
+ return String.format("#%02x%02x%02x", color.getRed(), color.getGreen(),
+ color.getBlue());
+ }
+}
Added: incubator/pivot/tags/v1.0.1/tools/src/pivot/tools/explorer/table/renderer/PropertyValueTableViewCellRenderer.java
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0.1/tools/src/pivot/tools/explorer/table/renderer/PropertyValueTableViewCellRenderer.java?rev=754936&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0.1/tools/src/pivot/tools/explorer/table/renderer/PropertyValueTableViewCellRenderer.java (added)
+++ incubator/pivot/tags/v1.0.1/tools/src/pivot/tools/explorer/table/renderer/PropertyValueTableViewCellRenderer.java Mon Mar 16 16:36:10 2009
@@ -0,0 +1,67 @@
+package pivot.tools.explorer.table.renderer;
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.util.Date;
+
+import pivot.collections.HashMap;
+import pivot.collections.Map;
+import pivot.tools.explorer.TableEntryAdapter;
+import pivot.wtk.TableView;
+import pivot.wtk.TableView.Column;
+import pivot.wtk.content.TableViewCellRenderer;
+import pivot.wtk.content.TableViewDateCellRenderer;
+
+public class PropertyValueTableViewCellRenderer extends TableViewCellRenderer {
+
+ private Map<Class<?>, TableView.CellRenderer> map = new HashMap<Class<?>, TableView.CellRenderer>();
+ private TableView.CellRenderer defaultRenderer = new TableViewCellRenderer();
+ private TableView.CellRenderer lastRenderer = defaultRenderer;
+
+
+ public PropertyValueTableViewCellRenderer() {
+ super();
+
+ map.put(Boolean.class, new BooleanPropertyCelRenderer());
+ map.put(Date.class, new TableViewDateCellRenderer());
+ map.put(Color.class, new ColorTableViewCellRenderer());
+
+ }
+
+
+ @Override
+ public void render(
+ Object value,
+ TableView tableView,
+ Column column,
+ boolean rowSelected,
+ boolean rowHighlighted,
+ boolean rowDisabled) {
+
+ lastRenderer = getRenderer(value);
+ lastRenderer.render(value, tableView, column, rowSelected, rowHighlighted, rowDisabled);
+
+ }
+
+ private TableView.CellRenderer getRenderer(Object value) {
+ if (value instanceof TableEntryAdapter) {
+ Object propertyValue = ((TableEntryAdapter)value).getValue();
+ if ( propertyValue != null ) {
+ TableView.CellRenderer renderer = map.get(propertyValue.getClass());
+ if ( renderer != null ) return renderer;
+ }
+ }
+ return defaultRenderer;
+ }
+
+ @Override
+ public void paint(Graphics2D graphics) {
+ lastRenderer.paint(graphics);
+ }
+
+ @Override
+ public void setSize(int width, int height) {
+ lastRenderer.setSize(width, height);
+ }
+
+}
Added: incubator/pivot/tags/v1.0.1/tools/src/pivot/tools/explorer/tree/TreeNodePath.java
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0.1/tools/src/pivot/tools/explorer/tree/TreeNodePath.java?rev=754936&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0.1/tools/src/pivot/tools/explorer/tree/TreeNodePath.java (added)
+++ incubator/pivot/tags/v1.0.1/tools/src/pivot/tools/explorer/tree/TreeNodePath.java Mon Mar 16 16:36:10 2009
@@ -0,0 +1,88 @@
+package pivot.tools.explorer.tree;
+
+import pivot.collections.ArrayList;
+import pivot.collections.List;
+import pivot.collections.Sequence;
+import pivot.tools.explorer.utils.Strings;
+import pivot.wtk.TreeView;
+
+/**
+ * List of tree nodes. Usually represents tree path.
+ *
+ * @author Eugene Ryzhikov
+ * @date Jul 31, 2008
+ *
+ * @param <T>
+ */
+public class TreeNodePath<T> extends ArrayList<T> {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Creates tree node path based on provided node index path
+ * @param <T>
+ * @param treeView
+ * @param indexPath
+ * @return
+ */
+ public static final <T extends Sequence<T>> TreeNodePath<T> create( final TreeView treeView, final Sequence<Integer> indexPath ) {
+
+ final TreeNodePath<T> result = new TreeNodePath<T>();
+
+ new TreePathVisitor<T>() {
+ @Override
+ protected void visit(T node) {
+ result.add(node);
+ }
+ }.start(treeView, indexPath);
+
+ return result;
+
+ }
+
+ public static final <T extends Sequence<T>> TreeNodePath<T> createFromSelection( final TreeView treeView ) {
+ return create( treeView, treeView.getSelectedPath());
+ }
+
+ /**
+ * Attmpts to set tree node path as selected tree in the tree
+ * @param tree
+ */
+ @SuppressWarnings("unchecked")
+ public Sequence<Integer> toIndexPath( final TreeView tree ) {
+
+ List<Integer> indexPath = new ArrayList<Integer>();
+
+ Sequence<T> nodes = (Sequence<T>) tree.getTreeData();
+
+ int index;
+ T node;
+ for ( int i=0, s=getLength(); i<s; i++ ) {
+
+ node = get(i);
+ index = nodes.indexOf(node);
+ if ( index < 0 ) break;
+
+ indexPath.add(index);
+ if ( node instanceof Sequence<?> ) {
+ nodes = (Sequence<T>) node;
+ } else {
+ throw new RuntimeException( "Node does not support List interface");
+ }
+
+ }
+
+ return indexPath;
+
+ }
+
+ public void applyAsSelection( TreeView tree ) {
+ tree.setSelectedPath( toIndexPath(tree));
+ }
+
+ @Override
+ public String toString() {
+ return Strings.createDelimited( this, "/");
+ }
+
+}
Added: incubator/pivot/tags/v1.0.1/tools/src/pivot/tools/explorer/tree/TreePathVisitor.java
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0.1/tools/src/pivot/tools/explorer/tree/TreePathVisitor.java?rev=754936&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0.1/tools/src/pivot/tools/explorer/tree/TreePathVisitor.java (added)
+++ incubator/pivot/tags/v1.0.1/tools/src/pivot/tools/explorer/tree/TreePathVisitor.java Mon Mar 16 16:36:10 2009
@@ -0,0 +1,47 @@
+/**
+ *
+ */
+package pivot.tools.explorer.tree;
+
+import pivot.collections.Sequence;
+import pivot.wtk.TreeView;
+
+/**
+ * Represents a "closure" visiting all the nodes in provided tree path.
+ * Assumes that tree nodes implement List interface of the same type
+ *
+ * @author Eugene Ryzhikov
+ * @date Jul 24, 2008
+ *
+ * @param <T> tree node type
+ */
+public abstract class TreePathVisitor<T extends Sequence<T>> {
+
+
+ /**
+ * Starts visiting process
+ * @param treeView
+ * @param path
+ */
+ @SuppressWarnings("unchecked")
+ public final void start( TreeView treeView, Sequence<Integer> path ) {
+
+ if (path==null) return;
+
+ Sequence<T> nodes = (Sequence<T>) treeView.getTreeData();
+
+ for ( int i=0, s=path.getLength(); i< s; i++ ) {
+ T node = nodes.get( path.get(i) );
+ visit( node );
+ if ( node instanceof Sequence<?> ) {
+ nodes = (Sequence<T>) node;
+ } else {
+ throw new RuntimeException( "Node does not support List interface");
+ }
+ }
+
+ }
+
+ protected abstract void visit( T node );
+
+}
\ No newline at end of file
Added: incubator/pivot/tags/v1.0.1/tools/src/pivot/tools/explorer/tree/renderer/ComponentNodeRenderer.java
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0.1/tools/src/pivot/tools/explorer/tree/renderer/ComponentNodeRenderer.java?rev=754936&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0.1/tools/src/pivot/tools/explorer/tree/renderer/ComponentNodeRenderer.java (added)
+++ incubator/pivot/tags/v1.0.1/tools/src/pivot/tools/explorer/tree/renderer/ComponentNodeRenderer.java Mon Mar 16 16:36:10 2009
@@ -0,0 +1,124 @@
+package pivot.tools.explorer.tree.renderer;
+
+import java.awt.Color;
+import java.awt.Font;
+
+import pivot.tools.explorer.ComponentAdapter;
+import pivot.wtk.Component;
+import pivot.wtk.FlowPane;
+import pivot.wtk.HorizontalAlignment;
+import pivot.wtk.ImageView;
+import pivot.wtk.Label;
+import pivot.wtk.TreeView;
+import pivot.wtk.VerticalAlignment;
+import pivot.wtk.media.Image;
+
+public class ComponentNodeRenderer extends FlowPane implements TreeView.NodeRenderer {
+ protected ImageView imageView = new ImageView();
+ protected Label label = new Label();
+
+ public static final int DEFAULT_ICON_WIDTH = 16;
+ public static final int DEFAULT_ICON_HEIGHT = 16;
+ public static boolean DEFAULT_SHOW_ICON = true;
+
+ public ComponentNodeRenderer() {
+ getStyles().put("horizontalAlignment", HorizontalAlignment.LEFT);
+ getStyles().put("verticalAlignment", VerticalAlignment.CENTER);
+
+ add(imageView);
+ add(label);
+
+ imageView.setPreferredSize(DEFAULT_ICON_WIDTH, DEFAULT_ICON_HEIGHT);
+ imageView.setDisplayable(DEFAULT_SHOW_ICON);
+
+ setPreferredHeight(DEFAULT_ICON_HEIGHT);
+ }
+
+ public void setSize(int width, int height) {
+ super.setSize(width, height);
+
+ // Since this component doesn't have a parent, it won't be validated
+ // via layout; ensure that it is valid here
+ validate();
+ }
+
+ @SuppressWarnings("unchecked")
+ public void render(Object node, TreeView treeView, boolean expanded,
+ boolean selected, boolean highlighted, boolean disabled) {
+ ComponentAdapter componentAdapter = (ComponentAdapter)node;
+ Image icon = componentAdapter.getIcon();
+ String text = componentAdapter.getText();
+
+ // Update the image view
+ imageView.setImage(icon);
+ imageView.getStyles().put("opacity",
+ (treeView.isEnabled() && !disabled) ? 1.0f : 0.5f);
+
+ // Show/hide the label
+ if (text == null) {
+ label.setDisplayable(false);
+ } else {
+ label.setDisplayable(true);
+ label.setText(text);
+
+ // Update the label styles
+ Component.StyleDictionary labelStyles = label.getStyles();
+
+ Object labelFont = treeView.getStyles().get("font");
+ if (labelFont instanceof Font) {
+ labelStyles.put("font", labelFont);
+ }
+
+ Object color = null;
+ if (treeView.isEnabled() && !disabled) {
+ if (selected) {
+ if (treeView.isFocused()) {
+ color = treeView.getStyles().get("selectionColor");
+ } else {
+ color = treeView.getStyles().get("inactiveSelectionColor");
+ }
+ } else {
+ color = treeView.getStyles().get("color");
+ }
+ } else {
+ color = treeView.getStyles().get("disabledColor");
+ }
+
+ if (color instanceof Color) {
+ labelStyles.put("color", color);
+ }
+ }
+ }
+
+ public int getIconWidth() {
+ return imageView.getPreferredWidth(-1);
+ }
+
+ public void setIconWidth(int iconWidth) {
+ if (iconWidth == -1) {
+ throw new IllegalArgumentException();
+ }
+
+ imageView.setPreferredWidth(iconWidth);
+ }
+
+ public int getIconHeight() {
+ return imageView.getPreferredHeight(-1);
+ }
+
+ public void setIconHeight(int iconHeight) {
+ if (iconHeight == -1) {
+ throw new IllegalArgumentException();
+ }
+
+ imageView.setPreferredHeight(iconHeight);
+ }
+
+ public boolean getShowIcon() {
+ return imageView.isDisplayable();
+ }
+
+ public void setShowIcon(boolean showIcon) {
+ imageView.setDisplayable(showIcon);
+ }
+}
Added: incubator/pivot/tags/v1.0.1/tools/src/pivot/tools/explorer/utils/Collections.java
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0.1/tools/src/pivot/tools/explorer/utils/Collections.java?rev=754936&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0.1/tools/src/pivot/tools/explorer/utils/Collections.java (added)
+++ incubator/pivot/tags/v1.0.1/tools/src/pivot/tools/explorer/utils/Collections.java Mon Mar 16 16:36:10 2009
@@ -0,0 +1,12 @@
+package pivot.tools.explorer.utils;
+
+import pivot.collections.ArrayList;
+import pivot.collections.List;
+
+public final class Collections {
+
+ public static final <T> List<T> list( T... items ) {
+ return new ArrayList<T>( items );
+ }
+
+}
Added: incubator/pivot/tags/v1.0.1/tools/src/pivot/tools/explorer/utils/Strings.java
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0.1/tools/src/pivot/tools/explorer/utils/Strings.java?rev=754936&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0.1/tools/src/pivot/tools/explorer/utils/Strings.java (added)
+++ incubator/pivot/tags/v1.0.1/tools/src/pivot/tools/explorer/utils/Strings.java Mon Mar 16 16:36:10 2009
@@ -0,0 +1,26 @@
+package pivot.tools.explorer.utils;
+
+/**
+ * String utilities
+ * This class may be later replaced with more common one such as the one from Jakarta Commons
+ *
+ * @author Eugene Ryzhikov
+ * @date Aug 1, 2008
+ *
+ */
+public final class Strings {
+
+ public static final <T> String createDelimited( Iterable<T> data, String delimiter ) {
+
+ if ( data == null ) return "";
+
+ StringBuilder sb = new StringBuilder();
+ for( T item: data ) {
+ if ( sb.length() > 0) sb.append("/");
+ sb.append(item);
+ }
+ return sb.toString();
+
+ }
+
+}
Added: incubator/pivot/tags/v1.0.1/tutorials/.classpath
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0.1/tutorials/.classpath?rev=754936&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0.1/tutorials/.classpath (added)
+++ incubator/pivot/tags/v1.0.1/tutorials/.classpath Mon Mar 16 16:36:10 2009
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/core"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/web"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/wtk"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: incubator/pivot/tags/v1.0.1/tutorials/.project
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0.1/tutorials/.project?rev=754936&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0.1/tutorials/.project (added)
+++ incubator/pivot/tags/v1.0.1/tutorials/.project Mon Mar 16 16:36:10 2009
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>tutorials</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added: incubator/pivot/tags/v1.0.1/tutorials/.settings/org.eclipse.core.resources.prefs
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0.1/tutorials/.settings/org.eclipse.core.resources.prefs?rev=754936&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0.1/tutorials/.settings/org.eclipse.core.resources.prefs (added)
+++ incubator/pivot/tags/v1.0.1/tutorials/.settings/org.eclipse.core.resources.prefs Mon Mar 16 16:36:10 2009
@@ -0,0 +1,4 @@
+#Thu Aug 07 19:50:21 EDT 2008
+eclipse.preferences.version=1
+encoding//src/pivot/tutorials/stocktracker/StockTracker.json=UTF-8
+encoding//src/pivot/tutorials/stocktracker/StockTracker_fr.json=UTF-8
Added: incubator/pivot/tags/v1.0.1/tutorials/src/pivot/tutorials/Demo.java
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0.1/tutorials/src/pivot/tutorials/Demo.java?rev=754936&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0.1/tutorials/src/pivot/tutorials/Demo.java (added)
+++ incubator/pivot/tags/v1.0.1/tutorials/src/pivot/tutorials/Demo.java Mon Mar 16 16:36:10 2009
@@ -0,0 +1,552 @@
+/*
+ * Copyright (c) 2008 VMware, Inc.
+ *
+ * Licensed 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 pivot.tutorials;
+
+import java.awt.Color;
+import java.net.URL;
+
+import pivot.collections.ArrayList;
+import pivot.collections.Dictionary;
+import pivot.collections.List;
+import pivot.collections.Map;
+import pivot.collections.Sequence;
+import pivot.serialization.JSONSerializer;
+import pivot.util.CalendarDate;
+import pivot.util.Vote;
+import pivot.wtk.Action;
+import pivot.wtk.Alert;
+import pivot.wtk.Application;
+import pivot.wtk.ApplicationContext;
+import pivot.wtk.Button;
+import pivot.wtk.ButtonPressListener;
+import pivot.wtk.ComponentKeyListener;
+import pivot.wtk.ComponentMouseButtonListener;
+import pivot.wtk.ComponentMouseListener;
+import pivot.wtk.Dimensions;
+import pivot.wtk.DragDropManager;
+import pivot.wtk.DragHandler;
+import pivot.wtk.DropAction;
+import pivot.wtk.DropHandler;
+import pivot.wtk.ImageView;
+import pivot.wtk.Insets;
+import pivot.wtk.Keyboard;
+import pivot.wtk.Menu;
+import pivot.wtk.MenuPopup;
+import pivot.wtk.MessageType;
+import pivot.wtk.Mouse;
+import pivot.wtk.Point;
+import pivot.wtk.Popup;
+import pivot.wtk.Prompt;
+import pivot.wtk.PushButton;
+import pivot.wtk.Component;
+import pivot.wtk.Display;
+import pivot.wtk.Bounds;
+import pivot.wtk.ScrollPane;
+import pivot.wtk.Spinner;
+import pivot.wtk.TableView;
+import pivot.wtk.TableViewHeader;
+import pivot.wtk.TextInput;
+import pivot.wtk.TreeView;
+import pivot.wtk.Visual;
+import pivot.wtk.Window;
+import pivot.wtk.WindowStateListener;
+import pivot.wtk.content.CalendarDateSpinnerData;
+import pivot.wtk.content.NumericSpinnerData;
+import pivot.wtk.content.TableRow;
+import pivot.wtk.content.TableViewHeaderData;
+import pivot.wtk.content.TreeNode;
+import pivot.wtk.content.TreeViewNodeRenderer;
+import pivot.wtk.effects.ReflectionDecorator;
+import pivot.wtk.media.Image;
+import pivot.wtkx.WTKXSerializer;
+
+public class Demo implements Application {
+ private class TreeViewEditHandler
+ implements ComponentMouseButtonListener, ComponentKeyListener {
+ Sequence<Integer> path = null;
+ boolean armed = false;
+ Popup popup = null;
+
+ private int getNodeLabelOffset() {
+ int nodeLabelOffset = editableTreeView.getNodeOffset(path);
+
+ TreeViewNodeRenderer nodeRenderer =
+ (TreeViewNodeRenderer)editableTreeView.getNodeRenderer();
+
+ nodeLabelOffset += ((Insets)nodeRenderer.getStyles().get("padding")).left;
+ if (nodeRenderer.getShowIcon()) {
+ nodeLabelOffset += nodeRenderer.getIconWidth();
+ nodeLabelOffset += (Integer)nodeRenderer.getStyles().get("spacing");
+ }
+
+ return nodeLabelOffset;
+ }
+
+ public boolean mouseDown(Component component, Mouse.Button button, int x, int y) {
+ return false;
+ }
+
+ public boolean mouseUp(Component component, Mouse.Button button, int x, int y) {
+ path = editableTreeView.getNodeAt(y);
+
+ armed = (popup == null
+ && path != null
+ && Keyboard.getModifiers() == 0
+ && editableTreeView.isPathSelected(path)
+ && x >= getNodeLabelOffset());
+
+ return false;
+ }
+
+ @SuppressWarnings("unchecked")
+ public void mouseClick(Component component, Mouse.Button button, int x, int y,
+ int count) {
+ if (armed
+ && count == 1) {
+ List<Object> treeData = (List<Object>)editableTreeView.getTreeData();
+ TreeNode nodeData = (TreeNode)Sequence.Tree.get(treeData, path);
+
+ Bounds nodeLabelBounds = editableTreeView.getNodeBounds(path);
+ int nodeLabelOffset = getNodeLabelOffset();
+ nodeLabelBounds.x += nodeLabelOffset;
+ nodeLabelBounds.width -= nodeLabelOffset;
+
+ Bounds viewportBounds = editableTreeViewScrollPane.getViewportBounds();
+
+ TextInput textInput = new TextInput();
+ textInput.setText(nodeData.getText());
+ textInput.setPreferredWidth(Math.min(nodeLabelBounds.width,
+ viewportBounds.width - nodeLabelBounds.x));
+ textInput.getComponentKeyListeners().add(this);
+
+ Point treeViewCoordinates =
+ editableTreeView.mapPointToAncestor(window.getDisplay(), 0, 0);
+
+ popup = new Popup(textInput);
+ popup.setLocation(treeViewCoordinates.x + nodeLabelBounds.x,
+ treeViewCoordinates.y + nodeLabelBounds.y
+ + (nodeLabelBounds.height - textInput.getPreferredHeight(-1)) / 2);
+
+ // Ensure that we clear the popup reference
+ popup.getWindowStateListeners().add(new WindowStateListener() {
+ public Vote previewWindowOpen(Window window, Display display) {
+ return Vote.APPROVE;
+ }
+
+ public void windowOpenVetoed(Window window, Vote reason) {
+ }
+
+ public void windowOpened(Window window) {
+ }
+
+ public Vote previewWindowClose(Window window) {
+ return Vote.APPROVE;
+ }
+
+ public void windowCloseVetoed(Window window, Vote reason) {
+ }
+
+ public void windowClosed(Window window, Display display) {
+ popup = null;
+ }
+ });
+
+ popup.open(editableTreeView);
+
+ textInput.requestFocus();
+ }
+
+ armed = false;
+ }
+
+ public void keyTyped(Component component, char character) {
+ }
+
+ @SuppressWarnings("unchecked")
+ public boolean keyPressed(Component component, int keyCode,
+ Keyboard.KeyLocation keyLocation) {
+ if (keyCode == Keyboard.KeyCode.ENTER) {
+ List<Object> treeData = (List<Object>)editableTreeView.getTreeData();
+ TreeNode nodeData = (TreeNode)Sequence.Tree.get(treeData, path);
+
+ TextInput textInput = (TextInput)component;
+ String text = textInput.getText();
+
+ nodeData.setText(text);
+
+ popup.close();
+ editableTreeView.requestFocus();
+ }
+
+ if (keyCode == Keyboard.KeyCode.ESCAPE) {
+ popup.close();
+ editableTreeView.requestFocus();
+ }
+
+ return false;
+ }
+
+ public boolean keyReleased(Component component, int keyCode,
+ Keyboard.KeyLocation keyLocation) {
+ return false;
+ }
+ }
+
+ private static class ImageDragHandler implements DragHandler {
+ ImageView imageView = null;
+ private Image image = null;
+ private Dimensions offset = null;
+
+ public boolean beginDrag(Component component, int x, int y) {
+ imageView = (ImageView)component;
+ image = imageView.getImage();
+
+ if (image != null) {
+ imageView.setImage((Image)null);
+ offset = new Dimensions(x - (imageView.getWidth() - image.getWidth()) / 2,
+ y - (imageView.getHeight() - image.getHeight()) / 2);
+ }
+
+ return (image != null);
+ }
+
+ public void endDrag(DropAction dropAction) {
+ if (dropAction == null) {
+ imageView.setImage(image);
+ }
+ }
+
+ public Object getContent() {
+ return image;
+ }
+
+ public Visual getRepresentation() {
+ return image;
+ }
+
+ public Dimensions getOffset() {
+ return offset;
+ }
+
+ public int getSupportedDropActions() {
+ return DropAction.MOVE.getMask();
+ }
+ }
+
+ private static class ImageDropHandler implements DropHandler {
+ public DropAction drop(Component component, int x, int y) {
+ DropAction dropAction = null;
+
+ DragDropManager dragDropManager = component.getDisplay().getDragDropManager();
+ Object dragContent = dragDropManager.getContent();
+ if (dragContent instanceof Image) {
+ ImageView imageView = (ImageView)component;
+
+ if (imageView.getImage() == null) {
+ imageView.setImage((Image)dragContent);
+ imageView.getStyles().put("backgroundColor", null);
+ dropAction = DropAction.MOVE;
+ }
+ }
+
+ return dropAction;
+ }
+ }
+
+ private static class ImageMouseHandler implements ComponentMouseListener {
+ public static final Color DROP_HIGHLIGHT_COLOR = new Color(0xf0, 0xe6, 0x8c);
+
+ public boolean mouseMove(Component component, int x, int y) {
+ return false;
+ }
+
+ public void mouseOver(Component component) {
+ DragDropManager dragDropManager = component.getDisplay().getDragDropManager();
+
+ if (dragDropManager.isActive()) {
+ Object dragContent = dragDropManager.getContent();
+ ImageView imageView = (ImageView)component;
+
+ if (dragContent instanceof Image
+ && imageView.getImage() == null) {
+ component.getStyles().put("backgroundColor", DROP_HIGHLIGHT_COLOR);
+ }
+ }
+ }
+
+ public void mouseOut(Component component) {
+ component.getStyles().put("backgroundColor", null);
+ }
+ }
+
+ private MenuPopup menuPopup = null;
+ private ImageView menuImageView = null;
+
+ private TableView sortableTableView = null;
+ private TableView customTableView = null;
+ private TableViewHeader sortableTableViewHeader = null;
+
+ private TreeView editableTreeView = null;
+ private ScrollPane editableTreeViewScrollPane = null;
+
+ private PushButton alertButton = null;
+ private PushButton promptButton = null;
+
+ private Window window = null;
+
+ public void startup(final Display display, Dictionary<String, String> properties) throws Exception {
+ // pivot.wtk.Theme.setTheme(new pivot.wtk.skin.terra.TerraTheme("test"));
+
+ WTKXSerializer wtkxSerializer = new WTKXSerializer();
+ Component content = (Component)wtkxSerializer.readObject("pivot/tutorials/demo.wtkx");
+
+ new Action("selectImageAction") {
+ public String getDescription() {
+ return "Select Image Action";
+ }
+
+ public void perform() {
+ Button.Group imageMenuGroup = Button.getGroup("imageMenuGroup");
+ Button selectedItem = imageMenuGroup.getSelection();
+
+ String imageName = (String)selectedItem.getUserData();
+
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+ URL imageURL = classLoader.getResource(imageName);
+
+ // If the image has not been added to the resource cache yet,
+ // add it
+ Image image = (Image)ApplicationContext.getResourceCache().get(imageURL);
+
+ if (image == null) {
+ image = Image.load(imageURL);
+ ApplicationContext.getResourceCache().put(imageURL, image);
+ }
+
+ // Update the image
+ menuImageView.setImage(image);
+ }
+ };
+
+ menuImageView = (ImageView)wtkxSerializer.getObjectByName("menus.imageView");
+ menuImageView.getComponentMouseButtonListeners().add(new ComponentMouseButtonListener() {
+ public boolean mouseDown(Component component, Mouse.Button button, int x, int y) {
+ if (button == Mouse.Button.RIGHT) {
+ menuPopup.open(display, component.mapPointToAncestor(display, x, y));
+ }
+
+ return false;
+ }
+
+ public boolean mouseUp(Component component, Mouse.Button button, int x, int y) {
+ return false;
+ }
+
+ public void mouseClick(Component component, Mouse.Button button, int x, int y, int count) {
+ }
+ });
+
+ sortableTableView = (TableView)wtkxSerializer.getObjectByName("tables.sortableTableView");
+ sortableTableViewHeader = (TableViewHeader)wtkxSerializer.getObjectByName("tables.sortableTableViewHeader");
+ customTableView = (TableView)wtkxSerializer.getObjectByName("tables.customTableView");
+ initializeTableViews();
+
+ editableTreeView = (TreeView)wtkxSerializer.getObjectByName("trees.editableTreeView");
+ editableTreeViewScrollPane = (ScrollPane)wtkxSerializer.getObjectByName("trees.editableTreeViewScrollPane");
+ initializeEditableTreeView();
+
+ Spinner numericSpinner = (Spinner)wtkxSerializer.getObjectByName("spinners.numericSpinner");
+ initializeNumericSpinner(numericSpinner);
+
+ Spinner dateSpinner = (Spinner)wtkxSerializer.getObjectByName("spinners.dateSpinner");
+ initializeDateSpinner(dateSpinner);
+
+ ImageDragHandler imageDragHandler = new ImageDragHandler();
+ ImageDropHandler imageDropHandler = new ImageDropHandler();
+ ImageMouseHandler imageMouseHandler = new ImageMouseHandler();
+
+ ImageView imageView1 = (ImageView)wtkxSerializer.getObjectByName("dragdrop.imageView1");
+ imageView1.setDragHandler(imageDragHandler);
+ imageView1.setDropHandler(imageDropHandler);
+ imageView1.getComponentMouseListeners().add(imageMouseHandler);
+
+ ImageView imageView2 = (ImageView)wtkxSerializer.getObjectByName("dragdrop.imageView2");
+ imageView2.setDragHandler(imageDragHandler);
+ imageView2.setDropHandler(imageDropHandler);
+ imageView2.getComponentMouseListeners().add(imageMouseHandler);
+
+ ImageView imageView3 = (ImageView)wtkxSerializer.getObjectByName("dragdrop.imageView3");
+ imageView3.setDragHandler(imageDragHandler);
+ imageView3.setDropHandler(imageDropHandler);
+ imageView3.getComponentMouseListeners().add(imageMouseHandler);
+
+ alertButton = (PushButton)wtkxSerializer.getObjectByName("alerts.alertButton");
+ promptButton = (PushButton)wtkxSerializer.getObjectByName("alerts.promptButton");
+ initializeAlertButtons();
+
+ menuPopup = new MenuPopup((Menu)wtkxSerializer.readObject("pivot/tutorials/menu_popup.wtkx"));
+
+ window = new Window();
+ window.setTitle("Pivot Demo");
+ window.setMaximized(true);
+ window.setContent(content);
+
+ window.open(display);
+ }
+
+ @SuppressWarnings("unchecked")
+ private void initializeTableViews() {
+ // Set table header data
+ TableView.ColumnSequence columns = sortableTableView.getColumns();
+ columns.get(0).setHeaderData(new TableViewHeaderData("#"));
+ columns.get(1).setHeaderData(new TableViewHeaderData("A"));
+ columns.get(2).setHeaderData(new TableViewHeaderData("B"));
+ columns.get(3).setHeaderData(new TableViewHeaderData("C"));
+ columns.get(4).setHeaderData(new TableViewHeaderData("D"));
+
+ // Populate table
+ ArrayList<Object> tableData = new ArrayList<Object>();
+
+ for (int i = 0; i < 10000; i++) {
+ TableRow tableRow = new TableRow();
+
+ tableRow.put("i", i);
+ tableRow.put("a", (int)Math.round(Math.random() * 10));
+ tableRow.put("b", (int)Math.round(Math.random() * 100));
+ tableRow.put("c", (int)Math.round(Math.random() * 1000));
+ tableRow.put("d", (int)Math.round(Math.random() * 10000));
+
+ tableData.add(tableRow);
+ }
+
+ sortableTableView.setTableData(tableData);
+
+ // Install header press listener
+ sortableTableViewHeader.getTableViewHeaderPressListeners().add(new TableView.SortHandler());
+
+ // Load images for custom table
+ List<?> customTableData = customTableView.getTableData();
+ for (int i = 0, n = customTableData.getLength(); i < n; i++) {
+ TableRow tableRow = (TableRow)customTableData.get(i);
+ tableRow.put("b", Image.load((URL)tableRow.get("b")));
+ }
+ }
+
+ private void initializeEditableTreeView() {
+ TreeViewEditHandler treeViewEditHandler = new TreeViewEditHandler();
+ editableTreeView.getComponentMouseButtonListeners().add(treeViewEditHandler);
+ }
+
+ private void initializeNumericSpinner(Spinner numericSpinner) {
+ NumericSpinnerData numericSpinnerData = new NumericSpinnerData(0, 256, 4);
+ numericSpinner.setSpinnerData(numericSpinnerData);
+ numericSpinner.setSelectedIndex(0);
+ }
+
+ private void initializeDateSpinner(Spinner dateSpinner) {
+ CalendarDate lowerBound = new CalendarDate(2008, 0, 0);
+ CalendarDate upperBound = new CalendarDate(2019, 11, 30);
+ CalendarDateSpinnerData spinnerData = new CalendarDateSpinnerData(lowerBound, upperBound);
+
+ CalendarDate today = new CalendarDate();
+ dateSpinner.setSpinnerData(spinnerData);
+ dateSpinner.setSelectedValue(today);
+ }
+
+ @SuppressWarnings("unchecked")
+ private void initializeAlertButtons() {
+ alertButton.getButtonPressListeners().add(new ButtonPressListener() {
+ public void buttonPressed(Button button) {
+ Button.Group messageTypeGroup = Button.getGroup("messageType");
+ Button selection = messageTypeGroup.getSelection();
+
+ Map<String, ?> userData = JSONSerializer.parseMap((String)selection.getUserData());
+ String messageType = (String)userData.get("type");
+
+ if (messageType.equals("custom")) {
+ ArrayList<String> options = new ArrayList<String>();
+ options.add("OK");
+ options.add("Cancel");
+
+ Component body = null;
+ WTKXSerializer wtkxSerializer = new WTKXSerializer();
+ try {
+ body = (Component)wtkxSerializer.readObject("pivot/tutorials/alert.wtkx");
+ } catch(Exception exception) {
+ System.out.println(exception);
+ }
+
+ Alert alert = new Alert(MessageType.QUESTION, "Please select your favorite icon:",
+ options, body);
+ alert.setTitle("Select Icon");
+ alert.setSelectedOption(0);
+ alert.getDecorators().update(0, new ReflectionDecorator());
+
+ alert.open(window);
+ } else {
+ String message = (String)userData.get("message");
+ Alert.alert(MessageType.decode(messageType), message, window);
+ }
+ }
+ });
+
+ promptButton.getButtonPressListeners().add(new ButtonPressListener() {
+ public void buttonPressed(Button button) {
+ Button.Group messageTypeGroup = Button.getGroup("messageType");
+ Button selection = messageTypeGroup.getSelection();
+
+ Map<String, ?> userData = JSONSerializer.parseMap((String)selection.getUserData());
+ String messageType = (String)userData.get("type");
+
+ if (messageType.equals("custom")) {
+ ArrayList<String> options = new ArrayList<String>();
+ options.add("OK");
+ options.add("Cancel");
+
+ Component body = null;
+ WTKXSerializer wtkxSerializer = new WTKXSerializer();
+ try {
+ body = (Component)wtkxSerializer.readObject("pivot/tutorials/alert.wtkx");
+ } catch(Exception exception) {
+ System.out.println(exception);
+ }
+
+ Prompt prompt = new Prompt(MessageType.QUESTION, "Please select your favorite icon:",
+ options, body);
+ prompt.setTitle("Select Icon");
+ prompt.setSelectedOption(0);
+ prompt.getDecorators().update(0, new ReflectionDecorator());
+
+ prompt.open(window);
+ } else {
+ String message = (String)userData.get("message");
+ Prompt.prompt(MessageType.decode(messageType), message, window);
+ }
+ }
+ });
+ }
+
+ public boolean shutdown(boolean optional) throws Exception {
+ window.close();
+ return true;
+ }
+
+ public void suspend() throws Exception {
+ }
+
+ public void resume() throws Exception {
+ }
+}
Added: incubator/pivot/tags/v1.0.1/tutorials/src/pivot/tutorials/HelloJava.java
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0.1/tutorials/src/pivot/tutorials/HelloJava.java?rev=754936&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0.1/tutorials/src/pivot/tutorials/HelloJava.java (added)
+++ incubator/pivot/tags/v1.0.1/tutorials/src/pivot/tutorials/HelloJava.java Mon Mar 16 16:36:10 2009
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2008 VMware, Inc.
+ *
+ * Licensed 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 pivot.tutorials;
+
+import java.awt.Color;
+import java.awt.Font;
+
+import pivot.collections.Dictionary;
+import pivot.wtk.Application;
+import pivot.wtk.Display;
+import pivot.wtk.HorizontalAlignment;
+import pivot.wtk.Label;
+import pivot.wtk.VerticalAlignment;
+import pivot.wtk.Window;
+
+public class HelloJava implements Application {
+ private Window window = null;
+
+ public void startup(Display display, Dictionary<String, String> properties) {
+ Label label = new Label();
+ label.setText("Hello World!");
+ label.getStyles().put("font", new Font("Arial", Font.BOLD, 24));
+ label.getStyles().put("color", Color.RED);
+ label.getStyles().put("horizontalAlignment",
+ HorizontalAlignment.CENTER);
+ label.getStyles().put("verticalAlignment",
+ VerticalAlignment.CENTER);
+
+ window = new Window();
+ window.setContent(label);
+ window.setMaximized(true);
+ window.open(display);
+ }
+
+ public boolean shutdown(boolean optional) {
+ window.close();
+ return true;
+ }
+
+ public void suspend() {
+ }
+
+ public void resume() {
+ }
+}
Added: incubator/pivot/tags/v1.0.1/tutorials/src/pivot/tutorials/HelloWTKX.java
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0.1/tutorials/src/pivot/tutorials/HelloWTKX.java?rev=754936&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0.1/tutorials/src/pivot/tutorials/HelloWTKX.java (added)
+++ incubator/pivot/tags/v1.0.1/tutorials/src/pivot/tutorials/HelloWTKX.java Mon Mar 16 16:36:10 2009
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2008 VMware, Inc.
+ *
+ * Licensed 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 pivot.tutorials;
+
+import pivot.collections.Dictionary;
+import pivot.wtk.Application;
+import pivot.wtk.Component;
+import pivot.wtk.Display;
+import pivot.wtk.Window;
+import pivot.wtkx.WTKXSerializer;
+
+public class HelloWTKX implements Application {
+ private Window window = null;
+
+ public void startup(Display display, Dictionary<String, String> properties)
+ throws Exception {
+ WTKXSerializer wtkxSerializer = new WTKXSerializer();
+ Component content =
+ (Component)wtkxSerializer.readObject("pivot/tutorials/hello.wtkx");
+
+ window = new Window();
+ window.setContent(content);
+ window.setMaximized(true);
+ window.open(display);
+ }
+
+ public boolean shutdown(boolean optional) {
+ window.close();
+ return true;
+ }
+
+ public void suspend() {
+ }
+
+ public void resume() {
+ }
+}
Added: incubator/pivot/tags/v1.0.1/tutorials/src/pivot/tutorials/IMG_0725_2.jpg
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0.1/tutorials/src/pivot/tutorials/IMG_0725_2.jpg?rev=754936&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/pivot/tags/v1.0.1/tutorials/src/pivot/tutorials/IMG_0725_2.jpg
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/pivot/tags/v1.0.1/tutorials/src/pivot/tutorials/IMG_0735_2.jpg
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0.1/tutorials/src/pivot/tutorials/IMG_0735_2.jpg?rev=754936&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/pivot/tags/v1.0.1/tutorials/src/pivot/tutorials/IMG_0735_2.jpg
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/pivot/tags/v1.0.1/tutorials/src/pivot/tutorials/IMG_0767_2.jpg
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0.1/tutorials/src/pivot/tutorials/IMG_0767_2.jpg?rev=754936&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/pivot/tags/v1.0.1/tutorials/src/pivot/tutorials/IMG_0767_2.jpg
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/pivot/tags/v1.0.1/tutorials/src/pivot/tutorials/alert.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0.1/tutorials/src/pivot/tutorials/alert.wtkx?rev=754936&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0.1/tutorials/src/pivot/tutorials/alert.wtkx (added)
+++ incubator/pivot/tags/v1.0.1/tutorials/src/pivot/tutorials/alert.wtkx Mon Mar 16 16:36:10 2009
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Copyright (c) 2008 VMware, Inc.
+
+Licensed 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.
+-->
+
+<FlowPane orientation="vertical"
+ xmlns:wtkx="http://pivot-toolkit.org/wtkx/2008"
+ xmlns:content="pivot.wtk.content" xmlns="pivot.wtk">
+ <RadioButton group="icons" selected="true">
+ <buttonData>
+ <content:ButtonData text="Bell" icon="@bell.png"/>
+ </buttonData>
+ </RadioButton>
+ <RadioButton group="icons" selected="true">
+ <buttonData>
+ <content:ButtonData text="Clock" icon="@clock.png"/>
+ </buttonData>
+ </RadioButton>
+ <RadioButton group="icons" selected="true">
+ <buttonData>
+ <content:ButtonData text="House" icon="@house.png"/>
+ </buttonData>
+ </RadioButton>
+</FlowPane>
+
Added: incubator/pivot/tags/v1.0.1/tutorials/src/pivot/tutorials/alerts.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0.1/tutorials/src/pivot/tutorials/alerts.wtkx?rev=754936&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0.1/tutorials/src/pivot/tutorials/alerts.wtkx (added)
+++ incubator/pivot/tags/v1.0.1/tutorials/src/pivot/tutorials/alerts.wtkx Mon Mar 16 16:36:10 2009
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Copyright (c) 2008 VMware, Inc.
+
+Licensed 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.
+-->
+
+<FlowPane xmlns:wtkx="http://pivot-toolkit.org/wtkx/2008"
+ xmlns:content="pivot.wtk.content"
+ xmlns="pivot.wtk">
+ <Border>
+ <content>
+ <FlowPane orientation="vertical" styles="{spacing: 12}">
+ <FlowPane orientation="vertical" styles="{padding: 6, spacing: 6}">
+ <RadioButton buttonData="Error" group="messageType" selected="true"
+ userData="{type:'error', message:'This is an error message.'}"/>
+ <RadioButton buttonData="Warning" group="messageType"
+ userData="{type:'warning', message:'This is a warning message.'}"/>
+ <RadioButton buttonData="Question" group="messageType"
+ userData="{type:'question', message:'This is a question message.'}"/>
+ <RadioButton buttonData="Info" group="messageType"
+ userData="{type:'info', message:'This is an info message.'}"/>
+ <RadioButton buttonData="Custom" group="messageType"
+ userData="{type:'custom', message:'This is a custom message.'}"/>
+
+ <FlowPane>
+ <PushButton wtkx:id="alertButton" buttonData="Show Alert"/>
+ <PushButton wtkx:id="promptButton" buttonData="Show Prompt"/>
+ </FlowPane>
+ </FlowPane>
+ </FlowPane>
+ </content>
+ </Border>
+</FlowPane>
+
Added: incubator/pivot/tags/v1.0.1/tutorials/src/pivot/tutorials/anchor.png
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0.1/tutorials/src/pivot/tutorials/anchor.png?rev=754936&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/pivot/tags/v1.0.1/tutorials/src/pivot/tutorials/anchor.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/pivot/tags/v1.0.1/tutorials/src/pivot/tutorials/application.png
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0.1/tutorials/src/pivot/tutorials/application.png?rev=754936&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/pivot/tags/v1.0.1/tutorials/src/pivot/tutorials/application.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/pivot/tags/v1.0.1/tutorials/src/pivot/tutorials/bell.png
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0.1/tutorials/src/pivot/tutorials/bell.png?rev=754936&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/pivot/tags/v1.0.1/tutorials/src/pivot/tutorials/bell.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/pivot/tags/v1.0.1/tutorials/src/pivot/tutorials/book_open.png
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0.1/tutorials/src/pivot/tutorials/book_open.png?rev=754936&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/pivot/tags/v1.0.1/tutorials/src/pivot/tutorials/book_open.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/pivot/tags/v1.0.1/tutorials/src/pivot/tutorials/buttons.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/tags/v1.0.1/tutorials/src/pivot/tutorials/buttons.wtkx?rev=754936&view=auto
==============================================================================
--- incubator/pivot/tags/v1.0.1/tutorials/src/pivot/tutorials/buttons.wtkx (added)
+++ incubator/pivot/tags/v1.0.1/tutorials/src/pivot/tutorials/buttons.wtkx Mon Mar 16 16:36:10 2009
@@ -0,0 +1,215 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Copyright (c) 2008 VMware, Inc.
+
+Licensed 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.
+-->
+
+<FlowPane xmlns:wtkx="http://pivot-toolkit.org/wtkx/2008"
+ xmlns:content="pivot.wtk.content" xmlns="pivot.wtk">
+ <Border>
+ <content>
+ <FlowPane orientation="vertical" styles="{padding:{top:2, left:4, bottom:4, right:4}, spacing:10}">
+ <FlowPane orientation="vertical">
+ <Label text="Basic Push Buttons" styles="{fontBold:true}"/>
+ <FlowPane>
+ <PushButton buttonData="One"/>
+ <PushButton buttonData="Two"/>
+ <PushButton buttonData="Three" enabled="false"/>
+ </FlowPane>
+ </FlowPane>
+
+ <FlowPane orientation="vertical">
+ <Label text="Ungrouped Toggle Buttons" styles="{fontBold:true}"/>
+ <FlowPane>
+ <PushButton buttonData="One" toggleButton="true"/>
+ <PushButton buttonData="Two" toggleButton="true"/>
+ <PushButton buttonData="Three" toggleButton="true" enabled="false"/>
+ </FlowPane>
+ </FlowPane>
+
+ <FlowPane orientation="vertical">
+ <Label text="Grouped Toggle Buttons" styles="{fontBold:true}"/>
+ <FlowPane>
+ <PushButton buttonData="One" toggleButton="true" group="toggleButtons"/>
+ <PushButton buttonData="Two" toggleButton="true" group="toggleButtons"/>
+ <PushButton buttonData="Three" toggleButton="true" group="toggleButtons" selected="true" enabled="false"/>
+ </FlowPane>
+ </FlowPane>
+
+ <FlowPane orientation="vertical">
+ <Label text="Image Buttons" styles="{fontBold:true}"/>
+ <FlowPane>
+ <PushButton>
+ <buttonData>
+ <content:ButtonData icon="@bell.png" text="Bell"/>
+ </buttonData>
+ </PushButton>
+ <PushButton>
+ <buttonData>
+ <content:ButtonData icon="@clock.png" text="Clock"/>
+ </buttonData>
+ <dataRenderer>
+ <content:ButtonDataRenderer orientation="vertical"/>
+ </dataRenderer>
+ </PushButton>
+ <PushButton enabled="false">
+ <buttonData>
+ <content:ButtonData icon="@house.png" text="House"/>
+ </buttonData>
+ </PushButton>
+ </FlowPane>
+ </FlowPane>
+
+ <FlowPane orientation="vertical">
+ <Label text="Toolbar Buttons" styles="{fontBold:true}"/>
+ <FlowPane>
+ <PushButton styles="{toolbar:true}">
+ <buttonData>
+ <content:ButtonData icon="@bell.png"/>
+ </buttonData>
+ </PushButton>
+ <PushButton styles="{toolbar:true}">
+ <buttonData>
+ <content:ButtonData icon="@clock.png"/>
+ </buttonData>
+ </PushButton>
+ <PushButton enabled="false" styles="{toolbar:true}">
+ <buttonData>
+ <content:ButtonData icon="@house.png"/>
+ </buttonData>
+ </PushButton>
+ </FlowPane>
+ </FlowPane>
+ </FlowPane>
+ </content>
+ </Border>
+
+ <Border>
+ <content>
+ <FlowPane orientation="vertical" styles="{padding:{top:2, left:4, bottom:4, right:4}, spacing:10}">
+ <FlowPane orientation="vertical">
+ <Label text="Basic Radio Buttons" styles="{fontBold:true}"/>
+ <FlowPane>
+ <RadioButton buttonData="One" group="radioButtons"/>
+ <RadioButton buttonData="Two" group="radioButtons"/>
+ <RadioButton buttonData="Three" group="radioButtons" selected="true" enabled="false"/>
+ </FlowPane>
+ </FlowPane>
+
+ <FlowPane orientation="vertical">
+ <Label text="Image Radio Buttons" styles="{fontBold:true}"/>
+ <FlowPane orientation="vertical">
+ <RadioButton group="imageRadioButtons">
+ <buttonData>
+ <content:ButtonData icon="@bell.png" text="Bell"/>
+ </buttonData>
+ </RadioButton>
+ <RadioButton group="imageRadioButtons">
+ <buttonData>
+ <content:ButtonData icon="@clock.png" text="Clock"/>
+ </buttonData>
+ </RadioButton>
+ <RadioButton group="imageRadioButtons" selected="true" enabled="false">
+ <buttonData>
+ <content:ButtonData icon="@house.png" text="House"/>
+ </buttonData>
+ </RadioButton>
+ </FlowPane>
+ </FlowPane>
+ </FlowPane>
+ </content>
+ </Border>
+
+ <Border>
+ <content>
+ <FlowPane orientation="vertical" styles="{padding:{top:2, left:4, bottom:4, right:4}, spacing:10}">
+ <FlowPane orientation="vertical">
+ <Label text="Basic Checkboxes" styles="{fontBold:true}"/>
+ <FlowPane>
+ <Checkbox buttonData="One"/>
+ <Checkbox buttonData="Two"/>
+ <Checkbox buttonData="Three" selected="true" enabled="false"/>
+ </FlowPane>
+ </FlowPane>
+
+ <FlowPane orientation="vertical">
+ <Label text="Image Checkboxes" styles="{fontBold:true}"/>
+ <FlowPane orientation="vertical">
+ <Checkbox>
+ <buttonData>
+ <content:ButtonData icon="@clock.png" text="Clock"/>
+ </buttonData>
+ </Checkbox>
+ <Checkbox>
+ <buttonData>
+ <content:ButtonData icon="@bell.png" text="Bell"/>
+ </buttonData>
+ </Checkbox>
+ <Checkbox selected="true" enabled="false">
+ <buttonData>
+ <content:ButtonData icon="@house.png" text="House"/>
+ </buttonData>
+ </Checkbox>
+ </FlowPane>
+ </FlowPane>
+
+ <FlowPane orientation="vertical">
+ <Label text="Tri-state Checkboxes" styles="{fontBold:true}"/>
+ <FlowPane orientation="vertical">
+ <Checkbox buttonData="Read" triState="true" state="selected"/>
+ <Checkbox buttonData="Write" triState="true" state="unselected"/>
+ <Checkbox buttonData="Execute" triState="true" state="mixed" enabled="false"/>
+ </FlowPane>
+ </FlowPane>
+ </FlowPane>
+ </content>
+ </Border>
+
+ <Border>
+ <content>
+ <FlowPane orientation="vertical" styles="{padding:{top:2, left:4, bottom:4, right:4}, spacing:10}">
+ <FlowPane orientation="vertical">
+ <Label text="Basic Link Buttons" styles="{fontBold:true}"/>
+ <FlowPane>
+ <LinkButton buttonData="One"/>
+ <LinkButton buttonData="Two"/>
+ <LinkButton buttonData="Three" enabled="false"/>
+ </FlowPane>
+ </FlowPane>
+
+ <FlowPane orientation="vertical">
+ <Label text="Image Link Buttons" styles="{fontBold:true}"/>
+ <FlowPane orientation="vertical">
+ <LinkButton>
+ <buttonData>
+ <content:ButtonData icon="@bell.png" text="Bell"/>
+ </buttonData>
+ </LinkButton>
+ <LinkButton>
+ <buttonData>
+ <content:ButtonData icon="@clock.png" text="Clock"/>
+ </buttonData>
+ </LinkButton>
+ <LinkButton enabled="false">
+ <buttonData>
+ <content:ButtonData icon="@house.png" text="House"/>
+ </buttonData>
+ </LinkButton>
+ </FlowPane>
+ </FlowPane>
+ </FlowPane>
+ </content>
+ </Border>
+</FlowPane>
+