Author: [email protected]
Date: Thu May 14 11:56:36 2009
New Revision: 5377
Added:
changes/jlabanca/scrolltable/eclipse/samples/TableController/ (props
changed)
changes/jlabanca/scrolltable/eclipse/samples/TableController/.checkstyle
changes/jlabanca/scrolltable/eclipse/samples/TableController/.classpath
changes/jlabanca/scrolltable/eclipse/samples/TableController/.project
(contents, props changed)
changes/jlabanca/scrolltable/eclipse/samples/TableController/TableController-gwtc.launch
changes/jlabanca/scrolltable/eclipse/samples/TableController/TableController.launch
changes/jlabanca/scrolltable/samples/tablecontroller/
changes/jlabanca/scrolltable/samples/tablecontroller/src/
changes/jlabanca/scrolltable/samples/tablecontroller/src/com/
changes/jlabanca/scrolltable/samples/tablecontroller/src/com/google/
changes/jlabanca/scrolltable/samples/tablecontroller/src/com/google/gwt/
changes/jlabanca/scrolltable/samples/tablecontroller/src/com/google/gwt/sample/
changes/jlabanca/scrolltable/samples/tablecontroller/src/com/google/gwt/sample/tablecontroller/
changes/jlabanca/scrolltable/samples/tablecontroller/src/com/google/gwt/sample/tablecontroller/TableController.gwt.xml
changes/jlabanca/scrolltable/samples/tablecontroller/src/com/google/gwt/sample/tablecontroller/client/
changes/jlabanca/scrolltable/samples/tablecontroller/src/com/google/gwt/sample/tablecontroller/client/TableControllerEntryPoint.java
(contents, props changed)
changes/jlabanca/scrolltable/samples/tablecontroller/src/com/google/gwt/sample/tablecontroller/client/option/
changes/jlabanca/scrolltable/samples/tablecontroller/src/com/google/gwt/sample/tablecontroller/client/option/AbstractOption.java
(contents, props changed)
changes/jlabanca/scrolltable/samples/tablecontroller/src/com/google/gwt/sample/tablecontroller/client/option/CustomForm.java
(contents, props changed)
changes/jlabanca/scrolltable/samples/tablecontroller/src/com/google/gwt/sample/tablecontroller/client/option/ShiftRowsOption.java
(contents, props changed)
changes/jlabanca/scrolltable/samples/tablecontroller/src/com/google/gwt/sample/tablecontroller/client/option/SortColumnOption.java
(contents, props changed)
changes/jlabanca/scrolltable/samples/tablecontroller/src/com/google/gwt/sample/tablecontroller/client/option/SwapRowsOption.java
(contents, props changed)
changes/jlabanca/scrolltable/samples/tablecontroller/src/com/google/gwt/sample/tablecontroller/public/
changes/jlabanca/scrolltable/samples/tablecontroller/war/
changes/jlabanca/scrolltable/samples/tablecontroller/war/TableController.css
(contents, props changed)
changes/jlabanca/scrolltable/samples/tablecontroller/war/TableController.html
(contents, props changed)
changes/jlabanca/scrolltable/samples/tablecontroller/war/WEB-INF/
changes/jlabanca/scrolltable/samples/tablecontroller/war/WEB-INF/classes/
changes/jlabanca/scrolltable/samples/tablecontroller/war/WEB-INF/classes/marker
changes/jlabanca/scrolltable/samples/tablecontroller/war/WEB-INF/web.xml
Log:
Initial version of TableController sample. The TableController sample
shows an example of advanced table controllers.
Patch by: jlabanca
Added:
changes/jlabanca/scrolltable/eclipse/samples/TableController/.checkstyle
==============================================================================
--- (empty file)
+++
changes/jlabanca/scrolltable/eclipse/samples/TableController/.checkstyle
Thu May 14 11:56:36 2009
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<fileset-config file-format-version="1.2.0" simple-config="false">
+ <fileset name="all" enabled="true" check-config-name="GWT Checks"
local="false">
+ <file-match-pattern match-pattern="." include-pattern="true"/>
+ </fileset>
+</fileset-config>
Added:
changes/jlabanca/scrolltable/eclipse/samples/TableController/.classpath
==============================================================================
--- (empty file)
+++ changes/jlabanca/scrolltable/eclipse/samples/TableController/.classpath
Thu May 14 11:56:36 2009
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="core/src"/>
+ <classpathentry kind="src" output="war" path="core/war"/>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/gwt-user"/>
+ <classpathentry combineaccessrules="false" kind="src"
path="/gwt-dev-linux"/>
+ <classpathentry kind="output" path="war/WEB-INF/classes"/>
+</classpath>
Added: changes/jlabanca/scrolltable/eclipse/samples/TableController/.project
==============================================================================
--- (empty file)
+++ changes/jlabanca/scrolltable/eclipse/samples/TableController/.project
Thu May 14 11:56:36 2009
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>TableController</name>
+ <comment>TableController project</comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+
<name>com.atlassw.tools.eclipse.checkstyle.CheckstyleBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+
<nature>com.atlassw.tools.eclipse.checkstyle.CheckstyleNature</nature>
+ </natures>
+ <linkedResources>
+ <link>
+ <name>core</name>
+ <type>2</type>
+
<locationURI>GWT_ROOT/samples/tablecontroller/</locationURI>
+ </link>
+ </linkedResources>
+</projectDescription>
Added:
changes/jlabanca/scrolltable/eclipse/samples/TableController/TableController-gwtc.launch
==============================================================================
--- (empty file)
+++
changes/jlabanca/scrolltable/eclipse/samples/TableController/TableController-gwtc.launch
Thu May 14 11:56:36 2009
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry
value="/gwt-dev-linux/core/src/com/google/gwt/dev/Compiler.java"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="1"/>
+</listAttribute>
+<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables"
value="true"/>
+<listAttribute key="org.eclipse.jdt.launching.CLASSPATH">
+<listEntry value="<?xml version="1.0"
encoding="UTF-8"
standalone="no"?> <runtimeClasspathEntry
containerPath="org.eclipse.jdt.launching.JRE_CONTAINER"
javaProject="TableController" path="1"
type="4"/> "/>
+<listEntry value="<?xml version="1.0"
encoding="UTF-8"
standalone="no"?> <runtimeClasspathEntry
internalArchive="/TableController/core/src" path="3"
type="2"/> "/>
+<listEntry value="<?xml version="1.0"
encoding="UTF-8"
standalone="no"?> <runtimeClasspathEntry
internalArchive="/gwt-user/core/src" path="3"
type="2"/> "/>
+<listEntry value="<?xml version="1.0"
encoding="UTF-8"
standalone="no"?> <runtimeClasspathEntry
internalArchive="/gwt-dev-linux/core/src" path="3"
type="2"/> "/>
+<listEntry value="<?xml version="1.0"
encoding="UTF-8"
standalone="no"?> <runtimeClasspathEntry
internalArchive="/gwt-user/core/super" path="3"
type="2"/> "/>
+<listEntry value="<?xml version="1.0"
encoding="UTF-8"
standalone="no"?> <runtimeClasspathEntry
internalArchive="/gwt-dev-linux/core/super" path="3"
type="2"/> "/>
+<listEntry value="<?xml version="1.0"
encoding="UTF-8"
standalone="no"?> <runtimeClasspathEntry
id="org.eclipse.jdt.launching.classpathentry.defaultClasspath"> <memento
exportedEntriesOnly="false"
project="TableController"/> </runtimeClasspathEntry> "/>
+</listAttribute>
+<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH"
value="false"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE"
value="com.google.gwt.dev.Compiler"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS"
value="com.google.gwt.sample.tablecontroller.TableController"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR"
value="TableController"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS"
value="-ea -Xmx256M -Dgwt.devjar="/usr/local/google/jlabanca/gwt_all/scrolltable/trunk/build/staging/gwt-linux-0.0.0/gwt-dev-linux.jar""/>
+</launchConfiguration>
Added:
changes/jlabanca/scrolltable/eclipse/samples/TableController/TableController.launch
==============================================================================
--- (empty file)
+++
changes/jlabanca/scrolltable/eclipse/samples/TableController/TableController.launch
Thu May 14 11:56:36 2009
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry
value="/gwt-dev-linux/core/src/com/google/gwt/dev/HostedMode.java"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="1"/>
+</listAttribute>
+<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables"
value="true"/>
+<listAttribute key="org.eclipse.jdt.launching.CLASSPATH">
+<listEntry value="<?xml version="1.0"
encoding="UTF-8"
standalone="no"?> <runtimeClasspathEntry
containerPath="org.eclipse.jdt.launching.JRE_CONTAINER"
javaProject="TableController" path="1"
type="4"/> "/>
+<listEntry value="<?xml version="1.0"
encoding="UTF-8"
standalone="no"?> <runtimeClasspathEntry
internalArchive="/TableController/core/src" path="3"
type="2"/> "/>
+<listEntry value="<?xml version="1.0"
encoding="UTF-8"
standalone="no"?> <runtimeClasspathEntry
internalArchive="/gwt-user/core/src" path="3"
type="2"/> "/>
+<listEntry value="<?xml version="1.0"
encoding="UTF-8"
standalone="no"?> <runtimeClasspathEntry
internalArchive="/gwt-dev-linux/core/src" path="3"
type="2"/> "/>
+<listEntry value="<?xml version="1.0"
encoding="UTF-8"
standalone="no"?> <runtimeClasspathEntry
internalArchive="/gwt-user/core/super" path="3"
type="2"/> "/>
+<listEntry value="<?xml version="1.0"
encoding="UTF-8"
standalone="no"?> <runtimeClasspathEntry
internalArchive="/gwt-dev-linux/core/super" path="3"
type="2"/> "/>
+<listEntry value="<?xml version="1.0"
encoding="UTF-8"
standalone="no"?> <runtimeClasspathEntry
id="org.eclipse.jdt.launching.classpathentry.defaultClasspath"> <memento
exportedEntriesOnly="false"
project="TableController"/> </runtimeClasspathEntry> "/>
+</listAttribute>
+<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH"
value="false"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE"
value="com.google.gwt.dev.HostedMode"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS"
value="-startupUrl
TableController.html com.google.gwt.sample.tablecontroller.TableController"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR"
value="TableController"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS"
value="-ea -Xmx256M -Dgwt.devjar="/usr/local/google/jlabanca/gwt_all/scrolltable/trunk/build/staging/gwt-linux-0.0.0/gwt-dev-linux.jar""/>
+</launchConfiguration>
Added:
changes/jlabanca/scrolltable/samples/tablecontroller/src/com/google/gwt/sample/tablecontroller/TableController.gwt.xml
==============================================================================
--- (empty file)
+++
changes/jlabanca/scrolltable/samples/tablecontroller/src/com/google/gwt/sample/tablecontroller/TableController.gwt.xml
Thu May 14 11:56:36 2009
@@ -0,0 +1,9 @@
+<module rename-to="tablecontroller">
+ <!-- Inherit the core Web Toolkit stuff. -->
+ <inherits name="com.google.gwt.core.Core"/>
+ <inherits name='com.google.gwt.user.User'/>
+ <inherits name="com.google.gwt.user.theme.standard.Standard"/>
+
+ <!-- Specify the app entry point class. -->
+ <entry-point
class='com.google.gwt.sample.tablecontroller.client.TableControllerEntryPoint'/>
+</module>
Added:
changes/jlabanca/scrolltable/samples/tablecontroller/src/com/google/gwt/sample/tablecontroller/client/TableControllerEntryPoint.java
==============================================================================
--- (empty file)
+++
changes/jlabanca/scrolltable/samples/tablecontroller/src/com/google/gwt/sample/tablecontroller/client/TableControllerEntryPoint.java
Thu May 14 11:56:36 2009
@@ -0,0 +1,145 @@
+/*
+ * Copyright 2008 Google 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 com.google.gwt.sample.tablecontroller.client;
+
+import com.google.gwt.core.client.EntryPoint;
+import com.google.gwt.event.logical.shared.SelectionEvent;
+import com.google.gwt.event.logical.shared.SelectionHandler;
+import com.google.gwt.sample.tablecontroller.client.option.AbstractOption;
+import com.google.gwt.sample.tablecontroller.client.option.ShiftRowsOption;
+import
com.google.gwt.sample.tablecontroller.client.option.SortColumnOption;
+import com.google.gwt.sample.tablecontroller.client.option.SwapRowsOption;
+import com.google.gwt.user.client.ui.FlexTable;
+import com.google.gwt.user.client.ui.HTMLTable;
+import com.google.gwt.user.client.ui.HasHorizontalAlignment;
+import com.google.gwt.user.client.ui.HasVerticalAlignment;
+import com.google.gwt.user.client.ui.Label;
+import com.google.gwt.user.client.ui.RootPanel;
+import com.google.gwt.user.client.ui.ScrollPanel;
+import com.google.gwt.user.client.ui.SimplePanel;
+import com.google.gwt.user.client.ui.Tree;
+import com.google.gwt.user.client.ui.TreeItem;
+import com.google.gwt.user.client.ui.Widget;
+import com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter;
+import com.google.gwt.user.table.client.ColumnSortController;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Entry point classes define <code>onModuleLoad()</code>.
+ */
+public class TableControllerEntryPoint implements EntryPoint {
+
+ /**
+ * A Mapping of {...@link TreeItem} in the menu to their associated options.
+ */
+ private Map<TreeItem, AbstractOption> optionMap = new HashMap<TreeItem,
AbstractOption>();
+
+ /**
+ * The panel that holds the visible option.
+ */
+ private SimplePanel optionWrapper = new SimplePanel();
+
+ public void onModuleLoad() {
+ // Add the main layout to the page
+ FlexTable layout = new FlexTable();
+ FlexCellFormatter formatter = layout.getFlexCellFormatter();
+ layout.setWidth("99%");
+ layout.setCellPadding(0);
+ layout.setCellSpacing(5);
+ RootPanel.get().add(layout);
+
+ // Initialize the table
+ FlexTable demoTable = new FlexTable();
+ {
+ // Create the table
+ demoTable.setStyleName("demoTable");
+ for (int r = 0; r < 10; r++) {
+ for (int c = 0; c < 5; c++) {
+ demoTable.setText(r, c, r + ":" + c);
+ }
+ }
+
+ // Add the scroll table to the layout
+ layout.setWidget(0, 1, demoTable);
+ formatter.setWidth(0, 1, "100%");
+ formatter.setVerticalAlignment(0, 1, HasVerticalAlignment.ALIGN_TOP);
+ }
+
+ // Initialize the options menu
+ {
+ // Attach a tree listener
+ Tree menu = new Tree();
+ menu.addSelectionHandler(new SelectionHandler<TreeItem>() {
+ public void onSelection(SelectionEvent<TreeItem> event) {
+ Widget option = optionMap.get(event.getSelectedItem());
+ if (option != null) {
+ optionWrapper.setWidget(option);
+ }
+ }
+ });
+
+ // Add it to the layout inside a scroll panel
+ ScrollPanel scrollPanel = new ScrollPanel(menu);
+ scrollPanel.setAlwaysShowScrollBars(true);
+ scrollPanel.setStyleName("mainMenuWrapper");
+ layout.setWidget(0, 0, scrollPanel);
+ formatter.setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_TOP);
+ formatter.setWidth(0, 0, "1px");
+
+ // Initialize the options in the menu
+ initOptions(menu, demoTable);
+ }
+
+ // Initialize the options area
+ {
+ optionWrapper.setStyleName("optionWrapper");
+ optionWrapper.setWidget(new Label("Select an option from the menu"));
+ layout.setWidget(1, 0, optionWrapper);
+ formatter.setColSpan(1, 0, 2);
+ formatter.setHorizontalAlignment(1, 0,
+ HasHorizontalAlignment.ALIGN_CENTER);
+ }
+ }
+
+ /**
+ * Initialize the main menu.
+ *
+ * @param menu the main menu
+ * @param table the main demo table
+ */
+ private void initOptions(Tree menu, HTMLTable table) {
+ // Sorting
+ {
+ ColumnSortController controller = new ColumnSortController(table);
+ TreeItem root = menu.addItem("Column Sorting");
+ mapOption(root.addItem("Shift Rows"), new
ShiftRowsOption(controller));
+ mapOption(root.addItem("Swap Rows"), new SwapRowsOption(controller));
+ mapOption(root.addItem("Sort Column"), new
SortColumnOption(controller));
+ }
+ }
+
+ /**
+ * Map a {...@link TreeItem} to an option.
+ *
+ * @param item the {...@link TreeItem}
+ * @param option the {...@link Widget} to display
+ */
+ private void mapOption(TreeItem item, AbstractOption option) {
+ optionMap.put(item, option);
+ }
+}
Added:
changes/jlabanca/scrolltable/samples/tablecontroller/src/com/google/gwt/sample/tablecontroller/client/option/AbstractOption.java
==============================================================================
--- (empty file)
+++
changes/jlabanca/scrolltable/samples/tablecontroller/src/com/google/gwt/sample/tablecontroller/client/option/AbstractOption.java
Thu May 14 11:56:36 2009
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2008 Google 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 com.google.gwt.sample.tablecontroller.client.option;
+
+import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.HTML;
+import com.google.gwt.user.client.ui.HasHorizontalAlignment;
+import com.google.gwt.user.client.ui.VerticalPanel;
+import com.google.gwt.user.client.ui.Widget;
+
+/**
+ * An option that can be lazily initialized.
+ */
+public abstract class AbstractOption extends Composite {
+ /**
+ * The style name applied to cells that contain labels.
+ */
+ protected static final String STYLENAME_LABEL = "AbstractOption-Label";
+
+ /**
+ * The panel that wraps the contents.
+ */
+ private VerticalPanel wrapper = new VerticalPanel();
+
+ /**
+ * Indicates if we've initialized this option or not.
+ */
+ private boolean initialized = false;
+
+ /**
+ * Construct a new {...@link AbstractOption}.
+ */
+ public AbstractOption() {
+ initWidget(wrapper);
+ }
+
+ /**
+ * @return the description to display at the top of the option
+ */
+ protected abstract String getDescription();
+
+ /**
+ * Initialize the tab for the first time.
+ */
+ protected final void initialize() {
+ if (initialized) {
+ return;
+ }
+ initialized = true;
+
+ // Add the content
+ wrapper.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
+ wrapper.add(new HTML(getDescription()));
+ wrapper.add(onInitialize());
+ }
+
+ /**
+ * Render the option.
+ *
+ * @return the widget to initialize to.
+ */
+ protected abstract Widget onInitialize();
+
+ /**
+ * This method is called immediately after a widget becomes attached to
the
+ * browser's document.
+ */
+ @Override
+ protected void onLoad() {
+ super.onLoad();
+ initialize();
+ }
+}
Added:
changes/jlabanca/scrolltable/samples/tablecontroller/src/com/google/gwt/sample/tablecontroller/client/option/CustomForm.java
==============================================================================
--- (empty file)
+++
changes/jlabanca/scrolltable/samples/tablecontroller/src/com/google/gwt/sample/tablecontroller/client/option/CustomForm.java
Thu May 14 11:56:36 2009
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2008 Google 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 com.google.gwt.sample.tablecontroller.client.option;
+
+import com.google.gwt.user.client.ui.Button;
+import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.FlexTable;
+import com.google.gwt.user.client.ui.HasHorizontalAlignment;
+import com.google.gwt.user.client.ui.Widget;
+
+/**
+ * A convenience class use to build a standard 2 column form.
+ */
+public class CustomForm extends Composite {
+ /**
+ * The style name applied to cells that contain labels.
+ */
+ protected static final String STYLENAME_LABEL = "AbstractOption-Label";
+
+ /**
+ * The panel that wraps the contents.
+ */
+ private FlexTable table = new FlexTable();
+
+ /**
+ * Construct a new {...@link AbstractOption}.
+ */
+ public CustomForm() {
+ initWidget(table);
+ }
+
+ /**
+ * Add a {...@link Button} to the form.
+ *
+ * @param button the button to add
+ */
+ public void addButton(Button button) {
+ int rowIndex = table.getRowCount();
+ table.setWidget(rowIndex, 0, button);
+ table.getFlexCellFormatter().setColSpan(rowIndex, 0, 2);
+ table.getCellFormatter().setHorizontalAlignment(rowIndex, 0,
+ HasHorizontalAlignment.ALIGN_CENTER);
+ }
+
+ /**
+ * Add a label and a widget on a single row.
+ *
+ * @param text the text of the label
+ * @param widget the widget to add
+ */
+ public void addLabeledWidget(String text, Widget widget) {
+ int rowIndex = table.getRowCount();
+ table.setText(rowIndex, 0, text);
+ table.getCellFormatter().setStyleName(rowIndex, 0, STYLENAME_LABEL);
+ table.setWidget(rowIndex, 1, widget);
+ }
+
+ /**
+ * Add a title to the form.
+ *
+ * @param title the text of the title
+ */
+ public void addTitle(String title) {
+ int rowIndex = table.getRowCount();
+ table.setText(rowIndex, 0, title);
+ table.getFlexCellFormatter().setColSpan(rowIndex, 0, 2);
+ table.getCellFormatter().setHorizontalAlignment(rowIndex, 0,
+ HasHorizontalAlignment.ALIGN_CENTER);
+ }
+}
Added:
changes/jlabanca/scrolltable/samples/tablecontroller/src/com/google/gwt/sample/tablecontroller/client/option/ShiftRowsOption.java
==============================================================================
--- (empty file)
+++
changes/jlabanca/scrolltable/samples/tablecontroller/src/com/google/gwt/sample/tablecontroller/client/option/ShiftRowsOption.java
Thu May 14 11:56:36 2009
@@ -0,0 +1,99 @@
+/*
+ * Copyright 2008 Google 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 com.google.gwt.sample.tablecontroller.client.option;
+
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.user.client.Window;
+import com.google.gwt.user.client.ui.Button;
+import com.google.gwt.user.client.ui.TextBox;
+import com.google.gwt.user.client.ui.Widget;
+import com.google.gwt.user.table.client.ColumnSortController;
+
+/**
+ * An option.
+ */
+public class ShiftRowsOption extends AbstractOption {
+
+ private ColumnSortController controller;
+
+ /**
+ * Construct a new {...@link ShiftRowsOption}.
+ *
+ * @param controller the table controller used to perform actions
+ */
+ public ShiftRowsOption(ColumnSortController controller) {
+ this.controller = controller;
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Shift rows up or down";
+ }
+
+ @Override
+ protected Widget onInitialize() {
+ CustomForm form = new CustomForm();
+
+ // Row selection
+ final TextBox rowBox = new TextBox();
+ rowBox.setText("3");
+ rowBox.setWidth("50px");
+ form.addLabeledWidget("Row Index:", rowBox);
+
+ // Add button to shift row up
+ {
+ Button button = new Button("Shift Row Up", new ClickHandler() {
+ public void onClick(ClickEvent event) {
+ try {
+ int row = Integer.parseInt(rowBox.getText());
+ if (row >= 0) {
+ controller.moveRowUp(row);
+ rowBox.setText((row - 1) + "");
+ }
+ } catch (NumberFormatException e) {
+ Window.alert("Please enter valid integers for the row and
column.");
+ } catch (IndexOutOfBoundsException e) {
+ Window.alert("The row or column index you entered is out of
bounds.");
+ }
+ }
+ });
+ form.addButton(button);
+ }
+
+ // Add button to shift row down
+ {
+ Button button = new Button("Shift Row Down", new ClickHandler() {
+ public void onClick(ClickEvent event) {
+ try {
+ int row = Integer.parseInt(rowBox.getText());
+ if (row >= 0) {
+ controller.moveRowDown(row);
+ rowBox.setText((row + 1) + "");
+ }
+ } catch (NumberFormatException e) {
+ Window.alert("Please enter valid integers for the row and
column.");
+ } catch (IndexOutOfBoundsException e) {
+ Window.alert("The row or column index you entered is out of
bounds.");
+ }
+ }
+ });
+ form.addButton(button);
+ }
+
+ return form;
+ }
+}
Added:
changes/jlabanca/scrolltable/samples/tablecontroller/src/com/google/gwt/sample/tablecontroller/client/option/SortColumnOption.java
==============================================================================
--- (empty file)
+++
changes/jlabanca/scrolltable/samples/tablecontroller/src/com/google/gwt/sample/tablecontroller/client/option/SortColumnOption.java
Thu May 14 11:56:36 2009
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2008 Google 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 com.google.gwt.sample.tablecontroller.client.option;
+
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.user.client.Window;
+import com.google.gwt.user.client.ui.Button;
+import com.google.gwt.user.client.ui.TextBox;
+import com.google.gwt.user.client.ui.Widget;
+import com.google.gwt.user.table.client.ColumnSortController;
+
+/**
+ * An option.
+ */
+public class SortColumnOption extends AbstractOption {
+
+ private ColumnSortController controller;
+
+ /**
+ * Construct a new {...@link SortColumnOption}.
+ *
+ * @param controller the table controller used to perform actions
+ */
+ public SortColumnOption(ColumnSortController controller) {
+ this.controller = controller;
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Sort a column in the table";
+ }
+
+ @Override
+ protected Widget onInitialize() {
+ CustomForm form = new CustomForm();
+ final TextBox columnBox = new TextBox();
+ columnBox.setText("3");
+ columnBox.setWidth("50px");
+ form.addLabeledWidget("Column Index:", columnBox);
+
+ // Add a button to sort the column
+ {
+ Button button = new Button("Sort Column", new ClickHandler() {
+ public void onClick(ClickEvent event) {
+ try {
+ int column = Integer.parseInt(columnBox.getText());
+ controller.sortColumn(column);
+ } catch (NumberFormatException e) {
+ Window.alert("Please enter valid integers for the row and
column.");
+ } catch (IndexOutOfBoundsException e) {
+ Window.alert("The row or column index you entered is out of
bounds.");
+ }
+ }
+ });
+ form.addButton(button);
+ }
+
+ return form;
+ }
+}
Added:
changes/jlabanca/scrolltable/samples/tablecontroller/src/com/google/gwt/sample/tablecontroller/client/option/SwapRowsOption.java
==============================================================================
--- (empty file)
+++
changes/jlabanca/scrolltable/samples/tablecontroller/src/com/google/gwt/sample/tablecontroller/client/option/SwapRowsOption.java
Thu May 14 11:56:36 2009
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2008 Google 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 com.google.gwt.sample.tablecontroller.client.option;
+
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.user.client.Window;
+import com.google.gwt.user.client.ui.Button;
+import com.google.gwt.user.client.ui.TextBox;
+import com.google.gwt.user.client.ui.Widget;
+import com.google.gwt.user.table.client.ColumnSortController;
+
+/**
+ * An option.
+ */
+public class SwapRowsOption extends AbstractOption {
+
+ private ColumnSortController controller;
+
+ /**
+ * Construct a new {...@link SwapRowsOption}.
+ *
+ * @param controller the table controller used to perform actions
+ */
+ public SwapRowsOption(ColumnSortController controller) {
+ this.controller = controller;
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Swap rows in the table";
+ }
+
+ @Override
+ protected Widget onInitialize() {
+ CustomForm form = new CustomForm();
+
+ // Row1 selection
+ final TextBox rowBox1 = new TextBox();
+ rowBox1.setText("3");
+ rowBox1.setWidth("50px");
+ form.addLabeledWidget("Row 1 Index:", rowBox1);
+
+ // Row2 selection
+ final TextBox rowBox2 = new TextBox();
+ rowBox2.setText("6");
+ rowBox2.setWidth("50px");
+ form.addLabeledWidget("Row 2 Index:", rowBox2);
+
+ // Add button to swap rows
+ {
+ Button button = new Button("Swap Rows", new ClickHandler() {
+ public void onClick(ClickEvent event) {
+ try {
+ int row1 = Integer.parseInt(rowBox1.getText());
+ int row2 = Integer.parseInt(rowBox2.getText());
+ if (row1 >= 0 && row2 >= 0) {
+ controller.swapRows(row1, row2);
+ }
+ } catch (NumberFormatException e) {
+ Window.alert("Please enter valid integers for the row and
column.");
+ } catch (IndexOutOfBoundsException e) {
+ Window.alert("The row or column index you entered is out of
bounds.");
+ }
+ }
+ });
+ form.addButton(button);
+ }
+
+ // Add button to reverse all rows
+ {
+ Button button = new Button("Reverse All Rows", new ClickHandler() {
+ public void onClick(ClickEvent event) {
+ controller.reverseRows();
+ }
+ });
+ form.addButton(button);
+ }
+
+ return form;
+ }
+}
Added:
changes/jlabanca/scrolltable/samples/tablecontroller/war/TableController.css
==============================================================================
--- (empty file)
+++
changes/jlabanca/scrolltable/samples/tablecontroller/war/TableController.css
Thu May 14 11:56:36 2009
@@ -0,0 +1,13 @@
+.mainMenuWrapper {
+ height: 400px;
+ width: 200px;
+ border: 1px solid #999;
+}
+
+.optionWrapper {
+ border-top: 3px solid #aaa;
+}
+
+.demoTable td {
+ border: 1px solid blue;
+}
\ No newline at end of file
Added:
changes/jlabanca/scrolltable/samples/tablecontroller/war/TableController.html
==============================================================================
--- (empty file)
+++
changes/jlabanca/scrolltable/samples/tablecontroller/war/TableController.html
Thu May 14 11:56:36 2009
@@ -0,0 +1,10 @@
+<HTML>
+ <head>
+ <title>Table Controller Sample</title>
+ <link REL=StyleSheet HREF="TableController.css" TYPE="text/css" />
+ <script language='javascript'
src='tablecontroller/tablecontroller.nocache.js'></script>
+ </head>
+ <body>
+ <iframe src="javascript:''" id="__gwt_historyFrame"
style="position:absolute;width:0;height:0;border:0"></iframe>
+ </body>
+</html>
Added:
changes/jlabanca/scrolltable/samples/tablecontroller/war/WEB-INF/classes/marker
==============================================================================
Added:
changes/jlabanca/scrolltable/samples/tablecontroller/war/WEB-INF/web.xml
==============================================================================
--- (empty file)
+++
changes/jlabanca/scrolltable/samples/tablecontroller/war/WEB-INF/web.xml
Thu May 14 11:56:36 2009
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app>
+
+ <!-- Default page to serve -->
+ <welcome-file-list>
+ <welcome-file>TableController.html</welcome-file>
+ </welcome-file-list>
+
+</web-app>
--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---