diff options
author | Jani Laakso <jani.laakso@itmill.com> | 2007-02-02 18:48:28 +0000 |
---|---|---|
committer | Jani Laakso <jani.laakso@itmill.com> | 2007-02-02 18:48:28 +0000 |
commit | 341e214a316ee55bb481f6c86cb1d8981cc025b5 (patch) | |
tree | 620b57bde9fbd716e1999a20eb1d47f729a20dbb /src/com/itmill/toolkit/demo/features/FeatureTable.java | |
parent | 334ca73c3ce83bf58188005a59683fbc6824e251 (diff) | |
download | vaadin-framework-341e214a316ee55bb481f6c86cb1d8981cc025b5.tar.gz vaadin-framework-341e214a316ee55bb481f6c86cb1d8981cc025b5.zip |
Indentation changes.
Layout changed.
svn changeset:426/svn branch:toolkit
Diffstat (limited to 'src/com/itmill/toolkit/demo/features/FeatureTable.java')
-rw-r--r-- | src/com/itmill/toolkit/demo/features/FeatureTable.java | 227 |
1 files changed, 93 insertions, 134 deletions
diff --git a/src/com/itmill/toolkit/demo/features/FeatureTable.java b/src/com/itmill/toolkit/demo/features/FeatureTable.java index 8f54ded7a8..fe117c2921 100644 --- a/src/com/itmill/toolkit/demo/features/FeatureTable.java +++ b/src/com/itmill/toolkit/demo/features/FeatureTable.java @@ -1,30 +1,30 @@ /* ************************************************************************* - IT Mill Toolkit + IT Mill Toolkit - Development of Browser User Interfaces Made Easy + Development of Browser User Interfaces Made Easy - Copyright (C) 2000-2006 IT Mill Ltd - - ************************************************************************* + Copyright (C) 2000-2006 IT Mill Ltd + + ************************************************************************* - This product is distributed under commercial license that can be found - from the product package on license.pdf. Use of this product might - require purchasing a commercial license from IT Mill Ltd. For guidelines - on usage, see licensing-guidelines.html + This product is distributed under commercial license that can be found + from the product package on license.pdf. Use of this product might + require purchasing a commercial license from IT Mill Ltd. For guidelines + on usage, see licensing-guidelines.html - ************************************************************************* - - For more information, contact: - - IT Mill Ltd phone: +358 2 4802 7180 - Ruukinkatu 2-4 fax: +358 2 4802 7181 - 20540, Turku email: info@itmill.com - Finland company www: www.itmill.com - - Primary source for information and releases: www.itmill.com + ************************************************************************* + + For more information, contact: + + IT Mill Ltd phone: +358 2 4802 7180 + Ruukinkatu 2-4 fax: +358 2 4802 7181 + 20540, Turku email: info@itmill.com + Finland company www: www.itmill.com + + Primary source for information and releases: www.itmill.com - ********************************************************************** */ + ********************************************************************** */ package com.itmill.toolkit.demo.features; @@ -33,38 +33,25 @@ import com.itmill.toolkit.ui.*; public class FeatureTable extends Feature implements Action.Handler { - private static final String[] firstnames = - new String[] { - "John", - "Mary", - "Joe", - "Sarah", - "Jeff", - "Jane", - "Peter", - "Marc", - "Josie", - "Linus" }; - private static final String[] lastnames = - new String[] { - "Torvalds", - "Smith", - "Jones", - "Beck", - "Sheridan", - "Picard", - "Hill", - "Fielding", + private static final String[] firstnames = new String[] { "John", "Mary", + "Joe", "Sarah", "Jeff", "Jane", "Peter", "Marc", "Josie", "Linus" }; + + private static final String[] lastnames = new String[] { "Torvalds", + "Smith", "Jones", "Beck", "Sheridan", "Picard", "Hill", "Fielding", "Einstein" }; - private static final String[] eyecolors = - new String[] { "Blue", "Green", "Brown" }; - private static final String[] haircolors = - new String[] { "Brown", "Black", "Red", "Blonde" }; + + private static final String[] eyecolors = new String[] { "Blue", "Green", + "Brown" }; + + private static final String[] haircolors = new String[] { "Brown", "Black", + "Red", "Blonde" }; private Table t; + private boolean actionsActive = false; - private Button actionHandlerSwitch = - new Button("Activate actions", this, "toggleActions"); + + private Button actionHandlerSwitch = new Button("Activate actions", this, + "toggleActions"); public void toggleActions() { if (actionsActive) { @@ -96,45 +83,33 @@ public class FeatureTable extends Feature implements Action.Handler { // Add random rows to table for (int j = 0; j < 500; j++) { - Object id = t.addItem( - new Object[] { - firstnames[(int) (Math.random() * (firstnames.length-1))], - lastnames[(int) (Math.random() * (lastnames.length-1))], - new Integer((int) (Math.random() * 80)), - eyecolors[(int) (Math.random() * 3)], - haircolors[(int) (Math.random() * 4)] }, - new Integer(j)); + Object id = t + .addItem( + new Object[] { + firstnames[(int) (Math.random() * (firstnames.length - 1))], + lastnames[(int) (Math.random() * (lastnames.length - 1))], + new Integer((int) (Math.random() * 80)), + eyecolors[(int) (Math.random() * 3)], + haircolors[(int) (Math.random() * 4)] }, + new Integer(j)); } // Actions l.addComponent(this.actionHandlerSwitch); // Properties - PropertyPanel p = new PropertyPanel(t); - Form ap = - p.createBeanPropertySet( - new String[] { - "pageLength", - "rowHeaderMode", - "selectable", - "columnHeaderMode", - "columnCollapsingAllowed", - "columnReorderingAllowed"}); - ap.replaceWithSelect( - "columnHeaderMode", - new Object[] { + propertyPanel = new PropertyPanel(t); + Form ap = propertyPanel.createBeanPropertySet(new String[] { + "pageLength", "rowHeaderMode", "selectable", + "columnHeaderMode", "columnCollapsingAllowed", + "columnReorderingAllowed" }); + ap.replaceWithSelect("columnHeaderMode", new Object[] { new Integer(Table.COLUMN_HEADER_MODE_EXPLICIT), new Integer(Table.COLUMN_HEADER_MODE_EXPLICIT_DEFAULTS_ID), new Integer(Table.COLUMN_HEADER_MODE_HIDDEN), - new Integer(Table.COLUMN_HEADER_MODE_ID)}, - new Object[] { - "Explicit", - "Explicit defaults ID", - "Hidden", - "ID" }); - ap.replaceWithSelect( - "rowHeaderMode", - new Object[] { + new Integer(Table.COLUMN_HEADER_MODE_ID) }, new Object[] { + "Explicit", "Explicit defaults ID", "Hidden", "ID" }); + ap.replaceWithSelect("rowHeaderMode", new Object[] { new Integer(Table.ROW_HEADER_MODE_EXPLICIT), new Integer(Table.ROW_HEADER_MODE_EXPLICIT_DEFAULTS_ID), new Integer(Table.ROW_HEADER_MODE_HIDDEN), @@ -142,72 +117,58 @@ public class FeatureTable extends Feature implements Action.Handler { new Integer(Table.ROW_HEADER_MODE_ID), new Integer(Table.ROW_HEADER_MODE_INDEX), new Integer(Table.ROW_HEADER_MODE_ITEM), - new Integer(Table.ROW_HEADER_MODE_PROPERTY)}, - new Object[] { - "Explicit", - "Explicit defaults ID", - "Hidden", - "Icon only", - "ID", - "Index", - "Item", - "Property" }); - Select themes = (Select) p.getField("style"); - themes - .addItem("list") - .getItemProperty(themes.getItemCaptionPropertyId()) - .setValue("list"); - themes - .addItem("paging") - .getItemProperty(themes.getItemCaptionPropertyId()) - .setValue("paging"); - p.addProperties("Table Properties", ap); - l.addComponent(p); + new Integer(Table.ROW_HEADER_MODE_PROPERTY) }, new Object[] { + "Explicit", "Explicit defaults ID", "Hidden", "Icon only", + "ID", "Index", "Item", "Property" }); + Select themes = (Select) propertyPanel.getField("style"); + themes.addItem("list").getItemProperty( + themes.getItemCaptionPropertyId()).setValue("list"); + themes.addItem("paging").getItemProperty( + themes.getItemCaptionPropertyId()).setValue("paging"); + propertyPanel.addProperties("Table Properties", ap); t.setRowHeaderMode(Table.ROW_HEADER_MODE_INDEX); t.setColumnHeaderMode(Table.COLUMN_HEADER_MODE_EXPLICIT_DEFAULTS_ID); t.setColumnCollapsingAllowed(true); t.setColumnReorderingAllowed(true); t.setSelectable(true); - + return l; } protected String getExampleSrc() { return "// Sample table\n" - + "t = new Table(\"Most Wanted Persons List\");\n" - + "t.setPageLength(10);\n\n" - + "// Add columns to table\n" - + "t.addContainerProperty(\"Firstname\", String.class, \"\");\n" - + "t.addContainerProperty(\"Lastname\", String.class, \"\");\n" - + "t.addContainerProperty(\"Age\", String.class, \"\");\n" - + "t.addContainerProperty(\"Eyecolor\", String.class, \"\");\n" - + "t.addContainerProperty(\"Haircolor\", String.class, \"\");\n\n" - + "// Add random rows to table\n" - + "for (int j = 0; j < 50; j++) {\n" - + " t.addItem(\n" - + " new Object[] {\n" - + " firstnames[(int) (Math.random() * 9)],\n" - + " lastnames[(int) (Math.random() * 9)],\n" - + " new Integer((int) (Math.random() * 80)),\n" - + " eyecolors[(int) (Math.random() * 3)],\n" - + " haircolors[(int) (Math.random() * 4)] },\n" - + " new Integer(j));\n" - + "}\n"; + + "t = new Table(\"Most Wanted Persons List\");\n" + + "t.setPageLength(10);\n\n" + + "// Add columns to table\n" + + "t.addContainerProperty(\"Firstname\", String.class, \"\");\n" + + "t.addContainerProperty(\"Lastname\", String.class, \"\");\n" + + "t.addContainerProperty(\"Age\", String.class, \"\");\n" + + "t.addContainerProperty(\"Eyecolor\", String.class, \"\");\n" + + "t.addContainerProperty(\"Haircolor\", String.class, \"\");\n\n" + + "// Add random rows to table\n" + + "for (int j = 0; j < 50; j++) {\n" + " t.addItem(\n" + + " new Object[] {\n" + + " firstnames[(int) (Math.random() * 9)],\n" + + " lastnames[(int) (Math.random() * 9)],\n" + + " new Integer((int) (Math.random() * 80)),\n" + + " eyecolors[(int) (Math.random() * 3)],\n" + + " haircolors[(int) (Math.random() * 4)] },\n" + + " new Integer(j));\n" + "}\n"; } protected String getDescriptionXHTML() { return "<p>The Table component is designed for displaying large volumes of tabular data, " - + "in multiple pages whenever needed.</p> " - + "<p>Selection of the displayed data is supported both in selecting exclusively one row " - + "or multiple rows at the same time. For each row, there may be a set of actions associated, " - + "depending on the theme these actions may be displayed either as a drop-down " - + "menu for each row or a set of command buttons.</p><p>" - + "Table may be connected to any datasource implementing the <code>Container</code> interface." - + "This way data found in external datasources can be directly presented in the table component." - + "</p><p>" - + "Table implements a number of features and you can test most of them in the table demo tab.</p>"; + + "in multiple pages whenever needed.</p> " + + "<p>Selection of the displayed data is supported both in selecting exclusively one row " + + "or multiple rows at the same time. For each row, there may be a set of actions associated, " + + "depending on the theme these actions may be displayed either as a drop-down " + + "menu for each row or a set of command buttons.</p><p>" + + "Table may be connected to any datasource implementing the <code>Container</code> interface." + + "This way data found in external datasources can be directly presented in the table component." + + "</p><p>" + + "Table implements a number of features and you can test most of them in the table demo tab.</p>"; } protected String getImage() { @@ -219,7 +180,9 @@ public class FeatureTable extends Feature implements Action.Handler { } private Action ACTION1 = new Action("Action 1"); + private Action ACTION2 = new Action("Action 2"); + private Action ACTION3 = new Action("Action 3"); private Action[] actions = new Action[] { ACTION1, ACTION2, ACTION3 }; @@ -229,12 +192,8 @@ public class FeatureTable extends Feature implements Action.Handler { } public void handleAction(Action action, Object sender, Object target) { - t.setDescription( - "Last action clicked was '" - + action.getCaption() - + "' on item '" - + t.getItem(target).toString() - + "'"); + t.setDescription("Last action clicked was '" + action.getCaption() + + "' on item '" + t.getItem(target).toString() + "'"); } } |