summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--build/build.xml5
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VButton.java14
-rw-r--r--src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java2
-rw-r--r--src/com/vaadin/ui/Table.java8
-rw-r--r--tests/src/com/vaadin/tests/components/ComponentTestCase.java41
-rw-r--r--tests/src/com/vaadin/tests/components/table/Tables.java410
-rw-r--r--tests/src/com/vaadin/tests/util/Log.java2
7 files changed, 462 insertions, 20 deletions
diff --git a/build/build.xml b/build/build.xml
index e7cad185aa..6bcaa2d2af 100644
--- a/build/build.xml
+++ b/build/build.xml
@@ -658,7 +658,7 @@
<target name="compile-widgetset" description="Compiles the widgetset given as the first parameter">
<fail unless="widgetset" message="No widgetset parameter set"/>
<echo>Compiling widgetset ${widgetset}. Output directory: ${widgetsets-output-dir}</echo>
- <java classname="com.google.gwt.dev.Compiler" failonerror="yes" fork="yes" maxmemory="128m">
+ <java classname="com.google.gwt.dev.Compiler" failonerror="yes" fork="yes" maxmemory="512m">
<classpath refid="widgetset-compile-classpath"/>
<arg value="-war" />
@@ -668,7 +668,8 @@
<arg value="${widgetset}" />
<jvmarg value="-Xss8M"/>
- <jvmarg value="-Djava.awt.headless=true"/>
+ <jvmarg value="-XX:MaxPermSize=256M"/>
+ <jvmarg value="-Djava.awt.headless=true"/>
</java>
<antcall target="remove-widgetset-gwt-tmp"/>
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VButton.java b/src/com/vaadin/terminal/gwt/client/ui/VButton.java
index d537997fbc..5a5eb0eda6 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VButton.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VButton.java
@@ -34,6 +34,11 @@ public class VButton extends FocusWidget implements Paintable, ClickHandler,
public static final String CLASSNAME = "v-button";
private static final String CLASSNAME_PRESSED = "v-pressed";
+ // mouse movement is checked before synthesizing click event on mouseout
+ protected static int MOVE_THRESHOLD = 3;
+ protected int mousedownX = 0;
+ protected int mousedownY = 0;
+
protected String id;
protected ApplicationConnection client;
@@ -204,6 +209,11 @@ public class VButton extends FocusWidget implements Paintable, ClickHandler,
break;
case Event.ONMOUSEDOWN:
if (event.getButton() == Event.BUTTON_LEFT) {
+ // save mouse position to detect movement before synthesizing
+ // event later
+ mousedownX = event.getClientX();
+ mousedownY = event.getClientY();
+
disallowNextClick = true;
clickPending = true;
setFocus(true);
@@ -240,7 +250,9 @@ public class VButton extends FocusWidget implements Paintable, ClickHandler,
Element to = event.getRelatedTarget();
if (getElement().isOrHasChild(DOM.eventGetTarget(event))
&& (to == null || !getElement().isOrHasChild(to))) {
- if (clickPending) {
+ if (clickPending
+ && Math.abs(mousedownX - event.getClientX()) < MOVE_THRESHOLD
+ && Math.abs(mousedownY - event.getClientY()) < MOVE_THRESHOLD) {
onClick();
break;
}
diff --git a/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java b/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java
index 407b0dae77..8f806ef693 100644
--- a/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java
+++ b/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java
@@ -1009,7 +1009,7 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet
String widgetsetURL = getWidgetsetURL(widgetset, request);
writer.write("document.write('<iframe tabIndex=\"-1\" id=\"__gwt_historyFrame\" "
+ "style=\"position:absolute;width:0;height:0;border:0;overflow:"
- + "hidden;\" src=\"javascript:false\"></iframe>');\n");
+ + "hidden;opacity:0;top:-100px;left:-100px;\" src=\"javascript:false\"></iframe>');\n");
writer.write("document.write(\"<script language='javascript' src='"
+ widgetsetURL + "'><\\/script>\");\n}\n");
}
diff --git a/src/com/vaadin/ui/Table.java b/src/com/vaadin/ui/Table.java
index 790c44d09e..12f69ec606 100644
--- a/src/com/vaadin/ui/Table.java
+++ b/src/com/vaadin/ui/Table.java
@@ -1036,9 +1036,9 @@ public class Table extends AbstractSelect implements Action.Container,
if (header == null) {
columnHeaders.remove(propertyId);
- return;
+ } else {
+ columnHeaders.put(propertyId, header);
}
- columnHeaders.put(propertyId, header);
// Assures the visual refresh
// FIXME: Is this really needed? Header captions should not affect
@@ -4006,9 +4006,9 @@ public class Table extends AbstractSelect implements Action.Container,
public void setColumnFooter(Object propertyId, String footer) {
if (footer == null) {
columnFooters.remove(propertyId);
- return;
+ } else {
+ columnFooters.put(propertyId, footer);
}
- columnFooters.put(propertyId, footer);
requestRepaint();
}
diff --git a/tests/src/com/vaadin/tests/components/ComponentTestCase.java b/tests/src/com/vaadin/tests/components/ComponentTestCase.java
index 883812159a..580662ef0d 100644
--- a/tests/src/com/vaadin/tests/components/ComponentTestCase.java
+++ b/tests/src/com/vaadin/tests/components/ComponentTestCase.java
@@ -8,6 +8,7 @@ import com.vaadin.data.Item;
import com.vaadin.data.Property;
import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.terminal.UserError;
+import com.vaadin.tests.util.Log;
import com.vaadin.ui.AbstractComponent;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
@@ -31,6 +32,8 @@ public abstract class ComponentTestCase<T extends AbstractComponent> extends
abstract protected void initializeComponents();
+ private Log log = null;
+
@Override
protected final void setup() {
((SpacingHandler) getLayout()).setSpacing(true);
@@ -222,16 +225,6 @@ public abstract class ComponentTestCase<T extends AbstractComponent> extends
select.addContainerProperty(VALUE, Object.class, "");
select.setItemCaptionPropertyId(CAPTION);
select.setNullSelectionAllowed(false);
- for (String itemCaption : options.keySet()) {
- Object itemId = new Object();
- Item i = select.addItem(itemId);
- i.getItemProperty(CAPTION).setValue(itemCaption);
- i.getItemProperty(VALUE).setValue(options.get(itemCaption));
- if (itemCaption.equals(initialValue)) {
- select.setValue(itemId);
- }
-
- }
select.addListener(new Property.ValueChangeListener() {
public void valueChange(ValueChangeEvent event) {
@@ -244,7 +237,17 @@ public abstract class ComponentTestCase<T extends AbstractComponent> extends
}
});
- select.setValue(initialValue);
+ for (String itemCaption : options.keySet()) {
+ Object itemId = new Object();
+ Item i = select.addItem(itemId);
+ i.getItemProperty(CAPTION).setValue(itemCaption);
+ i.getItemProperty(VALUE).setValue(options.get(itemCaption));
+ if (itemCaption.equals(initialValue)) {
+ select.setValue(itemId);
+ }
+
+ }
+
select.setDebugId("selectaction-" + caption);
select.setImmediate(true);
@@ -256,4 +259,20 @@ public abstract class ComponentTestCase<T extends AbstractComponent> extends
protected String getDescription() {
return "Generic test case for " + getTestClass().getSimpleName();
}
+
+ protected void enableLog() {
+ if (log == null) {
+ log = new Log(5).setNumberLogRows(true);
+ getLayout().addComponent(log, 1);
+ }
+
+ }
+
+ protected void log(String msg) {
+ if (log == null) {
+ throw new IllegalStateException(
+ "Use enableLog() before calling log()");
+ }
+ log.log(msg);
+ }
}
diff --git a/tests/src/com/vaadin/tests/components/table/Tables.java b/tests/src/com/vaadin/tests/components/table/Tables.java
new file mode 100644
index 0000000000..a9dee06adf
--- /dev/null
+++ b/tests/src/com/vaadin/tests/components/table/Tables.java
@@ -0,0 +1,410 @@
+package com.vaadin.tests.components.table;
+
+import java.util.LinkedHashMap;
+import java.util.List;
+
+import com.vaadin.data.Container;
+import com.vaadin.data.Item;
+import com.vaadin.data.util.IndexedContainer;
+import com.vaadin.event.ItemClickEvent;
+import com.vaadin.event.ItemClickEvent.ItemClickListener;
+import com.vaadin.tests.components.ComponentTestCase;
+import com.vaadin.ui.AbstractSelect.MultiSelectMode;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.Table.ColumnResizeEvent;
+import com.vaadin.ui.Table.ColumnResizeListener;
+import com.vaadin.ui.Table.FooterClickEvent;
+import com.vaadin.ui.Table.FooterClickListener;
+import com.vaadin.ui.Table.HeaderClickEvent;
+import com.vaadin.ui.Table.HeaderClickListener;
+
+public class Tables extends ComponentTestCase<Table> implements
+ ItemClickListener, HeaderClickListener, FooterClickListener,
+ ColumnResizeListener {
+
+ @Override
+ protected Class<Table> getTestClass() {
+ return Table.class;
+ }
+
+ @Override
+ protected void initializeComponents() {
+ addTestComponent(createTable());
+ enableLog();
+
+ }
+
+ private Table createTable() {
+ Table t = new Table();
+ return t;
+ }
+
+ private Container createContainer(int properties, int items) {
+ IndexedContainer c = new IndexedContainer();
+ for (int i = 1; i <= properties; i++) {
+ c.addContainerProperty("Column " + i, String.class, "");
+ }
+ for (int i = 1; i <= items; i++) {
+ Item item = c.addItem("Item " + i);
+ for (int j = 1; j <= properties; j++) {
+ item.getItemProperty("Column " + j).setValue(
+ "Item " + i + "," + j);
+ }
+ }
+
+ return c;
+ }
+
+ @Override
+ protected void createCustomActions(List<Component> actions) {
+ actions.add(createNullSelectCheckbox());
+ actions.add(createWidthSelect());
+ actions.add(createHeightSelect());
+ actions.add(createPageLengthSelect());
+ actions.add(createItemsInContainerSelect());
+ actions.add(createColumnsInContainerSelect());
+ actions.add(createSelectionModeSelect());
+ actions.add(createItemClickListenerCheckbox());
+ actions.add(createColumnResizeListenerCheckbox());
+
+ actions.add(createRowHeaderModeSelect());
+
+ actions.add(createHeaderVisibilitySelect());
+ actions.add(createHeaderClickListenerCheckbox());
+ actions.add(createHeaderTextCheckbox());
+
+ actions.add(createFooterVisibilityCheckbox());
+ actions.add(createFooterClickListenerCheckbox());
+ actions.add(createFooterTextCheckbox());
+
+ }
+
+ private Component createRowHeaderModeSelect() {
+ LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
+ options.put("Explicit", Table.ROW_HEADER_MODE_EXPLICIT);
+ options.put("Explicit defaults id",
+ Table.ROW_HEADER_MODE_EXPLICIT_DEFAULTS_ID);
+ options.put("Hidden", Table.ROW_HEADER_MODE_HIDDEN);
+ options.put("Icon only", Table.ROW_HEADER_MODE_ICON_ONLY);
+ options.put("Id", Table.ROW_HEADER_MODE_ID);
+ options.put("Index", Table.ROW_HEADER_MODE_INDEX);
+ options.put("Item", Table.ROW_HEADER_MODE_ITEM);
+ options.put("'Column 3' property", Table.ROW_HEADER_MODE_PROPERTY);
+
+ return super.createSelectAction("Row header mode", options, "Hidden",
+ new Command<Table, Integer>() {
+
+ public void execute(Table c, Integer value) {
+ if (value == Table.ROW_HEADER_MODE_PROPERTY) {
+ c.setItemCaptionPropertyId("Column 3");
+ }
+ c.setRowHeaderMode(value);
+
+ }
+ });
+ }
+
+ private Component createFooterTextCheckbox() {
+ return super.createCheckboxAction("Texts in footer", false,
+ new Command<Table, Boolean>() {
+
+ public void execute(Table c, Boolean value) {
+ for (Object propertyId : c.getContainerPropertyIds()) {
+ if (value) {
+ c.setColumnFooter(propertyId, "Footer: "
+ + propertyId);
+ } else {
+ c.setColumnFooter(propertyId, null);
+
+ }
+ }
+
+ }
+ });
+ }
+
+ private Component createHeaderTextCheckbox() {
+ return super.createCheckboxAction("Texts in header", false,
+ new Command<Table, Boolean>() {
+
+ public void execute(Table c, Boolean value) {
+ for (Object propertyId : c.getContainerPropertyIds()) {
+ if (value) {
+ c.setColumnHeader(propertyId, "Header: "
+ + propertyId);
+ } else {
+ c.setColumnHeader(propertyId, null);
+
+ }
+ }
+
+ }
+ });
+ }
+
+ private Component createItemClickListenerCheckbox() {
+ return super.createCheckboxAction("Item click listener", false,
+ new Command<Table, Boolean>() {
+
+ public void execute(Table c, Boolean value) {
+ if (value) {
+ c.addListener((ItemClickListener) Tables.this);
+ } else {
+ c.removeListener((ItemClickListener) Tables.this);
+ }
+
+ }
+ });
+ }
+
+ private Component createHeaderClickListenerCheckbox() {
+ return super.createCheckboxAction("Header click listener", false,
+ new Command<Table, Boolean>() {
+
+ public void execute(Table c, Boolean value) {
+ if (value) {
+ c.addListener((HeaderClickListener) Tables.this);
+ } else {
+ c.removeListener((HeaderClickListener) Tables.this);
+ }
+
+ }
+ });
+ }
+
+ private Component createFooterClickListenerCheckbox() {
+ return super.createCheckboxAction("Footer click listener", false,
+ new Command<Table, Boolean>() {
+
+ public void execute(Table c, Boolean value) {
+ if (value) {
+ c.addListener((FooterClickListener) Tables.this);
+ } else {
+ c.removeListener((FooterClickListener) Tables.this);
+ }
+
+ }
+ });
+ }
+
+ private Component createColumnResizeListenerCheckbox() {
+ return super.createCheckboxAction("Column resize listener", false,
+ new Command<Table, Boolean>() {
+
+ public void execute(Table c, Boolean value) {
+ if (value) {
+ c.addListener((ColumnResizeListener) Tables.this);
+ } else {
+ c.removeListener((ColumnResizeListener) Tables.this);
+ }
+
+ }
+ });
+ }
+
+ // TODO:
+ // Visible columns
+ // Column headers
+ // Column footers
+ // Column icons
+ // Column alignments
+ // Column width
+ // Column expand ratio
+ // Column collapse
+ // Column reordering allowed
+ // Column collapsing allowed
+ // setCurrentPageFirstItemIndex()
+ // setColumnHeaderMode(int)
+ // setRowHeaderMode(int)
+ // Generated column
+ // Cell style generator
+ // Editable
+ // Context menu
+
+ // Cache rate
+ // CurrentPageFirstItemId
+ private Component createNullSelectCheckbox() {
+ return super.createCheckboxAction("NullSelection", false,
+ new Command<Table, Boolean>() {
+
+ public void execute(Table c, Boolean value) {
+ c.setNullSelectionAllowed(value);
+ }
+ });
+ }
+
+ private Component createFooterVisibilityCheckbox() {
+ return createCheckboxAction("Footer visible", true,
+ new Command<Table, Boolean>() {
+
+ public void execute(Table c, Boolean value) {
+ c.setFooterVisible(value);
+ }
+ });
+ }
+
+ private Component createHeaderVisibilitySelect() {
+ LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
+ options.put("Explicit", Table.COLUMN_HEADER_MODE_EXPLICIT);
+ options.put("Explicit defaults id",
+ Table.COLUMN_HEADER_MODE_EXPLICIT_DEFAULTS_ID);
+ options.put("Id", Table.COLUMN_HEADER_MODE_ID);
+ options.put("Hidden", Table.COLUMN_HEADER_MODE_HIDDEN);
+
+ return createSelectAction("Header mode", options,
+ "Explicit defaults id", new Command<Table, Integer>() {
+
+ public void execute(Table c, Integer value) {
+ c.setColumnHeaderMode(value);
+
+ }
+ });
+ }
+
+ protected Component createWidthSelect() {
+ LinkedHashMap<String, String> options = new LinkedHashMap<String, String>();
+ options.put("Undefined", null);
+ options.put("200px", "200px");
+ options.put("500px", "500px");
+ options.put("800px", "800px");
+
+ return super.createSelectAction("Width", options, "Undefined",
+ new Command<Table, String>() {
+
+ public void execute(Table t, String value) {
+ t.setWidth(value);
+ }
+ });
+ }
+
+ protected Component createHeightSelect() {
+ LinkedHashMap<String, String> options = new LinkedHashMap<String, String>();
+ options.put("Undefined", null);
+ options.put("200px", "200px");
+ options.put("500px", "500px");
+ options.put("800px", "800px");
+
+ return super.createSelectAction("Height", options, "Undefined",
+ new Command<Table, String>() {
+
+ public void execute(Table t, String value) {
+ t.setHeight(value);
+ }
+ });
+ }
+
+ protected Component createPageLengthSelect() {
+ LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
+ options.put("0", 0);
+ options.put("5", 5);
+ options.put("10", 10);
+ options.put("20", 20);
+ options.put("50", 50);
+
+ return super.createSelectAction("PageLength", options, "10",
+ new Command<Table, Integer>() {
+
+ public void execute(Table t, Integer value) {
+ t.setPageLength(value);
+ }
+ });
+ }
+
+ protected Component createItemsInContainerSelect() {
+ LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
+ options.put("0", 0);
+ options.put("20", 20);
+ options.put("100", 100);
+ options.put("1000", 1000);
+ options.put("10000", 10000);
+ options.put("100000", 100000);
+
+ return super.createSelectAction("Items in container", options, "20",
+ new Command<Table, Integer>() {
+
+ public void execute(Table t, Integer value) {
+ t.setContainerDataSource(createContainer(t
+ .getContainerDataSource()
+ .getContainerPropertyIds().size(), value));
+ }
+ });
+ }
+
+ protected Component createColumnsInContainerSelect() {
+ LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
+ options.put("0", 0);
+ options.put("5", 5);
+ options.put("10", 10);
+ options.put("50", 50);
+ options.put("100", 100);
+ options.put("1000", 1000);
+
+ return super.createSelectAction("Columns in container", options, "10",
+ new Command<Table, Integer>() {
+
+ public void execute(Table t, Integer value) {
+ t.setContainerDataSource(createContainer(value, t
+ .getContainerDataSource().size()));
+ }
+ });
+ }
+
+ private enum SelectMode {
+ NONE, SINGLE, MULTI_SIMPLE, MULTI;
+ }
+
+ protected Component createSelectionModeSelect() {
+ LinkedHashMap<String, SelectMode> options = new LinkedHashMap<String, SelectMode>();
+ options.put("None", SelectMode.NONE);
+ options.put("Single", SelectMode.SINGLE);
+ options.put("Multi - simple", SelectMode.MULTI_SIMPLE);
+ options.put("Multi - ctrl/shift", SelectMode.MULTI);
+
+ return super.createSelectAction("Selection Mode", options,
+ "Multi - ctrl/shift", new Command<Table, SelectMode>() {
+
+ public void execute(Table t, SelectMode value) {
+ switch (value) {
+ case NONE:
+ t.setSelectable(false);
+ break;
+ case SINGLE:
+ t.setMultiSelect(false);
+ t.setSelectable(true);
+ break;
+ case MULTI_SIMPLE:
+ t.setSelectable(true);
+ t.setMultiSelect(true);
+ t.setMultiSelectMode(MultiSelectMode.SIMPLE);
+ break;
+ case MULTI:
+ t.setSelectable(true);
+ t.setMultiSelect(true);
+ t.setMultiSelectMode(MultiSelectMode.DEFAULT);
+ break;
+ }
+ }
+ });
+ }
+
+ public void columnResize(ColumnResizeEvent event) {
+ log("ColumnResize on " + event.getPropertyId() + " from "
+ + event.getPreviousWidth() + " to " + event.getCurrentWidth());
+ }
+
+ public void footerClick(FooterClickEvent event) {
+ log("FooterClick on " + event.getPropertyId() + " using "
+ + event.getButtonName());
+ }
+
+ public void headerClick(HeaderClickEvent event) {
+ log("HeaderClick on " + event.getPropertyId() + " using "
+ + event.getButtonName());
+ }
+
+ public void itemClick(ItemClickEvent event) {
+ log("ItemClick on " + event.getPropertyId() + " using "
+ + event.getButtonName());
+ }
+}
diff --git a/tests/src/com/vaadin/tests/util/Log.java b/tests/src/com/vaadin/tests/util/Log.java
index e991fe1787..a8e6a10ffc 100644
--- a/tests/src/com/vaadin/tests/util/Log.java
+++ b/tests/src/com/vaadin/tests/util/Log.java
@@ -17,7 +17,7 @@ public class Log extends VerticalLayout {
eventLabels.add(l);
addComponent(l);
}
-
+ setDebugId("Log");
setCaption("Events:");
}