From d8a2fcb4b179e7bd3bab4c9b968216e5acddaf2b Mon Sep 17 00:00:00 2001 From: Henri Sara Date: Wed, 8 Apr 2009 13:08:02 +0000 Subject: Merged #2817 to 6.0: AbstractField.isValid() and AbstractField.validate() were inconsistent with each other for empty non-required fields; ValidationExample depended on validator side effects svn changeset:7369/svn branch:6.0 --- src/com/itmill/toolkit/data/Validator.java | 3 +++ .../demo/sampler/features/commons/ValidationExample.java | 8 +++----- src/com/itmill/toolkit/ui/AbstractField.java | 14 +++++++------- 3 files changed, 13 insertions(+), 12 deletions(-) (limited to 'src/com/itmill/toolkit') diff --git a/src/com/itmill/toolkit/data/Validator.java b/src/com/itmill/toolkit/data/Validator.java index 0e09e3de6b..d0094914ed 100644 --- a/src/com/itmill/toolkit/data/Validator.java +++ b/src/com/itmill/toolkit/data/Validator.java @@ -17,6 +17,9 @@ import com.itmill.toolkit.terminal.PaintTarget; * {@link Validator.InvalidValueException} if the given value is not valid by * its standards. * + * Validators should not have side effects on other objects as they can be + * called from Paintable.paint(). + * * @author IT Mill Ltd. * @version * @VERSION@ diff --git a/src/com/itmill/toolkit/demo/sampler/features/commons/ValidationExample.java b/src/com/itmill/toolkit/demo/sampler/features/commons/ValidationExample.java index 75bacd5b10..19444045a9 100644 --- a/src/com/itmill/toolkit/demo/sampler/features/commons/ValidationExample.java +++ b/src/com/itmill/toolkit/demo/sampler/features/commons/ValidationExample.java @@ -46,17 +46,15 @@ public class ValidationExample extends VerticalLayout { throw new Validator.InvalidValueException("Username " + value + " already in use"); } - usernames.add(value); } }); username.addListener(new ValueChangeListener() { public void valueChange(ValueChangeEvent event) { TextField tf = (TextField) event.getProperty(); tf.validate(); - if (tf.isValid()) { - addComponent(new Label("Added " + tf.getValue() - + " to usernames")); - } + usernames.add(tf.getValue()); + addComponent(new Label("Added " + tf.getValue() + + " to usernames")); } }); diff --git a/src/com/itmill/toolkit/ui/AbstractField.java b/src/com/itmill/toolkit/ui/AbstractField.java index c998236f32..4d717826e6 100644 --- a/src/com/itmill/toolkit/ui/AbstractField.java +++ b/src/com/itmill/toolkit/ui/AbstractField.java @@ -639,12 +639,10 @@ public abstract class AbstractField extends AbstractComponent implements Field, */ public boolean isValid() { - if (isRequired()) { - if (isEmpty()) { + if (isEmpty()) { + if (isRequired()) { return false; - } - } else { - if (isEmpty()) { + } else { return true; } } @@ -675,9 +673,11 @@ public abstract class AbstractField extends AbstractComponent implements Field, */ public void validate() throws Validator.InvalidValueException { - if (isRequired()) { - if (isEmpty()) { + if (isEmpty()) { + if (isRequired()) { throw new Validator.EmptyValueException(requiredError); + } else { + return; } } -- cgit v1.2.3 From 6175ddd0c13112132665a752c8beac04de7ce8d3 Mon Sep 17 00:00:00 2001 From: Matti Tahvonen Date: Thu, 9 Apr 2009 08:41:24 +0000 Subject: new component, absolutelayout (aka coordinatelayout #1267) and simple test case svn changeset:7374/svn branch:6.0 --- .../default/absolutelayout/absolutelayout.css | 4 + WebContent/ITMILL/themes/default/styles.css | 6 + WebContent/ITMILL/themes/tests-tickets/styles.css | 12 + .../terminal/gwt/client/DefaultWidgetSet.java | 5 + .../terminal/gwt/client/ui/IAbsoluteLayout.java | 320 +++++++++++++++++++++ .../toolkit/tests/layouts/TestAbsoluteLayout.java | 54 ++++ src/com/itmill/toolkit/ui/AbsoluteLayout.java | 210 ++++++++++++++ 7 files changed, 611 insertions(+) create mode 100644 WebContent/ITMILL/themes/default/absolutelayout/absolutelayout.css create mode 100644 src/com/itmill/toolkit/terminal/gwt/client/ui/IAbsoluteLayout.java create mode 100644 src/com/itmill/toolkit/tests/layouts/TestAbsoluteLayout.java create mode 100644 src/com/itmill/toolkit/ui/AbsoluteLayout.java (limited to 'src/com/itmill/toolkit') diff --git a/WebContent/ITMILL/themes/default/absolutelayout/absolutelayout.css b/WebContent/ITMILL/themes/default/absolutelayout/absolutelayout.css new file mode 100644 index 0000000000..e77e380688 --- /dev/null +++ b/WebContent/ITMILL/themes/default/absolutelayout/absolutelayout.css @@ -0,0 +1,4 @@ +.i-absolutelayout-wrapper { + position: absolute; + overflow:hidden; +} diff --git a/WebContent/ITMILL/themes/default/styles.css b/WebContent/ITMILL/themes/default/styles.css index 439f4f2aec..cc8c3fda7e 100644 --- a/WebContent/ITMILL/themes/default/styles.css +++ b/WebContent/ITMILL/themes/default/styles.css @@ -1,5 +1,11 @@ /* Automatically compiled css file from subdirectories. */ +/* ./WebContent/ITMILL/themes/default/absolutelayout/absolutelayout.css */ +.i-absolutelayout-wrapper { + position: absolute; + overflow:hidden; +} + /* ./WebContent/ITMILL/themes/default/accordion/accordion.css */ .i-accordion { position: relative; diff --git a/WebContent/ITMILL/themes/tests-tickets/styles.css b/WebContent/ITMILL/themes/tests-tickets/styles.css index 225bbd6d1d..2c2b359ed9 100644 --- a/WebContent/ITMILL/themes/tests-tickets/styles.css +++ b/WebContent/ITMILL/themes/tests-tickets/styles.css @@ -1276,4 +1276,16 @@ padding:2px; .i-button-nowraplink span { white-space: normal; } + +.cyan { + background:cyan; +} +.yellow { + background:yellow; +} + +.green { + background:green; +} + \ No newline at end of file diff --git a/src/com/itmill/toolkit/terminal/gwt/client/DefaultWidgetSet.java b/src/com/itmill/toolkit/terminal/gwt/client/DefaultWidgetSet.java index e81f5fff47..0bc849affa 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/DefaultWidgetSet.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/DefaultWidgetSet.java @@ -5,6 +5,7 @@ package com.itmill.toolkit.terminal.gwt.client; import com.google.gwt.user.client.ui.Widget; +import com.itmill.toolkit.terminal.gwt.client.ui.IAbsoluteLayout; import com.itmill.toolkit.terminal.gwt.client.ui.IAccordion; import com.itmill.toolkit.terminal.gwt.client.ui.IButton; import com.itmill.toolkit.terminal.gwt.client.ui.ICheckBox; @@ -139,6 +140,8 @@ public class DefaultWidgetSet implements WidgetSet { return new IPopupView(); } else if (IUriFragmentUtility.class == classType) { return new IUriFragmentUtility(); + } else if (IAbsoluteLayout.class == classType) { + return new IAbsoluteLayout(); } return new IUnknownComponent(); @@ -249,6 +252,8 @@ public class DefaultWidgetSet implements WidgetSet { return IPopupView.class; } else if ("urifragment".equals(tag)) { return IUriFragmentUtility.class; + } else if (IAbsoluteLayout.TAGNAME.equals(tag)) { + return IAbsoluteLayout.class; } return IUnknownComponent.class; diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IAbsoluteLayout.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IAbsoluteLayout.java new file mode 100644 index 0000000000..fc1f14cb83 --- /dev/null +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IAbsoluteLayout.java @@ -0,0 +1,320 @@ +package com.itmill.toolkit.terminal.gwt.client.ui; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; +import java.util.Map.Entry; + +import com.google.gwt.dom.client.DivElement; +import com.google.gwt.dom.client.Document; +import com.google.gwt.dom.client.Style; +import com.google.gwt.user.client.DOM; +import com.google.gwt.user.client.Element; +import com.google.gwt.user.client.ui.ComplexPanel; +import com.google.gwt.user.client.ui.SimplePanel; +import com.google.gwt.user.client.ui.Widget; +import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection; +import com.itmill.toolkit.terminal.gwt.client.BrowserInfo; +import com.itmill.toolkit.terminal.gwt.client.Container; +import com.itmill.toolkit.terminal.gwt.client.Paintable; +import com.itmill.toolkit.terminal.gwt.client.RenderSpace; +import com.itmill.toolkit.terminal.gwt.client.UIDL; + +public class IAbsoluteLayout extends ComplexPanel implements Container { + + /** Tag name for widget creation */ + public static final String TAGNAME = "absolutelayout"; + + /** Class name, prefix in styling */ + public static final String CLASSNAME = "i-absolutelayout"; + + private DivElement marginElement; + + private Element canvas; + + private int excessPixelsHorizontal; + + private int excessPixelsVertical; + + private Object previousStyleName; + + private Map pidToComponentWrappper = new HashMap(); + + private ApplicationConnection client; + + private boolean rendering; + + public IAbsoluteLayout() { + setElement(Document.get().createDivElement()); + setStyleName(CLASSNAME); + marginElement = Document.get().createDivElement(); + canvas = DOM.createDiv(); + canvas.getStyle().setProperty("position", "relative"); + marginElement.appendChild(canvas); + getElement().appendChild(marginElement); + } + + public RenderSpace getAllocatedSpace(Widget child) { + // TODO needs some special handling for components with only on edge + // horizontally or vertically defined + AbsoluteWrapper wrapper = (AbsoluteWrapper) child.getParent(); + int w; + if (wrapper.left != null && wrapper.right != null) { + w = wrapper.getOffsetWidth(); + } else if (wrapper.right != null) { + // left == null + // available width == right edge == offsetleft + width + w = wrapper.getOffsetWidth() + wrapper.getElement().getOffsetLeft(); + } else { + // left != null && right == null || left == null && + // right == null + // available width == canvas width - offset left + w = canvas.getOffsetWidth() - wrapper.getElement().getOffsetLeft(); + } + int h; + if (wrapper.top != null && wrapper.bottom != null) { + h = wrapper.getOffsetHeight(); + } else if (wrapper.bottom != null) { + // top not defined, available space 0... bottom of wrapper + h = wrapper.getElement().getOffsetTop() + wrapper.getOffsetHeight(); + } else { + // top defined or both undefined, available space == canvas - top + h = canvas.getOffsetHeight() - wrapper.getElement().getOffsetTop(); + } + + return new RenderSpace(w, h); + } + + public boolean hasChildComponent(Widget component) { + for (Iterator> iterator = pidToComponentWrappper + .entrySet().iterator(); iterator.hasNext();) { + if (iterator.next().getValue().paintable == component) { + return true; + } + } + return false; + } + + public void replaceChildComponent(Widget oldComponent, Widget newComponent) { + for (Widget wrapper : getChildren()) { + AbsoluteWrapper w = (AbsoluteWrapper) wrapper; + if (w.getWidget() == oldComponent) { + w.setWidget(newComponent); + return; + } + } + } + + public boolean requestLayout(Set children) { + // component inside an absolute panel never affects parent nor the + // layout + return true; + } + + public void updateCaption(Paintable component, UIDL uidl) { + // TODO Auto-generated method stub + + } + + public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { + rendering = true; + this.client = client; + // TODO margin handling + if (client.updateComponent(this, uidl, true)) { + rendering = false; + return; + } + + HashSet unrenderedPids = new HashSet( + pidToComponentWrappper.keySet()); + + for (Iterator childIterator = uidl.getChildIterator(); childIterator + .hasNext();) { + UIDL cc = childIterator.next(); + UIDL componentUIDL = cc.getChildUIDL(0); + unrenderedPids.remove(componentUIDL.getId()); + getWrapper(client, componentUIDL).updateFromUIDL(cc); + } + + for (String pid : unrenderedPids) { + AbsoluteWrapper absoluteWrapper = pidToComponentWrappper.get(pid); + pidToComponentWrappper.remove(pid); + absoluteWrapper.destroy(); + } + rendering = false; + } + + private AbsoluteWrapper getWrapper(ApplicationConnection client, + UIDL componentUIDL) { + AbsoluteWrapper wrapper = pidToComponentWrappper.get(componentUIDL + .getId()); + if (wrapper == null) { + wrapper = new AbsoluteWrapper(client.getPaintable(componentUIDL)); + pidToComponentWrappper.put(componentUIDL.getId(), wrapper); + add(wrapper); + } + return wrapper; + + } + + @Override + public void add(Widget child) { + super.add(child, canvas); + } + + @Override + public void setStyleName(String style) { + super.setStyleName(style); + if (previousStyleName == null || !previousStyleName.equals(style)) { + excessPixelsHorizontal = -1; + excessPixelsVertical = -1; + } + } + + @Override + public void setWidth(String width) { + super.setWidth(width); + // TODO do this so that canvas gets the sized properly (the area + // inside marginals) + canvas.getStyle().setProperty("width", width); + + if (!rendering && BrowserInfo.get().isIE6()) { + relayoutWrappersForIe6(); + } + } + + @Override + public void setHeight(String height) { + super.setHeight(height); + // TODO do this so that canvas gets the sized properly (the area + // inside marginals) + canvas.getStyle().setProperty("height", height); + + if (!rendering && BrowserInfo.get().isIE6()) { + relayoutWrappersForIe6(); + } + } + + private void relayoutWrappersForIe6() { + for (Widget wrapper : getChildren()) { + ((AbsoluteWrapper) wrapper).ie6Layout(); + } + } + + public class AbsoluteWrapper extends SimplePanel { + private String css; + private String left; + private String top; + private String right; + private String bottom; + private String zIndex; + + private Paintable paintable; + + public AbsoluteWrapper(Paintable paintable) { + this.paintable = paintable; + setStyleName(CLASSNAME + "-wrapper"); + } + + public void destroy() { + client.unregisterPaintable(paintable); + removeFromParent(); + } + + public void updateFromUIDL(UIDL componentUIDL) { + setPosition(componentUIDL.getStringAttribute("css")); + if (getWidget() != paintable) { + setWidget((Widget) paintable); + } + paintable.updateFromUIDL(componentUIDL.getChildUIDL(0), client); + } + + public void setPosition(String stringAttribute) { + if (css == null || !css.equals(stringAttribute)) { + css = stringAttribute; + top = right = bottom = left = zIndex = null; + if (!css.equals("")) { + String[] properties = css.split(";"); + for (int i = 0; i < properties.length; i++) { + String[] keyValue = properties[i].split(":"); + if (keyValue[0].equals("left")) { + left = keyValue[1]; + } else if (keyValue[0].equals("top")) { + top = keyValue[1]; + } else if (keyValue[0].equals("right")) { + right = keyValue[1]; + } else if (keyValue[0].equals("bottom")) { + bottom = keyValue[1]; + } else if (keyValue[0].equals("z-index")) { + zIndex = keyValue[1]; + } + } + } + // ensure ne values + Style style = getElement().getStyle(); + style.setProperty("zIndex", zIndex); + style.setProperty("top", top); + style.setProperty("left", left); + style.setProperty("right", right); + style.setProperty("bottom", bottom); + + if (BrowserInfo.get().isIE6()) { + ie6Layout(); + } + } + + } + + private void ie6Layout() { + // special handling for IE6 is needed, it does not support + // setting both left/right or top/bottom + Style style = getElement().getStyle(); + if (bottom != null && top != null) { + // define height for wrapper to simulate bottom property + int bottompixels = measureForIE6(bottom); + ApplicationConnection.getConsole().log("ALB" + bottompixels); + int height = canvas.getOffsetHeight() - bottompixels + - getElement().getOffsetTop(); + ApplicationConnection.getConsole().log("ALB" + height); + if (height < 0) { + height = 0; + } + style.setPropertyPx("height", height); + } else { + // reset possibly existing value + style.setProperty("height", ""); + } + if (left != null && right != null) { + // define width for wrapper to simulate right property + int rightPixels = measureForIE6(right); + ApplicationConnection.getConsole().log("ALR" + rightPixels); + int width = canvas.getOffsetWidth() - rightPixels + - getElement().getOffsetWidth(); + ApplicationConnection.getConsole().log("ALR" + width); + if (width < 0) { + width = 0; + } + style.setPropertyPx("width", width); + } else { + // reset possibly existing value + style.setProperty("width", ""); + } + } + + } + + private Element measureElement; + + private int measureForIE6(String cssLength) { + if (measureElement == null) { + measureElement = DOM.createDiv(); + measureElement.getStyle().setProperty("position", "absolute"); + canvas.appendChild(measureElement); + } + measureElement.getStyle().setProperty("width", cssLength); + return measureElement.getOffsetWidth(); + } + +} diff --git a/src/com/itmill/toolkit/tests/layouts/TestAbsoluteLayout.java b/src/com/itmill/toolkit/tests/layouts/TestAbsoluteLayout.java new file mode 100644 index 0000000000..6631df2963 --- /dev/null +++ b/src/com/itmill/toolkit/tests/layouts/TestAbsoluteLayout.java @@ -0,0 +1,54 @@ +package com.itmill.toolkit.tests.layouts; + +import com.itmill.toolkit.tests.components.TestBase; +import com.itmill.toolkit.ui.AbsoluteLayout; +import com.itmill.toolkit.ui.Button; +import com.itmill.toolkit.ui.Label; + +public class TestAbsoluteLayout extends TestBase { + + @Override + protected String getDescription() { + return "This is absolute layout tester."; + } + + @Override + protected Integer getTicketNumber() { + return null; + } + + @Override + protected void setup() { + AbsoluteLayout layout = new AbsoluteLayout(); + setTheme("tests-tickets"); + layout.setStyleName("cyan"); + + layout.addComponent(new Label("Hello World")); + + Button button = new Button("Centered button,z-index:10;"); + button.setSizeFull(); + layout.addComponent(button, + "top:40%;bottom:40%;right:20%;left:20%;z-index:10;"); + + Label label = new Label( + "Exotic positioned label. Fullsize, top:100px; left:2cm; right: 3.5in; bottom:12.12mm "); + label.setStyleName("yellow"); + label.setSizeFull(); + layout.addComponent(label, + "top:100px; left:2cm; right: 3.5in; bottom:12.12mm"); + + label = new Label("fullize, bottom:80%;left:80%;"); + label.setStyleName("green"); + label.setSizeFull(); + layout.addComponent(label, "bottom:80%;left:80%;"); + + label = new Label("bottomright"); + label.setSizeUndefined(); + label.setStyleName("green"); + layout.addComponent(label, "bottom:0px; right:0px;"); + + getLayout().setSizeFull(); + getLayout().addComponent(layout); + + } +} diff --git a/src/com/itmill/toolkit/ui/AbsoluteLayout.java b/src/com/itmill/toolkit/ui/AbsoluteLayout.java new file mode 100644 index 0000000000..61a12bb76f --- /dev/null +++ b/src/com/itmill/toolkit/ui/AbsoluteLayout.java @@ -0,0 +1,210 @@ +package com.itmill.toolkit.ui; + +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map; + +import com.itmill.toolkit.terminal.PaintException; +import com.itmill.toolkit.terminal.PaintTarget; +import com.itmill.toolkit.terminal.gwt.client.ui.IAbsoluteLayout; + +/** + * AbsoluteLayout is a layout implementation that mimics html absolute + * positioning. + * + */ +public class AbsoluteLayout extends AbstractLayout { + + private Collection components = new HashSet(); + private Map componentToCoordinates = new HashMap(); + + public AbsoluteLayout() { + setSizeFull(); + } + + @Override + public String getTag() { + return IAbsoluteLayout.TAGNAME; + } + + public Iterator getComponentIterator() { + return components.iterator(); + } + + public void replaceComponent(Component oldComponent, Component newComponent) { + ComponentPosition position = getPosition(oldComponent); + removeComponent(oldComponent); + addComponent(newComponent); + componentToCoordinates.put(newComponent, position); + } + + @Override + public void addComponent(Component c) { + components.add(c); + super.addComponent(c); + } + + @Override + public void removeComponent(Component c) { + components.remove(c); + super.removeComponent(c); + } + + public void addComponent(Component c, String cssPosition) { + addComponent(c); + getPosition(c).setCSSString(cssPosition); + } + + public ComponentPosition getPosition(Component component) { + if (componentToCoordinates.containsKey(component)) { + return componentToCoordinates.get(component); + } else { + ComponentPosition coords = new ComponentPosition(); + componentToCoordinates.put(component, coords); + return coords; + } + } + + /** + * TODO symmetric getters and setters for fields to make this simpler to use + * in generic java tools + * + */ + public class ComponentPosition { + + private int zIndex = -1; + private float top = -1; + private float right = -1; + private float bottom = -1; + private float left = -1; + + private int topUnits; + private int rightUnits; + private int bottomUnits; + private int leftUnits; + + /** + * Sets the position attributes using CSS syntax. Example usage: + * + *
+         * setCSSString("top:10px;left:20%;z-index:16;");
+         * 
+ * + * @param css + */ + public void setCSSString(String css) { + String[] cssProperties = css.split(";"); + for (int i = 0; i < cssProperties.length; i++) { + String[] keyValuePair = cssProperties[i].split(":"); + String key = keyValuePair[0].trim(); + if (key.equals("z-index")) { + zIndex = Integer.parseInt(keyValuePair[1]); + } else { + String value = keyValuePair[1].trim(); + String unit = value.replaceAll("[0-9\\.]+", ""); + if (!unit.equals("")) { + value = value.substring(0, value.indexOf(unit)).trim(); + } + float v = Float.parseFloat(value); + int unitInt = parseCssUnit(unit); + if (key.equals("top")) { + top = v; + topUnits = unitInt; + } else if (key.equals("right")) { + right = v; + rightUnits = unitInt; + } else if (key.equals("bottom")) { + bottom = v; + bottomUnits = unitInt; + } else if (key.equals("left")) { + left = v; + leftUnits = unitInt; + } + } + } + requestRepaint(); + } + + private int parseCssUnit(String string) { + for (int i = 0; i < UNIT_SYMBOLS.length; i++) { + if (UNIT_SYMBOLS[i].equals(string)) { + return i; + } + } + return 0; // defaults to px (eg. top:0;) + } + + public String getCSSString() { + String s = ""; + if (top >= 0) { + s += "top:" + top + UNIT_SYMBOLS[topUnits] + ";"; + } + if (right >= 0) { + s += "right:" + right + UNIT_SYMBOLS[rightUnits] + ";"; + } + if (bottom >= 0) { + s += "bottom:" + bottom + UNIT_SYMBOLS[bottomUnits] + ";"; + } + if (left >= 0) { + s += "left:" + left + UNIT_SYMBOLS[leftUnits] + ";"; + } + if (zIndex >= 0) { + s += "z-index:" + zIndex + ";"; + } + return s; + } + + public void setTop(float topValue, int topUnits) { + validateLength(topValue, topUnits); + top = topValue; + this.topUnits = topUnits; + requestRepaint(); + } + + public void setRight(float rightValue, int rightUnits) { + validateLength(rightValue, rightUnits); + right = rightValue; + this.rightUnits = rightUnits; + requestRepaint(); + } + + public void setBottom(float bottomValue, int units) { + validateLength(bottomValue, units); + bottom = bottomValue; + bottomUnits = units; + requestRepaint(); + } + + public void setLeft(float leftValue, int units) { + validateLength(leftValue, units); + left = leftValue; + leftUnits = units; + requestRepaint(); + } + + public void setZIndex(int zIndex) { + this.zIndex = zIndex; + requestRepaint(); + } + + } + + @Override + public void paintContent(PaintTarget target) throws PaintException { + super.paintContent(target); + for (Component component : components) { + target.startTag("cc"); + target.addAttribute("css", getPosition(component).getCSSString()); + component.paint(target); + target.endTag("cc"); + } + } + + private static void validateLength(float topValue, int topUnits2) { + // TODO throw on invalid value + + } + +} -- cgit v1.2.3 From 4bb8706b53c3842971246920f380984ab0f1271d Mon Sep 17 00:00:00 2001 From: Matti Tahvonen Date: Thu, 9 Apr 2009 11:52:51 +0000 Subject: better test case for AbsoluteLayout. "Köyhän miehen wysiwyg" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit svn changeset:7377/svn branch:6.0 --- .../toolkit/tests/layouts/TestAbsoluteLayout.java | 158 +++++++++++++++++++++ 1 file changed, 158 insertions(+) (limited to 'src/com/itmill/toolkit') diff --git a/src/com/itmill/toolkit/tests/layouts/TestAbsoluteLayout.java b/src/com/itmill/toolkit/tests/layouts/TestAbsoluteLayout.java index 6631df2963..0550652c93 100644 --- a/src/com/itmill/toolkit/tests/layouts/TestAbsoluteLayout.java +++ b/src/com/itmill/toolkit/tests/layouts/TestAbsoluteLayout.java @@ -1,12 +1,63 @@ package com.itmill.toolkit.tests.layouts; +import java.util.Arrays; +import java.util.Iterator; + +import com.itmill.toolkit.data.Container; +import com.itmill.toolkit.data.Item; +import com.itmill.toolkit.data.Property; +import com.itmill.toolkit.data.Property.ValueChangeEvent; +import com.itmill.toolkit.data.Property.ValueChangeListener; +import com.itmill.toolkit.data.util.BeanItem; +import com.itmill.toolkit.data.util.IndexedContainer; import com.itmill.toolkit.tests.components.TestBase; import com.itmill.toolkit.ui.AbsoluteLayout; +import com.itmill.toolkit.ui.AbstractComponent; +import com.itmill.toolkit.ui.BaseFieldFactory; import com.itmill.toolkit.ui.Button; +import com.itmill.toolkit.ui.Component; +import com.itmill.toolkit.ui.Field; +import com.itmill.toolkit.ui.FieldFactory; +import com.itmill.toolkit.ui.Form; import com.itmill.toolkit.ui.Label; +import com.itmill.toolkit.ui.NativeSelect; +import com.itmill.toolkit.ui.TextField; +import com.itmill.toolkit.ui.Window; +import com.itmill.toolkit.ui.Button.ClickEvent; public class TestAbsoluteLayout extends TestBase { + private static class MFieldFactory extends BaseFieldFactory { + @Override + public Field createField(Container container, Object itemId, + Object propertyId, Component uiContext) { + // TODO Auto-generated method stub + return super.createField(container, itemId, propertyId, uiContext); + } + + @Override + public Field createField(Item item, Object propertyId, + Component uiContext) { + if (propertyId.equals("CSSString")) { + TextField f = new TextField(); + f.setRows(5); + f.setHeight("8em"); + f.setCaption("CSS string"); + return f; + } + return super.createField(item, propertyId, uiContext); + } + + private static MFieldFactory instance; + + public static FieldFactory get() { + if (instance == null) { + instance = new MFieldFactory(); + } + return instance; + } + }; + @Override protected String getDescription() { return "This is absolute layout tester."; @@ -22,6 +73,8 @@ public class TestAbsoluteLayout extends TestBase { AbsoluteLayout layout = new AbsoluteLayout(); setTheme("tests-tickets"); layout.setStyleName("cyan"); + layout.setWidth("1000px"); + layout.setHeight("500px"); layout.addComponent(new Label("Hello World")); @@ -50,5 +103,110 @@ public class TestAbsoluteLayout extends TestBase { getLayout().setSizeFull(); getLayout().addComponent(layout); + getMainWindow().addWindow(new EditorWindow(layout)); + } + + public class EditorWindow extends Window { + private final AbsoluteLayout l; + private Form componentEditor; + private Form positionEditor; + + public EditorWindow(AbsoluteLayout lo) { + super("AbsoluteLayout editor aka köyhän miehen wysiwyg"); + l = lo; + + setHeight("600px"); + + Button componentChooser = new Button("choose component to edit"); + componentChooser.addListener(new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + final Window chooser = new Window("Choose component"); + chooser.getLayout().setSizeUndefined(); + chooser.setModal(true); + + NativeSelect select = new NativeSelect( + "Choose component to edit"); + + select.setNullSelectionAllowed(false); + + IndexedContainer container = new IndexedContainer(); + container.addContainerProperty("caption", String.class, ""); + Iterator componentIterator = l + .getComponentIterator(); + while (componentIterator.hasNext()) { + AbstractComponent next = (AbstractComponent) componentIterator + .next(); + Item item = container.addItem(next); + + String caption = next.getTag(); + + caption += "; cap: " + next.getCaption() + "; debugid" + + getDebugId(); + + if (next instanceof Property) { + caption += " value:" + ((Property) next).getValue(); + } + + item.getItemProperty("caption").setValue(caption); + } + select.setContainerDataSource(container); + select.setItemCaptionPropertyId("caption"); + select.setImmediate(true); + + select.addListener(new ValueChangeListener() { + public void valueChange(ValueChangeEvent event) { + editcomponent((Component) event.getProperty() + .getValue()); + getMainWindow().removeWindow(chooser); + } + + }); + + chooser.addComponent(select); + + getMainWindow().addWindow(chooser); + + } + }); + + addComponent(componentChooser); + + componentEditor = new Form(); + componentEditor.setWriteThrough(false); + componentEditor.setCaption("Component properties:"); + componentEditor.setFieldFactory(MFieldFactory.get()); + addComponent(componentEditor); + + positionEditor = new Form(); + positionEditor.setCaption("Component position"); + positionEditor.setWriteThrough(false); + positionEditor.setFieldFactory(MFieldFactory.get()); + addComponent(positionEditor); + + Button b = new Button("Commit changes", new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + positionEditor.commit(); + componentEditor.commit(); + } + }); + addComponent(b); + + } + + private void editcomponent(Component value) { + + BeanItem beanItem = new BeanItem(value); + componentEditor.setItemDataSource(beanItem, Arrays + .asList(new String[] { "width", "widthUnits", "height", + "heightUnits", "caption", "styleName" })); + + beanItem = new BeanItem(l.getPosition(value)); + + positionEditor.setItemDataSource(beanItem); + + } + + } + } -- cgit v1.2.3 From 800582d3c3a6b194f293b814f9f04e33a3f39a99 Mon Sep 17 00:00:00 2001 From: Matti Tahvonen Date: Thu, 9 Apr 2009 12:08:37 +0000 Subject: enhancing test case svn changeset:7378/svn branch:6.0 --- .../toolkit/tests/layouts/TestAbsoluteLayout.java | 27 ++++++++++++++++------ 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'src/com/itmill/toolkit') diff --git a/src/com/itmill/toolkit/tests/layouts/TestAbsoluteLayout.java b/src/com/itmill/toolkit/tests/layouts/TestAbsoluteLayout.java index 0550652c93..cf78880dac 100644 --- a/src/com/itmill/toolkit/tests/layouts/TestAbsoluteLayout.java +++ b/src/com/itmill/toolkit/tests/layouts/TestAbsoluteLayout.java @@ -3,7 +3,6 @@ package com.itmill.toolkit.tests.layouts; import java.util.Arrays; import java.util.Iterator; -import com.itmill.toolkit.data.Container; import com.itmill.toolkit.data.Item; import com.itmill.toolkit.data.Property; import com.itmill.toolkit.data.Property.ValueChangeEvent; @@ -20,6 +19,7 @@ import com.itmill.toolkit.ui.Field; import com.itmill.toolkit.ui.FieldFactory; import com.itmill.toolkit.ui.Form; import com.itmill.toolkit.ui.Label; +import com.itmill.toolkit.ui.Layout; import com.itmill.toolkit.ui.NativeSelect; import com.itmill.toolkit.ui.TextField; import com.itmill.toolkit.ui.Window; @@ -28,12 +28,6 @@ import com.itmill.toolkit.ui.Button.ClickEvent; public class TestAbsoluteLayout extends TestBase { private static class MFieldFactory extends BaseFieldFactory { - @Override - public Field createField(Container container, Object itemId, - Object propertyId, Component uiContext) { - // TODO Auto-generated method stub - return super.createField(container, itemId, propertyId, uiContext); - } @Override public Field createField(Item item, Object propertyId, @@ -44,7 +38,20 @@ public class TestAbsoluteLayout extends TestBase { f.setHeight("8em"); f.setCaption("CSS string"); return f; + } else if (((String) propertyId).contains("Units")) { + NativeSelect s = new NativeSelect() { + }; + s.addContainerProperty("caption", String.class, ""); + s.setItemCaptionPropertyId("caption"); + s.setNullSelectionAllowed(false); + for (int i = 0; i < Layout.UNIT_SYMBOLS.length; i++) { + Item unitItem = s.addItem(i); + unitItem.getItemProperty("caption").setValue( + Layout.UNIT_SYMBOLS[i]); + } + return s; } + return super.createField(item, propertyId, uiContext); } @@ -202,6 +209,12 @@ public class TestAbsoluteLayout extends TestBase { "heightUnits", "caption", "styleName" })); beanItem = new BeanItem(l.getPosition(value)); + String c = "Component properties for " + + value.getClass().getSimpleName(); + if (value instanceof Label) { + c += "(" + ((Label) value).getValue() + ")"; + } + componentEditor.setCaption(c); positionEditor.setItemDataSource(beanItem); -- cgit v1.2.3 From 3d95383d3f0f7332fc84c9df0be0d2795f5935b8 Mon Sep 17 00:00:00 2001 From: Matti Tahvonen Date: Thu, 9 Apr 2009 12:56:09 +0000 Subject: absolutelayout: predictable order, cssstring parsing checks svn changeset:7379/svn branch:6.0 --- src/com/itmill/toolkit/ui/AbsoluteLayout.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/com/itmill/toolkit') diff --git a/src/com/itmill/toolkit/ui/AbsoluteLayout.java b/src/com/itmill/toolkit/ui/AbsoluteLayout.java index 61a12bb76f..72e9526552 100644 --- a/src/com/itmill/toolkit/ui/AbsoluteLayout.java +++ b/src/com/itmill/toolkit/ui/AbsoluteLayout.java @@ -2,8 +2,8 @@ package com.itmill.toolkit.ui; import java.util.Collection; import java.util.HashMap; -import java.util.HashSet; import java.util.Iterator; +import java.util.LinkedHashSet; import java.util.Map; import com.itmill.toolkit.terminal.PaintException; @@ -17,7 +17,7 @@ import com.itmill.toolkit.terminal.gwt.client.ui.IAbsoluteLayout; */ public class AbsoluteLayout extends AbstractLayout { - private Collection components = new HashSet(); + private Collection components = new LinkedHashSet(); private Map componentToCoordinates = new HashMap(); public AbsoluteLayout() { @@ -99,10 +99,18 @@ public class AbsoluteLayout extends AbstractLayout { for (int i = 0; i < cssProperties.length; i++) { String[] keyValuePair = cssProperties[i].split(":"); String key = keyValuePair[0].trim(); + if (key.equals("")) { + continue; + } if (key.equals("z-index")) { zIndex = Integer.parseInt(keyValuePair[1]); } else { - String value = keyValuePair[1].trim(); + String value; + if (keyValuePair.length > 1) { + value = keyValuePair[1].trim(); + } else { + value = ""; + } String unit = value.replaceAll("[0-9\\.]+", ""); if (!unit.equals("")) { value = value.substring(0, value.indexOf(unit)).trim(); -- cgit v1.2.3 From 64096660cee48f80291763799fe9872bce908f43 Mon Sep 17 00:00:00 2001 From: Matti Tahvonen Date: Thu, 9 Apr 2009 12:57:22 +0000 Subject: improvements for test case svn changeset:7380/svn branch:6.0 --- .../toolkit/tests/layouts/TestAbsoluteLayout.java | 99 ++++++++++++++++++++-- 1 file changed, 93 insertions(+), 6 deletions(-) (limited to 'src/com/itmill/toolkit') diff --git a/src/com/itmill/toolkit/tests/layouts/TestAbsoluteLayout.java b/src/com/itmill/toolkit/tests/layouts/TestAbsoluteLayout.java index cf78880dac..f3c02dce3d 100644 --- a/src/com/itmill/toolkit/tests/layouts/TestAbsoluteLayout.java +++ b/src/com/itmill/toolkit/tests/layouts/TestAbsoluteLayout.java @@ -1,5 +1,8 @@ package com.itmill.toolkit.tests.layouts; +import java.io.File; +import java.net.URL; +import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; @@ -179,6 +182,88 @@ public class TestAbsoluteLayout extends TestBase { addComponent(componentChooser); + Button addComp = new Button("add component"); + addComp.addListener(new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + final Window chooser = new Window( + "Choose component type to add"); + chooser.getLayout().setSizeUndefined(); + chooser.setModal(true); + + NativeSelect select = new NativeSelect( + "Choose component to edit"); + + select.setNullSelectionAllowed(false); + + IndexedContainer container = new IndexedContainer(); + + URL resource = AbstractComponent.class.getResource("."); + File directory = new File(resource.getFile()); + if (directory.exists()) { + // Get the list of the files contained in the + // package + final String[] files = directory.list(); + for (int j = 0; j < files.length; j++) { + // we are only interested in .class files + if (files[j].endsWith(".class")) { + // removes the .class extension + String p = resource.toString() + + files[j].substring(0, files[j] + .length() - 6); + p = p.replaceAll(".*classes/", ""); + p = p.replaceAll("/", "."); + Class c; + try { + c = Class.forName(p); + if (AbstractComponent.class + .isAssignableFrom(c) + && !p.toLowerCase().contains( + "layout") + && !p.toLowerCase().contains( + "abstract")) { + container.addItem(c); + } + } catch (ClassNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + } + select.setContainerDataSource(container); + select.setImmediate(true); + + select.addListener(new ValueChangeListener() { + public void valueChange(ValueChangeEvent event) { + Class c = (Class) event.getProperty().getValue(); + + try { + Component newInstance = (Component) c + .newInstance(); + l.addComponent(newInstance); + editcomponent(newInstance); + getMainWindow().removeWindow(chooser); + } catch (InstantiationException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IllegalAccessException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + }); + + chooser.addComponent(select); + + getMainWindow().addWindow(chooser); + + } + }); + + addComponent(addComp); + componentEditor = new Form(); componentEditor.setWriteThrough(false); componentEditor.setCaption("Component properties:"); @@ -204,22 +289,24 @@ public class TestAbsoluteLayout extends TestBase { private void editcomponent(Component value) { BeanItem beanItem = new BeanItem(value); - componentEditor.setItemDataSource(beanItem, Arrays - .asList(new String[] { "width", "widthUnits", "height", - "heightUnits", "caption", "styleName" })); - - beanItem = new BeanItem(l.getPosition(value)); String c = "Component properties for " + value.getClass().getSimpleName(); + ArrayList fields = new ArrayList(Arrays + .asList(new String[] { "width", "widthUnits", "height", + "heightUnits", "caption", "styleName" })); if (value instanceof Label) { c += "(" + ((Label) value).getValue() + ")"; + fields.add("value"); } + + componentEditor.setItemDataSource(beanItem, fields); + + beanItem = new BeanItem(l.getPosition(value)); componentEditor.setCaption(c); positionEditor.setItemDataSource(beanItem); } - } } -- cgit v1.2.3 From 8c21a6f36ea05bfa48b34d6162bc5a2fe3fa488b Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Thu, 9 Apr 2009 13:04:37 +0000 Subject: Merged fix for #2839 - Form should not measure borders before style names are set. svn changeset:7382/svn branch:6.0 --- src/com/itmill/toolkit/terminal/gwt/client/ui/IForm.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/com/itmill/toolkit') 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 0b91268d25..1639b6693b 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IForm.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IForm.java @@ -75,11 +75,10 @@ public class IForm extends ComplexPanel implements Container { public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { rendering = true; - + boolean measure = false; if (this.client == null) { this.client = client; - borderPaddingVertical = getOffsetHeight(); - borderPaddingHorizontal = getOffsetWidth() - desc.getOffsetWidth(); + measure = true; } if (client.updateComponent(this, uidl, false)) { @@ -87,6 +86,14 @@ public class IForm extends ComplexPanel implements Container { return; } + if (measure) { + // Measure the border when the style names have been set + borderPaddingVertical = getOffsetHeight(); + int ow = getOffsetWidth(); + int dow = desc.getOffsetWidth(); + borderPaddingHorizontal = ow - dow; + } + boolean legendEmpty = true; if (uidl.hasAttribute("caption")) { DOM.setInnerText(caption, uidl.getStringAttribute("caption")); -- cgit v1.2.3 From 204a857eb54f1840f27969faa9855c38390d2751 Mon Sep 17 00:00:00 2001 From: Joonas Lehtinen Date: Sun, 12 Apr 2009 00:07:09 +0000 Subject: Implementation serialization support for Toolkit. Fixes #695 svn changeset:7387/svn branch:6.0 --- src/com/itmill/toolkit/Application.java | 33 +-- .../toolkit/automatedtests/ComponentsInTable.java | 2 + .../automatedtests/SimplestApplication.java | 1 + .../featurebrowser/AccordionExample.java | 2 + .../featurebrowser/ButtonExample.java | 2 + .../featurebrowser/ClientCachingExample.java | 3 + .../featurebrowser/ComboBoxExample.java | 2 + .../featurebrowser/EmbeddedBrowserExample.java | 2 + .../featurebrowser/FeatureBrowser.java | 15 +- .../automatedtests/featurebrowser/FormExample.java | 18 +- .../featurebrowser/GeneratedColumnExample.java | 14 +- .../toolkit/automatedtests/util/DebugId.java | 3 +- .../itmill/toolkit/automatedtests/util/Log.java | 3 +- .../automatedtests/util/RandomComponents.java | 3 +- src/com/itmill/toolkit/data/Buffered.java | 12 +- .../itmill/toolkit/data/BufferedValidatable.java | 5 +- src/com/itmill/toolkit/data/Container.java | 35 ++-- src/com/itmill/toolkit/data/Item.java | 15 +- src/com/itmill/toolkit/data/Property.java | 34 ++- src/com/itmill/toolkit/data/Validatable.java | 5 +- src/com/itmill/toolkit/data/Validator.java | 4 +- src/com/itmill/toolkit/data/util/BeanItem.java | 3 +- .../toolkit/data/util/BeanItemContainer.java | 15 +- .../data/util/ContainerHierarchicalWrapper.java | 1 + .../toolkit/data/util/ContainerOrderedWrapper.java | 1 + .../toolkit/data/util/FilesystemContainer.java | 12 +- src/com/itmill/toolkit/data/util/Filter.java | 5 +- .../toolkit/data/util/HierarchicalContainer.java | 1 + .../itmill/toolkit/data/util/IndexedContainer.java | 22 +- .../itmill/toolkit/data/util/MethodProperty.java | 53 +++-- .../itmill/toolkit/data/util/ObjectProperty.java | 11 +- .../toolkit/data/util/PropertyFormatter.java | 11 +- .../itmill/toolkit/data/util/PropertysetItem.java | 6 +- .../itmill/toolkit/data/util/QueryContainer.java | 1 + .../data/validator/AbstractStringValidator.java | 1 + .../toolkit/data/validator/AbstractValidator.java | 1 + .../toolkit/data/validator/CompositeValidator.java | 1 + .../toolkit/data/validator/DoubleValidator.java | 1 + .../toolkit/data/validator/EmailValidator.java | 1 + .../toolkit/data/validator/IntegerValidator.java | 1 + .../toolkit/data/validator/NullValidator.java | 1 + .../toolkit/data/validator/RegexpValidator.java | 1 + .../data/validator/StringLengthValidator.java | 1 + src/com/itmill/toolkit/demo/HelloWorld.java | 8 +- .../itmill/toolkit/demo/ToolkitTunesLayout.java | 1 + .../itmill/toolkit/demo/sampler/ActiveLink.java | 3 +- src/com/itmill/toolkit/demo/sampler/Feature.java | 7 +- .../toolkit/demo/sampler/SamplerApplication.java | 2 +- .../demo/tutorial/addressbook/data/Person.java | 228 +++++++++++---------- .../tutorial/addressbook/data/PersonContainer.java | 158 +++++++------- .../tutorial/addressbook/data/SearchFilter.java | 76 +++---- src/com/itmill/toolkit/event/Action.java | 9 +- src/com/itmill/toolkit/event/EventRouter.java | 1 + src/com/itmill/toolkit/event/ItemClickEvent.java | 13 +- src/com/itmill/toolkit/event/ListenerMethod.java | 101 +++++++-- .../itmill/toolkit/event/MethodEventSource.java | 3 +- src/com/itmill/toolkit/event/ShortcutAction.java | 7 +- .../itmill/toolkit/service/ApplicationContext.java | 5 +- .../itmill/toolkit/service/FileTypeResolver.java | 4 +- .../toolkit/terminal/ApplicationResource.java | 4 +- src/com/itmill/toolkit/terminal/ClassResource.java | 5 +- .../toolkit/terminal/CompositeErrorMessage.java | 4 +- .../itmill/toolkit/terminal/DownloadStream.java | 4 +- src/com/itmill/toolkit/terminal/ErrorMessage.java | 4 +- .../itmill/toolkit/terminal/ExternalResource.java | 3 +- src/com/itmill/toolkit/terminal/FileResource.java | 1 + src/com/itmill/toolkit/terminal/KeyMapper.java | 4 +- .../itmill/toolkit/terminal/PaintException.java | 9 +- src/com/itmill/toolkit/terminal/PaintTarget.java | 4 +- src/com/itmill/toolkit/terminal/Paintable.java | 11 +- .../itmill/toolkit/terminal/ParameterHandler.java | 3 +- src/com/itmill/toolkit/terminal/Resource.java | 4 +- src/com/itmill/toolkit/terminal/Scrollable.java | 4 +- src/com/itmill/toolkit/terminal/Sizeable.java | 4 +- .../itmill/toolkit/terminal/StreamResource.java | 1 + src/com/itmill/toolkit/terminal/SystemError.java | 6 +- src/com/itmill/toolkit/terminal/Terminal.java | 8 +- src/com/itmill/toolkit/terminal/ThemeResource.java | 1 + src/com/itmill/toolkit/terminal/URIHandler.java | 3 +- src/com/itmill/toolkit/terminal/UploadStream.java | 3 +- src/com/itmill/toolkit/terminal/UserError.java | 1 + src/com/itmill/toolkit/terminal/VariableOwner.java | 3 +- .../terminal/gwt/client/ui/IMarginInfo.java | 5 +- .../terminal/gwt/server/ApplicationPortlet.java | 4 +- .../terminal/gwt/server/ApplicationServlet.java | 115 +++++------ .../gwt/server/ChangeVariablesErrorEvent.java | 1 + .../terminal/gwt/server/CommunicationManager.java | 19 +- .../gwt/server/ComponentSizeValidator.java | 21 +- .../terminal/gwt/server/HttpUploadStream.java | 1 + .../terminal/gwt/server/JsonPaintTarget.java | 20 +- .../gwt/server/PortletApplicationContext.java | 10 +- .../terminal/gwt/server/SessionExpired.java | 3 +- .../gwt/server/SystemMessageException.java | 6 +- .../terminal/gwt/server/WebApplicationContext.java | 32 ++- .../toolkit/terminal/gwt/server/WebBrowser.java | 1 + .../itmill/toolkit/tests/tickets/Ticket695.java | 40 ++++ src/com/itmill/toolkit/ui/AbsoluteLayout.java | 4 +- src/com/itmill/toolkit/ui/AbstractComponent.java | 4 +- .../toolkit/ui/AbstractComponentContainer.java | 1 + src/com/itmill/toolkit/ui/AbstractField.java | 9 +- src/com/itmill/toolkit/ui/AbstractLayout.java | 1 + .../itmill/toolkit/ui/AbstractOrderedLayout.java | 1 + src/com/itmill/toolkit/ui/AbstractSelect.java | 11 +- src/com/itmill/toolkit/ui/Accordion.java | 1 + src/com/itmill/toolkit/ui/Alignment.java | 5 +- src/com/itmill/toolkit/ui/AlignmentUtils.java | 4 +- src/com/itmill/toolkit/ui/BaseFieldFactory.java | 1 + src/com/itmill/toolkit/ui/Button.java | 9 +- src/com/itmill/toolkit/ui/CheckBox.java | 1 + src/com/itmill/toolkit/ui/ComboBox.java | 2 + src/com/itmill/toolkit/ui/Component.java | 19 +- src/com/itmill/toolkit/ui/ComponentContainer.java | 17 +- src/com/itmill/toolkit/ui/CustomComponent.java | 33 +-- src/com/itmill/toolkit/ui/CustomLayout.java | 1 + src/com/itmill/toolkit/ui/DateField.java | 1 + src/com/itmill/toolkit/ui/Embedded.java | 1 + src/com/itmill/toolkit/ui/ExpandLayout.java | 1 + src/com/itmill/toolkit/ui/Field.java | 6 +- src/com/itmill/toolkit/ui/FieldFactory.java | 4 +- src/com/itmill/toolkit/ui/Form.java | 1 + src/com/itmill/toolkit/ui/FormLayout.java | 1 + src/com/itmill/toolkit/ui/GridLayout.java | 14 +- src/com/itmill/toolkit/ui/HorizontalLayout.java | 1 + src/com/itmill/toolkit/ui/InlineDateField.java | 1 + src/com/itmill/toolkit/ui/Label.java | 6 +- src/com/itmill/toolkit/ui/Layout.java | 13 +- src/com/itmill/toolkit/ui/Link.java | 1 + src/com/itmill/toolkit/ui/ListSelect.java | 1 + src/com/itmill/toolkit/ui/LoginForm.java | 6 +- src/com/itmill/toolkit/ui/MenuBar.java | 10 +- src/com/itmill/toolkit/ui/NativeSelect.java | 1 + src/com/itmill/toolkit/ui/OptionGroup.java | 1 + src/com/itmill/toolkit/ui/OrderedLayout.java | 1 + src/com/itmill/toolkit/ui/Panel.java | 1 + src/com/itmill/toolkit/ui/PopupDateField.java | 1 + src/com/itmill/toolkit/ui/PopupView.java | 10 +- src/com/itmill/toolkit/ui/ProgressIndicator.java | 1 + src/com/itmill/toolkit/ui/RichTextArea.java | 1 + src/com/itmill/toolkit/ui/Select.java | 1 + src/com/itmill/toolkit/ui/Slider.java | 12 +- src/com/itmill/toolkit/ui/SplitPanel.java | 1 + src/com/itmill/toolkit/ui/TabSheet.java | 11 +- src/com/itmill/toolkit/ui/Table.java | 6 +- src/com/itmill/toolkit/ui/TextField.java | 1 + src/com/itmill/toolkit/ui/Tree.java | 18 +- src/com/itmill/toolkit/ui/TwinColSelect.java | 1 + src/com/itmill/toolkit/ui/Upload.java | 32 +-- src/com/itmill/toolkit/ui/UriFragmentUtility.java | 9 +- src/com/itmill/toolkit/ui/VerticalLayout.java | 1 + src/com/itmill/toolkit/ui/Window.java | 18 +- 150 files changed, 939 insertions(+), 743 deletions(-) create mode 100644 src/com/itmill/toolkit/tests/tickets/Ticket695.java (limited to 'src/com/itmill/toolkit') diff --git a/src/com/itmill/toolkit/Application.java b/src/com/itmill/toolkit/Application.java index 60045ac702..049969f9ec 100644 --- a/src/com/itmill/toolkit/Application.java +++ b/src/com/itmill/toolkit/Application.java @@ -4,6 +4,7 @@ package com.itmill.toolkit; +import java.io.Serializable; import java.net.SocketException; import java.net.URL; import java.util.Collection; @@ -84,7 +85,9 @@ import com.itmill.toolkit.ui.Window; * @VERSION@ * @since 3.0 */ -public abstract class Application implements URIHandler, Terminal.ErrorListener { +@SuppressWarnings("serial") +public abstract class Application implements URIHandler, + Terminal.ErrorListener, Serializable { /** * Random window name generator. @@ -757,11 +760,6 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener */ public class UserChangeEvent extends java.util.EventObject { - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3544951069307188281L; - /** * New user of the application. */ @@ -826,7 +824,7 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener * @VERSION@ * @since 3.0 */ - public interface UserChangeListener extends EventListener { + public interface UserChangeListener extends EventListener, Serializable { /** * The applicationUserChanged method Invoked when the @@ -872,11 +870,6 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener */ public class WindowDetachEvent extends EventObject { - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3544669568644691769L; - private final Window window; /** @@ -914,11 +907,6 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener */ public class WindowAttachEvent extends EventObject { - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3977578104367822392L; - private final Window window; /** @@ -954,7 +942,7 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener /** * Window attach listener interface. */ - public interface WindowAttachListener { + public interface WindowAttachListener extends Serializable { /** * Window attached @@ -968,7 +956,7 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener /** * Window detach listener interface. */ - public interface WindowDetachListener { + public interface WindowDetachListener extends Serializable { /** * Window detached. @@ -1186,7 +1174,7 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener *

* */ - public static class SystemMessages { + public static class SystemMessages implements Serializable { protected String sessionExpiredURL = null; protected boolean sessionExpiredNotificationEnabled = true; protected String sessionExpiredCaption = "Session Expired"; @@ -1369,7 +1357,8 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener *

*/ - public static class CustomizedSystemMessages extends SystemMessages { + public static class CustomizedSystemMessages extends SystemMessages + implements Serializable { /** * Sets the URL to go to when the session has expired. @@ -1557,7 +1546,6 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener } public class ApplicationError implements Terminal.ErrorEvent { - private final Throwable throwable; public ApplicationError(Throwable throwable) { @@ -1569,5 +1557,4 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener } } - } \ No newline at end of file diff --git a/src/com/itmill/toolkit/automatedtests/ComponentsInTable.java b/src/com/itmill/toolkit/automatedtests/ComponentsInTable.java index 1aabdfea71..48a71213e7 100644 --- a/src/com/itmill/toolkit/automatedtests/ComponentsInTable.java +++ b/src/com/itmill/toolkit/automatedtests/ComponentsInTable.java @@ -16,6 +16,8 @@ import com.itmill.toolkit.ui.Button.ClickEvent; public class ComponentsInTable extends CustomComponent { + private static final long serialVersionUID = 7179313717613510935L; + public ComponentsInTable(int cols, int rows) { final OrderedLayout main = new OrderedLayout(); setCompositionRoot(main); diff --git a/src/com/itmill/toolkit/automatedtests/SimplestApplication.java b/src/com/itmill/toolkit/automatedtests/SimplestApplication.java index 01f3990bd2..b21c1cd7b8 100644 --- a/src/com/itmill/toolkit/automatedtests/SimplestApplication.java +++ b/src/com/itmill/toolkit/automatedtests/SimplestApplication.java @@ -8,6 +8,7 @@ import com.itmill.toolkit.ui.Label; import com.itmill.toolkit.ui.Window; public class SimplestApplication extends com.itmill.toolkit.Application { + private static final long serialVersionUID = 1401107566407830534L; @Override public void init() { diff --git a/src/com/itmill/toolkit/automatedtests/featurebrowser/AccordionExample.java b/src/com/itmill/toolkit/automatedtests/featurebrowser/AccordionExample.java index f5e81ba9d5..e7609d9713 100644 --- a/src/com/itmill/toolkit/automatedtests/featurebrowser/AccordionExample.java +++ b/src/com/itmill/toolkit/automatedtests/featurebrowser/AccordionExample.java @@ -11,6 +11,8 @@ import com.itmill.toolkit.ui.VerticalLayout; * the tab contents between the vertical tabs. */ public class AccordionExample extends CustomComponent { + private static final long serialVersionUID = 7172404542359409349L; + public AccordionExample() { // Create a new accordion final Accordion accordion = new Accordion(); diff --git a/src/com/itmill/toolkit/automatedtests/featurebrowser/ButtonExample.java b/src/com/itmill/toolkit/automatedtests/featurebrowser/ButtonExample.java index bf61a443c6..ba7296fd13 100644 --- a/src/com/itmill/toolkit/automatedtests/featurebrowser/ButtonExample.java +++ b/src/com/itmill/toolkit/automatedtests/featurebrowser/ButtonExample.java @@ -24,6 +24,8 @@ import com.itmill.toolkit.ui.Button.ClickEvent; public class ButtonExample extends CustomComponent implements Button.ClickListener { + private static final long serialVersionUID = -3934416497726624080L; + public ButtonExample() { final VerticalLayout main = new VerticalLayout(); diff --git a/src/com/itmill/toolkit/automatedtests/featurebrowser/ClientCachingExample.java b/src/com/itmill/toolkit/automatedtests/featurebrowser/ClientCachingExample.java index 6cddcd29dc..b43770d45f 100644 --- a/src/com/itmill/toolkit/automatedtests/featurebrowser/ClientCachingExample.java +++ b/src/com/itmill/toolkit/automatedtests/featurebrowser/ClientCachingExample.java @@ -23,6 +23,7 @@ import com.itmill.toolkit.ui.VerticalLayout; */ public class ClientCachingExample extends CustomComponent { + private static final long serialVersionUID = -1033520074262036031L; private static final String msg = "This example is a (simple) demonstration of client-side caching." + " The content in one tab is intentionally made very slow to" + " 'produce' server-side. When you changes to this tab for the" @@ -52,6 +53,8 @@ public class ClientCachingExample extends CustomComponent { layout = new VerticalLayout(); layout.setMargin(true); l = new Label("Slow label - until cached client side.") { + private static final long serialVersionUID = -2741194381200799815L; + @Override public void paintContent(PaintTarget target) throws PaintException { try { diff --git a/src/com/itmill/toolkit/automatedtests/featurebrowser/ComboBoxExample.java b/src/com/itmill/toolkit/automatedtests/featurebrowser/ComboBoxExample.java index 03271a98e3..312c7b27d2 100644 --- a/src/com/itmill/toolkit/automatedtests/featurebrowser/ComboBoxExample.java +++ b/src/com/itmill/toolkit/automatedtests/featurebrowser/ComboBoxExample.java @@ -16,6 +16,8 @@ import com.itmill.toolkit.ui.AbstractSelect.Filtering; */ public class ComboBoxExample extends CustomComponent { + private static final long serialVersionUID = 1580175413996261572L; + private static final String[] firstnames = new String[] { "John", "Mary", "Joe", "Sarah", "Jeff", "Jane", "Peter", "Marc", "Robert", "Paula", "Lenny", "Kenny", "Nathan", "Nicole", "Laura", "Jos", "Josie", diff --git a/src/com/itmill/toolkit/automatedtests/featurebrowser/EmbeddedBrowserExample.java b/src/com/itmill/toolkit/automatedtests/featurebrowser/EmbeddedBrowserExample.java index 22f7d103f4..cd60dbd2bd 100644 --- a/src/com/itmill/toolkit/automatedtests/featurebrowser/EmbeddedBrowserExample.java +++ b/src/com/itmill/toolkit/automatedtests/featurebrowser/EmbeddedBrowserExample.java @@ -24,6 +24,8 @@ import com.itmill.toolkit.ui.Window.Notification; public class EmbeddedBrowserExample extends VerticalLayout implements Select.ValueChangeListener { + private static final long serialVersionUID = -6209869808788169597L; + // Default URL to open. private static final String DEFAULT_URL = "http://www.itmill.com/index_itmill_toolkit.htm"; diff --git a/src/com/itmill/toolkit/automatedtests/featurebrowser/FeatureBrowser.java b/src/com/itmill/toolkit/automatedtests/featurebrowser/FeatureBrowser.java index 5edbca6ea2..2c22926e2f 100644 --- a/src/com/itmill/toolkit/automatedtests/featurebrowser/FeatureBrowser.java +++ b/src/com/itmill/toolkit/automatedtests/featurebrowser/FeatureBrowser.java @@ -39,7 +39,9 @@ import com.itmill.toolkit.ui.Button.ClickEvent; public class FeatureBrowser extends com.itmill.toolkit.Application implements Select.ValueChangeListener { + private static final long serialVersionUID = -4653905515159295197L; // Property IDs + private static final Object PROPERTY_ID_CATEGORY = "Category"; private static final Object PROPERTY_ID_NAME = "Name"; private static final Object PROPERTY_ID_DESC = "Description"; @@ -167,7 +169,7 @@ public class FeatureBrowser extends com.itmill.toolkit.Application implements tree.addListener(this); tree.setImmediate(true); tree.expandItemsRecursively(rootId); - for (Iterator i = container.getItemIds().iterator(); i.hasNext();) { + for (Iterator i = container.getItemIds().iterator(); i.hasNext();) { Object id = i.next(); if (container.getChildren(id) == null) { tree.setChildrenAllowed(id, false); @@ -207,6 +209,8 @@ public class FeatureBrowser extends com.itmill.toolkit.Application implements final HorizontalLayout wbLayout = new HorizontalLayout(); Button b = new Button("Open in sub-window", new Button.ClickListener() { + private static final long serialVersionUID = -9168589977880405848L; + public void buttonClick(ClickEvent event) { Component component = (Component) ts.getComponentIterator() .next(); @@ -231,6 +235,9 @@ public class FeatureBrowser extends com.itmill.toolkit.Application implements b.setStyleName(Button.STYLE_LINK); wbLayout.addComponent(b); b = new Button("Open in native window", new Button.ClickListener() { + + private static final long serialVersionUID = 3847765713639897223L; + public void buttonClick(ClickEvent event) { Component component = (Component) ts.getComponentIterator() .next(); @@ -348,8 +355,8 @@ public class FeatureBrowser extends com.itmill.toolkit.Application implements tree.setValue(table.getValue()); table.addListener(this); final Item item = table.getItem(table.getValue()); - final Class c = (Class) item.getItemProperty(PROPERTY_ID_CLASS) - .getValue(); + final Class c = (Class) item.getItemProperty( + PROPERTY_ID_CLASS).getValue(); final Component component = getComponent(c); if (component != null) { final String caption = (String) item.getItemProperty( @@ -369,7 +376,7 @@ public class FeatureBrowser extends com.itmill.toolkit.Application implements } - private Component getComponent(Class componentClass) { + private Component getComponent(Class componentClass) { if (!exampleInstances.containsKey(componentClass)) { try { final Component c = (Component) componentClass.newInstance(); diff --git a/src/com/itmill/toolkit/automatedtests/featurebrowser/FormExample.java b/src/com/itmill/toolkit/automatedtests/featurebrowser/FormExample.java index 90ce0237c7..290a2ca1bf 100644 --- a/src/com/itmill/toolkit/automatedtests/featurebrowser/FormExample.java +++ b/src/com/itmill/toolkit/automatedtests/featurebrowser/FormExample.java @@ -1,5 +1,7 @@ package com.itmill.toolkit.automatedtests.featurebrowser; +import java.io.Serializable; + import com.itmill.toolkit.data.Item; import com.itmill.toolkit.data.Validator; import com.itmill.toolkit.data.util.BeanItem; @@ -25,6 +27,7 @@ import com.itmill.toolkit.ui.Button.ClickEvent; */ public class FormExample extends CustomComponent { + private static final long serialVersionUID = -5382205369084031674L; static final String cities[] = { "Amsterdam", "Berlin", "Helsinki", "Hong Kong", "London", "Luxemburg", "New York", "Oslo", "Paris", "Rome", "Stockholm", "Tokyo", "Turku" }; @@ -36,6 +39,7 @@ public class FormExample extends CustomComponent { final Address dataModel = new Address(); Button peekDataModelState = new Button("Show the data model state", new Button.ClickListener() { + private static final long serialVersionUID = -9128707564903086213L; public void buttonClick(ClickEvent event) { getWindow().showNotification( @@ -61,6 +65,9 @@ public class FormExample extends CustomComponent { } public static class AddressForm extends Form { + + private static final long serialVersionUID = -1356475197391501301L; + public AddressForm(String caption) { setCaption(caption); @@ -114,7 +121,10 @@ public class FormExample extends CustomComponent { * This is example on how to customize field creation. Any kind of field * components could be created on the fly. */ - static class MyFieldFactory extends BaseFieldFactory { + static class MyFieldFactory extends BaseFieldFactory implements + Serializable { + + private static final long serialVersionUID = 4993348078809959988L; @Override public Field createField(Item item, Object propertyId, @@ -138,6 +148,8 @@ public class FormExample extends CustomComponent { */ static class PostalCodeValidator implements Validator { + private static final long serialVersionUID = -7635596091609806427L; + public boolean isValid(Object value) { if (value == null || !(value instanceof String)) { return false; @@ -159,7 +171,9 @@ public class FormExample extends CustomComponent { * it would be a good idea to implement Item -interface for the datamodel to * make it directly bindable to form (without BeanItem wrapper) */ - public static class Address { + public static class Address implements Serializable { + + private static final long serialVersionUID = 6238878890199428556L; String name = ""; String streetAddress = ""; String postalCode = ""; diff --git a/src/com/itmill/toolkit/automatedtests/featurebrowser/GeneratedColumnExample.java b/src/com/itmill/toolkit/automatedtests/featurebrowser/GeneratedColumnExample.java index 6052d96642..4872a670fb 100644 --- a/src/com/itmill/toolkit/automatedtests/featurebrowser/GeneratedColumnExample.java +++ b/src/com/itmill/toolkit/automatedtests/featurebrowser/GeneratedColumnExample.java @@ -37,6 +37,7 @@ import com.itmill.toolkit.ui.Button.ClickListener; * @author magi */ public class GeneratedColumnExample extends CustomComponent { + /** * The business model: fill-up at a gas station. */ @@ -116,12 +117,13 @@ public class GeneratedColumnExample extends CustomComponent { * implementations, as they are not needed in this example. */ public class MySimpleIndexedContainer implements Container, Indexed { - Vector items; + + Vector items; Object itemtemplate; public MySimpleIndexedContainer(Object itemtemplate) { this.itemtemplate = itemtemplate; - items = new Vector(); // Yeah this is just a test + items = new Vector(); // Yeah this is just a test } public boolean addContainerProperty(Object propertyId, Class type, @@ -164,7 +166,7 @@ public class GeneratedColumnExample extends CustomComponent { if (itemId instanceof Integer) { int pos = ((Integer) itemId).intValue(); if (pos >= 0 && pos < items.size()) { - Item item = (Item) items.get(pos); + Item item = items.get(pos); // The BeanItem provides the property objects for the items. return item.getItemProperty(propertyId); @@ -185,7 +187,7 @@ public class GeneratedColumnExample extends CustomComponent { if (itemId instanceof Integer) { int pos = ((Integer) itemId).intValue(); if (pos >= 0 && pos < items.size()) { - return (Item) items.get(pos); + return items.get(pos); } } return null; @@ -365,6 +367,9 @@ public class GeneratedColumnExample extends CustomComponent { /** Table column generator for calculating consumption column. */ class ConsumptionColumnGenerator implements Table.ColumnGenerator { + + private static final long serialVersionUID = -1077081052659001251L; + /** * Generates a cell containing value calculated from the item. */ @@ -408,6 +413,7 @@ public class GeneratedColumnExample extends CustomComponent { /** Table column generator for calculating daily cost column. */ class DailyCostColumnGenerator extends ConsumptionColumnGenerator { + @Override public Component generateCell(FillUp fillup, FillUp prev) { double dailycost = fillup.dailyCost(prev); diff --git a/src/com/itmill/toolkit/automatedtests/util/DebugId.java b/src/com/itmill/toolkit/automatedtests/util/DebugId.java index 03dc6cedec..bcf9453109 100644 --- a/src/com/itmill/toolkit/automatedtests/util/DebugId.java +++ b/src/com/itmill/toolkit/automatedtests/util/DebugId.java @@ -4,11 +4,12 @@ package com.itmill.toolkit.automatedtests.util; +import java.io.Serializable; import java.util.HashMap; import com.itmill.toolkit.ui.Component; -public class DebugId { +public class DebugId implements Serializable { private static HashMap debugIds = new HashMap(); diff --git a/src/com/itmill/toolkit/automatedtests/util/Log.java b/src/com/itmill/toolkit/automatedtests/util/Log.java index 8d113e0fe5..d7f98540d1 100644 --- a/src/com/itmill/toolkit/automatedtests/util/Log.java +++ b/src/com/itmill/toolkit/automatedtests/util/Log.java @@ -4,6 +4,7 @@ package com.itmill.toolkit.automatedtests.util; +import java.io.Serializable; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; @@ -17,7 +18,7 @@ import java.util.Iterator; * figure out what went wrong. * */ -public class Log { +public class Log implements Serializable { // 3 (errors only) // 2 (+ warnings) diff --git a/src/com/itmill/toolkit/automatedtests/util/RandomComponents.java b/src/com/itmill/toolkit/automatedtests/util/RandomComponents.java index af2c44a40b..03b045e4a4 100644 --- a/src/com/itmill/toolkit/automatedtests/util/RandomComponents.java +++ b/src/com/itmill/toolkit/automatedtests/util/RandomComponents.java @@ -4,6 +4,7 @@ package com.itmill.toolkit.automatedtests.util; +import java.io.Serializable; import java.util.ArrayList; import java.util.Date; import java.util.Random; @@ -41,7 +42,7 @@ import com.itmill.toolkit.ui.Select; import com.itmill.toolkit.ui.TabSheet; import com.itmill.toolkit.ui.TextField; -public class RandomComponents { +public class RandomComponents implements Serializable { private Random rand = null; diff --git a/src/com/itmill/toolkit/data/Buffered.java b/src/com/itmill/toolkit/data/Buffered.java index 4aba27376d..0550c49146 100644 --- a/src/com/itmill/toolkit/data/Buffered.java +++ b/src/com/itmill/toolkit/data/Buffered.java @@ -4,6 +4,8 @@ package com.itmill.toolkit.data; +import java.io.Serializable; + import com.itmill.toolkit.data.Validator.InvalidValueException; import com.itmill.toolkit.terminal.ErrorMessage; import com.itmill.toolkit.terminal.PaintException; @@ -42,7 +44,7 @@ import com.itmill.toolkit.terminal.SystemError; * @VERSION@ * @since 3.0 */ -public interface Buffered { +public interface Buffered extends Serializable { /** * Updates all changes since the previous commit to the data source. The @@ -147,13 +149,9 @@ public interface Buffered { * @VERSION@ * @since 3.0 */ + @SuppressWarnings("serial") public class SourceException extends RuntimeException implements - ErrorMessage { - - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3256720671781630518L; + ErrorMessage, Serializable { /** Source class implementing the buffered interface */ private final Buffered source; diff --git a/src/com/itmill/toolkit/data/BufferedValidatable.java b/src/com/itmill/toolkit/data/BufferedValidatable.java index 756936710a..24fd689122 100644 --- a/src/com/itmill/toolkit/data/BufferedValidatable.java +++ b/src/com/itmill/toolkit/data/BufferedValidatable.java @@ -4,6 +4,8 @@ package com.itmill.toolkit.data; +import java.io.Serializable; + /** *

* This interface defines the combination of Validatable and @@ -16,7 +18,8 @@ package com.itmill.toolkit.data; * @VERSION@ * @since 3.0 */ -public interface BufferedValidatable extends Buffered, Validatable { +public interface BufferedValidatable extends Buffered, Validatable, + Serializable { /** * Tests if the invalid data is committed to datasource. The default is diff --git a/src/com/itmill/toolkit/data/Container.java b/src/com/itmill/toolkit/data/Container.java index 5df1b34f91..7b9bb31971 100644 --- a/src/com/itmill/toolkit/data/Container.java +++ b/src/com/itmill/toolkit/data/Container.java @@ -4,6 +4,7 @@ package com.itmill.toolkit.data; +import java.io.Serializable; import java.util.Collection; /** @@ -51,7 +52,7 @@ import java.util.Collection; * @VERSION@ * @since 3.0 */ -public interface Container { +public interface Container extends Serializable { /** * Gets the Item with the given Item ID from the Container. If the Container @@ -70,7 +71,7 @@ public interface Container { * * @return unmodifiable collection of Property IDs */ - public Collection getContainerPropertyIds(); + public Collection getContainerPropertyIds(); /** * Gets the ID's of all Items stored in the Container. The ID's are returned @@ -78,7 +79,7 @@ public interface Container { * * @return unmodifiable collection of Item IDs */ - public Collection getItemIds(); + public Collection getItemIds(); /** * Gets the Property identified by the given itemId and propertyId from the @@ -100,7 +101,7 @@ public interface Container { * ID identifying the Properties * @return data type of the Properties */ - public Class getType(Object propertyId); + public Class getType(Object propertyId); /** * Gets the number of Items in the Container. @@ -181,7 +182,7 @@ public interface Container { * @return true if the operation succeeded, false * if not */ - public boolean addContainerProperty(Object propertyId, Class type, + public boolean addContainerProperty(Object propertyId, Class type, Object defaultValue) throws UnsupportedOperationException; /** @@ -334,7 +335,7 @@ public interface Container { * * @return The sortable field ids. */ - Collection getSortableContainerPropertyIds(); + Collection getSortableContainerPropertyIds(); } @@ -418,7 +419,7 @@ public interface Container { * containing the IDs of all other Items that are children in * the container hierarchy */ - public Collection getChildren(Object itemId); + public Collection getChildren(Object itemId); /** * Gets the ID of the parent Item of the specified Item. @@ -438,7 +439,7 @@ public interface Container { * @return An unmodifiable {@link java.util.Collection collection} * containing IDs of all root elements of the container */ - public Collection rootItemIds(); + public Collection rootItemIds(); /** *

@@ -568,7 +569,7 @@ public interface Container { * * @since 5.0 */ - public interface Filterable extends Container { + public interface Filterable extends Container, Serializable { /** * Add a filter for given property. @@ -600,7 +601,7 @@ public interface Container { * Interface implemented by viewer classes capable of using a Container as a * data source. */ - public interface Viewer { + public interface Viewer extends Serializable { /** * Sets the Container that serves as the data source of the viewer. @@ -631,7 +632,7 @@ public interface Container { * internally. *

*/ - public interface Editor extends Container.Viewer { + public interface Editor extends Container.Viewer, Serializable { } @@ -641,7 +642,7 @@ public interface Container { * An Event object specifying the Container whose Item set has * changed. */ - public interface ItemSetChangeEvent { + public interface ItemSetChangeEvent extends Serializable { /** * Gets the Property where the event occurred. @@ -652,7 +653,7 @@ public interface Container { } /** Container Item set change listener interface. */ - public interface ItemSetChangeListener { + public interface ItemSetChangeListener extends Serializable { /** * Lets the listener know a Containers Item set has changed. @@ -677,7 +678,7 @@ public interface Container { * be able to implement an interface. *

*/ - public interface ItemSetChangeNotifier { + public interface ItemSetChangeNotifier extends Serializable { /** * Adds an Item set change listener for the object. @@ -702,7 +703,7 @@ public interface Container { * An Event object specifying the Container whose Property set * has changed. */ - public interface PropertySetChangeEvent { + public interface PropertySetChangeEvent extends Serializable { /** * Retrieves the Container whose contents have been modified. @@ -716,7 +717,7 @@ public interface Container { * The listener interface for receiving PropertySetChangeEvent * objects. */ - public interface PropertySetChangeListener { + public interface PropertySetChangeListener extends Serializable { /** * Notifies this listener that the Containers contents has changed. @@ -744,7 +745,7 @@ public interface Container { * be able to implement an interface. *

*/ - public interface PropertySetChangeNotifier { + public interface PropertySetChangeNotifier extends Serializable { /** * Registers a new Property set change listener for this Container. diff --git a/src/com/itmill/toolkit/data/Item.java b/src/com/itmill/toolkit/data/Item.java index a8ffc3d7c2..1259d9cbda 100644 --- a/src/com/itmill/toolkit/data/Item.java +++ b/src/com/itmill/toolkit/data/Item.java @@ -4,6 +4,7 @@ package com.itmill.toolkit.data; +import java.io.Serializable; import java.util.Collection; /** @@ -18,7 +19,7 @@ import java.util.Collection; * @VERSION@ * @since 3.0 */ -public interface Item { +public interface Item extends Serializable { /** * Gets the Property corresponding to the given Property ID stored in the @@ -37,7 +38,7 @@ public interface Item { * @return unmodifiable collection containing IDs of the Properties stored * the Item */ - public Collection getItemPropertyIds(); + public Collection getItemPropertyIds(); /** * Tries to add a new Property into the Item. @@ -78,7 +79,7 @@ public interface Item { * Interface implemented by viewer classes capable of using an Item as a * data source. */ - public interface Viewer { + public interface Viewer extends Serializable { /** * Sets the Item that serves as the data source of the viewer. @@ -105,7 +106,7 @@ public interface Item { * restrict the class from editing the contents of an internally. *

*/ - public interface Editor extends Item.Viewer { + public interface Editor extends Item.Viewer, Serializable { } @@ -119,7 +120,7 @@ public interface Item { * this event. *

*/ - public interface PropertySetChangeEvent { + public interface PropertySetChangeEvent extends Serializable { /** * Retrieves the Item whose contents has been modified. @@ -133,7 +134,7 @@ public interface Item { * The listener interface for receiving PropertySetChangeEvent * objects. */ - public interface PropertySetChangeListener { + public interface PropertySetChangeListener extends Serializable { /** * Notifies this listener that the Item's property set has changed. @@ -158,7 +159,7 @@ public interface Item { * be able to implement an interface. *

*/ - public interface PropertySetChangeNotifier { + public interface PropertySetChangeNotifier extends Serializable { /** * Registers a new property set change listener for this Item. diff --git a/src/com/itmill/toolkit/data/Property.java b/src/com/itmill/toolkit/data/Property.java index 42e438025c..b3277fdde2 100644 --- a/src/com/itmill/toolkit/data/Property.java +++ b/src/com/itmill/toolkit/data/Property.java @@ -4,6 +4,8 @@ package com.itmill.toolkit.data; +import java.io.Serializable; + /** *

* The Property is a simple data object that contains one typed @@ -33,7 +35,7 @@ package com.itmill.toolkit.data; * @VERSION@ * @since 3.0 */ -public interface Property { +public interface Property extends Serializable { /** * Gets the value stored in the Property. The returned object is compatible @@ -91,7 +93,7 @@ public interface Property { * * @return type of the Property */ - public Class getType(); + public Class getType(); /** * Tests if the Property is in read-only mode. In read-only mode calls to @@ -124,13 +126,9 @@ public interface Property { * @VERSION@ * @since 3.0 */ + @SuppressWarnings("serial") public class ReadOnlyException extends RuntimeException { - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3257571702287119410L; - /** * Constructs a new ReadOnlyException without a detail * message. @@ -160,13 +158,9 @@ public interface Property { * @VERSION@ * @since 3.0 */ + @SuppressWarnings("serial") public class ConversionException extends RuntimeException { - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3257571706666366008L; - /** * Constructs a new ConversionException without a detail * message. @@ -206,7 +200,7 @@ public interface Property { * @VERSION@ * @since 3.0 */ - public interface Viewer { + public interface Viewer extends Serializable { /** * Sets the Property that serves as the data source of the viewer. @@ -240,7 +234,7 @@ public interface Property { * @VERSION@ * @since 3.0 */ - public interface Editor extends Property.Viewer { + public interface Editor extends Property.Viewer, Serializable { } @@ -255,7 +249,7 @@ public interface Property { * @VERSION@ * @since 3.0 */ - public interface ValueChangeEvent { + public interface ValueChangeEvent extends Serializable { /** * Retrieves the Property that has been modified. @@ -274,7 +268,7 @@ public interface Property { * @VERSION@ * @since 3.0 */ - public interface ValueChangeListener { + public interface ValueChangeListener extends Serializable { /** * Notifies this listener that the Property's value has changed. @@ -304,7 +298,7 @@ public interface Property { * @VERSION@ * @since 3.0 */ - public interface ValueChangeNotifier { + public interface ValueChangeNotifier extends Serializable { /** * Registers a new value change listener for this Property. @@ -334,7 +328,7 @@ public interface Property { * @VERSION@ * @since 3.0 */ - public interface ReadOnlyStatusChangeEvent { + public interface ReadOnlyStatusChangeEvent extends Serializable { /** * Property whose read-only state has changed. @@ -353,7 +347,7 @@ public interface Property { * @VERSION@ * @since 3.0 */ - public interface ReadOnlyStatusChangeListener { + public interface ReadOnlyStatusChangeListener extends Serializable { /** * Notifies this listener that a Property's read-only status has @@ -385,7 +379,7 @@ public interface Property { * @VERSION@ * @since 3.0 */ - public interface ReadOnlyStatusChangeNotifier { + public interface ReadOnlyStatusChangeNotifier extends Serializable { /** * Registers a new read-only status change listener for this Property. diff --git a/src/com/itmill/toolkit/data/Validatable.java b/src/com/itmill/toolkit/data/Validatable.java index c8f5afb918..e5c074726b 100644 --- a/src/com/itmill/toolkit/data/Validatable.java +++ b/src/com/itmill/toolkit/data/Validatable.java @@ -4,6 +4,7 @@ package com.itmill.toolkit.data; +import java.io.Serializable; import java.util.Collection; /** @@ -19,7 +20,7 @@ import java.util.Collection; * @since 3.0 * @see com.itmill.toolkit.data.Validator */ -public interface Validatable { +public interface Validatable extends Serializable { /** *

@@ -54,7 +55,7 @@ public interface Validatable { * * @return collection of validators or null */ - public Collection getValidators(); + public Collection getValidators(); /** *

diff --git a/src/com/itmill/toolkit/data/Validator.java b/src/com/itmill/toolkit/data/Validator.java index d0094914ed..15fea5de34 100644 --- a/src/com/itmill/toolkit/data/Validator.java +++ b/src/com/itmill/toolkit/data/Validator.java @@ -4,6 +4,8 @@ package com.itmill.toolkit.data; +import java.io.Serializable; + import com.itmill.toolkit.terminal.ErrorMessage; import com.itmill.toolkit.terminal.PaintException; import com.itmill.toolkit.terminal.PaintTarget; @@ -25,7 +27,7 @@ import com.itmill.toolkit.terminal.PaintTarget; * @VERSION@ * @since 3.0 */ -public interface Validator { +public interface Validator extends Serializable { /** * Checks the given value against this validator. If the value is valid this diff --git a/src/com/itmill/toolkit/data/util/BeanItem.java b/src/com/itmill/toolkit/data/util/BeanItem.java index 65bc57a1b3..0df0ea39e8 100644 --- a/src/com/itmill/toolkit/data/util/BeanItem.java +++ b/src/com/itmill/toolkit/data/util/BeanItem.java @@ -22,6 +22,7 @@ import com.itmill.toolkit.data.Property; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class BeanItem extends PropertysetItem { /** @@ -97,7 +98,7 @@ public class BeanItem extends PropertysetItem { * @param propertyIds * id of the property. */ - public BeanItem(Object bean, Collection propertyIds) { + public BeanItem(Object bean, Collection propertyIds) { this.bean = bean; diff --git a/src/com/itmill/toolkit/data/util/BeanItemContainer.java b/src/com/itmill/toolkit/data/util/BeanItemContainer.java index 5ba44568ad..b2eb55d2cc 100644 --- a/src/com/itmill/toolkit/data/util/BeanItemContainer.java +++ b/src/com/itmill/toolkit/data/util/BeanItemContainer.java @@ -1,6 +1,7 @@ package com.itmill.toolkit.data.util; import java.beans.PropertyDescriptor; +import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -36,6 +37,7 @@ import com.itmill.toolkit.data.Property.ValueChangeNotifier; * * @since 5.4 */ +@SuppressWarnings("serial") public class BeanItemContainer implements Indexed, Sortable, Filterable, ItemSetChangeNotifier, ValueChangeListener { // filtered and unfiltered item IDs @@ -45,12 +47,19 @@ public class BeanItemContainer implements Indexed, Sortable, Filterable, // internal data model to obtain property IDs etc. private final Class type; - private final LinkedHashMap model; + private transient LinkedHashMap model; private List itemSetChangeListeners; private Set filters = new HashSet(); + /* Special serialization to handle method references */ + private void readObject(java.io.ObjectInputStream in) throws IOException, + ClassNotFoundException { + in.defaultReadObject(); + model = BeanItem.getPropertyDescriptors(type); + } + public BeanItemContainer(Class type) throws InstantiationException, IllegalAccessException { this.type = type; @@ -65,7 +74,6 @@ public class BeanItemContainer implements Indexed, Sortable, Filterable, * @throws IllegalAccessException * @throws InstantiationException */ - @SuppressWarnings("unchecked") public BeanItemContainer(Collection list) throws InstantiationException, IllegalAccessException { type = (Class) list.iterator().next().getClass(); @@ -106,7 +114,6 @@ public class BeanItemContainer implements Indexed, Sortable, Filterable, * Id of the new item to be added. * @return Returns new item or null if the operation fails. */ - @SuppressWarnings("unchecked") private Item addItemAtInternalIndex(int index, Object newItemId) { // Make sure that the Item has not been created yet if (allItems.contains(newItemId)) { @@ -364,7 +371,6 @@ public class BeanItemContainer implements Indexed, Sortable, Filterable, } } - @SuppressWarnings("unchecked") public void addContainerFilter(Object propertyId, String filterString, boolean ignoreCase, boolean onlyMatchPrefix) { if (filters.isEmpty()) { @@ -386,7 +392,6 @@ public class BeanItemContainer implements Indexed, Sortable, Filterable, * items, and send a notification if the set of visible items changed in any * way. */ - @SuppressWarnings("unchecked") protected void filterAll() { // avoid notification if the filtering had no effect List originalItems = list; diff --git a/src/com/itmill/toolkit/data/util/ContainerHierarchicalWrapper.java b/src/com/itmill/toolkit/data/util/ContainerHierarchicalWrapper.java index 91dd00fc46..2c88c2ab61 100644 --- a/src/com/itmill/toolkit/data/util/ContainerHierarchicalWrapper.java +++ b/src/com/itmill/toolkit/data/util/ContainerHierarchicalWrapper.java @@ -34,6 +34,7 @@ import com.itmill.toolkit.data.Property; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class ContainerHierarchicalWrapper implements Container.Hierarchical, Container.ItemSetChangeNotifier, Container.PropertySetChangeNotifier { diff --git a/src/com/itmill/toolkit/data/util/ContainerOrderedWrapper.java b/src/com/itmill/toolkit/data/util/ContainerOrderedWrapper.java index c9e5736b9a..a57fbb1719 100644 --- a/src/com/itmill/toolkit/data/util/ContainerOrderedWrapper.java +++ b/src/com/itmill/toolkit/data/util/ContainerOrderedWrapper.java @@ -31,6 +31,7 @@ import com.itmill.toolkit.data.Property; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class ContainerOrderedWrapper implements Container.Ordered, Container.ItemSetChangeNotifier, Container.PropertySetChangeNotifier { diff --git a/src/com/itmill/toolkit/data/util/FilesystemContainer.java b/src/com/itmill/toolkit/data/util/FilesystemContainer.java index f1d5273003..03451ad411 100644 --- a/src/com/itmill/toolkit/data/util/FilesystemContainer.java +++ b/src/com/itmill/toolkit/data/util/FilesystemContainer.java @@ -7,6 +7,7 @@ package com.itmill.toolkit.data.util; import java.io.File; import java.io.FilenameFilter; import java.io.IOException; +import java.io.Serializable; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; @@ -35,6 +36,7 @@ import com.itmill.toolkit.terminal.Resource; * @author mattitahvonen * */ +@SuppressWarnings("serial") public class FilesystemContainer implements Container.Hierarchical { /** @@ -62,13 +64,13 @@ public class FilesystemContainer implements Container.Hierarchical { */ public static Collection FILE_PROPERTIES; - private static Method FILEITEM_LASTMODIFIED; + private final static Method FILEITEM_LASTMODIFIED; - private static Method FILEITEM_NAME; + private final static Method FILEITEM_NAME; - private static Method FILEITEM_ICON; + private final static Method FILEITEM_ICON; - private static Method FILEITEM_SIZE; + private final static Method FILEITEM_SIZE; static { @@ -741,7 +743,7 @@ public class FilesystemContainer implements Container.Hierarchical { * @VERSION@ * @since 3.0 */ - public class FileExtensionFilter implements FilenameFilter { + public class FileExtensionFilter implements FilenameFilter, Serializable { private final String filter; diff --git a/src/com/itmill/toolkit/data/util/Filter.java b/src/com/itmill/toolkit/data/util/Filter.java index cbb1efae0d..cd31a57b9d 100644 --- a/src/com/itmill/toolkit/data/util/Filter.java +++ b/src/com/itmill/toolkit/data/util/Filter.java @@ -1,5 +1,7 @@ package com.itmill.toolkit.data.util; +import java.io.Serializable; + import com.itmill.toolkit.data.Item; import com.itmill.toolkit.data.Property; @@ -9,7 +11,8 @@ import com.itmill.toolkit.data.Property; * * @since 5.4 */ -public class Filter { +@SuppressWarnings("serial") +public class Filter implements Serializable { final Object propertyId; final String filterString; final boolean ignoreCase; diff --git a/src/com/itmill/toolkit/data/util/HierarchicalContainer.java b/src/com/itmill/toolkit/data/util/HierarchicalContainer.java index ce46da362a..75ade41e26 100644 --- a/src/com/itmill/toolkit/data/util/HierarchicalContainer.java +++ b/src/com/itmill/toolkit/data/util/HierarchicalContainer.java @@ -22,6 +22,7 @@ import com.itmill.toolkit.data.Item; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class HierarchicalContainer extends IndexedContainer implements Container.Hierarchical { diff --git a/src/com/itmill/toolkit/data/util/IndexedContainer.java b/src/com/itmill/toolkit/data/util/IndexedContainer.java index 0dbe44fc46..e649cace8e 100644 --- a/src/com/itmill/toolkit/data/util/IndexedContainer.java +++ b/src/com/itmill/toolkit/data/util/IndexedContainer.java @@ -4,6 +4,7 @@ package com.itmill.toolkit.data.util; +import java.io.Serializable; import java.lang.reflect.Constructor; import java.util.ArrayList; import java.util.Collection; @@ -45,6 +46,7 @@ import com.itmill.toolkit.data.Property; * @since 3.0 */ +@SuppressWarnings("serial") public class IndexedContainer implements Container.Indexed, Container.ItemSetChangeNotifier, Container.PropertySetChangeNotifier, Property.ValueChangeNotifier, Container.Sortable, Comparator, @@ -726,12 +728,7 @@ public class IndexedContainer implements Container.Indexed, * @since 3.0 */ private class PropertySetChangeEvent extends EventObject implements - Container.PropertySetChangeEvent { - - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3257002172528079926L; + Container.PropertySetChangeEvent, Serializable { private PropertySetChangeEvent(IndexedContainer source) { super(source); @@ -759,12 +756,8 @@ public class IndexedContainer implements Container.Indexed, * @since 3.0 */ public class ItemSetChangeEvent extends EventObject implements - Container.ItemSetChangeEvent { + Container.ItemSetChangeEvent, Serializable { - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3832616279386372147L; private final int addedItemIndex; private ItemSetChangeEvent(IndexedContainer source, int addedItemIndex) { @@ -804,12 +797,7 @@ public class IndexedContainer implements Container.Indexed, * @since 3.0 */ private class PropertyValueChangeEvent extends EventObject implements - Property.ValueChangeEvent { - - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3833749884498359857L; + Property.ValueChangeEvent, Serializable { private PropertyValueChangeEvent(Property source) { super(source); diff --git a/src/com/itmill/toolkit/data/util/MethodProperty.java b/src/com/itmill/toolkit/data/util/MethodProperty.java index 165d54c902..9d74175b2c 100644 --- a/src/com/itmill/toolkit/data/util/MethodProperty.java +++ b/src/com/itmill/toolkit/data/util/MethodProperty.java @@ -4,6 +4,7 @@ package com.itmill.toolkit.data.util; +import java.io.IOException; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -43,18 +44,19 @@ import com.itmill.toolkit.data.Property; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class MethodProperty implements Property, Property.ValueChangeNotifier, Property.ReadOnlyStatusChangeNotifier { /** * The object that includes the property the MethodProperty is bound to. */ - private final Object instance; + private transient Object instance; /** * Argument arrays for the getter and setter methods. */ - private Object[] setArgs, getArgs; + private transient Object[] setArgs, getArgs; /** * Is the MethodProperty read-only? @@ -64,7 +66,7 @@ public class MethodProperty implements Property, Property.ValueChangeNotifier, /** * The getter and setter methods. */ - private Method setMethod, getMethod; + private transient Method setMethod, getMethod; /** * Index of the new value in the argument list for the setter method. If the @@ -90,6 +92,41 @@ public class MethodProperty implements Property, Property.ValueChangeNotifier, */ private LinkedList valueChangeListeners = null; + /* Special serialization to handle method references */ + private void writeObject(java.io.ObjectOutputStream out) throws IOException { + out.defaultWriteObject(); + out.writeObject(instance); + out.writeObject(setArgs); + out.writeObject(getArgs); + out.writeObject(setMethod.getName()); + out.writeObject(setMethod.getParameterTypes()); + out.writeObject(getMethod.getName()); + out.writeObject(getMethod.getParameterTypes()); + }; + + /* Special serialization to handle method references */ + private void readObject(java.io.ObjectInputStream in) throws IOException, + ClassNotFoundException { + in.defaultReadObject(); + try { + instance = in.readObject(); + setArgs = (Object[]) in.readObject(); + getArgs = (Object[]) in.readObject(); + String name = (String) in.readObject(); + Class[] paramTypes = (Class[]) in.readObject(); + setMethod = instance.getClass().getMethod(name, paramTypes); + name = (String) in.readObject(); + paramTypes = (Class[]) in.readObject(); + getMethod = instance.getClass().getMethod(name, paramTypes); + } catch (SecurityException e) { + System.err.println("Internal deserialization error"); + e.printStackTrace(); + } catch (NoSuchMethodException e) { + System.err.println("Internal deserialization error"); + e.printStackTrace(); + } + }; + /** *

* Creates a new instance of MethodProperty from a named bean @@ -701,11 +738,6 @@ public class MethodProperty implements Property, Property.ValueChangeNotifier, */ public class MethodException extends RuntimeException { - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3690473623827855153L; - /** * Cause of the method exception */ @@ -762,11 +794,6 @@ public class MethodProperty implements Property, Property.ValueChangeNotifier, private class ReadOnlyStatusChangeEvent extends java.util.EventObject implements Property.ReadOnlyStatusChangeEvent { - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3258129163305955896L; - /** * Constructs a new read-only status change event for this object. * diff --git a/src/com/itmill/toolkit/data/util/ObjectProperty.java b/src/com/itmill/toolkit/data/util/ObjectProperty.java index 1821a815ed..dd31c89606 100644 --- a/src/com/itmill/toolkit/data/util/ObjectProperty.java +++ b/src/com/itmill/toolkit/data/util/ObjectProperty.java @@ -19,6 +19,7 @@ import com.itmill.toolkit.data.Property; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class ObjectProperty implements Property, Property.ValueChangeNotifier, Property.ReadOnlyStatusChangeNotifier { @@ -215,11 +216,6 @@ public class ObjectProperty implements Property, Property.ValueChangeNotifier, private class ValueChangeEvent extends java.util.EventObject implements Property.ValueChangeEvent { - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3256718468479725873L; - /** * Constructs a new value change event for this object. * @@ -252,11 +248,6 @@ public class ObjectProperty implements Property, Property.ValueChangeNotifier, private class ReadOnlyStatusChangeEvent extends java.util.EventObject implements Property.ReadOnlyStatusChangeEvent { - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3907208273529616696L; - /** * Constructs a new read-only status change event for this object. * diff --git a/src/com/itmill/toolkit/data/util/PropertyFormatter.java b/src/com/itmill/toolkit/data/util/PropertyFormatter.java index c6454a7f47..0b407bdd52 100644 --- a/src/com/itmill/toolkit/data/util/PropertyFormatter.java +++ b/src/com/itmill/toolkit/data/util/PropertyFormatter.java @@ -31,6 +31,7 @@ import com.itmill.toolkit.data.Property; * @author IT Mill Ltd. * @since 5.3.0 */ +@SuppressWarnings("serial") public abstract class PropertyFormatter implements Property, Property.ValueChangeNotifier, Property.ValueChangeListener, Property.ReadOnlyStatusChangeListener, @@ -228,11 +229,6 @@ public abstract class PropertyFormatter implements Property, private class ValueChangeEvent extends java.util.EventObject implements Property.ValueChangeEvent { - /** - * - */ - private static final long serialVersionUID = -489631310964258710L; - /** * Constructs a new value change event for this object. * @@ -263,11 +259,6 @@ public abstract class PropertyFormatter implements Property, private class ReadOnlyStatusChangeEvent extends java.util.EventObject implements Property.ReadOnlyStatusChangeEvent { - /** - * - */ - private static final long serialVersionUID = 8329395774911454548L; - /** * Constructs a new read-only status change event for this object. * diff --git a/src/com/itmill/toolkit/data/util/PropertysetItem.java b/src/com/itmill/toolkit/data/util/PropertysetItem.java index c6c01743e2..d2d2946d4e 100644 --- a/src/com/itmill/toolkit/data/util/PropertysetItem.java +++ b/src/com/itmill/toolkit/data/util/PropertysetItem.java @@ -25,6 +25,7 @@ import com.itmill.toolkit.data.Property; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class PropertysetItem implements Item, Item.PropertySetChangeNotifier, Cloneable { @@ -165,11 +166,6 @@ public class PropertysetItem implements Item, Item.PropertySetChangeNotifier, private class PropertySetChangeEvent extends EventObject implements Item.PropertySetChangeEvent { - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3257562910590055991L; - private PropertySetChangeEvent(Item source) { super(source); } diff --git a/src/com/itmill/toolkit/data/util/QueryContainer.java b/src/com/itmill/toolkit/data/util/QueryContainer.java index 2c76e58702..2139318e0c 100644 --- a/src/com/itmill/toolkit/data/util/QueryContainer.java +++ b/src/com/itmill/toolkit/data/util/QueryContainer.java @@ -46,6 +46,7 @@ import com.itmill.toolkit.data.Property; * @since 4.0 */ +@SuppressWarnings("serial") public class QueryContainer implements Container, Container.Ordered, Container.Indexed { diff --git a/src/com/itmill/toolkit/data/validator/AbstractStringValidator.java b/src/com/itmill/toolkit/data/validator/AbstractStringValidator.java index 7f26a87861..cecc63a637 100644 --- a/src/com/itmill/toolkit/data/validator/AbstractStringValidator.java +++ b/src/com/itmill/toolkit/data/validator/AbstractStringValidator.java @@ -15,6 +15,7 @@ package com.itmill.toolkit.data.validator; * @VERSION@ * @since 5.4 */ +@SuppressWarnings("serial") public abstract class AbstractStringValidator extends AbstractValidator { /** diff --git a/src/com/itmill/toolkit/data/validator/AbstractValidator.java b/src/com/itmill/toolkit/data/validator/AbstractValidator.java index 93d6ae41fa..c12ea0d848 100644 --- a/src/com/itmill/toolkit/data/validator/AbstractValidator.java +++ b/src/com/itmill/toolkit/data/validator/AbstractValidator.java @@ -15,6 +15,7 @@ import com.itmill.toolkit.data.Validator; * @VERSION@ * @since 5.4 */ +@SuppressWarnings("serial") public abstract class AbstractValidator implements Validator { /** diff --git a/src/com/itmill/toolkit/data/validator/CompositeValidator.java b/src/com/itmill/toolkit/data/validator/CompositeValidator.java index 6aa9d07b99..13266d4ca8 100644 --- a/src/com/itmill/toolkit/data/validator/CompositeValidator.java +++ b/src/com/itmill/toolkit/data/validator/CompositeValidator.java @@ -23,6 +23,7 @@ import com.itmill.toolkit.data.Validator; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class CompositeValidator extends AbstractValidator { /** diff --git a/src/com/itmill/toolkit/data/validator/DoubleValidator.java b/src/com/itmill/toolkit/data/validator/DoubleValidator.java index 56f537f5e4..9ee4fec65e 100644 --- a/src/com/itmill/toolkit/data/validator/DoubleValidator.java +++ b/src/com/itmill/toolkit/data/validator/DoubleValidator.java @@ -10,6 +10,7 @@ package com.itmill.toolkit.data.validator; * @VERSION@ * @since 5.4 */ +@SuppressWarnings("serial") public class DoubleValidator extends AbstractStringValidator { /** diff --git a/src/com/itmill/toolkit/data/validator/EmailValidator.java b/src/com/itmill/toolkit/data/validator/EmailValidator.java index b5abb4d712..f833d5ca77 100644 --- a/src/com/itmill/toolkit/data/validator/EmailValidator.java +++ b/src/com/itmill/toolkit/data/validator/EmailValidator.java @@ -13,6 +13,7 @@ package com.itmill.toolkit.data.validator; * @VERSION@ * @since 5.4 */ +@SuppressWarnings("serial") public class EmailValidator extends RegexpValidator { /** diff --git a/src/com/itmill/toolkit/data/validator/IntegerValidator.java b/src/com/itmill/toolkit/data/validator/IntegerValidator.java index f48e85943e..48afacf8c8 100644 --- a/src/com/itmill/toolkit/data/validator/IntegerValidator.java +++ b/src/com/itmill/toolkit/data/validator/IntegerValidator.java @@ -10,6 +10,7 @@ package com.itmill.toolkit.data.validator; * @VERSION@ * @since 5.4 */ +@SuppressWarnings("serial") public class IntegerValidator extends AbstractStringValidator { /** diff --git a/src/com/itmill/toolkit/data/validator/NullValidator.java b/src/com/itmill/toolkit/data/validator/NullValidator.java index e2038d9017..be2b041bb2 100644 --- a/src/com/itmill/toolkit/data/validator/NullValidator.java +++ b/src/com/itmill/toolkit/data/validator/NullValidator.java @@ -15,6 +15,7 @@ import com.itmill.toolkit.data.Validator; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class NullValidator implements Validator { private boolean onlyNullAllowed; diff --git a/src/com/itmill/toolkit/data/validator/RegexpValidator.java b/src/com/itmill/toolkit/data/validator/RegexpValidator.java index 56316bea84..eb42a2668a 100644 --- a/src/com/itmill/toolkit/data/validator/RegexpValidator.java +++ b/src/com/itmill/toolkit/data/validator/RegexpValidator.java @@ -21,6 +21,7 @@ import java.util.regex.Pattern; * @VERSION@ * @since 5.4 */ +@SuppressWarnings("serial") public class RegexpValidator extends AbstractStringValidator { private Pattern pattern; diff --git a/src/com/itmill/toolkit/data/validator/StringLengthValidator.java b/src/com/itmill/toolkit/data/validator/StringLengthValidator.java index e4c28041a7..6105b0e746 100644 --- a/src/com/itmill/toolkit/data/validator/StringLengthValidator.java +++ b/src/com/itmill/toolkit/data/validator/StringLengthValidator.java @@ -13,6 +13,7 @@ package com.itmill.toolkit.data.validator; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class StringLengthValidator extends AbstractValidator { private int minLength = -1; diff --git a/src/com/itmill/toolkit/demo/HelloWorld.java b/src/com/itmill/toolkit/demo/HelloWorld.java index d77ce235f2..817d7ce647 100644 --- a/src/com/itmill/toolkit/demo/HelloWorld.java +++ b/src/com/itmill/toolkit/demo/HelloWorld.java @@ -6,17 +6,17 @@ import com.itmill.toolkit.ui.Window; public class HelloWorld extends com.itmill.toolkit.Application { /** - * Init is invoked on application load (when a user accesses the application - * for the first time). + * Init is invoked on application load (when a user accesses the application + * for the first time). */ @Override public void init() { - // Main window is the primary browser window + // Main window is the primary browser window final Window main = new Window("Hello window"); setMainWindow(main); - // "Hello world" text is added to window as a Label component + // "Hello world" text is added to window as a Label component main.addComponent(new Label("Hello World!")); } } diff --git a/src/com/itmill/toolkit/demo/ToolkitTunesLayout.java b/src/com/itmill/toolkit/demo/ToolkitTunesLayout.java index fc0036d448..6d81263b39 100644 --- a/src/com/itmill/toolkit/demo/ToolkitTunesLayout.java +++ b/src/com/itmill/toolkit/demo/ToolkitTunesLayout.java @@ -23,6 +23,7 @@ import com.itmill.toolkit.ui.Window.Notification; * @author IT Mill Ltd. * */ +@SuppressWarnings("serial") public class ToolkitTunesLayout extends Application { @Override diff --git a/src/com/itmill/toolkit/demo/sampler/ActiveLink.java b/src/com/itmill/toolkit/demo/sampler/ActiveLink.java index 5432e96fc1..51cb8afe6c 100644 --- a/src/com/itmill/toolkit/demo/sampler/ActiveLink.java +++ b/src/com/itmill/toolkit/demo/sampler/ActiveLink.java @@ -1,5 +1,6 @@ package com.itmill.toolkit.demo.sampler; +import java.io.Serializable; import java.lang.reflect.Method; import java.util.HashSet; import java.util.Map; @@ -149,7 +150,7 @@ public class ActiveLink extends Link { /** * ActiveLink click listener */ - public interface LinkActivatedListener { + public interface LinkActivatedListener extends Serializable { /** * ActiveLink has been activated. diff --git a/src/com/itmill/toolkit/demo/sampler/Feature.java b/src/com/itmill/toolkit/demo/sampler/Feature.java index a63902aad4..10cc7e747d 100644 --- a/src/com/itmill/toolkit/demo/sampler/Feature.java +++ b/src/com/itmill/toolkit/demo/sampler/Feature.java @@ -3,6 +3,7 @@ package com.itmill.toolkit.demo.sampler; import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; +import java.io.Serializable; import com.itmill.toolkit.ui.Component; @@ -13,7 +14,7 @@ import com.itmill.toolkit.ui.Component; *

* */ -abstract public class Feature { +abstract public class Feature implements Serializable { public static final Object PROPERTY_ICON = "Icon"; public static final Object PROPERTY_NAME = "Name"; @@ -54,8 +55,8 @@ abstract public class Feature { * May return null, if the example has no related resources. *

*

- * The name of the NamedExternalResource will be shown in the UI.
Note - * that Javadoc should be referenced via {@link #getRelatedAPI()}. + * The name of the NamedExternalResource will be shown in the UI.
+ * Note that Javadoc should be referenced via {@link #getRelatedAPI()}. *

* * @see #getThemeBase() diff --git a/src/com/itmill/toolkit/demo/sampler/SamplerApplication.java b/src/com/itmill/toolkit/demo/sampler/SamplerApplication.java index 6b24a8bf4f..926cfc5310 100644 --- a/src/com/itmill/toolkit/demo/sampler/SamplerApplication.java +++ b/src/com/itmill/toolkit/demo/sampler/SamplerApplication.java @@ -21,7 +21,6 @@ import com.itmill.toolkit.terminal.ExternalResource; import com.itmill.toolkit.terminal.Resource; import com.itmill.toolkit.terminal.ThemeResource; import com.itmill.toolkit.terminal.URIHandler; -import com.itmill.toolkit.terminal.gwt.server.WebApplicationContext; import com.itmill.toolkit.ui.Alignment; import com.itmill.toolkit.ui.Button; import com.itmill.toolkit.ui.ComboBox; @@ -45,6 +44,7 @@ import com.itmill.toolkit.ui.PopupView.PopupVisibilityEvent; import com.itmill.toolkit.ui.UriFragmentUtility.FragmentChangedEvent; import com.itmill.toolkit.ui.UriFragmentUtility.FragmentChangedListener; +@SuppressWarnings("serial") public class SamplerApplication extends Application { // All features in one container diff --git a/src/com/itmill/toolkit/demo/tutorial/addressbook/data/Person.java b/src/com/itmill/toolkit/demo/tutorial/addressbook/data/Person.java index 02f670f4f4..80ed848205 100644 --- a/src/com/itmill/toolkit/demo/tutorial/addressbook/data/Person.java +++ b/src/com/itmill/toolkit/demo/tutorial/addressbook/data/Person.java @@ -1,117 +1,119 @@ package com.itmill.toolkit.demo.tutorial.addressbook.data; -public class Person { - private String firstName = ""; - private String lastName = ""; - private String email = ""; - private String phoneNumber = ""; - private String streetAddress = ""; - private Integer postalCode = null; - private String city = ""; - - /** - * @return the firstName - */ - public String getFirstName() { - return firstName; - } - - /** - * @param firstName - * the firstName to set - */ - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - /** - * @return the lastName - */ - public String getLastName() { - return lastName; - } - - /** - * @param lastName - * the lastName to set - */ - public void setLastName(String lastName) { - this.lastName = lastName; - } - - /** - * @return the email - */ - public String getEmail() { - return email; - } - - /** - * @param email - * the email to set - */ - public void setEmail(String email) { - this.email = email; - } - - /** - * @return the phoneNumber - */ - public String getPhoneNumber() { - return phoneNumber; - } - - /** - * @param phoneNumber - * the phoneNumber to set - */ - public void setPhoneNumber(String phoneNumber) { - this.phoneNumber = phoneNumber; - } - - /** - * @return the streetAddress - */ - public String getStreetAddress() { - return streetAddress; - } - - /** - * @param streetAddress - * the streetAddress to set - */ - public void setStreetAddress(String streetAddress) { - this.streetAddress = streetAddress; - } - - /** - * @return the postalCode - */ - public Integer getPostalCode() { - return postalCode; - } - - /** - * @param postalCode - * the postalCode to set - */ - public void setPostalCode(Integer postalCode) { - this.postalCode = postalCode; - } - - /** - * @return the city - */ - public String getCity() { - return city; - } - - /** - * @param city - * the city to set - */ - public void setCity(String city) { - this.city = city; - } +import java.io.Serializable; + +public class Person implements Serializable { + private String firstName = ""; + private String lastName = ""; + private String email = ""; + private String phoneNumber = ""; + private String streetAddress = ""; + private Integer postalCode = null; + private String city = ""; + + /** + * @return the firstName + */ + public String getFirstName() { + return firstName; + } + + /** + * @param firstName + * the firstName to set + */ + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + /** + * @return the lastName + */ + public String getLastName() { + return lastName; + } + + /** + * @param lastName + * the lastName to set + */ + public void setLastName(String lastName) { + this.lastName = lastName; + } + + /** + * @return the email + */ + public String getEmail() { + return email; + } + + /** + * @param email + * the email to set + */ + public void setEmail(String email) { + this.email = email; + } + + /** + * @return the phoneNumber + */ + public String getPhoneNumber() { + return phoneNumber; + } + + /** + * @param phoneNumber + * the phoneNumber to set + */ + public void setPhoneNumber(String phoneNumber) { + this.phoneNumber = phoneNumber; + } + + /** + * @return the streetAddress + */ + public String getStreetAddress() { + return streetAddress; + } + + /** + * @param streetAddress + * the streetAddress to set + */ + public void setStreetAddress(String streetAddress) { + this.streetAddress = streetAddress; + } + + /** + * @return the postalCode + */ + public Integer getPostalCode() { + return postalCode; + } + + /** + * @param postalCode + * the postalCode to set + */ + public void setPostalCode(Integer postalCode) { + this.postalCode = postalCode; + } + + /** + * @return the city + */ + public String getCity() { + return city; + } + + /** + * @param city + * the city to set + */ + public void setCity(String city) { + this.city = city; + } } \ No newline at end of file diff --git a/src/com/itmill/toolkit/demo/tutorial/addressbook/data/PersonContainer.java b/src/com/itmill/toolkit/demo/tutorial/addressbook/data/PersonContainer.java index b627f7e039..3c84ac4764 100644 --- a/src/com/itmill/toolkit/demo/tutorial/addressbook/data/PersonContainer.java +++ b/src/com/itmill/toolkit/demo/tutorial/addressbook/data/PersonContainer.java @@ -1,91 +1,93 @@ package com.itmill.toolkit.demo.tutorial.addressbook.data; +import java.io.Serializable; import java.util.Random; import com.itmill.toolkit.data.util.BeanItemContainer; -public class PersonContainer extends BeanItemContainer { +public class PersonContainer extends BeanItemContainer implements + Serializable { - /** - * Natural property order for Person bean. Used in tables and forms. - */ - public static final Object[] NATURAL_COL_ORDER = new Object[] { - "firstName", "lastName", "email", "phoneNumber", "streetAddress", - "postalCode", "city" }; + /** + * Natural property order for Person bean. Used in tables and forms. + */ + public static final Object[] NATURAL_COL_ORDER = new Object[] { + "firstName", "lastName", "email", "phoneNumber", "streetAddress", + "postalCode", "city" }; - /** - * "Human readable" captions for properties in same order as in - * NATURAL_COL_ORDER. - */ - public static final String[] COL_HEADERS_ENGLISH = new String[] { - "First name", "Last name", "Email", "Phone number", - "Street Address", "Postal Code", "City" }; + /** + * "Human readable" captions for properties in same order as in + * NATURAL_COL_ORDER. + */ + public static final String[] COL_HEADERS_ENGLISH = new String[] { + "First name", "Last name", "Email", "Phone number", + "Street Address", "Postal Code", "City" }; - public PersonContainer() throws InstantiationException, - IllegalAccessException { - super(Person.class); - } + public PersonContainer() throws InstantiationException, + IllegalAccessException { + super(Person.class); + } - public static PersonContainer createWithTestData() { - final String[] fnames = { "Peter", "Alice", "Joshua", "Mike", "Olivia", - "Nina", "Alex", "Rita", "Dan", "Umberto", "Henrik", "Rene", - "Lisa", "Marge" }; - final String[] lnames = { "Smith", "Gordon", "Simpson", "Brown", - "Clavel", "Simons", "Verne", "Scott", "Allison", "Gates", - "Rowling", "Barks", "Ross", "Schneider", "Tate" }; - final String cities[] = { "Amsterdam", "Berlin", "Helsinki", - "Hong Kong", "London", "Luxemburg", "New York", "Oslo", - "Paris", "Rome", "Stockholm", "Tokyo", "Turku" }; - final String streets[] = { "4215 Blandit Av.", "452-8121 Sem Ave", - "279-4475 Tellus Road", "4062 Libero. Av.", "7081 Pede. Ave", - "6800 Aliquet St.", "P.O. Box 298, 9401 Mauris St.", - "161-7279 Augue Ave", "P.O. Box 496, 1390 Sagittis. Rd.", - "448-8295 Mi Avenue", "6419 Non Av.", - "659-2538 Elementum Street", "2205 Quis St.", - "252-5213 Tincidunt St.", "P.O. Box 175, 4049 Adipiscing Rd.", - "3217 Nam Ave", "P.O. Box 859, 7661 Auctor St.", - "2873 Nonummy Av.", "7342 Mi, Avenue", - "539-3914 Dignissim. Rd.", "539-3675 Magna Avenue", - "Ap #357-5640 Pharetra Avenue", "416-2983 Posuere Rd.", - "141-1287 Adipiscing Avenue", "Ap #781-3145 Gravida St.", - "6897 Suscipit Rd.", "8336 Purus Avenue", "2603 Bibendum. Av.", - "2870 Vestibulum St.", "Ap #722 Aenean Avenue", - "446-968 Augue Ave", "1141 Ultricies Street", - "Ap #992-5769 Nunc Street", "6690 Porttitor Avenue", - "Ap #105-1700 Risus Street", - "P.O. Box 532, 3225 Lacus. Avenue", "736 Metus Street", - "414-1417 Fringilla Street", "Ap #183-928 Scelerisque Road", - "561-9262 Iaculis Avenue" }; - PersonContainer c = null; - Random r = new Random(0); - try { - c = new PersonContainer(); - for (int i = 0; i < 100; i++) { - Person p = new Person(); - p.setFirstName(fnames[r.nextInt(fnames.length)]); - p.setLastName(lnames[r.nextInt(lnames.length)]); - p.setCity(cities[r.nextInt(cities.length)]); - p.setEmail(p.getFirstName().toLowerCase() + "." - + p.getLastName().toLowerCase() + "@itmill.com"); - p.setPhoneNumber("+358 02 555 " + r.nextInt(10) + r.nextInt(10) - + r.nextInt(10) + r.nextInt(10)); - int n = r.nextInt(100000); - if (n < 10000) { - n += 10000; - } - p.setPostalCode(n); - p.setStreetAddress(streets[r.nextInt(streets.length)]); - c.addItem(p); - } - } catch (InstantiationException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IllegalAccessException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } + public static PersonContainer createWithTestData() { + final String[] fnames = { "Peter", "Alice", "Joshua", "Mike", "Olivia", + "Nina", "Alex", "Rita", "Dan", "Umberto", "Henrik", "Rene", + "Lisa", "Marge" }; + final String[] lnames = { "Smith", "Gordon", "Simpson", "Brown", + "Clavel", "Simons", "Verne", "Scott", "Allison", "Gates", + "Rowling", "Barks", "Ross", "Schneider", "Tate" }; + final String cities[] = { "Amsterdam", "Berlin", "Helsinki", + "Hong Kong", "London", "Luxemburg", "New York", "Oslo", + "Paris", "Rome", "Stockholm", "Tokyo", "Turku" }; + final String streets[] = { "4215 Blandit Av.", "452-8121 Sem Ave", + "279-4475 Tellus Road", "4062 Libero. Av.", "7081 Pede. Ave", + "6800 Aliquet St.", "P.O. Box 298, 9401 Mauris St.", + "161-7279 Augue Ave", "P.O. Box 496, 1390 Sagittis. Rd.", + "448-8295 Mi Avenue", "6419 Non Av.", + "659-2538 Elementum Street", "2205 Quis St.", + "252-5213 Tincidunt St.", "P.O. Box 175, 4049 Adipiscing Rd.", + "3217 Nam Ave", "P.O. Box 859, 7661 Auctor St.", + "2873 Nonummy Av.", "7342 Mi, Avenue", + "539-3914 Dignissim. Rd.", "539-3675 Magna Avenue", + "Ap #357-5640 Pharetra Avenue", "416-2983 Posuere Rd.", + "141-1287 Adipiscing Avenue", "Ap #781-3145 Gravida St.", + "6897 Suscipit Rd.", "8336 Purus Avenue", "2603 Bibendum. Av.", + "2870 Vestibulum St.", "Ap #722 Aenean Avenue", + "446-968 Augue Ave", "1141 Ultricies Street", + "Ap #992-5769 Nunc Street", "6690 Porttitor Avenue", + "Ap #105-1700 Risus Street", + "P.O. Box 532, 3225 Lacus. Avenue", "736 Metus Street", + "414-1417 Fringilla Street", "Ap #183-928 Scelerisque Road", + "561-9262 Iaculis Avenue" }; + PersonContainer c = null; + Random r = new Random(0); + try { + c = new PersonContainer(); + for (int i = 0; i < 100; i++) { + Person p = new Person(); + p.setFirstName(fnames[r.nextInt(fnames.length)]); + p.setLastName(lnames[r.nextInt(lnames.length)]); + p.setCity(cities[r.nextInt(cities.length)]); + p.setEmail(p.getFirstName().toLowerCase() + "." + + p.getLastName().toLowerCase() + "@itmill.com"); + p.setPhoneNumber("+358 02 555 " + r.nextInt(10) + r.nextInt(10) + + r.nextInt(10) + r.nextInt(10)); + int n = r.nextInt(100000); + if (n < 10000) { + n += 10000; + } + p.setPostalCode(n); + p.setStreetAddress(streets[r.nextInt(streets.length)]); + c.addItem(p); + } + } catch (InstantiationException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IllegalAccessException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } - return c; - } + return c; + } } diff --git a/src/com/itmill/toolkit/demo/tutorial/addressbook/data/SearchFilter.java b/src/com/itmill/toolkit/demo/tutorial/addressbook/data/SearchFilter.java index 137917a341..1ebd9fa372 100644 --- a/src/com/itmill/toolkit/demo/tutorial/addressbook/data/SearchFilter.java +++ b/src/com/itmill/toolkit/demo/tutorial/addressbook/data/SearchFilter.java @@ -1,41 +1,43 @@ package com.itmill.toolkit.demo.tutorial.addressbook.data; -public class SearchFilter { - - private final String term; - private final Object propertyId; - private String searchName; - - public SearchFilter(Object propertyId, String searchTerm, String name) { - this.propertyId = propertyId; - this.term = searchTerm; - this.searchName = name; - } - - /** - * @return the term - */ - public String getTerm() { - return term; - } - - /** - * @return the propertyId - */ - public Object getPropertyId() { - return propertyId; - } - - /** - * @return the name of the search - */ - public String getSearchName() { - return searchName; - } - - @Override - public String toString() { - return getSearchName(); - } +import java.io.Serializable; + +public class SearchFilter implements Serializable { + + private final String term; + private final Object propertyId; + private String searchName; + + public SearchFilter(Object propertyId, String searchTerm, String name) { + this.propertyId = propertyId; + term = searchTerm; + searchName = name; + } + + /** + * @return the term + */ + public String getTerm() { + return term; + } + + /** + * @return the propertyId + */ + public Object getPropertyId() { + return propertyId; + } + + /** + * @return the name of the search + */ + public String getSearchName() { + return searchName; + } + + @Override + public String toString() { + return getSearchName(); + } } diff --git a/src/com/itmill/toolkit/event/Action.java b/src/com/itmill/toolkit/event/Action.java index 3657a95c28..3c9074bc94 100644 --- a/src/com/itmill/toolkit/event/Action.java +++ b/src/com/itmill/toolkit/event/Action.java @@ -4,6 +4,8 @@ package com.itmill.toolkit.event; +import java.io.Serializable; + import com.itmill.toolkit.terminal.Resource; /** @@ -16,7 +18,8 @@ import com.itmill.toolkit.terminal.Resource; * @VERSION@ * @since 3.0 */ -public class Action { +@SuppressWarnings("serial") +public class Action implements Serializable { /** * Action title. @@ -77,7 +80,7 @@ public class Action { * @VERSION@ * @since 3.0 */ - public interface Handler { + public interface Handler extends Serializable { /** * Gets the list of actions applicable to this handler. @@ -120,7 +123,7 @@ public class Action { * @VERSION@ * @since 3.0 */ - public interface Container { + public interface Container extends Serializable { /** * Registers a new action handler for this container diff --git a/src/com/itmill/toolkit/event/EventRouter.java b/src/com/itmill/toolkit/event/EventRouter.java index 8ccd9b47d0..6d802a6fdc 100644 --- a/src/com/itmill/toolkit/event/EventRouter.java +++ b/src/com/itmill/toolkit/event/EventRouter.java @@ -20,6 +20,7 @@ import java.util.Set; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class EventRouter implements MethodEventSource { /** diff --git a/src/com/itmill/toolkit/event/ItemClickEvent.java b/src/com/itmill/toolkit/event/ItemClickEvent.java index 62d109b583..c68bc98788 100644 --- a/src/com/itmill/toolkit/event/ItemClickEvent.java +++ b/src/com/itmill/toolkit/event/ItemClickEvent.java @@ -1,5 +1,6 @@ package com.itmill.toolkit.event; +import java.io.Serializable; import java.lang.reflect.Method; import com.itmill.toolkit.data.Container; @@ -26,7 +27,8 @@ import com.itmill.toolkit.ui.Component.Event; * TODO extract generic super class/interfaces if we implement some other * click events. */ -public class ItemClickEvent extends Event { +@SuppressWarnings("serial") +public class ItemClickEvent extends Event implements Serializable { public static final int BUTTON_LEFT = MouseEventDetails.BUTTON_LEFT; public static final int BUTTON_MIDDLE = MouseEventDetails.BUTTON_MIDDLE; public static final int BUTTON_RIGHT = MouseEventDetails.BUTTON_RIGHT; @@ -107,11 +109,6 @@ public class ItemClickEvent extends Event { return details.isShiftKey(); } - /** - * Serial generated by eclipse - */ - private static final long serialVersionUID = 3576399524236787971L; - public static final Method ITEM_CLICK_METHOD; static { @@ -124,7 +121,7 @@ public class ItemClickEvent extends Event { } } - public interface ItemClickListener { + public interface ItemClickListener extends Serializable { public void itemClick(ItemClickEvent event); } @@ -134,7 +131,7 @@ public class ItemClickEvent extends Event { * @link {@link Container} interface may support emitting * {@link ItemClickEvent}s. */ - public interface ItemClickSource { + public interface ItemClickSource extends Serializable { /** * Register listener to handle ItemClickEvents. * diff --git a/src/com/itmill/toolkit/event/ListenerMethod.java b/src/com/itmill/toolkit/event/ListenerMethod.java index 1984dd8380..b0732398c7 100644 --- a/src/com/itmill/toolkit/event/ListenerMethod.java +++ b/src/com/itmill/toolkit/event/ListenerMethod.java @@ -4,6 +4,9 @@ package com.itmill.toolkit.event; +import java.io.IOException; +import java.io.NotSerializableException; +import java.io.Serializable; import java.lang.reflect.Method; import java.util.Arrays; import java.util.EventListener; @@ -35,24 +38,25 @@ import java.util.EventObject; * @VERSION@ * @since 3.0 */ -public class ListenerMethod implements EventListener { +@SuppressWarnings("serial") +public class ListenerMethod implements EventListener, Serializable { /** * Type of the event that should trigger this listener. Also the subclasses * of this class are accepted to trigger the listener. */ - private final Class eventType; + private final Class eventType; /** * The object containing the trigger method. */ - private final Object object; + private Object object; /** * The trigger method to call when an event passing the given criteria * fires. */ - private final Method method; + private transient Method method; /** * Optional argument set to pass to the trigger method. @@ -66,6 +70,67 @@ public class ListenerMethod implements EventListener { */ private int eventArgumentIndex; + /* Special serialization to handle method references */ + private void writeObject(java.io.ObjectOutputStream out) throws IOException { + try { + out.defaultWriteObject(); + String name = method.getName(); + Class[] paramTypes = method.getParameterTypes(); + out.writeObject(name); + out.writeObject(paramTypes); + } catch (NotSerializableException e) { + System.err + .println("Fatal error in serialization of the application: Class " + + object.getClass().getName() + + " must implement serialization."); + throw e; + } + + }; + + /* Special serialization to handle method references */ + private void readObject(java.io.ObjectInputStream in) throws IOException, + ClassNotFoundException { + in.defaultReadObject(); + try { + String name = (String) in.readObject(); + Class[] paramTypes = (Class[]) in.readObject(); + // We can not use getMethod directly as we want to support anonymous + // inner classes + method = findHighestMethod(object.getClass(), name, paramTypes); + } catch (SecurityException e) { + System.err.println("Internal deserialization error"); + e.printStackTrace(); + } + }; + + private static Method findHighestMethod(Class cls, String method, + Class[] paramTypes) { + Class[] ifaces = cls.getInterfaces(); + for (int i = 0; i < ifaces.length; i++) { + Method ifaceMethod = findHighestMethod(ifaces[i], method, + paramTypes); + if (ifaceMethod != null) { + return ifaceMethod; + } + } + if (cls.getSuperclass() != null) { + Method parentMethod = findHighestMethod(cls.getSuperclass(), + method, paramTypes); + if (parentMethod != null) { + return parentMethod; + } + } + Method[] methods = cls.getMethods(); + for (int i = 0; i < methods.length; i++) { + // we ignore parameter types for now - you need to add this + if (methods[i].getName().equals(method)) { + return methods[i]; + } + } + return null; + } + /** *

* Constructs a new event listener from a trigger method, it's arguments and @@ -98,7 +163,7 @@ public class ListenerMethod implements EventListener { * if method is not a member of object * . */ - public ListenerMethod(Class eventType, Object object, Method method, + public ListenerMethod(Class eventType, Object object, Method method, Object[] arguments, int eventArgumentIndex) throws java.lang.IllegalArgumentException { @@ -157,7 +222,7 @@ public class ListenerMethod implements EventListener { * unless exactly one match methodName is found in * object. */ - public ListenerMethod(Class eventType, Object object, String methodName, + public ListenerMethod(Class eventType, Object object, String methodName, Object[] arguments, int eventArgumentIndex) throws java.lang.IllegalArgumentException { @@ -218,7 +283,7 @@ public class ListenerMethod implements EventListener { * if method is not a member of object * . */ - public ListenerMethod(Class eventType, Object object, Method method, + public ListenerMethod(Class eventType, Object object, Method method, Object[] arguments) throws java.lang.IllegalArgumentException { // Check that the object is of correct type @@ -262,7 +327,7 @@ public class ListenerMethod implements EventListener { * unless exactly one match methodName is found in * object. */ - public ListenerMethod(Class eventType, Object object, String methodName, + public ListenerMethod(Class eventType, Object object, String methodName, Object[] arguments) throws java.lang.IllegalArgumentException { // Find the correct method @@ -307,7 +372,7 @@ public class ListenerMethod implements EventListener { * if method is not a member of object * . */ - public ListenerMethod(Class eventType, Object object, Method method) + public ListenerMethod(Class eventType, Object object, Method method) throws java.lang.IllegalArgumentException { // Checks that the object is of correct type @@ -320,7 +385,7 @@ public class ListenerMethod implements EventListener { this.method = method; eventArgumentIndex = -1; - final Class[] params = method.getParameterTypes(); + final Class[] params = method.getParameterTypes(); if (params.length == 0) { arguments = new Object[0]; @@ -358,7 +423,7 @@ public class ListenerMethod implements EventListener { * unless exactly one match methodName is found in * object. */ - public ListenerMethod(Class eventType, Object object, String methodName) + public ListenerMethod(Class eventType, Object object, String methodName) throws java.lang.IllegalArgumentException { // Finds the correct method @@ -378,7 +443,7 @@ public class ListenerMethod implements EventListener { this.method = method; eventArgumentIndex = -1; - final Class[] params = method.getParameterTypes(); + final Class[] params = method.getParameterTypes(); if (params.length == 0) { arguments = new Object[0]; @@ -447,7 +512,7 @@ public class ListenerMethod implements EventListener { * the one stored in this object and eventType equals * the event type stored in this object. * */ - public boolean matches(Class eventType, Object target) { + public boolean matches(Class eventType, Object target) { return (target == object) && (eventType.equals(this.eventType)); } @@ -469,7 +534,7 @@ public class ListenerMethod implements EventListener { * the event type stored in this object and method * equals with the method stored in this object */ - public boolean matches(Class eventType, Object target, Method method) { + public boolean matches(Class eventType, Object target, Method method) { return (target == object) && (eventType.equals(this.eventType) && method .equals(this.method)); @@ -524,12 +589,8 @@ public class ListenerMethod implements EventListener { * @VERSION@ * @since 3.0 */ - public class MethodException extends RuntimeException { - - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3257005445242894135L; + public class MethodException extends RuntimeException implements + Serializable { private final Throwable cause; diff --git a/src/com/itmill/toolkit/event/MethodEventSource.java b/src/com/itmill/toolkit/event/MethodEventSource.java index 8b5d9d797f..16aca65208 100644 --- a/src/com/itmill/toolkit/event/MethodEventSource.java +++ b/src/com/itmill/toolkit/event/MethodEventSource.java @@ -4,6 +4,7 @@ package com.itmill.toolkit.event; +import java.io.Serializable; import java.lang.reflect.Method; /** @@ -22,7 +23,7 @@ import java.lang.reflect.Method; * @VERSION@ * @since 3.0 */ -public interface MethodEventSource { +public interface MethodEventSource extends Serializable { /** *

diff --git a/src/com/itmill/toolkit/event/ShortcutAction.java b/src/com/itmill/toolkit/event/ShortcutAction.java index 4b4cca83b5..665add30b3 100644 --- a/src/com/itmill/toolkit/event/ShortcutAction.java +++ b/src/com/itmill/toolkit/event/ShortcutAction.java @@ -4,6 +4,8 @@ package com.itmill.toolkit.event; +import java.io.Serializable; + import com.itmill.toolkit.terminal.Resource; /** @@ -13,6 +15,7 @@ import com.itmill.toolkit.terminal.Resource; * @version * @since 4.0.1 */ +@SuppressWarnings("serial") public class ShortcutAction extends Action { private final int keyCode; @@ -43,7 +46,7 @@ public class ShortcutAction extends Action { * Key codes that can be used for shortcuts * */ - public interface KeyCode { + public interface KeyCode extends Serializable { public static final int ENTER = 13; public static final int ESCAPE = 27; @@ -173,7 +176,7 @@ public class ShortcutAction extends Action { * Modifier key constants * */ - public interface ModifierKey { + public interface ModifierKey extends Serializable { public static final int SHIFT = 16; public static final int CTRL = 17; diff --git a/src/com/itmill/toolkit/service/ApplicationContext.java b/src/com/itmill/toolkit/service/ApplicationContext.java index 0fc76c13cd..3bc0a29822 100644 --- a/src/com/itmill/toolkit/service/ApplicationContext.java +++ b/src/com/itmill/toolkit/service/ApplicationContext.java @@ -5,6 +5,7 @@ package com.itmill.toolkit.service; import java.io.File; +import java.io.Serializable; import java.util.Collection; import com.itmill.toolkit.Application; @@ -19,7 +20,7 @@ import com.itmill.toolkit.Application; * @VERSION@ * @since 3.1 */ -public interface ApplicationContext { +public interface ApplicationContext extends Serializable { /** * Returns application context base directory. @@ -68,7 +69,7 @@ public interface ApplicationContext { * between the client and the application. * */ - public interface TransactionListener { + public interface TransactionListener extends Serializable { /** * Invoked at the beginning of every transaction. diff --git a/src/com/itmill/toolkit/service/FileTypeResolver.java b/src/com/itmill/toolkit/service/FileTypeResolver.java index 7c57fece6f..97cd161681 100644 --- a/src/com/itmill/toolkit/service/FileTypeResolver.java +++ b/src/com/itmill/toolkit/service/FileTypeResolver.java @@ -5,6 +5,7 @@ package com.itmill.toolkit.service; import java.io.File; +import java.io.Serializable; import java.util.Collections; import java.util.Hashtable; import java.util.Map; @@ -25,7 +26,8 @@ import com.itmill.toolkit.terminal.ThemeResource; * @VERSION@ * @since 3.0 */ -public class FileTypeResolver { +@SuppressWarnings("serial") +public class FileTypeResolver implements Serializable { /** * Default icon given if no icon is specified for a mime-type. diff --git a/src/com/itmill/toolkit/terminal/ApplicationResource.java b/src/com/itmill/toolkit/terminal/ApplicationResource.java index 94f3a21a2e..c67de1a7a4 100644 --- a/src/com/itmill/toolkit/terminal/ApplicationResource.java +++ b/src/com/itmill/toolkit/terminal/ApplicationResource.java @@ -4,6 +4,8 @@ package com.itmill.toolkit.terminal; +import java.io.Serializable; + import com.itmill.toolkit.Application; /** @@ -21,7 +23,7 @@ import com.itmill.toolkit.Application; * @VERSION@ * @since 3.0 */ -public interface ApplicationResource extends Resource { +public interface ApplicationResource extends Resource, Serializable { /** * Default cache time. diff --git a/src/com/itmill/toolkit/terminal/ClassResource.java b/src/com/itmill/toolkit/terminal/ClassResource.java index 60ac7e311f..a8062940bb 100644 --- a/src/com/itmill/toolkit/terminal/ClassResource.java +++ b/src/com/itmill/toolkit/terminal/ClassResource.java @@ -4,6 +4,8 @@ package com.itmill.toolkit.terminal; +import java.io.Serializable; + import com.itmill.toolkit.Application; import com.itmill.toolkit.service.FileTypeResolver; @@ -20,7 +22,8 @@ import com.itmill.toolkit.service.FileTypeResolver; * @VERSION@ * @since 3.0 */ -public class ClassResource implements ApplicationResource { +@SuppressWarnings("serial") +public class ClassResource implements ApplicationResource, Serializable { /** * Default buffer size for this stream resource. diff --git a/src/com/itmill/toolkit/terminal/CompositeErrorMessage.java b/src/com/itmill/toolkit/terminal/CompositeErrorMessage.java index 47a50b1e26..7af3ac4628 100644 --- a/src/com/itmill/toolkit/terminal/CompositeErrorMessage.java +++ b/src/com/itmill/toolkit/terminal/CompositeErrorMessage.java @@ -4,6 +4,7 @@ package com.itmill.toolkit.terminal; +import java.io.Serializable; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; @@ -17,7 +18,8 @@ import java.util.List; * @VERSION@ * @since 3.0 */ -public class CompositeErrorMessage implements ErrorMessage { +@SuppressWarnings("serial") +public class CompositeErrorMessage implements ErrorMessage, Serializable { /** * Array of all the errors. diff --git a/src/com/itmill/toolkit/terminal/DownloadStream.java b/src/com/itmill/toolkit/terminal/DownloadStream.java index 1703dc2b92..8b91e15bb1 100644 --- a/src/com/itmill/toolkit/terminal/DownloadStream.java +++ b/src/com/itmill/toolkit/terminal/DownloadStream.java @@ -5,6 +5,7 @@ package com.itmill.toolkit.terminal; import java.io.InputStream; +import java.io.Serializable; import java.util.HashMap; import java.util.Iterator; import java.util.Map; @@ -17,7 +18,8 @@ import java.util.Map; * @VERSION@ * @since 3.0 */ -public class DownloadStream { +@SuppressWarnings("serial") +public class DownloadStream implements Serializable { /** * Maximum cache time. diff --git a/src/com/itmill/toolkit/terminal/ErrorMessage.java b/src/com/itmill/toolkit/terminal/ErrorMessage.java index d3cf40ba6d..5b07dcc4f7 100644 --- a/src/com/itmill/toolkit/terminal/ErrorMessage.java +++ b/src/com/itmill/toolkit/terminal/ErrorMessage.java @@ -4,6 +4,8 @@ package com.itmill.toolkit.terminal; +import java.io.Serializable; + /** * Interface for rendering error messages to terminal. All the visible errors * shown to user must implement this interface. @@ -13,7 +15,7 @@ package com.itmill.toolkit.terminal; * @VERSION@ * @since 3.0 */ -public interface ErrorMessage extends Paintable { +public interface ErrorMessage extends Paintable, Serializable { /** * Error code for system errors and bugs. diff --git a/src/com/itmill/toolkit/terminal/ExternalResource.java b/src/com/itmill/toolkit/terminal/ExternalResource.java index 1a210a059e..80feae3d00 100644 --- a/src/com/itmill/toolkit/terminal/ExternalResource.java +++ b/src/com/itmill/toolkit/terminal/ExternalResource.java @@ -4,6 +4,7 @@ package com.itmill.toolkit.terminal; +import java.io.Serializable; import java.net.URL; import com.itmill.toolkit.service.FileTypeResolver; @@ -18,7 +19,7 @@ import com.itmill.toolkit.service.FileTypeResolver; * @VERSION@ * @since 3.0 */ -public class ExternalResource implements Resource { +public class ExternalResource implements Resource, Serializable { /** * Url of the download. diff --git a/src/com/itmill/toolkit/terminal/FileResource.java b/src/com/itmill/toolkit/terminal/FileResource.java index 571d22ecfb..6fa26405e4 100644 --- a/src/com/itmill/toolkit/terminal/FileResource.java +++ b/src/com/itmill/toolkit/terminal/FileResource.java @@ -22,6 +22,7 @@ import com.itmill.toolkit.service.FileTypeResolver; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class FileResource implements ApplicationResource { /** diff --git a/src/com/itmill/toolkit/terminal/KeyMapper.java b/src/com/itmill/toolkit/terminal/KeyMapper.java index de6fbd27ba..4747cd4e98 100644 --- a/src/com/itmill/toolkit/terminal/KeyMapper.java +++ b/src/com/itmill/toolkit/terminal/KeyMapper.java @@ -4,6 +4,7 @@ package com.itmill.toolkit.terminal; +import java.io.Serializable; import java.util.Hashtable; /** @@ -15,7 +16,8 @@ import java.util.Hashtable; * @VERSION@ * @since 3.0 */ -public class KeyMapper { +@SuppressWarnings("serial") +public class KeyMapper implements Serializable { private int lastKey = 0; diff --git a/src/com/itmill/toolkit/terminal/PaintException.java b/src/com/itmill/toolkit/terminal/PaintException.java index c421edf94a..8464a418bf 100644 --- a/src/com/itmill/toolkit/terminal/PaintException.java +++ b/src/com/itmill/toolkit/terminal/PaintException.java @@ -5,6 +5,7 @@ package com.itmill.toolkit.terminal; import java.io.IOException; +import java.io.Serializable; /** * PaintExcepection is thrown if painting of a component fails. @@ -14,12 +15,8 @@ import java.io.IOException; * @VERSION@ * @since 3.0 */ -public class PaintException extends IOException { - - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3762535607221891897L; +@SuppressWarnings("serial") +public class PaintException extends IOException implements Serializable { /** * Constructs an instance of PaintExeception with the specified diff --git a/src/com/itmill/toolkit/terminal/PaintTarget.java b/src/com/itmill/toolkit/terminal/PaintTarget.java index 43f134bfd8..b232325831 100644 --- a/src/com/itmill/toolkit/terminal/PaintTarget.java +++ b/src/com/itmill/toolkit/terminal/PaintTarget.java @@ -4,6 +4,8 @@ package com.itmill.toolkit.terminal; +import java.io.Serializable; + /** * This interface defines the methods for painting XML to the UIDL stream. * @@ -12,7 +14,7 @@ package com.itmill.toolkit.terminal; * @VERSION@ * @since 3.0 */ -public interface PaintTarget { +public interface PaintTarget extends Serializable{ /** * Prints single XMLsection. diff --git a/src/com/itmill/toolkit/terminal/Paintable.java b/src/com/itmill/toolkit/terminal/Paintable.java index 61dbc27fc5..be09df281a 100644 --- a/src/com/itmill/toolkit/terminal/Paintable.java +++ b/src/com/itmill/toolkit/terminal/Paintable.java @@ -4,6 +4,7 @@ package com.itmill.toolkit.terminal; +import java.io.Serializable; import java.util.EventObject; /** @@ -16,7 +17,7 @@ import java.util.EventObject; * @VERSION@ * @since 3.0 */ -public interface Paintable extends java.util.EventListener { +public interface Paintable extends java.util.EventListener, Serializable { /** *

@@ -65,13 +66,9 @@ public interface Paintable extends java.util.EventListener { * This is typically done when the paint method would return * dissimilar UIDL from the previous call of the method. */ + @SuppressWarnings("serial") public class RepaintRequestEvent extends EventObject { - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3256725095530442805L; - /** * Constructs a new event. * @@ -99,7 +96,7 @@ public interface Paintable extends java.util.EventListener { * when the paint method would return dissimilar UIDL from the * previous call of the method. */ - public interface RepaintRequestListener { + public interface RepaintRequestListener extends Serializable { /** * Receives repaint request events. diff --git a/src/com/itmill/toolkit/terminal/ParameterHandler.java b/src/com/itmill/toolkit/terminal/ParameterHandler.java index 640292bc97..88ba0ae1c2 100644 --- a/src/com/itmill/toolkit/terminal/ParameterHandler.java +++ b/src/com/itmill/toolkit/terminal/ParameterHandler.java @@ -4,6 +4,7 @@ package com.itmill.toolkit.terminal; +import java.io.Serializable; import java.util.Map; /** @@ -24,7 +25,7 @@ import java.util.Map; * @VERSION@ * @since 3.0 */ -public interface ParameterHandler { +public interface ParameterHandler extends Serializable{ /** *

diff --git a/src/com/itmill/toolkit/terminal/Resource.java b/src/com/itmill/toolkit/terminal/Resource.java index 5cf07729aa..7e29ae250a 100644 --- a/src/com/itmill/toolkit/terminal/Resource.java +++ b/src/com/itmill/toolkit/terminal/Resource.java @@ -4,6 +4,8 @@ package com.itmill.toolkit.terminal; +import java.io.Serializable; + /** * Resource provided to the client terminal. Support for actually * displaying the resource type is left to the terminal. @@ -13,7 +15,7 @@ package com.itmill.toolkit.terminal; * @VERSION@ * @since 3.0 */ -public interface Resource { +public interface Resource extends Serializable{ /** * Gets the MIME type of the resource. diff --git a/src/com/itmill/toolkit/terminal/Scrollable.java b/src/com/itmill/toolkit/terminal/Scrollable.java index 4b9260c70d..3ab1a5df5c 100644 --- a/src/com/itmill/toolkit/terminal/Scrollable.java +++ b/src/com/itmill/toolkit/terminal/Scrollable.java @@ -4,6 +4,8 @@ package com.itmill.toolkit.terminal; +import java.io.Serializable; + /** *

* This interface is implemented by all visual objects that can be scrolled. The @@ -15,7 +17,7 @@ package com.itmill.toolkit.terminal; * @VERSION@ * @since 3.0 */ -public interface Scrollable { +public interface Scrollable extends Serializable { /** * Gets scroll left offset. diff --git a/src/com/itmill/toolkit/terminal/Sizeable.java b/src/com/itmill/toolkit/terminal/Sizeable.java index e4030be7bc..8b83012157 100644 --- a/src/com/itmill/toolkit/terminal/Sizeable.java +++ b/src/com/itmill/toolkit/terminal/Sizeable.java @@ -4,6 +4,8 @@ package com.itmill.toolkit.terminal; +import java.io.Serializable; + /** * Interface to be implemented by components wishing to display some object that * may be dynamically resized during runtime. @@ -13,7 +15,7 @@ package com.itmill.toolkit.terminal; * @VERSION@ * @since 3.0 */ -public interface Sizeable { +public interface Sizeable extends Serializable{ /** * Unit code representing pixels. diff --git a/src/com/itmill/toolkit/terminal/StreamResource.java b/src/com/itmill/toolkit/terminal/StreamResource.java index b1ad8f9c15..49bcc81d6f 100644 --- a/src/com/itmill/toolkit/terminal/StreamResource.java +++ b/src/com/itmill/toolkit/terminal/StreamResource.java @@ -20,6 +20,7 @@ import com.itmill.toolkit.service.FileTypeResolver; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class StreamResource implements ApplicationResource { /** diff --git a/src/com/itmill/toolkit/terminal/SystemError.java b/src/com/itmill/toolkit/terminal/SystemError.java index b5d2fae5d0..8f7f19a5a6 100644 --- a/src/com/itmill/toolkit/terminal/SystemError.java +++ b/src/com/itmill/toolkit/terminal/SystemError.java @@ -18,13 +18,9 @@ import java.io.StringWriter; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class SystemError extends RuntimeException implements ErrorMessage { - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3256445789512675891L; - /** * The cause of the system error. The cause is stored separately as JDK 1.3 * does not support causes natively. diff --git a/src/com/itmill/toolkit/terminal/Terminal.java b/src/com/itmill/toolkit/terminal/Terminal.java index e7a61b6457..5f136679d9 100644 --- a/src/com/itmill/toolkit/terminal/Terminal.java +++ b/src/com/itmill/toolkit/terminal/Terminal.java @@ -4,6 +4,8 @@ package com.itmill.toolkit.terminal; +import java.io.Serializable; + /** * Interface for different terminal types. * @@ -12,7 +14,7 @@ package com.itmill.toolkit.terminal; * @VERSION@ * @since 3.0 */ -public interface Terminal { +public interface Terminal extends Serializable { /** * Gets the name of the default theme. @@ -38,7 +40,7 @@ public interface Terminal { /** * Terminal error event. */ - public interface ErrorEvent { + public interface ErrorEvent extends Serializable{ /** * Gets the contained throwable. @@ -50,7 +52,7 @@ public interface Terminal { /** * Terminal error listener interface. */ - public interface ErrorListener { + public interface ErrorListener extends Serializable{ /** * Invoked when terminal error occurs. diff --git a/src/com/itmill/toolkit/terminal/ThemeResource.java b/src/com/itmill/toolkit/terminal/ThemeResource.java index 809f5a2bc8..1fcf0dd5f3 100644 --- a/src/com/itmill/toolkit/terminal/ThemeResource.java +++ b/src/com/itmill/toolkit/terminal/ThemeResource.java @@ -17,6 +17,7 @@ import com.itmill.toolkit.service.FileTypeResolver; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class ThemeResource implements Resource { /** diff --git a/src/com/itmill/toolkit/terminal/URIHandler.java b/src/com/itmill/toolkit/terminal/URIHandler.java index fc72c0c204..46fb322b0d 100644 --- a/src/com/itmill/toolkit/terminal/URIHandler.java +++ b/src/com/itmill/toolkit/terminal/URIHandler.java @@ -4,6 +4,7 @@ package com.itmill.toolkit.terminal; +import java.io.Serializable; import java.net.URL; /** @@ -19,7 +20,7 @@ import java.net.URL; * @VERSION@ * @since 3.0 */ -public interface URIHandler { +public interface URIHandler extends Serializable { /** * Handles a given relative URI. If the URI handling wants to emit a diff --git a/src/com/itmill/toolkit/terminal/UploadStream.java b/src/com/itmill/toolkit/terminal/UploadStream.java index b15bb1db15..225740ed43 100644 --- a/src/com/itmill/toolkit/terminal/UploadStream.java +++ b/src/com/itmill/toolkit/terminal/UploadStream.java @@ -5,6 +5,7 @@ package com.itmill.toolkit.terminal; import java.io.InputStream; +import java.io.Serializable; /** * Defines a variable type, that is used for passing uploaded files from @@ -16,7 +17,7 @@ import java.io.InputStream; * @VERSION@ * @since 3.0 */ -public interface UploadStream { +public interface UploadStream extends Serializable { /** * Gets the name of the stream. diff --git a/src/com/itmill/toolkit/terminal/UserError.java b/src/com/itmill/toolkit/terminal/UserError.java index 92b33e4f8b..e7c2df9004 100644 --- a/src/com/itmill/toolkit/terminal/UserError.java +++ b/src/com/itmill/toolkit/terminal/UserError.java @@ -13,6 +13,7 @@ package com.itmill.toolkit.terminal; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class UserError implements ErrorMessage { /** diff --git a/src/com/itmill/toolkit/terminal/VariableOwner.java b/src/com/itmill/toolkit/terminal/VariableOwner.java index c97497aede..fc1fe2ba16 100644 --- a/src/com/itmill/toolkit/terminal/VariableOwner.java +++ b/src/com/itmill/toolkit/terminal/VariableOwner.java @@ -4,6 +4,7 @@ package com.itmill.toolkit.terminal; +import java.io.Serializable; import java.util.Map; /** @@ -20,7 +21,7 @@ import java.util.Map; * @VERSION@ * @since 3.0 */ -public interface VariableOwner { +public interface VariableOwner extends Serializable { /** * Called when one or more variables handled by the implementing class are diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IMarginInfo.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IMarginInfo.java index 725659c916..62ef12a9bd 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IMarginInfo.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IMarginInfo.java @@ -4,7 +4,10 @@ package com.itmill.toolkit.terminal.gwt.client.ui; -public class IMarginInfo { +import java.io.Serializable; + +@SuppressWarnings("serial") +public class IMarginInfo implements Serializable { private static final int TOP = 1; private static final int RIGHT = 2; diff --git a/src/com/itmill/toolkit/terminal/gwt/server/ApplicationPortlet.java b/src/com/itmill/toolkit/terminal/gwt/server/ApplicationPortlet.java index 894eba519b..eff1fe3a66 100644 --- a/src/com/itmill/toolkit/terminal/gwt/server/ApplicationPortlet.java +++ b/src/com/itmill/toolkit/terminal/gwt/server/ApplicationPortlet.java @@ -2,6 +2,7 @@ package com.itmill.toolkit.terminal.gwt.server; import java.io.IOException; import java.io.PrintWriter; +import java.io.Serializable; import javax.portlet.ActionRequest; import javax.portlet.ActionResponse; @@ -15,7 +16,8 @@ import javax.portlet.RenderResponse; import com.itmill.toolkit.Application; -public class ApplicationPortlet implements Portlet { +@SuppressWarnings("serial") +public class ApplicationPortlet implements Portlet, Serializable { // The application to show protected String app = null; // some applications might require forced height (and, more seldom, width) diff --git a/src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java b/src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java index b9c8d58ff5..6fd6bfaa8c 100644 --- a/src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java +++ b/src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java @@ -10,6 +10,7 @@ import java.io.InputStream; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; +import java.io.Serializable; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -19,7 +20,6 @@ import java.security.GeneralSecurityException; import java.util.Collection; import java.util.Date; import java.util.Enumeration; -import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Properties; @@ -55,10 +55,9 @@ import com.itmill.toolkit.ui.Window; * @since 5.0 */ +@SuppressWarnings("serial") public class ApplicationServlet extends HttpServlet { - private static final long serialVersionUID = -4937882979845826574L; - /** * Version number of this release. For example "5.0.0". */ @@ -127,10 +126,6 @@ public class ApplicationServlet extends HttpServlet { private static final int MAX_BUFFER_SIZE = 64 * 1024; - // TODO This is session specific not servlet wide data. No need to store - // this here, move it to Session from where it can be queried when required - protected static HashMap applicationToAjaxAppMgrMap = new HashMap(); - private static final String RESOURCE_URI = "/RES/"; private static final String AJAX_UIDL_URI = "/UIDL"; @@ -162,8 +157,6 @@ public class ApplicationServlet extends HttpServlet { // If servlet is application runner, store request's classname String applicationRunnerClassname = null; - private ClassLoader classLoader; - /** * Called by the servlet container to indicate to a servlet that the servlet * is being placed into service. @@ -229,28 +222,6 @@ public class ApplicationServlet extends HttpServlet { System.err.println(NOT_PRODUCTION_MODE_INFO); } - // Gets custom class loader - final String classLoaderName = getApplicationOrSystemProperty( - "ClassLoader", null); - ClassLoader classLoader; - if (classLoaderName == null) { - classLoader = getClass().getClassLoader(); - } else { - try { - final Class classLoaderClass = getClass().getClassLoader() - .loadClass(classLoaderName); - final Constructor c = classLoaderClass - .getConstructor(new Class[] { ClassLoader.class }); - classLoader = (ClassLoader) c - .newInstance(new Object[] { getClass().getClassLoader() }); - } catch (final Exception e) { - throw new ServletException( - "Could not find specified class loader: " - + classLoaderName, e); - } - } - this.classLoader = classLoader; - // Loads the application class using the same class loader // as the servlet itself if (!isApplicationRunnerServlet) { @@ -262,7 +233,8 @@ public class ApplicationServlet extends HttpServlet { "Application not specified in servlet parameters"); } try { - applicationClass = classLoader.loadClass(applicationClassName); + applicationClass = getClassLoader().loadClass( + applicationClassName); } catch (final ClassNotFoundException e) { throw new ServletException("Failed to load application class: " + applicationClassName); @@ -274,6 +246,30 @@ public class ApplicationServlet extends HttpServlet { } + private ClassLoader getClassLoader() throws ServletException { + // Gets custom class loader + final String classLoaderName = getApplicationOrSystemProperty( + "ClassLoader", null); + ClassLoader classLoader; + if (classLoaderName == null) { + classLoader = getClass().getClassLoader(); + } else { + try { + final Class classLoaderClass = getClass().getClassLoader() + .loadClass(classLoaderName); + final Constructor c = classLoaderClass + .getConstructor(new Class[] { ClassLoader.class }); + classLoader = (ClassLoader) c + .newInstance(new Object[] { getClass().getClassLoader() }); + } catch (final Exception e) { + throw new ServletException( + "Could not find specified class loader: " + + classLoaderName, e); + } + } + return classLoader; + } + /** * Gets an application or system property value. * @@ -371,8 +367,9 @@ public class ApplicationServlet extends HttpServlet { // note: endTransaction is called on finalize below ((WebApplicationContext) application.getContext()) .startTransaction(application, request); - getApplicationManager(application).handleFileUpload(request, - response); + ((WebApplicationContext) application.getContext()) + .getApplicationManager(application, this) + .handleFileUpload(request, response); return; } @@ -417,8 +414,9 @@ public class ApplicationServlet extends HttpServlet { .startTransaction(application, request); // Handle UIDL request - getApplicationManager(application).handleUidlRequest( - request, response, this); + ((WebApplicationContext) application.getContext()) + .getApplicationManager(application, this) + .handleUidlRequest(request, response, this); return; } } @@ -432,7 +430,7 @@ public class ApplicationServlet extends HttpServlet { application.close(); final HttpSession session = request.getSession(false); if (session != null) { - ApplicationServlet.applicationToAjaxAppMgrMap + WebApplicationContext.getApplicationContext(session).applicationToAjaxAppMgrMap .remove(application); WebApplicationContext.getApplicationContext(session) .removeApplication(application); @@ -474,8 +472,9 @@ public class ApplicationServlet extends HttpServlet { DownloadStream download = null; // Handles the URI if the application is still running - download = getApplicationManager(application).handleURI(window, - request, response); + download = ((WebApplicationContext) application.getContext()) + .getApplicationManager(application, this).handleURI(window, + request, response); // If this is not a download request if (download == null) { @@ -623,9 +622,10 @@ public class ApplicationServlet extends HttpServlet { * @param request * @param response * @throws IOException + * @throws ServletException */ private void serveStaticResourcesInITMILL(String filename, - HttpServletResponse response) throws IOException { + HttpServletResponse response) throws IOException, ServletException { final ServletContext sc = getServletContext(); InputStream is = sc.getResourceAsStream(filename); @@ -634,7 +634,7 @@ public class ApplicationServlet extends HttpServlet { // strip leading "/" otherwise stream from JAR wont work filename = filename.substring(1); - is = classLoader.getResourceAsStream(filename); + is = getClassLoader().getResourceAsStream(filename); if (is == null) { // cannot serve requested file @@ -1430,10 +1430,12 @@ public class ApplicationServlet extends HttpServlet { * @throws SAXException * @throws IllegalAccessException * @throws InstantiationException + * @throws ServletException */ private Application getNewApplication(HttpServletRequest request, HttpServletResponse response) throws MalformedURLException, - SAXException, IllegalAccessException, InstantiationException { + SAXException, IllegalAccessException, InstantiationException, + ServletException { // Create application final WebApplicationContext context = WebApplicationContext @@ -1446,7 +1448,8 @@ public class ApplicationServlet extends HttpServlet { applicationUrl = new URL(getApplicationUrl(request).toString() + applicationClassname + "/"); try { - applicationClass = classLoader.loadClass(applicationClassname); + applicationClass = getClassLoader().loadClass( + applicationClassname); } catch (final ClassNotFoundException e) { throw new InstantiationException( "Failed to load application class: " @@ -1586,7 +1589,7 @@ public class ApplicationServlet extends HttpServlet { * Implementation of ParameterHandler.ErrorEvent interface. */ public class ParameterHandlerErrorImpl implements - ParameterHandler.ErrorEvent { + ParameterHandler.ErrorEvent, Serializable { private ParameterHandler owner; @@ -1615,7 +1618,8 @@ public class ApplicationServlet extends HttpServlet { /** * Implementation of URIHandler.ErrorEvent interface. */ - public class URIHandlerErrorImpl implements URIHandler.ErrorEvent { + public class URIHandlerErrorImpl implements URIHandler.ErrorEvent, + Serializable { private final URIHandler owner; @@ -1650,25 +1654,6 @@ public class ApplicationServlet extends HttpServlet { } } - /** - * Gets communication manager for an application. - * - * If this application has not been running before, new manager is created. - * - * @param application - * @return CommunicationManager - */ - private CommunicationManager getApplicationManager(Application application) { - CommunicationManager mgr = applicationToAjaxAppMgrMap.get(application); - - if (mgr == null) { - // Creates new manager - mgr = new CommunicationManager(application, this); - applicationToAjaxAppMgrMap.put(application, mgr); - } - return mgr; - } - /** * Gets resource path using different implementations. Required to * supporting different servlet container implementations (application @@ -1697,7 +1682,7 @@ public class ApplicationServlet extends HttpServlet { return resultPath; } - public class RequestError implements Terminal.ErrorEvent { + public class RequestError implements Terminal.ErrorEvent, Serializable { private final Throwable throwable; diff --git a/src/com/itmill/toolkit/terminal/gwt/server/ChangeVariablesErrorEvent.java b/src/com/itmill/toolkit/terminal/gwt/server/ChangeVariablesErrorEvent.java index 76bd1822c0..53523bea5a 100644 --- a/src/com/itmill/toolkit/terminal/gwt/server/ChangeVariablesErrorEvent.java +++ b/src/com/itmill/toolkit/terminal/gwt/server/ChangeVariablesErrorEvent.java @@ -5,6 +5,7 @@ import java.util.Map; import com.itmill.toolkit.ui.Component; import com.itmill.toolkit.ui.AbstractComponent.ComponentErrorEvent; +@SuppressWarnings("serial") public class ChangeVariablesErrorEvent implements ComponentErrorEvent { private Throwable throwable; diff --git a/src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java b/src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java index 5cb8405d2a..4905b858c5 100644 --- a/src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java +++ b/src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java @@ -12,6 +12,7 @@ import java.io.InputStreamReader; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; +import java.io.Serializable; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.net.URL; @@ -70,7 +71,9 @@ import com.itmill.toolkit.ui.Window; * @VERSION@ * @since 5.0 */ -public class CommunicationManager implements Paintable.RepaintRequestListener { +@SuppressWarnings("serial") +public class CommunicationManager implements Paintable.RepaintRequestListener, + Serializable { private static String GET_PARAM_REPAINT_ALL = "repaintAll"; @@ -776,8 +779,7 @@ public class CommunicationManager implements Paintable.RepaintRequestListener { return success; } - public class ErrorHandlerErrorEvent implements ErrorEvent { - + public class ErrorHandlerErrorEvent implements ErrorEvent, Serializable { private final Throwable throwable; public ErrorHandlerErrorEvent(Throwable throwable) { @@ -1207,7 +1209,9 @@ public class CommunicationManager implements Paintable.RepaintRequestListener { p.requestRepaintRequests(); } - private final class SingleValueMap implements Map { + private final class SingleValueMap implements Map, + Serializable { + private final String name; private final Object value; @@ -1298,7 +1302,8 @@ public class CommunicationManager implements Paintable.RepaintRequestListener { /** * Implementation of URIHandler.ErrorEvent interface. */ - public class URIHandlerErrorImpl implements URIHandler.ErrorEvent { + public class URIHandlerErrorImpl implements URIHandler.ErrorEvent, + Serializable { private final URIHandler owner; @@ -1356,7 +1361,9 @@ public class CommunicationManager implements Paintable.RepaintRequestListener { * FileUpload can determine content length. Used to detect files total size, * uploads progress can be tracked inside upload. */ - private class UploadProgressListener implements ProgressListener { + private class UploadProgressListener implements ProgressListener, + Serializable { + Upload uploadComponent; boolean updated = false; diff --git a/src/com/itmill/toolkit/terminal/gwt/server/ComponentSizeValidator.java b/src/com/itmill/toolkit/terminal/gwt/server/ComponentSizeValidator.java index 7aeee6b10b..afc7f4f554 100644 --- a/src/com/itmill/toolkit/terminal/gwt/server/ComponentSizeValidator.java +++ b/src/com/itmill/toolkit/terminal/gwt/server/ComponentSizeValidator.java @@ -2,6 +2,7 @@ package com.itmill.toolkit.terminal.gwt.server; import java.io.PrintStream; import java.io.PrintWriter; +import java.io.Serializable; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; @@ -26,7 +27,8 @@ import com.itmill.toolkit.ui.VerticalLayout; import com.itmill.toolkit.ui.Window; import com.itmill.toolkit.ui.GridLayout.Area; -public class ComponentSizeValidator { +@SuppressWarnings("serial") +public class ComponentSizeValidator implements Serializable { private final static int LAYERS_SHOWN = 4; @@ -72,12 +74,14 @@ public class ComponentSizeValidator { } } else if (component instanceof Form) { Form form = (Form) component; - if (form.getLayout() != null) + if (form.getLayout() != null) { errors = validateComponentRelativeSizes(form.getLayout(), errors, parent); - if (form.getFooter() != null) + } + if (form.getFooter() != null) { errors = validateComponentRelativeSizes(form.getFooter(), errors, parent); + } } return errors; @@ -148,7 +152,7 @@ public class ComponentSizeValidator { } } - public static class InvalidLayout { + public static class InvalidLayout implements Serializable { private Component component; @@ -265,7 +269,7 @@ public class ComponentSizeValidator { } } - private static class ComponentInfo { + private static class ComponentInfo implements Serializable { Component component; String info; @@ -561,8 +565,9 @@ public class ComponentSizeValidator { || parent instanceof TabSheet || parent instanceof CustomComponent) { // FIXME Could we use com.itmill.toolkit package name here and - // fail for all component containers? - // FIXME Actually this should be moved to containers so it can be implemented for custom containers + // fail for all component containers? + // FIXME Actually this should be moved to containers so it can + // be implemented for custom containers // TODO vertical splitpanel with another non relative component? return false; } else if (parent instanceof Window) { @@ -610,7 +615,7 @@ public class ComponentSizeValidator { private static Map widthLocations = new HashMap(); private static Map heightLocations = new HashMap(); - public static class FileLocation { + public static class FileLocation implements Serializable { public String method; public String file; public String className; diff --git a/src/com/itmill/toolkit/terminal/gwt/server/HttpUploadStream.java b/src/com/itmill/toolkit/terminal/gwt/server/HttpUploadStream.java index 5d789ac386..8026215088 100644 --- a/src/com/itmill/toolkit/terminal/gwt/server/HttpUploadStream.java +++ b/src/com/itmill/toolkit/terminal/gwt/server/HttpUploadStream.java @@ -14,6 +14,7 @@ import java.io.InputStream; * @VERSION@ * @since 5.0 */ +@SuppressWarnings("serial") public class HttpUploadStream implements com.itmill.toolkit.terminal.UploadStream { diff --git a/src/com/itmill/toolkit/terminal/gwt/server/JsonPaintTarget.java b/src/com/itmill/toolkit/terminal/gwt/server/JsonPaintTarget.java index 81351daf0c..95818a4e46 100644 --- a/src/com/itmill/toolkit/terminal/gwt/server/JsonPaintTarget.java +++ b/src/com/itmill/toolkit/terminal/gwt/server/JsonPaintTarget.java @@ -5,6 +5,7 @@ package com.itmill.toolkit.terminal.gwt.server; import java.io.PrintWriter; +import java.io.Serializable; import java.util.Collection; import java.util.HashSet; import java.util.Iterator; @@ -31,6 +32,7 @@ import com.itmill.toolkit.ui.Component; * @VERSION@ * @since 5.0 */ +@SuppressWarnings("serial") public class JsonPaintTarget implements PaintTarget { /* Document type declarations */ @@ -813,7 +815,7 @@ public class JsonPaintTarget implements PaintTarget { * @author mattitahvonen * */ - class JsonTag { + class JsonTag implements Serializable { boolean firstField = false; Vector variables = new Vector(); @@ -963,14 +965,14 @@ public class JsonPaintTarget implements PaintTarget { } } - abstract class Variable { + abstract class Variable implements Serializable { String name; public abstract String getJsonPresentation(); } - class BooleanVariable extends Variable { + class BooleanVariable extends Variable implements Serializable { boolean value; public BooleanVariable(VariableOwner owner, String name, boolean v) { @@ -985,7 +987,7 @@ public class JsonPaintTarget implements PaintTarget { } - class StringVariable extends Variable { + class StringVariable extends Variable implements Serializable { String value; public StringVariable(VariableOwner owner, String name, String v) { @@ -1000,7 +1002,7 @@ public class JsonPaintTarget implements PaintTarget { } - class IntVariable extends Variable { + class IntVariable extends Variable implements Serializable { int value; public IntVariable(VariableOwner owner, String name, int v) { @@ -1014,7 +1016,7 @@ public class JsonPaintTarget implements PaintTarget { } } - class LongVariable extends Variable { + class LongVariable extends Variable implements Serializable { long value; public LongVariable(VariableOwner owner, String name, long v) { @@ -1028,7 +1030,7 @@ public class JsonPaintTarget implements PaintTarget { } } - class FloatVariable extends Variable { + class FloatVariable extends Variable implements Serializable { float value; public FloatVariable(VariableOwner owner, String name, float v) { @@ -1042,7 +1044,7 @@ public class JsonPaintTarget implements PaintTarget { } } - class DoubleVariable extends Variable { + class DoubleVariable extends Variable implements Serializable { double value; public DoubleVariable(VariableOwner owner, String name, double v) { @@ -1056,7 +1058,7 @@ public class JsonPaintTarget implements PaintTarget { } } - class ArrayVariable extends Variable { + class ArrayVariable extends Variable implements Serializable { String[] value; public ArrayVariable(VariableOwner owner, String name, String[] v) { diff --git a/src/com/itmill/toolkit/terminal/gwt/server/PortletApplicationContext.java b/src/com/itmill/toolkit/terminal/gwt/server/PortletApplicationContext.java index 1ec2d9f93b..20df917afb 100644 --- a/src/com/itmill/toolkit/terminal/gwt/server/PortletApplicationContext.java +++ b/src/com/itmill/toolkit/terminal/gwt/server/PortletApplicationContext.java @@ -6,6 +6,7 @@ package com.itmill.toolkit.terminal.gwt.server; import java.io.IOException; import java.io.OutputStream; import java.io.PrintWriter; +import java.io.Serializable; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashSet; @@ -28,7 +29,9 @@ import com.itmill.toolkit.Application; * @author marc * */ -public class PortletApplicationContext extends WebApplicationContext { +@SuppressWarnings("serial") +public class PortletApplicationContext extends WebApplicationContext implements + Serializable { protected PortletSession portletSession; @@ -182,7 +185,7 @@ public class PortletApplicationContext extends WebApplicationContext { } } - public interface PortletListener { + public interface PortletListener extends Serializable { public void handleRenderRequest(RenderRequest request, RenderResponse response); @@ -190,7 +193,8 @@ public class PortletApplicationContext extends WebApplicationContext { ActionResponse response); } - private class RestrictedRenderResponse implements RenderResponse { + private class RestrictedRenderResponse implements RenderResponse, + Serializable { private RenderResponse response; diff --git a/src/com/itmill/toolkit/terminal/gwt/server/SessionExpired.java b/src/com/itmill/toolkit/terminal/gwt/server/SessionExpired.java index bd085725a3..c6a5238e90 100644 --- a/src/com/itmill/toolkit/terminal/gwt/server/SessionExpired.java +++ b/src/com/itmill/toolkit/terminal/gwt/server/SessionExpired.java @@ -1,7 +1,6 @@ package com.itmill.toolkit.terminal.gwt.server; +@SuppressWarnings("serial") public class SessionExpired extends Exception { - private static final long serialVersionUID = -2211425033877155423L; - } diff --git a/src/com/itmill/toolkit/terminal/gwt/server/SystemMessageException.java b/src/com/itmill/toolkit/terminal/gwt/server/SystemMessageException.java index 9ec3b5a2e1..098c728587 100644 --- a/src/com/itmill/toolkit/terminal/gwt/server/SystemMessageException.java +++ b/src/com/itmill/toolkit/terminal/gwt/server/SystemMessageException.java @@ -1,12 +1,8 @@ package com.itmill.toolkit.terminal.gwt.server; +@SuppressWarnings("serial") public class SystemMessageException extends RuntimeException { - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = -8249486543123286960L; - /** * Cause of the method exception */ diff --git a/src/com/itmill/toolkit/terminal/gwt/server/WebApplicationContext.java b/src/com/itmill/toolkit/terminal/gwt/server/WebApplicationContext.java index 143811789a..0193b4d3d7 100644 --- a/src/com/itmill/toolkit/terminal/gwt/server/WebApplicationContext.java +++ b/src/com/itmill/toolkit/terminal/gwt/server/WebApplicationContext.java @@ -6,9 +6,11 @@ package com.itmill.toolkit.terminal.gwt.server; import java.io.File; import java.io.PrintWriter; +import java.io.Serializable; import java.io.StringWriter; import java.util.Collection; import java.util.Collections; +import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; @@ -30,17 +32,20 @@ import com.itmill.toolkit.service.ApplicationContext; * @VERSION@ * @since 3.1 */ +@SuppressWarnings("serial") public class WebApplicationContext implements ApplicationContext, - HttpSessionBindingListener { + HttpSessionBindingListener, Serializable { protected List listeners; - protected HttpSession session; + protected transient HttpSession session; protected final HashSet applications = new HashSet(); protected WebBrowser browser = new WebBrowser(); + protected HashMap applicationToAjaxAppMgrMap = new HashMap(); + /** * Creates a new Web Application Context. * @@ -230,7 +235,7 @@ public class WebApplicationContext implements ApplicationContext, final Application app = (Application) applications.iterator() .next(); app.close(); - ApplicationServlet.applicationToAjaxAppMgrMap.remove(app); + applicationToAjaxAppMgrMap.remove(app); removeApplication(app); } } catch (Exception e) { @@ -257,4 +262,25 @@ public class WebApplicationContext implements ApplicationContext, public WebBrowser getBrowser() { return browser; } + + /** + * Gets communication manager for an application. + * + * If this application has not been running before, new manager is created. + * + * @param application + * @return CommunicationManager + */ + protected CommunicationManager getApplicationManager( + Application application, ApplicationServlet servlet) { + CommunicationManager mgr = applicationToAjaxAppMgrMap.get(application); + + if (mgr == null) { + // Creates new manager + mgr = new CommunicationManager(application, servlet); + applicationToAjaxAppMgrMap.put(application, mgr); + } + return mgr; + } + } diff --git a/src/com/itmill/toolkit/terminal/gwt/server/WebBrowser.java b/src/com/itmill/toolkit/terminal/gwt/server/WebBrowser.java index 027a8361de..789c28b843 100644 --- a/src/com/itmill/toolkit/terminal/gwt/server/WebBrowser.java +++ b/src/com/itmill/toolkit/terminal/gwt/server/WebBrowser.java @@ -10,6 +10,7 @@ import javax.servlet.http.HttpServletRequest; import com.itmill.toolkit.terminal.Terminal; +@SuppressWarnings("serial") public class WebBrowser implements Terminal { private int screenHeight = 0; diff --git a/src/com/itmill/toolkit/tests/tickets/Ticket695.java b/src/com/itmill/toolkit/tests/tickets/Ticket695.java new file mode 100644 index 0000000000..fc040d8ba3 --- /dev/null +++ b/src/com/itmill/toolkit/tests/tickets/Ticket695.java @@ -0,0 +1,40 @@ +package com.itmill.toolkit.tests.tickets; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.ObjectOutputStream; +import com.itmill.toolkit.Application; +import com.itmill.toolkit.ui.Button; +import com.itmill.toolkit.ui.Window; +import com.itmill.toolkit.ui.Button.ClickEvent; + +public class Ticket695 extends Application { + + private static final long serialVersionUID = 3803150085397590662L; + + @Override + public void init() { + final Window w = new Window("Serialization test #695"); + setMainWindow(w); + Button b = new Button("Serialize ApplicationContext"); + w.addComponent(b); + b.addListener(new Button.ClickListener() { + + public void buttonClick(ClickEvent event) { + ByteArrayOutputStream buffer = new ByteArrayOutputStream(); + try { + ObjectOutputStream oos = new ObjectOutputStream(buffer); + oos.writeObject(getContext()); + w.showNotification("ApplicationContext serialized (" + + buffer.size() + "bytes)"); + } catch (IOException e) { + e.printStackTrace(); + w + .showNotification("ApplicationContext serialization failed - see console for stacktrace"); + } + + } + }); + } + +} diff --git a/src/com/itmill/toolkit/ui/AbsoluteLayout.java b/src/com/itmill/toolkit/ui/AbsoluteLayout.java index 72e9526552..f3b65e2111 100644 --- a/src/com/itmill/toolkit/ui/AbsoluteLayout.java +++ b/src/com/itmill/toolkit/ui/AbsoluteLayout.java @@ -1,5 +1,6 @@ package com.itmill.toolkit.ui; +import java.io.Serializable; import java.util.Collection; import java.util.HashMap; import java.util.Iterator; @@ -15,6 +16,7 @@ import com.itmill.toolkit.terminal.gwt.client.ui.IAbsoluteLayout; * positioning. * */ +@SuppressWarnings("serial") public class AbsoluteLayout extends AbstractLayout { private Collection components = new LinkedHashSet(); @@ -72,7 +74,7 @@ public class AbsoluteLayout extends AbstractLayout { * in generic java tools * */ - public class ComponentPosition { + public class ComponentPosition implements Serializable { private int zIndex = -1; private float top = -1; diff --git a/src/com/itmill/toolkit/ui/AbstractComponent.java b/src/com/itmill/toolkit/ui/AbstractComponent.java index 0d7f40d5b2..f067b52b88 100644 --- a/src/com/itmill/toolkit/ui/AbstractComponent.java +++ b/src/com/itmill/toolkit/ui/AbstractComponent.java @@ -4,6 +4,7 @@ package com.itmill.toolkit.ui; +import java.io.Serializable; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collection; @@ -35,6 +36,7 @@ import com.itmill.toolkit.terminal.gwt.server.ComponentSizeValidator; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public abstract class AbstractComponent implements Component, MethodEventSource { /* Private members */ @@ -1236,7 +1238,7 @@ public abstract class AbstractComponent implements Component, MethodEventSource public interface ComponentErrorEvent extends Terminal.ErrorEvent { } - public interface ComponentErrorHandler { + public interface ComponentErrorHandler extends Serializable { /** * Handle the component error * diff --git a/src/com/itmill/toolkit/ui/AbstractComponentContainer.java b/src/com/itmill/toolkit/ui/AbstractComponentContainer.java index b9e96533e6..b46117d115 100644 --- a/src/com/itmill/toolkit/ui/AbstractComponentContainer.java +++ b/src/com/itmill/toolkit/ui/AbstractComponentContainer.java @@ -19,6 +19,7 @@ import java.util.LinkedList; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public abstract class AbstractComponentContainer extends AbstractComponent implements ComponentContainer { diff --git a/src/com/itmill/toolkit/ui/AbstractField.java b/src/com/itmill/toolkit/ui/AbstractField.java index 4d717826e6..3cbc788d6b 100644 --- a/src/com/itmill/toolkit/ui/AbstractField.java +++ b/src/com/itmill/toolkit/ui/AbstractField.java @@ -4,6 +4,7 @@ package com.itmill.toolkit.ui; +import java.io.Serializable; import java.lang.reflect.Method; import java.util.Collection; import java.util.Collections; @@ -49,6 +50,7 @@ import com.itmill.toolkit.terminal.PaintTarget; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public abstract class AbstractField extends AbstractComponent implements Field, Property.ReadOnlyStatusChangeNotifier { @@ -873,12 +875,7 @@ public abstract class AbstractField extends AbstractComponent implements Field, * @since 3.0 */ public class ReadOnlyStatusChangeEvent extends Component.Event implements - Property.ReadOnlyStatusChangeEvent { - - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3258688823264161846L; + Property.ReadOnlyStatusChangeEvent, Serializable { /** * New instance of text change event. diff --git a/src/com/itmill/toolkit/ui/AbstractLayout.java b/src/com/itmill/toolkit/ui/AbstractLayout.java index d250501b46..63e70b8350 100644 --- a/src/com/itmill/toolkit/ui/AbstractLayout.java +++ b/src/com/itmill/toolkit/ui/AbstractLayout.java @@ -17,6 +17,7 @@ import com.itmill.toolkit.ui.Layout.MarginHandler; * @VERSION@ * @since 5.0 */ +@SuppressWarnings("serial") public abstract class AbstractLayout extends AbstractComponentContainer implements Layout, MarginHandler { diff --git a/src/com/itmill/toolkit/ui/AbstractOrderedLayout.java b/src/com/itmill/toolkit/ui/AbstractOrderedLayout.java index 8d4b78b3ed..94a3bf3778 100644 --- a/src/com/itmill/toolkit/ui/AbstractOrderedLayout.java +++ b/src/com/itmill/toolkit/ui/AbstractOrderedLayout.java @@ -14,6 +14,7 @@ import com.itmill.toolkit.terminal.PaintException; import com.itmill.toolkit.terminal.PaintTarget; import com.itmill.toolkit.terminal.Sizeable; +@SuppressWarnings("serial") public abstract class AbstractOrderedLayout extends AbstractLayout implements Layout.AlignmentHandler, Layout.SpacingHandler { diff --git a/src/com/itmill/toolkit/ui/AbstractSelect.java b/src/com/itmill/toolkit/ui/AbstractSelect.java index 86fbc7adc2..05f08c5a8f 100644 --- a/src/com/itmill/toolkit/ui/AbstractSelect.java +++ b/src/com/itmill/toolkit/ui/AbstractSelect.java @@ -4,6 +4,7 @@ package com.itmill.toolkit.ui; +import java.io.Serializable; import java.util.Collection; import java.util.Collections; import java.util.HashMap; @@ -41,6 +42,7 @@ import com.itmill.toolkit.terminal.Resource; * @VERSION@ * @since 5.0 */ +@SuppressWarnings("serial") public abstract class AbstractSelect extends AbstractField implements Container, Container.Viewer, Container.PropertySetChangeListener, Container.PropertySetChangeNotifier, Container.ItemSetChangeNotifier, @@ -90,7 +92,7 @@ public abstract class AbstractSelect extends AbstractField implements * caption. FILTERINGMODE_CONTAINS (1) matches anywhere in the * caption. */ - public interface Filtering { + public interface Filtering extends Serializable { public static final int FILTERINGMODE_OFF = 0; public static final int FILTERINGMODE_STARTSWITH = 1; public static final int FILTERINGMODE_CONTAINS = 2; @@ -459,7 +461,7 @@ public abstract class AbstractSelect extends AbstractField implements return newItemHandler; } - public interface NewItemHandler { + public interface NewItemHandler extends Serializable { void addNewItem(String newItemCaption); } @@ -1464,7 +1466,8 @@ public abstract class AbstractSelect extends AbstractField implements /** * Implementation of item set change event. */ - private class ItemSetChangeEvent implements Container.ItemSetChangeEvent { + private class ItemSetChangeEvent implements Serializable, + Container.ItemSetChangeEvent { /** * Gets the Property where the event occurred. @@ -1481,7 +1484,7 @@ public abstract class AbstractSelect extends AbstractField implements * Implementation of property set change event. */ private class PropertySetChangeEvent implements - Container.PropertySetChangeEvent { + Container.PropertySetChangeEvent, Serializable { /** * Retrieves the Container whose contents have been modified. diff --git a/src/com/itmill/toolkit/ui/Accordion.java b/src/com/itmill/toolkit/ui/Accordion.java index 78d9c42743..c7aeb369e6 100644 --- a/src/com/itmill/toolkit/ui/Accordion.java +++ b/src/com/itmill/toolkit/ui/Accordion.java @@ -1,5 +1,6 @@ package com.itmill.toolkit.ui; +@SuppressWarnings("serial") public class Accordion extends TabSheet { @Override diff --git a/src/com/itmill/toolkit/ui/Alignment.java b/src/com/itmill/toolkit/ui/Alignment.java index 6d7ad9accf..91afc090fe 100644 --- a/src/com/itmill/toolkit/ui/Alignment.java +++ b/src/com/itmill/toolkit/ui/Alignment.java @@ -1,12 +1,15 @@ package com.itmill.toolkit.ui; +import java.io.Serializable; + import com.itmill.toolkit.terminal.gwt.client.ui.AlignmentInfo.Bits; /** * Class containing information about alignment of a component. Use the * pre-instantiated classes. */ -public final class Alignment { +@SuppressWarnings("serial") +public final class Alignment implements Serializable { public static final Alignment TOP_RIGHT = new Alignment(Bits.ALIGNMENT_TOP + Bits.ALIGNMENT_RIGHT); diff --git a/src/com/itmill/toolkit/ui/AlignmentUtils.java b/src/com/itmill/toolkit/ui/AlignmentUtils.java index 6a3c556241..f9962bef22 100644 --- a/src/com/itmill/toolkit/ui/AlignmentUtils.java +++ b/src/com/itmill/toolkit/ui/AlignmentUtils.java @@ -1,5 +1,6 @@ package com.itmill.toolkit.ui; +import java.io.Serializable; import java.util.HashMap; import java.util.Map; @@ -23,7 +24,8 @@ import com.itmill.toolkit.ui.Layout.AlignmentHandler; * r,right for right alignment * */ -public class AlignmentUtils { +@SuppressWarnings("serial") +public class AlignmentUtils implements Serializable { private static int horizontalMask = AlignmentHandler.ALIGNMENT_LEFT | AlignmentHandler.ALIGNMENT_HORIZONTAL_CENTER diff --git a/src/com/itmill/toolkit/ui/BaseFieldFactory.java b/src/com/itmill/toolkit/ui/BaseFieldFactory.java index 00e27fdfcc..d5fd225322 100644 --- a/src/com/itmill/toolkit/ui/BaseFieldFactory.java +++ b/src/com/itmill/toolkit/ui/BaseFieldFactory.java @@ -25,6 +25,7 @@ import com.itmill.toolkit.data.Property; * @since 3.1 */ +@SuppressWarnings("serial") public class BaseFieldFactory implements FieldFactory { /** diff --git a/src/com/itmill/toolkit/ui/Button.java b/src/com/itmill/toolkit/ui/Button.java index e90ac2f12a..2af5ba49a3 100644 --- a/src/com/itmill/toolkit/ui/Button.java +++ b/src/com/itmill/toolkit/ui/Button.java @@ -5,6 +5,7 @@ package com.itmill.toolkit.ui; import java.io.IOException; +import java.io.Serializable; import java.lang.reflect.Method; import java.util.Map; @@ -20,6 +21,7 @@ import com.itmill.toolkit.terminal.PaintTarget; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class Button extends AbstractField { /* Private members */ @@ -269,11 +271,6 @@ public class Button extends AbstractField { */ public class ClickEvent extends Component.Event { - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3546647602931118393L; - /** * New instance of text change event. * @@ -302,7 +299,7 @@ public class Button extends AbstractField { * @VERSION@ * @since 3.0 */ - public interface ClickListener { + public interface ClickListener extends Serializable { /** * Button has been pressed. diff --git a/src/com/itmill/toolkit/ui/CheckBox.java b/src/com/itmill/toolkit/ui/CheckBox.java index abb8d7bff6..731808a55e 100644 --- a/src/com/itmill/toolkit/ui/CheckBox.java +++ b/src/com/itmill/toolkit/ui/CheckBox.java @@ -8,6 +8,7 @@ import java.lang.reflect.Method; import com.itmill.toolkit.data.Property; +@SuppressWarnings("serial") public class CheckBox extends Button { /** * Creates a new switch button. diff --git a/src/com/itmill/toolkit/ui/ComboBox.java b/src/com/itmill/toolkit/ui/ComboBox.java index 1c251ef0a0..a901d00540 100644 --- a/src/com/itmill/toolkit/ui/ComboBox.java +++ b/src/com/itmill/toolkit/ui/ComboBox.java @@ -18,6 +18,7 @@ import com.itmill.toolkit.terminal.PaintTarget; * can not turn on multi-select mode. * */ +@SuppressWarnings("serial") public class ComboBox extends Select { private String inputPrompt = null; @@ -74,6 +75,7 @@ public class ComboBox extends Select { this.inputPrompt = inputPrompt; } + @Override public void paintContent(PaintTarget target) throws PaintException { if (inputPrompt != null) { target.addAttribute("prompt", inputPrompt); diff --git a/src/com/itmill/toolkit/ui/Component.java b/src/com/itmill/toolkit/ui/Component.java index 5368bca2cc..9fbc6231cc 100644 --- a/src/com/itmill/toolkit/ui/Component.java +++ b/src/com/itmill/toolkit/ui/Component.java @@ -4,6 +4,7 @@ package com.itmill.toolkit.ui; +import java.io.Serializable; import java.util.Collection; import java.util.EventListener; import java.util.EventObject; @@ -25,7 +26,8 @@ import com.itmill.toolkit.terminal.VariableOwner; * @VERSION@ * @since 3.0 */ -public interface Component extends Paintable, VariableOwner, Sizeable { +public interface Component extends Paintable, VariableOwner, Sizeable, + Serializable { /** * Gets style for component. Multiple styles are joined with spaces. @@ -316,11 +318,6 @@ public interface Component extends Paintable, VariableOwner, Sizeable { */ public class Event extends EventObject { - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 4048791277653274933L; - /** * Constructs a new event with a specified source component. * @@ -335,7 +332,7 @@ public interface Component extends Paintable, VariableOwner, Sizeable { /** * Listener interface for receiving Component.Events. */ - public interface Listener extends EventListener { + public interface Listener extends EventListener, Serializable { /** * Notifies the listener of a component event. @@ -366,13 +363,9 @@ public interface Component extends Paintable, VariableOwner, Sizeable { /** * Class of all component originated ErrorEvents. */ + @SuppressWarnings("serial") public class ErrorEvent extends Event { - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 4051323457293857333L; - private final ErrorMessage message; /** @@ -401,7 +394,7 @@ public interface Component extends Paintable, VariableOwner, Sizeable { /** * Listener interface for receiving Component.Errorss. */ - public interface ErrorListener extends EventListener { + public interface ErrorListener extends EventListener, Serializable { /** * Notifies the listener of a component error. diff --git a/src/com/itmill/toolkit/ui/ComponentContainer.java b/src/com/itmill/toolkit/ui/ComponentContainer.java index a73c8f4d6e..b696c0730d 100644 --- a/src/com/itmill/toolkit/ui/ComponentContainer.java +++ b/src/com/itmill/toolkit/ui/ComponentContainer.java @@ -4,6 +4,7 @@ package com.itmill.toolkit.ui; +import java.io.Serializable; import java.util.Iterator; /** @@ -116,7 +117,7 @@ public interface ComponentContainer extends Component { /** * Component attach listener interface. */ - public interface ComponentAttachListener { + public interface ComponentAttachListener extends Serializable { /** * A new component is attached to container. @@ -130,7 +131,7 @@ public interface ComponentContainer extends Component { /** * Component detach listener interface. */ - public interface ComponentDetachListener { + public interface ComponentDetachListener extends Serializable { /** * A component has been detached from container. @@ -144,13 +145,9 @@ public interface ComponentContainer extends Component { /** * Component attach event sent when a component is attached to container. */ + @SuppressWarnings("serial") public class ComponentAttachEvent extends Component.Event { - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3257285812184692019L; - private final Component component; /** @@ -192,13 +189,9 @@ public interface ComponentContainer extends Component { /** * Component detach event sent when a component is detached from container. */ + @SuppressWarnings("serial") public class ComponentDetachEvent extends Component.Event { - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3618140052337930290L; - private final Component component; /** diff --git a/src/com/itmill/toolkit/ui/CustomComponent.java b/src/com/itmill/toolkit/ui/CustomComponent.java index b0bc392f26..8313609475 100644 --- a/src/com/itmill/toolkit/ui/CustomComponent.java +++ b/src/com/itmill/toolkit/ui/CustomComponent.java @@ -4,6 +4,7 @@ package com.itmill.toolkit.ui; +import java.io.Serializable; import java.util.Iterator; import com.itmill.toolkit.terminal.PaintException; @@ -23,6 +24,7 @@ import com.itmill.toolkit.terminal.PaintTarget; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class CustomComponent extends AbstractComponentContainer { /** @@ -146,23 +148,26 @@ public class CustomComponent extends AbstractComponentContainer { return "customcomponent"; } - public Iterator getComponentIterator() { - return new Iterator() { - boolean first = getCompositionRoot() != null; + private class ComponentIterator implements Iterator, Serializable { + boolean first = getCompositionRoot() != null; - public boolean hasNext() { - return first; - } + public boolean hasNext() { + return first; + } - public Object next() { - first = false; - return root; - } + public Object next() { + first = false; + return root; + } - public void remove() { - throw new UnsupportedOperationException(); - } - }; + public void remove() { + throw new UnsupportedOperationException(); + } + } + + @SuppressWarnings("unchecked") + public Iterator getComponentIterator() { + return new ComponentIterator(); } /** diff --git a/src/com/itmill/toolkit/ui/CustomLayout.java b/src/com/itmill/toolkit/ui/CustomLayout.java index 826ddfb9b2..5fdfe24770 100644 --- a/src/com/itmill/toolkit/ui/CustomLayout.java +++ b/src/com/itmill/toolkit/ui/CustomLayout.java @@ -40,6 +40,7 @@ import com.itmill.toolkit.terminal.PaintTarget; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class CustomLayout extends AbstractLayout { private static final int BUFFER_SIZE = 10000; diff --git a/src/com/itmill/toolkit/ui/DateField.java b/src/com/itmill/toolkit/ui/DateField.java index 96ddc08b9e..6f76de48c5 100644 --- a/src/com/itmill/toolkit/ui/DateField.java +++ b/src/com/itmill/toolkit/ui/DateField.java @@ -33,6 +33,7 @@ import com.itmill.toolkit.terminal.PaintTarget; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class DateField extends AbstractField { /* Private members */ diff --git a/src/com/itmill/toolkit/ui/Embedded.java b/src/com/itmill/toolkit/ui/Embedded.java index 9577a2b643..6b1e2af445 100644 --- a/src/com/itmill/toolkit/ui/Embedded.java +++ b/src/com/itmill/toolkit/ui/Embedded.java @@ -19,6 +19,7 @@ import com.itmill.toolkit.terminal.Resource; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class Embedded extends AbstractComponent { /** diff --git a/src/com/itmill/toolkit/ui/ExpandLayout.java b/src/com/itmill/toolkit/ui/ExpandLayout.java index 352d11d1fd..ea6f037daa 100644 --- a/src/com/itmill/toolkit/ui/ExpandLayout.java +++ b/src/com/itmill/toolkit/ui/ExpandLayout.java @@ -18,6 +18,7 @@ package com.itmill.toolkit.ui; * * @deprecated Deprecated in favor of the new OrderedLayout */ +@SuppressWarnings("serial") @Deprecated public class ExpandLayout extends OrderedLayout { diff --git a/src/com/itmill/toolkit/ui/Field.java b/src/com/itmill/toolkit/ui/Field.java index 9f63fe0f18..8fb339a35d 100644 --- a/src/com/itmill/toolkit/ui/Field.java +++ b/src/com/itmill/toolkit/ui/Field.java @@ -79,14 +79,10 @@ public interface Field extends Component, BufferedValidatable, Property, * @VERSION@ * @since 3.0 */ + @SuppressWarnings("serial") public class ValueChangeEvent extends Component.Event implements Property.ValueChangeEvent { - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3545803169444672816L; - /** * Constructs a new event object with the specified source field object. * diff --git a/src/com/itmill/toolkit/ui/FieldFactory.java b/src/com/itmill/toolkit/ui/FieldFactory.java index 01bc707cc7..6598577f48 100644 --- a/src/com/itmill/toolkit/ui/FieldFactory.java +++ b/src/com/itmill/toolkit/ui/FieldFactory.java @@ -4,6 +4,8 @@ package com.itmill.toolkit.ui; +import java.io.Serializable; + import com.itmill.toolkit.data.Container; import com.itmill.toolkit.data.Item; import com.itmill.toolkit.data.Property; @@ -17,7 +19,7 @@ import com.itmill.toolkit.data.Property; * @VERSION@ * @since 3.1 */ -public interface FieldFactory { +public interface FieldFactory extends Serializable { /** * Creates a field based on type of data. diff --git a/src/com/itmill/toolkit/ui/Form.java b/src/com/itmill/toolkit/ui/Form.java index b31feaea68..ee45ec0478 100644 --- a/src/com/itmill/toolkit/ui/Form.java +++ b/src/com/itmill/toolkit/ui/Form.java @@ -53,6 +53,7 @@ import com.itmill.toolkit.terminal.PaintTarget; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class Form extends AbstractField implements Item.Editor, Buffered, Item, Validatable { diff --git a/src/com/itmill/toolkit/ui/FormLayout.java b/src/com/itmill/toolkit/ui/FormLayout.java index ddff9fa07f..54074f05f9 100644 --- a/src/com/itmill/toolkit/ui/FormLayout.java +++ b/src/com/itmill/toolkit/ui/FormLayout.java @@ -19,6 +19,7 @@ package com.itmill.toolkit.ui; * bottom are by default on. * */ +@SuppressWarnings( { "deprecation", "serial" }) public class FormLayout extends OrderedLayout { public FormLayout() { diff --git a/src/com/itmill/toolkit/ui/GridLayout.java b/src/com/itmill/toolkit/ui/GridLayout.java index 17cdc6754f..608871bcf5 100644 --- a/src/com/itmill/toolkit/ui/GridLayout.java +++ b/src/com/itmill/toolkit/ui/GridLayout.java @@ -4,6 +4,7 @@ package com.itmill.toolkit.ui; +import java.io.Serializable; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; @@ -34,6 +35,7 @@ import com.itmill.toolkit.terminal.PaintTarget; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class GridLayout extends AbstractLayout implements Layout.AlignmentHandler, Layout.SpacingHandler { @@ -656,7 +658,7 @@ public class GridLayout extends AbstractLayout implements * @VERSION@ * @since 3.0 */ - public class Area { + public class Area implements Serializable { /** * The column of the upper left corner cell of the area. @@ -843,11 +845,6 @@ public class GridLayout extends AbstractLayout implements */ public class OverlapsException extends java.lang.RuntimeException { - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3978144339870101561L; - private final Area existingArea; /** @@ -880,11 +877,6 @@ public class GridLayout extends AbstractLayout implements */ public class OutOfBoundsException extends java.lang.RuntimeException { - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3618985589664592694L; - private final Area areaOutOfBounds; /** diff --git a/src/com/itmill/toolkit/ui/HorizontalLayout.java b/src/com/itmill/toolkit/ui/HorizontalLayout.java index 1ae5d7a375..f648ba157a 100644 --- a/src/com/itmill/toolkit/ui/HorizontalLayout.java +++ b/src/com/itmill/toolkit/ui/HorizontalLayout.java @@ -11,6 +11,7 @@ package com.itmill.toolkit.ui; * @VERSION@ * @since 5.3 */ +@SuppressWarnings("serial") public class HorizontalLayout extends AbstractOrderedLayout { public HorizontalLayout() { diff --git a/src/com/itmill/toolkit/ui/InlineDateField.java b/src/com/itmill/toolkit/ui/InlineDateField.java index 46db9c7fc7..d24f1ecba5 100644 --- a/src/com/itmill/toolkit/ui/InlineDateField.java +++ b/src/com/itmill/toolkit/ui/InlineDateField.java @@ -21,6 +21,7 @@ import com.itmill.toolkit.data.Property; * @VERSION@ * @since 5.0 */ +@SuppressWarnings("serial") public class InlineDateField extends DateField { public InlineDateField() { diff --git a/src/com/itmill/toolkit/ui/Label.java b/src/com/itmill/toolkit/ui/Label.java index 1a9e497e9c..4a272ed1d1 100644 --- a/src/com/itmill/toolkit/ui/Label.java +++ b/src/com/itmill/toolkit/ui/Label.java @@ -36,6 +36,7 @@ import com.itmill.toolkit.terminal.PaintTarget; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class Label extends AbstractComponent implements Property, Property.Viewer, Property.ValueChangeListener, Property.ValueChangeNotifier, Comparable { @@ -403,11 +404,6 @@ public class Label extends AbstractComponent implements Property, public class ValueChangeEvent extends Component.Event implements Property.ValueChangeEvent { - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3906084563938586935L; - /** * New instance of text change event * diff --git a/src/com/itmill/toolkit/ui/Layout.java b/src/com/itmill/toolkit/ui/Layout.java index 78de97eaa8..d18cd93ea1 100644 --- a/src/com/itmill/toolkit/ui/Layout.java +++ b/src/com/itmill/toolkit/ui/Layout.java @@ -4,6 +4,8 @@ package com.itmill.toolkit.ui; +import java.io.Serializable; + import com.itmill.toolkit.terminal.gwt.client.ui.IMarginInfo; import com.itmill.toolkit.terminal.gwt.client.ui.AlignmentInfo.Bits; @@ -18,7 +20,7 @@ import com.itmill.toolkit.terminal.gwt.client.ui.AlignmentInfo.Bits; * @VERSION@ * @since 3.0 */ -public interface Layout extends ComponentContainer { +public interface Layout extends ComponentContainer, Serializable { /** * Enable layout margins. Affects all four sides of the layout. This will @@ -48,7 +50,7 @@ public interface Layout extends ComponentContainer { * AlignmentHandler is most commonly an advanced {@link Layout} that can * align its components. */ - public interface AlignmentHandler { + public interface AlignmentHandler extends Serializable { /** * Contained component should be aligned horizontally to the left. @@ -149,7 +151,7 @@ public interface Layout extends ComponentContainer { * components. * */ - public interface SpacingHandler { + public interface SpacingHandler extends Serializable { /** * Enable spacing between child components within this layout. * @@ -184,7 +186,7 @@ public interface Layout extends ComponentContainer { * This type of layout supports automatic addition of margins (space around * its components). */ - public interface MarginHandler { + public interface MarginHandler extends Serializable { /** * Enable margins for this layout. * @@ -212,7 +214,8 @@ public interface Layout extends ComponentContainer { public MarginInfo getMargin(); } - public static class MarginInfo extends IMarginInfo { + @SuppressWarnings("serial") + public static class MarginInfo extends IMarginInfo implements Serializable { public MarginInfo(boolean enabled) { super(enabled, enabled, enabled, enabled); diff --git a/src/com/itmill/toolkit/ui/Link.java b/src/com/itmill/toolkit/ui/Link.java index 50c1470acd..53f2837386 100644 --- a/src/com/itmill/toolkit/ui/Link.java +++ b/src/com/itmill/toolkit/ui/Link.java @@ -16,6 +16,7 @@ import com.itmill.toolkit.terminal.Resource; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class Link extends AbstractComponent { /* Target window border type constant: No window border */ diff --git a/src/com/itmill/toolkit/ui/ListSelect.java b/src/com/itmill/toolkit/ui/ListSelect.java index 508ac50858..9d3fe70fdb 100644 --- a/src/com/itmill/toolkit/ui/ListSelect.java +++ b/src/com/itmill/toolkit/ui/ListSelect.java @@ -14,6 +14,7 @@ import com.itmill.toolkit.terminal.PaintTarget; * This is a simple list select without, for instance, support for new items, * lazyloading, and other advanced features. */ +@SuppressWarnings("serial") public class ListSelect extends AbstractSelect { private int columns = 0; diff --git a/src/com/itmill/toolkit/ui/LoginForm.java b/src/com/itmill/toolkit/ui/LoginForm.java index 4aa5c704e8..06b9de2a7d 100644 --- a/src/com/itmill/toolkit/ui/LoginForm.java +++ b/src/com/itmill/toolkit/ui/LoginForm.java @@ -1,6 +1,7 @@ package com.itmill.toolkit.ui; import java.io.ByteArrayInputStream; +import java.io.Serializable; import java.lang.reflect.Method; import java.net.URL; import java.util.HashMap; @@ -33,6 +34,7 @@ import com.itmill.toolkit.terminal.URIHandler; * * @since 5.3 */ +@SuppressWarnings("serial") public class LoginForm extends CustomComponent { private Embedded iframe = new Embedded(); @@ -185,8 +187,6 @@ public class LoginForm extends CustomComponent { */ public class LoginEvent extends Event { - private static final long serialVersionUID = 1966036438671224308L; - private Map params; private LoginEvent(Map params) { @@ -213,7 +213,7 @@ public class LoginForm extends CustomComponent { * Login listener is a class capable to listen LoginEvents sent from * LoginBox */ - public interface LoginListener { + public interface LoginListener extends Serializable { /** * This method is fired on each login form post. * diff --git a/src/com/itmill/toolkit/ui/MenuBar.java b/src/com/itmill/toolkit/ui/MenuBar.java index c0f400933c..e3004eb196 100644 --- a/src/com/itmill/toolkit/ui/MenuBar.java +++ b/src/com/itmill/toolkit/ui/MenuBar.java @@ -1,5 +1,6 @@ package com.itmill.toolkit.ui; +import java.io.Serializable; import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -17,6 +18,7 @@ import com.itmill.toolkit.terminal.Resource; * are represented as vertical menu. *

*/ +@SuppressWarnings("serial") public class MenuBar extends AbstractComponent { // Items of the top-level menu @@ -70,7 +72,7 @@ public class MenuBar extends AbstractComponent { // This generates the tree from the contents of the menu while (itr.hasNext()) { - MenuItem item = (MenuItem) itr.next(); + MenuItem item = itr.next(); target.startTag("item"); @@ -127,7 +129,7 @@ public class MenuBar extends AbstractComponent { // Go through all the items in the menu while (!found && !items.empty()) { - tmpItem = (MenuItem) items.pop(); + tmpItem = items.pop(); found = (clickedId.intValue() == tmpItem.getId()); if (tmpItem.hasChildren()) { @@ -343,7 +345,7 @@ public class MenuBar extends AbstractComponent { * {@link com.itmill.toolkit.ui.MenuBar.MenuItem}. The selected item is * given as an argument. */ - public interface Command { + public interface Command extends Serializable { public void menuSelected(MenuBar.MenuItem selectedItem); } @@ -354,7 +356,7 @@ public class MenuBar extends AbstractComponent { * multiple MenuItems to a MenuItem and create a sub-menu. * */ - public class MenuItem { + public class MenuItem implements Serializable { /** Private members * */ private final int itsId; diff --git a/src/com/itmill/toolkit/ui/NativeSelect.java b/src/com/itmill/toolkit/ui/NativeSelect.java index 2cd78ac699..33a88c4ceb 100644 --- a/src/com/itmill/toolkit/ui/NativeSelect.java +++ b/src/com/itmill/toolkit/ui/NativeSelect.java @@ -16,6 +16,7 @@ import com.itmill.toolkit.terminal.PaintTarget; * "native" select without all the bells-and-whistles of the ComboBox is a * better choice. */ +@SuppressWarnings("serial") public class NativeSelect extends AbstractSelect { // width in characters, mimics TextField diff --git a/src/com/itmill/toolkit/ui/OptionGroup.java b/src/com/itmill/toolkit/ui/OptionGroup.java index 2ebaaea3ea..25664b2a7a 100644 --- a/src/com/itmill/toolkit/ui/OptionGroup.java +++ b/src/com/itmill/toolkit/ui/OptionGroup.java @@ -13,6 +13,7 @@ import com.itmill.toolkit.terminal.PaintTarget; /** * Configures select to be used as an option group. */ +@SuppressWarnings("serial") public class OptionGroup extends AbstractSelect { public OptionGroup() { diff --git a/src/com/itmill/toolkit/ui/OrderedLayout.java b/src/com/itmill/toolkit/ui/OrderedLayout.java index e95c490ee1..61c59b31aa 100644 --- a/src/com/itmill/toolkit/ui/OrderedLayout.java +++ b/src/com/itmill/toolkit/ui/OrderedLayout.java @@ -18,6 +18,7 @@ import com.itmill.toolkit.terminal.PaintTarget; * OrderedLayout but AbstractOrderedLayout (which also OrderedLayout * extends). */ +@SuppressWarnings("serial") @Deprecated public class OrderedLayout extends AbstractOrderedLayout { /* Predefined orientations */ diff --git a/src/com/itmill/toolkit/ui/Panel.java b/src/com/itmill/toolkit/ui/Panel.java index 1a8871e7e3..b471a0d330 100644 --- a/src/com/itmill/toolkit/ui/Panel.java +++ b/src/com/itmill/toolkit/ui/Panel.java @@ -24,6 +24,7 @@ import com.itmill.toolkit.terminal.Scrollable; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class Panel extends AbstractComponentContainer implements Scrollable, ComponentContainer.ComponentAttachListener, ComponentContainer.ComponentDetachListener, Action.Container { diff --git a/src/com/itmill/toolkit/ui/PopupDateField.java b/src/com/itmill/toolkit/ui/PopupDateField.java index b00f55ae92..873b991cd3 100644 --- a/src/com/itmill/toolkit/ui/PopupDateField.java +++ b/src/com/itmill/toolkit/ui/PopupDateField.java @@ -21,6 +21,7 @@ import com.itmill.toolkit.data.Property; * @VERSION@ * @since 5.0 */ +@SuppressWarnings("serial") public class PopupDateField extends DateField { public PopupDateField() { diff --git a/src/com/itmill/toolkit/ui/PopupView.java b/src/com/itmill/toolkit/ui/PopupView.java index 183187ebae..a9b9cb13be 100644 --- a/src/com/itmill/toolkit/ui/PopupView.java +++ b/src/com/itmill/toolkit/ui/PopupView.java @@ -1,5 +1,6 @@ package com.itmill.toolkit.ui; +import java.io.Serializable; import java.lang.reflect.Method; import java.util.Iterator; import java.util.Map; @@ -16,6 +17,7 @@ import com.itmill.toolkit.terminal.PaintTarget; * * @author IT Mill Ltd. */ +@SuppressWarnings("serial") public class PopupView extends AbstractComponentContainer { private Content content; @@ -330,7 +332,7 @@ public class PopupView extends AbstractComponentContainer { * dynamically loaded when they are redrawn. The user must take care that * neither of these methods ever return null. */ - public interface Content { + public interface Content extends Serializable { /** * This should return a small view of the full data. @@ -385,10 +387,6 @@ public class PopupView extends AbstractComponentContainer { * */ public class PopupVisibilityEvent extends Event { - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = -130167162207143457L; public PopupVisibilityEvent(PopupView source) { super(source); @@ -418,7 +416,7 @@ public class PopupView extends AbstractComponentContainer { * visibility of the popup changes. * */ - public interface PopupVisibilityListener { + public interface PopupVisibilityListener extends Serializable { /** * Pass to {@link PopupView#PopupVisibilityEvent} to start listening for * popup visibility changes. diff --git a/src/com/itmill/toolkit/ui/ProgressIndicator.java b/src/com/itmill/toolkit/ui/ProgressIndicator.java index fc5b308b64..6f05db772d 100644 --- a/src/com/itmill/toolkit/ui/ProgressIndicator.java +++ b/src/com/itmill/toolkit/ui/ProgressIndicator.java @@ -23,6 +23,7 @@ import com.itmill.toolkit.terminal.PaintTarget; * @VERSION@ * @since 4 */ +@SuppressWarnings("serial") public class ProgressIndicator extends AbstractField implements Property, Property.Viewer, Property.ValueChangeListener { diff --git a/src/com/itmill/toolkit/ui/RichTextArea.java b/src/com/itmill/toolkit/ui/RichTextArea.java index fad763819d..4e2830329b 100644 --- a/src/com/itmill/toolkit/ui/RichTextArea.java +++ b/src/com/itmill/toolkit/ui/RichTextArea.java @@ -14,6 +14,7 @@ import com.itmill.toolkit.terminal.PaintTarget; * {@link RichTextArea} may produce unexpected results as formatting is counted * into length of field. */ +@SuppressWarnings("serial") public class RichTextArea extends TextField { @Override diff --git a/src/com/itmill/toolkit/ui/Select.java b/src/com/itmill/toolkit/ui/Select.java index a778155b75..a1acec5e3e 100644 --- a/src/com/itmill/toolkit/ui/Select.java +++ b/src/com/itmill/toolkit/ui/Select.java @@ -35,6 +35,7 @@ import com.itmill.toolkit.terminal.Resource; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class Select extends AbstractSelect implements AbstractSelect.Filtering { /** diff --git a/src/com/itmill/toolkit/ui/Slider.java b/src/com/itmill/toolkit/ui/Slider.java index 0fb3496404..e47eb9a7d4 100644 --- a/src/com/itmill/toolkit/ui/Slider.java +++ b/src/com/itmill/toolkit/ui/Slider.java @@ -10,9 +10,9 @@ import com.itmill.toolkit.terminal.PaintException; import com.itmill.toolkit.terminal.PaintTarget; /** - * A component for selecting a numerical value within a range. A Slider - * can have the appearance of a scroll bar or e.g. look like an Adobe Photoshop - * style of a slider. + * A component for selecting a numerical value within a range. A Slider can have + * the appearance of a scroll bar or e.g. look like an Adobe Photoshop style of + * a slider. * * Example code: * class MyPlayer extends CustomComponent implements ValueChangeListener { @@ -46,6 +46,7 @@ import com.itmill.toolkit.terminal.PaintTarget; * * @author IT Mill Ltd. */ +@SuppressWarnings("serial") public class Slider extends AbstractField { public static final int ORIENTATION_HORIZONTAL = 0; @@ -485,11 +486,6 @@ public class Slider extends AbstractField { */ public class ValueOutOfBoundsException extends Exception { - /** - * Serial generated by Eclipse. - */ - private static final long serialVersionUID = -6451298598644446340L; - private final Double value; /** diff --git a/src/com/itmill/toolkit/ui/SplitPanel.java b/src/com/itmill/toolkit/ui/SplitPanel.java index 2af72da310..06b8073c6c 100644 --- a/src/com/itmill/toolkit/ui/SplitPanel.java +++ b/src/com/itmill/toolkit/ui/SplitPanel.java @@ -22,6 +22,7 @@ import com.itmill.toolkit.terminal.gwt.client.RenderInformation.Size; * @VERSION@ * @since 5.0 */ +@SuppressWarnings("serial") public class SplitPanel extends AbstractLayout { /* Predefined orientations */ diff --git a/src/com/itmill/toolkit/ui/TabSheet.java b/src/com/itmill/toolkit/ui/TabSheet.java index 25a5c65455..5d2e9ac57f 100644 --- a/src/com/itmill/toolkit/ui/TabSheet.java +++ b/src/com/itmill/toolkit/ui/TabSheet.java @@ -4,6 +4,7 @@ package com.itmill.toolkit.ui; +import java.io.Serializable; import java.lang.reflect.Method; import java.util.Iterator; import java.util.LinkedList; @@ -23,6 +24,7 @@ import com.itmill.toolkit.terminal.Paintable.RepaintRequestListener; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class TabSheet extends AbstractComponentContainer implements RepaintRequestListener { @@ -203,7 +205,7 @@ public class TabSheet extends AbstractComponentContainer implements * not) we select this tab instead */ if (selected == null || !selected.isVisible() - || (!selected.isEnabled() && this.isEnabled())) { + || (!selected.isEnabled() && isEnabled())) { selected = c; } target.startTag("tab"); @@ -451,11 +453,6 @@ public class TabSheet extends AbstractComponentContainer implements */ public class SelectedTabChangeEvent extends Component.Event { - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3258129141914940469L; - /** * New instance of selected tab change event * @@ -485,7 +482,7 @@ public class TabSheet extends AbstractComponentContainer implements * @VERSION@ * @since 3.0 */ - public interface SelectedTabChangeListener { + public interface SelectedTabChangeListener extends Serializable { /** * Visible tab in tab sheet has has been changed. diff --git a/src/com/itmill/toolkit/ui/Table.java b/src/com/itmill/toolkit/ui/Table.java index 1ad0eda6ad..4d4fdba7fb 100644 --- a/src/com/itmill/toolkit/ui/Table.java +++ b/src/com/itmill/toolkit/ui/Table.java @@ -4,6 +4,7 @@ package com.itmill.toolkit.ui; +import java.io.Serializable; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -49,6 +50,7 @@ import com.itmill.toolkit.terminal.gwt.client.MouseEventDetails; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class Table extends AbstractSelect implements Action.Container, Container.Ordered, Container.Sortable, ItemClickSource { @@ -3067,7 +3069,7 @@ public class Table extends AbstractSelect implements Action.Container, * Table.addGeneratedColumn along with an id for the column to be generated. * */ - public interface ColumnGenerator { + public interface ColumnGenerator extends Serializable { /** * Called by Table when a cell in a generated column needs to be @@ -3112,7 +3114,7 @@ public class Table extends AbstractSelect implements Action.Container, * to the cell content is i-table-cell-content-[style name], and * the row style will be i-table-row-[style name]. */ - public interface CellStyleGenerator { + public interface CellStyleGenerator extends Serializable { /** * Called by Table when a cell (and row) is painted. diff --git a/src/com/itmill/toolkit/ui/TextField.java b/src/com/itmill/toolkit/ui/TextField.java index e5572f0b9f..8c124799d8 100644 --- a/src/com/itmill/toolkit/ui/TextField.java +++ b/src/com/itmill/toolkit/ui/TextField.java @@ -31,6 +31,7 @@ import com.itmill.toolkit.terminal.PaintTarget; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class TextField extends AbstractField { /* Private members */ diff --git a/src/com/itmill/toolkit/ui/Tree.java b/src/com/itmill/toolkit/ui/Tree.java index 20c7e03961..18b18651f9 100644 --- a/src/com/itmill/toolkit/ui/Tree.java +++ b/src/com/itmill/toolkit/ui/Tree.java @@ -4,6 +4,7 @@ package com.itmill.toolkit.ui; +import java.io.Serializable; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collection; @@ -40,11 +41,10 @@ import com.itmill.toolkit.terminal.gwt.client.MouseEventDetails; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class Tree extends AbstractSelect implements Container.Hierarchical, Action.Container, ItemClickSource { - /* Static members */ - private static final Method EXPAND_METHOD; private static final Method COLLAPSE_METHOD; @@ -723,11 +723,6 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, */ public class ExpandEvent extends Component.Event { - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3832624001804481075L; - private final Object expandedItemId; /** @@ -760,7 +755,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, * @VERSION@ * @since 3.0 */ - public interface ExpandListener { + public interface ExpandListener extends Serializable { /** * A node has been expanded. @@ -813,11 +808,6 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, */ public class CollapseEvent extends Component.Event { - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3257009834783290160L; - private final Object collapsedItemId; /** @@ -850,7 +840,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, * @VERSION@ * @since 3.0 */ - public interface CollapseListener { + public interface CollapseListener extends Serializable { /** * A node has been collapsed. diff --git a/src/com/itmill/toolkit/ui/TwinColSelect.java b/src/com/itmill/toolkit/ui/TwinColSelect.java index 0876ec81d8..ac00498418 100644 --- a/src/com/itmill/toolkit/ui/TwinColSelect.java +++ b/src/com/itmill/toolkit/ui/TwinColSelect.java @@ -14,6 +14,7 @@ import com.itmill.toolkit.terminal.PaintTarget; * Multiselect component with two lists: left side for available items and right * side for selected items. */ +@SuppressWarnings("serial") public class TwinColSelect extends AbstractSelect { private int columns = 0; diff --git a/src/com/itmill/toolkit/ui/Upload.java b/src/com/itmill/toolkit/ui/Upload.java index a6fe4df873..e053d99fab 100644 --- a/src/com/itmill/toolkit/ui/Upload.java +++ b/src/com/itmill/toolkit/ui/Upload.java @@ -6,6 +6,7 @@ package com.itmill.toolkit.ui; import java.io.InputStream; import java.io.OutputStream; +import java.io.Serializable; import java.lang.reflect.Method; import java.util.Iterator; import java.util.LinkedHashSet; @@ -42,6 +43,7 @@ import com.itmill.toolkit.terminal.UploadStream; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class Upload extends AbstractComponent implements Component.Focusable { private boolean delayedFocus; @@ -235,7 +237,7 @@ public class Upload extends AbstractComponent implements Component.Focusable { * @VERSION@ * @since 3.0 */ - public interface Receiver { + public interface Receiver extends Serializable { /** * Invoked when a new upload arrives. @@ -291,9 +293,6 @@ public class Upload extends AbstractComponent implements Component.Focusable { */ public class FinishedEvent extends Component.Event { - /** - * Serial generated by eclipse. - */ private static final long serialVersionUID = 3257288015385670969L; /** @@ -379,9 +378,6 @@ public class Upload extends AbstractComponent implements Component.Focusable { */ public class FailedEvent extends FinishedEvent { - /** - * Serial generated by eclipse. - */ private static final long serialVersionUID = 3833746590157386293L; private Exception reason = null; @@ -429,9 +425,6 @@ public class Upload extends AbstractComponent implements Component.Focusable { */ public class NoOutputStreamEvent extends FailedEvent { - /** - * Serial generated by eclipse. - */ private static final long serialVersionUID = 4745219890852396500L; /** @@ -452,9 +445,6 @@ public class Upload extends AbstractComponent implements Component.Focusable { */ public class NoInputStreamEvent extends FailedEvent { - /** - * Serial generated by eclipse. - */ private static final long serialVersionUID = -529960205445737170L; /** @@ -481,9 +471,6 @@ public class Upload extends AbstractComponent implements Component.Focusable { */ public class SucceededEvent extends FinishedEvent { - /** - * Serial generated by eclipse. - */ private static final long serialVersionUID = 3256445798169524023L; /** @@ -510,9 +497,6 @@ public class Upload extends AbstractComponent implements Component.Focusable { */ public class StartedEvent extends Component.Event { - /** - * Serial generated by eclipse. - */ private static final long serialVersionUID = -3984393770487403525L; private final String filename; private final String type; @@ -567,7 +551,7 @@ public class Upload extends AbstractComponent implements Component.Focusable { * @VERSION@ * @since 5.0 */ - public interface StartedListener { + public interface StartedListener extends Serializable { /** * Upload has started. @@ -586,7 +570,7 @@ public class Upload extends AbstractComponent implements Component.Focusable { * @VERSION@ * @since 3.0 */ - public interface FinishedListener { + public interface FinishedListener extends Serializable { /** * Upload has finished. @@ -605,7 +589,7 @@ public class Upload extends AbstractComponent implements Component.Focusable { * @VERSION@ * @since 3.0 */ - public interface FailedListener { + public interface FailedListener extends Serializable { /** * Upload has finished unsuccessfully. @@ -624,7 +608,7 @@ public class Upload extends AbstractComponent implements Component.Focusable { * @VERSION@ * @since 3.0 */ - public interface SucceededListener { + public interface SucceededListener extends Serializable { /** * Upload successfull.. @@ -966,7 +950,7 @@ public class Upload extends AbstractComponent implements Component.Focusable { /** * ProgressListener receives events to track progress of upload. */ - public interface ProgressListener { + public interface ProgressListener extends Serializable { /** * Updates progress to listener * diff --git a/src/com/itmill/toolkit/ui/UriFragmentUtility.java b/src/com/itmill/toolkit/ui/UriFragmentUtility.java index 11d141e05c..3852bdc7d2 100644 --- a/src/com/itmill/toolkit/ui/UriFragmentUtility.java +++ b/src/com/itmill/toolkit/ui/UriFragmentUtility.java @@ -1,5 +1,6 @@ package com.itmill.toolkit.ui; +import java.io.Serializable; import java.lang.reflect.Method; import java.util.Map; @@ -15,12 +16,13 @@ import com.itmill.toolkit.terminal.PaintTarget; * bookmarking a program state and back button. * */ +@SuppressWarnings("serial") public class UriFragmentUtility extends AbstractComponent { /** * Listener that listens changes in URI fragment. */ - public interface FragmentChangedListener { + public interface FragmentChangedListener extends Serializable { public void fragmentChanged(FragmentChangedEvent source); @@ -31,11 +33,6 @@ public class UriFragmentUtility extends AbstractComponent { */ public class FragmentChangedEvent extends Component.Event { - /** - * Serial generated by eclipse - */ - private static final long serialVersionUID = -4142140007700263197L; - /** * Creates a new instance of UriFragmentReader change event. * diff --git a/src/com/itmill/toolkit/ui/VerticalLayout.java b/src/com/itmill/toolkit/ui/VerticalLayout.java index 1bc5e99794..21934bbd0f 100644 --- a/src/com/itmill/toolkit/ui/VerticalLayout.java +++ b/src/com/itmill/toolkit/ui/VerticalLayout.java @@ -12,6 +12,7 @@ package com.itmill.toolkit.ui; * @VERSION@ * @since 5.3 */ +@SuppressWarnings("serial") public class VerticalLayout extends AbstractOrderedLayout { public VerticalLayout() { diff --git a/src/com/itmill/toolkit/ui/Window.java b/src/com/itmill/toolkit/ui/Window.java index 530bd8441d..9dac2c2c2a 100644 --- a/src/com/itmill/toolkit/ui/Window.java +++ b/src/com/itmill/toolkit/ui/Window.java @@ -4,6 +4,7 @@ package com.itmill.toolkit.ui; +import java.io.Serializable; import java.lang.reflect.Method; import java.net.MalformedURLException; import java.net.URL; @@ -32,6 +33,7 @@ import com.itmill.toolkit.terminal.URIHandler; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class Window extends Panel implements URIHandler, ParameterHandler { /** @@ -787,7 +789,7 @@ public class Window extends Panel implements URIHandler, ParameterHandler { /** * Private data structure for storing opening window properties. */ - private class OpenResource { + private class OpenResource implements Serializable { private final Resource resource; @@ -1000,11 +1002,6 @@ public class Window extends Panel implements URIHandler, ParameterHandler { public class CloseEvent extends Component.Event { - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = -7235770057344367327L; - /** * * @param source @@ -1023,7 +1020,7 @@ public class Window extends Panel implements URIHandler, ParameterHandler { } } - public interface CloseListener { + public interface CloseListener extends Serializable { public void windowClose(CloseEvent e); } @@ -1073,9 +1070,6 @@ public class Window extends Panel implements URIHandler, ParameterHandler { */ public class ResizeEvent extends Component.Event { - // Generated serial - private static final long serialVersionUID = 8569831802323447687L; - /** * * @param source @@ -1099,7 +1093,7 @@ public class Window extends Panel implements URIHandler, ParameterHandler { * * @see com.itmill.toolkit.ui.Window.ResizeEvent */ - public interface ResizeListener { + public interface ResizeListener extends Serializable { public void windowResized(ResizeEvent e); } @@ -1403,7 +1397,7 @@ public class Window extends Panel implements URIHandler, ParameterHandler { *

* */ - public static class Notification { + public static class Notification implements Serializable { public static final int TYPE_HUMANIZED_MESSAGE = 1; public static final int TYPE_WARNING_MESSAGE = 2; public static final int TYPE_ERROR_MESSAGE = 3; -- cgit v1.2.3 From 050ee582add077199cbf28b395104c6cfc027f5a Mon Sep 17 00:00:00 2001 From: Joonas Lehtinen Date: Sun, 12 Apr 2009 09:20:58 +0000 Subject: Added serialization-time measurement to Ticket695 svn changeset:7388/svn branch:6.0 --- .../itmill/toolkit/tests/tickets/Ticket695.java | 55 ++++++++++++---------- 1 file changed, 29 insertions(+), 26 deletions(-) (limited to 'src/com/itmill/toolkit') diff --git a/src/com/itmill/toolkit/tests/tickets/Ticket695.java b/src/com/itmill/toolkit/tests/tickets/Ticket695.java index fc040d8ba3..8e45c4ca5c 100644 --- a/src/com/itmill/toolkit/tests/tickets/Ticket695.java +++ b/src/com/itmill/toolkit/tests/tickets/Ticket695.java @@ -3,6 +3,7 @@ package com.itmill.toolkit.tests.tickets; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.ObjectOutputStream; + import com.itmill.toolkit.Application; import com.itmill.toolkit.ui.Button; import com.itmill.toolkit.ui.Window; @@ -10,31 +11,33 @@ import com.itmill.toolkit.ui.Button.ClickEvent; public class Ticket695 extends Application { - private static final long serialVersionUID = 3803150085397590662L; - - @Override - public void init() { - final Window w = new Window("Serialization test #695"); - setMainWindow(w); - Button b = new Button("Serialize ApplicationContext"); - w.addComponent(b); - b.addListener(new Button.ClickListener() { - - public void buttonClick(ClickEvent event) { - ByteArrayOutputStream buffer = new ByteArrayOutputStream(); - try { - ObjectOutputStream oos = new ObjectOutputStream(buffer); - oos.writeObject(getContext()); - w.showNotification("ApplicationContext serialized (" - + buffer.size() + "bytes)"); - } catch (IOException e) { - e.printStackTrace(); - w - .showNotification("ApplicationContext serialization failed - see console for stacktrace"); - } - - } - }); - } + private static final long serialVersionUID = 3803150085397590662L; + + @Override + public void init() { + final Window w = new Window("Serialization test #695"); + setMainWindow(w); + Button b = new Button("Serialize ApplicationContext"); + w.addComponent(b); + b.addListener(new Button.ClickListener() { + + public void buttonClick(ClickEvent event) { + ByteArrayOutputStream buffer = new ByteArrayOutputStream(); + try { + ObjectOutputStream oos = new ObjectOutputStream(buffer); + long t = System.currentTimeMillis(); + oos.writeObject(getContext()); + w.showNotification("ApplicationContext serialized (" + + buffer.size() + "bytes) in " + + (System.currentTimeMillis() - t) + "ms"); + } catch (IOException e) { + e.printStackTrace(); + w + .showNotification("ApplicationContext serialization failed - see console for stacktrace"); + } + + } + }); + } } -- cgit v1.2.3 From d0fdb4c63b9a89ae4b58e8956aab47d3e38bac12 Mon Sep 17 00:00:00 2001 From: Joonas Lehtinen Date: Sun, 12 Apr 2009 09:50:09 +0000 Subject: Committing Arturs patch to #2840 svn changeset:7389/svn branch:6.0 --- .../terminal/gwt/server/CommunicationManager.java | 23 +++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'src/com/itmill/toolkit') diff --git a/src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java b/src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java index 4905b858c5..cd4fcae766 100644 --- a/src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java +++ b/src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java @@ -17,6 +17,7 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.net.URL; import java.security.GeneralSecurityException; +import java.text.DateFormat; import java.text.DateFormatSymbols; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -854,10 +855,6 @@ public class CommunicationManager implements Paintable.RepaintRequestListener, * ----------------------------- */ - // Store JVM default locale for later restoration - // (we'll have to change the default locale for a while) - final Locale jvmDefault = Locale.getDefault(); - // Send locale informations to client outWriter.print(", \"locales\":["); for (; pendingLocalesIndex < locales.size(); pendingLocalesIndex++) { @@ -916,10 +913,17 @@ public class CommunicationManager implements Paintable.RepaintRequestListener, /* * Date formatting (MM/DD/YYYY etc.) */ - // Force our locale as JVM default for a while (SimpleDateFormat - // uses JVM default) - Locale.setDefault(l); - final String df = new SimpleDateFormat().toPattern(); + + DateFormat dateFormat = DateFormat.getDateTimeInstance( + DateFormat.SHORT, DateFormat.SHORT, l); + if (!(dateFormat instanceof SimpleDateFormat)) { + System.err + .println("Unable to get default date pattern for locale " + + l.toString()); + dateFormat = new SimpleDateFormat(); + } + final String df = ((SimpleDateFormat) dateFormat).toPattern(); + int timeStart = df.indexOf("H"); if (timeStart < 0) { timeStart = df.indexOf("h"); @@ -963,9 +967,6 @@ public class CommunicationManager implements Paintable.RepaintRequestListener, } } outWriter.print("]"); // Close locales - - // Restore JVM default locale - Locale.setDefault(jvmDefault); } /** -- cgit v1.2.3 From fb903bda4e82149e7f8ca2958664c481e3fb75fe Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Mon, 13 Apr 2009 00:55:40 +0000 Subject: Workaround for #2835 - Force Google App Engine to re-serialize after each request. svn changeset:7391/svn branch:6.0 --- src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/com/itmill/toolkit') diff --git a/src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java b/src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java index 6fd6bfaa8c..17b6c66c45 100644 --- a/src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java +++ b/src/com/itmill/toolkit/terminal/gwt/server/ApplicationServlet.java @@ -578,6 +578,11 @@ public class ApplicationServlet extends HttpServlet { ((WebApplicationContext) application.getContext()) .endTransaction(application, request); } + + // Work-around for GAE session problem. Explicitly touch session so + // it is re-serialized. + request.getSession().setAttribute("sessionUpdated", + new Date().getTime()); } } -- cgit v1.2.3 From 331c7c6fc2ce8e085409f74528a6daf5af0e7c4b Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Tue, 14 Apr 2009 13:41:43 +0000 Subject: Merged fix for #2837 - Added SPACEBAR key code to ShortcutAction.KeyCode svn changeset:7403/svn branch:6.0 --- src/com/itmill/toolkit/event/ShortcutAction.java | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/com/itmill/toolkit') diff --git a/src/com/itmill/toolkit/event/ShortcutAction.java b/src/com/itmill/toolkit/event/ShortcutAction.java index 665add30b3..6090889ada 100644 --- a/src/com/itmill/toolkit/event/ShortcutAction.java +++ b/src/com/itmill/toolkit/event/ShortcutAction.java @@ -170,6 +170,8 @@ public class ShortcutAction extends Action { public static final int NUM8 = 56; public static final int NUM9 = 57; + + public static final int SPACEBAR = 32; } /** -- cgit v1.2.3 From 15824cc384cd04bb73cf15f834fa89fa7cf8aff0 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Tue, 14 Apr 2009 13:56:03 +0000 Subject: Merged test case for #2846 svn changeset:7405/svn branch:6.0 --- .../components/tabsheet/TabSheetCaptions.java | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/com/itmill/toolkit/tests/components/tabsheet/TabSheetCaptions.java (limited to 'src/com/itmill/toolkit') diff --git a/src/com/itmill/toolkit/tests/components/tabsheet/TabSheetCaptions.java b/src/com/itmill/toolkit/tests/components/tabsheet/TabSheetCaptions.java new file mode 100644 index 0000000000..be9cfaafbb --- /dev/null +++ b/src/com/itmill/toolkit/tests/components/tabsheet/TabSheetCaptions.java @@ -0,0 +1,44 @@ +package com.itmill.toolkit.tests.components.tabsheet; + +import com.itmill.toolkit.tests.components.TestBase; +import com.itmill.toolkit.ui.Button; +import com.itmill.toolkit.ui.Label; +import com.itmill.toolkit.ui.Panel; +import com.itmill.toolkit.ui.TabSheet; +import com.itmill.toolkit.ui.Button.ClickEvent; + +public class TabSheetCaptions extends TestBase { + + Panel panel1; + + @Override + protected String getDescription() { + return "Updating the tabsheet tab text should not change the caption of the component. Click on the button to change the tab text. This must update the tab and not touch the Panel's caption."; + } + + @Override + protected Integer getTicketNumber() { + return 2846; + } + + @Override + protected void setup() { + final TabSheet tabSheet = new TabSheet(); + + panel1 = new Panel("tab 1"); + panel1.setSizeFull(); + panel1.getLayout().setSizeFull(); + panel1.addComponent(new Label("This is first panel")); + tabSheet.addTab(panel1); + + Button button = new Button("Update tab caption"); + button.addListener(new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + tabSheet.setTabCaption(panel1, "This is a new caption"); + } + }); + + addComponent(tabSheet); + addComponent(button); + } +} -- cgit v1.2.3 From 64eba008b21555646dbbbac6a311e7fd099d873d Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Tue, 14 Apr 2009 14:38:18 +0000 Subject: Merged fix for #2813 - The DateField with RESOLUTION_YEAR or RESOLUTION_MONTH behaves oddly svn changeset:7409/svn branch:6.0 --- src/com/itmill/toolkit/terminal/gwt/client/ui/ICalendarPanel.java | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/com/itmill/toolkit') diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ICalendarPanel.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ICalendarPanel.java index 6f386e231a..62514c49d9 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ICalendarPanel.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ICalendarPanel.java @@ -318,6 +318,9 @@ public class ICalendarPanel extends FlexTable implements MouseListener { datefield.getClient().updateVariable(datefield.getId(), "year", datefield.getCurrentDate().getYear() + 1900, datefield.isImmediate()); + + /* Must update the value in the textfield also */ + updateCalendar(); } } } -- cgit v1.2.3 From 88286ad1ea4a02b37ddceea1c291945d40f43ea8 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Tue, 14 Apr 2009 14:40:42 +0000 Subject: Merged test case for #2813 svn changeset:7411/svn branch:6.0 --- .../components/datefield/TestDatefieldYear.java | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/com/itmill/toolkit/tests/components/datefield/TestDatefieldYear.java (limited to 'src/com/itmill/toolkit') diff --git a/src/com/itmill/toolkit/tests/components/datefield/TestDatefieldYear.java b/src/com/itmill/toolkit/tests/components/datefield/TestDatefieldYear.java new file mode 100644 index 0000000000..5be49c1b0c --- /dev/null +++ b/src/com/itmill/toolkit/tests/components/datefield/TestDatefieldYear.java @@ -0,0 +1,28 @@ +package com.itmill.toolkit.tests.components.datefield; + +import java.util.Date; + +import com.itmill.toolkit.tests.components.TestBase; +import com.itmill.toolkit.ui.DateField; + +public class TestDatefieldYear extends TestBase { + + @Override + protected String getDescription() { + return "A popup with resolution year or month should update the textfield when browsing. The value displayed in the textfield should always be the same as the popup shows."; + } + + @Override + protected Integer getTicketNumber() { + return 2813; + } + + @Override + protected void setup() { + DateField df = new DateField("Year", new Date(2009 - 1900, 4 - 1, 1)); + df.setResolution(DateField.RESOLUTION_YEAR); + df.setResolution(DateField.RESOLUTION_MONTH); + addComponent(df); + + } +} -- cgit v1.2.3 From 77248b49ed126c385d0c56c5bc28ea9b92ae1395 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Tue, 14 Apr 2009 14:58:14 +0000 Subject: Fix for #2848 - Sampler descriptions are not visible when running in GAE svn changeset:7412/svn branch:6.0 --- src/com/itmill/toolkit/demo/sampler/Feature.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/com/itmill/toolkit') diff --git a/src/com/itmill/toolkit/demo/sampler/Feature.java b/src/com/itmill/toolkit/demo/sampler/Feature.java index 10cc7e747d..54f5805916 100644 --- a/src/com/itmill/toolkit/demo/sampler/Feature.java +++ b/src/com/itmill/toolkit/demo/sampler/Feature.java @@ -186,4 +186,18 @@ abstract public class Feature implements Serializable { return getName(); } + @Override + public boolean equals(Object obj) { + // A feature is uniquely identified by its class name + if (obj == null) { + return false; + } + return obj.getClass() == getClass(); + } + + @Override + public int hashCode() { + // A feature is uniquely identified by its class name + return getClass().hashCode(); + } } \ No newline at end of file -- cgit v1.2.3 From 7a46af6a48c27c19093b518106cced1e8751702f Mon Sep 17 00:00:00 2001 From: Matti Tahvonen Date: Wed, 15 Apr 2009 10:56:56 +0000 Subject: fixes #2850 react only on login handler requests, now supports reloading svn changeset:7415/svn branch:6.0 --- src/com/itmill/toolkit/ui/LoginForm.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'src/com/itmill/toolkit') diff --git a/src/com/itmill/toolkit/ui/LoginForm.java b/src/com/itmill/toolkit/ui/LoginForm.java index 06b9de2a7d..eef64d598e 100644 --- a/src/com/itmill/toolkit/ui/LoginForm.java +++ b/src/com/itmill/toolkit/ui/LoginForm.java @@ -92,14 +92,18 @@ public class LoginForm extends CustomComponent { + ""; public DownloadStream handleURI(URL context, String relativeUri) { - if (window != null) { - window.removeURIHandler(this); + if (relativeUri != null && relativeUri.contains("loginHandler")) { + if (window != null) { + window.removeURIHandler(this); + } + DownloadStream downloadStream = new DownloadStream( + new ByteArrayInputStream(responce.getBytes()), + "text/html", "loginSuccesfull"); + downloadStream.setCacheTime(-1); + return downloadStream; + } else { + return null; } - DownloadStream downloadStream = new DownloadStream( - new ByteArrayInputStream(responce.getBytes()), "text/html", - "loginSuccesfull"); - downloadStream.setCacheTime(-1); - return downloadStream; } }; -- cgit v1.2.3 From e586ebe1d19e2168fd5ab8888376c9a95f317b47 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Thu, 16 Apr 2009 06:01:59 +0000 Subject: Merged fix for #2847 - Problem running on Oracle OAS10g svn changeset:7430/svn branch:6.0 --- .../terminal/gwt/server/CommunicationManager.java | 45 ++++++++++++++++------ 1 file changed, 34 insertions(+), 11 deletions(-) (limited to 'src/com/itmill/toolkit') diff --git a/src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java b/src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java index cd4fcae766..cfedb42dc4 100644 --- a/src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java +++ b/src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java @@ -612,17 +612,7 @@ public class CommunicationManager implements Paintable.RepaintRequestListener, boolean success = true; if (request.getContentLength() > 0) { - - byte[] buffer = new byte[request.getContentLength()]; - ServletInputStream inputStream = request.getInputStream(); - int totalBytesRead = 0; - int bytesRead; - while ((bytesRead = inputStream.read(buffer, totalBytesRead, - MAX_BUFFER_SIZE)) != -1) { - totalBytesRead += bytesRead; - } - - String changes = new String(buffer, "utf-8"); + String changes = readRequest(request); // Manage bursts one by one final String[] bursts = changes.split(VAR_BURST_SEPARATOR); @@ -780,6 +770,39 @@ public class CommunicationManager implements Paintable.RepaintRequestListener, return success; } + /** + * Reads the request data from the HttpServletRequest and returns it + * converted to an UTF-8 string. + * + * @param request + * @return + * @throws IOException + */ + private static String readRequest(HttpServletRequest request) + throws IOException { + + int requestLength = request.getContentLength(); + + byte[] buffer = new byte[requestLength]; + ServletInputStream inputStream = request.getInputStream(); + + int bytesRemaining = requestLength; + while (bytesRemaining >= 0) { + int bytesToRead = Math.min(bytesRemaining, MAX_BUFFER_SIZE); + int bytesRead = inputStream.read(buffer, requestLength + - bytesRemaining, bytesToRead); + if (bytesRead == -1) { + break; + } + + bytesRemaining -= bytesRead; + } + + String result = new String(buffer, "utf-8"); + + return result; + } + public class ErrorHandlerErrorEvent implements ErrorEvent, Serializable { private final Throwable throwable; -- cgit v1.2.3 From e49842867c11d2ed6e89605d0b905b5e9a5fd47a Mon Sep 17 00:00:00 2001 From: Matti Tahvonen Date: Thu, 16 Apr 2009 08:07:38 +0000 Subject: symmetric api for position information svn changeset:7434/svn branch:6.0 --- src/com/itmill/toolkit/ui/AbsoluteLayout.java | 176 +++++++++++++++++++++++--- 1 file changed, 156 insertions(+), 20 deletions(-) (limited to 'src/com/itmill/toolkit') diff --git a/src/com/itmill/toolkit/ui/AbsoluteLayout.java b/src/com/itmill/toolkit/ui/AbsoluteLayout.java index f3b65e2111..fd5e72aff6 100644 --- a/src/com/itmill/toolkit/ui/AbsoluteLayout.java +++ b/src/com/itmill/toolkit/ui/AbsoluteLayout.java @@ -77,10 +77,10 @@ public class AbsoluteLayout extends AbstractLayout { public class ComponentPosition implements Serializable { private int zIndex = -1; - private float top = -1; - private float right = -1; - private float bottom = -1; - private float left = -1; + private float topValue = -1; + private float rightValue = -1; + private float bottomValue = -1; + private float leftValue = -1; private int topUnits; private int rightUnits; @@ -120,16 +120,16 @@ public class AbsoluteLayout extends AbstractLayout { float v = Float.parseFloat(value); int unitInt = parseCssUnit(unit); if (key.equals("top")) { - top = v; + topValue = v; topUnits = unitInt; } else if (key.equals("right")) { - right = v; + rightValue = v; rightUnits = unitInt; } else if (key.equals("bottom")) { - bottom = v; + bottomValue = v; bottomUnits = unitInt; } else if (key.equals("left")) { - left = v; + leftValue = v; leftUnits = unitInt; } } @@ -148,17 +148,17 @@ public class AbsoluteLayout extends AbstractLayout { public String getCSSString() { String s = ""; - if (top >= 0) { - s += "top:" + top + UNIT_SYMBOLS[topUnits] + ";"; + if (topValue >= 0) { + s += "top:" + topValue + UNIT_SYMBOLS[topUnits] + ";"; } - if (right >= 0) { - s += "right:" + right + UNIT_SYMBOLS[rightUnits] + ";"; + if (rightValue >= 0) { + s += "right:" + rightValue + UNIT_SYMBOLS[rightUnits] + ";"; } - if (bottom >= 0) { - s += "bottom:" + bottom + UNIT_SYMBOLS[bottomUnits] + ";"; + if (bottomValue >= 0) { + s += "bottom:" + bottomValue + UNIT_SYMBOLS[bottomUnits] + ";"; } - if (left >= 0) { - s += "left:" + left + UNIT_SYMBOLS[leftUnits] + ";"; + if (leftValue >= 0) { + s += "left:" + leftValue + UNIT_SYMBOLS[leftUnits] + ";"; } if (zIndex >= 0) { s += "z-index:" + zIndex + ";"; @@ -168,28 +168,28 @@ public class AbsoluteLayout extends AbstractLayout { public void setTop(float topValue, int topUnits) { validateLength(topValue, topUnits); - top = topValue; + this.topValue = topValue; this.topUnits = topUnits; requestRepaint(); } public void setRight(float rightValue, int rightUnits) { validateLength(rightValue, rightUnits); - right = rightValue; + this.rightValue = rightValue; this.rightUnits = rightUnits; requestRepaint(); } public void setBottom(float bottomValue, int units) { validateLength(bottomValue, units); - bottom = bottomValue; + this.bottomValue = bottomValue; bottomUnits = units; requestRepaint(); } public void setLeft(float leftValue, int units) { validateLength(leftValue, units); - left = leftValue; + this.leftValue = leftValue; leftUnits = units; requestRepaint(); } @@ -199,6 +199,142 @@ public class AbsoluteLayout extends AbstractLayout { requestRepaint(); } + public void setTopValue(float topValue) { + validateLength(topValue, topUnits); + this.topValue = topValue; + requestRepaint(); + } + + public float getTopValue() { + return topValue; + } + + /** + * @return the rightValue + */ + public float getRightValue() { + return rightValue; + } + + /** + * @param rightValue + * the rightValue to set + */ + public void setRightValue(float rightValue) { + validateLength(rightValue, rightUnits); + this.rightValue = rightValue; + requestRepaint(); + } + + /** + * @return the bottomValue + */ + public float getBottomValue() { + return bottomValue; + } + + /** + * @param bottomValue + * the bottomValue to set + */ + public void setBottomValue(float bottomValue) { + validateLength(bottomValue, bottomUnits); + this.bottomValue = bottomValue; + requestRepaint(); + } + + /** + * @return the leftValue + */ + public float getLeftValue() { + return leftValue; + } + + /** + * @param leftValue + * the leftValue to set + */ + public void setLeftValue(float leftValue) { + validateLength(leftValue, leftUnits); + this.leftValue = leftValue; + requestRepaint(); + } + + /** + * @return the topUnits + */ + public int getTopUnits() { + return topUnits; + } + + /** + * @param topUnits + * the topUnits to set + */ + public void setTopUnits(int topUnits) { + validateLength(topValue, topUnits); + this.topUnits = topUnits; + requestRepaint(); + } + + /** + * @return the rightUnits + */ + public int getRightUnits() { + return rightUnits; + } + + /** + * @param rightUnits + * the rightUnits to set + */ + public void setRightUnits(int rightUnits) { + validateLength(rightValue, rightUnits); + this.rightUnits = rightUnits; + requestRepaint(); + } + + /** + * @return the bottomUnits + */ + public int getBottomUnits() { + return bottomUnits; + } + + /** + * @param bottomUnits + * the bottomUnits to set + */ + public void setBottomUnits(int bottomUnits) { + validateLength(bottomValue, bottomUnits); + this.bottomUnits = bottomUnits; + requestRepaint(); + } + + /** + * @return the leftUnits + */ + public int getLeftUnits() { + return leftUnits; + } + + /** + * @param leftUnits + * the leftUnits to set + */ + public void setLeftUnits(int leftUnits) { + validateLength(leftValue, leftUnits); + this.leftUnits = leftUnits; + requestRepaint(); + } + + /** + * @return the zIndex + */ + public int getZIndex() { + return zIndex; + } + } @Override -- cgit v1.2.3 From c3f59a1a057f692c761004f9bfa5f5f53658481d Mon Sep 17 00:00:00 2001 From: Matti Tahvonen Date: Thu, 16 Apr 2009 08:08:37 +0000 Subject: minor changes to open client side for extension svn changeset:7435/svn branch:6.0 --- src/com/itmill/toolkit/terminal/gwt/client/ui/IAbsoluteLayout.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/com/itmill/toolkit') diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IAbsoluteLayout.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IAbsoluteLayout.java index fc1f14cb83..2b2def0e7f 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IAbsoluteLayout.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IAbsoluteLayout.java @@ -32,7 +32,7 @@ public class IAbsoluteLayout extends ComplexPanel implements Container { private DivElement marginElement; - private Element canvas; + protected final Element canvas = DOM.createDiv(); private int excessPixelsHorizontal; @@ -42,7 +42,7 @@ public class IAbsoluteLayout extends ComplexPanel implements Container { private Map pidToComponentWrappper = new HashMap(); - private ApplicationConnection client; + protected ApplicationConnection client; private boolean rendering; @@ -50,7 +50,6 @@ public class IAbsoluteLayout extends ComplexPanel implements Container { setElement(Document.get().createDivElement()); setStyleName(CLASSNAME); marginElement = Document.get().createDivElement(); - canvas = DOM.createDiv(); canvas.getStyle().setProperty("position", "relative"); marginElement.appendChild(canvas); getElement().appendChild(marginElement); -- cgit v1.2.3 From 7271aabb80c0e65caf7271f7c25856b220cfde5d Mon Sep 17 00:00:00 2001 From: Matti Tahvonen Date: Thu, 16 Apr 2009 12:12:54 +0000 Subject: absolutelayout now updates relative component sizes properly on size changes svn changeset:7438/svn branch:6.0 --- .../terminal/gwt/client/ui/IAbsoluteLayout.java | 32 ++++++++++++++++++---- 1 file changed, 27 insertions(+), 5 deletions(-) (limited to 'src/com/itmill/toolkit') diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IAbsoluteLayout.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IAbsoluteLayout.java index 2b2def0e7f..8b10854959 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IAbsoluteLayout.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IAbsoluteLayout.java @@ -179,8 +179,20 @@ public class IAbsoluteLayout extends ComplexPanel implements Container { // inside marginals) canvas.getStyle().setProperty("width", width); - if (!rendering && BrowserInfo.get().isIE6()) { - relayoutWrappersForIe6(); + if (!rendering) { + if (BrowserInfo.get().isIE6()) { + relayoutWrappersForIe6(); + } + relayoutRelativeChildren(); + } + } + + private void relayoutRelativeChildren() { + for (Widget widget : getChildren()) { + if (widget instanceof Paintable) { + Paintable new_name = (Paintable) widget; + client.handleComponentRelativeSize(widget); + } } } @@ -191,8 +203,11 @@ public class IAbsoluteLayout extends ComplexPanel implements Container { // inside marginals) canvas.getStyle().setProperty("height", height); - if (!rendering && BrowserInfo.get().isIE6()) { - relayoutWrappersForIe6(); + if (!rendering) { + if (BrowserInfo.get().isIE6()) { + relayoutWrappersForIe6(); + } + relayoutRelativeChildren(); } } @@ -227,7 +242,14 @@ public class IAbsoluteLayout extends ComplexPanel implements Container { if (getWidget() != paintable) { setWidget((Widget) paintable); } - paintable.updateFromUIDL(componentUIDL.getChildUIDL(0), client); + UIDL childUIDL = componentUIDL.getChildUIDL(0); + paintable.updateFromUIDL(childUIDL, client); + if (childUIDL.hasAttribute("cached")) { + // child may need relative size adjustment if wrapper details + // have changed this could be optimized (check if wrapper size + // has changed) + client.handleComponentRelativeSize((Widget) paintable); + } } public void setPosition(String stringAttribute) { -- cgit v1.2.3 From cc8293321a7932a6ab7c8ed99c33cd53b892abc9 Mon Sep 17 00:00:00 2001 From: Matti Tahvonen Date: Thu, 16 Apr 2009 12:15:01 +0000 Subject: Paintable from client side can now be transmitted to server as a variable (will map to corresponding server side component) svn changeset:7439/svn branch:6.0 --- .../itmill/toolkit/terminal/gwt/client/ApplicationConnection.java | 6 ++++++ .../itmill/toolkit/terminal/gwt/server/CommunicationManager.java | 3 +++ 2 files changed, 9 insertions(+) (limited to 'src/com/itmill/toolkit') diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java b/src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java index f3541b5bb3..cb6874075c 100755 --- a/src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java @@ -898,6 +898,12 @@ public class ApplicationConnection { makeUidlRequest(req.toString(), false, forceSync, false); } + public void updateVariable(String paintableId, String variableName, + Paintable newValue, boolean immediate) { + String pid = (newValue != null) ? getPid(newValue) : null; + addVariableToQueue(paintableId, variableName, pid, immediate, 'p'); + } + public void updateVariable(String paintableId, String variableName, String newValue, boolean immediate) { addVariableToQueue(paintableId, variableName, newValue, immediate, 's'); diff --git a/src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java b/src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java index cfedb42dc4..0b92701363 100644 --- a/src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java +++ b/src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java @@ -867,6 +867,9 @@ public class CommunicationManager implements Paintable.RepaintRequestListener, case 'b': val = Boolean.valueOf(strValue); break; + case 'p': + val = idPaintableMap.get(strValue); + break; } return val; -- cgit v1.2.3 From e52771cdcd996630057f17372b41c8957a5bfc70 Mon Sep 17 00:00:00 2001 From: Henri Sara Date: Fri, 17 Apr 2009 08:27:47 +0000 Subject: BeanItemContainer javadoc merge to 6.0. svn changeset:7452/svn branch:6.0 --- .../toolkit/data/util/BeanItemContainer.java | 61 ++++++++++++++++++---- 1 file changed, 50 insertions(+), 11 deletions(-) (limited to 'src/com/itmill/toolkit') diff --git a/src/com/itmill/toolkit/data/util/BeanItemContainer.java b/src/com/itmill/toolkit/data/util/BeanItemContainer.java index b2eb55d2cc..d4da324feb 100644 --- a/src/com/itmill/toolkit/data/util/BeanItemContainer.java +++ b/src/com/itmill/toolkit/data/util/BeanItemContainer.java @@ -60,8 +60,13 @@ public class BeanItemContainer implements Indexed, Sortable, Filterable, model = BeanItem.getPropertyDescriptors(type); } - public BeanItemContainer(Class type) throws InstantiationException, - IllegalAccessException { + /** + * Constructs BeanItemContainer for beans of a given type. + * + * @param type + * the class of beans to be used with this containers. + */ + public BeanItemContainer(Class type) { this.type = type; model = BeanItem.getPropertyDescriptors(type); } @@ -71,11 +76,8 @@ public class BeanItemContainer implements Indexed, Sortable, Filterable, * * @param list * non empty {@link Collection} of beans. - * @throws IllegalAccessException - * @throws InstantiationException */ - public BeanItemContainer(Collection list) - throws InstantiationException, IllegalAccessException { + public BeanItemContainer(Collection list) { type = (Class) list.iterator().next().getClass(); model = BeanItem.getPropertyDescriptors(type); int i = 0; @@ -84,10 +86,22 @@ public class BeanItemContainer implements Indexed, Sortable, Filterable, } } + /** + * Unsupported operation. + * + * @see com.itmill.toolkit.data.Container.Indexed#addItemAt(int) + */ public Object addItemAt(int index) throws UnsupportedOperationException { throw new UnsupportedOperationException(); } + /** + * Adds new item at given index. + * + * The bean is used both as the item contents and as the item identifier. + * + * @see com.itmill.toolkit.data.Container.Indexed#addItemAt(int, Object) + */ public Item addItemAt(int index, Object newItemId) throws UnsupportedOperationException { if (index < 0 || index > size()) { @@ -139,7 +153,7 @@ public class BeanItemContainer implements Indexed, Sortable, Filterable, } } - public Object getIdByIndex(int index) { + public BT getIdByIndex(int index) { return list.get(index); } @@ -147,11 +161,24 @@ public class BeanItemContainer implements Indexed, Sortable, Filterable, return list.indexOf(itemId); } + /** + * Unsupported operation. + * + * @see com.itmill.toolkit.data.Container.Ordered#addItemAfter(Object) + */ public Object addItemAfter(Object previousItemId) throws UnsupportedOperationException { throw new UnsupportedOperationException(); } + /** + * Adds new item after the given item. + * + * The bean is used both as the item contents and as the item identifier. + * + * @see com.itmill.toolkit.data.Container.Ordered#addItemAfter(Object, + * Object) + */ public Item addItemAfter(Object previousItemId, Object newItemId) throws UnsupportedOperationException { // only add if the previous item is visible @@ -163,7 +190,7 @@ public class BeanItemContainer implements Indexed, Sortable, Filterable, } } - public Object firstItemId() { + public BT firstItemId() { if (list.size() > 0) { return list.get(0); } else { @@ -179,7 +206,7 @@ public class BeanItemContainer implements Indexed, Sortable, Filterable, return lastItemId() == itemId; } - public Object lastItemId() { + public BT lastItemId() { if (list.size() > 0) { return list.get(list.size() - 1); } else { @@ -187,7 +214,7 @@ public class BeanItemContainer implements Indexed, Sortable, Filterable, } } - public Object nextItemId(Object itemId) { + public BT nextItemId(Object itemId) { int index = list.indexOf(itemId); if (index >= 0 && index < list.size() - 1) { return list.get(index + 1); @@ -197,7 +224,7 @@ public class BeanItemContainer implements Indexed, Sortable, Filterable, } } - public Object prevItemId(Object itemId) { + public BT prevItemId(Object itemId) { int index = list.indexOf(itemId); if (index > 0) { return list.get(index - 1); @@ -213,10 +240,22 @@ public class BeanItemContainer implements Indexed, Sortable, Filterable, throw new UnsupportedOperationException(); } + /** + * Unsupported operation. + * + * @see com.itmill.toolkit.data.Container#addItem() + */ public Object addItem() throws UnsupportedOperationException { throw new UnsupportedOperationException(); } + /** + * Creates a new Item with the bean into the Container. + * + * The bean is used both as the item contents and as the item identifier. + * + * @see com.itmill.toolkit.data.Container#addItem(Object) + */ public Item addItem(Object itemId) throws UnsupportedOperationException { if (list.size() > 0) { // add immediately after last visible item -- cgit v1.2.3 From 43e9f8f1181d8e00926eb959cc54995f6f9c94da Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Fri, 17 Apr 2009 10:09:08 +0000 Subject: Merged additional fix for #2847 - Problem running on Oracle OAS10g. Fixed typo svn changeset:7455/svn branch:6.0 --- src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/com/itmill/toolkit') diff --git a/src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java b/src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java index 0b92701363..033284259d 100644 --- a/src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java +++ b/src/com/itmill/toolkit/terminal/gwt/server/CommunicationManager.java @@ -787,7 +787,7 @@ public class CommunicationManager implements Paintable.RepaintRequestListener, ServletInputStream inputStream = request.getInputStream(); int bytesRemaining = requestLength; - while (bytesRemaining >= 0) { + while (bytesRemaining > 0) { int bytesToRead = Math.min(bytesRemaining, MAX_BUFFER_SIZE); int bytesRead = inputStream.read(buffer, requestLength - bytesRemaining, bytesToRead); -- cgit v1.2.3 From 38ebfd1a0edb1cc8f16c9138cc714b8671a544a9 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Fri, 17 Apr 2009 11:08:52 +0000 Subject: Additional fix for #695 - Serialization support: Fixed NPE in MethodProperty svn changeset:7457/svn branch:6.0 --- .../itmill/toolkit/data/util/MethodProperty.java | 30 +++++++++++++++++----- 1 file changed, 24 insertions(+), 6 deletions(-) (limited to 'src/com/itmill/toolkit') diff --git a/src/com/itmill/toolkit/data/util/MethodProperty.java b/src/com/itmill/toolkit/data/util/MethodProperty.java index 9d74175b2c..e8f220be79 100644 --- a/src/com/itmill/toolkit/data/util/MethodProperty.java +++ b/src/com/itmill/toolkit/data/util/MethodProperty.java @@ -98,10 +98,20 @@ public class MethodProperty implements Property, Property.ValueChangeNotifier, out.writeObject(instance); out.writeObject(setArgs); out.writeObject(getArgs); - out.writeObject(setMethod.getName()); - out.writeObject(setMethod.getParameterTypes()); - out.writeObject(getMethod.getName()); - out.writeObject(getMethod.getParameterTypes()); + if (setMethod != null) { + out.writeObject(setMethod.getName()); + out.writeObject(setMethod.getParameterTypes()); + } else { + out.writeObject(""); + out.writeObject(""); + } + if (getMethod != null) { + out.writeObject(getMethod.getName()); + out.writeObject(getMethod.getParameterTypes()); + } else { + out.writeObject(""); + out.writeObject(""); + } }; /* Special serialization to handle method references */ @@ -114,10 +124,18 @@ public class MethodProperty implements Property, Property.ValueChangeNotifier, getArgs = (Object[]) in.readObject(); String name = (String) in.readObject(); Class[] paramTypes = (Class[]) in.readObject(); - setMethod = instance.getClass().getMethod(name, paramTypes); + if (name != null && !name.equals("")) { + setMethod = instance.getClass().getMethod(name, paramTypes); + } else { + setMethod = null; + } name = (String) in.readObject(); paramTypes = (Class[]) in.readObject(); - getMethod = instance.getClass().getMethod(name, paramTypes); + if (name != null && !name.equals("")) { + getMethod = instance.getClass().getMethod(name, paramTypes); + } else { + getMethod = null; + } } catch (SecurityException e) { System.err.println("Internal deserialization error"); e.printStackTrace(); -- cgit v1.2.3 From 2bd4106c653cf87e63532977d43c787288cf4918 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Fri, 17 Apr 2009 15:02:33 +0000 Subject: Removed serialVersionUIDs, added serial warning suppression svn changeset:7461/svn branch:6.0 --- src/com/itmill/toolkit/automatedtests/ComponentsInTable.java | 4 +--- .../itmill/toolkit/automatedtests/SimplestApplication.java | 2 +- .../automatedtests/featurebrowser/AccordionExample.java | 2 +- .../toolkit/automatedtests/featurebrowser/ButtonExample.java | 3 +-- .../automatedtests/featurebrowser/ClientCachingExample.java | 3 +-- .../automatedtests/featurebrowser/ComboBoxExample.java | 3 +-- .../automatedtests/featurebrowser/EmbeddedBrowserExample.java | 3 +-- .../toolkit/automatedtests/featurebrowser/FeatureBrowser.java | 5 +---- .../toolkit/automatedtests/featurebrowser/FormExample.java | 10 +--------- .../automatedtests/featurebrowser/GeneratedColumnExample.java | 3 +-- src/com/itmill/toolkit/automatedtests/util/StatusServlet.java | 3 +-- src/com/itmill/toolkit/data/Validator.java | 11 ++--------- src/com/itmill/toolkit/demo/sampler/ActiveLink.java | 3 +-- src/com/itmill/toolkit/demo/sampler/ModeSwitch.java | 2 +- .../toolkit/demo/sampler/features/form/FormPojoExample.java | 8 ++++++-- .../toolkit/terminal/gwt/client/LocaleNotLoadedException.java | 6 +----- src/com/itmill/toolkit/tests/tickets/Ticket695.java | 3 +-- src/com/itmill/toolkit/ui/Upload.java | 11 ----------- 18 files changed, 23 insertions(+), 62 deletions(-) (limited to 'src/com/itmill/toolkit') diff --git a/src/com/itmill/toolkit/automatedtests/ComponentsInTable.java b/src/com/itmill/toolkit/automatedtests/ComponentsInTable.java index 48a71213e7..4ac547bb0e 100644 --- a/src/com/itmill/toolkit/automatedtests/ComponentsInTable.java +++ b/src/com/itmill/toolkit/automatedtests/ComponentsInTable.java @@ -14,10 +14,9 @@ import com.itmill.toolkit.ui.OrderedLayout; import com.itmill.toolkit.ui.Table; import com.itmill.toolkit.ui.Button.ClickEvent; +@SuppressWarnings("serial") public class ComponentsInTable extends CustomComponent { - private static final long serialVersionUID = 7179313717613510935L; - public ComponentsInTable(int cols, int rows) { final OrderedLayout main = new OrderedLayout(); setCompositionRoot(main); @@ -42,7 +41,6 @@ public class ComponentsInTable extends CustomComponent { content.add(new Button("b" + i, new Button.ClickListener() { public void buttonClick(ClickEvent event) { - Button b = event.getButton(); System.out.println(event.getButton().getCaption() + " click: " + (new Date()).toGMTString()); System.out.println(event.getButton().getApplication()); diff --git a/src/com/itmill/toolkit/automatedtests/SimplestApplication.java b/src/com/itmill/toolkit/automatedtests/SimplestApplication.java index b21c1cd7b8..fef17670c1 100644 --- a/src/com/itmill/toolkit/automatedtests/SimplestApplication.java +++ b/src/com/itmill/toolkit/automatedtests/SimplestApplication.java @@ -7,8 +7,8 @@ package com.itmill.toolkit.automatedtests; import com.itmill.toolkit.ui.Label; import com.itmill.toolkit.ui.Window; +@SuppressWarnings("serial") public class SimplestApplication extends com.itmill.toolkit.Application { - private static final long serialVersionUID = 1401107566407830534L; @Override public void init() { diff --git a/src/com/itmill/toolkit/automatedtests/featurebrowser/AccordionExample.java b/src/com/itmill/toolkit/automatedtests/featurebrowser/AccordionExample.java index e7609d9713..4d35a85bb5 100644 --- a/src/com/itmill/toolkit/automatedtests/featurebrowser/AccordionExample.java +++ b/src/com/itmill/toolkit/automatedtests/featurebrowser/AccordionExample.java @@ -10,8 +10,8 @@ import com.itmill.toolkit.ui.VerticalLayout; * Accordion is a derivative of TabSheet, a vertical tabbed layout that places * the tab contents between the vertical tabs. */ +@SuppressWarnings("serial") public class AccordionExample extends CustomComponent { - private static final long serialVersionUID = 7172404542359409349L; public AccordionExample() { // Create a new accordion diff --git a/src/com/itmill/toolkit/automatedtests/featurebrowser/ButtonExample.java b/src/com/itmill/toolkit/automatedtests/featurebrowser/ButtonExample.java index ba7296fd13..f9c3b18fea 100644 --- a/src/com/itmill/toolkit/automatedtests/featurebrowser/ButtonExample.java +++ b/src/com/itmill/toolkit/automatedtests/featurebrowser/ButtonExample.java @@ -21,11 +21,10 @@ import com.itmill.toolkit.ui.Button.ClickEvent; * * @author IT Mill Ltd. */ +@SuppressWarnings("serial") public class ButtonExample extends CustomComponent implements Button.ClickListener { - private static final long serialVersionUID = -3934416497726624080L; - public ButtonExample() { final VerticalLayout main = new VerticalLayout(); diff --git a/src/com/itmill/toolkit/automatedtests/featurebrowser/ClientCachingExample.java b/src/com/itmill/toolkit/automatedtests/featurebrowser/ClientCachingExample.java index b43770d45f..af4b6e8827 100644 --- a/src/com/itmill/toolkit/automatedtests/featurebrowser/ClientCachingExample.java +++ b/src/com/itmill/toolkit/automatedtests/featurebrowser/ClientCachingExample.java @@ -21,9 +21,9 @@ import com.itmill.toolkit.ui.VerticalLayout; * * @author IT Mill Ltd. */ +@SuppressWarnings("serial") public class ClientCachingExample extends CustomComponent { - private static final long serialVersionUID = -1033520074262036031L; private static final String msg = "This example is a (simple) demonstration of client-side caching." + " The content in one tab is intentionally made very slow to" + " 'produce' server-side. When you changes to this tab for the" @@ -53,7 +53,6 @@ public class ClientCachingExample extends CustomComponent { layout = new VerticalLayout(); layout.setMargin(true); l = new Label("Slow label - until cached client side.") { - private static final long serialVersionUID = -2741194381200799815L; @Override public void paintContent(PaintTarget target) throws PaintException { diff --git a/src/com/itmill/toolkit/automatedtests/featurebrowser/ComboBoxExample.java b/src/com/itmill/toolkit/automatedtests/featurebrowser/ComboBoxExample.java index 312c7b27d2..130b9187b6 100644 --- a/src/com/itmill/toolkit/automatedtests/featurebrowser/ComboBoxExample.java +++ b/src/com/itmill/toolkit/automatedtests/featurebrowser/ComboBoxExample.java @@ -14,10 +14,9 @@ import com.itmill.toolkit.ui.AbstractSelect.Filtering; /** * */ +@SuppressWarnings("serial") public class ComboBoxExample extends CustomComponent { - private static final long serialVersionUID = 1580175413996261572L; - private static final String[] firstnames = new String[] { "John", "Mary", "Joe", "Sarah", "Jeff", "Jane", "Peter", "Marc", "Robert", "Paula", "Lenny", "Kenny", "Nathan", "Nicole", "Laura", "Jos", "Josie", diff --git a/src/com/itmill/toolkit/automatedtests/featurebrowser/EmbeddedBrowserExample.java b/src/com/itmill/toolkit/automatedtests/featurebrowser/EmbeddedBrowserExample.java index cd60dbd2bd..d5d54fa798 100644 --- a/src/com/itmill/toolkit/automatedtests/featurebrowser/EmbeddedBrowserExample.java +++ b/src/com/itmill/toolkit/automatedtests/featurebrowser/EmbeddedBrowserExample.java @@ -21,11 +21,10 @@ import com.itmill.toolkit.ui.Window.Notification; * @author IT Mill Ltd. * @see com.itmill.toolkit.ui.Window */ +@SuppressWarnings("serial") public class EmbeddedBrowserExample extends VerticalLayout implements Select.ValueChangeListener { - private static final long serialVersionUID = -6209869808788169597L; - // Default URL to open. private static final String DEFAULT_URL = "http://www.itmill.com/index_itmill_toolkit.htm"; diff --git a/src/com/itmill/toolkit/automatedtests/featurebrowser/FeatureBrowser.java b/src/com/itmill/toolkit/automatedtests/featurebrowser/FeatureBrowser.java index 2c22926e2f..5e235aea6e 100644 --- a/src/com/itmill/toolkit/automatedtests/featurebrowser/FeatureBrowser.java +++ b/src/com/itmill/toolkit/automatedtests/featurebrowser/FeatureBrowser.java @@ -36,10 +36,10 @@ import com.itmill.toolkit.ui.Button.ClickEvent; * @author IT Mill Ltd. * @see com.itmill.toolkit.ui.Window */ +@SuppressWarnings("serial") public class FeatureBrowser extends com.itmill.toolkit.Application implements Select.ValueChangeListener { - private static final long serialVersionUID = -4653905515159295197L; // Property IDs private static final Object PROPERTY_ID_CATEGORY = "Category"; @@ -209,7 +209,6 @@ public class FeatureBrowser extends com.itmill.toolkit.Application implements final HorizontalLayout wbLayout = new HorizontalLayout(); Button b = new Button("Open in sub-window", new Button.ClickListener() { - private static final long serialVersionUID = -9168589977880405848L; public void buttonClick(ClickEvent event) { Component component = (Component) ts.getComponentIterator() @@ -236,8 +235,6 @@ public class FeatureBrowser extends com.itmill.toolkit.Application implements wbLayout.addComponent(b); b = new Button("Open in native window", new Button.ClickListener() { - private static final long serialVersionUID = 3847765713639897223L; - public void buttonClick(ClickEvent event) { Component component = (Component) ts.getComponentIterator() .next(); diff --git a/src/com/itmill/toolkit/automatedtests/featurebrowser/FormExample.java b/src/com/itmill/toolkit/automatedtests/featurebrowser/FormExample.java index 290a2ca1bf..58e606b654 100644 --- a/src/com/itmill/toolkit/automatedtests/featurebrowser/FormExample.java +++ b/src/com/itmill/toolkit/automatedtests/featurebrowser/FormExample.java @@ -25,9 +25,9 @@ import com.itmill.toolkit.ui.Button.ClickEvent; * more complex than real use, as it tries to demonstrate more features than * needed in general case. */ +@SuppressWarnings("serial") public class FormExample extends CustomComponent { - private static final long serialVersionUID = -5382205369084031674L; static final String cities[] = { "Amsterdam", "Berlin", "Helsinki", "Hong Kong", "London", "Luxemburg", "New York", "Oslo", "Paris", "Rome", "Stockholm", "Tokyo", "Turku" }; @@ -39,7 +39,6 @@ public class FormExample extends CustomComponent { final Address dataModel = new Address(); Button peekDataModelState = new Button("Show the data model state", new Button.ClickListener() { - private static final long serialVersionUID = -9128707564903086213L; public void buttonClick(ClickEvent event) { getWindow().showNotification( @@ -66,8 +65,6 @@ public class FormExample extends CustomComponent { public static class AddressForm extends Form { - private static final long serialVersionUID = -1356475197391501301L; - public AddressForm(String caption) { setCaption(caption); @@ -124,8 +121,6 @@ public class FormExample extends CustomComponent { static class MyFieldFactory extends BaseFieldFactory implements Serializable { - private static final long serialVersionUID = 4993348078809959988L; - @Override public Field createField(Item item, Object propertyId, Component uiContext) { @@ -148,8 +143,6 @@ public class FormExample extends CustomComponent { */ static class PostalCodeValidator implements Validator { - private static final long serialVersionUID = -7635596091609806427L; - public boolean isValid(Object value) { if (value == null || !(value instanceof String)) { return false; @@ -173,7 +166,6 @@ public class FormExample extends CustomComponent { */ public static class Address implements Serializable { - private static final long serialVersionUID = 6238878890199428556L; String name = ""; String streetAddress = ""; String postalCode = ""; diff --git a/src/com/itmill/toolkit/automatedtests/featurebrowser/GeneratedColumnExample.java b/src/com/itmill/toolkit/automatedtests/featurebrowser/GeneratedColumnExample.java index 4872a670fb..5b9e4d86eb 100644 --- a/src/com/itmill/toolkit/automatedtests/featurebrowser/GeneratedColumnExample.java +++ b/src/com/itmill/toolkit/automatedtests/featurebrowser/GeneratedColumnExample.java @@ -36,6 +36,7 @@ import com.itmill.toolkit.ui.Button.ClickListener; * * @author magi */ +@SuppressWarnings("serial") public class GeneratedColumnExample extends CustomComponent { /** @@ -368,8 +369,6 @@ public class GeneratedColumnExample extends CustomComponent { /** Table column generator for calculating consumption column. */ class ConsumptionColumnGenerator implements Table.ColumnGenerator { - private static final long serialVersionUID = -1077081052659001251L; - /** * Generates a cell containing value calculated from the item. */ diff --git a/src/com/itmill/toolkit/automatedtests/util/StatusServlet.java b/src/com/itmill/toolkit/automatedtests/util/StatusServlet.java index 9912b23d1b..caf44abc89 100644 --- a/src/com/itmill/toolkit/automatedtests/util/StatusServlet.java +++ b/src/com/itmill/toolkit/automatedtests/util/StatusServlet.java @@ -15,10 +15,9 @@ import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +@SuppressWarnings("serial") public class StatusServlet extends HttpServlet { - private static final long serialVersionUID = -6764317622536660947L; - public static DateFormat dfHuman = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss"); diff --git a/src/com/itmill/toolkit/data/Validator.java b/src/com/itmill/toolkit/data/Validator.java index 15fea5de34..55626fb040 100644 --- a/src/com/itmill/toolkit/data/Validator.java +++ b/src/com/itmill/toolkit/data/Validator.java @@ -59,14 +59,10 @@ public interface Validator extends Serializable { * @VERSION@ * @since 3.0 */ + @SuppressWarnings("serial") public class InvalidValueException extends RuntimeException implements ErrorMessage { - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3689073941163422257L; - /** Array of validation errors that are causing the problem. */ private InvalidValueException[] causes = null; @@ -173,11 +169,8 @@ public interface Validator extends Serializable { } + @SuppressWarnings("serial") public class EmptyValueException extends Validator.InvalidValueException { - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = -4488988853486652602L; public EmptyValueException(String message) { super(message); diff --git a/src/com/itmill/toolkit/demo/sampler/ActiveLink.java b/src/com/itmill/toolkit/demo/sampler/ActiveLink.java index 51cb8afe6c..252a7b12e0 100644 --- a/src/com/itmill/toolkit/demo/sampler/ActiveLink.java +++ b/src/com/itmill/toolkit/demo/sampler/ActiveLink.java @@ -13,6 +13,7 @@ import com.itmill.toolkit.ui.Link; import com.itmill.toolkit.ui.Button.ClickEvent; import com.itmill.toolkit.ui.Button.ClickListener; +@SuppressWarnings("serial") public class ActiveLink extends Link { private static final String TAG = "activelink"; @@ -111,8 +112,6 @@ public class ActiveLink extends Link { public class LinkActivatedEvent extends Component.Event { - private static final long serialVersionUID = -6406243194818230362L; - private boolean linkOpened; /** diff --git a/src/com/itmill/toolkit/demo/sampler/ModeSwitch.java b/src/com/itmill/toolkit/demo/sampler/ModeSwitch.java index d662d421c9..fb6b1d791e 100644 --- a/src/com/itmill/toolkit/demo/sampler/ModeSwitch.java +++ b/src/com/itmill/toolkit/demo/sampler/ModeSwitch.java @@ -9,6 +9,7 @@ import com.itmill.toolkit.ui.CustomComponent; import com.itmill.toolkit.ui.GridLayout; import com.itmill.toolkit.ui.Button.ClickEvent; +@SuppressWarnings("serial") public class ModeSwitch extends CustomComponent { GridLayout layout = new GridLayout(3, 1); @@ -92,7 +93,6 @@ public class ModeSwitch extends CustomComponent { } public class ModeSwitchEvent extends Event { - private static final long serialVersionUID = -576318750089478453L; public ModeSwitchEvent() { super(ModeSwitch.this); diff --git a/src/com/itmill/toolkit/demo/sampler/features/form/FormPojoExample.java b/src/com/itmill/toolkit/demo/sampler/features/form/FormPojoExample.java index a4e3e0f731..22ed844fd4 100644 --- a/src/com/itmill/toolkit/demo/sampler/features/form/FormPojoExample.java +++ b/src/com/itmill/toolkit/demo/sampler/features/form/FormPojoExample.java @@ -1,5 +1,6 @@ package com.itmill.toolkit.demo.sampler.features.form; +import java.io.Serializable; import java.util.Arrays; import java.util.Date; import java.util.UUID; @@ -21,6 +22,7 @@ import com.itmill.toolkit.ui.VerticalLayout; import com.itmill.toolkit.ui.Window; import com.itmill.toolkit.ui.Button.ClickEvent; +@SuppressWarnings("serial") public class FormPojoExample extends VerticalLayout { // the 'POJO' we're editing @@ -101,7 +103,8 @@ public class FormPojoExample extends VerticalLayout { public PersonFieldFactory() { countries.setWidth("30em"); - countries.setContainerDataSource(ExampleUtil.getStaticISO3166Container()); + countries.setContainerDataSource(ExampleUtil + .getStaticISO3166Container()); countries .setItemCaptionPropertyId(ExampleUtil.iso3166_PROPERTY_NAME); countries.setItemIconPropertyId(ExampleUtil.iso3166_PROPERTY_FLAG); @@ -152,7 +155,8 @@ public class FormPojoExample extends VerticalLayout { } } - public class Person { + public class Person implements Serializable { + private String firstName = ""; private String lastName = ""; private Date birthdate; diff --git a/src/com/itmill/toolkit/terminal/gwt/client/LocaleNotLoadedException.java b/src/com/itmill/toolkit/terminal/gwt/client/LocaleNotLoadedException.java index 39c38bdd49..25a7058f5d 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/LocaleNotLoadedException.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/LocaleNotLoadedException.java @@ -4,13 +4,9 @@ package com.itmill.toolkit.terminal.gwt.client; +@SuppressWarnings("serial") public class LocaleNotLoadedException extends Exception { - /** - * Serial generated by Eclipse. - */ - private static final long serialVersionUID = 2005227056545210838L; - public LocaleNotLoadedException(String locale) { super(locale); } diff --git a/src/com/itmill/toolkit/tests/tickets/Ticket695.java b/src/com/itmill/toolkit/tests/tickets/Ticket695.java index 8e45c4ca5c..c37ee50c51 100644 --- a/src/com/itmill/toolkit/tests/tickets/Ticket695.java +++ b/src/com/itmill/toolkit/tests/tickets/Ticket695.java @@ -9,10 +9,9 @@ import com.itmill.toolkit.ui.Button; import com.itmill.toolkit.ui.Window; import com.itmill.toolkit.ui.Button.ClickEvent; +@SuppressWarnings("serial") public class Ticket695 extends Application { - private static final long serialVersionUID = 3803150085397590662L; - @Override public void init() { final Window w = new Window("Serialization test #695"); diff --git a/src/com/itmill/toolkit/ui/Upload.java b/src/com/itmill/toolkit/ui/Upload.java index e053d99fab..2b4620f322 100644 --- a/src/com/itmill/toolkit/ui/Upload.java +++ b/src/com/itmill/toolkit/ui/Upload.java @@ -293,8 +293,6 @@ public class Upload extends AbstractComponent implements Component.Focusable { */ public class FinishedEvent extends Component.Event { - private static final long serialVersionUID = 3257288015385670969L; - /** * Length of the received file. */ @@ -378,8 +376,6 @@ public class Upload extends AbstractComponent implements Component.Focusable { */ public class FailedEvent extends FinishedEvent { - private static final long serialVersionUID = 3833746590157386293L; - private Exception reason = null; /** @@ -425,8 +421,6 @@ public class Upload extends AbstractComponent implements Component.Focusable { */ public class NoOutputStreamEvent extends FailedEvent { - private static final long serialVersionUID = 4745219890852396500L; - /** * * @param source @@ -445,8 +439,6 @@ public class Upload extends AbstractComponent implements Component.Focusable { */ public class NoInputStreamEvent extends FailedEvent { - private static final long serialVersionUID = -529960205445737170L; - /** * * @param source @@ -471,8 +463,6 @@ public class Upload extends AbstractComponent implements Component.Focusable { */ public class SucceededEvent extends FinishedEvent { - private static final long serialVersionUID = 3256445798169524023L; - /** * * @param source @@ -497,7 +487,6 @@ public class Upload extends AbstractComponent implements Component.Focusable { */ public class StartedEvent extends Component.Event { - private static final long serialVersionUID = -3984393770487403525L; private final String filename; private final String type; -- cgit v1.2.3 From c2a6543cbf31109a73166908cef09cc607d2a403 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Mon, 20 Apr 2009 05:52:38 +0000 Subject: Merged all 5.4 build script and testing tools related changes to 6.0 svn changeset:7462/svn branch:6.0 --- build/bin/mergetool.py | 11 ++-- build/build.xml | 60 +++++++++++++++++----- build/package/start.sh | 2 +- .../toolkit/launcher/ITMillToolkitDesktopMode.java | 10 ++-- 4 files changed, 55 insertions(+), 28 deletions(-) (limited to 'src/com/itmill/toolkit') diff --git a/build/bin/mergetool.py b/build/bin/mergetool.py index 91d9d5105c..7ed1cb1579 100755 --- a/build/bin/mergetool.py +++ b/build/bin/mergetool.py @@ -79,12 +79,10 @@ def listChangedFiles(): changed = [] for line in lines: # Remove trailing newline - line = line.rstrip() - print line - + line = line[:-1] + # Extract the file state and name - filestate = line[0:2].strip() - filename = line[7:].strip() + (filestate, filename) = re.split(r'[ \+]+', line) # Ignore files in build directory if (filename.startswith("build/merge/") \ @@ -543,8 +541,7 @@ def commandRevert(): line = line[:-1] # Extract the file state and name - filestate = line[0:2].strip() - filename = line[7:].strip() + (filestate, filename) = re.split(r'[ \+]+', line) # Ignore files in build directory if (filename.startswith("build/merge/") \ diff --git a/build/build.xml b/build/build.xml index e5cadfd72e..ec50f34df7 100644 --- a/build/build.xml +++ b/build/build.xml @@ -186,9 +186,6 @@ Toolkit package is: ${toolkit-package} - - - @@ -975,6 +972,18 @@ + + + + + + + XEP license expected to be installed as ${xep.license.path.installed} + + + + + @@ -986,13 +995,15 @@ + - - + + + - + @@ -1009,7 +1020,7 @@ - + @@ -1120,7 +1131,7 @@ Installing ${output-dir}/WebContent/${lib-jar-name} to ${nightly.publish} Hopefully you have permissions for the copy operation with SSH. - + @@ -1137,16 +1148,37 @@ - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + ##teamcity[testSuiteStarted name='com.itmill.toolkit.tests.test-framework'] diff --git a/build/package/start.sh b/build/package/start.sh index 448d318415..febda97e4c 100644 --- a/build/package/start.sh +++ b/build/package/start.sh @@ -4,4 +4,4 @@ if [ "$1" != "" ] ; then cd $1 fi -java -cp WebContent/demo/lib/jetty/jetty-6.1.7.jar:WebContent/demo/lib/jetty/jetty-util-6.1.7.jar:WebContent/demo/lib/jetty/servlet-api-2.5-6.1.7.jar:WebContent/WEB-INF/classes:WebContent/WEB-INF/src com.itmill.toolkit.launcher.ITMillToolkitDesktopMode +java -cp WebContent/demo/lib/jetty/jetty-6.1.7.jar:WebContent/demo/lib/jetty/jetty-util-6.1.7.jar:WebContent/demo/lib/jetty/servlet-api-2.5-6.1.7.jar:WebContent/WEB-INF/classes:WebContent/WEB-INF/src com.itmill.toolkit.launcher.ITMillToolkitDesktopMode $ITMILLTOOLKIT_PARAMETERS diff --git a/src/com/itmill/toolkit/launcher/ITMillToolkitDesktopMode.java b/src/com/itmill/toolkit/launcher/ITMillToolkitDesktopMode.java index 72aecc4464..e16fea21cb 100644 --- a/src/com/itmill/toolkit/launcher/ITMillToolkitDesktopMode.java +++ b/src/com/itmill/toolkit/launcher/ITMillToolkitDesktopMode.java @@ -63,14 +63,12 @@ public class ITMillToolkitDesktopMode { final String url = ITMillToolkitWebMode.runServer(serverArgs, "Desktop Mode"); - // Open browser into application URL - if (url != null) { + if (!serverArgs.containsKey("nogui") && url != null) { + + // Open browser into application URL BrowserLauncher.openBrowser(url); - } - - // Open control dialog - if (url != null) { + // Open control dialog /* * Swing components should never be manipulated outside the event * dispatch thread. -- cgit v1.2.3 From 01a17f302922bbdcd7ee83eca7670bd11685d5c8 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Tue, 21 Apr 2009 05:53:51 +0000 Subject: Merged ComponentLocator javadocs. svn changeset:7466/svn branch:6.0 --- .../terminal/gwt/client/ComponentLocator.java | 45 +++++++++++++++++++++- 1 file changed, 43 insertions(+), 2 deletions(-) (limited to 'src/com/itmill/toolkit') diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ComponentLocator.java b/src/com/itmill/toolkit/terminal/gwt/client/ComponentLocator.java index b0078868dc..c4f44c9440 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ComponentLocator.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ComponentLocator.java @@ -10,12 +10,21 @@ import com.itmill.toolkit.terminal.gwt.client.ui.IView; import com.itmill.toolkit.terminal.gwt.client.ui.SubPartAware; /** - * Helper class for TestingTools that builds appropriate locators for browser - * bot. + * ComponentLocator provides methods for uniquely identifying DOM elements using + * string expressions. This class is EXPERIMENTAL and subject to change. */ public class ComponentLocator { + /** + * Separator used in the string expression between a parent and a child + * widget. + */ private static final String PARENTCHILD_SEPARATOR = "/"; + + /** + * Separator used in the string expression between a widget and the widget's + * sub part. NOT CURRENTLY IN USE. + */ private static final String SUBPART_SEPARATOR = "#"; private ApplicationConnection client; @@ -24,6 +33,19 @@ public class ComponentLocator { this.client = client; } + /** + * EXPERIMENTAL. + * + * Generates a string expression (path) which uniquely identifies the target + * element . The getElementByPath method can be used for the inverse + * operation, i.e. locating an element based on the string expression. + * + * @since 5.4 + * @param targetElement + * The element to generate a path for. + * @return A string expression uniquely identifying the target element or + * null if a string expression could not be created. + */ public String getPathForElement(Element targetElement) { String pid = null; @@ -130,6 +152,21 @@ public class ComponentLocator { return path; } + /** + * EXPERIMENTAL. + * + * Locates an element by using a string expression (path) which uniquely + * identifies the element. The getPathForElement method can be used for the + * inverse operation, i.e. generating a string expression for a target + * element. + * + * @since 5.4 + * @param path + * The string expression which uniquely identifies the target + * element. + * @return The DOM element identified by the path or null if the element + * could not be located. + */ public Element getElementByPath(String path) { // ApplicationConnection.getConsole() // .log("getElementByPath(" + path + ")"); @@ -169,6 +206,10 @@ public class ComponentLocator { } private String getPathForWidget(Widget w) { + if (w == null) { + return ""; + } + String pid = client.getPid(w.getElement()); if (isStaticPid(pid)) { return pid; -- cgit v1.2.3 From 4a385e9b2e224466eda615c4aa3fbc322b86682f Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Tue, 21 Apr 2009 07:33:33 +0000 Subject: Merged: Fixed #2857 - Added checks for constructor arguments. Added a simple test case for BeanItemContainer. Changed BeanItemContainer to always return BeanItems instead of generic Items. svn changeset:7468/svn branch:6.0 --- .../toolkit/data/util/BeanItemContainer.java | 44 ++++++++----- .../TestBeanItemContainerUsage.java | 75 ++++++++++++++++++++++ 2 files changed, 103 insertions(+), 16 deletions(-) create mode 100644 src/com/itmill/toolkit/tests/components/beanitemcontainer/TestBeanItemContainerUsage.java (limited to 'src/com/itmill/toolkit') diff --git a/src/com/itmill/toolkit/data/util/BeanItemContainer.java b/src/com/itmill/toolkit/data/util/BeanItemContainer.java index d4da324feb..aeb1e83c2d 100644 --- a/src/com/itmill/toolkit/data/util/BeanItemContainer.java +++ b/src/com/itmill/toolkit/data/util/BeanItemContainer.java @@ -16,7 +16,6 @@ import java.util.Map; import java.util.Set; import com.itmill.toolkit.data.Container; -import com.itmill.toolkit.data.Item; import com.itmill.toolkit.data.Property; import com.itmill.toolkit.data.Container.Filterable; import com.itmill.toolkit.data.Container.Indexed; @@ -65,23 +64,38 @@ public class BeanItemContainer implements Indexed, Sortable, Filterable, * * @param type * the class of beans to be used with this containers. + * @throws IllegalArgumentException + * If the type is null */ public BeanItemContainer(Class type) { + if (type == null) { + throw new IllegalArgumentException( + "The type passed to BeanItemContainer must not be null"); + } this.type = type; model = BeanItem.getPropertyDescriptors(type); } /** - * Constructs BeanItemContainer with given collection of beans in it. + * Constructs BeanItemContainer with given collection of beans in it. The + * collection must not be empty or an IllegalArgument is thrown. * - * @param list + * @param collection * non empty {@link Collection} of beans. + * @throws IllegalArgumentException + * If the collection is null or empty. */ - public BeanItemContainer(Collection list) { - type = (Class) list.iterator().next().getClass(); + public BeanItemContainer(Collection collection) + throws IllegalArgumentException { + if (collection == null || collection.isEmpty()) { + throw new IllegalArgumentException( + "The collection passed to BeanItemContainer must not be null or empty"); + } + + type = (Class) collection.iterator().next().getClass(); model = BeanItem.getPropertyDescriptors(type); int i = 0; - for (BT bt : list) { + for (BT bt : collection) { addItemAt(i++, bt); } } @@ -102,7 +116,7 @@ public class BeanItemContainer implements Indexed, Sortable, Filterable, * * @see com.itmill.toolkit.data.Container.Indexed#addItemAt(int, Object) */ - public Item addItemAt(int index, Object newItemId) + public BeanItem addItemAt(int index, Object newItemId) throws UnsupportedOperationException { if (index < 0 || index > size()) { return null; @@ -128,7 +142,7 @@ public class BeanItemContainer implements Indexed, Sortable, Filterable, * Id of the new item to be added. * @return Returns new item or null if the operation fails. */ - private Item addItemAtInternalIndex(int index, Object newItemId) { + private BeanItem addItemAtInternalIndex(int index, Object newItemId) { // Make sure that the Item has not been created yet if (allItems.contains(newItemId)) { return null; @@ -179,7 +193,7 @@ public class BeanItemContainer implements Indexed, Sortable, Filterable, * @see com.itmill.toolkit.data.Container.Ordered#addItemAfter(Object, * Object) */ - public Item addItemAfter(Object previousItemId, Object newItemId) + public BeanItem addItemAfter(Object previousItemId, Object newItemId) throws UnsupportedOperationException { // only add if the previous item is visible if (list.contains(previousItemId)) { @@ -256,7 +270,7 @@ public class BeanItemContainer implements Indexed, Sortable, Filterable, * * @see com.itmill.toolkit.data.Container#addItem(Object) */ - public Item addItem(Object itemId) throws UnsupportedOperationException { + public BeanItem addItem(Object itemId) throws UnsupportedOperationException { if (list.size() > 0) { // add immediately after last visible item int lastIndex = allItems.indexOf(lastItemId()); @@ -275,18 +289,16 @@ public class BeanItemContainer implements Indexed, Sortable, Filterable, return beanToItem.get(itemId).getItemProperty(propertyId); } - @SuppressWarnings("unchecked") - public Collection getContainerPropertyIds() { + public Collection getContainerPropertyIds() { return model.keySet(); } - public Item getItem(Object itemId) { + public BeanItem getItem(Object itemId) { return beanToItem.get(itemId); } - @SuppressWarnings("unchecked") - public Collection getItemIds() { - return (Collection) list.clone(); + public Collection getItemIds() { + return (Collection) list.clone(); } public Class getType(Object propertyId) { diff --git a/src/com/itmill/toolkit/tests/components/beanitemcontainer/TestBeanItemContainerUsage.java b/src/com/itmill/toolkit/tests/components/beanitemcontainer/TestBeanItemContainerUsage.java new file mode 100644 index 0000000000..b01197c759 --- /dev/null +++ b/src/com/itmill/toolkit/tests/components/beanitemcontainer/TestBeanItemContainerUsage.java @@ -0,0 +1,75 @@ +package com.itmill.toolkit.tests.components.beanitemcontainer; + +import java.util.ArrayList; +import java.util.List; + +import com.itmill.toolkit.data.util.BeanItemContainer; +import com.itmill.toolkit.tests.components.TestBase; +import com.itmill.toolkit.ui.Table; + +public class TestBeanItemContainerUsage extends TestBase { + + @Override + protected String getDescription() { + return "A test for the BeanItemContainer. The table should contain three persons and show their first and last names and their age."; + } + + @Override + protected Integer getTicketNumber() { + return 1061; + } + + @Override + protected void setup() { + Table t = new Table("Table containing Persons"); + t.setPageLength(5); + t.setWidth("100%"); + List persons = new ArrayList(); + persons.add(new Person("Jones", "Birchman", 35)); + persons.add(new Person("Marc", "Smith", 30)); + persons.add(new Person("Greg", "Sandman", 75)); + + BeanItemContainer bic = new BeanItemContainer(persons); + t.setContainerDataSource(bic); + + addComponent(t); + } + + public static class Person { + private String firstName; + private String lastName; + private int age; + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age = age; + } + + public Person(String firstName, String lastName, int age) { + super(); + this.firstName = firstName; + this.lastName = lastName; + this.age = age; + } + + } +} -- cgit v1.2.3 From 0ddfb6aaff25b019b68fd7828ec012c063b275ab Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Tue, 21 Apr 2009 08:27:50 +0000 Subject: Merged: Fix for #2679 - expand country column svn changeset:7470/svn branch:6.0 --- .../toolkit/demo/sampler/features/table/TableMainFeaturesExample.java | 1 + 1 file changed, 1 insertion(+) (limited to 'src/com/itmill/toolkit') diff --git a/src/com/itmill/toolkit/demo/sampler/features/table/TableMainFeaturesExample.java b/src/com/itmill/toolkit/demo/sampler/features/table/TableMainFeaturesExample.java index a7cbad0dc1..860467fbba 100644 --- a/src/com/itmill/toolkit/demo/sampler/features/table/TableMainFeaturesExample.java +++ b/src/com/itmill/toolkit/demo/sampler/features/table/TableMainFeaturesExample.java @@ -69,6 +69,7 @@ public class TableMainFeaturesExample extends VerticalLayout { Table.ALIGN_CENTER); // Column width + table.setColumnExpandRatio(ExampleUtil.iso3166_PROPERTY_NAME, 1); table.setColumnWidth(ExampleUtil.iso3166_PROPERTY_SHORT, 70); // Collapse one column - the user can make it visible again -- cgit v1.2.3 From ffeb0373d9bf1259974b7b2ac849ef173398060d Mon Sep 17 00:00:00 2001 From: Matti Tahvonen Date: Tue, 21 Apr 2009 12:30:42 +0000 Subject: fixes #2859 svn changeset:7473/svn branch:6.0 --- .../terminal/gwt/client/ui/IScrollTable.java | 79 ++++++++++++++-------- 1 file changed, 52 insertions(+), 27 deletions(-) (limited to 'src/com/itmill/toolkit') 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 f7a925ad00..892c330b68 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IScrollTable.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IScrollTable.java @@ -21,7 +21,6 @@ import com.google.gwt.user.client.Event; import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.ui.FlowPanel; -import com.google.gwt.user.client.ui.HasWidgets; import com.google.gwt.user.client.ui.Panel; import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.user.client.ui.ScrollListener; @@ -91,10 +90,15 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { private int selectMode = Table.SELECT_MODE_NONE; - private final HashSet selectedRowKeys = new HashSet(); + private final HashSet selectedRowKeys = new HashSet(); private boolean initializedAndAttached = false; + /** + * Flag to indicate if a column width recalculation is needed due update. + */ + private boolean headerChangedDuringUpdate = false; + private final TableHead tHead = new TableHead(); private final ScrollPanel bodyContainer = new ScrollPanel(); @@ -114,7 +118,7 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { * This map contains captions and icon urls for actions like: * "33_c" -> * "Edit" * "33_i" -> "http://dom.com/edit.png" */ - private final HashMap actionMap = new HashMap(); + private final HashMap actionMap = new HashMap(); private String[] visibleColOrder; private boolean initialContentReceived = false; private Element scrollPositionElement; @@ -137,7 +141,7 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { int scrollbarWidthReserved = -1; boolean relativeWidth = false; - private final ArrayList lazyUnregistryBag = new ArrayList(); + private final ArrayList lazyUnregistryBag = new ArrayList(); private String height; private String width = ""; private boolean rendering = false; @@ -154,6 +158,7 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { } + @SuppressWarnings("unchecked") public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { rendering = true; if (client.updateComponent(this, uidl, true)) { @@ -211,11 +216,11 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { } if (uidl.hasVariable("selected")) { - final Set selectedKeys = uidl + final Set selectedKeys = uidl .getStringArrayVariableAsSet("selected"); selectedRowKeys.clear(); - for (final Iterator it = selectedKeys.iterator(); it.hasNext();) { - selectedRowKeys.add(it.next()); + for (String string : selectedKeys) { + selectedRowKeys.add(string); } } @@ -260,6 +265,9 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { if (!recalcWidths && initializedAndAttached) { updateBody(rowData, uidl.getIntAttribute("firstrow"), uidl .getIntAttribute("rows")); + if (headerChangedDuringUpdate) { + lazyAdjustColumnWidths.schedule(1); + } } else { if (tBody != null) { tBody.removeFromParent(); @@ -278,6 +286,7 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { hideScrollPositionAnnotation(); purgeUnregistryBag(); rendering = false; + headerChangedDuringUpdate = false; } /** @@ -286,15 +295,15 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { * "subtreecaching" logic. */ private void purgeUnregistryBag() { - for (Iterator iterator = lazyUnregistryBag.iterator(); iterator + for (Iterator iterator = lazyUnregistryBag.iterator(); iterator .hasNext();) { - client.unregisterChildPaintables((HasWidgets) iterator.next()); + client.unregisterChildPaintables(iterator.next()); } lazyUnregistryBag.clear(); } private void updateActionMap(UIDL c) { - final Iterator it = c.getChildIterator(); + final Iterator it = c.getChildIterator(); while (it.hasNext()) { final UIDL action = (UIDL) it.next(); final String key = action.getStringAttribute("key"); @@ -310,11 +319,11 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { } public String getActionCaption(String actionKey) { - return (String) actionMap.get(actionKey + "_c"); + return actionMap.get(actionKey + "_c"); } public String getActionIcon(String actionKey) { - return (String) actionMap.get(actionKey + "_i"); + return actionMap.get(actionKey + "_i"); } private void updateHeader(String[] strings) { @@ -432,7 +441,7 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { } private IScrollTableRow getRenderedRowByKey(String key) { - final Iterator it = tBody.iterator(); + final Iterator it = tBody.iterator(); IScrollTableRow r = null; while (it.hasNext()) { r = (IScrollTableRow) it.next(); @@ -1351,6 +1360,22 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { if (isDefinedWidth()) { return width; } else { + if (naturalWidth == 0) { + // This is recently revealed column. Try to detect a proper + // value (greater of header and data + // cols) + final int hw = getOffsetWidth(); + int i = 0; + for (Iterator it = tHead.iterator(); it.hasNext(); i++) { + if (it.next() == this) { + break; + } + } + final int cw = tBody.getColWidth(i); + naturalWidth = (hw > cw ? hw : cw) + + IScrollTableBody.CELL_EXTRA_WIDTH; + + } return naturalWidth; } } @@ -1437,7 +1462,7 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { } public void updateCellsFromUIDL(UIDL uidl) { - Iterator it = uidl.getChildIterator(); + Iterator it = uidl.getChildIterator(); HashSet updated = new HashSet(); updated.add("0"); while (it.hasNext()) { @@ -1495,14 +1520,8 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { final HeaderCell c = getHeaderCell(cid); if (!c.isEnabled() || getHeaderCell(index) != c) { setHeaderCell(index, c); - if (c.getWidth() == -1) { - if (initializedAndAttached) { - // column is not drawn before, - // we will need a column width recalculation - initializedAndAttached = false; - initialContentReceived = false; - isNewBody = true; - } + if (initializedAndAttached) { + headerChangedDuringUpdate = true; } } } @@ -1668,6 +1687,7 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { } else { tHead.removeCell(colKey); collapsedColumns.add(colKey); + lazyAdjustColumnWidths.schedule(1); } // update variable to server @@ -1717,7 +1737,7 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { for (i = 0; i < visibleColOrder.length; i++) { cols[i] = visibleColOrder[i]; } - for (final Iterator it = collapsedColumns.iterator(); it + for (final Iterator it = collapsedColumns.iterator(); it .hasNext();) { cols[i++] = it.next(); } @@ -1782,7 +1802,7 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { private int rowHeight = -1; - private final List renderedRows = new Vector(); + private final List renderedRows = new Vector(); private boolean initDone = false; @@ -1970,7 +1990,7 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { renderedRows.add(row); } - public Iterator iterator() { + public Iterator iterator() { return renderedRows.iterator(); } @@ -2605,6 +2625,7 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { if (hCell.isDefinedWidth()) { totalExplicitColumnsWidths += hCell.getWidth(); } else { + totalExplicitColumnsWidths += hCell.getNaturalColumnWidth(); expandRatioDivider += hCell.getExpandRatio(); } } @@ -2636,8 +2657,12 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { newSpace = (int) (w + extraSpace * hCell.getExpandRatio() / expandRatioDivider); } else { - // divide relatively to natural column widths - newSpace = w + extraSpace * w / totalWidthR; + if (totalWidthR != 0) { + // divide relatively to natural column widths + newSpace = w + extraSpace * w / totalWidthR; + } else { + newSpace = w; + } } setColWidth(i, newSpace, false); } -- cgit v1.2.3 From 2846a4291aefd7d2cabad99b07cb7ba91bb771a8 Mon Sep 17 00:00:00 2001 From: Matti Tahvonen Date: Wed, 22 Apr 2009 08:43:58 +0000 Subject: generics for string array set svn changeset:7484/svn branch:6.0 --- src/com/itmill/toolkit/terminal/gwt/client/UIDL.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/com/itmill/toolkit') diff --git a/src/com/itmill/toolkit/terminal/gwt/client/UIDL.java b/src/com/itmill/toolkit/terminal/gwt/client/UIDL.java index fb9c989afd..0b75a98c3b 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/UIDL.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/UIDL.java @@ -417,9 +417,9 @@ public class UIDL { return s; } - public Set getStringArrayVariableAsSet(String name) { + public Set getStringArrayVariableAsSet(String name) { final JSONArray a = getArrayVariable(name); - final HashSet s = new HashSet(); + final HashSet s = new HashSet(); for (int i = 0; i < a.size(); i++) { s.add(((JSONString) a.get(i)).stringValue()); } -- cgit v1.2.3 From 7d2f57c19d553082aef5975c58ad304c15f321e8 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Thu, 23 Apr 2009 06:30:32 +0000 Subject: Merged: Added addBean(BT bean) convenience method to BeanItemContainer svn changeset:7497/svn branch:6.0 --- src/com/itmill/toolkit/data/util/BeanItemContainer.java | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/com/itmill/toolkit') diff --git a/src/com/itmill/toolkit/data/util/BeanItemContainer.java b/src/com/itmill/toolkit/data/util/BeanItemContainer.java index aeb1e83c2d..99e42e7e76 100644 --- a/src/com/itmill/toolkit/data/util/BeanItemContainer.java +++ b/src/com/itmill/toolkit/data/util/BeanItemContainer.java @@ -263,6 +263,17 @@ public class BeanItemContainer implements Indexed, Sortable, Filterable, throw new UnsupportedOperationException(); } + /** + * Creates a new Item with the bean into the Container. + * + * The bean is used both as the item contents and as the item identifier. + * + * @see com.itmill.toolkit.data.Container#addItem(Object) + */ + public BeanItem addBean(BT bean) { + return addItem(bean); + } + /** * Creates a new Item with the bean into the Container. * -- cgit v1.2.3 From 9ee170551c15c5f5ea1af658c7ea29c1a9b7b5d8 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Thu, 23 Apr 2009 06:32:07 +0000 Subject: Test case for #2862 svn changeset:7498/svn branch:6.0 --- .../components/table/ContainerSizeChange.java | 91 ++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 src/com/itmill/toolkit/tests/components/table/ContainerSizeChange.java (limited to 'src/com/itmill/toolkit') diff --git a/src/com/itmill/toolkit/tests/components/table/ContainerSizeChange.java b/src/com/itmill/toolkit/tests/components/table/ContainerSizeChange.java new file mode 100644 index 0000000000..b7356fca5b --- /dev/null +++ b/src/com/itmill/toolkit/tests/components/table/ContainerSizeChange.java @@ -0,0 +1,91 @@ +package com.itmill.toolkit.tests.components.table; + +import com.itmill.toolkit.data.Item; +import com.itmill.toolkit.data.util.IndexedContainer; +import com.itmill.toolkit.tests.components.TestBase; +import com.itmill.toolkit.ui.Button; +import com.itmill.toolkit.ui.Table; +import com.itmill.toolkit.ui.Button.ClickEvent; + +public class ContainerSizeChange extends TestBase { + + private Table table; + private MyDataSource ds; + + @Override + protected String getDescription() { + return "A table should be able to handle a decrease in the size of the container. The original container here contains 50 items and the decrease button removes 10 of these. To reproduce the problem: Click 'Decrease size' two times to reduce size to 30 and scroll to the end (50). What should happen is the table should notice the container size has decreased and show the last items which now exists in the new container."; + } + + @Override + protected Integer getTicketNumber() { + return 2862; + } + + @Override + protected void setup() { + table = new Table("A table"); + ds = new MyDataSource(); + table.setContainerDataSource(ds); + table.setPageLength(5); + addComponent(table); + + Button b = new Button("Decrease size", new Button.ClickListener() { + + public void buttonClick(ClickEvent event) { + ds.decreaseSize(); + } + + }); + + addComponent(b); + + b = new Button("Increase size", new Button.ClickListener() { + + public void buttonClick(ClickEvent event) { + ds.increaseSize(); + } + + }); + + addComponent(b); + + } + +} + +class MyDataSource extends IndexedContainer { + + private int size = 0; + + public MyDataSource() { + addContainerProperty("a", String.class, ""); + addContainerProperty("b", String.class, ""); + addContainerProperty("c", String.class, ""); + + for (int i = 0; i < 100; i++) { + Item item = addItem(String.valueOf(i)); + item.getItemProperty("a").setValue("a " + i); + item.getItemProperty("b").setValue("b " + i); + item.getItemProperty("c").setValue("c " + i); + } + size = 50; + } + + public void increaseSize() { + size += 10; + + } + + public void decreaseSize() { + if (size > 10) { + size -= 10; + } + + } + + @Override + public int size() { + return size; + } +} -- cgit v1.2.3 From f9e25051db127dafda9d37c4f39ae318cc095526 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Thu, 23 Apr 2009 06:43:20 +0000 Subject: Test case for #2853 svn changeset:7499/svn branch:6.0 --- .../tests/components/embedded/EmbeddedTooltip.java | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/com/itmill/toolkit/tests/components/embedded/EmbeddedTooltip.java (limited to 'src/com/itmill/toolkit') diff --git a/src/com/itmill/toolkit/tests/components/embedded/EmbeddedTooltip.java b/src/com/itmill/toolkit/tests/components/embedded/EmbeddedTooltip.java new file mode 100644 index 0000000000..f7644666ec --- /dev/null +++ b/src/com/itmill/toolkit/tests/components/embedded/EmbeddedTooltip.java @@ -0,0 +1,28 @@ +package com.itmill.toolkit.tests.components.embedded; + +import com.itmill.toolkit.terminal.ThemeResource; +import com.itmill.toolkit.tests.components.TestBase; +import com.itmill.toolkit.ui.Embedded; + +public class EmbeddedTooltip extends TestBase { + + @Override + protected String getDescription() { + return "The tooltip for an Embedded image should be visible also when hovering the image"; + } + + @Override + protected Integer getTicketNumber() { + return 2853; + } + + @Override + protected void setup() { + Embedded e = new Embedded("Embedded caption", new ThemeResource( + "icons/64/ok.png")); + e + .setDescription("Embedded tooltip, only shown on caption, not on the image"); + addComponent(e); + + } +} -- cgit v1.2.3 From b6887ea186554064c8d5cb8ad5cf1f97d50f0ff8 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Thu, 23 Apr 2009 06:54:08 +0000 Subject: Test case for #2861 svn changeset:7501/svn branch:6.0 --- .../components/tabsheet/AddAndRemoveTabs.java | 60 ++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 src/com/itmill/toolkit/tests/components/tabsheet/AddAndRemoveTabs.java (limited to 'src/com/itmill/toolkit') diff --git a/src/com/itmill/toolkit/tests/components/tabsheet/AddAndRemoveTabs.java b/src/com/itmill/toolkit/tests/components/tabsheet/AddAndRemoveTabs.java new file mode 100644 index 0000000000..2962905578 --- /dev/null +++ b/src/com/itmill/toolkit/tests/components/tabsheet/AddAndRemoveTabs.java @@ -0,0 +1,60 @@ +package com.itmill.toolkit.tests.components.tabsheet; + +import com.itmill.toolkit.tests.components.TestBase; +import com.itmill.toolkit.ui.Button; +import com.itmill.toolkit.ui.HorizontalLayout; +import com.itmill.toolkit.ui.TabSheet; +import com.itmill.toolkit.ui.Button.ClickEvent; + +public class AddAndRemoveTabs extends TestBase { + private TabSheet tabSheet; + + private int counter = 0; + + @Override + public void setup() { + tabSheet = new TabSheet(); + addTab(); + addComponent(tabSheet); + + Button addTabBtn = new Button("Add new tab", + new Button.ClickListener() { + + public void buttonClick(ClickEvent event) { + addTab(); + } + + }); + addComponent(addTabBtn); + } + + private void addTab() { + final HorizontalLayout layout = new HorizontalLayout(); + layout.setCaption("Test " + counter); + + Button closeTab = new Button("Close tab", new Button.ClickListener() { + + public void buttonClick(ClickEvent event) { + tabSheet.removeComponent(layout); + + } + + }); + + layout.addComponent(closeTab); + + tabSheet.addComponent(layout); + counter++; + } + + @Override + protected String getDescription() { + return "Removing all tabs and then adding new tabs should work properly and without javascript errors. All new tabs should be displayed and not only the first one"; + } + + @Override + protected Integer getTicketNumber() { + return 2861; + } + +} -- cgit v1.2.3 From b757fbbd85127027d31dbd138a1be9506b576074 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Thu, 23 Apr 2009 07:03:02 +0000 Subject: Merged: Fix for #2861 - TabSheet doesn't render new tab correctly, if all tabs have been removed svn changeset:7503/svn branch:6.0 --- src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheet.java | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/com/itmill/toolkit') 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 0bb89dcea6..519ec6034a 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheet.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ITabsheet.java @@ -124,6 +124,14 @@ public class ITabsheet extends ITabsheetBase { */ DOM.removeChild(tr, td); + + /* + * If this widget was selected we need to unmark it as the last + * selected + */ + if (w == oldSelected) { + oldSelected = null; + } } @Override -- cgit v1.2.3 From bc493e0ae6e67af9b28d5ef459bea8fcae756079 Mon Sep 17 00:00:00 2001 From: Matti Tahvonen Date: Thu, 23 Apr 2009 13:24:26 +0000 Subject: fixed test description and enhanced test svn changeset:7510/svn branch:6.0 --- src/com/itmill/toolkit/tests/components/table/ColumnWidths.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/com/itmill/toolkit') diff --git a/src/com/itmill/toolkit/tests/components/table/ColumnWidths.java b/src/com/itmill/toolkit/tests/components/table/ColumnWidths.java index af03414db5..1d7f9cc6fc 100644 --- a/src/com/itmill/toolkit/tests/components/table/ColumnWidths.java +++ b/src/com/itmill/toolkit/tests/components/table/ColumnWidths.java @@ -14,7 +14,8 @@ public class ColumnWidths extends TestBase { + "columns (by server or user (dragged)) columns " + "must consume the excess space. Space is divided " + "by default according to natural widths of columns." - + " Lastname should get 1/3 of excess spsace, the las column 2/3."; + + "In example last column is fixed width. Other columns" + + " should divide excess space relatively to 'natural' width unless user has resized column."; } @@ -58,7 +59,7 @@ public class ColumnWidths extends TestBase { table.setContainerDataSource(idx); table.setColumnHeader("firstname", "FirstName"); - table.setColumnHeader("lastname", "LastName"); + table.setColumnHeader("lastname", "LastName with long header"); table.setColumnWidth("150pxfixedCol", 150); -- cgit v1.2.3 From dc250f61b6b13db5ed67e08fceb720fe43ce44bd Mon Sep 17 00:00:00 2001 From: Matti Tahvonen Date: Thu, 23 Apr 2009 13:54:48 +0000 Subject: major refactoring and cleaning related to column width handling in scrolltable. Hardcoded margins now removed and most things ought to be possible to define with CSS. fixes #2417 svn changeset:7512/svn branch:6.0 --- WebContent/ITMILL/themes/default/styles.css | 50 ++- WebContent/ITMILL/themes/default/table/table.css | 50 ++- WebContent/ITMILL/themes/sampler/table/styles.css | 8 +- .../terminal/gwt/client/ui/IScrollTable.java | 335 +++++++++++---------- 4 files changed, 269 insertions(+), 174 deletions(-) (limited to 'src/com/itmill/toolkit') diff --git a/WebContent/ITMILL/themes/default/styles.css b/WebContent/ITMILL/themes/default/styles.css index cc8c3fda7e..14fa5dfc6f 100644 --- a/WebContent/ITMILL/themes/default/styles.css +++ b/WebContent/ITMILL/themes/default/styles.css @@ -1831,6 +1831,30 @@ input.i-modified, /* ./WebContent/ITMILL/themes/default/table/table.css */ + +/* Table theme building instructions + * + * Toolkit scroll table is very complex widget with dozens of features. These + * features set some limitations for theme builder. To keep things working, it + * is safest to try to just override values used in default theme and comfort to + * these instructions. + * + * + * Table cells in body: + * - padding/border for cells is to be defined for td elements (class name: .i-table-cell-content) + * - in default theme there are no borders, but they should work. Just set border-right or border-bottom + * - no padding or border is allowed for div inside cells (class name : .i-table-cell-wrapper) element + * - background is allowed for both elements + * + * Table headers: + * - table cells in header contain .i-table-resizer and + * .i-table-caption-container div elements, which are both floated to right + * - to align header caption to body content resizer width + .i-table-caption-container + * padding right should be equal to content cells padding-right and border-right. + * - Possible cell border in header must be themed into column resizer. + * + */ + .i-table { overflow: hidden; text-align: left /* Force default alignment */ @@ -1856,14 +1880,13 @@ input.i-modified, .i-table-header table, .i-table-table { - border-collapse: collapse; margin: 0; padding: 0; border: 0; + border-spacing:0; } -.i-table-header td, -.i-table-table td { +.i-table-header td { margin: 0; padding: 0; border: 0; @@ -1876,6 +1899,7 @@ input.i-modified, .i-table-resizer { display: block; height: 36px; + width:4px; float: right; background: transparent url(table/img/resizer-bg.png) repeat-y 50% 50%; cursor: col-resize; @@ -1889,6 +1913,11 @@ input.i-modified, font-size: 15px; padding-top: 9px; text-shadow: #ffffff 2px 2px 0; + /* To align captions and content to same place resizer width + caption + * container padding-right must be equal to table cell + * padding-right + border-righ + */ + padding-right:2px; } .i-table-header-cell-asc .i-table-caption-container { @@ -1903,7 +1932,6 @@ input.i-modified, background: transparent url(table/img/header-bg-over.png) repeat-x; } - .i-table-body { background: #fff; border: 1px solid #b6bbbc; @@ -1933,15 +1961,17 @@ input.i-modified, background: #57a7ed; color: #fff; } -.i-table-row td, -.i-table-row-odd td { - padding: 0; -} + .i-table-cell-content { + padding-top: 3px; + padding-left: 3px; + padding-right: 5px; + border-right:1px solid #f6f7f7; +} + +.i-table-cell-wrapper { white-space: nowrap; overflow: hidden; - padding: 3px 0 3px 3px; - margin-right: 5px; line-height: 23px; } diff --git a/WebContent/ITMILL/themes/default/table/table.css b/WebContent/ITMILL/themes/default/table/table.css index 7b327850c4..40a342dd58 100644 --- a/WebContent/ITMILL/themes/default/table/table.css +++ b/WebContent/ITMILL/themes/default/table/table.css @@ -1,3 +1,27 @@ + +/* Table theme building instructions + * + * Toolkit scroll table is very complex widget with dozens of features. These + * features set some limitations for theme builder. To keep things working, it + * is safest to try to just override values used in default theme and comfort to + * these instructions. + * + * + * Table cells in body: + * - padding/border for cells is to be defined for td elements (class name: .i-table-cell-content) + * - in default theme there are no borders, but they should work. Just set border-right or border-bottom + * - no padding or border is allowed for div inside cells (class name : .i-table-cell-wrapper) element + * - background is allowed for both elements + * + * Table headers: + * - table cells in header contain .i-table-resizer and + * .i-table-caption-container div elements, which are both floated to right + * - to align header caption to body content resizer width + .i-table-caption-container + * padding right should be equal to content cells padding-right and border-right. + * - Possible cell border in header must be themed into column resizer. + * + */ + .i-table { overflow: hidden; text-align: left /* Force default alignment */ @@ -23,14 +47,13 @@ .i-table-header table, .i-table-table { - border-collapse: collapse; margin: 0; padding: 0; border: 0; + border-spacing:0; } -.i-table-header td, -.i-table-table td { +.i-table-header td { margin: 0; padding: 0; border: 0; @@ -43,6 +66,7 @@ .i-table-resizer { display: block; height: 36px; + width:4px; float: right; background: transparent url(img/resizer-bg.png) repeat-y 50% 50%; cursor: col-resize; @@ -56,6 +80,11 @@ font-size: 15px; padding-top: 9px; text-shadow: #ffffff 2px 2px 0; + /* To align captions and content to same place resizer width + caption + * container padding-right must be equal to table cell + * padding-right + border-righ + */ + padding-right:2px; } .i-table-header-cell-asc .i-table-caption-container { @@ -70,7 +99,6 @@ background: transparent url(img/header-bg-over.png) repeat-x; } - .i-table-body { background: #fff; border: 1px solid #b6bbbc; @@ -100,15 +128,17 @@ background: #57a7ed; color: #fff; } -.i-table-row td, -.i-table-row-odd td { - padding: 0; -} + .i-table-cell-content { + padding-top: 3px; + padding-left: 3px; + padding-right: 5px; + border-right:1px solid #f6f7f7; +} + +.i-table-cell-wrapper { white-space: nowrap; overflow: hidden; - padding: 3px 0 3px 3px; - margin-right: 5px; line-height: 23px; } diff --git a/WebContent/ITMILL/themes/sampler/table/styles.css b/WebContent/ITMILL/themes/sampler/table/styles.css index 88f4503396..26c5f3f7e6 100644 --- a/WebContent/ITMILL/themes/sampler/table/styles.css +++ b/WebContent/ITMILL/themes/sampler/table/styles.css @@ -21,4 +21,10 @@ background-color: #ffd; font-family: monospace; margin: 0px; -} \ No newline at end of file +} + +.i-table .i-icon { + /* explicitly set icon width for fast browsers + * to properly detect row header width */ + width: 16px; +} 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 892c330b68..f686f137ae 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IScrollTable.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IScrollTable.java @@ -13,6 +13,11 @@ import java.util.List; import java.util.Set; import java.util.Vector; +import com.google.gwt.dom.client.Document; +import com.google.gwt.dom.client.NodeList; +import com.google.gwt.dom.client.TableCellElement; +import com.google.gwt.dom.client.TableRowElement; +import com.google.gwt.dom.client.TableSectionElement; import com.google.gwt.user.client.Command; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.DeferredCommand; @@ -137,10 +142,6 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { */ boolean recalcWidths = false; - int scrollbarWidthReservedInColumn = -1; - int scrollbarWidthReserved = -1; - boolean relativeWidth = false; - private final ArrayList lazyUnregistryBag = new ArrayList(); private String height; private String width = ""; @@ -166,10 +167,6 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { return; } - if (uidl.hasAttribute("width")) { - relativeWidth = uidl.getStringAttribute("width").endsWith("%"); - } - // we may have pending cache row fetch, cancel it. See #2136 rowRequestHandler.cancel(); @@ -559,21 +556,18 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { while (headCells.hasNext()) { final HeaderCell hCell = (HeaderCell) headCells.next(); int w = hCell.getWidth(); - if (w > 0) { + if (hCell.isDefinedWidth()) { // server has defined column width explicitly totalExplicitColumnsWidths += w; } else { if (hCell.getExpandRatio() > 0) { expandRatioDivider += hCell.getExpandRatio(); - w = IScrollTableBody.CELL_EXTRA_WIDTH - + IScrollTableBody.CELL_CONTENT_PADDING; + w = 0; } else { // get and store greater of header width and column width, // and // store it as a minimumn natural col width - final int hw = hCell.getOffsetWidth(); - final int cw = tBody.getColWidth(i); - w = (hw > cw ? hw : cw) + IScrollTableBody.CELL_EXTRA_WIDTH; + w = hCell.getNaturalColumnWidth(i); } hCell.setNaturalMinimumColumnWidth(w); } @@ -587,6 +581,7 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { // fix "natural" width if width not set if (width == null || "".equals(width)) { int w = total; + w += tBody.getCellExtraWidth() * visibleColOrder.length; w += getScrollbarWidth(); setContentWidth(w); } @@ -594,47 +589,23 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { int availW = tBody.getAvailableWidth(); // Hey IE, are you really sure about this? availW = tBody.getAvailableWidth(); + availW -= tBody.getCellExtraWidth() * visibleColOrder.length; - // FIXME this may fail if pagelenth does not correlate well with actual - // height (via setHeight()) - boolean verticalScrollbarVisible = (pageLength < totalRows); - - if (verticalScrollbarVisible) { - // There will be a vertical scrollbar and its width is not included - // in availW - availW -= Util.getNativeScrollbarSize(); + if (!(height != null && !height.equals(""))) { + if (pageLength < totalRows) { + availW -= Util.getNativeScrollbarSize(); + } } boolean needsReLayout = false; if (availW > total) { // natural size is smaller than available space - int extraSpace = availW - total; - int totalWidthR = total - totalExplicitColumnsWidths; + final int extraSpace = availW - total; + final int totalWidthR = total - totalExplicitColumnsWidths; if (totalWidthR > 0) { needsReLayout = true; - /* - * If the table has a relative width and there is enough space - * for a scrollbar we reserve this in the last column - */ - int scrollbarWidth = getScrollbarWidth(); - scrollbarWidth = Util.getNativeScrollbarSize(); - if (!verticalScrollbarVisible && relativeWidth - && totalWidthR >= scrollbarWidth) { - - scrollbarWidthReserved = scrollbarWidth + 1; // - int columnindex = tHead.getVisibleCellCount() - 1; - widths[columnindex] += scrollbarWidthReserved; - HeaderCell headerCell = tHead.getHeaderCell(columnindex); - if (headerCell.getWidth() == -1) { - totalWidthR += scrollbarWidthReserved; - headerCell.setNaturalMinimumColumnWidth(headerCell - .getNaturalColumnWidth() - + scrollbarWidthReserved); - } - extraSpace -= scrollbarWidthReserved; - scrollbarWidthReservedInColumn = columnindex; - } + if (expandRatioDivider > 0) { // visible columns have some active expand ratios, excess // space is divided according to them @@ -658,7 +629,7 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { i = 0; while (headCells.hasNext()) { HeaderCell hCell = (HeaderCell) headCells.next(); - if (hCell.getWidth() == -1) { + if (!hCell.isDefinedWidth()) { int w = widths[i]; final int newSpace = extraSpace * w / totalWidthR; w += newSpace; @@ -997,10 +968,6 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { public class HeaderCell extends Widget { - private static final int DRAG_WIDGET_WIDTH = 4; - - private static final int MINIMUM_COL_WIDTH = 20; - Element td = DOM.createTD(); Element captionContainer = DOM.createDiv(); @@ -1027,7 +994,7 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { private int width = -1; - private int naturalWidth = 0; + private int naturalWidth = -1; private char align = ALIGN_LEFT; @@ -1048,8 +1015,6 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { DOM.setElementProperty(colResizeWidget, "className", CLASSNAME + "-resizer"); - DOM.setStyleAttribute(colResizeWidget, "width", DRAG_WIDGET_WIDTH - + "px"); DOM.sinkEvents(colResizeWidget, Event.MOUSEEVENTS); setText(headerText); @@ -1089,10 +1054,24 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { DOM.setStyleAttribute(captionContainer, "width", ""); setWidth(""); } else { - DOM.setStyleAttribute(captionContainer, "width", (w - - DRAG_WIDGET_WIDTH - 4) - + "px"); - setWidth(w + "px"); + captionContainer.getStyle().setPropertyPx("width", w); + + /* + * if we already have tBody, set the header width properly, if + * not defer it. IE will fail with complex float in table header + * unless TD width is not explicitly set. + */ + if (tBody != null) { + int tdWidth = width + tBody.getCellExtraWidth(); + setWidth(tdWidth + "px"); + } else { + DeferredCommand.addCommand(new Command() { + public void execute() { + int tdWidth = width + tBody.getCellExtraWidth(); + setWidth(tdWidth + "px"); + } + }); + } } } @@ -1307,8 +1286,8 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { } int newWidth = originalWidth + deltaX; - if (newWidth < MINIMUM_COL_WIDTH) { - newWidth = MINIMUM_COL_WIDTH; + if (newWidth < tBody.getCellExtraWidth()) { + newWidth = tBody.getCellExtraWidth(); } setColWidth(colIndex, newWidth, true); } @@ -1354,27 +1333,34 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { * If column is resized by user or the width is defined by server the * actual width is returned. Else the natural min width is returned. * + * @param columnIndex + * column index hint, if -1 (unknown) it will be detected + * * @return */ - public int getNaturalColumnWidth() { + public int getNaturalColumnWidth(int columnIndex) { if (isDefinedWidth()) { return width; } else { - if (naturalWidth == 0) { + if (naturalWidth < 0) { // This is recently revealed column. Try to detect a proper // value (greater of header and data // cols) - final int hw = getOffsetWidth(); - int i = 0; - for (Iterator it = tHead.iterator(); it.hasNext(); i++) { - if (it.next() == this) { - break; + + final int hw = ((Element) getElement().getLastChild()) + .getOffsetWidth() + + tBody.getCellExtraWidth(); + if (columnIndex < 0) { + columnIndex = 0; + for (Iterator it = tHead.iterator(); it + .hasNext(); columnIndex++) { + if (it.next() == this) { + break; + } } } - final int cw = tBody.getColWidth(i); - naturalWidth = (hw > cw ? hw : cw) - + IScrollTableBody.CELL_EXTRA_WIDTH; - + final int cw = tBody.getColWidth(columnIndex); + naturalWidth = (hw > cw ? hw : cw); } return naturalWidth; } @@ -1428,6 +1414,10 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { private int focusedSlot = -1; public TableHead() { + if (BrowserInfo.get().isIE()) { + table.setPropertyInt("cellSpacing", 0); + } + DOM.setStyleAttribute(hTableWrapper, "overflow", "hidden"); DOM.setElementProperty(hTableWrapper, "className", CLASSNAME + "-header"); @@ -1770,7 +1760,7 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { * Returns column alignments for visible columns */ public char[] getColumnAlignments() { - final Iterator it = visibleCells.iterator(); + final Iterator it = visibleCells.iterator(); final char[] aligns = new char[visibleCells.size()]; int colIndex = 0; while (it.hasNext()) { @@ -1789,29 +1779,25 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { */ public class IScrollTableBody extends Panel { - public static final int CELL_EXTRA_WIDTH = 20; - public static final int DEFAULT_ROW_HEIGHT = 24; - /** - * Amount of padding inside one table cell (this is reduced from the - * "cellContent" element's width). You may override this in your own - * widgetset. - */ - public static final int CELL_CONTENT_PADDING = 8; - private int rowHeight = -1; private final List renderedRows = new Vector(); - private boolean initDone = false; + /** + * Due some optimizations row height measuring is deferred and initial + * set of rows is rendered detached. Flag set on when table body has + * been attached in dom and rowheight has been measured. + */ + private boolean tBodyMeasurementsDone = false; Element preSpacer = DOM.createDiv(); Element postSpacer = DOM.createDiv(); Element container = DOM.createDiv(); - Element tBody = DOM.createTBody(); + TableSectionElement tBodyElement = Document.get().createTBodyElement(); Element table = DOM.createTable(); private int firstRendered; @@ -1822,17 +1808,21 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { IScrollTableBody() { constructDOM(); + setElement(container); } private void constructDOM() { DOM.setElementProperty(table, "className", CLASSNAME + "-table"); + if (BrowserInfo.get().isIE()) { + table.setPropertyInt("cellSpacing", 0); + } DOM.setElementProperty(preSpacer, "className", CLASSNAME + "-row-spacer"); DOM.setElementProperty(postSpacer, "className", CLASSNAME + "-row-spacer"); - DOM.appendChild(table, tBody); + table.appendChild(tBodyElement); DOM.appendChild(container, preSpacer); DOM.appendChild(container, table); DOM.appendChild(container, postSpacer); @@ -1840,13 +1830,13 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { } public int getAvailableWidth() { - return DOM.getElementPropertyInt(preSpacer, "offsetWidth"); + return preSpacer.getOffsetWidth(); } public void renderInitialRows(UIDL rowData, int firstIndex, int rows) { firstRendered = firstIndex; lastRendered = firstIndex + rows - 1; - final Iterator it = rowData.getChildIterator(); + final Iterator it = rowData.getChildIterator(); aligns = tHead.getColumnAlignments(); while (it.hasNext()) { final IScrollTableRow row = new IScrollTableRow((UIDL) it @@ -1861,7 +1851,7 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { public void renderRows(UIDL rowData, int firstIndex, int rows) { // FIXME REVIEW aligns = tHead.getColumnAlignments(); - final Iterator it = rowData.getChildIterator(); + final Iterator it = rowData.getChildIterator(); if (firstIndex == lastRendered + 1) { while (it.hasNext()) { final IScrollTableRow row = createRow((UIDL) it.next()); @@ -1915,7 +1905,7 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { rowRequestHandler.setReqFirstRow(lastRendered + 1); rowRequestHandler.setReqRows(reactLastRow - lastRendered - 1); rowRequestHandler.deferRowFetch(1); - } else if (IScrollTable.this.tBody.getFirstRendered() > reactFirstRow) { + } else if (tBody.getFirstRendered() > reactFirstRow) { /* * Branch for fetching cache above visible area. * @@ -1946,9 +1936,9 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { final Element cell = DOM.getChild(row.getElement(), i); final int w = IScrollTable.this .getColWidth(getColKeyByIndex(i)); - DOM.setStyleAttribute(DOM.getFirstChild(cell), "width", - (w - CELL_CONTENT_PADDING) + "px"); - DOM.setStyleAttribute(cell, "width", w + "px"); + cell.getFirstChildElement().getStyle() + .setPropertyPx("width", w); + cell.getStyle().setPropertyPx("width", w); } return row; } @@ -1966,7 +1956,8 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { if (row.isSelected()) { row.addStyleName("i-selected"); } - DOM.insertChild(tBody, row.getElement(), 0); + tBodyElement.insertBefore(row.getElement(), tBodyElement + .getFirstChild()); adopt(row); renderedRows.add(0, row); } @@ -1985,7 +1976,7 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { if (row.isSelected()) { row.addStyleName("i-selected"); } - DOM.appendChild(tBody, row.getElement()); + tBodyElement.appendChild(row.getElement()); adopt(row); renderedRows.add(row); } @@ -2012,7 +2003,7 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { final IScrollTableRow toBeRemoved = (IScrollTableRow) renderedRows .get(index); lazyUnregistryBag.add(toBeRemoved); - DOM.removeChild(tBody, toBeRemoved.getElement()); + tBodyElement.removeChild(toBeRemoved.getElement()); orphan(toBeRemoved); renderedRows.remove(index); fixSpacers(); @@ -2058,15 +2049,17 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { } public int getRowHeight(boolean forceUpdate) { - if (initDone && !forceUpdate) { + if (tBodyMeasurementsDone && !forceUpdate) { return rowHeight; } else { - if (DOM.getChildCount(tBody) > 0) { - rowHeight = getTableHeight() / DOM.getChildCount(tBody); + + if (tBodyElement.getRows().getLength() > 0) { + rowHeight = getTableHeight() + / tBodyElement.getRows().getLength(); } else { return DEFAULT_ROW_HEIGHT; } - initDone = true; + tBodyMeasurementsDone = true; return rowHeight; } } @@ -2075,26 +2068,71 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { return table.getOffsetHeight(); } + /** + * Returns the width available for column content. + * + * @param i + * @return + */ public int getColWidth(int i) { - if (initDone) { - final Element e = DOM.getChild(DOM.getChild(tBody, 0), i); - return DOM.getElementPropertyInt(e, "offsetWidth"); + if (tBodyMeasurementsDone) { + final Element wrapper = (Element) tBodyElement + .getFirstChildElement().getChildNodes().getItem(i) + .getFirstChild(); + return wrapper.getOffsetWidth(); } else { return 0; } } + /** + * Sets the content width of a column. + * + * Due IE limitation, we must set the width to a wrapper elements inside + * table cells (with overflow hidden, which does not work on td + * elements). + * + * To get this work properly crossplatform, we will also set the width + * of td. + * + * @param colIndex + * @param w + */ public void setColWidth(int colIndex, int w) { - final int rows = DOM.getChildCount(tBody); + NodeList rows2 = tBodyElement.getRows(); + final int rows = rows2.getLength(); for (int i = 0; i < rows; i++) { - final Element cell = DOM.getChild(DOM.getChild(tBody, i), - colIndex); - DOM.setStyleAttribute(DOM.getFirstChild(cell), "width", - (w - CELL_CONTENT_PADDING) + "px"); - DOM.setStyleAttribute(cell, "width", w + "px"); + TableRowElement row = rows2.getItem(i); + TableCellElement cell = row.getCells().getItem(colIndex); + cell.getFirstChildElement().getStyle() + .setPropertyPx("width", w); + cell.getStyle().setPropertyPx("width", w); } } + private int cellExtraWidth = -1; + private int cellMarginLeft = -1; + + /** + * Method to return the space used for cell paddings + border. + */ + private int getCellExtraWidth() { + if (cellExtraWidth < 0) { + detectExtrawidth(); + } + return cellExtraWidth; + } + + private void detectExtrawidth() { + com.google.gwt.dom.client.Element firstTD = tBodyElement + .getFirstChildElement().getFirstChildElement(); + com.google.gwt.dom.client.Element wrapper = firstTD + .getFirstChildElement(); + cellExtraWidth = firstTD.getOffsetWidth() + - wrapper.getOffsetWidth(); + cellMarginLeft = wrapper.getOffsetLeft(); + } + private void reLayoutComponents() { for (Widget w : this) { IScrollTableRow r = (IScrollTableRow) w; @@ -2115,7 +2153,7 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { public void moveCol(int oldIndex, int newIndex) { // loop all rows and move given index to its new place - final Iterator rows = iterator(); + final Iterator rows = iterator(); while (rows.hasNext()) { final IScrollTableRow row = (IScrollTableRow) rows.next(); @@ -2131,7 +2169,7 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { public class IScrollTableRow extends Panel implements ActionOwner, Container { - Vector childWidgets = new Vector(); + Vector childWidgets = new Vector(); private boolean selected = false; private final int rowKey; private List pendingComponentPaints; @@ -2193,7 +2231,7 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { actionKeys = uidl.getStringArrayAttribute("al"); } - final Iterator cells = uidl.getChildIterator(); + final Iterator cells = uidl.getChildIterator(); while (cells.hasNext()) { final Object cell = cells.next(); visibleColumnIndex++; @@ -2229,26 +2267,26 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { if (style != null && !style.equals("")) { className += " " + CLASSNAME + "-cell-content-" + style; } - - DOM.setElementProperty(container, "className", className); + td.setClassName(className); + container.setClassName(CLASSNAME + "-cell-wrapper"); if (textIsHTML) { - DOM.setInnerHTML(container, text); + container.setInnerHTML(text); } else { - DOM.setInnerText(container, text); + container.setInnerText(text); } if (align != ALIGN_LEFT) { switch (align) { case ALIGN_CENTER: - DOM.setStyleAttribute(container, "textAlign", "center"); + container.getStyle().setProperty("textAlign", "center"); break; case ALIGN_RIGHT: default: - DOM.setStyleAttribute(container, "textAlign", "right"); + container.getStyle().setProperty("textAlign", "right"); break; } } - DOM.appendChild(td, container); - DOM.appendChild(getElement(), td); + td.appendChild(container); + getElement().appendChild(td); } public void addCell(Widget w, char align, String style) { @@ -2258,7 +2296,8 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { if (style != null && !style.equals("")) { className += " " + CLASSNAME + "-cell-content-" + style; } - DOM.setElementProperty(container, "className", className); + td.setClassName(className); + container.setClassName(CLASSNAME + "-cell-wrapper"); // TODO most components work with this, but not all (e.g. // Select) // Old comment: make widget cells respect align. @@ -2266,25 +2305,25 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { if (align != ALIGN_LEFT) { switch (align) { case ALIGN_CENTER: - DOM.setStyleAttribute(container, "textAlign", "center"); + container.getStyle().setProperty("textAlign", "center"); break; case ALIGN_RIGHT: default: - DOM.setStyleAttribute(container, "textAlign", "right"); + container.getStyle().setProperty("textAlign", "right"); break; } } - DOM.appendChild(td, container); - DOM.appendChild(getElement(), td); + td.appendChild(container); + getElement().appendChild(td); // ensure widget not attached to another element (possible tBody // change) w.removeFromParent(); - DOM.appendChild(container, w.getElement()); + container.appendChild(w.getElement()); adopt(w); childWidgets.add(w); } - public Iterator iterator() { + public Iterator iterator() { return childWidgets.iterator(); } @@ -2491,14 +2530,13 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { HeaderCell headerCell = tHead.getHeaderCell(i); if (headerCell != null) { if (initializedAndAttached) { - w = headerCell.getWidth() - CELL_CONTENT_PADDING; + w = headerCell.getWidth(); } else { // header offset width is not absolutely correct value, - // but - // a best guess (expecting similar content in all + // but a best guess (expecting similar content in all // columns -> // if one component is relative width so are others) - w = headerCell.getOffsetWidth() - CELL_CONTENT_PADDING; + w = headerCell.getOffsetWidth() - getCellExtraWidth(); } } return new RenderSpace(w, getRowHeight()); @@ -2573,19 +2611,7 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { this.width = width; if (width != null && !"".equals(width)) { - int oldWidth = getOffsetWidth(); super.setWidth(width); - int newWidth = getOffsetWidth(); - - if (scrollbarWidthReservedInColumn != -1 && oldWidth > newWidth - && (oldWidth - newWidth) < scrollbarWidthReserved) { - int col = scrollbarWidthReservedInColumn; - String colKey = getColKeyByIndex(col); - setColWidth(scrollbarWidthReservedInColumn, getColWidth(colKey) - - (oldWidth - newWidth), false); - scrollbarWidthReservedInColumn = -1; - } - int innerPixels = getOffsetWidth() - getBorderWidth(); if (innerPixels < 0) { innerPixels = 0; @@ -2619,54 +2645,57 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { int usedMinimumWidth = 0; int totalExplicitColumnsWidths = 0; float expandRatioDivider = 0; + int colIndex = 0; while (headCells.hasNext()) { final HeaderCell hCell = (HeaderCell) headCells.next(); - usedMinimumWidth += hCell.getNaturalColumnWidth(); if (hCell.isDefinedWidth()) { totalExplicitColumnsWidths += hCell.getWidth(); + usedMinimumWidth += hCell.getWidth(); } else { - totalExplicitColumnsWidths += hCell.getNaturalColumnWidth(); + usedMinimumWidth += hCell.getNaturalColumnWidth(colIndex); expandRatioDivider += hCell.getExpandRatio(); } + colIndex++; } int availW = tBody.getAvailableWidth(); // Hey IE, are you really sure about this? availW = tBody.getAvailableWidth(); + availW -= tBody.getCellExtraWidth() * visibleColOrder.length; int extraSpace = availW - usedMinimumWidth; if (extraSpace < 0) { extraSpace = 0; } - int totalWidthR = usedMinimumWidth - totalExplicitColumnsWidths; - if (totalWidthR < 0) { - totalWidthR = 0; - } + + int totalUndefinedNaturaWidths = usedMinimumWidth + - totalExplicitColumnsWidths; // we have some space that can be divided optimally HeaderCell hCell; - int i = 0; + colIndex = 0; headCells = tHead.iterator(); while (headCells.hasNext()) { hCell = (HeaderCell) headCells.next(); if (!hCell.isDefinedWidth()) { - int w = hCell.getNaturalColumnWidth(); + int w = hCell.getNaturalColumnWidth(colIndex); int newSpace; if (expandRatioDivider > 0) { // divide excess space by expand ratios newSpace = (int) (w + extraSpace * hCell.getExpandRatio() / expandRatioDivider); } else { - if (totalWidthR != 0) { + if (totalUndefinedNaturaWidths != 0) { // divide relatively to natural column widths - newSpace = w + extraSpace * w / totalWidthR; + newSpace = w + extraSpace * w + / totalUndefinedNaturaWidths; } else { newSpace = w; } } - setColWidth(i, newSpace, false); + setColWidth(colIndex, newSpace, false); } - i++; + colIndex++; } Util.runWebkitOverflowAutoFix(bodyContainer.getElement()); tBody.reLayoutComponents(); -- cgit v1.2.3 From 25c279f2c112a2aa010e6c04d57373c700af634d Mon Sep 17 00:00:00 2001 From: Matti Tahvonen Date: Thu, 23 Apr 2009 19:58:08 +0000 Subject: more cleaning for scroll table. Fixed npe on empty table (regression). Now detects better default values for row height and column extra space with initially empty table. svn changeset:7516/svn branch:6.0 --- .../terminal/gwt/client/ui/IScrollTable.java | 78 +++++++++++++++------- 1 file changed, 55 insertions(+), 23 deletions(-) (limited to 'src/com/itmill/toolkit') 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 f686f137ae..9b8766c68c 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IScrollTable.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IScrollTable.java @@ -2057,7 +2057,16 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { rowHeight = getTableHeight() / tBodyElement.getRows().getLength(); } else { - return DEFAULT_ROW_HEIGHT; + if (isAttached()) { + // measure row height by adding a dummy row + IScrollTableRow scrollTableRow = new IScrollTableRow(); + tBodyElement.appendChild(scrollTableRow.getElement()); + getRowHeight(forceUpdate); + tBodyElement.removeChild(scrollTableRow.getElement()); + } else { + // TODO investigate if this can never happen anymore + return DEFAULT_ROW_HEIGHT; + } } tBodyMeasurementsDone = true; return rowHeight; @@ -2071,15 +2080,21 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { /** * Returns the width available for column content. * - * @param i + * @param columnIndex * @return */ - public int getColWidth(int i) { + public int getColWidth(int columnIndex) { if (tBodyMeasurementsDone) { - final Element wrapper = (Element) tBodyElement - .getFirstChildElement().getChildNodes().getItem(i) - .getFirstChild(); - return wrapper.getOffsetWidth(); + NodeList rows = tBodyElement.getRows(); + if (rows.getLength() == 0) { + // no rows yet rendered + return 0; + } else { + com.google.gwt.dom.client.Element wrapperdiv = rows + .getItem(0).getCells().getItem(columnIndex) + .getFirstChildElement(); + return wrapperdiv.getOffsetWidth(); + } } else { return 0; } @@ -2111,7 +2126,6 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { } private int cellExtraWidth = -1; - private int cellMarginLeft = -1; /** * Method to return the space used for cell paddings + border. @@ -2124,13 +2138,21 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { } private void detectExtrawidth() { - com.google.gwt.dom.client.Element firstTD = tBodyElement - .getFirstChildElement().getFirstChildElement(); - com.google.gwt.dom.client.Element wrapper = firstTD - .getFirstChildElement(); - cellExtraWidth = firstTD.getOffsetWidth() - - wrapper.getOffsetWidth(); - cellMarginLeft = wrapper.getOffsetLeft(); + NodeList rows = tBodyElement.getRows(); + if (rows.getLength() == 0) { + /* need to temporary add empty row and detect */ + IScrollTableRow scrollTableRow = new IScrollTableRow(); + tBodyElement.appendChild(scrollTableRow.getElement()); + detectExtrawidth(); + tBodyElement.removeChild(scrollTableRow.getElement()); + } else { + TableRowElement item = rows.getItem(0); + TableCellElement firstTD = item.getCells().getItem(0); + com.google.gwt.dom.client.Element wrapper = firstTD + .getFirstChildElement(); + cellExtraWidth = firstTD.getOffsetWidth() + - wrapper.getOffsetWidth(); + } } private void reLayoutComponents() { @@ -2175,10 +2197,12 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { private List pendingComponentPaints; private String[] actionKeys = null; + private TableRowElement rowElement; private IScrollTableRow(int rowKey) { this.rowKey = rowKey; - setElement(DOM.createElement("tr")); + rowElement = Document.get().createTRElement(); + setElement(rowElement); DOM.sinkEvents(getElement(), Event.ONCLICK | Event.ONDBLCLICK | Event.ONCONTEXTMENU); } @@ -2258,6 +2282,15 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { } } + /** + * Add a dummy row, used for measurements if Table is empty. + */ + public IScrollTableRow() { + this(0); + addStyleName(CLASSNAME + "-row"); + addCell("_", 'b', "", true); + } + public void addCell(String text, char align, String style, boolean textIsHTML) { // String only content is optimized by not using Label widget @@ -2545,14 +2578,13 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { private int getColIndexOf(Widget child) { com.google.gwt.dom.client.Element widgetCell = child .getElement().getParentElement().getParentElement(); - com.google.gwt.dom.client.Element td = getElement() - .getFirstChildElement(); - int index = 0; - while (td != widgetCell && td.getNextSiblingElement() != null) { - index++; - td = td.getNextSiblingElement(); + NodeList cells = rowElement.getCells(); + for (int i = 0; i < cells.getLength(); i++) { + if (cells.getItem(i) == widgetCell) { + return i; + } } - return index; + return -1; } public boolean hasChildComponent(Widget component) { -- cgit v1.2.3 From afdcec2164e0ab73d125427373bed6e12b4ea47a Mon Sep 17 00:00:00 2001 From: Matti Tahvonen Date: Thu, 23 Apr 2009 21:02:21 +0000 Subject: fixed minor regression with undefined width tables with height defined. Added sanity check when destroying row (fixes #2862, regression). svn changeset:7517/svn branch:6.0 --- .../terminal/gwt/client/ui/IScrollTable.java | 44 +++++++++++++++------- 1 file changed, 31 insertions(+), 13 deletions(-) (limited to 'src/com/itmill/toolkit') 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 9b8766c68c..2f88424374 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IScrollTable.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IScrollTable.java @@ -578,11 +578,27 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { tHead.disableBrowserIntelligence(); + boolean willHaveScrollbarz = false; + if (!(height != null && !height.equals(""))) { + if (pageLength < totalRows) { + willHaveScrollbarz = true; + } + } else { + int fakeheight = tBody.getRowHeight() * totalRows; + int availableHeight = bodyContainer.getElement().getPropertyInt( + "clientHeight"); + if (fakeheight > availableHeight) { + willHaveScrollbarz = true; + } + } + // fix "natural" width if width not set if (width == null || "".equals(width)) { int w = total; w += tBody.getCellExtraWidth() * visibleColOrder.length; - w += getScrollbarWidth(); + if (willHaveScrollbarz) { + w += Util.getNativeScrollbarSize(); + } setContentWidth(w); } @@ -591,10 +607,8 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { availW = tBody.getAvailableWidth(); availW -= tBody.getCellExtraWidth() * visibleColOrder.length; - if (!(height != null && !height.equals(""))) { - if (pageLength < totalRows) { - availW -= Util.getNativeScrollbarSize(); - } + if (willHaveScrollbarz) { + availW -= Util.getNativeScrollbarSize(); } boolean needsReLayout = false; @@ -2000,14 +2014,18 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { index = renderedRows.size() - 1; lastRendered--; } - final IScrollTableRow toBeRemoved = (IScrollTableRow) renderedRows - .get(index); - lazyUnregistryBag.add(toBeRemoved); - tBodyElement.removeChild(toBeRemoved.getElement()); - orphan(toBeRemoved); - renderedRows.remove(index); - fixSpacers(); - return true; + if (index >= 0) { + final IScrollTableRow toBeRemoved = (IScrollTableRow) renderedRows + .get(index); + lazyUnregistryBag.add(toBeRemoved); + tBodyElement.removeChild(toBeRemoved.getElement()); + orphan(toBeRemoved); + renderedRows.remove(index); + fixSpacers(); + return true; + } else { + return false; + } } @Override -- cgit v1.2.3 From 321befdac2ac230afeba0815d1848b10b5bc9828 Mon Sep 17 00:00:00 2001 From: Matti Tahvonen Date: Fri, 24 Apr 2009 09:04:32 +0000 Subject: scrolltable theme refactoring: cleaning, fixing regressions svn changeset:7523/svn branch:6.0 --- .../terminal/gwt/client/ui/IScrollTable.java | 25 +++++++++++----------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'src/com/itmill/toolkit') 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 2f88424374..70bcc618a5 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IScrollTable.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IScrollTable.java @@ -15,6 +15,7 @@ import java.util.Vector; import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.NodeList; +import com.google.gwt.dom.client.Style; import com.google.gwt.dom.client.TableCellElement; import com.google.gwt.dom.client.TableRowElement; import com.google.gwt.dom.client.TableSectionElement; @@ -603,8 +604,10 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { } int availW = tBody.getAvailableWidth(); - // Hey IE, are you really sure about this? - availW = tBody.getAvailableWidth(); + if (BrowserInfo.get().isIE()) { + // Hey IE, are you really sure about this? + availW = tBody.getAvailableWidth(); + } availW -= tBody.getCellExtraWidth() * visibleColOrder.length; if (willHaveScrollbarz) { @@ -689,6 +692,7 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { */ int bodyHeight = tBody.getTableHeight(); bodyContainer.setHeight(bodyHeight + "px"); + Util.runWebkitOverflowAutoFix(bodyContainer.getElement()); } else { int bodyHeight = (tBody.getRowHeight(true) * pageLength); bodyContainer.setHeight(bodyHeight + "px"); @@ -726,16 +730,6 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { initializedAndAttached = true; } - private int getScrollbarWidth() { - if (BrowserInfo.get().isIE6()) { - return Util.measureHorizontalBorder(bodyContainer.getElement()); - } - - return bodyContainer.getOffsetWidth() - - DOM.getElementPropertyInt(bodyContainer.getElement(), - "clientWidth"); - } - /** * This method has logic which rows needs to be requested from server when * user scrolls @@ -1844,7 +1838,12 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { } public int getAvailableWidth() { - return preSpacer.getOffsetWidth(); + Style style = bodyContainer.getElement().getStyle(); + style.setProperty("overflow", "hidden"); + int w = bodyContainer.getElement().getPropertyInt("clientWidth"); + style.setProperty("overflow", "auto"); + return w; + // return preSpacer.getOffsetWidth(); } public void renderInitialRows(UIDL rowData, int firstIndex, int rows) { -- cgit v1.2.3 From b10f50ce72de52d1a48d10375277f435b2a83574 Mon Sep 17 00:00:00 2001 From: Matti Tahvonen Date: Fri, 24 Apr 2009 09:05:18 +0000 Subject: fixed invalid test case: column width pixels define the area available for content svn changeset:7524/svn branch:6.0 --- .../toolkit/tests/components/table/TableRowHeight2.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/com/itmill/toolkit') diff --git a/src/com/itmill/toolkit/tests/components/table/TableRowHeight2.java b/src/com/itmill/toolkit/tests/components/table/TableRowHeight2.java index f02a110bab..dc366e40fe 100644 --- a/src/com/itmill/toolkit/tests/components/table/TableRowHeight2.java +++ b/src/com/itmill/toolkit/tests/components/table/TableRowHeight2.java @@ -8,6 +8,9 @@ import com.itmill.toolkit.ui.Table; public class TableRowHeight2 extends TestBase { + private static final int TABLE_EXTRA = 2; // borders + private static final int COLEXTRASPACE = 6; // cell margins by theme + @Override protected String getDescription() { return "The table contains 2 rows, which both should be shown completely as the table height is undefined."; @@ -25,10 +28,16 @@ public class TableRowHeight2 extends TestBase { vl.setSizeFull(); Table table = new Table(); - table.setWidth("300px"); + + int COL_TITLE_W = 200; + int COL_TEST_W = 98; + + table + .setWidth((COL_TEST_W + COL_TITLE_W + 2 * COLEXTRASPACE + TABLE_EXTRA) + + "px"); table.setPageLength(0); - table.setColumnWidth("title", 200); - table.setColumnWidth("test", 98); + table.setColumnWidth("title", COL_TITLE_W); + table.setColumnWidth("test", COL_TEST_W); table.addContainerProperty("title", Button.class, ""); table.addContainerProperty("test", Button.class, ""); for (int i = 0; i < 2; i++) { -- cgit v1.2.3 From 19ad7df367dab9ba22b024f641c001fbf100d79a Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Mon, 27 Apr 2009 13:04:15 +0000 Subject: Merged: Fix for #2864 - Added server side checks for currentPageFirstItemId & currentPageFirstItemIndex validity svn changeset:7535/svn branch:6.0 --- src/com/itmill/toolkit/ui/Table.java | 37 +++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) (limited to 'src/com/itmill/toolkit') diff --git a/src/com/itmill/toolkit/ui/Table.java b/src/com/itmill/toolkit/ui/Table.java index 4d4fdba7fb..083b393aa8 100644 --- a/src/com/itmill/toolkit/ui/Table.java +++ b/src/com/itmill/toolkit/ui/Table.java @@ -822,8 +822,23 @@ public class Table extends AbstractSelect implements Action.Container, } } - // If the search for item index was successfull + // If the search for item index was successful if (index >= 0) { + /* + * The table is not capable of displaying an item in the container + * as the first if there are not enough items following the selected + * item so the whole table (pagelength) is filled. + */ + int maxIndex = size() - pageLength; + if (maxIndex < 0) { + maxIndex = 0; + } + + if (index > maxIndex) { + setCurrentPageFirstItemIndex(maxIndex); + return; + } + this.currentPageFirstItemId = currentPageFirstItemId; currentPageFirstItemIndex = index; } @@ -1087,14 +1102,26 @@ public class Table extends AbstractSelect implements Action.Container, private void setCurrentPageFirstItemIndex(int newIndex, boolean needsPageBufferReset) { - // Ensures that the new value is valid - if (newIndex >= size()) { - newIndex = size() - pageLength; - } + if (newIndex < 0) { newIndex = 0; } + /* + * The table is not capable of displaying an item in the container as + * the first if there are not enough items following the selected item + * so the whole table (pagelength) is filled. + */ + int maxIndex = size() - pageLength; + if (maxIndex < 0) { + maxIndex = 0; + } + + // Ensures that the new value is valid + if (newIndex > maxIndex) { + newIndex = maxIndex; + } + // Refresh first item id if (items instanceof Container.Indexed) { try { -- cgit v1.2.3 From 031aad4267fc6c49944b487164e9e1ba259ed549 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Mon, 27 Apr 2009 13:13:10 +0000 Subject: Test case for #2864 svn changeset:7536/svn branch:6.0 --- .../components/table/TestCurrentPageFirstItem.java | 60 ++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 src/com/itmill/toolkit/tests/components/table/TestCurrentPageFirstItem.java (limited to 'src/com/itmill/toolkit') diff --git a/src/com/itmill/toolkit/tests/components/table/TestCurrentPageFirstItem.java b/src/com/itmill/toolkit/tests/components/table/TestCurrentPageFirstItem.java new file mode 100644 index 0000000000..fd4aed015d --- /dev/null +++ b/src/com/itmill/toolkit/tests/components/table/TestCurrentPageFirstItem.java @@ -0,0 +1,60 @@ +package com.itmill.toolkit.tests.components.table; + +import com.itmill.toolkit.Application; +import com.itmill.toolkit.data.Container; +import com.itmill.toolkit.data.Item; +import com.itmill.toolkit.data.util.IndexedContainer; +import com.itmill.toolkit.ui.Button; +import com.itmill.toolkit.ui.Table; +import com.itmill.toolkit.ui.VerticalLayout; +import com.itmill.toolkit.ui.Window; +import com.itmill.toolkit.ui.Button.ClickEvent; +import com.itmill.toolkit.ui.Button.ClickListener; + +public class TestCurrentPageFirstItem extends Application implements + ClickListener { + + private Button buttonIndex; + private Button buttonItem; + private Table table; + private int counter = 0; + IndexedContainer container = new IndexedContainer(); + + @Override + public void init() { + try { + Window main = new Window("Table header Test"); + setMainWindow(main); + main.setSizeFull(); + // setTheme("testtheme"); + VerticalLayout baseLayout = new VerticalLayout(); + main.setLayout(baseLayout); + + table = new Table(); + container.addContainerProperty("row", String.class, ""); + table.setContainerDataSource(container); + table.setWidth("100%"); + table.setPageLength(3); + buttonIndex = new Button("Add row and select last index", this); + buttonItem = new Button("Add row and select last item", this); + + baseLayout.addComponent(table); + baseLayout.addComponent(buttonIndex); + baseLayout.addComponent(buttonItem); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public void buttonClick(ClickEvent event) { + Item item = container.addItem(++counter); + item.getItemProperty("row").setValue(counter + ""); + table.select(counter); + if (event.getButton() == buttonIndex) { + table.setCurrentPageFirstItemIndex(((Container.Indexed) table + .getContainerDataSource()).indexOfId(counter)); + } else { + table.setCurrentPageFirstItemId(counter); + } + } +} -- cgit v1.2.3 From 5cf5ea1c6773eb946eaeac4512a070b9f3ed47a8 Mon Sep 17 00:00:00 2001 From: Henri Sara Date: Tue, 28 Apr 2009 08:10:57 +0000 Subject: AutoGenerated annotation type for WYSIWYG editor and more. svn changeset:7542/svn branch:6.0 --- src/com/itmill/toolkit/annotations/AutoGenerated.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/com/itmill/toolkit/annotations/AutoGenerated.java (limited to 'src/com/itmill/toolkit') diff --git a/src/com/itmill/toolkit/annotations/AutoGenerated.java b/src/com/itmill/toolkit/annotations/AutoGenerated.java new file mode 100644 index 0000000000..f2483f4146 --- /dev/null +++ b/src/com/itmill/toolkit/annotations/AutoGenerated.java @@ -0,0 +1,15 @@ +package com.itmill.toolkit.annotations; + +/** + * Marker annotation for automatically generated code elements. + * + * These elements may be modified or removed by code generation. + * + * @author IT Mill Ltd. + * @version + * @VERSION@ + * @since 6.0 + */ +public @interface AutoGenerated { + +} -- cgit v1.2.3 From f97f1243281647357390e9a252b3e5b9e91250be Mon Sep 17 00:00:00 2001 From: Matti Tahvonen Date: Tue, 28 Apr 2009 08:55:43 +0000 Subject: added svg mime type for minetyperesolver svn changeset:7544/svn branch:6.0 --- src/com/itmill/toolkit/service/FileTypeResolver.java | 1 + 1 file changed, 1 insertion(+) (limited to 'src/com/itmill/toolkit') diff --git a/src/com/itmill/toolkit/service/FileTypeResolver.java b/src/com/itmill/toolkit/service/FileTypeResolver.java index 97cd161681..6a53441161 100644 --- a/src/com/itmill/toolkit/service/FileTypeResolver.java +++ b/src/com/itmill/toolkit/service/FileTypeResolver.java @@ -140,6 +140,7 @@ public class FileTypeResolver implements Serializable { + "image/jpeg jpeg jpg jpe," + "image/pcx pcx," + "image/png png," + + "image/svg+xml svg svgz," + "image/tiff tiff tif," + "image/vnd.wap.wbmp wbmp," + "image/x-cmu-raster ras," -- cgit v1.2.3 From a277d0c6f2fba04e277d2790bbb32f59946e0321 Mon Sep 17 00:00:00 2001 From: Matti Tahvonen Date: Tue, 28 Apr 2009 08:56:54 +0000 Subject: renamed setModal to setToolkitModality to avoid naming collision with GWT 1.6 svn changeset:7545/svn branch:6.0 --- .../toolkit/terminal/gwt/client/ui/IWindow.java | 26 +++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src/com/itmill/toolkit') 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 e329d410c0..ddb2c7f6a0 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IWindow.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IWindow.java @@ -104,7 +104,7 @@ public class IWindow extends IToolkitOverlay implements Container, /** Last known positiony read from UIDL or updated to application connection */ private int uidlPositionY = -1; - private boolean modal = false; + private boolean vaadinModality = false; private boolean resizable = true; @@ -135,7 +135,7 @@ public class IWindow extends IToolkitOverlay implements Container, private boolean immediate; public IWindow() { - super(false, false, true); // no autohide, not modal, shadow + super(false, false, true); // no autohide, not vaadinModality, shadow // Different style of shadow for windows setShadowStyle("window"); @@ -175,7 +175,7 @@ public class IWindow extends IToolkitOverlay implements Container, @Override protected void setZIndex(int zIndex) { super.setZIndex(zIndex); - if (modal) { + if (vaadinModality) { DOM.setStyleAttribute(modalityCurtain, "zIndex", "" + zIndex); } } @@ -239,8 +239,8 @@ public class IWindow extends IToolkitOverlay implements Container, } if (!uidl.hasAttribute("cached")) { - if (uidl.getBooleanAttribute("modal") != modal) { - setModal(!modal); + if (uidl.getBooleanAttribute("vaadinModality") != vaadinModality) { + setVaadinModality(!vaadinModality); } if (!isAttached()) { show(); @@ -485,7 +485,7 @@ public class IWindow extends IToolkitOverlay implements Container, @Override public void show() { - if (modal) { + if (vaadinModality) { showModalityCurtain(); } super.show(); @@ -529,15 +529,15 @@ public class IWindow extends IToolkitOverlay implements Container, @Override public void hide() { - if (modal) { + if (vaadinModality) { hideModalityCurtain(); } super.hide(); } - private void setModal(boolean modality) { - modal = modality; - if (modal) { + private void setVaadinModality(boolean modality) { + vaadinModality = modality; + if (vaadinModality) { modalityCurtain = DOM.createDiv(); DOM.setElementProperty(modalityCurtain, "className", CLASSNAME + "-modalitycurtain"); @@ -547,7 +547,7 @@ public class IWindow extends IToolkitOverlay implements Container, } else { DeferredCommand.addCommand(new Command() { public void execute() { - // modal window must on top of others + // vaadinModality window must on top of others bringToFront(); } }); @@ -900,8 +900,8 @@ public class IWindow extends IToolkitOverlay implements Container, } else if (resizing) { onResizeEvent(event); return false; - } else if (modal) { - // return false when modal and outside window + } else if (vaadinModality) { + // return false when vaadinModality and outside window final Element target = event.getTarget().cast(); if (!DOM.isOrHasChild(getElement(), target)) { return false; -- cgit v1.2.3 From 751af0244bee05184cae27aeabd3223c25163983 Mon Sep 17 00:00:00 2001 From: Matti Tahvonen Date: Tue, 28 Apr 2009 11:05:56 +0000 Subject: fixed regression from [7545] svn changeset:7550/svn branch:6.0 --- src/com/itmill/toolkit/terminal/gwt/client/ui/IWindow.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/com/itmill/toolkit') 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 ddb2c7f6a0..e58b32ab30 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IWindow.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IWindow.java @@ -135,7 +135,7 @@ public class IWindow extends IToolkitOverlay implements Container, private boolean immediate; public IWindow() { - super(false, false, true); // no autohide, not vaadinModality, shadow + super(false, false, true); // no autohide, not modal, shadow // Different style of shadow for windows setShadowStyle("window"); @@ -239,7 +239,7 @@ public class IWindow extends IToolkitOverlay implements Container, } if (!uidl.hasAttribute("cached")) { - if (uidl.getBooleanAttribute("vaadinModality") != vaadinModality) { + if (uidl.getBooleanAttribute("modal") != vaadinModality) { setVaadinModality(!vaadinModality); } if (!isAttached()) { @@ -901,7 +901,7 @@ public class IWindow extends IToolkitOverlay implements Container, onResizeEvent(event); return false; } else if (vaadinModality) { - // return false when vaadinModality and outside window + // return false when modal and outside window final Element target = event.getTarget().cast(); if (!DOM.isOrHasChild(getElement(), target)) { return false; -- cgit v1.2.3 From 7dac3bdccea22bd357062d5726b1383647628a6b Mon Sep 17 00:00:00 2001 From: Matti Tahvonen Date: Tue, 28 Apr 2009 18:08:25 +0000 Subject: recatored shadow position handling, avoids regression when updating to GWT 1.6 svn changeset:7553/svn branch:6.0 --- .../terminal/gwt/client/ui/IToolkitOverlay.java | 24 ++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'src/com/itmill/toolkit') diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IToolkitOverlay.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IToolkitOverlay.java index 763d75c3af..0ea4f14133 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IToolkitOverlay.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IToolkitOverlay.java @@ -84,7 +84,9 @@ public class IToolkitOverlay extends PopupPanel { addPopupListener(new PopupListener() { public void onPopupClosed(PopupPanel sender, boolean autoClosed) { - DOM.removeChild(RootPanel.get().getElement(), shadow); + if (shadow.getParentElement() != null) { + shadow.getParentElement().removeChild(shadow); + } } }); } @@ -144,6 +146,15 @@ public class IToolkitOverlay extends PopupPanel { } } + @Override + public void setVisible(boolean visible) { + super.setVisible(visible); + if (shadow != null) { + shadow.getStyle().setProperty("visibility", + visible ? "visible" : "hidden"); + } + } + /* * Needed to position overlays on top of native SELECT elements in IE6. See * bug #2004 @@ -206,16 +217,16 @@ public class IToolkitOverlay extends PopupPanel { * A value between 0.0 and 1.0, indicating the progress of the * animation (0=start, 1=end). */ - private void updateShadowSizeAndPosition(double progress) { + private void updateShadowSizeAndPosition(final double progress) { // Don't do anything if overlay element is not attached - if (!isAttached() || !isVisible()) { + if (!isAttached()) { return; } // Calculate proper z-index String zIndex = null; try { - // Odd behaviour with Windows Hosted Mode forces us to use this - // redundant try/catch block (See dev.itmill.com #2011) + // Odd behaviour with Windows Hosted Mode forces us to use + // this redundant try/catch block (See dev.itmill.com #2011) zIndex = DOM.getStyleAttribute(getElement(), "zIndex"); } catch (Exception ignore) { // Ignored, will cause no harm @@ -255,7 +266,8 @@ public class IToolkitOverlay extends PopupPanel { width = (int) (width * progress); height = (int) (height * progress); - // Opera needs some shaking to get parts of the shadow showing properly + // Opera needs some shaking to get parts of the shadow showing + // properly // (ticket #2704) if (BrowserInfo.get().isOpera()) { // Clear the height of all middle elements -- cgit v1.2.3 From 4968f78a891c236744a8fcd0ed622d615d413cda Mon Sep 17 00:00:00 2001 From: Matti Tahvonen Date: Tue, 28 Apr 2009 18:14:06 +0000 Subject: refactored notification fading, avoids regression when updating to GWT 1.6. Also added generics for notificatio event listener list. svn changeset:7554/svn branch:6.0 --- .../terminal/gwt/client/ui/INotification.java | 41 +++++++++++++--------- 1 file changed, 25 insertions(+), 16 deletions(-) (limited to 'src/com/itmill/toolkit') diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/INotification.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/INotification.java index 1186f99ad5..2064fac824 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/INotification.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/INotification.java @@ -34,6 +34,7 @@ public class INotification extends IToolkitOverlay { private static final int mouseMoveThreshold = 7; private static final int Z_INDEX_BASE = 20000; public static final String STYLE_SYSTEM = "system"; + private static final int FADE_ANIMATION_INTERVAL = 50; // == 20 fps private int startOpacity = 90; private int fadeMsec = 400; @@ -47,7 +48,7 @@ public class INotification extends IToolkitOverlay { private String temporaryStyle; - private ArrayList listeners; + private ArrayList listeners; public INotification() { setStylePrimaryName(STYLENAME); @@ -130,17 +131,20 @@ public class INotification extends IToolkitOverlay { public void fade() { DOM.removeEventPreview(this); cancelDelay(); - final int msec = fadeMsec / (startOpacity / 5); fader = new Timer() { - long timestamp = 0; - int opacity = startOpacity; + private final long start = new Date().getTime(); @Override public void run() { - double adjust = (timestamp == 0 ? 1 - : (new Date().getTime() - timestamp) / msec); - opacity -= adjust * 5d; - setOpacity(getElement(), opacity); + /* + * To make animation smooth, don't count that event happens on + * time. Reduce opacity according to the actual time spent + * instead of fixed decrement. + */ + long now = new Date().getTime(); + long timeEplaced = now - start; + float remainingFraction = 1 - timeEplaced / (float) fadeMsec; + int opacity = (int) (startOpacity * remainingFraction); if (opacity <= 0) { cancel(); hide(); @@ -150,12 +154,12 @@ public class INotification extends IToolkitOverlay { DOM.setStyleAttribute(getElement(), "width", ""); DOM.setStyleAttribute(getElement(), "height", ""); } - + } else { + setOpacity(getElement(), opacity); } - timestamp = new Date().getTime(); } }; - fader.scheduleRepeating(msec); + fader.scheduleRepeating(FADE_ANIMATION_INTERVAL); } public void setPosition(int position) { @@ -219,8 +223,10 @@ public class INotification extends IToolkitOverlay { private void setOpacity(Element el, int opacity) { DOM.setStyleAttribute(el, "opacity", "" + (opacity / 100.0)); - DOM.setStyleAttribute(el, "filter", "Alpha(opacity=" + opacity + ")"); - + if (BrowserInfo.get().isIE()) { + DOM.setStyleAttribute(el, "filter", "Alpha(opacity=" + opacity + + ")"); + } } @Override @@ -279,7 +285,7 @@ public class INotification extends IToolkitOverlay { public void addEventListener(EventListener listener) { if (listeners == null) { - listeners = new ArrayList(); + listeners = new ArrayList(); } listeners.add(listener); } @@ -293,14 +299,17 @@ public class INotification extends IToolkitOverlay { private void fireEvent(HideEvent event) { if (listeners != null) { - for (Iterator it = listeners.iterator(); it.hasNext();) { - EventListener l = (EventListener) it.next(); + for (Iterator it = listeners.iterator(); it + .hasNext();) { + EventListener l = it.next(); l.notificationHidden(event); } } } public class HideEvent extends EventObject { + private static final long serialVersionUID = 4428671753988459560L; + public HideEvent(Object source) { super(source); } -- cgit v1.2.3 From a0133d3f26aff03d1c231f42375e5ca34b010fc1 Mon Sep 17 00:00:00 2001 From: Matti Tahvonen Date: Tue, 28 Apr 2009 18:33:58 +0000 Subject: sanity check to Notification animation, GWT 1.6 regression svn changeset:7556/svn branch:6.0 --- .../toolkit/terminal/gwt/client/ui/INotification.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/com/itmill/toolkit') diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/INotification.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/INotification.java index 2064fac824..8df846cfea 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/INotification.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/INotification.java @@ -70,13 +70,15 @@ public class INotification extends IToolkitOverlay { public void startDelay() { DOM.removeEventPreview(this); if (delayMsec > 0) { - delay = new Timer() { - @Override - public void run() { - fade(); - } - }; - delay.schedule(delayMsec); + if (delay == null) { + delay = new Timer() { + @Override + public void run() { + fade(); + } + }; + delay.schedule(delayMsec); + } } else if (delayMsec == 0) { fade(); } -- cgit v1.2.3 From 10de4fcca895564cbaeeae2753ff9c862c003126 Mon Sep 17 00:00:00 2001 From: Matti Tahvonen Date: Wed, 29 Apr 2009 08:11:09 +0000 Subject: Minor IScrolltable fixes. Extra scrollbar space in some situations and table height when paging off. svn changeset:7559/svn branch:6.0 --- .../toolkit/terminal/gwt/client/ui/IScrollTable.java | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'src/com/itmill/toolkit') 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 70bcc618a5..596b47a191 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IScrollTable.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IScrollTable.java @@ -15,7 +15,6 @@ import java.util.Vector; import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.NodeList; -import com.google.gwt.dom.client.Style; import com.google.gwt.dom.client.TableCellElement; import com.google.gwt.dom.client.TableRowElement; import com.google.gwt.dom.client.TableSectionElement; @@ -687,10 +686,12 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { */ if (pageLength == totalRows) { /* - * We want to show all rows so the bodyHeight should be equal to - * the table height + * A hack to support variable height rows when paging is off. + * Generally this is not supported by scrolltable. We want to + * show all rows so the bodyHeight should be equal to the table + * height. */ - int bodyHeight = tBody.getTableHeight(); + int bodyHeight = tBody.getOffsetHeight(); bodyContainer.setHeight(bodyHeight + "px"); Util.runWebkitOverflowAutoFix(bodyContainer.getElement()); } else { @@ -1838,12 +1839,8 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { } public int getAvailableWidth() { - Style style = bodyContainer.getElement().getStyle(); - style.setProperty("overflow", "hidden"); - int w = bodyContainer.getElement().getPropertyInt("clientWidth"); - style.setProperty("overflow", "auto"); - return w; - // return preSpacer.getOffsetWidth(); + int availW = bodyContainer.getOffsetWidth() - getBorderWidth(); + return availW; } public void renderInitialRows(UIDL rowData, int firstIndex, int rows) { -- cgit v1.2.3 From d452ea2fd4a476157e841cce1d232398727c4f18 Mon Sep 17 00:00:00 2001 From: Matti Tahvonen Date: Wed, 29 Apr 2009 08:55:45 +0000 Subject: small optimization to table (reduce calls to Container.size() method, that is expensive in some containers) svn changeset:7564/svn branch:6.0 --- src/com/itmill/toolkit/ui/Table.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/com/itmill/toolkit') diff --git a/src/com/itmill/toolkit/ui/Table.java b/src/com/itmill/toolkit/ui/Table.java index 083b393aa8..7ff6d53700 100644 --- a/src/com/itmill/toolkit/ui/Table.java +++ b/src/com/itmill/toolkit/ui/Table.java @@ -1107,12 +1107,18 @@ public class Table extends AbstractSelect implements Action.Container, newIndex = 0; } + /* + * minimize Container.size() calls which may be expensive. For example + * it may cause sql query. + */ + final int size = size(); + /* * The table is not capable of displaying an item in the container as * the first if there are not enough items following the selected item * so the whole table (pagelength) is filled. */ - int maxIndex = size() - pageLength; + int maxIndex = size - pageLength; if (maxIndex < 0) { maxIndex = 0; } @@ -1150,7 +1156,7 @@ public class Table extends AbstractSelect implements Action.Container, // If we did hit the border if (((Container.Ordered) items).isLastId(currentPageFirstItemId)) { - currentPageFirstItemIndex = size() - 1; + currentPageFirstItemIndex = size - 1; } // Go backwards in the middle of the list (respect borders) @@ -1179,7 +1185,7 @@ public class Table extends AbstractSelect implements Action.Container, // If for some reason we do hit border again, override // the user index request if (((Container.Ordered) items).isLastId(currentPageFirstItemId)) { - newIndex = currentPageFirstItemIndex = size() - 1; + newIndex = currentPageFirstItemIndex = size - 1; } } if (needsPageBufferReset) { -- cgit v1.2.3 From 8b0cf2389f1152f50cb38832f0b1d84b9e5cdbe4 Mon Sep 17 00:00:00 2001 From: Matti Tahvonen Date: Wed, 29 Apr 2009 09:15:20 +0000 Subject: iscrolltable fix for scrollbars on size change svn changeset:7568/svn branch:6.0 --- .../terminal/gwt/client/ui/IScrollTable.java | 33 +++++++++++++--------- 1 file changed, 20 insertions(+), 13 deletions(-) (limited to 'src/com/itmill/toolkit') 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 596b47a191..96d10fa7c3 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IScrollTable.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IScrollTable.java @@ -578,19 +578,7 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { tHead.disableBrowserIntelligence(); - boolean willHaveScrollbarz = false; - if (!(height != null && !height.equals(""))) { - if (pageLength < totalRows) { - willHaveScrollbarz = true; - } - } else { - int fakeheight = tBody.getRowHeight() * totalRows; - int availableHeight = bodyContainer.getElement().getPropertyInt( - "clientHeight"); - if (fakeheight > availableHeight) { - willHaveScrollbarz = true; - } - } + boolean willHaveScrollbarz = willHaveScrollbars(); // fix "natural" width if width not set if (width == null || "".equals(width)) { @@ -731,6 +719,22 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { initializedAndAttached = true; } + private boolean willHaveScrollbars() { + if (!(height != null && !height.equals(""))) { + if (pageLength < totalRows) { + return true; + } + } else { + int fakeheight = tBody.getRowHeight() * totalRows; + int availableHeight = bodyContainer.getElement().getPropertyInt( + "clientHeight"); + if (fakeheight > availableHeight) { + return true; + } + } + return false; + } + /** * This method has logic which rows needs to be requested from server when * user scrolls @@ -2708,6 +2712,9 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener { // Hey IE, are you really sure about this? availW = tBody.getAvailableWidth(); availW -= tBody.getCellExtraWidth() * visibleColOrder.length; + if (willHaveScrollbars()) { + availW -= Util.getNativeScrollbarSize(); + } int extraSpace = availW - usedMinimumWidth; if (extraSpace < 0) { -- cgit v1.2.3