From d90f3ed208c5b5f8f6580afa95f8f22125361c2b Mon Sep 17 00:00:00 2001
From: Johannes Dahlström
Date: Mon, 9 Jan 2012 14:42:26 +0000
Subject: Add Firefox 9 and Chrome 16 to tested browsers, remove Firefox 4-8,
Chrome 15
svn changeset:22557/svn branch:6.8
---
tests/integration_tests.xml | 2 +-
tests/test.xml | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
(limited to 'tests')
diff --git a/tests/integration_tests.xml b/tests/integration_tests.xml
index 46b6653a23..5984097880 100644
--- a/tests/integration_tests.xml
+++ b/tests/integration_tests.xml
@@ -9,7 +9,7 @@
-
+
diff --git a/tests/test.xml b/tests/test.xml
index 46819970f8..f09c115fec 100644
--- a/tests/test.xml
+++ b/tests/test.xml
@@ -5,7 +5,7 @@
-
+
--
cgit v1.2.3
From 4f6bc36661f0d07a6bafd7af3a0cd386f3ab9675 Mon Sep 17 00:00:00 2001
From: Johannes Dahlström
Date: Thu, 12 Jan 2012 11:17:28 +0000
Subject: Merge from 6.7
svn changeset:22607/svn branch:6.8
---
WebContent/release-notes.html | 23 +--
src/com/vaadin/terminal/gwt/client/Util.java | 2 +
.../terminal/gwt/client/ui/VScrollTable.java | 35 ++--
.../vaadin/terminal/gwt/client/ui/VTextArea.java | 7 +
src/com/vaadin/terminal/gwt/client/ui/VView.java | 8 +
src/com/vaadin/ui/Table.java | 10 ++
.../orderedlayout/OrderedLayoutCases.java | 197 +++++++++++++++++++++
.../table/ScrollDetachSynchronization.java | 91 ++++++++++
.../tests/components/table/TableHeaderZoom.java | 10 +-
.../table/TableRepaintWhenMadeVisibile.java | 43 +++++
.../table/TableRepaintWhenMadeVisible.html | 42 +++++
.../tabsheet/WrapTabSheetInTabSheet.java | 42 +++++
.../textarea/TextAreaCursorPosition.java | 54 ++++++
.../TextFieldInputPromptAndClickShortcut.java | 57 ++++++
14 files changed, 579 insertions(+), 42 deletions(-)
create mode 100644 tests/testbench/com/vaadin/tests/components/orderedlayout/OrderedLayoutCases.java
create mode 100644 tests/testbench/com/vaadin/tests/components/table/ScrollDetachSynchronization.java
create mode 100644 tests/testbench/com/vaadin/tests/components/table/TableRepaintWhenMadeVisibile.java
create mode 100644 tests/testbench/com/vaadin/tests/components/table/TableRepaintWhenMadeVisible.html
create mode 100644 tests/testbench/com/vaadin/tests/components/tabsheet/WrapTabSheetInTabSheet.java
create mode 100644 tests/testbench/com/vaadin/tests/components/textarea/TextAreaCursorPosition.java
create mode 100644 tests/testbench/com/vaadin/tests/components/textfield/TextFieldInputPromptAndClickShortcut.java
(limited to 'tests')
diff --git a/WebContent/release-notes.html b/WebContent/release-notes.html
index 2fe8083556..8813bc343d 100644
--- a/WebContent/release-notes.html
+++ b/WebContent/release-notes.html
@@ -340,25 +340,6 @@
6.2.0 release notes for more details.
-
-
-
-
- Known problems and limitations in Vaadin
- @version@
-
-
-
- #1155 :
- Uncompressing the installation package fails in Windows if using
- the default Zip uncompression. Uncompression gives (in Windows
- Vista) an error message about too long filenames, and a more
- obscure message in other versions of Windows. Workaround: use 7-Zip or some other good unzip
- program for Windows.
-
-
-
Notes and Limitations for Google App Engine
The following instructions and limitations apply when you run a
@@ -480,11 +461,11 @@
- Mozilla Firefox 3-8
+ Mozilla Firefox 3-9
Internet Explorer 6-9
Safari 4-5
Opera 10-11
- Google Chrome 13-15
+ Google Chrome 13-16
diff --git a/src/com/vaadin/terminal/gwt/client/Util.java b/src/com/vaadin/terminal/gwt/client/Util.java
index a72c9c1dc2..3dbbd22329 100644
--- a/src/com/vaadin/terminal/gwt/client/Util.java
+++ b/src/com/vaadin/terminal/gwt/client/Util.java
@@ -1080,6 +1080,8 @@ public class Util {
VConsole.log("\t\t" + var[1] + " (" + var[2] + ")" + " : "
+ var[0]);
}
+ } else {
+ VConsole.log("\t" + id + ": Warning: no corresponding paintable!");
}
}
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java
index f1c1927b26..553934bf98 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java
@@ -2292,26 +2292,17 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
* of the caption container element by the correct amount
*/
public void resizeCaptionContainer(int rightSpacing) {
+
+ int captionContainerWidth = width
+ - colResizeWidget.getOffsetWidth() - rightSpacing;
+
if (BrowserInfo.get().isIE6() || td.getClassName().contains("-asc")
|| td.getClassName().contains("-desc")) {
- /*
- * Room for the sort indicator is made by subtracting the styled
- * margin and width of the resizer from the width of the caption
- * container.
- */
- int captionContainerWidth = width
- - sortIndicator.getOffsetWidth()
- - colResizeWidget.getOffsetWidth() - rightSpacing;
- captionContainer.getStyle().setPropertyPx("width",
- captionContainerWidth);
- } else {
- /*
- * Set the caption container element as wide as possible when
- * the sorting indicator is not visible.
- */
- captionContainer.getStyle().setPropertyPx("width",
- width - rightSpacing);
+ // Leave room for the sort indicator
+ captionContainerWidth -= sortIndicator.getOffsetWidth();
}
+ captionContainer.getStyle().setPropertyPx("width",
+ captionContainerWidth);
// Apply/Remove spacing if defined
if (rightSpacing > 0) {
@@ -6071,7 +6062,15 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
public void onScroll(ScrollEvent event) {
scrollLeft = scrollBodyPanel.getElement().getScrollLeft();
scrollTop = scrollBodyPanel.getScrollPosition();
- if (!initializedAndAttached) {
+ /*
+ * #6970 - IE sometimes fires scroll events for a detached table.
+ *
+ * FIXME initializedAndAttached should probably be renamed - its name
+ * doesn't seem to reflect its semantics. onDetach() doesn't set it to
+ * false, and changing that might break something else, so we need to
+ * check isAttached() separately.
+ */
+ if (!initializedAndAttached || !isAttached()) {
return;
}
if (!enabled) {
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VTextArea.java b/src/com/vaadin/terminal/gwt/client/ui/VTextArea.java
index a74fd9f5dc..cd09e24d67 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VTextArea.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VTextArea.java
@@ -69,4 +69,11 @@ public class VTextArea extends VTextField {
super.onBrowserEvent(event);
}
+ @Override
+ public int getCursorPos() {
+ // This is needed so that TextBoxImplIE6 is used to return the correct
+ // position for old Internet Explorer versions where it has to be
+ // detected in a different way.
+ return getImpl().getTextAreaCursorPos(getElement());
+ }
}
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VView.java b/src/com/vaadin/terminal/gwt/client/ui/VView.java
index f21c0aaac0..07ade6a8b1 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VView.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VView.java
@@ -591,6 +591,11 @@ public class VView extends SimplePanel implements Container, ResizeHandler,
String ownAppId = connection.getConfiguration().getRootPanelId();
+ // Hiding elements causes browser to forget scroll position -> must
+ // save values and restore when the elements are visible again #7976
+ int originalScrollTop = Window.getScrollTop();
+ int originalScrollLeft = Window.getScrollLeft();
+
// Set display: none for all Vaadin apps
for (int i = 0; i < vaadinApps.size(); i++) {
String appId = vaadinApps.get(i);
@@ -629,6 +634,9 @@ public class VView extends SimplePanel implements Container, ResizeHandler,
}
}
+ // Scroll back to original location
+ Window.scrollTo(originalScrollLeft, originalScrollTop);
+
return w;
}
diff --git a/src/com/vaadin/ui/Table.java b/src/com/vaadin/ui/Table.java
index b7235dd37b..d8c59c2e91 100644
--- a/src/com/vaadin/ui/Table.java
+++ b/src/com/vaadin/ui/Table.java
@@ -5148,4 +5148,14 @@ public class Table extends AbstractSelect implements Action.Container,
public RowGenerator getRowGenerator() {
return rowGenerator;
}
+
+ @Override
+ public void setVisible(boolean visible) {
+ if (!isVisible() && visible) {
+ // We need to ensure that the rows are sent to the client when the
+ // Table is made visible if it has been rendered as invisible.
+ setRowCacheInvalidated(true);
+ }
+ super.setVisible(visible);
+ }
}
diff --git a/tests/testbench/com/vaadin/tests/components/orderedlayout/OrderedLayoutCases.java b/tests/testbench/com/vaadin/tests/components/orderedlayout/OrderedLayoutCases.java
new file mode 100644
index 0000000000..d8b01c4099
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/components/orderedlayout/OrderedLayoutCases.java
@@ -0,0 +1,197 @@
+package com.vaadin.tests.components.orderedlayout;
+
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.tests.util.TestUtils;
+import com.vaadin.ui.AbstractOrderedLayout;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.NativeSelect;
+import com.vaadin.ui.VerticalLayout;
+
+public class OrderedLayoutCases extends TestBase {
+ private static final String[] dimensionValues = { "-1px", "5px", "300px",
+ "800px", "100%", "50%" };
+
+ private static class SampleChild extends VerticalLayout {
+ public SampleChild() {
+ setStyleName("showBorders");
+ addComponent(createSimpleSelector("Child width",
+ new ValueChangeListener() {
+ public void valueChange(ValueChangeEvent event) {
+ setWidth(event.getProperty().getValue().toString());
+ }
+ }, dimensionValues));
+ addComponent(createSimpleSelector("Child height",
+ new ValueChangeListener() {
+ public void valueChange(ValueChangeEvent event) {
+ setHeight(event.getProperty().getValue().toString());
+ }
+ }, dimensionValues));
+ addComponent(createSimpleSelector("Caption",
+ new ValueChangeListener() {
+ public void valueChange(ValueChangeEvent event) {
+ String value = event.getProperty().getValue()
+ .toString();
+ if (value.length() == 0) {
+ setCaption(null);
+ } else if (value.equals("Long")) {
+ setCaption("A rather long caption just to see what happens");
+ } else {
+ setCaption(value);
+ }
+ }
+ }, "", "Short", "Long"));
+
+ addComponent(createSimpleSelector("Expand ratio",
+ new ValueChangeListener() {
+ public void valueChange(ValueChangeEvent event) {
+ AbstractOrderedLayout parent = (AbstractOrderedLayout) getParent();
+ if (parent == null) {
+ return;
+ }
+ String value = event.getProperty().getValue()
+ .toString();
+ parent.setExpandRatio(SampleChild.this,
+ Float.parseFloat(value));
+ }
+ }, "0", "1", "2"));
+
+ // Why is Alignment not an enum? Now we have to use reflection just
+ // to get the different values as hardcoding is never an option! ;)
+ List alignmentValues = new ArrayList();
+ Field[] fields = Alignment.class.getDeclaredFields();
+ for (Field field : fields) {
+ if (field.getType() == Alignment.class) {
+ alignmentValues.add(field.getName());
+ }
+ }
+ addComponent(createSimpleSelector("Alignment",
+ new ValueChangeListener() {
+ public void valueChange(ValueChangeEvent event) {
+ String value = event.getProperty().getValue()
+ .toString();
+ AlignmentHandler parent = (AlignmentHandler) getParent();
+ if (parent == null) {
+ return;
+ }
+ try {
+ Field field = Alignment.class
+ .getDeclaredField(value);
+ Alignment alignment = (Alignment) field
+ .get(null);
+ parent.setComponentAlignment(SampleChild.this,
+ alignment);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }, alignmentValues, "TOP_LEFT")); // Sorry for not using
+ // more reflection magic
+ // just to find the
+ // default value...
+
+ }
+ }
+
+ private AbstractOrderedLayout currentLayout;
+
+ @Override
+ public void setup() {
+ TestUtils.injectCSS(getMainWindow(),
+ ".showBorders {border: 1px solid black};");
+
+ currentLayout = new HorizontalLayout();
+ for (int i = 0; i < 3; i++) {
+ currentLayout.addComponent(new SampleChild());
+ }
+
+ HorizontalLayout sizeBar = new HorizontalLayout();
+ sizeBar.setSpacing(true);
+
+ sizeBar.addComponent(createSimpleSelector("Layout width",
+ new ValueChangeListener() {
+ public void valueChange(ValueChangeEvent event) {
+ currentLayout.setWidth(event.getProperty().getValue()
+ .toString());
+ }
+ }, dimensionValues));
+ sizeBar.addComponent(createSimpleSelector("Layout height",
+ new ValueChangeListener() {
+ public void valueChange(ValueChangeEvent event) {
+ currentLayout.setHeight(event.getProperty().getValue()
+ .toString());
+ }
+ }, dimensionValues));
+ sizeBar.addComponent(createSimpleSelector("Direction",
+ new ValueChangeListener() {
+ public void valueChange(ValueChangeEvent event) {
+ Object value = event.getProperty().getValue();
+
+ AbstractOrderedLayout newLayout;
+ if (value.equals("Horizontal")) {
+ newLayout = new HorizontalLayout();
+ } else {
+ newLayout = new VerticalLayout();
+ }
+
+ while (currentLayout.getComponentCount() > 0) {
+ newLayout.addComponent(currentLayout
+ .getComponent(0));
+ }
+ newLayout.setStyleName("showBorders");
+
+ newLayout.setHeight(currentLayout.getHeight(),
+ currentLayout.getHeightUnits());
+ newLayout.setWidth(currentLayout.getWidth(),
+ currentLayout.getWidthUnits());
+
+ getLayout().replaceComponent(currentLayout, newLayout);
+ currentLayout = newLayout;
+ }
+ }, "Horizontal", "Vertical"));
+
+ addComponent(sizeBar);
+ addComponent(currentLayout);
+
+ getLayout().setSpacing(true);
+ getMainWindow().getContent().setSizeFull();
+ getLayout().setSizeFull();
+ getLayout().setExpandRatio(currentLayout, 1);
+ }
+
+ private static NativeSelect createSimpleSelector(String caption,
+ ValueChangeListener listener, String... values) {
+ return createSimpleSelector(caption, listener, Arrays.asList(values),
+ values[0]);
+ }
+
+ private static NativeSelect createSimpleSelector(String caption,
+ ValueChangeListener listener, List values,
+ String defaultValue) {
+ NativeSelect selector = new NativeSelect(caption, values);
+ selector.setNullSelectionAllowed(false);
+ selector.setImmediate(true);
+ selector.addListener(listener);
+ selector.setValue(defaultValue);
+ return selector;
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Tester application for exploring how Horizontal/VerticalLayout reacts to various settings ";
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/table/ScrollDetachSynchronization.java b/tests/testbench/com/vaadin/tests/components/table/ScrollDetachSynchronization.java
new file mode 100644
index 0000000000..fe99cfaf2a
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/components/table/ScrollDetachSynchronization.java
@@ -0,0 +1,91 @@
+package com.vaadin.tests.components.table;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Layout;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class ScrollDetachSynchronization extends TestBase {
+
+ @Override
+ public void setup() {
+ Window mainWindow = new Window("Synctest Application");
+ mainWindow.setContent(buildLayout());
+ setMainWindow(mainWindow);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Scrolling, then detaching, a table causes out of sync on IE";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 6970;
+ }
+
+ private Layout buildLayout() {
+ final VerticalLayout mainLayout = new VerticalLayout();
+ mainLayout.setSizeFull();
+
+ HorizontalLayout buttonBar = new HorizontalLayout();
+ buttonBar.setSizeUndefined();
+ Button first = new Button("First layout");
+ Button second = new Button("Second layout");
+ first.setDebugId("FirstButton");
+ second.setDebugId("SecondButton");
+ buttonBar.addComponent(first);
+ buttonBar.addComponent(second);
+ mainLayout.addComponent(buttonBar);
+
+ final HorizontalLayout firstLayout = buildTestLayout(true);
+ final HorizontalLayout secondLayout = buildTestLayout(false);
+
+ mainLayout.addComponent(firstLayout);
+ mainLayout.setExpandRatio(firstLayout, 1);
+
+ first.addListener(new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ if (mainLayout.getComponent(1).equals(secondLayout)) {
+ mainLayout.replaceComponent(secondLayout, firstLayout);
+ mainLayout.setExpandRatio(firstLayout, 1);
+ }
+ }
+ });
+ second.addListener(new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ if (mainLayout.getComponent(1).equals(firstLayout)) {
+ mainLayout.replaceComponent(firstLayout, secondLayout);
+ mainLayout.setExpandRatio(secondLayout, 1);
+ }
+ }
+ });
+ return mainLayout;
+ }
+
+ private HorizontalLayout buildTestLayout(boolean first) {
+ String which = first ? "First" : "Second";
+
+ HorizontalLayout hl = new HorizontalLayout();
+ hl.setSizeFull();
+ hl.setDebugId(which + "Layout");
+
+ Table t = new Table();
+ t.addContainerProperty("name", String.class, null);
+ for (int i = 0; i < 10; i++) {
+ String id = which + " " + i;
+ t.addItem(new String[] { id }, id);
+ }
+ t.setDebugId(which + "Table");
+ t.setItemCaptionPropertyId("name");
+ t.setSizeFull();
+
+ hl.addComponent(t);
+
+ return hl;
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/components/table/TableHeaderZoom.java b/tests/testbench/com/vaadin/tests/components/table/TableHeaderZoom.java
index 90a9191036..f7d85f1a3c 100644
--- a/tests/testbench/com/vaadin/tests/components/table/TableHeaderZoom.java
+++ b/tests/testbench/com/vaadin/tests/components/table/TableHeaderZoom.java
@@ -10,10 +10,14 @@ public class TableHeaderZoom extends TestBase {
@Override
protected void setup() {
Table table = new Table();
- table.setHeight("100px");
- table.setWidth("200px");
- table.setEnabled(false);
+ table.setHeight("400px");
+ table.setWidth("400px");
table.addContainerProperty("Column 1", String.class, "");
+ table.addContainerProperty("Column 2", String.class, "");
+
+ for (int i = 0; i < 100; ++i) {
+ table.addItem(new Object[] { "" + i, "foo" }, i);
+ }
Window main = getMainWindow();
main.setContent(new CssLayout());
diff --git a/tests/testbench/com/vaadin/tests/components/table/TableRepaintWhenMadeVisibile.java b/tests/testbench/com/vaadin/tests/components/table/TableRepaintWhenMadeVisibile.java
new file mode 100644
index 0000000000..a536303061
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/components/table/TableRepaintWhenMadeVisibile.java
@@ -0,0 +1,43 @@
+package com.vaadin.tests.components.table;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.Table;
+
+public class TableRepaintWhenMadeVisibile extends TestBase {
+
+ @Override
+ public void setup() {
+ final Table table = new Table();
+ table.addContainerProperty("sth", String.class, null);
+ table.addItem(new Object[] { "something" }, 1);
+ addComponent(table);
+
+ Button show = new Button("show", new ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ table.setVisible(true);
+ }
+ });
+ addComponent(show);
+ Button hide = new Button("hide", new ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ table.setVisible(false);
+ }
+ });
+ addComponent(hide);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "A Table should be rendered correctly when made visible again after being initially rendered invisible. Click 'hide', refresh the application and then click 'show'";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 7986;
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/components/table/TableRepaintWhenMadeVisible.html b/tests/testbench/com/vaadin/tests/components/table/TableRepaintWhenMadeVisible.html
new file mode 100644
index 0000000000..0563acd4a5
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/components/table/TableRepaintWhenMadeVisible.html
@@ -0,0 +1,42 @@
+
+
+
+
+
+
+New Test
+
+
+
+
+New Test
+
+
+ open
+ /run/com.vaadin.tests.components.table.TableRepaintWhenMadeVisibile?restartApplication
+
+
+
+ click
+ vaadin=runcomvaadintestscomponentstableTableRepaintWhenMadeVisibile::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
+
+
+
+ open
+ /run/com.vaadin.tests.components.table.TableRepaintWhenMadeVisibile
+
+
+
+ click
+ vaadin=runcomvaadintestscomponentstableTableRepaintWhenMadeVisibile::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
+
+
+
+ screenCapture
+
+ hidden-then-shown
+
+
+
+
+
diff --git a/tests/testbench/com/vaadin/tests/components/tabsheet/WrapTabSheetInTabSheet.java b/tests/testbench/com/vaadin/tests/components/tabsheet/WrapTabSheetInTabSheet.java
new file mode 100644
index 0000000000..e5947576a2
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/components/tabsheet/WrapTabSheetInTabSheet.java
@@ -0,0 +1,42 @@
+package com.vaadin.tests.components.tabsheet;
+
+import com.vaadin.Application;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.ComponentContainer;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.TabSheet;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class WrapTabSheetInTabSheet extends TestBase {
+ @Override
+ protected void setup() {
+ final VerticalLayout mainLayout = new VerticalLayout();
+ mainLayout.addComponent(new Label("This is main layout"));
+ addComponent(mainLayout);
+
+ Button b = new Button("Wrap main layout in a TabSheet");
+ b.addListener(new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ TabSheet tabsheet = new TabSheet();
+ ComponentContainer mainParent = (ComponentContainer) mainLayout
+ .getParent();
+ mainParent.replaceComponent(mainLayout, tabsheet);
+ tabsheet.addTab(mainLayout, "Default tab");
+ }
+ });
+ mainLayout.addComponent(b);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Click the button to add a TabSheet and move the window content into the TabSheet. Every click should wrap the contents with a new TabSheet and the contents should remain visible.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 8238;
+ }
+}
diff --git a/tests/testbench/com/vaadin/tests/components/textarea/TextAreaCursorPosition.java b/tests/testbench/com/vaadin/tests/components/textarea/TextAreaCursorPosition.java
new file mode 100644
index 0000000000..0fc63860e1
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/components/textarea/TextAreaCursorPosition.java
@@ -0,0 +1,54 @@
+package com.vaadin.tests.components.textarea;
+
+import com.vaadin.event.FieldEvents.TextChangeEvent;
+import com.vaadin.event.FieldEvents.TextChangeListener;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.AbstractField;
+import com.vaadin.ui.AbstractTextField;
+import com.vaadin.ui.AbstractTextField.TextChangeEventMode;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.TextArea;
+import com.vaadin.ui.TextField;
+
+public class TextAreaCursorPosition extends TestBase {
+
+ private TextField cursorPosition = new TextField("Cursor position");
+
+ @Override
+ public void setup() {
+ Label label = new Label(
+ "Test of calculation of cursor position of TextArea");
+ TextArea textArea = new TextArea();
+ addListener(textArea);
+ addComponent(label);
+ addComponent(textArea);
+ addComponent(cursorPosition);
+ cursorPosition.setValue("?");
+ addComponent(new Button("Force position update"));
+ }
+
+ public void addListener(AbstractField newField) {
+ AbstractTextField newTextField = (AbstractTextField) newField;
+ newTextField.setTextChangeEventMode(TextChangeEventMode.EAGER);
+
+ newTextField.addListener(new TextChangeListener() {
+ public void textChange(TextChangeEvent event) {
+ AbstractTextField component = (AbstractTextField) event
+ .getComponent();
+ cursorPosition.setValue(component.getCursorPosition());
+ }
+ });
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Writing something in the field updates the cursor position field. The position field can also be updated using the button.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 7726;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/textfield/TextFieldInputPromptAndClickShortcut.java b/tests/testbench/com/vaadin/tests/components/textfield/TextFieldInputPromptAndClickShortcut.java
new file mode 100644
index 0000000000..6aac7caddd
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/components/textfield/TextFieldInputPromptAndClickShortcut.java
@@ -0,0 +1,57 @@
+package com.vaadin.tests.components.textfield;
+
+import com.vaadin.event.ShortcutAction.KeyCode;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.tests.util.Log;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.CheckBox;
+import com.vaadin.ui.TextField;
+
+public class TextFieldInputPromptAndClickShortcut extends TestBase {
+
+ @Override
+ protected void setup() {
+ final Log log = new Log(5);
+
+ final TextField textField = new TextField();
+ Button button = new Button("Show Text", new ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ log.log("Field value: " + textField.getValue());
+ }
+ });
+ button.setClickShortcut(KeyCode.ESCAPE);
+
+ final CheckBox inputPromptSelection = new CheckBox("Input prompt",
+ new ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ if (event.getButton().getValue() == Boolean.TRUE) {
+ textField.setInputPrompt("Input prompt");
+ } else {
+ textField.setInputPrompt(null);
+ }
+ log.log("Set input prompt: "
+ + textField.getInputPrompt());
+ }
+ });
+ inputPromptSelection.setImmediate(true);
+
+ addComponent(textField);
+ addComponent(button);
+ addComponent(inputPromptSelection);
+ addComponent(log);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "With the input propmpt enabled, enter something into the field, press enter, remove the entered text and press the button. The previous text is still reported as the value. Without the input prompt, the new value is instead reported as blank.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
--
cgit v1.2.3
From c661750fbc7149becd34548ac3a0a844df39b3b7 Mon Sep 17 00:00:00 2001
From: Artur Signell
Date: Thu, 12 Jan 2012 16:22:25 +0000
Subject: #7614 Added getComponent(int) and getComponentIndex(Component) to
CssLayout
svn changeset:22620/svn branch:6.8
---
src/com/vaadin/ui/CssLayout.java | 26 ++++++-
.../AbstractIndexedLayoutTest.java | 84 ++++++++++++++++++++++
.../server/componentcontainer/CssLayoutTest.java | 34 +++++++++
.../server/componentcontainer/FormLayoutTest.java | 34 +++++++++
.../componentcontainer/VerticalLayoutTest.java | 34 +++++++++
5 files changed, 211 insertions(+), 1 deletion(-)
create mode 100644 tests/server-side/com/vaadin/tests/server/componentcontainer/AbstractIndexedLayoutTest.java
create mode 100644 tests/server-side/com/vaadin/tests/server/componentcontainer/CssLayoutTest.java
create mode 100644 tests/server-side/com/vaadin/tests/server/componentcontainer/FormLayoutTest.java
create mode 100644 tests/server-side/com/vaadin/tests/server/componentcontainer/VerticalLayoutTest.java
(limited to 'tests')
diff --git a/src/com/vaadin/ui/CssLayout.java b/src/com/vaadin/ui/CssLayout.java
index b952609b20..b9432df6b6 100644
--- a/src/com/vaadin/ui/CssLayout.java
+++ b/src/com/vaadin/ui/CssLayout.java
@@ -125,7 +125,7 @@ public class CssLayout extends AbstractLayout implements LayoutClickNotifier {
// see ticket #7668
if (c.getParent() == this) {
// When c is removed, all components after it are shifted down
- if (index > components.indexOf(c)) {
+ if (index > getComponentIndex(c)) {
index--;
}
removeComponent(c);
@@ -275,4 +275,28 @@ public class CssLayout extends AbstractLayout implements LayoutClickNotifier {
removeListener(CLICK_EVENT, LayoutClickEvent.class, listener);
}
+ /**
+ * Returns the index of the given component.
+ *
+ * @param component
+ * The component to look up.
+ * @return The index of the component or -1 if the component is not a child.
+ */
+ public int getComponentIndex(Component component) {
+ return components.indexOf(component);
+ }
+
+ /**
+ * Returns the component at the given position.
+ *
+ * @param index
+ * The position of the component.
+ * @return The component at the given index.
+ * @throws IndexOutOfBoundsException
+ * If the index is out of range.
+ */
+ public Component getComponent(int index) throws IndexOutOfBoundsException {
+ return components.get(index);
+ }
+
}
diff --git a/tests/server-side/com/vaadin/tests/server/componentcontainer/AbstractIndexedLayoutTest.java b/tests/server-side/com/vaadin/tests/server/componentcontainer/AbstractIndexedLayoutTest.java
new file mode 100644
index 0000000000..9271e9f1b3
--- /dev/null
+++ b/tests/server-side/com/vaadin/tests/server/componentcontainer/AbstractIndexedLayoutTest.java
@@ -0,0 +1,84 @@
+package com.vaadin.tests.server.componentcontainer;
+
+import junit.framework.TestCase;
+
+import com.vaadin.ui.Component;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Layout;
+
+public abstract class AbstractIndexedLayoutTest extends TestCase {
+
+ private Layout layout;
+
+ protected abstract Layout createLayout();
+
+ @Override
+ protected void setUp() throws Exception {
+ layout = createLayout();
+ }
+
+ public Layout getLayout() {
+ return layout;
+ }
+
+ public void testAddRemoveComponent() {
+ Label c1 = new Label();
+ Label c2 = new Label();
+
+ layout.addComponent(c1);
+
+ assertEquals(c1, getComponent(0));
+ assertEquals(1, getComponentCount());
+ layout.addComponent(c2);
+ assertEquals(c1, getComponent(0));
+ assertEquals(c2, getComponent(1));
+ assertEquals(2, getComponentCount());
+ layout.removeComponent(c1);
+ assertEquals(c2, getComponent(0));
+ assertEquals(1, getComponentCount());
+ layout.removeComponent(c2);
+ assertEquals(0, getComponentCount());
+ }
+
+ protected abstract int getComponentCount();
+
+ protected abstract Component getComponent(int index);
+
+ protected abstract int getComponentIndex(Component c);
+
+ public void testGetComponentIndex() {
+ Label c1 = new Label();
+ Label c2 = new Label();
+
+ layout.addComponent(c1);
+ assertEquals(0, getComponentIndex(c1));
+ layout.addComponent(c2);
+ assertEquals(0, getComponentIndex(c1));
+ assertEquals(1, getComponentIndex(c2));
+ layout.removeComponent(c1);
+ assertEquals(0, getComponentIndex(c2));
+ layout.removeComponent(c2);
+ assertEquals(-1, getComponentIndex(c2));
+ assertEquals(-1, getComponentIndex(c1));
+ }
+
+ public void testGetComponent() {
+ Label c1 = new Label();
+ Label c2 = new Label();
+
+ layout.addComponent(c1);
+ assertEquals(c1, getComponent(0));
+ layout.addComponent(c2);
+ assertEquals(c1, getComponent(0));
+ assertEquals(c2, getComponent(1));
+ layout.removeComponent(c1);
+ assertEquals(c2, getComponent(0));
+ layout.removeComponent(c2);
+ try {
+ getComponent(0);
+ fail();
+ } catch (IndexOutOfBoundsException e) {
+ // Expected
+ }
+ }
+}
diff --git a/tests/server-side/com/vaadin/tests/server/componentcontainer/CssLayoutTest.java b/tests/server-side/com/vaadin/tests/server/componentcontainer/CssLayoutTest.java
new file mode 100644
index 0000000000..dc9667c38e
--- /dev/null
+++ b/tests/server-side/com/vaadin/tests/server/componentcontainer/CssLayoutTest.java
@@ -0,0 +1,34 @@
+package com.vaadin.tests.server.componentcontainer;
+
+import com.vaadin.ui.Component;
+import com.vaadin.ui.CssLayout;
+import com.vaadin.ui.Layout;
+
+public class CssLayoutTest extends AbstractIndexedLayoutTest {
+
+ @Override
+ protected Layout createLayout() {
+ return new CssLayout();
+ }
+
+ @Override
+ public CssLayout getLayout() {
+ return (CssLayout) super.getLayout();
+ }
+
+ @Override
+ protected Component getComponent(int index) {
+ return getLayout().getComponent(index);
+ }
+
+ @Override
+ protected int getComponentIndex(Component c) {
+ return getLayout().getComponentIndex(c);
+ }
+
+ @Override
+ protected int getComponentCount() {
+ return getLayout().getComponentCount();
+ }
+
+}
diff --git a/tests/server-side/com/vaadin/tests/server/componentcontainer/FormLayoutTest.java b/tests/server-side/com/vaadin/tests/server/componentcontainer/FormLayoutTest.java
new file mode 100644
index 0000000000..71a813d423
--- /dev/null
+++ b/tests/server-side/com/vaadin/tests/server/componentcontainer/FormLayoutTest.java
@@ -0,0 +1,34 @@
+package com.vaadin.tests.server.componentcontainer;
+
+import com.vaadin.ui.Component;
+import com.vaadin.ui.FormLayout;
+import com.vaadin.ui.Layout;
+
+public class FormLayoutTest extends AbstractIndexedLayoutTest {
+
+ @Override
+ protected Layout createLayout() {
+ return new FormLayout();
+ }
+
+ @Override
+ public FormLayout getLayout() {
+ return (FormLayout) super.getLayout();
+ }
+
+ @Override
+ protected Component getComponent(int index) {
+ return getLayout().getComponent(index);
+ }
+
+ @Override
+ protected int getComponentIndex(Component c) {
+ return getLayout().getComponentIndex(c);
+ }
+
+ @Override
+ protected int getComponentCount() {
+ return getLayout().getComponentCount();
+ }
+
+}
diff --git a/tests/server-side/com/vaadin/tests/server/componentcontainer/VerticalLayoutTest.java b/tests/server-side/com/vaadin/tests/server/componentcontainer/VerticalLayoutTest.java
new file mode 100644
index 0000000000..0e3a1d5734
--- /dev/null
+++ b/tests/server-side/com/vaadin/tests/server/componentcontainer/VerticalLayoutTest.java
@@ -0,0 +1,34 @@
+package com.vaadin.tests.server.componentcontainer;
+
+import com.vaadin.ui.Component;
+import com.vaadin.ui.Layout;
+import com.vaadin.ui.VerticalLayout;
+
+public class VerticalLayoutTest extends AbstractIndexedLayoutTest {
+
+ @Override
+ protected Layout createLayout() {
+ return new VerticalLayout();
+ }
+
+ @Override
+ public VerticalLayout getLayout() {
+ return (VerticalLayout) super.getLayout();
+ }
+
+ @Override
+ protected Component getComponent(int index) {
+ return getLayout().getComponent(index);
+ }
+
+ @Override
+ protected int getComponentIndex(Component c) {
+ return getLayout().getComponentIndex(c);
+ }
+
+ @Override
+ protected int getComponentCount() {
+ return getLayout().getComponentCount();
+ }
+
+}
--
cgit v1.2.3
From 326ccadd49971a36bcf4c356f114eba70a4e337f Mon Sep 17 00:00:00 2001
From: Johannes Dahlström
Date: Mon, 16 Jan 2012 07:01:28 +0000
Subject: Merged #8105 Compile core files and test files to separate folders
svn changeset:22636/svn branch:6.8
---
build/build.properties | 2 +-
build/build.xml | 207 +++++++++---------
src/com/vaadin/launcher/util/BrowserLauncher.java | 127 -----------
.../com/vaadin/tests/VaadinClasses.java | 236 +++++++++++++++++++++
.../com/vaadin/launcher/util/BrowserLauncher.java | 127 +++++++++++
tests/testbench/com/vaadin/tests/Components.java | 17 +-
.../testbench/com/vaadin/tests/VaadinClasses.java | 235 --------------------
7 files changed, 480 insertions(+), 471 deletions(-)
delete mode 100644 src/com/vaadin/launcher/util/BrowserLauncher.java
create mode 100644 tests/server-side/com/vaadin/tests/VaadinClasses.java
create mode 100644 tests/testbench/com/vaadin/launcher/util/BrowserLauncher.java
delete mode 100644 tests/testbench/com/vaadin/tests/VaadinClasses.java
(limited to 'tests')
diff --git a/build/build.properties b/build/build.properties
index 82378c6dac..9e126a4479 100644
--- a/build/build.properties
+++ b/build/build.properties
@@ -2,7 +2,7 @@ result-path=build/result
checkout-path=build/checkout
product-file=vaadin
product-name=Vaadin
-toolkit-package=com/vaadin
+vaadin-package=com/vaadin
gwt-dir=lib/core/gwt
# repository into which Maven snapshots should be published
diff --git a/build/build.xml b/build/build.xml
index 8c3ee1d04a..1fdcc0ee25 100644
--- a/build/build.xml
+++ b/build/build.xml
@@ -43,14 +43,32 @@
uri="antlib:org.apache.maven.artifact.ant"
classpathref="maven-ant-tasks.classpath" />
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -86,7 +104,7 @@
-
+
@@ -95,9 +113,6 @@
-
-
-
@@ -109,17 +124,16 @@
Full Version: ${version.full}
-
- Vaadin package is: ${toolkit-package}
+ Vaadin package is: ${vaadin-package}
-
-
+
+
We are using gwt version ${gwt-version}.
@@ -185,13 +199,17 @@
Adding test class files and resources and launcher configuration.
-
-
-
+
+
+
+
+
+
+
-
+
@@ -201,8 +219,8 @@
-
-
+
+
@@ -258,11 +276,11 @@
-
+
-
-
-
-
+
+
+
+
@@ -316,7 +339,7 @@
Copying src directory and processing copied files.
Replacing <version> tag with build version for java/html/css/xml files.
-
+
@@ -324,13 +347,13 @@
-
+
-
+
@@ -346,17 +369,17 @@
Copying non java/html/css/xml files such as images.
-
+
-
+
-
+
@@ -383,12 +406,11 @@
- Adding VAADIN/themes, demo and hsqldb.jar files.
+ Adding VAADIN/themes and META-INF
-
@@ -431,20 +453,37 @@
-
+
Compiling src (server-side)
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+ Compiling src (Server and client side JUnit tests)
+
+
+
+
+
+
+
+ Compiling src (TestBench tests)
+
+
+
+
+
+
+
-
+
@@ -488,7 +527,7 @@
-
+
@@ -496,8 +535,8 @@
-
-
+
+
@@ -551,12 +590,7 @@
-
-
-
-
-
-
+
@@ -588,18 +622,14 @@
${gwt-version}
-
-
-
-
-
@@ -617,24 +647,10 @@
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
-
-
-
+
@@ -665,7 +681,7 @@
-
+
@@ -692,9 +708,7 @@
-
-
-
+
${javadoc.doctitle}
${javadoc.bottom}
@@ -784,7 +798,7 @@
-
+
@@ -793,8 +807,6 @@
-
-
Base version: ${version}
Build number: ${build.number}
Build tag: ${build.tag}
@@ -924,7 +936,7 @@
-
+
@@ -944,7 +956,7 @@
-
+
@@ -957,38 +969,35 @@
-
+
-
+ merge="false"
+ >
-
-
-
-
-
+
-
-
+
+
+
-
+
-
+
@@ -1040,7 +1049,7 @@
-
+
diff --git a/src/com/vaadin/launcher/util/BrowserLauncher.java b/src/com/vaadin/launcher/util/BrowserLauncher.java
deleted file mode 100644
index 55692cb251..0000000000
--- a/src/com/vaadin/launcher/util/BrowserLauncher.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
-@VaadinApache2LicenseForJavaFiles@
- */
-
-package com.vaadin.launcher.util;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStreamReader;
-
-/**
- * This class opens default browser for DemoLauncher class. Default browser is
- * detected by the operating system.
- *
- */
-public class BrowserLauncher {
-
- /**
- * Open browser on specified URL.
- *
- * @param url
- */
- public static void openBrowser(String url) {
-
- final Runtime runtime = Runtime.getRuntime();
- boolean started = false;
-
- final String os = System.getProperty("os.name", "windows")
- .toLowerCase();
-
- // Linux
- if (os.indexOf("linux") >= 0) {
- // See if the default browser is Konqueror by resolving the symlink.
- boolean isDefaultKonqueror = false;
- try {
- // Find out the location of the x-www-browser link from path.
- Process process = runtime.exec("which x-www-browser");
- BufferedInputStream ins = new BufferedInputStream(
- process.getInputStream());
- BufferedReader bufreader = new BufferedReader(
- new InputStreamReader(ins));
- String defaultLinkPath = bufreader.readLine();
- ins.close();
-
- // The path is null if the link did not exist.
- if (defaultLinkPath != null) {
- // See if the default browser is Konqueror.
- File file = new File(defaultLinkPath);
- String canonical = file.getCanonicalPath();
- if (canonical.indexOf("konqueror") != -1) {
- isDefaultKonqueror = true;
- }
- }
- } catch (IOException e1) {
- // The symlink was probably not found, so this is ok.
- }
-
- // Try x-www-browser, which is symlink to the default browser,
- // except if we found that it is Konqueror.
- if (!started && !isDefaultKonqueror) {
- try {
- runtime.exec("x-www-browser " + url);
- started = true;
- } catch (final IOException e) {
- }
- }
-
- // Try firefox
- if (!started) {
- try {
- runtime.exec("firefox " + url);
- started = true;
- } catch (final IOException e) {
- }
- }
-
- // Try mozilla
- if (!started) {
- try {
- runtime.exec("mozilla " + url);
- started = true;
- } catch (final IOException e) {
- }
- }
-
- // Try konqueror
- if (!started) {
- try {
- runtime.exec("konqueror " + url);
- started = true;
- } catch (final IOException e) {
- }
- }
- }
-
- // OS X
- if (os.indexOf("mac os x") >= 0) {
-
- // Try open
- if (!started) {
- try {
- runtime.exec("open " + url);
- started = true;
- } catch (final IOException e) {
- }
- }
- }
-
- // Try cmd /start command on windows
- if (os.indexOf("win") >= 0) {
- if (!started) {
- try {
- runtime.exec("cmd /c start " + url);
- started = true;
- } catch (final IOException e) {
- }
- }
- }
-
- if (!started) {
- System.out.println("Failed to open browser. Please go to " + url);
- }
- }
-
-}
diff --git a/tests/server-side/com/vaadin/tests/VaadinClasses.java b/tests/server-side/com/vaadin/tests/VaadinClasses.java
new file mode 100644
index 0000000000..e02c4f0b6e
--- /dev/null
+++ b/tests/server-side/com/vaadin/tests/VaadinClasses.java
@@ -0,0 +1,236 @@
+package com.vaadin.tests;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.net.JarURLConnection;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.jar.JarEntry;
+
+import org.junit.Test;
+
+import com.vaadin.Application;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.ComponentContainer;
+import com.vaadin.ui.CustomComponent;
+import com.vaadin.ui.DragAndDropWrapper;
+import com.vaadin.ui.HorizontalSplitPanel;
+import com.vaadin.ui.LoginForm;
+import com.vaadin.ui.PopupView;
+import com.vaadin.ui.SplitPanel;
+import com.vaadin.ui.VerticalSplitPanel;
+import com.vaadin.ui.Window;
+
+@SuppressWarnings("deprecation")
+public class VaadinClasses {
+
+ public static void main(String[] args) {
+ System.out.println("ComponentContainers");
+ System.out.println("===================");
+ for (Class extends ComponentContainer> c : getComponentContainers()) {
+ System.out.println(c.getName());
+ }
+ System.out.println();
+ System.out.println("Components");
+ System.out.println("==========");
+ for (Class extends Component> c : getComponents()) {
+ System.out.println(c.getName());
+ }
+ System.out.println();
+ System.out.println("Server side classes");
+ System.out.println("===================");
+ for (Class> c : getAllServerSideClasses()) {
+ System.out.println(c.getName());
+ }
+ }
+
+ public static List> getComponents() {
+ try {
+ return findClasses(Component.class, "com.vaadin.ui");
+ } catch (IOException e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ public static List> getAllServerSideClasses() {
+ try {
+ return findClassesNoTests(Object.class, "com.vaadin", new String[] {
+ "com.vaadin.tests", "com.vaadin.terminal.gwt.client" });
+ } catch (IOException e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ public static List> getComponentContainers() {
+ try {
+ return findClasses(ComponentContainer.class, "com.vaadin.ui");
+ } catch (IOException e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ public static List> getComponentContainersSupportingAddRemoveComponent() {
+ List> classes = getComponentContainers();
+ classes.remove(PopupView.class);
+ classes.remove(CustomComponent.class);
+ classes.remove(DragAndDropWrapper.class);
+ classes.remove(CustomComponent.class);
+ classes.remove(LoginForm.class);
+
+ return classes;
+ }
+
+ public static List> getComponentContainersSupportingUnlimitedNumberOfComponents() {
+ List> classes = getComponentContainersSupportingAddRemoveComponent();
+ classes.remove(SplitPanel.class);
+ classes.remove(VerticalSplitPanel.class);
+ classes.remove(HorizontalSplitPanel.class);
+ classes.remove(Window.class);
+
+ return classes;
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public static List> getBasicComponentTests() {
+ try {
+ // Given as name to avoid dependencies on testbench source folder
+ return (List) findClasses(
+ Class.forName("com.vaadin.tests.components.AbstractComponentTest"),
+ "com.vaadin.tests.components");
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+
+ }
+
+ private static List> findClasses(Class baseClass,
+ String basePackage) throws IOException {
+ return findClasses(baseClass, basePackage, new String[] {});
+ }
+
+ private static List> findClasses(Class baseClass,
+ String basePackage, String[] ignoredPackages) throws IOException {
+ List> classes = new ArrayList>();
+ String basePackageDirName = "/" + basePackage.replace('.', '/');
+ URL location = Application.class.getResource(basePackageDirName);
+ if (location.getProtocol().equals("file")) {
+ try {
+ File f = new File(location.toURI());
+ if (!f.exists()) {
+ throw new IOException("Directory " + f.toString()
+ + " does not exist");
+ }
+ findPackages(f, basePackage, baseClass, classes,
+ ignoredPackages);
+ } catch (URISyntaxException e) {
+ throw new IOException(e.getMessage());
+ }
+ } else if (location.getProtocol().equals("jar")) {
+ JarURLConnection juc = (JarURLConnection) location.openConnection();
+ findPackages(juc, basePackage, baseClass, classes);
+ }
+
+ Collections.sort(classes, new Comparator>() {
+
+ public int compare(Class extends T> o1, Class extends T> o2) {
+ return o1.getName().compareTo(o2.getName());
+ }
+
+ });
+ return classes;
+ }
+
+ private static List> findClassesNoTests(
+ Class baseClass, String basePackage, String[] ignoredPackages)
+ throws IOException {
+ List> classes = findClasses(baseClass, basePackage,
+ ignoredPackages);
+ List> classesNoTests = new ArrayList>();
+ for (Class extends T> clazz : classes) {
+ if (!clazz.getName().contains("Test")) {
+ boolean testPresent = false;
+ for (Method method : clazz.getMethods()) {
+ if (method.isAnnotationPresent(Test.class)) {
+ testPresent = true;
+ break;
+ }
+ }
+ if (!testPresent) {
+ classesNoTests.add(clazz);
+ }
+ }
+ }
+ return classesNoTests;
+ }
+
+ private static void findPackages(JarURLConnection juc,
+ String javaPackage, Class baseClass,
+ Collection> result) throws IOException {
+ String prefix = "com/vaadin/ui";
+ Enumeration ent = juc.getJarFile().entries();
+ while (ent.hasMoreElements()) {
+ JarEntry e = ent.nextElement();
+ if (e.getName().endsWith(".class")
+ && e.getName().startsWith(prefix)) {
+ String fullyQualifiedClassName = e.getName().replace('/', '.')
+ .replace(".class", "");
+ addClassIfMatches(result, fullyQualifiedClassName, baseClass);
+ }
+ }
+ }
+
+ private static void findPackages(File parent, String javaPackage,
+ Class baseClass, Collection> result,
+ String[] ignoredPackages) {
+ for (String ignoredPackage : ignoredPackages) {
+ if (javaPackage.equals(ignoredPackage)) {
+ return;
+ }
+ }
+
+ for (File file : parent.listFiles()) {
+ if (file.isDirectory()) {
+ findPackages(file, javaPackage + "." + file.getName(),
+ baseClass, result, ignoredPackages);
+ } else if (file.getName().endsWith(".class")) {
+ String fullyQualifiedClassName = javaPackage + "."
+ + file.getName().replace(".class", "");
+ addClassIfMatches(result, fullyQualifiedClassName, baseClass);
+ }
+ }
+
+ }
+
+ @SuppressWarnings("unchecked")
+ private static void addClassIfMatches(
+ Collection> result,
+ String fullyQualifiedClassName, Class baseClass) {
+ try {
+ // Try to load the class
+
+ Class> c = Class.forName(fullyQualifiedClassName);
+ if (baseClass.isAssignableFrom(c)
+ && !Modifier.isAbstract(c.getModifiers())) {
+ result.add((Class extends T>) c);
+ }
+ } catch (Exception e) {
+ // Could ignore that class cannot be loaded
+ e.printStackTrace();
+ } catch (LinkageError e) {
+ // Ignore. Client side classes will at least throw LinkageErrors
+ }
+
+ }
+}
diff --git a/tests/testbench/com/vaadin/launcher/util/BrowserLauncher.java b/tests/testbench/com/vaadin/launcher/util/BrowserLauncher.java
new file mode 100644
index 0000000000..55692cb251
--- /dev/null
+++ b/tests/testbench/com/vaadin/launcher/util/BrowserLauncher.java
@@ -0,0 +1,127 @@
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.launcher.util;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+/**
+ * This class opens default browser for DemoLauncher class. Default browser is
+ * detected by the operating system.
+ *
+ */
+public class BrowserLauncher {
+
+ /**
+ * Open browser on specified URL.
+ *
+ * @param url
+ */
+ public static void openBrowser(String url) {
+
+ final Runtime runtime = Runtime.getRuntime();
+ boolean started = false;
+
+ final String os = System.getProperty("os.name", "windows")
+ .toLowerCase();
+
+ // Linux
+ if (os.indexOf("linux") >= 0) {
+ // See if the default browser is Konqueror by resolving the symlink.
+ boolean isDefaultKonqueror = false;
+ try {
+ // Find out the location of the x-www-browser link from path.
+ Process process = runtime.exec("which x-www-browser");
+ BufferedInputStream ins = new BufferedInputStream(
+ process.getInputStream());
+ BufferedReader bufreader = new BufferedReader(
+ new InputStreamReader(ins));
+ String defaultLinkPath = bufreader.readLine();
+ ins.close();
+
+ // The path is null if the link did not exist.
+ if (defaultLinkPath != null) {
+ // See if the default browser is Konqueror.
+ File file = new File(defaultLinkPath);
+ String canonical = file.getCanonicalPath();
+ if (canonical.indexOf("konqueror") != -1) {
+ isDefaultKonqueror = true;
+ }
+ }
+ } catch (IOException e1) {
+ // The symlink was probably not found, so this is ok.
+ }
+
+ // Try x-www-browser, which is symlink to the default browser,
+ // except if we found that it is Konqueror.
+ if (!started && !isDefaultKonqueror) {
+ try {
+ runtime.exec("x-www-browser " + url);
+ started = true;
+ } catch (final IOException e) {
+ }
+ }
+
+ // Try firefox
+ if (!started) {
+ try {
+ runtime.exec("firefox " + url);
+ started = true;
+ } catch (final IOException e) {
+ }
+ }
+
+ // Try mozilla
+ if (!started) {
+ try {
+ runtime.exec("mozilla " + url);
+ started = true;
+ } catch (final IOException e) {
+ }
+ }
+
+ // Try konqueror
+ if (!started) {
+ try {
+ runtime.exec("konqueror " + url);
+ started = true;
+ } catch (final IOException e) {
+ }
+ }
+ }
+
+ // OS X
+ if (os.indexOf("mac os x") >= 0) {
+
+ // Try open
+ if (!started) {
+ try {
+ runtime.exec("open " + url);
+ started = true;
+ } catch (final IOException e) {
+ }
+ }
+ }
+
+ // Try cmd /start command on windows
+ if (os.indexOf("win") >= 0) {
+ if (!started) {
+ try {
+ runtime.exec("cmd /c start " + url);
+ started = true;
+ } catch (final IOException e) {
+ }
+ }
+ }
+
+ if (!started) {
+ System.out.println("Failed to open browser. Please go to " + url);
+ }
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/Components.java b/tests/testbench/com/vaadin/tests/Components.java
index 6987c04a54..d7bc18e2f6 100644
--- a/tests/testbench/com/vaadin/tests/Components.java
+++ b/tests/testbench/com/vaadin/tests/Components.java
@@ -32,7 +32,7 @@ import com.vaadin.ui.Window;
public class Components extends Application {
private static final Object CAPTION = "c";
- private Map>, String> tests = new HashMap>, String>();
+ private Map, String> tests = new HashMap, String>();
private Tree naviTree;
private HorizontalSplitPanel sp;
private Window mainWindow;
@@ -41,10 +41,9 @@ public class Components extends Application {
private List> componentsWithoutTests = new ArrayList>();
{
- for (Class extends AbstractComponentTest>> c : VaadinClasses
- .getBasicComponentTests()) {
+ for (Class> c : VaadinClasses.getBasicComponentTests()) {
String testClass = c.getSimpleName();
- tests.put(c, testClass);
+ tests.put((Class extends AbstractComponentTest>) c, testClass);
}
List> componentsWithoutTest = VaadinClasses
@@ -171,7 +170,7 @@ public class Components extends Application {
hc.setItemSorter(sorter);
naviTree.addContainerProperty(CAPTION, String.class, "");
naviTree.setItemCaptionPropertyId(CAPTION);
- for (Class extends AbstractComponentTest>> cls : tests.keySet()) {
+ for (Class extends AbstractComponentTest> cls : tests.keySet()) {
addTreeItem(cls);
}
hc.sort(new Object[] { CAPTION }, new boolean[] { true });
@@ -226,13 +225,13 @@ public class Components extends Application {
}
@SuppressWarnings("unchecked")
- private void addTreeItem(Class extends AbstractComponentTest>> cls) {
+ private void addTreeItem(Class extends AbstractComponentTest> cls) {
String name = tests.get(cls);
if (name == null) {
name = cls.getSimpleName();
}
- Class extends AbstractComponentTest>> superClass = (Class extends AbstractComponentTest>>) cls
+ Class extends AbstractComponentTest> superClass = (Class extends AbstractComponentTest>) cls
.getSuperclass();
// This cast is needed only to make compilation through Ant work ..
@@ -249,9 +248,9 @@ public class Components extends Application {
}
protected Component createTestComponent(
- Class extends AbstractComponentTest>> cls) {
+ Class extends AbstractComponentTest> cls) {
try {
- AbstractComponentTest> t = cls.newInstance();
+ AbstractComponentTest t = cls.newInstance();
t.init();
ComponentContainer c = t.getMainWindow().getContent();
t.getMainWindow().setContent(null);
diff --git a/tests/testbench/com/vaadin/tests/VaadinClasses.java b/tests/testbench/com/vaadin/tests/VaadinClasses.java
deleted file mode 100644
index 0f4e2ff4da..0000000000
--- a/tests/testbench/com/vaadin/tests/VaadinClasses.java
+++ /dev/null
@@ -1,235 +0,0 @@
-package com.vaadin.tests;
-
-import java.io.File;
-import java.io.IOException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.net.JarURLConnection;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.jar.JarEntry;
-
-import org.junit.Test;
-
-import com.vaadin.Application;
-import com.vaadin.tests.components.AbstractComponentTest;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.ComponentContainer;
-import com.vaadin.ui.CustomComponent;
-import com.vaadin.ui.DragAndDropWrapper;
-import com.vaadin.ui.HorizontalSplitPanel;
-import com.vaadin.ui.LoginForm;
-import com.vaadin.ui.PopupView;
-import com.vaadin.ui.SplitPanel;
-import com.vaadin.ui.VerticalSplitPanel;
-import com.vaadin.ui.Window;
-
-@SuppressWarnings("deprecation")
-public class VaadinClasses {
-
- public static void main(String[] args) {
- System.out.println("ComponentContainers");
- System.out.println("===================");
- for (Class extends ComponentContainer> c : getComponentContainers()) {
- System.out.println(c.getName());
- }
- System.out.println();
- System.out.println("Components");
- System.out.println("==========");
- for (Class extends Component> c : getComponents()) {
- System.out.println(c.getName());
- }
- System.out.println();
- System.out.println("Server side classes");
- System.out.println("===================");
- for (Class> c : getAllServerSideClasses()) {
- System.out.println(c.getName());
- }
- }
-
- public static List> getComponents() {
- try {
- return findClasses(Component.class, "com.vaadin.ui");
- } catch (IOException e) {
- e.printStackTrace();
- return null;
- }
- }
-
- public static List> getAllServerSideClasses() {
- try {
- return findClassesNoTests(Object.class, "com.vaadin", new String[] {
- "com.vaadin.tests", "com.vaadin.terminal.gwt.client" });
- } catch (IOException e) {
- e.printStackTrace();
- return null;
- }
- }
-
- public static List> getComponentContainers() {
- try {
- return findClasses(ComponentContainer.class, "com.vaadin.ui");
- } catch (IOException e) {
- e.printStackTrace();
- return null;
- }
- }
-
- public static List> getComponentContainersSupportingAddRemoveComponent() {
- List> classes = getComponentContainers();
- classes.remove(PopupView.class);
- classes.remove(CustomComponent.class);
- classes.remove(DragAndDropWrapper.class);
- classes.remove(CustomComponent.class);
- classes.remove(LoginForm.class);
-
- return classes;
- }
-
- public static List> getComponentContainersSupportingUnlimitedNumberOfComponents() {
- List> classes = getComponentContainersSupportingAddRemoveComponent();
- classes.remove(SplitPanel.class);
- classes.remove(VerticalSplitPanel.class);
- classes.remove(HorizontalSplitPanel.class);
- classes.remove(Window.class);
-
- return classes;
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- public static List>> getBasicComponentTests() {
- try {
- return (List) findClasses(AbstractComponentTest.class,
- "com.vaadin.tests.components");
- } catch (IOException e) {
- e.printStackTrace();
- return null;
- }
-
- }
-
- private static List> findClasses(Class baseClass,
- String basePackage) throws IOException {
- return findClasses(baseClass, basePackage, new String[] {});
- }
-
- private static List> findClasses(Class baseClass,
- String basePackage, String[] ignoredPackages) throws IOException {
- List> classes = new ArrayList>();
- String basePackageDirName = "/" + basePackage.replace('.', '/');
- URL location = Application.class.getResource(basePackageDirName);
- if (location.getProtocol().equals("file")) {
- try {
- File f = new File(location.toURI());
- if (!f.exists()) {
- throw new IOException("Directory " + f.toString()
- + " does not exist");
- }
- findPackages(f, basePackage, baseClass, classes,
- ignoredPackages);
- } catch (URISyntaxException e) {
- throw new IOException(e.getMessage());
- }
- } else if (location.getProtocol().equals("jar")) {
- JarURLConnection juc = (JarURLConnection) location.openConnection();
- findPackages(juc, basePackage, baseClass, classes);
- }
-
- Collections.sort(classes, new Comparator>() {
-
- public int compare(Class extends T> o1, Class extends T> o2) {
- return o1.getName().compareTo(o2.getName());
- }
-
- });
- return classes;
- }
-
- private static List> findClassesNoTests(
- Class baseClass, String basePackage, String[] ignoredPackages)
- throws IOException {
- List> classes = findClasses(baseClass, basePackage,
- ignoredPackages);
- List> classesNoTests = new ArrayList>();
- for (Class extends T> clazz : classes) {
- if (!clazz.getName().contains("Test")) {
- boolean testPresent = false;
- for (Method method : clazz.getMethods()) {
- if (method.isAnnotationPresent(Test.class)) {
- testPresent = true;
- break;
- }
- }
- if (!testPresent) {
- classesNoTests.add(clazz);
- }
- }
- }
- return classesNoTests;
- }
-
- private static void findPackages(JarURLConnection juc,
- String javaPackage, Class baseClass,
- Collection> result) throws IOException {
- String prefix = "com/vaadin/ui";
- Enumeration ent = juc.getJarFile().entries();
- while (ent.hasMoreElements()) {
- JarEntry e = ent.nextElement();
- if (e.getName().endsWith(".class")
- && e.getName().startsWith(prefix)) {
- String fullyQualifiedClassName = e.getName().replace('/', '.')
- .replace(".class", "");
- addClassIfMatches(result, fullyQualifiedClassName, baseClass);
- }
- }
- }
-
- private static void findPackages(File parent, String javaPackage,
- Class baseClass, Collection> result,
- String[] ignoredPackages) {
- for (String ignoredPackage : ignoredPackages) {
- if (javaPackage.equals(ignoredPackage)) {
- return;
- }
- }
-
- for (File file : parent.listFiles()) {
- if (file.isDirectory()) {
- findPackages(file, javaPackage + "." + file.getName(),
- baseClass, result, ignoredPackages);
- } else if (file.getName().endsWith(".class")) {
- String fullyQualifiedClassName = javaPackage + "."
- + file.getName().replace(".class", "");
- addClassIfMatches(result, fullyQualifiedClassName, baseClass);
- }
- }
-
- }
-
- @SuppressWarnings("unchecked")
- private static void addClassIfMatches(
- Collection> result,
- String fullyQualifiedClassName, Class baseClass) {
- try {
- // Try to load the class
-
- Class> c = Class.forName(fullyQualifiedClassName);
- if (baseClass.isAssignableFrom(c)
- && !Modifier.isAbstract(c.getModifiers())) {
- result.add((Class extends T>) c);
- }
- } catch (Exception e) {
- // Could ignore that class cannot be loaded
- e.printStackTrace();
- } catch (LinkageError e) {
- // Ignore. Client side classes will at least throw LinkageErrors
- }
-
- }
-}
--
cgit v1.2.3
From 69d6bf76820929777168055bf0a941d691463a6b Mon Sep 17 00:00:00 2001
From: Johannes Dahlström
Date: Mon, 16 Jan 2012 07:03:15 +0000
Subject: Merge from 6.7
svn changeset:22637/svn branch:6.8
---
WebContent/VAADIN/themes/reindeer-tests/styles.css | 27 ++-
.../terminal/gwt/client/ApplicationConnection.java | 139 ++++++++++----
.../vaadin/terminal/gwt/client/ui/VFormLayout.java | 19 +-
.../terminal/gwt/client/ui/VPopupCalendar.java | 22 ++-
.../terminal/gwt/client/ui/VTextualDate.java | 10 +-
.../components/datefield/DatePopupStyleName.html | 32 ++++
.../components/datefield/DatePopupStyleName.java | 33 ++++
.../WidthRecalculationOnEnableStateChange.html | 51 +++++
.../WidthRecalculationOnEnableStateChange.java | 44 +++++
.../formlayout/FormLayoutCaptionStyles.html | 46 +++++
.../formlayout/FormLayoutCaptionStyles.java | 55 ++++++
.../orderedlayout/OrderedLayoutCases.html | 102 ++++++++++
.../orderedlayout/OrderedLayoutCases.java | 171 ++++++++++++++++-
.../VerticalLayoutChangingChildrenSizes.html | 211 +++++++++++++++++++++
14 files changed, 899 insertions(+), 63 deletions(-)
create mode 100644 tests/testbench/com/vaadin/tests/components/datefield/DatePopupStyleName.html
create mode 100644 tests/testbench/com/vaadin/tests/components/datefield/DatePopupStyleName.java
create mode 100644 tests/testbench/com/vaadin/tests/components/datefield/WidthRecalculationOnEnableStateChange.html
create mode 100644 tests/testbench/com/vaadin/tests/components/datefield/WidthRecalculationOnEnableStateChange.java
create mode 100644 tests/testbench/com/vaadin/tests/components/formlayout/FormLayoutCaptionStyles.html
create mode 100644 tests/testbench/com/vaadin/tests/components/formlayout/FormLayoutCaptionStyles.java
create mode 100644 tests/testbench/com/vaadin/tests/components/orderedlayout/OrderedLayoutCases.html
create mode 100644 tests/testbench/com/vaadin/tests/components/orderedlayout/VerticalLayoutChangingChildrenSizes.html
(limited to 'tests')
diff --git a/WebContent/VAADIN/themes/reindeer-tests/styles.css b/WebContent/VAADIN/themes/reindeer-tests/styles.css
index 7d1727d4ca..243d1b87d4 100644
--- a/WebContent/VAADIN/themes/reindeer-tests/styles.css
+++ b/WebContent/VAADIN/themes/reindeer-tests/styles.css
@@ -1,4 +1,29 @@
@import url(../reindeer/styles.css);
.table-equal-rowheight .v-table-row {height: 30px;}
-.table-equal-rowheight .v-table-row-odd {height: 30px;}
\ No newline at end of file
+.table-equal-rowheight .v-table-row-odd {height: 30px;}
+
+.v-datefield-enabled-readonly-styled {
+ background: #ddd;
+}
+
+.v-datefield-enabled-readonly-styled input.v-datefield-textfield {
+ border: 1px solid black;
+}
+
+.v-datefield-enabled-readonly-styled .v-datefield.v-disabled {
+ opacity: 1;
+}
+
+.v-disabled.v-datefield-enabled-readonly-styled .v-datefield-button,
+.v-readonly.v-datefield-enabled-readonly-styled .v-datefield-button {
+ display: none;
+}
+
+.popup-style .v-datefield-calendarpanel-header,
+.v-datefield-popup-popup-style .v-datefield-calendarpanel-time {
+ background: red;
+}
+.popup-style .v-datefield-calendarpanel-body {
+ background: yellow;
+}
diff --git a/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java b/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java
index 89952afe8c..0bb311600c 100644
--- a/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java
+++ b/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java
@@ -22,6 +22,8 @@ import com.google.gwt.http.client.RequestBuilder;
import com.google.gwt.http.client.RequestCallback;
import com.google.gwt.http.client.RequestException;
import com.google.gwt.http.client.Response;
+import com.google.gwt.regexp.shared.MatchResult;
+import com.google.gwt.regexp.shared.RegExp;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Element;
@@ -94,6 +96,27 @@ public class ApplicationConnection {
public static final String ATTRIBUTE_DESCRIPTION = "description";
public static final String ATTRIBUTE_ERROR = "error";
+ /**
+ * A string that, if found in a non-JSON response to a UIDL request, will
+ * cause the browser to refresh the page. If followed by a colon, optional
+ * whitespace, and a URI, causes the browser to synchronously load the URI.
+ *
+ *
+ * This allows, for instance, a servlet filter to redirect the application
+ * to a custom login page when the session expires. For example:
+ *
+ *
+ *
+ * if (sessionExpired) {
+ * response.setHeader("Content-Type", "text/html");
+ * response.getWriter().write(
+ * myLoginPageHtml + "<!-- Vaadin-Refresh: "
+ * + request.getContextPath() + " -->");
+ * }
+ *
+ */
+ public static final String UIDL_REFRESH_TOKEN = "Vaadin-Refresh";
+
// will hold the UIDL security key (for XSS protection) once received
private String uidlSecurityKey = "init";
@@ -513,6 +536,27 @@ public class ApplicationConnection {
return;
}
+ String contentType = response.getHeader("Content-Type");
+ if (contentType == null
+ || !contentType.startsWith("application/json")) {
+ /*
+ * A servlet filter or equivalent may have intercepted
+ * the request and served non-UIDL content (for
+ * instance, a login page if the session has expired.)
+ * If the response contains a magic substring, do a
+ * synchronous refresh.
+ */
+ MatchResult refreshToken = RegExp.compile(
+ UIDL_REFRESH_TOKEN + "(:\\s*(.*?))?(\\s|$)")
+ .exec(response.getText());
+ if (refreshToken != null) {
+ redirect(refreshToken.getGroup(2));
+ VConsole.log("*** REDIRECT : "
+ + refreshToken.getGroup(2));
+ return;
+ }
+ }
+
final Date start = new Date();
// for(;;);[realjson]
final String jsonText = response.getText().substring(9,
@@ -1812,9 +1856,60 @@ public class ApplicationConnection {
fw.setEnabled(enabled);
}
+ TooltipInfo tooltipInfo = componentDetail.getTooltipInfo(null);
+ // Update tooltip
+ if (uidl.hasAttribute(ATTRIBUTE_DESCRIPTION)) {
+ tooltipInfo
+ .setTitle(uidl.getStringAttribute(ATTRIBUTE_DESCRIPTION));
+ } else {
+ tooltipInfo.setTitle(null);
+ }
+
+ // add error classname to components w/ error
+ if (uidl.hasAttribute(ATTRIBUTE_ERROR)) {
+ tooltipInfo.setErrorUidl(uidl.getErrors());
+ } else {
+ tooltipInfo.setErrorUidl(null);
+ }
+
+ // Style names
+ component.setStyleName(getStyleName(component.getStylePrimaryName(),
+ uidl, component instanceof Field));
+
+ // Set captions
+ if (manageCaption) {
+ final Container parent = Util.getLayout(component);
+ if (parent != null) {
+ parent.updateCaption((Paintable) component, uidl);
+ }
+ }
+ /*
+ * updateComponentSize need to be after caption update so caption can be
+ * taken into account
+ */
+
+ updateComponentSize(componentDetail, uidl);
+
+ return false;
+ }
+
+ /**
+ * Generates the style name for the widget based on the given primary style
+ * name (typically returned by Widget.getPrimaryStyleName()) and the UIDL.
+ * An additional "modified" style name can be added if the field parameter
+ * is set to true.
+ *
+ * @param primaryStyleName
+ * @param uidl
+ * @param isField
+ * @return
+ */
+ public static String getStyleName(String primaryStyleName, UIDL uidl,
+ boolean field) {
+ boolean enabled = !uidl.getBooleanAttribute("disabled");
+
StringBuffer styleBuf = new StringBuffer();
- final String primaryName = component.getStylePrimaryName();
- styleBuf.append(primaryName);
+ styleBuf.append(primaryStyleName);
// first disabling and read-only status
if (!enabled) {
@@ -1832,7 +1927,7 @@ public class ApplicationConnection {
final String[] styles = uidl.getStringAttribute("style").split(" ");
for (int i = 0; i < styles.length; i++) {
styleBuf.append(" ");
- styleBuf.append(primaryName);
+ styleBuf.append(primaryStyleName);
styleBuf.append("-");
styleBuf.append(styles[i]);
styleBuf.append(" ");
@@ -1841,55 +1936,25 @@ public class ApplicationConnection {
}
// add modified classname to Fields
- if (uidl.hasAttribute("modified") && component instanceof Field) {
+ if (field && uidl.hasAttribute("modified")) {
styleBuf.append(" ");
styleBuf.append(MODIFIED_CLASSNAME);
}
- TooltipInfo tooltipInfo = componentDetail.getTooltipInfo(null);
- // Update tooltip
- if (uidl.hasAttribute(ATTRIBUTE_DESCRIPTION)) {
- tooltipInfo
- .setTitle(uidl.getStringAttribute(ATTRIBUTE_DESCRIPTION));
- } else {
- tooltipInfo.setTitle(null);
- }
-
- // add error classname to components w/ error
if (uidl.hasAttribute(ATTRIBUTE_ERROR)) {
- tooltipInfo.setErrorUidl(uidl.getErrors());
styleBuf.append(" ");
- styleBuf.append(primaryName);
+ styleBuf.append(primaryStyleName);
styleBuf.append(ERROR_CLASSNAME_EXT);
- } else {
- tooltipInfo.setErrorUidl(null);
}
-
// add required style to required components
if (uidl.hasAttribute("required")) {
styleBuf.append(" ");
- styleBuf.append(primaryName);
+ styleBuf.append(primaryStyleName);
styleBuf.append(REQUIRED_CLASSNAME_EXT);
}
- // Styles + disabled & readonly
- component.setStyleName(styleBuf.toString());
-
- // Set captions
- if (manageCaption) {
- final Container parent = Util.getLayout(component);
- if (parent != null) {
- parent.updateCaption((Paintable) component, uidl);
- }
- }
- /*
- * updateComponentSize need to be after caption update so caption can be
- * taken into account
- */
-
- updateComponentSize(componentDetail, uidl);
+ return styleBuf.toString();
- return false;
}
private void updateComponentSize(ComponentDetail cd, UIDL uidl) {
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VFormLayout.java b/src/com/vaadin/terminal/gwt/client/ui/VFormLayout.java
index 9f9c6ffbba..d31d1acdd6 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VFormLayout.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VFormLayout.java
@@ -114,8 +114,7 @@ public class VFormLayout extends SimplePanel implements Container {
final Paintable p = client.getPaintable(childUidl);
Caption caption = componentToCaption.get(p);
if (caption == null) {
- caption = new Caption(p, client,
- getStylesFromUIDL(childUidl));
+ caption = new Caption(p, client);
caption.addClickHandler(this);
componentToCaption.put(p, caption);
}
@@ -197,7 +196,7 @@ public class VFormLayout extends SimplePanel implements Container {
if (oldComponent == candidate) {
Caption oldCap = componentToCaption.get(oldComponent);
final Caption newCap = new Caption(
- (Paintable) newComponent, client, null);
+ (Paintable) newComponent, client);
newCap.addClickHandler(this);
newCap.setStyleName(oldCap.getStyleName());
componentToCaption.put((Paintable) newComponent, newCap);
@@ -319,12 +318,15 @@ public class VFormLayout extends SimplePanel implements Container {
* return null
* @param client
*/
- public Caption(Paintable component, ApplicationConnection client,
- String[] styles) {
+ public Caption(Paintable component, ApplicationConnection client) {
super();
this.client = client;
owner = component;
+ sinkEvents(VTooltip.TOOLTIP_EVENTS);
+ }
+
+ private void setStyles(String[] styles) {
String style = CLASSNAME;
if (styles != null) {
for (int i = 0; i < styles.length; i++) {
@@ -332,16 +334,13 @@ public class VFormLayout extends SimplePanel implements Container {
}
}
setStyleName(style);
-
- sinkEvents(VTooltip.TOOLTIP_EVENTS);
}
public void updateCaption(UIDL uidl) {
setVisible(!uidl.getBooleanAttribute("invisible"));
- setStyleName(getElement(),
- ApplicationConnection.DISABLED_CLASSNAME,
- uidl.hasAttribute("disabled"));
+ // Update styles as they might have changed when the caption changed
+ setStyles(getStylesFromUIDL(uidl));
boolean isEmpty = true;
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VPopupCalendar.java b/src/com/vaadin/terminal/gwt/client/ui/VPopupCalendar.java
index 150831d4ed..549248aab3 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VPopupCalendar.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VPopupCalendar.java
@@ -45,6 +45,9 @@ import com.vaadin.terminal.gwt.client.ui.VCalendarPanel.TimeChangeListener;
public class VPopupCalendar extends VTextualDate implements Paintable, Field,
ClickHandler, CloseHandler, SubPartAware {
+ private static final String POPUP_PRIMARY_STYLE_NAME = VDateField.CLASSNAME
+ + "-popup";
+
private final Button calendarToggle;
private VCalendarPanel calendar;
@@ -90,7 +93,7 @@ public class VPopupCalendar extends VTextualDate implements Paintable, Field,
});
popup = new VOverlay(true, true, true);
- popup.setStyleName(VDateField.CLASSNAME + "-popup");
+ popup.setStyleName(POPUP_PRIMARY_STYLE_NAME);
popup.setWidget(calendar);
popup.addCloseHandler(this);
@@ -154,13 +157,18 @@ public class VPopupCalendar extends VTextualDate implements Paintable, Field,
@SuppressWarnings("deprecation")
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
boolean lastReadOnlyState = readonly;
+ boolean lastEnabledState = isEnabled();
+
parsable = uidl.getBooleanAttribute("parsable");
super.updateFromUIDL(uidl, client);
- popup.setStyleName(VDateField.CLASSNAME + "-popup "
- + VDateField.CLASSNAME + "-"
- + resolutionToString(currentResolution));
+ String popupStyleNames = ApplicationConnection.getStyleName(
+ POPUP_PRIMARY_STYLE_NAME, uidl, false);
+ popupStyleNames += " " + VDateField.CLASSNAME + "-"
+ + resolutionToString(currentResolution);
+ popup.setStyleName(popupStyleNames);
+
calendar.setDateTimeService(getDateTimeService());
calendar.setShowISOWeekNumbers(isShowISOWeekNumbers());
if (calendar.getResolution() != currentResolution) {
@@ -216,7 +224,11 @@ public class VPopupCalendar extends VTextualDate implements Paintable, Field,
calendarToggle.removeStyleName(CLASSNAME + "-button-readonly");
}
- if (lastReadOnlyState != readonly) {
+ if (lastReadOnlyState != readonly || lastEnabledState != isEnabled()) {
+ // Enabled or readonly state changed. Differences in theming might
+ // affect the width (for instance if the popup button is hidden) so
+ // we have to recalculate the width (IF the width of the field is
+ // fixed)
updateWidth();
}
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VTextualDate.java b/src/com/vaadin/terminal/gwt/client/ui/VTextualDate.java
index ff4378aedf..fb41829efc 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VTextualDate.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VTextualDate.java
@@ -384,8 +384,16 @@ public class VTextualDate extends VDateField implements Paintable, Field,
return fieldExtraWidth;
}
+ /**
+ * Force an recalculation of the width of the component IF the width has
+ * been defined. Does nothing if width is undefined as the width will be
+ * automatically adjusted by the browser.
+ */
public void updateWidth() {
- needLayout = true;
+ if (!needLayout) {
+ return;
+ }
+
fieldExtraWidth = -1;
iLayout();
}
diff --git a/tests/testbench/com/vaadin/tests/components/datefield/DatePopupStyleName.html b/tests/testbench/com/vaadin/tests/components/datefield/DatePopupStyleName.html
new file mode 100644
index 0000000000..f367fc383b
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/components/datefield/DatePopupStyleName.html
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+New Test
+
+
+
+
+New Test
+
+
+ open
+ /run/com.vaadin.tests.components.datefield.DatePopupStyleName?&restartApplication
+
+
+
+ mouseClick
+ vaadin=runcomvaadintestscomponentsdatefieldDatePopupStyleName::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VPopupCalendar[0]#popupButton
+ 4,10
+
+
+ screenCapture
+
+ styled-popup
+
+
+
+
+
diff --git a/tests/testbench/com/vaadin/tests/components/datefield/DatePopupStyleName.java b/tests/testbench/com/vaadin/tests/components/datefield/DatePopupStyleName.java
new file mode 100644
index 0000000000..ba4e324dc1
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/components/datefield/DatePopupStyleName.java
@@ -0,0 +1,33 @@
+package com.vaadin.tests.components.datefield;
+
+import java.util.Date;
+
+import com.vaadin.terminal.UserError;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.DateField;
+
+public class DatePopupStyleName extends TestBase {
+ @Override
+ public void setup() {
+ setTheme("reindeer-tests");
+
+ final DateField df = new DateField();
+ df.setValue(new Date(1203910239L));
+ df.setWidth("200px");
+ df.setRequired(true);
+ df.setComponentError(new UserError("abc"));
+ df.addStyleName("popup-style");
+ addComponent(df);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "The DateField is given a style name 'test', but that style isn't applied on the calendar popup element.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 8083;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/datefield/WidthRecalculationOnEnableStateChange.html b/tests/testbench/com/vaadin/tests/components/datefield/WidthRecalculationOnEnableStateChange.html
new file mode 100644
index 0000000000..70441efd9f
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/components/datefield/WidthRecalculationOnEnableStateChange.html
@@ -0,0 +1,51 @@
+
+
+
+
+
+
+New Test
+
+
+
+
+New Test
+
+
+ open
+ /run/com.vaadin.tests.components.datefield.WidthRecalculationOnEnableStateChange?restartApplication
+
+
+
+ click
+ vaadin=runcomvaadintestscomponentsdatefieldWidthRecalculationOnEnableStateChange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
+
+
+
+ screenCapture
+
+ disabled
+
+
+ click
+ vaadin=runcomvaadintestscomponentsdatefieldWidthRecalculationOnEnableStateChange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
+
+
+
+ screenCapture
+
+ enabled
+
+
+ click
+ vaadin=runcomvaadintestscomponentsdatefieldWidthRecalculationOnEnableStateChange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
+
+
+
+ screenCapture
+
+ readonly
+
+
+
+
diff --git a/tests/testbench/com/vaadin/tests/components/datefield/WidthRecalculationOnEnableStateChange.java b/tests/testbench/com/vaadin/tests/components/datefield/WidthRecalculationOnEnableStateChange.java
new file mode 100644
index 0000000000..f25a9f0350
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/components/datefield/WidthRecalculationOnEnableStateChange.java
@@ -0,0 +1,44 @@
+package com.vaadin.tests.components.datefield;
+
+import java.util.Date;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.DateField;
+
+public class WidthRecalculationOnEnableStateChange extends TestBase {
+ @Override
+ public void setup() {
+ setTheme("reindeer-tests");
+
+ final DateField df = new DateField();
+ df.setValue(new Date(1203910239L));
+ df.setWidth("200px");
+ df.addStyleName("enabled-readonly-styled");
+ addComponent(df);
+ addComponent(new Button("Toggle disabled for date field",
+ new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ df.setEnabled(!df.isEnabled());
+ }
+ }));
+ addComponent(new Button("Toggle read only for date field",
+ new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ df.setReadOnly(!df.isReadOnly());
+ }
+ }));
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Setting the disabled state doesn't recalculate the input element width. Setting the read-only state instead recalculates the width. In both cases, the popup button is hidden using CSS. The DateField is also given a style name 'test', but that style isn't applied on the calendar popup element.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 8085;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/formlayout/FormLayoutCaptionStyles.html b/tests/testbench/com/vaadin/tests/components/formlayout/FormLayoutCaptionStyles.html
new file mode 100644
index 0000000000..14b5cc4c53
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/components/formlayout/FormLayoutCaptionStyles.html
@@ -0,0 +1,46 @@
+
+
+
+
+
+
+New Test
+
+
+
+
+New Test
+
+
+ open
+ /run/com.vaadin.tests.components.formlayout.FormLayoutCaptionStyles?restartApplication
+
+
+
+ assertCSSClass
+ vaadin=runcomvaadintestscomponentsformlayoutFormLayoutCaptionStyles::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VFormLayout[0]/domChild[0]/domChild[1]/domChild[2]/domChild[0]/domChild[0]
+ v-caption-bold
+
+
+ assertCSSClass
+ vaadin=runcomvaadintestscomponentsformlayoutFormLayoutCaptionStyles::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[1]
+ bold
+
+
+ click
+ vaadin=runcomvaadintestscomponentsformlayoutFormLayoutCaptionStyles::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VButton[0]/domChild[0]/domChild[0]
+
+
+
+ assertNotCSSClass
+ vaadin=runcomvaadintestscomponentsformlayoutFormLayoutCaptionStyles::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[1]
+ bold
+
+
+ assertNotCSSClass
+ vaadin=runcomvaadintestscomponentsformlayoutFormLayoutCaptionStyles::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VFormLayout[0]/domChild[0]/domChild[1]/domChild[2]/domChild[0]/domChild[0]
+ v-caption-bold
+
+
+
+
diff --git a/tests/testbench/com/vaadin/tests/components/formlayout/FormLayoutCaptionStyles.java b/tests/testbench/com/vaadin/tests/components/formlayout/FormLayoutCaptionStyles.java
new file mode 100644
index 0000000000..e74969f637
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/components/formlayout/FormLayoutCaptionStyles.java
@@ -0,0 +1,55 @@
+package com.vaadin.tests.components.formlayout;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.FormLayout;
+import com.vaadin.ui.TextField;
+
+public class FormLayoutCaptionStyles extends TestBase {
+
+ @Override
+ protected void setup() {
+ setTheme("reindeer-tests");
+ FormLayout fl = new FormLayout();
+
+ TextField f1 = createTextField("Text field 1", "");
+ final TextField f2 = createTextField("Text field 2", "bold");
+
+ fl.addComponent(f1);
+ fl.addComponent(new Button("Toggle Text field 2 bold style",
+ new Button.ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ if ("bold".equals(f2.getStyleName())) {
+ f2.setStyleName("");
+ } else {
+ f2.setStyleName("bold");
+ }
+
+ }
+
+ }));
+ fl.addComponent(f2);
+
+ addComponent(fl);
+
+ }
+
+ private TextField createTextField(String caption, String style) {
+ TextField tf = new TextField(caption);
+ tf.setStyleName(style);
+ return tf;
+ }
+
+ @Override
+ protected String getDescription() {
+ return "The component style should be copied to the caption element. Changing the component style should update the caption style also";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 5982;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/components/orderedlayout/OrderedLayoutCases.html b/tests/testbench/com/vaadin/tests/components/orderedlayout/OrderedLayoutCases.html
new file mode 100644
index 0000000000..9e1400521b
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/components/orderedlayout/OrderedLayoutCases.html
@@ -0,0 +1,102 @@
+
+
+
+
+
+
+New Test
+
+
+
+
+New Test
+
+
+ open
+ /run/com.vaadin.tests.components.orderedlayout.OrderedLayoutCases?restartApplication
+
+
+
+ click
+ vaadin=runcomvaadintestscomponentsorderedlayoutOrderedLayoutCases::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]
+
+
+
+ screenCapture
+
+ 1-undefined-without-relative
+
+
+ click
+ vaadin=runcomvaadintestscomponentsorderedlayoutOrderedLayoutCases::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
+
+
+
+ screenCapture
+
+ 2-undefined-with-relative
+
+
+ click
+ vaadin=runcomvaadintestscomponentsorderedlayoutOrderedLayoutCases::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]
+
+
+
+ screenCapture
+
+ 3-fixed-with-overflow
+
+
+ click
+ vaadin=runcomvaadintestscomponentsorderedlayoutOrderedLayoutCases::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[3]/VButton[0]/domChild[0]/domChild[0]
+
+
+
+ screenCapture
+
+ 4-fixed-with-extra-space
+
+
+ click
+ vaadin=runcomvaadintestscomponentsorderedlayoutOrderedLayoutCases::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[7]/VButton[0]/domChild[0]
+
+
+
+
+ screenCapture
+
+ 8-undefined-relative-height
+
+
+ click
+ vaadin=runcomvaadintestscomponentsorderedlayoutOrderedLayoutCases::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[6]/VButton[0]/domChild[0]/domChild[0]
+
+
+
+ screenCapture
+
+ 7-fixed-relative-height
+
+
+ click
+ vaadin=runcomvaadintestscomponentsorderedlayoutOrderedLayoutCases::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[5]/VButton[0]/domChild[0]/domChild[0]
+
+
+
+ screenCapture
+
+ 6-multiple-expands
+
+
+ click
+ vaadin=runcomvaadintestscomponentsorderedlayoutOrderedLayoutCases::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[4]/VButton[0]/domChild[0]/domChild[0]
+
+
+
+ screenCapture
+
+ 5-expand-with-alignment
+
+
+
+
diff --git a/tests/testbench/com/vaadin/tests/components/orderedlayout/OrderedLayoutCases.java b/tests/testbench/com/vaadin/tests/components/orderedlayout/OrderedLayoutCases.java
index d8b01c4099..dae44e3299 100644
--- a/tests/testbench/com/vaadin/tests/components/orderedlayout/OrderedLayoutCases.java
+++ b/tests/testbench/com/vaadin/tests/components/orderedlayout/OrderedLayoutCases.java
@@ -11,17 +11,21 @@ import com.vaadin.tests.components.TestBase;
import com.vaadin.tests.util.TestUtils;
import com.vaadin.ui.AbstractOrderedLayout;
import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.Component;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.NativeSelect;
import com.vaadin.ui.VerticalLayout;
public class OrderedLayoutCases extends TestBase {
- private static final String[] dimensionValues = { "-1px", "5px", "300px",
+ private static final String[] dimensionValues = { "-1px", "5px", "350px",
"800px", "100%", "50%" };
private static class SampleChild extends VerticalLayout {
public SampleChild() {
- setStyleName("showBorders");
+ setStyleName("sampleChild");
addComponent(createSimpleSelector("Child width",
new ValueChangeListener() {
public void valueChange(ValueChangeEvent event) {
@@ -101,18 +105,24 @@ public class OrderedLayoutCases extends TestBase {
}
private AbstractOrderedLayout currentLayout;
+ private HorizontalLayout sizeBar;
@Override
- public void setup() {
- TestUtils.injectCSS(getMainWindow(),
- ".showBorders {border: 1px solid black};");
+ protected void setup() {
+ TestUtils
+ .injectCSS(
+ getMainWindow(),
+ ".sampleChild, .theLayout {border: 1px solid black;}"
+ + ".theLayout > div > div:first-child {background: aqua;}"
+ + ".theLayout > div > div:first-child + div {background: yellow;}"
+ + ".theLayout > div > div:first-child + div + div {background: lightgrey;}");
currentLayout = new HorizontalLayout();
for (int i = 0; i < 3; i++) {
currentLayout.addComponent(new SampleChild());
}
- HorizontalLayout sizeBar = new HorizontalLayout();
+ sizeBar = new HorizontalLayout();
sizeBar.setSpacing(true);
sizeBar.addComponent(createSimpleSelector("Layout width",
@@ -129,6 +139,20 @@ public class OrderedLayoutCases extends TestBase {
.toString());
}
}, dimensionValues));
+ sizeBar.addComponent(createSimpleSelector("Spacing",
+ new ValueChangeListener() {
+ public void valueChange(ValueChangeEvent event) {
+ currentLayout.setSpacing(Boolean.parseBoolean(event
+ .getProperty().getValue().toString()));
+ }
+ }, "false", "true"));
+ sizeBar.addComponent(createSimpleSelector("Margin",
+ new ValueChangeListener() {
+ public void valueChange(ValueChangeEvent event) {
+ currentLayout.setMargin(Boolean.parseBoolean(event
+ .getProperty().getValue().toString()));
+ }
+ }, "false", "true"));
sizeBar.addComponent(createSimpleSelector("Direction",
new ValueChangeListener() {
public void valueChange(ValueChangeEvent event) {
@@ -145,7 +169,7 @@ public class OrderedLayoutCases extends TestBase {
newLayout.addComponent(currentLayout
.getComponent(0));
}
- newLayout.setStyleName("showBorders");
+ newLayout.setStyleName("theLayout");
newLayout.setHeight(currentLayout.getHeight(),
currentLayout.getHeightUnits());
@@ -157,15 +181,145 @@ public class OrderedLayoutCases extends TestBase {
}
}, "Horizontal", "Vertical"));
+ HorizontalLayout caseBar = new HorizontalLayout();
+ caseBar.addComponent(new Button("Undefined without relative",
+ new ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ resetState();
+ // width: 350px to middle child
+ setChildState(1, 0, 2);
+ }
+ }));
+ caseBar.addComponent(new Button("Undefined with relative",
+ new ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ resetState();
+ // width: 100% to middle child
+ setChildState(1, 0, 4);
+ }
+ }));
+ caseBar.addComponent(new Button("Fixed with overflow",
+ new ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ resetState();
+ // layout width: 350px
+ setState(sizeBar, 0, 2);
+ // layout margin enabled
+ setState(sizeBar, 3, 1);
+ }
+ }));
+ caseBar.addComponent(new Button("Fixed with extra space",
+ new ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ resetState();
+ // Layout width: 800px
+ setState(sizeBar, 0, 3);
+ // layout margin enabled
+ setState(sizeBar, 3, 1);
+ // width: 350px to middle child
+ setChildState(1, 0, 2);
+ }
+ }));
+
+ caseBar.addComponent(new Button("Expand with alignment",
+ new ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ resetState();
+ // Layout width: 800px
+ setState(sizeBar, 0, 3);
+ // Layout height: 350px
+ setState(sizeBar, 1, 2);
+ // Expand: 1 to middle child
+ setChildState(1, 3, 1);
+ // Align bottom left to middle child
+ setChildState(1, 4, 6);
+ }
+ }));
+
+ caseBar.addComponent(new Button("Multiple expands",
+ new ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ resetState();
+ // Layout width: 800px
+ setState(sizeBar, 0, 3);
+ // Layout height: 350px
+ setState(sizeBar, 1, 2);
+ // Width 350px to middle child
+ setChildState(1, 0, 2);
+ // Apply to left and middle child
+ for (int i = 0; i < 2; i++) {
+ // Expand: 1
+ setChildState(i, 3, 1);
+ // Align: middle center
+ setChildState(i, 4, 5);
+ }
+ }
+ }));
+
+ caseBar.addComponent(new Button("Fixed + relative height",
+ new ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ resetState();
+ // Layout height: 100%
+ setState(sizeBar, 1, 4);
+ // Height: 350px to left child
+ setChildState(0, 1, 2);
+ // Height: 100% to middle child
+ setChildState(1, 1, 4);
+ }
+ }));
+
+ caseBar.addComponent(new Button("Undefined + relative height",
+ new ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ resetState();
+ // Height: 350px to left child
+ setChildState(0, 1, 2);
+ // Height: 100% to middle child
+ setChildState(1, 1, 4);
+ }
+ }));
+
+ caseBar.setSpacing(true);
+
+ addComponent(caseBar);
addComponent(sizeBar);
addComponent(currentLayout);
getLayout().setSpacing(true);
- getMainWindow().getContent().setSizeFull();
+ getLayout().getParent().setSizeFull();
getLayout().setSizeFull();
getLayout().setExpandRatio(currentLayout, 1);
}
+ private void resetState() {
+ for (int i = 0; i < sizeBar.getComponentCount(); i++) {
+ setState(sizeBar, i, 0);
+ }
+ for (int i = 0; i < 3; i++) {
+ // Child width and height -> -1px
+ SampleChild child = (SampleChild) currentLayout.getComponent(i);
+ for (int j = 0; j < child.getComponentCount(); j++) {
+ if (j == 4) {
+ setState(child, j, 1);
+ } else {
+ setState(child, j, 0);
+ }
+ }
+ }
+ }
+
+ private void setChildState(int childIndex, int selectIndex, int valueIndex) {
+ Component child = currentLayout.getComponent(childIndex);
+ setState(child, selectIndex, valueIndex);
+ }
+
+ private static void setState(Component container, int selectIndex, int value) {
+ NativeSelect select = (NativeSelect) ((AbstractOrderedLayout) container)
+ .getComponent(selectIndex);
+ select.setValue(new ArrayList(select.getItemIds()).get(value));
+ }
+
private static NativeSelect createSimpleSelector(String caption,
ValueChangeListener listener, String... values) {
return createSimpleSelector(caption, listener, Arrays.asList(values),
@@ -185,7 +339,6 @@ public class OrderedLayoutCases extends TestBase {
@Override
protected Integer getTicketNumber() {
- // TODO Auto-generated method stub
return null;
}
diff --git a/tests/testbench/com/vaadin/tests/components/orderedlayout/VerticalLayoutChangingChildrenSizes.html b/tests/testbench/com/vaadin/tests/components/orderedlayout/VerticalLayoutChangingChildrenSizes.html
new file mode 100644
index 0000000000..edcf60176d
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/components/orderedlayout/VerticalLayoutChangingChildrenSizes.html
@@ -0,0 +1,211 @@
+
+
+
+
+
+
+New Test
+
+
+
+
+New Test
+
+
+ open
+ /run/com.vaadin.tests.components.orderedlayout.VerticalLayoutTest?restartApplication
+
+
+
+
+ mouseClick
+ vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::PID_Smenu#item1
+ 28,5
+
+
+ mouseClick
+ vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::Root/VOverlay[0]/VMenuBar[0]#item0
+ 30,8
+
+
+
+ mouseClick
+ vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::PID_Smenu#item0
+ 41,8
+
+
+ mouseClick
+ vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::Root/VOverlay[0]/VMenuBar[0]#item3
+ 84,6
+
+
+ mouseClick
+ vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::Root/VOverlay[1]/VMenuBar[0]#item0
+ 43,6
+
+
+ mouseClick
+ vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::Root/VOverlay[2]/VMenuBar[0]#item0
+ 68,8
+
+
+ mouseClick
+ vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::Root/VOverlay[3]/VMenuBar[0]#item0
+ 30,11
+
+
+ screenCapture
+
+ auto-auto-one-button
+
+
+ mouseClick
+ vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::PID_Smenu#item0
+ 35,11
+
+
+ mouseClick
+ vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::Root/VOverlay[0]/VMenuBar[0]#item3
+ 85,5
+
+
+ mouseClick
+ vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::Root/VOverlay[1]/VMenuBar[0]#item0
+ 83,3
+
+
+ mouseClick
+ vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::Root/VOverlay[2]/VMenuBar[0]#item1
+ 28,7
+
+
+ mouseClick
+ vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::Root/VOverlay[3]/VMenuBar[0]#item1
+ 40,10
+
+
+ screenCapture
+
+ auto-auto-two-buttons
+
+
+
+ mouseClick
+ vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::PID_Smenu#item0
+ 42,6
+
+
+ mouseClick
+ vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::Root/VOverlay[0]/VMenuBar[0]#item3
+ 77,6
+
+
+ mouseClick
+ vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::Root/VOverlay[1]/VMenuBar[0]#item2
+ 115,7
+
+
+ mouseClick
+ vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::Root/VOverlay[2]/VMenuBar[0]#item0
+ 72,8
+
+
+ mouseClick
+ vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::Root/VOverlay[3]/VMenuBar[0]#item4
+ 14,2
+
+
+ screenCapture
+
+ auto-auto-two-buttons-equal-width
+
+
+
+ mouseClick
+ vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::PID_Smenu#item0
+ 22,9
+
+
+ mouseClick
+ vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::Root/VOverlay[0]/VMenuBar[0]#item3
+ 117,9
+
+
+ mouseClick
+ vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::Root/VOverlay[1]/VMenuBar[0]#item3
+ 104,8
+
+
+ mouseClick
+ vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::Root/VOverlay[2]/VMenuBar[0]#item1
+ 74,12
+
+
+ mouseClick
+ vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::Root/VOverlay[3]/VMenuBar[0]#item2
+ 23,8
+
+
+ screenCapture
+
+ auto-auto-two-buttons-lower-higher
+
+
+
+ mouseClick
+ vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::PID_Smenu#item0
+ 24,11
+
+
+ mouseClick
+ vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::Root/VOverlay[0]/VMenuBar[0]#item3
+ 104,12
+
+
+ mouseClick
+ vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::Root/VOverlay[1]/VMenuBar[0]#item2
+ 114,10
+
+
+ mouseClick
+ vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::Root/VOverlay[2]/VMenuBar[0]#item0
+ 87,11
+
+
+ mouseClick
+ vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::Root/VOverlay[3]/VMenuBar[0]#item0
+ 17,8
+
+
+ mouseClick
+ vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::PID_Smenu#item0
+ 28,3
+
+
+ mouseClick
+ vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::Root/VOverlay[0]/VMenuBar[0]#item3
+ 77,8
+
+
+ mouseClick
+ vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::Root/VOverlay[1]/VMenuBar[0]#item3
+ 96,6
+
+
+ mouseClick
+ vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::Root/VOverlay[2]/VMenuBar[0]#item1
+ 75,10
+
+
+ mouseClick
+ vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::Root/VOverlay[3]/VMenuBar[0]#item0
+ 19,3
+
+
+ screenCapture
+
+ auto-auto-two-buttons
+
+
+
+
--
cgit v1.2.3
From 272923e03232e07cca23abf51618c819807122e1 Mon Sep 17 00:00:00 2001
From: Johannes Dahlström
Date: Fri, 20 Jan 2012 10:30:03 +0000
Subject: Merge from 6.7
svn changeset:22729/svn branch:6.8
---
.../vaadin/terminal/gwt/client/VDebugConsole.java | 6 ++++--
.../vaadin/terminal/gwt/client/ui/VFormLayout.java | 16 +++++++++++----
.../terminal/gwt/client/ui/VTextualDate.java | 24 ++++++++++++++--------
tests/integration_base_files/cleanup.sh | 3 ++-
tests/integration_base_files/lock_age.sh | 2 +-
tests/integration_tests.xml | 8 ++++++++
tests/test.xml | 2 +-
.../combobox/ComboBoxIdenticalItems.html | 6 +++++-
.../orderedlayout/OrderedLayoutCases.java | 4 ++++
9 files changed, 52 insertions(+), 19 deletions(-)
(limited to 'tests')
diff --git a/src/com/vaadin/terminal/gwt/client/VDebugConsole.java b/src/com/vaadin/terminal/gwt/client/VDebugConsole.java
index e180c05aaa..c43581b000 100644
--- a/src/com/vaadin/terminal/gwt/client/VDebugConsole.java
+++ b/src/com/vaadin/terminal/gwt/client/VDebugConsole.java
@@ -730,8 +730,10 @@ public class VDebugConsole extends VOverlay implements Console {
forceLayout.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
- // TODO for each client in appconf force layout
- // VDebugConsole.this.client.forceLayout();
+ for (ApplicationConnection applicationConnection : ApplicationConfiguration
+ .getRunningApplications()) {
+ applicationConnection.forceLayout();
+ }
}
});
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VFormLayout.java b/src/com/vaadin/terminal/gwt/client/ui/VFormLayout.java
index d31d1acdd6..174e66b7aa 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VFormLayout.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VFormLayout.java
@@ -327,13 +327,21 @@ public class VFormLayout extends SimplePanel implements Container {
}
private void setStyles(String[] styles) {
- String style = CLASSNAME;
+ String styleName = CLASSNAME;
+
if (styles != null) {
- for (int i = 0; i < styles.length; i++) {
- style += " " + CLASSNAME + "-" + styles[i];
+ for (String style : styles) {
+ if (ApplicationConnection.DISABLED_CLASSNAME.equals(style)) {
+ // Add v-disabled also without classname prefix so
+ // generic v-disabled CSS rules work
+ styleName += " " + style;
+ }
+
+ styleName += " " + CLASSNAME + "-" + style;
}
}
- setStyleName(style);
+
+ setStyleName(styleName);
}
public void updateCaption(UIDL uidl) {
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VTextualDate.java b/src/com/vaadin/terminal/gwt/client/ui/VTextualDate.java
index fb41829efc..56cdf05ddb 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VTextualDate.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VTextualDate.java
@@ -340,7 +340,7 @@ public class VTextualDate extends VDateField implements Paintable, Field,
@Override
public void setWidth(String newWidth) {
- if (!"".equals(newWidth) && (width == null || !newWidth.equals(width))) {
+ if (!"".equals(newWidth) && (isUndefinedWidth() || !newWidth.equals(width))) {
if (BrowserInfo.get().isIE6()) {
// in IE6 cols ~ min-width
DOM.setElementProperty(text.getElement(), "size", "1");
@@ -353,19 +353,21 @@ public class VTextualDate extends VDateField implements Paintable, Field,
needLayout = false;
}
} else {
- if ("".equals(newWidth) && width != null && !"".equals(width)) {
+ if ("".equals(newWidth) && !isUndefinedWidth()) {
+ // Changing from defined to undefined
if (BrowserInfo.get().isIE6()) {
// revert IE6 hack
DOM.setElementProperty(text.getElement(), "size", "");
}
super.setWidth("");
- needLayout = true;
- iLayout();
- needLayout = false;
+ iLayout(true);
width = null;
}
}
}
+ protected boolean isUndefinedWidth() {
+ return width == null || "".equals(width);
+ }
/**
* Returns pixels in x-axis reserved for other than textfield content.
@@ -390,16 +392,20 @@ public class VTextualDate extends VDateField implements Paintable, Field,
* automatically adjusted by the browser.
*/
public void updateWidth() {
- if (!needLayout) {
+ if (isUndefinedWidth()) {
return;
}
-
+ needLayout = true;
fieldExtraWidth = -1;
- iLayout();
+ iLayout(true);
}
public void iLayout() {
- if (needLayout) {
+ iLayout(false);
+ }
+
+ public void iLayout(boolean force) {
+ if (needLayout || force) {
int textFieldWidth = getOffsetWidth() - getFieldExtraWidth();
if (textFieldWidth < 0) {
// Field can never be smaller than 0 (causes exception in IE)
diff --git a/tests/integration_base_files/cleanup.sh b/tests/integration_base_files/cleanup.sh
index 42fb5a434d..44e2e5f6ee 100644
--- a/tests/integration_base_files/cleanup.sh
+++ b/tests/integration_base_files/cleanup.sh
@@ -23,4 +23,5 @@ if [ -a /home/integration/demo.war ]
fi
echo Cleaning deploy dir
-rm -rf /home/integration/deploy/*
+ant -f /home/integration/deploy.xml clean
+
diff --git a/tests/integration_base_files/lock_age.sh b/tests/integration_base_files/lock_age.sh
index 6b78acb590..115a8fef79 100644
--- a/tests/integration_base_files/lock_age.sh
+++ b/tests/integration_base_files/lock_age.sh
@@ -8,7 +8,7 @@ if lockfile -r0 -! /home/integration/deploy/lock.file &> /dev/null
AGE=$[($DATE - $LOCK_AGE)/60]
- if [ "$AGE" -gt "15" ]
+ if [ "$AGE" -gt "20" ]
then
echo lock.file is $AGE min old.
./cleanup.sh
diff --git a/tests/integration_tests.xml b/tests/integration_tests.xml
index 5984097880..57d6bb47a9 100644
--- a/tests/integration_tests.xml
+++ b/tests/integration_tests.xml
@@ -259,6 +259,13 @@
+
+
+
+
+
+
+
@@ -308,6 +315,7 @@
+
diff --git a/tests/test.xml b/tests/test.xml
index f09c115fec..39d45d2a74 100644
--- a/tests/test.xml
+++ b/tests/test.xml
@@ -129,7 +129,7 @@
-
+
diff --git a/tests/testbench/com/vaadin/tests/components/combobox/ComboBoxIdenticalItems.html b/tests/testbench/com/vaadin/tests/components/combobox/ComboBoxIdenticalItems.html
index 6d18c60038..3ad7d62a09 100644
--- a/tests/testbench/com/vaadin/tests/components/combobox/ComboBoxIdenticalItems.html
+++ b/tests/testbench/com/vaadin/tests/components/combobox/ComboBoxIdenticalItems.html
@@ -101,12 +101,16 @@
vaadin=runcomvaadintestscomponentscomboboxComboBoxIdenticalItems::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VFilterSelect[0]/domChild[0]
enter
+
+ pause
+ 100
+
+
assertText
vaadin=runcomvaadintestscomponentscomboboxComboBoxIdenticalItems::PID_SLog_row_0
4. Item one-1 selected
-