aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/com/itmill/toolkit/Application.java28
-rw-r--r--src/com/itmill/toolkit/demo/CalendarDemo.java173
-rw-r--r--src/com/itmill/toolkit/demo/FilterSelect.java2
-rw-r--r--src/com/itmill/toolkit/demo/KeyboardShortcut.java49
-rw-r--r--src/com/itmill/toolkit/demo/colorpicker/ColorPicker.java12
-rw-r--r--src/com/itmill/toolkit/demo/colorpicker/ColorPickerApplication.java21
-rw-r--r--src/com/itmill/toolkit/demo/colorpicker/gwt/client/WidgetSet.java26
-rw-r--r--src/com/itmill/toolkit/demo/colorpicker/gwt/client/ui/GwtColorPicker.java62
-rw-r--r--src/com/itmill/toolkit/demo/colorpicker/gwt/client/ui/ItkColorPicker.java20
-rw-r--r--src/com/itmill/toolkit/demo/features/Feature.java4
-rw-r--r--src/com/itmill/toolkit/demo/features/FeatureBrowser.java26
-rw-r--r--src/com/itmill/toolkit/demo/features/FeatureDateField.java11
-rw-r--r--src/com/itmill/toolkit/demo/features/FeaturesApplication.java2
-rw-r--r--src/com/itmill/toolkit/demo/features/PropertyPanel.java6
-rw-r--r--src/com/itmill/toolkit/demo/reservation/GoogleMap.java402
-rw-r--r--src/com/itmill/toolkit/demo/reservation/ReservationApplication.java489
-rw-r--r--src/com/itmill/toolkit/demo/reservation/ResourceNotAvailableException.java2
-rw-r--r--src/com/itmill/toolkit/demo/reservation/ResourceSelectorPanel.java172
-rw-r--r--src/com/itmill/toolkit/demo/reservation/SampleDB.java901
-rw-r--r--src/com/itmill/toolkit/demo/reservation/gwt/client/WidgetSet.java36
-rw-r--r--src/com/itmill/toolkit/demo/reservation/gwt/client/ui/IGoogleMap.java133
-rw-r--r--src/com/itmill/toolkit/demo/util/SampleCalendarDatabase.java266
-rw-r--r--src/com/itmill/toolkit/terminal/PaintTarget.java10
-rwxr-xr-xsrc/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java18
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/Caption.java95
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/CaptionWrapper.java8
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/DateLocale.java35
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/DateTimeService.java468
-rwxr-xr-xsrc/com/itmill/toolkit/terminal/gwt/client/DebugConsole.java30
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/DefaultWidgetSet.java416
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ErrorMessage.java3
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/LocaleNotLoadedException.java2
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/LocaleService.java188
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/NullConsole.java6
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/UIDL.java31
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/Util.java7
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/WidgetSet.java21
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/CalendarEntry.java203
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/CalendarPanel.java685
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/ContextMenu.java32
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/HorizontalSplitPanelImages.java12
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IButton.java56
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/ICalendar.java298
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/ICheckBox.java8
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/ICustomComponent.java10
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/ICustomLayout.java46
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IDateField.java112
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IDateFieldCalendar.java8
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IEmbedded.java31
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IExpandLayout.java9
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IFilterSelect.java31
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IForm.java13
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IFormLayout.java30
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IGridLayout.java35
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/ILabel.java6
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/ILink.java57
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IOptionGroup.java34
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IOptionGroupBase.java96
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayout.java99
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayoutHorizontal.java6
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayoutVertical.java6
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IPanel.java10
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IPasswordField.java6
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IPopupCalendar.java52
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IProgressIndicator.java18
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IScrollTable.java16
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/ISelect.java38
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/ISplitPanel.java11
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheet.java70
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheetPanel.java156
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/ITextArea.java10
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/ITextField.java43
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/ITextualDate.java194
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/ITwinColSelect.java79
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IUnknownComponent.java10
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IUpload.java4
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IView.java60
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IWindow.java25
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/MenuBar.java883
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/MenuItem.java286
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/Time.java251
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/TreeAction.java25
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/VerticalSplitPanelImages.java10
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/util/DateLocale.java55
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/util/Pattern.java107
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/util/SimpleDateFormat.java47
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/util/SimpleDateParser.java108
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java1966
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java32
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/server/JsonPaintTarget.java55
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/server/Log.java10
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/server/WebApplicationContext.java19
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/server/WebBrowser.java28
-rw-r--r--src/com/itmill/toolkit/tests/BasicRandomTest.java34
-rw-r--r--src/com/itmill/toolkit/tests/RandomLayoutStress.java14
-rw-r--r--src/com/itmill/toolkit/tests/TestBench.java6
-rw-r--r--src/com/itmill/toolkit/tests/TestForApplicationLayoutThatUsesWholeBrosersSpace.java8
-rw-r--r--src/com/itmill/toolkit/tests/TestForBasicApplicationLayout.java49
-rw-r--r--src/com/itmill/toolkit/tests/TestForChildComponentRendering.java39
-rw-r--r--src/com/itmill/toolkit/tests/TestForGridLayoutChildComponentRendering.java52
-rw-r--r--src/com/itmill/toolkit/tests/TestForTablesInitialColumnWidthLogicRendering.java90
-rw-r--r--src/com/itmill/toolkit/tests/TestForTrees.java16
-rw-r--r--src/com/itmill/toolkit/tests/TestForUpload.java83
-rw-r--r--src/com/itmill/toolkit/tests/TestForWindowing.java152
-rw-r--r--src/com/itmill/toolkit/ui/AbstractComponent.java33
-rw-r--r--src/com/itmill/toolkit/ui/AbstractComponentContainer.java2
-rw-r--r--src/com/itmill/toolkit/ui/AbstractField.java9
-rw-r--r--src/com/itmill/toolkit/ui/Button.java1
-rw-r--r--src/com/itmill/toolkit/ui/CalendarField.java514
-rw-r--r--src/com/itmill/toolkit/ui/Component.java22
-rw-r--r--src/com/itmill/toolkit/ui/CustomComponent.java2
-rw-r--r--src/com/itmill/toolkit/ui/CustomLayout.java2
-rw-r--r--src/com/itmill/toolkit/ui/DateField.java11
-rw-r--r--src/com/itmill/toolkit/ui/ExpandLayout.java4
-rw-r--r--src/com/itmill/toolkit/ui/Label.java5
-rw-r--r--src/com/itmill/toolkit/ui/Panel.java35
-rw-r--r--src/com/itmill/toolkit/ui/Select.java51
-rw-r--r--src/com/itmill/toolkit/ui/Slider.java9
-rw-r--r--src/com/itmill/toolkit/ui/SplitPanel.java64
-rw-r--r--src/com/itmill/toolkit/ui/TabSheet.java12
-rw-r--r--src/com/itmill/toolkit/ui/Table.java36
-rw-r--r--src/com/itmill/toolkit/ui/TextField.java2
-rw-r--r--src/com/itmill/toolkit/ui/Tree.java40
-rw-r--r--src/com/itmill/toolkit/ui/Upload.java6
-rw-r--r--src/com/itmill/toolkit/ui/Window.java58
-rw-r--r--src/com/itmill/toolkit/ui/select/ContainsFilter.java19
-rw-r--r--src/com/itmill/toolkit/ui/select/OptionFilter.java3
-rw-r--r--src/com/itmill/toolkit/ui/select/StartsWithFilter.java19
128 files changed, 6308 insertions, 5982 deletions
diff --git a/src/com/itmill/toolkit/Application.java b/src/com/itmill/toolkit/Application.java
index b6a98ed541..78f3dad629 100644
--- a/src/com/itmill/toolkit/Application.java
+++ b/src/com/itmill/toolkit/Application.java
@@ -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
*/
diff --git a/src/com/itmill/toolkit/demo/CalendarDemo.java b/src/com/itmill/toolkit/demo/CalendarDemo.java
index 24f1ba9681..6b0667d06d 100644
--- a/src/com/itmill/toolkit/demo/CalendarDemo.java
+++ b/src/com/itmill/toolkit/demo/CalendarDemo.java
@@ -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);
+
+ }
}
diff --git a/src/com/itmill/toolkit/demo/FilterSelect.java b/src/com/itmill/toolkit/demo/FilterSelect.java
index 38c597ce77..88539f1d36 100644
--- a/src/com/itmill/toolkit/demo/FilterSelect.java
+++ b/src/com/itmill/toolkit/demo/FilterSelect.java
@@ -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
diff --git a/src/com/itmill/toolkit/demo/KeyboardShortcut.java b/src/com/itmill/toolkit/demo/KeyboardShortcut.java
index 76a3ba3321..4e8d1020aa 100644
--- a/src/com/itmill/toolkit/demo/KeyboardShortcut.java
+++ b/src/com/itmill/toolkit/demo/KeyboardShortcut.java
@@ -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");
diff --git a/src/com/itmill/toolkit/demo/colorpicker/ColorPicker.java b/src/com/itmill/toolkit/demo/colorpicker/ColorPicker.java
index f21e73ac80..7ad1734219 100644
--- a/src/com/itmill/toolkit/demo/colorpicker/ColorPicker.java
+++ b/src/com/itmill/toolkit/demo/colorpicker/ColorPicker.java
@@ -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);
}
}
}
diff --git a/src/com/itmill/toolkit/demo/colorpicker/ColorPickerApplication.java b/src/com/itmill/toolkit/demo/colorpicker/ColorPickerApplication.java
index 2321f22dd6..16d7bb09b7 100644
--- a/src/com/itmill/toolkit/demo/colorpicker/ColorPickerApplication.java
+++ b/src/com/itmill/toolkit/demo/colorpicker/ColorPickerApplication.java
@@ -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() {
diff --git a/src/com/itmill/toolkit/demo/colorpicker/gwt/client/WidgetSet.java b/src/com/itmill/toolkit/demo/colorpicker/gwt/client/WidgetSet.java
index 1fbfa40bf8..29ab393253 100644
--- a/src/com/itmill/toolkit/demo/colorpicker/gwt/client/WidgetSet.java
+++ b/src/com/itmill/toolkit/demo/colorpicker/gwt/client/WidgetSet.java
@@ -6,20 +6,20 @@ import com.itmill.toolkit.terminal.gwt.client.DefaultWidgetSet;
import com.itmill.toolkit.terminal.gwt.client.UIDL;
public class WidgetSet extends DefaultWidgetSet {
- public Widget createWidget(UIDL uidl) {
- String className = resolveWidgetTypeName(uidl);
- if ("com.itmill.toolkit.demo.colorpicker.gwt.client.ui.ItkColorPicker"
- .equals(className))
- return new ItkColorPicker();
+ public Widget createWidget(UIDL uidl) {
+ String className = resolveWidgetTypeName(uidl);
+ if ("com.itmill.toolkit.demo.colorpicker.gwt.client.ui.ItkColorPicker"
+ .equals(className))
+ return new ItkColorPicker();
- return super.createWidget(uidl);
- }
+ return super.createWidget(uidl);
+ }
- protected String resolveWidgetTypeName(UIDL uidl) {
- String tag = uidl.getTag();
- if ("colorpicker".equals(tag))
- return "com.itmill.toolkit.demo.colorpicker.gwt.client.ui.ItkColorPicker";
+ protected String resolveWidgetTypeName(UIDL uidl) {
+ String tag = uidl.getTag();
+ if ("colorpicker".equals(tag))
+ return "com.itmill.toolkit.demo.colorpicker.gwt.client.ui.ItkColorPicker";
- return super.resolveWidgetTypeName(uidl);
- }
+ return super.resolveWidgetTypeName(uidl);
+ }
}
diff --git a/src/com/itmill/toolkit/demo/colorpicker/gwt/client/ui/GwtColorPicker.java b/src/com/itmill/toolkit/demo/colorpicker/gwt/client/ui/GwtColorPicker.java
index f3b792baf3..ca36176993 100644
--- a/src/com/itmill/toolkit/demo/colorpicker/gwt/client/ui/GwtColorPicker.java
+++ b/src/com/itmill/toolkit/demo/colorpicker/gwt/client/ui/GwtColorPicker.java
@@ -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
diff --git a/src/com/itmill/toolkit/demo/colorpicker/gwt/client/ui/ItkColorPicker.java b/src/com/itmill/toolkit/demo/colorpicker/gwt/client/ui/ItkColorPicker.java
index 54dedf2991..c1d9f532f0 100644
--- a/src/com/itmill/toolkit/demo/colorpicker/gwt/client/ui/ItkColorPicker.java
+++ b/src/com/itmill/toolkit/demo/colorpicker/gwt/client/ui/ItkColorPicker.java
@@ -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);
}
}
diff --git a/src/com/itmill/toolkit/demo/features/Feature.java b/src/com/itmill/toolkit/demo/features/Feature.java
index ae1c017a08..8a38e6854f 100644
--- a/src/com/itmill/toolkit/demo/features/Feature.java
+++ b/src/com/itmill/toolkit/demo/features/Feature.java
@@ -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;
diff --git a/src/com/itmill/toolkit/demo/features/FeatureBrowser.java b/src/com/itmill/toolkit/demo/features/FeatureBrowser.java
index 4c279d681a..ad5d2ff175 100644
--- a/src/com/itmill/toolkit/demo/features/FeatureBrowser.java
+++ b/src/com/itmill/toolkit/demo/features/FeatureBrowser.java
@@ -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
-
+
}
}
diff --git a/src/com/itmill/toolkit/demo/features/FeatureDateField.java b/src/com/itmill/toolkit/demo/features/FeatureDateField.java
index dae5ca2573..915b3088a7 100644
--- a/src/com/itmill/toolkit/demo/features/FeatureDateField.java
+++ b/src/com/itmill/toolkit/demo/features/FeatureDateField.java
@@ -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());
diff --git a/src/com/itmill/toolkit/demo/features/FeaturesApplication.java b/src/com/itmill/toolkit/demo/features/FeaturesApplication.java
index 1c833e687f..17461faa43 100644
--- a/src/com/itmill/toolkit/demo/features/FeaturesApplication.java
+++ b/src/com/itmill/toolkit/demo/features/FeaturesApplication.java
@@ -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());
}
diff --git a/src/com/itmill/toolkit/demo/features/PropertyPanel.java b/src/com/itmill/toolkit/demo/features/PropertyPanel.java
index f3a711b650..9b9ae09b1d 100644
--- a/src/com/itmill/toolkit/demo/features/PropertyPanel.java
+++ b/src/com/itmill/toolkit/demo/features/PropertyPanel.java
@@ -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();
}
diff --git a/src/com/itmill/toolkit/demo/reservation/GoogleMap.java b/src/com/itmill/toolkit/demo/reservation/GoogleMap.java
index 0869cf5b64..cae3529e0f 100644
--- a/src/com/itmill/toolkit/demo/reservation/GoogleMap.java
+++ b/src/com/itmill/toolkit/demo/reservation/GoogleMap.java
@@ -14,206 +14,206 @@ import com.itmill.toolkit.terminal.Sizeable;
import com.itmill.toolkit.ui.AbstractComponent;
public class GoogleMap extends AbstractComponent implements Sizeable,
- Container.Viewer {
- private String TAG_MARKERS = "markers";
- private String TAG_MARKER = "marker";
- private int width = 400;
- private int height = 300;
- private int zoomLevel = 15;
- private Point2D.Double mapCenter;
-
- private Container dataSource;
- private Object itemMarkerHtmlPropertyId = new Object();
- private Object itemMarkerXPropertyId = new Object();
- private Object itemMarkerYPropertyId = new Object();
-
- public String getTag() {
- return "googlemap";
- }
-
- public void paintContent(PaintTarget target) throws PaintException {
- super.paintContent(target);
- if (null != mapCenter) {
- target.addAttribute("centerX", mapCenter.getX());
- target.addAttribute("centerY", mapCenter.getY());
- }
- target.addAttribute("zoom", zoomLevel);
- target.addAttribute("width", width);
- target.addAttribute("height", height);
-
- if (this.dataSource != null) {
- target.startTag(TAG_MARKERS);
- Collection itemIds = this.dataSource.getItemIds();
- for (Iterator it = itemIds.iterator(); it.hasNext();) {
- Object itemId = it.next();
- Item item = this.dataSource.getItem(itemId);
- Property p = item.getItemProperty(getItemMarkerXPropertyId());
- Double x = (Double) (p != null ? p.getValue() : null);
- p = item.getItemProperty(getItemMarkerYPropertyId());
- Double y = (Double) (p != null ? p.getValue() : null);
- if (x == null || y == null) {
- continue;
+ Container.Viewer {
+ private String TAG_MARKERS = "markers";
+ private String TAG_MARKER = "marker";
+ private int width = 400;
+ private int height = 300;
+ private int zoomLevel = 15;
+ private Point2D.Double mapCenter;
+
+ private Container dataSource;
+ private Object itemMarkerHtmlPropertyId = new Object();
+ private Object itemMarkerXPropertyId = new Object();
+ private Object itemMarkerYPropertyId = new Object();
+
+ public String getTag() {
+ return "googlemap";
+ }
+
+ public void paintContent(PaintTarget target) throws PaintException {
+ super.paintContent(target);
+ if (null != mapCenter) {
+ target.addAttribute("centerX", mapCenter.getX());
+ target.addAttribute("centerY", mapCenter.getY());
+ }
+ target.addAttribute("zoom", zoomLevel);
+ target.addAttribute("width", width);
+ target.addAttribute("height", height);
+
+ if (this.dataSource != null) {
+ target.startTag(TAG_MARKERS);
+ Collection itemIds = this.dataSource.getItemIds();
+ for (Iterator it = itemIds.iterator(); it.hasNext();) {
+ Object itemId = it.next();
+ Item item = this.dataSource.getItem(itemId);
+ Property p = item.getItemProperty(getItemMarkerXPropertyId());
+ Double x = (Double) (p != null ? p.getValue() : null);
+ p = item.getItemProperty(getItemMarkerYPropertyId());
+ Double y = (Double) (p != null ? p.getValue() : null);
+ if (x == null || y == null) {
+ continue;
+ }
+ target.startTag(TAG_MARKER);
+ target.addAttribute("x", x.doubleValue());
+ target.addAttribute("y", y.doubleValue());
+ p = item.getItemProperty(getItemMarkerHtmlPropertyId());
+ String h = (String) (p != null ? p.getValue() : null);
+ target.addAttribute("html", h);
+ target.endTag(TAG_MARKER);
+ }
+ target.endTag(TAG_MARKERS);
}
- target.startTag(TAG_MARKER);
- target.addAttribute("x", x.doubleValue());
- target.addAttribute("y", y.doubleValue());
- p = item.getItemProperty(getItemMarkerHtmlPropertyId());
- String h = (String) (p != null ? p.getValue() : null);
- target.addAttribute("html", h);
- target.endTag(TAG_MARKER);
- }
- target.endTag(TAG_MARKERS);
- }
- }
-
- public void setZoomLevel(int zoomLevel) {
- this.zoomLevel = zoomLevel;
- requestRepaint();
- }
-
- public int getZoomLevel() {
- return this.zoomLevel;
- }
-
- // Sizeable methods:
-
- public int getHeight() {
- return this.height;
- }
-
- public int getHeightUnits() {
- return Sizeable.UNITS_PIXELS;
- }
-
- public int getWidth() {
- return this.width;
- }
-
- public int getWidthUnits() {
- return Sizeable.UNITS_PIXELS;
- }
-
- public void setHeight(int height) {
- this.height = height;
- requestRepaint();
- }
-
- public void setHeightUnits(int units) {
- throw new UnsupportedOperationException();
- }
-
- public void setWidth(int width) {
- this.width = width;
- requestRepaint();
- }
-
- public void setWidthUnits(int units) {
- throw new UnsupportedOperationException();
- }
-
- public void setMapCenter(Point2D.Double center) {
- this.mapCenter = center;
- }
-
- public Point2D.Double getMapCenter() {
- return this.mapCenter;
- }
-
- // Container.Viewer methods:
-
- public Container getContainerDataSource() {
- return this.dataSource;
- }
-
- public void setContainerDataSource(Container newDataSource) {
-
- this.dataSource = newDataSource;
-
- requestRepaint();
- }
-
- // Item methods
-
- public Object getItemMarkerHtmlPropertyId() {
- return itemMarkerHtmlPropertyId;
- }
-
- public void setItemMarkerHtmlPropertyId(Object itemMarkerHtmlPropertyId) {
- this.itemMarkerHtmlPropertyId = itemMarkerHtmlPropertyId;
- requestRepaint();
- }
-
- public Object getItemMarkerXPropertyId() {
- return itemMarkerXPropertyId;
- }
-
- public void setItemMarkerXPropertyId(Object itemMarkerXPropertyId) {
- this.itemMarkerXPropertyId = itemMarkerXPropertyId;
- requestRepaint();
- }
-
- public Object getItemMarkerYPropertyId() {
- return itemMarkerYPropertyId;
- }
-
- public void setItemMarkerYPropertyId(Object itemMarkerYPropertyId) {
- this.itemMarkerYPropertyId = itemMarkerYPropertyId;
- requestRepaint();
- }
-
- // Marker add
-
- public Object addMarker(String html, Point2D.Double location) {
- if (location == null) {
- throw new IllegalArgumentException("Location must be non-null");
- }
- if (this.dataSource == null) {
- initDataSource();
- }
- Object markerId = this.dataSource.addItem();
- if (markerId == null) {
- return null;
- }
- Item marker = this.dataSource.getItem(markerId);
- Property p = marker.getItemProperty(getItemMarkerXPropertyId());
- p.setValue(new Double(location.x));
- p = marker.getItemProperty(getItemMarkerYPropertyId());
- p.setValue(new Double(location.y));
- p = marker.getItemProperty(getItemMarkerHtmlPropertyId());
- p.setValue(html);
-
- requestRepaint();
-
- return markerId;
- }
-
- public void removeMarker(Object markerId) {
- if (this.dataSource != null) {
- this.dataSource.removeItem(markerId);
- requestRepaint();
- }
- }
-
- public Item getMarkerItem(Object markerId) {
- if (this.dataSource != null) {
- return this.dataSource.getItem(markerId);
- } else {
- return null;
- }
- }
-
- // dataSource init helper:
- private void initDataSource() {
- this.dataSource = new IndexedContainer();
- this.dataSource.addContainerProperty(this.itemMarkerHtmlPropertyId,
- String.class, null);
- this.dataSource.addContainerProperty(this.itemMarkerXPropertyId,
- Double.class, new Double(0));
- this.dataSource.addContainerProperty(this.itemMarkerYPropertyId,
- Double.class, new Double(0));
- }
-
- public void clear() {
- setContainerDataSource(null);
- }
+ }
+
+ public void setZoomLevel(int zoomLevel) {
+ this.zoomLevel = zoomLevel;
+ requestRepaint();
+ }
+
+ public int getZoomLevel() {
+ return this.zoomLevel;
+ }
+
+ // Sizeable methods:
+
+ public int getHeight() {
+ return this.height;
+ }
+
+ public int getHeightUnits() {
+ return Sizeable.UNITS_PIXELS;
+ }
+
+ public int getWidth() {
+ return this.width;
+ }
+
+ public int getWidthUnits() {
+ return Sizeable.UNITS_PIXELS;
+ }
+
+ public void setHeight(int height) {
+ this.height = height;
+ requestRepaint();
+ }
+
+ public void setHeightUnits(int units) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setWidth(int width) {
+ this.width = width;
+ requestRepaint();
+ }
+
+ public void setWidthUnits(int units) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setMapCenter(Point2D.Double center) {
+ this.mapCenter = center;
+ }
+
+ public Point2D.Double getMapCenter() {
+ return this.mapCenter;
+ }
+
+ // Container.Viewer methods:
+
+ public Container getContainerDataSource() {
+ return this.dataSource;
+ }
+
+ public void setContainerDataSource(Container newDataSource) {
+
+ this.dataSource = newDataSource;
+
+ requestRepaint();
+ }
+
+ // Item methods
+
+ public Object getItemMarkerHtmlPropertyId() {
+ return itemMarkerHtmlPropertyId;
+ }
+
+ public void setItemMarkerHtmlPropertyId(Object itemMarkerHtmlPropertyId) {
+ this.itemMarkerHtmlPropertyId = itemMarkerHtmlPropertyId;
+ requestRepaint();
+ }
+
+ public Object getItemMarkerXPropertyId() {
+ return itemMarkerXPropertyId;
+ }
+
+ public void setItemMarkerXPropertyId(Object itemMarkerXPropertyId) {
+ this.itemMarkerXPropertyId = itemMarkerXPropertyId;
+ requestRepaint();
+ }
+
+ public Object getItemMarkerYPropertyId() {
+ return itemMarkerYPropertyId;
+ }
+
+ public void setItemMarkerYPropertyId(Object itemMarkerYPropertyId) {
+ this.itemMarkerYPropertyId = itemMarkerYPropertyId;
+ requestRepaint();
+ }
+
+ // Marker add
+
+ public Object addMarker(String html, Point2D.Double location) {
+ if (location == null) {
+ throw new IllegalArgumentException("Location must be non-null");
+ }
+ if (this.dataSource == null) {
+ initDataSource();
+ }
+ Object markerId = this.dataSource.addItem();
+ if (markerId == null) {
+ return null;
+ }
+ Item marker = this.dataSource.getItem(markerId);
+ Property p = marker.getItemProperty(getItemMarkerXPropertyId());
+ p.setValue(new Double(location.x));
+ p = marker.getItemProperty(getItemMarkerYPropertyId());
+ p.setValue(new Double(location.y));
+ p = marker.getItemProperty(getItemMarkerHtmlPropertyId());
+ p.setValue(html);
+
+ requestRepaint();
+
+ return markerId;
+ }
+
+ public void removeMarker(Object markerId) {
+ if (this.dataSource != null) {
+ this.dataSource.removeItem(markerId);
+ requestRepaint();
+ }
+ }
+
+ public Item getMarkerItem(Object markerId) {
+ if (this.dataSource != null) {
+ return this.dataSource.getItem(markerId);
+ } else {
+ return null;
+ }
+ }
+
+ // dataSource init helper:
+ private void initDataSource() {
+ this.dataSource = new IndexedContainer();
+ this.dataSource.addContainerProperty(this.itemMarkerHtmlPropertyId,
+ String.class, null);
+ this.dataSource.addContainerProperty(this.itemMarkerXPropertyId,
+ Double.class, new Double(0));
+ this.dataSource.addContainerProperty(this.itemMarkerYPropertyId,
+ Double.class, new Double(0));
+ }
+
+ public void clear() {
+ setContainerDataSource(null);
+ }
} \ No newline at end of file
diff --git a/src/com/itmill/toolkit/demo/reservation/ReservationApplication.java b/src/com/itmill/toolkit/demo/reservation/ReservationApplication.java
index 1476c4b668..2f9d8da779 100644
--- a/src/com/itmill/toolkit/demo/reservation/ReservationApplication.java
+++ b/src/com/itmill/toolkit/demo/reservation/ReservationApplication.java
@@ -25,259 +25,260 @@ import com.itmill.toolkit.ui.TabSheet.SelectedTabChangeEvent;
public class ReservationApplication extends Application {
- private SampleDB db;
-
- ResourceSelectorPanel resourcePanel;
-
- private CalendarField reservedFrom;
- private static final long DEFAULT_GAP_MILLIS = 3600000; // one hour
- private long currentGapMillis = DEFAULT_GAP_MILLIS;
- private CalendarField reservedTo;
-
- private Label resourceName;
- private Label statusLabel;
- private TextField description;
- private Button reservationButton;
-
- private Table allTable;
- private CalendarField allCalendar;
-
- private GoogleMap map;
-
- public void init() {
- db = new SampleDB(true);
- db.generateResources();
- db.generateDemoUser();
-
- Window mainWindow = new Window("Reservr");
- setMainWindow(mainWindow);
- setTheme("reservr");
-
- TabSheet mainTabs = new TabSheet();
- mainWindow.addComponent(mainTabs);
-
- mainWindow.addComponent(new Button("close", this, "close"));
-
- OrderedLayout reservationTab = new OrderedLayout();
- mainTabs.addTab(reservationTab, "Make reservation", null);
-
- resourcePanel = new ResourceSelectorPanel("Resources");
- resourcePanel.setResourceContainer(db.getResources(null));
- resourcePanel.addListener(
- ResourceSelectorPanel.SelectedResourcesChangedEvent.class,
- this, "selectedResourcesChanged");
- reservationTab.addComponent(resourcePanel);
-
- Panel reservationPanel = new Panel("Reservation", new OrderedLayout(
- OrderedLayout.ORIENTATION_HORIZONTAL));
- reservationTab.addComponent(reservationPanel);
-
- OrderedLayout infoLayout = new OrderedLayout();
- reservationPanel.addComponent(infoLayout);
- resourceName = new Label("From the list above");
- resourceName.setCaption("Choose resource");
- infoLayout.addComponent(resourceName);
- description = new TextField();
- description.setColumns(55);
- description.setRows(5);
- infoLayout.addComponent(description);
- reservationButton = new Button("Make reservation", this,
- "makeReservation");
- infoLayout.addComponent(reservationButton);
- statusLabel = new Label();
- infoLayout.addComponent(statusLabel);
-
- map = new GoogleMap();
- map.setWidth(360);
- map.setHeight(270);
- map.setItemMarkerHtmlPropertyId(SampleDB.Resource.PROPERTY_ID_NAME);
- map.setItemMarkerXPropertyId(SampleDB.Resource.PROPERTY_ID_LOCATIONX);
- map.setItemMarkerYPropertyId(SampleDB.Resource.PROPERTY_ID_LOCATIONY);
- map.setContainerDataSource(db.getResources(null));
- infoLayout.addComponent(map);
-
- Calendar from = Calendar.getInstance();
- reservedFrom = new CalendarField();
- reservedFrom.setMinimumDate(from.getTime());
- reservedFrom.setValue(from.getTime());
- reservedFrom.setImmediate(true);
- initCalendarFieldPropertyIds(reservedFrom);
- reservationPanel.addComponent(reservedFrom);
-
- Calendar to = Calendar.getInstance();
- to.add(Calendar.MILLISECOND, (int)currentGapMillis);
- reservedTo = new CalendarField();
- reservedTo.setMinimumDate(from.getTime());
- reservedTo.setValue(to.getTime());
- reservedTo.setImmediate(true);
- initCalendarFieldPropertyIds(reservedTo);
- reservationPanel.addComponent(reservedTo);
-
- reservedFrom.addListener(new ValueChangeListener() {
- public void valueChange(ValueChangeEvent event) {
- Date fd = (Date) reservedFrom.getValue();
- if (fd == null) {
- reservedTo.setValue(null);
- reservedTo.setEnabled(false);
- refreshSelectedResources();
- return;
- } else {
- reservedTo.setEnabled(true);
- }
- reservedTo.setMinimumDate(fd);
+ private SampleDB db;
+
+ ResourceSelectorPanel resourcePanel;
+
+ private CalendarField reservedFrom;
+ private static final long DEFAULT_GAP_MILLIS = 3600000; // one hour
+ private long currentGapMillis = DEFAULT_GAP_MILLIS;
+ private CalendarField reservedTo;
+
+ private Label resourceName;
+ private Label statusLabel;
+ private TextField description;
+ private Button reservationButton;
+
+ private Table allTable;
+ private CalendarField allCalendar;
+
+ private GoogleMap map;
+
+ public void init() {
+ db = new SampleDB(true);
+ db.generateResources();
+ db.generateDemoUser();
+
+ Window mainWindow = new Window("Reservr");
+ setMainWindow(mainWindow);
+ setTheme("reservr");
+
+ TabSheet mainTabs = new TabSheet();
+ mainWindow.addComponent(mainTabs);
+
+ mainWindow.addComponent(new Button("close", this, "close"));
+
+ OrderedLayout reservationTab = new OrderedLayout();
+ mainTabs.addTab(reservationTab, "Make reservation", null);
+
+ resourcePanel = new ResourceSelectorPanel("Resources");
+ resourcePanel.setResourceContainer(db.getResources(null));
+ resourcePanel.addListener(
+ ResourceSelectorPanel.SelectedResourcesChangedEvent.class,
+ this, "selectedResourcesChanged");
+ reservationTab.addComponent(resourcePanel);
+
+ Panel reservationPanel = new Panel("Reservation", new OrderedLayout(
+ OrderedLayout.ORIENTATION_HORIZONTAL));
+ reservationTab.addComponent(reservationPanel);
+
+ OrderedLayout infoLayout = new OrderedLayout();
+ reservationPanel.addComponent(infoLayout);
+ resourceName = new Label("From the list above");
+ resourceName.setCaption("Choose resource");
+ infoLayout.addComponent(resourceName);
+ description = new TextField();
+ description.setColumns(55);
+ description.setRows(5);
+ infoLayout.addComponent(description);
+ reservationButton = new Button("Make reservation", this,
+ "makeReservation");
+ infoLayout.addComponent(reservationButton);
+ statusLabel = new Label();
+ infoLayout.addComponent(statusLabel);
+
+ map = new GoogleMap();
+ map.setWidth(360);
+ map.setHeight(270);
+ map.setItemMarkerHtmlPropertyId(SampleDB.Resource.PROPERTY_ID_NAME);
+ map.setItemMarkerXPropertyId(SampleDB.Resource.PROPERTY_ID_LOCATIONX);
+ map.setItemMarkerYPropertyId(SampleDB.Resource.PROPERTY_ID_LOCATIONY);
+ map.setContainerDataSource(db.getResources(null));
+ infoLayout.addComponent(map);
+
+ Calendar from = Calendar.getInstance();
+ reservedFrom = new CalendarField();
+ reservedFrom.setMinimumDate(from.getTime());
+ reservedFrom.setValue(from.getTime());
+ reservedFrom.setImmediate(true);
+ initCalendarFieldPropertyIds(reservedFrom);
+ reservationPanel.addComponent(reservedFrom);
+
Calendar to = Calendar.getInstance();
- to.setTime(fd);
- to.add(Calendar.MILLISECOND, (int)currentGapMillis);
+ to.add(Calendar.MILLISECOND, (int) currentGapMillis);
+ reservedTo = new CalendarField();
+ reservedTo.setMinimumDate(from.getTime());
reservedTo.setValue(to.getTime());
- refreshSelectedResources();
- resetStatus();
- }
- });
- reservedTo.addListener(new ValueChangeListener() {
- public void valueChange(ValueChangeEvent event) {
- Date from = (Date) reservedFrom.getValue();
- Date to = (Date) reservedTo.getValue();
- currentGapMillis = to.getTime() - from.getTime();
- if (currentGapMillis <= 0 ) {
- Calendar t = Calendar.getInstance();
- t.setTime(from);
- t.add(Calendar.MILLISECOND, (int)DEFAULT_GAP_MILLIS);
- reservedTo.setValue(t.getTime());
+ reservedTo.setImmediate(true);
+ initCalendarFieldPropertyIds(reservedTo);
+ reservationPanel.addComponent(reservedTo);
+
+ reservedFrom.addListener(new ValueChangeListener() {
+ public void valueChange(ValueChangeEvent event) {
+ Date fd = (Date) reservedFrom.getValue();
+ if (fd == null) {
+ reservedTo.setValue(null);
+ reservedTo.setEnabled(false);
+ refreshSelectedResources();
+ return;
+ } else {
+ reservedTo.setEnabled(true);
+ }
+ reservedTo.setMinimumDate(fd);
+ Calendar to = Calendar.getInstance();
+ to.setTime(fd);
+ to.add(Calendar.MILLISECOND, (int) currentGapMillis);
+ reservedTo.setValue(to.getTime());
+ refreshSelectedResources();
+ resetStatus();
+ }
+ });
+ reservedTo.addListener(new ValueChangeListener() {
+ public void valueChange(ValueChangeEvent event) {
+ Date from = (Date) reservedFrom.getValue();
+ Date to = (Date) reservedTo.getValue();
+ currentGapMillis = to.getTime() - from.getTime();
+ if (currentGapMillis <= 0) {
+ Calendar t = Calendar.getInstance();
+ t.setTime(from);
+ t.add(Calendar.MILLISECOND, (int) DEFAULT_GAP_MILLIS);
+ reservedTo.setValue(t.getTime());
+ }
+ refreshSelectedResources();
+ resetStatus();
+ }
+ });
+
+ OrderedLayout allLayout = new OrderedLayout(
+ OrderedLayout.ORIENTATION_HORIZONTAL);
+ allCalendar = new CalendarField();
+ initCalendarFieldPropertyIds(allCalendar);
+ allLayout.addComponent(allCalendar);
+ allTable = new Table();
+ allLayout.addComponent(allTable);
+ mainTabs.addTab(allLayout, "All reservations", null);
+ mainTabs.addListener(new TabSheet.SelectedTabChangeListener() {
+ public void selectedTabChange(SelectedTabChangeEvent event) {
+ refreshReservations();
+ }
+ });
+
+ refreshReservations();
+ }
+
+ public void makeReservation() {
+ try {
+ Item resource = getActiveResource();
+ if (resource != null) {
+ db.addReservation(resource, 0, (Date) reservedFrom.getValue(),
+ (Date) reservedTo.getValue(), (String) description
+ .getValue());
+ statusLabel.setCaption("Success!");
+ statusLabel
+ .setValue("You have reserved the resource for the selected period.");
+ }
+ } catch (ResourceNotAvailableException e) {
+ statusLabel.setCaption("Reservation failed");
+ statusLabel
+ .setValue("The selected resource was not available for the selected period.");
}
- refreshSelectedResources();
- resetStatus();
- }
- });
-
- OrderedLayout allLayout = new OrderedLayout(
- OrderedLayout.ORIENTATION_HORIZONTAL);
- allCalendar = new CalendarField();
- initCalendarFieldPropertyIds(allCalendar);
- allLayout.addComponent(allCalendar);
- allTable = new Table();
- allLayout.addComponent(allTable);
- mainTabs.addTab(allLayout, "All reservations", null);
- mainTabs.addListener(new TabSheet.SelectedTabChangeListener() {
- public void selectedTabChange(SelectedTabChangeEvent event) {
refreshReservations();
- }
- });
-
- refreshReservations();
- }
-
- public void makeReservation() {
- try {
- Item resource = getActiveResource();
- if (resource != null) {
- db.addReservation(resource, 0, (Date) reservedFrom.getValue(),
- (Date) reservedTo.getValue(), (String) description
- .getValue());
- statusLabel.setCaption("Success!");
- statusLabel
- .setValue("You have reserved the resource for the selected period.");
- }
- } catch (ResourceNotAvailableException e) {
- statusLabel.setCaption("Reservation failed");
- statusLabel
- .setValue("The selected resource was not available for the selected period.");
}
- refreshReservations();
- }
-
- private Item getActiveResource() throws ResourceNotAvailableException {
- List rids = resourcePanel.getSelectedResources();
- if (rids != null && rids.size() > 0) {
- for (Iterator it = rids.iterator(); it.hasNext();) {
- Item resource = (Item) it.next();
- int id = ((Integer) resource.getItemProperty(
- SampleDB.Resource.PROPERTY_ID_ID).getValue())
- .intValue();
- if (db.isAvailableResource(id, (Date) reservedFrom.getValue(),
- (Date) reservedTo.getValue()))
- return resource;
- }
- throw new ResourceNotAvailableException("No available resource");
- } else {
- return null;
+
+ private Item getActiveResource() throws ResourceNotAvailableException {
+ List rids = resourcePanel.getSelectedResources();
+ if (rids != null && rids.size() > 0) {
+ for (Iterator it = rids.iterator(); it.hasNext();) {
+ Item resource = (Item) it.next();
+ int id = ((Integer) resource.getItemProperty(
+ SampleDB.Resource.PROPERTY_ID_ID).getValue())
+ .intValue();
+ if (db.isAvailableResource(id, (Date) reservedFrom.getValue(),
+ (Date) reservedTo.getValue()))
+ return resource;
+ }
+ throw new ResourceNotAvailableException("No available resource");
+ } else {
+ return null;
+ }
}
- }
-
- private void refreshReservations() {
- Container reservations = db.getReservations(resourcePanel
- .getSelectedResources());
- reservedFrom.setContainerDataSource(reservations);
- reservedTo.setContainerDataSource(reservations);
- refreshSelectedResources();
- Container allReservations = db.getReservations(null);
- allTable.setContainerDataSource(allReservations);
- allCalendar.setContainerDataSource(allReservations);
-
- }
-
- private void refreshSelectedResources() {
- Item resource = null;
- try {
- resource = getActiveResource();
- } catch (ResourceNotAvailableException e) {
- resourceName.setCaption("Not available");
- resourceName.setValue("Please choose another time period or resource");
- reservationButton.setEnabled(false);
- return;
+
+ private void refreshReservations() {
+ Container reservations = db.getReservations(resourcePanel
+ .getSelectedResources());
+ reservedFrom.setContainerDataSource(reservations);
+ reservedTo.setContainerDataSource(reservations);
+ refreshSelectedResources();
+ Container allReservations = db.getReservations(null);
+ allTable.setContainerDataSource(allReservations);
+ allCalendar.setContainerDataSource(allReservations);
+
}
- map.clear();
- if (resource == null) {
- resourceName.setCaption("Choose resource");
- resourceName.setValue("from the list above");
- reservationButton.setEnabled(false);
- map.setContainerDataSource(db.getResources(null));
- map.setZoomLevel(1);
-
- } else {
- LinkedList srs = resourcePanel.getSelectedResources();
- for (Iterator it = srs.iterator(); it.hasNext();) {
- resource = (Item)it.next();
- String name = (String) resource.getItemProperty(
- SampleDB.Resource.PROPERTY_ID_NAME).getValue();
- String desc = (String) resource.getItemProperty(
- SampleDB.Resource.PROPERTY_ID_DESCRIPTION).getValue();
- resourceName.setCaption(name);
- resourceName.setValue(desc);
- Double x = (Double) resource.getItemProperty(
- SampleDB.Resource.PROPERTY_ID_LOCATIONX).getValue();
- Double y = (Double) resource.getItemProperty(
- SampleDB.Resource.PROPERTY_ID_LOCATIONY).getValue();
- if (x != null && y != null) {
- map.addMarker(name + "<br/>" + desc, new Point2D.Double(x
- .doubleValue(), y.doubleValue()));
-
+
+ private void refreshSelectedResources() {
+ Item resource = null;
+ try {
+ resource = getActiveResource();
+ } catch (ResourceNotAvailableException e) {
+ resourceName.setCaption("Not available");
+ resourceName
+ .setValue("Please choose another time period or resource");
+ reservationButton.setEnabled(false);
+ return;
}
-
- }
- map.setZoomLevel((srs.size()==1?16:9));
- reservationButton.setEnabled(true);
+ map.clear();
+ if (resource == null) {
+ resourceName.setCaption("Choose resource");
+ resourceName.setValue("from the list above");
+ reservationButton.setEnabled(false);
+ map.setContainerDataSource(db.getResources(null));
+ map.setZoomLevel(1);
+
+ } else {
+ LinkedList srs = resourcePanel.getSelectedResources();
+ for (Iterator it = srs.iterator(); it.hasNext();) {
+ resource = (Item) it.next();
+ String name = (String) resource.getItemProperty(
+ SampleDB.Resource.PROPERTY_ID_NAME).getValue();
+ String desc = (String) resource.getItemProperty(
+ SampleDB.Resource.PROPERTY_ID_DESCRIPTION).getValue();
+ resourceName.setCaption(name);
+ resourceName.setValue(desc);
+ Double x = (Double) resource.getItemProperty(
+ SampleDB.Resource.PROPERTY_ID_LOCATIONX).getValue();
+ Double y = (Double) resource.getItemProperty(
+ SampleDB.Resource.PROPERTY_ID_LOCATIONY).getValue();
+ if (x != null && y != null) {
+ map.addMarker(name + "<br/>" + desc, new Point2D.Double(x
+ .doubleValue(), y.doubleValue()));
+
+ }
+
+ }
+ map.setZoomLevel((srs.size() == 1 ? 16 : 9));
+ reservationButton.setEnabled(true);
+ }
+
}
- }
-
- private void initCalendarFieldPropertyIds(CalendarField cal) {
- cal
- .setItemStartPropertyId(SampleDB.Reservation.PROPERTY_ID_RESERVED_FROM);
- cal.setItemEndPropertyId(SampleDB.Reservation.PROPERTY_ID_RESERVED_TO);
- cal.setItemTitlePropertyId(SampleDB.Resource.PROPERTY_ID_NAME);
- cal
- .setItemDescriptionPropertyId(SampleDB.Reservation.PROPERTY_ID_DESCRIPTION);
- }
-
- private void resetStatus() {
- statusLabel.setCaption(null);
- statusLabel.setValue(null);
- }
-
- public void selectedResourcesChanged(
- ResourceSelectorPanel.SelectedResourcesChangedEvent event) {
- refreshReservations();
- resetStatus();
- }
+ private void initCalendarFieldPropertyIds(CalendarField cal) {
+ cal
+ .setItemStartPropertyId(SampleDB.Reservation.PROPERTY_ID_RESERVED_FROM);
+ cal.setItemEndPropertyId(SampleDB.Reservation.PROPERTY_ID_RESERVED_TO);
+ cal.setItemTitlePropertyId(SampleDB.Resource.PROPERTY_ID_NAME);
+ cal
+ .setItemDescriptionPropertyId(SampleDB.Reservation.PROPERTY_ID_DESCRIPTION);
+ }
+
+ private void resetStatus() {
+ statusLabel.setCaption(null);
+ statusLabel.setValue(null);
+ }
+
+ public void selectedResourcesChanged(
+ ResourceSelectorPanel.SelectedResourcesChangedEvent event) {
+ refreshReservations();
+ resetStatus();
+ }
}
diff --git a/src/com/itmill/toolkit/demo/reservation/ResourceNotAvailableException.java b/src/com/itmill/toolkit/demo/reservation/ResourceNotAvailableException.java
index af46e2f4d3..39e5a82060 100644
--- a/src/com/itmill/toolkit/demo/reservation/ResourceNotAvailableException.java
+++ b/src/com/itmill/toolkit/demo/reservation/ResourceNotAvailableException.java
@@ -2,6 +2,6 @@ package com.itmill.toolkit.demo.reservation;
public class ResourceNotAvailableException extends Exception {
public ResourceNotAvailableException(String message) {
- super(message);
+ super(message);
}
}
diff --git a/src/com/itmill/toolkit/demo/reservation/ResourceSelectorPanel.java b/src/com/itmill/toolkit/demo/reservation/ResourceSelectorPanel.java
index 744447d240..8593336b42 100644
--- a/src/com/itmill/toolkit/demo/reservation/ResourceSelectorPanel.java
+++ b/src/com/itmill/toolkit/demo/reservation/ResourceSelectorPanel.java
@@ -13,104 +13,104 @@ import com.itmill.toolkit.ui.Panel;
import com.itmill.toolkit.ui.Button.ClickEvent;
public class ResourceSelectorPanel extends Panel implements
- Button.ClickListener {
- private HashMap categoryLayouts = new HashMap();
- private HashMap categoryResources = new HashMap();
+ Button.ClickListener {
+ private HashMap categoryLayouts = new HashMap();
+ private HashMap categoryResources = new HashMap();
- private Container allResources;
- private LinkedList selectedResources = null;
+ private Container allResources;
+ private LinkedList selectedResources = null;
- public ResourceSelectorPanel(String caption) {
- super(caption, new OrderedLayout(OrderedLayout.ORIENTATION_HORIZONTAL));
- }
+ public ResourceSelectorPanel(String caption) {
+ super(caption, new OrderedLayout(OrderedLayout.ORIENTATION_HORIZONTAL));
+ }
- public void setResourceContainer(Container resources) {
- this.removeAllComponents();
- categoryLayouts.clear();
- categoryResources.clear();
- if (resources != null && resources.size() > 0) {
- for (Iterator it = resources.getItemIds().iterator(); it.hasNext();) {
- Item resource = (Item) resources.getItem(it.next());
- Integer id = (Integer) resource.getItemProperty(
- SampleDB.Resource.PROPERTY_ID_ID).getValue();
- String category = (String) resource.getItemProperty(
- SampleDB.Resource.PROPERTY_ID_CATEGORY).getValue();
- String name = (String) resource.getItemProperty(
- SampleDB.Resource.PROPERTY_ID_NAME).getValue();
- String description = (String) resource.getItemProperty(
- SampleDB.Resource.PROPERTY_ID_DESCRIPTION).getValue();
- Button rButton = new Button(name, this);
- rButton.setStyle("link");
- rButton.setDescription(description);
- rButton.setData(resource);
- Layout resourceLayout = (Layout) categoryLayouts.get(category);
- LinkedList resourceList = (LinkedList) categoryResources
- .get(category);
- if (resourceLayout == null) {
- resourceLayout = new OrderedLayout();
- this.addComponent(resourceLayout);
- categoryLayouts.put(category, resourceLayout);
- resourceList = new LinkedList();
- categoryResources.put(category, resourceList);
- Button cButton = new Button(category + " (any)", this);
- cButton.setStyle("important-link");
- cButton.setData(category);
- resourceLayout.addComponent(cButton);
+ public void setResourceContainer(Container resources) {
+ this.removeAllComponents();
+ categoryLayouts.clear();
+ categoryResources.clear();
+ if (resources != null && resources.size() > 0) {
+ for (Iterator it = resources.getItemIds().iterator(); it.hasNext();) {
+ Item resource = (Item) resources.getItem(it.next());
+ Integer id = (Integer) resource.getItemProperty(
+ SampleDB.Resource.PROPERTY_ID_ID).getValue();
+ String category = (String) resource.getItemProperty(
+ SampleDB.Resource.PROPERTY_ID_CATEGORY).getValue();
+ String name = (String) resource.getItemProperty(
+ SampleDB.Resource.PROPERTY_ID_NAME).getValue();
+ String description = (String) resource.getItemProperty(
+ SampleDB.Resource.PROPERTY_ID_DESCRIPTION).getValue();
+ Button rButton = new Button(name, this);
+ rButton.setStyle("link");
+ rButton.setDescription(description);
+ rButton.setData(resource);
+ Layout resourceLayout = (Layout) categoryLayouts.get(category);
+ LinkedList resourceList = (LinkedList) categoryResources
+ .get(category);
+ if (resourceLayout == null) {
+ resourceLayout = new OrderedLayout();
+ this.addComponent(resourceLayout);
+ categoryLayouts.put(category, resourceLayout);
+ resourceList = new LinkedList();
+ categoryResources.put(category, resourceList);
+ Button cButton = new Button(category + " (any)", this);
+ cButton.setStyle("important-link");
+ cButton.setData(category);
+ resourceLayout.addComponent(cButton);
+ }
+ resourceLayout.addComponent(rButton);
+ resourceList.add(resource);
+ }
}
- resourceLayout.addComponent(rButton);
- resourceList.add(resource);
- }
}
- }
- private void setSelectedResources(LinkedList resources) {
- selectedResources = resources;
- fireEvent(new SelectedResourcesChangedEvent());
- }
+ private void setSelectedResources(LinkedList resources) {
+ selectedResources = resources;
+ fireEvent(new SelectedResourcesChangedEvent());
+ }
- public LinkedList getSelectedResources() {
- return selectedResources;
- }
+ public LinkedList getSelectedResources() {
+ return selectedResources;
+ }
+
+ public void buttonClick(ClickEvent event) {
+ Object source = event.getSource();
+ if (source instanceof Button) {
+ Object data = ((Button) source).getData();
+ String name = ((Button) source).getCaption();
+ resetStyles();
+ if (data instanceof Item) {
+ LinkedList rlist = new LinkedList();
+ rlist.add(data);
+ setSelectedResources(rlist);
+ } else {
+ String category = (String) data;
+ LinkedList resources = (LinkedList) categoryResources
+ .get(category);
+ setSelectedResources(resources);
+ }
+ ((Button) source).setStyle("selected-link");
+ }
- public void buttonClick(ClickEvent event) {
- Object source = event.getSource();
- if (source instanceof Button) {
- Object data = ((Button) source).getData();
- String name = ((Button) source).getCaption();
- resetStyles();
- if (data instanceof Item) {
- LinkedList rlist = new LinkedList();
- rlist.add(data);
- setSelectedResources(rlist);
- } else {
- String category = (String) data;
- LinkedList resources = (LinkedList) categoryResources
- .get(category);
- setSelectedResources(resources);
- }
- ((Button)source).setStyle("selected-link");
}
- }
-
- private void resetStyles() {
- for (Iterator it = categoryLayouts.values().iterator();it.hasNext();) {
- Layout lo = (Layout)it.next();
- for (Iterator bit = lo.getComponentIterator();bit.hasNext();) {
- Button b = (Button)bit.next();
- if (b.getData() instanceof Item) {
- b.setStyle("link");
- } else {
- b.setStyle("important-link");
+ private void resetStyles() {
+ for (Iterator it = categoryLayouts.values().iterator(); it.hasNext();) {
+ Layout lo = (Layout) it.next();
+ for (Iterator bit = lo.getComponentIterator(); bit.hasNext();) {
+ Button b = (Button) bit.next();
+ if (b.getData() instanceof Item) {
+ b.setStyle("link");
+ } else {
+ b.setStyle("important-link");
+ }
+ }
}
- }
+
}
-
- }
- public class SelectedResourcesChangedEvent extends Event {
- public SelectedResourcesChangedEvent() {
- super(ResourceSelectorPanel.this);
+ public class SelectedResourcesChangedEvent extends Event {
+ public SelectedResourcesChangedEvent() {
+ super(ResourceSelectorPanel.this);
+ }
}
- }
}
diff --git a/src/com/itmill/toolkit/demo/reservation/SampleDB.java b/src/com/itmill/toolkit/demo/reservation/SampleDB.java
index ea8a752a7a..ca9c648b22 100644
--- a/src/com/itmill/toolkit/demo/reservation/SampleDB.java
+++ b/src/com/itmill/toolkit/demo/reservation/SampleDB.java
@@ -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);
+ }
+
+ }
}
diff --git a/src/com/itmill/toolkit/demo/reservation/gwt/client/WidgetSet.java b/src/com/itmill/toolkit/demo/reservation/gwt/client/WidgetSet.java
index b17de6263f..6ab247405a 100644
--- a/src/com/itmill/toolkit/demo/reservation/gwt/client/WidgetSet.java
+++ b/src/com/itmill/toolkit/demo/reservation/gwt/client/WidgetSet.java
@@ -7,28 +7,28 @@ import com.itmill.toolkit.terminal.gwt.client.DefaultWidgetSet;
import com.itmill.toolkit.terminal.gwt.client.UIDL;
public class WidgetSet extends DefaultWidgetSet {
- public Widget createWidget(UIDL uidl) {
- String className = resolveWidgetTypeName(uidl);
- if ("com.itmill.toolkit.terminal.gwt.client.ui.IGoogleMap"
- .equals(className)) {
- return new IGoogleMap();
+ public Widget createWidget(UIDL uidl) {
+ String className = resolveWidgetTypeName(uidl);
+ if ("com.itmill.toolkit.terminal.gwt.client.ui.IGoogleMap"
+ .equals(className)) {
+ return new IGoogleMap();
+ }
+
+ return super.createWidget(uidl);
}
- return super.createWidget(uidl);
- }
+ protected String resolveWidgetTypeName(UIDL uidl) {
- protected String resolveWidgetTypeName(UIDL uidl) {
+ String tag = uidl.getTag();
+ if ("googlemap".equals(tag)) {
+ return "com.itmill.toolkit.terminal.gwt.client.ui.IGoogleMap";
+ }
- String tag = uidl.getTag();
- if ("googlemap".equals(tag)) {
- return "com.itmill.toolkit.terminal.gwt.client.ui.IGoogleMap";
+ return super.resolveWidgetTypeName(uidl);
}
- return super.resolveWidgetTypeName(uidl);
- }
-
- 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));
+ }
}
diff --git a/src/com/itmill/toolkit/demo/reservation/gwt/client/ui/IGoogleMap.java b/src/com/itmill/toolkit/demo/reservation/gwt/client/ui/IGoogleMap.java
index 87ed826338..1bcb669880 100644
--- a/src/com/itmill/toolkit/demo/reservation/gwt/client/ui/IGoogleMap.java
+++ b/src/com/itmill/toolkit/demo/reservation/gwt/client/ui/IGoogleMap.java
@@ -15,81 +15,82 @@ import com.mapitz.gwt.googleMaps.client.GMarkerEventManager;
public class IGoogleMap extends GMap2Widget implements Paintable {
- public static final String CLASSNAME = "i-googlemap";
-
- GMap2EventManager mapEventManager;
- GMarkerEventManager markerEventManager;
- GMap2 map;
-
- public IGoogleMap() {
- setStyleName(CLASSNAME);
- mapEventManager = GMap2EventManager.getInstance();
- map = this.getGmap();
- }
-
- public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
- map.clearOverlays();
- GLatLng pos = null;
- for (Iterator it = uidl.getChildIterator(); it.hasNext();) {
- UIDL u = (UIDL) it.next();
- if (u.getTag().equals("markers")) {
-
- for (Iterator m = u.getChildIterator(); m.hasNext();) {
- UIDL umarker = (UIDL) m.next();
- String html = "<span>"+umarker.getStringAttribute("html")+"</span>";
- double x = umarker.getDoubleAttribute("x");
- double y = umarker.getDoubleAttribute("y");
- pos = new GLatLng(x, y);
- GMarker marker = new GMarker(pos);
- map.addOverlay(marker);
- if (html != null) {
- addMarkerPopup(marker, html);
- }
- }
- }
- }
- if (uidl.hasAttribute("width")) {
- setWidth(""+uidl.getIntAttribute("width"));
- }
- if (uidl.hasAttribute("height")) {
- setHeight(""+uidl.getIntAttribute("height"));
- }
- if (uidl.hasAttribute("zoom")) {
- map.setZoom(uidl.getIntAttribute("zoom"));
- }
- if (uidl.hasAttribute("centerX") && uidl.hasAttribute("centerY")) {
- GLatLng center = new GLatLng(uidl.getDoubleAttribute("centerX"),
- uidl.getDoubleAttribute("centerY"));
- map.setCenter(center);
- } else if (pos!=null) {
- // use last marker position
- map.setCenter(pos);
- }
+ public static final String CLASSNAME = "i-googlemap";
- }
+ GMap2EventManager mapEventManager;
+ GMarkerEventManager markerEventManager;
+ GMap2 map;
- private void addMarkerPopup(GMarker marker, String html) {
- if (markerEventManager == null) {
- markerEventManager = GMarkerEventManager.getInstance();
+ public IGoogleMap() {
+ setStyleName(CLASSNAME);
+ mapEventManager = GMap2EventManager.getInstance();
+ map = this.getGmap();
}
- markerEventManager.addOnClickListener(marker, new MarkerEventListener(
- html));
+ public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
+ map.clearOverlays();
+ GLatLng pos = null;
+ for (Iterator it = uidl.getChildIterator(); it.hasNext();) {
+ UIDL u = (UIDL) it.next();
+ if (u.getTag().equals("markers")) {
- }
-
- private class MarkerEventListener implements GMarkerEventClickListener {
- String html;
+ for (Iterator m = u.getChildIterator(); m.hasNext();) {
+ UIDL umarker = (UIDL) m.next();
+ String html = "<span>" + umarker.getStringAttribute("html")
+ + "</span>";
+ double x = umarker.getDoubleAttribute("x");
+ double y = umarker.getDoubleAttribute("y");
+ pos = new GLatLng(x, y);
+ GMarker marker = new GMarker(pos);
+ map.addOverlay(marker);
+ if (html != null) {
+ addMarkerPopup(marker, html);
+ }
+ }
+ }
+ }
+ if (uidl.hasAttribute("width")) {
+ setWidth("" + uidl.getIntAttribute("width"));
+ }
+ if (uidl.hasAttribute("height")) {
+ setHeight("" + uidl.getIntAttribute("height"));
+ }
+ if (uidl.hasAttribute("zoom")) {
+ map.setZoom(uidl.getIntAttribute("zoom"));
+ }
+ if (uidl.hasAttribute("centerX") && uidl.hasAttribute("centerY")) {
+ GLatLng center = new GLatLng(uidl.getDoubleAttribute("centerX"),
+ uidl.getDoubleAttribute("centerY"));
+ map.setCenter(center);
+ } else if (pos != null) {
+ // use last marker position
+ map.setCenter(pos);
+ }
- public MarkerEventListener(String html) {
- this.html = html;
}
- public void onClick(GMarker marker) {
- marker.openInfoWindowHtml(html);
+ private void addMarkerPopup(GMarker marker, String html) {
+ if (markerEventManager == null) {
+ markerEventManager = GMarkerEventManager.getInstance();
+ }
+
+ markerEventManager.addOnClickListener(marker, new MarkerEventListener(
+ html));
+
}
- public void onDblClick(GMarker marker) {
+ private class MarkerEventListener implements GMarkerEventClickListener {
+ String html;
+
+ public MarkerEventListener(String html) {
+ this.html = html;
+ }
+
+ public void onClick(GMarker marker) {
+ marker.openInfoWindowHtml(html);
+ }
+
+ public void onDblClick(GMarker marker) {
+ }
}
- }
}
diff --git a/src/com/itmill/toolkit/demo/util/SampleCalendarDatabase.java b/src/com/itmill/toolkit/demo/util/SampleCalendarDatabase.java
index d27756b4f5..c452a44d24 100644
--- a/src/com/itmill/toolkit/demo/util/SampleCalendarDatabase.java
+++ b/src/com/itmill/toolkit/demo/util/SampleCalendarDatabase.java
@@ -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;
+ }
}
diff --git a/src/com/itmill/toolkit/terminal/PaintTarget.java b/src/com/itmill/toolkit/terminal/PaintTarget.java
index 941c19ec2f..c0736d6c97 100644
--- a/src/com/itmill/toolkit/terminal/PaintTarget.java
+++ b/src/com/itmill/toolkit/terminal/PaintTarget.java
@@ -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.
*
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java b/src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java
index 0d6ab62313..c7ee9e1628 100755
--- a/src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java
@@ -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);
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/Caption.java b/src/com/itmill/toolkit/terminal/gwt/client/Caption.java
index 885d7a8016..c16db41e58 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/Caption.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/Caption.java
@@ -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 if( errorIndicatorElement != 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
*/
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/CaptionWrapper.java b/src/com/itmill/toolkit/terminal/gwt/client/CaptionWrapper.java
index 1957de0ce8..a4e05f0283 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/CaptionWrapper.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/CaptionWrapper.java
@@ -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;
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/DateLocale.java b/src/com/itmill/toolkit/terminal/gwt/client/DateLocale.java
index 283e35a2bd..fec5417a01 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/DateLocale.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/DateLocale.java
@@ -1,56 +1,63 @@
package com.itmill.toolkit.terminal.gwt.client;
-public class DateLocale extends com.itmill.toolkit.terminal.gwt.client.util.DateLocale {
+public class DateLocale extends
+ com.itmill.toolkit.terminal.gwt.client.util.DateLocale {
private static String locale;
-
+
public DateLocale() {
locale = LocaleService.getDefaultLocale();
}
-
+
public static void setLocale(String l) {
- if(LocaleService.getAvailableLocales().contains(locale))
+ if (LocaleService.getAvailableLocales().contains(locale))
locale = l;
- else // TODO redirect to console
- System.out.println("Tried to use an unloaded locale \""+locale+"\". Using default in stead ("+locale+")");
+ else
+ // TODO redirect to console
+ System.out.println("Tried to use an unloaded locale \"" + locale
+ + "\". Using default in stead (" + locale + ")");
}
-
+
public static String getAM() {
try {
return LocaleService.getAmPmStrings(locale)[0];
} catch (LocaleNotLoadedException e) {
// TODO redirect to console
- System.out.println("Tried to use an unloaded locale \""+locale+"\".");
+ System.out.println("Tried to use an unloaded locale \"" + locale
+ + "\".");
return "AM";
}
}
-
+
public static String getPM() {
try {
return LocaleService.getAmPmStrings(locale)[1];
} catch (LocaleNotLoadedException e) {
// TODO redirect to console
- System.out.println("Tried to use an unloaded locale \""+locale+"\".");
+ System.out.println("Tried to use an unloaded locale \"" + locale
+ + "\".");
return "PM";
}
}
-
+
public String[] getWEEKDAY_LONG() {
try {
return LocaleService.getDayNames(locale);
} catch (LocaleNotLoadedException e) {
// TODO redirect to console
- System.out.println("Tried to use an unloaded locale \""+locale+"\".");
+ System.out.println("Tried to use an unloaded locale \"" + locale
+ + "\".");
return null;
}
}
-
+
public String[] getWEEKDAY_SHORT() {
try {
return LocaleService.getShortDayNames(locale);
} catch (LocaleNotLoadedException e) {
// TODO redirect to console
- System.out.println("Tried to use an unloaded locale \""+locale+"\".");
+ System.out.println("Tried to use an unloaded locale \"" + locale
+ + "\".");
return null;
}
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/DateTimeService.java b/src/com/itmill/toolkit/terminal/gwt/client/DateTimeService.java
index 62ff15d0ac..9d4b28a555 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/DateTimeService.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/DateTimeService.java
@@ -12,239 +12,239 @@ import com.itmill.toolkit.terminal.gwt.client.ui.IDateField;
*
*/
public class DateTimeService {
- public static int RESOLUTION_YEAR = 0;
- public static int RESOLUTION_MONTH = 1;
- public static int RESOLUTION_DAY = 2;
- public static int RESOLUTION_HOUR = 3;
- public static int RESOLUTION_MIN = 4;
- public static int RESOLUTION_SEC = 5;
- public static int RESOLUTION_MSEC = 6;
-
- private String currentLocale;
-
- private static int[] maxDaysInMonth = { 31, 28, 31, 30, 31, 30, 31, 31, 30,
- 31, 30, 31 };
-
- /**
- * Creates a new date time service with the application default locale.
- */
- public DateTimeService() {
- currentLocale = LocaleService.getDefaultLocale();
- }
-
- /**
- * Creates a new date time service with a given locale.
- *
- * @param locale
- * e.g. fi, en etc.
- * @throws LocaleNotLoadedException
- */
- public DateTimeService(String locale) throws LocaleNotLoadedException {
- setLocale(locale);
- }
-
- public void setLocale(String locale) throws LocaleNotLoadedException {
- if (LocaleService.getAvailableLocales().contains(locale))
- currentLocale = locale;
- else
- throw new LocaleNotLoadedException(locale);
- }
-
- public String getLocale() {
- return currentLocale;
- }
-
- public String getMonth(int month) {
- try {
- return LocaleService.getMonthNames(currentLocale)[month];
- } catch (LocaleNotLoadedException e) {
- // TODO redirect to console
- System.out.println(e + ":" + e.getMessage());
- }
- return null;
- }
-
- public String getShortMonth(int month) {
- try {
- return LocaleService.getShortMonthNames(currentLocale)[month];
- } catch (LocaleNotLoadedException e) {
- // TODO redirect to console
- System.out.println(e + ":" + e.getMessage());
- }
- return null;
- }
-
- public String getDay(int day) {
- try {
- return LocaleService.getDayNames(currentLocale)[day];
- } catch (LocaleNotLoadedException e) {
- // TODO redirect to console
- System.out.println(e + ":" + e.getMessage());
- }
- return null;
- }
-
- public String getShortDay(int day) {
- try {
- return LocaleService.getShortDayNames(currentLocale)[day];
- } catch (LocaleNotLoadedException e) {
- // TODO redirect to console
- System.out.println(e + ":" + e.getMessage());
- }
- return null;
- }
-
- public int getFirstDayOfWeek() {
- try {
- return LocaleService.getFirstDayOfWeek(currentLocale);
- } catch (LocaleNotLoadedException e) {
- // TODO redirect to console
- System.out.println(e + ":" + e.getMessage());
- }
- return 0;
- }
-
- public boolean isTwelveHourClock() {
- try {
- return LocaleService.isTwelveHourClock(currentLocale);
- } catch (LocaleNotLoadedException e) {
- // TODO redirect to console
- System.out.println(e + ":" + e.getMessage());
- }
- return false;
- }
-
- public String getClockDelimeter() {
- try {
- return LocaleService.getClockDelimiter(currentLocale);
- } catch (LocaleNotLoadedException e) {
- // TODO redirect to console
- System.out.println(e + ":" + e.getMessage());
- }
- return ":";
- }
-
- public String[] getAmPmStrings() {
- try {
- return LocaleService.getAmPmStrings(currentLocale);
- } catch (LocaleNotLoadedException e) {
- // TODO redirect to console
- System.out.println(e + ":" + e.getMessage());
- }
- String[] temp = new String[2];
- temp[0] = "AM";
- temp[1] = "PM";
- return temp;
- }
-
- public int getStartWeekDay(Date date) {
- Date dateForFirstOfThisMonth = new Date(date.getYear(),
- date.getMonth(), 1);
- int firstDay;
- try {
- firstDay = LocaleService.getFirstDayOfWeek(currentLocale);
- } catch (LocaleNotLoadedException e) {
- firstDay = 0;
- // TODO redirect to console
- System.out.println(e + ":" + e.getMessage());
- }
- int start = dateForFirstOfThisMonth.getDay() - firstDay;
- if (start < 0)
- start = 6;
- return start;
- }
-
- public String getDateFormat() {
- try {
- return LocaleService.getDateFormat(currentLocale);
- } catch (LocaleNotLoadedException e) {
- // TODO redirect to console
- System.out.println(e + ":" + e.getMessage());
- }
- return "M/d/yy";
- }
-
- public static int getNumberOfDaysInMonth(Date date) {
- int month = date.getMonth();
- if (month == 1 && true == isLeapYear(date))
- return 29;
- return maxDaysInMonth[month];
- }
-
- public static boolean isLeapYear(Date date) {
- // Instantiate the date for 1st March of that year
- Date firstMarch = new Date(date.getYear(), 2, 1);
-
- // Go back 1 day
- long firstMarchTime = firstMarch.getTime();
- long lastDayTimeFeb = firstMarchTime - (24 * 60 * 60 * 1000); // NUM_MILLISECS_A_DAY
-
- // Instantiate new Date with this time
- Date febLastDay = new Date(lastDayTimeFeb);
-
- // Check for date in this new instance
- return (29 == febLastDay.getDate()) ? true : false;
- }
-
- public static boolean isSameDay(Date d1, Date d2) {
- return (getDayInt(d1) == getDayInt(d2));
- }
-
- public static boolean isInRange(Date date, Date rangeStart, Date rangeEnd,
- int resolution) {
- Date s;
- Date e;
- if (rangeStart.after(rangeEnd)) {
- s = rangeEnd;
- e = rangeStart;
- } else {
- e = rangeEnd;
- s = rangeStart;
- }
- long start = s.getYear()*10000000000l;
- long end = e.getYear()*10000000000l;
- long target = date.getYear()*10000000000l;
-
- if (resolution == RESOLUTION_YEAR) {
- return (start<=target&&end>=target);
- }
- start += s.getMonth() * 100000000;
- end += e.getMonth() * 100000000;
- target += date.getMonth() * 100000000;
- if (resolution == RESOLUTION_MONTH) {
- return (start<=target&&end>=target);
- }
- start += s.getDate() * 1000000;
- end += e.getDate() * 1000000;
- target += date.getDate() * 1000000;
- if (resolution == RESOLUTION_DAY) {
- return (start<=target&&end>=target);
- }
- start += s.getHours() * 10000;
- end += e.getHours() * 10000;
- target += date.getHours() * 10000;
- if (resolution == RESOLUTION_HOUR) {
- return (start<=target&&end>=target);
- }
- start += s.getMinutes() * 100;
- end += e.getMinutes() * 100;
- target += date.getMinutes() * 100;
- if (resolution == RESOLUTION_MIN) {
- return (start<=target&&end>=target);
- }
- start += s.getSeconds();
- end += e.getSeconds();
- target += date.getSeconds();
- return (start<=target&&end>=target);
-
- }
-
- private static int getDayInt(Date date) {
- int y = date.getYear();
- int m = date.getMonth();
- int d = date.getDate();
-
- return ((y + 1900) * 10000 + m * 100 + d) * 1000000000;
- }
+ public static int RESOLUTION_YEAR = 0;
+ public static int RESOLUTION_MONTH = 1;
+ public static int RESOLUTION_DAY = 2;
+ public static int RESOLUTION_HOUR = 3;
+ public static int RESOLUTION_MIN = 4;
+ public static int RESOLUTION_SEC = 5;
+ public static int RESOLUTION_MSEC = 6;
+
+ private String currentLocale;
+
+ private static int[] maxDaysInMonth = { 31, 28, 31, 30, 31, 30, 31, 31, 30,
+ 31, 30, 31 };
+
+ /**
+ * Creates a new date time service with the application default locale.
+ */
+ public DateTimeService() {
+ currentLocale = LocaleService.getDefaultLocale();
+ }
+
+ /**
+ * Creates a new date time service with a given locale.
+ *
+ * @param locale
+ * e.g. fi, en etc.
+ * @throws LocaleNotLoadedException
+ */
+ public DateTimeService(String locale) throws LocaleNotLoadedException {
+ setLocale(locale);
+ }
+
+ public void setLocale(String locale) throws LocaleNotLoadedException {
+ if (LocaleService.getAvailableLocales().contains(locale))
+ currentLocale = locale;
+ else
+ throw new LocaleNotLoadedException(locale);
+ }
+
+ public String getLocale() {
+ return currentLocale;
+ }
+
+ public String getMonth(int month) {
+ try {
+ return LocaleService.getMonthNames(currentLocale)[month];
+ } catch (LocaleNotLoadedException e) {
+ // TODO redirect to console
+ System.out.println(e + ":" + e.getMessage());
+ }
+ return null;
+ }
+
+ public String getShortMonth(int month) {
+ try {
+ return LocaleService.getShortMonthNames(currentLocale)[month];
+ } catch (LocaleNotLoadedException e) {
+ // TODO redirect to console
+ System.out.println(e + ":" + e.getMessage());
+ }
+ return null;
+ }
+
+ public String getDay(int day) {
+ try {
+ return LocaleService.getDayNames(currentLocale)[day];
+ } catch (LocaleNotLoadedException e) {
+ // TODO redirect to console
+ System.out.println(e + ":" + e.getMessage());
+ }
+ return null;
+ }
+
+ public String getShortDay(int day) {
+ try {
+ return LocaleService.getShortDayNames(currentLocale)[day];
+ } catch (LocaleNotLoadedException e) {
+ // TODO redirect to console
+ System.out.println(e + ":" + e.getMessage());
+ }
+ return null;
+ }
+
+ public int getFirstDayOfWeek() {
+ try {
+ return LocaleService.getFirstDayOfWeek(currentLocale);
+ } catch (LocaleNotLoadedException e) {
+ // TODO redirect to console
+ System.out.println(e + ":" + e.getMessage());
+ }
+ return 0;
+ }
+
+ public boolean isTwelveHourClock() {
+ try {
+ return LocaleService.isTwelveHourClock(currentLocale);
+ } catch (LocaleNotLoadedException e) {
+ // TODO redirect to console
+ System.out.println(e + ":" + e.getMessage());
+ }
+ return false;
+ }
+
+ public String getClockDelimeter() {
+ try {
+ return LocaleService.getClockDelimiter(currentLocale);
+ } catch (LocaleNotLoadedException e) {
+ // TODO redirect to console
+ System.out.println(e + ":" + e.getMessage());
+ }
+ return ":";
+ }
+
+ public String[] getAmPmStrings() {
+ try {
+ return LocaleService.getAmPmStrings(currentLocale);
+ } catch (LocaleNotLoadedException e) {
+ // TODO redirect to console
+ System.out.println(e + ":" + e.getMessage());
+ }
+ String[] temp = new String[2];
+ temp[0] = "AM";
+ temp[1] = "PM";
+ return temp;
+ }
+
+ public int getStartWeekDay(Date date) {
+ Date dateForFirstOfThisMonth = new Date(date.getYear(),
+ date.getMonth(), 1);
+ int firstDay;
+ try {
+ firstDay = LocaleService.getFirstDayOfWeek(currentLocale);
+ } catch (LocaleNotLoadedException e) {
+ firstDay = 0;
+ // TODO redirect to console
+ System.out.println(e + ":" + e.getMessage());
+ }
+ int start = dateForFirstOfThisMonth.getDay() - firstDay;
+ if (start < 0)
+ start = 6;
+ return start;
+ }
+
+ public String getDateFormat() {
+ try {
+ return LocaleService.getDateFormat(currentLocale);
+ } catch (LocaleNotLoadedException e) {
+ // TODO redirect to console
+ System.out.println(e + ":" + e.getMessage());
+ }
+ return "M/d/yy";
+ }
+
+ public static int getNumberOfDaysInMonth(Date date) {
+ int month = date.getMonth();
+ if (month == 1 && true == isLeapYear(date))
+ return 29;
+ return maxDaysInMonth[month];
+ }
+
+ public static boolean isLeapYear(Date date) {
+ // Instantiate the date for 1st March of that year
+ Date firstMarch = new Date(date.getYear(), 2, 1);
+
+ // Go back 1 day
+ long firstMarchTime = firstMarch.getTime();
+ long lastDayTimeFeb = firstMarchTime - (24 * 60 * 60 * 1000); // NUM_MILLISECS_A_DAY
+
+ // Instantiate new Date with this time
+ Date febLastDay = new Date(lastDayTimeFeb);
+
+ // Check for date in this new instance
+ return (29 == febLastDay.getDate()) ? true : false;
+ }
+
+ public static boolean isSameDay(Date d1, Date d2) {
+ return (getDayInt(d1) == getDayInt(d2));
+ }
+
+ public static boolean isInRange(Date date, Date rangeStart, Date rangeEnd,
+ int resolution) {
+ Date s;
+ Date e;
+ if (rangeStart.after(rangeEnd)) {
+ s = rangeEnd;
+ e = rangeStart;
+ } else {
+ e = rangeEnd;
+ s = rangeStart;
+ }
+ long start = s.getYear() * 10000000000l;
+ long end = e.getYear() * 10000000000l;
+ long target = date.getYear() * 10000000000l;
+
+ if (resolution == RESOLUTION_YEAR) {
+ return (start <= target && end >= target);
+ }
+ start += s.getMonth() * 100000000;
+ end += e.getMonth() * 100000000;
+ target += date.getMonth() * 100000000;
+ if (resolution == RESOLUTION_MONTH) {
+ return (start <= target && end >= target);
+ }
+ start += s.getDate() * 1000000;
+ end += e.getDate() * 1000000;
+ target += date.getDate() * 1000000;
+ if (resolution == RESOLUTION_DAY) {
+ return (start <= target && end >= target);
+ }
+ start += s.getHours() * 10000;
+ end += e.getHours() * 10000;
+ target += date.getHours() * 10000;
+ if (resolution == RESOLUTION_HOUR) {
+ return (start <= target && end >= target);
+ }
+ start += s.getMinutes() * 100;
+ end += e.getMinutes() * 100;
+ target += date.getMinutes() * 100;
+ if (resolution == RESOLUTION_MIN) {
+ return (start <= target && end >= target);
+ }
+ start += s.getSeconds();
+ end += e.getSeconds();
+ target += date.getSeconds();
+ return (start <= target && end >= target);
+
+ }
+
+ private static int getDayInt(Date date) {
+ int y = date.getYear();
+ int m = date.getMonth();
+ int d = date.getDate();
+
+ return ((y + 1900) * 10000 + m * 100 + d) * 1000000000;
+ }
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/DebugConsole.java b/src/com/itmill/toolkit/terminal/gwt/client/DebugConsole.java
index 942448e999..14502239ea 100755
--- a/src/com/itmill/toolkit/terminal/gwt/client/DebugConsole.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/DebugConsole.java
@@ -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);
}
-
-
+
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/DefaultWidgetSet.java b/src/com/itmill/toolkit/terminal/gwt/client/DefaultWidgetSet.java
index 6112f98884..2be55b4834 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/DefaultWidgetSet.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/DefaultWidgetSet.java
@@ -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));
+ }
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ErrorMessage.java b/src/com/itmill/toolkit/terminal/gwt/client/ErrorMessage.java
index 2426fe858b..fd46951fc1 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ErrorMessage.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ErrorMessage.java
@@ -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;
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/LocaleNotLoadedException.java b/src/com/itmill/toolkit/terminal/gwt/client/LocaleNotLoadedException.java
index af962b9b74..1f1e805d0a 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/LocaleNotLoadedException.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/LocaleNotLoadedException.java
@@ -1,7 +1,7 @@
package com.itmill.toolkit.terminal.gwt.client;
public class LocaleNotLoadedException extends Exception {
-
+
/**
* Serial generated by Eclipse.
*/
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/LocaleService.java b/src/com/itmill/toolkit/terminal/gwt/client/LocaleService.java
index f5d9b1f344..31fe42d167 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/LocaleService.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/LocaleService.java
@@ -11,153 +11,171 @@ import com.google.gwt.json.client.JSONObject;
import com.google.gwt.json.client.JSONString;
/**
- * Date / time etc. localisation service for all widgets.
- * Caches all loaded locales as JSONObjects.
+ * Date / time etc. localisation service for all widgets. Caches all loaded
+ * locales as JSONObjects.
*
* @author IT Mill Ltd.
- *
+ *
*/
public class LocaleService {
-
+
private static Map cache = new HashMap();
private static String defaultLocale;
public static void addLocale(JSONObject json) {
- String key = ((JSONString)json.get("name")).stringValue();
- if(cache.containsKey(key))
+ String key = ((JSONString) json.get("name")).stringValue();
+ if (cache.containsKey(key))
cache.remove(key);
cache.put(key, json);
- if(cache.size()==1)
+ if (cache.size() == 1)
setDefaultLocale(key);
}
public static void setDefaultLocale(String locale) {
defaultLocale = locale;
}
-
+
public static String getDefaultLocale() {
return defaultLocale;
}
-
+
public static Set getAvailableLocales() {
return cache.keySet();
}
-
- public static String[] getMonthNames(String locale) throws LocaleNotLoadedException {
- if(cache.containsKey(locale)) {
+
+ public static String[] getMonthNames(String locale)
+ throws LocaleNotLoadedException {
+ if (cache.containsKey(locale)) {
JSONObject l = (JSONObject) cache.get(locale);
JSONArray mn = (JSONArray) l.get("mn");
String[] temp = new String[12];
- temp[0] = ((JSONString)mn.get(0)).stringValue();
- temp[1] = ((JSONString)mn.get(1)).stringValue();
- temp[2] = ((JSONString)mn.get(2)).stringValue();
- temp[3] = ((JSONString)mn.get(3)).stringValue();
- temp[4] = ((JSONString)mn.get(4)).stringValue();
- temp[5] = ((JSONString)mn.get(5)).stringValue();
- temp[6] = ((JSONString)mn.get(6)).stringValue();
- temp[7] = ((JSONString)mn.get(7)).stringValue();
- temp[8] = ((JSONString)mn.get(8)).stringValue();
- temp[9] = ((JSONString)mn.get(9)).stringValue();
- temp[10] = ((JSONString)mn.get(10)).stringValue();
- temp[11] = ((JSONString)mn.get(11)).stringValue();
+ temp[0] = ((JSONString) mn.get(0)).stringValue();
+ temp[1] = ((JSONString) mn.get(1)).stringValue();
+ temp[2] = ((JSONString) mn.get(2)).stringValue();
+ temp[3] = ((JSONString) mn.get(3)).stringValue();
+ temp[4] = ((JSONString) mn.get(4)).stringValue();
+ temp[5] = ((JSONString) mn.get(5)).stringValue();
+ temp[6] = ((JSONString) mn.get(6)).stringValue();
+ temp[7] = ((JSONString) mn.get(7)).stringValue();
+ temp[8] = ((JSONString) mn.get(8)).stringValue();
+ temp[9] = ((JSONString) mn.get(9)).stringValue();
+ temp[10] = ((JSONString) mn.get(10)).stringValue();
+ temp[11] = ((JSONString) mn.get(11)).stringValue();
return temp;
- } else throw new LocaleNotLoadedException(locale);
+ } else
+ throw new LocaleNotLoadedException(locale);
}
-
- public static String[] getShortMonthNames(String locale) throws LocaleNotLoadedException {
- if(cache.containsKey(locale)) {
+
+ public static String[] getShortMonthNames(String locale)
+ throws LocaleNotLoadedException {
+ if (cache.containsKey(locale)) {
JSONObject l = (JSONObject) cache.get(locale);
JSONArray smn = (JSONArray) l.get("smn");
String[] temp = new String[12];
- temp[0] = ((JSONString)smn.get(0)).stringValue();
- temp[1] = ((JSONString)smn.get(1)).stringValue();
- temp[2] = ((JSONString)smn.get(2)).stringValue();
- temp[3] = ((JSONString)smn.get(3)).stringValue();
- temp[4] = ((JSONString)smn.get(4)).stringValue();
- temp[5] = ((JSONString)smn.get(5)).stringValue();
- temp[6] = ((JSONString)smn.get(6)).stringValue();
- temp[7] = ((JSONString)smn.get(7)).stringValue();
- temp[8] = ((JSONString)smn.get(8)).stringValue();
- temp[9] = ((JSONString)smn.get(9)).stringValue();
- temp[10] = ((JSONString)smn.get(10)).stringValue();
- temp[11] = ((JSONString)smn.get(11)).stringValue();
+ temp[0] = ((JSONString) smn.get(0)).stringValue();
+ temp[1] = ((JSONString) smn.get(1)).stringValue();
+ temp[2] = ((JSONString) smn.get(2)).stringValue();
+ temp[3] = ((JSONString) smn.get(3)).stringValue();
+ temp[4] = ((JSONString) smn.get(4)).stringValue();
+ temp[5] = ((JSONString) smn.get(5)).stringValue();
+ temp[6] = ((JSONString) smn.get(6)).stringValue();
+ temp[7] = ((JSONString) smn.get(7)).stringValue();
+ temp[8] = ((JSONString) smn.get(8)).stringValue();
+ temp[9] = ((JSONString) smn.get(9)).stringValue();
+ temp[10] = ((JSONString) smn.get(10)).stringValue();
+ temp[11] = ((JSONString) smn.get(11)).stringValue();
return temp;
- } else throw new LocaleNotLoadedException(locale);
+ } else
+ throw new LocaleNotLoadedException(locale);
}
-
- public static String[] getDayNames(String locale) throws LocaleNotLoadedException{
- if(cache.containsKey(locale)) {
+
+ public static String[] getDayNames(String locale)
+ throws LocaleNotLoadedException {
+ if (cache.containsKey(locale)) {
JSONObject l = (JSONObject) cache.get(locale);
JSONArray dn = (JSONArray) l.get("dn");
String[] temp = new String[7];
- temp[0] = ((JSONString)dn.get(0)).stringValue();
- temp[1] = ((JSONString)dn.get(1)).stringValue();
- temp[2] = ((JSONString)dn.get(2)).stringValue();
- temp[3] = ((JSONString)dn.get(3)).stringValue();
- temp[4] = ((JSONString)dn.get(4)).stringValue();
- temp[5] = ((JSONString)dn.get(5)).stringValue();
- temp[6] = ((JSONString)dn.get(6)).stringValue();
+ temp[0] = ((JSONString) dn.get(0)).stringValue();
+ temp[1] = ((JSONString) dn.get(1)).stringValue();
+ temp[2] = ((JSONString) dn.get(2)).stringValue();
+ temp[3] = ((JSONString) dn.get(3)).stringValue();
+ temp[4] = ((JSONString) dn.get(4)).stringValue();
+ temp[5] = ((JSONString) dn.get(5)).stringValue();
+ temp[6] = ((JSONString) dn.get(6)).stringValue();
return temp;
- } else throw new LocaleNotLoadedException(locale);
+ } else
+ throw new LocaleNotLoadedException(locale);
}
-
- public static String[] getShortDayNames(String locale) throws LocaleNotLoadedException {
- if(cache.containsKey(locale)) {
+
+ public static String[] getShortDayNames(String locale)
+ throws LocaleNotLoadedException {
+ if (cache.containsKey(locale)) {
JSONObject l = (JSONObject) cache.get(locale);
JSONArray sdn = (JSONArray) l.get("sdn");
String[] temp = new String[7];
- temp[0] = ((JSONString)sdn.get(0)).stringValue();
- temp[1] = ((JSONString)sdn.get(1)).stringValue();
- temp[2] = ((JSONString)sdn.get(2)).stringValue();
- temp[3] = ((JSONString)sdn.get(3)).stringValue();
- temp[4] = ((JSONString)sdn.get(4)).stringValue();
- temp[5] = ((JSONString)sdn.get(5)).stringValue();
- temp[6] = ((JSONString)sdn.get(6)).stringValue();
+ temp[0] = ((JSONString) sdn.get(0)).stringValue();
+ temp[1] = ((JSONString) sdn.get(1)).stringValue();
+ temp[2] = ((JSONString) sdn.get(2)).stringValue();
+ temp[3] = ((JSONString) sdn.get(3)).stringValue();
+ temp[4] = ((JSONString) sdn.get(4)).stringValue();
+ temp[5] = ((JSONString) sdn.get(5)).stringValue();
+ temp[6] = ((JSONString) sdn.get(6)).stringValue();
return temp;
- } else throw new LocaleNotLoadedException(locale);
+ } else
+ throw new LocaleNotLoadedException(locale);
}
-
- public static int getFirstDayOfWeek(String locale) throws LocaleNotLoadedException {
- if(cache.containsKey(locale)) {
+
+ public static int getFirstDayOfWeek(String locale)
+ throws LocaleNotLoadedException {
+ if (cache.containsKey(locale)) {
JSONObject l = (JSONObject) cache.get(locale);
JSONNumber fdow = (JSONNumber) l.get("fdow");
return (int) fdow.getValue();
- } else throw new LocaleNotLoadedException(locale);
+ } else
+ throw new LocaleNotLoadedException(locale);
}
-
- public static String getDateFormat(String locale) throws LocaleNotLoadedException {
- if(cache.containsKey(locale)) {
+
+ public static String getDateFormat(String locale)
+ throws LocaleNotLoadedException {
+ if (cache.containsKey(locale)) {
JSONObject l = (JSONObject) cache.get(locale);
JSONString df = (JSONString) l.get("df");
return df.stringValue();
- } else throw new LocaleNotLoadedException(locale);
+ } else
+ throw new LocaleNotLoadedException(locale);
}
-
- public static boolean isTwelveHourClock(String locale) throws LocaleNotLoadedException {
- if(cache.containsKey(locale)) {
+
+ public static boolean isTwelveHourClock(String locale)
+ throws LocaleNotLoadedException {
+ if (cache.containsKey(locale)) {
JSONObject l = (JSONObject) cache.get(locale);
JSONBoolean thc = (JSONBoolean) l.get("thc");
return thc.booleanValue();
- } else throw new LocaleNotLoadedException(locale);
+ } else
+ throw new LocaleNotLoadedException(locale);
}
-
- public static String getClockDelimiter(String locale) throws LocaleNotLoadedException {
- if(cache.containsKey(locale)) {
+
+ public static String getClockDelimiter(String locale)
+ throws LocaleNotLoadedException {
+ if (cache.containsKey(locale)) {
JSONObject l = (JSONObject) cache.get(locale);
JSONString hmd = (JSONString) l.get("hmd");
return hmd.stringValue();
- } else throw new LocaleNotLoadedException(locale);
+ } else
+ throw new LocaleNotLoadedException(locale);
}
-
- public static String[] getAmPmStrings(String locale) throws LocaleNotLoadedException {
- if(cache.containsKey(locale)) {
+
+ public static String[] getAmPmStrings(String locale)
+ throws LocaleNotLoadedException {
+ if (cache.containsKey(locale)) {
JSONObject l = (JSONObject) cache.get(locale);
JSONArray ampm = (JSONArray) l.get("ampm");
String[] temp = new String[2];
- temp[0] = ((JSONString)ampm.get(0)).stringValue();
- temp[1] = ((JSONString)ampm.get(1)).stringValue();
+ temp[0] = ((JSONString) ampm.get(0)).stringValue();
+ temp[1] = ((JSONString) ampm.get(1)).stringValue();
return temp;
- } else throw new LocaleNotLoadedException(locale);
+ } else
+ throw new LocaleNotLoadedException(locale);
}
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/NullConsole.java b/src/com/itmill/toolkit/terminal/gwt/client/NullConsole.java
index 44f4aedc5e..055251cf45 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/NullConsole.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/NullConsole.java
@@ -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 {
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/UIDL.java b/src/com/itmill/toolkit/terminal/gwt/client/UIDL.java
index d57c6048ac..555b78c286 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/UIDL.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/UIDL.java
@@ -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() {
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/Util.java b/src/com/itmill/toolkit/terminal/gwt/client/Util.java
index ce993f13bc..3c38d957ae 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/Util.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/Util.java
@@ -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) {
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/WidgetSet.java b/src/com/itmill/toolkit/terminal/gwt/client/WidgetSet.java
index bec94e3a4c..aaa77a91ab 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/WidgetSet.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/WidgetSet.java
@@ -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);
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/CalendarEntry.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/CalendarEntry.java
index 19bb70707f..56447949e1 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/CalendarEntry.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/CalendarEntry.java
@@ -5,108 +5,109 @@ import java.util.Date;
import com.itmill.toolkit.terminal.gwt.client.DateTimeService;
public class CalendarEntry {
- private Date start;
- private Date end;
- private String title;
- private String description;
- private boolean notime;
-
- public CalendarEntry(Date start, Date end, String title, String description, boolean notime) {
- if (notime) {
- Date d = new Date(start.getTime());
- d.setSeconds(0);
- d.setMinutes(0);
- this.start = d;
- if (end != null) {
- d = new Date(end.getTime());
- d.setSeconds(0);
- d.setMinutes(0);
- this.end = d;
- } else {
- end = start;
- }
- } else {
- this.start = start;
- this.end = end;
+ private Date start;
+ private Date end;
+ private String title;
+ private String description;
+ private boolean notime;
+
+ public CalendarEntry(Date start, Date end, String title,
+ String description, boolean notime) {
+ if (notime) {
+ Date d = new Date(start.getTime());
+ d.setSeconds(0);
+ d.setMinutes(0);
+ this.start = d;
+ if (end != null) {
+ d = new Date(end.getTime());
+ d.setSeconds(0);
+ d.setMinutes(0);
+ this.end = d;
+ } else {
+ end = start;
+ }
+ } else {
+ this.start = start;
+ this.end = end;
+ }
+ this.title = title;
+ this.description = description;
+ this.notime = notime;
}
- this.title = title;
- this.description = description;
- this.notime = notime;
- }
-
- public CalendarEntry(Date start, Date end, String title, String description) {
- this(start, end, title, description, false);
- }
-
- public Date getStart() {
- return start;
- }
-
- public void setStart(Date start) {
- this.start = start;
- }
-
- public Date getEnd() {
- return end;
- }
-
- public void setEnd(Date end) {
- this.end = end;
- }
-
- public String getTitle() {
- return title;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public boolean isNotime() {
- return notime;
- }
-
- public void setNotime(boolean notime) {
- this.notime = notime;
- }
-
- public String getStringForDate(Date d) {
- // TODO format from DateTimeService
- String s = "";
- if (!notime) {
- if (!DateTimeService.isSameDay(d, start)) {
- s += (start.getYear() + 1900) + "." + (start.getMonth() + 1)
- + "." + start.getDate() + " ";
- }
- int i = start.getHours();
- s += (i < 10 ? "0" : "") + i;
- s += ":";
- i = start.getMinutes();
- s += (i < 10 ? "0" : "") + i;
- if (!start.equals(end)) {
- s += " - ";
- if (!DateTimeService.isSameDay(start, end)) {
- s += (end.getYear() + 1900) + "." + (end.getMonth() + 1) + "."
- + end.getDate() + " ";
- }
- i = end.getHours();
- s += (i < 10 ? "0" : "") + i;
- s += ":";
- i = end.getMinutes();
- s += (i < 10 ? "0" : "") + i;
- }
- s += " ";
+
+ public CalendarEntry(Date start, Date end, String title, String description) {
+ this(start, end, title, description, false);
+ }
+
+ public Date getStart() {
+ return start;
+ }
+
+ public void setStart(Date start) {
+ this.start = start;
+ }
+
+ public Date getEnd() {
+ return end;
+ }
+
+ public void setEnd(Date end) {
+ this.end = end;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public boolean isNotime() {
+ return notime;
+ }
+
+ public void setNotime(boolean notime) {
+ this.notime = notime;
+ }
+
+ public String getStringForDate(Date d) {
+ // TODO format from DateTimeService
+ String s = "";
+ if (!notime) {
+ if (!DateTimeService.isSameDay(d, start)) {
+ s += (start.getYear() + 1900) + "." + (start.getMonth() + 1)
+ + "." + start.getDate() + " ";
+ }
+ int i = start.getHours();
+ s += (i < 10 ? "0" : "") + i;
+ s += ":";
+ i = start.getMinutes();
+ s += (i < 10 ? "0" : "") + i;
+ if (!start.equals(end)) {
+ s += " - ";
+ if (!DateTimeService.isSameDay(start, end)) {
+ s += (end.getYear() + 1900) + "." + (end.getMonth() + 1)
+ + "." + end.getDate() + " ";
+ }
+ i = end.getHours();
+ s += (i < 10 ? "0" : "") + i;
+ s += ":";
+ i = end.getMinutes();
+ s += (i < 10 ? "0" : "") + i;
+ }
+ s += " ";
+ }
+ s += title;
+ return s;
}
- s += title;
- return s;
- }
} \ No newline at end of file
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/CalendarPanel.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/CalendarPanel.java
index d770444102..ea8df2924d 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/CalendarPanel.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/CalendarPanel.java
@@ -19,390 +19,399 @@ import com.itmill.toolkit.terminal.gwt.client.DateTimeService;
import com.itmill.toolkit.terminal.gwt.client.LocaleService;
public class CalendarPanel extends FlexTable implements MouseListener,
- ClickListener {
-
- private IDateField datefield;
-
- private IEventButton prevYear;
- private IEventButton nextYear;
- private IEventButton prevMonth;
- private IEventButton nextMonth;
-
- private Time time;
-
- private Date minDate = null;
- private Date maxDate = null;
-
- private CalendarEntrySource entrySource;
-
- /* Needed to identify resolution changes */
- private int resolution = IDateField.RESOLUTION_YEAR;
-
- /* Needed to identify locale changes */
- private String locale = LocaleService.getDefaultLocale();
-
- public CalendarPanel(IDateField parent) {
- datefield = parent;
- setStyleName(datefield.CLASSNAME + "-calendarpanel");
- // buildCalendar(true);
- addTableListener(new DateClickListener(this));
- }
-
- public CalendarPanel(IDateField parent, Date min, Date max) {
- datefield = parent;
- setStyleName(datefield.CLASSNAME + "-calendarpanel");
- // buildCalendar(true);
- addTableListener(new DateClickListener(this));
- }
-
- private void buildCalendar(boolean forceRedraw) {
- boolean needsMonth = datefield.getCurrentResolution() > IDateField.RESOLUTION_YEAR;
- boolean needsBody = datefield.getCurrentResolution() >= IDateField.RESOLUTION_DAY;
- boolean needsTime = datefield.getCurrentResolution() >= IDateField.RESOLUTION_HOUR;
- buildCalendarHeader(forceRedraw, needsMonth);
- clearCalendarBody(!needsBody);
- if (needsBody)
- buildCalendarBody();
- if (needsTime)
- buildTime(forceRedraw);
- else if (time != null) {
- remove(time);
- time = null;
+ ClickListener {
+
+ private IDateField datefield;
+
+ private IEventButton prevYear;
+ private IEventButton nextYear;
+ private IEventButton prevMonth;
+ private IEventButton nextMonth;
+
+ private Time time;
+
+ private Date minDate = null;
+ private Date maxDate = null;
+
+ private CalendarEntrySource entrySource;
+
+ /* Needed to identify resolution changes */
+ private int resolution = IDateField.RESOLUTION_YEAR;
+
+ /* Needed to identify locale changes */
+ private String locale = LocaleService.getDefaultLocale();
+
+ public CalendarPanel(IDateField parent) {
+ datefield = parent;
+ setStyleName(datefield.CLASSNAME + "-calendarpanel");
+ // buildCalendar(true);
+ addTableListener(new DateClickListener(this));
}
- }
- private void clearCalendarBody(boolean remove) {
- if (!remove) {
- for (int row = 2; row < 8; row++) {
- for (int col = 0; col < 7; col++) {
- setHTML(row, col, "&nbsp;");
- }
- }
- } else if (getRowCount() > 2) {
- while (getRowCount() > 2)
- removeRow(2);
+ public CalendarPanel(IDateField parent, Date min, Date max) {
+ datefield = parent;
+ setStyleName(datefield.CLASSNAME + "-calendarpanel");
+ // buildCalendar(true);
+ addTableListener(new DateClickListener(this));
}
- }
-
- private void buildCalendarHeader(boolean forceRedraw, boolean needsMonth) {
- // Can't draw a calendar without a date :)
- if (datefield.getCurrentDate() == null)
- datefield.setCurrentDate(new Date());
-
- if (forceRedraw) {
- if (prevMonth == null) { // Only do once
- prevYear = new IEventButton();
- prevYear.setHTML("&laquo;");
- nextYear = new IEventButton();
- nextYear.setHTML("&raquo;");
- prevYear.addMouseListener(this);
- nextYear.addMouseListener(this);
- prevYear.addClickListener(this);
- nextYear.addClickListener(this);
- setWidget(0, 0, prevYear);
- setWidget(0, 4, nextYear);
-
- if (needsMonth) {
- prevMonth = new IEventButton();
- prevMonth.setHTML("&lsaquo;");
- nextMonth = new IEventButton();
- nextMonth.setHTML("&rsaquo;");
- prevMonth.addMouseListener(this);
- nextMonth.addMouseListener(this);
- prevMonth.addClickListener(this);
- nextMonth.addClickListener(this);
- setWidget(0, 3, nextMonth);
- setWidget(0, 1, prevMonth);
- }
- getFlexCellFormatter().setColSpan(0, 2, 3);
- } else if (!needsMonth) {
- // Remove month traverse buttons
- prevMonth.removeClickListener(this);
- prevMonth.removeMouseListener(this);
- nextMonth.removeClickListener(this);
- nextMonth.removeMouseListener(this);
- remove(prevMonth);
- remove(nextMonth);
- prevMonth = null;
- nextMonth = null;
- }
-
- // Print weekday names
- int firstDay = datefield.getDateTimeService().getFirstDayOfWeek();
- for (int i = 0; i < 7; i++) {
- int day = i + firstDay;
- if (day > 6)
- day = 0;
- if (datefield.getCurrentResolution() > IDateField.RESOLUTION_MONTH)
- setHTML(1, i, "<strong>"
- + datefield.getDateTimeService().getShortDay(day)
- + "</strong>");
- else
- setHTML(1, i, "");
- }
+ private void buildCalendar(boolean forceRedraw) {
+ boolean needsMonth = datefield.getCurrentResolution() > IDateField.RESOLUTION_YEAR;
+ boolean needsBody = datefield.getCurrentResolution() >= IDateField.RESOLUTION_DAY;
+ boolean needsTime = datefield.getCurrentResolution() >= IDateField.RESOLUTION_HOUR;
+ buildCalendarHeader(forceRedraw, needsMonth);
+ clearCalendarBody(!needsBody);
+ if (needsBody)
+ buildCalendarBody();
+ if (needsTime)
+ buildTime(forceRedraw);
+ else if (time != null) {
+ remove(time);
+ time = null;
+ }
}
- String monthName = needsMonth ? datefield.getDateTimeService()
- .getMonth(datefield.getCurrentDate().getMonth()) : "";
- int year = datefield.getCurrentDate().getYear() + 1900;
- setHTML(0, 2, "<span class=\"" + datefield.CLASSNAME
- + "-calendarpanel-month\">" + monthName + " " + year
- + "</span>");
- }
-
- private void buildCalendarBody() {
- Date date = datefield.getCurrentDate();
- if (date == null)
- date = new Date();
- int startWeekDay = datefield.getDateTimeService().getStartWeekDay(date);
- int numDays = DateTimeService.getNumberOfDaysInMonth(date);
- int dayCount = 0;
- Date today = new Date();
- Date curr = new Date(date.getTime());
- for (int row = 2; row < 8; row++) {
- for (int col = 0; col < 7; col++) {
- if (!(row == 2 && col < startWeekDay)) {
- if (dayCount < numDays) {
- int selectedDate = ++dayCount;
- String title = "";
- if (this.entrySource != null) {
- curr.setDate(dayCount);
- List entries = this.entrySource.getEntries(curr,
- IDateField.RESOLUTION_DAY);
- if (entries != null) {
- for (Iterator it = entries.iterator(); it
- .hasNext();) {
- CalendarEntry entry = (CalendarEntry) it
- .next();
- title += (title.length() > 0 ? ", " : "")
- + entry.getStringForDate(curr);
+ private void clearCalendarBody(boolean remove) {
+ if (!remove) {
+ for (int row = 2; row < 8; row++) {
+ for (int col = 0; col < 7; col++) {
+ setHTML(row, col, "&nbsp;");
}
- }
}
- String baseclass = datefield.CLASSNAME
- + "-calendarpanel-day";
- String cssClass = baseclass;
- if (!isEnabledDate(curr)) {
- cssClass += " " + baseclass + "-disabled";
+ } else if (getRowCount() > 2) {
+ while (getRowCount() > 2)
+ removeRow(2);
+ }
+ }
+
+ private void buildCalendarHeader(boolean forceRedraw, boolean needsMonth) {
+ // Can't draw a calendar without a date :)
+ if (datefield.getCurrentDate() == null)
+ datefield.setCurrentDate(new Date());
+
+ if (forceRedraw) {
+ if (prevMonth == null) { // Only do once
+ prevYear = new IEventButton();
+ prevYear.setHTML("&laquo;");
+ nextYear = new IEventButton();
+ nextYear.setHTML("&raquo;");
+ prevYear.addMouseListener(this);
+ nextYear.addMouseListener(this);
+ prevYear.addClickListener(this);
+ nextYear.addClickListener(this);
+ setWidget(0, 0, prevYear);
+ setWidget(0, 4, nextYear);
+
+ if (needsMonth) {
+ prevMonth = new IEventButton();
+ prevMonth.setHTML("&lsaquo;");
+ nextMonth = new IEventButton();
+ nextMonth.setHTML("&rsaquo;");
+ prevMonth.addMouseListener(this);
+ nextMonth.addMouseListener(this);
+ prevMonth.addClickListener(this);
+ nextMonth.addClickListener(this);
+ setWidget(0, 3, nextMonth);
+ setWidget(0, 1, prevMonth);
+ }
+
+ getFlexCellFormatter().setColSpan(0, 2, 3);
+ } else if (!needsMonth) {
+ // Remove month traverse buttons
+ prevMonth.removeClickListener(this);
+ prevMonth.removeMouseListener(this);
+ nextMonth.removeClickListener(this);
+ nextMonth.removeMouseListener(this);
+ remove(prevMonth);
+ remove(nextMonth);
+ prevMonth = null;
+ nextMonth = null;
}
- if (date.getDate() == dayCount) {
- cssClass += " " + baseclass + "-selected";
+
+ // Print weekday names
+ int firstDay = datefield.getDateTimeService().getFirstDayOfWeek();
+ for (int i = 0; i < 7; i++) {
+ int day = i + firstDay;
+ if (day > 6)
+ day = 0;
+ if (datefield.getCurrentResolution() > IDateField.RESOLUTION_MONTH)
+ setHTML(1, i, "<strong>"
+ + datefield.getDateTimeService().getShortDay(day)
+ + "</strong>");
+ else
+ setHTML(1, i, "");
}
- if (today.getDate() == dayCount
- && today.getMonth() == date.getMonth()
- && today.getYear() == date.getYear()) {
- cssClass += " " + baseclass + "-today";
+ }
+
+ String monthName = needsMonth ? datefield.getDateTimeService()
+ .getMonth(datefield.getCurrentDate().getMonth()) : "";
+ int year = datefield.getCurrentDate().getYear() + 1900;
+ setHTML(0, 2, "<span class=\"" + datefield.CLASSNAME
+ + "-calendarpanel-month\">" + monthName + " " + year
+ + "</span>");
+ }
+
+ private void buildCalendarBody() {
+ Date date = datefield.getCurrentDate();
+ if (date == null)
+ date = new Date();
+ int startWeekDay = datefield.getDateTimeService().getStartWeekDay(date);
+ int numDays = DateTimeService.getNumberOfDaysInMonth(date);
+ int dayCount = 0;
+ Date today = new Date();
+ Date curr = new Date(date.getTime());
+ for (int row = 2; row < 8; row++) {
+ for (int col = 0; col < 7; col++) {
+ if (!(row == 2 && col < startWeekDay)) {
+ if (dayCount < numDays) {
+ int selectedDate = ++dayCount;
+ String title = "";
+ if (this.entrySource != null) {
+ curr.setDate(dayCount);
+ List entries = this.entrySource.getEntries(curr,
+ IDateField.RESOLUTION_DAY);
+ if (entries != null) {
+ for (Iterator it = entries.iterator(); it
+ .hasNext();) {
+ CalendarEntry entry = (CalendarEntry) it
+ .next();
+ title += (title.length() > 0 ? ", " : "")
+ + entry.getStringForDate(curr);
+ }
+ }
+ }
+ String baseclass = datefield.CLASSNAME
+ + "-calendarpanel-day";
+ String cssClass = baseclass;
+ if (!isEnabledDate(curr)) {
+ cssClass += " " + baseclass + "-disabled";
+ }
+ if (date.getDate() == dayCount) {
+ cssClass += " " + baseclass + "-selected";
+ }
+ if (today.getDate() == dayCount
+ && today.getMonth() == date.getMonth()
+ && today.getYear() == date.getYear()) {
+ cssClass += " " + baseclass + "-today";
+ }
+ if (title.length() > 0)
+ cssClass += " " + baseclass + "-entry";
+ setHTML(row, col, "<span title=\"" + title
+ + "\" class=\"" + cssClass + "\">"
+ + selectedDate + "</span>");
+ } else {
+ break;
+ }
+
+ }
}
- if (title.length() > 0)
- cssClass += " " + baseclass + "-entry";
- setHTML(row, col, "<span title=\"" + title
- + "\" class=\"" + cssClass + "\">"
- + selectedDate + "</span>");
- } else {
- break;
- }
+ }
+ }
+ private void buildTime(boolean forceRedraw) {
+ if (time == null) {
+ time = new Time(datefield);
+ setText(8, 0, ""); // Add new row
+ getFlexCellFormatter().setColSpan(8, 0, 7);
+ setWidget(8, 0, time);
}
- }
+ time.updateTime(forceRedraw);
}
- }
-
- private void buildTime(boolean forceRedraw) {
- if (time == null) {
- time = new Time(datefield);
- setText(8, 0, ""); // Add new row
- getFlexCellFormatter().setColSpan(8, 0, 7);
- setWidget(8, 0, time);
+
+ /**
+ *
+ * @param forceRedraw
+ * Build all from scratch, in case of e.g. locale changes
+ */
+ public void updateCalendar() {
+ // Locale and resolution changes force a complete redraw
+ buildCalendar(locale != datefield.getCurrentLocale()
+ || resolution != datefield.getCurrentResolution());
+ if (datefield instanceof ITextualDate)
+ ((ITextualDate) datefield).buildDate();
+ locale = datefield.getCurrentLocale();
+ resolution = datefield.getCurrentResolution();
}
- time.updateTime(forceRedraw);
- }
-
- /**
- *
- * @param forceRedraw
- * Build all from scratch, in case of e.g. locale changes
- */
- public void updateCalendar() {
- // Locale and resolution changes force a complete redraw
- buildCalendar(locale != datefield.getCurrentLocale()
- || resolution != datefield.getCurrentResolution());
- if (datefield instanceof ITextualDate)
- ((ITextualDate) datefield).buildDate();
- locale = datefield.getCurrentLocale();
- resolution = datefield.getCurrentResolution();
- }
-
- public void onClick(Widget sender) {
- processClickEvent(sender);
- }
-
- private boolean isEnabledDate(Date date) {
- if ((this.minDate != null && date.before(this.minDate))
- || (this.maxDate != null && date.after(this.maxDate))) {
- return false;
+
+ public void onClick(Widget sender) {
+ processClickEvent(sender);
}
- return true;
- }
-
- private void processClickEvent(Widget sender) {
- if (!datefield.isEnabled() || datefield.isReadonly())
- return;
-
- if (sender == prevYear) {
- datefield.getCurrentDate().setYear(datefield.getCurrentDate().getYear() - 1);
- datefield.getClient().updateVariable(datefield.getId(), "year",
- datefield.getCurrentDate().getYear() + 1900, datefield.isImmediate());
- updateCalendar();
- } else if (sender == nextYear) {
- datefield.getCurrentDate().setYear(datefield.getCurrentDate().getYear() + 1);
- datefield.getClient().updateVariable(datefield.getId(), "year",
- datefield.getCurrentDate().getYear() + 1900, datefield.isImmediate());
- updateCalendar();
- } else if (sender == prevMonth) {
- datefield.getCurrentDate().setMonth(datefield.getCurrentDate().getMonth() - 1);
- datefield.getClient().updateVariable(datefield.getId(), "month",
- datefield.getCurrentDate().getMonth() + 1, datefield.isImmediate());
- updateCalendar();
- } else if (sender == nextMonth) {
- datefield.getCurrentDate().setMonth(datefield.getCurrentDate().getMonth() + 1);
- datefield.getClient().updateVariable(datefield.getId(), "month",
- datefield.getCurrentDate().getMonth() + 1, datefield.isImmediate());
- updateCalendar();
+
+ private boolean isEnabledDate(Date date) {
+ if ((this.minDate != null && date.before(this.minDate))
+ || (this.maxDate != null && date.after(this.maxDate))) {
+ return false;
+ }
+ return true;
}
- }
- private Timer timer;
+ private void processClickEvent(Widget sender) {
+ if (!datefield.isEnabled() || datefield.isReadonly())
+ return;
+
+ if (sender == prevYear) {
+ datefield.getCurrentDate().setYear(
+ datefield.getCurrentDate().getYear() - 1);
+ datefield.getClient().updateVariable(datefield.getId(), "year",
+ datefield.getCurrentDate().getYear() + 1900,
+ datefield.isImmediate());
+ updateCalendar();
+ } else if (sender == nextYear) {
+ datefield.getCurrentDate().setYear(
+ datefield.getCurrentDate().getYear() + 1);
+ datefield.getClient().updateVariable(datefield.getId(), "year",
+ datefield.getCurrentDate().getYear() + 1900,
+ datefield.isImmediate());
+ updateCalendar();
+ } else if (sender == prevMonth) {
+ datefield.getCurrentDate().setMonth(
+ datefield.getCurrentDate().getMonth() - 1);
+ datefield.getClient().updateVariable(datefield.getId(), "month",
+ datefield.getCurrentDate().getMonth() + 1,
+ datefield.isImmediate());
+ updateCalendar();
+ } else if (sender == nextMonth) {
+ datefield.getCurrentDate().setMonth(
+ datefield.getCurrentDate().getMonth() + 1);
+ datefield.getClient().updateVariable(datefield.getId(), "month",
+ datefield.getCurrentDate().getMonth() + 1,
+ datefield.isImmediate());
+ updateCalendar();
+ }
+ }
- public void onMouseDown(final Widget sender, int x, int y) {
- if (sender instanceof IEventButton) {
- timer = new Timer() {
- public void run() {
- processClickEvent(sender);
+ private Timer timer;
+
+ public void onMouseDown(final Widget sender, int x, int y) {
+ if (sender instanceof IEventButton) {
+ timer = new Timer() {
+ public void run() {
+ processClickEvent(sender);
+ }
+ };
+ timer.scheduleRepeating(100);
}
- };
- timer.scheduleRepeating(100);
}
- }
- public void onMouseEnter(Widget sender) {
- }
+ public void onMouseEnter(Widget sender) {
+ }
- public void onMouseLeave(Widget sender) {
- if (timer != null)
- timer.cancel();
- }
+ public void onMouseLeave(Widget sender) {
+ if (timer != null)
+ timer.cancel();
+ }
- public void onMouseMove(Widget sender, int x, int y) {
- }
+ public void onMouseMove(Widget sender, int x, int y) {
+ }
- public void onMouseUp(Widget sender, int x, int y) {
- if (timer != null)
- timer.cancel();
- }
+ public void onMouseUp(Widget sender, int x, int y) {
+ if (timer != null)
+ timer.cancel();
+ }
- private class IEventButton extends IButton implements SourcesMouseEvents {
+ private class IEventButton extends IButton implements SourcesMouseEvents {
- private MouseListenerCollection mouseListeners;
+ private MouseListenerCollection mouseListeners;
- public IEventButton() {
- super();
- sinkEvents(Event.FOCUSEVENTS | Event.KEYEVENTS | Event.ONCLICK
- | Event.MOUSEEVENTS);
- }
+ public IEventButton() {
+ super();
+ sinkEvents(Event.FOCUSEVENTS | Event.KEYEVENTS | Event.ONCLICK
+ | Event.MOUSEEVENTS);
+ }
- public void addMouseListener(MouseListener listener) {
- if (mouseListeners == null) {
- mouseListeners = new MouseListenerCollection();
- }
- mouseListeners.add(listener);
- }
+ public void addMouseListener(MouseListener listener) {
+ if (mouseListeners == null) {
+ mouseListeners = new MouseListenerCollection();
+ }
+ mouseListeners.add(listener);
+ }
- public void removeMouseListener(MouseListener listener) {
- if (mouseListeners != null)
- mouseListeners.remove(listener);
- }
+ public void removeMouseListener(MouseListener listener) {
+ if (mouseListeners != null)
+ mouseListeners.remove(listener);
+ }
- public void onBrowserEvent(Event event) {
- super.onBrowserEvent(event);
- switch (DOM.eventGetType(event)) {
- case Event.ONMOUSEDOWN:
- case Event.ONMOUSEUP:
- case Event.ONMOUSEMOVE:
- case Event.ONMOUSEOVER:
- case Event.ONMOUSEOUT:
- if (mouseListeners != null) {
- mouseListeners.fireMouseEvent(this, event);
+ public void onBrowserEvent(Event event) {
+ super.onBrowserEvent(event);
+ switch (DOM.eventGetType(event)) {
+ case Event.ONMOUSEDOWN:
+ case Event.ONMOUSEUP:
+ case Event.ONMOUSEMOVE:
+ case Event.ONMOUSEOVER:
+ case Event.ONMOUSEOUT:
+ if (mouseListeners != null) {
+ mouseListeners.fireMouseEvent(this, event);
+ }
+ break;
+ }
}
- break;
- }
}
- }
- private class DateClickListener implements TableListener {
+ private class DateClickListener implements TableListener {
- private CalendarPanel cal;
+ private CalendarPanel cal;
- public DateClickListener(CalendarPanel panel) {
- cal = panel;
- }
+ public DateClickListener(CalendarPanel panel) {
+ cal = panel;
+ }
- public void onCellClicked(SourcesTableEvents sender, int row, int col) {
- if (sender != cal || row < 2 || row > 7 || !cal.datefield.isEnabled()
- || cal.datefield.isReadonly())
- return;
+ public void onCellClicked(SourcesTableEvents sender, int row, int col) {
+ if (sender != cal || row < 2 || row > 7
+ || !cal.datefield.isEnabled() || cal.datefield.isReadonly())
+ return;
- String text = cal.getText(row, col);
- if (text.equals(" "))
- return;
+ String text = cal.getText(row, col);
+ if (text.equals(" "))
+ return;
- Integer day = new Integer(text);
+ Integer day = new Integer(text);
- Date newDate = new Date(cal.datefield.getCurrentDate().getTime());
- newDate.setDate(day.intValue());
- if (!isEnabledDate(newDate)) {
- return;
- }
- cal.datefield.getCurrentDate().setTime(newDate.getTime());
- cal.datefield.getClient().updateVariable(cal.datefield.getId(), "day",
- cal.datefield.getCurrentDate().getDate(), cal.datefield.isImmediate());
+ Date newDate = new Date(cal.datefield.getCurrentDate().getTime());
+ newDate.setDate(day.intValue());
+ if (!isEnabledDate(newDate)) {
+ return;
+ }
+ cal.datefield.getCurrentDate().setTime(newDate.getTime());
+ cal.datefield.getClient().updateVariable(cal.datefield.getId(),
+ "day", cal.datefield.getCurrentDate().getDate(),
+ cal.datefield.isImmediate());
- updateCalendar();
- }
+ updateCalendar();
+ }
- }
-
- public void setLimits(Date min, Date max) {
- if (min != null) {
- Date d = new Date(min.getTime());
- d.setHours(0);
- d.setMinutes(0);
- d.setSeconds(1);
- this.minDate = d;
- } else {
- this.minDate = null;
}
- if (max != null) {
- Date d = new Date(max.getTime());
- d.setHours(24);
- d.setMinutes(59);
- d.setSeconds(59);
- this.maxDate = d;
- } else {
- this.maxDate = null;
+
+ public void setLimits(Date min, Date max) {
+ if (min != null) {
+ Date d = new Date(min.getTime());
+ d.setHours(0);
+ d.setMinutes(0);
+ d.setSeconds(1);
+ this.minDate = d;
+ } else {
+ this.minDate = null;
+ }
+ if (max != null) {
+ Date d = new Date(max.getTime());
+ d.setHours(24);
+ d.setMinutes(59);
+ d.setSeconds(59);
+ this.maxDate = d;
+ } else {
+ this.maxDate = null;
+ }
}
- }
- public void setCalendarEntrySource(CalendarEntrySource entrySource) {
- this.entrySource = entrySource;
- }
+ public void setCalendarEntrySource(CalendarEntrySource entrySource) {
+ this.entrySource = entrySource;
+ }
- public CalendarEntrySource getCalendarEntrySource() {
- return this.entrySource;
- }
+ public CalendarEntrySource getCalendarEntrySource() {
+ return this.entrySource;
+ }
- public interface CalendarEntrySource {
- public List getEntries(Date date, int resolution);
- }
+ public interface CalendarEntrySource {
+ public List getEntries(Date date, int resolution);
+ }
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ContextMenu.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ContextMenu.java
index f3f1600046..82bbfadffc 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ContextMenu.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ContextMenu.java
@@ -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() {
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/HorizontalSplitPanelImages.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/HorizontalSplitPanelImages.java
index 7069e99c15..bea7940db0 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/HorizontalSplitPanelImages.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/HorizontalSplitPanelImages.java
@@ -4,12 +4,12 @@ import com.google.gwt.user.client.ui.AbstractImagePrototype;
public interface HorizontalSplitPanelImages extends
com.google.gwt.user.client.ui.HorizontalSplitPanelImages {
-
+
/**
- * An image representing the drag thumb.
- *
- * @gwt.resource com/itmill/toolkit/terminal/gwt/public/default/common/img/blank.gif
- */
+ * An image representing the drag thumb.
+ *
+ * @gwt.resource com/itmill/toolkit/terminal/gwt/public/default/common/img/blank.gif
+ */
AbstractImagePrototype horizontalSplitPanelThumb();
-
+
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IButton.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IButton.java
index 2e091f11fa..7d3f4de822 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IButton.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IButton.java
@@ -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 if( errorIndicatorElement != 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();
}
}
-
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ICalendar.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ICalendar.java
index 15eca990a0..dea6ee2d54 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ICalendar.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ICalendar.java
@@ -17,170 +17,170 @@ import com.itmill.toolkit.terminal.gwt.client.UIDL;
public class ICalendar extends IDateField {
- private CalendarPanel calPanel;
-
- private HTMLTable hourTable;
-
- private EntrySource entrySource;
-
- private TableListener ftListener = new HourTableListener();
-
- private int realResolution = RESOLUTION_DAY;
-
- private static final String CLASSNAME = IDateField.CLASSNAME
- + "-entrycalendar";
-
- public ICalendar() {
- super();
- setStyleName(CLASSNAME);
- calPanel = new CalendarPanel(this);
- add(calPanel);
- this.entrySource = new EntrySource();
- calPanel.setCalendarEntrySource(this.entrySource);
- calPanel.addTableListener(new TableListener() {
- public void onCellClicked(SourcesTableEvents sender, int row,
- int cell) {
- buildDayView(date);
- }
- });
- }
-
- public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
- super.updateFromUIDL(uidl, client);
- // We want to draw our own hour list
- this.realResolution = currentResolution;
- this.currentResolution = RESOLUTION_DAY;
- if (uidl.hasAttribute("min")) {
- String mins = uidl.getStringAttribute("min");
- long min = (mins != null ? Long.parseLong(mins) : 0);
- String maxs = uidl.getStringAttribute("max");
- long max = (maxs != null ? Long.parseLong(maxs) : 0);
- Date minDate = (min > 0 ? new Date(min) : null);
- Date maxDate = (max > 0 ? new Date(max) : null);
- calPanel.setLimits(minDate, maxDate);
+ private CalendarPanel calPanel;
+
+ private HTMLTable hourTable;
+
+ private EntrySource entrySource;
+
+ private TableListener ftListener = new HourTableListener();
+
+ private int realResolution = RESOLUTION_DAY;
+
+ private static final String CLASSNAME = IDateField.CLASSNAME
+ + "-entrycalendar";
+
+ public ICalendar() {
+ super();
+ setStyleName(CLASSNAME);
+ calPanel = new CalendarPanel(this);
+ add(calPanel);
+ this.entrySource = new EntrySource();
+ calPanel.setCalendarEntrySource(this.entrySource);
+ calPanel.addTableListener(new TableListener() {
+ public void onCellClicked(SourcesTableEvents sender, int row,
+ int cell) {
+ buildDayView(date);
+ }
+ });
}
- this.entrySource.clear();
- for (Iterator cit = uidl.getChildIterator(); cit.hasNext();) {
- UIDL child = (UIDL) cit.next();
- if (child.getTag().equals("items")) {
- for (Iterator iit = child.getChildIterator(); iit.hasNext();) {
- UIDL item = (UIDL) iit.next();
- this.entrySource.addItem(item);
+
+ public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
+ super.updateFromUIDL(uidl, client);
+ // We want to draw our own hour list
+ this.realResolution = currentResolution;
+ this.currentResolution = RESOLUTION_DAY;
+ if (uidl.hasAttribute("min")) {
+ String mins = uidl.getStringAttribute("min");
+ long min = (mins != null ? Long.parseLong(mins) : 0);
+ String maxs = uidl.getStringAttribute("max");
+ long max = (maxs != null ? Long.parseLong(maxs) : 0);
+ Date minDate = (min > 0 ? new Date(min) : null);
+ Date maxDate = (max > 0 ? new Date(max) : null);
+ calPanel.setLimits(minDate, maxDate);
}
- break;
- }
- }
- calPanel.updateCalendar();
- buildDayView(this.date);
- }
-
- protected void buildDayView(Date date) {
- boolean firstRender = false;
- if (this.hourTable == null) {
- hourTable = new FlexTable();
- firstRender = true;
- hourTable.addTableListener(this.ftListener);
- SimplePanel p = new SimplePanel();
- p.add(hourTable);
- p.setStyleName(CLASSNAME + "-hours");
- this.calPanel.getFlexCellFormatter().setColSpan(8, 0, 7);
- this.calPanel.setWidget(8, 0, p);
- }
- Date curr = new Date(date.getTime());
- for (int i = 0; i < 24; i++) {
- curr.setHours(i);
- String style = (i % 2 == 0 ? "even" : "odd");
- if (realResolution >= RESOLUTION_HOUR) {
- if (this.date != null && this.date.getHours() == i) {
- style = "selected";
+ this.entrySource.clear();
+ for (Iterator cit = uidl.getChildIterator(); cit.hasNext();) {
+ UIDL child = (UIDL) cit.next();
+ if (child.getTag().equals("items")) {
+ for (Iterator iit = child.getChildIterator(); iit.hasNext();) {
+ UIDL item = (UIDL) iit.next();
+ this.entrySource.addItem(item);
+ }
+ break;
+ }
}
- }
- hourTable.getRowFormatter().setStyleName(i,
- CLASSNAME + "-row-" + style);
- if (firstRender) {
- String hstr = (i < 10 ? "0" : "") + i + ":00";
- if (this.dts.isTwelveHourClock()) {
- String ampm = (i < 12 ? "am" : "pm");
- hstr = (i <= 12 ? i : i - 12) + ":00 " + ampm;
+ calPanel.updateCalendar();
+ buildDayView(this.date);
+ }
+
+ protected void buildDayView(Date date) {
+ boolean firstRender = false;
+ if (this.hourTable == null) {
+ hourTable = new FlexTable();
+ firstRender = true;
+ hourTable.addTableListener(this.ftListener);
+ SimplePanel p = new SimplePanel();
+ p.add(hourTable);
+ p.setStyleName(CLASSNAME + "-hours");
+ this.calPanel.getFlexCellFormatter().setColSpan(8, 0, 7);
+ this.calPanel.setWidget(8, 0, p);
}
- hourTable.setHTML(i, 0, "<span>" + hstr + "</span>");
- hourTable.getCellFormatter().setStyleName(i, 0,
- CLASSNAME + "-time");
- }
- List entries = this.entrySource.getEntries(curr,
- DateTimeService.RESOLUTION_HOUR);
- String text = "";
- if (entries != null) {
- for (Iterator it = entries.iterator(); it.hasNext();) {
- CalendarEntry entry = (CalendarEntry) it.next();
- String title = entry.getTitle();
- String desc = entry.getDescription();
- text += (text == "" ? "" : ", ");
- String e = "<span"
- + (desc != null ? " title=\"" + desc + "\"" : "")
- + ">";
- e += (title != null ? title : "?");
- e += "</span>";
- text += e;
+ Date curr = new Date(date.getTime());
+ for (int i = 0; i < 24; i++) {
+ curr.setHours(i);
+ String style = (i % 2 == 0 ? "even" : "odd");
+ if (realResolution >= RESOLUTION_HOUR) {
+ if (this.date != null && this.date.getHours() == i) {
+ style = "selected";
+ }
+ }
+ hourTable.getRowFormatter().setStyleName(i,
+ CLASSNAME + "-row-" + style);
+ if (firstRender) {
+ String hstr = (i < 10 ? "0" : "") + i + ":00";
+ if (this.dts.isTwelveHourClock()) {
+ String ampm = (i < 12 ? "am" : "pm");
+ hstr = (i <= 12 ? i : i - 12) + ":00 " + ampm;
+ }
+ hourTable.setHTML(i, 0, "<span>" + hstr + "</span>");
+ hourTable.getCellFormatter().setStyleName(i, 0,
+ CLASSNAME + "-time");
+ }
+ List entries = this.entrySource.getEntries(curr,
+ DateTimeService.RESOLUTION_HOUR);
+ String text = "";
+ if (entries != null) {
+ for (Iterator it = entries.iterator(); it.hasNext();) {
+ CalendarEntry entry = (CalendarEntry) it.next();
+ String title = entry.getTitle();
+ String desc = entry.getDescription();
+ text += (text == "" ? "" : ", ");
+ String e = "<span"
+ + (desc != null ? " title=\"" + desc + "\"" : "")
+ + ">";
+ e += (title != null ? title : "?");
+ e += "</span>";
+ text += e;
+ }
+ }
+ hourTable.setHTML(i, 1, text);
+ hourTable.getCellFormatter().setStyleName(i, 1,
+ CLASSNAME + "-title");
}
- }
- hourTable.setHTML(i, 1, text);
- hourTable.getCellFormatter().setStyleName(i, 1,
- CLASSNAME + "-title");
+
}
- }
+ private class HourTableListener implements TableListener {
- private class HourTableListener implements TableListener {
+ public void onCellClicked(SourcesTableEvents sender, int row, int cell) {
+ if (realResolution < RESOLUTION_HOUR || date == null) {
+ return;
+ }
+ date.setHours(row);
+ client.updateVariable(id, "hour", row, immediate);
+ }
- public void onCellClicked(SourcesTableEvents sender, int row, int cell) {
- if (realResolution < RESOLUTION_HOUR || date == null) {
- return;
- }
- date.setHours(row);
- client.updateVariable(id, "hour", row, immediate);
}
- }
-
- private class EntrySource implements CalendarPanel.CalendarEntrySource {
-
- private HashMap items = new HashMap();
-
- public void addItem(UIDL item) {
- Integer id = new Integer(item.getIntAttribute("id"));
- long start = Long.parseLong(item.getStringAttribute("start"));
- Date startDate = new Date(start);
- long end = Long.parseLong(item.getStringAttribute("end"));
- Date endDate = (end > 0 && end != start ? new Date(end) : new Date(
- start));
- String title = item.getStringAttribute("title");
- String desc = item.getStringAttribute("description");
- boolean notime = item.getBooleanAttribute("notime");
- if (items.containsKey(id)) {
- items.remove(id);
- }
- items.put(id, new CalendarEntry(startDate, endDate, title, desc,
- notime));
- }
+ private class EntrySource implements CalendarPanel.CalendarEntrySource {
+
+ private HashMap items = new HashMap();
+
+ public void addItem(UIDL item) {
+ Integer id = new Integer(item.getIntAttribute("id"));
+ long start = Long.parseLong(item.getStringAttribute("start"));
+ Date startDate = new Date(start);
+ long end = Long.parseLong(item.getStringAttribute("end"));
+ Date endDate = (end > 0 && end != start ? new Date(end) : new Date(
+ start));
+ String title = item.getStringAttribute("title");
+ String desc = item.getStringAttribute("description");
+ boolean notime = item.getBooleanAttribute("notime");
+ if (items.containsKey(id)) {
+ items.remove(id);
+ }
+ items.put(id, new CalendarEntry(startDate, endDate, title, desc,
+ notime));
+ }
- public List getEntries(Date date, int resolution) {
- ArrayList res = new ArrayList();
- for (Iterator it = this.items.values().iterator(); it.hasNext();) {
- CalendarEntry item = (CalendarEntry) it.next();
- if (DateTimeService.isInRange(date, item.getStart(), item
- .getEnd(), resolution)) {
- res.add(item);
+ public List getEntries(Date date, int resolution) {
+ ArrayList res = new ArrayList();
+ for (Iterator it = this.items.values().iterator(); it.hasNext();) {
+ CalendarEntry item = (CalendarEntry) it.next();
+ if (DateTimeService.isInRange(date, item.getStart(), item
+ .getEnd(), resolution)) {
+ res.add(item);
+ }
+ }
+
+ return res;
}
- }
- return res;
- }
+ public void clear() {
+ items.clear();
+ }
- public void clear() {
- items.clear();
}
- }
-
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ICheckBox.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ICheckBox.java
index 6282c9d5f8..9998eda636 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ICheckBox.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ICheckBox.java
@@ -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;
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ICustomComponent.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ICustomComponent.java
index 322b9359bc..e75adb340d 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ICustomComponent.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ICustomComponent.java
@@ -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();
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ICustomLayout.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ICustomLayout.java
index 29ecf57652..ba143440cf 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ICustomLayout.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ICustomLayout.java
@@ -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;
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IDateField.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IDateField.java
index 43c17e0a54..12635655be 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IDateField.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IDateField.java
@@ -12,13 +12,13 @@ import com.itmill.toolkit.terminal.gwt.client.UIDL;
public class IDateField extends FlowPanel implements Paintable {
public static final String CLASSNAME = "i-datefield";
-
+
String id;
-
+
ApplicationConnection client;
-
+
protected boolean immediate;
-
+
public static int RESOLUTION_YEAR = 0;
public static int RESOLUTION_MONTH = 1;
public static int RESOLUTION_DAY = 2;
@@ -26,24 +26,24 @@ public class IDateField extends FlowPanel implements Paintable {
public static int RESOLUTION_MIN = 4;
public static int RESOLUTION_SEC = 5;
public static int RESOLUTION_MSEC = 6;
-
+
protected int currentResolution = RESOLUTION_YEAR;
-
+
protected String currentLocale;
-
+
protected boolean readonly;
-
+
protected boolean enabled;
-
+
protected Date date = null;
-
+
protected DateTimeService dts;
-
+
public IDateField() {
setStyleName(CLASSNAME);
dts = new DateTimeService();
}
-
+
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
// Ensure correct implementation and let layout manage caption
if (client.updateComponent(this, uidl, true))
@@ -53,11 +53,11 @@ public class IDateField extends FlowPanel implements Paintable {
this.client = client;
this.id = uidl.getId();
this.immediate = uidl.getBooleanAttribute("immediate");
-
+
readonly = uidl.getBooleanAttribute("readonly");
enabled = !uidl.getBooleanAttribute("disabled");
-
- if(uidl.hasAttribute("locale")) {
+
+ if (uidl.hasAttribute("locale")) {
String locale = uidl.getStringAttribute("locale");
try {
dts.setLocale(locale);
@@ -65,47 +65,57 @@ public class IDateField extends FlowPanel implements Paintable {
} catch (LocaleNotLoadedException e) {
currentLocale = dts.getLocale();
// TODO redirect this to console
- System.out.println("Tried to use an unloaded locale \"" + locale + "\". Using default locale (" + currentLocale + ").");
+ System.out.println("Tried to use an unloaded locale \""
+ + locale + "\". Using default locale (" + currentLocale
+ + ").");
}
}
int newResolution;
- if(uidl.hasVariable("msec"))
+ if (uidl.hasVariable("msec"))
newResolution = RESOLUTION_MSEC;
- else if(uidl.hasVariable("sec"))
+ else if (uidl.hasVariable("sec"))
newResolution = RESOLUTION_SEC;
- else if(uidl.hasVariable("min"))
+ else if (uidl.hasVariable("min"))
newResolution = RESOLUTION_MIN;
- else if(uidl.hasVariable("hour"))
+ else if (uidl.hasVariable("hour"))
newResolution = RESOLUTION_HOUR;
- else if(uidl.hasVariable("day"))
+ else if (uidl.hasVariable("day"))
newResolution = RESOLUTION_DAY;
- else if(uidl.hasVariable("month"))
+ else if (uidl.hasVariable("month"))
newResolution = RESOLUTION_MONTH;
else
newResolution = RESOLUTION_YEAR;
-
+
currentResolution = newResolution;
-
+
int year = uidl.getIntVariable("year");
- int month = (currentResolution >= RESOLUTION_MONTH)? uidl.getIntVariable("month") : -1;
- int day = (currentResolution >= RESOLUTION_DAY)? uidl.getIntVariable("day") : -1;
- int hour = (currentResolution >= RESOLUTION_HOUR)? uidl.getIntVariable("hour") : -1;
- int min = (currentResolution >= RESOLUTION_MIN)? uidl.getIntVariable("min") : -1;
- int sec = (currentResolution >= RESOLUTION_SEC)? uidl.getIntVariable("sec") : -1;
- int msec = (currentResolution >= RESOLUTION_MSEC)? uidl.getIntVariable("msec") : -1;
-
+ int month = (currentResolution >= RESOLUTION_MONTH) ? uidl
+ .getIntVariable("month") : -1;
+ int day = (currentResolution >= RESOLUTION_DAY) ? uidl
+ .getIntVariable("day") : -1;
+ int hour = (currentResolution >= RESOLUTION_HOUR) ? uidl
+ .getIntVariable("hour") : -1;
+ int min = (currentResolution >= RESOLUTION_MIN) ? uidl
+ .getIntVariable("min") : -1;
+ int sec = (currentResolution >= RESOLUTION_SEC) ? uidl
+ .getIntVariable("sec") : -1;
+ int msec = (currentResolution >= RESOLUTION_MSEC) ? uidl
+ .getIntVariable("msec") : -1;
+
// Construct new date for this datefield (only if not null)
- if(year > -1)
- date = new Date((long) getTime(year, month, day, hour, min, sec, msec));
-
+ if (year > -1)
+ date = new Date((long) getTime(year, month, day, hour, min, sec,
+ msec));
+
}
-
+
/*
- * We need this redundant native function because
- * Java's Date object doesn't have a setMilliseconds method.
+ * We need this redundant native function because Java's Date object doesn't
+ * have a setMilliseconds method.
*/
- private static native double getTime(int y, int m, int d, int h, int mi, int s, int ms) /*-{
+ private static native double getTime(int y, int m, int d, int h, int mi,
+ int s, int ms) /*-{
try {
var date = new Date();
if(y && y >= 0) date.setFullYear(y);
@@ -122,7 +132,7 @@ public class IDateField extends FlowPanel implements Paintable {
return (new Date()).getTime();
}
}-*/;
-
+
public int getMilliseconds() {
return (int) (date.getTime() - date.getTime() / 1000 * 1000);
}
@@ -132,50 +142,50 @@ public class IDateField extends FlowPanel implements Paintable {
}
public int getCurrentResolution() {
- return currentResolution;
+ return currentResolution;
}
public void setCurrentResolution(int currentResolution) {
- this.currentResolution = currentResolution;
+ this.currentResolution = currentResolution;
}
public String getCurrentLocale() {
- return currentLocale;
+ return currentLocale;
}
public void setCurrentLocale(String currentLocale) {
- this.currentLocale = currentLocale;
+ this.currentLocale = currentLocale;
}
public Date getCurrentDate() {
- return date;
+ return date;
}
public void setCurrentDate(Date date) {
- this.date = date;
+ this.date = date;
}
public boolean isImmediate() {
- return immediate;
+ return immediate;
}
public boolean isReadonly() {
- return readonly;
+ return readonly;
}
public boolean isEnabled() {
- return enabled;
+ return enabled;
}
public DateTimeService getDateTimeService() {
- return dts;
+ return dts;
}
public String getId() {
- return id;
+ return id;
}
public ApplicationConnection getClient() {
- return client;
+ return client;
}
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IDateFieldCalendar.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IDateFieldCalendar.java
index e48f35cd12..276170f990 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IDateFieldCalendar.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IDateFieldCalendar.java
@@ -4,16 +4,16 @@ import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection;
import com.itmill.toolkit.terminal.gwt.client.UIDL;
public class IDateFieldCalendar extends IDateField {
-
+
private CalendarPanel date;
-
+
public IDateFieldCalendar() {
super();
- setStyleName(CLASSNAME+"-calendar");
+ setStyleName(CLASSNAME + "-calendar");
date = new CalendarPanel(this);
add(date);
}
-
+
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
super.updateFromUIDL(uidl, client);
date.updateCalendar();
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IEmbedded.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IEmbedded.java
index ce9a261a5d..b0677746ca 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IEmbedded.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IEmbedded.java
@@ -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");
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IExpandLayout.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IExpandLayout.java
index ecbfcf35a7..953b5efd4d 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IExpandLayout.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IExpandLayout.java
@@ -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);
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IFilterSelect.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IFilterSelect.java
index cd28799e71..03aa883d91 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IFilterSelect.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IFilterSelect.java
@@ -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
*/
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IForm.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IForm.java
index 5d9231efb9..06c93dcfac 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IForm.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IForm.java
@@ -8,26 +8,25 @@ import com.itmill.toolkit.terminal.gwt.client.Paintable;
import com.itmill.toolkit.terminal.gwt.client.UIDL;
public class IForm extends SimplePanel implements Paintable {
-
+
public static final String CLASSNAME = "i-form";
-
- private Container lo;
+
+ private Container lo;
private ApplicationConnection client;
-
+
public IForm() {
super();
setStyleName(CLASSNAME);
}
-
+
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
this.client = client;
UIDL layoutUidl = uidl.getChildUIDL(0);
- if(lo == null) {
+ if (lo == null) {
lo = (Container) client.getWidget(layoutUidl);
setWidget((Widget) lo);
}
lo.updateFromUIDL(layoutUidl, client);
}
}
-
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IFormLayout.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IFormLayout.java
index 400169ffa6..3dfe2ab055 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IFormLayout.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IFormLayout.java
@@ -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);
}
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IGridLayout.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IGridLayout.java
index a3d2a47144..73b5a95e80 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IGridLayout.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IGridLayout.java
@@ -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);
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ILabel.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ILabel.java
index bb204679ef..a3721acabb 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ILabel.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ILabel.java
@@ -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);
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ILink.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ILink.java
index 415a89e423..64653fb0f0 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ILink.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ILink.java
@@ -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);
}
}
-
+
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IOptionGroup.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IOptionGroup.java
index d8d759f814..e7e8e92897 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IOptionGroup.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IOptionGroup.java
@@ -11,28 +11,28 @@ import com.google.gwt.user.client.ui.Widget;
import com.itmill.toolkit.terminal.gwt.client.UIDL;
public class IOptionGroup extends IOptionGroupBase {
-
+
public static final String CLASSNAME = "i-select-optiongroup";
-
+
private Panel panel;
-
+
private Map optionsToKeys;
-
+
public IOptionGroup() {
super(CLASSNAME);
panel = (Panel) optionsContainer;
optionsToKeys = new HashMap();
}
-
+
/*
* Return true if no elements were changed, false otherwise.
*/
protected void buildOptions(UIDL uidl) {
panel.clear();
- for(Iterator it = uidl.getChildIterator(); it.hasNext();) {
+ for (Iterator it = uidl.getChildIterator(); it.hasNext();) {
UIDL opUidl = (UIDL) it.next();
CheckBox op;
- if(multiselect) {
+ if (multiselect) {
op = new ICheckBox();
op.setText(opUidl.getStringAttribute("caption"));
} else {
@@ -41,7 +41,8 @@ public class IOptionGroup extends IOptionGroupBase {
}
op.addStyleName(CLASSNAME_OPTION);
op.setChecked(opUidl.getBooleanAttribute("selected"));
- op.setEnabled(!opUidl.getBooleanAttribute("disabled") && !readonly && !disabled);
+ op.setEnabled(!opUidl.getBooleanAttribute("disabled") && !readonly
+ && !disabled);
op.addClickListener(this);
optionsToKeys.put(op, opUidl.getStringAttribute("key"));
panel.add(op);
@@ -51,16 +52,21 @@ public class IOptionGroup extends IOptionGroupBase {
protected Object[] getSelectedItems() {
return selectedKeys.toArray();
}
-
+
public void onClick(Widget sender) {
super.onClick(sender);
- if(sender instanceof CheckBox) {
+ if (sender instanceof CheckBox) {
boolean selected = ((CheckBox) sender).isChecked();
String key = (String) optionsToKeys.get(sender);
- if(!multiselect) selectedKeys.clear();
- if(selected) selectedKeys.add(key);
- else selectedKeys.remove(key);
- client.updateVariable(id, "selected", getSelectedItems(), immediate);
+ if (!multiselect)
+ selectedKeys.clear();
+ if (selected)
+ selectedKeys.add(key);
+ else
+ selectedKeys.remove(key);
+ client
+ .updateVariable(id, "selected", getSelectedItems(),
+ immediate);
}
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IOptionGroupBase.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IOptionGroupBase.java
index 884a0ccfea..d57f1e7426 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IOptionGroupBase.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IOptionGroupBase.java
@@ -13,40 +13,40 @@ import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection;
import com.itmill.toolkit.terminal.gwt.client.Paintable;
import com.itmill.toolkit.terminal.gwt.client.UIDL;
-abstract class IOptionGroupBase extends Composite implements Paintable, ClickListener, ChangeListener, KeyboardListener {
-
+abstract class IOptionGroupBase extends Composite implements Paintable,
+ ClickListener, ChangeListener, KeyboardListener {
+
public static final String CLASSNAME_OPTION = "i-select-option";
ApplicationConnection client;
-
+
String id;
-
+
protected boolean immediate;
-
+
protected Set selectedKeys;
-
+
protected boolean multiselect;
-
+
protected boolean disabled;
-
+
protected boolean readonly;
-
+
/**
- * Widget holding the different options
- * (e.g. ListBox or Panel for radio buttons)
- * (optional, fallbacks to container Panel)
+ * Widget holding the different options (e.g. ListBox or Panel for radio
+ * buttons) (optional, fallbacks to container Panel)
*/
protected Widget optionsContainer;
-
+
/**
* Panel containing the component
*/
private Panel container;
-
+
private ITextField newItemField;
-
+
private IButton newItemButton;
-
+
public IOptionGroupBase(String classname) {
container = new FlowPanel();
initWidget(container);
@@ -55,36 +55,37 @@ abstract class IOptionGroupBase extends Composite implements Paintable, ClickLis
immediate = false;
multiselect = false;
}
-
- /* Call this if you wish to specify your own container
- * for the option elements (e.g. SELECT)
+
+ /*
+ * Call this if you wish to specify your own container for the option
+ * elements (e.g. SELECT)
*/
public IOptionGroupBase(Widget w, String classname) {
this(classname);
optionsContainer = w;
container.add(optionsContainer);
}
-
+
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
this.client = client;
this.id = uidl.getId();
-
- if(client.updateComponent(this, uidl, true))
+
+ if (client.updateComponent(this, uidl, true))
return;
-
+
selectedKeys = uidl.getStringArrayVariableAsSet("selected");
-
+
readonly = uidl.getBooleanAttribute("readonly");
disabled = uidl.getBooleanAttribute("disabled");
multiselect = "multi".equals(uidl.getStringAttribute("selectmode"));
immediate = uidl.getBooleanAttribute("immediate");
-
+
UIDL ops = uidl.getChildUIDL(0);
-
+
buildOptions(ops);
-
- if(uidl.getBooleanAttribute("allownewitem")) {
- if(newItemField == null) {
+
+ if (uidl.getBooleanAttribute("allownewitem")) {
+ if (newItemField == null) {
newItemButton = new IButton();
newItemButton.setText("+");
newItemButton.addClickListener(this);
@@ -94,53 +95,56 @@ abstract class IOptionGroupBase extends Composite implements Paintable, ClickLis
}
newItemField.setEnabled(!disabled && !readonly);
newItemButton.setEnabled(!disabled && !readonly);
-
- if(newItemField != null && newItemField.getParent() == container)
+
+ if (newItemField != null && newItemField.getParent() == container)
return;
container.add(newItemField);
container.add(newItemButton);
- } else if(newItemField != null) {
+ } else if (newItemField != null) {
container.remove(newItemField);
container.remove(newItemButton);
}
-
+
}
public void onClick(Widget sender) {
- if(sender == newItemButton && !newItemField.getText().equals("")) {
+ if (sender == newItemButton && !newItemField.getText().equals("")) {
client.updateVariable(id, "newitem", newItemField.getText(), true);
newItemField.setText("");
}
}
-
+
public void onChange(Widget sender) {
- if(multiselect) {
- client.updateVariable(id, "selected", getSelectedItems(), immediate);
+ if (multiselect) {
+ client
+ .updateVariable(id, "selected", getSelectedItems(),
+ immediate);
} else {
- client.updateVariable(id, "selected", new String[] { "" + getSelectedItem()}, immediate);
+ client.updateVariable(id, "selected", new String[] { ""
+ + getSelectedItem() }, immediate);
}
}
-
+
public void onKeyPress(Widget sender, char keyCode, int modifiers) {
- if(sender == newItemField && keyCode==KeyboardListener.KEY_ENTER)
+ if (sender == newItemField && keyCode == KeyboardListener.KEY_ENTER)
newItemButton.click();
}
-
+
public void onKeyUp(Widget sender, char keyCode, int modifiers) {
// Ignore, subclasses may override
}
-
+
public void onKeyDown(Widget sender, char keyCode, int modifiers) {
// Ignore, subclasses may override
}
-
+
protected abstract void buildOptions(UIDL uidl);
-
+
protected abstract Object[] getSelectedItems();
-
+
protected Object getSelectedItem() {
Object[] sel = getSelectedItems();
- if(sel.length > 0)
+ if (sel.length > 0)
return sel[0];
else
return null;
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayout.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayout.java
index d7048cd375..bbc5655d01 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayout.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayout.java
@@ -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;
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayoutHorizontal.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayoutHorizontal.java
index df751dfeaa..d323d171b7 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayoutHorizontal.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayoutHorizontal.java
@@ -2,7 +2,7 @@ package com.itmill.toolkit.terminal.gwt.client.ui;
public class IOrderedLayoutHorizontal extends IOrderedLayout {
- public IOrderedLayoutHorizontal() {
- super(ORIENTATION_HORIZONTAL);
- }
+ public IOrderedLayoutHorizontal() {
+ super(ORIENTATION_HORIZONTAL);
+ }
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayoutVertical.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayoutVertical.java
index 19b150b941..10de874f65 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayoutVertical.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IOrderedLayoutVertical.java
@@ -2,7 +2,7 @@ package com.itmill.toolkit.terminal.gwt.client.ui;
public class IOrderedLayoutVertical extends IOrderedLayout {
- public IOrderedLayoutVertical() {
- super(ORIENTATION_VERTICAL);
- }
+ public IOrderedLayoutVertical() {
+ super(ORIENTATION_VERTICAL);
+ }
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IPanel.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IPanel.java
index 1926575903..fb23d8433b 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IPanel.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IPanel.java
@@ -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", "");
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IPasswordField.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IPasswordField.java
index 18ff9304b3..1dd3043f32 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IPasswordField.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IPasswordField.java
@@ -6,12 +6,12 @@ import com.google.gwt.user.client.DOM;
* This class represents a password field.
*
* @author IT Mill Ltd.
- *
+ *
*/
public class IPasswordField extends ITextField {
-
+
public IPasswordField() {
super(DOM.createInputPassword());
}
-
+
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IPopupCalendar.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IPopupCalendar.java
index 62885d6578..8f9e6ecb1a 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IPopupCalendar.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IPopupCalendar.java
@@ -9,56 +9,58 @@ 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 IPopupCalendar extends ITextualDate implements Paintable, ClickListener, PopupListener {
-
+public class IPopupCalendar extends ITextualDate implements Paintable,
+ ClickListener, PopupListener {
+
private IButton calendarToggle;
-
+
private CalendarPanel calendar;
-
+
private PopupPanel popup;
-
+
public IPopupCalendar() {
super();
-
+
calendarToggle = new IButton();
calendarToggle.setText("...");
calendarToggle.addClickListener(this);
add(calendarToggle);
-
+
calendar = new CalendarPanel(this);
popup = new PopupPanel(true);
- popup.setStyleName(IDateField.CLASSNAME+"-calendar");
+ popup.setStyleName(IDateField.CLASSNAME + "-calendar");
popup.setWidget(calendar);
popup.addPopupListener(this);
}
-
+
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
super.updateFromUIDL(uidl, client);
- if(date != null)
+ if (date != null)
calendar.updateCalendar();
calendarToggle.setEnabled(enabled);
}
public void onClick(Widget sender) {
- if(sender == calendarToggle) {
- calendar.updateCalendar();
- popup.show();
- int w = calendar.getOffsetWidth();
- int h = calendar.getOffsetHeight();
- int t = calendarToggle.getAbsoluteTop();
- int l = calendarToggle.getAbsoluteLeft();
- if(l+w > Window.getClientWidth())
- l = Window.getClientWidth() - w;
- if(t+h > Window.getClientHeight())
- t = Window.getClientHeight() - h - calendarToggle.getOffsetHeight() - 2;
- popup.setPopupPosition(l, t + calendarToggle.getOffsetHeight() + 2);
- popup.setWidth(w + "px");
- popup.setHeight(h + "px");
+ if (sender == calendarToggle) {
+ calendar.updateCalendar();
+ popup.show();
+ int w = calendar.getOffsetWidth();
+ int h = calendar.getOffsetHeight();
+ int t = calendarToggle.getAbsoluteTop();
+ int l = calendarToggle.getAbsoluteLeft();
+ if (l + w > Window.getClientWidth())
+ l = Window.getClientWidth() - w;
+ if (t + h > Window.getClientHeight())
+ t = Window.getClientHeight() - h
+ - calendarToggle.getOffsetHeight() - 2;
+ popup.setPopupPosition(l, t + calendarToggle.getOffsetHeight() + 2);
+ popup.setWidth(w + "px");
+ popup.setHeight(h + "px");
}
}
public void onPopupClosed(PopupPanel sender, boolean autoClosed) {
- if(sender == popup)
+ if (sender == popup)
buildDate();
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IProgressIndicator.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IProgressIndicator.java
index d0a5b1c6dc..9c9bedfd9b 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IProgressIndicator.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IProgressIndicator.java
@@ -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();
}
-
+
}
-
+
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IScrollTable.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IScrollTable.java
index 04d6e54452..268cc6d530 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IScrollTable.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IScrollTable.java
@@ -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);
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ISelect.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ISelect.java
index 99d25f75e5..b60b9ccf39 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ISelect.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ISelect.java
@@ -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);
}
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ISplitPanel.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ISplitPanel.java
index c356a6461b..f78d586787 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ISplitPanel.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ISplitPanel.java
@@ -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;
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheet.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheet.java
index 03d4a45598..134fd30064 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheet.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheet.java
@@ -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");
}
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheetPanel.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheetPanel.java
index 7ab01ed121..4c37633e82 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheetPanel.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheetPanel.java
@@ -10,93 +10,97 @@ import com.google.gwt.user.client.ui.Widget;
* {@link com.itmill.toolkit.terminal.gwt.client.ui.ITabsheetPanel}.
*
* This class has the same basic functionality as the GWT DeckPanel
- * {@link com.google.gwt.user.client.ui.DeckPanel}, with the exception
- * that it doesn't manipulate the child widgets' width and height attributes.
+ * {@link com.google.gwt.user.client.ui.DeckPanel}, with the exception that it
+ * doesn't manipulate the child widgets' width and height attributes.
*/
public class ITabsheetPanel extends ComplexPanel {
- private Widget visibleWidget;
+ private Widget visibleWidget;
- /**
- * Creates an empty tabsheet panel.
- */
- public ITabsheetPanel() {
- setElement(DOM.createDiv());
- }
+ /**
+ * Creates an empty tabsheet panel.
+ */
+ public ITabsheetPanel() {
+ setElement(DOM.createDiv());
+ }
- /**
- * Adds the specified widget to the deck.
- *
- * @param w the widget to be added
- */
- public void add(Widget w) {
- super.add(w, getElement());
- initChildWidget(w);
- }
+ /**
+ * Adds the specified widget to the deck.
+ *
+ * @param w
+ * the widget to be added
+ */
+ public void add(Widget w) {
+ super.add(w, getElement());
+ initChildWidget(w);
+ }
- /**
- * Gets the index of the currently-visible widget.
- *
- * @return the visible widget's index
- */
- public int getVisibleWidget() {
- return getWidgetIndex(visibleWidget);
- }
+ /**
+ * Gets the index of the currently-visible widget.
+ *
+ * @return the visible widget's index
+ */
+ public int getVisibleWidget() {
+ return getWidgetIndex(visibleWidget);
+ }
- /**
- * Inserts a widget before the specified index.
- *
- * @param w the widget to be inserted
- * @param beforeIndex the index before which it will be inserted
- * @throws IndexOutOfBoundsException if <code>beforeIndex</code> is out of
- * range
- */
- public void insert(Widget w, int beforeIndex) {
- super.insert(w, getElement(), beforeIndex, true);
- initChildWidget(w);
- }
+ /**
+ * Inserts a widget before the specified index.
+ *
+ * @param w
+ * the widget to be inserted
+ * @param beforeIndex
+ * the index before which it will be inserted
+ * @throws IndexOutOfBoundsException
+ * if <code>beforeIndex</code> is out of range
+ */
+ public void insert(Widget w, int beforeIndex) {
+ super.insert(w, getElement(), beforeIndex, true);
+ initChildWidget(w);
+ }
- public boolean remove(Widget w) {
- boolean removed = super.remove(w);
- if (removed) {
- resetChildWidget(w);
+ public boolean remove(Widget w) {
+ boolean removed = super.remove(w);
+ if (removed) {
+ resetChildWidget(w);
- if (visibleWidget == w) {
- visibleWidget = null;
- }
- }
- return removed;
- }
+ if (visibleWidget == w) {
+ visibleWidget = null;
+ }
+ }
+ return removed;
+ }
- /**
- * Shows the widget at the specified index. This causes the currently- visible
- * widget to be hidden.
- *
- * @param index the index of the widget to be shown
- */
- public void showWidget(int index) {
- checkIndexBoundsForAccess(index);
+ /**
+ * Shows the widget at the specified index. This causes the currently-
+ * visible widget to be hidden.
+ *
+ * @param index
+ * the index of the widget to be shown
+ */
+ public void showWidget(int index) {
+ checkIndexBoundsForAccess(index);
- if (visibleWidget != null) {
- visibleWidget.setVisible(false);
- }
- visibleWidget = getWidget(index);
- visibleWidget.setVisible(true);
- }
+ if (visibleWidget != null) {
+ visibleWidget.setVisible(false);
+ }
+ visibleWidget = getWidget(index);
+ visibleWidget.setVisible(true);
+ }
- /**
- * Make the widget invisible, and set its width and height to full.
- */
- private void initChildWidget(Widget w) {
- w.setVisible(false);
- }
+ /**
+ * Make the widget invisible, and set its width and height to full.
+ */
+ private void initChildWidget(Widget w) {
+ w.setVisible(false);
+ }
- /**
- * Make the widget visible, and clear the widget's width and height
- * attributes. This is done so that any changes to the visibility, height, or
- * width of the widget that were done by the panel are undone.
- */
- private void resetChildWidget(Widget w) {
- w.setVisible(true);
- }
+ /**
+ * Make the widget visible, and clear the widget's width and height
+ * attributes. This is done so that any changes to the visibility, height,
+ * or width of the widget that were done by the panel are undone.
+ */
+ private void resetChildWidget(Widget w) {
+ w.setVisible(true);
+ }
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ITextArea.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ITextArea.java
index 9bcc8bc5ac..69fdd7ce49 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ITextArea.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ITextArea.java
@@ -8,20 +8,20 @@ import com.itmill.toolkit.terminal.gwt.client.UIDL;
* This class represents a multiline textfield (textarea).
*
* @author IT Mill Ltd.
- *
+ *
*/
public class ITextArea extends ITextField {
public ITextArea() {
super(DOM.createTextArea());
}
-
+
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
// Call parent renderer explicitly
super.updateFromUIDL(uidl, client);
-
- if(uidl.hasAttribute("rows"))
+
+ if (uidl.hasAttribute("rows"))
setRows(new Integer(uidl.getStringAttribute("rows")).intValue());
}
-
+
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ITextField.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ITextField.java
index 038777f6f8..cd3c548e0e 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ITextField.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ITextField.java
@@ -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) {}
-}-*/;
+ }-*/;
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ITextualDate.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ITextualDate.java
index 7fe11c2cec..889f74ba98 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ITextualDate.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ITextualDate.java
@@ -1,6 +1,5 @@
package com.itmill.toolkit.terminal.gwt.client.ui;
-
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.ui.ChangeListener;
import com.google.gwt.user.client.ui.Widget;
@@ -10,21 +9,22 @@ import com.itmill.toolkit.terminal.gwt.client.Paintable;
import com.itmill.toolkit.terminal.gwt.client.UIDL;
import com.itmill.toolkit.terminal.gwt.client.util.SimpleDateFormat;
-public class ITextualDate extends IDateField implements Paintable, ChangeListener {
-
+public class ITextualDate extends IDateField implements Paintable,
+ ChangeListener {
+
private ITextField text;
-
+
private SimpleDateFormat format;
-
+
private DateLocale dl;
-
+
public ITextualDate() {
super();
text = new ITextField();
text.addChangeListener(this);
add(text);
}
-
+
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
super.updateFromUIDL(uidl, client);
buildDate();
@@ -33,145 +33,181 @@ public class ITextualDate extends IDateField implements Paintable, ChangeListene
public void buildDate() {
dl = new DateLocale();
DateLocale.setLocale(currentLocale);
-
+
DateLocale.SUPPORTED_DF_TOKENS = DateLocale.TOKENS_RESOLUTION_YEAR;
- if(currentResolution == IDateField.RESOLUTION_MONTH)
+ if (currentResolution == IDateField.RESOLUTION_MONTH)
DateLocale.SUPPORTED_DF_TOKENS = DateLocale.TOKENS_RESOLUTION_MONTH;
- else if(currentResolution >= IDateField.RESOLUTION_DAY)
+ else if (currentResolution >= IDateField.RESOLUTION_DAY)
DateLocale.SUPPORTED_DF_TOKENS = DateLocale.TOKENS_RESOLUTION_DAY;
-
+
format = new SimpleDateFormat(cleanFormat(dts.getDateFormat()));
format.setLocale(dl);
-
+
// Size the textfield a bit smaller if no clock time is needed
- if(currentResolution <= IDateField.RESOLUTION_DAY)
+ if (currentResolution <= IDateField.RESOLUTION_DAY)
text.setColumns(12);
-
+
// Create the initial text for the textfield
String dateText = "";
- if(date != null) {
+ if (date != null) {
dateText = format.format(date);
-
- if(currentResolution >= IDateField.RESOLUTION_HOUR) {
+
+ if (currentResolution >= IDateField.RESOLUTION_HOUR) {
DateLocale.SUPPORTED_DF_TOKENS = DateLocale.TOKENS_RESOLUTION_ALL;
int h = date.getHours();
- if(h > 11 && dts.isTwelveHourClock())
+ if (h > 11 && dts.isTwelveHourClock())
h -= 12;
- int m = currentResolution > IDateField.RESOLUTION_HOUR? date.getMinutes() : 0;
- dateText += " " + (h<10?"0"+h:""+h) + dts.getClockDelimeter() + (m<10?"0"+m:""+m);
+ int m = currentResolution > IDateField.RESOLUTION_HOUR ? date
+ .getMinutes() : 0;
+ dateText += " " + (h < 10 ? "0" + h : "" + h)
+ + dts.getClockDelimeter() + (m < 10 ? "0" + m : "" + m);
}
- if(currentResolution >= IDateField.RESOLUTION_SEC) {
+ if (currentResolution >= IDateField.RESOLUTION_SEC) {
int s = date.getSeconds();
- dateText += dts.getClockDelimeter() + (s<10?"0"+s:""+s);
+ dateText += dts.getClockDelimeter()
+ + (s < 10 ? "0" + s : "" + s);
}
- if(currentResolution == IDateField.RESOLUTION_MSEC) {
+ if (currentResolution == IDateField.RESOLUTION_MSEC) {
int ms = getMilliseconds();
- String text = ""+ms;
- if(ms<10) text = "00"+text;
- else if(ms<100) text = "0"+text;
+ String text = "" + ms;
+ if (ms < 10)
+ text = "00" + text;
+ else if (ms < 100)
+ text = "0" + text;
dateText += "." + text;
}
- if(currentResolution >= IDateField.RESOLUTION_HOUR && dts.isTwelveHourClock())
- dateText += " " + (date.getHours()<12? dts.getAmPmStrings()[0] : dts.getAmPmStrings()[1]);
+ if (currentResolution >= IDateField.RESOLUTION_HOUR
+ && dts.isTwelveHourClock())
+ dateText += " "
+ + (date.getHours() < 12 ? dts.getAmPmStrings()[0] : dts
+ .getAmPmStrings()[1]);
}
-
+
text.setText(dateText);
- text.setEnabled(enabled&&!readonly);
-
- if(readonly)
+ text.setEnabled(enabled && !readonly);
+
+ if (readonly)
text.addStyleName("i-readonly");
else
text.removeStyleName("i-readonly");
}
public void onChange(Widget sender) {
- if(sender == text) {
- if(!text.getText().equals("")) {
+ if (sender == text) {
+ if (!text.getText().equals("")) {
DateLocale.SUPPORTED_DF_TOKENS = DateLocale.TOKENS_RESOLUTION_ALL;
- if(currentResolution == IDateField.RESOLUTION_YEAR)
+ if (currentResolution == IDateField.RESOLUTION_YEAR)
DateLocale.SUPPORTED_DF_TOKENS = DateLocale.TOKENS_RESOLUTION_YEAR;
- else if(currentResolution == IDateField.RESOLUTION_MONTH)
+ else if (currentResolution == IDateField.RESOLUTION_MONTH)
DateLocale.SUPPORTED_DF_TOKENS = DateLocale.TOKENS_RESOLUTION_MONTH;
- else if(currentResolution == IDateField.RESOLUTION_DAY)
+ else if (currentResolution == IDateField.RESOLUTION_DAY)
DateLocale.SUPPORTED_DF_TOKENS = DateLocale.TOKENS_RESOLUTION_DAY;
-
+
String f = cleanFormat(dts.getDateFormat());
-
- if(currentResolution >= IDateField.RESOLUTION_HOUR)
- f += " " + (dts.isTwelveHourClock()?
- DateLocale.TOKEN_HOUR_12 + DateLocale.TOKEN_HOUR_12
- : DateLocale.TOKEN_HOUR_24 + DateLocale.TOKEN_HOUR_24)
- + dts.getClockDelimeter() + DateLocale.TOKEN_MINUTE + DateLocale.TOKEN_MINUTE;
- if(currentResolution >= IDateField.RESOLUTION_SEC)
- f += dts.getClockDelimeter() + DateLocale.TOKEN_SECOND + DateLocale.TOKEN_SECOND;
- if(currentResolution == IDateField.RESOLUTION_MSEC)
- f += "." + DateLocale.TOKEN_MILLISECOND + DateLocale.TOKEN_MILLISECOND + DateLocale.TOKEN_MILLISECOND;
- if(currentResolution >= IDateField.RESOLUTION_HOUR && dts.isTwelveHourClock())
+
+ if (currentResolution >= IDateField.RESOLUTION_HOUR)
+ f += " "
+ + (dts.isTwelveHourClock() ? DateLocale.TOKEN_HOUR_12
+ + DateLocale.TOKEN_HOUR_12
+ : DateLocale.TOKEN_HOUR_24
+ + DateLocale.TOKEN_HOUR_24)
+ + dts.getClockDelimeter() + DateLocale.TOKEN_MINUTE
+ + DateLocale.TOKEN_MINUTE;
+ if (currentResolution >= IDateField.RESOLUTION_SEC)
+ f += dts.getClockDelimeter() + DateLocale.TOKEN_SECOND
+ + DateLocale.TOKEN_SECOND;
+ if (currentResolution == IDateField.RESOLUTION_MSEC)
+ f += "." + DateLocale.TOKEN_MILLISECOND
+ + DateLocale.TOKEN_MILLISECOND
+ + DateLocale.TOKEN_MILLISECOND;
+ if (currentResolution >= IDateField.RESOLUTION_HOUR
+ && dts.isTwelveHourClock())
f += " " + DateLocale.TOKEN_AM_PM;
-
+
format = new SimpleDateFormat(f);
DateLocale.setLocale(currentLocale);
format.setLocale(dl);
-
+
try {
date = format.parse(text.getText());
} catch (Exception e) {
ApplicationConnection.getConsole().log(e.getMessage());
- text.addStyleName(ITextField.CLASSNAME+"-error");
+ text.addStyleName(ITextField.CLASSNAME + "-error");
Timer t = new Timer() {
public void run() {
- text.removeStyleName(ITextField.CLASSNAME+"-error");
+ text.removeStyleName(ITextField.CLASSNAME
+ + "-error");
}
};
t.schedule(2000);
return;
}
-
+
} else
date = null;
-
+
// Update variables
// (only the smallest defining resolution needs to be immediate)
- client.updateVariable(id, "year", date!=null?date.getYear()+1900:-1, currentResolution==IDateField.RESOLUTION_YEAR&&immediate);
- if(currentResolution >= IDateField.RESOLUTION_MONTH)
- client.updateVariable(id, "month", date!=null?date.getMonth()+1:-1, currentResolution==IDateField.RESOLUTION_MONTH&&immediate);
- if(currentResolution >= IDateField.RESOLUTION_DAY)
- client.updateVariable(id, "day", date!=null?date.getDate():-1, currentResolution==IDateField.RESOLUTION_DAY&&immediate);
- if(currentResolution >= IDateField.RESOLUTION_HOUR)
- client.updateVariable(id, "hour", date!=null?date.getHours():-1, currentResolution==IDateField.RESOLUTION_HOUR&&immediate);
- if(currentResolution >= IDateField.RESOLUTION_MIN)
- client.updateVariable(id, "min", date!=null?date.getMinutes():-1, currentResolution==IDateField.RESOLUTION_MIN&&immediate);
- if(currentResolution >= IDateField.RESOLUTION_SEC)
- client.updateVariable(id, "sec", date!=null?date.getSeconds():-1, currentResolution==IDateField.RESOLUTION_SEC&&immediate);
- if(currentResolution == IDateField.RESOLUTION_MSEC)
- client.updateVariable(id, "msec", date!=null?getMilliseconds():-1, immediate);
-
+ client.updateVariable(id, "year",
+ date != null ? date.getYear() + 1900 : -1,
+ currentResolution == IDateField.RESOLUTION_YEAR
+ && immediate);
+ if (currentResolution >= IDateField.RESOLUTION_MONTH)
+ client.updateVariable(id, "month", date != null ? date
+ .getMonth() + 1 : -1,
+ currentResolution == IDateField.RESOLUTION_MONTH
+ && immediate);
+ if (currentResolution >= IDateField.RESOLUTION_DAY)
+ client.updateVariable(id, "day", date != null ? date.getDate()
+ : -1, currentResolution == IDateField.RESOLUTION_DAY
+ && immediate);
+ if (currentResolution >= IDateField.RESOLUTION_HOUR)
+ client.updateVariable(id, "hour", date != null ? date
+ .getHours() : -1,
+ currentResolution == IDateField.RESOLUTION_HOUR
+ && immediate);
+ if (currentResolution >= IDateField.RESOLUTION_MIN)
+ client.updateVariable(id, "min", date != null ? date
+ .getMinutes() : -1,
+ currentResolution == IDateField.RESOLUTION_MIN
+ && immediate);
+ if (currentResolution >= IDateField.RESOLUTION_SEC)
+ client.updateVariable(id, "sec", date != null ? date
+ .getSeconds() : -1,
+ currentResolution == IDateField.RESOLUTION_SEC
+ && immediate);
+ if (currentResolution == IDateField.RESOLUTION_MSEC)
+ client.updateVariable(id, "msec",
+ date != null ? getMilliseconds() : -1, immediate);
+
buildDate();
}
}
-
+
private String cleanFormat(String format) {
// Remove unnecessary d & M if resolution is too low
- if(currentResolution < IDateField.RESOLUTION_DAY)
+ if (currentResolution < IDateField.RESOLUTION_DAY)
format = format.replaceAll("d", "");
- if(currentResolution < IDateField.RESOLUTION_MONTH)
+ if (currentResolution < IDateField.RESOLUTION_MONTH)
format = format.replaceAll("M", "");
-
+
// Remove unsupported patterns
// TODO support for 'G', era designator (used at least in Japan)
format = format.replaceAll("[GzZwWkK]", "");
-
+
// Remove extra delimiters ('/' and '.')
- while(format.startsWith("/") || format.startsWith(".") || format.startsWith("-"))
+ while (format.startsWith("/") || format.startsWith(".")
+ || format.startsWith("-"))
format = format.substring(1);
- while(format.endsWith("/") || format.endsWith(".") || format.endsWith("-"))
- format = format.substring(0, format.length()-1);
-
+ while (format.endsWith("/") || format.endsWith(".")
+ || format.endsWith("-"))
+ format = format.substring(0, format.length() - 1);
+
// Remove duplicate delimiters
format = format.replaceAll("//", "/");
format = format.replaceAll("\\.\\.", ".");
format = format.replaceAll("--", "-");
-
+
return format.trim();
}
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ITwinColSelect.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ITwinColSelect.java
index b710b00b63..be8763e2f2 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ITwinColSelect.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ITwinColSelect.java
@@ -11,40 +11,40 @@ import com.google.gwt.user.client.ui.Widget;
import com.itmill.toolkit.terminal.gwt.client.UIDL;
public class ITwinColSelect extends IOptionGroupBase {
-
+
private static final String CLASSNAME = "i-select-twincol";
-
+
private static final int VISIBLE_COUNT = 10;
-
+
private ListBox options;
-
+
private ListBox selections;
-
+
private IButton add;
-
+
private IButton remove;
-
+
public ITwinColSelect() {
super(CLASSNAME);
options = new ListBox();
selections = new ListBox();
options.setVisibleItemCount(VISIBLE_COUNT);
selections.setVisibleItemCount(VISIBLE_COUNT);
- options.setStyleName(CLASSNAME+"-options");
- selections.setStyleName(CLASSNAME+"-selections");
+ options.setStyleName(CLASSNAME + "-options");
+ selections.setStyleName(CLASSNAME + "-selections");
Panel buttons = new FlowPanel();
- buttons.setStyleName(CLASSNAME+"-buttons");
+ buttons.setStyleName(CLASSNAME + "-buttons");
add = new IButton();
remove = new IButton();
add.setText(">>");
remove.setText("<<");
add.addClickListener(this);
remove.addClickListener(this);
- Panel p = ((Panel)optionsContainer);
+ Panel p = ((Panel) optionsContainer);
p.add(options);
buttons.add(add);
HTML br = new HTML("&nbsp;");
- br.setStyleName(CLASSNAME+"-deco");
+ br.setStyleName(CLASSNAME + "-deco");
buttons.add(br);
buttons.add(remove);
p.add(buttons);
@@ -62,53 +62,55 @@ public class ITwinColSelect extends IOptionGroupBase {
options.clear();
selections.clear();
for (Iterator i = uidl.getChildIterator(); i.hasNext();) {
- UIDL optionUidl = (UIDL)i.next();
- if(optionUidl.hasAttribute("selected")) {
- selections.addItem(optionUidl.getStringAttribute("caption"), optionUidl.getStringAttribute("key"));
+ UIDL optionUidl = (UIDL) i.next();
+ if (optionUidl.hasAttribute("selected")) {
+ selections.addItem(optionUidl.getStringAttribute("caption"),
+ optionUidl.getStringAttribute("key"));
} else
- options.addItem(optionUidl.getStringAttribute("caption"), optionUidl.getStringAttribute("key"));
+ options.addItem(optionUidl.getStringAttribute("caption"),
+ optionUidl.getStringAttribute("key"));
}
}
protected Object[] getSelectedItems() {
Vector selectedItemKeys = new Vector();
- for(int i = 0; i < selections.getItemCount(); i++) {
+ for (int i = 0; i < selections.getItemCount(); i++) {
selectedItemKeys.add(selections.getValue(i));
}
return selectedItemKeys.toArray();
}
-
+
private boolean[] getItemsToAdd() {
boolean[] selectedIndexes = new boolean[options.getItemCount()];
- for(int i = 0; i < options.getItemCount(); i++) {
- if(options.isItemSelected(i))
+ for (int i = 0; i < options.getItemCount(); i++) {
+ if (options.isItemSelected(i))
selectedIndexes[i] = true;
else
selectedIndexes[i] = false;
}
return selectedIndexes;
}
-
+
private boolean[] getItemsToRemove() {
boolean[] selectedIndexes = new boolean[selections.getItemCount()];
- for(int i = 0; i < selections.getItemCount(); i++) {
- if(selections.isItemSelected(i))
+ for (int i = 0; i < selections.getItemCount(); i++) {
+ if (selections.isItemSelected(i))
selectedIndexes[i] = true;
else
selectedIndexes[i] = false;
}
return selectedIndexes;
}
-
+
public void onClick(Widget sender) {
super.onClick(sender);
- if(sender == add) {
+ if (sender == add) {
boolean[] sel = getItemsToAdd();
- for(int i=0; i < sel.length; i++) {
- if(sel[i]) {
- int optionIndex = i-(sel.length-options.getItemCount());
+ for (int i = 0; i < sel.length; i++) {
+ if (sel[i]) {
+ int optionIndex = i - (sel.length - options.getItemCount());
selectedKeys.add(options.getValue(optionIndex));
-
+
// Move selection to another column
String text = options.getItemText(optionIndex);
String value = options.getValue(optionIndex);
@@ -116,15 +118,17 @@ public class ITwinColSelect extends IOptionGroupBase {
options.removeItem(optionIndex);
}
}
- client.updateVariable(id, "selected", selectedKeys.toArray(), immediate);
-
- } else if(sender == remove) {
+ client.updateVariable(id, "selected", selectedKeys.toArray(),
+ immediate);
+
+ } else if (sender == remove) {
boolean[] sel = getItemsToRemove();
- for(int i=0; i < sel.length; i++) {
- if(sel[i]) {
- int selectionIndex = i-(sel.length-selections.getItemCount());
+ for (int i = 0; i < sel.length; i++) {
+ if (sel[i]) {
+ int selectionIndex = i
+ - (sel.length - selections.getItemCount());
selectedKeys.remove(selections.getValue(selectionIndex));
-
+
// Move selection to another column
String text = selections.getItemText(selectionIndex);
String value = selections.getValue(selectionIndex);
@@ -132,7 +136,8 @@ public class ITwinColSelect extends IOptionGroupBase {
selections.removeItem(selectionIndex);
}
}
- client.updateVariable(id, "selected", selectedKeys.toArray(), immediate);
+ client.updateVariable(id, "selected", selectedKeys.toArray(),
+ immediate);
}
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IUnknownComponent.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IUnknownComponent.java
index b9d6b55082..6263c1abeb 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IUnknownComponent.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IUnknownComponent.java
@@ -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);
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IUpload.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IUpload.java
index b43293cdc1..f31f33c3e5 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IUpload.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IUpload.java
@@ -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);
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IView.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IView.java
index d06f40e6f8..8cca2b6dce 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IView.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IView.java
@@ -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
}
}
-
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IWindow.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IWindow.java
index 98626adcfb..ce26267062 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IWindow.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IWindow.java
@@ -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);
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/MenuBar.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/MenuBar.java
index d204284bd9..47dddb68fa 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/MenuBar.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/MenuBar.java
@@ -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));
+ }
+ }
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/MenuItem.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/MenuItem.java
index 49d3348f5b..295c17e41e 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/MenuItem.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/MenuItem.java
@@ -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);
+ }
+ }
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/Time.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/Time.java
index fae1143600..04cb796d37 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/Time.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/Time.java
@@ -6,223 +6,242 @@ import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.Widget;
public class Time extends FlowPanel implements ChangeListener {
-
+
private IDateField datefield;
-
+
private ListBox hours;
-
+
private ListBox mins;
-
+
private ListBox sec;
-
+
private ListBox msec;
-
+
private ListBox ampm;
-
+
private int resolution = IDateField.RESOLUTION_HOUR;
-
+
private boolean readonly;
-
+
public Time(IDateField parent) {
super();
datefield = parent;
- setStyleName(IDateField.CLASSNAME+"-time");
+ setStyleName(IDateField.CLASSNAME + "-time");
}
-
+
private void buildTime(boolean redraw) {
boolean thc = datefield.getDateTimeService().isTwelveHourClock();
- if(redraw) {
+ if (redraw) {
clear();
- int numHours = thc?12:24;
+ int numHours = thc ? 12 : 24;
hours = new ListBox();
hours.setStyleName(ISelect.CLASSNAME);
- for(int i=0; i<numHours; i++)
- hours.addItem((i<10)?"0"+i:""+i);
+ for (int i = 0; i < numHours; i++)
+ hours.addItem((i < 10) ? "0" + i : "" + i);
hours.addChangeListener(this);
- if(thc) {
+ if (thc) {
ampm = new ListBox();
ampm.setStyleName(ISelect.CLASSNAME);
- String[] ampmText = datefield.getDateTimeService().getAmPmStrings();
+ String[] ampmText = datefield.getDateTimeService()
+ .getAmPmStrings();
ampm.addItem(ampmText[0]);
ampm.addItem(ampmText[1]);
ampm.addChangeListener(this);
}
-
- if(datefield.getCurrentResolution() >= IDateField.RESOLUTION_MIN) {
+
+ if (datefield.getCurrentResolution() >= IDateField.RESOLUTION_MIN) {
mins = new ListBox();
mins.setStyleName(ISelect.CLASSNAME);
- for(int i=0; i<60; i++)
- mins.addItem((i<10)?"0"+i:""+i);
+ for (int i = 0; i < 60; i++)
+ mins.addItem((i < 10) ? "0" + i : "" + i);
mins.addChangeListener(this);
}
- if(datefield.getCurrentResolution() >= IDateField.RESOLUTION_SEC) {
+ if (datefield.getCurrentResolution() >= IDateField.RESOLUTION_SEC) {
sec = new ListBox();
sec.setStyleName(ISelect.CLASSNAME);
- for(int i=0; i<60; i++)
- sec.addItem((i<10)?"0"+i:""+i);
+ for (int i = 0; i < 60; i++)
+ sec.addItem((i < 10) ? "0" + i : "" + i);
sec.addChangeListener(this);
}
- if(datefield.getCurrentResolution() == IDateField.RESOLUTION_MSEC) {
+ if (datefield.getCurrentResolution() == IDateField.RESOLUTION_MSEC) {
msec = new ListBox();
msec.setStyleName(ISelect.CLASSNAME);
- for(int i=0; i<1000; i++) {
- if(i<10)
- msec.addItem("00"+i);
- else if(i<100)
- msec.addItem("0"+i);
- else msec.addItem(""+i);
+ for (int i = 0; i < 1000; i++) {
+ if (i < 10)
+ msec.addItem("00" + i);
+ else if (i < 100)
+ msec.addItem("0" + i);
+ else
+ msec.addItem("" + i);
}
msec.addChangeListener(this);
}
-
- String delimiter = datefield.getDateTimeService().getClockDelimeter();
+
+ String delimiter = datefield.getDateTimeService()
+ .getClockDelimeter();
boolean ro = datefield.isReadonly();
-
- if(ro) {
+
+ if (ro) {
int h = 0;
- if(datefield.getCurrentDate() != null)
+ if (datefield.getCurrentDate() != null)
h = datefield.getCurrentDate().getHours();
- if(thc) h -= h<12? 0 : 12;
- add(new ILabel(h<10? "0"+h : ""+h));
- } else add(hours);
-
- if(datefield.getCurrentResolution() >= IDateField.RESOLUTION_MIN) {
+ if (thc)
+ h -= h < 12 ? 0 : 12;
+ add(new ILabel(h < 10 ? "0" + h : "" + h));
+ } else
+ add(hours);
+
+ if (datefield.getCurrentResolution() >= IDateField.RESOLUTION_MIN) {
add(new ILabel(delimiter));
- if(ro) {
+ if (ro) {
int m = mins.getSelectedIndex();
- add(new ILabel(m<10? "0"+m : ""+m));
- }
- else add(mins);
+ add(new ILabel(m < 10 ? "0" + m : "" + m));
+ } else
+ add(mins);
}
- if(datefield.getCurrentResolution() >= IDateField.RESOLUTION_SEC) {
+ if (datefield.getCurrentResolution() >= IDateField.RESOLUTION_SEC) {
add(new ILabel(delimiter));
- if(ro) {
+ if (ro) {
int s = sec.getSelectedIndex();
- add(new ILabel(s<10? "0"+s : ""+s));
- }
- else add(sec);
+ add(new ILabel(s < 10 ? "0" + s : "" + s));
+ } else
+ add(sec);
}
- if(datefield.getCurrentResolution() == IDateField.RESOLUTION_MSEC) {
+ if (datefield.getCurrentResolution() == IDateField.RESOLUTION_MSEC) {
add(new ILabel("."));
- if(ro) {
+ if (ro) {
int m = datefield.getMilliseconds();
- String ms = m<100? "0"+m : ""+m;
- add(new ILabel(m<10? "0"+ms : ms));
- }
- else add(msec);
+ String ms = m < 100 ? "0" + m : "" + m;
+ add(new ILabel(m < 10 ? "0" + ms : ms));
+ } else
+ add(msec);
}
- if(datefield.getCurrentResolution() == IDateField.RESOLUTION_HOUR) {
- add(new ILabel(delimiter+"00")); // o'clock
+ if (datefield.getCurrentResolution() == IDateField.RESOLUTION_HOUR) {
+ add(new ILabel(delimiter + "00")); // o'clock
}
- if(thc) {
+ if (thc) {
add(new ILabel("&nbsp;"));
- if(ro) add(new ILabel(ampm.getItemText(datefield.getCurrentDate().getHours()<12? 0 : 1)));
- else add(ampm);
+ if (ro)
+ add(new ILabel(ampm.getItemText(datefield.getCurrentDate()
+ .getHours() < 12 ? 0 : 1)));
+ else
+ add(ampm);
}
-
- if(ro) return;
+
+ if (ro)
+ return;
}
-
+
// Update times
- if(thc) {
+ if (thc) {
int h = datefield.getCurrentDate().getHours();
- ampm.setSelectedIndex(h<12? 0 : 1);
- h -= ampm.getSelectedIndex()*12;
+ ampm.setSelectedIndex(h < 12 ? 0 : 1);
+ h -= ampm.getSelectedIndex() * 12;
hours.setSelectedIndex(h);
} else
hours.setSelectedIndex(datefield.getCurrentDate().getHours());
- if(datefield.getCurrentResolution() >= IDateField.RESOLUTION_MIN)
+ if (datefield.getCurrentResolution() >= IDateField.RESOLUTION_MIN)
mins.setSelectedIndex(datefield.getCurrentDate().getMinutes());
- if(datefield.getCurrentResolution() >= IDateField.RESOLUTION_SEC)
+ if (datefield.getCurrentResolution() >= IDateField.RESOLUTION_SEC)
sec.setSelectedIndex(datefield.getCurrentDate().getSeconds());
- if(datefield.getCurrentResolution() == IDateField.RESOLUTION_MSEC)
+ if (datefield.getCurrentResolution() == IDateField.RESOLUTION_MSEC)
msec.setSelectedIndex(datefield.getMilliseconds());
- if(thc)
- ampm.setSelectedIndex(datefield.getCurrentDate().getHours()<12?0:1);
-
- if(datefield.isReadonly() && !redraw) {
+ if (thc)
+ ampm
+ .setSelectedIndex(datefield.getCurrentDate().getHours() < 12 ? 0
+ : 1);
+
+ if (datefield.isReadonly() && !redraw) {
// Do complete redraw when in read-only status
clear();
- String delimiter = datefield.getDateTimeService().getClockDelimeter();
-
+ String delimiter = datefield.getDateTimeService()
+ .getClockDelimeter();
+
int h = datefield.getCurrentDate().getHours();
- if(thc) h -= h<12? 0 : 12;
- add(new ILabel(h<10? "0"+h : ""+h));
-
- if(datefield.getCurrentResolution() >= IDateField.RESOLUTION_MIN) {
+ if (thc)
+ h -= h < 12 ? 0 : 12;
+ add(new ILabel(h < 10 ? "0" + h : "" + h));
+
+ if (datefield.getCurrentResolution() >= IDateField.RESOLUTION_MIN) {
add(new ILabel(delimiter));
int m = mins.getSelectedIndex();
- add(new ILabel(m<10? "0"+m : ""+m));
+ add(new ILabel(m < 10 ? "0" + m : "" + m));
}
- if(datefield.getCurrentResolution() >= IDateField.RESOLUTION_SEC) {
+ if (datefield.getCurrentResolution() >= IDateField.RESOLUTION_SEC) {
add(new ILabel(delimiter));
int s = sec.getSelectedIndex();
- add(new ILabel(s<10? "0"+s : ""+s));
+ add(new ILabel(s < 10 ? "0" + s : "" + s));
}
- if(datefield.getCurrentResolution() == IDateField.RESOLUTION_MSEC) {
+ if (datefield.getCurrentResolution() == IDateField.RESOLUTION_MSEC) {
add(new ILabel("."));
int m = datefield.getMilliseconds();
- String ms = m<100? "0"+m : ""+m;
- add(new ILabel(m<10? "0"+ms : ms));
+ String ms = m < 100 ? "0" + m : "" + m;
+ add(new ILabel(m < 10 ? "0" + ms : ms));
}
- if(datefield.getCurrentResolution() == IDateField.RESOLUTION_HOUR) {
- add(new ILabel(delimiter+"00")); // o'clock
+ if (datefield.getCurrentResolution() == IDateField.RESOLUTION_HOUR) {
+ add(new ILabel(delimiter + "00")); // o'clock
}
- if(thc) {
+ if (thc) {
add(new ILabel("&nbsp;"));
- add(new ILabel(ampm.getItemText(datefield.getCurrentDate().getHours()<12? 0 : 1)));
+ add(new ILabel(ampm.getItemText(datefield.getCurrentDate()
+ .getHours() < 12 ? 0 : 1)));
}
}
-
+
boolean enabled = datefield.isEnabled();
hours.setEnabled(enabled);
- if(mins != null) mins.setEnabled(enabled);
- if(sec != null) sec.setEnabled(enabled);
- if(msec != null) msec.setEnabled(enabled);
- if(ampm != null) ampm.setEnabled(enabled);
-
+ if (mins != null)
+ mins.setEnabled(enabled);
+ if (sec != null)
+ sec.setEnabled(enabled);
+ if (msec != null)
+ msec.setEnabled(enabled);
+ if (ampm != null)
+ ampm.setEnabled(enabled);
+
}
public void updateTime(boolean redraw) {
- buildTime(redraw || resolution != datefield.getCurrentResolution()
- || readonly != datefield.isReadonly());
- if(datefield instanceof ITextualDate)
+ buildTime(redraw || resolution != datefield.getCurrentResolution()
+ || readonly != datefield.isReadonly());
+ if (datefield instanceof ITextualDate)
((ITextualDate) datefield).buildDate();
resolution = datefield.getCurrentResolution();
readonly = datefield.isReadonly();
}
public void onChange(Widget sender) {
- if(sender == hours) {
+ if (sender == hours) {
int h = hours.getSelectedIndex();
- if(datefield.getDateTimeService().isTwelveHourClock())
- h = h + ampm.getSelectedIndex()*12;
+ if (datefield.getDateTimeService().isTwelveHourClock())
+ h = h + ampm.getSelectedIndex() * 12;
datefield.getCurrentDate().setHours(h);
- datefield.getClient().updateVariable(datefield.getId(), "hour", h, datefield.isImmediate());
+ datefield.getClient().updateVariable(datefield.getId(), "hour", h,
+ datefield.isImmediate());
updateTime(false);
- }
- else if(sender == mins) {
+ } else if (sender == mins) {
int m = mins.getSelectedIndex();
datefield.getCurrentDate().setMinutes(m);
- datefield.getClient().updateVariable(datefield.getId(), "min", m, datefield.isImmediate());
+ datefield.getClient().updateVariable(datefield.getId(), "min", m,
+ datefield.isImmediate());
updateTime(false);
- }
- else if(sender == sec) {
+ } else if (sender == sec) {
int s = sec.getSelectedIndex();
datefield.getCurrentDate().setSeconds(s);
- datefield.getClient().updateVariable(datefield.getId(), "sec", s, datefield.isImmediate());
+ datefield.getClient().updateVariable(datefield.getId(), "sec", s,
+ datefield.isImmediate());
updateTime(false);
- }
- else if(sender == msec) {
+ } else if (sender == msec) {
int ms = msec.getSelectedIndex();
datefield.setMilliseconds(ms);
- datefield.getClient().updateVariable(datefield.getId(), "msec", ms, datefield.isImmediate());
+ datefield.getClient().updateVariable(datefield.getId(), "msec", ms,
+ datefield.isImmediate());
updateTime(false);
- }
- else if(sender == ampm) {
- int h = hours.getSelectedIndex() + ampm.getSelectedIndex()*12;
+ } else if (sender == ampm) {
+ int h = hours.getSelectedIndex() + ampm.getSelectedIndex() * 12;
datefield.getCurrentDate().setHours(h);
- datefield.getClient().updateVariable(datefield.getId(), "hour", h, datefield.isImmediate());
+ datefield.getClient().updateVariable(datefield.getId(), "hour", h,
+ datefield.isImmediate());
updateTime(false);
}
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/TreeAction.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/TreeAction.java
index 04e2aa00cf..3e690455af 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/TreeAction.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/TreeAction.java
@@ -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;
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/VerticalSplitPanelImages.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/VerticalSplitPanelImages.java
index 1a11bdd712..e4e68f3004 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/VerticalSplitPanelImages.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/VerticalSplitPanelImages.java
@@ -4,12 +4,12 @@ import com.google.gwt.user.client.ui.AbstractImagePrototype;
public interface VerticalSplitPanelImages extends
com.google.gwt.user.client.ui.VerticalSplitPanelImages {
-
+
/**
- * An image representing the drag thumb.
- *
- * @gwt.resource com/itmill/toolkit/terminal/gwt/public/default/common/img/blank.gif
- */
+ * An image representing the drag thumb.
+ *
+ * @gwt.resource com/itmill/toolkit/terminal/gwt/public/default/common/img/blank.gif
+ */
AbstractImagePrototype verticalSplitPanelThumb();
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/util/DateLocale.java b/src/com/itmill/toolkit/terminal/gwt/client/util/DateLocale.java
index 8c5b4c29b8..43de47bfcd 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/util/DateLocale.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/util/DateLocale.java
@@ -5,9 +5,10 @@ import java.util.List;
/**
* Date locale support for the {@link SimpleDateParser}. You are encouraged to
- * extend this class and provide implementations for other locales.
+ * extend this class and provide implementations for other locales.
+ *
* @author <a href="mailto:g.georgovassilis@gmail.com">George Georgovassilis</a>
- *
+ *
*/
public class DateLocale {
public final static String TOKEN_DAY_OF_WEEK = "E";
@@ -25,9 +26,9 @@ public class DateLocale {
public final static String TOKEN_MINUTE = "m";
public final static String TOKEN_SECOND = "s";
-
+
public final static String TOKEN_MILLISECOND = "S";
-
+
public final static String TOKEN_AM_PM = "a";
public final static String AM = "AM";
@@ -35,44 +36,44 @@ public class DateLocale {
public final static String PM = "PM";
public static List SUPPORTED_DF_TOKENS = Arrays.asList(new String[] {
- TOKEN_DAY_OF_WEEK, TOKEN_DAY_OF_MONTH, TOKEN_MONTH, TOKEN_YEAR,
- TOKEN_HOUR_12, TOKEN_HOUR_24, TOKEN_MINUTE, TOKEN_SECOND,
- TOKEN_AM_PM });
-
+ TOKEN_DAY_OF_WEEK, TOKEN_DAY_OF_MONTH, TOKEN_MONTH, TOKEN_YEAR,
+ TOKEN_HOUR_12, TOKEN_HOUR_24, TOKEN_MINUTE, TOKEN_SECOND,
+ TOKEN_AM_PM });
+
public static List TOKENS_RESOLUTION_ALL = Arrays.asList(new String[] {
- TOKEN_DAY_OF_WEEK, TOKEN_DAY_OF_MONTH, TOKEN_MONTH, TOKEN_YEAR,
- TOKEN_HOUR_12, TOKEN_HOUR_24, TOKEN_MINUTE, TOKEN_SECOND,
- TOKEN_AM_PM });
-
- public static List TOKENS_RESOLUTION_YEAR = Arrays.asList(new String[] {
- TOKEN_YEAR});
-
+ TOKEN_DAY_OF_WEEK, TOKEN_DAY_OF_MONTH, TOKEN_MONTH, TOKEN_YEAR,
+ TOKEN_HOUR_12, TOKEN_HOUR_24, TOKEN_MINUTE, TOKEN_SECOND,
+ TOKEN_AM_PM });
+
+ public static List TOKENS_RESOLUTION_YEAR = Arrays
+ .asList(new String[] { TOKEN_YEAR });
+
public static List TOKENS_RESOLUTION_MONTH = Arrays.asList(new String[] {
- TOKEN_YEAR, TOKEN_MONTH});
-
+ TOKEN_YEAR, TOKEN_MONTH });
+
public static List TOKENS_RESOLUTION_DAY = Arrays.asList(new String[] {
- TOKEN_YEAR, TOKEN_MONTH, TOKEN_DAY_OF_MONTH});
+ TOKEN_YEAR, TOKEN_MONTH, TOKEN_DAY_OF_MONTH });
public String[] MONTH_LONG = { "January", "February", "March", "April",
- "May", "June", "July", "August", "September", "October",
- "November", "December" };
+ "May", "June", "July", "August", "September", "October",
+ "November", "December" };
public String[] MONTH_SHORT = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
- "Jul", "Aug", "Sept", "Oct", "Nov", "Dec" };
+ "Jul", "Aug", "Sept", "Oct", "Nov", "Dec" };
public String[] WEEKDAY_LONG = { "Sunday", "Monday", "Tuesday",
- "Wednesday", "Thursday", "Friday", "Saturday" };
+ "Wednesday", "Thursday", "Friday", "Saturday" };
public String[] WEEKDAY_SHORT = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri",
- "Sat" };
+ "Sat" };
public static String getAM() {
- return AM;
- }
+ return AM;
+ }
public static String getPM() {
- return PM;
- }
+ return PM;
+ }
public String[] getWEEKDAY_LONG() {
return WEEKDAY_LONG;
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/util/Pattern.java b/src/com/itmill/toolkit/terminal/gwt/client/util/Pattern.java
index 7c8e4def97..f82365b211 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/util/Pattern.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/util/Pattern.java
@@ -22,18 +22,21 @@ import com.google.gwt.core.client.JavaScriptObject;
/**
* <p>
- * Implementation of the {@link java.util.regex.Pattern} class with a
- * wrapper aroung the Javascript <a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Guide:Regular_Expressions">RegExp</a> object.
- * As most of the methods delegate to the JavaScript RegExp object, certain differences in the
- * declaration and behaviour of regular expressions must be expected.
+ * Implementation of the {@link java.util.regex.Pattern} class with a wrapper
+ * aroung the Javascript <a
+ * href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Guide:Regular_Expressions">RegExp</a>
+ * object. As most of the methods delegate to the JavaScript RegExp object,
+ * certain differences in the declaration and behaviour of regular expressions
+ * must be expected.
* </p>
* <p>
- * Please note that neither the {@link java.util.regex.Pattern#compile(String)} method nor
- * {@link Matcher} instances are supported. For the later, consider using {@link Pattern#match(String)}.
+ * Please note that neither the {@link java.util.regex.Pattern#compile(String)}
+ * method nor {@link Matcher} instances are supported. For the later, consider
+ * using {@link Pattern#match(String)}.
* </p>
*
* @author George Georgovassilis
- *
+ *
*/
public class Pattern {
@@ -60,22 +63,25 @@ public class Pattern {
private static native JavaScriptObject _createExpression(String pattern,
String flags)/*-{
- return new RegExp(pattern, flags);
- }-*/;
+ return new RegExp(pattern, flags);
+ }-*/;
private native void _match(String text, List matches)/*-{
- var regExp = this.@com.itmill.toolkit.terminal.gwt.client.util.Pattern::regExp;
- var result = text.match(regExp);
- if (result == null) return;
- for (var i=0;i<result.length;i++)
- matches.@java.util.ArrayList::add(Ljava/lang/Object;)(result[i]);
- }-*/;
+ var regExp = this.@com.itmill.toolkit.terminal.gwt.client.util.Pattern::regExp;
+ var result = text.match(regExp);
+ if (result == null) return;
+ for (var i=0;i<result.length;i++)
+ matches.@java.util.ArrayList::add(Ljava/lang/Object;)(result[i]);
+ }-*/;
/**
- * Determines wether the specified regular expression is validated by the
+ * Determines wether the specified regular expression is validated by the
* provided input.
- * @param regex Regular expression
- * @param input String to validate
+ *
+ * @param regex
+ * Regular expression
+ * @param input
+ * String to validate
* @return <code>true</code> if matched.
*/
public static boolean matches(String regex, String input) {
@@ -83,10 +89,10 @@ public class Pattern {
}
/**
- * Escape a provided string so that it will be interpreted as a literal
- * in regular expressions.
- * The current implementation does escape each character even if not neccessary,
- * generating verbose literals.
+ * Escape a provided string so that it will be interpreted as a literal in
+ * regular expressions. The current implementation does escape each
+ * character even if not neccessary, generating verbose literals.
+ *
* @param input
* @return
*/
@@ -100,7 +106,9 @@ public class Pattern {
/**
* Class constructor
- * @param pattern Regular expression
+ *
+ * @param pattern
+ * Regular expression
*/
public Pattern(String pattern) {
this(pattern, 0);
@@ -108,21 +116,25 @@ public class Pattern {
/**
* Class constructor
- * @param pattern Regular expression
- * @param flags
+ *
+ * @param pattern
+ * Regular expression
+ * @param flags
*/
public Pattern(String pattern, int flags) {
regExp = createExpression(pattern, flags);
}
/**
- * This method is borrowed from the JavaScript RegExp object.
- * It parses a string and returns as an array any assignments to parenthesis groups
- * in the pattern's regular expression
+ * This method is borrowed from the JavaScript RegExp object. It parses a
+ * string and returns as an array any assignments to parenthesis groups in
+ * the pattern's regular expression
+ *
* @param text
* @return Array of strings following java's Pattern convention for groups:
- * Group 0 is the entire input string and the remaining groups are the matched parenthesis.
- * In case nothing was matched an empty array is returned.
+ * Group 0 is the entire input string and the remaining groups are
+ * the matched parenthesis. In case nothing was matched an empty
+ * array is returned.
*/
public String[] match(String text) {
List matches = new ArrayList();
@@ -135,41 +147,44 @@ public class Pattern {
/**
* Determines wether a provided text matches the regular expression
+ *
* @param text
* @return
*/
public native boolean matches(String text)/*-{
- var regExp = this.@com.itmill.toolkit.terminal.gwt.client.util.Pattern::regExp;
- return regExp.test(text);
- }-*/;
+ var regExp = this.@com.itmill.toolkit.terminal.gwt.client.util.Pattern::regExp;
+ return regExp.test(text);
+ }-*/;
/**
* Returns the regular expression for this pattern
+ *
* @return
*/
public native String pattern()/*-{
- var regExp = this.@com.itmill.toolkit.terminal.gwt.client.util.Pattern::regExp;
- return regExp.source;
- }-*/;
+ var regExp = this.@com.itmill.toolkit.terminal.gwt.client.util.Pattern::regExp;
+ return regExp.source;
+ }-*/;
private native void _split(String input, List results)/*-{
- var regExp = this.@com.itmill.toolkit.terminal.gwt.client.util.Pattern::regExp;
- var parts = input.split(regExp);
- for (var i=0;i<parts.length;i++)
- results.@java.util.ArrayList::add(Ljava/lang/Object;)(parts[i] );
- }-*/;
-
+ var regExp = this.@com.itmill.toolkit.terminal.gwt.client.util.Pattern::regExp;
+ var parts = input.split(regExp);
+ for (var i=0;i<parts.length;i++)
+ results.@java.util.ArrayList::add(Ljava/lang/Object;)(parts[i] );
+ }-*/;
+
/**
* Split an input string by the pattern's regular expression
+ *
* @param input
* @return Array of strings
*/
- public String[] split(String input){
- List results = new ArrayList();
+ public String[] split(String input) {
+ List results = new ArrayList();
_split(input, results);
String[] parts = new String[results.size()];
- for (int i=0;i<results.size();i++)
- parts[i] = (String)results.get(i);
+ for (int i = 0; i < results.size(); i++)
+ parts[i] = (String) results.get(i);
return parts;
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/util/SimpleDateFormat.java b/src/com/itmill/toolkit/terminal/gwt/client/util/SimpleDateFormat.java
index e7903c7ee6..8bfb4b957f 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/util/SimpleDateFormat.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/util/SimpleDateFormat.java
@@ -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);
};
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/util/SimpleDateParser.java b/src/com/itmill/toolkit/terminal/gwt/client/util/SimpleDateParser.java
index a3c6b17237..1ff5d5c458 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/util/SimpleDateParser.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/util/SimpleDateParser.java
@@ -2,20 +2,20 @@ package com.itmill.toolkit.terminal.gwt.client.util;
import java.util.Date;
-
/**
- * This is a simple regular expression based parser for date notations.
- * While our aim is to fully support in the future the JDK date parser, currently
- * only numeric notations and literals are supported such as <code>dd/MM/yyyy HH:mm:ss.SSSS</code>.
- * Each entity is parsed with the same number of digits, i.e. for <code>dd</code> two digits will be
- * parsed while for <code>d</code> only one will be parsed.
+ * This is a simple regular expression based parser for date notations. While
+ * our aim is to fully support in the future the JDK date parser, currently only
+ * numeric notations and literals are supported such as
+ * <code>dd/MM/yyyy HH:mm:ss.SSSS</code>. Each entity is parsed with the same
+ * number of digits, i.e. for <code>dd</code> two digits will be parsed while
+ * for <code>d</code> only one will be parsed.
+ *
* @author <a href="mailto:g.georgovassilis@gmail.com">George Georgovassilis</a>
- *
+ *
*/
public class SimpleDateParser {
-
private final static String DAY_IN_MONTH = "d";
private final static String MONTH = "M";
@@ -35,28 +35,27 @@ public class SimpleDateParser {
private final static int INSTRUCTION = 1;
private final static String[] TOKENS[] = {
- { "SSSS", "(\\d\\d\\d\\d)",DateLocale.TOKEN_MILLISECOND },
- { "SSS", "(\\d\\d\\d)", DateLocale.TOKEN_MILLISECOND },
- { "SS", "(\\d\\d)", DateLocale.TOKEN_MILLISECOND },
- { "S", "(\\d)", DateLocale.TOKEN_MILLISECOND },
- { "ss", "(\\d\\d)", DateLocale.TOKEN_SECOND },
- { "s", "(\\d\\d)", DateLocale.TOKEN_SECOND },
- { "mm", "(\\d\\d)", DateLocale.TOKEN_MINUTE },
- { "m", "(\\d\\d)", DateLocale.TOKEN_MINUTE},
- { "HH", "(\\d\\d)", DateLocale.TOKEN_HOUR_24},
- { "H", "(\\d{1,2})", DateLocale.TOKEN_HOUR_24 },
- { "hh", "(\\d\\d)", DateLocale.TOKEN_HOUR_12},
- { "h", "(\\d{1,2})", DateLocale.TOKEN_HOUR_12 },
- { "dd", "(\\d\\d)", DateLocale.TOKEN_DAY_OF_MONTH },
- { "d", "(\\d{1,2})", DateLocale.TOKEN_DAY_OF_MONTH },
- { "MM", "(\\d\\d)", DateLocale.TOKEN_MONTH },
- { "M", "(\\d{1,2})", DateLocale.TOKEN_MONTH },
- { "yyyy", "(\\d\\d\\d\\d)", DateLocale.TOKEN_YEAR },
- { "yyy", "(\\d\\d\\d\\d)", DateLocale.TOKEN_YEAR },
- { "yy", "(\\d\\d\\d\\d)", DateLocale.TOKEN_YEAR },
- { "y", "(\\d{1,2})", DateLocale.TOKEN_YEAR },
- { "a", "(\\S{1,4})", DateLocale.TOKEN_AM_PM }
- };
+ { "SSSS", "(\\d\\d\\d\\d)", DateLocale.TOKEN_MILLISECOND },
+ { "SSS", "(\\d\\d\\d)", DateLocale.TOKEN_MILLISECOND },
+ { "SS", "(\\d\\d)", DateLocale.TOKEN_MILLISECOND },
+ { "S", "(\\d)", DateLocale.TOKEN_MILLISECOND },
+ { "ss", "(\\d\\d)", DateLocale.TOKEN_SECOND },
+ { "s", "(\\d\\d)", DateLocale.TOKEN_SECOND },
+ { "mm", "(\\d\\d)", DateLocale.TOKEN_MINUTE },
+ { "m", "(\\d\\d)", DateLocale.TOKEN_MINUTE },
+ { "HH", "(\\d\\d)", DateLocale.TOKEN_HOUR_24 },
+ { "H", "(\\d{1,2})", DateLocale.TOKEN_HOUR_24 },
+ { "hh", "(\\d\\d)", DateLocale.TOKEN_HOUR_12 },
+ { "h", "(\\d{1,2})", DateLocale.TOKEN_HOUR_12 },
+ { "dd", "(\\d\\d)", DateLocale.TOKEN_DAY_OF_MONTH },
+ { "d", "(\\d{1,2})", DateLocale.TOKEN_DAY_OF_MONTH },
+ { "MM", "(\\d\\d)", DateLocale.TOKEN_MONTH },
+ { "M", "(\\d{1,2})", DateLocale.TOKEN_MONTH },
+ { "yyyy", "(\\d\\d\\d\\d)", DateLocale.TOKEN_YEAR },
+ { "yyy", "(\\d\\d\\d\\d)", DateLocale.TOKEN_YEAR },
+ { "yy", "(\\d\\d\\d\\d)", DateLocale.TOKEN_YEAR },
+ { "y", "(\\d{1,2})", DateLocale.TOKEN_YEAR },
+ { "a", "(\\S{1,4})", DateLocale.TOKEN_AM_PM } };
private Pattern regularExpression;
@@ -65,13 +64,13 @@ public class SimpleDateParser {
private static void _parse(String format, String[] args) {
if (format.length() == 0)
return;
- if (format.startsWith("'")){
+ if (format.startsWith("'")) {
format = format.substring(1);
int end = format.indexOf("'");
if (end == -1)
throw new IllegalArgumentException("Unmatched single quotes.");
- args[REGEX]+=Pattern.quote(format.substring(0,end));
- format = format.substring(end+1);
+ args[REGEX] += Pattern.quote(format.substring(0, end));
+ format = format.substring(end + 1);
}
for (int i = 0; i < TOKENS.length; i++) {
String[] row = TOKENS[i];
@@ -84,12 +83,13 @@ public class SimpleDateParser {
_parse(format, args);
return;
}
- args[REGEX] += Pattern.quote(""+format.charAt(0));
+ args[REGEX] += Pattern.quote("" + format.charAt(0));
format = format.substring(1);
_parse(format, args);
}
- private static void load(Date date, String text, String component, String input, Pattern regex) {
+ private static void load(Date date, String text, String component,
+ String input, Pattern regex) {
if (component.equals(DateLocale.TOKEN_MILLISECOND)) {
date.setTime(date.getTime() / 1000 * 1000 + Integer.parseInt(text));
}
@@ -105,12 +105,21 @@ public class SimpleDateParser {
if (component.equals(DateLocale.TOKEN_HOUR_24)) {
date.setHours(Integer.parseInt(text));
}
-
+
if (component.equals(DateLocale.TOKEN_HOUR_12)) {
int h = Integer.parseInt(text);
- String token = com.itmill.toolkit.terminal.gwt.client.DateLocale.getPM();
- String which = input.substring(input.length() - token.length()); // Assumes both AM and PM tokens have same length
- if(which.equalsIgnoreCase(token))
+ String token = com.itmill.toolkit.terminal.gwt.client.DateLocale
+ .getPM();
+ String which = input.substring(input.length() - token.length()); // Assumes
+ // both
+ // AM
+ // and
+ // PM
+ // tokens
+ // have
+ // same
+ // length
+ if (which.equalsIgnoreCase(token))
h += 12;
date.setHours(h);
}
@@ -119,11 +128,11 @@ public class SimpleDateParser {
date.setDate(Integer.parseInt(text));
}
if (component.equals(DateLocale.TOKEN_MONTH)) {
- date.setMonth(Integer.parseInt(text)-1);
+ date.setMonth(Integer.parseInt(text) - 1);
}
if (component.equals(DateLocale.TOKEN_YEAR)) {
- //TODO: fix for short patterns
- date.setYear(Integer.parseInt(text)-1900);
+ // TODO: fix for short patterns
+ date.setYear(Integer.parseInt(text) - 1900);
}
}
@@ -139,17 +148,20 @@ public class SimpleDateParser {
Date date = new Date(0, 0, 0, 0, 0, 0);
String matches[] = regularExpression.match(input);
if (matches == null)
- throw new IllegalArgumentException(input+" does not match "+regularExpression.pattern());
- if (matches.length-1!=instructions.length())
- throw new IllegalArgumentException("Different group count - "+input+" does not match "+regularExpression.pattern());
+ throw new IllegalArgumentException(input + " does not match "
+ + regularExpression.pattern());
+ if (matches.length - 1 != instructions.length())
+ throw new IllegalArgumentException("Different group count - "
+ + input + " does not match " + regularExpression.pattern());
for (int group = 0; group < instructions.length(); group++) {
String match = matches[group + 1];
- load(date, match, ""+instructions.charAt(group), input, regularExpression);
+ load(date, match, "" + instructions.charAt(group), input,
+ regularExpression);
}
return date;
}
-
- public static Date parse(String input, String pattern){
+
+ public static Date parse(String input, String pattern) {
return new SimpleDateParser(pattern).parse(input);
}
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java b/src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java
index ef4d173542..a11cb67de0 100644
--- a/src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java
+++ b/src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java
@@ -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
diff --git a/src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java b/src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java
index 416eff723d..21320385af 100644
--- a/src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java
+++ b/src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java
@@ -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);
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/server/JsonPaintTarget.java b/src/com/itmill/toolkit/terminal/gwt/server/JsonPaintTarget.java
index 1fa7b6d82e..8ef70ffa46 100644
--- a/src/com/itmill/toolkit/terminal/gwt/server/JsonPaintTarget.java
+++ b/src/com/itmill/toolkit/terminal/gwt/server/JsonPaintTarget.java
@@ -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;
diff --git a/src/com/itmill/toolkit/terminal/gwt/server/Log.java b/src/com/itmill/toolkit/terminal/gwt/server/Log.java
index a9fe1e0ff4..5fe6417dad 100644
--- a/src/com/itmill/toolkit/terminal/gwt/server/Log.java
+++ b/src/com/itmill/toolkit/terminal/gwt/server/Log.java
@@ -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);
}
diff --git a/src/com/itmill/toolkit/terminal/gwt/server/WebApplicationContext.java b/src/com/itmill/toolkit/terminal/gwt/server/WebApplicationContext.java
index e414c0a0b5..30c0070b4f 100644
--- a/src/com/itmill/toolkit/terminal/gwt/server/WebApplicationContext.java
+++ b/src/com/itmill/toolkit/terminal/gwt/server/WebApplicationContext.java
@@ -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
*/
diff --git a/src/com/itmill/toolkit/terminal/gwt/server/WebBrowser.java b/src/com/itmill/toolkit/terminal/gwt/server/WebBrowser.java
index c065a85deb..3e78a9180a 100644
--- a/src/com/itmill/toolkit/terminal/gwt/server/WebBrowser.java
+++ b/src/com/itmill/toolkit/terminal/gwt/server/WebBrowser.java
@@ -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
*/
diff --git a/src/com/itmill/toolkit/tests/BasicRandomTest.java b/src/com/itmill/toolkit/tests/BasicRandomTest.java
index 559e057811..2a6d892627 100644
--- a/src/com/itmill/toolkit/tests/BasicRandomTest.java
+++ b/src/com/itmill/toolkit/tests/BasicRandomTest.java
@@ -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);
diff --git a/src/com/itmill/toolkit/tests/RandomLayoutStress.java b/src/com/itmill/toolkit/tests/RandomLayoutStress.java
index 3218c7e25c..965c6a0615 100644
--- a/src/com/itmill/toolkit/tests/RandomLayoutStress.java
+++ b/src/com/itmill/toolkit/tests/RandomLayoutStress.java
@@ -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.
diff --git a/src/com/itmill/toolkit/tests/TestBench.java b/src/com/itmill/toolkit/tests/TestBench.java
index b6d95efbe2..7787d5c2bc 100644
--- a/src/com/itmill/toolkit/tests/TestBench.java
+++ b/src/com/itmill/toolkit/tests/TestBench.java
@@ -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);
diff --git a/src/com/itmill/toolkit/tests/TestForApplicationLayoutThatUsesWholeBrosersSpace.java b/src/com/itmill/toolkit/tests/TestForApplicationLayoutThatUsesWholeBrosersSpace.java
index d79b0aaef7..b7b53bd720 100644
--- a/src/com/itmill/toolkit/tests/TestForApplicationLayoutThatUsesWholeBrosersSpace.java
+++ b/src/com/itmill/toolkit/tests/TestForApplicationLayoutThatUsesWholeBrosersSpace.java
@@ -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šš"));
diff --git a/src/com/itmill/toolkit/tests/TestForBasicApplicationLayout.java b/src/com/itmill/toolkit/tests/TestForBasicApplicationLayout.java
index afa51e18a1..1edbc0b83f 100644
--- a/src/com/itmill/toolkit/tests/TestForBasicApplicationLayout.java
+++ b/src/com/itmill/toolkit/tests/TestForBasicApplicationLayout.java
@@ -17,48 +17,50 @@ import com.itmill.toolkit.ui.Button.ClickEvent;
import com.itmill.toolkit.ui.Button.ClickListener;
public class TestForBasicApplicationLayout extends CustomComponent {
-
+
private Button click;
private Button click2;
private TabSheet tab;
-
+
public TestForBasicApplicationLayout() {
- OrderedLayout main = new OrderedLayout();
+ OrderedLayout main = new OrderedLayout();
setCompositionRoot(main);
-
+
click = new Button("Set height -1", new ClickListener() {
public void buttonClick(ClickEvent event) {
tab.setHeight(-1);
}
-
+
});
-
+
click2 = new Button("Set height 100%", new ClickListener() {
public void buttonClick(ClickEvent event) {
tab.setHeight(100);
tab.setHeightUnits(Sizeable.UNITS_PERCENTAGE);
}
-
+
});
-
+
SplitPanel sp = new SplitPanel(SplitPanel.ORIENTATION_HORIZONTAL);
- sp.setSplitPosition(290, Sizeable.UNITS_PIXELS); // Width of left side area
-
+ sp.setSplitPosition(290, Sizeable.UNITS_PIXELS); // Width of left
+ // side area
+
SplitPanel sp2 = new SplitPanel(SplitPanel.ORIENTATION_VERTICAL);
- sp2.setSplitPosition(255, Sizeable.UNITS_PIXELS); // Height of right-top area
-
+ sp2.setSplitPosition(255, Sizeable.UNITS_PIXELS); // Height of
+ // right-top area
+
Panel p = new Panel("Accordion Panel");
p.setHeight(100);
p.setHeightUnits(Panel.UNITS_PERCENTAGE);
-
+
tab = new TabSheet();
tab.setWidth(100);
tab.setWidthUnits(Sizeable.UNITS_PERCENTAGE);
tab.setHeight(740);
tab.setHeightUnits(Sizeable.UNITS_PIXELS);
-
+
Panel report = new Panel("Monthly Program Runs", new ExpandLayout());
OrderedLayout controls = new OrderedLayout();
controls.addComponent(new Label("Report tab"));
@@ -67,16 +69,17 @@ public class TestForBasicApplicationLayout extends CustomComponent {
report.addComponent(controls);
DateField cal = new DateField();
cal.setResolution(DateField.RESOLUTION_DAY);
- cal.setLocale(new Locale("en","US"));
+ cal.setLocale(new Locale("en", "US"));
report.addComponent(cal);
- ((ExpandLayout)report.getLayout()).expand(controls);
+ ((ExpandLayout) report.getLayout()).expand(controls);
report.setStyle("light");
report.setHeight(100);
report.setHeightUnits(Sizeable.UNITS_PERCENTAGE);
-
+
sp2.setFirstComponent(report);
-
- Table table = TestForTablesInitialColumnWidthLogicRendering.getTestTable(5,200);
+
+ Table table = TestForTablesInitialColumnWidthLogicRendering
+ .getTestTable(5, 200);
table.setPageLength(15);
table.setSelectable(true);
table.setRowHeaderMode(Table.ROW_HEADER_MODE_INDEX);
@@ -89,17 +92,17 @@ public class TestForBasicApplicationLayout extends CustomComponent {
table.setHeightUnits(Sizeable.UNITS_PERCENTAGE);
table.addStyleName("table-inline");
sp2.setSecondComponent(table);
-
+
tab.addTab(new Label("Tab1"), "Summary", null);
tab.addTab(sp2, "Reports", null);
tab.addTab(new Label("Tab 3"), "Statistics", null);
tab.addTab(new Label("Tab 4"), "Error Tracking", null);
tab.setSelectedTab(sp2);
-
+
sp.setFirstComponent(p);
sp.setSecondComponent(tab);
-
+
main.addComponent(sp);
}
-
+
}
diff --git a/src/com/itmill/toolkit/tests/TestForChildComponentRendering.java b/src/com/itmill/toolkit/tests/TestForChildComponentRendering.java
index 3c72608da6..55ffab976f 100644
--- a/src/com/itmill/toolkit/tests/TestForChildComponentRendering.java
+++ b/src/com/itmill/toolkit/tests/TestForChildComponentRendering.java
@@ -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));
-
- }
+ }
}
-
-
diff --git a/src/com/itmill/toolkit/tests/TestForGridLayoutChildComponentRendering.java b/src/com/itmill/toolkit/tests/TestForGridLayoutChildComponentRendering.java
index 23f9f47b32..853f68e09b 100644
--- a/src/com/itmill/toolkit/tests/TestForGridLayoutChildComponentRendering.java
+++ b/src/com/itmill/toolkit/tests/TestForGridLayoutChildComponentRendering.java
@@ -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));
-
- }
+ }
}
-
-
diff --git a/src/com/itmill/toolkit/tests/TestForTablesInitialColumnWidthLogicRendering.java b/src/com/itmill/toolkit/tests/TestForTablesInitialColumnWidthLogicRendering.java
index 1fafe4c26e..1d33986bf6 100644
--- a/src/com/itmill/toolkit/tests/TestForTablesInitialColumnWidthLogicRendering.java
+++ b/src/com/itmill/toolkit/tests/TestForTablesInitialColumnWidthLogicRendering.java
@@ -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)];
}
-
-}
-
+}
diff --git a/src/com/itmill/toolkit/tests/TestForTrees.java b/src/com/itmill/toolkit/tests/TestForTrees.java
index 907902ba9d..5e9bb4db54 100644
--- a/src/com/itmill/toolkit/tests/TestForTrees.java
+++ b/src/com/itmill/toolkit/tests/TestForTrees.java
@@ -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));
}
diff --git a/src/com/itmill/toolkit/tests/TestForUpload.java b/src/com/itmill/toolkit/tests/TestForUpload.java
index 88367ff2db..b3e818ea22 100644
--- a/src/com/itmill/toolkit/tests/TestForUpload.java
+++ b/src/com/itmill/toolkit/tests/TestForUpload.java
@@ -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());
}
diff --git a/src/com/itmill/toolkit/tests/TestForWindowing.java b/src/com/itmill/toolkit/tests/TestForWindowing.java
index 7f7f4de8dd..0712b4e1db 100644
--- a/src/com/itmill/toolkit/tests/TestForWindowing.java
+++ b/src/com/itmill/toolkit/tests/TestForWindowing.java
@@ -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;
}
-
+
}
diff --git a/src/com/itmill/toolkit/ui/AbstractComponent.java b/src/com/itmill/toolkit/ui/AbstractComponent.java
index 18ce5b59a5..13d40bc23d 100644
--- a/src/com/itmill/toolkit/ui/AbstractComponent.java
+++ b/src/com/itmill/toolkit/ui/AbstractComponent.java
@@ -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);
}
diff --git a/src/com/itmill/toolkit/ui/AbstractComponentContainer.java b/src/com/itmill/toolkit/ui/AbstractComponentContainer.java
index 1719d6aac9..5d50f1eaf1 100644
--- a/src/com/itmill/toolkit/ui/AbstractComponentContainer.java
+++ b/src/com/itmill/toolkit/ui/AbstractComponentContainer.java
@@ -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);
}
diff --git a/src/com/itmill/toolkit/ui/AbstractField.java b/src/com/itmill/toolkit/ui/AbstractField.java
index 1cf7b69ac4..877920273d 100644
--- a/src/com/itmill/toolkit/ui/AbstractField.java
+++ b/src/com/itmill/toolkit/ui/AbstractField.java
@@ -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))) {
diff --git a/src/com/itmill/toolkit/ui/Button.java b/src/com/itmill/toolkit/ui/Button.java
index 8968c229f2..4ac7365dac 100644
--- a/src/com/itmill/toolkit/ui/Button.java
+++ b/src/com/itmill/toolkit/ui/Button.java
@@ -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.
diff --git a/src/com/itmill/toolkit/ui/CalendarField.java b/src/com/itmill/toolkit/ui/CalendarField.java
index 83ae89c9f6..34800f49c4 100644
--- a/src/com/itmill/toolkit/ui/CalendarField.java
+++ b/src/com/itmill/toolkit/ui/CalendarField.java
@@ -16,286 +16,288 @@ import com.itmill.toolkit.terminal.PaintTarget;
// TODO Allow item selection
public class CalendarField extends DateField implements Container.Viewer {
- private Date minDate;
- private Date maxDate;
-
- private Container dataSource;
- private Object itemStartPropertyId;
- private Object itemEndPropertyId;
- private Object itemTitlePropertyId;
- private Object itemDescriptionPropertyId;
- private Object itemNotimePropertyId;
-
- public CalendarField() {
- super();
- init();
- }
-
- public CalendarField(Property dataSource) throws IllegalArgumentException {
- super(dataSource);
- init();
- }
-
- public CalendarField(String caption, Date value) {
- super(caption, value);
- init();
- }
-
- public CalendarField(String caption, Property dataSource) {
- super(caption, dataSource);
- init();
- }
-
- public CalendarField(String caption) {
- super(caption);
- init();
- }
-
- /*
- * Gets the components UIDL tag string. Don't add a JavaDoc comment here, we
- * use the default documentation from implemented interface.
- */
- public String getTag() {
- return "calendarfield";
- }
-
- public void init() {
- super.setResolution(RESOLUTION_HOUR);
-
- }
-
- /**
- * Sets the resolution of the CalendarField. Only RESOLUTION_DAY and
- * RESOLUTION_HOUR are supported.
- *
- * @param resolution
- * the resolution to set.
- * @see com.itmill.toolkit.ui.DateField#setResolution(int)
- */
- public void setResolution(int resolution) {
- if (resolution != RESOLUTION_DAY && resolution != RESOLUTION_HOUR) {
- throw new IllegalArgumentException();
+ private Date minDate;
+ private Date maxDate;
+
+ private Container dataSource;
+ private Object itemStartPropertyId;
+ private Object itemEndPropertyId;
+ private Object itemTitlePropertyId;
+ private Object itemDescriptionPropertyId;
+ private Object itemNotimePropertyId;
+
+ public CalendarField() {
+ super();
+ init();
}
- super.setResolution(resolution);
- }
-
- public void setMinimumDate(Date date) {
- this.minDate = date;
- requestRepaint();
- }
-
- public Date getMinimumDate() {
- return minDate;
- }
-
- public void setMaximumDate(Date date) {
- this.maxDate = date;
- requestRepaint();
- }
-
- public Date getMaximumDate() {
- return maxDate;
- }
-
- public Container getContainerDataSource() {
- return this.dataSource;
- }
-
- public void setContainerDataSource(Container newDataSource) {
- if (newDataSource==null||checkDataSource(newDataSource)) {
- this.dataSource = newDataSource;
- } else {
- // TODO error message
- throw new IllegalArgumentException();
+
+ public CalendarField(Property dataSource) throws IllegalArgumentException {
+ super(dataSource);
+ init();
}
- requestRepaint();
- }
- private boolean checkDataSource(Container dataSource) {
- /*
- * if (!(dataSource instanceof Container.Sortable)) { // we really want
- * the data source to be sortable return false; }
- */
- // Check old propertyIds
- if (this.itemEndPropertyId != null) {
- Class c = dataSource.getType(this.itemEndPropertyId);
- if (!Date.class.isAssignableFrom(c)) {
- this.itemEndPropertyId = null;
- }
+ public CalendarField(String caption, Date value) {
+ super(caption, value);
+ init();
}
- if (this.itemNotimePropertyId != null) {
- Class c = dataSource.getType(this.itemNotimePropertyId);
- if (!Boolean.class.isAssignableFrom(c)) {
- this.itemNotimePropertyId = null;
- }
+
+ public CalendarField(String caption, Property dataSource) {
+ super(caption, dataSource);
+ init();
}
- if (this.itemStartPropertyId != null) {
- Class c = dataSource.getType(this.itemStartPropertyId);
- if (Date.class.isAssignableFrom(c)) {
- // All we _really_ need is one date
- return true;
- } else {
- this.itemStartPropertyId = null;
- }
+
+ public CalendarField(String caption) {
+ super(caption);
+ init();
}
- // We need at least one Date
- Collection ids = dataSource.getContainerPropertyIds();
- for (Iterator it = ids.iterator(); it.hasNext();) {
- Object id = it.next();
- Class c = dataSource.getType(id);
- if (Date.class.isAssignableFrom(c)) {
- this.itemStartPropertyId = id;
- return true;
- }
+
+ /*
+ * Gets the components UIDL tag string. Don't add a JavaDoc comment here, we
+ * use the default documentation from implemented interface.
+ */
+ public String getTag() {
+ return "calendarfield";
}
- return false;
- }
+ public void init() {
+ super.setResolution(RESOLUTION_HOUR);
- public Object getItemStartPropertyId() {
- return itemStartPropertyId;
- }
+ }
- public void setItemStartPropertyId(Object propertyId) {
- // TODO nullcheck for property id
- if (this.dataSource != null
- && !Date.class.isAssignableFrom(dataSource.getType(propertyId))) {
- // TODO error message
- throw new IllegalArgumentException();
+ /**
+ * Sets the resolution of the CalendarField. Only RESOLUTION_DAY and
+ * RESOLUTION_HOUR are supported.
+ *
+ * @param resolution
+ * the resolution to set.
+ * @see com.itmill.toolkit.ui.DateField#setResolution(int)
+ */
+ public void setResolution(int resolution) {
+ if (resolution != RESOLUTION_DAY && resolution != RESOLUTION_HOUR) {
+ throw new IllegalArgumentException();
+ }
+ super.setResolution(resolution);
}
- this.itemStartPropertyId = propertyId;
- }
-
- public Object getItemEndPropertyId() {
- return itemEndPropertyId;
- }
-
- public void setItemEndPropertyId(Object propertyId) {
- // TODO nullcheck for property id
- if (this.dataSource != null
- && !Date.class.isAssignableFrom(dataSource.getType(propertyId))) {
- // TODO error message
- throw new IllegalArgumentException();
+
+ public void setMinimumDate(Date date) {
+ this.minDate = date;
+ requestRepaint();
}
- this.itemEndPropertyId = propertyId;
- }
-
- public Object getItemTitlePropertyId() {
- return itemTitlePropertyId;
- }
-
- public void setItemTitlePropertyId(Object propertyId) {
- this.itemTitlePropertyId = propertyId;
- }
-
- public Object getItemDescriptionPropertyId() {
- return itemDescriptionPropertyId;
- }
-
- public void setItemDescriptionPropertyId(Object propertyId) {
- this.itemDescriptionPropertyId = propertyId;
- }
-
- public Object getitemNotimePropertyId() {
- return itemNotimePropertyId;
- }
-
- public void setItemNotimePropertyId(Object propertyId) {
- // TODO nullcheck for property id
- if (this.dataSource != null
- && !Boolean.class.isAssignableFrom(dataSource.getType(propertyId))) {
- // TODO error message
- throw new IllegalArgumentException();
+
+ public Date getMinimumDate() {
+ return minDate;
}
- this.itemNotimePropertyId = propertyId;
- }
-
- /**
- * Paints the content of this component.
- *
- * @param target
- * the Paint Event.
- * @throws PaintException
- * if the paint operation failed.
- */
- public void paintContent(PaintTarget target) throws PaintException {
- super.paintContent(target);
-
- if (this.minDate != null) {
- target.addAttribute("min", String.valueOf(this.minDate.getTime()));
+
+ public void setMaximumDate(Date date) {
+ this.maxDate = date;
+ requestRepaint();
}
- if (this.maxDate != null) {
- target.addAttribute("max", String.valueOf(this.maxDate.getTime()));
+
+ public Date getMaximumDate() {
+ return maxDate;
}
- if (this.dataSource != null) {
- target.startTag("items");
-
- // send one month now, the rest via lazyloading
- int month = new Date().getMonth();
- Object value = getValue();
- if (value != null && value instanceof Date) {
- month = ((Date) value).getMonth();
- }
-
- for (Iterator it = this.dataSource.getItemIds().iterator(); it
- .hasNext();) {
- Object itemId = it.next();
- Item item = (Item) this.dataSource.getItem(itemId);
- Property p = item.getItemProperty(this.itemStartPropertyId);
- Date start = (Date) p.getValue();
- Date end = start; // assume same day
- if (this.itemEndPropertyId != null) {
- p = item.getItemProperty(this.itemEndPropertyId);
- end = (Date) p.getValue();
- if (end == null) {
- end = start;
- } else if (end.before(start)) {
- Date tmp = start;
- start = end;
- end = tmp;
- }
+ public Container getContainerDataSource() {
+ return this.dataSource;
+ }
+
+ public void setContainerDataSource(Container newDataSource) {
+ if (newDataSource == null || checkDataSource(newDataSource)) {
+ this.dataSource = newDataSource;
+ } else {
+ // TODO error message
+ throw new IllegalArgumentException();
}
+ requestRepaint();
+ }
- if (start != null) {
- if ((start.getMonth() <= month || end.getMonth() >= month)) {
- target.startTag("item");
- // TODO different id!
- target.addAttribute("id", itemId.hashCode());
- target.addAttribute("start", ""+start.getTime());
- if (end != start) {
- target.addAttribute("end", ""+end.getTime());
+ private boolean checkDataSource(Container dataSource) {
+ /*
+ * if (!(dataSource instanceof Container.Sortable)) { // we really want
+ * the data source to be sortable return false; }
+ */
+ // Check old propertyIds
+ if (this.itemEndPropertyId != null) {
+ Class c = dataSource.getType(this.itemEndPropertyId);
+ if (!Date.class.isAssignableFrom(c)) {
+ this.itemEndPropertyId = null;
}
- if (this.itemTitlePropertyId != null) {
- p = item.getItemProperty(this.itemTitlePropertyId);
- Object val = p.getValue();
- if (val != null) {
- target.addAttribute("title", val.toString());
- }
+ }
+ if (this.itemNotimePropertyId != null) {
+ Class c = dataSource.getType(this.itemNotimePropertyId);
+ if (!Boolean.class.isAssignableFrom(c)) {
+ this.itemNotimePropertyId = null;
}
- if (this.itemDescriptionPropertyId != null) {
- p = item.getItemProperty(this.itemDescriptionPropertyId);
- Object val = p.getValue();
- if (val != null) {
- target.addAttribute("description", val.toString());
- }
+ }
+ if (this.itemStartPropertyId != null) {
+ Class c = dataSource.getType(this.itemStartPropertyId);
+ if (Date.class.isAssignableFrom(c)) {
+ // All we _really_ need is one date
+ return true;
+ } else {
+ this.itemStartPropertyId = null;
}
- if (this.itemNotimePropertyId != null) {
- p = item
- .getItemProperty(this.itemNotimePropertyId);
- Object val = p.getValue();
- if (val != null) {
- target.addAttribute("notime", ((Boolean) val)
- .booleanValue());
- }
+ }
+ // We need at least one Date
+ Collection ids = dataSource.getContainerPropertyIds();
+ for (Iterator it = ids.iterator(); it.hasNext();) {
+ Object id = it.next();
+ Class c = dataSource.getType(id);
+ if (Date.class.isAssignableFrom(c)) {
+ this.itemStartPropertyId = id;
+ return true;
}
+ }
+
+ return false;
+ }
+
+ public Object getItemStartPropertyId() {
+ return itemStartPropertyId;
+ }
+
+ public void setItemStartPropertyId(Object propertyId) {
+ // TODO nullcheck for property id
+ if (this.dataSource != null
+ && !Date.class.isAssignableFrom(dataSource.getType(propertyId))) {
+ // TODO error message
+ throw new IllegalArgumentException();
+ }
+ this.itemStartPropertyId = propertyId;
+ }
+
+ public Object getItemEndPropertyId() {
+ return itemEndPropertyId;
+ }
- target.endTag("item");
- }
+ public void setItemEndPropertyId(Object propertyId) {
+ // TODO nullcheck for property id
+ if (this.dataSource != null
+ && !Date.class.isAssignableFrom(dataSource.getType(propertyId))) {
+ // TODO error message
+ throw new IllegalArgumentException();
}
- }
+ this.itemEndPropertyId = propertyId;
+ }
+
+ public Object getItemTitlePropertyId() {
+ return itemTitlePropertyId;
+ }
+
+ public void setItemTitlePropertyId(Object propertyId) {
+ this.itemTitlePropertyId = propertyId;
+ }
+
+ public Object getItemDescriptionPropertyId() {
+ return itemDescriptionPropertyId;
+ }
+
+ public void setItemDescriptionPropertyId(Object propertyId) {
+ this.itemDescriptionPropertyId = propertyId;
+ }
+
+ public Object getitemNotimePropertyId() {
+ return itemNotimePropertyId;
+ }
- target.endTag("items");
+ public void setItemNotimePropertyId(Object propertyId) {
+ // TODO nullcheck for property id
+ if (this.dataSource != null
+ && !Boolean.class.isAssignableFrom(dataSource
+ .getType(propertyId))) {
+ // TODO error message
+ throw new IllegalArgumentException();
+ }
+ this.itemNotimePropertyId = propertyId;
+ }
+
+ /**
+ * Paints the content of this component.
+ *
+ * @param target
+ * the Paint Event.
+ * @throws PaintException
+ * if the paint operation failed.
+ */
+ public void paintContent(PaintTarget target) throws PaintException {
+ super.paintContent(target);
+
+ if (this.minDate != null) {
+ target.addAttribute("min", String.valueOf(this.minDate.getTime()));
+ }
+ if (this.maxDate != null) {
+ target.addAttribute("max", String.valueOf(this.maxDate.getTime()));
+ }
+
+ if (this.dataSource != null) {
+ target.startTag("items");
+
+ // send one month now, the rest via lazyloading
+ int month = new Date().getMonth();
+ Object value = getValue();
+ if (value != null && value instanceof Date) {
+ month = ((Date) value).getMonth();
+ }
+
+ for (Iterator it = this.dataSource.getItemIds().iterator(); it
+ .hasNext();) {
+ Object itemId = it.next();
+ Item item = (Item) this.dataSource.getItem(itemId);
+ Property p = item.getItemProperty(this.itemStartPropertyId);
+ Date start = (Date) p.getValue();
+ Date end = start; // assume same day
+ if (this.itemEndPropertyId != null) {
+ p = item.getItemProperty(this.itemEndPropertyId);
+ end = (Date) p.getValue();
+ if (end == null) {
+ end = start;
+ } else if (end.before(start)) {
+ Date tmp = start;
+ start = end;
+ end = tmp;
+ }
+ }
+
+ if (start != null) {
+ if ((start.getMonth() <= month || end.getMonth() >= month)) {
+ target.startTag("item");
+ // TODO different id!
+ target.addAttribute("id", itemId.hashCode());
+ target.addAttribute("start", "" + start.getTime());
+ if (end != start) {
+ target.addAttribute("end", "" + end.getTime());
+ }
+ if (this.itemTitlePropertyId != null) {
+ p = item.getItemProperty(this.itemTitlePropertyId);
+ Object val = p.getValue();
+ if (val != null) {
+ target.addAttribute("title", val.toString());
+ }
+ }
+ if (this.itemDescriptionPropertyId != null) {
+ p = item
+ .getItemProperty(this.itemDescriptionPropertyId);
+ Object val = p.getValue();
+ if (val != null) {
+ target.addAttribute("description", val
+ .toString());
+ }
+ }
+ if (this.itemNotimePropertyId != null) {
+ p = item.getItemProperty(this.itemNotimePropertyId);
+ Object val = p.getValue();
+ if (val != null) {
+ target.addAttribute("notime", ((Boolean) val)
+ .booleanValue());
+ }
+ }
+
+ target.endTag("item");
+ }
+ }
+ }
+
+ target.endTag("items");
+ }
}
- }
}
diff --git a/src/com/itmill/toolkit/ui/Component.java b/src/com/itmill/toolkit/ui/Component.java
index 234b8d9836..7af0485e0e 100644
--- a/src/com/itmill/toolkit/ui/Component.java
+++ b/src/com/itmill/toolkit/ui/Component.java
@@ -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
diff --git a/src/com/itmill/toolkit/ui/CustomComponent.java b/src/com/itmill/toolkit/ui/CustomComponent.java
index 79c2a5f416..56615a61c1 100644
--- a/src/com/itmill/toolkit/ui/CustomComponent.java
+++ b/src/com/itmill/toolkit/ui/CustomComponent.java
@@ -535,7 +535,7 @@ public class CustomComponent implements Component {
* @see com.itmill.toolkit.ui.Component#getStyle()
*/
public void removeStyleName(String style) {
-
+
}
}
diff --git a/src/com/itmill/toolkit/ui/CustomLayout.java b/src/com/itmill/toolkit/ui/CustomLayout.java
index 9cc263f99b..be0073a89a 100644
--- a/src/com/itmill/toolkit/ui/CustomLayout.java
+++ b/src/com/itmill/toolkit/ui/CustomLayout.java
@@ -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;
/**
diff --git a/src/com/itmill/toolkit/ui/DateField.java b/src/com/itmill/toolkit/ui/DateField.java
index 350716a595..989aca9f79 100644
--- a/src/com/itmill/toolkit/ui/DateField.java
+++ b/src/com/itmill/toolkit/ui/DateField.java
@@ -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();
diff --git a/src/com/itmill/toolkit/ui/ExpandLayout.java b/src/com/itmill/toolkit/ui/ExpandLayout.java
index 8a0b412bac..253edb8155 100644
--- a/src/com/itmill/toolkit/ui/ExpandLayout.java
+++ b/src/com/itmill/toolkit/ui/ExpandLayout.java
@@ -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;
}
diff --git a/src/com/itmill/toolkit/ui/Label.java b/src/com/itmill/toolkit/ui/Label.java
index 2f2e2ef6be..1a3684fbe7 100644
--- a/src/com/itmill/toolkit/ui/Label.java
+++ b/src/com/itmill/toolkit/ui/Label.java
@@ -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;
diff --git a/src/com/itmill/toolkit/ui/Panel.java b/src/com/itmill/toolkit/ui/Panel.java
index 80444cc94b..dd7d012097 100644
--- a/src/com/itmill/toolkit/ui/Panel.java
+++ b/src/com/itmill/toolkit/ui/Panel.java
@@ -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();
}
}
-
+
}
/**
diff --git a/src/com/itmill/toolkit/ui/Select.java b/src/com/itmill/toolkit/ui/Select.java
index c0ebf98492..961e0c9b01 100644
--- a/src/com/itmill/toolkit/ui/Select.java
+++ b/src/com/itmill/toolkit/ui/Select.java
@@ -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;
}
-
+
}
diff --git a/src/com/itmill/toolkit/ui/Slider.java b/src/com/itmill/toolkit/ui/Slider.java
index 19e6a1a9c9..20ef7d65ea 100644
--- a/src/com/itmill/toolkit/ui/Slider.java
+++ b/src/com/itmill/toolkit/ui/Slider.java
@@ -7,9 +7,8 @@ import com.itmill.toolkit.terminal.PaintTarget;
/**
* TODO comment
- *
- * Example code:
- * <code>
+ *
+ * Example code: <code>
* class MyPlayer extends CustomComponent implements ValueChangeListener {
*
* Label volumeIndicator = new Label();
@@ -38,7 +37,7 @@ import com.itmill.toolkit.terminal.PaintTarget;
* }
*
* </code>
- *
+ *
*/
public class Slider extends AbstractField {
@@ -427,7 +426,7 @@ public class Slider extends AbstractField {
* ValueOutOfBoundsException
*
* @author IT Mill Ltd.
- *
+ *
*/
public class ValueOutOfBoundsException extends Exception {
diff --git a/src/com/itmill/toolkit/ui/SplitPanel.java b/src/com/itmill/toolkit/ui/SplitPanel.java
index 71a757eff5..e18a6e9840 100644
--- a/src/com/itmill/toolkit/ui/SplitPanel.java
+++ b/src/com/itmill/toolkit/ui/SplitPanel.java
@@ -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;
}
diff --git a/src/com/itmill/toolkit/ui/TabSheet.java b/src/com/itmill/toolkit/ui/TabSheet.java
index 41409c1f83..9152e01745 100644
--- a/src/com/itmill/toolkit/ui/TabSheet.java
+++ b/src/com/itmill/toolkit/ui/TabSheet.java
@@ -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");
diff --git a/src/com/itmill/toolkit/ui/Table.java b/src/com/itmill/toolkit/ui/Table.java
index ccc6405ca8..2299383366 100644
--- a/src/com/itmill/toolkit/ui/Table.java
+++ b/src/com/itmill/toolkit/ui/Table.java
@@ -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) {
diff --git a/src/com/itmill/toolkit/ui/TextField.java b/src/com/itmill/toolkit/ui/TextField.java
index a8d1bd279c..f2d15da712 100644
--- a/src/com/itmill/toolkit/ui/TextField.java
+++ b/src/com/itmill/toolkit/ui/TextField.java
@@ -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);
}
}
diff --git a/src/com/itmill/toolkit/ui/Tree.java b/src/com/itmill/toolkit/ui/Tree.java
index 1bc4f8f968..5d84385b7e 100644
--- a/src/com/itmill/toolkit/ui/Tree.java
+++ b/src/com/itmill/toolkit/ui/Tree.java
@@ -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
diff --git a/src/com/itmill/toolkit/ui/Upload.java b/src/com/itmill/toolkit/ui/Upload.java
index 421fe9abd1..94149ac7ef 100644
--- a/src/com/itmill/toolkit/ui/Upload.java
+++ b/src/com/itmill/toolkit/ui/Upload.java
@@ -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
*/
diff --git a/src/com/itmill/toolkit/ui/Window.java b/src/com/itmill/toolkit/ui/Window.java
index bea093221c..4f30743c5b 100644
--- a/src/com/itmill/toolkit/ui/Window.java
+++ b/src/com/itmill/toolkit/ui/Window.java
@@ -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;
diff --git a/src/com/itmill/toolkit/ui/select/ContainsFilter.java b/src/com/itmill/toolkit/ui/select/ContainsFilter.java
index 9fe7906aad..6f4f353175 100644
--- a/src/com/itmill/toolkit/ui/select/ContainsFilter.java
+++ b/src/com/itmill/toolkit/ui/select/ContainsFilter.java
@@ -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);
diff --git a/src/com/itmill/toolkit/ui/select/OptionFilter.java b/src/com/itmill/toolkit/ui/select/OptionFilter.java
index 7f953829f9..3b56eede4d 100644
--- a/src/com/itmill/toolkit/ui/select/OptionFilter.java
+++ b/src/com/itmill/toolkit/ui/select/OptionFilter.java
@@ -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);
diff --git a/src/com/itmill/toolkit/ui/select/StartsWithFilter.java b/src/com/itmill/toolkit/ui/select/StartsWithFilter.java
index 1ceba53559..9972aa5ac4 100644
--- a/src/com/itmill/toolkit/ui/select/StartsWithFilter.java
+++ b/src/com/itmill/toolkit/ui/select/StartsWithFilter.java
@@ -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);