summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/tabsheet/VTabsheet.java11
-rw-r--r--src/com/vaadin/ui/Table.java3
-rw-r--r--src/com/vaadin/ui/UniqueSerializable.java35
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/table/TableSerialization.java24
-rw-r--r--tests/server-side/com/vaadin/tests/util/UniqueSerializableTest.java33
5 files changed, 105 insertions, 1 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/ui/tabsheet/VTabsheet.java b/src/com/vaadin/terminal/gwt/client/ui/tabsheet/VTabsheet.java
index 6639781523..b63fe483ce 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/tabsheet/VTabsheet.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/tabsheet/VTabsheet.java
@@ -212,14 +212,17 @@ public class VTabsheet extends VTabsheetBase implements Focusable,
tabCaption.setWidth(tabCaption.getRequiredWidth() + "px");
}
+ @Override
public HandlerRegistration addFocusHandler(FocusHandler handler) {
return addDomHandler(handler, FocusEvent.getType());
}
+ @Override
public HandlerRegistration addBlurHandler(BlurHandler handler) {
return addDomHandler(handler, BlurEvent.getType());
}
+ @Override
public HandlerRegistration addKeyDownHandler(KeyDownHandler handler) {
return addDomHandler(handler, KeyDownEvent.getType());
}
@@ -331,6 +334,7 @@ public class VTabsheet extends VTabsheetBase implements Focusable,
}
return width;
}
+
public Element getCloseButton() {
return closeButton;
}
@@ -361,6 +365,7 @@ public class VTabsheet extends VTabsheetBase implements Focusable,
setElement(el);
}
+ @Override
public void onClose(VCloseEvent event) {
Tab tab = event.getTab();
if (!tab.isEnabledOnServer()) {
@@ -396,6 +401,7 @@ public class VTabsheet extends VTabsheetBase implements Focusable,
return t;
}
+ @Override
public void onClick(ClickEvent event) {
TabCaption caption = (TabCaption) event.getSource();
Element targetElement = event.getNativeEvent().getEventTarget()
@@ -1032,6 +1038,7 @@ public class VTabsheet extends VTabsheetBase implements Focusable,
final Style style = scroller.getStyle();
style.setProperty("whiteSpace", "normal");
Scheduler.get().scheduleDeferred(new Command() {
+ @Override
public void execute() {
style.setProperty("whiteSpace", "");
}
@@ -1116,6 +1123,7 @@ public class VTabsheet extends VTabsheetBase implements Focusable,
}
}
+ @Override
public void onBlur(BlurEvent event) {
if (focusedTab != null && event.getSource() instanceof Tab) {
focusedTab = null;
@@ -1125,6 +1133,7 @@ public class VTabsheet extends VTabsheetBase implements Focusable,
}
}
+ @Override
public void onFocus(FocusEvent event) {
if (focusedTab == null && event.getSource() instanceof Tab) {
focusedTab = (Tab) event.getSource();
@@ -1134,6 +1143,7 @@ public class VTabsheet extends VTabsheetBase implements Focusable,
}
}
+ @Override
public void focus() {
tb.getTab(activeTabIndex).focus();
}
@@ -1142,6 +1152,7 @@ public class VTabsheet extends VTabsheetBase implements Focusable,
tb.getTab(activeTabIndex).blur();
}
+ @Override
public void onKeyDown(KeyDownEvent event) {
if (event.getSource() instanceof Tab) {
int keycode = event.getNativeEvent().getKeyCode();
diff --git a/src/com/vaadin/ui/Table.java b/src/com/vaadin/ui/Table.java
index 8d5d4994c1..70d9570b01 100644
--- a/src/com/vaadin/ui/Table.java
+++ b/src/com/vaadin/ui/Table.java
@@ -331,7 +331,8 @@ public class Table extends AbstractSelect implements Action.Container,
private static final double CACHE_RATE_DEFAULT = 2;
private static final String ROW_HEADER_COLUMN_KEY = "0";
- private static final Object ROW_HEADER_FAKE_PROPERTY_ID = new Object();
+ private static final Object ROW_HEADER_FAKE_PROPERTY_ID = new UniqueSerializable() {
+ };
/* Private table extensions to Select */
diff --git a/src/com/vaadin/ui/UniqueSerializable.java b/src/com/vaadin/ui/UniqueSerializable.java
new file mode 100644
index 0000000000..f6f354ef58
--- /dev/null
+++ b/src/com/vaadin/ui/UniqueSerializable.java
@@ -0,0 +1,35 @@
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+package com.vaadin.ui;
+
+import java.io.Serializable;
+
+/**
+ * A base class for generating an unique object that is serializable.
+ * <p>
+ * This class is abstract but has no abstract methods to force users to create
+ * an anonymous inner class. Otherwise each instance will not be unique.
+ *
+ * @author Vaadin Ltd
+ * @version @VERSION@
+ * @since 7.0
+ *
+ */
+public abstract class UniqueSerializable implements Serializable {
+
+ public static UniqueSerializable create() {
+ return new UniqueSerializable() {
+ };
+ }
+
+ @Override
+ public int hashCode() {
+ return getClass().hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return getClass() == obj.getClass();
+ }
+}
diff --git a/tests/server-side/com/vaadin/tests/server/component/table/TableSerialization.java b/tests/server-side/com/vaadin/tests/server/component/table/TableSerialization.java
new file mode 100644
index 0000000000..44dcd60fa5
--- /dev/null
+++ b/tests/server-side/com/vaadin/tests/server/component/table/TableSerialization.java
@@ -0,0 +1,24 @@
+package com.vaadin.tests.server.component.table;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.lang.SerializationUtils;
+
+import com.vaadin.ui.Table;
+
+public class TableSerialization extends TestCase {
+
+ public void testSerialization() {
+ Table t = new Table();
+ byte[] ser = SerializationUtils.serialize(t);
+ Table t2 = (Table) SerializationUtils.deserialize(ser);
+
+ }
+ public void testSerializationWithRowHeaders() {
+ Table t = new Table();
+ t.setRowHeaderMode(Table.ROW_HEADER_MODE_EXPLICIT);
+ t.setColumnWidth(null, 100);
+ byte[] ser = SerializationUtils.serialize(t);
+ Table t2 = (Table) SerializationUtils.deserialize(ser);
+ }
+}
diff --git a/tests/server-side/com/vaadin/tests/util/UniqueSerializableTest.java b/tests/server-side/com/vaadin/tests/util/UniqueSerializableTest.java
new file mode 100644
index 0000000000..578d983c4d
--- /dev/null
+++ b/tests/server-side/com/vaadin/tests/util/UniqueSerializableTest.java
@@ -0,0 +1,33 @@
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+package com.vaadin.tests.util;
+
+import java.io.Serializable;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.lang.SerializationUtils;
+
+import com.vaadin.ui.UniqueSerializable;
+
+public class UniqueSerializableTest extends TestCase implements Serializable {
+
+ public void testUniqueness() {
+ UniqueSerializable o1 = new UniqueSerializable() {
+ };
+ UniqueSerializable o2 = new UniqueSerializable() {
+ };
+ assertFalse(o1 == o2);
+ assertFalse(o1.equals(o2));
+ }
+
+ public void testSerialization() {
+ UniqueSerializable o1 = new UniqueSerializable() {
+ };
+ UniqueSerializable d1 = (UniqueSerializable) SerializationUtils
+ .deserialize(SerializationUtils.serialize(o1));
+ assertTrue(d1.equals(o1));
+ }
+
+}