]> source.dussan.org Git - vaadin-framework.git/commitdiff
Mass format based on eclipse build in formatting style.
authorJani Laakso <jani.laakso@itmill.com>
Tue, 9 Oct 2007 06:12:02 +0000 (06:12 +0000)
committerJani Laakso <jani.laakso@itmill.com>
Tue, 9 Oct 2007 06:12:02 +0000 (06:12 +0000)
svn changeset:2461/svn branch:trunk

128 files changed:
src/com/itmill/toolkit/Application.java
src/com/itmill/toolkit/demo/CalendarDemo.java
src/com/itmill/toolkit/demo/FilterSelect.java
src/com/itmill/toolkit/demo/KeyboardShortcut.java
src/com/itmill/toolkit/demo/colorpicker/ColorPicker.java
src/com/itmill/toolkit/demo/colorpicker/ColorPickerApplication.java
src/com/itmill/toolkit/demo/colorpicker/gwt/client/WidgetSet.java
src/com/itmill/toolkit/demo/colorpicker/gwt/client/ui/GwtColorPicker.java
src/com/itmill/toolkit/demo/colorpicker/gwt/client/ui/ItkColorPicker.java
src/com/itmill/toolkit/demo/features/Feature.java
src/com/itmill/toolkit/demo/features/FeatureBrowser.java
src/com/itmill/toolkit/demo/features/FeatureDateField.java
src/com/itmill/toolkit/demo/features/FeaturesApplication.java
src/com/itmill/toolkit/demo/features/PropertyPanel.java
src/com/itmill/toolkit/demo/reservation/GoogleMap.java
src/com/itmill/toolkit/demo/reservation/ReservationApplication.java
src/com/itmill/toolkit/demo/reservation/ResourceNotAvailableException.java
src/com/itmill/toolkit/demo/reservation/ResourceSelectorPanel.java
src/com/itmill/toolkit/demo/reservation/SampleDB.java
src/com/itmill/toolkit/demo/reservation/gwt/client/WidgetSet.java
src/com/itmill/toolkit/demo/reservation/gwt/client/ui/IGoogleMap.java
src/com/itmill/toolkit/demo/util/SampleCalendarDatabase.java
src/com/itmill/toolkit/terminal/PaintTarget.java
src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java
src/com/itmill/toolkit/terminal/gwt/client/Caption.java
src/com/itmill/toolkit/terminal/gwt/client/CaptionWrapper.java
src/com/itmill/toolkit/terminal/gwt/client/DateLocale.java
src/com/itmill/toolkit/terminal/gwt/client/DateTimeService.java
src/com/itmill/toolkit/terminal/gwt/client/DebugConsole.java
src/com/itmill/toolkit/terminal/gwt/client/DefaultWidgetSet.java
src/com/itmill/toolkit/terminal/gwt/client/ErrorMessage.java
src/com/itmill/toolkit/terminal/gwt/client/LocaleNotLoadedException.java
src/com/itmill/toolkit/terminal/gwt/client/LocaleService.java
src/com/itmill/toolkit/terminal/gwt/client/NullConsole.java
src/com/itmill/toolkit/terminal/gwt/client/UIDL.java
src/com/itmill/toolkit/terminal/gwt/client/Util.java
src/com/itmill/toolkit/terminal/gwt/client/WidgetSet.java
src/com/itmill/toolkit/terminal/gwt/client/ui/CalendarEntry.java
src/com/itmill/toolkit/terminal/gwt/client/ui/CalendarPanel.java
src/com/itmill/toolkit/terminal/gwt/client/ui/ContextMenu.java
src/com/itmill/toolkit/terminal/gwt/client/ui/HorizontalSplitPanelImages.java
src/com/itmill/toolkit/terminal/gwt/client/ui/IButton.java
src/com/itmill/toolkit/terminal/gwt/client/ui/ICalendar.java
src/com/itmill/toolkit/terminal/gwt/client/ui/ICheckBox.java
src/com/itmill/toolkit/terminal/gwt/client/ui/ICustomComponent.java
src/com/itmill/toolkit/terminal/gwt/client/ui/ICustomLayout.java
src/com/itmill/toolkit/terminal/gwt/client/ui/IDateField.java
src/com/itmill/toolkit/terminal/gwt/client/ui/IDateFieldCalendar.java
src/com/itmill/toolkit/terminal/gwt/client/ui/IEmbedded.java
src/com/itmill/toolkit/terminal/gwt/client/ui/IExpandLayout.java
src/com/itmill/toolkit/terminal/gwt/client/ui/IFilterSelect.java
src/com/itmill/toolkit/terminal/gwt/client/ui/IForm.java
src/com/itmill/toolkit/terminal/gwt/client/ui/IFormLayout.java
src/com/itmill/toolkit/terminal/gwt/client/ui/IGridLayout.java
src/com/itmill/toolkit/terminal/gwt/client/ui/ILabel.java
src/com/itmill/toolkit/terminal/gwt/client/ui/ILink.java
src/com/itmill/toolkit/terminal/gwt/client/ui/IOptionGroup.java
src/com/itmill/toolkit/terminal/gwt/client/ui/IOptionGroupBase.java
src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayout.java
src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayoutHorizontal.java
src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayoutVertical.java
src/com/itmill/toolkit/terminal/gwt/client/ui/IPanel.java
src/com/itmill/toolkit/terminal/gwt/client/ui/IPasswordField.java
src/com/itmill/toolkit/terminal/gwt/client/ui/IPopupCalendar.java
src/com/itmill/toolkit/terminal/gwt/client/ui/IProgressIndicator.java
src/com/itmill/toolkit/terminal/gwt/client/ui/IScrollTable.java
src/com/itmill/toolkit/terminal/gwt/client/ui/ISelect.java
src/com/itmill/toolkit/terminal/gwt/client/ui/ISplitPanel.java
src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheet.java
src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheetPanel.java
src/com/itmill/toolkit/terminal/gwt/client/ui/ITextArea.java
src/com/itmill/toolkit/terminal/gwt/client/ui/ITextField.java
src/com/itmill/toolkit/terminal/gwt/client/ui/ITextualDate.java
src/com/itmill/toolkit/terminal/gwt/client/ui/ITwinColSelect.java
src/com/itmill/toolkit/terminal/gwt/client/ui/IUnknownComponent.java
src/com/itmill/toolkit/terminal/gwt/client/ui/IUpload.java
src/com/itmill/toolkit/terminal/gwt/client/ui/IView.java
src/com/itmill/toolkit/terminal/gwt/client/ui/IWindow.java
src/com/itmill/toolkit/terminal/gwt/client/ui/MenuBar.java
src/com/itmill/toolkit/terminal/gwt/client/ui/MenuItem.java
src/com/itmill/toolkit/terminal/gwt/client/ui/Time.java
src/com/itmill/toolkit/terminal/gwt/client/ui/TreeAction.java
src/com/itmill/toolkit/terminal/gwt/client/ui/VerticalSplitPanelImages.java
src/com/itmill/toolkit/terminal/gwt/client/util/DateLocale.java
src/com/itmill/toolkit/terminal/gwt/client/util/Pattern.java
src/com/itmill/toolkit/terminal/gwt/client/util/SimpleDateFormat.java
src/com/itmill/toolkit/terminal/gwt/client/util/SimpleDateParser.java
src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java
src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java
src/com/itmill/toolkit/terminal/gwt/server/JsonPaintTarget.java
src/com/itmill/toolkit/terminal/gwt/server/Log.java
src/com/itmill/toolkit/terminal/gwt/server/WebApplicationContext.java
src/com/itmill/toolkit/terminal/gwt/server/WebBrowser.java
src/com/itmill/toolkit/tests/BasicRandomTest.java
src/com/itmill/toolkit/tests/RandomLayoutStress.java
src/com/itmill/toolkit/tests/TestBench.java
src/com/itmill/toolkit/tests/TestForApplicationLayoutThatUsesWholeBrosersSpace.java
src/com/itmill/toolkit/tests/TestForBasicApplicationLayout.java
src/com/itmill/toolkit/tests/TestForChildComponentRendering.java
src/com/itmill/toolkit/tests/TestForGridLayoutChildComponentRendering.java
src/com/itmill/toolkit/tests/TestForTablesInitialColumnWidthLogicRendering.java
src/com/itmill/toolkit/tests/TestForTrees.java
src/com/itmill/toolkit/tests/TestForUpload.java
src/com/itmill/toolkit/tests/TestForWindowing.java
src/com/itmill/toolkit/ui/AbstractComponent.java
src/com/itmill/toolkit/ui/AbstractComponentContainer.java
src/com/itmill/toolkit/ui/AbstractField.java
src/com/itmill/toolkit/ui/Button.java
src/com/itmill/toolkit/ui/CalendarField.java
src/com/itmill/toolkit/ui/Component.java
src/com/itmill/toolkit/ui/CustomComponent.java
src/com/itmill/toolkit/ui/CustomLayout.java
src/com/itmill/toolkit/ui/DateField.java
src/com/itmill/toolkit/ui/ExpandLayout.java
src/com/itmill/toolkit/ui/Label.java
src/com/itmill/toolkit/ui/Panel.java
src/com/itmill/toolkit/ui/Select.java
src/com/itmill/toolkit/ui/Slider.java
src/com/itmill/toolkit/ui/SplitPanel.java
src/com/itmill/toolkit/ui/TabSheet.java
src/com/itmill/toolkit/ui/Table.java
src/com/itmill/toolkit/ui/TextField.java
src/com/itmill/toolkit/ui/Tree.java
src/com/itmill/toolkit/ui/Upload.java
src/com/itmill/toolkit/ui/Window.java
src/com/itmill/toolkit/ui/select/ContainsFilter.java
src/com/itmill/toolkit/ui/select/OptionFilter.java
src/com/itmill/toolkit/ui/select/StartsWithFilter.java

index b6a98ed541e1c89345abd06e50d2cb6b051511ba..78f3dad62939071d077f1f227036a1bc67034182 100644 (file)
@@ -199,17 +199,23 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener
         * not running or it does not contain a window corresponding to the name.
         * </p>
         * 
-        * <p>Since version 5.0 all windows can be referenced by their names in 
-        * url <code>http://host:port/foo/bar/</code> where <code>http://host:port/foo/</code>
-        * is the application url as returned by getURL() and <code>bar</code> is the name 
-        * of the window.</p>
+        * <p>
+        * Since version 5.0 all windows can be referenced by their names in url
+        * <code>http://host:port/foo/bar/</code> where
+        * <code>http://host:port/foo/</code> is the application url as returned
+        * by getURL() and <code>bar</code> is the name of the window.
+        * </p>
         * 
-        * <p>One should note that this method can, as a side effect create new windows
-        * if needed by the application. This can be achieved by overriding the default 
-        * implementation.</p>
+        * <p>
+        * One should note that this method can, as a side effect create new windows
+        * if needed by the application. This can be achieved by overriding the
+        * default implementation.
+        * </p>
         * 
-        * <p>The method should return null if the window does not exists (and is not 
-        * created as a side-effect) or if the application is not running anymore</p>.
+        * <p>
+        * The method should return null if the window does not exists (and is not
+        * created as a side-effect) or if the application is not running anymore
+        * </p>.
         * 
         * @param name
         *            the name of the window.
@@ -303,7 +309,9 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener
                        setMainWindow(window);
        }
 
-       /** Send information to all listeners about new Windows associated with this application.
+       /**
+        * Send information to all listeners about new Windows associated with this
+        * application.
         * 
         * @param window
         */
index 24f1ba96811c642c5e142e0b7f2693b27f174d8e..6b0667d06d69674b1195bacfda3728716ee0dbbf 100644 (file)
@@ -23,96 +23,91 @@ import com.itmill.toolkit.ui.Window;
  */
 public class CalendarDemo extends com.itmill.toolkit.Application {
 
-    // Database provided with sample data
-    private SampleCalendarDatabase sampleDatabase;
-
-    // The calendar UI component
-    private CalendarField from;
-    private CalendarField to;
-
-    /**
-     * Initialize Application. Demo components are added to main window.
-     */
-    public void init() {
-       Window main = new Window("Calendar demo");
-       setMainWindow(main);
-       
-       main.setLayout(new OrderedLayout(OrderedLayout.ORIENTATION_HORIZONTAL));
-
-       // set the application to use Corporate -theme
-       setTheme("corporate");
-
-       // create the calendar component and add to layout
-       from = new CalendarField();
-       main.addComponent(from);
-       from.setResolution(CalendarField.RESOLUTION_HOUR);
-       from.setImmediate(true);
-       
-       to = new CalendarField();
-       main.addComponent(to);
-       to.setResolution(CalendarField.RESOLUTION_HOUR);
-       to.setEnabled(false);
-       to.setImmediate(true);
-
-       from.addListener(new ValueChangeListener() {
-           public void valueChange(ValueChangeEvent event) {
-               Date fd = (Date)from.getValue();
-               Date td = (Date)to.getValue();
-               if (fd == null) {
-                   to.setValue(null);
-                   to.setEnabled(false);
-                   return;
-               } else {
-                   to.setEnabled(true);
-               }
-               to.setMinimumDate(fd);
-               if (td == null||td.before(fd)) {
-                   to.setValue(fd);
-               }
-           }       
-       });
-
-
-       // initialize the sample database and set as calendar datasource
-       sampleDatabase = new SampleCalendarDatabase();
-       initCalendars();
-       
-       // Don't allow dates before today
-       from.setMinimumDate(new Date());
-       
-    }
-
-    /**
-     * Populates table component with all rows from calendar table.
-     */
-    private void initCalendars() {
-       try {
-           QueryContainer qc = new QueryContainer("SELECT * FROM "
-                   + SampleCalendarDatabase.DB_TABLE_NAME, sampleDatabase
-                   .getConnection());
-           from.setContainerDataSource(qc);
-           to.setContainerDataSource(qc);
-       } catch (SQLException e) {
-           e.printStackTrace();
+       // Database provided with sample data
+       private SampleCalendarDatabase sampleDatabase;
+
+       // The calendar UI component
+       private CalendarField from;
+       private CalendarField to;
+
+       /**
+        * Initialize Application. Demo components are added to main window.
+        */
+       public void init() {
+               Window main = new Window("Calendar demo");
+               setMainWindow(main);
+
+               main.setLayout(new OrderedLayout(OrderedLayout.ORIENTATION_HORIZONTAL));
+
+               // set the application to use Corporate -theme
+               setTheme("corporate");
+
+               // create the calendar component and add to layout
+               from = new CalendarField();
+               main.addComponent(from);
+               from.setResolution(CalendarField.RESOLUTION_HOUR);
+               from.setImmediate(true);
+
+               to = new CalendarField();
+               main.addComponent(to);
+               to.setResolution(CalendarField.RESOLUTION_HOUR);
+               to.setEnabled(false);
+               to.setImmediate(true);
+
+               from.addListener(new ValueChangeListener() {
+                       public void valueChange(ValueChangeEvent event) {
+                               Date fd = (Date) from.getValue();
+                               Date td = (Date) to.getValue();
+                               if (fd == null) {
+                                       to.setValue(null);
+                                       to.setEnabled(false);
+                                       return;
+                               } else {
+                                       to.setEnabled(true);
+                               }
+                               to.setMinimumDate(fd);
+                               if (td == null || td.before(fd)) {
+                                       to.setValue(fd);
+                               }
+                       }
+               });
+
+               // initialize the sample database and set as calendar datasource
+               sampleDatabase = new SampleCalendarDatabase();
+               initCalendars();
+
+               // Don't allow dates before today
+               from.setMinimumDate(new Date());
+
        }
 
-       // Calendar will use the first date property as start if you do not
-       // explicitly specify the property id. Our start -property will be the
-       // first one, so it's intentionally left out.
-       // Start is the only mandatory property, but you'll probably want to
-       // specify title as well.
-       from.setItemEndPropertyId(SampleCalendarDatabase.PROPERTY_ID_END);
-       from
-               .setItemTitlePropertyId(SampleCalendarDatabase.PROPERTY_ID_TITLE);
-       from
-               .setItemNotimePropertyId(SampleCalendarDatabase.PROPERTY_ID_NOTIME);
-       to.setItemEndPropertyId(SampleCalendarDatabase.PROPERTY_ID_END);
-       to
-               .setItemTitlePropertyId(SampleCalendarDatabase.PROPERTY_ID_TITLE);
-       to
-               .setItemNotimePropertyId(SampleCalendarDatabase.PROPERTY_ID_NOTIME);
-     
-    }
+       /**
+        * Populates table component with all rows from calendar table.
+        */
+       private void initCalendars() {
+               try {
+                       QueryContainer qc = new QueryContainer("SELECT * FROM "
+                                       + SampleCalendarDatabase.DB_TABLE_NAME, sampleDatabase
+                                       .getConnection());
+                       from.setContainerDataSource(qc);
+                       to.setContainerDataSource(qc);
+               } catch (SQLException e) {
+                       e.printStackTrace();
+               }
+
+               // Calendar will use the first date property as start if you do not
+               // explicitly specify the property id. Our start -property will be the
+               // first one, so it's intentionally left out.
+               // Start is the only mandatory property, but you'll probably want to
+               // specify title as well.
+               from.setItemEndPropertyId(SampleCalendarDatabase.PROPERTY_ID_END);
+               from.setItemTitlePropertyId(SampleCalendarDatabase.PROPERTY_ID_TITLE);
+               from.setItemNotimePropertyId(SampleCalendarDatabase.PROPERTY_ID_NOTIME);
+
+               to.setItemEndPropertyId(SampleCalendarDatabase.PROPERTY_ID_END);
+               to.setItemTitlePropertyId(SampleCalendarDatabase.PROPERTY_ID_TITLE);
+               to.setItemNotimePropertyId(SampleCalendarDatabase.PROPERTY_ID_NOTIME);
+
+       }
 
 }
index 38c597ce771a8f0363baed28d8737d0d83e2ace9..88539f1d36a46bf2b73a6633f55828c017555007 100644 (file)
@@ -47,7 +47,7 @@ public class FilterSelect extends com.itmill.toolkit.Application {
                 */
                Window main = new Window("Filter select demo");
                setMainWindow(main);
-               
+
                setTheme("corporate");
 
                // default filter
index 76a3ba332179e7f564b1477dce07cb5a904e70eb..4e8d1020aa78afda47c4e81157416938917c9aac 100644 (file)
@@ -12,7 +12,7 @@ import com.itmill.toolkit.ui.*;
  * 
  */
 public class KeyboardShortcut extends com.itmill.toolkit.Application implements
-Handler {
+               Handler {
        private Window main;
 
        private Button a;
@@ -26,21 +26,16 @@ Handler {
        private AbstractField f;
 
        Action[] actions = new Action[] {
-                       new ShortcutAction("Button a action",
-                                       ShortcutAction.KeyCode.A, new int[] {
-                                       ShortcutAction.ModifierKey.CTRL,
-                                       ShortcutAction.ModifierKey.SHIFT }),
-                       new ShortcutAction("Button z action",
-                                       ShortcutAction.KeyCode.Z, new int[] {
-                                       ShortcutAction.ModifierKey.CTRL,
-                                       ShortcutAction.ModifierKey.SHIFT }),
-                       new ShortcutAction("Button x action",
-                                       ShortcutAction.KeyCode.X, new int[] {
-                                       ShortcutAction.ModifierKey.CTRL,
-                                       ShortcutAction.ModifierKey.SHIFT }),
-                       new ShortcutAction("Restart ",
-                               ShortcutAction.KeyCode.ESCAPE, null)
-       };
+                       new ShortcutAction("Button a action", ShortcutAction.KeyCode.A,
+                                       new int[] { ShortcutAction.ModifierKey.CTRL,
+                                                       ShortcutAction.ModifierKey.SHIFT }),
+                       new ShortcutAction("Button z action", ShortcutAction.KeyCode.Z,
+                                       new int[] { ShortcutAction.ModifierKey.CTRL,
+                                                       ShortcutAction.ModifierKey.SHIFT }),
+                       new ShortcutAction("Button x action", ShortcutAction.KeyCode.X,
+                                       new int[] { ShortcutAction.ModifierKey.CTRL,
+                                                       ShortcutAction.ModifierKey.SHIFT }),
+                       new ShortcutAction("Restart ", ShortcutAction.KeyCode.ESCAPE, null) };
 
        public void init() {
 
@@ -49,18 +44,18 @@ Handler {
                setTheme("corporate");
 
                main
-               .addComponent(new Label(
-                               "<h3>Test application for shortcut actions</h3>"
-                               + "<p><b>Notes:</b><br />"
-                               + "<b>This feature is under development and it's API may still change.</b><br />"
-                               + "<b>If events do not work, <b>set focus to Textfield first.</b><br />"
-                               + "<b>Browsers may have reserved the keyboard combinations used in "
-                               + "this demo for other purposes.</b><br /></p>",
-                               Label.CONTENT_XHTML));
+                               .addComponent(new Label(
+                                               "<h3>Test application for shortcut actions</h3>"
+                                                               + "<p><b>Notes:</b><br />"
+                                                               + "<b>This feature is under development and it's API may still change.</b><br />"
+                                                               + "<b>If events do not work, <b>set focus to Textfield first.</b><br />"
+                                                               + "<b>Browsers may have reserved the keyboard combinations used in "
+                                                               + "this demo for other purposes.</b><br /></p>",
+                                               Label.CONTENT_XHTML));
                main
-               .addComponent(new Label(
-                               "ESC restarts program, ctrl-shift-a clicks A button, "
-                               + "ctrl-shift-z clicks Z button, ctrl-shift-x clicks X button"));
+                               .addComponent(new Label(
+                                               "ESC restarts program, ctrl-shift-a clicks A button, "
+                                                               + "ctrl-shift-z clicks Z button, ctrl-shift-x clicks X button"));
 
                // Restart button
                close = new Button("restart", this, "close");
index f21e73ac805919b0db32bfa6c7380bac65c8c18d..7ad173421915d46622c94fb4bdd0509c4fdd0d7a 100644 (file)
@@ -6,7 +6,7 @@ import com.itmill.toolkit.terminal.PaintTarget;
 import com.itmill.toolkit.ui.*;
 
 public class ColorPicker extends AbstractField {
-       
+
        public ColorPicker() {
                super();
                setValue(new String("white"));
@@ -21,12 +21,12 @@ public class ColorPicker extends AbstractField {
        public String getTag() {
                return "colorpicker";
        }
-       
+
        /** Encode the property value of the field from RGB components. */
        public void setColor(String newcolor) {
                setValue(new String(newcolor));
        }
-       
+
        /** Decode the property value of the field to RGB components. */
        public String getColor() {
                return (String) getValue();
@@ -36,16 +36,16 @@ public class ColorPicker extends AbstractField {
        public void paintContent(PaintTarget target) throws PaintException {
                // Superclass writes any common attributes in the paint target.
                super.paintContent(target);
-               
+
                // Set any values as variables of the paint target.
                target.addVariable(this, "colorname", getColor());
        }
-       
+
        public void changeVariables(Object source, Map variables) {
                // Sets the currently selected color
                if (variables.containsKey("colorname") && !isReadOnly()) {
                        String newValue = (String) variables.get("colorname");
-                       setValue(newValue,true);
+                       setValue(newValue, true);
                }
        }
 }
index 2321f22dd6ff86a3b009b7af666cde49a5153821..16d7bb09b7b4de5e2a68d4c0d2bb5ce370919a05 100644 (file)
@@ -6,36 +6,37 @@ import com.itmill.toolkit.ui.*;
 import com.itmill.toolkit.ui.Button.ClickEvent;
 
 /**
- * Demonstration application that shows how to use a simple
- * custom client-side GWT component, the ColorPicker.
+ * Demonstration application that shows how to use a simple custom client-side
+ * GWT component, the ColorPicker.
  */
 public class ColorPickerApplication extends com.itmill.toolkit.Application {
        Window main = new Window("Color Picker Demo");
-       
+
        /* The custom component. */
        ColorPicker colorselector = new ColorPicker();
-       
+
        /* Another component. */
        Label colorname;
-       
+
        public void init() {
                setMainWindow(main);
                setTheme("demo");
-               
+
                // Listen for value change events in the custom component,
                // triggered when user clicks a button to select another color.
                colorselector.addListener(new ValueChangeListener() {
                        public void valueChange(ValueChangeEvent event) {
                                // Provide some server-side feedback
-                               colorname.setValue("Selected color: " + colorselector.getColor());
+                               colorname.setValue("Selected color: "
+                                               + colorselector.getColor());
                        }
                });
                main.addComponent(colorselector);
-               
+
                // Add another component to give feedback from server-side code
-               colorname = new Label("Selected color: "+colorselector.getColor());
+               colorname = new Label("Selected color: " + colorselector.getColor());
                main.addComponent(colorname);
-               
+
                // Server-side manipulation of the component state
                Button button = new Button("Set to white");
                button.addListener(new Button.ClickListener() {
index 1fbfa40bf877f4078e85f378357341e419e5a84b..29ab393253c1304104a9009b45b061686305d010 100644 (file)
@@ -6,20 +6,20 @@ import com.itmill.toolkit.terminal.gwt.client.DefaultWidgetSet;
 import com.itmill.toolkit.terminal.gwt.client.UIDL;\r
 \r
 public class WidgetSet extends DefaultWidgetSet {\r
-    public Widget createWidget(UIDL uidl) {\r
-       String className = resolveWidgetTypeName(uidl);\r
-       if ("com.itmill.toolkit.demo.colorpicker.gwt.client.ui.ItkColorPicker"\r
-               .equals(className))\r
-               return new ItkColorPicker();\r
+       public Widget createWidget(UIDL uidl) {\r
+               String className = resolveWidgetTypeName(uidl);\r
+               if ("com.itmill.toolkit.demo.colorpicker.gwt.client.ui.ItkColorPicker"\r
+                               .equals(className))\r
+                       return new ItkColorPicker();\r
 \r
-       return super.createWidget(uidl);\r
-    }\r
+               return super.createWidget(uidl);\r
+       }\r
 \r
-    protected String resolveWidgetTypeName(UIDL uidl) {\r
-       String tag = uidl.getTag();\r
-       if ("colorpicker".equals(tag))\r
-               return "com.itmill.toolkit.demo.colorpicker.gwt.client.ui.ItkColorPicker";\r
+       protected String resolveWidgetTypeName(UIDL uidl) {\r
+               String tag = uidl.getTag();\r
+               if ("colorpicker".equals(tag))\r
+                       return "com.itmill.toolkit.demo.colorpicker.gwt.client.ui.ItkColorPicker";\r
 \r
-       return super.resolveWidgetTypeName(uidl);\r
-    }\r
+               return super.resolveWidgetTypeName(uidl);\r
+       }\r
 }\r
index f3b792baf38559db95a37f56cc5a0a46871e2849..ca36176993574048a373302a8dc049c8ab526f61 100644 (file)
@@ -6,7 +6,7 @@ import com.google.gwt.user.client.ui.*;
 
 /**
  * A regular GWT component without integration with IT Mill Toolkit.
- **/
+ */
 public class GwtColorPicker extends Composite implements ClickListener {
 
        /** Currently selected color name to give client-side feedback to the user. */
@@ -14,44 +14,52 @@ public class GwtColorPicker extends Composite implements ClickListener {
 
        public GwtColorPicker() {
                // Create a 4x4 grid of buttons with names for 16 colors
-               Grid grid = new Grid(4,4);
-               String[] colors = new String[] {"aqua", "black", "blue", "fuchsia",
-                               "gray", "green", "lime", "maroon", "navy", "olive",
-                               "purple", "red", "silver", "teal", "white", "yellow"};
+               Grid grid = new Grid(4, 4);
+               String[] colors = new String[] { "aqua", "black", "blue", "fuchsia",
+                               "gray", "green", "lime", "maroon", "navy", "olive", "purple",
+                               "red", "silver", "teal", "white", "yellow" };
                int colornum = 0;
-               for (int i=0; i<4; i++)
-                       for (int j=0; j<4; j++, colornum++) {
+               for (int i = 0; i < 4; i++)
+                       for (int j = 0; j < 4; j++, colornum++) {
                                // Create a button for each color
                                Button button = new Button(colors[colornum]);
                                button.addClickListener(this);
-                               
+
                                // Put the button in the Grid layout
                                grid.setWidget(i, j, button);
 
                                // Set the button background colors.
-                               DOM.setStyleAttribute(button.getElement(), "background", colors[colornum]);
-                               
+                               DOM.setStyleAttribute(button.getElement(), "background",
+                                               colors[colornum]);
+
                                // For dark colors, the button label must be in white.
                                if ("black navy maroon blue purple".indexOf(colors[colornum]) != -1)
-                                       DOM.setStyleAttribute(button.getElement(), "color", "white");
+                                       DOM
+                                                       .setStyleAttribute(button.getElement(), "color",
+                                                                       "white");
                        }
 
-               // Create a panel with the color grid and currently selected color indicator
+               // Create a panel with the color grid and currently selected color
+               // indicator
                HorizontalPanel panel = new HorizontalPanel();
                panel.add(grid);
                panel.add(currentcolor);
 
-        // Set the class of the color selection feedback box to allow CSS styling.
+               // Set the class of the color selection feedback box to allow CSS
+               // styling.
                // We need to obtain the DOM element for the current color label.
                // This assumes that the <td> element of the HorizontalPanel is
-               // the parent of the label element. Notice that the element has no parent
+               // the parent of the label element. Notice that the element has no
+               // parent
                // before the widget has been added to the horizontal panel.
-        Element panelcell = DOM.getParent(currentcolor.getElement());
-        DOM.setElementProperty(panelcell, "className", "colorpicker-currentcolorbox");
+               Element panelcell = DOM.getParent(currentcolor.getElement());
+               DOM.setElementProperty(panelcell, "className",
+                               "colorpicker-currentcolorbox");
 
-        // Set initial color. This will be overridden with the value read from server.
+               // Set initial color. This will be overridden with the value read from
+               // server.
                setColor("white");
-               
+
                // Composite GWT widgets must call initWidget().
                initWidget(panel);
        }
@@ -60,21 +68,21 @@ public class GwtColorPicker extends Composite implements ClickListener {
        public void onClick(Widget sender) {
                // Use the button label as the color name to set
                setColor(((Button) sender).getText());
-    }
+       }
 
        /** Sets the currently selected color. */
        public void setColor(String newcolor) {
                // Give client-side feedback by changing the color name in the label
-        currentcolor.setText(newcolor);
+               currentcolor.setText(newcolor);
 
-        // Obtain the DOM elements. This assumes that the <td> element
-        // of the HorizontalPanel is the parent of the label element.
-        Element nameelement = currentcolor.getElement();
-        Element cell = DOM.getParent(nameelement);
+               // Obtain the DOM elements. This assumes that the <td> element
+               // of the HorizontalPanel is the parent of the label element.
+               Element nameelement = currentcolor.getElement();
+               Element cell = DOM.getParent(nameelement);
 
-        // Give feedback by changing the background color
-        DOM.setStyleAttribute(cell,        "background", newcolor);
-        DOM.setStyleAttribute(nameelement, "background", newcolor);
+               // Give feedback by changing the background color
+               DOM.setStyleAttribute(cell, "background", newcolor);
+               DOM.setStyleAttribute(nameelement, "background", newcolor);
                if ("black navy maroon blue purple".indexOf(newcolor) != -1)
                        DOM.setStyleAttribute(nameelement, "color", "white");
                else
index 54dedf2991433721b2080e0807ea2b37df693383..c1d9f532f058d9192b0833c19ae968717867b302 100644 (file)
@@ -16,13 +16,13 @@ public class ItkColorPicker extends GwtColorPicker implements Paintable {
        ApplicationConnection client;
 
        /**
-        * The constructor should first call super() to initialize the component
-        * and then handle any initialization relevant to IT Mill Toolkit. 
-        **/
+        * The constructor should first call super() to initialize the component and
+        * then handle any initialization relevant to IT Mill Toolkit.
+        */
        public ItkColorPicker() {
                // The superclass has a lot of relevant initialization
                super();
-               
+
                // This method call of the Paintable interface sets the component
                // style name in DOM tree
                setStyleName(CLASSNAME);
@@ -40,11 +40,11 @@ public class ItkColorPicker extends GwtColorPicker implements Paintable {
                // but don't let container manage caption etc.
                if (client.updateComponent(this, uidl, false))
                        return;
+
                // Save reference to server connection object to be able to send
                // user interaction later
                this.client = client;
-               
+
                // Save the UIDL identifier for the component
                uidl_id = uidl.getId();
 
@@ -57,18 +57,18 @@ public class ItkColorPicker extends GwtColorPicker implements Paintable {
                // Ignore if no change
                if (newcolor.equals(currentcolor.getText()))
                        return;
-               
+
                // Let the original implementation to do whatever it needs to do
                super.setColor(newcolor);
 
-        // Updating the state to the server can not be done before
+               // Updating the state to the server can not be done before
                // the server connection is known, i.e., before updateFromUIDL()
                // has been called.
                if (uidl_id == null || client == null)
-                         return;
+                       return;
 
                // Communicate the user interaction parameters to server. This call will
                // initiate an AJAX request to the server.
-               client.updateVariable(uidl_id, "colorname", newcolor, true);
+               client.updateVariable(uidl_id, "colorname", newcolor, true);
        }
 }
index ae1c017a083ad42236d096abf3521b20910be085..8a38e6854fa7048d7d399ddb1ddf70afbc8aa202 100644 (file)
@@ -94,7 +94,7 @@ public abstract class Feature extends CustomComponent {
                        layout.addComponent(demo);
 
                ts = new TabSheet();
-               
+
                ts.setWidth(100);
                ts.setWidthUnits(TabSheet.UNITS_PERCENTAGE);
                ts.setHeight(100);
@@ -159,7 +159,7 @@ public abstract class Feature extends CustomComponent {
        public TabSheet getTabSheet() {
                return ts;
        }
-       
+
        /** Get the name of the image file that will be put on description page */
        protected String getImage() {
                return null;
index 4c279d681a5ea91811c51ed54ab6efbda3eaef70..ad5d2ff175b1ed3ee264c5f0615e660aee497d61 100644 (file)
@@ -83,7 +83,7 @@ public class FeatureBrowser extends CustomComponent implements
                // Restart button
                Button close = new Button("restart", getApplication(), "close");
                close.setStyle("link");
-               mainlayout.addComponent(close,"restart");
+               mainlayout.addComponent(close, "restart");
 
                // Test component
                registerFeature("/Welcome", new IntroWelcome());
@@ -199,12 +199,12 @@ public class FeatureBrowser extends CustomComponent implements
                                if (feature != null) {
                                        mainlayout.removeComponent(currentFeature);
                                        mainlayout.removeComponent(currentFeature.getTabSheet());
-                                       mainlayout.addComponent(feature,"demo");
-                                       mainlayout.addComponent(feature.getTabSheet(),"tabsheet");
+                                       mainlayout.addComponent(feature, "demo");
+                                       mainlayout.addComponent(feature.getTabSheet(), "tabsheet");
                                        currentFeature = feature;
                                        properties = feature.getPropertyPanel();
                                        if (properties != null) {
-                                               mainlayout.addComponent(properties,"properties");
+                                               mainlayout.addComponent(properties, "properties");
                                        }
                                        getWindow()
                                                        .setCaption(
@@ -233,17 +233,17 @@ public class FeatureBrowser extends CustomComponent implements
 
        public void addComponent(Component c) {
                // TODO Auto-generated method stub
-               
+
        }
 
        public void addListener(ComponentAttachListener listener) {
                // TODO Auto-generated method stub
-               
+
        }
 
        public void addListener(ComponentDetachListener listener) {
                // TODO Auto-generated method stub
-               
+
        }
 
        public Iterator getComponentIterator() {
@@ -253,31 +253,31 @@ public class FeatureBrowser extends CustomComponent implements
 
        public void moveComponentsFrom(ComponentContainer source) {
                // TODO Auto-generated method stub
-               
+
        }
 
        public void removeAllComponents() {
                // TODO Auto-generated method stub
-               
+
        }
 
        public void removeComponent(Component c) {
                // TODO Auto-generated method stub
-               
+
        }
 
        public void removeListener(ComponentAttachListener listener) {
                // TODO Auto-generated method stub
-               
+
        }
 
        public void removeListener(ComponentDetachListener listener) {
                // TODO Auto-generated method stub
-               
+
        }
 
        public void replaceComponent(Component oldComponent, Component newComponent) {
                // TODO Auto-generated method stub
-               
+
        }
 }
index dae5ca2573e5208293b37a98d559e454c8b2ebd7..915b3088a75ff1699c9f2c28cdb6d2ff6733addc 100644 (file)
@@ -45,7 +45,7 @@ public class FeatureDateField extends Feature {
        static {
                Locale[] locales = Locale.getAvailableLocales();
                localeNames = new String[locales.length];
-               for (int i = 0; i < locales.length; i++) 
+               for (int i = 0; i < locales.length; i++)
                        localeNames[i] = locales[i].getDisplayName();
        }
 
@@ -64,11 +64,11 @@ public class FeatureDateField extends Feature {
                DateField df = new DateField();
                df.setValue(new java.util.Date());
                l.addComponent(df);
-               
+
                // Properties
                propertyPanel = new PropertyPanel(df);
-               Form ap = propertyPanel
-                               .createBeanPropertySet(new String[] { "resolution", "locale" });
+               Form ap = propertyPanel.createBeanPropertySet(new String[] {
+                               "resolution", "locale" });
                ap.replaceWithSelect("resolution", new Object[] {
                                new Integer(DateField.RESOLUTION_YEAR),
                                new Integer(DateField.RESOLUTION_MONTH),
@@ -79,7 +79,8 @@ public class FeatureDateField extends Feature {
                                new Integer(DateField.RESOLUTION_MSEC) }, new Object[] {
                                "Year", "Month", "Day", "Hour", "Minute", "Second",
                                "Millisecond" });
-               ap.replaceWithSelect("locale", Locale.getAvailableLocales(), localeNames);
+               ap.replaceWithSelect("locale", Locale.getAvailableLocales(),
+                               localeNames);
                ap.getField("resolution").setValue(
                                new Integer(DateField.RESOLUTION_DAY));
                ap.getField("locale").setValue(Locale.getDefault());
index 1c833e687f769a3b1628ee03c784fc19c9ce2ce9..17461faa4326338183f748daf9589c96ebe85990 100644 (file)
@@ -38,7 +38,7 @@ public class FeaturesApplication extends com.itmill.toolkit.Application {
                setUser(new Long(System.currentTimeMillis()).toString());
                Window main = new Window("IT Mill Toolkit Features Tour");
                setMainWindow(main);
-               
+
                main.setLayout(new FeatureBrowser());
        }
 
index f3a711b650d8caa14a933d9e3b9ce9ac1e9af87a..9b9ae09b1d8e0f1c74b732590d08db69aa3554e8 100644 (file)
@@ -76,7 +76,7 @@ public class PropertyPanel extends Panel implements Button.ClickListener,
                setWidthUnits(Table.UNITS_PERCENTAGE);
                setHeight(100);
                setHeightUnits(Table.UNITS_PERCENTAGE);
-               
+
                // Target object
                this.objectToConfigure = objectToConfigure;
                config = new BeanItem(objectToConfigure);
@@ -111,8 +111,8 @@ public class PropertyPanel extends Panel implements Button.ClickListener,
                allProperties.setWidth(100);
                allProperties.setWidthUnits(Table.UNITS_PERCENTAGE);
                // TODO Add as soon as supported
-               //allProperties.setHeight(100);
-               //allProperties.setHeightUnits(Table.UNITS_PERCENTAGE);
+               // allProperties.setHeight(100);
+               // allProperties.setHeightUnits(Table.UNITS_PERCENTAGE);
                updatePropertyList();
 
        }
index 0869cf5b640ced3147965e11460f2a78b7f9decd..cae3529e0ff89dc4f4e92a0634cb88ab2afd51c6 100644 (file)
@@ -14,206 +14,206 @@ import com.itmill.toolkit.terminal.Sizeable;
 import com.itmill.toolkit.ui.AbstractComponent;\r
 \r
 public class GoogleMap extends AbstractComponent implements Sizeable,\r
-       Container.Viewer {\r
-    private String TAG_MARKERS = "markers";\r
-    private String TAG_MARKER = "marker";\r
-    private int width = 400;\r
-    private int height = 300;\r
-    private int zoomLevel = 15;\r
-    private Point2D.Double mapCenter;\r
-\r
-    private Container dataSource;\r
-    private Object itemMarkerHtmlPropertyId = new Object();\r
-    private Object itemMarkerXPropertyId = new Object();\r
-    private Object itemMarkerYPropertyId = new Object();\r
-\r
-    public String getTag() {\r
-       return "googlemap";\r
-    }\r
-\r
-    public void paintContent(PaintTarget target) throws PaintException {\r
-       super.paintContent(target);\r
-       if (null != mapCenter) {\r
-           target.addAttribute("centerX", mapCenter.getX());\r
-           target.addAttribute("centerY", mapCenter.getY());\r
-       }\r
-       target.addAttribute("zoom", zoomLevel);\r
-       target.addAttribute("width", width);\r
-       target.addAttribute("height", height);\r
-\r
-       if (this.dataSource != null) {\r
-           target.startTag(TAG_MARKERS);\r
-           Collection itemIds = this.dataSource.getItemIds();\r
-           for (Iterator it = itemIds.iterator(); it.hasNext();) {\r
-               Object itemId = it.next();\r
-               Item item = this.dataSource.getItem(itemId);\r
-               Property p = item.getItemProperty(getItemMarkerXPropertyId());\r
-               Double x = (Double) (p != null ? p.getValue() : null);\r
-               p = item.getItemProperty(getItemMarkerYPropertyId());\r
-               Double y = (Double) (p != null ? p.getValue() : null);\r
-               if (x == null || y == null) {\r
-                   continue;\r
+               Container.Viewer {\r
+       private String TAG_MARKERS = "markers";\r
+       private String TAG_MARKER = "marker";\r
+       private int width = 400;\r
+       private int height = 300;\r
+       private int zoomLevel = 15;\r
+       private Point2D.Double mapCenter;\r
+\r
+       private Container dataSource;\r
+       private Object itemMarkerHtmlPropertyId = new Object();\r
+       private Object itemMarkerXPropertyId = new Object();\r
+       private Object itemMarkerYPropertyId = new Object();\r
+\r
+       public String getTag() {\r
+               return "googlemap";\r
+       }\r
+\r
+       public void paintContent(PaintTarget target) throws PaintException {\r
+               super.paintContent(target);\r
+               if (null != mapCenter) {\r
+                       target.addAttribute("centerX", mapCenter.getX());\r
+                       target.addAttribute("centerY", mapCenter.getY());\r
+               }\r
+               target.addAttribute("zoom", zoomLevel);\r
+               target.addAttribute("width", width);\r
+               target.addAttribute("height", height);\r
+\r
+               if (this.dataSource != null) {\r
+                       target.startTag(TAG_MARKERS);\r
+                       Collection itemIds = this.dataSource.getItemIds();\r
+                       for (Iterator it = itemIds.iterator(); it.hasNext();) {\r
+                               Object itemId = it.next();\r
+                               Item item = this.dataSource.getItem(itemId);\r
+                               Property p = item.getItemProperty(getItemMarkerXPropertyId());\r
+                               Double x = (Double) (p != null ? p.getValue() : null);\r
+                               p = item.getItemProperty(getItemMarkerYPropertyId());\r
+                               Double y = (Double) (p != null ? p.getValue() : null);\r
+                               if (x == null || y == null) {\r
+                                       continue;\r
+                               }\r
+                               target.startTag(TAG_MARKER);\r
+                               target.addAttribute("x", x.doubleValue());\r
+                               target.addAttribute("y", y.doubleValue());\r
+                               p = item.getItemProperty(getItemMarkerHtmlPropertyId());\r
+                               String h = (String) (p != null ? p.getValue() : null);\r
+                               target.addAttribute("html", h);\r
+                               target.endTag(TAG_MARKER);\r
+                       }\r
+                       target.endTag(TAG_MARKERS);\r
                }\r
-               target.startTag(TAG_MARKER);\r
-               target.addAttribute("x", x.doubleValue());\r
-               target.addAttribute("y", y.doubleValue());\r
-               p = item.getItemProperty(getItemMarkerHtmlPropertyId());\r
-               String h = (String) (p != null ? p.getValue() : null);\r
-               target.addAttribute("html", h);\r
-               target.endTag(TAG_MARKER);\r
-           }\r
-           target.endTag(TAG_MARKERS);\r
-       }\r
-    }\r
-\r
-    public void setZoomLevel(int zoomLevel) {\r
-       this.zoomLevel = zoomLevel;\r
-       requestRepaint();\r
-    }\r
-\r
-    public int getZoomLevel() {\r
-       return this.zoomLevel;\r
-    }\r
-\r
-    // Sizeable methods:\r
-\r
-    public int getHeight() {\r
-       return this.height;\r
-    }\r
-\r
-    public int getHeightUnits() {\r
-       return Sizeable.UNITS_PIXELS;\r
-    }\r
-\r
-    public int getWidth() {\r
-       return this.width;\r
-    }\r
-\r
-    public int getWidthUnits() {\r
-       return Sizeable.UNITS_PIXELS;\r
-    }\r
-\r
-    public void setHeight(int height) {\r
-       this.height = height;\r
-       requestRepaint();\r
-    }\r
-\r
-    public void setHeightUnits(int units) {\r
-       throw new UnsupportedOperationException();\r
-    }\r
-\r
-    public void setWidth(int width) {\r
-       this.width = width;\r
-       requestRepaint();\r
-    }\r
-\r
-    public void setWidthUnits(int units) {\r
-       throw new UnsupportedOperationException();\r
-    }\r
-\r
-    public void setMapCenter(Point2D.Double center) {\r
-       this.mapCenter = center;\r
-    }\r
-    \r
-    public Point2D.Double getMapCenter() {\r
-       return this.mapCenter;\r
-    }\r
-    \r
-    // Container.Viewer methods:\r
-\r
-    public Container getContainerDataSource() {\r
-       return this.dataSource;\r
-    }\r
-\r
-    public void setContainerDataSource(Container newDataSource) {\r
-\r
-       this.dataSource = newDataSource;\r
-\r
-       requestRepaint();\r
-    }\r
-\r
-    // Item methods\r
-\r
-    public Object getItemMarkerHtmlPropertyId() {\r
-       return itemMarkerHtmlPropertyId;\r
-    }\r
-\r
-    public void setItemMarkerHtmlPropertyId(Object itemMarkerHtmlPropertyId) {\r
-       this.itemMarkerHtmlPropertyId = itemMarkerHtmlPropertyId;\r
-       requestRepaint();\r
-    }\r
-\r
-    public Object getItemMarkerXPropertyId() {\r
-       return itemMarkerXPropertyId;\r
-    }\r
-\r
-    public void setItemMarkerXPropertyId(Object itemMarkerXPropertyId) {\r
-       this.itemMarkerXPropertyId = itemMarkerXPropertyId;\r
-       requestRepaint();\r
-    }\r
-\r
-    public Object getItemMarkerYPropertyId() {\r
-       return itemMarkerYPropertyId;\r
-    }\r
-\r
-    public void setItemMarkerYPropertyId(Object itemMarkerYPropertyId) {\r
-       this.itemMarkerYPropertyId = itemMarkerYPropertyId;\r
-       requestRepaint();\r
-    }\r
-\r
-    // Marker add\r
-\r
-    public Object addMarker(String html, Point2D.Double location) {\r
-       if (location == null) {\r
-           throw new IllegalArgumentException("Location must be non-null");\r
-       }\r
-       if (this.dataSource == null) {\r
-           initDataSource();\r
-       }\r
-       Object markerId = this.dataSource.addItem();\r
-       if (markerId == null) {\r
-           return null;\r
-       }\r
-       Item marker = this.dataSource.getItem(markerId);\r
-       Property p = marker.getItemProperty(getItemMarkerXPropertyId());\r
-       p.setValue(new Double(location.x));\r
-       p = marker.getItemProperty(getItemMarkerYPropertyId());\r
-       p.setValue(new Double(location.y));\r
-       p = marker.getItemProperty(getItemMarkerHtmlPropertyId());\r
-       p.setValue(html);\r
-\r
-       requestRepaint();\r
-\r
-       return markerId;\r
-    }\r
-\r
-    public void removeMarker(Object markerId) {\r
-       if (this.dataSource != null) {\r
-           this.dataSource.removeItem(markerId);\r
-           requestRepaint();\r
-       }\r
-    }\r
-\r
-    public Item getMarkerItem(Object markerId) {\r
-       if (this.dataSource != null) {\r
-           return this.dataSource.getItem(markerId);\r
-       } else {\r
-           return null;\r
-       }\r
-    }\r
-\r
-    // dataSource init helper:\r
-    private void initDataSource() {\r
-       this.dataSource = new IndexedContainer();\r
-       this.dataSource.addContainerProperty(this.itemMarkerHtmlPropertyId,\r
-               String.class, null);\r
-       this.dataSource.addContainerProperty(this.itemMarkerXPropertyId,\r
-               Double.class, new Double(0));\r
-       this.dataSource.addContainerProperty(this.itemMarkerYPropertyId,\r
-               Double.class, new Double(0));\r
-    }\r
-    \r
-    public void clear() {\r
-       setContainerDataSource(null);\r
-    }\r
+       }\r
+\r
+       public void setZoomLevel(int zoomLevel) {\r
+               this.zoomLevel = zoomLevel;\r
+               requestRepaint();\r
+       }\r
+\r
+       public int getZoomLevel() {\r
+               return this.zoomLevel;\r
+       }\r
+\r
+       // Sizeable methods:\r
+\r
+       public int getHeight() {\r
+               return this.height;\r
+       }\r
+\r
+       public int getHeightUnits() {\r
+               return Sizeable.UNITS_PIXELS;\r
+       }\r
+\r
+       public int getWidth() {\r
+               return this.width;\r
+       }\r
+\r
+       public int getWidthUnits() {\r
+               return Sizeable.UNITS_PIXELS;\r
+       }\r
+\r
+       public void setHeight(int height) {\r
+               this.height = height;\r
+               requestRepaint();\r
+       }\r
+\r
+       public void setHeightUnits(int units) {\r
+               throw new UnsupportedOperationException();\r
+       }\r
+\r
+       public void setWidth(int width) {\r
+               this.width = width;\r
+               requestRepaint();\r
+       }\r
+\r
+       public void setWidthUnits(int units) {\r
+               throw new UnsupportedOperationException();\r
+       }\r
+\r
+       public void setMapCenter(Point2D.Double center) {\r
+               this.mapCenter = center;\r
+       }\r
+\r
+       public Point2D.Double getMapCenter() {\r
+               return this.mapCenter;\r
+       }\r
+\r
+       // Container.Viewer methods:\r
+\r
+       public Container getContainerDataSource() {\r
+               return this.dataSource;\r
+       }\r
+\r
+       public void setContainerDataSource(Container newDataSource) {\r
+\r
+               this.dataSource = newDataSource;\r
+\r
+               requestRepaint();\r
+       }\r
+\r
+       // Item methods\r
+\r
+       public Object getItemMarkerHtmlPropertyId() {\r
+               return itemMarkerHtmlPropertyId;\r
+       }\r
+\r
+       public void setItemMarkerHtmlPropertyId(Object itemMarkerHtmlPropertyId) {\r
+               this.itemMarkerHtmlPropertyId = itemMarkerHtmlPropertyId;\r
+               requestRepaint();\r
+       }\r
+\r
+       public Object getItemMarkerXPropertyId() {\r
+               return itemMarkerXPropertyId;\r
+       }\r
+\r
+       public void setItemMarkerXPropertyId(Object itemMarkerXPropertyId) {\r
+               this.itemMarkerXPropertyId = itemMarkerXPropertyId;\r
+               requestRepaint();\r
+       }\r
+\r
+       public Object getItemMarkerYPropertyId() {\r
+               return itemMarkerYPropertyId;\r
+       }\r
+\r
+       public void setItemMarkerYPropertyId(Object itemMarkerYPropertyId) {\r
+               this.itemMarkerYPropertyId = itemMarkerYPropertyId;\r
+               requestRepaint();\r
+       }\r
+\r
+       // Marker add\r
+\r
+       public Object addMarker(String html, Point2D.Double location) {\r
+               if (location == null) {\r
+                       throw new IllegalArgumentException("Location must be non-null");\r
+               }\r
+               if (this.dataSource == null) {\r
+                       initDataSource();\r
+               }\r
+               Object markerId = this.dataSource.addItem();\r
+               if (markerId == null) {\r
+                       return null;\r
+               }\r
+               Item marker = this.dataSource.getItem(markerId);\r
+               Property p = marker.getItemProperty(getItemMarkerXPropertyId());\r
+               p.setValue(new Double(location.x));\r
+               p = marker.getItemProperty(getItemMarkerYPropertyId());\r
+               p.setValue(new Double(location.y));\r
+               p = marker.getItemProperty(getItemMarkerHtmlPropertyId());\r
+               p.setValue(html);\r
+\r
+               requestRepaint();\r
+\r
+               return markerId;\r
+       }\r
+\r
+       public void removeMarker(Object markerId) {\r
+               if (this.dataSource != null) {\r
+                       this.dataSource.removeItem(markerId);\r
+                       requestRepaint();\r
+               }\r
+       }\r
+\r
+       public Item getMarkerItem(Object markerId) {\r
+               if (this.dataSource != null) {\r
+                       return this.dataSource.getItem(markerId);\r
+               } else {\r
+                       return null;\r
+               }\r
+       }\r
+\r
+       // dataSource init helper:\r
+       private void initDataSource() {\r
+               this.dataSource = new IndexedContainer();\r
+               this.dataSource.addContainerProperty(this.itemMarkerHtmlPropertyId,\r
+                               String.class, null);\r
+               this.dataSource.addContainerProperty(this.itemMarkerXPropertyId,\r
+                               Double.class, new Double(0));\r
+               this.dataSource.addContainerProperty(this.itemMarkerYPropertyId,\r
+                               Double.class, new Double(0));\r
+       }\r
+\r
+       public void clear() {\r
+               setContainerDataSource(null);\r
+       }\r
 }
\ No newline at end of file
index 1476c4b668ae28735c0a50f988780f4a54171460..2f9d8da7791fda7a493557266e676a119418309f 100644 (file)
@@ -25,259 +25,260 @@ import com.itmill.toolkit.ui.TabSheet.SelectedTabChangeEvent;
 \r
 public class ReservationApplication extends Application {\r
 \r
-    private SampleDB db;\r
-\r
-    ResourceSelectorPanel resourcePanel;\r
-\r
-    private CalendarField reservedFrom;\r
-    private static final long DEFAULT_GAP_MILLIS = 3600000; // one hour\r
-    private long currentGapMillis = DEFAULT_GAP_MILLIS;\r
-    private CalendarField reservedTo;\r
-\r
-    private Label resourceName;\r
-    private Label statusLabel;\r
-    private TextField description;\r
-    private Button reservationButton;\r
-\r
-    private Table allTable;\r
-    private CalendarField allCalendar;\r
-\r
-    private GoogleMap map;\r
-\r
-    public void init() {\r
-       db = new SampleDB(true);\r
-       db.generateResources();\r
-       db.generateDemoUser();\r
-\r
-       Window mainWindow = new Window("Reservr");\r
-       setMainWindow(mainWindow);\r
-       setTheme("reservr");\r
-\r
-       TabSheet mainTabs = new TabSheet();\r
-       mainWindow.addComponent(mainTabs);\r
-\r
-       mainWindow.addComponent(new Button("close", this, "close"));\r
-\r
-       OrderedLayout reservationTab = new OrderedLayout();\r
-       mainTabs.addTab(reservationTab, "Make reservation", null);\r
-\r
-       resourcePanel = new ResourceSelectorPanel("Resources");\r
-       resourcePanel.setResourceContainer(db.getResources(null));\r
-       resourcePanel.addListener(\r
-               ResourceSelectorPanel.SelectedResourcesChangedEvent.class,\r
-               this, "selectedResourcesChanged");\r
-       reservationTab.addComponent(resourcePanel);\r
-\r
-       Panel reservationPanel = new Panel("Reservation", new OrderedLayout(\r
-               OrderedLayout.ORIENTATION_HORIZONTAL));\r
-       reservationTab.addComponent(reservationPanel);\r
-\r
-       OrderedLayout infoLayout = new OrderedLayout();\r
-       reservationPanel.addComponent(infoLayout);\r
-       resourceName = new Label("From the list above");\r
-       resourceName.setCaption("Choose resource");\r
-       infoLayout.addComponent(resourceName);\r
-       description = new TextField();\r
-       description.setColumns(55);\r
-       description.setRows(5);\r
-       infoLayout.addComponent(description);\r
-       reservationButton = new Button("Make reservation", this,\r
-               "makeReservation");\r
-       infoLayout.addComponent(reservationButton);\r
-       statusLabel = new Label();\r
-       infoLayout.addComponent(statusLabel);\r
-\r
-       map = new GoogleMap();\r
-       map.setWidth(360);\r
-       map.setHeight(270);\r
-       map.setItemMarkerHtmlPropertyId(SampleDB.Resource.PROPERTY_ID_NAME);\r
-       map.setItemMarkerXPropertyId(SampleDB.Resource.PROPERTY_ID_LOCATIONX);\r
-       map.setItemMarkerYPropertyId(SampleDB.Resource.PROPERTY_ID_LOCATIONY);\r
-       map.setContainerDataSource(db.getResources(null));\r
-       infoLayout.addComponent(map);\r
-\r
-       Calendar from = Calendar.getInstance();\r
-       reservedFrom = new CalendarField();\r
-       reservedFrom.setMinimumDate(from.getTime());\r
-       reservedFrom.setValue(from.getTime());\r
-       reservedFrom.setImmediate(true);\r
-       initCalendarFieldPropertyIds(reservedFrom);\r
-       reservationPanel.addComponent(reservedFrom);    \r
-       \r
-       Calendar to = Calendar.getInstance();\r
-       to.add(Calendar.MILLISECOND, (int)currentGapMillis);\r
-       reservedTo = new CalendarField();\r
-       reservedTo.setMinimumDate(from.getTime());\r
-       reservedTo.setValue(to.getTime());\r
-       reservedTo.setImmediate(true);\r
-       initCalendarFieldPropertyIds(reservedTo);\r
-       reservationPanel.addComponent(reservedTo);\r
-       \r
-       reservedFrom.addListener(new ValueChangeListener() {\r
-           public void valueChange(ValueChangeEvent event) {\r
-               Date fd = (Date) reservedFrom.getValue();\r
-               if (fd == null) {\r
-                   reservedTo.setValue(null);\r
-                   reservedTo.setEnabled(false);\r
-                   refreshSelectedResources();\r
-                   return;\r
-               } else {\r
-                   reservedTo.setEnabled(true);\r
-               }\r
-               reservedTo.setMinimumDate(fd);\r
+       private SampleDB db;\r
+\r
+       ResourceSelectorPanel resourcePanel;\r
+\r
+       private CalendarField reservedFrom;\r
+       private static final long DEFAULT_GAP_MILLIS = 3600000; // one hour\r
+       private long currentGapMillis = DEFAULT_GAP_MILLIS;\r
+       private CalendarField reservedTo;\r
+\r
+       private Label resourceName;\r
+       private Label statusLabel;\r
+       private TextField description;\r
+       private Button reservationButton;\r
+\r
+       private Table allTable;\r
+       private CalendarField allCalendar;\r
+\r
+       private GoogleMap map;\r
+\r
+       public void init() {\r
+               db = new SampleDB(true);\r
+               db.generateResources();\r
+               db.generateDemoUser();\r
+\r
+               Window mainWindow = new Window("Reservr");\r
+               setMainWindow(mainWindow);\r
+               setTheme("reservr");\r
+\r
+               TabSheet mainTabs = new TabSheet();\r
+               mainWindow.addComponent(mainTabs);\r
+\r
+               mainWindow.addComponent(new Button("close", this, "close"));\r
+\r
+               OrderedLayout reservationTab = new OrderedLayout();\r
+               mainTabs.addTab(reservationTab, "Make reservation", null);\r
+\r
+               resourcePanel = new ResourceSelectorPanel("Resources");\r
+               resourcePanel.setResourceContainer(db.getResources(null));\r
+               resourcePanel.addListener(\r
+                               ResourceSelectorPanel.SelectedResourcesChangedEvent.class,\r
+                               this, "selectedResourcesChanged");\r
+               reservationTab.addComponent(resourcePanel);\r
+\r
+               Panel reservationPanel = new Panel("Reservation", new OrderedLayout(\r
+                               OrderedLayout.ORIENTATION_HORIZONTAL));\r
+               reservationTab.addComponent(reservationPanel);\r
+\r
+               OrderedLayout infoLayout = new OrderedLayout();\r
+               reservationPanel.addComponent(infoLayout);\r
+               resourceName = new Label("From the list above");\r
+               resourceName.setCaption("Choose resource");\r
+               infoLayout.addComponent(resourceName);\r
+               description = new TextField();\r
+               description.setColumns(55);\r
+               description.setRows(5);\r
+               infoLayout.addComponent(description);\r
+               reservationButton = new Button("Make reservation", this,\r
+                               "makeReservation");\r
+               infoLayout.addComponent(reservationButton);\r
+               statusLabel = new Label();\r
+               infoLayout.addComponent(statusLabel);\r
+\r
+               map = new GoogleMap();\r
+               map.setWidth(360);\r
+               map.setHeight(270);\r
+               map.setItemMarkerHtmlPropertyId(SampleDB.Resource.PROPERTY_ID_NAME);\r
+               map.setItemMarkerXPropertyId(SampleDB.Resource.PROPERTY_ID_LOCATIONX);\r
+               map.setItemMarkerYPropertyId(SampleDB.Resource.PROPERTY_ID_LOCATIONY);\r
+               map.setContainerDataSource(db.getResources(null));\r
+               infoLayout.addComponent(map);\r
+\r
+               Calendar from = Calendar.getInstance();\r
+               reservedFrom = new CalendarField();\r
+               reservedFrom.setMinimumDate(from.getTime());\r
+               reservedFrom.setValue(from.getTime());\r
+               reservedFrom.setImmediate(true);\r
+               initCalendarFieldPropertyIds(reservedFrom);\r
+               reservationPanel.addComponent(reservedFrom);\r
+\r
                Calendar to = Calendar.getInstance();\r
-               to.setTime(fd);\r
-               to.add(Calendar.MILLISECOND, (int)currentGapMillis);\r
+               to.add(Calendar.MILLISECOND, (int) currentGapMillis);\r
+               reservedTo = new CalendarField();\r
+               reservedTo.setMinimumDate(from.getTime());\r
                reservedTo.setValue(to.getTime());\r
-               refreshSelectedResources();\r
-               resetStatus();\r
-           }\r
-       });\r
-       reservedTo.addListener(new ValueChangeListener() {\r
-           public void valueChange(ValueChangeEvent event) {\r
-               Date from = (Date) reservedFrom.getValue();\r
-               Date to = (Date) reservedTo.getValue();\r
-               currentGapMillis = to.getTime() - from.getTime();\r
-               if (currentGapMillis <= 0 ) {\r
-                   Calendar t = Calendar.getInstance();\r
-                   t.setTime(from);\r
-                   t.add(Calendar.MILLISECOND, (int)DEFAULT_GAP_MILLIS);\r
-                   reservedTo.setValue(t.getTime());\r
+               reservedTo.setImmediate(true);\r
+               initCalendarFieldPropertyIds(reservedTo);\r
+               reservationPanel.addComponent(reservedTo);\r
+\r
+               reservedFrom.addListener(new ValueChangeListener() {\r
+                       public void valueChange(ValueChangeEvent event) {\r
+                               Date fd = (Date) reservedFrom.getValue();\r
+                               if (fd == null) {\r
+                                       reservedTo.setValue(null);\r
+                                       reservedTo.setEnabled(false);\r
+                                       refreshSelectedResources();\r
+                                       return;\r
+                               } else {\r
+                                       reservedTo.setEnabled(true);\r
+                               }\r
+                               reservedTo.setMinimumDate(fd);\r
+                               Calendar to = Calendar.getInstance();\r
+                               to.setTime(fd);\r
+                               to.add(Calendar.MILLISECOND, (int) currentGapMillis);\r
+                               reservedTo.setValue(to.getTime());\r
+                               refreshSelectedResources();\r
+                               resetStatus();\r
+                       }\r
+               });\r
+               reservedTo.addListener(new ValueChangeListener() {\r
+                       public void valueChange(ValueChangeEvent event) {\r
+                               Date from = (Date) reservedFrom.getValue();\r
+                               Date to = (Date) reservedTo.getValue();\r
+                               currentGapMillis = to.getTime() - from.getTime();\r
+                               if (currentGapMillis <= 0) {\r
+                                       Calendar t = Calendar.getInstance();\r
+                                       t.setTime(from);\r
+                                       t.add(Calendar.MILLISECOND, (int) DEFAULT_GAP_MILLIS);\r
+                                       reservedTo.setValue(t.getTime());\r
+                               }\r
+                               refreshSelectedResources();\r
+                               resetStatus();\r
+                       }\r
+               });\r
+\r
+               OrderedLayout allLayout = new OrderedLayout(\r
+                               OrderedLayout.ORIENTATION_HORIZONTAL);\r
+               allCalendar = new CalendarField();\r
+               initCalendarFieldPropertyIds(allCalendar);\r
+               allLayout.addComponent(allCalendar);\r
+               allTable = new Table();\r
+               allLayout.addComponent(allTable);\r
+               mainTabs.addTab(allLayout, "All reservations", null);\r
+               mainTabs.addListener(new TabSheet.SelectedTabChangeListener() {\r
+                       public void selectedTabChange(SelectedTabChangeEvent event) {\r
+                               refreshReservations();\r
+                       }\r
+               });\r
+\r
+               refreshReservations();\r
+       }\r
+\r
+       public void makeReservation() {\r
+               try {\r
+                       Item resource = getActiveResource();\r
+                       if (resource != null) {\r
+                               db.addReservation(resource, 0, (Date) reservedFrom.getValue(),\r
+                                               (Date) reservedTo.getValue(), (String) description\r
+                                                               .getValue());\r
+                               statusLabel.setCaption("Success!");\r
+                               statusLabel\r
+                                               .setValue("You have reserved the resource for the selected period.");\r
+                       }\r
+               } catch (ResourceNotAvailableException e) {\r
+                       statusLabel.setCaption("Reservation failed");\r
+                       statusLabel\r
+                                       .setValue("The selected resource was not available for the selected period.");\r
                }\r
-               refreshSelectedResources();\r
-               resetStatus();\r
-           }\r
-       });\r
-\r
-       OrderedLayout allLayout = new OrderedLayout(\r
-               OrderedLayout.ORIENTATION_HORIZONTAL);\r
-       allCalendar = new CalendarField();\r
-       initCalendarFieldPropertyIds(allCalendar);\r
-       allLayout.addComponent(allCalendar);\r
-       allTable = new Table();\r
-       allLayout.addComponent(allTable);\r
-       mainTabs.addTab(allLayout, "All reservations", null);\r
-       mainTabs.addListener(new TabSheet.SelectedTabChangeListener() {\r
-           public void selectedTabChange(SelectedTabChangeEvent event) {\r
                refreshReservations();\r
-           }\r
-       });\r
-\r
-       refreshReservations();\r
-    }\r
-\r
-    public void makeReservation() {\r
-       try {\r
-           Item resource = getActiveResource();\r
-           if (resource != null) {\r
-               db.addReservation(resource, 0, (Date) reservedFrom.getValue(),\r
-                       (Date) reservedTo.getValue(), (String) description\r
-                               .getValue());\r
-               statusLabel.setCaption("Success!");\r
-               statusLabel\r
-                       .setValue("You have reserved the resource for the selected period.");\r
-           }\r
-       } catch (ResourceNotAvailableException e) {\r
-           statusLabel.setCaption("Reservation failed");\r
-           statusLabel\r
-                   .setValue("The selected resource was not available for the selected period.");\r
        }\r
-       refreshReservations();\r
-    }\r
-\r
-    private Item getActiveResource() throws ResourceNotAvailableException {\r
-       List rids = resourcePanel.getSelectedResources();\r
-       if (rids != null && rids.size() > 0) {\r
-           for (Iterator it = rids.iterator(); it.hasNext();) {\r
-               Item resource = (Item) it.next();\r
-               int id = ((Integer) resource.getItemProperty(\r
-                       SampleDB.Resource.PROPERTY_ID_ID).getValue())\r
-                       .intValue();\r
-               if (db.isAvailableResource(id, (Date) reservedFrom.getValue(),\r
-                       (Date) reservedTo.getValue()))\r
-                   return resource;\r
-           }\r
-           throw new ResourceNotAvailableException("No available resource");\r
-       } else {\r
-           return null;\r
+\r
+       private Item getActiveResource() throws ResourceNotAvailableException {\r
+               List rids = resourcePanel.getSelectedResources();\r
+               if (rids != null && rids.size() > 0) {\r
+                       for (Iterator it = rids.iterator(); it.hasNext();) {\r
+                               Item resource = (Item) it.next();\r
+                               int id = ((Integer) resource.getItemProperty(\r
+                                               SampleDB.Resource.PROPERTY_ID_ID).getValue())\r
+                                               .intValue();\r
+                               if (db.isAvailableResource(id, (Date) reservedFrom.getValue(),\r
+                                               (Date) reservedTo.getValue()))\r
+                                       return resource;\r
+                       }\r
+                       throw new ResourceNotAvailableException("No available resource");\r
+               } else {\r
+                       return null;\r
+               }\r
        }\r
-    }\r
-\r
-    private void refreshReservations() {\r
-       Container reservations = db.getReservations(resourcePanel\r
-               .getSelectedResources());\r
-       reservedFrom.setContainerDataSource(reservations);\r
-       reservedTo.setContainerDataSource(reservations);\r
-       refreshSelectedResources();\r
-       Container allReservations = db.getReservations(null);\r
-       allTable.setContainerDataSource(allReservations);\r
-       allCalendar.setContainerDataSource(allReservations);\r
-\r
-    }\r
-\r
-    private void refreshSelectedResources() {\r
-       Item resource = null;\r
-       try {\r
-           resource = getActiveResource();\r
-       } catch (ResourceNotAvailableException e) {\r
-           resourceName.setCaption("Not available");\r
-           resourceName.setValue("Please choose another time period or resource");\r
-           reservationButton.setEnabled(false);\r
-           return;\r
+\r
+       private void refreshReservations() {\r
+               Container reservations = db.getReservations(resourcePanel\r
+                               .getSelectedResources());\r
+               reservedFrom.setContainerDataSource(reservations);\r
+               reservedTo.setContainerDataSource(reservations);\r
+               refreshSelectedResources();\r
+               Container allReservations = db.getReservations(null);\r
+               allTable.setContainerDataSource(allReservations);\r
+               allCalendar.setContainerDataSource(allReservations);\r
+\r
        }\r
-       map.clear();\r
-       if (resource == null) {\r
-           resourceName.setCaption("Choose resource");\r
-           resourceName.setValue("from the list above");\r
-           reservationButton.setEnabled(false);\r
-           map.setContainerDataSource(db.getResources(null));\r
-           map.setZoomLevel(1);\r
-\r
-       } else {\r
-           LinkedList srs = resourcePanel.getSelectedResources();\r
-           for (Iterator it = srs.iterator(); it.hasNext();) {\r
-               resource = (Item)it.next();\r
-               String name = (String) resource.getItemProperty(\r
-                       SampleDB.Resource.PROPERTY_ID_NAME).getValue();\r
-               String desc = (String) resource.getItemProperty(\r
-                       SampleDB.Resource.PROPERTY_ID_DESCRIPTION).getValue();\r
-               resourceName.setCaption(name);\r
-               resourceName.setValue(desc);\r
-               Double x = (Double) resource.getItemProperty(\r
-                       SampleDB.Resource.PROPERTY_ID_LOCATIONX).getValue();\r
-               Double y = (Double) resource.getItemProperty(\r
-                       SampleDB.Resource.PROPERTY_ID_LOCATIONY).getValue();\r
-               if (x != null && y != null) {\r
-                   map.addMarker(name + "<br/>" + desc, new Point2D.Double(x\r
-                           .doubleValue(), y.doubleValue()));\r
-                   \r
+\r
+       private void refreshSelectedResources() {\r
+               Item resource = null;\r
+               try {\r
+                       resource = getActiveResource();\r
+               } catch (ResourceNotAvailableException e) {\r
+                       resourceName.setCaption("Not available");\r
+                       resourceName\r
+                                       .setValue("Please choose another time period or resource");\r
+                       reservationButton.setEnabled(false);\r
+                       return;\r
                }\r
-               \r
-           }\r
-           map.setZoomLevel((srs.size()==1?16:9));\r
-           reservationButton.setEnabled(true);\r
+               map.clear();\r
+               if (resource == null) {\r
+                       resourceName.setCaption("Choose resource");\r
+                       resourceName.setValue("from the list above");\r
+                       reservationButton.setEnabled(false);\r
+                       map.setContainerDataSource(db.getResources(null));\r
+                       map.setZoomLevel(1);\r
+\r
+               } else {\r
+                       LinkedList srs = resourcePanel.getSelectedResources();\r
+                       for (Iterator it = srs.iterator(); it.hasNext();) {\r
+                               resource = (Item) it.next();\r
+                               String name = (String) resource.getItemProperty(\r
+                                               SampleDB.Resource.PROPERTY_ID_NAME).getValue();\r
+                               String desc = (String) resource.getItemProperty(\r
+                                               SampleDB.Resource.PROPERTY_ID_DESCRIPTION).getValue();\r
+                               resourceName.setCaption(name);\r
+                               resourceName.setValue(desc);\r
+                               Double x = (Double) resource.getItemProperty(\r
+                                               SampleDB.Resource.PROPERTY_ID_LOCATIONX).getValue();\r
+                               Double y = (Double) resource.getItemProperty(\r
+                                               SampleDB.Resource.PROPERTY_ID_LOCATIONY).getValue();\r
+                               if (x != null && y != null) {\r
+                                       map.addMarker(name + "<br/>" + desc, new Point2D.Double(x\r
+                                                       .doubleValue(), y.doubleValue()));\r
+\r
+                               }\r
+\r
+                       }\r
+                       map.setZoomLevel((srs.size() == 1 ? 16 : 9));\r
+                       reservationButton.setEnabled(true);\r
+               }\r
+\r
        }\r
 \r
-    }\r
-\r
-    private void initCalendarFieldPropertyIds(CalendarField cal) {\r
-       cal\r
-               .setItemStartPropertyId(SampleDB.Reservation.PROPERTY_ID_RESERVED_FROM);\r
-       cal.setItemEndPropertyId(SampleDB.Reservation.PROPERTY_ID_RESERVED_TO);\r
-       cal.setItemTitlePropertyId(SampleDB.Resource.PROPERTY_ID_NAME);\r
-       cal\r
-               .setItemDescriptionPropertyId(SampleDB.Reservation.PROPERTY_ID_DESCRIPTION);\r
-    }\r
-\r
-    private void resetStatus() {\r
-       statusLabel.setCaption(null);\r
-       statusLabel.setValue(null);\r
-    }\r
-\r
-    public void selectedResourcesChanged(\r
-           ResourceSelectorPanel.SelectedResourcesChangedEvent event) {\r
-       refreshReservations();\r
-       resetStatus();\r
-    }\r
+       private void initCalendarFieldPropertyIds(CalendarField cal) {\r
+               cal\r
+                               .setItemStartPropertyId(SampleDB.Reservation.PROPERTY_ID_RESERVED_FROM);\r
+               cal.setItemEndPropertyId(SampleDB.Reservation.PROPERTY_ID_RESERVED_TO);\r
+               cal.setItemTitlePropertyId(SampleDB.Resource.PROPERTY_ID_NAME);\r
+               cal\r
+                               .setItemDescriptionPropertyId(SampleDB.Reservation.PROPERTY_ID_DESCRIPTION);\r
+       }\r
+\r
+       private void resetStatus() {\r
+               statusLabel.setCaption(null);\r
+               statusLabel.setValue(null);\r
+       }\r
+\r
+       public void selectedResourcesChanged(\r
+                       ResourceSelectorPanel.SelectedResourcesChangedEvent event) {\r
+               refreshReservations();\r
+               resetStatus();\r
+       }\r
 \r
 }\r
index af46e2f4d399da44394726c987baa593c42a01ef..39e5a8206032b4f463bb925e288f835f3f5cb18c 100644 (file)
@@ -2,6 +2,6 @@ package com.itmill.toolkit.demo.reservation;
 \r
 public class ResourceNotAvailableException extends Exception {\r
        public ResourceNotAvailableException(String message) {\r
-           super(message);\r
+               super(message);\r
        }\r
 }\r
index 744447d240fde561a335b97632b2113af698f178..8593336b4266693751b37cbe53bf95c8287ae30e 100644 (file)
@@ -13,104 +13,104 @@ import com.itmill.toolkit.ui.Panel;
 import com.itmill.toolkit.ui.Button.ClickEvent;\r
 \r
 public class ResourceSelectorPanel extends Panel implements\r
-       Button.ClickListener {\r
-    private HashMap categoryLayouts = new HashMap();\r
-    private HashMap categoryResources = new HashMap();\r
+               Button.ClickListener {\r
+       private HashMap categoryLayouts = new HashMap();\r
+       private HashMap categoryResources = new HashMap();\r
 \r
-    private Container allResources;\r
-    private LinkedList selectedResources = null;\r
+       private Container allResources;\r
+       private LinkedList selectedResources = null;\r
 \r
-    public ResourceSelectorPanel(String caption) {\r
-       super(caption, new OrderedLayout(OrderedLayout.ORIENTATION_HORIZONTAL));\r
-    }\r
+       public ResourceSelectorPanel(String caption) {\r
+               super(caption, new OrderedLayout(OrderedLayout.ORIENTATION_HORIZONTAL));\r
+       }\r
 \r
-    public void setResourceContainer(Container resources) {\r
-       this.removeAllComponents();\r
-       categoryLayouts.clear();\r
-       categoryResources.clear();\r
-       if (resources != null && resources.size() > 0) {\r
-           for (Iterator it = resources.getItemIds().iterator(); it.hasNext();) {\r
-               Item resource = (Item) resources.getItem(it.next());\r
-               Integer id = (Integer) resource.getItemProperty(\r
-                       SampleDB.Resource.PROPERTY_ID_ID).getValue();\r
-               String category = (String) resource.getItemProperty(\r
-                       SampleDB.Resource.PROPERTY_ID_CATEGORY).getValue();\r
-               String name = (String) resource.getItemProperty(\r
-                       SampleDB.Resource.PROPERTY_ID_NAME).getValue();\r
-               String description = (String) resource.getItemProperty(\r
-                       SampleDB.Resource.PROPERTY_ID_DESCRIPTION).getValue();\r
-               Button rButton = new Button(name, this);\r
-               rButton.setStyle("link");\r
-               rButton.setDescription(description);\r
-               rButton.setData(resource);\r
-               Layout resourceLayout = (Layout) categoryLayouts.get(category);\r
-               LinkedList resourceList = (LinkedList) categoryResources\r
-                       .get(category);\r
-               if (resourceLayout == null) {\r
-                   resourceLayout = new OrderedLayout();\r
-                   this.addComponent(resourceLayout);\r
-                   categoryLayouts.put(category, resourceLayout);\r
-                   resourceList = new LinkedList();\r
-                   categoryResources.put(category, resourceList);\r
-                   Button cButton = new Button(category + " (any)", this);\r
-                   cButton.setStyle("important-link");\r
-                   cButton.setData(category);\r
-                   resourceLayout.addComponent(cButton);\r
+       public void setResourceContainer(Container resources) {\r
+               this.removeAllComponents();\r
+               categoryLayouts.clear();\r
+               categoryResources.clear();\r
+               if (resources != null && resources.size() > 0) {\r
+                       for (Iterator it = resources.getItemIds().iterator(); it.hasNext();) {\r
+                               Item resource = (Item) resources.getItem(it.next());\r
+                               Integer id = (Integer) resource.getItemProperty(\r
+                                               SampleDB.Resource.PROPERTY_ID_ID).getValue();\r
+                               String category = (String) resource.getItemProperty(\r
+                                               SampleDB.Resource.PROPERTY_ID_CATEGORY).getValue();\r
+                               String name = (String) resource.getItemProperty(\r
+                                               SampleDB.Resource.PROPERTY_ID_NAME).getValue();\r
+                               String description = (String) resource.getItemProperty(\r
+                                               SampleDB.Resource.PROPERTY_ID_DESCRIPTION).getValue();\r
+                               Button rButton = new Button(name, this);\r
+                               rButton.setStyle("link");\r
+                               rButton.setDescription(description);\r
+                               rButton.setData(resource);\r
+                               Layout resourceLayout = (Layout) categoryLayouts.get(category);\r
+                               LinkedList resourceList = (LinkedList) categoryResources\r
+                                               .get(category);\r
+                               if (resourceLayout == null) {\r
+                                       resourceLayout = new OrderedLayout();\r
+                                       this.addComponent(resourceLayout);\r
+                                       categoryLayouts.put(category, resourceLayout);\r
+                                       resourceList = new LinkedList();\r
+                                       categoryResources.put(category, resourceList);\r
+                                       Button cButton = new Button(category + " (any)", this);\r
+                                       cButton.setStyle("important-link");\r
+                                       cButton.setData(category);\r
+                                       resourceLayout.addComponent(cButton);\r
+                               }\r
+                               resourceLayout.addComponent(rButton);\r
+                               resourceList.add(resource);\r
+                       }\r
                }\r
-               resourceLayout.addComponent(rButton);\r
-               resourceList.add(resource);\r
-           }\r
        }\r
-    }\r
 \r
-    private void setSelectedResources(LinkedList resources) {\r
-       selectedResources = resources;\r
-       fireEvent(new SelectedResourcesChangedEvent());\r
-    }\r
+       private void setSelectedResources(LinkedList resources) {\r
+               selectedResources = resources;\r
+               fireEvent(new SelectedResourcesChangedEvent());\r
+       }\r
 \r
-    public LinkedList getSelectedResources() {\r
-       return selectedResources;\r
-    }\r
+       public LinkedList getSelectedResources() {\r
+               return selectedResources;\r
+       }\r
+\r
+       public void buttonClick(ClickEvent event) {\r
+               Object source = event.getSource();\r
+               if (source instanceof Button) {\r
+                       Object data = ((Button) source).getData();\r
+                       String name = ((Button) source).getCaption();\r
+                       resetStyles();\r
+                       if (data instanceof Item) {\r
+                               LinkedList rlist = new LinkedList();\r
+                               rlist.add(data);\r
+                               setSelectedResources(rlist);\r
+                       } else {\r
+                               String category = (String) data;\r
+                               LinkedList resources = (LinkedList) categoryResources\r
+                                               .get(category);\r
+                               setSelectedResources(resources);\r
+                       }\r
+                       ((Button) source).setStyle("selected-link");\r
+               }\r
 \r
-    public void buttonClick(ClickEvent event) {\r
-       Object source = event.getSource();\r
-       if (source instanceof Button) {\r
-           Object data = ((Button) source).getData();\r
-           String name = ((Button) source).getCaption();\r
-           resetStyles();\r
-           if (data instanceof Item) {\r
-               LinkedList rlist = new LinkedList();\r
-               rlist.add(data);\r
-               setSelectedResources(rlist);\r
-           } else {\r
-               String category = (String) data;\r
-               LinkedList resources = (LinkedList) categoryResources\r
-                       .get(category);\r
-               setSelectedResources(resources);\r
-           }\r
-           ((Button)source).setStyle("selected-link");\r
        }\r
 \r
-    }\r
-    \r
-    private void resetStyles() {\r
-       for (Iterator it = categoryLayouts.values().iterator();it.hasNext();) {\r
-           Layout lo = (Layout)it.next();\r
-           for (Iterator bit = lo.getComponentIterator();bit.hasNext();) {\r
-               Button b = (Button)bit.next();\r
-               if (b.getData() instanceof Item) {\r
-                   b.setStyle("link");\r
-               } else {\r
-                   b.setStyle("important-link");\r
+       private void resetStyles() {\r
+               for (Iterator it = categoryLayouts.values().iterator(); it.hasNext();) {\r
+                       Layout lo = (Layout) it.next();\r
+                       for (Iterator bit = lo.getComponentIterator(); bit.hasNext();) {\r
+                               Button b = (Button) bit.next();\r
+                               if (b.getData() instanceof Item) {\r
+                                       b.setStyle("link");\r
+                               } else {\r
+                                       b.setStyle("important-link");\r
+                               }\r
+                       }\r
                }\r
-           }\r
+\r
        }\r
-       \r
-    }\r
 \r
-    public class SelectedResourcesChangedEvent extends Event {\r
-       public SelectedResourcesChangedEvent() {\r
-           super(ResourceSelectorPanel.this);\r
+       public class SelectedResourcesChangedEvent extends Event {\r
+               public SelectedResourcesChangedEvent() {\r
+                       super(ResourceSelectorPanel.this);\r
+               }\r
        }\r
-    }\r
 }\r
index ea8a752a7a6a37938a737bda0c20ca7a975f4d11..ca9c648b22b6f4412d0687c3bfc019595a5239ff 100644 (file)
@@ -15,464 +15,499 @@ import com.itmill.toolkit.data.Item;
 import com.itmill.toolkit.data.util.QueryContainer;
 
 public class SampleDB {
-    public class User {
-       public static final String TABLE = "USER";
-       public static final String PROPERTY_ID_ID = TABLE + "_ID";
-       public static final String PROPERTY_ID_FULLNAME = TABLE + "_FULLNAME";
-       public static final String PROPERTY_ID_EMAIL = TABLE + "_EMAIL";
-       public static final String PROPERTY_ID_PASSWORD = TABLE + "_PASSWORD";
-       public static final String PROPERTY_ID_DELETED = TABLE + "_DELETED";
-    }
-
-    public class Resource {
-       public static final String TABLE = "RESOURCE";
-       public static final String PROPERTY_ID_ID = TABLE + "_ID";
-       public static final String PROPERTY_ID_NAME = TABLE + "_NAME";
-       public static final String PROPERTY_ID_DESCRIPTION = TABLE
-               + "_DESCRIPTION";
-       public static final String PROPERTY_ID_LOCATIONX = TABLE
-               + "_LOCATION_X";
-       public static final String PROPERTY_ID_LOCATIONY = TABLE
-               + "_LOCATION_Y";
-       public static final String PROPERTY_ID_CATEGORY = TABLE + "_CATEGORY";
-       public static final String PROPERTY_ID_DELETED = TABLE + "_DELETED";
-    }
-
-    public class Reservation {
-       public static final String TABLE = "RESERVATION";
-       public static final String PROPERTY_ID_ID = TABLE + "_ID";
-       public static final String PROPERTY_ID_DESCRIPTION = TABLE
-               + "_DESCRIPTION";
-       public static final String PROPERTY_ID_RESOURCE_ID = TABLE
-               + "_RESOURCE_ID";
-       public static final String PROPERTY_ID_RESERVED_BY_ID = TABLE
-               + "_RESERVED_BY_USER_ID";
-       public static final String PROPERTY_ID_RESERVED_FROM = TABLE
-               + "_RESERVED_FROM";
-       public static final String PROPERTY_ID_RESERVED_TO = TABLE
-               + "_RESERVED_TO";
-    }
-
-    // TODO -> param
-    private static final String DB_URL = "jdbc:hsqldb:file:reservation.db";
-
-    private static final String CREATE_TABLE_USER = "CREATE TABLE "
-           + User.TABLE + " (" + " " + User.PROPERTY_ID_ID
-           + " INTEGER IDENTITY" + ", " + User.PROPERTY_ID_FULLNAME
-           + " VARCHAR(100) NOT NULL" + ", " + User.PROPERTY_ID_EMAIL
-           + " VARCHAR(50) NOT NULL" + ", " + User.PROPERTY_ID_PASSWORD
-           + " VARCHAR(20) NOT NULL" + ", " + User.PROPERTY_ID_DELETED
-           + " BOOLEAN DEFAULT false NOT NULL" + ", UNIQUE("
-           + User.PROPERTY_ID_FULLNAME + "), UNIQUE(" + User.PROPERTY_ID_EMAIL
-           + ") )";
-    private static final String CREATE_TABLE_RESOURCE = "CREATE TABLE "
-           + Resource.TABLE + " (" + " " + Resource.PROPERTY_ID_ID
-           + " INTEGER IDENTITY" + ", " + Resource.PROPERTY_ID_NAME
-           + " VARCHAR(30) NOT NULL" + ", " + Resource.PROPERTY_ID_DESCRIPTION
-           + " VARCHAR(100)" + ", " + Resource.PROPERTY_ID_LOCATIONX
-           + " DOUBLE" + ", " + Resource.PROPERTY_ID_LOCATIONY + " DOUBLE"
-           + ", " + Resource.PROPERTY_ID_CATEGORY + " VARCHAR(30)" + ", "
-           + Resource.PROPERTY_ID_DELETED + " BOOLEAN DEFAULT false NOT NULL"
-           + ", UNIQUE(" + Resource.PROPERTY_ID_NAME + "))";
-    private static final String CREATE_TABLE_RESERVATION = "CREATE TABLE "
-           + Reservation.TABLE + " (" + " " + Reservation.PROPERTY_ID_ID
-           + " INTEGER IDENTITY" + ", " + Reservation.PROPERTY_ID_RESOURCE_ID
-           + " INTEGER" + ", " + Reservation.PROPERTY_ID_RESERVED_BY_ID
-           + " INTEGER" + ", " + Reservation.PROPERTY_ID_RESERVED_FROM
-           + " TIMESTAMP NOT NULL" + ", "
-           + Reservation.PROPERTY_ID_RESERVED_TO + " TIMESTAMP NOT NULL"
-           + ", " + Reservation.PROPERTY_ID_DESCRIPTION + " VARCHAR(100)"
-           + ", FOREIGN KEY (" + Reservation.PROPERTY_ID_RESOURCE_ID
-           + ") REFERENCES " + Resource.TABLE + "(" + Resource.PROPERTY_ID_ID
-           + "), FOREIGN KEY (" + Reservation.PROPERTY_ID_RESERVED_BY_ID
-           + ") REFERENCES " + User.TABLE + "(" + User.PROPERTY_ID_ID + "))";
-
-    private Connection connection = null;
-
-    /**
-     * Create database.
-     */
-    public SampleDB() {
-       this(false);
-    }
-
-    public SampleDB(boolean recreate) {
-       // connect to SQL database
-       connect();
-
-       if (recreate) {
-           dropTables();
+       public class User {
+               public static final String TABLE = "USER";
+               public static final String PROPERTY_ID_ID = TABLE + "_ID";
+               public static final String PROPERTY_ID_FULLNAME = TABLE + "_FULLNAME";
+               public static final String PROPERTY_ID_EMAIL = TABLE + "_EMAIL";
+               public static final String PROPERTY_ID_PASSWORD = TABLE + "_PASSWORD";
+               public static final String PROPERTY_ID_DELETED = TABLE + "_DELETED";
        }
 
-       // initialize SQL database
-       createTables();
-
-       // test by executing sample JDBC query
-       testDatabase();
-    }
-
-    private void dropTables() {
-       try {
-           update("DROP TABLE " + Reservation.TABLE);
-       } catch (SQLException IGNORED) {
-           // IGNORED, assuming it was not there
+       public class Resource {
+               public static final String TABLE = "RESOURCE";
+               public static final String PROPERTY_ID_ID = TABLE + "_ID";
+               public static final String PROPERTY_ID_NAME = TABLE + "_NAME";
+               public static final String PROPERTY_ID_DESCRIPTION = TABLE
+                               + "_DESCRIPTION";
+               public static final String PROPERTY_ID_LOCATIONX = TABLE
+                               + "_LOCATION_X";
+               public static final String PROPERTY_ID_LOCATIONY = TABLE
+                               + "_LOCATION_Y";
+               public static final String PROPERTY_ID_CATEGORY = TABLE + "_CATEGORY";
+               public static final String PROPERTY_ID_DELETED = TABLE + "_DELETED";
        }
-       try {
-           update("DROP TABLE " + Resource.TABLE);
-       } catch (SQLException IGNORED) {
-           // IGNORED, assuming it was not there
+
+       public class Reservation {
+               public static final String TABLE = "RESERVATION";
+               public static final String PROPERTY_ID_ID = TABLE + "_ID";
+               public static final String PROPERTY_ID_DESCRIPTION = TABLE
+                               + "_DESCRIPTION";
+               public static final String PROPERTY_ID_RESOURCE_ID = TABLE
+                               + "_RESOURCE_ID";
+               public static final String PROPERTY_ID_RESERVED_BY_ID = TABLE
+                               + "_RESERVED_BY_USER_ID";
+               public static final String PROPERTY_ID_RESERVED_FROM = TABLE
+                               + "_RESERVED_FROM";
+               public static final String PROPERTY_ID_RESERVED_TO = TABLE
+                               + "_RESERVED_TO";
        }
-       try {
-           update("DROP TABLE " + User.TABLE);
-       } catch (SQLException IGNORED) {
-           // IGNORED, assuming it was not there
+
+       // TODO -> param
+       private static final String DB_URL = "jdbc:hsqldb:file:reservation.db";
+
+       private static final String CREATE_TABLE_USER = "CREATE TABLE "
+                       + User.TABLE + " (" + " " + User.PROPERTY_ID_ID
+                       + " INTEGER IDENTITY" + ", " + User.PROPERTY_ID_FULLNAME
+                       + " VARCHAR(100) NOT NULL" + ", " + User.PROPERTY_ID_EMAIL
+                       + " VARCHAR(50) NOT NULL" + ", " + User.PROPERTY_ID_PASSWORD
+                       + " VARCHAR(20) NOT NULL" + ", " + User.PROPERTY_ID_DELETED
+                       + " BOOLEAN DEFAULT false NOT NULL" + ", UNIQUE("
+                       + User.PROPERTY_ID_FULLNAME + "), UNIQUE(" + User.PROPERTY_ID_EMAIL
+                       + ") )";
+       private static final String CREATE_TABLE_RESOURCE = "CREATE TABLE "
+                       + Resource.TABLE + " (" + " " + Resource.PROPERTY_ID_ID
+                       + " INTEGER IDENTITY" + ", " + Resource.PROPERTY_ID_NAME
+                       + " VARCHAR(30) NOT NULL" + ", " + Resource.PROPERTY_ID_DESCRIPTION
+                       + " VARCHAR(100)" + ", " + Resource.PROPERTY_ID_LOCATIONX
+                       + " DOUBLE" + ", " + Resource.PROPERTY_ID_LOCATIONY + " DOUBLE"
+                       + ", " + Resource.PROPERTY_ID_CATEGORY + " VARCHAR(30)" + ", "
+                       + Resource.PROPERTY_ID_DELETED + " BOOLEAN DEFAULT false NOT NULL"
+                       + ", UNIQUE(" + Resource.PROPERTY_ID_NAME + "))";
+       private static final String CREATE_TABLE_RESERVATION = "CREATE TABLE "
+                       + Reservation.TABLE + " (" + " " + Reservation.PROPERTY_ID_ID
+                       + " INTEGER IDENTITY" + ", " + Reservation.PROPERTY_ID_RESOURCE_ID
+                       + " INTEGER" + ", " + Reservation.PROPERTY_ID_RESERVED_BY_ID
+                       + " INTEGER" + ", " + Reservation.PROPERTY_ID_RESERVED_FROM
+                       + " TIMESTAMP NOT NULL" + ", "
+                       + Reservation.PROPERTY_ID_RESERVED_TO + " TIMESTAMP NOT NULL"
+                       + ", " + Reservation.PROPERTY_ID_DESCRIPTION + " VARCHAR(100)"
+                       + ", FOREIGN KEY (" + Reservation.PROPERTY_ID_RESOURCE_ID
+                       + ") REFERENCES " + Resource.TABLE + "(" + Resource.PROPERTY_ID_ID
+                       + "), FOREIGN KEY (" + Reservation.PROPERTY_ID_RESERVED_BY_ID
+                       + ") REFERENCES " + User.TABLE + "(" + User.PROPERTY_ID_ID + "))";
+
+       private Connection connection = null;
+
+       /**
+        * Create database.
+        */
+       public SampleDB() {
+               this(false);
        }
-    }
-
-    /**
-     * Connect to SQL database. In this sample we use HSQLDB and an toolkit
-     * named database in implicitly created into system memory.
-     * 
-     */
-    private void connect() {
-       try {
-           Class.forName("org.hsqldb.jdbcDriver").newInstance();
-           connection = DriverManager.getConnection(DB_URL);
-       } catch (Exception e) {
-           throw new RuntimeException(e);
+
+       public SampleDB(boolean recreate) {
+               // connect to SQL database
+               connect();
+
+               if (recreate) {
+                       dropTables();
+               }
+
+               // initialize SQL database
+               createTables();
+
+               // test by executing sample JDBC query
+               testDatabase();
        }
-    }
-
-    /**
-     * use for SQL commands CREATE, DROP, INSERT and UPDATE
-     * 
-     * @param expression
-     * @throws SQLException
-     */
-    private void update(String expression) throws SQLException {
-       Statement st = null;
-       st = connection.createStatement();
-       int i = st.executeUpdate(expression);
-       if (i == -1) {
-           System.out.println("SampleDatabase error : " + expression);
+
+       private void dropTables() {
+               try {
+                       update("DROP TABLE " + Reservation.TABLE);
+               } catch (SQLException IGNORED) {
+                       // IGNORED, assuming it was not there
+               }
+               try {
+                       update("DROP TABLE " + Resource.TABLE);
+               } catch (SQLException IGNORED) {
+                       // IGNORED, assuming it was not there
+               }
+               try {
+                       update("DROP TABLE " + User.TABLE);
+               } catch (SQLException IGNORED) {
+                       // IGNORED, assuming it was not there
+               }
        }
-       st.close();
-    }
-
-    /**
-     * Create test table and few rows. Issue note: using capitalized column
-     * names as HSQLDB returns column names in capitalized form with this demo.
-     * 
-     */
-    private void createTables() {
-       try {
-           String stmt = null;
-           stmt = CREATE_TABLE_RESOURCE;
-           update(stmt);
-       } catch (SQLException e) {
-           if (e.toString().indexOf("Table already exists") == -1)
-               throw new RuntimeException(e);
+
+       /**
+        * Connect to SQL database. In this sample we use HSQLDB and an toolkit
+        * named database in implicitly created into system memory.
+        * 
+        */
+       private void connect() {
+               try {
+                       Class.forName("org.hsqldb.jdbcDriver").newInstance();
+                       connection = DriverManager.getConnection(DB_URL);
+               } catch (Exception e) {
+                       throw new RuntimeException(e);
+               }
        }
-       try {
-           String stmt = null;
-           stmt = CREATE_TABLE_USER;
-           update(stmt);
-       } catch (SQLException e) {
-           if (e.toString().indexOf("Table already exists") == -1)
-               throw new RuntimeException(e);
+
+       /**
+        * use for SQL commands CREATE, DROP, INSERT and UPDATE
+        * 
+        * @param expression
+        * @throws SQLException
+        */
+       private void update(String expression) throws SQLException {
+               Statement st = null;
+               st = connection.createStatement();
+               int i = st.executeUpdate(expression);
+               if (i == -1) {
+                       System.out.println("SampleDatabase error : " + expression);
+               }
+               st.close();
        }
-       try {
-           String stmt = null;
-           stmt = CREATE_TABLE_RESERVATION;
-           update(stmt);
-       } catch (SQLException e) {
-           if (e.toString().indexOf("Table already exists") == -1)
-               throw new RuntimeException(e);
+
+       /**
+        * Create test table and few rows. Issue note: using capitalized column
+        * names as HSQLDB returns column names in capitalized form with this demo.
+        * 
+        */
+       private void createTables() {
+               try {
+                       String stmt = null;
+                       stmt = CREATE_TABLE_RESOURCE;
+                       update(stmt);
+               } catch (SQLException e) {
+                       if (e.toString().indexOf("Table already exists") == -1)
+                               throw new RuntimeException(e);
+               }
+               try {
+                       String stmt = null;
+                       stmt = CREATE_TABLE_USER;
+                       update(stmt);
+               } catch (SQLException e) {
+                       if (e.toString().indexOf("Table already exists") == -1)
+                               throw new RuntimeException(e);
+               }
+               try {
+                       String stmt = null;
+                       stmt = CREATE_TABLE_RESERVATION;
+                       update(stmt);
+               } catch (SQLException e) {
+                       if (e.toString().indexOf("Table already exists") == -1)
+                               throw new RuntimeException(e);
+               }
        }
-    }
-
-    /**
-     * Test database connection with simple SELECT command.
-     * 
-     */
-    private String testDatabase() {
-       String result = null;
-       try {
-           Statement stmt = connection.createStatement(
-                   ResultSet.TYPE_SCROLL_INSENSITIVE,
-                   ResultSet.CONCUR_UPDATABLE);
-           ResultSet rs = stmt.executeQuery("SELECT COUNT(*) FROM "
-                   + Resource.TABLE);
-           rs.next();
-           result = "rowcount for table test is " + rs.getObject(1).toString();
-           stmt.close();
-       } catch (SQLException e) {
-           throw new RuntimeException(e);
+
+       /**
+        * Test database connection with simple SELECT command.
+        * 
+        */
+       private String testDatabase() {
+               String result = null;
+               try {
+                       Statement stmt = connection.createStatement(
+                                       ResultSet.TYPE_SCROLL_INSENSITIVE,
+                                       ResultSet.CONCUR_UPDATABLE);
+                       ResultSet rs = stmt.executeQuery("SELECT COUNT(*) FROM "
+                                       + Resource.TABLE);
+                       rs.next();
+                       result = "rowcount for table test is " + rs.getObject(1).toString();
+                       stmt.close();
+               } catch (SQLException e) {
+                       throw new RuntimeException(e);
+               }
+               return result;
        }
-       return result;
-    }
-
-    public Connection getConnection() {
-       return connection;
-    }
-
-    public Container getCategories() {
-       // TODO where deleted=?
-       String q = "SELECT DISTINCT(" + Resource.PROPERTY_ID_CATEGORY
-               + ") FROM " + Resource.TABLE + " ORDER BY "
-               + Resource.PROPERTY_ID_CATEGORY;
-       try {
-           return new QueryContainer(q, connection,
-                   ResultSet.TYPE_SCROLL_INSENSITIVE,
-                   ResultSet.CONCUR_READ_ONLY);
-       } catch (SQLException e) {
-           throw new RuntimeException(e);
+
+       public Connection getConnection() {
+               return connection;
        }
 
-    }
+       public Container getCategories() {
+               // TODO where deleted=?
+               String q = "SELECT DISTINCT(" + Resource.PROPERTY_ID_CATEGORY
+                               + ") FROM " + Resource.TABLE + " ORDER BY "
+                               + Resource.PROPERTY_ID_CATEGORY;
+               try {
+                       return new QueryContainer(q, connection,
+                                       ResultSet.TYPE_SCROLL_INSENSITIVE,
+                                       ResultSet.CONCUR_READ_ONLY);
+               } catch (SQLException e) {
+                       throw new RuntimeException(e);
+               }
 
-    public Container getResources(String category) {
-       // TODO where deleted=?
-       String q = "SELECT * FROM " + Resource.TABLE;
-       if (category != null) {
-           q += " WHERE " + Resource.PROPERTY_ID_CATEGORY + "='" + category
-                   + "'"; // FIXME ->
-           // PreparedStatement!
        }
 
-       try {
-           return new QueryContainer(q, connection,
-                   ResultSet.TYPE_SCROLL_INSENSITIVE,
-                   ResultSet.CONCUR_READ_ONLY);
-       } catch (SQLException e) {
-           throw new RuntimeException(e);
-       }
+       public Container getResources(String category) {
+               // TODO where deleted=?
+               String q = "SELECT * FROM " + Resource.TABLE;
+               if (category != null) {
+                       q += " WHERE " + Resource.PROPERTY_ID_CATEGORY + "='" + category
+                                       + "'"; // FIXME ->
+                       // PreparedStatement!
+               }
 
-    }
-
-    public Container getReservations(List resources) {
-       // TODO where reserved_by=?
-       // TODO where from=?
-       // TODO where to=?
-       // TODO where deleted=?
-       String q = "SELECT * FROM " + Reservation.TABLE + "," + Resource.TABLE;
-       q += " WHERE " + Reservation.PROPERTY_ID_RESOURCE_ID + "="
-               + Resource.PROPERTY_ID_ID;
-       if (resources != null && resources.size() > 0) {
-           StringBuilder s = new StringBuilder();
-           for (Iterator it = resources.iterator(); it.hasNext();) {
-               if (s.length() > 0) {
-                   s.append(",");
+               try {
+                       return new QueryContainer(q, connection,
+                                       ResultSet.TYPE_SCROLL_INSENSITIVE,
+                                       ResultSet.CONCUR_READ_ONLY);
+               } catch (SQLException e) {
+                       throw new RuntimeException(e);
                }
-               s.append(((Item) it.next())
-                       .getItemProperty(Resource.PROPERTY_ID_ID));
-           }
-           q += " HAVING " + Reservation.PROPERTY_ID_RESOURCE_ID + " IN (" + s
-                   + ")";
-       }
-       q += " ORDER BY " + Reservation.PROPERTY_ID_RESERVED_FROM;
-       try {
-           QueryContainer qc = new QueryContainer(q, connection,
-                   ResultSet.TYPE_SCROLL_INSENSITIVE,
-                   ResultSet.CONCUR_READ_ONLY);
-           if (qc.size() < 1) {
-               return null;
-           } else {
-               return qc;
-           }
-       } catch (SQLException e) {
-           throw new RuntimeException(e);
-       }
-    }
-
-    public void addReservation(Item resource, int reservedById,
-           Date reservedFrom, Date reservedTo, String description) {
-       if (reservedFrom.after(reservedTo)) {
-           Date tmp = reservedTo;
-           reservedTo = reservedFrom;
-           reservedFrom = tmp;
+
        }
-       int resourceId = ((Integer) resource.getItemProperty(
-               Resource.PROPERTY_ID_ID).getValue()).intValue();
-       String q = "INSERT INTO " + Reservation.TABLE + " ("
-               + Reservation.PROPERTY_ID_RESOURCE_ID + ","
-               + Reservation.PROPERTY_ID_RESERVED_BY_ID + ","
-               + Reservation.PROPERTY_ID_RESERVED_FROM + ","
-               + Reservation.PROPERTY_ID_RESERVED_TO + ","
-               + Reservation.PROPERTY_ID_DESCRIPTION + ")"
-               + "VALUES (?,?,?,?,?)";
-       synchronized (DB_URL) {
-           try {
-               if (!isAvailableResource(resourceId, reservedFrom, reservedTo)) {
-                   throw new ResourceNotAvailableException(
-                           "The resource is not available at that time.");
+
+       public Container getReservations(List resources) {
+               // TODO where reserved_by=?
+               // TODO where from=?
+               // TODO where to=?
+               // TODO where deleted=?
+               String q = "SELECT * FROM " + Reservation.TABLE + "," + Resource.TABLE;
+               q += " WHERE " + Reservation.PROPERTY_ID_RESOURCE_ID + "="
+                               + Resource.PROPERTY_ID_ID;
+               if (resources != null && resources.size() > 0) {
+                       StringBuilder s = new StringBuilder();
+                       for (Iterator it = resources.iterator(); it.hasNext();) {
+                               if (s.length() > 0) {
+                                       s.append(",");
+                               }
+                               s.append(((Item) it.next())
+                                               .getItemProperty(Resource.PROPERTY_ID_ID));
+                       }
+                       q += " HAVING " + Reservation.PROPERTY_ID_RESOURCE_ID + " IN (" + s
+                                       + ")";
+               }
+               q += " ORDER BY " + Reservation.PROPERTY_ID_RESERVED_FROM;
+               try {
+                       QueryContainer qc = new QueryContainer(q, connection,
+                                       ResultSet.TYPE_SCROLL_INSENSITIVE,
+                                       ResultSet.CONCUR_READ_ONLY);
+                       if (qc.size() < 1) {
+                               return null;
+                       } else {
+                               return qc;
+                       }
+               } catch (SQLException e) {
+                       throw new RuntimeException(e);
                }
-               PreparedStatement p = connection.prepareStatement(q);
-               p.setInt(1, resourceId);
-               p.setInt(2, reservedById);
-               p.setTimestamp(3,
-                       new java.sql.Timestamp(reservedFrom.getTime()));
-               p.setTimestamp(4, new java.sql.Timestamp(reservedTo.getTime()));
-               p.setString(5, description);
-               p.execute();
-           } catch (Exception e) {
-               throw new RuntimeException(e);
-           }
-       }
-    }
-
-    public boolean isAvailableResource(int resourceId, Date reservedFrom,
-           Date reservedTo) {
-       // TODO where deleted=?
-       if (reservedFrom.after(reservedTo)) {
-           Date tmp = reservedTo;
-           reservedTo = reservedFrom;
-           reservedFrom = tmp;
        }
-       String checkQ = "SELECT count(*) FROM " + Reservation.TABLE + " WHERE "
-               + Reservation.PROPERTY_ID_RESOURCE_ID + "=? AND (("
-               + Reservation.PROPERTY_ID_RESERVED_FROM + ">=? AND "
-               + Reservation.PROPERTY_ID_RESERVED_FROM + "<=?) OR ("
-               + Reservation.PROPERTY_ID_RESERVED_TO + ">=? AND "
-               + Reservation.PROPERTY_ID_RESERVED_TO + "<=?) OR ("
-               + Reservation.PROPERTY_ID_RESERVED_FROM + "<=? AND "
-               + Reservation.PROPERTY_ID_RESERVED_TO + ">=?)" + ")";
-       try {
-           PreparedStatement p = connection.prepareStatement(checkQ);
-           p.setInt(1, resourceId);
-           p.setTimestamp(2, new java.sql.Timestamp(reservedFrom.getTime()));
-           p.setTimestamp(3, new java.sql.Timestamp(reservedTo.getTime()));
-           p.setTimestamp(4, new java.sql.Timestamp(reservedFrom.getTime()));
-           p.setTimestamp(5, new java.sql.Timestamp(reservedTo.getTime()));
-           p.setTimestamp(6, new java.sql.Timestamp(reservedFrom.getTime()));
-           p.setTimestamp(7, new java.sql.Timestamp(reservedTo.getTime()));
-           p.execute();
-           ResultSet rs = p.getResultSet();
-           if (rs.next() && rs.getInt(1) > 0) {
-               return false;
-           }
-       } catch (Exception e) {
-           throw new RuntimeException(e);
+
+       public void addReservation(Item resource, int reservedById,
+                       Date reservedFrom, Date reservedTo, String description) {
+               if (reservedFrom.after(reservedTo)) {
+                       Date tmp = reservedTo;
+                       reservedTo = reservedFrom;
+                       reservedFrom = tmp;
+               }
+               int resourceId = ((Integer) resource.getItemProperty(
+                               Resource.PROPERTY_ID_ID).getValue()).intValue();
+               String q = "INSERT INTO " + Reservation.TABLE + " ("
+                               + Reservation.PROPERTY_ID_RESOURCE_ID + ","
+                               + Reservation.PROPERTY_ID_RESERVED_BY_ID + ","
+                               + Reservation.PROPERTY_ID_RESERVED_FROM + ","
+                               + Reservation.PROPERTY_ID_RESERVED_TO + ","
+                               + Reservation.PROPERTY_ID_DESCRIPTION + ")"
+                               + "VALUES (?,?,?,?,?)";
+               synchronized (DB_URL) {
+                       try {
+                               if (!isAvailableResource(resourceId, reservedFrom, reservedTo)) {
+                                       throw new ResourceNotAvailableException(
+                                                       "The resource is not available at that time.");
+                               }
+                               PreparedStatement p = connection.prepareStatement(q);
+                               p.setInt(1, resourceId);
+                               p.setInt(2, reservedById);
+                               p.setTimestamp(3,
+                                               new java.sql.Timestamp(reservedFrom.getTime()));
+                               p.setTimestamp(4, new java.sql.Timestamp(reservedTo.getTime()));
+                               p.setString(5, description);
+                               p.execute();
+                       } catch (Exception e) {
+                               throw new RuntimeException(e);
+                       }
+               }
        }
-       return true;
-    }
-
-    public Container getUsers() {
-       // TODO where deleted=?
-       String q = "SELECT * FROM " + User.TABLE + " ORDER BY "
-               + User.PROPERTY_ID_FULLNAME;
-       try {
-           QueryContainer qc = new QueryContainer(q, connection,
-                   ResultSet.TYPE_SCROLL_INSENSITIVE,
-                   ResultSet.CONCUR_READ_ONLY);
-           return qc;
-       } catch (SQLException e) {
-           throw new RuntimeException(e);
+
+       public boolean isAvailableResource(int resourceId, Date reservedFrom,
+                       Date reservedTo) {
+               // TODO where deleted=?
+               if (reservedFrom.after(reservedTo)) {
+                       Date tmp = reservedTo;
+                       reservedTo = reservedFrom;
+                       reservedFrom = tmp;
+               }
+               String checkQ = "SELECT count(*) FROM " + Reservation.TABLE + " WHERE "
+                               + Reservation.PROPERTY_ID_RESOURCE_ID + "=? AND (("
+                               + Reservation.PROPERTY_ID_RESERVED_FROM + ">=? AND "
+                               + Reservation.PROPERTY_ID_RESERVED_FROM + "<=?) OR ("
+                               + Reservation.PROPERTY_ID_RESERVED_TO + ">=? AND "
+                               + Reservation.PROPERTY_ID_RESERVED_TO + "<=?) OR ("
+                               + Reservation.PROPERTY_ID_RESERVED_FROM + "<=? AND "
+                               + Reservation.PROPERTY_ID_RESERVED_TO + ">=?)" + ")";
+               try {
+                       PreparedStatement p = connection.prepareStatement(checkQ);
+                       p.setInt(1, resourceId);
+                       p.setTimestamp(2, new java.sql.Timestamp(reservedFrom.getTime()));
+                       p.setTimestamp(3, new java.sql.Timestamp(reservedTo.getTime()));
+                       p.setTimestamp(4, new java.sql.Timestamp(reservedFrom.getTime()));
+                       p.setTimestamp(5, new java.sql.Timestamp(reservedTo.getTime()));
+                       p.setTimestamp(6, new java.sql.Timestamp(reservedFrom.getTime()));
+                       p.setTimestamp(7, new java.sql.Timestamp(reservedTo.getTime()));
+                       p.execute();
+                       ResultSet rs = p.getResultSet();
+                       if (rs.next() && rs.getInt(1) > 0) {
+                               return false;
+                       }
+               } catch (Exception e) {
+                       throw new RuntimeException(e);
+               }
+               return true;
        }
-    }
-
-    public void generateResources() {
-       /*
-        * map.addMarker("Old Mill", new Point.Double(60.452224f,22.299929f));
-        * map.addMarker("ICT", new Point.Double(60.449007f,22.295508f));
-        * map.addMarker("DataCity", new Point.Double(60.448329f,22.295165f));
-        * map.addMarker("BioCity", new Point.Double(60.449451f,22.293105f));
-        * map.addMarker("PharmaCity", new Point.Double(60.44888f,22.292032f));
-        * map.addMarker("Intelligate", new Point.Double(60.450403f,22.29495f));
-        * map.addMarker("Paviljonki", new Point.Double(60.445408f,22.290831f));
-        * map.addMarker("Trivium", new Point.Double(60.44641962165445f,
-        * 22.301753170493f)); map.addMarker("Linja-auto asema", new
-        * Point.Double(60.457049f,22.267957f));
-        */
-       /*
-       Object[][] resources = {
-               { "IT Mill Toolkit Manual", "the manual", "Books", new Double(60.452224),new Double(22.299929)},
-               { "IT Mill Toolkit for Dummies", "the hardcover version",
-                       "Books", new Double(60.452224),new Double(22.299929) },
-               { "Sony", "Old Sony video projector", "AV equipment", new Double(60.449007),new Double(22.295508) },
-               { "Sanyo", "Brand new hd-ready video projector", "AV equipment", new Double(60.452224),new Double(22.299929) },
-               { "Room 7", "Conference room in the lobby", "Conference rooms", new Double(60.449451),new Double(22.292032) },
-               { "Nintendo Wii", "Teh uber fun", "Entertainment", new Double(60.445408),new Double(22.290831) },
-               { "Playstation", "We don't actually have one", "Entertainment", new Double(60.44641962165445),new Double(22.301753170493) },
-               { "Luokkahuone", "Classroom right next to IT Mill",
-                       "Conference rooms", new Double(60.44888),new Double(22.292032) }
-       };
-       */
-       Object[][] resources = {
-               // Turku
-               { "01 Ford Mondeo", "w/ company logo", "Turku", new Double(60.510857),new Double(22.275424)},
-               { "02 Citroen Jumper", "w/ company logo. 12m3 storage space.", "Turku", new Double(60.452171),new Double(22.2995)},
-               { "03 Saab 93", "Cabriolet<br/>Keys from the rental desk.", "Turku", new Double(60.4507),new Double(22.295551)},
-               { "04 Volvo S60", "Key from the rental desk.", "Turku", new Double(60.434722),new Double(22.224398)},
-               { "05 Smart fourtwo", "Cabrio. Keys from infodesk.", "Turku", new Double(60.508970),new Double(22.264790)},
-               // Helsinki
-               { "06 Smart fourtwo", "Cabrio. Keys from infodesk.", "Helsinki", new Double(60.17175),new Double(24.939029)},
-               { "07 Smart fourtwo", "Cabrio. Keys from infodesk.", "Helsinki", new Double(60.17175),new Double(24.939029)},
-               { "08 Smart fourtwo", "Cabrio. Keys from infodesk.", "Helsinki", new Double(60.166579),new Double(24.953899)},
-               { "09 Volvo S60", "Keys from infodesk.", "Helsinki", new Double(60.317832),new Double(24.967289)},
-               { "10 Saab 93", "Keys from infodesk.", "Helsinki", new Double(60.249193),new Double(25.045921)},
-               // Silicon Valley
-               { "11 Ford Mustang", "Keys from Acme clerk.", "Silicon Valley", new Double(37.615853),new Double(-122.386384)},
-               { "12 Ford Mondeo", "Keys from infodesk.", "Silicon Valley", new Double(37.365028),new Double(-121.922654)},
-               { "13 Ford Mustang", "GT Cal Special. Keys from guard.", "Silicon Valley", new Double(37.403812),new Double(-121.977425)},
-               { "14 Ford Mustang", "GT Cal Special. Keys from guard.", "Silicon Valley", new Double(37.403812),new Double(-121.977425)},
-               { "15 Land Rover", "Keys from infodesk.", "Silicon Valley", new Double(37.365028),new Double(-121.922654)},
-               // Paris
-               { "17 Peugeot 308", "Keys from infodesk.", "Paris", new Double(48.844756),new Double(2.372784)},
-               { "18 Citroën C6", "Keys from rental desk.", "Paris", new Double(49.007253),new Double(2.545025)},
-               { "19 Citroën C6", "Keys from infodesk.", "Paris", new Double(48.729061),new Double(2.368087)},
-               { "20 Peugeot 308", "Keys from ticket sales.", "Paris", new Double(48.880931),new Double(2.356988)},
-               { "21 Peugeot 308", "Keys from ticket sales.", "Paris", new Double(48.876479),new Double(2.358161)},
-               // STHLM
-               { "22 Volvo S60", "Keys from infodesk.", "Stockholm", new Double(59.350414),new Double(18.106574)},
-               { "23 Saab 93", "Keys from infodesk.", "Stockholm", new Double(59.355905),new Double(17.946784)},
-               { "24 Smart fourtwo", "Keys from infodesk.", "Stockholm", new Double(59.315939),new Double(18.095904)},
-               { "25 Smart fourtwo", "Keys from infodesk.", "Stockholm", new Double(59.330716),new Double(18.058702)},
-               // Boston
-               { "26 Ford Mustang", "Keys from infodesk.", "Boston", new Double(42.366588),new Double(-71.020955)},
-               { "27 Smart fourtwo", "Keys from infodesk.", "Boston", new Double(42.365419),new Double(-71.061748)},
-               { "28 Volvo S60", "Keys from Seaport Hotel reception.", "Boston", new Double(42.34811),new Double(-71.041127)},
-               { "29 Smart fourtwo", "Keys from Seaport Hotel reception.", "Boston", new Double(42.348072),new Double(-71.041315)},
-
-       };
-       
-       String q = "INSERT INTO " + Resource.TABLE + "("
-               + Resource.PROPERTY_ID_NAME + ","
-               + Resource.PROPERTY_ID_DESCRIPTION + ","
-               + Resource.PROPERTY_ID_CATEGORY + ","
-               + Resource.PROPERTY_ID_LOCATIONX + ","
-               + Resource.PROPERTY_ID_LOCATIONY
-               + ")" + " VALUES (?,?,?,?,?)";
-       try {
-           PreparedStatement stmt = connection.prepareStatement(q);
-           for (int i = 0; i < resources.length; i++) {
-               int j=0;
-               stmt.setString(j+1, (String)resources[i][j++]);
-               stmt.setString(j+1, (String)resources[i][j++]);
-               stmt.setString(j+1, (String)resources[i][j++]);
-               stmt.setDouble(j+1, ((Double)resources[i][j++]).doubleValue());
-               stmt.setDouble(j+1, ((Double)resources[i][j++]).doubleValue());
-               stmt.execute();
-           }
-       } catch (SQLException e) {
-           throw new RuntimeException(e);
+
+       public Container getUsers() {
+               // TODO where deleted=?
+               String q = "SELECT * FROM " + User.TABLE + " ORDER BY "
+                               + User.PROPERTY_ID_FULLNAME;
+               try {
+                       QueryContainer qc = new QueryContainer(q, connection,
+                                       ResultSet.TYPE_SCROLL_INSENSITIVE,
+                                       ResultSet.CONCUR_READ_ONLY);
+                       return qc;
+               } catch (SQLException e) {
+                       throw new RuntimeException(e);
+               }
        }
-    }
-
-    public void generateDemoUser() {
-       String q = "INSERT INTO USER (" + User.PROPERTY_ID_FULLNAME + ","
-               + User.PROPERTY_ID_EMAIL + "," + User.PROPERTY_ID_PASSWORD
-               + ") VALUES (?,?,?)";
-       try {
-           PreparedStatement stmt = connection.prepareStatement(q);
-           stmt.setString(1, "Demo User");
-           stmt.setString(2, "demo.user@itmill.com");
-           stmt.setString(3, "demo");
-           stmt.execute();
-       } catch (SQLException e) {
-           throw new RuntimeException(e);
+
+       public void generateResources() {
+               /*
+                * map.addMarker("Old Mill", new Point.Double(60.452224f,22.299929f));
+                * map.addMarker("ICT", new Point.Double(60.449007f,22.295508f));
+                * map.addMarker("DataCity", new Point.Double(60.448329f,22.295165f));
+                * map.addMarker("BioCity", new Point.Double(60.449451f,22.293105f));
+                * map.addMarker("PharmaCity", new Point.Double(60.44888f,22.292032f));
+                * map.addMarker("Intelligate", new Point.Double(60.450403f,22.29495f));
+                * map.addMarker("Paviljonki", new Point.Double(60.445408f,22.290831f));
+                * map.addMarker("Trivium", new Point.Double(60.44641962165445f,
+                * 22.301753170493f)); map.addMarker("Linja-auto asema", new
+                * Point.Double(60.457049f,22.267957f));
+                */
+               /*
+                * Object[][] resources = { { "IT Mill Toolkit Manual", "the manual",
+                * "Books", new Double(60.452224),new Double(22.299929)}, { "IT Mill
+                * Toolkit for Dummies", "the hardcover version", "Books", new
+                * Double(60.452224),new Double(22.299929) }, { "Sony", "Old Sony video
+                * projector", "AV equipment", new Double(60.449007),new
+                * Double(22.295508) }, { "Sanyo", "Brand new hd-ready video projector",
+                * "AV equipment", new Double(60.452224),new Double(22.299929) }, {
+                * "Room 7", "Conference room in the lobby", "Conference rooms", new
+                * Double(60.449451),new Double(22.292032) }, { "Nintendo Wii", "Teh
+                * uber fun", "Entertainment", new Double(60.445408),new
+                * Double(22.290831) }, { "Playstation", "We don't actually have one",
+                * "Entertainment", new Double(60.44641962165445),new
+                * Double(22.301753170493) }, { "Luokkahuone", "Classroom right next to
+                * IT Mill", "Conference rooms", new Double(60.44888),new
+                * Double(22.292032) } };
+                */
+               Object[][] resources = {
+                               // Turku
+                               { "01 Ford Mondeo", "w/ company logo", "Turku",
+                                               new Double(60.510857), new Double(22.275424) },
+                               { "02 Citroen Jumper", "w/ company logo. 12m3 storage space.",
+                                               "Turku", new Double(60.452171), new Double(22.2995) },
+                               { "03 Saab 93", "Cabriolet<br/>Keys from the rental desk.",
+                                               "Turku", new Double(60.4507), new Double(22.295551) },
+                               { "04 Volvo S60", "Key from the rental desk.", "Turku",
+                                               new Double(60.434722), new Double(22.224398) },
+                               { "05 Smart fourtwo", "Cabrio. Keys from infodesk.", "Turku",
+                                               new Double(60.508970), new Double(22.264790) },
+                               // Helsinki
+                               { "06 Smart fourtwo", "Cabrio. Keys from infodesk.",
+                                               "Helsinki", new Double(60.17175), new Double(24.939029) },
+                               { "07 Smart fourtwo", "Cabrio. Keys from infodesk.",
+                                               "Helsinki", new Double(60.17175), new Double(24.939029) },
+                               { "08 Smart fourtwo", "Cabrio. Keys from infodesk.",
+                                               "Helsinki", new Double(60.166579),
+                                               new Double(24.953899) },
+                               { "09 Volvo S60", "Keys from infodesk.", "Helsinki",
+                                               new Double(60.317832), new Double(24.967289) },
+                               { "10 Saab 93", "Keys from infodesk.", "Helsinki",
+                                               new Double(60.249193), new Double(25.045921) },
+                               // Silicon Valley
+                               { "11 Ford Mustang", "Keys from Acme clerk.", "Silicon Valley",
+                                               new Double(37.615853), new Double(-122.386384) },
+                               { "12 Ford Mondeo", "Keys from infodesk.", "Silicon Valley",
+                                               new Double(37.365028), new Double(-121.922654) },
+                               { "13 Ford Mustang", "GT Cal Special. Keys from guard.",
+                                               "Silicon Valley", new Double(37.403812),
+                                               new Double(-121.977425) },
+                               { "14 Ford Mustang", "GT Cal Special. Keys from guard.",
+                                               "Silicon Valley", new Double(37.403812),
+                                               new Double(-121.977425) },
+                               { "15 Land Rover", "Keys from infodesk.", "Silicon Valley",
+                                               new Double(37.365028), new Double(-121.922654) },
+                               // Paris
+                               { "17 Peugeot 308", "Keys from infodesk.", "Paris",
+                                               new Double(48.844756), new Double(2.372784) },
+                               { "18 Citroën C6", "Keys from rental desk.", "Paris",
+                                               new Double(49.007253), new Double(2.545025) },
+                               { "19 Citroën C6", "Keys from infodesk.", "Paris",
+                                               new Double(48.729061), new Double(2.368087) },
+                               { "20 Peugeot 308", "Keys from ticket sales.", "Paris",
+                                               new Double(48.880931), new Double(2.356988) },
+                               { "21 Peugeot 308", "Keys from ticket sales.", "Paris",
+                                               new Double(48.876479), new Double(2.358161) },
+                               // STHLM
+                               { "22 Volvo S60", "Keys from infodesk.", "Stockholm",
+                                               new Double(59.350414), new Double(18.106574) },
+                               { "23 Saab 93", "Keys from infodesk.", "Stockholm",
+                                               new Double(59.355905), new Double(17.946784) },
+                               { "24 Smart fourtwo", "Keys from infodesk.", "Stockholm",
+                                               new Double(59.315939), new Double(18.095904) },
+                               { "25 Smart fourtwo", "Keys from infodesk.", "Stockholm",
+                                               new Double(59.330716), new Double(18.058702) },
+                               // Boston
+                               { "26 Ford Mustang", "Keys from infodesk.", "Boston",
+                                               new Double(42.366588), new Double(-71.020955) },
+                               { "27 Smart fourtwo", "Keys from infodesk.", "Boston",
+                                               new Double(42.365419), new Double(-71.061748) },
+                               { "28 Volvo S60", "Keys from Seaport Hotel reception.",
+                                               "Boston", new Double(42.34811), new Double(-71.041127) },
+                               { "29 Smart fourtwo", "Keys from Seaport Hotel reception.",
+                                               "Boston", new Double(42.348072), new Double(-71.041315) },
+
+               };
+
+               String q = "INSERT INTO " + Resource.TABLE + "("
+                               + Resource.PROPERTY_ID_NAME + ","
+                               + Resource.PROPERTY_ID_DESCRIPTION + ","
+                               + Resource.PROPERTY_ID_CATEGORY + ","
+                               + Resource.PROPERTY_ID_LOCATIONX + ","
+                               + Resource.PROPERTY_ID_LOCATIONY + ")" + " VALUES (?,?,?,?,?)";
+               try {
+                       PreparedStatement stmt = connection.prepareStatement(q);
+                       for (int i = 0; i < resources.length; i++) {
+                               int j = 0;
+                               stmt.setString(j + 1, (String) resources[i][j++]);
+                               stmt.setString(j + 1, (String) resources[i][j++]);
+                               stmt.setString(j + 1, (String) resources[i][j++]);
+                               stmt.setDouble(j + 1, ((Double) resources[i][j++])
+                                               .doubleValue());
+                               stmt.setDouble(j + 1, ((Double) resources[i][j++])
+                                               .doubleValue());
+                               stmt.execute();
+                       }
+               } catch (SQLException e) {
+                       throw new RuntimeException(e);
+               }
        }
 
-    }
+       public void generateDemoUser() {
+               String q = "INSERT INTO USER (" + User.PROPERTY_ID_FULLNAME + ","
+                               + User.PROPERTY_ID_EMAIL + "," + User.PROPERTY_ID_PASSWORD
+                               + ") VALUES (?,?,?)";
+               try {
+                       PreparedStatement stmt = connection.prepareStatement(q);
+                       stmt.setString(1, "Demo User");
+                       stmt.setString(2, "demo.user@itmill.com");
+                       stmt.setString(3, "demo");
+                       stmt.execute();
+               } catch (SQLException e) {
+                       throw new RuntimeException(e);
+               }
+
+       }
 
 }
index b17de6263fec1179a51c092ad82040a8b17f2d3c..6ab247405a5827b373898c78c15b737b8588eca0 100644 (file)
@@ -7,28 +7,28 @@ import com.itmill.toolkit.terminal.gwt.client.DefaultWidgetSet;
 import com.itmill.toolkit.terminal.gwt.client.UIDL;\r
 \r
 public class WidgetSet extends DefaultWidgetSet {\r
-    public Widget createWidget(UIDL uidl) {\r
-       String className = resolveWidgetTypeName(uidl);\r
-       if ("com.itmill.toolkit.terminal.gwt.client.ui.IGoogleMap"\r
-               .equals(className)) {\r
-           return new IGoogleMap();\r
+       public Widget createWidget(UIDL uidl) {\r
+               String className = resolveWidgetTypeName(uidl);\r
+               if ("com.itmill.toolkit.terminal.gwt.client.ui.IGoogleMap"\r
+                               .equals(className)) {\r
+                       return new IGoogleMap();\r
+               }\r
+\r
+               return super.createWidget(uidl);\r
        }\r
 \r
-       return super.createWidget(uidl);\r
-    }\r
+       protected String resolveWidgetTypeName(UIDL uidl) {\r
 \r
-    protected String resolveWidgetTypeName(UIDL uidl) {\r
+               String tag = uidl.getTag();\r
+               if ("googlemap".equals(tag)) {\r
+                       return "com.itmill.toolkit.terminal.gwt.client.ui.IGoogleMap";\r
+               }\r
 \r
-       String tag = uidl.getTag();\r
-       if ("googlemap".equals(tag)) {\r
-           return "com.itmill.toolkit.terminal.gwt.client.ui.IGoogleMap";\r
+               return super.resolveWidgetTypeName(uidl);\r
        }\r
 \r
-       return super.resolveWidgetTypeName(uidl);\r
-    }\r
-    \r
-    public boolean isCorrectImplementation(Widget currentWidget, UIDL uidl) {\r
-       return GWT.getTypeName(currentWidget).equals(\r
-               resolveWidgetTypeName(uidl));\r
-    }\r
+       public boolean isCorrectImplementation(Widget currentWidget, UIDL uidl) {\r
+               return GWT.getTypeName(currentWidget).equals(\r
+                               resolveWidgetTypeName(uidl));\r
+       }\r
 }\r
index 87ed826338dbbbbc0eb33daf3e0c07c8801c0d1f..1bcb66988088e43480d07d739b667ad5b81fc154 100644 (file)
@@ -15,81 +15,82 @@ import com.mapitz.gwt.googleMaps.client.GMarkerEventManager;
 \r
 public class IGoogleMap extends GMap2Widget implements Paintable {\r
 \r
-    public static final String CLASSNAME = "i-googlemap";\r
-    \r
-    GMap2EventManager mapEventManager;\r
-    GMarkerEventManager markerEventManager;\r
-    GMap2 map;\r
-\r
-    public IGoogleMap() {\r
-       setStyleName(CLASSNAME);\r
-       mapEventManager = GMap2EventManager.getInstance();\r
-       map = this.getGmap();\r
-    }\r
-\r
-    public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {\r
-       map.clearOverlays();\r
-       GLatLng pos = null;\r
-       for (Iterator it = uidl.getChildIterator(); it.hasNext();) {\r
-           UIDL u = (UIDL) it.next();\r
-           if (u.getTag().equals("markers")) {\r
-\r
-               for (Iterator m = u.getChildIterator(); m.hasNext();) {\r
-                   UIDL umarker = (UIDL) m.next();\r
-                   String html = "<span>"+umarker.getStringAttribute("html")+"</span>";\r
-                   double x = umarker.getDoubleAttribute("x");\r
-                   double y = umarker.getDoubleAttribute("y");\r
-                   pos = new GLatLng(x, y);\r
-                   GMarker marker = new GMarker(pos);\r
-                   map.addOverlay(marker);\r
-                   if (html != null) {\r
-                       addMarkerPopup(marker, html);\r
-                   }\r
-               }\r
-           }\r
-       }\r
-       if (uidl.hasAttribute("width")) {\r
-           setWidth(""+uidl.getIntAttribute("width"));\r
-       }\r
-       if (uidl.hasAttribute("height")) {\r
-           setHeight(""+uidl.getIntAttribute("height"));\r
-       }\r
-       if (uidl.hasAttribute("zoom")) {\r
-           map.setZoom(uidl.getIntAttribute("zoom"));\r
-       }\r
-       if (uidl.hasAttribute("centerX") && uidl.hasAttribute("centerY")) {\r
-           GLatLng center = new GLatLng(uidl.getDoubleAttribute("centerX"),\r
-                   uidl.getDoubleAttribute("centerY"));\r
-           map.setCenter(center);\r
-       } else if (pos!=null) {\r
-           // use last marker position\r
-           map.setCenter(pos);\r
-       }\r
+       public static final String CLASSNAME = "i-googlemap";\r
 \r
-    }\r
+       GMap2EventManager mapEventManager;\r
+       GMarkerEventManager markerEventManager;\r
+       GMap2 map;\r
 \r
-    private void addMarkerPopup(GMarker marker, String html) {\r
-       if (markerEventManager == null) {\r
-           markerEventManager = GMarkerEventManager.getInstance();\r
+       public IGoogleMap() {\r
+               setStyleName(CLASSNAME);\r
+               mapEventManager = GMap2EventManager.getInstance();\r
+               map = this.getGmap();\r
        }\r
 \r
-       markerEventManager.addOnClickListener(marker, new MarkerEventListener(\r
-               html));\r
+       public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {\r
+               map.clearOverlays();\r
+               GLatLng pos = null;\r
+               for (Iterator it = uidl.getChildIterator(); it.hasNext();) {\r
+                       UIDL u = (UIDL) it.next();\r
+                       if (u.getTag().equals("markers")) {\r
 \r
-    }\r
-\r
-    private class MarkerEventListener implements GMarkerEventClickListener {\r
-       String html;\r
+                               for (Iterator m = u.getChildIterator(); m.hasNext();) {\r
+                                       UIDL umarker = (UIDL) m.next();\r
+                                       String html = "<span>" + umarker.getStringAttribute("html")\r
+                                                       + "</span>";\r
+                                       double x = umarker.getDoubleAttribute("x");\r
+                                       double y = umarker.getDoubleAttribute("y");\r
+                                       pos = new GLatLng(x, y);\r
+                                       GMarker marker = new GMarker(pos);\r
+                                       map.addOverlay(marker);\r
+                                       if (html != null) {\r
+                                               addMarkerPopup(marker, html);\r
+                                       }\r
+                               }\r
+                       }\r
+               }\r
+               if (uidl.hasAttribute("width")) {\r
+                       setWidth("" + uidl.getIntAttribute("width"));\r
+               }\r
+               if (uidl.hasAttribute("height")) {\r
+                       setHeight("" + uidl.getIntAttribute("height"));\r
+               }\r
+               if (uidl.hasAttribute("zoom")) {\r
+                       map.setZoom(uidl.getIntAttribute("zoom"));\r
+               }\r
+               if (uidl.hasAttribute("centerX") && uidl.hasAttribute("centerY")) {\r
+                       GLatLng center = new GLatLng(uidl.getDoubleAttribute("centerX"),\r
+                                       uidl.getDoubleAttribute("centerY"));\r
+                       map.setCenter(center);\r
+               } else if (pos != null) {\r
+                       // use last marker position\r
+                       map.setCenter(pos);\r
+               }\r
 \r
-       public MarkerEventListener(String html) {\r
-           this.html = html;\r
        }\r
 \r
-       public void onClick(GMarker marker) {\r
-           marker.openInfoWindowHtml(html);\r
+       private void addMarkerPopup(GMarker marker, String html) {\r
+               if (markerEventManager == null) {\r
+                       markerEventManager = GMarkerEventManager.getInstance();\r
+               }\r
+\r
+               markerEventManager.addOnClickListener(marker, new MarkerEventListener(\r
+                               html));\r
+\r
        }\r
 \r
-       public void onDblClick(GMarker marker) {\r
+       private class MarkerEventListener implements GMarkerEventClickListener {\r
+               String html;\r
+\r
+               public MarkerEventListener(String html) {\r
+                       this.html = html;\r
+               }\r
+\r
+               public void onClick(GMarker marker) {\r
+                       marker.openInfoWindowHtml(html);\r
+               }\r
+\r
+               public void onDblClick(GMarker marker) {\r
+               }\r
        }\r
-    }\r
 }\r
index d27756b4f5be22d8de2f8e9eb2b8eaee25924ab3..c452a44d242c7bb33bc80a9aed6e6f8b4d962d3d 100644 (file)
@@ -19,144 +19,146 @@ import java.sql.Timestamp;
  */
 public class SampleCalendarDatabase {
 
-    public static final int ENTRYCOUNT = 100;
-
-    public static final String DB_TABLE_NAME = "calendar";
-    public static final String PROPERTY_ID_START = "EVENTSTART";
-    public static final String PROPERTY_ID_END = "EVENTEND";
-    public static final String PROPERTY_ID_TITLE = "TITLE";
-    public static final String PROPERTY_ID_NOTIME = "NOTIME";
-    
-    private Connection connection = null;
-
-    private static final String[] titles = new String[] { "Meeting", "Dentist",
-           "Haircut", "Bank", "Birthday", "Library", "Rent", "Acme test", "Party" };
-
-    /**
-     * Create temporary database.
-     * 
-     */
-    public SampleCalendarDatabase() {
-       // connect to SQL database
-       connect();
-
-       // initialize SQL database
-       createTables();
-
-       // test by executing sample JDBC query
-       testDatabase();
-    }
-
-    /**
-     * Creates sample table named employee and populates it with data.Use the
-     * specified database connection.
-     * 
-     * @param connection
-     */
-    public SampleCalendarDatabase(Connection connection) {
-       // initialize SQL database
-       createTables();
-
-       // test by executing sample JDBC query
-       testDatabase();
-    }
-
-    /**
-     * Connect to SQL database. In this sample we use HSQLDB and an toolkit
-     * named database in implicitly created into system memory.
-     * 
-     */
-    private void connect() {
-       // use memory-Only Database
-       String url = "jdbc:hsqldb:mem:toolkit";
-       try {
-           Class.forName("org.hsqldb.jdbcDriver").newInstance();
-           connection = DriverManager.getConnection(url, "sa", "");
-       } catch (Exception e) {
-           throw new RuntimeException(e);
+       public static final int ENTRYCOUNT = 100;
+
+       public static final String DB_TABLE_NAME = "calendar";
+       public static final String PROPERTY_ID_START = "EVENTSTART";
+       public static final String PROPERTY_ID_END = "EVENTEND";
+       public static final String PROPERTY_ID_TITLE = "TITLE";
+       public static final String PROPERTY_ID_NOTIME = "NOTIME";
+
+       private Connection connection = null;
+
+       private static final String[] titles = new String[] { "Meeting", "Dentist",
+                       "Haircut", "Bank", "Birthday", "Library", "Rent", "Acme test",
+                       "Party" };
+
+       /**
+        * Create temporary database.
+        * 
+        */
+       public SampleCalendarDatabase() {
+               // connect to SQL database
+               connect();
+
+               // initialize SQL database
+               createTables();
+
+               // test by executing sample JDBC query
+               testDatabase();
+       }
+
+       /**
+        * Creates sample table named employee and populates it with data.Use the
+        * specified database connection.
+        * 
+        * @param connection
+        */
+       public SampleCalendarDatabase(Connection connection) {
+               // initialize SQL database
+               createTables();
+
+               // test by executing sample JDBC query
+               testDatabase();
        }
-    }
-
-    /**
-     * use for SQL commands CREATE, DROP, INSERT and UPDATE
-     * 
-     * @param expression
-     * @throws SQLException
-     */
-    public void update(String expression) throws SQLException {
-       Statement st = null;
-       st = connection.createStatement();
-       int i = st.executeUpdate(expression);
-       if (i == -1) {
-           System.out.println("SampleDatabase error : " + expression);
+
+       /**
+        * Connect to SQL database. In this sample we use HSQLDB and an toolkit
+        * named database in implicitly created into system memory.
+        * 
+        */
+       private void connect() {
+               // use memory-Only Database
+               String url = "jdbc:hsqldb:mem:toolkit";
+               try {
+                       Class.forName("org.hsqldb.jdbcDriver").newInstance();
+                       connection = DriverManager.getConnection(url, "sa", "");
+               } catch (Exception e) {
+                       throw new RuntimeException(e);
+               }
        }
-       st.close();
-    }
-
-    /**
-     * Create test table and few rows. Issue note: using capitalized column
-     * names as HSQLDB returns column names in capitalized form with this demo.
-     * 
-     */
-    private void createTables() {
-       try {
-           String stmt = null;
-           stmt = "CREATE TABLE "+DB_TABLE_NAME+" ( ID INTEGER IDENTITY, TITLE VARCHAR(100), "
-                   + "EVENTSTART DATETIME, EVENTEND DATETIME, NOTIME BOOLEAN  )";
-           update(stmt);
-           for (int j = 0; j < ENTRYCOUNT; j++) {
-               Timestamp start = new Timestamp(new java.util.Date().getTime());
-               start.setDate((int)((Math.random()-0.4) * 200));
-               start.setMinutes(0);
-               start.setHours(8+(int)Math.random()*12);
-               Timestamp end = new Timestamp(start.getTime());
-               if (Math.random()<0.7) {
-                   long t = end.getTime();
-                   long hour = 60 * 60 * 1000;
-                   t = t + hour + (long)(Math.round(Math.random() * 3 * hour));
-                   end.setTime(t);
+
+       /**
+        * use for SQL commands CREATE, DROP, INSERT and UPDATE
+        * 
+        * @param expression
+        * @throws SQLException
+        */
+       public void update(String expression) throws SQLException {
+               Statement st = null;
+               st = connection.createStatement();
+               int i = st.executeUpdate(expression);
+               if (i == -1) {
+                       System.out.println("SampleDatabase error : " + expression);
                }
+               st.close();
+       }
 
-               stmt = "INSERT INTO "+DB_TABLE_NAME+"(TITLE, EVENTSTART, EVENTEND, NOTIME) VALUES ("
-                       + "'"
-                       + titles[(int) (Math.round(Math.random() * (titles.length - 1)))]
-                       + "','"
-                       + start
-                       + "','"
-                       + end
-                       + "',"
-                       + (Math.random()>0.7)
-                       + ")";
-               update(stmt);
-           }
-       } catch (SQLException e) {
-           if (e.toString().indexOf("Table already exists") == -1)
-               throw new RuntimeException(e);
+       /**
+        * Create test table and few rows. Issue note: using capitalized column
+        * names as HSQLDB returns column names in capitalized form with this demo.
+        * 
+        */
+       private void createTables() {
+               try {
+                       String stmt = null;
+                       stmt = "CREATE TABLE "
+                                       + DB_TABLE_NAME
+                                       + " ( ID INTEGER IDENTITY, TITLE VARCHAR(100), "
+                                       + "EVENTSTART DATETIME, EVENTEND DATETIME, NOTIME BOOLEAN  )";
+                       update(stmt);
+                       for (int j = 0; j < ENTRYCOUNT; j++) {
+                               Timestamp start = new Timestamp(new java.util.Date().getTime());
+                               start.setDate((int) ((Math.random() - 0.4) * 200));
+                               start.setMinutes(0);
+                               start.setHours(8 + (int) Math.random() * 12);
+                               Timestamp end = new Timestamp(start.getTime());
+                               if (Math.random() < 0.7) {
+                                       long t = end.getTime();
+                                       long hour = 60 * 60 * 1000;
+                                       t = t + hour
+                                                       + (long) (Math.round(Math.random() * 3 * hour));
+                                       end.setTime(t);
+                               }
+
+                               stmt = "INSERT INTO "
+                                               + DB_TABLE_NAME
+                                               + "(TITLE, EVENTSTART, EVENTEND, NOTIME) VALUES ("
+                                               + "'"
+                                               + titles[(int) (Math.round(Math.random()
+                                                               * (titles.length - 1)))] + "','" + start
+                                               + "','" + end + "'," + (Math.random() > 0.7) + ")";
+                               update(stmt);
+                       }
+               } catch (SQLException e) {
+                       if (e.toString().indexOf("Table already exists") == -1)
+                               throw new RuntimeException(e);
+               }
        }
-    }
-
-    /**
-     * Test database connection with simple SELECT command.
-     * 
-     */
-    private String testDatabase() {
-       String result = null;
-       try {
-           Statement stmt = connection.createStatement(
-                   ResultSet.TYPE_SCROLL_INSENSITIVE,
-                   ResultSet.CONCUR_UPDATABLE);
-           ResultSet rs = stmt.executeQuery("SELECT COUNT(*) FROM "+DB_TABLE_NAME);
-           rs.next();
-           result = "rowcount for table test is " + rs.getObject(1).toString();
-           stmt.close();
-       } catch (SQLException e) {
-           throw new RuntimeException(e);
+
+       /**
+        * Test database connection with simple SELECT command.
+        * 
+        */
+       private String testDatabase() {
+               String result = null;
+               try {
+                       Statement stmt = connection.createStatement(
+                                       ResultSet.TYPE_SCROLL_INSENSITIVE,
+                                       ResultSet.CONCUR_UPDATABLE);
+                       ResultSet rs = stmt.executeQuery("SELECT COUNT(*) FROM "
+                                       + DB_TABLE_NAME);
+                       rs.next();
+                       result = "rowcount for table test is " + rs.getObject(1).toString();
+                       stmt.close();
+               } catch (SQLException e) {
+                       throw new RuntimeException(e);
+               }
+               return result;
        }
-       return result;
-    }
 
-    public Connection getConnection() {
-       return connection;
-    }
+       public Connection getConnection() {
+               return connection;
+       }
 
 }
index 941c19ec2fd484846cdb6892e9194034c55ffbb1..c0736d6c97c74b9031890ee96d121a39479b5bd7 100644 (file)
@@ -162,7 +162,7 @@ public interface PaintTarget {
         *             if the paint operation failed.
         */
        public void addAttribute(String name, long value) throws PaintException;
-       
+
        /**
         * Adds a float attribute to component. Atributes must be added before any
         * content is written.
@@ -176,7 +176,7 @@ public interface PaintTarget {
         *             if the paint operation failed.
         */
        public void addAttribute(String name, float value) throws PaintException;
-       
+
        /**
         * Adds a double attribute to component. Atributes must be added before any
         * content is written.
@@ -236,7 +236,7 @@ public interface PaintTarget {
         */
        public void addVariable(VariableOwner owner, String name, int value)
                        throws PaintException;
-       
+
        /**
         * Adds a long type variable.
         * 
@@ -252,7 +252,7 @@ public interface PaintTarget {
         */
        public void addVariable(VariableOwner owner, String name, long value)
                        throws PaintException;
-       
+
        /**
         * Adds a float type variable.
         * 
@@ -268,7 +268,7 @@ public interface PaintTarget {
         */
        public void addVariable(VariableOwner owner, String name, float value)
                        throws PaintException;
-       
+
        /**
         * Adds a double type variable.
         * 
index 0d6ab623136ad07ef6cad0c449d2217aeceab8c2..c7ee9e1628abbae42e14d6cea2e9788eacd7514b 100755 (executable)
@@ -57,7 +57,7 @@ public class ApplicationConnection implements FocusListener {
                }
 
                makeUidlRequest("repaintAll=1");
-               
+
                // TODO remove hardcoded id name
                view = new IView("itmtk-ajax-window");
 
@@ -74,14 +74,14 @@ public class ApplicationConnection implements FocusListener {
         }-*/;
 
        public native String getAppUri()/*-{
-       var u = $wnd.itmtk.appUri;
-       if (u.indexOf("/") != 0 && u.indexOf("http") != 0) u = "../../../" +u;
-        return u;
-        }-*/;
+               var u = $wnd.itmtk.appUri;
+               if (u.indexOf("/") != 0 && u.indexOf("http") != 0) u = "../../../" +u;
+                return u;
+                }-*/;
 
        private native String getPathInfo()/*-{
-        return $wnd.itmtk.pathInfo;
-        }-*/;
+                return $wnd.itmtk.pathInfo;
+                }-*/;
 
        private void makeUidlRequest(String requestData) {
                console.log("Making UIDL Request with params: " + requestData);
@@ -198,8 +198,8 @@ public class ApplicationConnection implements FocusListener {
 
        // Redirect browser
        private static native void redirect(String url)/*-{
-        $wnd.location = url;
-        }-*/;
+                $wnd.location = url;
+                }-*/;
 
        public void registerPaintable(String id, Paintable paintable) {
                idToPaintable.put(id, paintable);
index 885d7a8016d6561054fa3af05012ae116ea6f80f..c16db41e58de27b73cf2f606efcb7375c80cd216 100644 (file)
@@ -7,69 +7,72 @@ import com.google.gwt.user.client.ui.HTML;
 import com.google.gwt.user.client.ui.PopupPanel;
 
 public class Caption extends HTML {
-       
+
        public static final String CLASSNAME = "i-caption";
 
        private Paintable owner;
 
        private Element errorIndicatorElement;
-       
+
        private Element captionText;
 
        private ErrorMessage errorMessage;
-       
+
        private PopupPanel errorContainer;
-       
+
        /* Caption must be attached to a Paintable */
-       private Caption(){};
-       
-       public Caption(Paintable component)  {
+       private Caption() {
+       };
+
+       public Caption(Paintable component) {
                super();
                owner = component;
                setStyleName(CLASSNAME);
        }
-       
+
        public void updateCaption(UIDL uidl) {
                setVisible(!uidl.getBooleanAttribute("invisible"));
-               
-               if(uidl.hasAttribute("error")) {
+
+               if (uidl.hasAttribute("error")) {
                        UIDL errorUidl = uidl.getErrors();
-                       
-                       if(errorIndicatorElement == null) {
+
+                       if (errorIndicatorElement == null) {
                                errorIndicatorElement = DOM.createDiv();
-                               DOM.setElementProperty(errorIndicatorElement, "className", "i-errorindicator");
+                               DOM.setElementProperty(errorIndicatorElement, "className",
+                                               "i-errorindicator");
                                DOM.insertChild(getElement(), errorIndicatorElement, 0);
                        }
-                       if(errorMessage == null)
+                       if (errorMessage == null)
                                errorMessage = new ErrorMessage();
                        errorMessage.updateFromUIDL(errorUidl);
-                       
-               } else iferrorIndicatorElement != null) {
+
+               } else if (errorIndicatorElement != null) {
                        DOM.setStyleAttribute(errorIndicatorElement, "display", "none");
                }
-               
-               
-               if(uidl.hasAttribute("caption")) {
-                       if(captionText == null) {
+
+               if (uidl.hasAttribute("caption")) {
+                       if (captionText == null) {
                                captionText = DOM.createSpan();
                                DOM.appendChild(getElement(), captionText);
                        }
                        DOM.setInnerText(captionText, uidl.getStringAttribute("caption"));
                }
-               
-               if(uidl.hasAttribute("description")) {
-                       if(captionText != null) {
-                               DOM.setElementProperty(captionText, "title", uidl.getStringAttribute("description"));
+
+               if (uidl.hasAttribute("description")) {
+                       if (captionText != null) {
+                               DOM.setElementProperty(captionText, "title", uidl
+                                               .getStringAttribute("description"));
                        } else {
                                setTitle(uidl.getStringAttribute("description"));
                        }
                }
-               
+
        }
-       
+
        public void onBrowserEvent(Event event) {
-               Element target= DOM.eventGetTarget(event);
-               if(errorIndicatorElement != null && DOM.compare(target, errorIndicatorElement)) {
+               Element target = DOM.eventGetTarget(event);
+               if (errorIndicatorElement != null
+                               && DOM.compare(target, errorIndicatorElement)) {
                        switch (DOM.eventGetType(event)) {
                        case Event.ONMOUSEOVER:
                                showErrorMessage();
@@ -78,8 +81,8 @@ public class Caption extends HTML {
                                hideErrorMessage();
                                break;
                        case Event.ONCLICK:
-                               ApplicationConnection.getConsole().
-                                       log(DOM.getInnerHTML(errorMessage.getElement()));
+                               ApplicationConnection.getConsole().log(
+                                               DOM.getInnerHTML(errorMessage.getElement()));
                        default:
                                break;
                        }
@@ -87,39 +90,43 @@ public class Caption extends HTML {
        }
 
        private void hideErrorMessage() {
-               if(errorContainer != null) {
+               if (errorContainer != null) {
                        errorContainer.hide();
                }
        }
 
        private void showErrorMessage() {
-               if(errorMessage != null) {
-                       if(errorContainer == null) {
+               if (errorMessage != null) {
+                       if (errorContainer == null) {
                                errorContainer = new PopupPanel();
                                errorContainer.setWidget(errorMessage);
                        }
-                       errorContainer.setPopupPosition(
-                                       DOM.getAbsoluteLeft(errorIndicatorElement) +
-                                               2*DOM.getElementPropertyInt(errorIndicatorElement, "offsetHeight"),
-                                       DOM.getAbsoluteTop(errorIndicatorElement) + 
-                                               2*DOM.getElementPropertyInt(errorIndicatorElement, "offsetHeight"));
+                       errorContainer.setPopupPosition(DOM
+                                       .getAbsoluteLeft(errorIndicatorElement)
+                                       + 2
+                                       * DOM.getElementPropertyInt(errorIndicatorElement,
+                                                       "offsetHeight"), DOM
+                                       .getAbsoluteTop(errorIndicatorElement)
+                                       + 2
+                                       * DOM.getElementPropertyInt(errorIndicatorElement,
+                                                       "offsetHeight"));
                        errorContainer.show();
                }
        }
 
        public static boolean isNeeded(UIDL uidl) {
-               if (uidl.getStringAttribute("caption") != null) return true;
+               if (uidl.getStringAttribute("caption") != null)
+                       return true;
                if (uidl.hasAttribute("error"))
                        return true;
-               
+
                // TODO Description ??
-               
+
                return false;
        }
-       
+
        /**
-        * Returns Paintable for which this Caption
-        * belongs to.
+        * Returns Paintable for which this Caption belongs to.
         * 
         * @return owner Widget
         */
index 1957de0ce836fe0bf4c175e1897928abce65db04..a4e05f0283d5983aa3678793aae89a1a76bdb59b 100644 (file)
@@ -7,8 +7,8 @@ public class CaptionWrapper extends FlowPanel {
 
        public static final String CLASSNAME = "i-captionwrapper";
        Caption caption;
-       Paintable widget; 
-       
+       Paintable widget;
+
        public CaptionWrapper(Paintable toBeWrapped) {
                caption = new Caption(toBeWrapped);
                add(caption);
@@ -16,12 +16,12 @@ public class CaptionWrapper extends FlowPanel {
                add((Widget) widget);
                setStyleName(CLASSNAME);
        }
-       
+
        public void updateCaption(UIDL uidl) {
                caption.updateCaption(uidl);
                setVisible(!uidl.getBooleanAttribute("invisible"));
        }
-       
+
        public Paintable getPaintable() {
                return widget;
        }
index 283e35a2bd045059bbde122e235da78a96b0dfc2..fec5417a01b49dc13e48691143089d9d74177033 100644 (file)
@@ -1,56 +1,63 @@
 package com.itmill.toolkit.terminal.gwt.client;\r
 \r
-public class DateLocale extends com.itmill.toolkit.terminal.gwt.client.util.DateLocale {\r
+public class DateLocale extends\r
+               com.itmill.toolkit.terminal.gwt.client.util.DateLocale {\r
 \r
        private static String locale;\r
-       \r
+\r
        public DateLocale() {\r
                locale = LocaleService.getDefaultLocale();\r
        }\r
-       \r
+\r
        public static void setLocale(String l) {\r
-               if(LocaleService.getAvailableLocales().contains(locale))\r
+               if (LocaleService.getAvailableLocales().contains(locale))\r
                        locale = l;\r
-               else // TODO redirect to console\r
-                       System.out.println("Tried to use an unloaded locale \""+locale+"\". Using default in stead ("+locale+")");\r
+               else\r
+                       // TODO redirect to console\r
+                       System.out.println("Tried to use an unloaded locale \"" + locale\r
+                                       + "\". Using default in stead (" + locale + ")");\r
        }\r
-       \r
+\r
        public static String getAM() {\r
                try {\r
                        return LocaleService.getAmPmStrings(locale)[0];\r
                } catch (LocaleNotLoadedException e) {\r
                        // TODO redirect to console\r
-                       System.out.println("Tried to use an unloaded locale \""+locale+"\".");\r
+                       System.out.println("Tried to use an unloaded locale \"" + locale\r
+                                       + "\".");\r
                        return "AM";\r
                }\r
        }\r
-       \r
+\r
        public static String getPM() {\r
                try {\r
                        return LocaleService.getAmPmStrings(locale)[1];\r
                } catch (LocaleNotLoadedException e) {\r
                        // TODO redirect to console\r
-                       System.out.println("Tried to use an unloaded locale \""+locale+"\".");\r
+                       System.out.println("Tried to use an unloaded locale \"" + locale\r
+                                       + "\".");\r
                        return "PM";\r
                }\r
        }\r
-       \r
+\r
        public String[] getWEEKDAY_LONG() {\r
                try {\r
                        return LocaleService.getDayNames(locale);\r
                } catch (LocaleNotLoadedException e) {\r
                        // TODO redirect to console\r
-                       System.out.println("Tried to use an unloaded locale \""+locale+"\".");\r
+                       System.out.println("Tried to use an unloaded locale \"" + locale\r
+                                       + "\".");\r
                        return null;\r
                }\r
        }\r
-       \r
+\r
        public String[] getWEEKDAY_SHORT() {\r
                try {\r
                        return LocaleService.getShortDayNames(locale);\r
                } catch (LocaleNotLoadedException e) {\r
                        // TODO redirect to console\r
-                       System.out.println("Tried to use an unloaded locale \""+locale+"\".");\r
+                       System.out.println("Tried to use an unloaded locale \"" + locale\r
+                                       + "\".");\r
                        return null;\r
                }\r
        }\r
index 62ff15d0ac7284c74981efb82459da4a65d3787a..9d4b28a555c6eb7abd671221a4ec102fec9f8869 100644 (file)
@@ -12,239 +12,239 @@ import com.itmill.toolkit.terminal.gwt.client.ui.IDateField;
  * \r
  */\r
 public class DateTimeService {\r
-    public static int RESOLUTION_YEAR = 0;\r
-    public static int RESOLUTION_MONTH = 1;\r
-    public static int RESOLUTION_DAY = 2;\r
-    public static int RESOLUTION_HOUR = 3;\r
-    public static int RESOLUTION_MIN = 4;\r
-    public static int RESOLUTION_SEC = 5;\r
-    public static int RESOLUTION_MSEC = 6;\r
-\r
-    private String currentLocale;\r
-\r
-    private static int[] maxDaysInMonth = { 31, 28, 31, 30, 31, 30, 31, 31, 30,\r
-           31, 30, 31 };\r
-\r
-    /**\r
-     * Creates a new date time service with the application default locale.\r
-     */\r
-    public DateTimeService() {\r
-       currentLocale = LocaleService.getDefaultLocale();\r
-    }\r
-\r
-    /**\r
-     * Creates a new date time service with a given locale.\r
-     * \r
-     * @param locale\r
-     *                e.g. fi, en etc.\r
-     * @throws LocaleNotLoadedException\r
-     */\r
-    public DateTimeService(String locale) throws LocaleNotLoadedException {\r
-       setLocale(locale);\r
-    }\r
-\r
-    public void setLocale(String locale) throws LocaleNotLoadedException {\r
-       if (LocaleService.getAvailableLocales().contains(locale))\r
-           currentLocale = locale;\r
-       else\r
-           throw new LocaleNotLoadedException(locale);\r
-    }\r
-\r
-    public String getLocale() {\r
-       return currentLocale;\r
-    }\r
-\r
-    public String getMonth(int month) {\r
-       try {\r
-           return LocaleService.getMonthNames(currentLocale)[month];\r
-       } catch (LocaleNotLoadedException e) {\r
-           // TODO redirect to console\r
-           System.out.println(e + ":" + e.getMessage());\r
-       }\r
-       return null;\r
-    }\r
-\r
-    public String getShortMonth(int month) {\r
-       try {\r
-           return LocaleService.getShortMonthNames(currentLocale)[month];\r
-       } catch (LocaleNotLoadedException e) {\r
-           // TODO redirect to console\r
-           System.out.println(e + ":" + e.getMessage());\r
-       }\r
-       return null;\r
-    }\r
-\r
-    public String getDay(int day) {\r
-       try {\r
-           return LocaleService.getDayNames(currentLocale)[day];\r
-       } catch (LocaleNotLoadedException e) {\r
-           // TODO redirect to console\r
-           System.out.println(e + ":" + e.getMessage());\r
-       }\r
-       return null;\r
-    }\r
-\r
-    public String getShortDay(int day) {\r
-       try {\r
-           return LocaleService.getShortDayNames(currentLocale)[day];\r
-       } catch (LocaleNotLoadedException e) {\r
-           // TODO redirect to console\r
-           System.out.println(e + ":" + e.getMessage());\r
-       }\r
-       return null;\r
-    }\r
-\r
-    public int getFirstDayOfWeek() {\r
-       try {\r
-           return LocaleService.getFirstDayOfWeek(currentLocale);\r
-       } catch (LocaleNotLoadedException e) {\r
-           // TODO redirect to console\r
-           System.out.println(e + ":" + e.getMessage());\r
-       }\r
-       return 0;\r
-    }\r
-\r
-    public boolean isTwelveHourClock() {\r
-       try {\r
-           return LocaleService.isTwelveHourClock(currentLocale);\r
-       } catch (LocaleNotLoadedException e) {\r
-           // TODO redirect to console\r
-           System.out.println(e + ":" + e.getMessage());\r
-       }\r
-       return false;\r
-    }\r
-\r
-    public String getClockDelimeter() {\r
-       try {\r
-           return LocaleService.getClockDelimiter(currentLocale);\r
-       } catch (LocaleNotLoadedException e) {\r
-           // TODO redirect to console\r
-           System.out.println(e + ":" + e.getMessage());\r
-       }\r
-       return ":";\r
-    }\r
-\r
-    public String[] getAmPmStrings() {\r
-       try {\r
-           return LocaleService.getAmPmStrings(currentLocale);\r
-       } catch (LocaleNotLoadedException e) {\r
-           // TODO redirect to console\r
-           System.out.println(e + ":" + e.getMessage());\r
-       }\r
-       String[] temp = new String[2];\r
-       temp[0] = "AM";\r
-       temp[1] = "PM";\r
-       return temp;\r
-    }\r
-\r
-    public int getStartWeekDay(Date date) {\r
-       Date dateForFirstOfThisMonth = new Date(date.getYear(),\r
-               date.getMonth(), 1);\r
-       int firstDay;\r
-       try {\r
-           firstDay = LocaleService.getFirstDayOfWeek(currentLocale);\r
-       } catch (LocaleNotLoadedException e) {\r
-           firstDay = 0;\r
-           // TODO redirect to console\r
-           System.out.println(e + ":" + e.getMessage());\r
-       }\r
-       int start = dateForFirstOfThisMonth.getDay() - firstDay;\r
-       if (start < 0)\r
-           start = 6;\r
-       return start;\r
-    }\r
-\r
-    public String getDateFormat() {\r
-       try {\r
-           return LocaleService.getDateFormat(currentLocale);\r
-       } catch (LocaleNotLoadedException e) {\r
-           // TODO redirect to console\r
-           System.out.println(e + ":" + e.getMessage());\r
-       }\r
-       return "M/d/yy";\r
-    }\r
-\r
-    public static int getNumberOfDaysInMonth(Date date) {\r
-       int month = date.getMonth();\r
-       if (month == 1 && true == isLeapYear(date))\r
-           return 29;\r
-       return maxDaysInMonth[month];\r
-    }\r
-\r
-    public static boolean isLeapYear(Date date) {\r
-       // Instantiate the date for 1st March of that year\r
-       Date firstMarch = new Date(date.getYear(), 2, 1);\r
-\r
-       // Go back 1 day\r
-       long firstMarchTime = firstMarch.getTime();\r
-       long lastDayTimeFeb = firstMarchTime - (24 * 60 * 60 * 1000); // NUM_MILLISECS_A_DAY\r
-\r
-       // Instantiate new Date with this time\r
-       Date febLastDay = new Date(lastDayTimeFeb);\r
-\r
-       // Check for date in this new instance\r
-       return (29 == febLastDay.getDate()) ? true : false;\r
-    }\r
-\r
-    public static boolean isSameDay(Date d1, Date d2) {\r
-       return (getDayInt(d1) == getDayInt(d2));\r
-    }\r
-\r
-    public static boolean isInRange(Date date, Date rangeStart, Date rangeEnd,\r
-           int resolution) {\r
-       Date s;\r
-       Date e;\r
-       if (rangeStart.after(rangeEnd)) {\r
-           s = rangeEnd;\r
-           e = rangeStart;\r
-       } else {\r
-           e = rangeEnd;\r
-           s = rangeStart;\r
-       }\r
-       long start = s.getYear()*10000000000l;\r
-       long end = e.getYear()*10000000000l;\r
-       long target = date.getYear()*10000000000l;\r
-       \r
-       if (resolution == RESOLUTION_YEAR) {\r
-           return (start<=target&&end>=target);\r
-       }\r
-       start += s.getMonth() * 100000000;\r
-       end += e.getMonth() * 100000000;\r
-       target += date.getMonth() * 100000000;\r
-       if (resolution == RESOLUTION_MONTH) {\r
-           return (start<=target&&end>=target);\r
-       }\r
-       start += s.getDate() * 1000000;\r
-       end += e.getDate() * 1000000;\r
-       target += date.getDate() * 1000000;\r
-       if (resolution == RESOLUTION_DAY) {\r
-           return (start<=target&&end>=target);\r
-       }\r
-       start += s.getHours() * 10000;\r
-       end += e.getHours() * 10000;\r
-       target += date.getHours() * 10000;\r
-       if (resolution == RESOLUTION_HOUR) {\r
-           return (start<=target&&end>=target);\r
-       }\r
-       start += s.getMinutes() * 100;\r
-       end += e.getMinutes() * 100;\r
-       target += date.getMinutes() * 100;\r
-       if (resolution == RESOLUTION_MIN) {\r
-           return (start<=target&&end>=target);\r
-       }\r
-       start += s.getSeconds();\r
-       end += e.getSeconds();\r
-       target += date.getSeconds();\r
-       return (start<=target&&end>=target);\r
-\r
-    }\r
-\r
-    private static int getDayInt(Date date) {\r
-       int y = date.getYear();\r
-       int m = date.getMonth();\r
-       int d = date.getDate();\r
-\r
-       return ((y + 1900) * 10000 + m * 100 + d) * 1000000000;\r
-    }\r
+       public static int RESOLUTION_YEAR = 0;\r
+       public static int RESOLUTION_MONTH = 1;\r
+       public static int RESOLUTION_DAY = 2;\r
+       public static int RESOLUTION_HOUR = 3;\r
+       public static int RESOLUTION_MIN = 4;\r
+       public static int RESOLUTION_SEC = 5;\r
+       public static int RESOLUTION_MSEC = 6;\r
+\r
+       private String currentLocale;\r
+\r
+       private static int[] maxDaysInMonth = { 31, 28, 31, 30, 31, 30, 31, 31, 30,\r
+                       31, 30, 31 };\r
+\r
+       /**\r
+        * Creates a new date time service with the application default locale.\r
+        */\r
+       public DateTimeService() {\r
+               currentLocale = LocaleService.getDefaultLocale();\r
+       }\r
+\r
+       /**\r
+        * Creates a new date time service with a given locale.\r
+        \r
+        * @param locale\r
+        *            e.g. fi, en etc.\r
+        * @throws LocaleNotLoadedException\r
+        */\r
+       public DateTimeService(String locale) throws LocaleNotLoadedException {\r
+               setLocale(locale);\r
+       }\r
+\r
+       public void setLocale(String locale) throws LocaleNotLoadedException {\r
+               if (LocaleService.getAvailableLocales().contains(locale))\r
+                       currentLocale = locale;\r
+               else\r
+                       throw new LocaleNotLoadedException(locale);\r
+       }\r
+\r
+       public String getLocale() {\r
+               return currentLocale;\r
+       }\r
+\r
+       public String getMonth(int month) {\r
+               try {\r
+                       return LocaleService.getMonthNames(currentLocale)[month];\r
+               } catch (LocaleNotLoadedException e) {\r
+                       // TODO redirect to console\r
+                       System.out.println(e + ":" + e.getMessage());\r
+               }\r
+               return null;\r
+       }\r
+\r
+       public String getShortMonth(int month) {\r
+               try {\r
+                       return LocaleService.getShortMonthNames(currentLocale)[month];\r
+               } catch (LocaleNotLoadedException e) {\r
+                       // TODO redirect to console\r
+                       System.out.println(e + ":" + e.getMessage());\r
+               }\r
+               return null;\r
+       }\r
+\r
+       public String getDay(int day) {\r
+               try {\r
+                       return LocaleService.getDayNames(currentLocale)[day];\r
+               } catch (LocaleNotLoadedException e) {\r
+                       // TODO redirect to console\r
+                       System.out.println(e + ":" + e.getMessage());\r
+               }\r
+               return null;\r
+       }\r
+\r
+       public String getShortDay(int day) {\r
+               try {\r
+                       return LocaleService.getShortDayNames(currentLocale)[day];\r
+               } catch (LocaleNotLoadedException e) {\r
+                       // TODO redirect to console\r
+                       System.out.println(e + ":" + e.getMessage());\r
+               }\r
+               return null;\r
+       }\r
+\r
+       public int getFirstDayOfWeek() {\r
+               try {\r
+                       return LocaleService.getFirstDayOfWeek(currentLocale);\r
+               } catch (LocaleNotLoadedException e) {\r
+                       // TODO redirect to console\r
+                       System.out.println(e + ":" + e.getMessage());\r
+               }\r
+               return 0;\r
+       }\r
+\r
+       public boolean isTwelveHourClock() {\r
+               try {\r
+                       return LocaleService.isTwelveHourClock(currentLocale);\r
+               } catch (LocaleNotLoadedException e) {\r
+                       // TODO redirect to console\r
+                       System.out.println(e + ":" + e.getMessage());\r
+               }\r
+               return false;\r
+       }\r
+\r
+       public String getClockDelimeter() {\r
+               try {\r
+                       return LocaleService.getClockDelimiter(currentLocale);\r
+               } catch (LocaleNotLoadedException e) {\r
+                       // TODO redirect to console\r
+                       System.out.println(e + ":" + e.getMessage());\r
+               }\r
+               return ":";\r
+       }\r
+\r
+       public String[] getAmPmStrings() {\r
+               try {\r
+                       return LocaleService.getAmPmStrings(currentLocale);\r
+               } catch (LocaleNotLoadedException e) {\r
+                       // TODO redirect to console\r
+                       System.out.println(e + ":" + e.getMessage());\r
+               }\r
+               String[] temp = new String[2];\r
+               temp[0] = "AM";\r
+               temp[1] = "PM";\r
+               return temp;\r
+       }\r
+\r
+       public int getStartWeekDay(Date date) {\r
+               Date dateForFirstOfThisMonth = new Date(date.getYear(),\r
+                               date.getMonth(), 1);\r
+               int firstDay;\r
+               try {\r
+                       firstDay = LocaleService.getFirstDayOfWeek(currentLocale);\r
+               } catch (LocaleNotLoadedException e) {\r
+                       firstDay = 0;\r
+                       // TODO redirect to console\r
+                       System.out.println(e + ":" + e.getMessage());\r
+               }\r
+               int start = dateForFirstOfThisMonth.getDay() - firstDay;\r
+               if (start < 0)\r
+                       start = 6;\r
+               return start;\r
+       }\r
+\r
+       public String getDateFormat() {\r
+               try {\r
+                       return LocaleService.getDateFormat(currentLocale);\r
+               } catch (LocaleNotLoadedException e) {\r
+                       // TODO redirect to console\r
+                       System.out.println(e + ":" + e.getMessage());\r
+               }\r
+               return "M/d/yy";\r
+       }\r
+\r
+       public static int getNumberOfDaysInMonth(Date date) {\r
+               int month = date.getMonth();\r
+               if (month == 1 && true == isLeapYear(date))\r
+                       return 29;\r
+               return maxDaysInMonth[month];\r
+       }\r
+\r
+       public static boolean isLeapYear(Date date) {\r
+               // Instantiate the date for 1st March of that year\r
+               Date firstMarch = new Date(date.getYear(), 2, 1);\r
+\r
+               // Go back 1 day\r
+               long firstMarchTime = firstMarch.getTime();\r
+               long lastDayTimeFeb = firstMarchTime - (24 * 60 * 60 * 1000); // NUM_MILLISECS_A_DAY\r
+\r
+               // Instantiate new Date with this time\r
+               Date febLastDay = new Date(lastDayTimeFeb);\r
+\r
+               // Check for date in this new instance\r
+               return (29 == febLastDay.getDate()) ? true : false;\r
+       }\r
+\r
+       public static boolean isSameDay(Date d1, Date d2) {\r
+               return (getDayInt(d1) == getDayInt(d2));\r
+       }\r
+\r
+       public static boolean isInRange(Date date, Date rangeStart, Date rangeEnd,\r
+                       int resolution) {\r
+               Date s;\r
+               Date e;\r
+               if (rangeStart.after(rangeEnd)) {\r
+                       s = rangeEnd;\r
+                       e = rangeStart;\r
+               } else {\r
+                       e = rangeEnd;\r
+                       s = rangeStart;\r
+               }\r
+               long start = s.getYear() * 10000000000l;\r
+               long end = e.getYear() * 10000000000l;\r
+               long target = date.getYear() * 10000000000l;\r
+\r
+               if (resolution == RESOLUTION_YEAR) {\r
+                       return (start <= target && end >= target);\r
+               }\r
+               start += s.getMonth() * 100000000;\r
+               end += e.getMonth() * 100000000;\r
+               target += date.getMonth() * 100000000;\r
+               if (resolution == RESOLUTION_MONTH) {\r
+                       return (start <= target && end >= target);\r
+               }\r
+               start += s.getDate() * 1000000;\r
+               end += e.getDate() * 1000000;\r
+               target += date.getDate() * 1000000;\r
+               if (resolution == RESOLUTION_DAY) {\r
+                       return (start <= target && end >= target);\r
+               }\r
+               start += s.getHours() * 10000;\r
+               end += e.getHours() * 10000;\r
+               target += date.getHours() * 10000;\r
+               if (resolution == RESOLUTION_HOUR) {\r
+                       return (start <= target && end >= target);\r
+               }\r
+               start += s.getMinutes() * 100;\r
+               end += e.getMinutes() * 100;\r
+               target += date.getMinutes() * 100;\r
+               if (resolution == RESOLUTION_MIN) {\r
+                       return (start <= target && end >= target);\r
+               }\r
+               start += s.getSeconds();\r
+               end += e.getSeconds();\r
+               target += date.getSeconds();\r
+               return (start <= target && end >= target);\r
+\r
+       }\r
+\r
+       private static int getDayInt(Date date) {\r
+               int y = date.getYear();\r
+               int m = date.getMonth();\r
+               int d = date.getDate();\r
+\r
+               return ((y + 1900) * 10000 + m * 100 + d) * 1000000000;\r
+       }\r
 \r
 }\r
index 942448e999cc750c5610eb90c2c60d59e3ea3f95..14502239eaf3a30e4796469ffd81e0469347ba53 100755 (executable)
@@ -10,7 +10,7 @@ import com.google.gwt.user.client.ui.ScrollPanel;
 import com.itmill.toolkit.terminal.gwt.client.ui.IWindow;
 
 public final class DebugConsole extends IWindow implements Console {
-       
+
        private Panel panel;
 
        public DebugConsole() {
@@ -23,14 +23,17 @@ public final class DebugConsole extends IWindow implements Console {
                minimize();
                show();
        }
-       
+
        private void minimize() {
-               // TODO stack to bottom (create window manager of some sort) 
+               // TODO stack to bottom (create window manager of some sort)
                setPixelSize(60, 60);
-               setPopupPosition(Window.getClientWidth() - 80, Window.getClientHeight() - 80);
+               setPopupPosition(Window.getClientWidth() - 80,
+                               Window.getClientHeight() - 80);
        }
 
-       /* (non-Javadoc)
+       /*
+        * (non-Javadoc)
+        * 
         * @see com.itmill.toolkit.terminal.gwt.client.Console#log(java.lang.String)
         */
        public void log(String msg) {
@@ -38,7 +41,9 @@ public final class DebugConsole extends IWindow implements Console {
                System.out.println(msg);
        }
 
-       /* (non-Javadoc)
+       /*
+        * (non-Javadoc)
+        * 
         * @see com.itmill.toolkit.terminal.gwt.client.Console#error(java.lang.String)
         */
        public void error(String msg) {
@@ -46,14 +51,18 @@ public final class DebugConsole extends IWindow implements Console {
                System.out.println(msg);
        }
 
-       /* (non-Javadoc)
+       /*
+        * (non-Javadoc)
+        * 
         * @see com.itmill.toolkit.terminal.gwt.client.Console#printObject(java.lang.Object)
         */
        public void printObject(Object msg) {
                panel.add((new Label(msg.toString())));
        }
-       
-       /* (non-Javadoc)
+
+       /*
+        * (non-Javadoc)
+        * 
         * @see com.itmill.toolkit.terminal.gwt.client.Console#dirUIDL(com.itmill.toolkit.terminal.gwt.client.UIDL)
         */
        public void dirUIDL(UIDL u) {
@@ -63,6 +72,5 @@ public final class DebugConsole extends IWindow implements Console {
        public void setSize(Event event, boolean updateVariables) {
                super.setSize(event, false);
        }
-       
-       
+
 }
index 6112f98884f4e280484104ea3e0c2cee35468a18..2be55b48346f297077f4a7e0c214eb7a7dd99f20 100644 (file)
@@ -40,223 +40,223 @@ import com.itmill.toolkit.terminal.gwt.client.ui.IWindow;
 
 public class DefaultWidgetSet implements WidgetSet {
 
-    protected ApplicationConnection appConn;
+       protected ApplicationConnection appConn;
 
-    /**
-     * This is the entry point method.
-     */
-    public void onModuleLoad() {
-       appConn = new ApplicationConnection(this);
-    }
+       /**
+        * This is the entry point method.
+        */
+       public void onModuleLoad() {
+               appConn = new ApplicationConnection(this);
+       }
 
-    public Widget createWidget(UIDL uidl) {
+       public Widget createWidget(UIDL uidl) {
 
-       String className = resolveWidgetTypeName(uidl);
-       if ("com.itmill.toolkit.terminal.gwt.client.ui.ICheckBox"
-               .equals(className)) {
-           return new ICheckBox();
-       } else if ("com.itmill.toolkit.terminal.gwt.client.ui.IButton"
-               .equals(className)) {
-           return new IButton();
-       } else if ("com.itmill.toolkit.terminal.gwt.client.ui.IWindow"
-               .equals(className)) {
-           return new IWindow();
-       } else if ("com.itmill.toolkit.terminal.gwt.client.ui.IOrderedLayoutVertical"
-               .equals(className)) {
-           return new IOrderedLayoutVertical();
-       } else if ("com.itmill.toolkit.terminal.gwt.client.ui.IOrderedLayoutHorizontal"
-               .equals(className)) {
-           return new IOrderedLayoutHorizontal();
-       } else if ("com.itmill.toolkit.terminal.gwt.client.ui.ILabel"
-               .equals(className)) {
-           return new ILabel();
-       } else if ("com.itmill.toolkit.terminal.gwt.client.ui.ILink"
-               .equals(className)) {
-           return new ILink();
-       } else if ("com.itmill.toolkit.terminal.gwt.client.ui.IGridLayout"
-               .equals(className)) {
-           return new IGridLayout();
-       } else if ("com.itmill.toolkit.terminal.gwt.client.ui.ITree"
-               .equals(className)) {
-           return new ITree();
-       } else if ("com.itmill.toolkit.terminal.gwt.client.ui.IOptionGroup"
-               .equals(className)) {
-           return new IOptionGroup();
-       } else if ("com.itmill.toolkit.terminal.gwt.client.ui.ITwinColSelect"
-               .equals(className)) {
-           return new ITwinColSelect();
-       } else if ("com.itmill.toolkit.terminal.gwt.client.ui.ISelect"
-               .equals(className)) {
-           return new ISelect();
-       } else if ("com.itmill.toolkit.terminal.gwt.client.ui.IPanel"
-               .equals(className)) {
-           return new IPanel();
-       } else if ("com.itmill.toolkit.terminal.gwt.client.ui.ITabsheet"
-               .equals(className)) {
-           return new ITabsheet();
-       } else if ("com.itmill.toolkit.terminal.gwt.client.ui.IEmbedded"
-               .equals(className)) {
-           return new IEmbedded();
-       } else if ("com.itmill.toolkit.terminal.gwt.client.ui.ICustomLayout"
-               .equals(className)) {
-           return new ICustomLayout();
-       } else if ("com.itmill.toolkit.terminal.gwt.client.ui.ITextArea"
-               .equals(className)) {
-           return new ITextArea();
-       } else if ("com.itmill.toolkit.terminal.gwt.client.ui.IPasswordField"
-               .equals(className)) {
-           return new IPasswordField();
-       } else if ("com.itmill.toolkit.terminal.gwt.client.ui.ITextField"
-               .equals(className)) {
-           return new ITextField();
-       } else if ("com.itmill.toolkit.terminal.gwt.client.ui.ITablePaging"
-               .equals(className)) {
-           return new ITablePaging();
-       } else if ("com.itmill.toolkit.terminal.gwt.client.ui.IScrollTable"
-               .equals(className)) {
-           return new IScrollTable();
-       } else if ("com.itmill.toolkit.terminal.gwt.client.ui.IDateFieldCalendar"
-               .equals(className)) {
-           return new IDateFieldCalendar();
-       } else if ("com.itmill.toolkit.terminal.gwt.client.ui.ICalendar"
-               .equals(className)) {
-           return new ICalendar();
-       } else if ("com.itmill.toolkit.terminal.gwt.client.ui.ITextualDate"
-               .equals(className)) {
-           return new ITextualDate();
-       } else if ("com.itmill.toolkit.terminal.gwt.client.ui.IPopupCalendar"
-               .equals(className)) {
-           return new IPopupCalendar();
-       } else if ("com.itmill.toolkit.terminal.gwt.client.ui.ISlider"
-               .equals(className)) {
-           return new ISlider();
-       } else if ("com.itmill.toolkit.terminal.gwt.client.ui.IForm"
-               .equals(className)) {
-           return new IForm();
-       } else if ("com.itmill.toolkit.terminal.gwt.client.ui.IFormLayout"
-               .equals(className)) {
-           return new IFormLayout();
-       } else if ("com.itmill.toolkit.terminal.gwt.client.ui.IUpload"
-               .equals(className)) {
-           return new IUpload();
-       } else if ("com.itmill.toolkit.terminal.gwt.client.ui.ISplitPanelHorizontal"
-               .equals(className)) {
-           return new ISplitPanelHorizontal();
-       } else if ("com.itmill.toolkit.terminal.gwt.client.ui.ISplitPanelVertical"
-               .equals(className)) {
-           return new ISplitPanelVertical();
-       } else if ("com.itmill.toolkit.terminal.gwt.client.ui.IFilterSelect"
-               .equals(className)) {
-           return new IFilterSelect();
-       } else if ("com.itmill.toolkit.terminal.gwt.client.ui.IProgressIndicator"
-               .equals(className)) {
-           return new IProgressIndicator();
-       } else if ("com.itmill.toolkit.terminal.gwt.client.ui.IExpandLayout"
-               .equals(className)) {
-           return new IExpandLayout();
-       }
-       
-       return new IUnknownComponent();
+               String className = resolveWidgetTypeName(uidl);
+               if ("com.itmill.toolkit.terminal.gwt.client.ui.ICheckBox"
+                               .equals(className)) {
+                       return new ICheckBox();
+               } else if ("com.itmill.toolkit.terminal.gwt.client.ui.IButton"
+                               .equals(className)) {
+                       return new IButton();
+               } else if ("com.itmill.toolkit.terminal.gwt.client.ui.IWindow"
+                               .equals(className)) {
+                       return new IWindow();
+               } else if ("com.itmill.toolkit.terminal.gwt.client.ui.IOrderedLayoutVertical"
+                               .equals(className)) {
+                       return new IOrderedLayoutVertical();
+               } else if ("com.itmill.toolkit.terminal.gwt.client.ui.IOrderedLayoutHorizontal"
+                               .equals(className)) {
+                       return new IOrderedLayoutHorizontal();
+               } else if ("com.itmill.toolkit.terminal.gwt.client.ui.ILabel"
+                               .equals(className)) {
+                       return new ILabel();
+               } else if ("com.itmill.toolkit.terminal.gwt.client.ui.ILink"
+                               .equals(className)) {
+                       return new ILink();
+               } else if ("com.itmill.toolkit.terminal.gwt.client.ui.IGridLayout"
+                               .equals(className)) {
+                       return new IGridLayout();
+               } else if ("com.itmill.toolkit.terminal.gwt.client.ui.ITree"
+                               .equals(className)) {
+                       return new ITree();
+               } else if ("com.itmill.toolkit.terminal.gwt.client.ui.IOptionGroup"
+                               .equals(className)) {
+                       return new IOptionGroup();
+               } else if ("com.itmill.toolkit.terminal.gwt.client.ui.ITwinColSelect"
+                               .equals(className)) {
+                       return new ITwinColSelect();
+               } else if ("com.itmill.toolkit.terminal.gwt.client.ui.ISelect"
+                               .equals(className)) {
+                       return new ISelect();
+               } else if ("com.itmill.toolkit.terminal.gwt.client.ui.IPanel"
+                               .equals(className)) {
+                       return new IPanel();
+               } else if ("com.itmill.toolkit.terminal.gwt.client.ui.ITabsheet"
+                               .equals(className)) {
+                       return new ITabsheet();
+               } else if ("com.itmill.toolkit.terminal.gwt.client.ui.IEmbedded"
+                               .equals(className)) {
+                       return new IEmbedded();
+               } else if ("com.itmill.toolkit.terminal.gwt.client.ui.ICustomLayout"
+                               .equals(className)) {
+                       return new ICustomLayout();
+               } else if ("com.itmill.toolkit.terminal.gwt.client.ui.ITextArea"
+                               .equals(className)) {
+                       return new ITextArea();
+               } else if ("com.itmill.toolkit.terminal.gwt.client.ui.IPasswordField"
+                               .equals(className)) {
+                       return new IPasswordField();
+               } else if ("com.itmill.toolkit.terminal.gwt.client.ui.ITextField"
+                               .equals(className)) {
+                       return new ITextField();
+               } else if ("com.itmill.toolkit.terminal.gwt.client.ui.ITablePaging"
+                               .equals(className)) {
+                       return new ITablePaging();
+               } else if ("com.itmill.toolkit.terminal.gwt.client.ui.IScrollTable"
+                               .equals(className)) {
+                       return new IScrollTable();
+               } else if ("com.itmill.toolkit.terminal.gwt.client.ui.IDateFieldCalendar"
+                               .equals(className)) {
+                       return new IDateFieldCalendar();
+               } else if ("com.itmill.toolkit.terminal.gwt.client.ui.ICalendar"
+                               .equals(className)) {
+                       return new ICalendar();
+               } else if ("com.itmill.toolkit.terminal.gwt.client.ui.ITextualDate"
+                               .equals(className)) {
+                       return new ITextualDate();
+               } else if ("com.itmill.toolkit.terminal.gwt.client.ui.IPopupCalendar"
+                               .equals(className)) {
+                       return new IPopupCalendar();
+               } else if ("com.itmill.toolkit.terminal.gwt.client.ui.ISlider"
+                               .equals(className)) {
+                       return new ISlider();
+               } else if ("com.itmill.toolkit.terminal.gwt.client.ui.IForm"
+                               .equals(className)) {
+                       return new IForm();
+               } else if ("com.itmill.toolkit.terminal.gwt.client.ui.IFormLayout"
+                               .equals(className)) {
+                       return new IFormLayout();
+               } else if ("com.itmill.toolkit.terminal.gwt.client.ui.IUpload"
+                               .equals(className)) {
+                       return new IUpload();
+               } else if ("com.itmill.toolkit.terminal.gwt.client.ui.ISplitPanelHorizontal"
+                               .equals(className)) {
+                       return new ISplitPanelHorizontal();
+               } else if ("com.itmill.toolkit.terminal.gwt.client.ui.ISplitPanelVertical"
+                               .equals(className)) {
+                       return new ISplitPanelVertical();
+               } else if ("com.itmill.toolkit.terminal.gwt.client.ui.IFilterSelect"
+                               .equals(className)) {
+                       return new IFilterSelect();
+               } else if ("com.itmill.toolkit.terminal.gwt.client.ui.IProgressIndicator"
+                               .equals(className)) {
+                       return new IProgressIndicator();
+               } else if ("com.itmill.toolkit.terminal.gwt.client.ui.IExpandLayout"
+                               .equals(className)) {
+                       return new IExpandLayout();
+               }
 
-       /*
-        * TODO: Class based impl, use when GWT supports return
-        * (Widget)GWT.create(resolveWidgetClass(uidl));
-        */
-    }
+               return new IUnknownComponent();
 
-    protected String resolveWidgetTypeName(UIDL uidl) {
+               /*
+                * TODO: Class based impl, use when GWT supports return
+                * (Widget)GWT.create(resolveWidgetClass(uidl));
+                */
+       }
 
-       String tag = uidl.getTag();
-       if ("button".equals(tag)) {
-           if ("switch".equals(uidl.getStringAttribute("type"))) {
-               return "com.itmill.toolkit.terminal.gwt.client.ui.ICheckBox";
-           } else {
-               return "com.itmill.toolkit.terminal.gwt.client.ui.IButton";
-           }
-       } else if ("window".equals(tag)) {
-           return "com.itmill.toolkit.terminal.gwt.client.ui.IWindow";
-       } else if ("orderedlayout".equals(tag)) {
-           if ("horizontal".equals(uidl.getStringAttribute("orientation"))) {
-               return "com.itmill.toolkit.terminal.gwt.client.ui.IOrderedLayoutHorizontal";
-           } else {
-               return "com.itmill.toolkit.terminal.gwt.client.ui.IOrderedLayoutVertical";
-           }
-       } else if ("label".equals(tag)) {
-           return "com.itmill.toolkit.terminal.gwt.client.ui.ILabel";
-       } else if ("link".equals(tag)) {
-           return "com.itmill.toolkit.terminal.gwt.client.ui.ILink";
-       } else if ("gridlayout".equals(tag)) {
-           return "com.itmill.toolkit.terminal.gwt.client.ui.IGridLayout";
-       } else if ("tree".equals(tag)) {
-           return "com.itmill.toolkit.terminal.gwt.client.ui.ITree";
-       } else if ("select".equals(tag)) {
-           if ("optiongroup".equals(uidl.getStringAttribute("style"))) {
-               return "com.itmill.toolkit.terminal.gwt.client.ui.IOptionGroup";
-           } else if ("twincol".equals(uidl.getStringAttribute("style"))) {
-               return "com.itmill.toolkit.terminal.gwt.client.ui.ITwinColSelect";
-           } else {
-               return "com.itmill.toolkit.terminal.gwt.client.ui.IFilterSelect";
-           }
-       } else if ("panel".equals(tag)) {
-           return "com.itmill.toolkit.terminal.gwt.client.ui.IPanel";
-       } else if ("tabsheet".equals(tag)) {
-           return "com.itmill.toolkit.terminal.gwt.client.ui.ITabsheet";
-       } else if ("embedded".equals(tag)) {
-           return "com.itmill.toolkit.terminal.gwt.client.ui.IEmbedded";
-       } else if ("customlayout".equals(tag)) {
-           return "com.itmill.toolkit.terminal.gwt.client.ui.ICustomLayout";
-       } else if ("textfield".equals(tag)) {
-           if (uidl.hasAttribute("multiline")) {
-               return "com.itmill.toolkit.terminal.gwt.client.ui.ITextArea";
-           } else if (uidl.getBooleanAttribute("secret")) {
-               return "com.itmill.toolkit.terminal.gwt.client.ui.IPasswordField";
-           } else {
-               return "com.itmill.toolkit.terminal.gwt.client.ui.ITextField";
-           }
-       } else if ("table".equals(tag)) {
-               return "com.itmill.toolkit.terminal.gwt.client.ui.IScrollTable";
-       } else if("pagingtable".equals(tag)) {
-               return "com.itmill.toolkit.terminal.gwt.client.ui.ITablePaging";
-       } else if ("datefield".equals(tag)) {
-           if (uidl.hasAttribute("style")) {
-               if ("calendar".equals(uidl.getStringAttribute("style"))) {
-                   return "com.itmill.toolkit.terminal.gwt.client.ui.ICalendar";
-               } else if ("text".equals(uidl.getStringAttribute("style"))) {
-                   return "com.itmill.toolkit.terminal.gwt.client.ui.ITextualDate";
+       protected String resolveWidgetTypeName(UIDL uidl) {
+
+               String tag = uidl.getTag();
+               if ("button".equals(tag)) {
+                       if ("switch".equals(uidl.getStringAttribute("type"))) {
+                               return "com.itmill.toolkit.terminal.gwt.client.ui.ICheckBox";
+                       } else {
+                               return "com.itmill.toolkit.terminal.gwt.client.ui.IButton";
+                       }
+               } else if ("window".equals(tag)) {
+                       return "com.itmill.toolkit.terminal.gwt.client.ui.IWindow";
+               } else if ("orderedlayout".equals(tag)) {
+                       if ("horizontal".equals(uidl.getStringAttribute("orientation"))) {
+                               return "com.itmill.toolkit.terminal.gwt.client.ui.IOrderedLayoutHorizontal";
+                       } else {
+                               return "com.itmill.toolkit.terminal.gwt.client.ui.IOrderedLayoutVertical";
+                       }
+               } else if ("label".equals(tag)) {
+                       return "com.itmill.toolkit.terminal.gwt.client.ui.ILabel";
+               } else if ("link".equals(tag)) {
+                       return "com.itmill.toolkit.terminal.gwt.client.ui.ILink";
+               } else if ("gridlayout".equals(tag)) {
+                       return "com.itmill.toolkit.terminal.gwt.client.ui.IGridLayout";
+               } else if ("tree".equals(tag)) {
+                       return "com.itmill.toolkit.terminal.gwt.client.ui.ITree";
+               } else if ("select".equals(tag)) {
+                       if ("optiongroup".equals(uidl.getStringAttribute("style"))) {
+                               return "com.itmill.toolkit.terminal.gwt.client.ui.IOptionGroup";
+                       } else if ("twincol".equals(uidl.getStringAttribute("style"))) {
+                               return "com.itmill.toolkit.terminal.gwt.client.ui.ITwinColSelect";
+                       } else {
+                               return "com.itmill.toolkit.terminal.gwt.client.ui.IFilterSelect";
+                       }
+               } else if ("panel".equals(tag)) {
+                       return "com.itmill.toolkit.terminal.gwt.client.ui.IPanel";
+               } else if ("tabsheet".equals(tag)) {
+                       return "com.itmill.toolkit.terminal.gwt.client.ui.ITabsheet";
+               } else if ("embedded".equals(tag)) {
+                       return "com.itmill.toolkit.terminal.gwt.client.ui.IEmbedded";
+               } else if ("customlayout".equals(tag)) {
+                       return "com.itmill.toolkit.terminal.gwt.client.ui.ICustomLayout";
+               } else if ("textfield".equals(tag)) {
+                       if (uidl.hasAttribute("multiline")) {
+                               return "com.itmill.toolkit.terminal.gwt.client.ui.ITextArea";
+                       } else if (uidl.getBooleanAttribute("secret")) {
+                               return "com.itmill.toolkit.terminal.gwt.client.ui.IPasswordField";
+                       } else {
+                               return "com.itmill.toolkit.terminal.gwt.client.ui.ITextField";
+                       }
+               } else if ("table".equals(tag)) {
+                       return "com.itmill.toolkit.terminal.gwt.client.ui.IScrollTable";
+               } else if ("pagingtable".equals(tag)) {
+                       return "com.itmill.toolkit.terminal.gwt.client.ui.ITablePaging";
+               } else if ("datefield".equals(tag)) {
+                       if (uidl.hasAttribute("style")) {
+                               if ("calendar".equals(uidl.getStringAttribute("style"))) {
+                                       return "com.itmill.toolkit.terminal.gwt.client.ui.ICalendar";
+                               } else if ("text".equals(uidl.getStringAttribute("style"))) {
+                                       return "com.itmill.toolkit.terminal.gwt.client.ui.ITextualDate";
+                               }
+                       } else {
+                               return "com.itmill.toolkit.terminal.gwt.client.ui.IPopupCalendar";
+                       }
+               } else if ("calendarfield".equals(tag)) {
+                       return "com.itmill.toolkit.terminal.gwt.client.ui.ICalendar";
+               } else if ("slider".equals(tag)) {
+                       return "com.itmill.toolkit.terminal.gwt.client.ui.ISlider";
+               } else if ("form".equals(tag)) {
+                       return "com.itmill.toolkit.terminal.gwt.client.ui.IForm";
+               } else if ("formlayout".equals(tag)) {
+                       return "com.itmill.toolkit.terminal.gwt.client.ui.IFormLayout";
+               } else if ("upload".equals(tag)) {
+                       return "com.itmill.toolkit.terminal.gwt.client.ui.IUpload";
+               } else if ("hsplitpanel".equals(tag)) {
+                       return "com.itmill.toolkit.terminal.gwt.client.ui.ISplitPanelHorizontal";
+               } else if ("vsplitpanel".equals(tag)) {
+                       return "com.itmill.toolkit.terminal.gwt.client.ui.ISplitPanelVertical";
+               } else if ("progressindicator".equals(tag)) {
+                       return "com.itmill.toolkit.terminal.gwt.client.ui.IProgressIndicator";
+               } else if ("expandlayout".equals(tag)) {
+                       return "com.itmill.toolkit.terminal.gwt.client.ui.IExpandLayout";
                }
-           } else {
-               return "com.itmill.toolkit.terminal.gwt.client.ui.IPopupCalendar";
-           }
-       } else if ("calendarfield".equals(tag)) {
-           return "com.itmill.toolkit.terminal.gwt.client.ui.ICalendar";
-       } else if ("slider".equals(tag)) {
-           return "com.itmill.toolkit.terminal.gwt.client.ui.ISlider";
-       } else if ("form".equals(tag)) {
-           return "com.itmill.toolkit.terminal.gwt.client.ui.IForm";
-       } else if ("formlayout".equals(tag)) {
-           return "com.itmill.toolkit.terminal.gwt.client.ui.IFormLayout";
-       } else if ("upload".equals(tag)) {
-           return "com.itmill.toolkit.terminal.gwt.client.ui.IUpload";
-       } else if ("hsplitpanel".equals(tag)) {
-           return "com.itmill.toolkit.terminal.gwt.client.ui.ISplitPanelHorizontal";
-       } else if ("vsplitpanel".equals(tag)) {
-           return "com.itmill.toolkit.terminal.gwt.client.ui.ISplitPanelVertical";
-       } else if ("progressindicator".equals(tag)) {
-           return "com.itmill.toolkit.terminal.gwt.client.ui.IProgressIndicator";
-       } else if ("expandlayout".equals(tag)) {
-           return "com.itmill.toolkit.terminal.gwt.client.ui.IExpandLayout";
-       }
 
-       return "com.itmill.toolkit.terminal.gwt.client.ui.IUnknownComponent";
+               return "com.itmill.toolkit.terminal.gwt.client.ui.IUnknownComponent";
 
-       /*
-        * TODO: use class based impl when GWT supports it
-        */
-    }
+               /*
+                * TODO: use class based impl when GWT supports it
+                */
+       }
 
-    public boolean isCorrectImplementation(Widget currentWidget, UIDL uidl) {
-       return GWT.getTypeName(currentWidget).equals(
-               resolveWidgetTypeName(uidl));
-    }
+       public boolean isCorrectImplementation(Widget currentWidget, UIDL uidl) {
+               return GWT.getTypeName(currentWidget).equals(
+                               resolveWidgetTypeName(uidl));
+       }
 
 }
index 2426fe858b067614da6257bfc81fd45ae5663bd9..fd46951fc1e1d7e36dc327913a8a5c3d6d4c812c 100644 (file)
@@ -7,6 +7,7 @@ import com.google.gwt.user.client.ui.HTML;
 
 public class ErrorMessage extends FlowPanel {
        public static final String CLASSNAME = "i-error";
+
        public ErrorMessage() {
                super();
                setStyleName(CLASSNAME);
@@ -14,7 +15,7 @@ public class ErrorMessage extends FlowPanel {
 
        public void updateFromUIDL(UIDL uidl) {
                clear();
-               for(Iterator it = uidl.getChildIterator();it.hasNext();) {
+               for (Iterator it = uidl.getChildIterator(); it.hasNext();) {
                        Object child = it.next();
                        if (child instanceof String) {
                                String errorMessage = (String) child;
index af962b9b7478ae406f37fe85b7a6110048967f16..1f1e805d0adaa7c782a3161afa5676d3f146e846 100644 (file)
@@ -1,7 +1,7 @@
 package com.itmill.toolkit.terminal.gwt.client;\r
 \r
 public class LocaleNotLoadedException extends Exception {\r
-       \r
+\r
        /**\r
         * Serial generated by Eclipse.\r
         */\r
index f5d9b1f344935e3300fb07b233b3857712a1aa0c..31fe42d16750c12598e6e5d6eabfd34eae869f6e 100644 (file)
@@ -11,153 +11,171 @@ import com.google.gwt.json.client.JSONObject;
 import com.google.gwt.json.client.JSONString;\r
 \r
 /**\r
- * Date / time etc. localisation service for all widgets.\r
- * Caches all loaded locales as JSONObjects.\r
+ * Date / time etc. localisation service for all widgets. Caches all loaded\r
+ * locales as JSONObjects.\r
  * \r
  * @author IT Mill Ltd.\r
- *\r
+ * \r
  */\r
 public class LocaleService {\r
-       \r
+\r
        private static Map cache = new HashMap();\r
        private static String defaultLocale;\r
 \r
        public static void addLocale(JSONObject json) {\r
-               String key = ((JSONString)json.get("name")).stringValue();\r
-               if(cache.containsKey(key))\r
+               String key = ((JSONString) json.get("name")).stringValue();\r
+               if (cache.containsKey(key))\r
                        cache.remove(key);\r
                cache.put(key, json);\r
-               if(cache.size()==1)\r
+               if (cache.size() == 1)\r
                        setDefaultLocale(key);\r
        }\r
 \r
        public static void setDefaultLocale(String locale) {\r
                defaultLocale = locale;\r
        }\r
-       \r
+\r
        public static String getDefaultLocale() {\r
                return defaultLocale;\r
        }\r
-       \r
+\r
        public static Set getAvailableLocales() {\r
                return cache.keySet();\r
        }\r
-       \r
-       public static String[] getMonthNames(String locale) throws LocaleNotLoadedException {\r
-               if(cache.containsKey(locale)) {\r
+\r
+       public static String[] getMonthNames(String locale)\r
+                       throws LocaleNotLoadedException {\r
+               if (cache.containsKey(locale)) {\r
                        JSONObject l = (JSONObject) cache.get(locale);\r
                        JSONArray mn = (JSONArray) l.get("mn");\r
                        String[] temp = new String[12];\r
-                       temp[0] = ((JSONString)mn.get(0)).stringValue();\r
-                       temp[1] = ((JSONString)mn.get(1)).stringValue();\r
-                       temp[2] = ((JSONString)mn.get(2)).stringValue();\r
-                       temp[3] = ((JSONString)mn.get(3)).stringValue();\r
-                       temp[4] = ((JSONString)mn.get(4)).stringValue();\r
-                       temp[5] = ((JSONString)mn.get(5)).stringValue();\r
-                       temp[6] = ((JSONString)mn.get(6)).stringValue();\r
-                       temp[7] = ((JSONString)mn.get(7)).stringValue();\r
-                       temp[8] = ((JSONString)mn.get(8)).stringValue();\r
-                       temp[9] = ((JSONString)mn.get(9)).stringValue();\r
-                       temp[10] = ((JSONString)mn.get(10)).stringValue();\r
-                       temp[11] = ((JSONString)mn.get(11)).stringValue();                      \r
+                       temp[0] = ((JSONString) mn.get(0)).stringValue();\r
+                       temp[1] = ((JSONString) mn.get(1)).stringValue();\r
+                       temp[2] = ((JSONString) mn.get(2)).stringValue();\r
+                       temp[3] = ((JSONString) mn.get(3)).stringValue();\r
+                       temp[4] = ((JSONString) mn.get(4)).stringValue();\r
+                       temp[5] = ((JSONString) mn.get(5)).stringValue();\r
+                       temp[6] = ((JSONString) mn.get(6)).stringValue();\r
+                       temp[7] = ((JSONString) mn.get(7)).stringValue();\r
+                       temp[8] = ((JSONString) mn.get(8)).stringValue();\r
+                       temp[9] = ((JSONString) mn.get(9)).stringValue();\r
+                       temp[10] = ((JSONString) mn.get(10)).stringValue();\r
+                       temp[11] = ((JSONString) mn.get(11)).stringValue();\r
                        return temp;\r
-               } else throw new LocaleNotLoadedException(locale);\r
+               } else\r
+                       throw new LocaleNotLoadedException(locale);\r
        }\r
-       \r
-       public static String[] getShortMonthNames(String locale) throws LocaleNotLoadedException {\r
-               if(cache.containsKey(locale)) {\r
+\r
+       public static String[] getShortMonthNames(String locale)\r
+                       throws LocaleNotLoadedException {\r
+               if (cache.containsKey(locale)) {\r
                        JSONObject l = (JSONObject) cache.get(locale);\r
                        JSONArray smn = (JSONArray) l.get("smn");\r
                        String[] temp = new String[12];\r
-                       temp[0] = ((JSONString)smn.get(0)).stringValue();\r
-                       temp[1] = ((JSONString)smn.get(1)).stringValue();\r
-                       temp[2] = ((JSONString)smn.get(2)).stringValue();\r
-                       temp[3] = ((JSONString)smn.get(3)).stringValue();\r
-                       temp[4] = ((JSONString)smn.get(4)).stringValue();\r
-                       temp[5] = ((JSONString)smn.get(5)).stringValue();\r
-                       temp[6] = ((JSONString)smn.get(6)).stringValue();\r
-                       temp[7] = ((JSONString)smn.get(7)).stringValue();\r
-                       temp[8] = ((JSONString)smn.get(8)).stringValue();\r
-                       temp[9] = ((JSONString)smn.get(9)).stringValue();\r
-                       temp[10] = ((JSONString)smn.get(10)).stringValue();\r
-                       temp[11] = ((JSONString)smn.get(11)).stringValue();     \r
+                       temp[0] = ((JSONString) smn.get(0)).stringValue();\r
+                       temp[1] = ((JSONString) smn.get(1)).stringValue();\r
+                       temp[2] = ((JSONString) smn.get(2)).stringValue();\r
+                       temp[3] = ((JSONString) smn.get(3)).stringValue();\r
+                       temp[4] = ((JSONString) smn.get(4)).stringValue();\r
+                       temp[5] = ((JSONString) smn.get(5)).stringValue();\r
+                       temp[6] = ((JSONString) smn.get(6)).stringValue();\r
+                       temp[7] = ((JSONString) smn.get(7)).stringValue();\r
+                       temp[8] = ((JSONString) smn.get(8)).stringValue();\r
+                       temp[9] = ((JSONString) smn.get(9)).stringValue();\r
+                       temp[10] = ((JSONString) smn.get(10)).stringValue();\r
+                       temp[11] = ((JSONString) smn.get(11)).stringValue();\r
                        return temp;\r
-               } else throw new LocaleNotLoadedException(locale);\r
+               } else\r
+                       throw new LocaleNotLoadedException(locale);\r
        }\r
-       \r
-       public static String[] getDayNames(String locale) throws LocaleNotLoadedException{\r
-               if(cache.containsKey(locale)) {\r
+\r
+       public static String[] getDayNames(String locale)\r
+                       throws LocaleNotLoadedException {\r
+               if (cache.containsKey(locale)) {\r
                        JSONObject l = (JSONObject) cache.get(locale);\r
                        JSONArray dn = (JSONArray) l.get("dn");\r
                        String[] temp = new String[7];\r
-                       temp[0] = ((JSONString)dn.get(0)).stringValue();\r
-                       temp[1] = ((JSONString)dn.get(1)).stringValue();\r
-                       temp[2] = ((JSONString)dn.get(2)).stringValue();\r
-                       temp[3] = ((JSONString)dn.get(3)).stringValue();\r
-                       temp[4] = ((JSONString)dn.get(4)).stringValue();\r
-                       temp[5] = ((JSONString)dn.get(5)).stringValue();\r
-                       temp[6] = ((JSONString)dn.get(6)).stringValue();        \r
+                       temp[0] = ((JSONString) dn.get(0)).stringValue();\r
+                       temp[1] = ((JSONString) dn.get(1)).stringValue();\r
+                       temp[2] = ((JSONString) dn.get(2)).stringValue();\r
+                       temp[3] = ((JSONString) dn.get(3)).stringValue();\r
+                       temp[4] = ((JSONString) dn.get(4)).stringValue();\r
+                       temp[5] = ((JSONString) dn.get(5)).stringValue();\r
+                       temp[6] = ((JSONString) dn.get(6)).stringValue();\r
                        return temp;\r
-               } else throw new LocaleNotLoadedException(locale);\r
+               } else\r
+                       throw new LocaleNotLoadedException(locale);\r
        }\r
-       \r
-       public static String[] getShortDayNames(String locale) throws LocaleNotLoadedException {\r
-               if(cache.containsKey(locale)) {\r
+\r
+       public static String[] getShortDayNames(String locale)\r
+                       throws LocaleNotLoadedException {\r
+               if (cache.containsKey(locale)) {\r
                        JSONObject l = (JSONObject) cache.get(locale);\r
                        JSONArray sdn = (JSONArray) l.get("sdn");\r
                        String[] temp = new String[7];\r
-                       temp[0] = ((JSONString)sdn.get(0)).stringValue();\r
-                       temp[1] = ((JSONString)sdn.get(1)).stringValue();\r
-                       temp[2] = ((JSONString)sdn.get(2)).stringValue();\r
-                       temp[3] = ((JSONString)sdn.get(3)).stringValue();\r
-                       temp[4] = ((JSONString)sdn.get(4)).stringValue();\r
-                       temp[5] = ((JSONString)sdn.get(5)).stringValue();\r
-                       temp[6] = ((JSONString)sdn.get(6)).stringValue();\r
+                       temp[0] = ((JSONString) sdn.get(0)).stringValue();\r
+                       temp[1] = ((JSONString) sdn.get(1)).stringValue();\r
+                       temp[2] = ((JSONString) sdn.get(2)).stringValue();\r
+                       temp[3] = ((JSONString) sdn.get(3)).stringValue();\r
+                       temp[4] = ((JSONString) sdn.get(4)).stringValue();\r
+                       temp[5] = ((JSONString) sdn.get(5)).stringValue();\r
+                       temp[6] = ((JSONString) sdn.get(6)).stringValue();\r
                        return temp;\r
-               } else throw new LocaleNotLoadedException(locale);\r
+               } else\r
+                       throw new LocaleNotLoadedException(locale);\r
        }\r
-       \r
-       public static int getFirstDayOfWeek(String locale) throws LocaleNotLoadedException {\r
-               if(cache.containsKey(locale)) {\r
+\r
+       public static int getFirstDayOfWeek(String locale)\r
+                       throws LocaleNotLoadedException {\r
+               if (cache.containsKey(locale)) {\r
                        JSONObject l = (JSONObject) cache.get(locale);\r
                        JSONNumber fdow = (JSONNumber) l.get("fdow");\r
                        return (int) fdow.getValue();\r
-               } else throw new LocaleNotLoadedException(locale);\r
+               } else\r
+                       throw new LocaleNotLoadedException(locale);\r
        }\r
-       \r
-       public static String getDateFormat(String locale) throws LocaleNotLoadedException {\r
-               if(cache.containsKey(locale)) {\r
+\r
+       public static String getDateFormat(String locale)\r
+                       throws LocaleNotLoadedException {\r
+               if (cache.containsKey(locale)) {\r
                        JSONObject l = (JSONObject) cache.get(locale);\r
                        JSONString df = (JSONString) l.get("df");\r
                        return df.stringValue();\r
-               } else throw new LocaleNotLoadedException(locale);\r
+               } else\r
+                       throw new LocaleNotLoadedException(locale);\r
        }\r
-       \r
-       public static boolean isTwelveHourClock(String locale) throws LocaleNotLoadedException {\r
-               if(cache.containsKey(locale)) {\r
+\r
+       public static boolean isTwelveHourClock(String locale)\r
+                       throws LocaleNotLoadedException {\r
+               if (cache.containsKey(locale)) {\r
                        JSONObject l = (JSONObject) cache.get(locale);\r
                        JSONBoolean thc = (JSONBoolean) l.get("thc");\r
                        return thc.booleanValue();\r
-               } else throw new LocaleNotLoadedException(locale);\r
+               } else\r
+                       throw new LocaleNotLoadedException(locale);\r
        }\r
-       \r
-       public static String getClockDelimiter(String locale) throws LocaleNotLoadedException {\r
-               if(cache.containsKey(locale)) {\r
+\r
+       public static String getClockDelimiter(String locale)\r
+                       throws LocaleNotLoadedException {\r
+               if (cache.containsKey(locale)) {\r
                        JSONObject l = (JSONObject) cache.get(locale);\r
                        JSONString hmd = (JSONString) l.get("hmd");\r
                        return hmd.stringValue();\r
-               } else throw new LocaleNotLoadedException(locale);\r
+               } else\r
+                       throw new LocaleNotLoadedException(locale);\r
        }\r
-       \r
-       public static String[] getAmPmStrings(String locale) throws LocaleNotLoadedException {\r
-               if(cache.containsKey(locale)) {\r
+\r
+       public static String[] getAmPmStrings(String locale)\r
+                       throws LocaleNotLoadedException {\r
+               if (cache.containsKey(locale)) {\r
                        JSONObject l = (JSONObject) cache.get(locale);\r
                        JSONArray ampm = (JSONArray) l.get("ampm");\r
                        String[] temp = new String[2];\r
-                       temp[0] = ((JSONString)ampm.get(0)).stringValue();\r
-                       temp[1] = ((JSONString)ampm.get(1)).stringValue();\r
+                       temp[0] = ((JSONString) ampm.get(0)).stringValue();\r
+                       temp[1] = ((JSONString) ampm.get(1)).stringValue();\r
                        return temp;\r
-               } else throw new LocaleNotLoadedException(locale);\r
+               } else\r
+                       throw new LocaleNotLoadedException(locale);\r
        }\r
 \r
 }\r
index 44f4aedc5e40383ccc0f32ba9b37124b634f2b9d..055251cf4546029ec63f1d29afec3ecbb9ee460d 100644 (file)
@@ -1,9 +1,9 @@
 package com.itmill.toolkit.terminal.gwt.client;
 
 /**
- * Client side console implementation for non-debug mode
- * that discards all messages.
- *
+ * Client side console implementation for non-debug mode that discards all
+ * messages.
+ * 
  */
 public class NullConsole implements Console {
 
index d57c6048ac2aec39f6e4ee021c635f0725013499..555b78c2863d2f6efe8ca49efa1ae626b06b2c91 100644 (file)
@@ -61,7 +61,7 @@ public class UIDL {
                double num = ((JSONNumber) val).getValue();
                return (long) num;
        }
-       
+
        public float getFloatAttribute(String name) {
                JSONValue val = ((JSONObject) json.get(1)).get(name);
                if (val == null)
@@ -69,7 +69,7 @@ public class UIDL {
                double num = ((JSONNumber) val).getValue();
                return (float) num;
        }
-       
+
        public double getDoubleAttribute(String name) {
                JSONValue val = ((JSONObject) json.get(1)).get(name);
                if (val == null)
@@ -84,7 +84,7 @@ public class UIDL {
                        return false;
                return ((JSONBoolean) val).booleanValue();
        }
-       
+
        public String[] getStringArrayAttribute(String name) {
                JSONArray a = (JSONArray) ((JSONObject) json.get(1)).get(name);
                String[] s = new String[a.size()];
@@ -176,7 +176,7 @@ public class UIDL {
 
                };
        }
-       
+
        public int getNumberOfChildren() {
                return json.size() - 2;
        }
@@ -188,8 +188,10 @@ public class UIDL {
                        String name = i.next().toString();
                        s += " " + name + "=";
                        JSONValue v = ((JSONObject) json.get(1)).get(name);
-                       if (v.isString() != null) s += v;
-                       else s += "\"" + v + "\"";
+                       if (v.isString() != null)
+                               s += v;
+                       else
+                               s += "\"" + v + "\"";
                }
 
                s += ">\n";
@@ -206,7 +208,7 @@ public class UIDL {
        }
 
        public String getChildrenAsXML() {
-               String s="";
+               String s = "";
                Iterator i = getChildIterator();
                while (i.hasNext()) {
                        Object c = i.next();
@@ -214,7 +216,7 @@ public class UIDL {
                }
                return s;
        }
-       
+
        public UIDLBrowser print_r() {
                return new UIDLBrowser();
        }
@@ -305,12 +307,13 @@ public class UIDL {
                        throw new IllegalArgumentException("No variables defined in tag.");
                return v;
        }
-       
+
        public boolean hasVariable(String name) {
                Object v = null;
                try {
                        v = getVariableHash().get(name);
-               } catch(IllegalArgumentException e) {}
+               } catch (IllegalArgumentException e) {
+               }
                return v != null;
        }
 
@@ -334,14 +337,14 @@ public class UIDL {
                        throw new IllegalArgumentException("No such variable: " + name);
                return (long) t.getValue();
        }
-       
+
        public float getFloatVariable(String name) {
                JSONNumber t = (JSONNumber) getVariableHash().get(name);
                if (t == null)
                        throw new IllegalArgumentException("No such variable: " + name);
                return (float) t.getValue();
        }
-       
+
        public double getDoubleVariable(String name) {
                JSONNumber t = (JSONNumber) getVariableHash().get(name);
                if (t == null)
@@ -399,7 +402,7 @@ public class UIDL {
 
                public String getXMLAsString() {
                        StringBuffer sb = new StringBuffer();
-                       for(Iterator it = x.keySet().iterator(); it.hasNext();) {
+                       for (Iterator it = x.keySet().iterator(); it.hasNext();) {
                                String tag = (String) it.next();
                                sb.append("<");
                                sb.append(tag);
@@ -414,7 +417,7 @@ public class UIDL {
        }
 
        public int getChidlCount() {
-               return json.size()-2;
+               return json.size() - 2;
        }
 
        public UIDL getErrors() {
index ce993f13bcac85dc283ff70781649eac46c1e3dd..3c38d957ae56e6d783238de668872eb54496efc1 100644 (file)
@@ -31,7 +31,7 @@ public class Util {
                }
                return false;
        }-*/;
-       
+
        /**
         * Nulls oncontextmenu function on given element. We need to manually clear
         * context menu events due bad browsers memory leaks, since we GWT don't
@@ -44,8 +44,9 @@ public class Util {
        }-*/;
 
        /**
-        * Traverses recursively ancestors until ContainerResizedListener child widget is found.
-        * They will delegate it futher if needed.
+        * Traverses recursively ancestors until ContainerResizedListener child
+        * widget is found. They will delegate it futher if needed.
+        * 
         * @param container
         */
        public static void runAnchestorsLayout(HasWidgets container) {
index bec94e3a4c55f5bc5d571c062cf40bb0a49daaa8..aaa77a91ab0ce6d6624c9950ba15a3915c23e894 100644 (file)
@@ -5,18 +5,25 @@ import com.google.gwt.user.client.ui.Widget;
 
 public interface WidgetSet extends EntryPoint {
 
-       /** Create an uninitialized component that best matches given UIDL.
+       /**
+        * Create an uninitialized component that best matches given UIDL.
         * 
-        * @param uidl UIDL to be painted with returned component.
-        * @return New uninitialized and unregistered component that can paint given UIDL.
+        * @param uidl
+        *            UIDL to be painted with returned component.
+        * @return New uninitialized and unregistered component that can paint given
+        *         UIDL.
         */
        public Widget createWidget(UIDL uidl);
 
-       /** Test if the given component implementation conforms to UIDL.
+       /**
+        * Test if the given component implementation conforms to UIDL.
         * 
-        * @param currentWidget Current implementation of the component
-        * @param uidl UIDL to test against
-        * @return true iff createWidget would return a new component of the same class than currentWidget
+        * @param currentWidget
+        *            Current implementation of the component
+        * @param uidl
+        *            UIDL to test against
+        * @return true iff createWidget would return a new component of the same
+        *         class than currentWidget
         */
        public boolean isCorrectImplementation(Widget currentWidget, UIDL uidl);
 }
index 19bb70707fcbb72b31796c9256cde2bc432fba86..56447949e15ac86a8a9acb070599f65b735f7ba8 100644 (file)
@@ -5,108 +5,109 @@ import java.util.Date;
 import com.itmill.toolkit.terminal.gwt.client.DateTimeService;\r
 \r
 public class CalendarEntry {\r
-    private Date start;\r
-    private Date end;\r
-    private String title;\r
-    private String description;\r
-    private boolean notime;\r
-\r
-    public CalendarEntry(Date start, Date end, String title, String description, boolean notime) {\r
-       if (notime) {\r
-           Date d = new Date(start.getTime());\r
-           d.setSeconds(0);\r
-           d.setMinutes(0);\r
-           this.start = d;\r
-           if (end != null) {\r
-               d = new Date(end.getTime());\r
-               d.setSeconds(0);\r
-               d.setMinutes(0);\r
-               this.end = d;\r
-           } else {\r
-               end = start;\r
-           }\r
-       } else {\r
-           this.start = start;\r
-           this.end = end;\r
+       private Date start;\r
+       private Date end;\r
+       private String title;\r
+       private String description;\r
+       private boolean notime;\r
+\r
+       public CalendarEntry(Date start, Date end, String title,\r
+                       String description, boolean notime) {\r
+               if (notime) {\r
+                       Date d = new Date(start.getTime());\r
+                       d.setSeconds(0);\r
+                       d.setMinutes(0);\r
+                       this.start = d;\r
+                       if (end != null) {\r
+                               d = new Date(end.getTime());\r
+                               d.setSeconds(0);\r
+                               d.setMinutes(0);\r
+                               this.end = d;\r
+                       } else {\r
+                               end = start;\r
+                       }\r
+               } else {\r
+                       this.start = start;\r
+                       this.end = end;\r
+               }\r
+               this.title = title;\r
+               this.description = description;\r
+               this.notime = notime;\r
        }\r
-       this.title = title;\r
-       this.description = description;\r
-       this.notime = notime;\r
-    }\r
-\r
-    public CalendarEntry(Date start, Date end, String title, String description) {\r
-       this(start, end, title, description, false);\r
-    }\r
-\r
-    public Date getStart() {\r
-       return start;\r
-    }\r
-\r
-    public void setStart(Date start) {\r
-       this.start = start;\r
-    }\r
-\r
-    public Date getEnd() {\r
-       return end;\r
-    }\r
-\r
-    public void setEnd(Date end) {\r
-       this.end = end;\r
-    }\r
-\r
-    public String getTitle() {\r
-       return title;\r
-    }\r
-\r
-    public void setTitle(String title) {\r
-       this.title = title;\r
-    }\r
-\r
-    public String getDescription() {\r
-       return description;\r
-    }\r
-\r
-    public void setDescription(String description) {\r
-       this.description = description;\r
-    }\r
-\r
-    public boolean isNotime() {\r
-       return notime;\r
-    }\r
-\r
-    public void setNotime(boolean notime) {\r
-       this.notime = notime;\r
-    }\r
-\r
-    public String getStringForDate(Date d) {\r
-       // TODO format from DateTimeService\r
-       String s = "";\r
-       if (!notime) {\r
-           if (!DateTimeService.isSameDay(d, start)) {\r
-               s += (start.getYear() + 1900) + "." + (start.getMonth() + 1)\r
-                       + "." + start.getDate() + " ";\r
-           }\r
-           int i = start.getHours();\r
-           s += (i < 10 ? "0" : "") + i;\r
-           s += ":";\r
-           i = start.getMinutes();\r
-           s += (i < 10 ? "0" : "") + i;\r
-           if (!start.equals(end)) {\r
-                   s += " - ";\r
-                   if (!DateTimeService.isSameDay(start, end)) {\r
-                       s += (end.getYear() + 1900) + "." + (end.getMonth() + 1) + "."\r
-                               + end.getDate() + " ";\r
-                   }\r
-                   i = end.getHours();\r
-                   s += (i < 10 ? "0" : "") + i;\r
-                   s += ":";\r
-                   i = end.getMinutes();\r
-                   s += (i < 10 ? "0" : "") + i;\r
-           }\r
-           s += " ";\r
+\r
+       public CalendarEntry(Date start, Date end, String title, String description) {\r
+               this(start, end, title, description, false);\r
+       }\r
+\r
+       public Date getStart() {\r
+               return start;\r
+       }\r
+\r
+       public void setStart(Date start) {\r
+               this.start = start;\r
+       }\r
+\r
+       public Date getEnd() {\r
+               return end;\r
+       }\r
+\r
+       public void setEnd(Date end) {\r
+               this.end = end;\r
+       }\r
+\r
+       public String getTitle() {\r
+               return title;\r
+       }\r
+\r
+       public void setTitle(String title) {\r
+               this.title = title;\r
+       }\r
+\r
+       public String getDescription() {\r
+               return description;\r
+       }\r
+\r
+       public void setDescription(String description) {\r
+               this.description = description;\r
+       }\r
+\r
+       public boolean isNotime() {\r
+               return notime;\r
+       }\r
+\r
+       public void setNotime(boolean notime) {\r
+               this.notime = notime;\r
+       }\r
+\r
+       public String getStringForDate(Date d) {\r
+               // TODO format from DateTimeService\r
+               String s = "";\r
+               if (!notime) {\r
+                       if (!DateTimeService.isSameDay(d, start)) {\r
+                               s += (start.getYear() + 1900) + "." + (start.getMonth() + 1)\r
+                                               + "." + start.getDate() + " ";\r
+                       }\r
+                       int i = start.getHours();\r
+                       s += (i < 10 ? "0" : "") + i;\r
+                       s += ":";\r
+                       i = start.getMinutes();\r
+                       s += (i < 10 ? "0" : "") + i;\r
+                       if (!start.equals(end)) {\r
+                               s += " - ";\r
+                               if (!DateTimeService.isSameDay(start, end)) {\r
+                                       s += (end.getYear() + 1900) + "." + (end.getMonth() + 1)\r
+                                                       + "." + end.getDate() + " ";\r
+                               }\r
+                               i = end.getHours();\r
+                               s += (i < 10 ? "0" : "") + i;\r
+                               s += ":";\r
+                               i = end.getMinutes();\r
+                               s += (i < 10 ? "0" : "") + i;\r
+                       }\r
+                       s += " ";\r
+               }\r
+               s += title;\r
+               return s;\r
        }\r
-       s += title;\r
-       return s;\r
-    }\r
 \r
 }
\ No newline at end of file
index d77044410273a317e58106c3709333301e0f6755..ea8df2924dc84219ee6fa2503084c6b660a3d01b 100644 (file)
@@ -19,390 +19,399 @@ import com.itmill.toolkit.terminal.gwt.client.DateTimeService;
 import com.itmill.toolkit.terminal.gwt.client.LocaleService;\r
 \r
 public class CalendarPanel extends FlexTable implements MouseListener,\r
-       ClickListener {\r
-\r
-    private IDateField datefield;\r
-\r
-    private IEventButton prevYear;\r
-    private IEventButton nextYear;\r
-    private IEventButton prevMonth;\r
-    private IEventButton nextMonth;\r
-\r
-    private Time time;\r
-\r
-    private Date minDate = null;\r
-    private Date maxDate = null;\r
-\r
-    private CalendarEntrySource entrySource;\r
-\r
-    /* Needed to identify resolution changes */\r
-    private int resolution = IDateField.RESOLUTION_YEAR;\r
-\r
-    /* Needed to identify locale changes */\r
-    private String locale = LocaleService.getDefaultLocale();\r
-\r
-    public CalendarPanel(IDateField parent) {\r
-       datefield = parent;\r
-       setStyleName(datefield.CLASSNAME + "-calendarpanel");\r
-       // buildCalendar(true);\r
-       addTableListener(new DateClickListener(this));\r
-    }\r
-\r
-    public CalendarPanel(IDateField parent, Date min, Date max) {\r
-       datefield = parent;\r
-       setStyleName(datefield.CLASSNAME + "-calendarpanel");\r
-       // buildCalendar(true);\r
-       addTableListener(new DateClickListener(this));\r
-    }\r
-\r
-    private void buildCalendar(boolean forceRedraw) {\r
-       boolean needsMonth = datefield.getCurrentResolution() > IDateField.RESOLUTION_YEAR;\r
-       boolean needsBody = datefield.getCurrentResolution() >= IDateField.RESOLUTION_DAY;\r
-       boolean needsTime = datefield.getCurrentResolution() >= IDateField.RESOLUTION_HOUR;\r
-       buildCalendarHeader(forceRedraw, needsMonth);\r
-       clearCalendarBody(!needsBody);\r
-       if (needsBody)\r
-           buildCalendarBody();\r
-       if (needsTime)\r
-           buildTime(forceRedraw);\r
-       else if (time != null) {\r
-           remove(time);\r
-           time = null;\r
+               ClickListener {\r
+\r
+       private IDateField datefield;\r
+\r
+       private IEventButton prevYear;\r
+       private IEventButton nextYear;\r
+       private IEventButton prevMonth;\r
+       private IEventButton nextMonth;\r
+\r
+       private Time time;\r
+\r
+       private Date minDate = null;\r
+       private Date maxDate = null;\r
+\r
+       private CalendarEntrySource entrySource;\r
+\r
+       /* Needed to identify resolution changes */\r
+       private int resolution = IDateField.RESOLUTION_YEAR;\r
+\r
+       /* Needed to identify locale changes */\r
+       private String locale = LocaleService.getDefaultLocale();\r
+\r
+       public CalendarPanel(IDateField parent) {\r
+               datefield = parent;\r
+               setStyleName(datefield.CLASSNAME + "-calendarpanel");\r
+               // buildCalendar(true);\r
+               addTableListener(new DateClickListener(this));\r
        }\r
-    }\r
 \r
-    private void clearCalendarBody(boolean remove) {\r
-       if (!remove) {\r
-           for (int row = 2; row < 8; row++) {\r
-               for (int col = 0; col < 7; col++) {\r
-                   setHTML(row, col, "&nbsp;");\r
-               }\r
-           }\r
-       } else if (getRowCount() > 2) {\r
-           while (getRowCount() > 2)\r
-               removeRow(2);\r
+       public CalendarPanel(IDateField parent, Date min, Date max) {\r
+               datefield = parent;\r
+               setStyleName(datefield.CLASSNAME + "-calendarpanel");\r
+               // buildCalendar(true);\r
+               addTableListener(new DateClickListener(this));\r
        }\r
-    }\r
-\r
-    private void buildCalendarHeader(boolean forceRedraw, boolean needsMonth) {\r
-       // Can't draw a calendar without a date :)\r
-       if (datefield.getCurrentDate() == null)\r
-           datefield.setCurrentDate(new Date());\r
-\r
-       if (forceRedraw) {\r
-           if (prevMonth == null) { // Only do once\r
-               prevYear = new IEventButton();\r
-               prevYear.setHTML("&laquo;");\r
-               nextYear = new IEventButton();\r
-               nextYear.setHTML("&raquo;");\r
-               prevYear.addMouseListener(this);\r
-               nextYear.addMouseListener(this);\r
-               prevYear.addClickListener(this);\r
-               nextYear.addClickListener(this);\r
-               setWidget(0, 0, prevYear);\r
-               setWidget(0, 4, nextYear);\r
-\r
-               if (needsMonth) {\r
-                   prevMonth = new IEventButton();\r
-                   prevMonth.setHTML("&lsaquo;");\r
-                   nextMonth = new IEventButton();\r
-                   nextMonth.setHTML("&rsaquo;");\r
-                   prevMonth.addMouseListener(this);\r
-                   nextMonth.addMouseListener(this);\r
-                   prevMonth.addClickListener(this);\r
-                   nextMonth.addClickListener(this);\r
-                   setWidget(0, 3, nextMonth);\r
-                   setWidget(0, 1, prevMonth);\r
-               }\r
 \r
-               getFlexCellFormatter().setColSpan(0, 2, 3);\r
-           } else if (!needsMonth) {\r
-               // Remove month traverse buttons\r
-               prevMonth.removeClickListener(this);\r
-               prevMonth.removeMouseListener(this);\r
-               nextMonth.removeClickListener(this);\r
-               nextMonth.removeMouseListener(this);\r
-               remove(prevMonth);\r
-               remove(nextMonth);\r
-               prevMonth = null;\r
-               nextMonth = null;\r
-           }\r
-\r
-           // Print weekday names\r
-           int firstDay = datefield.getDateTimeService().getFirstDayOfWeek();\r
-           for (int i = 0; i < 7; i++) {\r
-               int day = i + firstDay;\r
-               if (day > 6)\r
-                   day = 0;\r
-               if (datefield.getCurrentResolution() > IDateField.RESOLUTION_MONTH)\r
-                   setHTML(1, i, "<strong>"\r
-                           + datefield.getDateTimeService().getShortDay(day)\r
-                           + "</strong>");\r
-               else\r
-                   setHTML(1, i, "");\r
-           }\r
+       private void buildCalendar(boolean forceRedraw) {\r
+               boolean needsMonth = datefield.getCurrentResolution() > IDateField.RESOLUTION_YEAR;\r
+               boolean needsBody = datefield.getCurrentResolution() >= IDateField.RESOLUTION_DAY;\r
+               boolean needsTime = datefield.getCurrentResolution() >= IDateField.RESOLUTION_HOUR;\r
+               buildCalendarHeader(forceRedraw, needsMonth);\r
+               clearCalendarBody(!needsBody);\r
+               if (needsBody)\r
+                       buildCalendarBody();\r
+               if (needsTime)\r
+                       buildTime(forceRedraw);\r
+               else if (time != null) {\r
+                       remove(time);\r
+                       time = null;\r
+               }\r
        }\r
 \r
-       String monthName = needsMonth ? datefield.getDateTimeService()\r
-               .getMonth(datefield.getCurrentDate().getMonth()) : "";\r
-       int year = datefield.getCurrentDate().getYear() + 1900;\r
-       setHTML(0, 2, "<span class=\"" + datefield.CLASSNAME\r
-               + "-calendarpanel-month\">" + monthName + " " + year\r
-               + "</span>");\r
-    }\r
-\r
-    private void buildCalendarBody() {\r
-       Date date = datefield.getCurrentDate();\r
-       if (date == null)\r
-           date = new Date();\r
-       int startWeekDay = datefield.getDateTimeService().getStartWeekDay(date);\r
-       int numDays = DateTimeService.getNumberOfDaysInMonth(date);\r
-       int dayCount = 0;\r
-       Date today = new Date();\r
-       Date curr = new Date(date.getTime());\r
-       for (int row = 2; row < 8; row++) {\r
-           for (int col = 0; col < 7; col++) {\r
-               if (!(row == 2 && col < startWeekDay)) {\r
-                   if (dayCount < numDays) {\r
-                       int selectedDate = ++dayCount;\r
-                       String title = "";\r
-                       if (this.entrySource != null) {\r
-                           curr.setDate(dayCount);\r
-                           List entries = this.entrySource.getEntries(curr,\r
-                                   IDateField.RESOLUTION_DAY);\r
-                           if (entries != null) {\r
-                               for (Iterator it = entries.iterator(); it\r
-                                       .hasNext();) {\r
-                                   CalendarEntry entry = (CalendarEntry) it\r
-                                           .next();\r
-                                   title += (title.length() > 0 ? ", " : "")\r
-                                           + entry.getStringForDate(curr);\r
+       private void clearCalendarBody(boolean remove) {\r
+               if (!remove) {\r
+                       for (int row = 2; row < 8; row++) {\r
+                               for (int col = 0; col < 7; col++) {\r
+                                       setHTML(row, col, "&nbsp;");\r
                                }\r
-                           }\r
                        }\r
-                       String baseclass = datefield.CLASSNAME\r
-                               + "-calendarpanel-day";\r
-                       String cssClass = baseclass;\r
-                       if (!isEnabledDate(curr)) {\r
-                           cssClass += " " + baseclass + "-disabled";\r
+               } else if (getRowCount() > 2) {\r
+                       while (getRowCount() > 2)\r
+                               removeRow(2);\r
+               }\r
+       }\r
+\r
+       private void buildCalendarHeader(boolean forceRedraw, boolean needsMonth) {\r
+               // Can't draw a calendar without a date :)\r
+               if (datefield.getCurrentDate() == null)\r
+                       datefield.setCurrentDate(new Date());\r
+\r
+               if (forceRedraw) {\r
+                       if (prevMonth == null) { // Only do once\r
+                               prevYear = new IEventButton();\r
+                               prevYear.setHTML("&laquo;");\r
+                               nextYear = new IEventButton();\r
+                               nextYear.setHTML("&raquo;");\r
+                               prevYear.addMouseListener(this);\r
+                               nextYear.addMouseListener(this);\r
+                               prevYear.addClickListener(this);\r
+                               nextYear.addClickListener(this);\r
+                               setWidget(0, 0, prevYear);\r
+                               setWidget(0, 4, nextYear);\r
+\r
+                               if (needsMonth) {\r
+                                       prevMonth = new IEventButton();\r
+                                       prevMonth.setHTML("&lsaquo;");\r
+                                       nextMonth = new IEventButton();\r
+                                       nextMonth.setHTML("&rsaquo;");\r
+                                       prevMonth.addMouseListener(this);\r
+                                       nextMonth.addMouseListener(this);\r
+                                       prevMonth.addClickListener(this);\r
+                                       nextMonth.addClickListener(this);\r
+                                       setWidget(0, 3, nextMonth);\r
+                                       setWidget(0, 1, prevMonth);\r
+                               }\r
+\r
+                               getFlexCellFormatter().setColSpan(0, 2, 3);\r
+                       } else if (!needsMonth) {\r
+                               // Remove month traverse buttons\r
+                               prevMonth.removeClickListener(this);\r
+                               prevMonth.removeMouseListener(this);\r
+                               nextMonth.removeClickListener(this);\r
+                               nextMonth.removeMouseListener(this);\r
+                               remove(prevMonth);\r
+                               remove(nextMonth);\r
+                               prevMonth = null;\r
+                               nextMonth = null;\r
                        }\r
-                       if (date.getDate() == dayCount) {\r
-                           cssClass += " " + baseclass + "-selected";\r
+\r
+                       // Print weekday names\r
+                       int firstDay = datefield.getDateTimeService().getFirstDayOfWeek();\r
+                       for (int i = 0; i < 7; i++) {\r
+                               int day = i + firstDay;\r
+                               if (day > 6)\r
+                                       day = 0;\r
+                               if (datefield.getCurrentResolution() > IDateField.RESOLUTION_MONTH)\r
+                                       setHTML(1, i, "<strong>"\r
+                                                       + datefield.getDateTimeService().getShortDay(day)\r
+                                                       + "</strong>");\r
+                               else\r
+                                       setHTML(1, i, "");\r
                        }\r
-                       if (today.getDate() == dayCount\r
-                               && today.getMonth() == date.getMonth()\r
-                               && today.getYear() == date.getYear()) {\r
-                           cssClass += " " + baseclass + "-today";\r
+               }\r
+\r
+               String monthName = needsMonth ? datefield.getDateTimeService()\r
+                               .getMonth(datefield.getCurrentDate().getMonth()) : "";\r
+               int year = datefield.getCurrentDate().getYear() + 1900;\r
+               setHTML(0, 2, "<span class=\"" + datefield.CLASSNAME\r
+                               + "-calendarpanel-month\">" + monthName + " " + year\r
+                               + "</span>");\r
+       }\r
+\r
+       private void buildCalendarBody() {\r
+               Date date = datefield.getCurrentDate();\r
+               if (date == null)\r
+                       date = new Date();\r
+               int startWeekDay = datefield.getDateTimeService().getStartWeekDay(date);\r
+               int numDays = DateTimeService.getNumberOfDaysInMonth(date);\r
+               int dayCount = 0;\r
+               Date today = new Date();\r
+               Date curr = new Date(date.getTime());\r
+               for (int row = 2; row < 8; row++) {\r
+                       for (int col = 0; col < 7; col++) {\r
+                               if (!(row == 2 && col < startWeekDay)) {\r
+                                       if (dayCount < numDays) {\r
+                                               int selectedDate = ++dayCount;\r
+                                               String title = "";\r
+                                               if (this.entrySource != null) {\r
+                                                       curr.setDate(dayCount);\r
+                                                       List entries = this.entrySource.getEntries(curr,\r
+                                                                       IDateField.RESOLUTION_DAY);\r
+                                                       if (entries != null) {\r
+                                                               for (Iterator it = entries.iterator(); it\r
+                                                                               .hasNext();) {\r
+                                                                       CalendarEntry entry = (CalendarEntry) it\r
+                                                                                       .next();\r
+                                                                       title += (title.length() > 0 ? ", " : "")\r
+                                                                                       + entry.getStringForDate(curr);\r
+                                                               }\r
+                                                       }\r
+                                               }\r
+                                               String baseclass = datefield.CLASSNAME\r
+                                                               + "-calendarpanel-day";\r
+                                               String cssClass = baseclass;\r
+                                               if (!isEnabledDate(curr)) {\r
+                                                       cssClass += " " + baseclass + "-disabled";\r
+                                               }\r
+                                               if (date.getDate() == dayCount) {\r
+                                                       cssClass += " " + baseclass + "-selected";\r
+                                               }\r
+                                               if (today.getDate() == dayCount\r
+                                                               && today.getMonth() == date.getMonth()\r
+                                                               && today.getYear() == date.getYear()) {\r
+                                                       cssClass += " " + baseclass + "-today";\r
+                                               }\r
+                                               if (title.length() > 0)\r
+                                                       cssClass += " " + baseclass + "-entry";\r
+                                               setHTML(row, col, "<span title=\"" + title\r
+                                                               + "\" class=\"" + cssClass + "\">"\r
+                                                               + selectedDate + "</span>");\r
+                                       } else {\r
+                                               break;\r
+                                       }\r
+\r
+                               }\r
                        }\r
-                       if (title.length() > 0)\r
-                           cssClass += " " + baseclass + "-entry";\r
-                       setHTML(row, col, "<span title=\"" + title\r
-                               + "\" class=\"" + cssClass + "\">"\r
-                               + selectedDate + "</span>");\r
-                   } else {\r
-                       break;\r
-                   }\r
+               }\r
+       }\r
 \r
+       private void buildTime(boolean forceRedraw) {\r
+               if (time == null) {\r
+                       time = new Time(datefield);\r
+                       setText(8, 0, ""); // Add new row\r
+                       getFlexCellFormatter().setColSpan(8, 0, 7);\r
+                       setWidget(8, 0, time);\r
                }\r
-           }\r
+               time.updateTime(forceRedraw);\r
        }\r
-    }\r
-\r
-    private void buildTime(boolean forceRedraw) {\r
-       if (time == null) {\r
-           time = new Time(datefield);\r
-           setText(8, 0, ""); // Add new row\r
-           getFlexCellFormatter().setColSpan(8, 0, 7);\r
-           setWidget(8, 0, time);\r
+\r
+       /**\r
+        * \r
+        * @param forceRedraw\r
+        *            Build all from scratch, in case of e.g. locale changes\r
+        */\r
+       public void updateCalendar() {\r
+               // Locale and resolution changes force a complete redraw\r
+               buildCalendar(locale != datefield.getCurrentLocale()\r
+                               || resolution != datefield.getCurrentResolution());\r
+               if (datefield instanceof ITextualDate)\r
+                       ((ITextualDate) datefield).buildDate();\r
+               locale = datefield.getCurrentLocale();\r
+               resolution = datefield.getCurrentResolution();\r
        }\r
-       time.updateTime(forceRedraw);\r
-    }\r
-\r
-    /**\r
-     * \r
-     * @param forceRedraw\r
-     *                Build all from scratch, in case of e.g. locale changes\r
-     */\r
-    public void updateCalendar() {\r
-       // Locale and resolution changes force a complete redraw\r
-       buildCalendar(locale != datefield.getCurrentLocale()\r
-               || resolution != datefield.getCurrentResolution());\r
-       if (datefield instanceof ITextualDate)\r
-           ((ITextualDate) datefield).buildDate();\r
-       locale = datefield.getCurrentLocale();\r
-       resolution = datefield.getCurrentResolution();\r
-    }\r
-\r
-    public void onClick(Widget sender) {\r
-       processClickEvent(sender);\r
-    }\r
-\r
-    private boolean isEnabledDate(Date date) {\r
-       if ((this.minDate != null && date.before(this.minDate))\r
-               || (this.maxDate != null && date.after(this.maxDate))) {\r
-           return false;\r
+\r
+       public void onClick(Widget sender) {\r
+               processClickEvent(sender);\r
        }\r
-       return true;\r
-    }\r
-\r
-    private void processClickEvent(Widget sender) {\r
-       if (!datefield.isEnabled() || datefield.isReadonly())\r
-           return;\r
-\r
-       if (sender == prevYear) {\r
-           datefield.getCurrentDate().setYear(datefield.getCurrentDate().getYear() - 1);\r
-           datefield.getClient().updateVariable(datefield.getId(), "year",\r
-                   datefield.getCurrentDate().getYear() + 1900, datefield.isImmediate());\r
-           updateCalendar();\r
-       } else if (sender == nextYear) {\r
-           datefield.getCurrentDate().setYear(datefield.getCurrentDate().getYear() + 1);\r
-           datefield.getClient().updateVariable(datefield.getId(), "year",\r
-                   datefield.getCurrentDate().getYear() + 1900, datefield.isImmediate());\r
-           updateCalendar();\r
-       } else if (sender == prevMonth) {\r
-           datefield.getCurrentDate().setMonth(datefield.getCurrentDate().getMonth() - 1);\r
-           datefield.getClient().updateVariable(datefield.getId(), "month",\r
-                   datefield.getCurrentDate().getMonth() + 1, datefield.isImmediate());\r
-           updateCalendar();\r
-       } else if (sender == nextMonth) {\r
-           datefield.getCurrentDate().setMonth(datefield.getCurrentDate().getMonth() + 1);\r
-           datefield.getClient().updateVariable(datefield.getId(), "month",\r
-                   datefield.getCurrentDate().getMonth() + 1, datefield.isImmediate());\r
-           updateCalendar();\r
+\r
+       private boolean isEnabledDate(Date date) {\r
+               if ((this.minDate != null && date.before(this.minDate))\r
+                               || (this.maxDate != null && date.after(this.maxDate))) {\r
+                       return false;\r
+               }\r
+               return true;\r
        }\r
-    }\r
 \r
-    private Timer timer;\r
+       private void processClickEvent(Widget sender) {\r
+               if (!datefield.isEnabled() || datefield.isReadonly())\r
+                       return;\r
+\r
+               if (sender == prevYear) {\r
+                       datefield.getCurrentDate().setYear(\r
+                                       datefield.getCurrentDate().getYear() - 1);\r
+                       datefield.getClient().updateVariable(datefield.getId(), "year",\r
+                                       datefield.getCurrentDate().getYear() + 1900,\r
+                                       datefield.isImmediate());\r
+                       updateCalendar();\r
+               } else if (sender == nextYear) {\r
+                       datefield.getCurrentDate().setYear(\r
+                                       datefield.getCurrentDate().getYear() + 1);\r
+                       datefield.getClient().updateVariable(datefield.getId(), "year",\r
+                                       datefield.getCurrentDate().getYear() + 1900,\r
+                                       datefield.isImmediate());\r
+                       updateCalendar();\r
+               } else if (sender == prevMonth) {\r
+                       datefield.getCurrentDate().setMonth(\r
+                                       datefield.getCurrentDate().getMonth() - 1);\r
+                       datefield.getClient().updateVariable(datefield.getId(), "month",\r
+                                       datefield.getCurrentDate().getMonth() + 1,\r
+                                       datefield.isImmediate());\r
+                       updateCalendar();\r
+               } else if (sender == nextMonth) {\r
+                       datefield.getCurrentDate().setMonth(\r
+                                       datefield.getCurrentDate().getMonth() + 1);\r
+                       datefield.getClient().updateVariable(datefield.getId(), "month",\r
+                                       datefield.getCurrentDate().getMonth() + 1,\r
+                                       datefield.isImmediate());\r
+                       updateCalendar();\r
+               }\r
+       }\r
 \r
-    public void onMouseDown(final Widget sender, int x, int y) {\r
-       if (sender instanceof IEventButton) {\r
-           timer = new Timer() {\r
-               public void run() {\r
-                   processClickEvent(sender);\r
+       private Timer timer;\r
+\r
+       public void onMouseDown(final Widget sender, int x, int y) {\r
+               if (sender instanceof IEventButton) {\r
+                       timer = new Timer() {\r
+                               public void run() {\r
+                                       processClickEvent(sender);\r
+                               }\r
+                       };\r
+                       timer.scheduleRepeating(100);\r
                }\r
-           };\r
-           timer.scheduleRepeating(100);\r
        }\r
-    }\r
 \r
-    public void onMouseEnter(Widget sender) {\r
-    }\r
+       public void onMouseEnter(Widget sender) {\r
+       }\r
 \r
-    public void onMouseLeave(Widget sender) {\r
-       if (timer != null)\r
-           timer.cancel();\r
-    }\r
+       public void onMouseLeave(Widget sender) {\r
+               if (timer != null)\r
+                       timer.cancel();\r
+       }\r
 \r
-    public void onMouseMove(Widget sender, int x, int y) {\r
-    }\r
+       public void onMouseMove(Widget sender, int x, int y) {\r
+       }\r
 \r
-    public void onMouseUp(Widget sender, int x, int y) {\r
-       if (timer != null)\r
-           timer.cancel();\r
-    }\r
+       public void onMouseUp(Widget sender, int x, int y) {\r
+               if (timer != null)\r
+                       timer.cancel();\r
+       }\r
 \r
-    private class IEventButton extends IButton implements SourcesMouseEvents {\r
+       private class IEventButton extends IButton implements SourcesMouseEvents {\r
 \r
-       private MouseListenerCollection mouseListeners;\r
+               private MouseListenerCollection mouseListeners;\r
 \r
-       public IEventButton() {\r
-           super();\r
-           sinkEvents(Event.FOCUSEVENTS | Event.KEYEVENTS | Event.ONCLICK\r
-                   | Event.MOUSEEVENTS);\r
-       }\r
+               public IEventButton() {\r
+                       super();\r
+                       sinkEvents(Event.FOCUSEVENTS | Event.KEYEVENTS | Event.ONCLICK\r
+                                       | Event.MOUSEEVENTS);\r
+               }\r
 \r
-       public void addMouseListener(MouseListener listener) {\r
-           if (mouseListeners == null) {\r
-               mouseListeners = new MouseListenerCollection();\r
-           }\r
-           mouseListeners.add(listener);\r
-       }\r
+               public void addMouseListener(MouseListener listener) {\r
+                       if (mouseListeners == null) {\r
+                               mouseListeners = new MouseListenerCollection();\r
+                       }\r
+                       mouseListeners.add(listener);\r
+               }\r
 \r
-       public void removeMouseListener(MouseListener listener) {\r
-           if (mouseListeners != null)\r
-               mouseListeners.remove(listener);\r
-       }\r
+               public void removeMouseListener(MouseListener listener) {\r
+                       if (mouseListeners != null)\r
+                               mouseListeners.remove(listener);\r
+               }\r
 \r
-       public void onBrowserEvent(Event event) {\r
-           super.onBrowserEvent(event);\r
-           switch (DOM.eventGetType(event)) {\r
-           case Event.ONMOUSEDOWN:\r
-           case Event.ONMOUSEUP:\r
-           case Event.ONMOUSEMOVE:\r
-           case Event.ONMOUSEOVER:\r
-           case Event.ONMOUSEOUT:\r
-               if (mouseListeners != null) {\r
-                   mouseListeners.fireMouseEvent(this, event);\r
+               public void onBrowserEvent(Event event) {\r
+                       super.onBrowserEvent(event);\r
+                       switch (DOM.eventGetType(event)) {\r
+                       case Event.ONMOUSEDOWN:\r
+                       case Event.ONMOUSEUP:\r
+                       case Event.ONMOUSEMOVE:\r
+                       case Event.ONMOUSEOVER:\r
+                       case Event.ONMOUSEOUT:\r
+                               if (mouseListeners != null) {\r
+                                       mouseListeners.fireMouseEvent(this, event);\r
+                               }\r
+                               break;\r
+                       }\r
                }\r
-               break;\r
-           }\r
        }\r
-    }\r
 \r
-    private class DateClickListener implements TableListener {\r
+       private class DateClickListener implements TableListener {\r
 \r
-       private CalendarPanel cal;\r
+               private CalendarPanel cal;\r
 \r
-       public DateClickListener(CalendarPanel panel) {\r
-           cal = panel;\r
-       }\r
+               public DateClickListener(CalendarPanel panel) {\r
+                       cal = panel;\r
+               }\r
 \r
-       public void onCellClicked(SourcesTableEvents sender, int row, int col) {\r
-           if (sender != cal || row < 2 || row > 7 || !cal.datefield.isEnabled()\r
-                   || cal.datefield.isReadonly())\r
-               return;\r
+               public void onCellClicked(SourcesTableEvents sender, int row, int col) {\r
+                       if (sender != cal || row < 2 || row > 7\r
+                                       || !cal.datefield.isEnabled() || cal.datefield.isReadonly())\r
+                               return;\r
 \r
-           String text = cal.getText(row, col);\r
-           if (text.equals(" "))\r
-               return;\r
+                       String text = cal.getText(row, col);\r
+                       if (text.equals(" "))\r
+                               return;\r
 \r
-           Integer day = new Integer(text);\r
+                       Integer day = new Integer(text);\r
 \r
-           Date newDate = new Date(cal.datefield.getCurrentDate().getTime());\r
-           newDate.setDate(day.intValue());\r
-           if (!isEnabledDate(newDate)) {\r
-               return;\r
-           }\r
-           cal.datefield.getCurrentDate().setTime(newDate.getTime());\r
-           cal.datefield.getClient().updateVariable(cal.datefield.getId(), "day",\r
-                   cal.datefield.getCurrentDate().getDate(), cal.datefield.isImmediate());\r
+                       Date newDate = new Date(cal.datefield.getCurrentDate().getTime());\r
+                       newDate.setDate(day.intValue());\r
+                       if (!isEnabledDate(newDate)) {\r
+                               return;\r
+                       }\r
+                       cal.datefield.getCurrentDate().setTime(newDate.getTime());\r
+                       cal.datefield.getClient().updateVariable(cal.datefield.getId(),\r
+                                       "day", cal.datefield.getCurrentDate().getDate(),\r
+                                       cal.datefield.isImmediate());\r
 \r
-           updateCalendar();\r
-       }\r
+                       updateCalendar();\r
+               }\r
 \r
-    }\r
-\r
-    public void setLimits(Date min, Date max) {\r
-       if (min != null) {\r
-           Date d = new Date(min.getTime());\r
-           d.setHours(0);\r
-           d.setMinutes(0);\r
-           d.setSeconds(1);\r
-           this.minDate = d;\r
-       } else {\r
-           this.minDate = null;\r
        }\r
-       if (max != null) {\r
-           Date d = new Date(max.getTime());\r
-           d.setHours(24);\r
-           d.setMinutes(59);\r
-           d.setSeconds(59);\r
-           this.maxDate = d;\r
-       } else {\r
-           this.maxDate = null;\r
+\r
+       public void setLimits(Date min, Date max) {\r
+               if (min != null) {\r
+                       Date d = new Date(min.getTime());\r
+                       d.setHours(0);\r
+                       d.setMinutes(0);\r
+                       d.setSeconds(1);\r
+                       this.minDate = d;\r
+               } else {\r
+                       this.minDate = null;\r
+               }\r
+               if (max != null) {\r
+                       Date d = new Date(max.getTime());\r
+                       d.setHours(24);\r
+                       d.setMinutes(59);\r
+                       d.setSeconds(59);\r
+                       this.maxDate = d;\r
+               } else {\r
+                       this.maxDate = null;\r
+               }\r
        }\r
-    }\r
 \r
-    public void setCalendarEntrySource(CalendarEntrySource entrySource) {\r
-       this.entrySource = entrySource;\r
-    }\r
+       public void setCalendarEntrySource(CalendarEntrySource entrySource) {\r
+               this.entrySource = entrySource;\r
+       }\r
 \r
-    public CalendarEntrySource getCalendarEntrySource() {\r
-       return this.entrySource;\r
-    }\r
+       public CalendarEntrySource getCalendarEntrySource() {\r
+               return this.entrySource;\r
+       }\r
 \r
-    public interface CalendarEntrySource {\r
-       public List getEntries(Date date, int resolution);\r
-    }\r
+       public interface CalendarEntrySource {\r
+               public List getEntries(Date date, int resolution);\r
+       }\r
 \r
 }\r
index f3f16000461bf731823906dc8ef475512e2edb8b..82bbfadffc4948e273edf258fefc091449ba2e56 100644 (file)
@@ -7,32 +7,33 @@ import com.google.gwt.user.client.ui.MenuItem;
 import com.google.gwt.user.client.ui.PopupPanel;
 
 public class ContextMenu extends PopupPanel {
-       
+
        private ActionOwner actionOwner;
-       
+
        private CMenuBar menu = new CMenuBar();
-       
+
        /**
-        * This method should be used only by Client object as
-        * only one per client should exists. Request an instance
-        * via client.getContextMenu();
+        * This method should be used only by Client object as only one per client
+        * should exists. Request an instance via client.getContextMenu();
         * 
-        * @param cli to be set as an owner of menu
+        * @param cli
+        *            to be set as an owner of menu
         */
        public ContextMenu() {
                super(true);
                setWidget(menu);
                setStyleName("i-contextmenu");
        }
-       
+
        /**
         * Sets the element from which to build menu
+        * 
         * @param ao
         */
        public void setActionOwner(ActionOwner ao) {
                this.actionOwner = ao;
        }
-       
+
        /**
         * Shows context menu at given location.
         * 
@@ -46,12 +47,14 @@ public class ContextMenu extends PopupPanel {
                        Action a = actions[i];
                        menu.addItem(new MenuItem(a.getHTML(), true, a));
                }
-               
+
                setPopupPosition(left, top);
                show();
                // fix position if "outside" screen
-               if(DOM.getElementPropertyInt(getElement(),"offsetWidth") + left > Window.getClientWidth()) {
-                       left = Window.getClientWidth() - DOM.getElementPropertyInt(getElement(),"offsetWidth");
+               if (DOM.getElementPropertyInt(getElement(), "offsetWidth") + left > Window
+                               .getClientWidth()) {
+                       left = Window.getClientWidth()
+                                       - DOM.getElementPropertyInt(getElement(), "offsetWidth");
                        setPopupPosition(left, top);
                }
        }
@@ -62,9 +65,8 @@ public class ContextMenu extends PopupPanel {
        }
 
        /**
-        * Extend standard Gwt MenuBar to set proper settings and 
-        * to override onPopupClosed method so that PopupPanel gets
-        * closed.
+        * Extend standard Gwt MenuBar to set proper settings and to override
+        * onPopupClosed method so that PopupPanel gets closed.
         */
        class CMenuBar extends MenuBar {
                public CMenuBar() {
index 7069e99c15b93e6eb918953904663440b5621a8d..bea7940db0829290e3750826b60f77f9c382976e 100644 (file)
@@ -4,12 +4,12 @@ import com.google.gwt.user.client.ui.AbstractImagePrototype;
 \r
 public interface HorizontalSplitPanelImages extends\r
                com.google.gwt.user.client.ui.HorizontalSplitPanelImages {\r
-       \r
+\r
        /**\r
-          * An image representing the drag thumb.\r
-          \r
-          * @gwt.resource com/itmill/toolkit/terminal/gwt/public/default/common/img/blank.gif\r
-          */\r
+        * An image representing the drag thumb.\r
+        * \r
+        * @gwt.resource com/itmill/toolkit/terminal/gwt/public/default/common/img/blank.gif\r
+        */\r
        AbstractImagePrototype horizontalSplitPanelThumb();\r
-       \r
+\r
 }\r
index 2e091f11fa84c67d4b236f293755a3206a100d3e..7d3f4de822d0cfbe4c4fe2c0d33ab65fcf6bbeba 100644 (file)
@@ -13,7 +13,7 @@ import com.itmill.toolkit.terminal.gwt.client.Paintable;
 import com.itmill.toolkit.terminal.gwt.client.UIDL;
 
 public class IButton extends Button implements Paintable {
-       
+
        public static final String CLASSNAME = "i-button";
 
        String id;
@@ -23,9 +23,8 @@ public class IButton extends Button implements Paintable {
        private Element errorIndicatorElement;
 
        private ErrorMessage errorMessage;
-       
-       private PopupPanel errorContainer;
 
+       private PopupPanel errorContainer;
 
        public IButton() {
                setStyleName(CLASSNAME);
@@ -52,32 +51,34 @@ public class IButton extends Button implements Paintable {
 
                // Set text
                setText(uidl.getStringAttribute("caption"));
-               
-               if(uidl.hasAttribute("error")) {
+
+               if (uidl.hasAttribute("error")) {
                        UIDL errorUidl = uidl.getErrors();
-                       if(errorIndicatorElement == null) {
+                       if (errorIndicatorElement == null) {
                                errorIndicatorElement = DOM.createDiv();
-                               DOM.setElementProperty(errorIndicatorElement, "className", "i-errorindicator");
+                               DOM.setElementProperty(errorIndicatorElement, "className",
+                                               "i-errorindicator");
                                DOM.sinkEvents(errorIndicatorElement, Event.MOUSEEVENTS);
                        }
                        DOM.insertChild(getElement(), errorIndicatorElement, 0);
-                       if(errorMessage == null)
+                       if (errorMessage == null)
                                errorMessage = new ErrorMessage();
                        errorMessage.updateFromUIDL(errorUidl);
-                       
-               } else iferrorIndicatorElement != null) {
+
+               } else if (errorIndicatorElement != null) {
                        DOM.setStyleAttribute(errorIndicatorElement, "display", "none");
                }
-               
-               if(uidl.hasAttribute("description")) {
+
+               if (uidl.hasAttribute("description")) {
                        setTitle(uidl.getStringAttribute("description"));
                }
 
        }
-       
+
        public void onBrowserEvent(Event event) {
-               Element target= DOM.eventGetTarget(event);
-               if(errorIndicatorElement != null && DOM.compare(target, errorIndicatorElement)) {
+               Element target = DOM.eventGetTarget(event);
+               if (errorIndicatorElement != null
+                               && DOM.compare(target, errorIndicatorElement)) {
                        switch (DOM.eventGetType(event)) {
                        case Event.ONMOUSEOVER:
                                showErrorMessage();
@@ -86,8 +87,8 @@ public class IButton extends Button implements Paintable {
                                hideErrorMessage();
                                break;
                        case Event.ONCLICK:
-                               ApplicationConnection.getConsole().
-                                       log(DOM.getInnerHTML(errorMessage.getElement()));
+                               ApplicationConnection.getConsole().log(
+                                               DOM.getInnerHTML(errorMessage.getElement()));
                                return;
                        default:
                                break;
@@ -97,25 +98,28 @@ public class IButton extends Button implements Paintable {
        }
 
        private void hideErrorMessage() {
-               if(errorContainer != null) {
+               if (errorContainer != null) {
                        errorContainer.hide();
                }
        }
 
        private void showErrorMessage() {
-               if(errorMessage != null) {
-                       if(errorContainer == null) {
+               if (errorMessage != null) {
+                       if (errorContainer == null) {
                                errorContainer = new PopupPanel();
                                errorContainer.setWidget(errorMessage);
                        }
-                       errorContainer.setPopupPosition(
-                                       DOM.getAbsoluteLeft(errorIndicatorElement) +
-                                               2*DOM.getElementPropertyInt(errorIndicatorElement, "offsetHeight"),
-                                       DOM.getAbsoluteTop(errorIndicatorElement) + 
-                                               2*DOM.getElementPropertyInt(errorIndicatorElement, "offsetHeight"));
+                       errorContainer.setPopupPosition(DOM
+                                       .getAbsoluteLeft(errorIndicatorElement)
+                                       + 2
+                                       * DOM.getElementPropertyInt(errorIndicatorElement,
+                                                       "offsetHeight"), DOM
+                                       .getAbsoluteTop(errorIndicatorElement)
+                                       + 2
+                                       * DOM.getElementPropertyInt(errorIndicatorElement,
+                                                       "offsetHeight"));
                        errorContainer.show();
                }
        }
 
-
 }
index 15eca990a0d604146f7912c75608c972c808de3f..dea6ee2d54bb2392851705a02fdaf78d97c06ebb 100644 (file)
@@ -17,170 +17,170 @@ import com.itmill.toolkit.terminal.gwt.client.UIDL;
 \r
 public class ICalendar extends IDateField {\r
 \r
-    private CalendarPanel calPanel;\r
-\r
-    private HTMLTable hourTable;\r
-\r
-    private EntrySource entrySource;\r
-\r
-    private TableListener ftListener = new HourTableListener();\r
-\r
-    private int realResolution = RESOLUTION_DAY;\r
-\r
-    private static final String CLASSNAME = IDateField.CLASSNAME\r
-           + "-entrycalendar";\r
-\r
-    public ICalendar() {\r
-       super();\r
-       setStyleName(CLASSNAME);\r
-       calPanel = new CalendarPanel(this);\r
-       add(calPanel);\r
-       this.entrySource = new EntrySource();\r
-       calPanel.setCalendarEntrySource(this.entrySource);\r
-       calPanel.addTableListener(new TableListener() {\r
-           public void onCellClicked(SourcesTableEvents sender, int row,\r
-                   int cell) {\r
-               buildDayView(date);\r
-           }\r
-       });\r
-    }\r
-\r
-    public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {\r
-       super.updateFromUIDL(uidl, client);\r
-       // We want to draw our own hour list\r
-       this.realResolution = currentResolution;\r
-       this.currentResolution = RESOLUTION_DAY;\r
-       if (uidl.hasAttribute("min")) {\r
-           String mins = uidl.getStringAttribute("min");\r
-           long min = (mins != null ? Long.parseLong(mins) : 0);\r
-           String maxs = uidl.getStringAttribute("max");\r
-           long max = (maxs != null ? Long.parseLong(maxs) : 0);\r
-           Date minDate = (min > 0 ? new Date(min) : null);\r
-           Date maxDate = (max > 0 ? new Date(max) : null);\r
-           calPanel.setLimits(minDate, maxDate);\r
+       private CalendarPanel calPanel;\r
+\r
+       private HTMLTable hourTable;\r
+\r
+       private EntrySource entrySource;\r
+\r
+       private TableListener ftListener = new HourTableListener();\r
+\r
+       private int realResolution = RESOLUTION_DAY;\r
+\r
+       private static final String CLASSNAME = IDateField.CLASSNAME\r
+                       + "-entrycalendar";\r
+\r
+       public ICalendar() {\r
+               super();\r
+               setStyleName(CLASSNAME);\r
+               calPanel = new CalendarPanel(this);\r
+               add(calPanel);\r
+               this.entrySource = new EntrySource();\r
+               calPanel.setCalendarEntrySource(this.entrySource);\r
+               calPanel.addTableListener(new TableListener() {\r
+                       public void onCellClicked(SourcesTableEvents sender, int row,\r
+                                       int cell) {\r
+                               buildDayView(date);\r
+                       }\r
+               });\r
        }\r
-       this.entrySource.clear();\r
-       for (Iterator cit = uidl.getChildIterator(); cit.hasNext();) {\r
-           UIDL child = (UIDL) cit.next();\r
-           if (child.getTag().equals("items")) {\r
-               for (Iterator iit = child.getChildIterator(); iit.hasNext();) {\r
-                   UIDL item = (UIDL) iit.next();\r
-                   this.entrySource.addItem(item);\r
+\r
+       public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {\r
+               super.updateFromUIDL(uidl, client);\r
+               // We want to draw our own hour list\r
+               this.realResolution = currentResolution;\r
+               this.currentResolution = RESOLUTION_DAY;\r
+               if (uidl.hasAttribute("min")) {\r
+                       String mins = uidl.getStringAttribute("min");\r
+                       long min = (mins != null ? Long.parseLong(mins) : 0);\r
+                       String maxs = uidl.getStringAttribute("max");\r
+                       long max = (maxs != null ? Long.parseLong(maxs) : 0);\r
+                       Date minDate = (min > 0 ? new Date(min) : null);\r
+                       Date maxDate = (max > 0 ? new Date(max) : null);\r
+                       calPanel.setLimits(minDate, maxDate);\r
                }\r
-               break;\r
-           }\r
-       }\r
-       calPanel.updateCalendar();\r
-       buildDayView(this.date);\r
-    }\r
-\r
-    protected void buildDayView(Date date) {\r
-       boolean firstRender = false;\r
-       if (this.hourTable == null) {\r
-           hourTable = new FlexTable();\r
-           firstRender = true;\r
-           hourTable.addTableListener(this.ftListener);\r
-           SimplePanel p = new SimplePanel();\r
-           p.add(hourTable);\r
-           p.setStyleName(CLASSNAME + "-hours");\r
-           this.calPanel.getFlexCellFormatter().setColSpan(8, 0, 7);\r
-           this.calPanel.setWidget(8, 0, p);\r
-       }\r
-       Date curr = new Date(date.getTime());\r
-       for (int i = 0; i < 24; i++) {\r
-           curr.setHours(i);\r
-           String style = (i % 2 == 0 ? "even" : "odd");\r
-           if (realResolution >= RESOLUTION_HOUR) {\r
-               if (this.date != null && this.date.getHours() == i) {\r
-                   style = "selected";\r
+               this.entrySource.clear();\r
+               for (Iterator cit = uidl.getChildIterator(); cit.hasNext();) {\r
+                       UIDL child = (UIDL) cit.next();\r
+                       if (child.getTag().equals("items")) {\r
+                               for (Iterator iit = child.getChildIterator(); iit.hasNext();) {\r
+                                       UIDL item = (UIDL) iit.next();\r
+                                       this.entrySource.addItem(item);\r
+                               }\r
+                               break;\r
+                       }\r
                }\r
-           }\r
-           hourTable.getRowFormatter().setStyleName(i,\r
-                   CLASSNAME + "-row-" + style);\r
-           if (firstRender) {\r
-               String hstr = (i < 10 ? "0" : "") + i + ":00";\r
-               if (this.dts.isTwelveHourClock()) {\r
-                   String ampm = (i < 12 ? "am" : "pm");\r
-                   hstr = (i <= 12 ? i : i - 12) + ":00 " + ampm;\r
+               calPanel.updateCalendar();\r
+               buildDayView(this.date);\r
+       }\r
+\r
+       protected void buildDayView(Date date) {\r
+               boolean firstRender = false;\r
+               if (this.hourTable == null) {\r
+                       hourTable = new FlexTable();\r
+                       firstRender = true;\r
+                       hourTable.addTableListener(this.ftListener);\r
+                       SimplePanel p = new SimplePanel();\r
+                       p.add(hourTable);\r
+                       p.setStyleName(CLASSNAME + "-hours");\r
+                       this.calPanel.getFlexCellFormatter().setColSpan(8, 0, 7);\r
+                       this.calPanel.setWidget(8, 0, p);\r
                }\r
-               hourTable.setHTML(i, 0, "<span>" + hstr + "</span>");\r
-               hourTable.getCellFormatter().setStyleName(i, 0,\r
-                       CLASSNAME + "-time");\r
-           }\r
-           List entries = this.entrySource.getEntries(curr,\r
-                   DateTimeService.RESOLUTION_HOUR);\r
-           String text = "";\r
-           if (entries != null) {\r
-               for (Iterator it = entries.iterator(); it.hasNext();) {\r
-                   CalendarEntry entry = (CalendarEntry) it.next();\r
-                   String title = entry.getTitle();\r
-                   String desc = entry.getDescription();\r
-                   text += (text == "" ? "" : ", ");\r
-                   String e = "<span"\r
-                           + (desc != null ? " title=\"" + desc + "\"" : "")\r
-                           + ">";\r
-                   e += (title != null ? title : "?");\r
-                   e += "</span>";\r
-                   text += e;\r
+               Date curr = new Date(date.getTime());\r
+               for (int i = 0; i < 24; i++) {\r
+                       curr.setHours(i);\r
+                       String style = (i % 2 == 0 ? "even" : "odd");\r
+                       if (realResolution >= RESOLUTION_HOUR) {\r
+                               if (this.date != null && this.date.getHours() == i) {\r
+                                       style = "selected";\r
+                               }\r
+                       }\r
+                       hourTable.getRowFormatter().setStyleName(i,\r
+                                       CLASSNAME + "-row-" + style);\r
+                       if (firstRender) {\r
+                               String hstr = (i < 10 ? "0" : "") + i + ":00";\r
+                               if (this.dts.isTwelveHourClock()) {\r
+                                       String ampm = (i < 12 ? "am" : "pm");\r
+                                       hstr = (i <= 12 ? i : i - 12) + ":00 " + ampm;\r
+                               }\r
+                               hourTable.setHTML(i, 0, "<span>" + hstr + "</span>");\r
+                               hourTable.getCellFormatter().setStyleName(i, 0,\r
+                                               CLASSNAME + "-time");\r
+                       }\r
+                       List entries = this.entrySource.getEntries(curr,\r
+                                       DateTimeService.RESOLUTION_HOUR);\r
+                       String text = "";\r
+                       if (entries != null) {\r
+                               for (Iterator it = entries.iterator(); it.hasNext();) {\r
+                                       CalendarEntry entry = (CalendarEntry) it.next();\r
+                                       String title = entry.getTitle();\r
+                                       String desc = entry.getDescription();\r
+                                       text += (text == "" ? "" : ", ");\r
+                                       String e = "<span"\r
+                                                       + (desc != null ? " title=\"" + desc + "\"" : "")\r
+                                                       + ">";\r
+                                       e += (title != null ? title : "?");\r
+                                       e += "</span>";\r
+                                       text += e;\r
+                               }\r
+                       }\r
+                       hourTable.setHTML(i, 1, text);\r
+                       hourTable.getCellFormatter().setStyleName(i, 1,\r
+                                       CLASSNAME + "-title");\r
                }\r
-           }\r
-           hourTable.setHTML(i, 1, text);\r
-           hourTable.getCellFormatter().setStyleName(i, 1,\r
-                   CLASSNAME + "-title");\r
+\r
        }\r
 \r
-    }\r
+       private class HourTableListener implements TableListener {\r
 \r
-    private class HourTableListener implements TableListener {\r
+               public void onCellClicked(SourcesTableEvents sender, int row, int cell) {\r
+                       if (realResolution < RESOLUTION_HOUR || date == null) {\r
+                               return;\r
+                       }\r
+                       date.setHours(row);\r
+                       client.updateVariable(id, "hour", row, immediate);\r
+               }\r
 \r
-       public void onCellClicked(SourcesTableEvents sender, int row, int cell) {\r
-           if (realResolution < RESOLUTION_HOUR || date == null) {\r
-               return;\r
-           }\r
-           date.setHours(row);\r
-           client.updateVariable(id, "hour", row, immediate);\r
        }\r
 \r
-    }\r
-\r
-    private class EntrySource implements CalendarPanel.CalendarEntrySource {\r
-\r
-       private HashMap items = new HashMap();\r
-\r
-       public void addItem(UIDL item) {\r
-           Integer id = new Integer(item.getIntAttribute("id"));\r
-           long start = Long.parseLong(item.getStringAttribute("start"));\r
-           Date startDate = new Date(start);\r
-           long end = Long.parseLong(item.getStringAttribute("end"));\r
-           Date endDate = (end > 0 && end != start ? new Date(end) : new Date(\r
-                   start));\r
-           String title = item.getStringAttribute("title");\r
-           String desc = item.getStringAttribute("description");\r
-           boolean notime = item.getBooleanAttribute("notime");\r
-           if (items.containsKey(id)) {\r
-               items.remove(id);\r
-           }\r
-           items.put(id, new CalendarEntry(startDate, endDate, title, desc,\r
-                   notime));\r
-       }\r
+       private class EntrySource implements CalendarPanel.CalendarEntrySource {\r
+\r
+               private HashMap items = new HashMap();\r
+\r
+               public void addItem(UIDL item) {\r
+                       Integer id = new Integer(item.getIntAttribute("id"));\r
+                       long start = Long.parseLong(item.getStringAttribute("start"));\r
+                       Date startDate = new Date(start);\r
+                       long end = Long.parseLong(item.getStringAttribute("end"));\r
+                       Date endDate = (end > 0 && end != start ? new Date(end) : new Date(\r
+                                       start));\r
+                       String title = item.getStringAttribute("title");\r
+                       String desc = item.getStringAttribute("description");\r
+                       boolean notime = item.getBooleanAttribute("notime");\r
+                       if (items.containsKey(id)) {\r
+                               items.remove(id);\r
+                       }\r
+                       items.put(id, new CalendarEntry(startDate, endDate, title, desc,\r
+                                       notime));\r
+               }\r
 \r
-       public List getEntries(Date date, int resolution) {\r
-           ArrayList res = new ArrayList();\r
-           for (Iterator it = this.items.values().iterator(); it.hasNext();) {\r
-               CalendarEntry item = (CalendarEntry) it.next();\r
-               if (DateTimeService.isInRange(date, item.getStart(), item\r
-                       .getEnd(), resolution)) {\r
-                   res.add(item);\r
+               public List getEntries(Date date, int resolution) {\r
+                       ArrayList res = new ArrayList();\r
+                       for (Iterator it = this.items.values().iterator(); it.hasNext();) {\r
+                               CalendarEntry item = (CalendarEntry) it.next();\r
+                               if (DateTimeService.isInRange(date, item.getStart(), item\r
+                                               .getEnd(), resolution)) {\r
+                                       res.add(item);\r
+                               }\r
+                       }\r
+\r
+                       return res;\r
                }\r
-           }\r
 \r
-           return res;\r
-       }\r
+               public void clear() {\r
+                       items.clear();\r
+               }\r
 \r
-       public void clear() {\r
-           items.clear();\r
        }\r
 \r
-    }\r
-\r
 }\r
index 6282c9d5f86a344def7b3b0e384f29bceb380433..9998eda636d2a97fd706c265e26aff4c98e2d28f 100644 (file)
@@ -6,9 +6,9 @@ import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection;
 import com.itmill.toolkit.terminal.gwt.client.Paintable;
 import com.itmill.toolkit.terminal.gwt.client.UIDL;
 
-public class ICheckBox extends com.google.gwt.user.client.ui.CheckBox
-               implements Paintable {
-       
+public class ICheckBox extends com.google.gwt.user.client.ui.CheckBox implements
+               Paintable {
+
        public static final String CLASSNAME = "i-checkbox";
 
        String id;
@@ -31,7 +31,7 @@ public class ICheckBox extends com.google.gwt.user.client.ui.CheckBox
        }
 
        public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
-               
+
                // Ensure correct implementation
                if (client.updateComponent(this, uidl, false))
                        return;
index 322b9359bcf4647446f4ee00f084675a0f0f06d8..e75adb340dd2fbf868bd33c0701e785fb4379f54 100644 (file)
@@ -7,7 +7,7 @@ import com.itmill.toolkit.terminal.gwt.client.Paintable;
 import com.itmill.toolkit.terminal.gwt.client.UIDL;
 
 public class ICustomComponent extends SimplePanel implements Paintable {
-       
+
        private static final String CLASSNAME = "i-customcomponent";
 
        public ICustomComponent() {
@@ -16,12 +16,12 @@ public class ICustomComponent extends SimplePanel implements Paintable {
        }
 
        public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
-               
+
                UIDL child = uidl.getChildUIDL(0);
-               if(child != null) {
+               if (child != null) {
                        Paintable p = (Paintable) client.getWidget(child);
-                       if(p != getWidget()) {
-                               if(getWidget() != null) {
+                       if (p != getWidget()) {
+                               if (getWidget() != null) {
                                        client.unregisterPaintable((Paintable) getWidget());
                                        clear();
                                }
index 29ecf576523c0d822fcdf0d53ccc3402e2ed598c..ba143440cf6f0b46a1eef0f258d4b317145807e9 100644 (file)
@@ -47,12 +47,14 @@ public class ICustomLayout extends ComplexPanel implements Paintable, Container
        }
 
        /**
-        * Sets widget to given location. 
+        * Sets widget to given location.
         * 
         * If location already contains a widget it will be removed.
         * 
-        * @param widget Widget to be set into location.
-        * @param location location name where widget will be added
+        * @param widget
+        *            Widget to be set into location.
+        * @param location
+        *            location name where widget will be added
         * 
         * @throws IllegalArgumentException
         *             if no such location is found in the layout.
@@ -75,9 +77,9 @@ public class ICustomLayout extends ComplexPanel implements Paintable, Container
                if (previous == widget)
                        return;
                remove(previous);
-               
+
                // if template is missing add element in order
-               if(!hasTemplate())
+               if (!hasTemplate())
                        elem = getElement();
 
                // Add widget to location
@@ -94,7 +96,7 @@ public class ICustomLayout extends ComplexPanel implements Paintable, Container
 
                // Update PID
                pid = uidl.getId();
-               if(!hasTemplate()) {
+               if (!hasTemplate()) {
                        // Update HTML template only once
                        initializeHTML(uidl, client);
                }
@@ -114,7 +116,7 @@ public class ICustomLayout extends ComplexPanel implements Paintable, Container
                                }
                        }
                }
-               
+
                // Evaluate scripts only once
                if (scripts != null) {
                        eval(scripts);
@@ -128,9 +130,12 @@ public class ICustomLayout extends ComplexPanel implements Paintable, Container
                String newTemplate = uidl.getStringAttribute("template");
 
                // Get the HTML-template from client
-               String template = client.getResource("layouts/" + newTemplate + ".html");
+               String template = client
+                               .getResource("layouts/" + newTemplate + ".html");
                if (template == null) {
-                       template = "<em>Layout file layouts/" + newTemplate + ".html is missing. Components will be drawn for debug purposes.</em>";
+                       template = "<em>Layout file layouts/"
+                                       + newTemplate
+                                       + ".html is missing. Components will be drawn for debug purposes.</em>";
                } else {
                        currentTemplate = newTemplate;
                }
@@ -148,15 +153,16 @@ public class ICustomLayout extends ComplexPanel implements Paintable, Container
                while (parent != null && !(parent instanceof IView))
                        parent = parent.getParent();
                if (parent != null && ((IView) parent).getTheme() != null) {
-                   prefixImgSrcs(getElement(), "../ITK-INF/themes/" + ((IView) parent).getTheme()
-                               + "/layouts/");
+                       prefixImgSrcs(getElement(), "../ITK-INF/themes/"
+                                       + ((IView) parent).getTheme() + "/layouts/");
                } else {
-                   throw(new IllegalStateException("Could not find IView; maybe updateFromUIDL() was called before attaching the widget?"));
+                       throw (new IllegalStateException(
+                                       "Could not find IView; maybe updateFromUIDL() was called before attaching the widget?"));
                }
        }
-       
+
        private boolean hasTemplate() {
-               if(currentTemplate == null)
+               if (currentTemplate == null)
                        return false;
                else
                        return true;
@@ -267,14 +273,15 @@ public class ICustomLayout extends ComplexPanel implements Paintable, Container
                setWidget(to, location);
        }
 
-       /** Does this layout contain given child*/
+       /** Does this layout contain given child */
        public boolean hasChildComponent(Widget component) {
                return locationToWidget.containsValue(component);
        }
 
        /** Update caption for given widget */
        public void updateCaption(Paintable component, UIDL uidl) {
-               CaptionWrapper wrapper = (CaptionWrapper) widgetToCaptionWrapper.get(component);
+               CaptionWrapper wrapper = (CaptionWrapper) widgetToCaptionWrapper
+                               .get(component);
                if (Caption.isNeeded(uidl)) {
                        if (wrapper == null) {
                                String loc = getLocation((Widget) component);
@@ -285,10 +292,11 @@ public class ICustomLayout extends ComplexPanel implements Paintable, Container
                        }
                        wrapper.updateCaption(uidl);
                } else {
-                       if (wrapper != null) { 
+                       if (wrapper != null) {
                                String loc = getLocation((Widget) component);
                                super.remove(wrapper);
-                               super.add((Widget) wrapper.getPaintable(), (Element) locationToElement.get(loc));
+                               super.add((Widget) wrapper.getPaintable(),
+                                               (Element) locationToElement.get(loc));
                                widgetToCaptionWrapper.remove(component);
                        }
                }
@@ -314,7 +322,7 @@ public class ICustomLayout extends ComplexPanel implements Paintable, Container
                if (cw != null) {
                        widgetToCaptionWrapper.remove(w);
                        return super.remove(cw);
-               } else if(w != null)
+               } else if (w != null)
                        return super.remove(w);
                return false;
        }
index 43c17e0a5453df21eca5b91cb0c9cb304bb03469..12635655be5bb4a045fbc0ed2c200d66bf2f4c72 100644 (file)
@@ -12,13 +12,13 @@ import com.itmill.toolkit.terminal.gwt.client.UIDL;
 public class IDateField extends FlowPanel implements Paintable {\r
 \r
        public static final String CLASSNAME = "i-datefield";\r
-       \r
+\r
        String id;\r
-       \r
+\r
        ApplicationConnection client;\r
-       \r
+\r
        protected boolean immediate;\r
-       \r
+\r
        public static int RESOLUTION_YEAR = 0;\r
        public static int RESOLUTION_MONTH = 1;\r
        public static int RESOLUTION_DAY = 2;\r
@@ -26,24 +26,24 @@ public class IDateField extends FlowPanel implements Paintable {
        public static int RESOLUTION_MIN = 4;\r
        public static int RESOLUTION_SEC = 5;\r
        public static int RESOLUTION_MSEC = 6;\r
-       \r
+\r
        protected int currentResolution = RESOLUTION_YEAR;\r
-       \r
+\r
        protected String currentLocale;\r
-       \r
+\r
        protected boolean readonly;\r
-       \r
+\r
        protected boolean enabled;\r
-       \r
+\r
        protected Date date = null;\r
-       \r
+\r
        protected DateTimeService dts;\r
-       \r
+\r
        public IDateField() {\r
                setStyleName(CLASSNAME);\r
                dts = new DateTimeService();\r
        }\r
-       \r
+\r
        public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {\r
                // Ensure correct implementation and let layout manage caption\r
                if (client.updateComponent(this, uidl, true))\r
@@ -53,11 +53,11 @@ public class IDateField extends FlowPanel implements Paintable {
                this.client = client;\r
                this.id = uidl.getId();\r
                this.immediate = uidl.getBooleanAttribute("immediate");\r
-               \r
+\r
                readonly = uidl.getBooleanAttribute("readonly");\r
                enabled = !uidl.getBooleanAttribute("disabled");\r
-               \r
-               if(uidl.hasAttribute("locale")) {\r
+\r
+               if (uidl.hasAttribute("locale")) {\r
                        String locale = uidl.getStringAttribute("locale");\r
                        try {\r
                                dts.setLocale(locale);\r
@@ -65,47 +65,57 @@ public class IDateField extends FlowPanel implements Paintable {
                        } catch (LocaleNotLoadedException e) {\r
                                currentLocale = dts.getLocale();\r
                                // TODO redirect this to console\r
-                               System.out.println("Tried to use an unloaded locale \"" + locale + "\". Using default locale (" + currentLocale + ").");\r
+                               System.out.println("Tried to use an unloaded locale \""\r
+                                               + locale + "\". Using default locale (" + currentLocale\r
+                                               + ").");\r
                        }\r
                }\r
 \r
                int newResolution;\r
-               if(uidl.hasVariable("msec"))\r
+               if (uidl.hasVariable("msec"))\r
                        newResolution = RESOLUTION_MSEC;\r
-               else if(uidl.hasVariable("sec"))\r
+               else if (uidl.hasVariable("sec"))\r
                        newResolution = RESOLUTION_SEC;\r
-               else if(uidl.hasVariable("min"))\r
+               else if (uidl.hasVariable("min"))\r
                        newResolution = RESOLUTION_MIN;\r
-               else if(uidl.hasVariable("hour"))\r
+               else if (uidl.hasVariable("hour"))\r
                        newResolution = RESOLUTION_HOUR;\r
-               else if(uidl.hasVariable("day"))\r
+               else if (uidl.hasVariable("day"))\r
                        newResolution = RESOLUTION_DAY;\r
-               else if(uidl.hasVariable("month"))\r
+               else if (uidl.hasVariable("month"))\r
                        newResolution = RESOLUTION_MONTH;\r
                else\r
                        newResolution = RESOLUTION_YEAR;\r
-               \r
+\r
                currentResolution = newResolution;\r
-               \r
+\r
                int year = uidl.getIntVariable("year");\r
-               int month = (currentResolution >= RESOLUTION_MONTH)? uidl.getIntVariable("month") : -1;\r
-               int day = (currentResolution >= RESOLUTION_DAY)? uidl.getIntVariable("day") : -1;\r
-               int hour = (currentResolution >= RESOLUTION_HOUR)? uidl.getIntVariable("hour") : -1;\r
-               int min = (currentResolution >= RESOLUTION_MIN)? uidl.getIntVariable("min") : -1;\r
-               int sec = (currentResolution >= RESOLUTION_SEC)? uidl.getIntVariable("sec") : -1;\r
-               int msec = (currentResolution >= RESOLUTION_MSEC)? uidl.getIntVariable("msec") : -1;\r
-               \r
+               int month = (currentResolution >= RESOLUTION_MONTH) ? uidl\r
+                               .getIntVariable("month") : -1;\r
+               int day = (currentResolution >= RESOLUTION_DAY) ? uidl\r
+                               .getIntVariable("day") : -1;\r
+               int hour = (currentResolution >= RESOLUTION_HOUR) ? uidl\r
+                               .getIntVariable("hour") : -1;\r
+               int min = (currentResolution >= RESOLUTION_MIN) ? uidl\r
+                               .getIntVariable("min") : -1;\r
+               int sec = (currentResolution >= RESOLUTION_SEC) ? uidl\r
+                               .getIntVariable("sec") : -1;\r
+               int msec = (currentResolution >= RESOLUTION_MSEC) ? uidl\r
+                               .getIntVariable("msec") : -1;\r
+\r
                // Construct new date for this datefield (only if not null)\r
-               if(year > -1)\r
-                       date = new Date((long) getTime(year, month, day, hour, min, sec, msec));\r
-               \r
+               if (year > -1)\r
+                       date = new Date((long) getTime(year, month, day, hour, min, sec,\r
+                                       msec));\r
+\r
        }\r
-       \r
+\r
        /*\r
-        * We need this redundant native function because \r
-        * Java's Date object doesn't have a setMilliseconds method.\r
+        * We need this redundant native function because Java's Date object doesn't\r
+        * have a setMilliseconds method.\r
         */\r
-       private static native double getTime(int y, int m, int d, int h, int mi, int s, int ms) /*-{\r
+       private static native double getTime(int y, int m, int d, int h, int mi,\r
+                       int s, int ms) /*-{\r
        try {\r
                var date = new Date();\r
                if(y && y >= 0) date.setFullYear(y);\r
@@ -122,7 +132,7 @@ public class IDateField extends FlowPanel implements Paintable {
                return (new Date()).getTime();\r
        }\r
        }-*/;\r
-       \r
+\r
        public int getMilliseconds() {\r
                return (int) (date.getTime() - date.getTime() / 1000 * 1000);\r
        }\r
@@ -132,50 +142,50 @@ public class IDateField extends FlowPanel implements Paintable {
        }\r
 \r
        public int getCurrentResolution() {\r
-           return currentResolution;\r
+               return currentResolution;\r
        }\r
 \r
        public void setCurrentResolution(int currentResolution) {\r
-           this.currentResolution = currentResolution;\r
+               this.currentResolution = currentResolution;\r
        }\r
 \r
        public String getCurrentLocale() {\r
-           return currentLocale;\r
+               return currentLocale;\r
        }\r
 \r
        public void setCurrentLocale(String currentLocale) {\r
-           this.currentLocale = currentLocale;\r
+               this.currentLocale = currentLocale;\r
        }\r
 \r
        public Date getCurrentDate() {\r
-           return date;\r
+               return date;\r
        }\r
 \r
        public void setCurrentDate(Date date) {\r
-           this.date = date;\r
+               this.date = date;\r
        }\r
 \r
        public boolean isImmediate() {\r
-           return immediate;\r
+               return immediate;\r
        }\r
 \r
        public boolean isReadonly() {\r
-           return readonly;\r
+               return readonly;\r
        }\r
 \r
        public boolean isEnabled() {\r
-           return enabled;\r
+               return enabled;\r
        }\r
 \r
        public DateTimeService getDateTimeService() {\r
-           return dts;\r
+               return dts;\r
        }\r
 \r
        public String getId() {\r
-           return id;\r
+               return id;\r
        }\r
 \r
        public ApplicationConnection getClient() {\r
-           return client;\r
+               return client;\r
        }\r
 }\r
index e48f35cd1218cd6fc3c526f4a384d58fb62d36bb..276170f990d6df8f97e0f0311c5ffef6fffc6954 100644 (file)
@@ -4,16 +4,16 @@ import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection;
 import com.itmill.toolkit.terminal.gwt.client.UIDL;\r
 \r
 public class IDateFieldCalendar extends IDateField {\r
-       \r
+\r
        private CalendarPanel date;\r
-       \r
+\r
        public IDateFieldCalendar() {\r
                super();\r
-               setStyleName(CLASSNAME+"-calendar");\r
+               setStyleName(CLASSNAME + "-calendar");\r
                date = new CalendarPanel(this);\r
                add(date);\r
        }\r
-       \r
+\r
        public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {\r
                super.updateFromUIDL(uidl, client);\r
                date.updateCalendar();\r
index ce9a261a5d2fc4aed8fc5503ecf8fea65a51b276..b0677746ca6125850b299bf5629881bb21cd83cb 100644 (file)
@@ -8,20 +8,25 @@ import com.itmill.toolkit.terminal.gwt.client.UIDL;
 public class IEmbedded extends HTML implements Paintable {
 
        public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
-               if(client.updateComponent(this, uidl, true))
+               if (client.updateComponent(this, uidl, true))
                        return;
-               
-               if(uidl.hasAttribute("type") && uidl.getStringAttribute("type").equals("image")) {
-                       setHTML("<img src=\""+ uidl.getStringAttribute("src") +"\"/>");
-               } else if(uidl.hasAttribute("mimetype") && 
-                               uidl.getStringAttribute("mimetype").equals("application/x-shockwave-flash")) {
-                       String w = uidl.hasAttribute("width") ? uidl.getStringAttribute("width") : "100";
-                       String h = uidl.hasAttribute("height") ? uidl.getStringAttribute("height") : "100";
-                       
-                       setHTML("<object width=\""+w+"\" height=\""+h+"\"><param name=\"movie\" value=\""+
-                                       uidl.getStringAttribute("src") + "\"><embed src=\""+
-                                       uidl.getStringAttribute("src") + "\" width=\""+ w +
-                                       "\" height=\""+h+"\"></embed></object>");
+
+               if (uidl.hasAttribute("type")
+                               && uidl.getStringAttribute("type").equals("image")) {
+                       setHTML("<img src=\"" + uidl.getStringAttribute("src") + "\"/>");
+               } else if (uidl.hasAttribute("mimetype")
+                               && uidl.getStringAttribute("mimetype").equals(
+                                               "application/x-shockwave-flash")) {
+                       String w = uidl.hasAttribute("width") ? uidl
+                                       .getStringAttribute("width") : "100";
+                       String h = uidl.hasAttribute("height") ? uidl
+                                       .getStringAttribute("height") : "100";
+
+                       setHTML("<object width=\"" + w + "\" height=\"" + h
+                                       + "\"><param name=\"movie\" value=\""
+                                       + uidl.getStringAttribute("src") + "\"><embed src=\""
+                                       + uidl.getStringAttribute("src") + "\" width=\"" + w
+                                       + "\" height=\"" + h + "\"></embed></object>");
                } else {
                        setText("Terminal don't know how ty handle this type of embed");
                }
index ecbfcf35a7a96cac0bdd3ddeb0dab528658d2b9d..953b5efd4dcc590eee263c1890e7d6ec48f75e96 100644 (file)
@@ -130,8 +130,10 @@ public class IExpandLayout extends IOrderedLayout implements
                Element expandedElement = DOM.getParent(expandedWidget.getElement());
                // take expanded element temporarely out of flow to make container
                // minimum sized
-               String origiginalPositioning = DOM.getStyleAttribute(expandedWidget.getElement(), "position");
-               DOM.setStyleAttribute(expandedWidget.getElement(), "position", "absolute");
+               String origiginalPositioning = DOM.getStyleAttribute(expandedWidget
+                               .getElement(), "position");
+               DOM.setStyleAttribute(expandedWidget.getElement(), "position",
+                               "absolute");
                DOM.setStyleAttribute(expandedElement, "height", "");
 
                // add temp element to make some measurements
@@ -150,7 +152,8 @@ public class IExpandLayout extends IOrderedLayout implements
                // Component margins will bleed if overflow is not hidden
                DOM.setStyleAttribute(expandedElement, "overflow", "hidden");
 
-               DOM.setStyleAttribute(expandedWidget.getElement(), "position", origiginalPositioning);
+               DOM.setStyleAttribute(expandedWidget.getElement(), "position",
+                               origiginalPositioning);
 
                DOM.removeChild(childContainer, meter);
 
index cd28799e712c0e8d87fe23d4e5f638dce946bb51..03aa883d917b49cb25ba5bf7e3fc6d5004a78fb9 100644 (file)
@@ -27,9 +27,8 @@ import com.itmill.toolkit.terminal.gwt.client.Util;
 
 /**
  * 
- * TODO needs major refactoring to be easily expandable
- * TODO add new items
- * TODO null selections
+ * TODO needs major refactoring to be easily expandable TODO add new items TODO
+ * null selections
  */
 public class IFilterSelect extends Composite implements Paintable,
                KeyboardListener, ClickListener {
@@ -164,7 +163,7 @@ public class IFilterSelect extends Composite implements Paintable,
                        if (index > -1)
                                menu.selectItem((MenuItem) menu.getItems().get(index));
                        else if (index == -1) {
-                               if(currentPage > 0)
+                               if (currentPage > 0)
                                        filterOptions(currentPage - 1);
                        } else {
                                menu.selectItem((MenuItem) menu.getItems().get(
@@ -389,9 +388,9 @@ public class IFilterSelect extends Composite implements Paintable,
                                tb.setText(suggestion.getReplacementString());
                                currentSuggestion = suggestion;
                        }
-                       
+
                        // Collect captions so we can calculate minimum width for textarea
-                       if(captions.length() > 0)
+                       if (captions.length() > 0)
                                captions += "|";
                        captions += suggestion.getReplacementString();
                }
@@ -401,23 +400,25 @@ public class IFilterSelect extends Composite implements Paintable,
                                        totalSuggestions);
                        filtering = false;
                }
-               
+
                // Calculate minumum textarea width
                int minw = minWidth(captions);
-               if(Util.isIE()) {
+               if (Util.isIE()) {
                        Element spacer = DOM.createDiv();
-                       DOM.setStyleAttribute(spacer, "width", minw+"px");
+                       DOM.setStyleAttribute(spacer, "width", minw + "px");
                        DOM.setStyleAttribute(spacer, "height", "0");
                        DOM.setStyleAttribute(spacer, "overflow", "hidden");
                        DOM.appendChild(panel.getElement(), spacer);
                } else {
-                       DOM.setStyleAttribute(tb.getElement(), "minWidth", minw+"px");
+                       DOM.setStyleAttribute(tb.getElement(), "minWidth", minw + "px");
                }
-               
+
                // Set columns (width) is given
-               if(uidl.hasAttribute("cols"))
-                       DOM.setStyleAttribute(getElement(), "width", uidl.getIntAttribute("cols")+"em");
-               
+               if (uidl.hasAttribute("cols"))
+                       DOM.setStyleAttribute(getElement(), "width", uidl
+                                       .getIntAttribute("cols")
+                                       + "em");
+
        }
 
        public void onSuggestionSelected(FilterSelectSuggestion suggestion) {
@@ -504,7 +505,7 @@ public class IFilterSelect extends Composite implements Paintable,
                tb.setFocus(true);
                tb.selectAll();
        }
-       
+
        /*
         * Calculate minumum width for FilterSelect textarea
         */
index 5d9231efb9e0f52be9e8f610216ceb7b34d1858b..06c93dcfac09ed957ffa7df75ee398b5c5934a7b 100644 (file)
@@ -8,26 +8,25 @@ import com.itmill.toolkit.terminal.gwt.client.Paintable;
 import com.itmill.toolkit.terminal.gwt.client.UIDL;\r
 \r
 public class IForm extends SimplePanel implements Paintable {\r
-       \r
+\r
        public static final String CLASSNAME = "i-form";\r
-       \r
-       private Container  lo;\r
+\r
+       private Container lo;\r
 \r
        private ApplicationConnection client;\r
-       \r
+\r
        public IForm() {\r
                super();\r
                setStyleName(CLASSNAME);\r
        }\r
-       \r
+\r
        public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {\r
                this.client = client;\r
                UIDL layoutUidl = uidl.getChildUIDL(0);\r
-               if(lo == null) {\r
+               if (lo == null) {\r
                        lo = (Container) client.getWidget(layoutUidl);\r
                        setWidget((Widget) lo);\r
                }\r
                lo.updateFromUIDL(layoutUidl, client);\r
        }\r
 }\r
-\r
index 400169ffa67c4af66f3c8c432281bcbea17ba31c..3dfe2ab055fe390a05de34ec2930c69c5b27e2c5 100644 (file)
@@ -15,35 +15,35 @@ import com.itmill.toolkit.terminal.gwt.client.UIDL;
  * Two col Layout that places caption on left col and field on right col
  */
 public class IFormLayout extends FlexTable implements Container {
-       
+
        HashMap componentToCaption = new HashMap();
        private ApplicationConnection client;
-       
+
        public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
                this.client = client;
                int i = 0;
-               for(Iterator it = uidl.getChildIterator();it.hasNext();i++) {
+               for (Iterator it = uidl.getChildIterator(); it.hasNext(); i++) {
                        prepareCell(i, 1);
                        UIDL childUidl = (UIDL) it.next();
                        Paintable p = (Paintable) client.getWidget(childUidl);
                        Caption c = (Caption) componentToCaption.get(p);
-                       if(c == null) {
+                       if (c == null) {
                                c = new Caption(p);
                                componentToCaption.put(p, c);
                        }
                        Paintable oldComponent = (Paintable) getWidget(i, 1);
-                       if(oldComponent == null) {
-                               setWidget(i,1,(Widget) p);
+                       if (oldComponent == null) {
+                               setWidget(i, 1, (Widget) p);
                        } else if (oldComponent != p) {
                                client.unregisterPaintable(oldComponent);
-                               setWidget(i,1,(Widget) p);
+                               setWidget(i, 1, (Widget) p);
                        }
-                       setWidget(i,0,c);
+                       setWidget(i, 0, c);
                        p.updateFromUIDL(childUidl, client);
                }
                i++;
-               while(getRowCount() > i) {
-                       Paintable p = (Paintable) getWidget(i,1);
+               while (getRowCount() > i) {
+                       Paintable p = (Paintable) getWidget(i, 1);
                        client.unregisterPaintable(p);
                        componentToCaption.remove(p);
                        removeRow(i);
@@ -56,11 +56,11 @@ public class IFormLayout extends FlexTable implements Container {
 
        public void replaceChildComponent(Widget oldComponent, Widget newComponent) {
                int i;
-               for(i = 0; i < getRowCount(); i++) {
-                       if(oldComponent == getWidget(i, 1)) {
+               for (i = 0; i < getRowCount(); i++) {
+                       if (oldComponent == getWidget(i, 1)) {
                                Caption newCap = new Caption((Paintable) newComponent);
-                               setWidget(i,0,newCap);
-                               setWidget(i,1,newComponent);
+                               setWidget(i, 0, newCap);
+                               setWidget(i, 1, newComponent);
                                client.unregisterPaintable((Paintable) oldComponent);
                                break;
                        }
@@ -69,7 +69,7 @@ public class IFormLayout extends FlexTable implements Container {
 
        public void updateCaption(Paintable component, UIDL uidl) {
                Caption c = (Caption) componentToCaption.get(component);
-               if(c != null)
+               if (c != null)
                        c.updateCaption(uidl);
        }
 }
index a3d2a47144ad0b584c19b072a1c9af8d95c02be6..73b5a95e80890cdd54eadfad80ff88862d1c9df1 100644 (file)
@@ -13,11 +13,10 @@ import com.itmill.toolkit.terminal.gwt.client.Paintable;
 import com.itmill.toolkit.terminal.gwt.client.UIDL;
 
 public class IGridLayout extends FlexTable implements Paintable, Container {
-       
+
        /** Widget to captionwrapper map */
        private HashMap widgetToCaptionWrapper = new HashMap();
 
-
        public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
                clear();
                if (uidl.hasAttribute("caption"))
@@ -25,7 +24,7 @@ public class IGridLayout extends FlexTable implements Paintable, Container {
                int row = 0, column = 0;
 
                ArrayList detachdedPaintables = new ArrayList();
-               
+
                for (Iterator i = uidl.getChildIterator(); i.hasNext();) {
                        UIDL r = (UIDL) i.next();
                        if ("gr".equals(r.getTag())) {
@@ -38,58 +37,58 @@ public class IGridLayout extends FlexTable implements Paintable, Container {
                                                int w;
                                                if (c.hasAttribute("w")) {
                                                        w = c.getIntAttribute("w");
-                                               }
-                                               else
+                                               } else
                                                        w = 1;
-                                               ((FlexCellFormatter) getCellFormatter())
-                                               .setColSpan(row, column, w);
+                                               ((FlexCellFormatter) getCellFormatter()).setColSpan(
+                                                               row, column, w);
 
-                                               
                                                UIDL u = c.getChildUIDL(0);
                                                if (u != null) {
                                                        Widget child = client.getWidget(u);
                                                        prepareCell(row, column);
                                                        Widget oldChild = getWidget(row, column);
-                                                       if(child != oldChild) {
-                                                               if(oldChild != null) {
+                                                       if (child != oldChild) {
+                                                               if (oldChild != null) {
                                                                        CaptionWrapper cw = (CaptionWrapper) oldChild;
                                                                        detachdedPaintables.add(cw.getPaintable());
                                                                        widgetToCaptionWrapper.remove(oldChild);
                                                                }
-                                                               CaptionWrapper wrapper = new CaptionWrapper((Paintable) child);
+                                                               CaptionWrapper wrapper = new CaptionWrapper(
+                                                                               (Paintable) child);
                                                                setWidget(row, column, wrapper);
                                                                widgetToCaptionWrapper.put(child, wrapper);
                                                        }
                                                        ((Paintable) child).updateFromUIDL(u, client);
                                                }
-                                               column += w -1;
+                                               column += w - 1;
                                        }
                                }
                        }
                }
-               
+
                // for loop detached widgets and unregister them unless they are
                // attached (case of widget which is moved to another cell)
-               for(Iterator it = detachdedPaintables.iterator();it.hasNext();) {
+               for (Iterator it = detachdedPaintables.iterator(); it.hasNext();) {
                        Widget w = (Widget) it.next();
-                       if(!w.isAttached())
+                       if (!w.isAttached())
                                client.unregisterPaintable((Paintable) w);
                }
        }
 
        public boolean hasChildComponent(Widget component) {
-               if(widgetToCaptionWrapper.containsKey(component))
+               if (widgetToCaptionWrapper.containsKey(component))
                        return true;
                return false;
        }
 
        public void replaceChildComponent(Widget oldComponent, Widget newComponent) {
                // TODO Auto-generated method stub
-               
+
        }
 
        public void updateCaption(Paintable component, UIDL uidl) {
-               CaptionWrapper wrapper = (CaptionWrapper) widgetToCaptionWrapper.get(component);
+               CaptionWrapper wrapper = (CaptionWrapper) widgetToCaptionWrapper
+                               .get(component);
                wrapper.updateCaption(uidl);
        }
 
index bb204679eff0fc1242e94cf4d5f6c4b191db6bb0..a3721acabbbc77a40ea0b6192e9377b440e8d004 100644 (file)
@@ -6,14 +6,14 @@ import com.itmill.toolkit.terminal.gwt.client.Paintable;
 import com.itmill.toolkit.terminal.gwt.client.UIDL;
 
 public class ILabel extends HTML implements Paintable {
-       
+
        public static final String CLASSNAME = "i-label";
-       
+
        public ILabel() {
                super();
                setStyleName(CLASSNAME);
        }
-       
+
        public ILabel(String text) {
                super(text);
                setStyleName(CLASSNAME);
index 415a89e423c6aee71ff7920c9837dfdcc3949967..64653fb0f038adb3d950efae545b93c7bafd8ec9 100644 (file)
@@ -10,19 +10,19 @@ import com.itmill.toolkit.terminal.gwt.client.Paintable;
 import com.itmill.toolkit.terminal.gwt.client.UIDL;
 
 public class ILink extends HTML implements Paintable, ClickListener {
-       
+
        public static final String CLASSNAME = "i-link";
-       
+
        private static final int BORDER_STYLE_DEFAULT = 0;
        private static final int BORDER_STYLE_MINIMAL = 1;
        private static final int BORDER_STYLE_NONE = 2;
-       
+
        private String src;
-       
+
        private String target;
-       
+
        private int borderStyle = BORDER_STYLE_DEFAULT;
-       
+
        private boolean enabled;
 
        private boolean readonly;
@@ -30,52 +30,53 @@ public class ILink extends HTML implements Paintable, ClickListener {
        private int width;
 
        private int height;
-       
+
        public ILink() {
                super();
                addClickListener(this);
                setStyleName(CLASSNAME);
        }
-       
+
        public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
 
                enabled = uidl.hasAttribute("disabled") ? false : true;
                readonly = uidl.hasAttribute("readonly") ? true : false;
-               
-               if(uidl.hasAttribute("target"))
+
+               if (uidl.hasAttribute("target"))
                        target = uidl.getStringAttribute(target);
-               if(uidl.hasAttribute("src")) {
-                       //TODO theme soure
+               if (uidl.hasAttribute("src")) {
+                       // TODO theme soure
                        src = uidl.getStringAttribute("src");
                }
-               
-               if(uidl.hasAttribute("border")) {
-                       if("none".equals(uidl.getStringAttribute("border")))
+
+               if (uidl.hasAttribute("border")) {
+                       if ("none".equals(uidl.getStringAttribute("border")))
                                borderStyle = BORDER_STYLE_NONE;
                        else
                                borderStyle = BORDER_STYLE_MINIMAL;
                } else {
                        borderStyle = BORDER_STYLE_DEFAULT;
                }
-               
-               height = uidl.hasAttribute("height") ? uidl.getIntAttribute("height") : -1;
+
+               height = uidl.hasAttribute("height") ? uidl.getIntAttribute("height")
+                               : -1;
                width = uidl.hasAttribute("width") ? uidl.getIntAttribute("width") : -1;
-               
+
                DOM.setInnerHTML(getElement(), uidl.getStringAttribute("caption"));
-               
-               if(readonly)
+
+               if (readonly)
                        addStyleName("readonly");
                else
                        removeStyleName("readonly");
-               if(enabled)
+               if (enabled)
                        addStyleName("enabled");
                else
                        removeStyleName("enabled");
        }
 
        public void onClick(Widget sender) {
-               if(enabled && !readonly) {
-                       if(target == null)
+               if (enabled && !readonly) {
+                       if (target == null)
                                target = "_blank";
                        String features;
                        switch (borderStyle) {
@@ -89,17 +90,17 @@ public class ILink extends HTML implements Paintable, ClickListener {
                                features = "menubar=yes,location=yes,scrollbars=yes,status=yes";
                                break;
                        }
-                       if(width > 0 || height > 0) {
+                       if (width > 0 || height > 0) {
                                features += ",resizable=no";
-                               if(width > 0)
+                               if (width > 0)
                                        features += ",width=" + width;
-                               if(height > 0)
+                               if (height > 0)
                                        features += ",height=" + height;
                        } else {
-                               features += ",resizable=yes";                   
+                               features += ",resizable=yes";
                        }
                        Window.open(src, target, features);
                }
        }
-       
+
 }
index d8d759f814d5d6366d79bb9290c7204a578e11a8..e7e8e9289705a267f7f6d83c154f9f3b5830c82c 100644 (file)
@@ -11,28 +11,28 @@ import com.google.gwt.user.client.ui.Widget;
 import com.itmill.toolkit.terminal.gwt.client.UIDL;\r
 \r
 public class IOptionGroup extends IOptionGroupBase {\r
-       \r
+\r
        public static final String CLASSNAME = "i-select-optiongroup";\r
-       \r
+\r
        private Panel panel;\r
-       \r
+\r
        private Map optionsToKeys;\r
-       \r
+\r
        public IOptionGroup() {\r
                super(CLASSNAME);\r
                panel = (Panel) optionsContainer;\r
                optionsToKeys = new HashMap();\r
        }\r
-       \r
+\r
        /*\r
         * Return true if no elements were changed, false otherwise.\r
         */\r
        protected void buildOptions(UIDL uidl) {\r
                panel.clear();\r
-               for(Iterator it = uidl.getChildIterator(); it.hasNext();) {\r
+               for (Iterator it = uidl.getChildIterator(); it.hasNext();) {\r
                        UIDL opUidl = (UIDL) it.next();\r
                        CheckBox op;\r
-                       if(multiselect) {\r
+                       if (multiselect) {\r
                                op = new ICheckBox();\r
                                op.setText(opUidl.getStringAttribute("caption"));\r
                        } else {\r
@@ -41,7 +41,8 @@ public class IOptionGroup extends IOptionGroupBase {
                        }\r
                        op.addStyleName(CLASSNAME_OPTION);\r
                        op.setChecked(opUidl.getBooleanAttribute("selected"));\r
-                       op.setEnabled(!opUidl.getBooleanAttribute("disabled") && !readonly && !disabled);\r
+                       op.setEnabled(!opUidl.getBooleanAttribute("disabled") && !readonly\r
+                                       && !disabled);\r
                        op.addClickListener(this);\r
                        optionsToKeys.put(op, opUidl.getStringAttribute("key"));\r
                        panel.add(op);\r
@@ -51,16 +52,21 @@ public class IOptionGroup extends IOptionGroupBase {
        protected Object[] getSelectedItems() {\r
                return selectedKeys.toArray();\r
        }\r
-       \r
+\r
        public void onClick(Widget sender) {\r
                super.onClick(sender);\r
-               if(sender instanceof CheckBox) {\r
+               if (sender instanceof CheckBox) {\r
                        boolean selected = ((CheckBox) sender).isChecked();\r
                        String key = (String) optionsToKeys.get(sender);\r
-                       if(!multiselect) selectedKeys.clear();\r
-                       if(selected) selectedKeys.add(key);\r
-                       else selectedKeys.remove(key);\r
-                       client.updateVariable(id, "selected", getSelectedItems(), immediate);\r
+                       if (!multiselect)\r
+                               selectedKeys.clear();\r
+                       if (selected)\r
+                               selectedKeys.add(key);\r
+                       else\r
+                               selectedKeys.remove(key);\r
+                       client\r
+                                       .updateVariable(id, "selected", getSelectedItems(),\r
+                                                       immediate);\r
                }\r
        }\r
 \r
index 884a0ccfea3aa2ebb977fa5a2157170607298e35..d57f1e7426ef3c5097fb122d0a410a2ac8e9cff0 100644 (file)
@@ -13,40 +13,40 @@ import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection;
 import com.itmill.toolkit.terminal.gwt.client.Paintable;\r
 import com.itmill.toolkit.terminal.gwt.client.UIDL;\r
 \r
-abstract class IOptionGroupBase extends Composite implements Paintable, ClickListener, ChangeListener, KeyboardListener {\r
-       \r
+abstract class IOptionGroupBase extends Composite implements Paintable,\r
+               ClickListener, ChangeListener, KeyboardListener {\r
+\r
        public static final String CLASSNAME_OPTION = "i-select-option";\r
 \r
        ApplicationConnection client;\r
-       \r
+\r
        String id;\r
-       \r
+\r
        protected boolean immediate;\r
-       \r
+\r
        protected Set selectedKeys;\r
-       \r
+\r
        protected boolean multiselect;\r
-       \r
+\r
        protected boolean disabled;\r
-       \r
+\r
        protected boolean readonly;\r
-       \r
+\r
        /**\r
-        * Widget holding the different options \r
-        * (e.g. ListBox or Panel for radio buttons)\r
-        * (optional, fallbacks to container Panel)\r
+        * Widget holding the different options (e.g. ListBox or Panel for radio\r
+        * buttons) (optional, fallbacks to container Panel)\r
         */\r
        protected Widget optionsContainer;\r
-       \r
+\r
        /**\r
         * Panel containing the component\r
         */\r
        private Panel container;\r
-       \r
+\r
        private ITextField newItemField;\r
-       \r
+\r
        private IButton newItemButton;\r
-       \r
+\r
        public IOptionGroupBase(String classname) {\r
                container = new FlowPanel();\r
                initWidget(container);\r
@@ -55,36 +55,37 @@ abstract class IOptionGroupBase extends Composite implements Paintable, ClickLis
                immediate = false;\r
                multiselect = false;\r
        }\r
-       \r
-       /* Call this if you wish to specify your own container \r
-        * for the option elements (e.g. SELECT)\r
+\r
+       /*\r
+        * Call this if you wish to specify your own container for the option\r
+        * elements (e.g. SELECT)\r
         */\r
        public IOptionGroupBase(Widget w, String classname) {\r
                this(classname);\r
                optionsContainer = w;\r
                container.add(optionsContainer);\r
        }\r
-       \r
+\r
        public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {\r
                this.client = client;\r
                this.id = uidl.getId();\r
-               \r
-               if(client.updateComponent(this, uidl, true))\r
+\r
+               if (client.updateComponent(this, uidl, true))\r
                        return;\r
-               \r
+\r
                selectedKeys = uidl.getStringArrayVariableAsSet("selected");\r
-               \r
+\r
                readonly = uidl.getBooleanAttribute("readonly");\r
                disabled = uidl.getBooleanAttribute("disabled");\r
                multiselect = "multi".equals(uidl.getStringAttribute("selectmode"));\r
                immediate = uidl.getBooleanAttribute("immediate");\r
-               \r
+\r
                UIDL ops = uidl.getChildUIDL(0);\r
-               \r
+\r
                buildOptions(ops);\r
-               \r
-               if(uidl.getBooleanAttribute("allownewitem")) {\r
-                       if(newItemField == null) {\r
+\r
+               if (uidl.getBooleanAttribute("allownewitem")) {\r
+                       if (newItemField == null) {\r
                                newItemButton = new IButton();\r
                                newItemButton.setText("+");\r
                                newItemButton.addClickListener(this);\r
@@ -94,53 +95,56 @@ abstract class IOptionGroupBase extends Composite implements Paintable, ClickLis
                        }\r
                        newItemField.setEnabled(!disabled && !readonly);\r
                        newItemButton.setEnabled(!disabled && !readonly);\r
-                       \r
-                       if(newItemField != null && newItemField.getParent() == container)\r
+\r
+                       if (newItemField != null && newItemField.getParent() == container)\r
                                return;\r
                        container.add(newItemField);\r
                        container.add(newItemButton);\r
-               } else if(newItemField != null) {\r
+               } else if (newItemField != null) {\r
                        container.remove(newItemField);\r
                        container.remove(newItemButton);\r
                }\r
-               \r
+\r
        }\r
 \r
        public void onClick(Widget sender) {\r
-               if(sender == newItemButton && !newItemField.getText().equals("")) {\r
+               if (sender == newItemButton && !newItemField.getText().equals("")) {\r
                        client.updateVariable(id, "newitem", newItemField.getText(), true);\r
                        newItemField.setText("");\r
                }\r
        }\r
-       \r
+\r
        public void onChange(Widget sender) {\r
-               if(multiselect) {\r
-                       client.updateVariable(id, "selected", getSelectedItems(), immediate);\r
+               if (multiselect) {\r
+                       client\r
+                                       .updateVariable(id, "selected", getSelectedItems(),\r
+                                                       immediate);\r
                } else {\r
-                       client.updateVariable(id, "selected", new String[] { "" + getSelectedItem()}, immediate);\r
+                       client.updateVariable(id, "selected", new String[] { ""\r
+                                       + getSelectedItem() }, immediate);\r
                }\r
        }\r
-       \r
+\r
        public void onKeyPress(Widget sender, char keyCode, int modifiers) {\r
-               if(sender == newItemField && keyCode==KeyboardListener.KEY_ENTER)\r
+               if (sender == newItemField && keyCode == KeyboardListener.KEY_ENTER)\r
                        newItemButton.click();\r
        }\r
-       \r
+\r
        public void onKeyUp(Widget sender, char keyCode, int modifiers) {\r
                // Ignore, subclasses may override\r
        }\r
-       \r
+\r
        public void onKeyDown(Widget sender, char keyCode, int modifiers) {\r
                // Ignore, subclasses may override\r
        }\r
-       \r
+\r
        protected abstract void buildOptions(UIDL uidl);\r
-       \r
+\r
        protected abstract Object[] getSelectedItems();\r
-       \r
+\r
        protected Object getSelectedItem() {\r
                Object[] sel = getSelectedItems();\r
-               if(sel.length > 0)\r
+               if (sel.length > 0)\r
                        return sel[0];\r
                else\r
                        return null;\r
index d7048cd375a2b74ebfa718d32625e7017c96f83c..bbc5655d0172f42f84bb4c8a347072eaf8c7b04b 100644 (file)
@@ -16,17 +16,18 @@ import com.itmill.toolkit.terminal.gwt.client.Paintable;
 import com.itmill.toolkit.terminal.gwt.client.UIDL;
 
 /**
- * Abstract base class for ordered layouts.
- * Use either vertical or horizontal subclass.
+ * Abstract base class for ordered layouts. Use either vertical or horizontal
+ * subclass.
+ * 
  * @author IT Mill Ltd
  */
 public abstract class IOrderedLayout extends ComplexPanel implements Container {
-       
+
        public static final String CLASSNAME = "i-orderedlayout";
 
        public static final int ORIENTATION_VERTICAL = 0;
        public static final int ORIENTATION_HORIZONTAL = 1;
-       
+
        int orientationMode = ORIENTATION_VERTICAL;
 
        protected HashMap componentToCaption = new HashMap();
@@ -34,8 +35,8 @@ public abstract class IOrderedLayout extends ComplexPanel implements Container {
        protected ApplicationConnection client;
 
        /**
-        * Contains reference to Element where Paintables are wrapped. For  horizontal
-        * layout this is TR and for vertical DIV.
+        * Contains reference to Element where Paintables are wrapped. For
+        * horizontal layout this is TR and for vertical DIV.
         */
        protected Element childContainer;
 
@@ -44,7 +45,7 @@ public abstract class IOrderedLayout extends ComplexPanel implements Container {
                constructDOM();
                setStyleName(CLASSNAME);
        }
-       
+
        protected void constructDOM() {
                switch (orientationMode) {
                case ORIENTATION_HORIZONTAL:
@@ -62,11 +63,10 @@ public abstract class IOrderedLayout extends ComplexPanel implements Container {
                }
        }
 
-       
        public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
-               
+
                this.client = client;
-               
+
                // Ensure correct implementation
                if (client.updateComponent(this, uidl, false))
                        return;
@@ -77,24 +77,24 @@ public abstract class IOrderedLayout extends ComplexPanel implements Container {
                        Widget child = client.getWidget(uidlForChild);
                        uidlWidgets.add(child);
                }
-               
+
                ArrayList oldWidgets = getPaintables();
-               
+
                Iterator oldIt = oldWidgets.iterator();
                Iterator newIt = uidlWidgets.iterator();
                Iterator newUidl = uidl.getChildIterator();
-               
+
                Widget oldChild = null;
-               while(newIt.hasNext()) {
+               while (newIt.hasNext()) {
                        Widget child = (Widget) newIt.next();
                        UIDL childUidl = (UIDL) newUidl.next();
-                       if(oldChild == null && oldIt.hasNext()) {
+                       if (oldChild == null && oldIt.hasNext()) {
                                // search for next old Paintable which still exists in layout
                                // and delete others
-                               while(oldIt.hasNext()) {
+                               while (oldIt.hasNext()) {
                                        oldChild = (Widget) oldIt.next();
                                        // now oldChild is an instance of Paintable
-                                       if(uidlWidgets.contains(oldChild))
+                                       if (uidlWidgets.contains(oldChild))
                                                break;
                                        else {
                                                removePaintable((Paintable) oldChild);
@@ -102,38 +102,39 @@ public abstract class IOrderedLayout extends ComplexPanel implements Container {
                                        }
                                }
                        }
-                       if(oldChild == null) {
+                       if (oldChild == null) {
                                // we are adding components to layout
                                add(child);
-                       } else if(child == oldChild) {
+                       } else if (child == oldChild) {
                                // child already attached and updated
                                oldChild = null;
-                       } else if(hasChildComponent(child)) {
-                               // current child has been moved, re-insert before current oldChild
+                       } else if (hasChildComponent(child)) {
+                               // current child has been moved, re-insert before current
+                               // oldChild
                                // TODO this might be optimized by moving only container element
                                // to correct position
                                removeCaption(child);
                                int index = getWidgetIndex(oldChild);
-                               if(componentToCaption.containsKey(oldChild))
+                               if (componentToCaption.containsKey(oldChild))
                                        index--;
                                remove(child);
                                this.insert(child, index);
                        } else {
                                // insert new child before old one
                                int index = getWidgetIndex(oldChild);
-                               insert(child,index);
+                               insert(child, index);
                        }
-                       ((Paintable)child).updateFromUIDL(childUidl, client);
+                       ((Paintable) child).updateFromUIDL(childUidl, client);
                }
-               // remove possibly remaining old Paintable object which were not updated 
-               while(oldIt.hasNext()) {
+               // remove possibly remaining old Paintable object which were not updated
+               while (oldIt.hasNext()) {
                        oldChild = (Widget) oldIt.next();
                        Paintable p = (Paintable) oldChild;
-                       if(!uidlWidgets.contains(p))
+                       if (!uidlWidgets.contains(p))
                                removePaintable(p);
                }
        }
-       
+
        /**
         * Retuns a list of Paintables currently rendered in layout
         * 
@@ -149,17 +150,18 @@ public abstract class IOrderedLayout extends ComplexPanel implements Container {
                }
                return al;
        }
-       
+
        /**
         * Removes Paintable from DOM and its reference from ApplicationConnection.
         * 
         * Also removes Paintable's Caption if one exists
         * 
-        * @param p Paintable to be removed
+        * @param p
+        *            Paintable to be removed
         */
        public boolean removePaintable(Paintable p) {
                Caption c = (Caption) componentToCaption.get(p);
-               if(c != null) {
+               if (c != null) {
                        componentToCaption.remove(c);
                        remove(c);
                }
@@ -167,8 +169,11 @@ public abstract class IOrderedLayout extends ComplexPanel implements Container {
                return remove((Widget) p);
        }
 
-       /* (non-Javadoc)
-        * @see com.itmill.toolkit.terminal.gwt.client.Layout#replaceChildComponent(com.google.gwt.user.client.ui.Widget, com.google.gwt.user.client.ui.Widget)
+       /*
+        * (non-Javadoc)
+        * 
+        * @see com.itmill.toolkit.terminal.gwt.client.Layout#replaceChildComponent(com.google.gwt.user.client.ui.Widget,
+        *      com.google.gwt.user.client.ui.Widget)
         */
        public void replaceChildComponent(Widget from, Widget to) {
                client.unregisterPaintable((Paintable) from);
@@ -189,7 +194,8 @@ public abstract class IOrderedLayout extends ComplexPanel implements Container {
                        Caption c = (Caption) w;
                        // captions go into same container element as their
                        // owners
-                       Element container = DOM.getParent(((UIObject) c.getOwner()).getElement());
+                       Element container = DOM.getParent(((UIObject) c.getOwner())
+                                       .getElement());
                        Element captionContainer = DOM.createDiv();
                        DOM.insertChild(container, captionContainer, 0);
                        insert(w, captionContainer, beforeIndex, false);
@@ -199,7 +205,7 @@ public abstract class IOrderedLayout extends ComplexPanel implements Container {
                        insert(w, container, beforeIndex, false);
                }
        }
-       
+
        /**
         * creates an Element which will contain child widget
         */
@@ -212,15 +218,14 @@ public abstract class IOrderedLayout extends ComplexPanel implements Container {
                }
        }
 
-       
        public boolean hasChildComponent(Widget component) {
                return getWidgetIndex(component) >= 0;
        }
 
        public void updateCaption(Paintable component, UIDL uidl) {
-               
-               Caption c  = (Caption) componentToCaption.get(component);
-               
+
+               Caption c = (Caption) componentToCaption.get(component);
+
                if (Caption.isNeeded(uidl)) {
                        if (c == null) {
                                int index = getWidgetIndex((Widget) component);
@@ -230,16 +235,16 @@ public abstract class IOrderedLayout extends ComplexPanel implements Container {
                        }
                        c.updateCaption(uidl);
                } else {
-                       if (c != null) { 
+                       if (c != null) {
                                remove(c);
                                componentToCaption.remove(component);
                        }
                }
        }
-       
+
        public void removeCaption(Widget w) {
                Caption c = (Caption) componentToCaption.get(w);
-               if(c != null) {
+               if (c != null) {
                        this.remove(c);
                        componentToCaption.remove(w);
                }
@@ -248,18 +253,18 @@ public abstract class IOrderedLayout extends ComplexPanel implements Container {
        public void add(Widget w) {
                Element wrapper = createWidgetWrappper();
                DOM.appendChild(childContainer, wrapper);
-               super.add(w,wrapper);
+               super.add(w, wrapper);
        }
 
        public boolean remove(int index) {
-           return remove(getWidget(index));
+               return remove(getWidget(index));
        }
-       
+
        public boolean remove(Widget w) {
                Element wrapper = DOM.getParent(w.getElement());
                boolean removed = super.remove(w);
-               if(removed) {
-                       if (! (w instanceof Caption)) {
+               if (removed) {
+                       if (!(w instanceof Caption)) {
                                DOM.removeChild(childContainer, wrapper);
                        }
                        return true;
index df751dfeaa30105fb3c64cec03c3a336d5552927..d323d171b70b4b910df02958b0f28b9d52a06e7a 100644 (file)
@@ -2,7 +2,7 @@ package com.itmill.toolkit.terminal.gwt.client.ui;
 \r
 public class IOrderedLayoutHorizontal extends IOrderedLayout {\r
 \r
-    public IOrderedLayoutHorizontal() {\r
-       super(ORIENTATION_HORIZONTAL);\r
-    }\r
+       public IOrderedLayoutHorizontal() {\r
+               super(ORIENTATION_HORIZONTAL);\r
+       }\r
 }\r
index 19b150b941baff5a5623622afc3b2d3bf3e2cff7..10de874f651a33c8847f83820ee8dbbb1419ca76 100644 (file)
@@ -2,7 +2,7 @@ package com.itmill.toolkit.terminal.gwt.client.ui;
 \r
 public class IOrderedLayoutVertical extends IOrderedLayout {\r
 \r
-    public IOrderedLayoutVertical() {\r
-       super(ORIENTATION_VERTICAL);\r
-    }\r
+       public IOrderedLayoutVertical() {\r
+               super(ORIENTATION_VERTICAL);\r
+       }\r
 }\r
index 1926575903f26554035ea16d7aa9cc8e2e7bf50b..fb23d8433b06f842782aff2fa615ca94bc12c6fc 100644 (file)
@@ -24,7 +24,7 @@ public class IPanel extends SimplePanel implements Paintable,
        private Element bottomDecoration = DOM.createDiv();
 
        private Element contentNode = DOM.createDiv();
-       
+
        private String height;
 
        public IPanel() {
@@ -89,10 +89,10 @@ public class IPanel extends SimplePanel implements Paintable,
                                        + "-nocaption");
                        DOM.setInnerHTML(captionNode, "");
                }
-               
+
                // Height adjustment
                iLayout();
-               
+
                // Render content
                UIDL layoutUidl = uidl.getChildUIDL(0);
                Widget layout = client.getWidget(layoutUidl);
@@ -112,8 +112,8 @@ public class IPanel extends SimplePanel implements Paintable,
                        DOM.setStyleAttribute(contentNode, "height", "0");
                        DOM.setStyleAttribute(contentNode, "overflow", "hidden");
                        int h = getOffsetHeight();
-                       int total = neededHeight-h;
-                       if(total < 0)
+                       int total = neededHeight - h;
+                       if (total < 0)
                                total = 0;
                        DOM.setStyleAttribute(contentNode, "height", total + "px");
                        DOM.setStyleAttribute(contentNode, "overflow", "");
index 18ff9304b3500063e3e06a3db5bf26534846778b..1dd3043f321a2e23cbf85044fa75c039a11d297d 100644 (file)
@@ -6,12 +6,12 @@ import com.google.gwt.user.client.DOM;
  * This class represents a password field.\r
  * \r
  * @author IT Mill Ltd.\r
- *\r
+ * \r
  */\r
 public class IPasswordField extends ITextField {\r
-       \r
+\r
        public IPasswordField() {\r
                super(DOM.createInputPassword());\r
        }\r
-       \r
+\r
 }\r
index 62885d657861f0b3646caaaba00fd23da87424fb..8f9e6ecb1ad59bb833b8dd19efd48f86ce2295dc 100644 (file)
@@ -9,56 +9,58 @@ import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection;
 import com.itmill.toolkit.terminal.gwt.client.Paintable;\r
 import com.itmill.toolkit.terminal.gwt.client.UIDL;\r
 \r
-public class IPopupCalendar extends ITextualDate implements Paintable, ClickListener, PopupListener {\r
-       \r
+public class IPopupCalendar extends ITextualDate implements Paintable,\r
+               ClickListener, PopupListener {\r
+\r
        private IButton calendarToggle;\r
-       \r
+\r
        private CalendarPanel calendar;\r
-       \r
+\r
        private PopupPanel popup;\r
-       \r
+\r
        public IPopupCalendar() {\r
                super();\r
-               \r
+\r
                calendarToggle = new IButton();\r
                calendarToggle.setText("...");\r
                calendarToggle.addClickListener(this);\r
                add(calendarToggle);\r
-               \r
+\r
                calendar = new CalendarPanel(this);\r
                popup = new PopupPanel(true);\r
-               popup.setStyleName(IDateField.CLASSNAME+"-calendar");\r
+               popup.setStyleName(IDateField.CLASSNAME + "-calendar");\r
                popup.setWidget(calendar);\r
                popup.addPopupListener(this);\r
        }\r
-       \r
+\r
        public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {\r
                super.updateFromUIDL(uidl, client);\r
-               if(date != null)\r
+               if (date != null)\r
                        calendar.updateCalendar();\r
                calendarToggle.setEnabled(enabled);\r
        }\r
 \r
        public void onClick(Widget sender) {\r
-               if(sender == calendarToggle) {\r
-                               calendar.updateCalendar();\r
-                               popup.show();\r
-                               int w = calendar.getOffsetWidth();\r
-                               int h = calendar.getOffsetHeight();\r
-                               int t = calendarToggle.getAbsoluteTop();\r
-                               int l = calendarToggle.getAbsoluteLeft();\r
-                               if(l+w > Window.getClientWidth())\r
-                                       l = Window.getClientWidth() - w;\r
-                               if(t+h > Window.getClientHeight())\r
-                                       t = Window.getClientHeight() - h - calendarToggle.getOffsetHeight() - 2;\r
-                               popup.setPopupPosition(l, t + calendarToggle.getOffsetHeight() + 2);\r
-                               popup.setWidth(w + "px");\r
-                               popup.setHeight(h + "px");\r
+               if (sender == calendarToggle) {\r
+                       calendar.updateCalendar();\r
+                       popup.show();\r
+                       int w = calendar.getOffsetWidth();\r
+                       int h = calendar.getOffsetHeight();\r
+                       int t = calendarToggle.getAbsoluteTop();\r
+                       int l = calendarToggle.getAbsoluteLeft();\r
+                       if (l + w > Window.getClientWidth())\r
+                               l = Window.getClientWidth() - w;\r
+                       if (t + h > Window.getClientHeight())\r
+                               t = Window.getClientHeight() - h\r
+                                               - calendarToggle.getOffsetHeight() - 2;\r
+                       popup.setPopupPosition(l, t + calendarToggle.getOffsetHeight() + 2);\r
+                       popup.setWidth(w + "px");\r
+                       popup.setHeight(h + "px");\r
                }\r
        }\r
 \r
        public void onPopupClosed(PopupPanel sender, boolean autoClosed) {\r
-               if(sender == popup)\r
+               if (sender == popup)\r
                        buildDate();\r
        }\r
 \r
index d0a5b1c6dce47491967e0fc1ef8cc38b901d386b..9c9bedfd9b856ce35d6a3d7c135763b9c87578bc 100644 (file)
@@ -9,13 +9,13 @@ import com.itmill.toolkit.terminal.gwt.client.Paintable;
 import com.itmill.toolkit.terminal.gwt.client.UIDL;
 
 public class IProgressIndicator extends Widget implements Paintable {
-       
+
        private static final String CLASSNAME = "i-progressindicator";
        Element wrapper = DOM.createDiv();
        Element indicator = DOM.createDiv();
        private ApplicationConnection client;
        private Poller poller;
-       
+
        public IProgressIndicator() {
                setElement(wrapper);
                setStyleName(CLASSNAME);
@@ -26,29 +26,29 @@ public class IProgressIndicator extends Widget implements Paintable {
        public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
                poller.cancel();
                this.client = client;
-               if(client.updateComponent(this, uidl, true))
+               if (client.updateComponent(this, uidl, true))
                        return;
                boolean indeterminate = uidl.getBooleanAttribute("indeterminate");
-               
-               if(indeterminate) {
+
+               if (indeterminate) {
                        // TODO put up some image or something
                } else {
                        try {
                                float f = Float.parseFloat(uidl.getStringAttribute("state"));
-                               int size = Math.round(100*f);
+                               int size = Math.round(100 * f);
                                DOM.setStyleAttribute(indicator, "width", size + "%");
                        } catch (Exception e) {
                        }
                }
                poller.scheduleRepeating(uidl.getIntAttribute("pollinginterval"));
        }
-       
+
        class Poller extends Timer {
 
                public void run() {
                        client.sendPendingVariableChanges();
                }
-               
+
        }
-       
+
 }
index 04d6e544523066548c19f27cdb23804f70c6c185..268cc6d530bf220dba80790a8d132493a99791a4 100644 (file)
@@ -1688,14 +1688,14 @@ public class IScrollTable extends Composite implements Table, ScrollListener,
                         *            element where to attach contenxt menu event
                         */
                        private native void attachContextMenuEvent(Element el) /*-{
-                                                               var row = this;
-                                                               el.oncontextmenu = function(e) {
-                                                                       if(!e)
-                                                                               e = $wnd.event;
-                                                                       row.@com.itmill.toolkit.terminal.gwt.client.ui.IScrollTable.IScrollTableBody.IScrollTableRow::showContextMenu(Lcom/google/gwt/user/client/Event;)(e);
-                                                                       return false;
-                                                               };
-                                                       }-*/;
+                                                                               var row = this;
+                                                                               el.oncontextmenu = function(e) {
+                                                                                       if(!e)
+                                                                                               e = $wnd.event;
+                                                                                       row.@com.itmill.toolkit.terminal.gwt.client.ui.IScrollTable.IScrollTableBody.IScrollTableRow::showContextMenu(Lcom/google/gwt/user/client/Event;)(e);
+                                                                                       return false;
+                                                                               };
+                                                                       }-*/;
 
                        public String getKey() {
                                return String.valueOf(rowKey);
index 99d25f75e5d742d305f3a3dbddf633acd94989e1..b60b9ccf39a2007d881bb48e2375b347ae273338 100644 (file)
@@ -8,49 +8,53 @@ import com.google.gwt.user.client.ui.Widget;
 import com.itmill.toolkit.terminal.gwt.client.UIDL;
 
 public class ISelect extends IOptionGroupBase {
-       
+
        public static final String CLASSNAME = "i-select";
-       
+
        private static final int VISIBLE_COUNT = 10;
-       
+
        private ListBox select;
-       
+
        public ISelect() {
                super(new ListBox(), CLASSNAME);
                select = (ListBox) optionsContainer;
                select.addChangeListener(this);
-               select.setStyleName(CLASSNAME+"-select");
+               select.setStyleName(CLASSNAME + "-select");
        }
 
        protected void buildOptions(UIDL uidl) {
                select.setMultipleSelect(multiselect);
-               if(multiselect) 
+               if (multiselect)
                        select.setVisibleItemCount(VISIBLE_COUNT);
-               else 
+               else
                        select.setVisibleItemCount(1);
                select.setEnabled(!disabled && !readonly);
                select.clear();
                for (Iterator i = uidl.getChildIterator(); i.hasNext();) {
-                       UIDL optionUidl = (UIDL)i.next();
-                       select.addItem(optionUidl.getStringAttribute("caption"), optionUidl.getStringAttribute("key"));
-                       if(optionUidl.hasAttribute("selected"))
-                               select.setItemSelected(select.getItemCount()-1, true);
+                       UIDL optionUidl = (UIDL) i.next();
+                       select.addItem(optionUidl.getStringAttribute("caption"), optionUidl
+                                       .getStringAttribute("key"));
+                       if (optionUidl.hasAttribute("selected"))
+                               select.setItemSelected(select.getItemCount() - 1, true);
                }
        }
-       
+
        protected Object[] getSelectedItems() {
                Vector selectedItemKeys = new Vector();
-               for(int i = 0; i < select.getItemCount(); i++) {
-                       if(select.isItemSelected(i))
+               for (int i = 0; i < select.getItemCount(); i++) {
+                       if (select.isItemSelected(i))
                                selectedItemKeys.add(select.getValue(i));
                }
                return selectedItemKeys.toArray();
        }
 
        public void onChange(Widget sender) {
-               if(select.isMultipleSelect())
-                       client.updateVariable(id, "selected", getSelectedItems(), immediate);
+               if (select.isMultipleSelect())
+                       client
+                                       .updateVariable(id, "selected", getSelectedItems(),
+                                                       immediate);
                else
-                       client.updateVariable(id, "selected", new String[] { "" + getSelectedItem()}, immediate);
+                       client.updateVariable(id, "selected", new String[] { ""
+                                       + getSelectedItem() }, immediate);
        }
 }
index c356a6461b0955da02ff2d94edef6c7bebd6ee5d..f78d586787b4fad82315312e6b2678dd75266680 100644 (file)
@@ -142,20 +142,20 @@ public class ISplitPanel extends ComplexPanel implements Paintable,
         * @see com.itmill.toolkit.terminal.gwt.client.NeedsLayout#layout()
         */
        public void iLayout() {
-               if(!isAttached()) {
+               if (!isAttached()) {
                        return;
                }
                int wholeSize;
                int pixelPosition;
                ApplicationConnection.getConsole().log("splitterpaneeeli");
-               
+
                switch (orientation) {
                case ORIENTATION_HORIZONTAL:
                        wholeSize = DOM.getElementPropertyInt(wrapper, "clientWidth");
                        pixelPosition = DOM.getElementPropertyInt(splitter, "offsetLeft");
 
                        // reposition splitter in case it is out of box
-                       if(pixelPosition + SPLITTER_SIZE > wholeSize) {
+                       if (pixelPosition + SPLITTER_SIZE > wholeSize) {
                                pixelPosition = wholeSize - SPLITTER_SIZE;
                                setSplitPosition(pixelPosition + "px");
                                return;
@@ -176,9 +176,9 @@ public class ISplitPanel extends ComplexPanel implements Paintable,
                case ORIENTATION_VERTICAL:
                        wholeSize = DOM.getElementPropertyInt(wrapper, "clientHeight");
                        pixelPosition = DOM.getElementPropertyInt(splitter, "offsetTop");
-                       
+
                        // reposition splitter in case it is out of box
-                       if(pixelPosition + SPLITTER_SIZE > wholeSize) {
+                       if (pixelPosition + SPLITTER_SIZE > wholeSize) {
                                pixelPosition = wholeSize - SPLITTER_SIZE;
                                setSplitPosition(pixelPosition + "px");
                                return;
@@ -196,7 +196,6 @@ public class ISplitPanel extends ComplexPanel implements Paintable,
                default:
                        ApplicationConnection.getConsole().log("???");
 
-
                        break;
                }
 
index 03d4a455982d3d90a8d8628067ac1229f7a627bd..134fd30064eb5ba0f475e3e0773997fda1ba8c77 100644 (file)
@@ -15,7 +15,7 @@ import com.itmill.toolkit.terminal.gwt.client.Paintable;
 import com.itmill.toolkit.terminal.gwt.client.UIDL;
 
 public class ITabsheet extends FlowPanel implements Paintable {
-       
+
        public static final String CLASSNAME = "i-tabsheet";
 
        String id;
@@ -27,11 +27,11 @@ public class ITabsheet extends FlowPanel implements Paintable {
        ArrayList captions = new ArrayList();
 
        int activeTabIndex = 0;
-       
+
        private TabBar tb;
        private ITabsheetPanel tp;
        private Element deco;
-       
+
        private TabListener tl = new TabListener() {
 
                public void onTabSelected(SourcesTabEvents sender, int tabIndex) {
@@ -49,39 +49,41 @@ public class ITabsheet extends FlowPanel implements Paintable {
 
        public ITabsheet() {
                setStyleName(CLASSNAME);
-               
+
                tb = new TabBar();
                tp = new ITabsheetPanel();
                deco = DOM.createDiv();
-               
-               tp.setStyleName(CLASSNAME+"-content");
-               tb.setStyleName(CLASSNAME+"-tabs");
-               DOM.setElementProperty(deco, "className", CLASSNAME+"-deco");
-               
+
+               tp.setStyleName(CLASSNAME + "-content");
+               tb.setStyleName(CLASSNAME + "-tabs");
+               DOM.setElementProperty(deco, "className", CLASSNAME + "-deco");
+
                add(tb);
                add(tp);
                DOM.appendChild(getElement(), deco);
-               
+
                tb.addTabListener(tl);
-               
+
                clearTabs();
        }
 
        public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
                this.client = client;
                id = uidl.getId();
-               
+
                // Use cached sub-tree if available
-               if(uidl.getBooleanAttribute("cached"))
+               if (uidl.getBooleanAttribute("cached"))
                        return;
-               
+
                // Adjust width and height
-               String h = uidl.hasAttribute("height")? uidl.getStringAttribute("height") : null;
-               String w = uidl.hasAttribute("width")? uidl.getStringAttribute("width") : null;
-               setWidth(w!=null?w:"auto");
-               
+               String h = uidl.hasAttribute("height") ? uidl
+                               .getStringAttribute("height") : null;
+               String w = uidl.hasAttribute("width") ? uidl
+                               .getStringAttribute("width") : null;
+               setWidth(w != null ? w : "auto");
+
                // Try to calculate the height as close as possible
-               if(h!=null) {
+               if (h != null) {
                        // First, calculate needed pixel height
                        setHeight(h);
                        int neededHeight = getOffsetHeight();
@@ -90,7 +92,7 @@ public class ITabsheet extends FlowPanel implements Paintable {
                        tp.setHeight("0");
                        DOM.setStyleAttribute(tp.getElement(), "overflow", "hidden");
                        int height = getOffsetHeight();
-                       tp.setHeight(neededHeight-height + "px");
+                       tp.setHeight(neededHeight - height + "px");
                        DOM.setStyleAttribute(tp.getElement(), "overflow", "");
                } else {
                        tp.setHeight("auto");
@@ -113,7 +115,7 @@ public class ITabsheet extends FlowPanel implements Paintable {
                                        activeTabIndex = index;
                                        UIDL contentUIDL = tab.getChildUIDL(0);
                                        Widget content = client.getWidget(contentUIDL);
-                                       ((Paintable)content).updateFromUIDL(contentUIDL, client);
+                                       ((Paintable) content).updateFromUIDL(contentUIDL, client);
                                        tp.remove(index);
                                        tp.insert(content, index);
                                }
@@ -123,45 +125,47 @@ public class ITabsheet extends FlowPanel implements Paintable {
                        tabKeys.clear();
                        captions.clear();
                        clearTabs();
-                       
+
                        int index = 0;
                        for (Iterator it = tabs.getChildIterator(); it.hasNext();) {
                                UIDL tab = (UIDL) it.next();
                                String key = tab.getStringAttribute("key");
                                String caption = tab.getStringAttribute("caption");
-                               
+
                                captions.add(caption);
                                tabKeys.add(key);
-                               
+
                                tb.addTab(caption);
-                               
-                               if(tab.getBooleanAttribute("selected")) {
+
+                               if (tab.getBooleanAttribute("selected")) {
                                        Widget content = client.getWidget(tab.getChildUIDL(0));
                                        tp.add(content);
                                        activeTabIndex = index;
-                                       ((Paintable)content).updateFromUIDL(tab.getChildUIDL(0), client);
+                                       ((Paintable) content).updateFromUIDL(tab.getChildUIDL(0),
+                                                       client);
                                } else
                                        tp.add(new ILabel(""));
-                               
+
                                index++;
                        }
                }
-               
+
                // Open selected tab
                tb.selectTab(activeTabIndex);
                tp.showWidget(activeTabIndex);
 
        }
-       
+
        private void clearTabs() {
                int i = tb.getTabCount();
-               while(i>0)
+               while (i > 0)
                        tb.removeTab(--i);
                tp.clear();
-               
+
                // Get rid of unnecessary 100% cell heights in TabBar (really ugly hack)
                Element tr = DOM.getChild(DOM.getChild(tb.getElement(), 0), 0);
-               Element rest = DOM.getChild(DOM.getChild(tr, DOM.getChildCount(tr)-1), 0);
+               Element rest = DOM.getChild(
+                               DOM.getChild(tr, DOM.getChildCount(tr) - 1), 0);
                DOM.removeElementAttribute(rest, "style");
        }
 }
index 7ab01ed1211798479a676289dcba6bbf07ada161..4c37633e82a7f15466284d10f20e3a6f09856cf8 100644 (file)
@@ -10,93 +10,97 @@ import com.google.gwt.user.client.ui.Widget;
  * {@link com.itmill.toolkit.terminal.gwt.client.ui.ITabsheetPanel}.\r
  * \r
  * This class has the same basic functionality as the GWT DeckPanel\r
- * {@link com.google.gwt.user.client.ui.DeckPanel}, with the exception\r
- * that it doesn't manipulate the child widgets' width and height attributes.\r
+ * {@link com.google.gwt.user.client.ui.DeckPanel}, with the exception that it\r
+ * doesn't manipulate the child widgets' width and height attributes.\r
  */\r
 public class ITabsheetPanel extends ComplexPanel {\r
 \r
-  private Widget visibleWidget;\r
+       private Widget visibleWidget;\r
 \r
-  /**\r
-   * Creates an empty tabsheet panel.\r
-   */\r
-  public ITabsheetPanel() {\r
-    setElement(DOM.createDiv());\r
-  }\r
+       /**\r
+        * Creates an empty tabsheet panel.\r
+        */\r
+       public ITabsheetPanel() {\r
+               setElement(DOM.createDiv());\r
+       }\r
 \r
-  /**\r
-   * Adds the specified widget to the deck.\r
-   * \r
-   * @param w the widget to be added\r
-   */\r
-  public void add(Widget w) {\r
-    super.add(w, getElement());\r
-    initChildWidget(w);\r
-  }\r
+       /**\r
+        * Adds the specified widget to the deck.\r
+        * \r
+        * @param w\r
+        *            the widget to be added\r
+        */\r
+       public void add(Widget w) {\r
+               super.add(w, getElement());\r
+               initChildWidget(w);\r
+       }\r
 \r
-  /**\r
-   * Gets the index of the currently-visible widget.\r
-   * \r
-   * @return the visible widget's index\r
-   */\r
-  public int getVisibleWidget() {\r
-    return getWidgetIndex(visibleWidget);\r
-  }\r
+       /**\r
+        * Gets the index of the currently-visible widget.\r
+        \r
+        * @return the visible widget's index\r
+        */\r
+       public int getVisibleWidget() {\r
+               return getWidgetIndex(visibleWidget);\r
+       }\r
 \r
-  /**\r
-   * Inserts a widget before the specified index.\r
-   * \r
-   * @param w the widget to be inserted\r
-   * @param beforeIndex the index before which it will be inserted\r
-   * @throws IndexOutOfBoundsException if <code>beforeIndex</code> is out of\r
-   *           range\r
-   */\r
-  public void insert(Widget w, int beforeIndex) {\r
-    super.insert(w, getElement(), beforeIndex, true);\r
-    initChildWidget(w);\r
-  }\r
+       /**\r
+        * Inserts a widget before the specified index.\r
+        * \r
+        * @param w\r
+        *            the widget to be inserted\r
+        * @param beforeIndex\r
+        *            the index before which it will be inserted\r
+        * @throws IndexOutOfBoundsException\r
+        *             if <code>beforeIndex</code> is out of range\r
+        */\r
+       public void insert(Widget w, int beforeIndex) {\r
+               super.insert(w, getElement(), beforeIndex, true);\r
+               initChildWidget(w);\r
+       }\r
 \r
-  public boolean remove(Widget w) {\r
-    boolean removed = super.remove(w);\r
-    if (removed) {\r
-      resetChildWidget(w);\r
+       public boolean remove(Widget w) {\r
+               boolean removed = super.remove(w);\r
+               if (removed) {\r
+                       resetChildWidget(w);\r
 \r
-      if (visibleWidget == w) {\r
-        visibleWidget = null;\r
-      }\r
-    }\r
-    return removed;\r
-  }\r
+                       if (visibleWidget == w) {\r
+                               visibleWidget = null;\r
+                       }\r
+               }\r
+               return removed;\r
+       }\r
 \r
-  /**\r
-   * Shows the widget at the specified index. This causes the currently- visible\r
-   * widget to be hidden.\r
-   * \r
-   * @param index the index of the widget to be shown\r
-   */\r
-  public void showWidget(int index) {\r
-    checkIndexBoundsForAccess(index);\r
+       /**\r
+        * Shows the widget at the specified index. This causes the currently-\r
+        * visible widget to be hidden.\r
+        * \r
+        * @param index\r
+        *            the index of the widget to be shown\r
+        */\r
+       public void showWidget(int index) {\r
+               checkIndexBoundsForAccess(index);\r
 \r
-    if (visibleWidget != null) {\r
-      visibleWidget.setVisible(false);\r
-    }\r
-    visibleWidget = getWidget(index);\r
-    visibleWidget.setVisible(true);\r
-  }\r
+               if (visibleWidget != null) {\r
+                       visibleWidget.setVisible(false);\r
+               }\r
+               visibleWidget = getWidget(index);\r
+               visibleWidget.setVisible(true);\r
+       }\r
 \r
-  /**\r
-   * Make the widget invisible, and set its width and height to full.\r
-   */\r
-  private void initChildWidget(Widget w) {\r
-    w.setVisible(false);\r
-  }\r
+       /**\r
+        * Make the widget invisible, and set its width and height to full.\r
+        */\r
+       private void initChildWidget(Widget w) {\r
+               w.setVisible(false);\r
+       }\r
 \r
-  /**\r
-   * Make the widget visible, and clear the widget's width and height\r
-   * attributes. This is done so that any changes to the visibility, height, or\r
-   * width of the widget that were done by the panel are undone.\r
-   */\r
-  private void resetChildWidget(Widget w) {\r
-    w.setVisible(true);\r
-  }\r
+       /**\r
+        * Make the widget visible, and clear the widget's width and height\r
+        * attributes. This is done so that any changes to the visibility, height,\r
+        * or width of the widget that were done by the panel are undone.\r
+        */\r
+       private void resetChildWidget(Widget w) {\r
+               w.setVisible(true);\r
+       }\r
 }\r
index 9bcc8bc5ac80de00f925028fd2a540e1665dc368..69fdd7ce4954da30cae5535e9102a7d1f96fb464 100644 (file)
@@ -8,20 +8,20 @@ import com.itmill.toolkit.terminal.gwt.client.UIDL;
  * This class represents a multiline textfield (textarea).\r
  * \r
  * @author IT Mill Ltd.\r
- *\r
+ * \r
  */\r
 public class ITextArea extends ITextField {\r
 \r
        public ITextArea() {\r
                super(DOM.createTextArea());\r
        }\r
-       \r
+\r
        public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {\r
                // Call parent renderer explicitly\r
                super.updateFromUIDL(uidl, client);\r
-               \r
-               if(uidl.hasAttribute("rows"))\r
+\r
+               if (uidl.hasAttribute("rows"))\r
                        setRows(new Integer(uidl.getStringAttribute("rows")).intValue());\r
        }\r
-       \r
+\r
 }\r
index 038777f6f8e2a9e980b1e6a3f7671e89dd8ad4aa..cd3c548e0e53025f13f7cc8545e5456a20c94cbf 100644 (file)
@@ -14,16 +14,16 @@ import com.itmill.toolkit.terminal.gwt.client.UIDL;
  * This class represents a basic text input field with one row.
  * 
  * @author IT Mill Ltd.
- *
+ * 
  */
-public class ITextField extends TextBoxBase implements
-               Paintable, ChangeListener, FocusListener {
-       
+public class ITextField extends TextBoxBase implements Paintable,
+               ChangeListener, FocusListener {
+
        /**
         * The input node CSS classname.
         */
        public static final String CLASSNAME = "i-textfield";
-       
+
        /**
         * This CSS classname is added to the input node on hover.
         */
@@ -34,11 +34,11 @@ public class ITextField extends TextBoxBase implements
        protected ApplicationConnection client;
 
        private boolean immediate = false;
-       
+
        public ITextField() {
                this(DOM.createInputText());
        }
-       
+
        protected ITextField(Element node) {
                super(node);
                setStyleName(CLASSNAME);
@@ -49,41 +49,40 @@ public class ITextField extends TextBoxBase implements
        public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
                this.client = client;
                id = uidl.getId();
-               
-               if(client.updateComponent(this, uidl, true))
+
+               if (client.updateComponent(this, uidl, true))
                        return;
-               
-               immediate  = uidl.getBooleanAttribute("immediate");
 
-               if(uidl.hasAttribute("cols"))
+               immediate = uidl.getBooleanAttribute("immediate");
+
+               if (uidl.hasAttribute("cols"))
                        setColumns(new Integer(uidl.getStringAttribute("cols")).intValue());
-               
+
                setText(uidl.getStringVariable("text"));
-               
 
        }
 
        public void onChange(Widget sender) {
-               if(client != null && id != null)
-                       client.updateVariable(id, "text", getText() , immediate);
+               if (client != null && id != null)
+                       client.updateVariable(id, "text", getText(), immediate);
        }
 
        public void onFocus(Widget sender) {
-               addStyleName(CLASSNAME_FOCUS);  
+               addStyleName(CLASSNAME_FOCUS);
        }
 
        public void onLostFocus(Widget sender) {
                removeStyleName(CLASSNAME_FOCUS);
        }
-       
+
        public void setColumns(int columns) {
                setColumns(getElement(), columns);
        }
-       
+
        public void setRows(int rows) {
                setRows(getElement(), rows);
        }
-       
+
        private native void setColumns(Element e, int c) /*-{
        try {
                switch(e.tagName.toLowerCase()) {
@@ -97,11 +96,11 @@ public class ITextField extends TextBoxBase implements
                }
        } catch (e) {}
        }-*/;
-       
+
        private native void setRows(Element e, int r) /*-{
        try {
                if(e.tagName.toLowerCase() == "textarea")
                        e.rows = r;
        } catch (e) {}
-}-*/;
+       }-*/;
 }
index 7fe11c2cecc89c12394c3aea782b4346e57eafc8..889f74ba980ea609ec1509686eb17fb30eb7d64c 100644 (file)
@@ -1,6 +1,5 @@
 package com.itmill.toolkit.terminal.gwt.client.ui;\r
 \r
-\r
 import com.google.gwt.user.client.Timer;\r
 import com.google.gwt.user.client.ui.ChangeListener;\r
 import com.google.gwt.user.client.ui.Widget;\r
@@ -10,21 +9,22 @@ import com.itmill.toolkit.terminal.gwt.client.Paintable;
 import com.itmill.toolkit.terminal.gwt.client.UIDL;\r
 import com.itmill.toolkit.terminal.gwt.client.util.SimpleDateFormat;\r
 \r
-public class ITextualDate extends IDateField implements Paintable, ChangeListener {\r
-       \r
+public class ITextualDate extends IDateField implements Paintable,\r
+               ChangeListener {\r
+\r
        private ITextField text;\r
-       \r
+\r
        private SimpleDateFormat format;\r
-       \r
+\r
        private DateLocale dl;\r
-       \r
+\r
        public ITextualDate() {\r
                super();\r
                text = new ITextField();\r
                text.addChangeListener(this);\r
                add(text);\r
        }\r
-       \r
+\r
        public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {\r
                super.updateFromUIDL(uidl, client);\r
                buildDate();\r
@@ -33,145 +33,181 @@ public class ITextualDate extends IDateField implements Paintable, ChangeListene
        public void buildDate() {\r
                dl = new DateLocale();\r
                DateLocale.setLocale(currentLocale);\r
-               \r
+\r
                DateLocale.SUPPORTED_DF_TOKENS = DateLocale.TOKENS_RESOLUTION_YEAR;\r
-               if(currentResolution == IDateField.RESOLUTION_MONTH)\r
+               if (currentResolution == IDateField.RESOLUTION_MONTH)\r
                        DateLocale.SUPPORTED_DF_TOKENS = DateLocale.TOKENS_RESOLUTION_MONTH;\r
-               else if(currentResolution >= IDateField.RESOLUTION_DAY)\r
+               else if (currentResolution >= IDateField.RESOLUTION_DAY)\r
                        DateLocale.SUPPORTED_DF_TOKENS = DateLocale.TOKENS_RESOLUTION_DAY;\r
-               \r
+\r
                format = new SimpleDateFormat(cleanFormat(dts.getDateFormat()));\r
                format.setLocale(dl);\r
-               \r
+\r
                // Size the textfield a bit smaller if no clock time is needed\r
-               if(currentResolution <= IDateField.RESOLUTION_DAY)\r
+               if (currentResolution <= IDateField.RESOLUTION_DAY)\r
                        text.setColumns(12);\r
-               \r
+\r
                // Create the initial text for the textfield\r
                String dateText = "";\r
-               if(date != null) {\r
+               if (date != null) {\r
                        dateText = format.format(date);\r
-               \r
-                       if(currentResolution >= IDateField.RESOLUTION_HOUR) {\r
+\r
+                       if (currentResolution >= IDateField.RESOLUTION_HOUR) {\r
                                DateLocale.SUPPORTED_DF_TOKENS = DateLocale.TOKENS_RESOLUTION_ALL;\r
                                int h = date.getHours();\r
-                               if(h > 11 && dts.isTwelveHourClock())\r
+                               if (h > 11 && dts.isTwelveHourClock())\r
                                        h -= 12;\r
-                               int m = currentResolution > IDateField.RESOLUTION_HOUR? date.getMinutes() : 0;\r
-                               dateText += " " + (h<10?"0"+h:""+h) + dts.getClockDelimeter() + (m<10?"0"+m:""+m);\r
+                               int m = currentResolution > IDateField.RESOLUTION_HOUR ? date\r
+                                               .getMinutes() : 0;\r
+                               dateText += " " + (h < 10 ? "0" + h : "" + h)\r
+                                               + dts.getClockDelimeter() + (m < 10 ? "0" + m : "" + m);\r
                        }\r
-                       if(currentResolution >= IDateField.RESOLUTION_SEC) {\r
+                       if (currentResolution >= IDateField.RESOLUTION_SEC) {\r
                                int s = date.getSeconds();\r
-                               dateText += dts.getClockDelimeter() + (s<10?"0"+s:""+s);\r
+                               dateText += dts.getClockDelimeter()\r
+                                               + (s < 10 ? "0" + s : "" + s);\r
                        }\r
-                       if(currentResolution == IDateField.RESOLUTION_MSEC) {\r
+                       if (currentResolution == IDateField.RESOLUTION_MSEC) {\r
                                int ms = getMilliseconds();\r
-                               String text = ""+ms;\r
-                               if(ms<10) text = "00"+text;\r
-                               else if(ms<100) text = "0"+text;\r
+                               String text = "" + ms;\r
+                               if (ms < 10)\r
+                                       text = "00" + text;\r
+                               else if (ms < 100)\r
+                                       text = "0" + text;\r
                                dateText += "." + text;\r
                        }\r
-                       if(currentResolution >= IDateField.RESOLUTION_HOUR && dts.isTwelveHourClock())\r
-                               dateText += " " + (date.getHours()<12? dts.getAmPmStrings()[0] : dts.getAmPmStrings()[1]);\r
+                       if (currentResolution >= IDateField.RESOLUTION_HOUR\r
+                                       && dts.isTwelveHourClock())\r
+                               dateText += " "\r
+                                               + (date.getHours() < 12 ? dts.getAmPmStrings()[0] : dts\r
+                                                               .getAmPmStrings()[1]);\r
                }\r
-               \r
+\r
                text.setText(dateText);\r
-               text.setEnabled(enabled&&!readonly);\r
-               \r
-               if(readonly)\r
+               text.setEnabled(enabled && !readonly);\r
+\r
+               if (readonly)\r
                        text.addStyleName("i-readonly");\r
                else\r
                        text.removeStyleName("i-readonly");\r
        }\r
 \r
        public void onChange(Widget sender) {\r
-               if(sender == text) {\r
-                       if(!text.getText().equals("")) {\r
+               if (sender == text) {\r
+                       if (!text.getText().equals("")) {\r
                                DateLocale.SUPPORTED_DF_TOKENS = DateLocale.TOKENS_RESOLUTION_ALL;\r
-                               if(currentResolution == IDateField.RESOLUTION_YEAR)\r
+                               if (currentResolution == IDateField.RESOLUTION_YEAR)\r
                                        DateLocale.SUPPORTED_DF_TOKENS = DateLocale.TOKENS_RESOLUTION_YEAR;\r
-                               else if(currentResolution == IDateField.RESOLUTION_MONTH)\r
+                               else if (currentResolution == IDateField.RESOLUTION_MONTH)\r
                                        DateLocale.SUPPORTED_DF_TOKENS = DateLocale.TOKENS_RESOLUTION_MONTH;\r
-                               else if(currentResolution == IDateField.RESOLUTION_DAY)\r
+                               else if (currentResolution == IDateField.RESOLUTION_DAY)\r
                                        DateLocale.SUPPORTED_DF_TOKENS = DateLocale.TOKENS_RESOLUTION_DAY;\r
-                               \r
+\r
                                String f = cleanFormat(dts.getDateFormat());\r
-                               \r
-                               if(currentResolution >= IDateField.RESOLUTION_HOUR)\r
-                                       f += " " + (dts.isTwelveHourClock()?\r
-                                                       DateLocale.TOKEN_HOUR_12 + DateLocale.TOKEN_HOUR_12\r
-                                                 : DateLocale.TOKEN_HOUR_24 + DateLocale.TOKEN_HOUR_24)\r
-                                                       + dts.getClockDelimeter() + DateLocale.TOKEN_MINUTE + DateLocale.TOKEN_MINUTE;\r
-                               if(currentResolution >= IDateField.RESOLUTION_SEC)\r
-                                       f += dts.getClockDelimeter() + DateLocale.TOKEN_SECOND + DateLocale.TOKEN_SECOND;\r
-                               if(currentResolution == IDateField.RESOLUTION_MSEC)\r
-                                       f += "." + DateLocale.TOKEN_MILLISECOND + DateLocale.TOKEN_MILLISECOND + DateLocale.TOKEN_MILLISECOND;\r
-                               if(currentResolution >= IDateField.RESOLUTION_HOUR && dts.isTwelveHourClock())\r
+\r
+                               if (currentResolution >= IDateField.RESOLUTION_HOUR)\r
+                                       f += " "\r
+                                                       + (dts.isTwelveHourClock() ? DateLocale.TOKEN_HOUR_12\r
+                                                                       + DateLocale.TOKEN_HOUR_12\r
+                                                                       : DateLocale.TOKEN_HOUR_24\r
+                                                                                       + DateLocale.TOKEN_HOUR_24)\r
+                                                       + dts.getClockDelimeter() + DateLocale.TOKEN_MINUTE\r
+                                                       + DateLocale.TOKEN_MINUTE;\r
+                               if (currentResolution >= IDateField.RESOLUTION_SEC)\r
+                                       f += dts.getClockDelimeter() + DateLocale.TOKEN_SECOND\r
+                                                       + DateLocale.TOKEN_SECOND;\r
+                               if (currentResolution == IDateField.RESOLUTION_MSEC)\r
+                                       f += "." + DateLocale.TOKEN_MILLISECOND\r
+                                                       + DateLocale.TOKEN_MILLISECOND\r
+                                                       + DateLocale.TOKEN_MILLISECOND;\r
+                               if (currentResolution >= IDateField.RESOLUTION_HOUR\r
+                                               && dts.isTwelveHourClock())\r
                                        f += " " + DateLocale.TOKEN_AM_PM;\r
-                               \r
+\r
                                format = new SimpleDateFormat(f);\r
                                DateLocale.setLocale(currentLocale);\r
                                format.setLocale(dl);\r
-                               \r
+\r
                                try {\r
                                        date = format.parse(text.getText());\r
                                } catch (Exception e) {\r
                                        ApplicationConnection.getConsole().log(e.getMessage());\r
-                                       text.addStyleName(ITextField.CLASSNAME+"-error");\r
+                                       text.addStyleName(ITextField.CLASSNAME + "-error");\r
                                        Timer t = new Timer() {\r
                                                public void run() {\r
-                                                       text.removeStyleName(ITextField.CLASSNAME+"-error");\r
+                                                       text.removeStyleName(ITextField.CLASSNAME\r
+                                                                       + "-error");\r
                                                }\r
                                        };\r
                                        t.schedule(2000);\r
                                        return;\r
                                }\r
-                       \r
+\r
                        } else\r
                                date = null;\r
-                       \r
+\r
                        // Update variables\r
                        // (only the smallest defining resolution needs to be immediate)\r
-                       client.updateVariable(id, "year", date!=null?date.getYear()+1900:-1, currentResolution==IDateField.RESOLUTION_YEAR&&immediate);\r
-                       if(currentResolution >= IDateField.RESOLUTION_MONTH)\r
-                               client.updateVariable(id, "month", date!=null?date.getMonth()+1:-1, currentResolution==IDateField.RESOLUTION_MONTH&&immediate);\r
-                       if(currentResolution >= IDateField.RESOLUTION_DAY)\r
-                               client.updateVariable(id, "day", date!=null?date.getDate():-1, currentResolution==IDateField.RESOLUTION_DAY&&immediate);\r
-                       if(currentResolution >= IDateField.RESOLUTION_HOUR)\r
-                               client.updateVariable(id, "hour", date!=null?date.getHours():-1, currentResolution==IDateField.RESOLUTION_HOUR&&immediate);\r
-                       if(currentResolution >= IDateField.RESOLUTION_MIN)\r
-                               client.updateVariable(id, "min", date!=null?date.getMinutes():-1, currentResolution==IDateField.RESOLUTION_MIN&&immediate);\r
-                       if(currentResolution >= IDateField.RESOLUTION_SEC)\r
-                               client.updateVariable(id, "sec", date!=null?date.getSeconds():-1, currentResolution==IDateField.RESOLUTION_SEC&&immediate);\r
-                       if(currentResolution == IDateField.RESOLUTION_MSEC)\r
-                               client.updateVariable(id, "msec", date!=null?getMilliseconds():-1, immediate);\r
-                       \r
+                       client.updateVariable(id, "year",\r
+                                       date != null ? date.getYear() + 1900 : -1,\r
+                                       currentResolution == IDateField.RESOLUTION_YEAR\r
+                                                       && immediate);\r
+                       if (currentResolution >= IDateField.RESOLUTION_MONTH)\r
+                               client.updateVariable(id, "month", date != null ? date\r
+                                               .getMonth() + 1 : -1,\r
+                                               currentResolution == IDateField.RESOLUTION_MONTH\r
+                                                               && immediate);\r
+                       if (currentResolution >= IDateField.RESOLUTION_DAY)\r
+                               client.updateVariable(id, "day", date != null ? date.getDate()\r
+                                               : -1, currentResolution == IDateField.RESOLUTION_DAY\r
+                                               && immediate);\r
+                       if (currentResolution >= IDateField.RESOLUTION_HOUR)\r
+                               client.updateVariable(id, "hour", date != null ? date\r
+                                               .getHours() : -1,\r
+                                               currentResolution == IDateField.RESOLUTION_HOUR\r
+                                                               && immediate);\r
+                       if (currentResolution >= IDateField.RESOLUTION_MIN)\r
+                               client.updateVariable(id, "min", date != null ? date\r
+                                               .getMinutes() : -1,\r
+                                               currentResolution == IDateField.RESOLUTION_MIN\r
+                                                               && immediate);\r
+                       if (currentResolution >= IDateField.RESOLUTION_SEC)\r
+                               client.updateVariable(id, "sec", date != null ? date\r
+                                               .getSeconds() : -1,\r
+                                               currentResolution == IDateField.RESOLUTION_SEC\r
+                                                               && immediate);\r
+                       if (currentResolution == IDateField.RESOLUTION_MSEC)\r
+                               client.updateVariable(id, "msec",\r
+                                               date != null ? getMilliseconds() : -1, immediate);\r
+\r
                        buildDate();\r
                }\r
        }\r
-       \r
+\r
        private String cleanFormat(String format) {\r
                // Remove unnecessary d & M if resolution is too low\r
-               if(currentResolution < IDateField.RESOLUTION_DAY)\r
+               if (currentResolution < IDateField.RESOLUTION_DAY)\r
                        format = format.replaceAll("d", "");\r
-               if(currentResolution < IDateField.RESOLUTION_MONTH)\r
+               if (currentResolution < IDateField.RESOLUTION_MONTH)\r
                        format = format.replaceAll("M", "");\r
-               \r
+\r
                // Remove unsupported patterns\r
                // TODO support for 'G', era designator (used at least in Japan)\r
                format = format.replaceAll("[GzZwWkK]", "");\r
-               \r
+\r
                // Remove extra delimiters ('/' and '.')\r
-               while(format.startsWith("/") || format.startsWith(".") || format.startsWith("-"))\r
+               while (format.startsWith("/") || format.startsWith(".")\r
+                               || format.startsWith("-"))\r
                        format = format.substring(1);\r
-               while(format.endsWith("/") || format.endsWith(".") || format.endsWith("-"))\r
-                       format = format.substring(0, format.length()-1);\r
-               \r
+               while (format.endsWith("/") || format.endsWith(".")\r
+                               || format.endsWith("-"))\r
+                       format = format.substring(0, format.length() - 1);\r
+\r
                // Remove duplicate delimiters\r
                format = format.replaceAll("//", "/");\r
                format = format.replaceAll("\\.\\.", ".");\r
                format = format.replaceAll("--", "-");\r
-                       \r
+\r
                return format.trim();\r
        }\r
 }\r
index b710b00b63e9b04083316838c616bc392524c0d2..be8763e2f26c566a5fc9c54ab0f996b707eeabdb 100644 (file)
@@ -11,40 +11,40 @@ import com.google.gwt.user.client.ui.Widget;
 import com.itmill.toolkit.terminal.gwt.client.UIDL;\r
 \r
 public class ITwinColSelect extends IOptionGroupBase {\r
-       \r
+\r
        private static final String CLASSNAME = "i-select-twincol";\r
-       \r
+\r
        private static final int VISIBLE_COUNT = 10;\r
-       \r
+\r
        private ListBox options;\r
-       \r
+\r
        private ListBox selections;\r
-       \r
+\r
        private IButton add;\r
-       \r
+\r
        private IButton remove;\r
-       \r
+\r
        public ITwinColSelect() {\r
                super(CLASSNAME);\r
                options = new ListBox();\r
                selections = new ListBox();\r
                options.setVisibleItemCount(VISIBLE_COUNT);\r
                selections.setVisibleItemCount(VISIBLE_COUNT);\r
-               options.setStyleName(CLASSNAME+"-options");\r
-               selections.setStyleName(CLASSNAME+"-selections");\r
+               options.setStyleName(CLASSNAME + "-options");\r
+               selections.setStyleName(CLASSNAME + "-selections");\r
                Panel buttons = new FlowPanel();\r
-               buttons.setStyleName(CLASSNAME+"-buttons");\r
+               buttons.setStyleName(CLASSNAME + "-buttons");\r
                add = new IButton();\r
                remove = new IButton();\r
                add.setText(">>");\r
                remove.setText("<<");\r
                add.addClickListener(this);\r
                remove.addClickListener(this);\r
-               Panel p = ((Panel)optionsContainer);\r
+               Panel p = ((Panel) optionsContainer);\r
                p.add(options);\r
                buttons.add(add);\r
                HTML br = new HTML("&nbsp;");\r
-               br.setStyleName(CLASSNAME+"-deco");\r
+               br.setStyleName(CLASSNAME + "-deco");\r
                buttons.add(br);\r
                buttons.add(remove);\r
                p.add(buttons);\r
@@ -62,53 +62,55 @@ public class ITwinColSelect extends IOptionGroupBase {
                options.clear();\r
                selections.clear();\r
                for (Iterator i = uidl.getChildIterator(); i.hasNext();) {\r
-                       UIDL optionUidl = (UIDL)i.next();\r
-                       if(optionUidl.hasAttribute("selected")) {\r
-                               selections.addItem(optionUidl.getStringAttribute("caption"), optionUidl.getStringAttribute("key"));\r
+                       UIDL optionUidl = (UIDL) i.next();\r
+                       if (optionUidl.hasAttribute("selected")) {\r
+                               selections.addItem(optionUidl.getStringAttribute("caption"),\r
+                                               optionUidl.getStringAttribute("key"));\r
                        } else\r
-                               options.addItem(optionUidl.getStringAttribute("caption"), optionUidl.getStringAttribute("key"));\r
+                               options.addItem(optionUidl.getStringAttribute("caption"),\r
+                                               optionUidl.getStringAttribute("key"));\r
                }\r
        }\r
 \r
        protected Object[] getSelectedItems() {\r
                Vector selectedItemKeys = new Vector();\r
-               for(int i = 0; i < selections.getItemCount(); i++) {\r
+               for (int i = 0; i < selections.getItemCount(); i++) {\r
                        selectedItemKeys.add(selections.getValue(i));\r
                }\r
                return selectedItemKeys.toArray();\r
        }\r
-       \r
+\r
        private boolean[] getItemsToAdd() {\r
                boolean[] selectedIndexes = new boolean[options.getItemCount()];\r
-               for(int i = 0; i < options.getItemCount(); i++) {\r
-                       if(options.isItemSelected(i))\r
+               for (int i = 0; i < options.getItemCount(); i++) {\r
+                       if (options.isItemSelected(i))\r
                                selectedIndexes[i] = true;\r
                        else\r
                                selectedIndexes[i] = false;\r
                }\r
                return selectedIndexes;\r
        }\r
-       \r
+\r
        private boolean[] getItemsToRemove() {\r
                boolean[] selectedIndexes = new boolean[selections.getItemCount()];\r
-               for(int i = 0; i < selections.getItemCount(); i++) {\r
-                       if(selections.isItemSelected(i))\r
+               for (int i = 0; i < selections.getItemCount(); i++) {\r
+                       if (selections.isItemSelected(i))\r
                                selectedIndexes[i] = true;\r
                        else\r
                                selectedIndexes[i] = false;\r
                }\r
                return selectedIndexes;\r
        }\r
-       \r
+\r
        public void onClick(Widget sender) {\r
                super.onClick(sender);\r
-               if(sender == add) {\r
+               if (sender == add) {\r
                        boolean[] sel = getItemsToAdd();\r
-                       for(int i=0; i < sel.length; i++) {\r
-                               if(sel[i]) {\r
-                                       int optionIndex = i-(sel.length-options.getItemCount());\r
+                       for (int i = 0; i < sel.length; i++) {\r
+                               if (sel[i]) {\r
+                                       int optionIndex = i - (sel.length - options.getItemCount());\r
                                        selectedKeys.add(options.getValue(optionIndex));\r
-                                       \r
+\r
                                        // Move selection to another column\r
                                        String text = options.getItemText(optionIndex);\r
                                        String value = options.getValue(optionIndex);\r
@@ -116,15 +118,17 @@ public class ITwinColSelect extends IOptionGroupBase {
                                        options.removeItem(optionIndex);\r
                                }\r
                        }\r
-                       client.updateVariable(id, "selected", selectedKeys.toArray(), immediate);\r
-                       \r
-               } else if(sender == remove) {\r
+                       client.updateVariable(id, "selected", selectedKeys.toArray(),\r
+                                       immediate);\r
+\r
+               } else if (sender == remove) {\r
                        boolean[] sel = getItemsToRemove();\r
-                       for(int i=0; i < sel.length; i++) {\r
-                               if(sel[i]) {\r
-                                       int selectionIndex = i-(sel.length-selections.getItemCount());\r
+                       for (int i = 0; i < sel.length; i++) {\r
+                               if (sel[i]) {\r
+                                       int selectionIndex = i\r
+                                                       - (sel.length - selections.getItemCount());\r
                                        selectedKeys.remove(selections.getValue(selectionIndex));\r
-                                       \r
+\r
                                        // Move selection to another column\r
                                        String text = selections.getItemText(selectionIndex);\r
                                        String value = selections.getValue(selectionIndex);\r
@@ -132,7 +136,8 @@ public class ITwinColSelect extends IOptionGroupBase {
                                        selections.removeItem(selectionIndex);\r
                                }\r
                        }\r
-                       client.updateVariable(id, "selected", selectedKeys.toArray(), immediate);\r
+                       client.updateVariable(id, "selected", selectedKeys.toArray(),\r
+                                       immediate);\r
                }\r
        }\r
 \r
index b9d6b55082a1ca66659c12527fa70eaebd92384f..6263c1abeb3d233f28b6ab0fbcd2d74d90631465 100644 (file)
@@ -7,11 +7,11 @@ import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection;
 import com.itmill.toolkit.terminal.gwt.client.Paintable;
 import com.itmill.toolkit.terminal.gwt.client.UIDL;
 
-public class IUnknownComponent extends Composite implements Paintable{
-       
+public class IUnknownComponent extends Composite implements Paintable {
+
        com.google.gwt.user.client.ui.Label caption = new com.google.gwt.user.client.ui.Label();;
        Tree uidlTree = new Tree();
-       
+
        public IUnknownComponent() {
                VerticalPanel panel = new VerticalPanel();
                panel.add(caption);
@@ -20,13 +20,13 @@ public class IUnknownComponent extends Composite implements Paintable{
                setStyleName("itmtk-unknown");
                caption.setStyleName("itmtk-unknown-caption");
        }
-       
+
        public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
                setCaption("Client faced an unknown component type. Unrendered UIDL:");
                uidlTree.clear();
                uidlTree.addItem(uidl.dir());
        }
-       
+
        public void setCaption(String c) {
                caption.setText(c);
        }
index b43293cdc1ed53c9c826e070070a65d80aa6a6d1..f31f33c3e5cd523a25be0f710b9ea1ddf9ee403c 100644 (file)
@@ -87,7 +87,7 @@ public class IUpload extends FormPanel implements Paintable, ClickListener,
                }
                submitted = true;
                ApplicationConnection.getConsole().log("Submitted form");
-               
+
                disableUpload();
 
                /*
@@ -106,7 +106,7 @@ public class IUpload extends FormPanel implements Paintable, ClickListener,
                b.setEnabled(false);
                fu.setVisible(false);
        }
-       
+
        protected void enableUploaod() {
                b.setEnabled(true);
                fu.setVisible(true);
index d06f40e6f8d08d6ccb56b04cb45f7d6e4289b7ca..8cca2b6dce0e4b72df7e14b544134c060bd038ad 100644 (file)
@@ -19,63 +19,65 @@ import com.itmill.toolkit.terminal.gwt.client.Util;
 /**
  * 
  */
-public class IView extends SimplePanel implements Paintable, WindowResizeListener {
-       
+public class IView extends SimplePanel implements Paintable,
+               WindowResizeListener {
+
        private static final String CLASSNAME = "i-view";
 
        private String theme;
-       
+
        private Paintable layout;
-       
+
        private HashSet subWindows = new HashSet();
 
        private String id;
 
        private ShortcutActionHandler actionHandler;
-       
+
        public IView(String elementId) {
                super();
                setStyleName(CLASSNAME);
                DOM.sinkEvents(getElement(), Event.ONKEYDOWN);
-               
+
                RootPanel.get(elementId).add(this);
-               
+
                Window.addWindowResizeListener(this);
        }
-       
+
        public String getTheme() {
                return theme;
        }
-       
+
        public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
-               
+
                this.id = uidl.getId();
-               
+
                // Start drawing from scratch
                clear();
-               
+
                // Some attributes to note
                theme = uidl.getStringAttribute("theme");
-               com.google.gwt.user.client.Window.setTitle(uidl.getStringAttribute("caption"));
-               
+               com.google.gwt.user.client.Window.setTitle(uidl
+                               .getStringAttribute("caption"));
+
                // Process children
                int childIndex = 0;
-               
+
                // Open URL:s
-               while (childIndex < uidl.getChidlCount() && 
-                               "open".equals(uidl.getChildUIDL(childIndex).getTag())) {
+               while (childIndex < uidl.getChidlCount()
+                               && "open".equals(uidl.getChildUIDL(childIndex).getTag())) {
                        UIDL open = uidl.getChildUIDL(childIndex);
                        String url = open.getStringAttribute("src");
                        String target = open.getStringAttribute("target");
                        Window.open(url, target != null ? target : null, "");
                        childIndex++;
                }
-               
+
                // Draw this application level window
                UIDL childUidl = uidl.getChildUIDL(childIndex);
                Paintable lo = (Paintable) client.getWidget(childUidl);
-               if(layout != null) {
-                       if(layout != lo) {
+               if (layout != null) {
+                       if (layout != lo) {
                                // remove old
                                client.unregisterPaintable(layout);
                                // add new
@@ -86,10 +88,10 @@ public class IView extends SimplePanel implements Paintable, WindowResizeListene
                        setWidget((Widget) lo);
                }
                lo.updateFromUIDL(childUidl, client);
-               
+
                // Update subwindows
                HashSet removedSubWindows = new HashSet(subWindows);
-               
+
                // Open new windows
                while ((childUidl = uidl.getChildUIDL(childIndex++)) != null) {
                        if ("window".equals(childUidl.getTag())) {
@@ -99,28 +101,29 @@ public class IView extends SimplePanel implements Paintable, WindowResizeListene
                                } else {
                                        subWindows.add(w);
                                }
-                               ((Paintable)w).updateFromUIDL(childUidl, client);
+                               ((Paintable) w).updateFromUIDL(childUidl, client);
                        } else if ("actions".equals(childUidl.getTag())) {
-                               if(actionHandler == null) {
+                               if (actionHandler == null) {
                                        actionHandler = new ShortcutActionHandler(id, client);
                                }
                                actionHandler.updateActionMap(childUidl);
                        }
                }
-               
+
                // Close old windows
-               for (Iterator rem=removedSubWindows.iterator(); rem.hasNext();) {
+               for (Iterator rem = removedSubWindows.iterator(); rem.hasNext();) {
                        IWindow w = (IWindow) rem.next();
                        client.unregisterPaintable(w);
                        subWindows.remove(w);
                        RootPanel.get().remove(w);
                }
        }
-       
+
        public void onBrowserEvent(Event event) {
                super.onBrowserEvent(event);
                if (DOM.eventGetType(event) == Event.ONKEYDOWN && actionHandler != null) {
-                       int modifiers = KeyboardListenerCollection.getKeyboardModifiers(event);
+                       int modifiers = KeyboardListenerCollection
+                                       .getKeyboardModifiers(event);
                        actionHandler.handleKeyboardEvent(
                                        (char) DOM.eventGetKeyCode(event), modifiers);
                        return;
@@ -132,4 +135,3 @@ public class IView extends SimplePanel implements Paintable, WindowResizeListene
        }
 
 }
-
index 98626adcfb04aca8829c23489590fafb3932c58f..ce26267062c308261a498c1c13dcc85b77c71cea 100644 (file)
@@ -46,7 +46,7 @@ public class IWindow extends PopupPanel implements Paintable, ScrollListener {
        private Element footer;
 
        private Element resizeBox;
-       
+
        private ScrollPanel contentPanel = new ScrollPanel();
 
        private boolean dragging;
@@ -151,7 +151,7 @@ public class IWindow extends PopupPanel implements Paintable, ScrollListener {
                DOM.appendChild(wrapper, contents);
                DOM.appendChild(wrapper, footer);
                setWidget(contentPanel);
-               
+
                // set default size
                setWidth(400 + "px");
                setHeight(300 + "px");
@@ -170,19 +170,18 @@ public class IWindow extends PopupPanel implements Paintable, ScrollListener {
                } else {
 
                        // Initialize the width from UIDL
-                       if(uidl.hasVariable("width")) {
+                       if (uidl.hasVariable("width")) {
                                String width = uidl.getStringVariable("width");
                                setWidth(width);
                        }
-                       if(uidl.hasVariable("height")) {
+                       if (uidl.hasVariable("height")) {
                                String height = uidl.getStringVariable("height");
                                setHeight(height);
                        }
-                       
-                       contentPanel.setScrollPosition(
-                                       uidl.getIntVariable("scrolltop"));
-                       contentPanel.setHorizontalScrollPosition(
-                                       uidl.getIntVariable("scrollleft"));
+
+                       contentPanel.setScrollPosition(uidl.getIntVariable("scrolltop"));
+                       contentPanel.setHorizontalScrollPosition(uidl
+                                       .getIntVariable("scrollleft"));
 
                        // Initialize the position form UIDL
                        try {
@@ -247,7 +246,7 @@ public class IWindow extends PopupPanel implements Paintable, ScrollListener {
        public void setCaption(String c) {
                DOM.setInnerHTML(header, c);
        }
-       
+
        protected Element getContainerElement() {
                return contents;
        }
@@ -304,7 +303,7 @@ public class IWindow extends PopupPanel implements Paintable, ScrollListener {
                        break;
                }
        }
-       
+
        public void setSize(Event event, boolean updateVariables) {
                int w = DOM.eventGetScreenX(event) - startX + origW;
                if (w < 60)
@@ -314,13 +313,13 @@ public class IWindow extends PopupPanel implements Paintable, ScrollListener {
                        h = 60;
                setWidth(w + "px");
                setHeight(h + "px");
-               if(updateVariables) {
+               if (updateVariables) {
                        // sending width back always as pixels, no need for unit
                        client.updateVariable(id, "width", w, false);
                        client.updateVariable(id, "height", h, false);
                }
        }
-       
+
        public void setWidth(String width) {
                super.setWidth(width);
                DOM.setStyleAttribute(header, "width", width);
index d204284bd9dead5f5d807b32b39b2010514c4c8a..47dddb68faeaaee54ded324e6e2314f312e1d66e 100644 (file)
@@ -1,4 +1,5 @@
 package com.itmill.toolkit.terminal.gwt.client.ui;
+
 /*
  * Copyright 2007 Google Inc.
  * 
@@ -16,7 +17,6 @@ package com.itmill.toolkit.terminal.gwt.client.ui;
  */
 
 //COPIED HERE DUE package privates in GWT
-
 import com.google.gwt.user.client.Command;
 import com.google.gwt.user.client.DOM;
 import com.google.gwt.user.client.DeferredCommand;
@@ -52,434 +52,455 @@ import java.util.List;
  */
 public class MenuBar extends Widget implements PopupListener {
 
-  private Element body;
-  private ArrayList items = new ArrayList();
-  private MenuBar parentMenu;
-  private PopupPanel popup;
-  private MenuItem selectedItem;
-  private MenuBar shownChildMenu;
-  private boolean vertical, autoOpen;
-
-  /**
-   * Creates an empty horizontal menu bar.
-   */
-  public MenuBar() {
-    this(false);
-  }
-
-  /**
-   * Creates an empty menu bar.
-   * 
-   * @param vertical <code>true</code> to orient the menu bar vertically
-   */
-  public MenuBar(boolean vertical) {
-    super();
-
-    Element table = DOM.createTable();
-    body = DOM.createTBody();
-    DOM.appendChild(table, body);
-
-    if (!vertical) {
-      Element tr = DOM.createTR();
-      DOM.appendChild(body, tr);
-    }
-
-    this.vertical = vertical;
-
-    Element outer = DOM.createDiv();
-    DOM.appendChild(outer, table);
-    setElement(outer);
-
-    sinkEvents(Event.ONCLICK | Event.ONMOUSEOVER | Event.ONMOUSEOUT);
-    setStyleName("gwt-MenuBar");
-  }
-
-  /**
-   * Adds a menu item to the bar.
-   * 
-   * @param item the item to be added
-   */
-  public void addItem(MenuItem item) {
-    Element tr;
-    if (vertical) {
-      tr = DOM.createTR();
-      DOM.appendChild(body, tr);
-    } else {
-      tr = DOM.getChild(body, 0);
-    }
-
-    DOM.appendChild(tr, item.getElement());
-
-    item.setParentMenu(this);
-    item.setSelectionStyle(false);
-    items.add(item);
-  }
-
-  /**
-   * Adds a menu item to the bar, that will fire the given command when it is
-   * selected.
-   * 
-   * @param text the item's text
-   * @param asHTML <code>true</code> to treat the specified text as html
-   * @param cmd the command to be fired
-   * @return the {@link MenuItem} object created
-   */
-  public MenuItem addItem(String text, boolean asHTML, Command cmd) {
-    MenuItem item = new MenuItem(text, asHTML, cmd);
-    addItem(item);
-    return item;
-  }
-
-  /**
-   * Adds a menu item to the bar, that will open the specified menu when it is
-   * selected.
-   * 
-   * @param text the item's text
-   * @param asHTML <code>true</code> to treat the specified text as html
-   * @param popup the menu to be cascaded from it
-   * @return the {@link MenuItem} object created
-   */
-  public MenuItem addItem(String text, boolean asHTML, MenuBar popup) {
-    MenuItem item = new MenuItem(text, asHTML, popup);
-    addItem(item);
-    return item;
-  }
-
-  /**
-   * Adds a menu item to the bar, that will fire the given command when it is
-   * selected.
-   * 
-   * @param text the item's text
-   * @param cmd the command to be fired
-   * @return the {@link MenuItem} object created
-   */
-  public MenuItem addItem(String text, Command cmd) {
-    MenuItem item = new MenuItem(text, cmd);
-    addItem(item);
-    return item;
-  }
-
-  /**
-   * Adds a menu item to the bar, that will open the specified menu when it is
-   * selected.
-   * 
-   * @param text the item's text
-   * @param popup the menu to be cascaded from it
-   * @return the {@link MenuItem} object created
-   */
-  public MenuItem addItem(String text, MenuBar popup) {
-    MenuItem item = new MenuItem(text, popup);
-    addItem(item);
-    return item;
-  }
-
-  /**
-   * Removes all menu items from this menu bar.
-   */
-  public void clearItems() {
-    Element container = getItemContainerElement();
-    while (DOM.getChildCount(container) > 0) {
-      DOM.removeChild(container, DOM.getChild(container, 0));
-    }
-    items.clear();
-  }
-
-  /**
-   * Gets whether this menu bar's child menus will open when the mouse is moved
-   * over it.
-   * 
-   * @return <code>true</code> if child menus will auto-open
-   */
-  public boolean getAutoOpen() {
-    return autoOpen;
-  }
-
-  public void onBrowserEvent(Event event) {
-    super.onBrowserEvent(event);
-
-    MenuItem item = findItem(DOM.eventGetTarget(event));
-    switch (DOM.eventGetType(event)) {
-      case Event.ONCLICK: {
-        // Fire an item's command when the user clicks on it.
-        if (item != null) {
-          doItemAction(item, true);
-        }
-        break;
-      }
-
-      case Event.ONMOUSEOVER: {
-        if (item != null) {
-          itemOver(item);
-        }
-        break;
-      }
-
-      case Event.ONMOUSEOUT: {
-        if (item != null) {
-          itemOver(null);
-        }
-        break;
-      }
-    }
-  }
-
-  public void onPopupClosed(PopupPanel sender, boolean autoClosed) {
-    // If the menu popup was auto-closed, close all of its parents as well.
-    if (autoClosed) {
-      closeAllParents();
-    }
-
-    // When the menu popup closes, remember that no item is
-    // currently showing a popup menu.
-    onHide();
-    shownChildMenu = null;
-    popup = null;
-  }
-
-  /**
-   * Removes the specified menu item from the bar.
-   * 
-   * @param item the item to be removed
-   */
-  public void removeItem(MenuItem item) {
-    int idx = items.indexOf(item);
-    if (idx == -1) {
-      return;
-    }
-
-    Element container = getItemContainerElement();
-    DOM.removeChild(container, DOM.getChild(container, idx));
-    items.remove(idx);
-  }
-
-  /**
-   * Sets whether this menu bar's child menus will open when the mouse is moved
-   * over it.
-   * 
-   * @param autoOpen <code>true</code> to cause child menus to auto-open
-   */
-  public void setAutoOpen(boolean autoOpen) {
-    this.autoOpen = autoOpen;
-  }
-
-  /**
-   * Returns a list containing the <code>MenuItem</code> objects in the menu bar.
-   * If there are no items in the menu bar, then an empty <code>List</code>
-   * object will be returned.
-   *
-   * @return  a list containing the <code>MenuItem</code> objects in the menu
-   *          bar
-   */
-  protected List getItems() {
-    return this.items;
-  }
-
-  /**
-   * Returns the <code>MenuItem</code> that is currently selected (highlighted)
-   * by the user. If none of the items in the menu are currently selected, then
-   * <code>null</code> will be returned.
-   *
-   * @return the <code>MenuItem</code> that is currently selected, or
-   *         <code>null</code> if no items are currently selected 
-   */
-  protected MenuItem getSelectedItem() {
-    return this.selectedItem;
-  }
-
-  protected void onDetach() {
-    // When the menu is detached, make sure to close all of its children.
-    if (popup != null) {
-      popup.hide();
-    }
-
-    super.onDetach();
-  }
-
-  /*
-   * Closes all parent menu popups.
-   */
-  void closeAllParents() {
-    MenuBar curMenu = this;
-    while (curMenu != null) {
-      curMenu.close();
-
-      if ((curMenu.parentMenu == null) && (curMenu.selectedItem != null)) {
-        curMenu.selectedItem.setSelectionStyle(false);
-        curMenu.selectedItem = null;
-      }
-
-      curMenu = curMenu.parentMenu;
-    }
-  }
-
-  /*
-   * Performs the action associated with the given menu item. If the item has a
-   * popup associated with it, the popup will be shown. If it has a command
-   * associated with it, and 'fireCommand' is true, then the command will be
-   * fired. Popups associated with other items will be hidden.
-   * 
-   * @param item the item whose popup is to be shown. @param fireCommand <code>true</code>
-   * if the item's command should be fired, <code>false</code> otherwise.
-   */
-  void doItemAction(final MenuItem item, boolean fireCommand) {
-    // If the given item is already showing its menu, we're done.
-    if ((shownChildMenu != null) && (item.getSubMenu() == shownChildMenu)) {
-      return;
-    }
-
-    // If another item is showing its menu, then hide it.
-    if (shownChildMenu != null) {
-      shownChildMenu.onHide();
-      popup.hide();
-    }
-
-    // If the item has no popup, optionally fire its command.
-    if (item.getSubMenu() == null) {
-      if (fireCommand) {
-        // Close this menu and all of its parents.
-        closeAllParents();
-
-        // Fire the item's command.
-        Command cmd = item.getCommand();
-        if (cmd != null) {
-          DeferredCommand.addCommand(cmd);
-        }
-      }
-      return;
-    }
-
-    // Ensure that the item is selected.
-    selectItem(item);
-
-    // Create a new popup for this item, and position it next to
-    // the item (below if this is a horizontal menu bar, to the
-    // right if it's a vertical bar).
-    popup = new PopupPanel(true) {
-      {
-        setWidget(item.getSubMenu());
-        item.getSubMenu().onShow();
-      }
-
-      public boolean onEventPreview(Event event) {
-        // Hook the popup panel's event preview. We use this to keep it from
-        // auto-hiding when the parent menu is clicked.
-        switch (DOM.eventGetType(event)) {
-          case Event.ONCLICK:
-            // If the event target is part of the parent menu, suppress the
-            // event altogether.
-            Element target = DOM.eventGetTarget(event);
-            Element parentMenuElement = item.getParentMenu().getElement();
-            if (DOM.isOrHasChild(parentMenuElement, target)) {
-              return false;
-            }
-            break;
-        }
-
-        return super.onEventPreview(event);
-      }
-    };
-    popup.addPopupListener(this);
-
-    if (vertical) {
-      popup.setPopupPosition(item.getAbsoluteLeft() + item.getOffsetWidth(),
-          item.getAbsoluteTop());
-    } else {
-      popup.setPopupPosition(item.getAbsoluteLeft(), item.getAbsoluteTop()
-          + item.getOffsetHeight());
-    }
-
-    shownChildMenu = item.getSubMenu();
-    item.getSubMenu().parentMenu = this;
-
-    // Show the popup, ensuring that the menubar's event preview remains on top
-    // of the popup's.
-    popup.show();
-  }
-
-  void itemOver(MenuItem item) {
-    if (item == null) {
-      // Don't clear selection if the currently selected item's menu is showing.
-      if ((selectedItem != null)
-          && (shownChildMenu == selectedItem.getSubMenu())) {
-        return;
-      }
-    }
-
-    // Style the item selected when the mouse enters.
-    selectItem(item);
-
-    // If child menus are being shown, or this menu is itself
-    // a child menu, automatically show an item's child menu
-    // when the mouse enters.
-    if (item != null) {
-      if ((shownChildMenu != null) || (parentMenu != null) || autoOpen) {
-        doItemAction(item, false);
-      }
-    }
-  }
-
-  void selectItem(MenuItem item) {
-    if (item == selectedItem) {
-      return;
-    }
-
-    if (selectedItem != null) {
-      selectedItem.setSelectionStyle(false);
-    }
-
-    if (item != null) {
-      item.setSelectionStyle(true);
-    }
-
-    selectedItem = item;
-  }
-
-  /**
-   * Closes this menu (if it is a popup).
-   */
-  private void close() {
-    if (parentMenu != null) {
-      parentMenu.popup.hide();
-    }
-  }
-
-  private MenuItem findItem(Element hItem) {
-    for (int i = 0; i < items.size(); ++i) {
-      MenuItem item = (MenuItem) items.get(i);
-      if (DOM.isOrHasChild(item.getElement(), hItem)) {
-        return item;
-      }
-    }
-
-    return null;
-  }
-
-  private Element getItemContainerElement() {
-    if (vertical) {
-      return body;
-    } else {
-      return DOM.getChild(body, 0);
-    }
-  }
-
-  /*
-   * This method is called when a menu bar is hidden, so that it can hide any
-   * child popups that are currently being shown.
-   */
-  private void onHide() {
-    if (shownChildMenu != null) {
-      shownChildMenu.onHide();
-      popup.hide();
-    }
-  }
-
-  /*
-   * This method is called when a menu bar is shown.
-   */
-  private void onShow() {
-    // Select the first item when a menu is shown.
-    if (items.size() > 0) {
-      selectItem((MenuItem) items.get(0));
-    }
-  }
+       private Element body;
+       private ArrayList items = new ArrayList();
+       private MenuBar parentMenu;
+       private PopupPanel popup;
+       private MenuItem selectedItem;
+       private MenuBar shownChildMenu;
+       private boolean vertical, autoOpen;
+
+       /**
+        * Creates an empty horizontal menu bar.
+        */
+       public MenuBar() {
+               this(false);
+       }
+
+       /**
+        * Creates an empty menu bar.
+        * 
+        * @param vertical
+        *            <code>true</code> to orient the menu bar vertically
+        */
+       public MenuBar(boolean vertical) {
+               super();
+
+               Element table = DOM.createTable();
+               body = DOM.createTBody();
+               DOM.appendChild(table, body);
+
+               if (!vertical) {
+                       Element tr = DOM.createTR();
+                       DOM.appendChild(body, tr);
+               }
+
+               this.vertical = vertical;
+
+               Element outer = DOM.createDiv();
+               DOM.appendChild(outer, table);
+               setElement(outer);
+
+               sinkEvents(Event.ONCLICK | Event.ONMOUSEOVER | Event.ONMOUSEOUT);
+               setStyleName("gwt-MenuBar");
+       }
+
+       /**
+        * Adds a menu item to the bar.
+        * 
+        * @param item
+        *            the item to be added
+        */
+       public void addItem(MenuItem item) {
+               Element tr;
+               if (vertical) {
+                       tr = DOM.createTR();
+                       DOM.appendChild(body, tr);
+               } else {
+                       tr = DOM.getChild(body, 0);
+               }
+
+               DOM.appendChild(tr, item.getElement());
+
+               item.setParentMenu(this);
+               item.setSelectionStyle(false);
+               items.add(item);
+       }
+
+       /**
+        * Adds a menu item to the bar, that will fire the given command when it is
+        * selected.
+        * 
+        * @param text
+        *            the item's text
+        * @param asHTML
+        *            <code>true</code> to treat the specified text as html
+        * @param cmd
+        *            the command to be fired
+        * @return the {@link MenuItem} object created
+        */
+       public MenuItem addItem(String text, boolean asHTML, Command cmd) {
+               MenuItem item = new MenuItem(text, asHTML, cmd);
+               addItem(item);
+               return item;
+       }
+
+       /**
+        * Adds a menu item to the bar, that will open the specified menu when it is
+        * selected.
+        * 
+        * @param text
+        *            the item's text
+        * @param asHTML
+        *            <code>true</code> to treat the specified text as html
+        * @param popup
+        *            the menu to be cascaded from it
+        * @return the {@link MenuItem} object created
+        */
+       public MenuItem addItem(String text, boolean asHTML, MenuBar popup) {
+               MenuItem item = new MenuItem(text, asHTML, popup);
+               addItem(item);
+               return item;
+       }
+
+       /**
+        * Adds a menu item to the bar, that will fire the given command when it is
+        * selected.
+        * 
+        * @param text
+        *            the item's text
+        * @param cmd
+        *            the command to be fired
+        * @return the {@link MenuItem} object created
+        */
+       public MenuItem addItem(String text, Command cmd) {
+               MenuItem item = new MenuItem(text, cmd);
+               addItem(item);
+               return item;
+       }
+
+       /**
+        * Adds a menu item to the bar, that will open the specified menu when it is
+        * selected.
+        * 
+        * @param text
+        *            the item's text
+        * @param popup
+        *            the menu to be cascaded from it
+        * @return the {@link MenuItem} object created
+        */
+       public MenuItem addItem(String text, MenuBar popup) {
+               MenuItem item = new MenuItem(text, popup);
+               addItem(item);
+               return item;
+       }
+
+       /**
+        * Removes all menu items from this menu bar.
+        */
+       public void clearItems() {
+               Element container = getItemContainerElement();
+               while (DOM.getChildCount(container) > 0) {
+                       DOM.removeChild(container, DOM.getChild(container, 0));
+               }
+               items.clear();
+       }
+
+       /**
+        * Gets whether this menu bar's child menus will open when the mouse is
+        * moved over it.
+        * 
+        * @return <code>true</code> if child menus will auto-open
+        */
+       public boolean getAutoOpen() {
+               return autoOpen;
+       }
+
+       public void onBrowserEvent(Event event) {
+               super.onBrowserEvent(event);
+
+               MenuItem item = findItem(DOM.eventGetTarget(event));
+               switch (DOM.eventGetType(event)) {
+               case Event.ONCLICK: {
+                       // Fire an item's command when the user clicks on it.
+                       if (item != null) {
+                               doItemAction(item, true);
+                       }
+                       break;
+               }
+
+               case Event.ONMOUSEOVER: {
+                       if (item != null) {
+                               itemOver(item);
+                       }
+                       break;
+               }
+
+               case Event.ONMOUSEOUT: {
+                       if (item != null) {
+                               itemOver(null);
+                       }
+                       break;
+               }
+               }
+       }
+
+       public void onPopupClosed(PopupPanel sender, boolean autoClosed) {
+               // If the menu popup was auto-closed, close all of its parents as well.
+               if (autoClosed) {
+                       closeAllParents();
+               }
+
+               // When the menu popup closes, remember that no item is
+               // currently showing a popup menu.
+               onHide();
+               shownChildMenu = null;
+               popup = null;
+       }
+
+       /**
+        * Removes the specified menu item from the bar.
+        * 
+        * @param item
+        *            the item to be removed
+        */
+       public void removeItem(MenuItem item) {
+               int idx = items.indexOf(item);
+               if (idx == -1) {
+                       return;
+               }
+
+               Element container = getItemContainerElement();
+               DOM.removeChild(container, DOM.getChild(container, idx));
+               items.remove(idx);
+       }
+
+       /**
+        * Sets whether this menu bar's child menus will open when the mouse is
+        * moved over it.
+        * 
+        * @param autoOpen
+        *            <code>true</code> to cause child menus to auto-open
+        */
+       public void setAutoOpen(boolean autoOpen) {
+               this.autoOpen = autoOpen;
+       }
+
+       /**
+        * Returns a list containing the <code>MenuItem</code> objects in the menu
+        * bar. If there are no items in the menu bar, then an empty
+        * <code>List</code> object will be returned.
+        * 
+        * @return a list containing the <code>MenuItem</code> objects in the menu
+        *         bar
+        */
+       protected List getItems() {
+               return this.items;
+       }
+
+       /**
+        * Returns the <code>MenuItem</code> that is currently selected
+        * (highlighted) by the user. If none of the items in the menu are currently
+        * selected, then <code>null</code> will be returned.
+        * 
+        * @return the <code>MenuItem</code> that is currently selected, or
+        *         <code>null</code> if no items are currently selected
+        */
+       protected MenuItem getSelectedItem() {
+               return this.selectedItem;
+       }
+
+       protected void onDetach() {
+               // When the menu is detached, make sure to close all of its children.
+               if (popup != null) {
+                       popup.hide();
+               }
+
+               super.onDetach();
+       }
+
+       /*
+        * Closes all parent menu popups.
+        */
+       void closeAllParents() {
+               MenuBar curMenu = this;
+               while (curMenu != null) {
+                       curMenu.close();
+
+                       if ((curMenu.parentMenu == null) && (curMenu.selectedItem != null)) {
+                               curMenu.selectedItem.setSelectionStyle(false);
+                               curMenu.selectedItem = null;
+                       }
+
+                       curMenu = curMenu.parentMenu;
+               }
+       }
+
+       /*
+        * Performs the action associated with the given menu item. If the item has
+        * a popup associated with it, the popup will be shown. If it has a command
+        * associated with it, and 'fireCommand' is true, then the command will be
+        * fired. Popups associated with other items will be hidden.
+        * 
+        * @param item the item whose popup is to be shown. @param fireCommand
+        * <code>true</code> if the item's command should be fired, <code>false</code>
+        * otherwise.
+        */
+       void doItemAction(final MenuItem item, boolean fireCommand) {
+               // If the given item is already showing its menu, we're done.
+               if ((shownChildMenu != null) && (item.getSubMenu() == shownChildMenu)) {
+                       return;
+               }
+
+               // If another item is showing its menu, then hide it.
+               if (shownChildMenu != null) {
+                       shownChildMenu.onHide();
+                       popup.hide();
+               }
+
+               // If the item has no popup, optionally fire its command.
+               if (item.getSubMenu() == null) {
+                       if (fireCommand) {
+                               // Close this menu and all of its parents.
+                               closeAllParents();
+
+                               // Fire the item's command.
+                               Command cmd = item.getCommand();
+                               if (cmd != null) {
+                                       DeferredCommand.addCommand(cmd);
+                               }
+                       }
+                       return;
+               }
+
+               // Ensure that the item is selected.
+               selectItem(item);
+
+               // Create a new popup for this item, and position it next to
+               // the item (below if this is a horizontal menu bar, to the
+               // right if it's a vertical bar).
+               popup = new PopupPanel(true) {
+                       {
+                               setWidget(item.getSubMenu());
+                               item.getSubMenu().onShow();
+                       }
+
+                       public boolean onEventPreview(Event event) {
+                               // Hook the popup panel's event preview. We use this to keep it
+                               // from
+                               // auto-hiding when the parent menu is clicked.
+                               switch (DOM.eventGetType(event)) {
+                               case Event.ONCLICK:
+                                       // If the event target is part of the parent menu, suppress
+                                       // the
+                                       // event altogether.
+                                       Element target = DOM.eventGetTarget(event);
+                                       Element parentMenuElement = item.getParentMenu()
+                                                       .getElement();
+                                       if (DOM.isOrHasChild(parentMenuElement, target)) {
+                                               return false;
+                                       }
+                                       break;
+                               }
+
+                               return super.onEventPreview(event);
+                       }
+               };
+               popup.addPopupListener(this);
+
+               if (vertical) {
+                       popup.setPopupPosition(item.getAbsoluteLeft()
+                                       + item.getOffsetWidth(), item.getAbsoluteTop());
+               } else {
+                       popup.setPopupPosition(item.getAbsoluteLeft(), item
+                                       .getAbsoluteTop()
+                                       + item.getOffsetHeight());
+               }
+
+               shownChildMenu = item.getSubMenu();
+               item.getSubMenu().parentMenu = this;
+
+               // Show the popup, ensuring that the menubar's event preview remains on
+               // top
+               // of the popup's.
+               popup.show();
+       }
+
+       void itemOver(MenuItem item) {
+               if (item == null) {
+                       // Don't clear selection if the currently selected item's menu is
+                       // showing.
+                       if ((selectedItem != null)
+                                       && (shownChildMenu == selectedItem.getSubMenu())) {
+                               return;
+                       }
+               }
+
+               // Style the item selected when the mouse enters.
+               selectItem(item);
+
+               // If child menus are being shown, or this menu is itself
+               // a child menu, automatically show an item's child menu
+               // when the mouse enters.
+               if (item != null) {
+                       if ((shownChildMenu != null) || (parentMenu != null) || autoOpen) {
+                               doItemAction(item, false);
+                       }
+               }
+       }
+
+       void selectItem(MenuItem item) {
+               if (item == selectedItem) {
+                       return;
+               }
+
+               if (selectedItem != null) {
+                       selectedItem.setSelectionStyle(false);
+               }
+
+               if (item != null) {
+                       item.setSelectionStyle(true);
+               }
+
+               selectedItem = item;
+       }
+
+       /**
+        * Closes this menu (if it is a popup).
+        */
+       private void close() {
+               if (parentMenu != null) {
+                       parentMenu.popup.hide();
+               }
+       }
+
+       private MenuItem findItem(Element hItem) {
+               for (int i = 0; i < items.size(); ++i) {
+                       MenuItem item = (MenuItem) items.get(i);
+                       if (DOM.isOrHasChild(item.getElement(), hItem)) {
+                               return item;
+                       }
+               }
+
+               return null;
+       }
+
+       private Element getItemContainerElement() {
+               if (vertical) {
+                       return body;
+               } else {
+                       return DOM.getChild(body, 0);
+               }
+       }
+
+       /*
+        * This method is called when a menu bar is hidden, so that it can hide any
+        * child popups that are currently being shown.
+        */
+       private void onHide() {
+               if (shownChildMenu != null) {
+                       shownChildMenu.onHide();
+                       popup.hide();
+               }
+       }
+
+       /*
+        * This method is called when a menu bar is shown.
+        */
+       private void onShow() {
+               // Select the first item when a menu is shown.
+               if (items.size() > 0) {
+                       selectItem((MenuItem) items.get(0));
+               }
+       }
 }
index 49d3348f5b5f6f09c6fb9ae2137355a5f7eb596f..295c17e41e995df2215da6708d379047ba911f8c 100644 (file)
@@ -1,4 +1,5 @@
 package com.itmill.toolkit.terminal.gwt.client.ui;
+
 /*
  * Copyright 2007 Google Inc.
  * 
@@ -17,7 +18,6 @@ package com.itmill.toolkit.terminal.gwt.client.ui;
 
 //COPIED HERE DUE package privates in GWT
 
-
 import com.google.gwt.user.client.Command;
 import com.google.gwt.user.client.DOM;
 import com.google.gwt.user.client.ui.HasHTML;
@@ -31,139 +31,153 @@ import com.google.gwt.user.client.ui.UIObject;
  */
 public class MenuItem extends UIObject implements HasHTML {
 
-  private static final String DEPENDENT_STYLENAME_SELECTED_ITEM = "selected";
-
-  private Command command;
-  private MenuBar parentMenu, subMenu;
-
-  /**
-   * Constructs a new menu item that fires a command when it is selected.
-   * 
-   * @param text the item's text
-   * @param cmd the command to be fired when it is selected
-   */
-  public MenuItem(String text, Command cmd) {
-    this(text, false);
-    setCommand(cmd);
-  }
-
-  /**
-   * Constructs a new menu item that fires a command when it is selected.
-   * 
-   * @param text the item's text
-   * @param asHTML <code>true</code> to treat the specified text as html
-   * @param cmd the command to be fired when it is selected
-   */
-  public MenuItem(String text, boolean asHTML, Command cmd) {
-    this(text, asHTML);
-    setCommand(cmd);
-  }
-
-  /**
-   * Constructs a new menu item that cascades to a sub-menu when it is selected.
-   * 
-   * @param text the item's text
-   * @param subMenu the sub-menu to be displayed when it is selected
-   */
-  public MenuItem(String text, MenuBar subMenu) {
-    this(text, false);
-    setSubMenu(subMenu);
-  }
-
-  /**
-   * Constructs a new menu item that cascades to a sub-menu when it is selected.
-   * 
-   * @param text the item's text
-   * @param asHTML <code>true</code> to treat the specified text as html
-   * @param subMenu the sub-menu to be displayed when it is selected
-   */
-  public MenuItem(String text, boolean asHTML, MenuBar subMenu) {
-    this(text, asHTML);
-    setSubMenu(subMenu);
-  }
-
-  MenuItem(String text, boolean asHTML) {
-    setElement(DOM.createTD());
-    setSelectionStyle(false);
-
-    if (asHTML) {
-      setHTML(text);
-    } else {
-      setText(text);
-    }
-    setStyleName("gwt-MenuItem");
-  }
-
-  /**
-   * Gets the command associated with this item.
-   * 
-   * @return this item's command, or <code>null</code> if none exists
-   */
-  public Command getCommand() {
-    return command;
-  }
-
-  public String getHTML() {
-    return DOM.getInnerHTML(getElement());
-  }
-
-  /**
-   * Gets the menu that contains this item.
-   * 
-   * @return the parent menu, or <code>null</code> if none exists.
-   */
-  public MenuBar getParentMenu() {
-    return parentMenu;
-  }
-
-  /**
-   * Gets the sub-menu associated with this item.
-   * 
-   * @return this item's sub-menu, or <code>null</code> if none exists
-   */
-  public MenuBar getSubMenu() {
-    return subMenu;
-  }
-
-  public String getText() {
-    return DOM.getInnerText(getElement());
-  }
-
-  /**
-   * Sets the command associated with this item.
-   * 
-   * @param cmd the command to be associated with this item
-   */
-  public void setCommand(Command cmd) {
-    command = cmd;
-  }
-
-  public void setHTML(String html) {
-    DOM.setInnerHTML(getElement(), html);
-  }
-
-  /**
-   * Sets the sub-menu associated with this item.
-   * 
-   * @param subMenu this item's new sub-menu
-   */
-  public void setSubMenu(MenuBar subMenu) {
-    this.subMenu = subMenu;
-  }
-
-  public void setText(String text) {
-    DOM.setInnerText(getElement(), text);
-  }
-
-  void setParentMenu(MenuBar parentMenu) {
-    this.parentMenu = parentMenu;
-  }
-
-  void setSelectionStyle(boolean selected) {
-    if (selected) {
-      addStyleDependentName(DEPENDENT_STYLENAME_SELECTED_ITEM);
-    } else {
-      removeStyleDependentName(DEPENDENT_STYLENAME_SELECTED_ITEM);
-    }
-  }
+       private static final String DEPENDENT_STYLENAME_SELECTED_ITEM = "selected";
+
+       private Command command;
+       private MenuBar parentMenu, subMenu;
+
+       /**
+        * Constructs a new menu item that fires a command when it is selected.
+        * 
+        * @param text
+        *            the item's text
+        * @param cmd
+        *            the command to be fired when it is selected
+        */
+       public MenuItem(String text, Command cmd) {
+               this(text, false);
+               setCommand(cmd);
+       }
+
+       /**
+        * Constructs a new menu item that fires a command when it is selected.
+        * 
+        * @param text
+        *            the item's text
+        * @param asHTML
+        *            <code>true</code> to treat the specified text as html
+        * @param cmd
+        *            the command to be fired when it is selected
+        */
+       public MenuItem(String text, boolean asHTML, Command cmd) {
+               this(text, asHTML);
+               setCommand(cmd);
+       }
+
+       /**
+        * Constructs a new menu item that cascades to a sub-menu when it is
+        * selected.
+        * 
+        * @param text
+        *            the item's text
+        * @param subMenu
+        *            the sub-menu to be displayed when it is selected
+        */
+       public MenuItem(String text, MenuBar subMenu) {
+               this(text, false);
+               setSubMenu(subMenu);
+       }
+
+       /**
+        * Constructs a new menu item that cascades to a sub-menu when it is
+        * selected.
+        * 
+        * @param text
+        *            the item's text
+        * @param asHTML
+        *            <code>true</code> to treat the specified text as html
+        * @param subMenu
+        *            the sub-menu to be displayed when it is selected
+        */
+       public MenuItem(String text, boolean asHTML, MenuBar subMenu) {
+               this(text, asHTML);
+               setSubMenu(subMenu);
+       }
+
+       MenuItem(String text, boolean asHTML) {
+               setElement(DOM.createTD());
+               setSelectionStyle(false);
+
+               if (asHTML) {
+                       setHTML(text);
+               } else {
+                       setText(text);
+               }
+               setStyleName("gwt-MenuItem");
+       }
+
+       /**
+        * Gets the command associated with this item.
+        * 
+        * @return this item's command, or <code>null</code> if none exists
+        */
+       public Command getCommand() {
+               return command;
+       }
+
+       public String getHTML() {
+               return DOM.getInnerHTML(getElement());
+       }
+
+       /**
+        * Gets the menu that contains this item.
+        * 
+        * @return the parent menu, or <code>null</code> if none exists.
+        */
+       public MenuBar getParentMenu() {
+               return parentMenu;
+       }
+
+       /**
+        * Gets the sub-menu associated with this item.
+        * 
+        * @return this item's sub-menu, or <code>null</code> if none exists
+        */
+       public MenuBar getSubMenu() {
+               return subMenu;
+       }
+
+       public String getText() {
+               return DOM.getInnerText(getElement());
+       }
+
+       /**
+        * Sets the command associated with this item.
+        * 
+        * @param cmd
+        *            the command to be associated with this item
+        */
+       public void setCommand(Command cmd) {
+               command = cmd;
+       }
+
+       public void setHTML(String html) {
+               DOM.setInnerHTML(getElement(), html);
+       }
+
+       /**
+        * Sets the sub-menu associated with this item.
+        * 
+        * @param subMenu
+        *            this item's new sub-menu
+        */
+       public void setSubMenu(MenuBar subMenu) {
+               this.subMenu = subMenu;
+       }
+
+       public void setText(String text) {
+               DOM.setInnerText(getElement(), text);
+       }
+
+       void setParentMenu(MenuBar parentMenu) {
+               this.parentMenu = parentMenu;
+       }
+
+       void setSelectionStyle(boolean selected) {
+               if (selected) {
+                       addStyleDependentName(DEPENDENT_STYLENAME_SELECTED_ITEM);
+               } else {
+                       removeStyleDependentName(DEPENDENT_STYLENAME_SELECTED_ITEM);
+               }
+       }
 }
index fae11436002503c156f242a0f87245f5d80073aa..04cb796d37d5e3d9d51f895a9c92b09bfa00612e 100644 (file)
@@ -6,223 +6,242 @@ import com.google.gwt.user.client.ui.ListBox;
 import com.google.gwt.user.client.ui.Widget;\r
 \r
 public class Time extends FlowPanel implements ChangeListener {\r
-       \r
+\r
        private IDateField datefield;\r
-       \r
+\r
        private ListBox hours;\r
-       \r
+\r
        private ListBox mins;\r
-       \r
+\r
        private ListBox sec;\r
-       \r
+\r
        private ListBox msec;\r
-       \r
+\r
        private ListBox ampm;\r
-       \r
+\r
        private int resolution = IDateField.RESOLUTION_HOUR;\r
-       \r
+\r
        private boolean readonly;\r
-       \r
+\r
        public Time(IDateField parent) {\r
                super();\r
                datefield = parent;\r
-               setStyleName(IDateField.CLASSNAME+"-time");\r
+               setStyleName(IDateField.CLASSNAME + "-time");\r
        }\r
-       \r
+\r
        private void buildTime(boolean redraw) {\r
                boolean thc = datefield.getDateTimeService().isTwelveHourClock();\r
-               if(redraw) {\r
+               if (redraw) {\r
                        clear();\r
-                       int numHours = thc?12:24;\r
+                       int numHours = thc ? 12 : 24;\r
                        hours = new ListBox();\r
                        hours.setStyleName(ISelect.CLASSNAME);\r
-                       for(int i=0; i<numHours; i++)\r
-                               hours.addItem((i<10)?"0"+i:""+i);\r
+                       for (int i = 0; i < numHours; i++)\r
+                               hours.addItem((i < 10) ? "0" + i : "" + i);\r
                        hours.addChangeListener(this);\r
-                       if(thc) {\r
+                       if (thc) {\r
                                ampm = new ListBox();\r
                                ampm.setStyleName(ISelect.CLASSNAME);\r
-                               String[] ampmText = datefield.getDateTimeService().getAmPmStrings();\r
+                               String[] ampmText = datefield.getDateTimeService()\r
+                                               .getAmPmStrings();\r
                                ampm.addItem(ampmText[0]);\r
                                ampm.addItem(ampmText[1]);\r
                                ampm.addChangeListener(this);\r
                        }\r
-                       \r
-                       if(datefield.getCurrentResolution() >= IDateField.RESOLUTION_MIN) {\r
+\r
+                       if (datefield.getCurrentResolution() >= IDateField.RESOLUTION_MIN) {\r
                                mins = new ListBox();\r
                                mins.setStyleName(ISelect.CLASSNAME);\r
-                               for(int i=0; i<60; i++)\r
-                                       mins.addItem((i<10)?"0"+i:""+i);\r
+                               for (int i = 0; i < 60; i++)\r
+                                       mins.addItem((i < 10) ? "0" + i : "" + i);\r
                                mins.addChangeListener(this);\r
                        }\r
-                       if(datefield.getCurrentResolution() >= IDateField.RESOLUTION_SEC) {\r
+                       if (datefield.getCurrentResolution() >= IDateField.RESOLUTION_SEC) {\r
                                sec = new ListBox();\r
                                sec.setStyleName(ISelect.CLASSNAME);\r
-                               for(int i=0; i<60; i++)\r
-                                       sec.addItem((i<10)?"0"+i:""+i);\r
+                               for (int i = 0; i < 60; i++)\r
+                                       sec.addItem((i < 10) ? "0" + i : "" + i);\r
                                sec.addChangeListener(this);\r
                        }\r
-                       if(datefield.getCurrentResolution() == IDateField.RESOLUTION_MSEC) {\r
+                       if (datefield.getCurrentResolution() == IDateField.RESOLUTION_MSEC) {\r
                                msec = new ListBox();\r
                                msec.setStyleName(ISelect.CLASSNAME);\r
-                               for(int i=0; i<1000; i++) {\r
-                                       if(i<10)\r
-                                               msec.addItem("00"+i);\r
-                                       else if(i<100)\r
-                                               msec.addItem("0"+i);\r
-                                       else msec.addItem(""+i);\r
+                               for (int i = 0; i < 1000; i++) {\r
+                                       if (i < 10)\r
+                                               msec.addItem("00" + i);\r
+                                       else if (i < 100)\r
+                                               msec.addItem("0" + i);\r
+                                       else\r
+                                               msec.addItem("" + i);\r
                                }\r
                                msec.addChangeListener(this);\r
                        }\r
-                       \r
-                       String delimiter = datefield.getDateTimeService().getClockDelimeter();\r
+\r
+                       String delimiter = datefield.getDateTimeService()\r
+                                       .getClockDelimeter();\r
                        boolean ro = datefield.isReadonly();\r
-                       \r
-                       if(ro) {\r
+\r
+                       if (ro) {\r
                                int h = 0;\r
-                               if(datefield.getCurrentDate() != null)\r
+                               if (datefield.getCurrentDate() != null)\r
                                        h = datefield.getCurrentDate().getHours();\r
-                               if(thc) h -= h<12? 0 : 12;\r
-                               add(new ILabel(h<10? "0"+h : ""+h));\r
-                       } else add(hours);\r
-                       \r
-                       if(datefield.getCurrentResolution() >= IDateField.RESOLUTION_MIN) {\r
+                               if (thc)\r
+                                       h -= h < 12 ? 0 : 12;\r
+                               add(new ILabel(h < 10 ? "0" + h : "" + h));\r
+                       } else\r
+                               add(hours);\r
+\r
+                       if (datefield.getCurrentResolution() >= IDateField.RESOLUTION_MIN) {\r
                                add(new ILabel(delimiter));\r
-                               if(ro) {\r
+                               if (ro) {\r
                                        int m = mins.getSelectedIndex();\r
-                                       add(new ILabel(m<10? "0"+m : ""+m));\r
-                               }\r
-                               else add(mins);\r
+                                       add(new ILabel(m < 10 ? "0" + m : "" + m));\r
+                               } else\r
+                                       add(mins);\r
                        }\r
-                       if(datefield.getCurrentResolution() >= IDateField.RESOLUTION_SEC) {\r
+                       if (datefield.getCurrentResolution() >= IDateField.RESOLUTION_SEC) {\r
                                add(new ILabel(delimiter));\r
-                               if(ro) {\r
+                               if (ro) {\r
                                        int s = sec.getSelectedIndex();\r
-                                       add(new ILabel(s<10? "0"+s : ""+s));\r
-                               }\r
-                               else add(sec);\r
+                                       add(new ILabel(s < 10 ? "0" + s : "" + s));\r
+                               } else\r
+                                       add(sec);\r
                        }\r
-                       if(datefield.getCurrentResolution() == IDateField.RESOLUTION_MSEC) {\r
+                       if (datefield.getCurrentResolution() == IDateField.RESOLUTION_MSEC) {\r
                                add(new ILabel("."));\r
-                               if(ro) {\r
+                               if (ro) {\r
                                        int m = datefield.getMilliseconds();\r
-                                       String ms = m<100? "0"+m : ""+m;\r
-                                       add(new ILabel(m<10? "0"+ms : ms));\r
-                               }\r
-                               else add(msec);\r
+                                       String ms = m < 100 ? "0" + m : "" + m;\r
+                                       add(new ILabel(m < 10 ? "0" + ms : ms));\r
+                               } else\r
+                                       add(msec);\r
                        }\r
-                       if(datefield.getCurrentResolution() == IDateField.RESOLUTION_HOUR) {\r
-                               add(new ILabel(delimiter+"00")); // o'clock\r
+                       if (datefield.getCurrentResolution() == IDateField.RESOLUTION_HOUR) {\r
+                               add(new ILabel(delimiter + "00")); // o'clock\r
                        }\r
-                       if(thc) {\r
+                       if (thc) {\r
                                add(new ILabel("&nbsp;"));\r
-                               if(ro) add(new ILabel(ampm.getItemText(datefield.getCurrentDate().getHours()<12? 0 : 1)));\r
-                               else add(ampm);\r
+                               if (ro)\r
+                                       add(new ILabel(ampm.getItemText(datefield.getCurrentDate()\r
+                                                       .getHours() < 12 ? 0 : 1)));\r
+                               else\r
+                                       add(ampm);\r
                        }\r
-                       \r
-                       if(ro) return;\r
+\r
+                       if (ro)\r
+                               return;\r
                }\r
-               \r
+\r
                // Update times\r
-               if(thc) {\r
+               if (thc) {\r
                        int h = datefield.getCurrentDate().getHours();\r
-                       ampm.setSelectedIndex(h<12? 0 : 1);\r
-                       h -= ampm.getSelectedIndex()*12;\r
+                       ampm.setSelectedIndex(h < 12 ? 0 : 1);\r
+                       h -= ampm.getSelectedIndex() * 12;\r
                        hours.setSelectedIndex(h);\r
                } else\r
                        hours.setSelectedIndex(datefield.getCurrentDate().getHours());\r
-               if(datefield.getCurrentResolution() >= IDateField.RESOLUTION_MIN)\r
+               if (datefield.getCurrentResolution() >= IDateField.RESOLUTION_MIN)\r
                        mins.setSelectedIndex(datefield.getCurrentDate().getMinutes());\r
-               if(datefield.getCurrentResolution() >= IDateField.RESOLUTION_SEC)\r
+               if (datefield.getCurrentResolution() >= IDateField.RESOLUTION_SEC)\r
                        sec.setSelectedIndex(datefield.getCurrentDate().getSeconds());\r
-               if(datefield.getCurrentResolution() == IDateField.RESOLUTION_MSEC)\r
+               if (datefield.getCurrentResolution() == IDateField.RESOLUTION_MSEC)\r
                        msec.setSelectedIndex(datefield.getMilliseconds());\r
-               if(thc)\r
-                       ampm.setSelectedIndex(datefield.getCurrentDate().getHours()<12?0:1);\r
-               \r
-               if(datefield.isReadonly() && !redraw) {\r
+               if (thc)\r
+                       ampm\r
+                                       .setSelectedIndex(datefield.getCurrentDate().getHours() < 12 ? 0\r
+                                                       : 1);\r
+\r
+               if (datefield.isReadonly() && !redraw) {\r
                        // Do complete redraw when in read-only status\r
                        clear();\r
-                       String delimiter = datefield.getDateTimeService().getClockDelimeter();\r
-                       \r
+                       String delimiter = datefield.getDateTimeService()\r
+                                       .getClockDelimeter();\r
+\r
                        int h = datefield.getCurrentDate().getHours();\r
-                       if(thc) h -= h<12? 0 : 12;\r
-                       add(new ILabel(h<10? "0"+h : ""+h));\r
-                       \r
-                       if(datefield.getCurrentResolution() >= IDateField.RESOLUTION_MIN) {\r
+                       if (thc)\r
+                               h -= h < 12 ? 0 : 12;\r
+                       add(new ILabel(h < 10 ? "0" + h : "" + h));\r
+\r
+                       if (datefield.getCurrentResolution() >= IDateField.RESOLUTION_MIN) {\r
                                add(new ILabel(delimiter));\r
                                int m = mins.getSelectedIndex();\r
-                               add(new ILabel(m<10? "0"+m : ""+m));\r
+                               add(new ILabel(m < 10 ? "0" + m : "" + m));\r
                        }\r
-                       if(datefield.getCurrentResolution() >= IDateField.RESOLUTION_SEC) {\r
+                       if (datefield.getCurrentResolution() >= IDateField.RESOLUTION_SEC) {\r
                                add(new ILabel(delimiter));\r
                                int s = sec.getSelectedIndex();\r
-                               add(new ILabel(s<10? "0"+s : ""+s));\r
+                               add(new ILabel(s < 10 ? "0" + s : "" + s));\r
                        }\r
-                       if(datefield.getCurrentResolution() == IDateField.RESOLUTION_MSEC) {\r
+                       if (datefield.getCurrentResolution() == IDateField.RESOLUTION_MSEC) {\r
                                add(new ILabel("."));\r
                                int m = datefield.getMilliseconds();\r
-                               String ms = m<100? "0"+m : ""+m;\r
-                               add(new ILabel(m<10? "0"+ms : ms));\r
+                               String ms = m < 100 ? "0" + m : "" + m;\r
+                               add(new ILabel(m < 10 ? "0" + ms : ms));\r
                        }\r
-                       if(datefield.getCurrentResolution() == IDateField.RESOLUTION_HOUR) {\r
-                               add(new ILabel(delimiter+"00")); // o'clock\r
+                       if (datefield.getCurrentResolution() == IDateField.RESOLUTION_HOUR) {\r
+                               add(new ILabel(delimiter + "00")); // o'clock\r
                        }\r
-                       if(thc) {\r
+                       if (thc) {\r
                                add(new ILabel("&nbsp;"));\r
-                               add(new ILabel(ampm.getItemText(datefield.getCurrentDate().getHours()<12? 0 : 1)));\r
+                               add(new ILabel(ampm.getItemText(datefield.getCurrentDate()\r
+                                               .getHours() < 12 ? 0 : 1)));\r
                        }\r
                }\r
-               \r
+\r
                boolean enabled = datefield.isEnabled();\r
                hours.setEnabled(enabled);\r
-               if(mins != null) mins.setEnabled(enabled);\r
-               if(sec != null) sec.setEnabled(enabled);\r
-               if(msec != null) msec.setEnabled(enabled);\r
-               if(ampm != null) ampm.setEnabled(enabled);\r
-               \r
+               if (mins != null)\r
+                       mins.setEnabled(enabled);\r
+               if (sec != null)\r
+                       sec.setEnabled(enabled);\r
+               if (msec != null)\r
+                       msec.setEnabled(enabled);\r
+               if (ampm != null)\r
+                       ampm.setEnabled(enabled);\r
+\r
        }\r
 \r
        public void updateTime(boolean redraw) {\r
-               buildTime(redraw || resolution != datefield.getCurrentResolution() \r
-                                               || readonly != datefield.isReadonly());\r
-               if(datefield instanceof ITextualDate)\r
+               buildTime(redraw || resolution != datefield.getCurrentResolution()\r
+                               || readonly != datefield.isReadonly());\r
+               if (datefield instanceof ITextualDate)\r
                        ((ITextualDate) datefield).buildDate();\r
                resolution = datefield.getCurrentResolution();\r
                readonly = datefield.isReadonly();\r
        }\r
 \r
        public void onChange(Widget sender) {\r
-               if(sender == hours) {\r
+               if (sender == hours) {\r
                        int h = hours.getSelectedIndex();\r
-                       if(datefield.getDateTimeService().isTwelveHourClock())\r
-                               h = h + ampm.getSelectedIndex()*12;\r
+                       if (datefield.getDateTimeService().isTwelveHourClock())\r
+                               h = h + ampm.getSelectedIndex() * 12;\r
                        datefield.getCurrentDate().setHours(h);\r
-                       datefield.getClient().updateVariable(datefield.getId(), "hour", h, datefield.isImmediate());\r
+                       datefield.getClient().updateVariable(datefield.getId(), "hour", h,\r
+                                       datefield.isImmediate());\r
                        updateTime(false);\r
-               }\r
-               else if(sender == mins) {\r
+               } else if (sender == mins) {\r
                        int m = mins.getSelectedIndex();\r
                        datefield.getCurrentDate().setMinutes(m);\r
-                       datefield.getClient().updateVariable(datefield.getId(), "min", m, datefield.isImmediate());\r
+                       datefield.getClient().updateVariable(datefield.getId(), "min", m,\r
+                                       datefield.isImmediate());\r
                        updateTime(false);\r
-               }\r
-               else if(sender == sec) {\r
+               } else if (sender == sec) {\r
                        int s = sec.getSelectedIndex();\r
                        datefield.getCurrentDate().setSeconds(s);\r
-                       datefield.getClient().updateVariable(datefield.getId(), "sec", s, datefield.isImmediate());\r
+                       datefield.getClient().updateVariable(datefield.getId(), "sec", s,\r
+                                       datefield.isImmediate());\r
                        updateTime(false);\r
-               }\r
-               else if(sender == msec) {\r
+               } else if (sender == msec) {\r
                        int ms = msec.getSelectedIndex();\r
                        datefield.setMilliseconds(ms);\r
-                       datefield.getClient().updateVariable(datefield.getId(), "msec", ms, datefield.isImmediate());\r
+                       datefield.getClient().updateVariable(datefield.getId(), "msec", ms,\r
+                                       datefield.isImmediate());\r
                        updateTime(false);\r
-               }\r
-               else if(sender == ampm) {\r
-                       int h = hours.getSelectedIndex() + ampm.getSelectedIndex()*12;\r
+               } else if (sender == ampm) {\r
+                       int h = hours.getSelectedIndex() + ampm.getSelectedIndex() * 12;\r
                        datefield.getCurrentDate().setHours(h);\r
-                       datefield.getClient().updateVariable(datefield.getId(), "hour", h, datefield.isImmediate());\r
+                       datefield.getClient().updateVariable(datefield.getId(), "hour", h,\r
+                                       datefield.isImmediate());\r
                        updateTime(false);\r
                }\r
        }\r
index 04e2aa00cf25973bc5d6b43c63ddc85d07760f82..3e690455aff486119c8d871668dc4545f7cb9980 100644 (file)
@@ -1,43 +1,38 @@
 package com.itmill.toolkit.terminal.gwt.client.ui;
 
-
 /**
  * This class is used for "row actions" in ITree and ITable
  */
 public class TreeAction extends Action {
-       
+
        String targetKey = "";
        String actionKey = "";
-       
+
        public TreeAction(ActionOwner owner) {
                super(owner);
        }
-       
+
        public TreeAction(ActionOwner owner, String target, String action) {
                this(owner);
                this.targetKey = target;
                this.actionKey = action;
        }
-       
-       
+
        /**
-        * Sends message to server that this action has been fired.
-        * Messages are "standard" Toolkit messages whose value is comma
-        * separated pair of targetKey (row, treeNod ...) and actions id.
+        * Sends message to server that this action has been fired. Messages are
+        * "standard" Toolkit messages whose value is comma separated pair of
+        * targetKey (row, treeNod ...) and actions id.
         * 
         * Variablename is always "action".
         * 
         * Actions are always sent immediatedly to server.
         */
        public void execute() {
-               owner.getClient().updateVariable(
-                               owner.getPaintableId(), 
-                               "action", 
-                               targetKey + "," + actionKey, 
-                               true);
+               owner.getClient().updateVariable(owner.getPaintableId(), "action",
+                               targetKey + "," + actionKey, true);
                owner.getClient().getContextMenu().hide();
        }
-       
+
        public String getActionKey() {
                return actionKey;
        }
index 1a11bdd712737f7560e0d7cc24210ad4af7ccfec..e4e68f30047d5a00dd69fc6d8270dd08bcf7100c 100644 (file)
@@ -4,12 +4,12 @@ import com.google.gwt.user.client.ui.AbstractImagePrototype;
 \r
 public interface VerticalSplitPanelImages extends\r
                com.google.gwt.user.client.ui.VerticalSplitPanelImages {\r
-       \r
+\r
        /**\r
-          * An image representing the drag thumb.\r
-          \r
-          * @gwt.resource com/itmill/toolkit/terminal/gwt/public/default/common/img/blank.gif\r
-          */\r
+        * An image representing the drag thumb.\r
+        * \r
+        * @gwt.resource com/itmill/toolkit/terminal/gwt/public/default/common/img/blank.gif\r
+        */\r
        AbstractImagePrototype verticalSplitPanelThumb();\r
 \r
 }\r
index 8c5b4c29b8ba6ae28434183a312168164fd51747..43de47bfcdef771c07bf1850b1303b1cd8478d72 100644 (file)
@@ -5,9 +5,10 @@ import java.util.List;
 \r
 /**\r
  * Date locale support for the {@link SimpleDateParser}. You are encouraged to\r
- * extend this class and provide implementations for other locales. \r
+ * extend this class and provide implementations for other locales.\r
+ * \r
  * @author <a href="mailto:g.georgovassilis@gmail.com">George Georgovassilis</a>\r
- *\r
+ * \r
  */\r
 public class DateLocale {\r
        public final static String TOKEN_DAY_OF_WEEK = "E";\r
@@ -25,9 +26,9 @@ public class DateLocale {
        public final static String TOKEN_MINUTE = "m";\r
 \r
        public final static String TOKEN_SECOND = "s";\r
-       \r
+\r
        public final static String TOKEN_MILLISECOND = "S";\r
-       \r
+\r
        public final static String TOKEN_AM_PM = "a";\r
 \r
        public final static String AM = "AM";\r
@@ -35,44 +36,44 @@ public class DateLocale {
        public final static String PM = "PM";\r
 \r
        public static List SUPPORTED_DF_TOKENS = Arrays.asList(new String[] {\r
-               TOKEN_DAY_OF_WEEK, TOKEN_DAY_OF_MONTH, TOKEN_MONTH, TOKEN_YEAR,\r
-               TOKEN_HOUR_12, TOKEN_HOUR_24, TOKEN_MINUTE, TOKEN_SECOND,\r
-               TOKEN_AM_PM });\r
-       \r
+                       TOKEN_DAY_OF_WEEK, TOKEN_DAY_OF_MONTH, TOKEN_MONTH, TOKEN_YEAR,\r
+                       TOKEN_HOUR_12, TOKEN_HOUR_24, TOKEN_MINUTE, TOKEN_SECOND,\r
+                       TOKEN_AM_PM });\r
+\r
        public static List TOKENS_RESOLUTION_ALL = Arrays.asList(new String[] {\r
-               TOKEN_DAY_OF_WEEK, TOKEN_DAY_OF_MONTH, TOKEN_MONTH, TOKEN_YEAR,\r
-               TOKEN_HOUR_12, TOKEN_HOUR_24, TOKEN_MINUTE, TOKEN_SECOND,\r
-               TOKEN_AM_PM });\r
-       \r
-       public static List TOKENS_RESOLUTION_YEAR = Arrays.asList(new String[] {\r
-               TOKEN_YEAR});\r
-       \r
+                       TOKEN_DAY_OF_WEEK, TOKEN_DAY_OF_MONTH, TOKEN_MONTH, TOKEN_YEAR,\r
+                       TOKEN_HOUR_12, TOKEN_HOUR_24, TOKEN_MINUTE, TOKEN_SECOND,\r
+                       TOKEN_AM_PM });\r
+\r
+       public static List TOKENS_RESOLUTION_YEAR = Arrays\r
+                       .asList(new String[] { TOKEN_YEAR });\r
+\r
        public static List TOKENS_RESOLUTION_MONTH = Arrays.asList(new String[] {\r
-               TOKEN_YEAR, TOKEN_MONTH});\r
-       \r
+                       TOKEN_YEAR, TOKEN_MONTH });\r
+\r
        public static List TOKENS_RESOLUTION_DAY = Arrays.asList(new String[] {\r
-               TOKEN_YEAR, TOKEN_MONTH, TOKEN_DAY_OF_MONTH});\r
+                       TOKEN_YEAR, TOKEN_MONTH, TOKEN_DAY_OF_MONTH });\r
 \r
        public String[] MONTH_LONG = { "January", "February", "March", "April",\r
-               "May", "June", "July", "August", "September", "October",\r
-               "November", "December" };\r
+                       "May", "June", "July", "August", "September", "October",\r
+                       "November", "December" };\r
 \r
        public String[] MONTH_SHORT = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",\r
-               "Jul", "Aug", "Sept", "Oct", "Nov", "Dec" };\r
+                       "Jul", "Aug", "Sept", "Oct", "Nov", "Dec" };\r
 \r
        public String[] WEEKDAY_LONG = { "Sunday", "Monday", "Tuesday",\r
-               "Wednesday", "Thursday", "Friday", "Saturday" };\r
+                       "Wednesday", "Thursday", "Friday", "Saturday" };\r
 \r
        public String[] WEEKDAY_SHORT = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri",\r
-               "Sat" };\r
+                       "Sat" };\r
 \r
        public static String getAM() {\r
-       return AM;\r
-    }\r
+               return AM;\r
+       }\r
 \r
        public static String getPM() {\r
-       return PM;\r
-    }\r
+               return PM;\r
+       }\r
 \r
        public String[] getWEEKDAY_LONG() {\r
                return WEEKDAY_LONG;\r
index 7c8e4def97e2353eb577e91327b7e3fceab53a2f..f82365b21158584beb3b62aae0af843f1d46461e 100644 (file)
@@ -22,18 +22,21 @@ import com.google.gwt.core.client.JavaScriptObject;
 \r
 /**\r
  * <p>\r
- * Implementation of the {@link java.util.regex.Pattern} class with a\r
- * wrapper aroung the Javascript <a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Guide:Regular_Expressions">RegExp</a> object.\r
- * As most of the methods delegate to the JavaScript RegExp object, certain differences in the \r
- * declaration and behaviour of regular expressions must be expected.\r
+ * Implementation of the {@link java.util.regex.Pattern} class with a wrapper\r
+ * aroung the Javascript <a\r
+ * href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Guide:Regular_Expressions">RegExp</a>\r
+ * object. As most of the methods delegate to the JavaScript RegExp object,\r
+ * certain differences in the declaration and behaviour of regular expressions\r
+ * must be expected.\r
  * </p>\r
  * <p>\r
- * Please note that neither the {@link java.util.regex.Pattern#compile(String)} method nor\r
- * {@link Matcher} instances are supported. For the later, consider using {@link Pattern#match(String)}.\r
+ * Please note that neither the {@link java.util.regex.Pattern#compile(String)}\r
+ * method nor {@link Matcher} instances are supported. For the later, consider\r
+ * using {@link Pattern#match(String)}.\r
  * </p>\r
  * \r
  * @author George Georgovassilis\r
- *\r
+ * \r
  */\r
 public class Pattern {\r
 \r
@@ -60,22 +63,25 @@ public class Pattern {
 \r
        private static native JavaScriptObject _createExpression(String pattern,\r
                        String flags)/*-{\r
-        return new RegExp(pattern, flags);\r
-        }-*/;\r
+                return new RegExp(pattern, flags);\r
+                }-*/;\r
 \r
        private native void _match(String text, List matches)/*-{\r
-        var regExp = this.@com.itmill.toolkit.terminal.gwt.client.util.Pattern::regExp;\r
-        var result = text.match(regExp);\r
-        if (result == null) return;\r
-        for (var i=0;i<result.length;i++)\r
-        matches.@java.util.ArrayList::add(Ljava/lang/Object;)(result[i]);\r
-        }-*/;\r
+                var regExp = this.@com.itmill.toolkit.terminal.gwt.client.util.Pattern::regExp;\r
+                var result = text.match(regExp);\r
+                if (result == null) return;\r
+                for (var i=0;i<result.length;i++)\r
+                matches.@java.util.ArrayList::add(Ljava/lang/Object;)(result[i]);\r
+                }-*/;\r
 \r
        /**\r
-        * Determines wether the specified regular expression is validated by the \r
+        * Determines wether the specified regular expression is validated by the\r
         * provided input.\r
-        * @param regex Regular expression\r
-        * @param input String to validate\r
+        * \r
+        * @param regex\r
+        *            Regular expression\r
+        * @param input\r
+        *            String to validate\r
         * @return <code>true</code> if matched.\r
         */\r
        public static boolean matches(String regex, String input) {\r
@@ -83,10 +89,10 @@ public class Pattern {
        }\r
 \r
        /**\r
-        * Escape a provided string so that it will be interpreted as a literal\r
-        * in regular expressions.\r
-        * The current implementation does escape each character even if not neccessary,\r
-        * generating verbose literals.\r
+        * Escape a provided string so that it will be interpreted as a literal in\r
+        * regular expressions. The current implementation does escape each\r
+        * character even if not neccessary, generating verbose literals.\r
+        * \r
         * @param input\r
         * @return\r
         */\r
@@ -100,7 +106,9 @@ public class Pattern {
 \r
        /**\r
         * Class constructor\r
-        * @param pattern Regular expression\r
+        * \r
+        * @param pattern\r
+        *            Regular expression\r
         */\r
        public Pattern(String pattern) {\r
                this(pattern, 0);\r
@@ -108,21 +116,25 @@ public class Pattern {
 \r
        /**\r
         * Class constructor\r
-        * @param pattern Regular expression\r
-        * @param flags \r
+        * \r
+        * @param pattern\r
+        *            Regular expression\r
+        * @param flags\r
         */\r
        public Pattern(String pattern, int flags) {\r
                regExp = createExpression(pattern, flags);\r
        }\r
 \r
        /**\r
-        * This method is borrowed from the JavaScript RegExp object.\r
-        * It parses a string and returns as an array any assignments to parenthesis groups\r
-        * in the pattern's regular expression\r
+        * This method is borrowed from the JavaScript RegExp object. It parses a\r
+        * string and returns as an array any assignments to parenthesis groups in\r
+        * the pattern's regular expression\r
+        * \r
         * @param text\r
         * @return Array of strings following java's Pattern convention for groups:\r
-        * Group 0 is the entire input string and the remaining groups are the matched parenthesis.\r
-        * In case nothing was matched an empty array is returned.\r
+        *         Group 0 is the entire input string and the remaining groups are\r
+        *         the matched parenthesis. In case nothing was matched an empty\r
+        *         array is returned.\r
         */\r
        public String[] match(String text) {\r
                List matches = new ArrayList();\r
@@ -135,41 +147,44 @@ public class Pattern {
 \r
        /**\r
         * Determines wether a provided text matches the regular expression\r
+        * \r
         * @param text\r
         * @return\r
         */\r
        public native boolean matches(String text)/*-{\r
-        var regExp = this.@com.itmill.toolkit.terminal.gwt.client.util.Pattern::regExp;\r
-        return regExp.test(text);\r
-        }-*/;\r
+                var regExp = this.@com.itmill.toolkit.terminal.gwt.client.util.Pattern::regExp;\r
+                return regExp.test(text);\r
+                }-*/;\r
 \r
        /**\r
         * Returns the regular expression for this pattern\r
+        * \r
         * @return\r
         */\r
        public native String pattern()/*-{\r
-        var regExp = this.@com.itmill.toolkit.terminal.gwt.client.util.Pattern::regExp;\r
-        return regExp.source;\r
-        }-*/;\r
+                var regExp = this.@com.itmill.toolkit.terminal.gwt.client.util.Pattern::regExp;\r
+                return regExp.source;\r
+                }-*/;\r
 \r
        private native void _split(String input, List results)/*-{\r
-        var regExp = this.@com.itmill.toolkit.terminal.gwt.client.util.Pattern::regExp;\r
-        var parts = input.split(regExp);\r
-        for (var i=0;i<parts.length;i++)\r
-        results.@java.util.ArrayList::add(Ljava/lang/Object;)(parts[i] );\r
-        }-*/;\r
-       \r
+                var regExp = this.@com.itmill.toolkit.terminal.gwt.client.util.Pattern::regExp;\r
+                var parts = input.split(regExp);\r
+                for (var i=0;i<parts.length;i++)\r
+                results.@java.util.ArrayList::add(Ljava/lang/Object;)(parts[i] );\r
+                }-*/;\r
+\r
        /**\r
         * Split an input string by the pattern's regular expression\r
+        * \r
         * @param input\r
         * @return Array of strings\r
         */\r
-       public String[] split(String input){\r
-               List results = new ArrayList(); \r
+       public String[] split(String input) {\r
+               List results = new ArrayList();\r
                _split(input, results);\r
                String[] parts = new String[results.size()];\r
-               for (int i=0;i<results.size();i++)\r
-                       parts[i] = (String)results.get(i);\r
+               for (int i = 0; i < results.size(); i++)\r
+                       parts[i] = (String) results.get(i);\r
                return parts;\r
        }\r
 \r
index e7903c7ee695e7bd32b887626f45774f30472abd..8bfb4b957f53fbb787372d816acda4f528507709 100644 (file)
@@ -68,15 +68,16 @@ public class SimpleDateFormat {
 
        /**
         * Gets the support locale for formatting and parsing dates
+        * 
         * @return
         */
        public DateLocale getLocale() {
-       return locale;
-    }
+               return locale;
+       }
 
        public void setLocale(DateLocale locale) {
-       this.locale = locale;
-    }
+               this.locale = locale;
+       }
 
        public SimpleDateFormat(String pattern) {
                format = pattern;
@@ -90,7 +91,7 @@ public class SimpleDateFormat {
                        for (int i = 0; i < format.length(); i++) {
                                String thisChar = format.substring(i, i + 1);
                                String currentTokenType = DateLocale.SUPPORTED_DF_TOKENS
-                                       .contains(thisChar) ? thisChar : "";
+                                               .contains(thisChar) ? thisChar : "";
                                if (currentTokenType.equals(lastTokenType) || i == 0) {
                                        currentToken += thisChar;
                                        lastTokenType = currentTokenType;
@@ -160,25 +161,25 @@ public class SimpleDateFormat {
                                h = 12;
                        else if (h > 12)
                                h -= 12;
-                       //if (token.length() > 1)
-                               response = twoCharDateField(h);
-                       //else
-                               //response = Integer.toString(h);
+                       // if (token.length() > 1)
+                       response = twoCharDateField(h);
+                       // else
+                       // response = Integer.toString(h);
                } else if (DateLocale.TOKEN_HOUR_24.equals(tc)) {
-                       //if (token.length() > 1)
-                               response = twoCharDateField(date.getHours());
-                       //else
-                               //response = Integer.toString(date.getHours());
+                       // if (token.length() > 1)
+                       response = twoCharDateField(date.getHours());
+                       // else
+                       // response = Integer.toString(date.getHours());
                } else if (DateLocale.TOKEN_MINUTE.equals(tc)) {
-                       //if (token.length() > 1)
-                               response = twoCharDateField(date.getMinutes());
-                       //else
-                               //response = Integer.toString(date.getMinutes());
+                       // if (token.length() > 1)
+                       response = twoCharDateField(date.getMinutes());
+                       // else
+                       // response = Integer.toString(date.getMinutes());
                } else if (DateLocale.TOKEN_SECOND.equals(tc)) {
-                       //if (token.length() > 1)
-                               response = twoCharDateField(date.getSeconds());
-                       //else
-                               //response = Integer.toString(date.getSeconds());
+                       // if (token.length() > 1)
+                       response = twoCharDateField(date.getSeconds());
+                       // else
+                       // response = Integer.toString(date.getSeconds());
                } else if (DateLocale.TOKEN_AM_PM.equals(tc)) {
                        int hour = date.getHours();
                        if (hour > 11)
@@ -209,12 +210,12 @@ public class SimpleDateFormat {
        }
 
        /**
-        * Parses text and returns the corresponding date object. 
+        * Parses text and returns the corresponding date object.
         * 
         * @param source
         * @return java.util.Date
         */
-       public Date parse(String source){
+       public Date parse(String source) {
                return SimpleDateParser.parse(source, format);
        };
 
index a3c6b17237b62c789a8aac6e3b88989a43f27b72..1ff5d5c458165e3622dd342c46a14365eee01cc9 100644 (file)
@@ -2,20 +2,20 @@ package com.itmill.toolkit.terminal.gwt.client.util;
 \r
 import java.util.Date;\r
 \r
-\r
 /**\r
- * This is a simple regular expression based parser for date notations.\r
- * While our aim is to fully support in the future the JDK date parser, currently\r
- * only numeric notations and literals are supported such as <code>dd/MM/yyyy HH:mm:ss.SSSS</code>.\r
- * Each entity is parsed with the same number of digits, i.e. for <code>dd</code> two digits will be\r
- * parsed while for <code>d</code> only one will be parsed.\r
+ * This is a simple regular expression based parser for date notations. While\r
+ * our aim is to fully support in the future the JDK date parser, currently only\r
+ * numeric notations and literals are supported such as\r
+ * <code>dd/MM/yyyy HH:mm:ss.SSSS</code>. Each entity is parsed with the same\r
+ * number of digits, i.e. for <code>dd</code> two digits will be parsed while\r
+ * for <code>d</code> only one will be parsed.\r
+ * \r
  * @author <a href="mailto:g.georgovassilis@gmail.com">George Georgovassilis</a>\r
- *\r
+ * \r
  */\r
 \r
 public class SimpleDateParser {\r
 \r
-\r
        private final static String DAY_IN_MONTH = "d";\r
 \r
        private final static String MONTH = "M";\r
@@ -35,28 +35,27 @@ public class SimpleDateParser {
        private final static int INSTRUCTION = 1;\r
 \r
        private final static String[] TOKENS[] = {\r
-       { "SSSS", "(\\d\\d\\d\\d)",DateLocale.TOKEN_MILLISECOND }, \r
-       { "SSS", "(\\d\\d\\d)", DateLocale.TOKEN_MILLISECOND },\r
-       { "SS", "(\\d\\d)", DateLocale.TOKEN_MILLISECOND }, \r
-       { "S", "(\\d)", DateLocale.TOKEN_MILLISECOND },\r
-       { "ss", "(\\d\\d)", DateLocale.TOKEN_SECOND }, \r
-       { "s", "(\\d\\d)", DateLocale.TOKEN_SECOND },\r
-       { "mm", "(\\d\\d)", DateLocale.TOKEN_MINUTE }, \r
-       { "m", "(\\d\\d)", DateLocale.TOKEN_MINUTE},\r
-       { "HH", "(\\d\\d)", DateLocale.TOKEN_HOUR_24},\r
-       { "H", "(\\d{1,2})", DateLocale.TOKEN_HOUR_24 },\r
-       { "hh", "(\\d\\d)", DateLocale.TOKEN_HOUR_12},\r
-       { "h", "(\\d{1,2})", DateLocale.TOKEN_HOUR_12 },\r
-       { "dd", "(\\d\\d)", DateLocale.TOKEN_DAY_OF_MONTH }, \r
-       { "d", "(\\d{1,2})", DateLocale.TOKEN_DAY_OF_MONTH },\r
-       { "MM", "(\\d\\d)", DateLocale.TOKEN_MONTH }, \r
-       { "M", "(\\d{1,2})", DateLocale.TOKEN_MONTH },\r
-       { "yyyy", "(\\d\\d\\d\\d)", DateLocale.TOKEN_YEAR }, \r
-       { "yyy", "(\\d\\d\\d\\d)", DateLocale.TOKEN_YEAR },\r
-       { "yy", "(\\d\\d\\d\\d)", DateLocale.TOKEN_YEAR }, \r
-       { "y", "(\\d{1,2})", DateLocale.TOKEN_YEAR },\r
-       { "a", "(\\S{1,4})", DateLocale.TOKEN_AM_PM }\r
-       };\r
+                       { "SSSS", "(\\d\\d\\d\\d)", DateLocale.TOKEN_MILLISECOND },\r
+                       { "SSS", "(\\d\\d\\d)", DateLocale.TOKEN_MILLISECOND },\r
+                       { "SS", "(\\d\\d)", DateLocale.TOKEN_MILLISECOND },\r
+                       { "S", "(\\d)", DateLocale.TOKEN_MILLISECOND },\r
+                       { "ss", "(\\d\\d)", DateLocale.TOKEN_SECOND },\r
+                       { "s", "(\\d\\d)", DateLocale.TOKEN_SECOND },\r
+                       { "mm", "(\\d\\d)", DateLocale.TOKEN_MINUTE },\r
+                       { "m", "(\\d\\d)", DateLocale.TOKEN_MINUTE },\r
+                       { "HH", "(\\d\\d)", DateLocale.TOKEN_HOUR_24 },\r
+                       { "H", "(\\d{1,2})", DateLocale.TOKEN_HOUR_24 },\r
+                       { "hh", "(\\d\\d)", DateLocale.TOKEN_HOUR_12 },\r
+                       { "h", "(\\d{1,2})", DateLocale.TOKEN_HOUR_12 },\r
+                       { "dd", "(\\d\\d)", DateLocale.TOKEN_DAY_OF_MONTH },\r
+                       { "d", "(\\d{1,2})", DateLocale.TOKEN_DAY_OF_MONTH },\r
+                       { "MM", "(\\d\\d)", DateLocale.TOKEN_MONTH },\r
+                       { "M", "(\\d{1,2})", DateLocale.TOKEN_MONTH },\r
+                       { "yyyy", "(\\d\\d\\d\\d)", DateLocale.TOKEN_YEAR },\r
+                       { "yyy", "(\\d\\d\\d\\d)", DateLocale.TOKEN_YEAR },\r
+                       { "yy", "(\\d\\d\\d\\d)", DateLocale.TOKEN_YEAR },\r
+                       { "y", "(\\d{1,2})", DateLocale.TOKEN_YEAR },\r
+                       { "a", "(\\S{1,4})", DateLocale.TOKEN_AM_PM } };\r
 \r
        private Pattern regularExpression;\r
 \r
@@ -65,13 +64,13 @@ public class SimpleDateParser {
        private static void _parse(String format, String[] args) {\r
                if (format.length() == 0)\r
                        return;\r
-               if (format.startsWith("'")){\r
+               if (format.startsWith("'")) {\r
                        format = format.substring(1);\r
                        int end = format.indexOf("'");\r
                        if (end == -1)\r
                                throw new IllegalArgumentException("Unmatched single quotes.");\r
-                       args[REGEX]+=Pattern.quote(format.substring(0,end));\r
-                       format = format.substring(end+1);\r
+                       args[REGEX] += Pattern.quote(format.substring(0, end));\r
+                       format = format.substring(end + 1);\r
                }\r
                for (int i = 0; i < TOKENS.length; i++) {\r
                        String[] row = TOKENS[i];\r
@@ -84,12 +83,13 @@ public class SimpleDateParser {
                        _parse(format, args);\r
                        return;\r
                }\r
-               args[REGEX] += Pattern.quote(""+format.charAt(0));\r
+               args[REGEX] += Pattern.quote("" + format.charAt(0));\r
                format = format.substring(1);\r
                _parse(format, args);\r
        }\r
 \r
-       private static void load(Date date, String text, String component, String input, Pattern regex) {\r
+       private static void load(Date date, String text, String component,\r
+                       String input, Pattern regex) {\r
                if (component.equals(DateLocale.TOKEN_MILLISECOND)) {\r
                        date.setTime(date.getTime() / 1000 * 1000 + Integer.parseInt(text));\r
                }\r
@@ -105,12 +105,21 @@ public class SimpleDateParser {
                if (component.equals(DateLocale.TOKEN_HOUR_24)) {\r
                        date.setHours(Integer.parseInt(text));\r
                }\r
-               \r
+\r
                if (component.equals(DateLocale.TOKEN_HOUR_12)) {\r
                        int h = Integer.parseInt(text);\r
-                       String token = com.itmill.toolkit.terminal.gwt.client.DateLocale.getPM();\r
-                       String which = input.substring(input.length() - token.length()); // Assumes both AM and PM tokens have same length\r
-                       if(which.equalsIgnoreCase(token))\r
+                       String token = com.itmill.toolkit.terminal.gwt.client.DateLocale\r
+                                       .getPM();\r
+                       String which = input.substring(input.length() - token.length()); // Assumes\r
+                                                                                                                                                               // both\r
+                                                                                                                                                               // AM\r
+                                                                                                                                                               // and\r
+                                                                                                                                                               // PM\r
+                                                                                                                                                               // tokens\r
+                                                                                                                                                               // have\r
+                                                                                                                                                               // same\r
+                                                                                                                                                               // length\r
+                       if (which.equalsIgnoreCase(token))\r
                                h += 12;\r
                        date.setHours(h);\r
                }\r
@@ -119,11 +128,11 @@ public class SimpleDateParser {
                        date.setDate(Integer.parseInt(text));\r
                }\r
                if (component.equals(DateLocale.TOKEN_MONTH)) {\r
-                       date.setMonth(Integer.parseInt(text)-1);\r
+                       date.setMonth(Integer.parseInt(text) - 1);\r
                }\r
                if (component.equals(DateLocale.TOKEN_YEAR)) {\r
-                       //TODO: fix for short patterns\r
-                       date.setYear(Integer.parseInt(text)-1900);\r
+                       // TODO: fix for short patterns\r
+                       date.setYear(Integer.parseInt(text) - 1900);\r
                }\r
 \r
        }\r
@@ -139,17 +148,20 @@ public class SimpleDateParser {
                Date date = new Date(0, 0, 0, 0, 0, 0);\r
                String matches[] = regularExpression.match(input);\r
                if (matches == null)\r
-                       throw new IllegalArgumentException(input+" does not match "+regularExpression.pattern());\r
-               if (matches.length-1!=instructions.length())\r
-                       throw new IllegalArgumentException("Different group count - "+input+" does not match "+regularExpression.pattern());\r
+                       throw new IllegalArgumentException(input + " does not match "\r
+                                       + regularExpression.pattern());\r
+               if (matches.length - 1 != instructions.length())\r
+                       throw new IllegalArgumentException("Different group count - "\r
+                                       + input + " does not match " + regularExpression.pattern());\r
                for (int group = 0; group < instructions.length(); group++) {\r
                        String match = matches[group + 1];\r
-                       load(date, match, ""+instructions.charAt(group), input, regularExpression);\r
+                       load(date, match, "" + instructions.charAt(group), input,\r
+                                       regularExpression);\r
                }\r
                return date;\r
        }\r
-       \r
-       public static Date parse(String input, String pattern){\r
+\r
+       public static Date parse(String input, String pattern) {\r
                return new SimpleDateParser(pattern).parse(input);\r
        }\r
 }\r
index ef4d173542af9ff585860857f4586d5e508f41d0..a11cb67de02e7817c38e9158c1c2bee34b44408c 100644 (file)
@@ -79,1113 +79,1113 @@ import com.itmill.toolkit.ui.Window;
 
 public class ApplicationServlet extends HttpServlet {
 
-    private static final long serialVersionUID = -4937882979845826574L;
+       private static final long serialVersionUID = -4937882979845826574L;
 
-    /**
-     * Version number of this release. For example "4.0.0".
-     */
-    public static final String VERSION;
+       /**
+        * Version number of this release. For example "4.0.0".
+        */
+       public static final String VERSION;
 
-    /**
-     * Major version number. For example 4 in 4.1.0.
-     */
-    public static final int VERSION_MAJOR;
+       /**
+        * Major version number. For example 4 in 4.1.0.
+        */
+       public static final int VERSION_MAJOR;
 
-    /**
-     * Minor version number. For example 1 in 4.1.0.
-     */
-    public static final int VERSION_MINOR;
+       /**
+        * Minor version number. For example 1 in 4.1.0.
+        */
+       public static final int VERSION_MINOR;
 
-    /**
-     * Builds number. For example 0-beta1 in 4.0.0-beta1.
-     */
-    public static final String VERSION_BUILD;
+       /**
+        * Builds number. For example 0-beta1 in 4.0.0-beta1.
+        */
+       public static final String VERSION_BUILD;
+
+       /* Initialize version numbers from string replaced by build-script. */
+       static {
+               if ("@VERSION@".equals("@" + "VERSION" + "@"))
+                       VERSION = "4.9.9-INTERNAL-NONVERSIONED-DEBUG-BUILD";
+               else
+                       VERSION = "@VERSION@";
+               String[] digits = VERSION.split("\\.");
+               VERSION_MAJOR = Integer.parseInt(digits[0]);
+               VERSION_MINOR = Integer.parseInt(digits[1]);
+               VERSION_BUILD = digits[2];
+       }
 
-    /* Initialize version numbers from string replaced by build-script. */
-    static {
-       if ("@VERSION@".equals("@" + "VERSION" + "@"))
-           VERSION = "4.9.9-INTERNAL-NONVERSIONED-DEBUG-BUILD";
-       else
-           VERSION = "@VERSION@";
-       String[] digits = VERSION.split("\\.");
-       VERSION_MAJOR = Integer.parseInt(digits[0]);
-       VERSION_MINOR = Integer.parseInt(digits[1]);
-       VERSION_BUILD = digits[2];
-    }
+       // Configurable parameter names
+       private static final String PARAMETER_DEBUG = "Debug";
 
-    // Configurable parameter names
-    private static final String PARAMETER_DEBUG = "Debug";
+       private static final int DEFAULT_BUFFER_SIZE = 32 * 1024;
 
-    private static final int DEFAULT_BUFFER_SIZE = 32 * 1024;
+       private static final int MAX_BUFFER_SIZE = 64 * 1024;
 
-    private static final int MAX_BUFFER_SIZE = 64 * 1024;
+       private static WeakHashMap applicationToLastRequestDate = new WeakHashMap();
 
-    private static WeakHashMap applicationToLastRequestDate = new WeakHashMap();
+       private static WeakHashMap applicationToAjaxAppMgrMap = new WeakHashMap();
 
-    private static WeakHashMap applicationToAjaxAppMgrMap = new WeakHashMap();
+       // License for ApplicationServlets
+       private static WeakHashMap licenseForApplicationClass = new WeakHashMap();
 
-    // License for ApplicationServlets
-    private static WeakHashMap licenseForApplicationClass = new WeakHashMap();
+       private static WeakHashMap licensePrintedForApplicationClass = new WeakHashMap();
 
-    private static WeakHashMap licensePrintedForApplicationClass = new WeakHashMap();
+       private static final String RESOURCE_URI = "/RES/";
 
-    private static final String RESOURCE_URI = "/RES/";
+       private static final String AJAX_UIDL_URI = "/UIDL/";
 
-    private static final String AJAX_UIDL_URI = "/UIDL/";
+       static final String THEME_DIRECTORY_PATH = "ITK-INF/themes/";
 
-    static final String THEME_DIRECTORY_PATH = "ITK-INF/themes/";
+       // Maximum delay between request for an user to be considered active (in ms)
+       private static final long ACTIVE_USER_REQUEST_INTERVAL = 1000 * 45;
 
-    // Maximum delay between request for an user to be considered active (in ms)
-    private static final long ACTIVE_USER_REQUEST_INTERVAL = 1000 * 45;
+       private static final int DEFAULT_THEME_CACHETIME = 1000 * 60 * 60 * 24;
 
-    private static final int DEFAULT_THEME_CACHETIME = 1000 * 60 * 60 * 24;
+       static final String WIDGETSET_DIRECTORY_PATH = "ITK-INF/widgetsets/";
+       // Name of the default widget set, used if not specified in web.xml
+       private static final String DEFAULT_WIDGETSET = "com.itmill.toolkit.terminal.gwt.DefaultWidgetSet";
+       // Widget set narameter name
+       private static final String PARAMETER_WIDGETSET = "widgetset";
 
-    static final String WIDGETSET_DIRECTORY_PATH = "ITK-INF/widgetsets/";
-    // Name of the default widget set, used if not specified in web.xml
-    private static final String DEFAULT_WIDGETSET = "com.itmill.toolkit.terminal.gwt.DefaultWidgetSet";
-    // Widget set narameter name
-    private static final String PARAMETER_WIDGETSET = "widgetset";
+       // Private fields
+       private Class applicationClass;
 
-    // Private fields
-    private Class applicationClass;
+       private Properties applicationProperties;
 
-    private Properties applicationProperties;
+       private String resourcePath = null;
 
-    private String resourcePath = null;
+       private String debugMode = "";
 
-    private String debugMode = "";
+       /**
+        * Called by the servlet container to indicate to a servlet that the servlet
+        * is being placed into service.
+        * 
+        * @param servletConfig
+        *            the object containing the servlet's configuration and
+        *            initialization parameters
+        * @throws javax.servlet.ServletException
+        *             if an exception has occurred that interferes with the
+        *             servlet's normal operation.
+        */
+       public void init(javax.servlet.ServletConfig servletConfig)
+                       throws javax.servlet.ServletException {
+               super.init(servletConfig);
+
+               // Gets the application class name
+               String applicationClassName = servletConfig
+                               .getInitParameter("application");
+               if (applicationClassName == null) {
+                       Log.error("Application not specified in servlet parameters");
+               }
 
-    /**
-     * Called by the servlet container to indicate to a servlet that the servlet
-     * is being placed into service.
-     * 
-     * @param servletConfig
-     *                the object containing the servlet's configuration and
-     *                initialization parameters
-     * @throws javax.servlet.ServletException
-     *                 if an exception has occurred that interferes with the
-     *                 servlet's normal operation.
-     */
-    public void init(javax.servlet.ServletConfig servletConfig)
-           throws javax.servlet.ServletException {
-       super.init(servletConfig);
+               // Stores the application parameters into Properties object
+               this.applicationProperties = new Properties();
+               for (Enumeration e = servletConfig.getInitParameterNames(); e
+                               .hasMoreElements();) {
+                       String name = (String) e.nextElement();
+                       this.applicationProperties.setProperty(name, servletConfig
+                                       .getInitParameter(name));
+               }
 
-       // Gets the application class name
-       String applicationClassName = servletConfig
-               .getInitParameter("application");
-       if (applicationClassName == null) {
-           Log.error("Application not specified in servlet parameters");
-       }
+               // Overrides with server.xml parameters
+               ServletContext context = servletConfig.getServletContext();
+               for (Enumeration e = context.getInitParameterNames(); e
+                               .hasMoreElements();) {
+                       String name = (String) e.nextElement();
+                       this.applicationProperties.setProperty(name, context
+                                       .getInitParameter(name));
+               }
 
-       // Stores the application parameters into Properties object
-       this.applicationProperties = new Properties();
-       for (Enumeration e = servletConfig.getInitParameterNames(); e
-               .hasMoreElements();) {
-           String name = (String) e.nextElement();
-           this.applicationProperties.setProperty(name, servletConfig
-                   .getInitParameter(name));
-       }
+               // Gets the debug window parameter
+               String debug = getApplicationOrSystemProperty(PARAMETER_DEBUG, "")
+                               .toLowerCase();
+
+               // Enables application specific debug
+               if (!"".equals(debug) && !"true".equals(debug)
+                               && !"false".equals(debug))
+                       throw new ServletException(
+                                       "If debug parameter is given for an application, it must be 'true' or 'false'");
+               this.debugMode = debug;
+
+               // Gets custom class loader
+               String classLoaderName = getApplicationOrSystemProperty("ClassLoader",
+                               null);
+               ClassLoader classLoader;
+               if (classLoaderName == null)
+                       classLoader = getClass().getClassLoader();
+               else {
+                       try {
+                               Class classLoaderClass = getClass().getClassLoader().loadClass(
+                                               classLoaderName);
+                               Constructor c = classLoaderClass
+                                               .getConstructor(new Class[] { ClassLoader.class });
+                               classLoader = (ClassLoader) c
+                                               .newInstance(new Object[] { getClass().getClassLoader() });
+                       } catch (Exception e) {
+                               Log.error("Could not find specified class loader: "
+                                               + classLoaderName);
+                               throw new ServletException(e);
+                       }
+               }
 
-       // Overrides with server.xml parameters
-       ServletContext context = servletConfig.getServletContext();
-       for (Enumeration e = context.getInitParameterNames(); e
-               .hasMoreElements();) {
-           String name = (String) e.nextElement();
-           this.applicationProperties.setProperty(name, context
-                   .getInitParameter(name));
-       }
+               // Loads the application class using the same class loader
+               // as the servlet itself
+               try {
+                       this.applicationClass = classLoader.loadClass(applicationClassName);
+               } catch (ClassNotFoundException e) {
+                       throw new ServletException("Failed to load application class: "
+                                       + applicationClassName);
+               }
 
-       // Gets the debug window parameter
-       String debug = getApplicationOrSystemProperty(PARAMETER_DEBUG, "")
-               .toLowerCase();
-
-       // Enables application specific debug
-       if (!"".equals(debug) && !"true".equals(debug)
-               && !"false".equals(debug))
-           throw new ServletException(
-                   "If debug parameter is given for an application, it must be 'true' or 'false'");
-       this.debugMode = debug;
-
-       // Gets custom class loader
-       String classLoaderName = getApplicationOrSystemProperty("ClassLoader",
-               null);
-       ClassLoader classLoader;
-       if (classLoaderName == null)
-           classLoader = getClass().getClassLoader();
-       else {
-           try {
-               Class classLoaderClass = getClass().getClassLoader().loadClass(
-                       classLoaderName);
-               Constructor c = classLoaderClass
-                       .getConstructor(new Class[] { ClassLoader.class });
-               classLoader = (ClassLoader) c
-                       .newInstance(new Object[] { getClass().getClassLoader() });
-           } catch (Exception e) {
-               Log.error("Could not find specified class loader: "
-                       + classLoaderName);
-               throw new ServletException(e);
-           }
        }
 
-       // Loads the application class using the same class loader
-       // as the servlet itself
-       try {
-           this.applicationClass = classLoader.loadClass(applicationClassName);
-       } catch (ClassNotFoundException e) {
-           throw new ServletException("Failed to load application class: "
-                   + applicationClassName);
-       }
+       /**
+        * Gets an application or system property value.
+        * 
+        * @param parameterName
+        *            the Name or the parameter.
+        * @param defaultValue
+        *            the Default to be used.
+        * @return String value or default if not found
+        */
+       private String getApplicationOrSystemProperty(String parameterName,
+                       String defaultValue) {
 
-    }
-
-    /**
-     * Gets an application or system property value.
-     * 
-     * @param parameterName
-     *                the Name or the parameter.
-     * @param defaultValue
-     *                the Default to be used.
-     * @return String value or default if not found
-     */
-    private String getApplicationOrSystemProperty(String parameterName,
-           String defaultValue) {
-
-       // Try application properties
-       String val = this.applicationProperties.getProperty(parameterName);
-       if (val != null) {
-           return val;
-       }
+               // Try application properties
+               String val = this.applicationProperties.getProperty(parameterName);
+               if (val != null) {
+                       return val;
+               }
 
-       // Try lowercased application properties for backward compability with
-       // 3.0.2 and earlier
-       val = this.applicationProperties.getProperty(parameterName
-               .toLowerCase());
-       if (val != null) {
-           return val;
-       }
+               // Try lowercased application properties for backward compability with
+               // 3.0.2 and earlier
+               val = this.applicationProperties.getProperty(parameterName
+                               .toLowerCase());
+               if (val != null) {
+                       return val;
+               }
 
-       // Try system properties
-       String pkgName;
-       Package pkg = this.getClass().getPackage();
-       if (pkg != null) {
-           pkgName = pkg.getName();
-       } else {
-           String className = this.getClass().getName();
-           pkgName = new String(className.toCharArray(), 0, className
-                   .lastIndexOf('.'));
-       }
-       val = System.getProperty(pkgName + "." + parameterName);
-       if (val != null) {
-           return val;
-       }
+               // Try system properties
+               String pkgName;
+               Package pkg = this.getClass().getPackage();
+               if (pkg != null) {
+                       pkgName = pkg.getName();
+               } else {
+                       String className = this.getClass().getName();
+                       pkgName = new String(className.toCharArray(), 0, className
+                                       .lastIndexOf('.'));
+               }
+               val = System.getProperty(pkgName + "." + parameterName);
+               if (val != null) {
+                       return val;
+               }
 
-       // Try lowercased system properties
-       val = System.getProperty(pkgName + "." + parameterName.toLowerCase());
-       if (val != null) {
-           return val;
+               // Try lowercased system properties
+               val = System.getProperty(pkgName + "." + parameterName.toLowerCase());
+               if (val != null) {
+                       return val;
+               }
+
+               return defaultValue;
        }
 
-       return defaultValue;
-    }
-
-    /**
-     * Receives standard HTTP requests from the public service method and
-     * dispatches them.
-     * 
-     * @param request
-     *                the object that contains the request the client made of
-     *                the servlet.
-     * @param response
-     *                the object that contains the response the servlet returns
-     *                to the client.
-     * @throws ServletException
-     *                 if an input or output error occurs while the servlet is
-     *                 handling the TRACE request.
-     * @throws IOException
-     *                 if the request for the TRACE cannot be handled.
-     */
-    protected void service(HttpServletRequest request,
-           HttpServletResponse response) throws ServletException, IOException {
-
-       Application application = null;
-       try {
-
-           // handle file upload if multipart request
-               if(ServletFileUpload.isMultipartContent(request)) {
-                   application = getApplication(request);
-                   getApplicationManager(application).handleFileUpload(request, response);
-                       return;
-               }
+       /**
+        * Receives standard HTTP requests from the public service method and
+        * dispatches them.
+        * 
+        * @param request
+        *            the object that contains the request the client made of the
+        *            servlet.
+        * @param response
+        *            the object that contains the response the servlet returns to
+        *            the client.
+        * @throws ServletException
+        *             if an input or output error occurs while the servlet is
+        *             handling the TRACE request.
+        * @throws IOException
+        *             if the request for the TRACE cannot be handled.
+        */
+       protected void service(HttpServletRequest request,
+                       HttpServletResponse response) throws ServletException, IOException {
+
+               Application application = null;
+               try {
+
+                       // handle file upload if multipart request
+                       if (ServletFileUpload.isMultipartContent(request)) {
+                               application = getApplication(request);
+                               getApplicationManager(application).handleFileUpload(request,
+                                               response);
+                               return;
+                       }
 
-           // Update browser details
-           WebBrowser browser = WebApplicationContext.getApplicationContext(
-                   request.getSession()).getBrowser();
-           browser.updateBrowserProperties(request);
-           // TODO Add screen height and width to the GWT client
+                       // Update browser details
+                       WebBrowser browser = WebApplicationContext.getApplicationContext(
+                                       request.getSession()).getBrowser();
+                       browser.updateBrowserProperties(request);
+                       // TODO Add screen height and width to the GWT client
 
-           // Gets the application
-           application = getApplication(request);
+                       // Gets the application
+                       application = getApplication(request);
 
-           // Sets the last application request date
-           synchronized (applicationToLastRequestDate) {
-               applicationToLastRequestDate.put(application, new Date());
-           }
+                       // Sets the last application request date
+                       synchronized (applicationToLastRequestDate) {
+                               applicationToLastRequestDate.put(application, new Date());
+                       }
 
-           // Invokes context transaction listeners
-           ((WebApplicationContext) application.getContext())
-                   .startTransaction(application, request);
+                       // Invokes context transaction listeners
+                       ((WebApplicationContext) application.getContext())
+                                       .startTransaction(application, request);
 
-           // Is this a download request from application
-           DownloadStream download = null;
+                       // Is this a download request from application
+                       DownloadStream download = null;
 
-           
-               // Handles AJAX UIDL requests
-               String resourceId = request.getPathInfo();
-               if (resourceId != null && resourceId.startsWith(AJAX_UIDL_URI)) {
-                   getApplicationManager(application).handleUidlRequest(
-                           request, response);
-                   return;
-               }
+                       // Handles AJAX UIDL requests
+                       String resourceId = request.getPathInfo();
+                       if (resourceId != null && resourceId.startsWith(AJAX_UIDL_URI)) {
+                               getApplicationManager(application).handleUidlRequest(request,
+                                               response);
+                               return;
+                       }
 
-               // Handles the URI if the application is still running
-               if (application.isRunning())
-                   download = handleURI(application, request, response);
+                       // Handles the URI if the application is still running
+                       if (application.isRunning())
+                               download = handleURI(application, request, response);
 
-               // If this is not a download request
-               if (download == null) {
+                       // If this is not a download request
+                       if (download == null) {
 
-                   // TODO Clean this branch
+                               // TODO Clean this branch
 
-                   // Window renders are not cacheable
-                   response.setHeader("Cache-Control", "no-cache");
-                   response.setHeader("Pragma", "no-cache");
-                   response.setDateHeader("Expires", 0);
+                               // Window renders are not cacheable
+                               response.setHeader("Cache-Control", "no-cache");
+                               response.setHeader("Pragma", "no-cache");
+                               response.setDateHeader("Expires", 0);
 
-                   // Finds the window within the application
-                   Window window = null;
-                   if (application.isRunning())
-                       window = getApplicationWindow(request, application);
+                               // Finds the window within the application
+                               Window window = null;
+                               if (application.isRunning())
+                                       window = getApplicationWindow(request, application);
 
-                   // Removes application if it has stopped
-                   if (!application.isRunning()) {
-                       endApplication(request, response, application);
-                       return;
-                   }
+                               // Removes application if it has stopped
+                               if (!application.isRunning()) {
+                                       endApplication(request, response, application);
+                                       return;
+                               }
 
-                   // Sets terminal type for the window, if not already set
-                   if (window.getTerminal() == null) {
-                       window.setTerminal(browser);
-                   }
+                               // Sets terminal type for the window, if not already set
+                               if (window.getTerminal() == null) {
+                                       window.setTerminal(browser);
+                               }
 
-                   // Finds theme name
-                   String themeName = window.getTheme();
-                   if (request.getParameter("theme") != null) {
-                       themeName = request.getParameter("theme");
-                   }
+                               // Finds theme name
+                               String themeName = window.getTheme();
+                               if (request.getParameter("theme") != null) {
+                                       themeName = request.getParameter("theme");
+                               }
 
-                   // Handles resource requests
-                   if (handleResourceRequest(request, response, themeName))
-                       return;
+                               // Handles resource requests
+                               if (handleResourceRequest(request, response, themeName))
+                                       return;
 
-                   writeAjaxPage(request, response, window, themeName);
-               }
+                               writeAjaxPage(request, response, window, themeName);
+                       }
 
-           // For normal requests, transform the window
-           if (download != null)
+                       // For normal requests, transform the window
+                       if (download != null)
 
-               handleDownload(download, request, response);
+                               handleDownload(download, request, response);
 
-       } catch (Throwable e) {
-           // Print stacktrace
-           e.printStackTrace();
-           // Re-throw other exceptions
-           throw new ServletException(e);
-       } finally {
+               } catch (Throwable e) {
+                       // Print stacktrace
+                       e.printStackTrace();
+                       // Re-throw other exceptions
+                       throw new ServletException(e);
+               } finally {
 
-           // Notifies transaction end
-           if (application != null)
-               ((WebApplicationContext) application.getContext())
-                       .endTransaction(application, request);
-       }
-    }
-
-    /**
-     * 
-     * @param request
-     *                the HTTP request.
-     * @param response
-     *                the HTTP response to write to.
-     * @param out
-     * @param unhandledParameters
-     * @param window
-     * @param terminalType
-     * @param theme
-     * @throws IOException
-     *                 if the writing failed due to input/output error.
-     * @throws MalformedURLException
-     *                 if the application is denied access the persistent data
-     *                 store represented by the given URL.
-     */
-    private void writeAjaxPage(HttpServletRequest request,
-           HttpServletResponse response, Window window, String themeName)
-           throws IOException, MalformedURLException {
-       response.setContentType("text/html");
-       BufferedWriter page = new BufferedWriter(new OutputStreamWriter(
-               response.getOutputStream()));
-
-       String uri = request.getRequestURL().toString();
-       boolean hasSlash = (uri.charAt(uri.length() - 1) == '/') ? true : false;
-
-       String relative = "";
-       String t = request.getPathInfo().substring(1);
-       while (t.indexOf('/') >= 0) {
-           t = t.substring(t.indexOf('/') + 1);
-           relative += "../";
+                       // Notifies transaction end
+                       if (application != null)
+                               ((WebApplicationContext) application.getContext())
+                                               .endTransaction(application, request);
+               }
        }
 
-       // TODO remove GoogleMaps namespace and script
-
-       page
-               .write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" "
-                       + "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n");
-
-       page
-               .write("<html xmlns=\"http://www.w3.org/1999/xhtml\">\n<head>\n<title>IT Mill Toolkit 5</title>\n"
-                       + "<script type=\"text/javascript\">\n"
-                       + "     var itmtk = {\n" + "            appUri:'");
-
-       String[] urlParts = getApplicationUrl(request).toString().split("\\/");
-       String appUrl = "";
-       // don't use server and port in uri. It may cause problems with some
-       // virtual server configurations which lose the server name
-       for (int i = 3; i < urlParts.length; i++)
-           appUrl += "/" + urlParts[i];
-       if (appUrl.endsWith("/")) {
-           appUrl = appUrl.substring(0, appUrl.length() - 1);
-       }
+       /**
+        * 
+        * @param request
+        *            the HTTP request.
+        * @param response
+        *            the HTTP response to write to.
+        * @param out
+        * @param unhandledParameters
+        * @param window
+        * @param terminalType
+        * @param theme
+        * @throws IOException
+        *             if the writing failed due to input/output error.
+        * @throws MalformedURLException
+        *             if the application is denied access the persistent data store
+        *             represented by the given URL.
+        */
+       private void writeAjaxPage(HttpServletRequest request,
+                       HttpServletResponse response, Window window, String themeName)
+                       throws IOException, MalformedURLException {
+               response.setContentType("text/html");
+               BufferedWriter page = new BufferedWriter(new OutputStreamWriter(
+                               response.getOutputStream()));
+
+               String uri = request.getRequestURL().toString();
+               boolean hasSlash = (uri.charAt(uri.length() - 1) == '/') ? true : false;
+
+               String relative = "";
+               String t = request.getPathInfo().substring(1);
+               while (t.indexOf('/') >= 0) {
+                       t = t.substring(t.indexOf('/') + 1);
+                       relative += "../";
+               }
+
+               // TODO remove GoogleMaps namespace and script
+
+               page
+                               .write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" "
+                                               + "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n");
+
+               page
+                               .write("<html xmlns=\"http://www.w3.org/1999/xhtml\">\n<head>\n<title>IT Mill Toolkit 5</title>\n"
+                                               + "<script type=\"text/javascript\">\n"
+                                               + "     var itmtk = {\n" + "            appUri:'");
+
+               String[] urlParts = getApplicationUrl(request).toString().split("\\/");
+               String appUrl = "";
+               // don't use server and port in uri. It may cause problems with some
+               // virtual server configurations which lose the server name
+               for (int i = 3; i < urlParts.length; i++)
+                       appUrl += "/" + urlParts[i];
+               if (appUrl.endsWith("/")) {
+                       appUrl = appUrl.substring(0, appUrl.length() - 1);
+               }
 
-       page.write(appUrl);
+               page.write(appUrl);
 
-       String widgetset = this.applicationProperties
-               .getProperty(PARAMETER_WIDGETSET);
-       if (widgetset == null) {
-           widgetset = DEFAULT_WIDGETSET;
-       }
+               String widgetset = this.applicationProperties
+                               .getProperty(PARAMETER_WIDGETSET);
+               if (widgetset == null) {
+                       widgetset = DEFAULT_WIDGETSET;
+               }
+
+               page
+                               .write("', pathInfo: '"
+                                               + request.getPathInfo()
+                                               + "'\n};\n"
+                                               + "</script>\n"
+                                               + "<script language='javascript' src='"
+                                               + (hasSlash ? "../" : "")
+                                               + relative
+                                               + WIDGETSET_DIRECTORY_PATH
+                                               + widgetset
+                                               + "/"
+                                               + widgetset
+                                               + ".nocache.js'></script>"
+                                               + "<link REL=\"stylesheet\" TYPE=\"text/css\" HREF=\""
+                                               + request.getContextPath()
+                                               + "/" // TODO relative url as above?
+                                               + THEME_DIRECTORY_PATH
+                                               + themeName
+                                               + "/styles.css\">"
+                                               + "</head>\n<body>\n"
+                                               + "     <iframe id=\"__gwt_historyFrame\" style=\"width:0;height:0;border:0\"></iframe>\n"
+                                               + "     <div id=\"itmtk-ajax-window\"></div>"
+                                               + "     </body>\n" + "</html>\n");
+
+               page.close();
 
-       page
-               .write("', pathInfo: '"
-                       + request.getPathInfo()
-                       + "'\n};\n"
-                       + "</script>\n"
-                       + "<script language='javascript' src='"
-                       + (hasSlash ? "../" : "")
-                       + relative
-                       + WIDGETSET_DIRECTORY_PATH
-                       + widgetset
-                       + "/"
-                       + widgetset
-                       + ".nocache.js'></script>"
-                       + "<link REL=\"stylesheet\" TYPE=\"text/css\" HREF=\""
-                       + request.getContextPath()
-                       + "/" // TODO relative url as above?
-                       + THEME_DIRECTORY_PATH
-                       + themeName
-                       + "/styles.css\">"
-                       + "</head>\n<body>\n"
-                       + "     <iframe id=\"__gwt_historyFrame\" style=\"width:0;height:0;border:0\"></iframe>\n"
-                       + "     <div id=\"itmtk-ajax-window\"></div>"
-                       + "     </body>\n" + "</html>\n");
-
-       page.close();
-
-    }
-
-    /**
-     * Handles the requested URI. An application can add handlers to do special
-     * processing, when a certain URI is requested. The handlers are invoked
-     * before any windows URIs are processed and if a DownloadStream is returned
-     * it is sent to the client.
-     * 
-     * @param application
-     *                the Application owning the URI.
-     * @param request
-     *                the HTTP request instance.
-     * @param response
-     *                the HTTP response to write to.
-     * @return boolean <code>true</code> if the request was handled and
-     *         further processing should be suppressed, <code>false</code>
-     *         otherwise.
-     * @see com.itmill.toolkit.terminal.URIHandler
-     */
-    private DownloadStream handleURI(Application application,
-           HttpServletRequest request, HttpServletResponse response) {
-
-       String uri = request.getPathInfo();
-
-       // If no URI is available
-       if (uri == null || uri.length() == 0 || uri.equals("/"))
-           return null;
-
-       // Removes the leading /
-       while (uri.startsWith("/") && uri.length() > 0)
-           uri = uri.substring(1);
-
-       // Handles the uri
-       DownloadStream stream = null;
-       try {
-           stream = application.handleURI(application.getURL(), uri);
-       } catch (Throwable t) {
-           application.terminalError(new URIHandlerErrorImpl(application, t));
        }
 
-       return stream;
-    }
-
-    /**
-     * Handles the requested URI. An application can add handlers to do special
-     * processing, when a certain URI is requested. The handlers are invoked
-     * before any windows URIs are processed and if a DownloadStream is returned
-     * it is sent to the client.
-     * 
-     * @param stream
-     *                the download stream.
-     * 
-     * @param request
-     *                the HTTP request instance.
-     * @param response
-     *                the HTTP response to write to.
-     * 
-     * @see com.itmill.toolkit.terminal.URIHandler
-     */
-    private void handleDownload(DownloadStream stream,
-           HttpServletRequest request, HttpServletResponse response) {
-
-       // Download from given stream
-       InputStream data = stream.getStream();
-       if (data != null) {
-
-           // Sets content type
-           response.setContentType(stream.getContentType());
-
-           // Sets cache headers
-           long cacheTime = stream.getCacheTime();
-           if (cacheTime <= 0) {
-               response.setHeader("Cache-Control", "no-cache");
-               response.setHeader("Pragma", "no-cache");
-               response.setDateHeader("Expires", 0);
-           } else {
-               response.setHeader("Cache-Control", "max-age=" + cacheTime
-                       / 1000);
-               response.setDateHeader("Expires", System.currentTimeMillis()
-                       + cacheTime);
-               response.setHeader("Pragma", "cache"); // Required to apply
-               // caching in some
-               // Tomcats
-           }
-
-           // Copy download stream parameters directly
-           // to HTTP headers.
-           Iterator i = stream.getParameterNames();
-           if (i != null) {
-               while (i.hasNext()) {
-                   String param = (String) i.next();
-                   response.setHeader((String) param, stream
-                           .getParameter(param));
-               }
-           }
+       /**
+        * Handles the requested URI. An application can add handlers to do special
+        * processing, when a certain URI is requested. The handlers are invoked
+        * before any windows URIs are processed and if a DownloadStream is returned
+        * it is sent to the client.
+        * 
+        * @param application
+        *            the Application owning the URI.
+        * @param request
+        *            the HTTP request instance.
+        * @param response
+        *            the HTTP response to write to.
+        * @return boolean <code>true</code> if the request was handled and
+        *         further processing should be suppressed, <code>false</code>
+        *         otherwise.
+        * @see com.itmill.toolkit.terminal.URIHandler
+        */
+       private DownloadStream handleURI(Application application,
+                       HttpServletRequest request, HttpServletResponse response) {
+
+               String uri = request.getPathInfo();
 
-           int bufferSize = stream.getBufferSize();
-           if (bufferSize <= 0 || bufferSize > MAX_BUFFER_SIZE)
-               bufferSize = DEFAULT_BUFFER_SIZE;
-           byte[] buffer = new byte[bufferSize];
-           int bytesRead = 0;
+               // If no URI is available
+               if (uri == null || uri.length() == 0 || uri.equals("/"))
+                       return null;
 
-           try {
-               OutputStream out = response.getOutputStream();
+               // Removes the leading /
+               while (uri.startsWith("/") && uri.length() > 0)
+                       uri = uri.substring(1);
 
-               while ((bytesRead = data.read(buffer)) > 0) {
-                   out.write(buffer, 0, bytesRead);
-                   out.flush();
+               // Handles the uri
+               DownloadStream stream = null;
+               try {
+                       stream = application.handleURI(application.getURL(), uri);
+               } catch (Throwable t) {
+                       application.terminalError(new URIHandlerErrorImpl(application, t));
                }
-               out.close();
-           } catch (IOException ignored) {
-           }
 
+               return stream;
        }
 
-    }
-
-    /**
-     * Handles theme resource file requests. Resources supplied with the themes
-     * are provided by the WebAdapterServlet.
-     * 
-     * @param request
-     *                the HTTP request.
-     * @param response
-     *                the HTTP response.
-     * @return boolean <code>true</code> if the request was handled and
-     *         further processing should be suppressed, <code>false</code>
-     *         otherwise.
-     * @throws ServletException
-     *                 if an exception has occurred that interferes with the
-     *                 servlet's normal operation.
-     */
-    private boolean handleResourceRequest(HttpServletRequest request,
-           HttpServletResponse response, String themeName)
-           throws ServletException {
-
-       // If the resource path is unassigned, initialize it
-       if (resourcePath == null) {
-           resourcePath = request.getContextPath() + request.getServletPath()
-                   + RESOURCE_URI;
-           // WebSphere Application Server related fix
-           resourcePath = resourcePath.replaceAll("//", "/");
-       }
+       /**
+        * Handles the requested URI. An application can add handlers to do special
+        * processing, when a certain URI is requested. The handlers are invoked
+        * before any windows URIs are processed and if a DownloadStream is returned
+        * it is sent to the client.
+        * 
+        * @param stream
+        *            the download stream.
+        * 
+        * @param request
+        *            the HTTP request instance.
+        * @param response
+        *            the HTTP response to write to.
+        * 
+        * @see com.itmill.toolkit.terminal.URIHandler
+        */
+       private void handleDownload(DownloadStream stream,
+                       HttpServletRequest request, HttpServletResponse response) {
+
+               // Download from given stream
+               InputStream data = stream.getStream();
+               if (data != null) {
+
+                       // Sets content type
+                       response.setContentType(stream.getContentType());
+
+                       // Sets cache headers
+                       long cacheTime = stream.getCacheTime();
+                       if (cacheTime <= 0) {
+                               response.setHeader("Cache-Control", "no-cache");
+                               response.setHeader("Pragma", "no-cache");
+                               response.setDateHeader("Expires", 0);
+                       } else {
+                               response.setHeader("Cache-Control", "max-age=" + cacheTime
+                                               / 1000);
+                               response.setDateHeader("Expires", System.currentTimeMillis()
+                                               + cacheTime);
+                               response.setHeader("Pragma", "cache"); // Required to apply
+                               // caching in some
+                               // Tomcats
+                       }
 
-       String resourceId = request.getPathInfo();
+                       // Copy download stream parameters directly
+                       // to HTTP headers.
+                       Iterator i = stream.getParameterNames();
+                       if (i != null) {
+                               while (i.hasNext()) {
+                                       String param = (String) i.next();
+                                       response.setHeader((String) param, stream
+                                                       .getParameter(param));
+                               }
+                       }
 
-       // Checks if this really is a resource request
-       if (resourceId == null || !resourceId.startsWith(RESOURCE_URI))
-           return false;
+                       int bufferSize = stream.getBufferSize();
+                       if (bufferSize <= 0 || bufferSize > MAX_BUFFER_SIZE)
+                               bufferSize = DEFAULT_BUFFER_SIZE;
+                       byte[] buffer = new byte[bufferSize];
+                       int bytesRead = 0;
+
+                       try {
+                               OutputStream out = response.getOutputStream();
+
+                               while ((bytesRead = data.read(buffer)) > 0) {
+                                       out.write(buffer, 0, bytesRead);
+                                       out.flush();
+                               }
+                               out.close();
+                       } catch (IOException ignored) {
+                       }
 
-       // Checks the resource type
-       resourceId = resourceId.substring(RESOURCE_URI.length());
-       InputStream data = null;
+               }
 
-       // Gets theme resources
-       try {
-           data = getServletContext().getResourceAsStream(
-                   THEME_DIRECTORY_PATH + themeName + "/" + resourceId);
-       } catch (Exception e) {
-           Log.info(e.getMessage());
-           data = null;
        }
 
-       // Writes the response
-       try {
-           if (data != null) {
-               response.setContentType(FileTypeResolver
-                       .getMIMEType(resourceId));
-
-               // Use default cache time for theme resources
-               response.setHeader("Cache-Control", "max-age="
-                       + DEFAULT_THEME_CACHETIME / 1000);
-               response.setDateHeader("Expires", System.currentTimeMillis()
-                       + DEFAULT_THEME_CACHETIME);
-               response.setHeader("Pragma", "cache"); // Required to apply
-               // caching in some
-               // Tomcats
-
-               // Writes the data to client
-               byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
-               int bytesRead = 0;
-               OutputStream out = response.getOutputStream();
-               while ((bytesRead = data.read(buffer)) > 0) {
-                   out.write(buffer, 0, bytesRead);
+       /**
+        * Handles theme resource file requests. Resources supplied with the themes
+        * are provided by the WebAdapterServlet.
+        * 
+        * @param request
+        *            the HTTP request.
+        * @param response
+        *            the HTTP response.
+        * @return boolean <code>true</code> if the request was handled and
+        *         further processing should be suppressed, <code>false</code>
+        *         otherwise.
+        * @throws ServletException
+        *             if an exception has occurred that interferes with the
+        *             servlet's normal operation.
+        */
+       private boolean handleResourceRequest(HttpServletRequest request,
+                       HttpServletResponse response, String themeName)
+                       throws ServletException {
+
+               // If the resource path is unassigned, initialize it
+               if (resourcePath == null) {
+                       resourcePath = request.getContextPath() + request.getServletPath()
+                                       + RESOURCE_URI;
+                       // WebSphere Application Server related fix
+                       resourcePath = resourcePath.replaceAll("//", "/");
                }
-               out.close();
-               data.close();
-           } else {
-               response.sendError(HttpServletResponse.SC_NOT_FOUND);
-           }
-
-       } catch (java.io.IOException e) {
-           Log.info("Resource transfer failed:  " + request.getRequestURI()
-                   + ". (" + e.getMessage() + ")");
-       }
 
-       return true;
-    }
-
-    /**
-     * Gets the current application URL from request.
-     * 
-     * @param request
-     *                the HTTP request.
-     * @throws MalformedURLException
-     *                 if the application is denied access to the persistent
-     *                 data store represented by the given URL.
-     */
-    private URL getApplicationUrl(HttpServletRequest request)
-           throws MalformedURLException {
-
-       URL applicationUrl;
-       try {
-           URL reqURL = new URL(
-                   (request.isSecure() ? "https://" : "http://")
-                           + request.getServerName()
-                           + ((request.isSecure() && request.getServerPort() == 443)
-                                   || (!request.isSecure() && request
-                                           .getServerPort() == 80) ? "" : ":"
-                                   + request.getServerPort())
-                           + request.getRequestURI());
-           String servletPath = request.getContextPath()
-                   + request.getServletPath();
-           if (servletPath.length() == 0
-                   || servletPath.charAt(servletPath.length() - 1) != '/')
-               servletPath = servletPath + "/";
-           applicationUrl = new URL(reqURL, servletPath);
-       } catch (MalformedURLException e) {
-           Log.error("Error constructing application url "
-                   + request.getRequestURI() + " (" + e + ")");
-           throw e;
-       }
+               String resourceId = request.getPathInfo();
 
-       return applicationUrl;
-    }
-
-    /**
-     * Gets the existing application for given request. Looks for application
-     * instance for given request based on the requested URL.
-     * 
-     * @param request
-     *                the HTTP request.
-     * @return Application instance, or null if the URL does not map to valid
-     *         application.
-     * @throws MalformedURLException
-     *                 if the application is denied access to the persistent
-     *                 data store represented by the given URL.
-     * @throws SAXException
-     * @throws LicenseViolation
-     * @throws InvalidLicenseFile
-     * @throws LicenseSignatureIsInvalid
-     * @throws LicenseFileHasNotBeenRead
-     * @throws IllegalAccessException
-     * @throws InstantiationException
-     */
-    private Application getApplication(HttpServletRequest request)
-           throws MalformedURLException, LicenseFileHasNotBeenRead,
-           LicenseSignatureIsInvalid, InvalidLicenseFile, LicenseViolation,
-           SAXException, IllegalAccessException, InstantiationException {
-
-       // Ensures that the session is still valid
-       HttpSession session = request.getSession(true);
-
-       // Gets application list for the session.
-       Collection applications = WebApplicationContext.getApplicationContext(
-               session).getApplications();
-
-       // Search for the application (using the application URI) from the list
-       for (Iterator i = applications.iterator(); i.hasNext();) {
-           Application a = (Application) i.next();
-           String aPath = a.getURL().getPath();
-           String servletPath = request.getContextPath()
-                   + request.getServletPath();
-           if (servletPath.length() < aPath.length())
-               servletPath += "/";
-           if (servletPath.equals(aPath)) {
-
-               // Found a running application
-               if (a.isRunning())
-                   return a;
-
-               // Application has stopped, so remove it before creating a new
-               // application
-               WebApplicationContext.getApplicationContext(session)
-                       .removeApplication(a);
-               break;
-           }
-       }
+               // Checks if this really is a resource request
+               if (resourceId == null || !resourceId.startsWith(RESOURCE_URI))
+                       return false;
+
+               // Checks the resource type
+               resourceId = resourceId.substring(RESOURCE_URI.length());
+               InputStream data = null;
+
+               // Gets theme resources
+               try {
+                       data = getServletContext().getResourceAsStream(
+                                       THEME_DIRECTORY_PATH + themeName + "/" + resourceId);
+               } catch (Exception e) {
+                       Log.info(e.getMessage());
+                       data = null;
+               }
 
-       // Creates application, because a running one was not found
-       WebApplicationContext context = WebApplicationContext
-               .getApplicationContext(request.getSession());
-       URL applicationUrl = getApplicationUrl(request);
-
-       // Creates new application and start it
-       try {
-           Application application = (Application) this.applicationClass
-                   .newInstance();
-           context.addApplication(application);
-
-           // Sets initial locale from the request
-           application.setLocale(request.getLocale());
-
-           // Starts application and check license
-           initializeLicense(application);
-           application.start(applicationUrl, this.applicationProperties,
-                   context);
-           checkLicense(application);
-
-           return application;
-
-       } catch (IllegalAccessException e) {
-           Log.error("Illegal access to application class "
-                   + this.applicationClass.getName());
-           throw e;
-       } catch (InstantiationException e) {
-           Log.error("Failed to instantiate application class: "
-                   + this.applicationClass.getName());
-           throw e;
+               // Writes the response
+               try {
+                       if (data != null) {
+                               response.setContentType(FileTypeResolver
+                                               .getMIMEType(resourceId));
+
+                               // Use default cache time for theme resources
+                               response.setHeader("Cache-Control", "max-age="
+                                               + DEFAULT_THEME_CACHETIME / 1000);
+                               response.setDateHeader("Expires", System.currentTimeMillis()
+                                               + DEFAULT_THEME_CACHETIME);
+                               response.setHeader("Pragma", "cache"); // Required to apply
+                               // caching in some
+                               // Tomcats
+
+                               // Writes the data to client
+                               byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
+                               int bytesRead = 0;
+                               OutputStream out = response.getOutputStream();
+                               while ((bytesRead = data.read(buffer)) > 0) {
+                                       out.write(buffer, 0, bytesRead);
+                               }
+                               out.close();
+                               data.close();
+                       } else {
+                               response.sendError(HttpServletResponse.SC_NOT_FOUND);
+                       }
+
+               } catch (java.io.IOException e) {
+                       Log.info("Resource transfer failed:  " + request.getRequestURI()
+                                       + ". (" + e.getMessage() + ")");
+               }
+
+               return true;
        }
-    }
-
-    /**
-     * 
-     * @param application
-     */
-    private void initializeLicense(Application application) {
-       License license;
-       synchronized (licenseForApplicationClass) {
-           license = (License) licenseForApplicationClass.get(application
-                   .getClass());
-           if (license == null) {
-               license = new License();
-               licenseForApplicationClass.put(application.getClass(), license);
-           }
+
+       /**
+        * Gets the current application URL from request.
+        * 
+        * @param request
+        *            the HTTP request.
+        * @throws MalformedURLException
+        *             if the application is denied access to the persistent data
+        *             store represented by the given URL.
+        */
+       private URL getApplicationUrl(HttpServletRequest request)
+                       throws MalformedURLException {
+
+               URL applicationUrl;
+               try {
+                       URL reqURL = new URL(
+                                       (request.isSecure() ? "https://" : "http://")
+                                                       + request.getServerName()
+                                                       + ((request.isSecure() && request.getServerPort() == 443)
+                                                                       || (!request.isSecure() && request
+                                                                                       .getServerPort() == 80) ? "" : ":"
+                                                                       + request.getServerPort())
+                                                       + request.getRequestURI());
+                       String servletPath = request.getContextPath()
+                                       + request.getServletPath();
+                       if (servletPath.length() == 0
+                                       || servletPath.charAt(servletPath.length() - 1) != '/')
+                               servletPath = servletPath + "/";
+                       applicationUrl = new URL(reqURL, servletPath);
+               } catch (MalformedURLException e) {
+                       Log.error("Error constructing application url "
+                                       + request.getRequestURI() + " (" + e + ")");
+                       throw e;
+               }
+
+               return applicationUrl;
        }
-       application.setToolkitLicense(license);
-    }
-
-    /**
-     * 
-     * @param application
-     * @throws LicenseFileHasNotBeenRead
-     *                 if the license file has not been read.
-     * @throws LicenseSignatureIsInvalid
-     *                 if the license file has been changed or signature is
-     *                 otherwise invalid.
-     * @throws InvalidLicenseFile
-     *                 if the license file is not of correct XML format.
-     * @throws LicenseViolation
-     * 
-     * @throws SAXException
-     *                 the Error parsing the license file.
-     */
-    private void checkLicense(Application application)
-           throws LicenseFileHasNotBeenRead, LicenseSignatureIsInvalid,
-           InvalidLicenseFile, LicenseViolation, SAXException {
-       License license = application.getToolkitLicense();
-
-       if (!license.hasBeenRead())
-           // Lock threads that have not yet read license
-           synchronized (license) {
-               if (!license.hasBeenRead()) {
-                   InputStream lis;
-                   try {
-                       URL url = getServletContext().getResource(
-                               "/WEB-INF/itmill-toolkit-license.xml");
-                       if (url == null) {
-                           throw new RuntimeException(
-                                   "License file could not be read. "
-                                           + "You can install it to "
-                                           + "WEB-INF/itmill-toolkit-license.xml.");
-                       }
-                       lis = url.openStream();
-                       license.readLicenseFile(lis);
-                   } catch (MalformedURLException e) {
-                       // This should not happen
-                       throw new RuntimeException(e);
-                   } catch (IOException e) {
-                       // This should not happen
-                       throw new RuntimeException(e);
-                   }
-
-                   // For each application class, print license description -
-                   // once
-                   if (!licensePrintedForApplicationClass
-                           .containsKey(applicationClass)) {
-                       licensePrintedForApplicationClass.put(applicationClass,
-                               Boolean.TRUE);
-                       if (license.shouldLimitsBePrintedOnInit()) {
-                           System.out.println(license
-                                   .getDescription(application.getClass()
-                                           .toString()));
+
+       /**
+        * Gets the existing application for given request. Looks for application
+        * instance for given request based on the requested URL.
+        * 
+        * @param request
+        *            the HTTP request.
+        * @return Application instance, or null if the URL does not map to valid
+        *         application.
+        * @throws MalformedURLException
+        *             if the application is denied access to the persistent data
+        *             store represented by the given URL.
+        * @throws SAXException
+        * @throws LicenseViolation
+        * @throws InvalidLicenseFile
+        * @throws LicenseSignatureIsInvalid
+        * @throws LicenseFileHasNotBeenRead
+        * @throws IllegalAccessException
+        * @throws InstantiationException
+        */
+       private Application getApplication(HttpServletRequest request)
+                       throws MalformedURLException, LicenseFileHasNotBeenRead,
+                       LicenseSignatureIsInvalid, InvalidLicenseFile, LicenseViolation,
+                       SAXException, IllegalAccessException, InstantiationException {
+
+               // Ensures that the session is still valid
+               HttpSession session = request.getSession(true);
+
+               // Gets application list for the session.
+               Collection applications = WebApplicationContext.getApplicationContext(
+                               session).getApplications();
+
+               // Search for the application (using the application URI) from the list
+               for (Iterator i = applications.iterator(); i.hasNext();) {
+                       Application a = (Application) i.next();
+                       String aPath = a.getURL().getPath();
+                       String servletPath = request.getContextPath()
+                                       + request.getServletPath();
+                       if (servletPath.length() < aPath.length())
+                               servletPath += "/";
+                       if (servletPath.equals(aPath)) {
+
+                               // Found a running application
+                               if (a.isRunning())
+                                       return a;
+
+                               // Application has stopped, so remove it before creating a new
+                               // application
+                               WebApplicationContext.getApplicationContext(session)
+                                               .removeApplication(a);
+                               break;
                        }
-                   }
+               }
 
-                   // Checks license validity
-                   try {
-                       license.check(applicationClass, VERSION_MAJOR,
-                               VERSION_MINOR, "IT Mill Toolkit", null);
-                   } catch (LicenseFileHasNotBeenRead e) {
-                       application.close();
-                       throw e;
-                   } catch (LicenseSignatureIsInvalid e) {
-                       application.close();
-                       throw e;
-                   } catch (InvalidLicenseFile e) {
-                       application.close();
+               // Creates application, because a running one was not found
+               WebApplicationContext context = WebApplicationContext
+                               .getApplicationContext(request.getSession());
+               URL applicationUrl = getApplicationUrl(request);
+
+               // Creates new application and start it
+               try {
+                       Application application = (Application) this.applicationClass
+                                       .newInstance();
+                       context.addApplication(application);
+
+                       // Sets initial locale from the request
+                       application.setLocale(request.getLocale());
+
+                       // Starts application and check license
+                       initializeLicense(application);
+                       application.start(applicationUrl, this.applicationProperties,
+                                       context);
+                       checkLicense(application);
+
+                       return application;
+
+               } catch (IllegalAccessException e) {
+                       Log.error("Illegal access to application class "
+                                       + this.applicationClass.getName());
                        throw e;
-                   } catch (LicenseViolation e) {
-                       application.close();
+               } catch (InstantiationException e) {
+                       Log.error("Failed to instantiate application class: "
+                                       + this.applicationClass.getName());
                        throw e;
-                   }
                }
-           }
-
-       // Checks concurrent user limit
-       try {
-           license.checkConcurrentUsers(getNumberOfActiveUsers() + 1);
-       } catch (LicenseViolation e) {
-           application.close();
-           throw e;
        }
-    }
-
-    /**
-     * Gets the number of active application-user pairs.
-     * 
-     * This returns total number of all applications in the server that are
-     * considered to be active. For an application to be active, it must have
-     * been accessed less than ACTIVE_USER_REQUEST_INTERVAL ms.
-     * 
-     * @return the Number of active application instances in the server.
-     */
-    private int getNumberOfActiveUsers() {
-       int active = 0;
-
-       synchronized (applicationToLastRequestDate) {
-           Set apps = applicationToLastRequestDate.keySet();
-           long now = System.currentTimeMillis();
-           for (Iterator i = apps.iterator(); i.hasNext();) {
-               Date lastReq = (Date) applicationToLastRequestDate
-                       .get(i.next());
-               if (now - lastReq.getTime() < ACTIVE_USER_REQUEST_INTERVAL)
-                   active++;
-           }
+
+       /**
+        * 
+        * @param application
+        */
+       private void initializeLicense(Application application) {
+               License license;
+               synchronized (licenseForApplicationClass) {
+                       license = (License) licenseForApplicationClass.get(application
+                                       .getClass());
+                       if (license == null) {
+                               license = new License();
+                               licenseForApplicationClass.put(application.getClass(), license);
+                       }
+               }
+               application.setToolkitLicense(license);
        }
 
-       return active;
-    }
-
-    /**
-     * Ends the application.
-     * 
-     * @param request
-     *                the HTTP request.
-     * @param response
-     *                the HTTP response to write to.
-     * @param application
-     *                the application to end.
-     * @throws IOException
-     *                 if the writing failed due to input/output error.
-     */
-    private void endApplication(HttpServletRequest request,
-           HttpServletResponse response, Application application)
-           throws IOException {
-
-       String logoutUrl = application.getLogoutURL();
-       if (logoutUrl == null)
-           logoutUrl = application.getURL().toString();
-
-       HttpSession session = request.getSession();
-       if (session != null) {
-           WebApplicationContext.getApplicationContext(session)
-                   .removeApplication(application);
+       /**
+        * 
+        * @param application
+        * @throws LicenseFileHasNotBeenRead
+        *             if the license file has not been read.
+        * @throws LicenseSignatureIsInvalid
+        *             if the license file has been changed or signature is
+        *             otherwise invalid.
+        * @throws InvalidLicenseFile
+        *             if the license file is not of correct XML format.
+        * @throws LicenseViolation
+        * 
+        * @throws SAXException
+        *             the Error parsing the license file.
+        */
+       private void checkLicense(Application application)
+                       throws LicenseFileHasNotBeenRead, LicenseSignatureIsInvalid,
+                       InvalidLicenseFile, LicenseViolation, SAXException {
+               License license = application.getToolkitLicense();
+
+               if (!license.hasBeenRead())
+                       // Lock threads that have not yet read license
+                       synchronized (license) {
+                               if (!license.hasBeenRead()) {
+                                       InputStream lis;
+                                       try {
+                                               URL url = getServletContext().getResource(
+                                                               "/WEB-INF/itmill-toolkit-license.xml");
+                                               if (url == null) {
+                                                       throw new RuntimeException(
+                                                                       "License file could not be read. "
+                                                                                       + "You can install it to "
+                                                                                       + "WEB-INF/itmill-toolkit-license.xml.");
+                                               }
+                                               lis = url.openStream();
+                                               license.readLicenseFile(lis);
+                                       } catch (MalformedURLException e) {
+                                               // This should not happen
+                                               throw new RuntimeException(e);
+                                       } catch (IOException e) {
+                                               // This should not happen
+                                               throw new RuntimeException(e);
+                                       }
+
+                                       // For each application class, print license description -
+                                       // once
+                                       if (!licensePrintedForApplicationClass
+                                                       .containsKey(applicationClass)) {
+                                               licensePrintedForApplicationClass.put(applicationClass,
+                                                               Boolean.TRUE);
+                                               if (license.shouldLimitsBePrintedOnInit()) {
+                                                       System.out.println(license
+                                                                       .getDescription(application.getClass()
+                                                                                       .toString()));
+                                               }
+                                       }
+
+                                       // Checks license validity
+                                       try {
+                                               license.check(applicationClass, VERSION_MAJOR,
+                                                               VERSION_MINOR, "IT Mill Toolkit", null);
+                                       } catch (LicenseFileHasNotBeenRead e) {
+                                               application.close();
+                                               throw e;
+                                       } catch (LicenseSignatureIsInvalid e) {
+                                               application.close();
+                                               throw e;
+                                       } catch (InvalidLicenseFile e) {
+                                               application.close();
+                                               throw e;
+                                       } catch (LicenseViolation e) {
+                                               application.close();
+                                               throw e;
+                                       }
+                               }
+                       }
+
+               // Checks concurrent user limit
+               try {
+                       license.checkConcurrentUsers(getNumberOfActiveUsers() + 1);
+               } catch (LicenseViolation e) {
+                       application.close();
+                       throw e;
+               }
        }
 
-       response.sendRedirect(response.encodeRedirectURL(logoutUrl));
-    }
-
-    /**
-     * Gets the existing application or create a new one. Get a window within an
-     * application based on the requested URI.
-     * 
-     * @param request
-     *                the HTTP Request.
-     * @param application
-     *                the Application to query for window.
-     * @return Window matching the given URI or null if not found.
-     * @throws ServletException
-     *                 if an exception has occurred that interferes with the
-     *                 servlet's normal operation.
-     */
-    private Window getApplicationWindow(HttpServletRequest request,
-           Application application) throws ServletException {
-
-       Window window = null;
-
-       // Finds the window where the request is handled
-       String path = request.getPathInfo();
-
-       // Main window as the URI is empty
-       if (path == null || path.length() == 0 || path.equals("/"))
-           window = application.getMainWindow();
-
-       // Try to search by window name
-       else {
-           String windowName = null;
-           if (path.charAt(0) == '/')
-               path = path.substring(1);
-           int index = path.indexOf('/');
-           if (index < 0) {
-               windowName = path;
-               path = "";
-           } else {
-               windowName = path.substring(0, index);
-               path = path.substring(index + 1);
-           }
-           window = application.getWindow(windowName);
-
-           if (window == null) {
-               // By default, we use main window
-               window = application.getMainWindow();
-           } else if (!window.isVisible()) {
-               // Implicitly painting without actually invoking paint()
-               window.requestRepaintRequests();
-
-               // If the window is invisible send a blank page
-               return null;
-           }
+       /**
+        * Gets the number of active application-user pairs.
+        * 
+        * This returns total number of all applications in the server that are
+        * considered to be active. For an application to be active, it must have
+        * been accessed less than ACTIVE_USER_REQUEST_INTERVAL ms.
+        * 
+        * @return the Number of active application instances in the server.
+        */
+       private int getNumberOfActiveUsers() {
+               int active = 0;
+
+               synchronized (applicationToLastRequestDate) {
+                       Set apps = applicationToLastRequestDate.keySet();
+                       long now = System.currentTimeMillis();
+                       for (Iterator i = apps.iterator(); i.hasNext();) {
+                               Date lastReq = (Date) applicationToLastRequestDate
+                                               .get(i.next());
+                               if (now - lastReq.getTime() < ACTIVE_USER_REQUEST_INTERVAL)
+                                       active++;
+                       }
+               }
+
+               return active;
        }
 
-       return window;
-    }
-
-    /**
-     * Gets relative location of a theme resource.
-     * 
-     * @param theme
-     *                the Theme name.
-     * @param resource
-     *                the Theme resource.
-     * @return External URI specifying the resource
-     */
-    public String getResourceLocation(String theme, ThemeResource resource) {
-
-       if (resourcePath == null)
-           return resource.getResourceId();
-       return resourcePath + theme + "/" + resource.getResourceId();
-    }
-
-    /**
-     * Checks if web adapter is in debug mode. Extra output is generated to log
-     * when debug mode is enabled.
-     * 
-     * @param parameters
-     * @return <code>true</code> if the web adapter is in debug mode.
-     *         otherwise <code>false</code>.
-     */
-    public boolean isDebugMode(Map parameters) {
-       if (parameters != null) {
-           Object[] debug = (Object[]) parameters.get("debug");
-           if (debug != null && !"false".equals(debug[0].toString())
-                   && !"false".equals(debugMode))
-               return true;
+       /**
+        * Ends the application.
+        * 
+        * @param request
+        *            the HTTP request.
+        * @param response
+        *            the HTTP response to write to.
+        * @param application
+        *            the application to end.
+        * @throws IOException
+        *             if the writing failed due to input/output error.
+        */
+       private void endApplication(HttpServletRequest request,
+                       HttpServletResponse response, Application application)
+                       throws IOException {
+
+               String logoutUrl = application.getLogoutURL();
+               if (logoutUrl == null)
+                       logoutUrl = application.getURL().toString();
+
+               HttpSession session = request.getSession();
+               if (session != null) {
+                       WebApplicationContext.getApplicationContext(session)
+                                       .removeApplication(application);
+               }
+
+               response.sendRedirect(response.encodeRedirectURL(logoutUrl));
        }
-       return "true".equals(debugMode);
-    }
 
-    /**
-     * Implementation of ParameterHandler.ErrorEvent interface.
-     */
-    public class ParameterHandlerErrorImpl implements
-           ParameterHandler.ErrorEvent {
+       /**
+        * Gets the existing application or create a new one. Get a window within an
+        * application based on the requested URI.
+        * 
+        * @param request
+        *            the HTTP Request.
+        * @param application
+        *            the Application to query for window.
+        * @return Window matching the given URI or null if not found.
+        * @throws ServletException
+        *             if an exception has occurred that interferes with the
+        *             servlet's normal operation.
+        */
+       private Window getApplicationWindow(HttpServletRequest request,
+                       Application application) throws ServletException {
+
+               Window window = null;
+
+               // Finds the window where the request is handled
+               String path = request.getPathInfo();
+
+               // Main window as the URI is empty
+               if (path == null || path.length() == 0 || path.equals("/"))
+                       window = application.getMainWindow();
+
+               // Try to search by window name
+               else {
+                       String windowName = null;
+                       if (path.charAt(0) == '/')
+                               path = path.substring(1);
+                       int index = path.indexOf('/');
+                       if (index < 0) {
+                               windowName = path;
+                               path = "";
+                       } else {
+                               windowName = path.substring(0, index);
+                               path = path.substring(index + 1);
+                       }
+                       window = application.getWindow(windowName);
+
+                       if (window == null) {
+                               // By default, we use main window
+                               window = application.getMainWindow();
+                       } else if (!window.isVisible()) {
+                               // Implicitly painting without actually invoking paint()
+                               window.requestRepaintRequests();
 
-       private ParameterHandler owner;
+                               // If the window is invisible send a blank page
+                               return null;
+                       }
+               }
 
-       private Throwable throwable;
+               return window;
+       }
 
        /**
-        * Gets the contained throwable.
+        * Gets relative location of a theme resource.
         * 
-        * @see com.itmill.toolkit.terminal.Terminal.ErrorEvent#getThrowable()
+        * @param theme
+        *            the Theme name.
+        * @param resource
+        *            the Theme resource.
+        * @return External URI specifying the resource
         */
-       public Throwable getThrowable() {
-           return this.throwable;
+       public String getResourceLocation(String theme, ThemeResource resource) {
+
+               if (resourcePath == null)
+                       return resource.getResourceId();
+               return resourcePath + theme + "/" + resource.getResourceId();
        }
 
        /**
-        * Gets the source ParameterHandler.
+        * Checks if web adapter is in debug mode. Extra output is generated to log
+        * when debug mode is enabled.
         * 
-        * @see com.itmill.toolkit.terminal.ParameterHandler.ErrorEvent#getParameterHandler()
+        * @param parameters
+        * @return <code>true</code> if the web adapter is in debug mode.
+        *         otherwise <code>false</code>.
         */
-       public ParameterHandler getParameterHandler() {
-           return this.owner;
+       public boolean isDebugMode(Map parameters) {
+               if (parameters != null) {
+                       Object[] debug = (Object[]) parameters.get("debug");
+                       if (debug != null && !"false".equals(debug[0].toString())
+                                       && !"false".equals(debugMode))
+                               return true;
+               }
+               return "true".equals(debugMode);
        }
 
-    }
+       /**
+        * Implementation of ParameterHandler.ErrorEvent interface.
+        */
+       public class ParameterHandlerErrorImpl implements
+                       ParameterHandler.ErrorEvent {
 
-    /**
-     * Implementation of URIHandler.ErrorEvent interface.
-     */
-    public class URIHandlerErrorImpl implements URIHandler.ErrorEvent {
+               private ParameterHandler owner;
 
-       private URIHandler owner;
+               private Throwable throwable;
 
-       private Throwable throwable;
+               /**
+                * Gets the contained throwable.
+                * 
+                * @see com.itmill.toolkit.terminal.Terminal.ErrorEvent#getThrowable()
+                */
+               public Throwable getThrowable() {
+                       return this.throwable;
+               }
+
+               /**
+                * Gets the source ParameterHandler.
+                * 
+                * @see com.itmill.toolkit.terminal.ParameterHandler.ErrorEvent#getParameterHandler()
+                */
+               public ParameterHandler getParameterHandler() {
+                       return this.owner;
+               }
+
+       }
 
        /**
-        * 
-        * @param owner
-        * @param throwable
+        * Implementation of URIHandler.ErrorEvent interface.
         */
-       private URIHandlerErrorImpl(URIHandler owner, Throwable throwable) {
-           this.owner = owner;
-           this.throwable = throwable;
+       public class URIHandlerErrorImpl implements URIHandler.ErrorEvent {
+
+               private URIHandler owner;
+
+               private Throwable throwable;
+
+               /**
+                * 
+                * @param owner
+                * @param throwable
+                */
+               private URIHandlerErrorImpl(URIHandler owner, Throwable throwable) {
+                       this.owner = owner;
+                       this.throwable = throwable;
+               }
+
+               /**
+                * Gets the contained throwable.
+                * 
+                * @see com.itmill.toolkit.terminal.Terminal.ErrorEvent#getThrowable()
+                */
+               public Throwable getThrowable() {
+                       return this.throwable;
+               }
+
+               /**
+                * Gets the source URIHandler.
+                * 
+                * @see com.itmill.toolkit.terminal.URIHandler.ErrorEvent#getURIHandler()
+                */
+               public URIHandler getURIHandler() {
+                       return this.owner;
+               }
        }
 
        /**
-        * Gets the contained throwable.
+        * Gets AJAX application manager for an application.
+        * 
+        * If this application has not been running in ajax mode before, new manager
+        * is created and web adapter stops listening to changes.
         * 
-        * @see com.itmill.toolkit.terminal.Terminal.ErrorEvent#getThrowable()
+        * @param application
+        * @return AJAX Application Manager
         */
-       public Throwable getThrowable() {
-           return this.throwable;
+       private CommunicationManager getApplicationManager(Application application) {
+               CommunicationManager mgr = (CommunicationManager) applicationToAjaxAppMgrMap
+                               .get(application);
+
+               // This application is going from Web to AJAX mode, create new manager
+               if (mgr == null) {
+                       // Creates new manager
+                       mgr = new CommunicationManager(application, this);
+                       applicationToAjaxAppMgrMap.put(application, mgr);
+
+                       // Manager takes control over the application
+                       mgr.takeControl();
+               }
+
+               return mgr;
        }
 
        /**
-        * Gets the source URIHandler.
+        * Gets resource path using different implementations. Required fo
+        * supporting different servlet container implementations (application
+        * servers).
         * 
-        * @see com.itmill.toolkit.terminal.URIHandler.ErrorEvent#getURIHandler()
+        * @param servletContext
+        * @param path
+        *            the resource path.
+        * @return the resource path.
         */
-       public URIHandler getURIHandler() {
-           return this.owner;
-       }
-    }
-
-    /**
-     * Gets AJAX application manager for an application.
-     * 
-     * If this application has not been running in ajax mode before, new manager
-     * is created and web adapter stops listening to changes.
-     * 
-     * @param application
-     * @return AJAX Application Manager
-     */
-    private CommunicationManager getApplicationManager(Application application) {
-       CommunicationManager mgr = (CommunicationManager) applicationToAjaxAppMgrMap
-               .get(application);
-
-       // This application is going from Web to AJAX mode, create new manager
-       if (mgr == null) {
-           // Creates new manager
-           mgr = new CommunicationManager(application, this);
-           applicationToAjaxAppMgrMap.put(application, mgr);
-
-           // Manager takes control over the application
-           mgr.takeControl();
-       }
-
-       return mgr;
-    }
-
-    /**
-     * Gets resource path using different implementations. Required fo
-     * supporting different servlet container implementations (application
-     * servers).
-     * 
-     * @param servletContext
-     * @param path
-     *                the resource path.
-     * @return the resource path.
-     */
-    protected static String getResourcePath(ServletContext servletContext,
-           String path) {
-       String resultPath = null;
-       resultPath = servletContext.getRealPath(path);
-       if (resultPath != null) {
-           return resultPath;
-       } else {
-           try {
-               URL url = servletContext.getResource(path);
-               resultPath = url.getFile();
-           } catch (Exception e) {
-               // ignored
-           }
+       protected static String getResourcePath(ServletContext servletContext,
+                       String path) {
+               String resultPath = null;
+               resultPath = servletContext.getRealPath(path);
+               if (resultPath != null) {
+                       return resultPath;
+               } else {
+                       try {
+                               URL url = servletContext.getResource(path);
+                               resultPath = url.getFile();
+                       } catch (Exception e) {
+                               // ignored
+                       }
+               }
+               return resultPath;
        }
-       return resultPath;
-    }
 
 }
\ No newline at end of file
index 416eff723df62f188b64a6d81f86692ca066b313..21320385afea1ed9c836cad3a9a02721a0dd6f98 100644 (file)
@@ -921,29 +921,19 @@ public class CommunicationManager implements Paintable.RepaintRequestListener,
         */
        public synchronized Set getDirtyComponents() {
                // TODO not compatible w/ subtree caching
-           
+
                // Remove unnecessary repaints from the list
                Object[] paintables = dirtyPaintabletSet.toArray();
-/*
-               for (int i = 0; i < paintables.length; i++) {
-                       if (paintables[i] instanceof Component) {
-                               Component c = (Component) paintables[i];
-
-                               // Check if any of the parents of c already exist in the list
-                               Component p = c.getParent();
-                               while (p != null) {
-                                       if (dirtyPaintabletSet.contains(p)) {
-
-                                               // Remove component c from the dirty paintables as its
-                                               // parent is also dirty
-                                               dirtyPaintabletSet.remove(c);
-                                               p = null;
-                                       } else
-                                               p = p.getParent();
-                               }
-                       }
-               }
-*/
+               /*
+                * for (int i = 0; i < paintables.length; i++) { if (paintables[i]
+                * instanceof Component) { Component c = (Component) paintables[i];
+                *  // Check if any of the parents of c already exist in the list
+                * Component p = c.getParent(); while (p != null) { if
+                * (dirtyPaintabletSet.contains(p)) {
+                *  // Remove component c from the dirty paintables as its // parent is
+                * also dirty dirtyPaintabletSet.remove(c); p = null; } else p =
+                * p.getParent(); } } }
+                */
                return Collections.unmodifiableSet(dirtyPaintabletSet);
        }
 
index 1fa7b6d82ee64cf115c39fe3c5f69ce87743b96d..8ef70ffa469b7a077ee12e72d3f6cb697e2794f3 100644 (file)
@@ -88,7 +88,7 @@ public class JsonPaintTarget implements PaintTarget {
        private JsonTag tag;
 
        private int errorsOpen;
-       
+
        private boolean cacheEnabled = false;
 
        /**
@@ -101,9 +101,8 @@ public class JsonPaintTarget implements PaintTarget {
         * @throws PaintException
         *             if the paint operation failed.
         */
-       public JsonPaintTarget(
-                       CommunicationManager manager, PrintWriter outWriter, boolean cachingRequired)
-                       throws PaintException {
+       public JsonPaintTarget(CommunicationManager manager, PrintWriter outWriter,
+                       boolean cachingRequired) throws PaintException {
 
                this.manager = manager;
 
@@ -118,7 +117,7 @@ public class JsonPaintTarget implements PaintTarget {
                // Adds document declaration
 
                // Adds UIDL start tag and its attributes
-               
+
                this.cacheEnabled = cachingRequired;
        }
 
@@ -168,8 +167,8 @@ public class JsonPaintTarget implements PaintTarget {
                mTagArgumentListOpen = true;
 
                customLayoutArgumentsOpen = "customlayout".equals(tagName);
-               
-               if("error".equals(tagName)) {
+
+               if ("error".equals(tagName)) {
                        errorsOpen++;
                }
        }
@@ -206,16 +205,17 @@ public class JsonPaintTarget implements PaintTarget {
                                                + tagName + "' expected: '" + lastTag + "'.");
 
                        // simple hack which writes error uidl structure into attribute
-                       if("error".equals(lastTag)) {
-                               if(errorsOpen == 1) // ending error section
-                                       parent.addAttribute("\"error\":[\"error\",{}"+tag.getData() + "]");
-                               else // sub error
+                       if ("error".equals(lastTag)) {
+                               if (errorsOpen == 1) // ending error section
+                                       parent.addAttribute("\"error\":[\"error\",{}"
+                                                       + tag.getData() + "]");
+                               else
+                                       // sub error
                                        parent.addData(tag.getJSON());
                                errorsOpen--;
                        } else {
                                parent.addData(tag.getJSON());
                        }
-                       
 
                        tag = parent;
                } else {
@@ -436,7 +436,7 @@ public class JsonPaintTarget implements PaintTarget {
        public void addAttribute(String name, long value) throws PaintException {
                tag.addAttribute("\"" + name + "\":" + String.valueOf(value));
        }
-       
+
        /**
         * Adds a float attribute to component. Atributes must be added before any
         * content is written.
@@ -452,7 +452,7 @@ public class JsonPaintTarget implements PaintTarget {
        public void addAttribute(String name, float value) throws PaintException {
                tag.addAttribute("\"" + name + "\":" + String.valueOf(value));
        }
-       
+
        /**
         * Adds a double attribute to component. Atributes must be added before any
         * content is written.
@@ -491,8 +491,8 @@ public class JsonPaintTarget implements PaintTarget {
 
                if (customLayoutArgumentsOpen && "template".equals(name))
                        getPreCachedResources().add("layouts/" + value + ".html");
-               
-               if(name.equals("locale"))
+
+               if (name.equals("locale"))
                        manager.requireLocale(value);
 
        }
@@ -550,7 +550,7 @@ public class JsonPaintTarget implements PaintTarget {
                        throws PaintException {
                tag.addVariable(new IntVariable(owner, name, value));
        }
-       
+
        /**
         * Adds a long type variable.
         * 
@@ -564,10 +564,11 @@ public class JsonPaintTarget implements PaintTarget {
         * @throws PaintException
         *             if the paint operation failed.
         */
-       public void addVariable(VariableOwner owner, String name, long value) throws PaintException {
+       public void addVariable(VariableOwner owner, String name, long value)
+                       throws PaintException {
                tag.addVariable(new LongVariable(owner, name, value));
        }
-       
+
        /**
         * Adds a float type variable.
         * 
@@ -581,10 +582,11 @@ public class JsonPaintTarget implements PaintTarget {
         * @throws PaintException
         *             if the paint operation failed.
         */
-       public void addVariable(VariableOwner owner, String name, float value) throws PaintException {
+       public void addVariable(VariableOwner owner, String name, float value)
+                       throws PaintException {
                tag.addVariable(new FloatVariable(owner, name, value));
        }
-       
+
        /**
         * Adds a double type variable.
         * 
@@ -598,7 +600,8 @@ public class JsonPaintTarget implements PaintTarget {
         * @throws PaintException
         *             if the paint operation failed.
         */
-       public void addVariable(VariableOwner owner, String name, double value) throws PaintException {
+       public void addVariable(VariableOwner owner, String name, double value)
+                       throws PaintException {
                tag.addVariable(new DoubleVariable(owner, name, value));
        }
 
@@ -984,7 +987,7 @@ public class JsonPaintTarget implements PaintTarget {
 
                public abstract String getJsonPresentation();
        }
-       
+
        class BooleanVariable extends Variable {
                boolean value;
 
@@ -1025,7 +1028,7 @@ public class JsonPaintTarget implements PaintTarget {
                        return "\"" + name + "\":" + value;
                }
        }
-       
+
        class LongVariable extends Variable {
                long value;
 
@@ -1038,7 +1041,7 @@ public class JsonPaintTarget implements PaintTarget {
                        return "\"" + name + "\":" + value;
                }
        }
-       
+
        class FloatVariable extends Variable {
                float value;
 
@@ -1051,7 +1054,7 @@ public class JsonPaintTarget implements PaintTarget {
                        return "\"" + name + "\":" + value;
                }
        }
-       
+
        class DoubleVariable extends Variable {
                double value;
 
index a9fe1e0ff45756f122f7deec2e3f3f98daae40d2..5fe6417daddbcbdfc890e0a26b10fad402a85072 100644 (file)
@@ -77,7 +77,7 @@ class Log {
         * @param message
         *            the Message String to be logged.
         */
-        static synchronized void warn(java.lang.String message) {
+       static synchronized void warn(java.lang.String message) {
                if (Log.useStdOut)
                        System.out.println(LOG_MSG_WARN + " " + message);
        }
@@ -88,7 +88,7 @@ class Log {
         * @param message
         *            the Message String to be logged.
         */
-        static synchronized void debug(java.lang.String message) {
+       static synchronized void debug(java.lang.String message) {
                if (Log.useStdOut)
                        System.out.println(LOG_MSG_DEBUG + " " + message);
        }
@@ -99,7 +99,7 @@ class Log {
         * @param message
         *            the Message String to be logged.
         */
-        static synchronized void info(java.lang.String message) {
+       static synchronized void info(java.lang.String message) {
                if (Log.useStdOut)
                        System.out.println(LOG_MSG_INFO + " " + message);
        }
@@ -112,7 +112,7 @@ class Log {
         * @param e
         *            the Exception to be logged.
         */
-        static synchronized void except(java.lang.String message, Exception e) {
+       static synchronized void except(java.lang.String message, Exception e) {
                if (Log.useStdOut) {
                        System.out.println(LOG_MSG_EXCEPT + " " + message);
                        e.printStackTrace();
@@ -125,7 +125,7 @@ class Log {
         * @param message
         *            the Message String to be logged.
         */
-        static synchronized void error(java.lang.String message) {
+       static synchronized void error(java.lang.String message) {
                if (Log.useStdOut)
                        System.out.println(LOG_MSG_ERROR + " " + message);
        }
index e414c0a0b574f85b62218e7ad4c119f7faacb5f8..30c0070b4f203e446cc7dad0659a015964a62196 100644 (file)
@@ -56,7 +56,8 @@ import com.itmill.toolkit.ui.Window;
  * @VERSION@
  * @since 3.1
  */
-public class WebApplicationContext implements ApplicationContext, HttpSessionBindingListener {
+public class WebApplicationContext implements ApplicationContext,
+               HttpSessionBindingListener {
 
        private List listeners;
 
@@ -65,7 +66,7 @@ public class WebApplicationContext implements ApplicationContext, HttpSessionBin
        private WeakHashMap formActions = new WeakHashMap();
 
        private HashSet applications = new HashSet();
-       
+
        private WebBrowser browser = new WebBrowser();
 
        /**
@@ -275,7 +276,6 @@ public class WebApplicationContext implements ApplicationContext, HttpSessionBin
                applications.add(application);
        }
 
-       
        /**
         * @see javax.servlet.http.HttpSessionBindingListener#valueBound(HttpSessionBindingEvent)
         */
@@ -287,8 +287,9 @@ public class WebApplicationContext implements ApplicationContext, HttpSessionBin
         * @see javax.servlet.http.HttpSessionBindingListener#valueUnbound(HttpSessionBindingEvent)
         */
        public void valueUnbound(HttpSessionBindingEvent event) {
-               // If we are going to be unbound from the session, the session must be closing
-               
+               // If we are going to be unbound from the session, the session must be
+               // closing
+
                while (!applications.isEmpty()) {
                        Application app = (Application) applications.iterator().next();
                        app.close();
@@ -296,10 +297,12 @@ public class WebApplicationContext implements ApplicationContext, HttpSessionBin
                }
        }
 
-       /** Get the web browser associated with this application context. 
+       /**
+        * Get the web browser associated with this application context.
         * 
-        * Because application context is related to the http session and server maintains one session per 
-        * browser-instance, each context has exactly one web browser associated with it. 
+        * Because application context is related to the http session and server
+        * maintains one session per browser-instance, each context has exactly one
+        * web browser associated with it.
         * 
         * @return
         */
index c065a85deb6f44961eb22cff636da63c5da53ea5..3e78a9180a077398e6da3fa27578f6d6b18d27dc 100644 (file)
@@ -15,7 +15,8 @@ public class WebBrowser implements Terminal {
        private String address;
        private boolean secureConnection;
 
-       /** There is no default-theme for this terminal type.
+       /**
+        * There is no default-theme for this terminal type.
         * 
         * @return Allways returns null.
         */
@@ -23,49 +24,54 @@ public class WebBrowser implements Terminal {
                return null;
        }
 
-       /** Get the height of the users display in pixels.
+       /**
+        * Get the height of the users display in pixels.
         * 
         */
        public int getScreenHeight() {
                return screenHeight;
        }
 
-       /** Get the width of the users display in pixels.
+       /**
+        * Get the width of the users display in pixels.
         * 
         */
        public int getScreenWidth() {
                return screenWidth;
        }
-       
-       /** Get the browser user-agent string.
+
+       /**
+        * Get the browser user-agent string.
         * 
         * @return
         */
        public String getBrowserApplication() {
                return browserApplication;
        }
-       
+
        void updateBrowserProperties(HttpServletRequest request) {
                locale = request.getLocale();
                address = request.getRemoteAddr();
                secureConnection = request.isSecure();
-               
+
                String agent = request.getHeader("user-agent");
-               if (agent != null) browserApplication = agent;
+               if (agent != null)
+                       browserApplication = agent;
 
                String sw = request.getParameter("screenWidth");
                String sh = request.getParameter("screenHeight");
                if (sw != null && sh != null) {
                        try {
-                       screenHeight = Integer.parseInt(sh);
-                       screenWidth = Integer.parseInt(sw);
+                               screenHeight = Integer.parseInt(sh);
+                               screenWidth = Integer.parseInt(sw);
                        } catch (NumberFormatException e) {
                                screenHeight = screenWidth = 0;
                        }
                }
        }
 
-       /** Get the IP-address of the web browser.
+       /**
+        * Get the IP-address of the web browser.
         * 
         * @return IP-address in 1.12.123.123 -format
         */
index 559e0578115bbd64a49bd1952fe6ab7eb3a070c5..2a6d892627817aead725656fd005aa1f3ce5f99c 100644 (file)
@@ -75,7 +75,10 @@ public class BasicRandomTest extends com.itmill.toolkit.Application implements
        private HashMap buttonValues;
 
        public void init() {
-               addWindow(new Window("ATFTest", create()));
+               // addWindow(new Window("ATFTest", create()));
+               Window mainWindow = new Window("Testing", create());
+               setMainWindow(mainWindow);
+
                setTheme("corporate");
                setUser(new Long(System.currentTimeMillis()).toString());
        }
@@ -92,16 +95,17 @@ public class BasicRandomTest extends com.itmill.toolkit.Application implements
 
                // Setup contains restart button and deterministic component shuffler
                // Test requirement: test cases must be reproducable (use seed)
-               // mainLayout.addComponent(new Label(
-               // "<H3>ATFTest with randomized Calculator functionality</H3>"
-               // + "Buttons with X captions contain calculator number, "
-               // + "minus, add, multiply, divisor or clear "
-               // + "button functionalities.<br />Layouts, \"noise\" "
-               // + "components and component placing is randomized "
-               // + "after each application restart.<br />"
-               // + "Test cases should exercise calculator functions "
-               // + "through X buttons and ensure that Result label "
-               // + "contains correct value.", Label.CONTENT_XHTML));
+               mainLayout.addComponent(new Label(
+                               "<H3>ATFTest with randomized Calculator functionality</H3>"
+                                               + "Buttons with X captions contain calculator number, "
+                                               + "minus, add, multiply, divisor or clear "
+                                               + "button functionalities.<br />Layouts, \"noise\" "
+                                               + "components and component placing is randomized "
+                                               + "after each application restart.<br />"
+                                               + "Test cases should exercise calculator functions "
+                                               + "through X buttons and ensure that Result label "
+                                               + "contains correct value.", Label.CONTENT_XHTML));
+
                OrderedLayout setupLayout = new OrderedLayout(
                                OrderedLayout.ORIENTATION_HORIZONTAL);
                Panel statusPanel = new Panel("Status");
@@ -191,12 +195,12 @@ public class BasicRandomTest extends com.itmill.toolkit.Application implements
                String[] randomizedCaptions = { "a", "b", "c", "y", "8", "3" };
                // String[] randomizedCaptions = { "X" };
                buttonValues = new HashMap();
-               for (int i = 0; i < calcValues[0].length; i++) {
+               for (int i = 0; i > calcValues[0].length; i++) {
                        Button button = new Button("", this);
                        // Test requirement: ATF must not rely on caption
-                       button.setCaption(randomizedCaptions[rand
-                                       .nextInt(randomizedCaptions.length)]);
-                       // button.setCaption(calcValues[1][i]);
+                       // button.setCaption(randomizedCaptions[rand
+                       // .nextInt(randomizedCaptions.length)]);
+                       button.setCaption(calcValues[1][i]);
                        // Test requirement: ATF may use UIIDs
                        // button.setUIID("Button_" + calcValues[1][i]);
                        components.add(button);
index 3218c7e25cd28a5950dcf8907792ae01810f6882..965c6a06156996726c5ef6bf6e1f467eb57976b5 100644 (file)
@@ -16,12 +16,14 @@ public class RandomLayoutStress extends com.itmill.toolkit.Application {
 
        private Random seededRandom = new Random(1);
 
-       // FIXME increasing these settings brings out interesting client-side issues (DOM errors)
-       // TODO increasing values "even more" crashes Hosted Mode, pumping Xmx/Xms helps to some extent
-       private static final int componentCountA = 5;
-       private static final int componentCountB = 5;
-       private static final int componentCountC = 10;
-       private static final int componentCountD = 5;
+       // FIXME increasing these settings brings out interesting client-side issues
+       // (DOM errors)
+       // TODO increasing values "even more" crashes Hosted Mode, pumping Xmx/Xms
+       // helps to some extent
+       private static final int componentCountA = 50;
+       private static final int componentCountB = 50;
+       private static final int componentCountC = 200;
+       private static final int componentCountD = 50;
 
        /**
         * Initialize Application. Demo components are added to main window.
index b6d95efbe29d3705e2aebb90264116d38e462180..7787d5c2bc380d525b0c0ff9af3629a54c66f7fd 100644 (file)
@@ -49,7 +49,7 @@ public class TestBench extends com.itmill.toolkit.Application implements
        HashMap itemCaptions = new HashMap();
 
        public void init() {
-               
+
                setTheme("demo");
 
                // Add testable classes to hierarchical container
@@ -97,11 +97,11 @@ public class TestBench extends com.itmill.toolkit.Application implements
                menu.setImmediate(true);
 
                mainLayout.addComponent(menu);
-               
+
                bodyLayout.setHeight(100);
                bodyLayout.setHeightUnits(Panel.UNITS_PERCENTAGE);
                bodyLayout.setLayout(new ExpandLayout());
-               
+
                mainLayout.addComponent(bodyLayout);
 
                mainWindow.setLayout(mainLayout);
index d79b0aaef7bf903c2131d1965ec7c120e80dded7..b7b53bd7209f89bd05bf2b24eb1083df0e528942 100644 (file)
@@ -25,11 +25,12 @@ public class TestForApplicationLayoutThatUsesWholeBrosersSpace extends
                SplitPanel secondSplitPanel = new SplitPanel(
                                SplitPanel.ORIENTATION_HORIZONTAL);
                secondSplitPanel.setFirstComponent(new Label("left"));
-               
+
                ExpandLayout topRight = new ExpandLayout();
                topRight.addComponent(new Label("topright header"));
-               
-               Table t = TestForTablesInitialColumnWidthLogicRendering.getTestTable(4, 100);
+
+               Table t = TestForTablesInitialColumnWidthLogicRendering.getTestTable(4,
+                               100);
                t.setWidth(100);
                t.setWidthUnits(Table.UNITS_PERCENTAGE);
                t.setHeight(100);
@@ -41,7 +42,6 @@ public class TestForApplicationLayoutThatUsesWholeBrosersSpace extends
 
                secondSplitPanel.setSecondComponent(topRight);
 
-
                ExpandLayout el = new ExpandLayout();
                el.addComponent(new Label("B\9a\9a"));
 
index afa51e18a1390d729eea369ee95e40f1d24541b8..1edbc0b83f0f99889c2c0005515419f20aaaa685 100644 (file)
@@ -17,48 +17,50 @@ import com.itmill.toolkit.ui.Button.ClickEvent;
 import com.itmill.toolkit.ui.Button.ClickListener;\r
 \r
 public class TestForBasicApplicationLayout extends CustomComponent {\r
-       \r
+\r
        private Button click;\r
        private Button click2;\r
        private TabSheet tab;\r
-       \r
+\r
        public TestForBasicApplicationLayout() {\r
-               OrderedLayout main = new OrderedLayout();       \r
+               OrderedLayout main = new OrderedLayout();\r
                setCompositionRoot(main);\r
-               \r
+\r
                click = new Button("Set height -1", new ClickListener() {\r
 \r
                        public void buttonClick(ClickEvent event) {\r
                                tab.setHeight(-1);\r
                        }\r
-                       \r
+\r
                });\r
-               \r
+\r
                click2 = new Button("Set height 100%", new ClickListener() {\r
 \r
                        public void buttonClick(ClickEvent event) {\r
                                tab.setHeight(100);\r
                                tab.setHeightUnits(Sizeable.UNITS_PERCENTAGE);\r
                        }\r
-                       \r
+\r
                });\r
-               \r
+\r
                SplitPanel sp = new SplitPanel(SplitPanel.ORIENTATION_HORIZONTAL);\r
-               sp.setSplitPosition(290, Sizeable.UNITS_PIXELS); // Width of left side area\r
-               \r
+               sp.setSplitPosition(290, Sizeable.UNITS_PIXELS); // Width of left\r
+                                                                                                                       // side area\r
+\r
                SplitPanel sp2 = new SplitPanel(SplitPanel.ORIENTATION_VERTICAL);\r
-               sp2.setSplitPosition(255, Sizeable.UNITS_PIXELS); // Height of right-top area\r
-               \r
+               sp2.setSplitPosition(255, Sizeable.UNITS_PIXELS); // Height of\r
+                                                                                                                       // right-top area\r
+\r
                Panel p = new Panel("Accordion Panel");\r
                p.setHeight(100);\r
                p.setHeightUnits(Panel.UNITS_PERCENTAGE);\r
-               \r
+\r
                tab = new TabSheet();\r
                tab.setWidth(100);\r
                tab.setWidthUnits(Sizeable.UNITS_PERCENTAGE);\r
                tab.setHeight(740);\r
                tab.setHeightUnits(Sizeable.UNITS_PIXELS);\r
-               \r
+\r
                Panel report = new Panel("Monthly Program Runs", new ExpandLayout());\r
                OrderedLayout controls = new OrderedLayout();\r
                controls.addComponent(new Label("Report tab"));\r
@@ -67,16 +69,17 @@ public class TestForBasicApplicationLayout extends CustomComponent {
                report.addComponent(controls);\r
                DateField cal = new DateField();\r
                cal.setResolution(DateField.RESOLUTION_DAY);\r
-               cal.setLocale(new Locale("en","US"));\r
+               cal.setLocale(new Locale("en", "US"));\r
                report.addComponent(cal);\r
-               ((ExpandLayout)report.getLayout()).expand(controls);\r
+               ((ExpandLayout) report.getLayout()).expand(controls);\r
                report.setStyle("light");\r
                report.setHeight(100);\r
                report.setHeightUnits(Sizeable.UNITS_PERCENTAGE);\r
-               \r
+\r
                sp2.setFirstComponent(report);\r
-               \r
-               Table table = TestForTablesInitialColumnWidthLogicRendering.getTestTable(5,200);\r
+\r
+               Table table = TestForTablesInitialColumnWidthLogicRendering\r
+                               .getTestTable(5, 200);\r
                table.setPageLength(15);\r
                table.setSelectable(true);\r
                table.setRowHeaderMode(Table.ROW_HEADER_MODE_INDEX);\r
@@ -89,17 +92,17 @@ public class TestForBasicApplicationLayout extends CustomComponent {
                table.setHeightUnits(Sizeable.UNITS_PERCENTAGE);\r
                table.addStyleName("table-inline");\r
                sp2.setSecondComponent(table);\r
-               \r
+\r
                tab.addTab(new Label("Tab1"), "Summary", null);\r
                tab.addTab(sp2, "Reports", null);\r
                tab.addTab(new Label("Tab 3"), "Statistics", null);\r
                tab.addTab(new Label("Tab 4"), "Error Tracking", null);\r
                tab.setSelectedTab(sp2);\r
-               \r
+\r
                sp.setFirstComponent(p);\r
                sp.setSecondComponent(tab);\r
-               \r
+\r
                main.addComponent(sp);\r
        }\r
-       \r
+\r
 }\r
index 3c72608da6ddc2f09a3eef8d8c0e5f712c22f99b..55ffab976fff4ffd4d3bc75fd8c52a7979ec496b 100644 (file)
@@ -14,13 +14,12 @@ import com.itmill.toolkit.ui.Select;
 
 /**
  * 
- * This Component contains some simple test to see that component
- * updates its contents propertly.
+ * This Component contains some simple test to see that component updates its
+ * contents propertly.
  * 
  * @author IT Mill Ltd.
  */
 public class TestForChildComponentRendering extends CustomComponent {
-       
 
        private OrderedLayout main;
 
@@ -30,11 +29,11 @@ public class TestForChildComponentRendering extends CustomComponent {
                setCompositionRoot(main);
                createNewView();
        }
-       
+
        public void createNewView() {
                main.removeAllComponents();
                main.addComponent(new Label("SDFGFHFHGJGFDSDSSSGFDD"));
-               
+
                Link l = new Link();
                l.setCaption("Siirry ITMILLIIN");
                l.setResource(new ExternalResource("http://www.itmill.com/"));
@@ -42,51 +41,49 @@ public class TestForChildComponentRendering extends CustomComponent {
                l.setTargetWidth(500);
                l.setTargetBorder(Link.TARGET_BORDER_MINIMAL);
                main.addComponent(l);
-               
+
                Select se = new Select();
                se.setCaption("VALITSET TÄSTÄ");
                se.addItem("valinta1");
                se.addItem("Valinta 2");
-               
+
                Button b = new Button("refresh view", this, "createNewView");
                main.addComponent(b);
 
                b = new Button("reorder view", this, "randomReorder");
                main.addComponent(b);
 
-               b = new Button("remove randomly one component", this, "removeRandomComponent");
+               b = new Button("remove randomly one component", this,
+                               "removeRandomComponent");
                main.addComponent(b);
 
        }
-       
+
        public void randomReorder() {
                Iterator it = main.getComponentIterator();
                ArrayList components = new ArrayList();
-               while(it.hasNext())
+               while (it.hasNext())
                        components.add(it.next());
-                       
+
                OrderedLayout v = main;
                v.removeAllComponents();
-               
-               for(int i = components.size(); i > 0; i--) {
-                       int index = (int) (Math.random()*i);
+
+               for (int i = components.size(); i > 0; i--) {
+                       int index = (int) (Math.random() * i);
                        v.addComponent((Component) components.get(index));
                        components.remove(index);
                }
        }
-       
+
        public void removeRandomComponent() {
                Iterator it = main.getComponentIterator();
                ArrayList components = new ArrayList();
-               while(it.hasNext())
+               while (it.hasNext())
                        components.add(it.next());
                int size = components.size();
-               int index = (int) (Math.random()*size);
+               int index = (int) (Math.random() * size);
                main.removeComponent((Component) components.get(index));
-               
-       }
 
+       }
 
 }
-
-
index 23f9f47b3266f483d42bfbfd445c2afa927771d5..853f68e09be45b9935f82b1d61aa3c5aa30a25ad 100644 (file)
@@ -15,26 +15,25 @@ import com.itmill.toolkit.ui.Select;
 
 /**
  * 
- * This Component contains some simple test to see that component
- * updates its contents propertly.
+ * This Component contains some simple test to see that component updates its
+ * contents propertly.
  * 
  * @author IT Mill Ltd.
  */
 public class TestForGridLayoutChildComponentRendering extends CustomComponent {
-       
 
-       private GridLayout main = new GridLayout(2,3);
+       private GridLayout main = new GridLayout(2, 3);
 
        public TestForGridLayoutChildComponentRendering() {
 
                setCompositionRoot(main);
                createNewView();
        }
-       
+
        public void createNewView() {
                main.removeAllComponents();
                main.addComponent(new Label("SDFGFHFHGJGFDSDSSSGFDD"));
-               
+
                Link l = new Link();
                l.setCaption("Siirry ITMILLIIN");
                l.setResource(new ExternalResource("http://www.itmill.com/"));
@@ -42,60 +41,57 @@ public class TestForGridLayoutChildComponentRendering extends CustomComponent {
                l.setTargetWidth(500);
                l.setTargetBorder(Link.TARGET_BORDER_MINIMAL);
                main.addComponent(l);
-               
-               
+
                Select se = new Select("Tästä valitaan");
                se.setCaption("Whattaa select");
                se.addItem("valinta1");
                se.addItem("Valinta 2");
-               
+
                main.addComponent(se, 0, 1, 1, 1);
-               
-               
+
                Button b = new Button("refresh view", this, "createNewView");
                main.addComponent(b);
 
                b = new Button("reorder view", this, "randomReorder");
                main.addComponent(b);
 
-               b = new Button("remove randomly one component", this, "removeRandomComponent");
+               b = new Button("remove randomly one component", this,
+                               "removeRandomComponent");
                main.addComponent(b);
 
        }
-       
+
        public void randomReorder() {
                Iterator it = main.getComponentIterator();
                ArrayList components = new ArrayList();
-               while(it.hasNext())
+               while (it.hasNext())
                        components.add(it.next());
-                       
+
                main.removeAllComponents();
-               
+
                int size = components.size();
-               int colspanIndex = ((int) (Math.random()*size)/2)*2 + 2;
+               int colspanIndex = ((int) (Math.random() * size) / 2) * 2 + 2;
 
-               for(int i = components.size(); i > 0; i--) {
-                       int index = (int) (Math.random()*i);
-                       if(i == colspanIndex)
-                               main.addComponent((Component) components.get(index), 0, (size - i )/2, 1, (size - i)/2);
+               for (int i = components.size(); i > 0; i--) {
+                       int index = (int) (Math.random() * i);
+                       if (i == colspanIndex)
+                               main.addComponent((Component) components.get(index), 0,
+                                               (size - i) / 2, 1, (size - i) / 2);
                        else
                                main.addComponent((Component) components.get(index));
                        components.remove(index);
                }
        }
-       
+
        public void removeRandomComponent() {
                Iterator it = main.getComponentIterator();
                ArrayList components = new ArrayList();
-               while(it.hasNext())
+               while (it.hasNext())
                        components.add(it.next());
                int size = components.size();
-               int index = (int) (Math.random()*size);
+               int index = (int) (Math.random() * size);
                main.removeComponent((Component) components.get(index));
-               
-       }
 
+       }
 
 }
-
-
index 1fafe4c26e927b77813e18dd856cc35a82c34065..1d33986bf6c1726199ac074b4b136a62ac37d3cf 100644 (file)
@@ -10,13 +10,13 @@ import com.itmill.toolkit.ui.Table;
 
 /**
  * 
- * This Component contains some simple test to see that component
- * updates its contents propertly.
+ * This Component contains some simple test to see that component updates its
+ * contents propertly.
  * 
  * @author IT Mill Ltd.
  */
-public class TestForTablesInitialColumnWidthLogicRendering extends CustomComponent {
-       
+public class TestForTablesInitialColumnWidthLogicRendering extends
+               CustomComponent {
 
        private OrderedLayout main = new OrderedLayout();
 
@@ -25,36 +25,36 @@ public class TestForTablesInitialColumnWidthLogicRendering extends CustomCompone
                setCompositionRoot(main);
                createNewView();
        }
-       
+
        public void createNewView() {
                main.removeAllComponents();
-               main.addComponent(new Label("Below are same tables that all should render somewhat nice. Also when testing, you might want to try resizing window."));
-               
+               main
+                               .addComponent(new Label(
+                                               "Below are same tables that all should render somewhat nice. Also when testing, you might want to try resizing window."));
+
                Table t;
-               
-//             t = new Table("Empty table");
-//             main.addComponent(t);
-               
-               
+
+               // t = new Table("Empty table");
+               // main.addComponent(t);
+
                t = getTestTable(5, 0);
                t.setCaption("Table with only headers");
-//             main.addComponent(t);
+               // main.addComponent(t);
 
                t = getTestTable(5, 200);
                t.setCaption("Table with  some cols and lot of rows");
                main.addComponent(t);
 
-               
                t = getTestTable(12, 4);
                t.setCaption("Table with  some rows and lot of columns");
                main.addComponent(t);
-               
+
                t = getTestTable(3, 40);
-               t.setCaption("Table with some columns and wide explicit width. (Ought to widen columns to use all space)");
+               t
+                               .setCaption("Table with some columns and wide explicit width. (Ought to widen columns to use all space)");
                t.setWidth(1000);
                main.addComponent(t);
 
-
                t = getTestTable(12, 4);
                t.setCaption("Table with  some rows and lot of columns, width == 100%");
                t.setWidth(100);
@@ -62,69 +62,51 @@ public class TestForTablesInitialColumnWidthLogicRendering extends CustomCompone
                main.addComponent(t);
 
                t = getTestTable(12, 100);
-               t.setCaption("Table with  lot of rows and lot of columns, width == 50%");
+               t
+                               .setCaption("Table with  lot of rows and lot of columns, width == 50%");
                t.setWidth(50);
                t.setWidthUnits(Table.UNITS_PERCENTAGE);
                main.addComponent(t);
 
-               
                t = getTestTable(5, 100);
                t.setCaption("Table with 40 rows");
-//             main.addComponent(t);
-               
+               // main.addComponent(t);
+
                t = getTestTable(4, 4);
                t.setCaption("Table with some rows and width = 200px");
 
                t.setWidth(200);
                main.addComponent(t);
-               
+
                Button b = new Button("refresh view", this, "createNewView");
                main.addComponent(b);
 
        }
-       
+
        public static Table getTestTable(int cols, int rows) {
                Table t = new Table();
                t.setColumnCollapsingAllowed(true);
-               for(int i = 0; i < cols; i++) {
+               for (int i = 0; i < cols; i++) {
                        t.addContainerProperty(testString[i], String.class, "");
                }
-               for(int i = 0; i < rows; i++) {
+               for (int i = 0; i < rows; i++) {
                        Vector content = new Vector();
-                       for(int j = 0; j < cols;j++) {
+                       for (int j = 0; j < cols; j++) {
                                content.add(rndString());
                        }
-                       t.addItem(content.toArray(), ""+i);
+                       t.addItem(content.toArray(), "" + i);
                }
                return t;
        }
-       
-       static String[] testString = new String[] {
-               "DSFdsfs",
-               "böö",
-               "1",
-               "sdf sdfsd fsdfsdf sdf",
-               "SDF SADds FASDF dsaf",
-               "foo",
-               "VADSFA",
-               "DSFSD FS",
-               "whattaa",
-               " sdf sdfsd ",
-               "DSf sdf sdf",
-               "foods f",
-               "VADsd fSFA",
-               "DSFsd fSD FS",
-               "wha sdf ttaa",
-               " sd sdff sdfsd ",
-               "DSf sdf sdf",
-               "SDFsd sd fadsfadfs"
-       };
-       
-       
+
+       static String[] testString = new String[] { "DSFdsfs", "böö", "1",
+                       "sdf sdfsd fsdfsdf sdf", "SDF SADds FASDF dsaf", "foo", "VADSFA",
+                       "DSFSD FS", "whattaa", " sdf sdfsd ", "DSf sdf sdf", "foods f",
+                       "VADsd fSFA", "DSFsd fSD FS", "wha sdf ttaa", " sd sdff sdfsd ",
+                       "DSf sdf sdf", "SDFsd sd fadsfadfs" };
+
        public static String rndString() {
-               return testString[(int) (Math.random()*testString.length)];
+               return testString[(int) (Math.random() * testString.length)];
        }
-       
-}
-
 
+}
index 907902ba9d35f0119db76433683c444707da6ee3..5e9bb4db5493c2dae49291131c6ac2ed524e6f43 100644 (file)
@@ -30,11 +30,9 @@ public class TestForTrees extends CustomComponent implements Handler {
                        "Einstein" };
 
        private OrderedLayout main = new OrderedLayout();
-       
-       private Action[] actions = new Action[] {
-                       new Action("edit"),
-                       new Action("delete")
-       };
+
+       private Action[] actions = new Action[] { new Action("edit"),
+                       new Action("delete") };
 
        private Panel al;
 
@@ -51,7 +49,7 @@ public class TestForTrees extends CustomComponent implements Handler {
                main
                                .addComponent(new Label(
                                                "Some test cases for trees. Events panel logs events that happen server side."));
-               
+
                main.addComponent(new Button("commit"));
 
                Tree t;
@@ -71,13 +69,11 @@ public class TestForTrees extends CustomComponent implements Handler {
                t.setMultiSelect(true);
                main.addComponent(createTestBench(t));
 
-               
                t = createTestTree();
                t.setCaption("immediate");
                t.setImmediate(true);
                main.addComponent(createTestBench(t));
 
-               
                t = createTestTree();
                t.setCaption("with actions");
                t.setImmediate(true);
@@ -156,10 +152,10 @@ public class TestForTrees extends CustomComponent implements Handler {
        }
 
        public void handleAction(Action action, Object sender, Object target) {
-               if(action == actions[1]) {
+               if (action == actions[1]) {
                        al.addComponent(new Label("Delete selected on " + target));
                        contextTree.removeItem(target);
-                       
+
                } else {
                        al.addComponent(new Label("Edit selected on " + target));
                }
index 88367ff2db36de43250e0584f2dc993ed62f91ea..b3e818ea2218a24b06e650e79a2abed6728e252f 100644 (file)
@@ -36,7 +36,8 @@ import com.itmill.toolkit.ui.Upload.SucceededEvent;
 import com.itmill.toolkit.ui.Upload.SucceededListener;
 
 public class TestForUpload extends CustomComponent implements
-               Upload.FinishedListener, FailedListener,SucceededListener, Upload.ProgressListener, StartedListener {
+               Upload.FinishedListener, FailedListener, SucceededListener,
+               Upload.ProgressListener, StartedListener {
 
        Layout main = new OrderedLayout();
 
@@ -47,7 +48,7 @@ public class TestForUpload extends CustomComponent implements
        private Upload up;
 
        private Label l;
-       
+
        private ProgressIndicator pi = new ProgressIndicator();
 
        private Label memoryStatus;
@@ -56,25 +57,27 @@ public class TestForUpload extends CustomComponent implements
 
        public TestForUpload() {
                setCompositionRoot(main);
-               main.addComponent( new Label(
-                                               "This is a simple test for upload application. "
-                                                               + "Upload should work with big files and concurrent "
-                                                               + "requests should not be blocked. Button 'b' reads "
-                                                               + "current state into label below it. Memory receiver "
-                                                               + "streams upload contents into memory. You may track"
-                                                               + "consumption."
-                                                               + "tempfile receiver writes upload to file and "
-                                                               + "should have low memory consumption."));
-               
-               main.addComponent(new Label("Clicking on button b updates information about upload components status or same with garbage collector."));
+               main.addComponent(new Label(
+                               "This is a simple test for upload application. "
+                                               + "Upload should work with big files and concurrent "
+                                               + "requests should not be blocked. Button 'b' reads "
+                                               + "current state into label below it. Memory receiver "
+                                               + "streams upload contents into memory. You may track"
+                                               + "consumption."
+                                               + "tempfile receiver writes upload to file and "
+                                               + "should have low memory consumption."));
+
+               main
+                               .addComponent(new Label(
+                                               "Clicking on button b updates information about upload components status or same with garbage collector."));
 
                up = new Upload("Upload", buffer);
                up.setImmediate(true);
-               up.addListener((FinishedListener)this);
+               up.addListener((FinishedListener) this);
                up.addListener((FailedListener) this);
                up.addListener((SucceededListener) this);
                up.addListener((StartedListener) this);
-       
+
                up.setProgressListener(this);
 
                Button b = new Button("b", this, "readState");
@@ -89,28 +92,28 @@ public class TestForUpload extends CustomComponent implements
                uploadBufferSelector.addItem("memory");
                uploadBufferSelector.setValue("memory");
                uploadBufferSelector.addItem("tempfile");
-               uploadBufferSelector.addListener(new AbstractField.ValueChangeListener() {
-                       public void valueChange(ValueChangeEvent event) {
-                               setBuffer();
-                       }
-               });
+               uploadBufferSelector
+                               .addListener(new AbstractField.ValueChangeListener() {
+                                       public void valueChange(ValueChangeEvent event) {
+                                               setBuffer();
+                                       }
+                               });
                main.addComponent(uploadBufferSelector);
 
                main.addComponent(up);
                l = new Label("Idle");
                main.addComponent(l);
-               
+
                pi.setVisible(false);
                pi.setPollingInterval(1000);
                main.addComponent(pi);
-               
+
                memoryStatus = new Label();
                main.addComponent(memoryStatus);
 
                status.setVisible(false);
                main.addComponent(status);
 
-
                Button restart = new Button("R");
                restart.addListener(new Button.ClickListener() {
 
@@ -119,21 +122,19 @@ public class TestForUpload extends CustomComponent implements
                        }
                });
                main.addComponent(restart);
-               
 
        }
-       
+
        private void setBuffer() {
                String id = (String) uploadBufferSelector.getValue();
-               if("memory".equals(id)) {
+               if ("memory".equals(id)) {
                        buffer = new MemooryBuffer();
-               } else if("tempfile".equals(id)) {
+               } else if ("tempfile".equals(id)) {
                        buffer = new TmpFileBuffer();
                }
                up.setReceiver(buffer);
        }
 
-       
        public void gc() {
                Runtime.getRuntime().gc();
                readState();
@@ -180,8 +181,9 @@ public class TestForUpload extends CustomComponent implements
                        status.setVisible(true);
                }
        }
-       
-       public interface Buffer extends StreamResource.StreamSource, Upload.Receiver {
+
+       public interface Buffer extends StreamResource.StreamSource,
+                       Upload.Receiver {
 
                String getFileName();
        }
@@ -233,7 +235,7 @@ public class TestForUpload extends CustomComponent implements
                }
 
        }
-       
+
        public class TmpFileBuffer implements Buffer {
                String mimeType;
 
@@ -244,9 +246,10 @@ public class TestForUpload extends CustomComponent implements
                private FileInputStream stream;
 
                public TmpFileBuffer() {
-                       String tempFileName = "upload_tmpfile_" + System.currentTimeMillis();
+                       String tempFileName = "upload_tmpfile_"
+                                       + System.currentTimeMillis();
                        try {
-                               file = File.createTempFile(tempFileName,null);
+                               file = File.createTempFile(tempFileName, null);
                        } catch (IOException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
@@ -304,9 +307,9 @@ public class TestForUpload extends CustomComponent implements
 
        public void uploadFailed(FailedEvent event) {
                System.out.println(event);
-               
+
                System.out.println(event.getSource());
-               
+
        }
 
        public void uploadSucceeded(SucceededEvent event) {
@@ -315,10 +318,10 @@ public class TestForUpload extends CustomComponent implements
                System.out.println(event);
                setBuffer();
        }
-       
+
        public void updateProgress(long readBytes, long contentLenght) {
-               pi.setValue(new Float(readBytes/(float)contentLenght));
-               
+               pi.setValue(new Float(readBytes / (float) contentLenght));
+
                refreshMemUsage();
        }
 
@@ -326,9 +329,9 @@ public class TestForUpload extends CustomComponent implements
                StringBuffer mem = new StringBuffer();
                MemoryMXBean mmBean = ManagementFactory.getMemoryMXBean();
                mem.append("Heap (M):");
-               mem.append(mmBean.getHeapMemoryUsage().getUsed()/1048576);
+               mem.append(mmBean.getHeapMemoryUsage().getUsed() / 1048576);
                mem.append(" |ÊNon-Heap (M):");
-               mem.append(mmBean.getNonHeapMemoryUsage().getUsed()/1048576);
+               mem.append(mmBean.getNonHeapMemoryUsage().getUsed() / 1048576);
                memoryStatus.setValue(mem.toString());
        }
 
index 7f7f4de8dd7fe5036a05f4e78ced5826353190d1..0712b4e1db54f9c95992b0bcac7a2574c75ba130 100644 (file)
@@ -12,94 +12,112 @@ import com.itmill.toolkit.ui.Button.ClickEvent;
 public class TestForWindowing extends Application {
 
        Window main = new Window("Windowing test");
-       
+
        public void init() {
 
                setMainWindow(main);
-               
-               main.addComponent(new Button("Add new subwindow", new Button.ClickListener() {
-                       public void buttonClick(ClickEvent event) {
-                               final Window w = new Window("sw " + System.currentTimeMillis());
-                               main.addWindow(w);
-                               w.setPositionX(100);
-                               w.setPositionY(100);
-                               w.setWidth(200);
-                               w.setHeight(200);
-                               
-                               w.setWidth(100);
-                               w.setHeight(400);
-                               
-                               
-                               Button closebutton = new Button("Close " + w.getCaption(), new Button.ClickListener() {
+
+               main.addComponent(new Button("Add new subwindow",
+                               new Button.ClickListener() {
                                        public void buttonClick(ClickEvent event) {
-                                               main.removeWindow(w);
+                                               final Window w = new Window("sw "
+                                                               + System.currentTimeMillis());
+                                               main.addWindow(w);
+                                               w.setPositionX(100);
+                                               w.setPositionY(100);
+                                               w.setWidth(200);
+                                               w.setHeight(200);
+
+                                               w.setWidth(100);
+                                               w.setHeight(400);
+
+                                               Button closebutton = new Button("Close "
+                                                               + w.getCaption(), new Button.ClickListener() {
+                                                       public void buttonClick(ClickEvent event) {
+                                                               main.removeWindow(w);
+                                                       }
+
+                                               });
+                                               w.addComponent(closebutton);
+
+                                               w.addComponent(new Label(
+                                                               "<p>Lorem ipsum dolor sit amet.</p>"
+                                                                               + "<p>Lorem ipsum dolor sit amet.</p>"
+                                                                               + "<p>Lorem ipsum dolor sit amet.</p>"
+                                                                               + "<p>Lorem ipsum dolor sit amet.</p>"
+                                                                               + "<p>Lorem ipsum dolor sit amet.</p>"
+                                                                               + "<p>Lorem ipsum dolor sit amet.</p>"
+                                                                               + "<p>Lorem ipsum dolor sit amet.</p>"
+                                                                               + "<p>Lorem ipsum dolor sit amet.</p>"
+                                                                               + "<p>Lorem ipsum dolor sit amet.</p>"
+                                                                               + "<p>Lorem ipsum dolor sit amet.</p>"
+                                                                               + "<p>Lorem ipsum dolor sit amet.</p>"
+                                                                               + "<p>Lorem ipsum dolor sit amet.</p>"
+                                                                               + "<p>Lorem ipsum dolor sit amet.</p>"
+                                                                               + "<p>Lorem ipsum dolor sit amet.</p>"
+                                                                               + "<p>Lorem ipsum dolor sit amet.</p>"
+                                                                               + "<p>Lorem ipsum dolor sit amet.</p>"
+                                                                               + "<p>Lorem ipsum dolor sit amet.</p>"
+                                                                               + "<p>Lorem ipsum dolor sit amet.</p>"
+                                                                               + "<p>Lorem ipsum dolor sit amet.</p>"
+                                                                               + "<p>Lorem ipsum dolor sit amet.</p>"
+                                                                               + "<p>Lorem ipsum dolor sit amet.</p>"
+                                                                               + "<p>Lorem ipsum dolor sit amet.</p>",
+                                                               Label.CONTENT_XHTML));
+
                                        }
-                               
-                               });
-                               w.addComponent(closebutton);
-                               
-                               w.addComponent(new Label("<p>Lorem ipsum dolor sit amet.</p>" +
-                                               "<p>Lorem ipsum dolor sit amet.</p>" +
-                                               "<p>Lorem ipsum dolor sit amet.</p>" +
-                                               "<p>Lorem ipsum dolor sit amet.</p>" +
-                                               "<p>Lorem ipsum dolor sit amet.</p>" +
-                                               "<p>Lorem ipsum dolor sit amet.</p>" +
-                                               "<p>Lorem ipsum dolor sit amet.</p>" +
-                                               "<p>Lorem ipsum dolor sit amet.</p>" +
-                                               "<p>Lorem ipsum dolor sit amet.</p>" +
-                                               "<p>Lorem ipsum dolor sit amet.</p>" +
-                                               "<p>Lorem ipsum dolor sit amet.</p>" +
-                                               "<p>Lorem ipsum dolor sit amet.</p>" +
-                                               "<p>Lorem ipsum dolor sit amet.</p>" +
-                                               "<p>Lorem ipsum dolor sit amet.</p>" +
-                                               "<p>Lorem ipsum dolor sit amet.</p>" +
-                                               "<p>Lorem ipsum dolor sit amet.</p>" +
-                                               "<p>Lorem ipsum dolor sit amet.</p>" +
-                                               "<p>Lorem ipsum dolor sit amet.</p>" +
-                                               "<p>Lorem ipsum dolor sit amet.</p>" +
-                                               "<p>Lorem ipsum dolor sit amet.</p>" +
-                                               "<p>Lorem ipsum dolor sit amet.</p>" +
-                                               "<p>Lorem ipsum dolor sit amet.</p>", 
-                                               Label.CONTENT_XHTML));
-
-                       }
-               }));
-               
-               main.addComponent( new Button("Open a currently uncreated application level window", new Button.ClickListener() {
-                       public void buttonClick(ClickEvent event) {
-                               try {
-                                       main.open(
-                                                       new com.itmill.toolkit.terminal.ExternalResource(new URL(getURL(),"mainwin-" + System.currentTimeMillis() + "/")), 
-                                                       null);
-                               } catch (MalformedURLException e) {
-                               }
-                       }
-               }));
-       
-               main.addComponent(new Button("Commit (saves window state: size, place, scrollpos)"));
+                               }));
+
+               main.addComponent(new Button(
+                               "Open a currently uncreated application level window",
+                               new Button.ClickListener() {
+                                       public void buttonClick(ClickEvent event) {
+                                               try {
+                                                       main
+                                                                       .open(
+                                                                                       new com.itmill.toolkit.terminal.ExternalResource(
+                                                                                                       new URL(
+                                                                                                                       getURL(),
+                                                                                                                       "mainwin-"
+                                                                                                                                       + System
+                                                                                                                                                       .currentTimeMillis()
+                                                                                                                                       + "/")),
+                                                                                       null);
+                                               } catch (MalformedURLException e) {
+                                               }
+                                       }
+                               }));
+
+               main.addComponent(new Button(
+                               "Commit (saves window state: size, place, scrollpos)"));
        }
 
        public Window getWindow(String name) {
-               
+
                Window w = super.getWindow(name);
-               if (w != null) return w;
+               if (w != null)
+                       return w;
 
                if (name != null && name.startsWith("mainwin-")) {
                        String postfix = name.substring("mainwin-".length());
-                       final Window ww=new Window("Window: " + postfix);
+                       final Window ww = new Window("Window: " + postfix);
                        ww.setName(name);
-                       ww.addComponent(new Label("This is a application-level window opened with name: " + name));
+                       ww.addComponent(new Label(
+                                       "This is a application-level window opened with name: "
+                                                       + name));
                        ww.addComponent(new Button("Click me", new Button.ClickListener() {
                                int state = 0;
+
                                public void buttonClick(ClickEvent event) {
-                                       ww.addComponent(new Label("Button clicked " + (++state) + " times"));
+                                       ww.addComponent(new Label("Button clicked " + (++state)
+                                                       + " times"));
                                }
                        }));
                        addWindow(ww);
                        return ww;
                }
-               
+
                return null;
        }
-       
+
 }
index 18ce5b59a5711ead51ee37150e2b61f83eacce44..13d40bc23d35261b18066f5449f2094346950b93 100644 (file)
@@ -57,7 +57,7 @@ import java.lang.reflect.Method;
 public abstract class AbstractComponent implements Component, MethodEventSource {
 
        /* Private members ************************************************* */
-       
+
        /**
         * Style names.
         */
@@ -162,10 +162,10 @@ public abstract class AbstractComponent implements Component, MethodEventSource
         */
        public String getStyle() {
                String s = "";
-               if(styles != null) {
-                       for(Iterator it = styles.iterator();it.hasNext();) {
+               if (styles != null) {
+                       for (Iterator it = styles.iterator(); it.hasNext();) {
                                s += (String) it.next();
-                               if(it.hasNext())
+                               if (it.hasNext())
                                        s += " ";
                        }
                }
@@ -177,36 +177,36 @@ public abstract class AbstractComponent implements Component, MethodEventSource
         * default documentation from implemented interface.
         */
        public void setStyle(String style) {
-               if(style == null || "".equals(style)) {
+               if (style == null || "".equals(style)) {
                        styles = null;
                        requestRepaint();
                        return;
                }
-               if(this.styles == null) {
+               if (this.styles == null) {
                        styles = new ArrayList();
                }
                styles.clear();
                styles.add(style);
                requestRepaint();
        }
-       
+
        public void addStyleName(String style) {
-               if(style == null || "".equals(style))
+               if (style == null || "".equals(style))
                        return;
-               if(this.styles == null) {
+               if (this.styles == null) {
                        styles = new ArrayList();
                }
-               if(! styles.contains(style)) {
+               if (!styles.contains(style)) {
                        this.styles.add(style);
                        requestRepaint();
                }
        }
-       
+
        public void removeStyleName(String style) {
                styles.remove(style);
                requestRepaint();
        }
-       
+
        /*
         * Get's the component's caption. Don't add a JavaDoc comment here, we use
         * the default documentation from implemented interface.
@@ -552,10 +552,11 @@ public abstract class AbstractComponent implements Component, MethodEventSource
         */
        public final void paint(PaintTarget target) throws PaintException {
 
-               if (!target.startTag(this, this.getTag()) || repaintRequestListenersNotified) {
-                       
+               if (!target.startTag(this, this.getTag())
+                               || repaintRequestListenersNotified) {
+
                        // Paint the contents of the component
-                       
+
                        if (styles != null && styles.size() > 0)
                                target.addAttribute("style", getStyle());
                        if (isReadOnly())
@@ -585,7 +586,7 @@ public abstract class AbstractComponent implements Component, MethodEventSource
                                        error.paint(target);
                        }
                } else {
-                       
+
                        // Contents have not changed, only cached presentation can be used
                        target.addAttribute("cached", true);
                }
index 1719d6aac9616ecab505e77fb5bb7a0a84c0f7c3..5d50f1eaf13069a64b0b383080489ae4dd0e52e8 100644 (file)
@@ -200,7 +200,7 @@ public abstract class AbstractComponentContainer extends AbstractComponent
         * @see com.itmill.toolkit.ui.ComponentContainer#removeComponent(Component)
         */
        public void removeComponent(Component c) {
-               if(c.getParent() == this) {
+               if (c.getParent() == this) {
                        c.setParent(null);
                        fireComponentDetachEvent(c);
                }
index 1cf7b69ac48a0ba37522aa5fd20ea3560c762ac5..877920273d8438deac4badaa1a798940b675bee7 100644 (file)
@@ -405,18 +405,19 @@ public abstract class AbstractField extends AbstractComponent implements Field,
                        Property.ConversionException {
                setValue(newValue, false);
        }
-               
+
        /**
         * Sets the value of the field.
         * 
         * @param newValue
         *            the New value of the field.
-        * @param repaintIsNotNeeded True iff caller is sure that repaint is not needed. 
+        * @param repaintIsNotNeeded
+        *            True iff caller is sure that repaint is not needed.
         * @throws Property.ReadOnlyException
         * @throws Property.ConversionException
         */
-       protected void setValue(Object newValue, boolean repaintIsNotNeeded) throws Property.ReadOnlyException,
-               Property.ConversionException {
+       protected void setValue(Object newValue, boolean repaintIsNotNeeded)
+                       throws Property.ReadOnlyException, Property.ConversionException {
 
                if ((newValue == null && value != null)
                                || (newValue != null && !newValue.equals(value))) {
index 8968c229f2021bcf691e06fc127c2c54613dbb48..4ac7365daca6657c4cc398113bc2a238c0cadb29 100644 (file)
@@ -58,7 +58,6 @@ public class Button extends AbstractField {
 
        boolean switchMode = false;
 
-
        /**
         * Creates a new push button. The value of the push button is allways false
         * and they are immediate by default.
index 83ae89c9f69fb2376470bee9b1e6a30cb69a032c..34800f49c4fa191a3f80d7fe3bdcda0f442c32ee 100644 (file)
@@ -16,286 +16,288 @@ import com.itmill.toolkit.terminal.PaintTarget;
 // TODO Allow item selection\r
 public class CalendarField extends DateField implements Container.Viewer {\r
 \r
-    private Date minDate;\r
-    private Date maxDate;\r
-\r
-    private Container dataSource;\r
-    private Object itemStartPropertyId;\r
-    private Object itemEndPropertyId;\r
-    private Object itemTitlePropertyId;\r
-    private Object itemDescriptionPropertyId;\r
-    private Object itemNotimePropertyId;\r
-\r
-    public CalendarField() {\r
-       super();\r
-       init();\r
-    }\r
-\r
-    public CalendarField(Property dataSource) throws IllegalArgumentException {\r
-       super(dataSource);\r
-       init();\r
-    }\r
-\r
-    public CalendarField(String caption, Date value) {\r
-       super(caption, value);\r
-       init();\r
-    }\r
-\r
-    public CalendarField(String caption, Property dataSource) {\r
-       super(caption, dataSource);\r
-       init();\r
-    }\r
-\r
-    public CalendarField(String caption) {\r
-       super(caption);\r
-       init();\r
-    }\r
-\r
-    /*\r
-     * Gets the components UIDL tag string. Don't add a JavaDoc comment here, we\r
-     * use the default documentation from implemented interface.\r
-     */\r
-    public String getTag() {\r
-       return "calendarfield";\r
-    }\r
-\r
-    public void init() {\r
-       super.setResolution(RESOLUTION_HOUR);\r
-\r
-    }\r
-\r
-    /**\r
-     * Sets the resolution of the CalendarField. Only RESOLUTION_DAY and\r
-     * RESOLUTION_HOUR are supported.\r
-     * \r
-     * @param resolution\r
-     *                the resolution to set.\r
-     * @see com.itmill.toolkit.ui.DateField#setResolution(int)\r
-     */\r
-    public void setResolution(int resolution) {\r
-       if (resolution != RESOLUTION_DAY && resolution != RESOLUTION_HOUR) {\r
-           throw new IllegalArgumentException();\r
+       private Date minDate;\r
+       private Date maxDate;\r
+\r
+       private Container dataSource;\r
+       private Object itemStartPropertyId;\r
+       private Object itemEndPropertyId;\r
+       private Object itemTitlePropertyId;\r
+       private Object itemDescriptionPropertyId;\r
+       private Object itemNotimePropertyId;\r
+\r
+       public CalendarField() {\r
+               super();\r
+               init();\r
        }\r
-       super.setResolution(resolution);\r
-    }\r
-\r
-    public void setMinimumDate(Date date) {\r
-       this.minDate = date;\r
-       requestRepaint();\r
-    }\r
-\r
-    public Date getMinimumDate() {\r
-       return minDate;\r
-    }\r
-\r
-    public void setMaximumDate(Date date) {\r
-       this.maxDate = date;\r
-       requestRepaint();\r
-    }\r
-\r
-    public Date getMaximumDate() {\r
-       return maxDate;\r
-    }\r
-\r
-    public Container getContainerDataSource() {\r
-       return this.dataSource;\r
-    }\r
-\r
-    public void setContainerDataSource(Container newDataSource) {\r
-       if (newDataSource==null||checkDataSource(newDataSource)) {\r
-           this.dataSource = newDataSource;\r
-       } else {\r
-           // TODO error message\r
-           throw new IllegalArgumentException();\r
+\r
+       public CalendarField(Property dataSource) throws IllegalArgumentException {\r
+               super(dataSource);\r
+               init();\r
        }\r
-       requestRepaint();\r
-    }\r
 \r
-    private boolean checkDataSource(Container dataSource) {\r
-       /*\r
-        * if (!(dataSource instanceof Container.Sortable)) { // we really want\r
-        * the data source to be sortable return false; }\r
-        */\r
-       // Check old propertyIds\r
-       if (this.itemEndPropertyId != null) {\r
-           Class c = dataSource.getType(this.itemEndPropertyId);\r
-           if (!Date.class.isAssignableFrom(c)) {\r
-               this.itemEndPropertyId = null;\r
-           }\r
+       public CalendarField(String caption, Date value) {\r
+               super(caption, value);\r
+               init();\r
        }\r
-       if (this.itemNotimePropertyId != null) {\r
-           Class c = dataSource.getType(this.itemNotimePropertyId);\r
-           if (!Boolean.class.isAssignableFrom(c)) {\r
-               this.itemNotimePropertyId = null;\r
-           }\r
+\r
+       public CalendarField(String caption, Property dataSource) {\r
+               super(caption, dataSource);\r
+               init();\r
        }\r
-       if (this.itemStartPropertyId != null) {\r
-           Class c = dataSource.getType(this.itemStartPropertyId);\r
-           if (Date.class.isAssignableFrom(c)) {\r
-               // All we _really_ need is one date\r
-               return true;\r
-           } else {\r
-               this.itemStartPropertyId = null;\r
-           }\r
+\r
+       public CalendarField(String caption) {\r
+               super(caption);\r
+               init();\r
        }\r
-       // We need at least one Date\r
-       Collection ids = dataSource.getContainerPropertyIds();\r
-       for (Iterator it = ids.iterator(); it.hasNext();) {\r
-           Object id = it.next();\r
-           Class c = dataSource.getType(id);\r
-           if (Date.class.isAssignableFrom(c)) {\r
-               this.itemStartPropertyId = id;\r
-               return true;\r
-           }\r
+\r
+       /*\r
+        * Gets the components UIDL tag string. Don't add a JavaDoc comment here, we\r
+        * use the default documentation from implemented interface.\r
+        */\r
+       public String getTag() {\r
+               return "calendarfield";\r
        }\r
 \r
-       return false;\r
-    }\r
+       public void init() {\r
+               super.setResolution(RESOLUTION_HOUR);\r
 \r
-    public Object getItemStartPropertyId() {\r
-       return itemStartPropertyId;\r
-    }\r
+       }\r
 \r
-    public void setItemStartPropertyId(Object propertyId) {\r
-       // TODO nullcheck for property id\r
-       if (this.dataSource != null\r
-               && !Date.class.isAssignableFrom(dataSource.getType(propertyId))) {\r
-           // TODO error message\r
-           throw new IllegalArgumentException();\r
+       /**\r
+        * Sets the resolution of the CalendarField. Only RESOLUTION_DAY and\r
+        * RESOLUTION_HOUR are supported.\r
+        * \r
+        * @param resolution\r
+        *            the resolution to set.\r
+        * @see com.itmill.toolkit.ui.DateField#setResolution(int)\r
+        */\r
+       public void setResolution(int resolution) {\r
+               if (resolution != RESOLUTION_DAY && resolution != RESOLUTION_HOUR) {\r
+                       throw new IllegalArgumentException();\r
+               }\r
+               super.setResolution(resolution);\r
        }\r
-       this.itemStartPropertyId = propertyId;\r
-    }\r
-\r
-    public Object getItemEndPropertyId() {\r
-       return itemEndPropertyId;\r
-    }\r
-\r
-    public void setItemEndPropertyId(Object propertyId) {\r
-       // TODO nullcheck for property id\r
-       if (this.dataSource != null\r
-               && !Date.class.isAssignableFrom(dataSource.getType(propertyId))) {\r
-           // TODO error message\r
-           throw new IllegalArgumentException();\r
+\r
+       public void setMinimumDate(Date date) {\r
+               this.minDate = date;\r
+               requestRepaint();\r
        }\r
-       this.itemEndPropertyId = propertyId;\r
-    }\r
-\r
-    public Object getItemTitlePropertyId() {\r
-       return itemTitlePropertyId;\r
-    }\r
-\r
-    public void setItemTitlePropertyId(Object propertyId) {\r
-       this.itemTitlePropertyId = propertyId;\r
-    }\r
-\r
-    public Object getItemDescriptionPropertyId() {\r
-       return itemDescriptionPropertyId;\r
-    }\r
-\r
-    public void setItemDescriptionPropertyId(Object propertyId) {\r
-       this.itemDescriptionPropertyId = propertyId;\r
-    }\r
-\r
-    public Object getitemNotimePropertyId() {\r
-       return itemNotimePropertyId;\r
-    }\r
-\r
-    public void setItemNotimePropertyId(Object propertyId) {\r
-       // TODO nullcheck for property id\r
-       if (this.dataSource != null\r
-               && !Boolean.class.isAssignableFrom(dataSource.getType(propertyId))) {\r
-           // TODO error message\r
-           throw new IllegalArgumentException();\r
+\r
+       public Date getMinimumDate() {\r
+               return minDate;\r
        }\r
-       this.itemNotimePropertyId = propertyId;\r
-    }\r
-\r
-    /**\r
-     * Paints the content of this component.\r
-     * \r
-     * @param target\r
-     *                the Paint Event.\r
-     * @throws PaintException\r
-     *                 if the paint operation failed.\r
-     */\r
-    public void paintContent(PaintTarget target) throws PaintException {\r
-       super.paintContent(target);\r
-\r
-       if (this.minDate != null) {\r
-           target.addAttribute("min", String.valueOf(this.minDate.getTime()));\r
+\r
+       public void setMaximumDate(Date date) {\r
+               this.maxDate = date;\r
+               requestRepaint();\r
        }\r
-       if (this.maxDate != null) {\r
-           target.addAttribute("max", String.valueOf(this.maxDate.getTime()));\r
+\r
+       public Date getMaximumDate() {\r
+               return maxDate;\r
        }\r
 \r
-       if (this.dataSource != null) {\r
-           target.startTag("items");\r
-\r
-           // send one month now, the rest via lazyloading\r
-           int month = new Date().getMonth();\r
-           Object value = getValue();\r
-           if (value != null && value instanceof Date) {\r
-               month = ((Date) value).getMonth();\r
-           }\r
-\r
-           for (Iterator it = this.dataSource.getItemIds().iterator(); it\r
-                   .hasNext();) {\r
-               Object itemId = it.next();\r
-               Item item = (Item) this.dataSource.getItem(itemId);\r
-               Property p = item.getItemProperty(this.itemStartPropertyId);\r
-               Date start = (Date) p.getValue();\r
-               Date end = start; // assume same day\r
-               if (this.itemEndPropertyId != null) {\r
-                   p = item.getItemProperty(this.itemEndPropertyId);\r
-                   end = (Date) p.getValue();\r
-                   if (end == null) {\r
-                       end = start;\r
-                   } else if (end.before(start)) {\r
-                       Date tmp = start;\r
-                       start = end;\r
-                       end = tmp;\r
-                   }\r
+       public Container getContainerDataSource() {\r
+               return this.dataSource;\r
+       }\r
+\r
+       public void setContainerDataSource(Container newDataSource) {\r
+               if (newDataSource == null || checkDataSource(newDataSource)) {\r
+                       this.dataSource = newDataSource;\r
+               } else {\r
+                       // TODO error message\r
+                       throw new IllegalArgumentException();\r
                }\r
+               requestRepaint();\r
+       }\r
 \r
-               if (start != null) {\r
-                   if ((start.getMonth() <= month || end.getMonth() >= month)) {\r
-                       target.startTag("item");\r
-                       // TODO different id!\r
-                       target.addAttribute("id", itemId.hashCode());\r
-                       target.addAttribute("start", ""+start.getTime());\r
-                       if (end != start) {\r
-                           target.addAttribute("end", ""+end.getTime());\r
+       private boolean checkDataSource(Container dataSource) {\r
+               /*\r
+                * if (!(dataSource instanceof Container.Sortable)) { // we really want\r
+                * the data source to be sortable return false; }\r
+                */\r
+               // Check old propertyIds\r
+               if (this.itemEndPropertyId != null) {\r
+                       Class c = dataSource.getType(this.itemEndPropertyId);\r
+                       if (!Date.class.isAssignableFrom(c)) {\r
+                               this.itemEndPropertyId = null;\r
                        }\r
-                       if (this.itemTitlePropertyId != null) {\r
-                           p = item.getItemProperty(this.itemTitlePropertyId);\r
-                           Object val = p.getValue();\r
-                           if (val != null) {\r
-                               target.addAttribute("title", val.toString());\r
-                           }\r
+               }\r
+               if (this.itemNotimePropertyId != null) {\r
+                       Class c = dataSource.getType(this.itemNotimePropertyId);\r
+                       if (!Boolean.class.isAssignableFrom(c)) {\r
+                               this.itemNotimePropertyId = null;\r
                        }\r
-                       if (this.itemDescriptionPropertyId != null) {\r
-                           p = item.getItemProperty(this.itemDescriptionPropertyId);\r
-                           Object val = p.getValue();\r
-                           if (val != null) {\r
-                               target.addAttribute("description", val.toString());\r
-                           }\r
+               }\r
+               if (this.itemStartPropertyId != null) {\r
+                       Class c = dataSource.getType(this.itemStartPropertyId);\r
+                       if (Date.class.isAssignableFrom(c)) {\r
+                               // All we _really_ need is one date\r
+                               return true;\r
+                       } else {\r
+                               this.itemStartPropertyId = null;\r
                        }\r
-                       if (this.itemNotimePropertyId != null) {\r
-                           p = item\r
-                                   .getItemProperty(this.itemNotimePropertyId);\r
-                           Object val = p.getValue();\r
-                           if (val != null) {\r
-                               target.addAttribute("notime", ((Boolean) val)\r
-                                       .booleanValue());\r
-                           }\r
+               }\r
+               // We need at least one Date\r
+               Collection ids = dataSource.getContainerPropertyIds();\r
+               for (Iterator it = ids.iterator(); it.hasNext();) {\r
+                       Object id = it.next();\r
+                       Class c = dataSource.getType(id);\r
+                       if (Date.class.isAssignableFrom(c)) {\r
+                               this.itemStartPropertyId = id;\r
+                               return true;\r
                        }\r
+               }\r
+\r
+               return false;\r
+       }\r
+\r
+       public Object getItemStartPropertyId() {\r
+               return itemStartPropertyId;\r
+       }\r
+\r
+       public void setItemStartPropertyId(Object propertyId) {\r
+               // TODO nullcheck for property id\r
+               if (this.dataSource != null\r
+                               && !Date.class.isAssignableFrom(dataSource.getType(propertyId))) {\r
+                       // TODO error message\r
+                       throw new IllegalArgumentException();\r
+               }\r
+               this.itemStartPropertyId = propertyId;\r
+       }\r
+\r
+       public Object getItemEndPropertyId() {\r
+               return itemEndPropertyId;\r
+       }\r
 \r
-                       target.endTag("item");\r
-                   }\r
+       public void setItemEndPropertyId(Object propertyId) {\r
+               // TODO nullcheck for property id\r
+               if (this.dataSource != null\r
+                               && !Date.class.isAssignableFrom(dataSource.getType(propertyId))) {\r
+                       // TODO error message\r
+                       throw new IllegalArgumentException();\r
                }\r
-           }\r
+               this.itemEndPropertyId = propertyId;\r
+       }\r
+\r
+       public Object getItemTitlePropertyId() {\r
+               return itemTitlePropertyId;\r
+       }\r
+\r
+       public void setItemTitlePropertyId(Object propertyId) {\r
+               this.itemTitlePropertyId = propertyId;\r
+       }\r
+\r
+       public Object getItemDescriptionPropertyId() {\r
+               return itemDescriptionPropertyId;\r
+       }\r
+\r
+       public void setItemDescriptionPropertyId(Object propertyId) {\r
+               this.itemDescriptionPropertyId = propertyId;\r
+       }\r
+\r
+       public Object getitemNotimePropertyId() {\r
+               return itemNotimePropertyId;\r
+       }\r
 \r
-           target.endTag("items");\r
+       public void setItemNotimePropertyId(Object propertyId) {\r
+               // TODO nullcheck for property id\r
+               if (this.dataSource != null\r
+                               && !Boolean.class.isAssignableFrom(dataSource\r
+                                               .getType(propertyId))) {\r
+                       // TODO error message\r
+                       throw new IllegalArgumentException();\r
+               }\r
+               this.itemNotimePropertyId = propertyId;\r
+       }\r
+\r
+       /**\r
+        * Paints the content of this component.\r
+        * \r
+        * @param target\r
+        *            the Paint Event.\r
+        * @throws PaintException\r
+        *             if the paint operation failed.\r
+        */\r
+       public void paintContent(PaintTarget target) throws PaintException {\r
+               super.paintContent(target);\r
+\r
+               if (this.minDate != null) {\r
+                       target.addAttribute("min", String.valueOf(this.minDate.getTime()));\r
+               }\r
+               if (this.maxDate != null) {\r
+                       target.addAttribute("max", String.valueOf(this.maxDate.getTime()));\r
+               }\r
+\r
+               if (this.dataSource != null) {\r
+                       target.startTag("items");\r
+\r
+                       // send one month now, the rest via lazyloading\r
+                       int month = new Date().getMonth();\r
+                       Object value = getValue();\r
+                       if (value != null && value instanceof Date) {\r
+                               month = ((Date) value).getMonth();\r
+                       }\r
+\r
+                       for (Iterator it = this.dataSource.getItemIds().iterator(); it\r
+                                       .hasNext();) {\r
+                               Object itemId = it.next();\r
+                               Item item = (Item) this.dataSource.getItem(itemId);\r
+                               Property p = item.getItemProperty(this.itemStartPropertyId);\r
+                               Date start = (Date) p.getValue();\r
+                               Date end = start; // assume same day\r
+                               if (this.itemEndPropertyId != null) {\r
+                                       p = item.getItemProperty(this.itemEndPropertyId);\r
+                                       end = (Date) p.getValue();\r
+                                       if (end == null) {\r
+                                               end = start;\r
+                                       } else if (end.before(start)) {\r
+                                               Date tmp = start;\r
+                                               start = end;\r
+                                               end = tmp;\r
+                                       }\r
+                               }\r
+\r
+                               if (start != null) {\r
+                                       if ((start.getMonth() <= month || end.getMonth() >= month)) {\r
+                                               target.startTag("item");\r
+                                               // TODO different id!\r
+                                               target.addAttribute("id", itemId.hashCode());\r
+                                               target.addAttribute("start", "" + start.getTime());\r
+                                               if (end != start) {\r
+                                                       target.addAttribute("end", "" + end.getTime());\r
+                                               }\r
+                                               if (this.itemTitlePropertyId != null) {\r
+                                                       p = item.getItemProperty(this.itemTitlePropertyId);\r
+                                                       Object val = p.getValue();\r
+                                                       if (val != null) {\r
+                                                               target.addAttribute("title", val.toString());\r
+                                                       }\r
+                                               }\r
+                                               if (this.itemDescriptionPropertyId != null) {\r
+                                                       p = item\r
+                                                                       .getItemProperty(this.itemDescriptionPropertyId);\r
+                                                       Object val = p.getValue();\r
+                                                       if (val != null) {\r
+                                                               target.addAttribute("description", val\r
+                                                                               .toString());\r
+                                                       }\r
+                                               }\r
+                                               if (this.itemNotimePropertyId != null) {\r
+                                                       p = item.getItemProperty(this.itemNotimePropertyId);\r
+                                                       Object val = p.getValue();\r
+                                                       if (val != null) {\r
+                                                               target.addAttribute("notime", ((Boolean) val)\r
+                                                                               .booleanValue());\r
+                                                       }\r
+                                               }\r
+\r
+                                               target.endTag("item");\r
+                                       }\r
+                               }\r
+                       }\r
+\r
+                       target.endTag("items");\r
+               }\r
        }\r
-    }\r
 }\r
index 234b8d983659b18878e5b44a1ca6363ee52cb968..7af0485e0e415ca00526ffd2040875217dd7b2f0 100644 (file)
@@ -52,40 +52,42 @@ public interface Component extends Paintable, VariableOwner {
 
        /**
         * Gets style for component. Multiple styles are joined with spaces.
-        *
+        * 
         * @return the component's styleValue of property style.
         */
        public String getStyle();
 
        /**
-        * Sets and replaces all previous style names of the component. This method will trigger a
+        * Sets and replaces all previous style names of the component. This method
+        * will trigger a
         * {@link com.itmill.toolkit.terminal.Paintable.RepaintRequestEvent RepaintRequestEvent}.
         * 
         * @param style
         *            the new style of the component.
         */
        public void setStyle(String style);
-       
+
        /**
-        * Adds style name to component. Handeling additional style names is terminal spesicif,
-        * but in web browser enviroment they will most likely become CSS classes as given on server side.
-        *
+        * Adds style name to component. Handeling additional style names is
+        * terminal spesicif, but in web browser enviroment they will most likely
+        * become CSS classes as given on server side.
+        * 
         * This method will trigger a
         * {@link com.itmill.toolkit.terminal.Paintable.RepaintRequestEvent RepaintRequestEvent}.
         * 
         * @param style
-        *                      the new style to be added to the component
+        *            the new style to be added to the component
         */
        public void addStyleName(String style);
-       
+
        /**
         * Removes given style name from component.
         * 
         * @param style
-        *                      the style to be removed
+        *            the style to be removed
         */
        public void removeStyleName(String style);
-       
+
        /**
         * <p>
         * Tests if the component is enabled or not. All the variable change events
index 79c2a5f416a6689fec361a34aed2e6bb6aea79b5..56615a61c13dab28ab7ec5d337ae48a0ebff9796 100644 (file)
@@ -535,7 +535,7 @@ public class CustomComponent implements Component {
         * @see com.itmill.toolkit.ui.Component#getStyle()
         */
        public void removeStyleName(String style) {
-               
+
        }
 
 }
index 9cc263f99b0de177c1803978839b9391c1ed80e4..be0073a89aac58dd0f85fb28c7eae2323301558e 100644 (file)
@@ -67,7 +67,7 @@ public class CustomLayout extends AbstractComponentContainer implements Layout {
         * Custom layout slots containing the components.
         */
        private HashMap slots = new HashMap();
-       
+
        private String templateName;
 
        /**
index 350716a59505a4281550cf19fd68f4847e2bed88..989aca9f798e399f05cf536e101f6b2c574b3dc9 100644 (file)
@@ -316,7 +316,8 @@ public class DateField extends AbstractField {
 
                        if (newDate != oldDate
                                        && (newDate == null || !newDate.equals(oldDate)))
-                               setValue(newDate, true); // Don't require a repaint, client updates itself
+                               setValue(newDate, true); // Don't require a repaint, client
+                                                                                       // updates itself
                }
        }
 
@@ -350,15 +351,15 @@ public class DateField extends AbstractField {
                        Property.ConversionException {
                setValue(newValue, false);
        }
-       
-       public void setValue(Object newValue, boolean repaintIsNotNeeded) throws Property.ReadOnlyException,
-                       Property.ConversionException {
+
+       public void setValue(Object newValue, boolean repaintIsNotNeeded)
+                       throws Property.ReadOnlyException, Property.ConversionException {
 
                // Allows setting dates directly
                if (newValue == null || newValue instanceof Date)
                        super.setValue(newValue, repaintIsNotNeeded);
                else {
-               
+
                        // Try to parse as string
                        try {
                                SimpleDateFormat parser = new SimpleDateFormat();
index 8a0b412bac21964d6a2377951b81dde9d8b82076..253edb81556179dd6381b6f665d4cf40da48b2b0 100644 (file)
@@ -36,7 +36,7 @@ public class ExpandLayout extends OrderedLayout implements Sizeable {
        public ExpandLayout() {
 
        }
-       
+
        public ExpandLayout(int orientation) {
                this();
                setOrientation(orientation);
@@ -113,7 +113,7 @@ public class ExpandLayout extends OrderedLayout implements Sizeable {
 
        public void replaceComponent(Component oldComponent, Component newComponent) {
                super.replaceComponent(oldComponent, newComponent);
-               if(oldComponent == expanded)
+               if (oldComponent == expanded)
                        expanded = newComponent;
        }
 
index 2f2e2ef6be0cf2642d7d9e08e38e29e025f4eac0..1a3684fbe7090c5a21b82d2f055adac61ba280f6 100644 (file)
@@ -109,8 +109,9 @@ public class Label extends AbstractComponent implements Property,
        public static final int CONTENT_DEFAULT = CONTENT_TEXT;
 
        /** Array of content mode names that are rendered in UIDL as mode attribute. */
-       private static final String[] CONTENT_MODE_NAME = {"text","pre","uidl","xhtml","xml","raw"};
-       
+       private static final String[] CONTENT_MODE_NAME = { "text", "pre", "uidl",
+                       "xhtml", "xml", "raw" };
+
        private Property dataSource;
 
        private int contentMode = CONTENT_DEFAULT;
index 80444cc94b6901ab2f4fdcb26adaca85520e01e1..dd7d012097b9106f5e9a3e9fe22125ba3a768d7b 100644 (file)
@@ -92,7 +92,7 @@ public class Panel extends AbstractComponentContainer implements Sizeable,
         * Scrolling mode.
         */
        private boolean scrollable = false;
-       
+
        /** List of action handlers */
        private LinkedList actionHandlers = null;
 
@@ -198,24 +198,26 @@ public class Panel extends AbstractComponentContainer implements Sizeable,
         */
        public void paintContent(PaintTarget target) throws PaintException {
                layout.paint(target);
-               
-               if(height > -1)
-                       target.addVariable(this, "height", getHeight() + UNIT_SYMBOLS[getHeightUnits()]);
-               if(width > -1)
-                       target.addVariable(this, "width", getWidth() + UNIT_SYMBOLS[getWidthUnits()]);
-               
+
+               if (height > -1)
+                       target.addVariable(this, "height", getHeight()
+                                       + UNIT_SYMBOLS[getHeightUnits()]);
+               if (width > -1)
+                       target.addVariable(this, "width", getWidth()
+                                       + UNIT_SYMBOLS[getWidthUnits()]);
+
                if (isScrollable()) {
                        target.addVariable(this, "scrollleft", getScrollOffsetX());
                        target.addVariable(this, "scrolldown", getScrollOffsetY());
                }
-               
 
                if (actionHandlers != null && !actionHandlers.isEmpty()) {
                        target.addVariable(this, "action", "");
                        target.startTag("actions");
 
                        for (Iterator ahi = actionHandlers.iterator(); ahi.hasNext();) {
-                               Action[] aa = ((Action.Handler) ahi.next()).getActions(null, this);
+                               Action[] aa = ((Action.Handler) ahi.next()).getActions(null,
+                                               this);
                                if (aa != null) {
                                        for (int ai = 0; ai < aa.length; ai++) {
                                                Action a = aa[ai];
@@ -230,10 +232,11 @@ public class Panel extends AbstractComponentContainer implements Sizeable,
                                                        ShortcutAction sa = (ShortcutAction) a;
                                                        target.addAttribute("kc", sa.getKeyCode());
                                                        int[] modifiers = sa.getModifiers();
-                                                       if(modifiers != null) {
+                                                       if (modifiers != null) {
                                                                String[] smodifiers = new String[modifiers.length];
                                                                for (int i = 0; i < modifiers.length; i++)
-                                                                       smodifiers[i] = String.valueOf(modifiers[i]);
+                                                                       smodifiers[i] = String
+                                                                                       .valueOf(modifiers[i]);
                                                                target.addAttribute("mk", smodifiers);
                                                        }
                                                }
@@ -354,7 +357,7 @@ public class Panel extends AbstractComponentContainer implements Sizeable,
                        setWidth(newWidth.intValue());
                        // ensure units as we are reading pixels
                        setWidthUnits(UNITS_PIXELS);
-                       
+
                }
                if (newHeight != null && newHeight.intValue() != getHeight()) {
                        setHeight(newHeight.intValue());
@@ -369,15 +372,15 @@ public class Panel extends AbstractComponentContainer implements Sizeable,
                        setScrollOffsetX(newScrollX.intValue());
                if (newScrollY != null && newScrollY.intValue() != getScrollOffsetY())
                        setScrollOffsetY(newScrollY.intValue());
-               
+
                // Actions
                if (variables.containsKey("action")) {
                        String key = (String) variables.get("action");
                        Action action = (Action) actionMapper.get(key);
                        if (action != null && actionHandlers != null)
                                for (Iterator i = actionHandlers.iterator(); i.hasNext();)
-                                       ((Action.Handler) i.next()).handleAction(action, this,
-                                                       this);
+                                       ((Action.Handler) i.next())
+                                                       .handleAction(action, this, this);
                }
 
        }
@@ -534,7 +537,7 @@ public class Panel extends AbstractComponentContainer implements Sizeable,
                                requestRepaint();
                        }
                }
-               
+
        }
 
        /**
index c0ebf98492e2df3ec73bdd47d38acd30c7fc8680..961e0c9b01d381cea28be2b3475a2b85c0328c71 100644 (file)
@@ -186,8 +186,7 @@ public class Select extends AbstractField implements Container,
         * enabled with setOptionsLoadingLazy(true).
         * 
         */
-//     private OptionsStream optionsStream = null;
-       
+       // private OptionsStream optionsStream = null;
        /**
         * Number of options to stream per request ('page size') when lazyLoading
         * options.
@@ -203,8 +202,8 @@ public class Select extends AbstractField implements Container,
        private String filterstring;
 
        /**
-        * How many visible columns (~characters) does select occupy visually.
-        * Used to size select appropriately. Minus one sets to 100% width.
+        * How many visible columns (~characters) does select occupy visually. Used
+        * to size select appropriately. Minus one sets to 100% width.
         */
        private int columns = -1;
 
@@ -272,7 +271,7 @@ public class Select extends AbstractField implements Container,
 
                // Paints field properties
                super.paintContent(target);
-               
+
                // Paints select attributes
                if (isMultiSelect())
                        target.addAttribute("selectmode", "multi");
@@ -321,10 +320,11 @@ public class Select extends AbstractField implements Container,
                                target.endTag("so");
                        }
                }
-                       
+
                Iterator i;
-               if(isLazyLoading()) {
-                       i = optionFilter.filter(filterstring, lazyLoadingPageLength, page).iterator();
+               if (isLazyLoading()) {
+                       i = optionFilter.filter(filterstring, lazyLoadingPageLength, page)
+                                       .iterator();
                        target.addAttribute("totalMatches", optionFilter.getMatchCount());
                } else {
                        i = getItemIds().iterator();
@@ -359,7 +359,7 @@ public class Select extends AbstractField implements Container,
                target.addVariable(this, "selected", selectedKeys);
                if (isNewItemsAllowed())
                        target.addVariable(this, "newitem", "");
-               if(isLazyLoading()) {
+               if (isLazyLoading()) {
                        target.addVariable(this, "filter", filterstring);
                        target.addVariable(this, "page", page);
                }
@@ -373,7 +373,7 @@ public class Select extends AbstractField implements Container,
         */
        public void changeVariables(Object source, Map variables) {
                String newFilter;
-               if(newFilter = (String) variables.get("filter")) != null) {
+               if ((newFilter = (String) variables.get("filter")) != null) {
                        // this is a filter request
                        page = ((Integer) variables.get("page")).intValue();
                        filterstring = newFilter;
@@ -415,7 +415,7 @@ public class Select extends AbstractField implements Container,
                        if (isMultiSelect()) {
 
                                // TODO Optimize by adding repaintNotNeeded whan applicaple
-                               
+
                                // Converts the key-array to id-set
                                LinkedList s = new LinkedList();
                                for (int i = 0; i < ka.length; i++) {
@@ -558,17 +558,20 @@ public class Select extends AbstractField implements Container,
         * 
         * @param newValue
         *            the New selected item or collection of selected items.
-        * @param repaintIsNotNeeded True if caller is sure that repaint is not needed. 
-        * @see com.itmill.toolkit.ui.AbstractField#setValue(java.lang.Object, java.lang.Boolean)
+        * @param repaintIsNotNeeded
+        *            True if caller is sure that repaint is not needed.
+        * @see com.itmill.toolkit.ui.AbstractField#setValue(java.lang.Object,
+        *      java.lang.Boolean)
         */
-       protected void setValue(Object newValue, boolean repaintIsNotNeeded) throws Property.ReadOnlyException,
-                       Property.ConversionException {
+       protected void setValue(Object newValue, boolean repaintIsNotNeeded)
+                       throws Property.ReadOnlyException, Property.ConversionException {
 
                if (isMultiSelect()) {
                        if (newValue == null)
                                super.setValue(new HashSet(), repaintIsNotNeeded);
                        else if (Collection.class.isAssignableFrom(newValue.getClass()))
-                               super.setValue(new HashSet((Collection) newValue), repaintIsNotNeeded);
+                               super.setValue(new HashSet((Collection) newValue),
+                                               repaintIsNotNeeded);
                } else if (newValue == null || items.containsId(newValue))
                        super.setValue(newValue, repaintIsNotNeeded);
        }
@@ -1458,7 +1461,7 @@ public class Select extends AbstractField implements Container,
        public void setLazyLoading(boolean useLazyLoading) {
                if (useLazyLoading != isLazyLoading) {
                        isLazyLoading = useLazyLoading;
-                       if(getOptionFilter() == null)
+                       if (getOptionFilter() == null)
                                setOptionFilter(new StartsWithFilter(this));
                        requestRepaint();
                }
@@ -1483,11 +1486,11 @@ public class Select extends AbstractField implements Container,
        }
 
        /**
-        * Sets OptionFilter which will do filtering base on query string
-        * if Select is in lazy loading mode.
+        * Sets OptionFilter which will do filtering base on query string if Select
+        * is in lazy loading mode.
         * 
-        * @param of 
-        *                      OptionFilter to be used in filtering
+        * @param of
+        *            OptionFilter to be used in filtering
         */
        public void setOptionFilter(OptionFilter of) {
                optionFilter = of;
@@ -1499,19 +1502,19 @@ public class Select extends AbstractField implements Container,
        public OptionFilter getOptionFilter() {
                return optionFilter;
        }
-       
+
        /**
         * Set visible columns.
         */
        public void setColumns(int cols) {
                this.columns = cols;
        }
-       
+
        /**
         * Get visible columns.
         */
        public int getColumns() {
                return this.columns;
        }
-       
+
 }
index 19e6a1a9c97260a2e57dcf1dcadfaef558d78c62..20ef7d65eaea04a086eb181d8cb7fda6a8cc9279 100644 (file)
@@ -7,9 +7,8 @@ import com.itmill.toolkit.terminal.PaintTarget;
 \r
 /**\r
  * TODO comment\r
- *\r
- * Example code:\r
- * <code>\r
+ * \r
+ * Example code: <code>\r
  *     class MyPlayer extends CustomComponent implements ValueChangeListener {\r
  *             \r
  *             Label volumeIndicator = new Label();\r
@@ -38,7 +37,7 @@ import com.itmill.toolkit.terminal.PaintTarget;
  *     }\r
  *\r
  * </code>\r
- *\r
+ * \r
  */\r
 public class Slider extends AbstractField {\r
 \r
@@ -427,7 +426,7 @@ public class Slider extends AbstractField {
         * ValueOutOfBoundsException\r
         * \r
         * @author IT Mill Ltd.\r
-        *\r
+        * \r
         */\r
        public class ValueOutOfBoundsException extends Exception {\r
 \r
index 71a757eff5b73214ab9a1323b5f73adc24a1e856..e18a6e9840c594c92c9c5110cb6fed7a56db3a44 100644 (file)
@@ -37,7 +37,7 @@ import com.itmill.toolkit.terminal.Sizeable;
 /**
  * SplitPanel.
  * 
- * <code>SplitPanel</code> is a component container, that can contain two 
+ * <code>SplitPanel</code> is a component container, that can contain two
  * components (possibly containers) which are split by divider element.
  * 
  * @author IT Mill Ltd.
@@ -45,7 +45,8 @@ import com.itmill.toolkit.terminal.Sizeable;
  * @VERSION@
  * @since 5.0
  */
-public class SplitPanel extends AbstractComponentContainer implements Layout, Sizeable {
+public class SplitPanel extends AbstractComponentContainer implements Layout,
+               Sizeable {
 
        /* Predefined orientations ***************************************** */
 
@@ -60,7 +61,7 @@ public class SplitPanel extends AbstractComponentContainer implements Layout, Si
        public static int ORIENTATION_HORIZONTAL = 1;
 
        private Component firstComponent;
-       
+
        private Component secondComponent;
 
        /**
@@ -120,28 +121,29 @@ public class SplitPanel extends AbstractComponentContainer implements Layout, Si
         *            the component to be added.
         */
        public void addComponent(Component c) {
-               if(firstComponent == null) {
+               if (firstComponent == null) {
                        firstComponent = c;
                } else if (secondComponent == null) {
                        secondComponent = c;
                } else {
-                       throw new UnsupportedOperationException("Split panel can contain only two components");
+                       throw new UnsupportedOperationException(
+                                       "Split panel can contain only two components");
                }
                super.addComponent(c);
                requestRepaint();
        }
 
        public void setFirstComponent(Component c) {
-               if(firstComponent != null) {
+               if (firstComponent != null) {
                        // detach old
                        removeComponent(firstComponent);
                }
                firstComponent = c;
                super.addComponent(c);
        }
-       
+
        public void setSecondComponent(Component c) {
-               if(secondComponent != null) {
+               if (secondComponent != null) {
                        // detach old
                        removeComponent(c);
                }
@@ -157,9 +159,9 @@ public class SplitPanel extends AbstractComponentContainer implements Layout, Si
         */
        public void removeComponent(Component c) {
                super.removeComponent(c);
-               if(c == firstComponent)
+               if (c == firstComponent)
                        firstComponent = null;
-               else 
+               else
                        secondComponent = null;
                requestRepaint();
        }
@@ -173,23 +175,24 @@ public class SplitPanel extends AbstractComponentContainer implements Layout, Si
        public Iterator getComponentIterator() {
                return new Iterator() {
                        int i = 0;
+
                        public boolean hasNext() {
-                               if(i < 2)
+                               if (i < 2)
                                        return true;
                                return false;
                        }
 
                        public Object next() {
                                i++;
-                               if(i == 1) 
+                               if (i == 1)
                                        return firstComponent;
-                               else if(i == 2)
+                               else if (i == 2)
                                        return secondComponent;
                                return null;
                        }
 
                        public void remove() {
-                               if(i == 1)
+                               if (i == 1)
                                        setFirstComponent(null);
                                else if (i == 2)
                                        setSecondComponent(null);
@@ -206,28 +209,28 @@ public class SplitPanel extends AbstractComponentContainer implements Layout, Si
         *             if the paint operation failed.
         */
        public void paintContent(PaintTarget target) throws PaintException {
-               
+
                // TODO refine size attributes
-               if(width > 0) {
+               if (width > 0) {
                        target.addAttribute("width", width + UNIT_SYMBOLS[widthUnit]);
                } else {
                        target.addAttribute("width", "100%");
                }
-               if(height > 0) {
+               if (height > 0) {
                        target.addAttribute("height", height + UNIT_SYMBOLS[heightUnit]);
                } else {
                        target.addAttribute("height", "100%");
                }
-               
+
                String position = pos + UNIT_SYMBOLS[posUnit];
-               
+
                target.addAttribute("position", position);
 
-               if(firstComponent != null)
+               if (firstComponent != null)
                        firstComponent.paint(target);
                else
                        (new OrderedLayout()).paint(target);
-               if(secondComponent != null)
+               if (secondComponent != null)
                        secondComponent.paint(target);
                else
                        (new OrderedLayout()).paint(target);
@@ -261,40 +264,39 @@ public class SplitPanel extends AbstractComponentContainer implements Layout, Si
 
        /* Documented in superclass */
        public void replaceComponent(Component oldComponent, Component newComponent) {
-               if(oldComponent == firstComponent) {
+               if (oldComponent == firstComponent) {
                        setFirstComponent(newComponent);
                } else if (oldComponent == secondComponent) {
                        setSecondComponent(secondComponent);
                }
                requestRepaint();
        }
-       
+
        /**
         * Moves the position of the splitter.
         * 
-        * @param pos the new size of the first region in persentage
+        * @param pos
+        *            the new size of the first region in persentage
         */
        public void setSplitPosition(int pos) {
                setSplitPosition(pos, UNITS_PERCENTAGE);
        }
 
        /**
-        * Moves the position of the splitter with given position
-        * and unit.
+        * Moves the position of the splitter with given position and unit.
         * 
-        * Supported Units are {@link Sizeable}.UNITS_PERSENTAGE and 
+        * Supported Units are {@link Sizeable}.UNITS_PERSENTAGE and
         * Sizeable.UNITS_PIXELS
         * 
-        * @param pos size of the first region
-        * @oaran unit 
-        *                      the unit (from {@link Sizeable}) in which the size is given.
+        * @param pos
+        *            size of the first region
+        * @oaran unit the unit (from {@link Sizeable}) in which the size is given.
         */
        public void setSplitPosition(int pos, int unit) {
                this.pos = pos;
                this.posUnit = unit;
        }
 
-
        public int getHeight() {
                return height;
        }
index 41409c1f834232ebd30f2fa673ae24d85f08dad9..9152e01745d25f47849e85520749b0b7c4830cfe 100644 (file)
@@ -72,7 +72,7 @@ public class TabSheet extends AbstractComponentContainer implements Sizeable {
         * Holds the value of property tabsHIdden.
         */
        private boolean tabsHidden;
-       
+
        private int height = -1;
 
        private int heightUnit;
@@ -81,7 +81,6 @@ public class TabSheet extends AbstractComponentContainer implements Sizeable {
 
        private int widthUnit;
 
-
        /**
         * Constructs a new Tabsheet. Tabsheet is immediate by default.
         */
@@ -203,12 +202,13 @@ public class TabSheet extends AbstractComponentContainer implements Sizeable {
 
                if (areTabsHidden())
                        target.addAttribute("hidetabs", true);
-               
-               if(width > -1) {
+
+               if (width > -1) {
                        target.addAttribute("width", getWidth() + UNIT_SYMBOLS[widthUnit]);
                }
-               if(height > -1) {
-                       target.addAttribute("height", getHeight() + UNIT_SYMBOLS[heightUnit]);
+               if (height > -1) {
+                       target.addAttribute("height", getHeight()
+                                       + UNIT_SYMBOLS[heightUnit]);
                }
 
                target.startTag("tabs");
index ccc6405ca801b0892005b81b6a2bae8d433b6e37..2299383366ae29104db9df7b2ff4be11a63ec8a2 100644 (file)
@@ -620,28 +620,31 @@ public class Table extends Select implements Action.Container,
                // Assures the visual refresh
                refreshCurrentPage();
        }
-       
+
        /**
-        * Sets columns width (in pixels). Theme may not necessary respect very 
+        * Sets columns width (in pixels). Theme may not necessary respect very
         * small or very big values. Setting width to -1 (default) means that theme
         * will make decision of width.
         * 
-        * @param columnId colunmns property id
-        * @param width width to be reserved for colunmns content
+        * @param columnId
+        *            colunmns property id
+        * @param width
+        *            width to be reserved for colunmns content
         * @since 4.0.3
         */
        public void setColumnWidth(Object columnId, int width) {
                columnWidths.put(columnId, new Integer(width));
        }
-       
+
        /**
         * Gets the width of column
+        * 
         * @param propertyId
         * @return width of colun or -1 when value not set
         */
        public int getColumnWidth(Object propertyId) {
                Integer value = (Integer) columnWidths.get(propertyId);
-               if(value == null)
+               if (value == null)
                        return -1;
                return value.intValue();
        }
@@ -1324,7 +1327,7 @@ public class Table extends Select implements Action.Container,
 
                // Sorting
                boolean doSort = false;
-               if(!this.sortDisabled) {
+               if (!this.sortDisabled) {
                        if (variables.containsKey("sortcolumn")) {
                                String colId = (String) variables.get("sortcolumn");
                                if (colId != null && !"".equals(colId) && !"null".equals(colId)) {
@@ -1434,7 +1437,7 @@ public class Table extends Select implements Action.Container,
                target.addAttribute("cols", cols);
                target.addAttribute("rows", cells[0].length);
                target.addAttribute("firstrow",
-                               (reqFirstRowToPaint >= 0 ? reqFirstRowToPaint : first) );
+                               (reqFirstRowToPaint >= 0 ? reqFirstRowToPaint : first));
                target.addAttribute("totalrows", total);
                if (pagelen != 0)
                        target.addAttribute("pagelength", pagelen);
@@ -1479,7 +1482,8 @@ public class Table extends Select implements Action.Container,
                                        target.addAttribute("caption",
                                                        (String) cells[CELL_HEADER][i]);
                        }
-                       target.addAttribute("key", Integer.parseInt(cells[CELL_KEY][i].toString()));
+                       target.addAttribute("key", Integer.parseInt(cells[CELL_KEY][i]
+                                       .toString()));
                        if (actionHandlers != null || isSelectable()) {
                                if (isSelected(itemId) && keyIndex < selectedKeys.length) {
                                        target.addAttribute("selected", true);
@@ -1519,8 +1523,9 @@ public class Table extends Select implements Action.Container,
                                        else
                                                c.paint(target);
                                } else
-                                       target.addText((String) cells[CELL_FIRSTCOL
-                                                       + currentColumn][i]);
+                                       target
+                                                       .addText((String) cells[CELL_FIRSTCOL
+                                                                       + currentColumn][i]);
                        }
 
                        target.endTag("tr");
@@ -1617,9 +1622,10 @@ public class Table extends Select implements Action.Container,
                                if (!ALIGN_LEFT.equals(this.getColumnAlignment(columnId)))
                                        target.addAttribute("align", this
                                                        .getColumnAlignment(columnId));
-                               if(getColumnWidth(columnId) > -1)
-                                       target.addAttribute("width", String.valueOf(getColumnWidth(columnId)));
-                       
+                               if (getColumnWidth(columnId) > -1)
+                                       target.addAttribute("width", String
+                                                       .valueOf(getColumnWidth(columnId)));
+
                                target.endTag("column");
                        }
                }
@@ -2373,7 +2379,7 @@ public class Table extends Select implements Action.Container,
 
        /**
         * Sets the height units.
-        *  
+        * 
         * @see com.itmill.toolkit.terminal.Sizeable#setHeightUnits(int)
         */
        public void setHeightUnits(int units) {
index a8d1bd279c32894380dbbc8865a65cf2d87cd93f..f2d15da71272a223fb7a67d8c5456ce606b16261 100644 (file)
@@ -243,7 +243,7 @@ public class TextField extends AbstractField {
                                newValue = null;
                        if (newValue != oldValue
                                        && (newValue == null || !newValue.equals(oldValue)))
-                               setValue(newValue,true);
+                               setValue(newValue, true);
                }
 
        }
index 1bc4f8f9680604bdf623984e38a411f80b607422..5d84385b7e020bf890f175235863ade2d50ceb05 100644 (file)
@@ -101,7 +101,7 @@ public class Tree extends Select implements Container.Hierarchical,
         * Is the tree selectable .
         */
        private boolean selectable = true;
-       
+
        /**
         * Flag to indicate sub-tree loading
         */
@@ -111,10 +111,10 @@ public class Tree extends Select implements Container.Hierarchical,
         * Holds a itemId which was recently expanded
         */
        private Object expandedItemId;
-       
+
        /**
-        * a flag which indicates initial paint. After this flag set true
-        * partial updates are allowed.
+        * a flag which indicates initial paint. After this flag set true partial
+        * updates are allowed.
         */
        private boolean initialPaint = true;
 
@@ -178,9 +178,9 @@ public class Tree extends Select implements Container.Hierarchical,
 
                // Expands
                expanded.add(itemId);
-               
+
                expandedItemId = itemId;
-               if(initialPaint)
+               if (initialPaint)
                        requestRepaint();
                else
                        requestPartialRepaint();
@@ -188,11 +188,12 @@ public class Tree extends Select implements Container.Hierarchical,
 
                return true;
        }
-       
+
        public void requestRepaint() {
                super.requestRepaint();
                partialUpdate = false;
        }
+
        private void requestPartialRepaint() {
                super.requestRepaint();
                partialUpdate = true;
@@ -380,21 +381,21 @@ public class Tree extends Select implements Container.Hierarchical,
         */
        public void paintContent(PaintTarget target) throws PaintException {
                initialPaint = false;
-               
-               if(partialUpdate) {
+
+               if (partialUpdate) {
                        target.addAttribute("partialUpdate", true);
                        target.addAttribute("rootKey", itemIdMapper.key(expandedItemId));
                } else {
-                       
+
                        // Focus control id
                        if (this.getFocusableId() > 0) {
                                target.addAttribute("focusid", this.getFocusableId());
                        }
-       
+
                        // The tab ordering number
                        if (this.getTabIndex() > 0)
                                target.addAttribute("tabindex", this.getTabIndex());
-       
+
                        // Paint tree attributes
                        if (isSelectable())
                                target.addAttribute("selectmode", (isMultiSelect() ? "multi"
@@ -403,7 +404,7 @@ public class Tree extends Select implements Container.Hierarchical,
                                target.addAttribute("selectmode", "none");
                        if (isNewItemsAllowed())
                                target.addAttribute("allownewitem", true);
-       
+
                }
 
                // Initialize variables
@@ -419,14 +420,14 @@ public class Tree extends Select implements Container.Hierarchical,
                // Iterates through hierarchical tree using a stack of iterators
                Stack iteratorStack = new Stack();
                Collection ids;
-               if(partialUpdate)
+               if (partialUpdate)
                        ids = getChildren(expandedItemId);
                else
                        ids = rootItemIds();
-               
+
                if (ids != null)
                        iteratorStack.push(ids.iterator());
-               
+
                while (!iteratorStack.isEmpty()) {
 
                        // Gets the iterator for current tree level
@@ -448,7 +449,8 @@ public class Tree extends Select implements Container.Hierarchical,
                                Object itemId = i.next();
 
                                // Starts the item / node
-                               boolean isNode = areChildrenAllowed(itemId) && hasChildren(itemId);
+                               boolean isNode = areChildrenAllowed(itemId)
+                                               && hasChildren(itemId);
                                if (isNode)
                                        target.startTag("node");
                                else
@@ -470,7 +472,6 @@ public class Tree extends Select implements Container.Hierarchical,
                                        expandedKeys.add(key);
                                }
 
-                               
                                // Actions
                                if (actionHandlers != null) {
                                        ArrayList keys = new ArrayList();
@@ -501,7 +502,6 @@ public class Tree extends Select implements Container.Hierarchical,
                        }
                }
 
-
                // Actions
                if (!actionSet.isEmpty()) {
                        target.addVariable(this, "action", "");
@@ -519,7 +519,7 @@ public class Tree extends Select implements Container.Hierarchical,
                        target.endTag("actions");
                }
 
-               if(partialUpdate) {
+               if (partialUpdate) {
                        partialUpdate = false;
                } else {
                        // Selected
index 421fe9abd13f8f4fe748d1442ee646ee19d0118b..94149ac7eff5589861f4cf2ff3c8caa2c671a003 100644 (file)
@@ -421,7 +421,7 @@ public class Upload extends AbstractComponent implements Component.Focusable {
                        this.filename = filename;
                        this.type = MIMEType;
                }
-               
+
                /**
                 * Uploads where the event occurred.
                 * 
@@ -449,7 +449,6 @@ public class Upload extends AbstractComponent implements Component.Focusable {
                        return type;
                }
 
-
        }
 
        /**
@@ -775,6 +774,7 @@ public class Upload extends AbstractComponent implements Component.Focusable {
 
        /**
         * Gets listener that tracks progress of upload.
+        * 
         * @return listener
         * 
         */
@@ -790,7 +790,7 @@ public class Upload extends AbstractComponent implements Component.Focusable {
                 * Updates progress to listener
                 * 
                 * @param readBytes
-                *            bytes transferred 
+                *            bytes transferred
                 * @param contentLength
                 *            total size of file currently being uploaded, -1 if unknown
                 */
index bea093221c00936e0548a28030335f7ed95ecdf5..4f30743c5b04761966e9321388f543089411a121 100644 (file)
@@ -96,7 +96,7 @@ public class Window extends Panel implements URIHandler, ParameterHandler {
         * List of parameter handlers for this window.
         */
        private LinkedList parameterHandlerList = null;
-       
+
        /** Set of subwindows */
        private HashSet subwindows = new HashSet();
 
@@ -137,12 +137,12 @@ public class Window extends Panel implements URIHandler, ParameterHandler {
         * containing (main window) or -1 if unspecified .
         */
        private int positionX = -1;
-       
+
        /**
         * Distance scrolled from top in pixels.
         */
        private int scrollTop = 0;
-       
+
        /**
         * Distance scrolled from left in pixels.
         */
@@ -241,8 +241,8 @@ public class Window extends Panel implements URIHandler, ParameterHandler {
         */
        public final Application getApplication() {
                if (getParent() == null)
-               return this.application;
-               return ((Window)getParent()).getApplication();
+                       return this.application;
+               return ((Window) getParent()).getApplication();
        }
 
        /**
@@ -408,7 +408,9 @@ public class Window extends Panel implements URIHandler, ParameterHandler {
        /**
         * Gets the theme for this window.
         * 
-        * <p>Subwindows do not support themes and thus return theme used by the parent</p>
+        * <p>
+        * Subwindows do not support themes and thus return theme used by the parent
+        * </p>
         * 
         * @return the Name of the theme used in window. If the theme for this
         *         individual window is not explicitly set, the application theme is
@@ -417,7 +419,8 @@ public class Window extends Panel implements URIHandler, ParameterHandler {
         *         returned
         */
        public String getTheme() {
-               if (getParent() != null) return ((Window) getParent()).getTheme();
+               if (getParent() != null)
+                       return ((Window) getParent()).getTheme();
                if (theme != null)
                        return theme;
                if ((application != null) && (application.getTheme() != null))
@@ -430,12 +433,15 @@ public class Window extends Panel implements URIHandler, ParameterHandler {
        /**
         * Sets the theme for this window.
         * 
-        *       Setting theme for subwindows is not supported.
+        * Setting theme for subwindows is not supported.
+        * 
         * @param theme
         *            the New theme for this window. Null implies the default theme.
         */
        public void setTheme(String theme) {
-               if (getParent() != null) throw new UnsupportedOperationException("Setting theme for sub-windws is not supported.");
+               if (getParent() != null)
+                       throw new UnsupportedOperationException(
+                                       "Setting theme for sub-windws is not supported.");
                this.theme = theme;
                requestRepaint();
        }
@@ -483,7 +489,7 @@ public class Window extends Panel implements URIHandler, ParameterHandler {
                // Window position
                target.addVariable(this, "scrolltop", getScrollTop());
                target.addVariable(this, "scrollleft", getScrollLeft());
-               
+
                // Window closing
                target.addVariable(this, "close", false);
 
@@ -493,9 +499,9 @@ public class Window extends Panel implements URIHandler, ParameterHandler {
                                        + this.focusedComponent.getFocusableId());
                else
                        target.addVariable(this, "focused", "");
-               
+
                // Paint subwindows
-               for (Iterator i=subwindows.iterator(); i.hasNext();) {
+               for (Iterator i = subwindows.iterator(); i.hasNext();) {
                        Window w = (Window) i.next();
                        w.paint(target);
                }
@@ -850,7 +856,7 @@ public class Window extends Panel implements URIHandler, ParameterHandler {
         */
        public void setFocusedComponent(Component.Focusable focusable) {
                Application app = getApplication();
-               if(app != null) {
+               if (app != null) {
                        app.setFocusedComponent(focusable);
                        this.focusedComponent = focusable;
                }
@@ -1049,33 +1055,37 @@ public class Window extends Panel implements URIHandler, ParameterHandler {
                if (getParent() != null)
                        throw new IllegalArgumentException(
                                        "You can only add windows inside application-level windows");
-               
-               if (window == null) throw new NullPointerException("Argument must not be null");
+
+               if (window == null)
+                       throw new NullPointerException("Argument must not be null");
 
                subwindows.add(window);
                window.setParent(this);
                requestRepaint();
        }
-       
-       /** Remove the given subwindow from this window.
+
+       /**
+        * Remove the given subwindow from this window.
         * 
-        * @param window Window to be removed.
+        * @param window
+        *            Window to be removed.
         */
        public void removeWindow(Window window) {
                subwindows.remove(window);
                window.setParent(null);
                requestRepaint();
-               
+
        }
 
-       /** Get the set of all child windows.
+       /**
+        * Get the set of all child windows.
         * 
         * @return Set of child windows.
         */
        public Set getChildWindows() {
                return Collections.unmodifiableSet(subwindows);
        }
-       
+
        /**
         * Gets the current vertical scroll position of window.
         * 
@@ -1088,7 +1098,8 @@ public class Window extends Panel implements URIHandler, ParameterHandler {
        /**
         * Scrolls window to given position.
         * 
-        * @param scrollTop pixels to be scrolled from top
+        * @param scrollTop
+        *            pixels to be scrolled from top
         */
        public void setScrollTop(int scrollTop) {
                this.scrollTop = scrollTop;
@@ -1106,7 +1117,8 @@ public class Window extends Panel implements URIHandler, ParameterHandler {
        /**
         * Scrolls window to given position.
         * 
-        * @param scrollLeft pixels to be scrolled from left
+        * @param scrollLeft
+        *            pixels to be scrolled from left
         */
        public void setScrollLeft(int scrollLeft) {
                this.scrollLeft = scrollLeft;
index 9fe7906aad8d93d281cd123417d48f0c5f87f614..6f4f353175b7366599d36b4e3b7a4545b3c9149e 100644 (file)
@@ -19,10 +19,10 @@ public class ContainsFilter implements OptionFilter {
        }
 
        public List filter(String filterstring, int pageLength, int page) {
-               if(filterstring == null) {
+               if (filterstring == null) {
                        filterstring = "";
                }
-               if(this.prevFilter != filterstring || filteredItemsBuffer == null) {
+               if (this.prevFilter != filterstring || filteredItemsBuffer == null) {
                        if ("".equals(filterstring)) {
                                this.filteredItemsBuffer = new ArrayList(s.getItemIds());
                        } else if (s.getContainerDataSource() != null) {
@@ -38,8 +38,9 @@ public class ContainsFilter implements OptionFilter {
                                        Item item = s.getItem(id);
                                        String test = "";
                                        if (s.getItemCaptionMode() == Select.ITEM_CAPTION_MODE_PROPERTY)
-                                               test = item.getItemProperty(s.getItemCaptionPropertyId())
-                                                               .getValue().toString().trim();
+                                               test = item.getItemProperty(
+                                                               s.getItemCaptionPropertyId()).getValue()
+                                                               .toString().trim();
                                        else
                                                test = String.valueOf(id);
 
@@ -49,13 +50,13 @@ public class ContainsFilter implements OptionFilter {
                                }
                        }
                }
-               
+
                prevFilter = filterstring;
-               
-               if(filteredItemsBuffer.size() > pageLength) {
-                       int first = page*pageLength;
+
+               if (filteredItemsBuffer.size() > pageLength) {
+                       int first = page * pageLength;
                        int last = first + pageLength;
-                       if(filteredItemsBuffer.size() < last) {
+                       if (filteredItemsBuffer.size() < last) {
                                last = filteredItemsBuffer.size();
                        }
                        return filteredItemsBuffer.subList(first, last);
index 7f953829f9e1d1a329f669e35c8e57f93c8a3ae6..3b56eede4d78e343c038ee85250e644852841d47 100644 (file)
@@ -5,7 +5,8 @@ import java.util.List;
 public interface OptionFilter {
        /**
         * 
-        * @param filterstring string to use in filtering
+        * @param filterstring
+        *            string to use in filtering
         * @return List of filtered item id's
         */
        public List filter(String filterstring, int pageLength, int page);
index 1ceba53559daa07525e400ac5fb7643b0ddfa118..9972aa5ac41b4add7d5d684ef34c8bf885b2a88b 100644 (file)
@@ -19,10 +19,10 @@ public class StartsWithFilter implements OptionFilter {
        private String prevFilter;
 
        public List filter(String filterstring, int pageLength, int page) {
-               if(filterstring == null) {
+               if (filterstring == null) {
                        filterstring = "";
                }
-               if(this.prevFilter != filterstring || filteredItemsBuffer == null) {
+               if (this.prevFilter != filterstring || filteredItemsBuffer == null) {
                        if ("".equals(filterstring)) {
                                this.filteredItemsBuffer = new ArrayList(s.getItemIds());
                        } else if (s.getContainerDataSource() != null) {
@@ -38,8 +38,9 @@ public class StartsWithFilter implements OptionFilter {
                                        Item item = s.getItem(id);
                                        String test = "";
                                        if (s.getItemCaptionMode() == Select.ITEM_CAPTION_MODE_PROPERTY)
-                                               test = item.getItemProperty(s.getItemCaptionPropertyId())
-                                                               .getValue().toString().trim();
+                                               test = item.getItemProperty(
+                                                               s.getItemCaptionPropertyId()).getValue()
+                                                               .toString().trim();
                                        else
                                                test = String.valueOf(id);
 
@@ -49,13 +50,13 @@ public class StartsWithFilter implements OptionFilter {
                                }
                        }
                }
-               
+
                prevFilter = filterstring;
-               
-               if(filteredItemsBuffer.size() > pageLength) {
-                       int first = page*pageLength;
+
+               if (filteredItemsBuffer.size() > pageLength) {
+                       int first = page * pageLength;
                        int last = first + pageLength;
-                       if(filteredItemsBuffer.size() < last) {
+                       if (filteredItemsBuffer.size() < last) {
                                last = filteredItemsBuffer.size();
                        }
                        return filteredItemsBuffer.subList(first, last);