aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenri Sara <hesara@vaadin.com>2012-01-27 18:38:13 +0200
committerHenri Sara <hesara@vaadin.com>2012-01-27 18:38:13 +0200
commit91b3084e060f975ee35573972ace8bcf8fe3a5ed (patch)
tree154bb05f457b91388454fe42cd7652ca0d05c688
parent06ef07c7fd6eab0b7446367fa5a43384ae469cef (diff)
downloadvaadin-framework-91b3084e060f975ee35573972ace8bcf8fe3a5ed.tar.gz
vaadin-framework-91b3084e060f975ee35573972ace8bcf8fe3a5ed.zip
Merge changes from master to rpc branch.
-rw-r--r--WebContent/VAADIN/themes/base/datefield/datefield.css3
-rw-r--r--WebContent/VAADIN/themes/base/table/table.css12
-rw-r--r--WebContent/VAADIN/themes/base/tabsheet/tabsheet.css6
-rw-r--r--WebContent/VAADIN/themes/base/textfield/textfield-normal.css1
-rw-r--r--WebContent/VAADIN/themes/base/window/window.css15
-rw-r--r--WebContent/VAADIN/themes/chameleon/components/tabsheet/tabsheet.css1
-rw-r--r--WebContent/VAADIN/themes/reindeer-tests/styles.css27
-rw-r--r--WebContent/VAADIN/themes/reindeer/tabsheet/tabsheet-scroller.css1
-rw-r--r--build/build.properties2
-rw-r--r--build/build.xml233
-rw-r--r--build/ivy/ivy.xml16
-rw-r--r--src/com/vaadin/data/validator/CompositeValidator.java2
-rw-r--r--src/com/vaadin/terminal/Sizeable.java4
-rw-r--r--src/com/vaadin/terminal/UserError.java6
-rw-r--r--src/com/vaadin/terminal/gwt/client/ApplicationConnection.java190
-rw-r--r--src/com/vaadin/terminal/gwt/client/Container.java4
-rw-r--r--src/com/vaadin/terminal/gwt/client/Util.java20
-rw-r--r--src/com/vaadin/terminal/gwt/client/VDebugConsole.java6
-rw-r--r--src/com/vaadin/terminal/gwt/client/VPaintable.java57
-rw-r--r--src/com/vaadin/terminal/gwt/client/VPaintableMap.java11
-rw-r--r--src/com/vaadin/terminal/gwt/client/VPaintableWidget.java3
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/ShortcutActionHandler.java9
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VAbstractPaintableWidget.java44
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VButton.java82
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VButtonPaintable.java87
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VCalendarPanel.java200
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VDragAndDropWrapper.java11
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VFormLayout.java34
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java149
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VMenuBarPaintable.java161
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VNativeButton.java77
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VNativeButtonPaintable.java83
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VPopupCalendar.java936
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java420
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VScrollTablePaintable.java254
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VSlider.java1142
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VTabsheet.java5
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VTextArea.java7
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VTextField.java6
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VTextualDate.java35
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VTreeTable.java92
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VTreeTablePaintable.java101
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VUpload.java2
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VView.java8
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VWindow.java82
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/label/VLabel.java7
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/label/VLabelPaintable.java22
-rw-r--r--src/com/vaadin/ui/AbstractComponent.java10
-rw-r--r--src/com/vaadin/ui/AbstractSelect.java112
-rw-r--r--src/com/vaadin/ui/Button.java3
-rw-r--r--src/com/vaadin/ui/Component.java13
-rw-r--r--src/com/vaadin/ui/CssLayout.java26
-rw-r--r--src/com/vaadin/ui/MenuBar.java3
-rw-r--r--src/com/vaadin/ui/NativeButton.java4
-rw-r--r--src/com/vaadin/ui/Table.java354
-rw-r--r--src/com/vaadin/ui/TreeTable.java7
-rw-r--r--tests/integration_base_files/lock_age.sh2
-rw-r--r--tests/integration_tests.xml190
-rw-r--r--tests/server-side/com/vaadin/tests/VaadinClasses.java (renamed from tests/testbench/com/vaadin/tests/VaadinClasses.java)9
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/datefield/ResolutionTest.java (renamed from tests/testbench/com/vaadin/tests/components/datefield/ResolutionTest.java)2
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/table/TableColumnAlignments.java64
-rw-r--r--tests/server-side/com/vaadin/tests/server/componentcontainer/AbstractIndexedLayoutTest.java84
-rw-r--r--tests/server-side/com/vaadin/tests/server/componentcontainer/CssLayoutTest.java34
-rw-r--r--tests/server-side/com/vaadin/tests/server/componentcontainer/FormLayoutTest.java34
-rw-r--r--tests/server-side/com/vaadin/tests/server/componentcontainer/VerticalLayoutTest.java34
-rw-r--r--tests/test.xml2
-rw-r--r--tests/testbench/com/vaadin/launcher/util/BrowserLauncher.java (renamed from src/com/vaadin/launcher/util/BrowserLauncher.java)0
-rw-r--r--tests/testbench/com/vaadin/tests/Components.java17
-rw-r--r--tests/testbench/com/vaadin/tests/components/combobox/ComboBoxIdenticalItems.html6
-rw-r--r--tests/testbench/com/vaadin/tests/components/datefield/DatePopupStyleName.html32
-rw-r--r--tests/testbench/com/vaadin/tests/components/datefield/DatePopupStyleName.java33
-rw-r--r--tests/testbench/com/vaadin/tests/components/datefield/WidthRecalculationOnEnableStateChange.html51
-rw-r--r--tests/testbench/com/vaadin/tests/components/datefield/WidthRecalculationOnEnableStateChange.java44
-rw-r--r--tests/testbench/com/vaadin/tests/components/formlayout/FormLayoutCaptionStyles.html46
-rw-r--r--tests/testbench/com/vaadin/tests/components/formlayout/FormLayoutCaptionStyles.java55
-rw-r--r--tests/testbench/com/vaadin/tests/components/orderedlayout/OrderedLayoutCases.html102
-rw-r--r--tests/testbench/com/vaadin/tests/components/orderedlayout/OrderedLayoutCases.java179
-rw-r--r--tests/testbench/com/vaadin/tests/components/orderedlayout/VerticalLayoutChangingChildrenSizes.html211
-rw-r--r--tests/testbench/com/vaadin/tests/components/table/ScrollDetachSynchronization.java88
-rw-r--r--tests/testbench/com/vaadin/tests/components/table/TableHeaderZoom.java10
-rw-r--r--tests/testbench/com/vaadin/tests/components/table/TableRepaintWhenMadeVisibile.java43
-rw-r--r--tests/testbench/com/vaadin/tests/components/table/TableRepaintWhenMadeVisible.html42
-rw-r--r--tests/testbench/com/vaadin/tests/components/table/Tables.java71
-rw-r--r--tests/testbench/com/vaadin/tests/components/tabsheet/WrapTabSheetInTabSheet.java42
-rw-r--r--tests/testbench/com/vaadin/tests/components/textarea/TextAreaCursorPosition.java54
-rw-r--r--tests/testbench/com/vaadin/tests/components/textfield/TextFieldInputPromptAndClickShortcut.java59
86 files changed, 4396 insertions, 2452 deletions
diff --git a/WebContent/VAADIN/themes/base/datefield/datefield.css b/WebContent/VAADIN/themes/base/datefield/datefield.css
index 88d6f92c79..7af440c735 100644
--- a/WebContent/VAADIN/themes/base/datefield/datefield.css
+++ b/WebContent/VAADIN/themes/base/datefield/datefield.css
@@ -60,6 +60,9 @@
.v-datefield-calendarpanel-day-focused {
outline: 1px dotted black;
}
+.v-datefield-calendarpanel-day-offmonth {
+ color: #666;
+}
.v-datefield-time {
white-space: nowrap;
diff --git a/WebContent/VAADIN/themes/base/table/table.css b/WebContent/VAADIN/themes/base/table/table.css
index e2b2a16ffe..877faf364f 100644
--- a/WebContent/VAADIN/themes/base/table/table.css
+++ b/WebContent/VAADIN/themes/base/table/table.css
@@ -49,6 +49,12 @@
cursor: pointer;
}
+.v-table.v-disabled .v-table-header-cell,
+.v-table.v-disabled .v-table-header-cell-asc,
+.v-table.v-disabled .v-table-header-cell-desc {
+ cursor: default;
+}
+
.v-table-footer-wrap {
overflow: hidden;
border: 1px solid #aaa;
@@ -85,6 +91,9 @@
width: 1px;
overflow: hidden;
}
+.v-table.v-disabled .v-table-resizer {
+ cursor: default;
+}
.v-table-caption-container {
overflow: hidden;
white-space: nowrap;
@@ -174,6 +183,9 @@
position: relative; /* hide this from IE, it works without it */
cursor: pointer;
}
+.v-table.v-disabled .v-table-column-selector {
+ cursor: default;
+}
.v-table-focus-slot-left {
border-left: 2px solid #999;
float: none;
diff --git a/WebContent/VAADIN/themes/base/tabsheet/tabsheet.css b/WebContent/VAADIN/themes/base/tabsheet/tabsheet.css
index 7f978076b8..892b2958a4 100644
--- a/WebContent/VAADIN/themes/base/tabsheet/tabsheet.css
+++ b/WebContent/VAADIN/themes/base/tabsheet/tabsheet.css
@@ -88,7 +88,11 @@
padding: 0.2em 0.5em;
}
.v-tabsheet-tabitem .v-caption {
- cursor: pointer;
+ cursor: inherit;
+}
+.v-tabsheet.v-disabled .v-tabsheet-tabitem,
+.v-tabsheet-tabitemcell-disabled .v-tabsheet-tabitem {
+ cursor: default;
}
.v-tabsheet-tabitem-selected {
cursor: default;
diff --git a/WebContent/VAADIN/themes/base/textfield/textfield-normal.css b/WebContent/VAADIN/themes/base/textfield/textfield-normal.css
index aa787dd4dc..557a960c76 100644
--- a/WebContent/VAADIN/themes/base/textfield/textfield-normal.css
+++ b/WebContent/VAADIN/themes/base/textfield/textfield-normal.css
@@ -2,6 +2,7 @@
text-align: left /* Force default alignment */
}
.v-textarea {
+ resize: none;
}
.v-textfield-focus,
.v-textarea-focus {
diff --git a/WebContent/VAADIN/themes/base/window/window.css b/WebContent/VAADIN/themes/base/window/window.css
index d5dfd66e2b..5f014247e2 100644
--- a/WebContent/VAADIN/themes/base/window/window.css
+++ b/WebContent/VAADIN/themes/base/window/window.css
@@ -2,10 +2,15 @@
background: #fff;
}
.v-window-outerheader {
- cursor: move;
padding: 0.3em 1em;
height: 1em;
}
+
+.v-window-outerheader,
+.v-window-draggingCurtain {
+ cursor: move;
+}
+
.v-window-header {
font-weight: bold;
}
@@ -37,16 +42,22 @@ div.v-window-header {
zoom: 1;
height: 10px;
position: relative;
+ cursor: move;
}
.v-window-resizebox {
width: 10px;
height: 10px;
- cursor: se-resize;
background: #ddd;
overflow: hidden;
position: absolute;
right: 0;
}
+
+.v-window-resizebox,
+.v-window-resizingCurtain {
+ cursor: se-resize;
+}
+
.v-window div.v-window-footer-noresize {
height: 0;
}
diff --git a/WebContent/VAADIN/themes/chameleon/components/tabsheet/tabsheet.css b/WebContent/VAADIN/themes/chameleon/components/tabsheet/tabsheet.css
index 0db9b9d960..d1697c584a 100644
--- a/WebContent/VAADIN/themes/chameleon/components/tabsheet/tabsheet.css
+++ b/WebContent/VAADIN/themes/chameleon/components/tabsheet/tabsheet.css
@@ -93,7 +93,6 @@
width: 16px;
height: 14px;
overflow: hidden;
- cursor: default;
opacity: .5;
filter: alpha(opacity=50);
}
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/WebContent/VAADIN/themes/reindeer/tabsheet/tabsheet-scroller.css b/WebContent/VAADIN/themes/reindeer/tabsheet/tabsheet-scroller.css
index 217676558e..18ad5c9194 100644
--- a/WebContent/VAADIN/themes/reindeer/tabsheet/tabsheet-scroller.css
+++ b/WebContent/VAADIN/themes/reindeer/tabsheet/tabsheet-scroller.css
@@ -24,7 +24,6 @@
width: 18px;
height: 17px;
overflow: hidden;
- cursor: default;
}
.v-tabsheet-scroller button::-moz-focus-inner {
border: none;
diff --git a/build/build.properties b/build/build.properties
index df8e6e77a8..a1b285c952 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 e21984cf06..0fe17a5b73 100644
--- a/build/build.xml
+++ b/build/build.xml
@@ -25,20 +25,37 @@
<target name="init-deps" depends="common.init-deps" >
<property name="ivy.resolved" value="1" />
- <ivy:resolve file="build/ivy/ivy.xml" resolveid="common" conf="ss.compile, cs.compile, ss.test.runtime"/>
- <ivy:cachepath pathid="compile.classpath" conf="ss.compile"/>
- <ivy:cachepath pathid="client-side.compile.classpath" conf="cs.compile"/>
- <ivy:cachepath pathid="test.runtime.classpath" conf="ss.test.runtime"/>
+ <ivy:resolve file="build/ivy/ivy.xml" resolveid="common" conf="ss.compile, cs.compile, ss.test.compile"/>
+ <ivy:cachepath pathid="compile.classpath.server-side" conf="ss.compile"/>
+ <ivy:cachepath pathid="compile.classpath.client-side" conf="cs.compile"/>
+ <ivy:cachepath pathid="compile.classpath.server-side-tests" conf="ss.test.compile"/>
</target>
<!-- Clean results - - - - - - - - - - - - - - - - - - - - - - - - - -->
- <target name="clean-result" depends="">
- <property file="build/build.properties" />
+ <target name="clean-result" depends="build.properties">
<!-- Clean build result directory. -->
<delete dir="${result-path}" includes="**/*" followsymlinks="false" defaultexcludes="false" includeemptydirs="true" failonerror="false"/>
</target>
+ <target name="build.properties">
+ <property file="build/build.properties" />
+
+ <property file="build/VERSION.properties" />
+ <property file="build/GWT-VERSION.properties" />
+
+ <!-- result source and classes folders -->
+ <property name="result-src-core" value="${result-path}/src/core"/>
+ <property name="result-src-junit" value="${result-path}/src/junit"/>
+ <property name="result-src-testbench" value="${result-path}/src/testbench"/>
+ <property name="result-classes-core" value="${result-path}/classes/core"/>
+ <property name="result-classes-junit" value="${result-path}/classes/junit"/>
+ <property name="result-classes-testbench" value="${result-path}/classes/testbench"/>
+ <!-- Folder where Emma instrumented classes are placed (if Emma is used)-->
+ <property name="result-classes-core-for-emma-war" value="${result-path}/classes/emma-war"/>
+ <property name="result-classes-core-for-emma-junit" value="${result-path}/classes/emma-junit"/>
+
+ </target>
<target name="clean-all" depends="clean-result">
</target>
@@ -62,7 +79,7 @@
<!-- Initialization - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- ================================================================== -->
- <target name="init" depends="init-deps">
+ <target name="init" depends="init-deps, build.properties">
<!-- Current timestamp in different formats. -->
<tstamp>
<format property="build.date" pattern="yyyy-MM-dd"/>
@@ -71,9 +88,6 @@
<format property="build.date.compact" pattern="yyyyMMdd"/>
</tstamp>
- <property file="build/VERSION.properties" />
- <property file="build/GWT-VERSION.properties" />
-
<antcontrib:propertyregex property="version.major" input="${version}" regexp="([^\.]*)\.([^\.]*)\.([^\.]*)" select="\1"/>
<antcontrib:propertyregex property="version.minor" input="${version}" regexp="([^\.]*)\.([^\.]*)\.([^\.]*)" select="\2"/>
<antcontrib:propertyregex property="version.revision" input="${version}" regexp="([^\.]*)\.([^\.]*)\.([^\.]*)" select="\3"/>
@@ -85,17 +99,16 @@
<echo>Full Version: ${version.full}</echo>
<!-- Other properties -->
- <property file="build/build.properties" />
<property file="build/html-style.properties" />
- <echo>Vaadin package is: ${toolkit-package}</echo>
+ <echo>Vaadin package is: ${vaadin-package}</echo>
<!-- Create result dir unless already exists -->
<mkdir dir="${result-path}" />
<!-- Create dirs that might be used by the test coverage generation -->
- <mkdir dir="${result-path}/war_emma_classes" />
- <mkdir dir="${result-path}/junit_emma_classes" />
+ <mkdir dir="${result-classes-core-for-emma-war}" />
+ <mkdir dir="${result-classes-core-for-emma-junit}" />
<mkdir dir="${result-path}/coverage" />
<echo>We are using gwt version ${gwt-version}.</echo>
@@ -139,13 +152,17 @@
<echo>Adding test class files and resources and launcher configuration.</echo>
<copy todir="${output-dir}/WebContent/WEB-INF/classes">
- <fileset dir="${result-path}/classes">
- <include name="${toolkit-package}/tests/**/*" />
- <include name="${toolkit-package}/launcher/**" />
+ <fileset dir="${result-classes-testbench}">
+ <include name="${vaadin-package}/tests/**/*" />
+ <include name="${vaadin-package}/launcher/**" />
+ </fileset>
+ <fileset dir="${result-classes-junit}">
+ <!-- VaadinClasses is used by both JUnit and TestBench tests -->
+ <include name="**/VaadinClasses*.class" />
</fileset>
<!-- test resources -->
<fileset dir="tests/testbench">
- <include name="${toolkit-package}/tests/**/*" />
+ <include name="${vaadin-package}/tests/**/*" />
<!-- Pre-processed versions of these copied above -->
<exclude name="**/*.java" />
<exclude name="**/*.html" />
@@ -155,8 +172,8 @@
<!-- Include files required by the DemoLauncher/DevelopmentServerLauncher -->
<fileset dir="tests/testbench">
- <include name="${toolkit-package}/launcher/jetty-webdefault.xml" />
- <include name="${toolkit-package}/launcher/keystore" />
+ <include name="${vaadin-package}/launcher/jetty-webdefault.xml" />
+ <include name="${vaadin-package}/launcher/keystore" />
</fileset>
</copy>
@@ -216,11 +233,11 @@
<!-- However, since compiling the server-side is required by the client-side -->
<!-- compilation, the server-side will actually be built before it. -->
<target name="build"
- depends="compile-server-side, compile-client-side, vaadin.jar, vaadin-sources.jar"
+ depends="compile-server-side, compile-tests, compile-client-side, vaadin.jar, vaadin-sources.jar"
description="Build package required files, without packing them.">
</target>
- <target name="compile-server-side" depends="compile-java, webcontent"/>
+ <target name="compile-server-side" depends="compile-core, webcontent"/>
<!-- Copy and preprocess sources for packaging
NOTE: Replaces <version></version> tags with build version tag for some "textual" files
@@ -234,20 +251,25 @@
* tests/client-side (Client-side JUnit test cases)
These are copied to
- * {$result-path}/src/core
- * {$result-path}/src/tests
- * {$result-path}/src/junit
-
+ * ${result-path}/src/core
+ * ${result-path}/src/tests
+ * ${result-path}/src/junit
+
+ And compiled to
+ * ${result-path}/classes/core
+ * ${result-path}/classes/tests
+ * ${result-path}/classes/junit
+
Java/HTML/CSS/XML files are filtered so the license is added and the version is set.
Other files are just copied.
-->
<loadfile property="VaadinApache2LicenseForJavaFiles" srcFile="build/VaadinApache2LicenseForJavaFiles.txt" />
- <mkdir dir="${result-path}/src" />
- <mkdir dir="${result-path}/src/core" />
- <mkdir dir="${result-path}/src/tests" />
- <mkdir dir="${result-path}/src/junit" />
+ <mkdir dir="${result-path}/src" />
+ <mkdir dir="${result-src-core}" />
+ <mkdir dir="${result-src-testbench}" />
+ <mkdir dir="${result-src-junit}" />
<patternset id="preprocessable-files">
<include name="**/*.java" />
@@ -274,7 +296,7 @@
<echo>Copying src directory and processing copied files.</echo>
<echo>Replacing &lt;version&gt; tag with build version for java/html/css/xml files.</echo>
- <copy todir="${result-path}/src/core" overwrite="yes">
+ <copy todir="${result-src-core}" overwrite="yes">
<filterset refid="version-and-license"/>
<filterset refid="pre-css-style"/>
<fileset dir="src">
@@ -282,13 +304,13 @@
</fileset>
</copy>
- <copy todir="${result-path}/src/tests">
+ <copy todir="${result-src-testbench}">
<filterset refid="version-and-license"/>
<fileset dir="tests/testbench">
<patternset refid="preprocessable-files" />
</fileset>
</copy>
- <copy todir="${result-path}/src/junit">
+ <copy todir="${result-src-junit}">
<filterset refid="version-and-license"/>
<fileset dir="tests/server-side">
<patternset refid="preprocessable-files" />
@@ -304,17 +326,17 @@
<!-- Add other files such as images, these are not filtered or processed by fixcrlf task -->
<echo>Copying non java/html/css/xml files such as images.</echo>
- <copy todir="${result-path}/src/core">
+ <copy todir="${result-src-core}">
<fileset dir="src">
<patternset refid="non-preprocessable-files" />
</fileset>
</copy>
- <copy todir="${result-path}/src/tests">
+ <copy todir="${result-src-testbench}">
<fileset dir="tests/testbench">
<patternset refid="non-preprocessable-files" />
</fileset>
</copy>
- <copy todir="${result-path}/src/junit">
+ <copy todir="${result-src-junit}">
<fileset dir="tests/server-side">
<patternset refid="non-preprocessable-files" />
</fileset>
@@ -331,12 +353,11 @@
<target name="webcontent" depends="preprocess-src,defaulttheme">
<!-- Add WebContent -->
- <echo>Adding VAADIN/themes and demo files.</echo>
+ <echo>Adding VAADIN/themes and META-INF</echo>
<copy todir="${output-dir}/WebContent">
<fileset dir="WebContent">
<exclude name="**/.svn" />
- <!-- TODO check what is necessary -->
- <include name="demo/**/*" />
+ <include name="WEB-INF/lib/hsqldb.jar" />
<include name="VAADIN/themes/**/*" />
<include name="VAADIN/vaadinBootstrap.js" />
<include name="META-INF/**/*" />
@@ -379,27 +400,40 @@
</copy>
</target>
- <target name="compile-java" depends="init, webcontent">
+ <target name="compile-core" depends="init, preprocess-src">
<echo>Compiling src (server-side)</echo>
-
- <!-- Compile all sources at the same time as they depend on each other -->
- <mkdir dir="${result-path}/classes" />
- <javac source="1.5" target="1.5" includeantruntime="false" destdir="${result-path}/classes" debug="true" encoding="UTF-8">
- <classpath>
- <path refid="compile.classpath" />
- <path refid="test.runtime.classpath" />
- </classpath>
- <src path="${result-path}/src/core"/>
- <src path="${result-path}/src/tests"/>
- <src path="${result-path}/src/junit"/>
+ <!-- Compile core sources first as the other sources depend on these -->
+ <mkdir dir="${result-classes-core}" />
+ <javac source="1.5" target="1.5" classpathref="compile.classpath.server-side" destdir="${result-classes-core}" debug="true" encoding="UTF-8" includeantruntime="false">
+ <src path="${result-src-core}"/>
+ </javac>
+ </target>
+
+ <target name="compile-tests" depends="compile-core">
+ <echo>Compiling src (Server and client side JUnit tests)</echo>
+ <!-- Compile server and client side JUnit tests -->
+ <mkdir dir="${result-classes-junit}" />
+ <javac source="1.5" target="1.5" classpathref="compile.classpath.server-side-tests" destdir="${result-classes-junit}" debug="true" encoding="UTF-8" includeantruntime="false">
+ <classpath path="${result-classes-core}"></classpath>
+ <src path="${result-src-junit}"/>
+ </javac>
+
+ <echo>Compiling src (TestBench tests)</echo>
+ <!-- Compile TestBench tests -->
+ <mkdir dir="${result-classes-testbench}" />
+ <javac source="1.5" target="1.5" classpathref="compile.classpath.server-side" destdir="${result-classes-testbench}" debug="true" encoding="UTF-8" includeantruntime="false">
+ <classpath path="${result-classes-junit}"></classpath>
+ <classpath path="${result-classes-core}"></classpath>
+ <src path="${result-src-testbench}"/>
</javac>
+
</target>
<target name="compile-helpers" depends="init">
<mkdir dir="${buildhelpers-classes}" />
<ivy:cachepath pathid="buildhelpers.dependencies" resolveId="buildhelpers" conf="compile" file="build/ivy/buildhelpers-ivy.xml"/>
<javac source="1.5" target="1.5" includeantruntime="false" srcdir="${buildhelpers-src}"
- classpathref="buildhelpers.dependencies" destdir="${buildhelpers-classes}" debug="true" encoding="UTF-8" />
+ classpathref="buildhelpers.dependencies" destdir="${buildhelpers-classes}" debug="true" encoding="UTF-8" />
</target>
<target name="defaulttheme" depends="init, compile-helpers">
@@ -441,8 +475,8 @@
</target>
<!-- The widgetset generator is currently compiled along with rest of server-side Java. -->
- <target name="compile-widgetset-generator" depends="init, preprocess-src, compile-java"/>
-
+ <target name="compile-widgetset-generator" depends="compile-core"/>
+
<target name="compile-widgetset" depends="init-deps" description="Compiles the widgetset given as the first parameter">
<fail unless="widgetset" message="No widgetset parameter set"/>
<property name="widgetset-style" value="OBF" />
@@ -452,9 +486,9 @@
<mkdir dir="${widgetsets-output-dir}"/>
<java classname="com.google.gwt.dev.Compiler" failonerror="yes" fork="yes" maxmemory="512m">
<classpath>
- <path refid="client-side.compile.classpath" />
- <pathelement location="${result-path}/classes" />
- <pathelement location="${result-path}/src/core" />
+ <path refid="compile.classpath.client-side" />
+ <pathelement location="${result-classes-core}" />
+ <pathelement location="${result-src-core}" />
</classpath>
<arg value="-war" />
<arg value="${widgetsets-output-dir}" />
@@ -476,14 +510,14 @@
<target name="compile-widgetset-default">
<antcall target="compile-widgetset">
- <reference refid="client-side.compile.classpath" />
+ <reference refid="compile.classpath.client-side" />
<param name="widgetset" value="com.vaadin.terminal.gwt.DefaultWidgetSet"/>
</antcall>
</target>
<target name="compile-widgetset-portal-default" unless="compile.only.default-widgetset">
<antcall target="compile-widgetset">
- <reference refid="client-side.compile.classpath" />
+ <reference refid="compile.classpath.client-side" />
<param name="widgetset" value="com.vaadin.portal.gwt.PortalDefaultWidgetSet"/>
</antcall>
</target>
@@ -500,12 +534,7 @@
</target>
<!-- Definitions for building local components, i.e., not for an installation package. -->
- <target name="init-nonpackage">
- <property file="build/VERSION.properties" />
- <property file="build/GWT-VERSION.properties" />
-
- <property file="build/build.properties" />
-
+ <target name="init-nonpackage" depends="build.properties">
<!-- Definitions for building the client-side. -->
<property name="widgetsets-output-dir" value="WebContent/VAADIN/widgetsets" />
@@ -537,18 +566,14 @@
<echo file="${output-dir}/META-INF/GWT-VERSION">${gwt-version}</echo>
<emma enabled="${emma.enabled}" >
- <instr instrpath="${result-path}/classes"
- destdir="${result-path}/war_emma_classes"
+ <instr instrpath="${result-classes-core}"
+ destdir="${result-classes-core-for-emma-war}"
mode="copy"
metadatafile="${result-path}/war.es"
merge="false"
>
<filter includes="com.vaadin.*" />
<filter excludes="com.vaadin.terminal.gwt.*" />
- <filter excludes="com.vaadin.tests.*" />
- <filter excludes="*Test*" />
- <filter excludes="com.vaadin.launcher.*" />
- <filter excludes="com.vaadin.data.util.sqlcontainer.*" />
</instr>
</emma>
@@ -566,24 +591,10 @@
<attribute name="Bundle-Version" value="${version.full}" />
</manifest>
<!-- Include any instrumented class files before the normal classes -->
- <fileset dir="${result-path}/war_emma_classes">
- <patternset>
- <exclude name="${toolkit-package}/tests/**"/>
- <exclude name="${toolkit-package}/launcher/**" />
- </patternset>
- </fileset>
- <fileset dir="${result-path}/classes">
- <patternset>
- <exclude name="${toolkit-package}/tests/**"/>
- <exclude name="${toolkit-package}/launcher/**" />
- </patternset>
- </fileset>
+ <fileset dir="${result-classes-core-for-emma-war}" />
+ <fileset dir="${result-classes-core}"/>
<!-- add sources -->
- <fileset dir="${result-path}/src/core">
- <patternset>
- <exclude name="${toolkit-package}/launcher/**" />
- </patternset>
- </fileset>
+ <fileset dir="${result-src-core}"/>
<fileset dir="${output-dir}/WebContent">
<patternset>
<include name="VAADIN/widgetsets/com.vaadin.terminal.gwt.DefaultWidgetSet/**/*" />
@@ -615,7 +626,7 @@
<target name="vaadin-sources.jar" depends="init">
<jar file="${result-path}/${lib-sources-jar-name}" compress="true">
- <fileset dir="${result-path}/src/core">
+ <fileset dir="${result-src-core}">
<patternset>
<include name="**/*.java" />
</patternset>
@@ -641,10 +652,8 @@
<target name="javadoc" depends="init, preprocess-src">
<property name="javadoc.destdir" value="${output-dir}/WebContent/docs/api"/>
- <javadoc destdir="${javadoc.destdir}" author="true" version="true" use="true" windowtitle="${product-name}" classpathref="compile.classpath">
- <packageset dir="${result-path}/src/core">
- <include name="${toolkit-package}/**" />
- </packageset>
+ <javadoc destdir="${javadoc.destdir}" author="true" version="true" use="true" windowtitle="${product-name}" classpathref="compile.classpath.client-side">
+ <packageset dir="${result-src-core}"/>
<doctitle>${javadoc.doctitle}</doctitle>
<!-- <header><![CDATA[<script type="text/javascript" src=".html-style/style.js"></script>]]></header> -->
<bottom>${javadoc.bottom}</bottom>
@@ -734,7 +743,7 @@
<!-- Initialize a nightly build. -->
- <target name="nightly-init">
+ <target name="nightly-init" depends="build.properties">
<!-- Mandatory parameters. -->
<fail unless="build.number" message="The build.number property must be defined."/>
@@ -743,8 +752,6 @@
<!-- Optional parameters. -->
<property name="build.tag" value="dev"/>
- <property file="build/VERSION.properties" />
-
<echo>Base version: ${version}</echo>
<echo>Build number: ${build.number}</echo>
<echo>Build tag: ${build.tag}</echo>
@@ -870,7 +877,7 @@
<!-- Automated tests. -->
<!-- ================================================================== -->
- <target name="tests" depends="compile-java, internal-package-war">
+ <target name="tests" depends="compile-tests, internal-package-war">
<!-- Run all different types of tests in parallel to decrease testing time -->
<parallel threadcount="3">
<sequential>
@@ -890,7 +897,7 @@
<include name="*.em" />
</fileset>
</merge>
- <report sourcepath="${result-path}/src/core" >
+ <report sourcepath="${result-src-core}" >
<fileset dir="${result-path}" >
<include name="combined.es" />
</fileset>
@@ -903,38 +910,34 @@
</target>
<!-- Assumes java classes have been compiled but depends does not work out well as this is run from a <parallel> task-->
- <target name="server-side-tests" depends="init-deps" unless="tests.serverside.skip">
+ <target name="server-side-tests" unless="tests.serverside.skip" depends="compile-tests">
<emma enabled="${emma.enabled}" >
- <instr instrpath="${result-path}/classes"
+ <instr instrpath="${result-classes-core}"
+ destdir="${result-classes-core-for-emma-junit}"
mode="copy"
- destdir="${result-path}/junit_emma_classes"
metadatafile="${result-path}/unittests.em"
- merge="false"
- >
+ merge="false"
+ >
<filter includes="com.vaadin.*" />
- <filter excludes="com.vaadin.tests.*" />
- <filter excludes="com.vaadin.terminal.gwt.client.*" />
- <filter excludes="com.vaadin.terminal.gwt.widgetsetutils.*" />
- <filter excludes="*Test*" />
- <filter excludes="com.vaadin.launcher.*" />
+ <filter excludes="com.vaadin.terminal.gwt.*" />
</instr>
</emma>
<junit printsummary="yes">
<classpath>
- <pathelement path="${result-path}/junit_emma_classes" />
- <pathelement path="${result-path}/classes" />
- <path refid="test.runtime.classpath"></path>
- <path refid="compile.classpath"></path>
+ <pathelement path="${result-classes-core-for-emma-junit}" />
+ <pathelement path="${result-classes-core}" />
+ <pathelement path="${result-classes-junit}" />
+ <path refid="compile.classpath.server-side-tests"></path>
</classpath>
<jvmarg value="-Demma.coverage.out.file=../${result-path}/unittests.ec" />
<batchtest fork="yes">
- <fileset dir="tests/server-side" includes="**/*.java" excludes="**/Abstract*.java,com/vaadin/tests/data/bean/*.java,com/vaadin/tests/util/*.java" />
+ <fileset dir="tests/server-side" includes="**/*.java" excludes="**/Abstract*.java,com/vaadin/tests/data/bean/*.java,com/vaadin/tests/util/*.java,**/VaadinClasses.java" />
<fileset dir="tests/client-side" includes="**/*.java" excludes="**/Abstract*.java" />
</batchtest>
</junit>
<emma enabled="${emma.enabled}" >
- <report sourcepath="${result-path}/src/core" >
+ <report sourcepath="${result-src-core}" >
<fileset dir="${result-path}" >
<include name="unittests.*" />
</fileset>
@@ -989,7 +992,7 @@
</ant>
<emma enabled="${emma.enabled}" >
- <report sourcepath="${result-path}/src/core" >
+ <report sourcepath="${result-src-core}" >
<fileset dir="${result-path}" >
<include name="war.*" />
</fileset>
diff --git a/build/ivy/ivy.xml b/build/ivy/ivy.xml
index 4fcb44887b..ffcf7b19c8 100644
--- a/build/ivy/ivy.xml
+++ b/build/ivy/ivy.xml
@@ -6,7 +6,7 @@
<configurations >
<conf name="ss.compile" extends="cs.compile" description="Server side compilation dependencies" visibility="private"/>
<conf name="cs.compile" description="Client side compilation dependencies" visibility="private"/>
- <conf name="ss.test.runtime" description="Test runtime dependencies" visibility="private"/>
+ <conf name="ss.test.compile" extends="ss.compile" description="Test compilation dependencies" visibility="private"/>
<conf name="taskdefs" description="Ant task definitions" visibility="private" />
</configurations>
<publications />
@@ -26,21 +26,21 @@
<dependency org="com.google.gwt" name="gwt-dev" rev="2.4.0" conf="cs.compile->master" />
<!-- Test frameworks & related -->
- <dependency org="junit" name="junit" rev="4.5" conf="ss.test.runtime -> master"/>
- <dependency org="org.easymock" name="easymock" rev="3.0" conf="ss.test.runtime -> master, runtime(*)"/>
- <dependency org="org.hsqldb" name="hsqldb" rev="2.2.6" conf="ss.test.runtime -> master, runtime(*)"/>
+ <dependency org="junit" name="junit" rev="4.5" conf="ss.test.compile -> master"/>
+ <dependency org="org.easymock" name="easymock" rev="3.0" conf="ss.test.compile -> master, runtime(*)"/>
+ <dependency org="org.hsqldb" name="hsqldb" rev="2.2.6" conf="ss.test.compile -> master, runtime(*)"/>
<!-- Ant tasks -->
<dependency org="ant-contrib" name="ant-contrib" rev="1.0b3" conf="taskdefs ->master"/>
<dependency org="org.apache.maven" name="maven-ant-tasks" rev="2.0.10" conf="taskdefs ->master"/>
<!-- Emma -->
- <dependency org="emma" name="emma_ant" rev="2.0.5312" conf="ss.test.runtime,taskdefs ->master"/>
- <dependency org="emma" name="emma" rev="2.0.5312-patched" conf="ss.test.runtime,taskdefs ->*"/>
+ <dependency org="emma" name="emma_ant" rev="2.0.5312" conf="ss.test.compile,taskdefs ->master"/>
+ <dependency org="emma" name="emma" rev="2.0.5312-patched" conf="ss.test.compile,taskdefs ->*"/>
<!-- Bean Validation implementation -->
- <dependency org="org.slf4j" name="slf4j-log4j12" rev="1.6.1" conf="ss.test.runtime -> default"/>
- <dependency org="org.hibernate" name="hibernate-validator" rev="4.2.0.Final" conf="ss.test.runtime -> default"/>
+ <dependency org="org.slf4j" name="slf4j-log4j12" rev="1.6.1" conf="ss.test.compile -> default"/>
+ <dependency org="org.hibernate" name="hibernate-validator" rev="4.2.0.Final" conf="ss.test.compile -> default"/>
</dependencies>
</ivy-module> \ No newline at end of file
diff --git a/src/com/vaadin/data/validator/CompositeValidator.java b/src/com/vaadin/data/validator/CompositeValidator.java
index 083af70f30..956d773032 100644
--- a/src/com/vaadin/data/validator/CompositeValidator.java
+++ b/src/com/vaadin/data/validator/CompositeValidator.java
@@ -155,7 +155,7 @@ public class CompositeValidator implements Validator {
*/
public void setMode(CombinationMode mode) {
if (mode == null) {
- throw new IllegalStateException(
+ throw new IllegalArgumentException(
"The validator can't be set to null");
}
this.mode = mode;
diff --git a/src/com/vaadin/terminal/Sizeable.java b/src/com/vaadin/terminal/Sizeable.java
index 055c74f20f..e3c98e0fa9 100644
--- a/src/com/vaadin/terminal/Sizeable.java
+++ b/src/com/vaadin/terminal/Sizeable.java
@@ -129,14 +129,14 @@ public interface Sizeable extends Serializable {
public static Unit getUnitFromSymbol(String symbol) {
if (symbol == null) {
- return null;
+ return Unit.PIXELS; // Defaults to pixels
}
for (Unit unit : Unit.values()) {
if (symbol.equals(unit.getSymbol())) {
return unit;
}
}
- return null;
+ return Unit.PIXELS; // Defaults to pixels
}
}
diff --git a/src/com/vaadin/terminal/UserError.java b/src/com/vaadin/terminal/UserError.java
index 1cb79c146a..8ec45ac725 100644
--- a/src/com/vaadin/terminal/UserError.java
+++ b/src/com/vaadin/terminal/UserError.java
@@ -89,6 +89,12 @@ public class UserError implements ErrorMessage {
public UserError(String message, ContentMode contentMode,
ErrorLevel errorLevel) {
+ if (contentMode == null) {
+ contentMode = ContentMode.TEXT;
+ }
+ if (errorLevel == null) {
+ errorLevel = ErrorLevel.ERROR;
+ }
msg = message;
mode = contentMode;
level = errorLevel;
diff --git a/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java b/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java
index 5e1bb89b0c..e790c1d3fc 100644
--- a/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java
+++ b/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java
@@ -25,6 +25,8 @@ import com.google.gwt.http.client.RequestException;
import com.google.gwt.http.client.Response;
import com.google.gwt.json.client.JSONArray;
import com.google.gwt.json.client.JSONString;
+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;
@@ -41,6 +43,7 @@ import com.vaadin.terminal.gwt.client.RenderInformation.Size;
import com.vaadin.terminal.gwt.client.communication.JsonEncoder;
import com.vaadin.terminal.gwt.client.communication.MethodInvocation;
import com.vaadin.terminal.gwt.client.ui.Field;
+import com.vaadin.terminal.gwt.client.ui.VAbstractPaintableWidget;
import com.vaadin.terminal.gwt.client.ui.VContextMenu;
import com.vaadin.terminal.gwt.client.ui.VNotification;
import com.vaadin.terminal.gwt.client.ui.VNotification.HideEvent;
@@ -102,6 +105,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.
+ *
+ * <p>
+ * This allows, for instance, a servlet filter to redirect the application
+ * to a custom login page when the session expires. For example:
+ * </p>
+ *
+ * <pre>
+ * if (sessionExpired) {
+ * response.setHeader(&quot;Content-Type&quot;, &quot;text/html&quot;);
+ * response.getWriter().write(
+ * myLoginPageHtml + &quot;&lt;!-- Vaadin-Refresh: &quot;
+ * + request.getContextPath() + &quot; --&gt;&quot;);
+ * }
+ * </pre>
+ */
+ public static final String UIDL_REFRESH_TOKEN = "Vaadin-Refresh";
+
// will hold the UIDL security key (for XSS protection) once received
private String uidlSecurityKey = "init";
@@ -526,6 +550,25 @@ 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. See #8241.
+ */
+ MatchResult refreshToken = RegExp.compile(
+ UIDL_REFRESH_TOKEN + "(:\\s*(.*?))?(\\s|$)")
+ .exec(response.getText());
+ if (refreshToken != null) {
+ redirect(refreshToken.getGroup(2));
+ return;
+ }
+ }
+
// for(;;);[realjson]
final String jsonText = response.getText().substring(9,
response.getText().length() - 1);
@@ -1540,9 +1583,10 @@ public class ApplicationConnection {
*
* @return Returns true iff no further painting is needed by caller
*/
- public boolean updateComponent(Widget component, UIDL uidl,
+ @Deprecated
+ public boolean updateComponent(VPaintableWidget paintable, UIDL uidl,
boolean manageCaption) {
- VPaintableWidget paintable = paintableMap.getPaintable(component);
+ Widget component = paintable.getWidgetForPaintable();
String pid = paintableMap.getPid(paintable);
if (pid == null) {
@@ -1603,9 +1647,68 @@ public class ApplicationConnection {
fw.setEnabled(enabled);
}
+ // Style names
+ component.setStyleName(getStyleName(component.getStylePrimaryName(),
+ uidl, component instanceof Field));
+
+ TooltipInfo tooltipInfo = paintableMap.getTooltipInfo(paintable, null);
+ // Update tooltip
+ if (uidl.hasAttribute(ATTRIBUTE_DESCRIPTION)) {
+ tooltipInfo
+ .setTitle(uidl.getStringAttribute(ATTRIBUTE_DESCRIPTION));
+ } else {
+ tooltipInfo.setTitle(null);
+ }
+
+ // Set captions
+ if (manageCaption) {
+ final Container parent = Util.getLayout(component);
+ if (parent != null) {
+ parent.updateCaption(paintable, uidl);
+ }
+ }
+
+ // add error classname to components w/ error
+ if (uidl.hasAttribute(ATTRIBUTE_ERROR)) {
+ tooltipInfo.setErrorUidl(uidl.getErrors());
+ } else {
+ tooltipInfo.setErrorUidl(null);
+ }
+
+ // Set captions
+ if (manageCaption) {
+ final Container parent = Util.getLayout(component);
+ if (parent != null) {
+ parent.updateCaption(paintable, uidl);
+ }
+ }
+ /*
+ * updateComponentSize need to be after caption update so caption can be
+ * taken into account
+ */
+
+ updateComponentSize(paintable, 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) {
@@ -1623,7 +1726,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(" ");
@@ -1632,55 +1735,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 = paintableMap.getTooltipInfo(paintable, 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, uidl);
- }
- }
- /*
- * updateComponentSize need to be after caption update so caption can be
- * taken into account
- */
-
- updateComponentSize(paintable, uidl);
-
- return false;
+ return styleBuf.toString();
}
private void updateComponentSize(VPaintableWidget paintable, UIDL uidl) {
@@ -1773,7 +1846,7 @@ public class ApplicationConnection {
while (childWidgets.hasNext()) {
final Widget child = childWidgets.next();
- if (child instanceof VPaintableWidget) {
+ if (getPaintableMap().isPaintable(child)) {
if (handleComponentRelativeSize(child)) {
/*
@@ -1808,7 +1881,7 @@ public class ApplicationConnection {
if (paintable == null) {
return false;
}
- boolean debugSizes = false;
+ boolean debugSizes = true;
FloatSize relativeSize = paintableMap.getRelativeSize(paintable);
if (relativeSize == null) {
@@ -1983,6 +2056,10 @@ public class ApplicationConnection {
if (!paintableMap.hasPaintable(pid)) {
// Create and register a new paintable if no old was found
VPaintableWidget p = widgetSet.createWidget(uidl, configuration);
+ if (p instanceof VAbstractPaintableWidget) {
+ ((VAbstractPaintableWidget) p).setConnection(this);
+ ((VAbstractPaintableWidget) p).init();
+ }
paintableMap.registerPaintable(pid, p);
}
return (VPaintableWidget) paintableMap.getPaintable(pid);
@@ -2146,7 +2223,7 @@ public class ApplicationConnection {
}
};
- private VPaintableMap paintableMap = new VPaintableMap();
+ private VPaintableMap paintableMap = GWT.create(VPaintableMap.class);
/**
* Components can call this function to run all layout functions. This is
@@ -2229,7 +2306,7 @@ public class ApplicationConnection {
* @return true if at least one listener has been registered on server side
* for the event identified by eventIdentifier.
*/
- public boolean hasEventListeners(VPaintable paintable,
+ public boolean hasEventListeners(VPaintableWidget paintable,
String eventIdentifier) {
return paintableMap.hasEventListeners(paintable, eventIdentifier);
}
@@ -2284,4 +2361,31 @@ public class ApplicationConnection {
paintableMap.unregisterPaintable(p);
}
+ public VTooltip getVTooltip() {
+ return tooltip;
+ }
+
+ @Deprecated
+ public void handleWidgetTooltipEvent(Event event, Widget owner, Object key) {
+ handleTooltipEvent(event, getPaintableMap().getPaintable(owner), key);
+
+ }
+
+ @Deprecated
+ public void handleWidgetTooltipEvent(Event event, Widget owner) {
+ handleTooltipEvent(event, getPaintableMap().getPaintable(owner));
+
+ }
+
+ @Deprecated
+ public void registerWidgetTooltip(Widget owner, Object key, TooltipInfo info) {
+ registerTooltip(getPaintableMap().getPaintable(owner), key, info);
+ }
+
+ @Deprecated
+ public boolean hasWidgetEventListeners(Widget widget, String eventIdentifier) {
+ return hasEventListeners(getPaintableMap().getPaintable(widget),
+ eventIdentifier);
+ }
+
}
diff --git a/src/com/vaadin/terminal/gwt/client/Container.java b/src/com/vaadin/terminal/gwt/client/Container.java
index 7c92bc261b..db6bbf0ee4 100644
--- a/src/com/vaadin/terminal/gwt/client/Container.java
+++ b/src/com/vaadin/terminal/gwt/client/Container.java
@@ -42,12 +42,12 @@ public interface Container extends VPaintableWidget {
* must provide service for it's childen to show those elements for them.
* </p>
*
- * @param component
+ * @param paintable
* Child component for which service is requested.
* @param uidl
* UIDL of the child component.
*/
- void updateCaption(VPaintableWidget component, UIDL uidl);
+ void updateCaption(VPaintableWidget paintable, UIDL uidl);
/**
* Called when a child components size has been updated in the rendering
diff --git a/src/com/vaadin/terminal/gwt/client/Util.java b/src/com/vaadin/terminal/gwt/client/Util.java
index b411d9a89e..4487341bd7 100644
--- a/src/com/vaadin/terminal/gwt/client/Util.java
+++ b/src/com/vaadin/terminal/gwt/client/Util.java
@@ -832,6 +832,24 @@ public class Util {
}-*/;
/**
+ * Helper method to find the nearest parent paintable instance by traversing
+ * the DOM upwards from given element.
+ *
+ * @param element
+ * the element to start from
+ */
+ public static VPaintableWidget findPaintable(ApplicationConnection client,
+ Element element) {
+ Widget widget = Util.findWidget(element, null);
+ VPaintableMap vPaintableMap = VPaintableMap.get(client);
+ while (widget != null && !vPaintableMap.isPaintable(widget)) {
+ widget = widget.getParent();
+ }
+ return vPaintableMap.getPaintable(widget);
+
+ }
+
+ /**
* Helper method to find first instance of given Widget type found by
* traversing DOM upwards from given element.
*
@@ -968,6 +986,8 @@ public class Util {
+ invocation.getMethodName() + "(" + formattedParams
+ ")");
}
+ } else {
+ VConsole.log("\t" + id + ": Warning: no corresponding paintable!");
}
}
diff --git a/src/com/vaadin/terminal/gwt/client/VDebugConsole.java b/src/com/vaadin/terminal/gwt/client/VDebugConsole.java
index 892260e6ca..fdaf944b9f 100644
--- a/src/com/vaadin/terminal/gwt/client/VDebugConsole.java
+++ b/src/com/vaadin/terminal/gwt/client/VDebugConsole.java
@@ -734,8 +734,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/VPaintable.java b/src/com/vaadin/terminal/gwt/client/VPaintable.java
index 02b529b428..d85c6d33e2 100644
--- a/src/com/vaadin/terminal/gwt/client/VPaintable.java
+++ b/src/com/vaadin/terminal/gwt/client/VPaintable.java
@@ -4,8 +4,13 @@
package com.vaadin.terminal.gwt.client;
/**
- * TODO
+ * Interface implemented by all client side classes that can be communicate with
+ * the server. Classes implementing this interface are initialized by the
+ * framework when needed and have the ability to communicate with the server.
*
+ * @author Vaadin Ltd
+ * @version @VERSION@
+ * @since 7.0.0
*/
public interface VPaintable {
/**
@@ -16,4 +21,54 @@ public interface VPaintable {
*/
public void updateFromUIDL(UIDL uidl, ApplicationConnection client);
+ // /**
+ // * Returns the id for this VPaintable. This must always be what has been
+ // set
+ // * using {@link #setId(String)}.
+ // *
+ // * @return The id for the VPaintable.
+ // */
+ // public String getId();
+ //
+ // /**
+ // * Sets the id for the VPaintable. This method is called once by the
+ // * framework when the VPaintable is initialized and should never be called
+ // * otherwise.
+ // * <p>
+ // * The VPaintable id is used to map the server and the client paintables
+ // * together. It is unique in this root and assigned by the framework.
+ // * </p>
+ // *
+ // * @param id
+ // * The id of the paintable.
+ // */
+ // public void setId(String id);
+
+ /**
+ * Gets ApplicationConnection instance that created this VPaintable.
+ *
+ * @return The ApplicationConnection as set by
+ * {@link #setConnection(ApplicationConnection)}
+ */
+ // public ApplicationConnection getConnection();
+
+ /**
+ * Sets the reference to ApplicationConnection. This method is called by the
+ * framework when the VPaintable is created and should never be called
+ * otherwise.
+ *
+ * @param connection
+ * The ApplicationConnection that created this VPaintable
+ */
+ // public void setConnection(ApplicationConnection connection);
+
+ /**
+ * Tests whether the component is enabled or not. A user can not interact
+ * with disabled components. Disabled components are rendered in a style
+ * that indicates the status, usually in gray color. Children of a disabled
+ * component are also disabled.
+ *
+ * @return true if the component is enabled, false otherwise
+ */
+ // public boolean isEnabled();
}
diff --git a/src/com/vaadin/terminal/gwt/client/VPaintableMap.java b/src/com/vaadin/terminal/gwt/client/VPaintableMap.java
index ef355d3cad..f21d85558c 100644
--- a/src/com/vaadin/terminal/gwt/client/VPaintableMap.java
+++ b/src/com/vaadin/terminal/gwt/client/VPaintableMap.java
@@ -335,7 +335,7 @@ public class VPaintableMap {
}
- private ComponentDetail getComponentDetail(VPaintable paintable) {
+ private ComponentDetail getComponentDetail(VPaintableWidget paintable) {
return idToComponentDetail.get(getPid(paintable));
}
@@ -344,7 +344,7 @@ public class VPaintableMap {
}
/**
- * FIXME: Should not be here
+ * FIXME: Should be moved to VAbstractPaintableWidget
*
* @param paintable
* @return
@@ -354,6 +354,11 @@ public class VPaintableMap {
return getComponentDetail(paintable).getTooltipInfo(key);
}
+ @Deprecated
+ public TooltipInfo getWidgetTooltipInfo(Widget widget, Object key) {
+ return getTooltipInfo(getPaintable(widget), key);
+ }
+
public Collection<? extends VPaintable> getPaintables() {
return Collections.unmodifiableCollection(paintableToId.keySet());
}
@@ -378,7 +383,7 @@ public class VPaintableMap {
* @return
*/
@Deprecated
- public boolean hasEventListeners(VPaintable paintable,
+ public boolean hasEventListeners(VPaintableWidget paintable,
String eventIdentifier) {
return getComponentDetail(paintable).hasEventListeners(eventIdentifier);
}
diff --git a/src/com/vaadin/terminal/gwt/client/VPaintableWidget.java b/src/com/vaadin/terminal/gwt/client/VPaintableWidget.java
index 9171fdceda..2f0cae1cc1 100644
--- a/src/com/vaadin/terminal/gwt/client/VPaintableWidget.java
+++ b/src/com/vaadin/terminal/gwt/client/VPaintableWidget.java
@@ -17,7 +17,8 @@ import com.google.gwt.user.client.ui.Widget;
public interface VPaintableWidget extends VPaintable {
/**
- * TODO: Renamed to getWidget
+ * TODO: Rename to getWidget
*/
public Widget getWidgetForPaintable();
+
}
diff --git a/src/com/vaadin/terminal/gwt/client/ui/ShortcutActionHandler.java b/src/com/vaadin/terminal/gwt/client/ui/ShortcutActionHandler.java
index 38f7878ba4..2bd578a45d 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/ShortcutActionHandler.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/ShortcutActionHandler.java
@@ -15,13 +15,11 @@ import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.HasWidgets;
import com.google.gwt.user.client.ui.KeyboardListener;
import com.google.gwt.user.client.ui.KeyboardListenerCollection;
-import com.google.gwt.user.client.ui.Widget;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.BrowserInfo;
import com.vaadin.terminal.gwt.client.Container;
import com.vaadin.terminal.gwt.client.UIDL;
import com.vaadin.terminal.gwt.client.Util;
-import com.vaadin.terminal.gwt.client.VPaintableMap;
import com.vaadin.terminal.gwt.client.VPaintableWidget;
import com.vaadin.terminal.gwt.client.ui.richtextarea.VRichTextArea;
@@ -137,12 +135,7 @@ public class ShortcutActionHandler {
VPaintableWidget target) {
final Element et = DOM.eventGetTarget(event);
if (target == null) {
- Widget w = Util.findWidget(et, null);
- VPaintableMap paintableMap = VPaintableMap.get(client);
- while (w != null && !paintableMap.isPaintable(w)) {
- w = w.getParent();
- }
- target = paintableMap.getPaintable(w);
+ target = Util.findPaintable(client, et);
}
final VPaintableWidget finalTarget = target;
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VAbstractPaintableWidget.java b/src/com/vaadin/terminal/gwt/client/ui/VAbstractPaintableWidget.java
index dff5a286ba..9a2e728454 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VAbstractPaintableWidget.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VAbstractPaintableWidget.java
@@ -1,12 +1,19 @@
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
package com.vaadin.terminal.gwt.client.ui;
-import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.Widget;
+import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.VPaintableWidget;
public abstract class VAbstractPaintableWidget implements VPaintableWidget {
private Widget widget;
+ private ApplicationConnection connection;
+
+ /* State variables */
+ // private boolean enabled = true;
/**
* Default constructor
@@ -15,14 +22,18 @@ public abstract class VAbstractPaintableWidget implements VPaintableWidget {
}
/**
+ * Called after the application connection reference has been set up
+ */
+ public void init() {
+ }
+
+ /**
* Creates and returns the widget for this VPaintableWidget. This method
* should only be called once when initializing the paintable.
*
* @return
*/
- protected Widget createWidget() {
- return GWT.create(getWidgetClass());
- }
+ protected abstract Widget createWidget();
/**
* Returns the widget associated with this paintable. The widget returned by
@@ -38,12 +49,27 @@ public abstract class VAbstractPaintableWidget implements VPaintableWidget {
return widget;
}
- /**
- * Returns the class of the widget for this paintable. Used to instansiate
- * the widget.
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.terminal.gwt.client.VPaintable#getConnection()
+ */
+ public final ApplicationConnection getConnection() {
+ return connection;
+ }
+
+ /*
+ * (non-Javadoc)
*
- * @return The widget class.
+ * @see
+ * com.vaadin.terminal.gwt.client.VPaintable#setConnection(com.vaadin.terminal
+ * .gwt.client.ApplicationConnection)
*/
- protected abstract Class<? extends Widget> getWidgetClass();
+ public final void setConnection(ApplicationConnection connection) {
+ this.connection = connection;
+ }
+ // public boolean isEnabled() {
+ // return enabled;
+ // }
}
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VButton.java b/src/com/vaadin/terminal/gwt/client/ui/VButton.java
index b638304657..6872d5f640 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VButton.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VButton.java
@@ -23,18 +23,15 @@ import com.google.gwt.user.client.ui.FocusWidget;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.BrowserInfo;
-import com.vaadin.terminal.gwt.client.EventHelper;
import com.vaadin.terminal.gwt.client.EventId;
import com.vaadin.terminal.gwt.client.MouseEventDetails;
-import com.vaadin.terminal.gwt.client.VPaintableWidget;
-import com.vaadin.terminal.gwt.client.UIDL;
import com.vaadin.terminal.gwt.client.Util;
import com.vaadin.terminal.gwt.client.VTooltip;
import com.vaadin.terminal.gwt.client.communication.ClientToServerRpc;
import com.vaadin.terminal.gwt.client.communication.ClientToServerRpc.InitializableClientToServerRpc;
-public class VButton extends FocusWidget implements VPaintableWidget,
- ClickHandler, FocusHandler, BlurHandler {
+public class VButton extends FocusWidget implements ClickHandler, FocusHandler,
+ BlurHandler {
public static final String CLASSNAME = "v-button";
private static final String CLASSNAME_PRESSED = "v-pressed";
@@ -67,7 +64,7 @@ public class VButton extends FocusWidget implements VPaintableWidget,
protected int mousedownX = 0;
protected int mousedownY = 0;
- protected String id;
+ protected String paintableId;
protected ApplicationConnection client;
@@ -90,7 +87,7 @@ public class VButton extends FocusWidget implements VPaintableWidget,
private int tabIndex = 0;
- private boolean disableOnClick = false;
+ protected boolean disableOnClick = false;
/*
* BELOW PRIVATE MEMBERS COPY-PASTED FROM GWT CustomButton
@@ -113,10 +110,10 @@ public class VButton extends FocusWidget implements VPaintableWidget,
private boolean disallowNextClick = false;
private boolean isHovering;
- private HandlerRegistration focusHandlerRegistration;
- private HandlerRegistration blurHandlerRegistration;
+ protected HandlerRegistration focusHandlerRegistration;
+ protected HandlerRegistration blurHandlerRegistration;
- private int clickShortcut = 0;
+ protected int clickShortcut = 0;
private ButtonClientToServerRpc buttonRpcProxy;
public VButton() {
@@ -139,59 +136,6 @@ public class VButton extends FocusWidget implements VPaintableWidget,
addClickHandler(this);
}
- public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
-
- // Ensure correct implementation,
- // but don't let container manage caption etc.
- if (client.updateComponent(this, uidl, false)) {
- return;
- }
-
- focusHandlerRegistration = EventHelper.updateFocusHandler(this, client,
- focusHandlerRegistration);
- blurHandlerRegistration = EventHelper.updateBlurHandler(this, client,
- blurHandlerRegistration);
-
- // Save details
- this.client = client;
- id = uidl.getId();
-
- // Set text
- setText(uidl.getStringAttribute("caption"));
-
- disableOnClick = uidl.hasAttribute(ATTR_DISABLE_ON_CLICK);
-
- // handle error
- if (uidl.hasAttribute("error")) {
- if (errorIndicatorElement == null) {
- errorIndicatorElement = DOM.createSpan();
- errorIndicatorElement.setClassName("v-errorindicator");
- }
- wrapper.insertBefore(errorIndicatorElement, captionElement);
-
- } else if (errorIndicatorElement != null) {
- wrapper.removeChild(errorIndicatorElement);
- errorIndicatorElement = null;
- }
-
- if (uidl.hasAttribute("icon")) {
- if (icon == null) {
- icon = new Icon(client);
- wrapper.insertBefore(icon.getElement(), captionElement);
- }
- icon.setUri(uidl.getStringAttribute("icon"));
- } else {
- if (icon != null) {
- wrapper.removeChild(icon.getElement());
- icon = null;
- }
- }
-
- if (uidl.hasAttribute("keycode")) {
- clickShortcut = uidl.getIntAttribute("keycode");
- }
- }
-
public void setText(String text) {
captionElement.setInnerText(text);
}
@@ -212,7 +156,7 @@ public class VButton extends FocusWidget implements VPaintableWidget,
*/
public void onBrowserEvent(Event event) {
if (client != null) {
- client.handleTooltipEvent(event, this);
+ client.handleWidgetTooltipEvent(event, this);
}
if (DOM.eventGetType(event) == Event.ONLOAD) {
Util.notifyParentOfSizeChange(this, true);
@@ -374,7 +318,7 @@ public class VButton extends FocusWidget implements VPaintableWidget,
* .dom.client.ClickEvent)
*/
public void onClick(ClickEvent event) {
- if (id == null || client == null) {
+ if (paintableId == null || client == null) {
return;
}
if (BrowserInfo.get().isSafari()) {
@@ -396,8 +340,8 @@ public class VButton extends FocusWidget implements VPaintableWidget,
protected ButtonClientToServerRpc getButtonRpcProxy() {
if (null == buttonRpcProxy) {
buttonRpcProxy = GWT.create(ButtonClientToServerRpc.class);
- ((InitializableClientToServerRpc) buttonRpcProxy).initRpc(id,
- client);
+ ((InitializableClientToServerRpc) buttonRpcProxy).initRpc(
+ paintableId, client);
}
return buttonRpcProxy;
}
@@ -531,11 +475,11 @@ public class VButton extends FocusWidget implements VPaintableWidget,
}-*/;
public void onFocus(FocusEvent arg0) {
- client.updateVariable(id, EventId.FOCUS, "", true);
+ client.updateVariable(paintableId, EventId.FOCUS, "", true);
}
public void onBlur(BlurEvent arg0) {
- client.updateVariable(id, EventId.BLUR, "", true);
+ client.updateVariable(paintableId, EventId.BLUR, "", true);
}
public Widget getWidgetForPaintable() {
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VButtonPaintable.java b/src/com/vaadin/terminal/gwt/client/ui/VButtonPaintable.java
new file mode 100644
index 0000000000..1367d412a8
--- /dev/null
+++ b/src/com/vaadin/terminal/gwt/client/ui/VButtonPaintable.java
@@ -0,0 +1,87 @@
+package com.vaadin.terminal.gwt.client.ui;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.user.client.DOM;
+import com.google.gwt.user.client.ui.Widget;
+import com.vaadin.terminal.gwt.client.ApplicationConnection;
+import com.vaadin.terminal.gwt.client.EventHelper;
+import com.vaadin.terminal.gwt.client.UIDL;
+
+public class VButtonPaintable extends VAbstractPaintableWidget {
+
+ public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
+
+ // Ensure correct implementation,
+ // but don't let container manage caption etc.
+ if (client.updateComponent(this, uidl, false)) {
+ return;
+ }
+
+ getWidgetForPaintable().focusHandlerRegistration = EventHelper
+ .updateFocusHandler(this, client,
+ getWidgetForPaintable().focusHandlerRegistration);
+ getWidgetForPaintable().blurHandlerRegistration = EventHelper
+ .updateBlurHandler(this, client,
+ getWidgetForPaintable().blurHandlerRegistration);
+
+ // Save details
+ getWidgetForPaintable().client = client;
+ getWidgetForPaintable().paintableId = uidl.getId();
+
+ // Set text
+ getWidgetForPaintable().setText(uidl.getStringAttribute("caption"));
+
+ getWidgetForPaintable().disableOnClick = uidl
+ .hasAttribute(VButton.ATTR_DISABLE_ON_CLICK);
+
+ // handle error
+ if (uidl.hasAttribute("error")) {
+ if (getWidgetForPaintable().errorIndicatorElement == null) {
+ getWidgetForPaintable().errorIndicatorElement = DOM
+ .createSpan();
+ getWidgetForPaintable().errorIndicatorElement
+ .setClassName("v-errorindicator");
+ }
+ getWidgetForPaintable().wrapper.insertBefore(
+ getWidgetForPaintable().errorIndicatorElement,
+ getWidgetForPaintable().captionElement);
+
+ } else if (getWidgetForPaintable().errorIndicatorElement != null) {
+ getWidgetForPaintable().wrapper
+ .removeChild(getWidgetForPaintable().errorIndicatorElement);
+ getWidgetForPaintable().errorIndicatorElement = null;
+ }
+
+ if (uidl.hasAttribute("icon")) {
+ if (getWidgetForPaintable().icon == null) {
+ getWidgetForPaintable().icon = new Icon(client);
+ getWidgetForPaintable().wrapper.insertBefore(
+ getWidgetForPaintable().icon.getElement(),
+ getWidgetForPaintable().captionElement);
+ }
+ getWidgetForPaintable().icon
+ .setUri(uidl.getStringAttribute("icon"));
+ } else {
+ if (getWidgetForPaintable().icon != null) {
+ getWidgetForPaintable().wrapper
+ .removeChild(getWidgetForPaintable().icon.getElement());
+ getWidgetForPaintable().icon = null;
+ }
+ }
+
+ if (uidl.hasAttribute("keycode")) {
+ getWidgetForPaintable().clickShortcut = uidl
+ .getIntAttribute("keycode");
+ }
+ }
+
+ @Override
+ protected Widget createWidget() {
+ return GWT.create(VButton.class);
+ }
+
+ @Override
+ public VButton getWidgetForPaintable() {
+ return (VButton) super.getWidgetForPaintable();
+ }
+}
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VCalendarPanel.java b/src/com/vaadin/terminal/gwt/client/ui/VCalendarPanel.java
index ed05a3e67d..b318fe0af3 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VCalendarPanel.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VCalendarPanel.java
@@ -104,6 +104,8 @@ public class VCalendarPanel extends FocusableFlexTable implements
private static final String CN_SELECTED = "selected";
+ private static final String CN_OFFMONTH = "offmonth";
+
/**
* Represents a click handler for when a user selects a value by using the
* mouse
@@ -118,7 +120,7 @@ public class VCalendarPanel extends FocusableFlexTable implements
*/
public void onClick(ClickEvent event) {
Day day = (Day) event.getSource();
- focusDay(day.getDay());
+ focusDay(day.getDate());
selectFocused();
onSubmit();
}
@@ -152,6 +154,8 @@ public class VCalendarPanel extends FocusableFlexTable implements
private boolean showISOWeekNumbers;
+ private Date displayedMonth;
+
private Date focusedDate;
private Day selectedDay;
@@ -191,18 +195,18 @@ public class VCalendarPanel extends FocusableFlexTable implements
* Sets the focus to given day of current time. Used when moving in the
* calender with the keyboard.
*
- * @param day
+ * @param date
* The day number from by Date.getDate()
*/
- private void focusDay(int day) {
+ private void focusDay(Date day) {
// Only used when calender body is present
if (resolution > VDateField.RESOLUTION_MONTH) {
if (focusedDay != null) {
focusedDay.removeStyleDependentName(CN_FOCUSED);
}
- if (day > 0 && focusedDate != null) {
- focusedDate.setDate(day);
+ if (day != null && focusedDate != null) {
+ focusedDate.setTime(day.getTime());
int rowCount = days.getRowCount();
for (int i = 0; i < rowCount; i++) {
int cellCount = days.getCellCount(i);
@@ -210,7 +214,7 @@ public class VCalendarPanel extends FocusableFlexTable implements
Widget widget = days.getWidget(i, j);
if (widget != null && widget instanceof Day) {
Day curday = (Day) widget;
- if (curday.getDay() == day) {
+ if (curday.getDate().equals(day)) {
curday.addStyleDependentName(CN_FOCUSED);
focusedDay = curday;
focusedRow = i;
@@ -226,9 +230,9 @@ public class VCalendarPanel extends FocusableFlexTable implements
/**
* Sets the selection hightlight to a given date of current time
*
- * @param day
+ * @param date
*/
- private void selectDate(int day) {
+ private void selectDate(Date date) {
if (selectedDay != null) {
selectedDay.removeStyleDependentName(CN_SELECTED);
}
@@ -240,7 +244,7 @@ public class VCalendarPanel extends FocusableFlexTable implements
Widget widget = days.getWidget(i, j);
if (widget != null && widget instanceof Day) {
Day curday = (Day) widget;
- if (curday.getDay() == day) {
+ if (curday.getDate().equals(date)) {
curday.addStyleDependentName(CN_SELECTED);
selectedDay = curday;
return;
@@ -279,7 +283,7 @@ public class VCalendarPanel extends FocusableFlexTable implements
// it was forced to 1 above.
value.setDate(focusedDate.getDate());
- selectDate(focusedDate.getDate());
+ selectDate(focusedDate);
} else {
VConsole.log("Trying to select a the focused date which is NULL!");
}
@@ -468,97 +472,62 @@ public class VCalendarPanel extends FocusableFlexTable implements
}
}
- // The day of month that is selected, -1 if no day of this month is
- // selected (i.e, showing another month/year than selected or nothing is
- // selected)
- int dayOfMonthSelected = -1;
- // The day of month that is today, -1 if no day of this month is today
- // (i.e., showing another month/year than current)
- int dayOfMonthToday = -1;
-
- boolean initiallyNull = value == null;
-
- if (!initiallyNull && value.getMonth() == focusedDate.getMonth()
- && value.getYear() == focusedDate.getYear()) {
- dayOfMonthSelected = value.getDate();
- }
- final Date today = new Date();
- if (today.getMonth() == focusedDate.getMonth()
- && today.getYear() == focusedDate.getYear()) {
- dayOfMonthToday = today.getDate();
- }
+ // today must have zeroed hours, minutes, seconds, and milliseconds
+ final Date tmp = new Date();
+ final Date today = new Date(tmp.getYear(), tmp.getMonth(),
+ tmp.getDate());
final int startWeekDay = getDateTimeService().getStartWeekDay(
focusedDate);
- final int daysInMonth = DateTimeService
- .getNumberOfDaysInMonth(focusedDate);
-
- int dayCount = 0;
- final Date curr = new Date(focusedDate.getTime());
+ final Date curr = (Date) focusedDate.clone();
+ // Start from the first day of the week that at least partially belongs
+ // to the current month
+ curr.setDate(-startWeekDay);
// No month has more than 6 weeks so 6 is a safe maximum for rows.
for (int weekOfMonth = 1; weekOfMonth < 7; weekOfMonth++) {
- boolean weekNumberProcessed[] = new boolean[] { false, false,
- false, false, false, false, false };
-
for (int dayOfWeek = 0; dayOfWeek < 7; dayOfWeek++) {
- if (!(weekOfMonth == 1 && dayOfWeek < startWeekDay)) {
-
- if (dayCount >= daysInMonth) {
- // All days printed and we are done
- break;
- }
-
- final int dayOfMonth = ++dayCount;
-
- curr.setDate(dayCount);
- // Actually write the day of month
- Day day = new Day(dayOfMonth);
+ // Actually write the day of month
+ Day day = new Day((Date) curr.clone());
- if (dayOfMonthSelected == dayOfMonth) {
- day.addStyleDependentName(CN_SELECTED);
- selectedDay = day;
+ if (curr.equals(value)) {
+ day.addStyleDependentName(CN_SELECTED);
+ selectedDay = day;
+ }
+ if (curr.equals(today)) {
+ day.addStyleDependentName(CN_TODAY);
+ }
+ if (curr.equals(focusedDate)) {
+ focusedDay = day;
+ focusedRow = weekOfMonth;
+ if (hasFocus) {
+ day.addStyleDependentName(CN_FOCUSED);
}
+ }
+ if (curr.getMonth() != focusedDate.getMonth()) {
+ day.addStyleDependentName(CN_OFFMONTH);
+ }
- if (dayOfMonthToday == dayOfMonth) {
- day.addStyleDependentName(CN_TODAY);
- }
+ days.setWidget(weekOfMonth, firstWeekdayColumn + dayOfWeek, day);
- if (dayOfMonth == focusedDate.getDate()) {
- focusedDay = day;
- focusedRow = weekOfMonth;
- if (hasFocus) {
- day.addStyleDependentName(CN_FOCUSED);
- }
- }
+ // ISO week numbers if requested
+ days.getCellFormatter().setVisible(weekOfMonth, weekColumn,
+ isShowISOWeekNumbers());
+ if (isShowISOWeekNumbers()) {
+ final String baseCssClass = VDateField.CLASSNAME
+ + "-calendarpanel-weeknumber";
+ String weekCssClass = baseCssClass;
- days.setWidget(weekOfMonth, firstWeekdayColumn + dayOfWeek,
- day);
-
- // ISO week numbers if requested
- if (!weekNumberProcessed[weekOfMonth]) {
- days.getCellFormatter().setVisible(weekOfMonth,
- weekColumn, isShowISOWeekNumbers());
- if (isShowISOWeekNumbers()) {
- final String baseCssClass = VDateField.CLASSNAME
- + "-calendarpanel-weeknumber";
- String weekCssClass = baseCssClass;
-
- int weekNumber = DateTimeService
- .getISOWeekNumber(curr);
-
- days.setHTML(weekOfMonth, 0, "<span class=\""
- + weekCssClass + "\"" + ">" + weekNumber
- + "</span>");
- weekNumberProcessed[weekOfMonth] = true;
- }
+ int weekNumber = DateTimeService.getISOWeekNumber(curr);
- }
+ days.setHTML(weekOfMonth, 0, "<span class=\""
+ + weekCssClass + "\"" + ">" + weekNumber
+ + "</span>");
}
+ curr.setDate(curr.getDate() + 1);
}
}
-
}
/**
@@ -622,6 +591,7 @@ public class VCalendarPanel extends FocusableFlexTable implements
while (focusedDate.getMonth() != requestedMonth) {
focusedDate.setDate(focusedDate.getDate() - 1);
}
+ displayedMonth.setMonth(displayedMonth.getMonth() + 1);
renderCalendar();
}
@@ -641,6 +611,7 @@ public class VCalendarPanel extends FocusableFlexTable implements
while (focusedDate.getMonth() == currentMonth) {
focusedDate.setDate(focusedDate.getDate() - 1);
}
+ displayedMonth.setMonth(displayedMonth.getMonth() - 1);
renderCalendar();
}
@@ -650,6 +621,7 @@ public class VCalendarPanel extends FocusableFlexTable implements
*/
private void focusPreviousYear(int years) {
focusedDate.setYear(focusedDate.getYear() - years);
+ displayedMonth.setYear(displayedMonth.getYear() - years);
renderCalendar();
}
@@ -658,6 +630,7 @@ public class VCalendarPanel extends FocusableFlexTable implements
*/
private void focusNextYear(int years) {
focusedDate.setYear(focusedDate.getYear() + years);
+ displayedMonth.setYear(displayedMonth.getYear() + years);
renderCalendar();
}
@@ -906,7 +879,7 @@ public class VCalendarPanel extends FocusableFlexTable implements
if (newCurrentDate.getMonth() == focusedDate.getMonth()) {
// Month did not change, only move the selection
- focusDay(focusedDate.getDate() + 1);
+ focusDay(newCurrentDate);
} else {
// If the month changed we need to re-render the calendar
focusedDate.setDate(focusedDate.getDate() + 1);
@@ -925,7 +898,7 @@ public class VCalendarPanel extends FocusableFlexTable implements
if (newCurrentDate.getMonth() == focusedDate.getMonth()) {
// Month did not change, only move the selection
- focusDay(focusedDate.getDate() - 1);
+ focusDay(newCurrentDate);
} else {
// If the month changed we need to re-render the calendar
focusedDate.setDate(focusedDate.getDate() - 1);
@@ -945,10 +918,10 @@ public class VCalendarPanel extends FocusableFlexTable implements
if (newCurrentDate.getMonth() == focusedDate.getMonth()
&& focusedRow > 1) {
// Month did not change, only move the selection
- focusDay(focusedDate.getDate() - 7);
+ focusDay(newCurrentDate);
} else {
// If the month changed we need to re-render the calendar
- focusedDate.setDate(focusedDate.getDate() - 7);
+ focusedDate = newCurrentDate;
renderCalendar();
}
@@ -964,10 +937,10 @@ public class VCalendarPanel extends FocusableFlexTable implements
if (newCurrentDate.getMonth() == focusedDate.getMonth()) {
// Month did not change, only move the selection
- focusDay(focusedDate.getDate() + 7);
+ focusDay(newCurrentDate);
} else {
// If the month changed we need to re-render the calendar
- focusedDate.setDate(focusedDate.getDate() + 7);
+ focusedDate = newCurrentDate;
renderCalendar();
}
@@ -1211,27 +1184,28 @@ public class VCalendarPanel extends FocusableFlexTable implements
return;
}
- Date oldFocusedValue = focusedDate;
+ Date oldDisplayedMonth = displayedMonth;
value = currentDate;
if (value == null) {
- focusedDate = null;
+ focusedDate = displayedMonth = null;
} else {
focusedDate = (Date) value.clone();
+ displayedMonth = (Date) value.clone();
}
// Re-render calendar if month or year of focused date has changed
- if (oldFocusedValue == null || value == null
- || oldFocusedValue.getYear() != value.getYear()
- || oldFocusedValue.getMonth() != value.getMonth()) {
+ if (oldDisplayedMonth == null || value == null
+ || oldDisplayedMonth.getYear() != value.getYear()
+ || oldDisplayedMonth.getMonth() != value.getMonth()) {
renderCalendar();
} else {
- focusDay(currentDate.getDate());
+ focusDay(currentDate);
selectFocused();
}
if (!hasFocus) {
- focusDay(-1);
+ focusDay((Date) null);
}
}
@@ -1512,17 +1486,17 @@ public class VCalendarPanel extends FocusableFlexTable implements
private class Day extends InlineHTML {
private static final String BASECLASS = VDateField.CLASSNAME
+ "-calendarpanel-day";
- private final int day;
+ private final Date date;
- Day(int dayOfMonth) {
- super("" + dayOfMonth);
+ Day(Date date) {
+ super("" + date.getDate());
setStyleName(BASECLASS);
- day = dayOfMonth;
+ this.date = date;
addClickHandler(dayClickHandler);
}
- public int getDay() {
- return day;
+ public Date getDate() {
+ return date;
}
}
@@ -1605,7 +1579,7 @@ public class VCalendarPanel extends FocusableFlexTable implements
public void onBlur(final BlurEvent event) {
if (event.getSource() instanceof VCalendarPanel) {
hasFocus = false;
- focusDay(-1);
+ focusDay(null);
}
}
@@ -1622,7 +1596,7 @@ public class VCalendarPanel extends FocusableFlexTable implements
// Focuses the current day if the calendar shows the days
if (focusedDay != null) {
- focusDay(focusedDay.getDay());
+ focusDay(focusedDate);
}
}
}
@@ -1653,7 +1627,15 @@ public class VCalendarPanel extends FocusableFlexTable implements
// Day, find out which dayOfMonth and use that as the identifier
Day day = Util.findWidget(subElement, Day.class);
if (day != null) {
- return SUBPART_DAY + day.getDay();
+ Date date = day.getDate();
+ int id = date.getDate();
+ if (date.getMonth() < displayedMonth.getMonth()) {
+ id -= DateTimeService.getNumberOfDaysInMonth(date);
+ } else if (date.getMonth() > displayedMonth.getMonth()) {
+ id += DateTimeService
+ .getNumberOfDaysInMonth(displayedMonth);
+ }
+ return SUBPART_DAY + id;
}
} else if (time != null) {
if (contains(time.hours, subElement)) {
@@ -1714,14 +1696,18 @@ public class VCalendarPanel extends FocusableFlexTable implements
return time.ampm.getElement();
}
if (subPart.startsWith(SUBPART_DAY)) {
+ // can be less than 1 or greater than the number of days in the current month
+ // these map to the "off-month" days
int dayOfMonth = Integer.parseInt(subPart.substring(SUBPART_DAY
.length()));
+ Date date = new Date(displayedMonth.getYear(),
+ displayedMonth.getMonth(), dayOfMonth);
Iterator<Widget> iter = days.iterator();
while (iter.hasNext()) {
Widget w = iter.next();
if (w instanceof Day) {
Day day = (Day) w;
- if (day.getDay() == dayOfMonth) {
+ if (day.getDate().equals(date)) {
return day.getElement();
}
}
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VDragAndDropWrapper.java b/src/com/vaadin/terminal/gwt/client/ui/VDragAndDropWrapper.java
index da916f262e..3251a03d6a 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VDragAndDropWrapper.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VDragAndDropWrapper.java
@@ -113,14 +113,9 @@ public class VDragAndDropWrapper extends VCustomComponent implements
VTransferable transferable = new VTransferable();
transferable.setDragSource(VDragAndDropWrapper.this);
- Widget widget = Util.findWidget((Element) event.getEventTarget()
- .cast(), null);
- VPaintableMap vPaintableMap = VPaintableMap.get(client);
- while (widget != null && !vPaintableMap.isPaintable(widget)) {
- widget = widget.getParent();
- }
- VPaintableWidget paintable = vPaintableMap.getPaintable(widget);
-
+ VPaintableWidget paintable = Util.findPaintable(client,
+ (Element) event.getEventTarget().cast());
+ Widget widget = paintable.getWidgetForPaintable();
transferable.setData("component", paintable);
VDragEvent dragEvent = VDragAndDropManager.get().startDrag(
transferable, event, true);
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VFormLayout.java b/src/com/vaadin/terminal/gwt/client/ui/VFormLayout.java
index 6d068dd11a..e6305b3c42 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VFormLayout.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VFormLayout.java
@@ -117,8 +117,7 @@ public class VFormLayout extends SimplePanel implements Container {
Widget childWidget = childPaintable.getWidgetForPaintable();
Caption caption = widgetToCaption.get(childWidget);
if (caption == null) {
- caption = new Caption(childPaintable, client,
- getStylesFromUIDL(childUidl));
+ caption = new Caption(childPaintable, client);
caption.addClickHandler(this);
widgetToCaption.put(childWidget, caption);
}
@@ -208,8 +207,7 @@ public class VFormLayout extends SimplePanel implements Container {
VPaintableWidget newPaintable = paintableMap
.getPaintable(newComponent);
Caption oldCap = widgetToCaption.get(oldComponent);
- final Caption newCap = new Caption(newPaintable, client,
- null);
+ final Caption newCap = new Caption(newPaintable, client);
newCap.addClickHandler(this);
newCap.setStyleName(oldCap.getStyleName());
widgetToCaption.put(newComponent, newCap);
@@ -333,29 +331,37 @@ public class VFormLayout extends SimplePanel implements Container {
* return null
* @param client
*/
- public Caption(VPaintableWidget component,
- ApplicationConnection client, String[] styles) {
+ public Caption(VPaintableWidget component, ApplicationConnection client) {
super();
this.client = client;
owner = component;
- String style = CLASSNAME;
+ sinkEvents(VTooltip.TOOLTIP_EVENTS);
+ }
+
+ private void setStyles(String[] styles) {
+ 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);
- sinkEvents(VTooltip.TOOLTIP_EVENTS);
+ setStyleName(styleName);
}
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/VMenuBar.java b/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java
index 306086e357..c39155d032 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java
@@ -4,9 +4,7 @@
package com.vaadin.terminal.gwt.client.ui;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
-import java.util.Stack;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.Scheduler;
@@ -35,14 +33,12 @@ import com.google.gwt.user.client.ui.Widget;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.BrowserInfo;
import com.vaadin.terminal.gwt.client.ContainerResizedListener;
-import com.vaadin.terminal.gwt.client.VPaintableMap;
import com.vaadin.terminal.gwt.client.TooltipInfo;
import com.vaadin.terminal.gwt.client.UIDL;
import com.vaadin.terminal.gwt.client.Util;
-import com.vaadin.terminal.gwt.client.VPaintableWidget;
import com.vaadin.terminal.gwt.client.VTooltip;
-public class VMenuBar extends SimpleFocusablePanel implements VPaintableWidget,
+public class VMenuBar extends SimpleFocusablePanel implements
CloseHandler<PopupPanel>, ContainerResizedListener, KeyPressHandler,
KeyDownHandler, FocusHandler, SubPartAware {
@@ -82,7 +78,7 @@ public class VMenuBar extends SimpleFocusablePanel implements VPaintableWidget,
protected VMenuBar parentMenu;
protected CustomMenuItem selected;
- private boolean enabled = true;
+ boolean enabled = true;
private String width = "notinited";
@@ -94,9 +90,9 @@ public class VMenuBar extends SimpleFocusablePanel implements VPaintableWidget,
}
});
- private boolean openRootOnHover;
+ boolean openRootOnHover;
- private boolean htmlContentAllowed;
+ boolean htmlContentAllowed;
public VMenuBar() {
// Create an empty horizontal menubar
@@ -168,133 +164,6 @@ public class VMenuBar extends SimpleFocusablePanel implements VPaintableWidget,
}
/**
- * This method must be implemented to update the client-side component from
- * UIDL data received from server.
- *
- * This method is called when the page is loaded for the first time, and
- * every time UI changes in the component are received from the server.
- */
- public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
- // This call should be made first. Ensure correct implementation,
- // and let the containing layout manage caption, etc.
- if (client.updateComponent(this, uidl, true)) {
- return;
- }
-
- htmlContentAllowed = uidl.hasAttribute(HTML_CONTENT_ALLOWED);
-
- openRootOnHover = uidl.getBooleanAttribute(OPEN_ROOT_MENU_ON_HOWER);
-
- enabled = !uidl.getBooleanAttribute("disabled");
-
- // For future connections
- this.client = client;
- uidlId = uidl.getId();
-
- // Empty the menu every time it receives new information
- if (!getItems().isEmpty()) {
- clearItems();
- }
-
- UIDL options = uidl.getChildUIDL(0);
-
- if (uidl.hasAttribute("width")) {
- UIDL moreItemUIDL = options.getChildUIDL(0);
- StringBuffer itemHTML = new StringBuffer();
-
- if (moreItemUIDL.hasAttribute("icon")) {
- itemHTML.append("<img src=\""
- + Util.escapeAttribute(client
- .translateVaadinUri(moreItemUIDL
- .getStringAttribute("icon")))
- + "\" class=\"" + Icon.CLASSNAME + "\" alt=\"\" />");
- }
-
- String moreItemText = moreItemUIDL.getStringAttribute("text");
- if ("".equals(moreItemText)) {
- moreItemText = "&#x25BA;";
- }
- itemHTML.append(moreItemText);
-
- moreItem = GWT.create(CustomMenuItem.class);
- moreItem.setHTML(itemHTML.toString());
- moreItem.setCommand(emptyCommand);
-
- collapsedRootItems = new VMenuBar(true, (VMenuBar) VPaintableMap
- .get(client).getPaintable(uidlId));
- moreItem.setSubMenu(collapsedRootItems);
- moreItem.addStyleName(CLASSNAME + "-more-menuitem");
- }
-
- UIDL uidlItems = uidl.getChildUIDL(1);
- Iterator<Object> itr = uidlItems.getChildIterator();
- Stack<Iterator<Object>> iteratorStack = new Stack<Iterator<Object>>();
- Stack<VMenuBar> menuStack = new Stack<VMenuBar>();
- VMenuBar currentMenu = this;
-
- while (itr.hasNext()) {
- UIDL item = (UIDL) itr.next();
- CustomMenuItem currentItem = null;
-
- final int itemId = item.getIntAttribute("id");
-
- boolean itemHasCommand = item.hasAttribute("command");
- boolean itemIsCheckable = item.hasAttribute(ATTRIBUTE_CHECKED);
-
- String itemHTML = buildItemHTML(item);
-
- Command cmd = null;
- if (!item.hasAttribute("separator")) {
- if (itemHasCommand || itemIsCheckable) {
- // Construct a command that fires onMenuClick(int) with the
- // item's id-number
- cmd = new Command() {
- public void execute() {
- hostReference.onMenuClick(itemId);
- }
- };
- }
- }
-
- currentItem = currentMenu.addItem(itemHTML.toString(), cmd);
- currentItem.updateFromUIDL(item, client);
-
- if (item.getChildCount() > 0) {
- menuStack.push(currentMenu);
- iteratorStack.push(itr);
- itr = item.getChildIterator();
- currentMenu = new VMenuBar(true, currentMenu);
- if (uidl.hasAttribute("style")) {
- for (String style : uidl.getStringAttribute("style").split(
- " ")) {
- currentMenu.addStyleDependentName(style);
- }
- }
- currentItem.setSubMenu(currentMenu);
- }
-
- while (!itr.hasNext() && !iteratorStack.empty()) {
- boolean hasCheckableItem = false;
- for (CustomMenuItem menuItem : currentMenu.getItems()) {
- hasCheckableItem = hasCheckableItem
- || menuItem.isCheckable();
- }
- if (hasCheckableItem) {
- currentMenu.addStyleDependentName("check-column");
- } else {
- currentMenu.removeStyleDependentName("check-column");
- }
-
- itr = iteratorStack.pop();
- currentMenu = menuStack.pop();
- }
- }// while
-
- iLayout(false);
-
- }// updateFromUIDL
-
- /**
* Build the HTML content for a menu item.
*
* @param item
@@ -473,7 +342,7 @@ public class VMenuBar extends SimpleFocusablePanel implements VPaintableWidget,
// Handle tooltips
if (targetItem == null && client != null) {
// Handle root menubar tooltips
- client.handleTooltipEvent(e, this);
+ client.handleWidgetTooltipEvent(e, this);
} else if (targetItem != null) {
// Handle item tooltips
targetItem.onBrowserEvent(e);
@@ -1051,7 +920,7 @@ public class VMenuBar extends SimpleFocusablePanel implements VPaintableWidget,
TooltipInfo info = new TooltipInfo(description);
VMenuBar root = findRootMenu();
- client.registerTooltip(root, this, info);
+ client.registerWidgetTooltip(root, this, info);
}
}
@@ -1059,7 +928,7 @@ public class VMenuBar extends SimpleFocusablePanel implements VPaintableWidget,
public void onBrowserEvent(Event event) {
super.onBrowserEvent(event);
if (client != null) {
- client.handleTooltipEvent(event, findRootMenu(), this);
+ client.handleWidgetTooltipEvent(event, findRootMenu(), this);
}
}
@@ -1551,8 +1420,4 @@ public class VMenuBar extends SimpleFocusablePanel implements VPaintableWidget,
return null;
}
- public Widget getWidgetForPaintable() {
- return this;
- }
-
}
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VMenuBarPaintable.java b/src/com/vaadin/terminal/gwt/client/ui/VMenuBarPaintable.java
new file mode 100644
index 0000000000..fabc77bced
--- /dev/null
+++ b/src/com/vaadin/terminal/gwt/client/ui/VMenuBarPaintable.java
@@ -0,0 +1,161 @@
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+package com.vaadin.terminal.gwt.client.ui;
+
+import java.util.Iterator;
+import java.util.Stack;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.user.client.Command;
+import com.google.gwt.user.client.ui.Widget;
+import com.vaadin.terminal.gwt.client.ApplicationConnection;
+import com.vaadin.terminal.gwt.client.UIDL;
+import com.vaadin.terminal.gwt.client.Util;
+import com.vaadin.terminal.gwt.client.ui.VMenuBar.CustomMenuItem;
+
+public class VMenuBarPaintable extends VAbstractPaintableWidget {
+ /**
+ * This method must be implemented to update the client-side component from
+ * UIDL data received from server.
+ *
+ * This method is called when the page is loaded for the first time, and
+ * every time UI changes in the component are received from the server.
+ */
+ public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
+ // This call should be made first. Ensure correct implementation,
+ // and let the containing layout manage caption, etc.
+ if (client.updateComponent(this, uidl, true)) {
+ return;
+ }
+
+ getWidgetForPaintable().htmlContentAllowed = uidl
+ .hasAttribute(VMenuBar.HTML_CONTENT_ALLOWED);
+
+ getWidgetForPaintable().openRootOnHover = uidl
+ .getBooleanAttribute(VMenuBar.OPEN_ROOT_MENU_ON_HOWER);
+
+ getWidgetForPaintable().enabled = !uidl.getBooleanAttribute("disabled");
+
+ // For future connections
+ getWidgetForPaintable().client = client;
+ getWidgetForPaintable().uidlId = uidl.getId();
+
+ // Empty the menu every time it receives new information
+ if (!getWidgetForPaintable().getItems().isEmpty()) {
+ getWidgetForPaintable().clearItems();
+ }
+
+ UIDL options = uidl.getChildUIDL(0);
+
+ if (uidl.hasAttribute("width")) {
+ UIDL moreItemUIDL = options.getChildUIDL(0);
+ StringBuffer itemHTML = new StringBuffer();
+
+ if (moreItemUIDL.hasAttribute("icon")) {
+ itemHTML.append("<img src=\""
+ + Util.escapeAttribute(client
+ .translateVaadinUri(moreItemUIDL
+ .getStringAttribute("icon")))
+ + "\" class=\"" + Icon.CLASSNAME + "\" alt=\"\" />");
+ }
+
+ String moreItemText = moreItemUIDL.getStringAttribute("text");
+ if ("".equals(moreItemText)) {
+ moreItemText = "&#x25BA;";
+ }
+ itemHTML.append(moreItemText);
+
+ getWidgetForPaintable().moreItem = GWT.create(CustomMenuItem.class);
+ getWidgetForPaintable().moreItem.setHTML(itemHTML.toString());
+ getWidgetForPaintable().moreItem.setCommand(VMenuBar.emptyCommand);
+
+ getWidgetForPaintable().collapsedRootItems = new VMenuBar(true,
+ getWidgetForPaintable());
+ getWidgetForPaintable().moreItem
+ .setSubMenu(getWidgetForPaintable().collapsedRootItems);
+ getWidgetForPaintable().moreItem.addStyleName(VMenuBar.CLASSNAME
+ + "-more-menuitem");
+ }
+
+ UIDL uidlItems = uidl.getChildUIDL(1);
+ Iterator<Object> itr = uidlItems.getChildIterator();
+ Stack<Iterator<Object>> iteratorStack = new Stack<Iterator<Object>>();
+ Stack<VMenuBar> menuStack = new Stack<VMenuBar>();
+ VMenuBar currentMenu = getWidgetForPaintable();
+
+ while (itr.hasNext()) {
+ UIDL item = (UIDL) itr.next();
+ CustomMenuItem currentItem = null;
+
+ final int itemId = item.getIntAttribute("id");
+
+ boolean itemHasCommand = item.hasAttribute("command");
+ boolean itemIsCheckable = item
+ .hasAttribute(VMenuBar.ATTRIBUTE_CHECKED);
+
+ String itemHTML = getWidgetForPaintable().buildItemHTML(item);
+
+ Command cmd = null;
+ if (!item.hasAttribute("separator")) {
+ if (itemHasCommand || itemIsCheckable) {
+ // Construct a command that fires onMenuClick(int) with the
+ // item's id-number
+ cmd = new Command() {
+ public void execute() {
+ getWidgetForPaintable().hostReference
+ .onMenuClick(itemId);
+ }
+ };
+ }
+ }
+
+ currentItem = currentMenu.addItem(itemHTML.toString(), cmd);
+ currentItem.updateFromUIDL(item, client);
+
+ if (item.getChildCount() > 0) {
+ menuStack.push(currentMenu);
+ iteratorStack.push(itr);
+ itr = item.getChildIterator();
+ currentMenu = new VMenuBar(true, currentMenu);
+ if (uidl.hasAttribute("style")) {
+ for (String style : uidl.getStringAttribute("style").split(
+ " ")) {
+ currentMenu.addStyleDependentName(style);
+ }
+ }
+ currentItem.setSubMenu(currentMenu);
+ }
+
+ while (!itr.hasNext() && !iteratorStack.empty()) {
+ boolean hasCheckableItem = false;
+ for (CustomMenuItem menuItem : currentMenu.getItems()) {
+ hasCheckableItem = hasCheckableItem
+ || menuItem.isCheckable();
+ }
+ if (hasCheckableItem) {
+ currentMenu.addStyleDependentName("check-column");
+ } else {
+ currentMenu.removeStyleDependentName("check-column");
+ }
+
+ itr = iteratorStack.pop();
+ currentMenu = menuStack.pop();
+ }
+ }// while
+
+ getWidgetForPaintable().iLayout(false);
+
+ }// updateFromUIDL
+
+ @Override
+ protected Widget createWidget() {
+ return GWT.create(VMenuBar.class);
+ }
+
+ @Override
+ public VMenuBar getWidgetForPaintable() {
+ return (VMenuBar) super.getWidgetForPaintable();
+ }
+
+}
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VNativeButton.java b/src/com/vaadin/terminal/gwt/client/ui/VNativeButton.java
index 8385130a42..a0b374c97e 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VNativeButton.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VNativeButton.java
@@ -19,24 +19,21 @@ import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.BrowserInfo;
-import com.vaadin.terminal.gwt.client.EventHelper;
import com.vaadin.terminal.gwt.client.EventId;
import com.vaadin.terminal.gwt.client.MouseEventDetails;
-import com.vaadin.terminal.gwt.client.VPaintableWidget;
-import com.vaadin.terminal.gwt.client.UIDL;
import com.vaadin.terminal.gwt.client.Util;
import com.vaadin.terminal.gwt.client.VTooltip;
import com.vaadin.terminal.gwt.client.communication.ClientToServerRpc.InitializableClientToServerRpc;
import com.vaadin.terminal.gwt.client.ui.VButton.ButtonClientToServerRpc;
-public class VNativeButton extends Button implements VPaintableWidget,
- ClickHandler, FocusHandler, BlurHandler {
+public class VNativeButton extends Button implements ClickHandler,
+ FocusHandler, BlurHandler {
public static final String CLASSNAME = "v-nativebutton";
protected String width = null;
- protected String id;
+ protected String paintableId;
protected ApplicationConnection client;
@@ -55,10 +52,10 @@ public class VNativeButton extends Button implements VPaintableWidget,
*/
private boolean clickPending;
- private HandlerRegistration focusHandlerRegistration;
- private HandlerRegistration blurHandlerRegistration;
+ protected HandlerRegistration focusHandlerRegistration;
+ protected HandlerRegistration blurHandlerRegistration;
- private boolean disableOnClick = false;
+ protected boolean disableOnClick = false;
public VNativeButton() {
setStyleName(CLASSNAME);
@@ -73,56 +70,6 @@ public class VNativeButton extends Button implements VPaintableWidget,
sinkEvents(Event.ONMOUSEUP);
}
- public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
-
- // Ensure correct implementation,
- // but don't let container manage caption etc.
- if (client.updateComponent(this, uidl, false)) {
- return;
- }
-
- disableOnClick = uidl.hasAttribute(VButton.ATTR_DISABLE_ON_CLICK);
-
- focusHandlerRegistration = EventHelper.updateFocusHandler(this, client,
- focusHandlerRegistration);
- blurHandlerRegistration = EventHelper.updateBlurHandler(this, client,
- blurHandlerRegistration);
-
- // Save details
- this.client = client;
- id = uidl.getId();
-
- // Set text
- setText(uidl.getStringAttribute("caption"));
-
- // handle error
- if (uidl.hasAttribute("error")) {
- if (errorIndicatorElement == null) {
- errorIndicatorElement = DOM.createSpan();
- errorIndicatorElement.setClassName("v-errorindicator");
- }
- getElement().insertBefore(errorIndicatorElement, captionElement);
-
- } else if (errorIndicatorElement != null) {
- getElement().removeChild(errorIndicatorElement);
- errorIndicatorElement = null;
- }
-
- if (uidl.hasAttribute("icon")) {
- if (icon == null) {
- icon = new Icon(client);
- getElement().insertBefore(icon.getElement(), captionElement);
- }
- icon.setUri(uidl.getStringAttribute("icon"));
- } else {
- if (icon != null) {
- getElement().removeChild(icon.getElement());
- icon = null;
- }
- }
-
- }
-
@Override
public void setText(String text) {
captionElement.setInnerText(text);
@@ -148,7 +95,7 @@ public class VNativeButton extends Button implements VPaintableWidget,
}
if (client != null) {
- client.handleTooltipEvent(event, this);
+ client.handleWidgetTooltipEvent(event, this);
}
}
@@ -166,7 +113,7 @@ public class VNativeButton extends Button implements VPaintableWidget,
* .dom.client.ClickEvent)
*/
public void onClick(ClickEvent event) {
- if (id == null || client == null) {
+ if (paintableId == null || client == null) {
return;
}
@@ -189,18 +136,18 @@ public class VNativeButton extends Button implements VPaintableWidget,
protected ButtonClientToServerRpc getButtonRpcProxy() {
if (null == buttonRpcProxy) {
buttonRpcProxy = GWT.create(ButtonClientToServerRpc.class);
- ((InitializableClientToServerRpc) buttonRpcProxy).initRpc(id,
- client);
+ ((InitializableClientToServerRpc) buttonRpcProxy).initRpc(
+ paintableId, client);
}
return buttonRpcProxy;
}
public void onFocus(FocusEvent arg0) {
- client.updateVariable(id, EventId.FOCUS, "", true);
+ client.updateVariable(paintableId, EventId.FOCUS, "", true);
}
public void onBlur(BlurEvent arg0) {
- client.updateVariable(id, EventId.BLUR, "", true);
+ client.updateVariable(paintableId, EventId.BLUR, "", true);
}
@Override
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VNativeButtonPaintable.java b/src/com/vaadin/terminal/gwt/client/ui/VNativeButtonPaintable.java
new file mode 100644
index 0000000000..5e0dceea75
--- /dev/null
+++ b/src/com/vaadin/terminal/gwt/client/ui/VNativeButtonPaintable.java
@@ -0,0 +1,83 @@
+package com.vaadin.terminal.gwt.client.ui;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.user.client.DOM;
+import com.google.gwt.user.client.ui.Widget;
+import com.vaadin.terminal.gwt.client.ApplicationConnection;
+import com.vaadin.terminal.gwt.client.EventHelper;
+import com.vaadin.terminal.gwt.client.UIDL;
+
+public class VNativeButtonPaintable extends VAbstractPaintableWidget {
+
+ public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
+
+ // Ensure correct implementation,
+ // but don't let container manage caption etc.
+ if (client.updateComponent(this, uidl, false)) {
+ return;
+ }
+
+ getWidgetForPaintable().disableOnClick = uidl
+ .hasAttribute(VButton.ATTR_DISABLE_ON_CLICK);
+
+ getWidgetForPaintable().focusHandlerRegistration = EventHelper
+ .updateFocusHandler(this, client,
+ getWidgetForPaintable().focusHandlerRegistration);
+ getWidgetForPaintable().blurHandlerRegistration = EventHelper
+ .updateBlurHandler(this, client,
+ getWidgetForPaintable().blurHandlerRegistration);
+
+ // Save details
+ getWidgetForPaintable().client = client;
+ getWidgetForPaintable().paintableId = uidl.getId();
+
+ // Set text
+ getWidgetForPaintable().setText(uidl.getStringAttribute("caption"));
+
+ // handle error
+ if (uidl.hasAttribute("error")) {
+ if (getWidgetForPaintable().errorIndicatorElement == null) {
+ getWidgetForPaintable().errorIndicatorElement = DOM
+ .createSpan();
+ getWidgetForPaintable().errorIndicatorElement
+ .setClassName("v-errorindicator");
+ }
+ getWidgetForPaintable().getElement().insertBefore(
+ getWidgetForPaintable().errorIndicatorElement,
+ getWidgetForPaintable().captionElement);
+
+ } else if (getWidgetForPaintable().errorIndicatorElement != null) {
+ getWidgetForPaintable().getElement().removeChild(
+ getWidgetForPaintable().errorIndicatorElement);
+ getWidgetForPaintable().errorIndicatorElement = null;
+ }
+
+ if (uidl.hasAttribute("icon")) {
+ if (getWidgetForPaintable().icon == null) {
+ getWidgetForPaintable().icon = new Icon(client);
+ getWidgetForPaintable().getElement().insertBefore(
+ getWidgetForPaintable().icon.getElement(),
+ getWidgetForPaintable().captionElement);
+ }
+ getWidgetForPaintable().icon
+ .setUri(uidl.getStringAttribute("icon"));
+ } else {
+ if (getWidgetForPaintable().icon != null) {
+ getWidgetForPaintable().getElement().removeChild(
+ getWidgetForPaintable().icon.getElement());
+ getWidgetForPaintable().icon = null;
+ }
+ }
+
+ }
+
+ @Override
+ protected Widget createWidget() {
+ return GWT.create(VNativeButton.class);
+ }
+
+ @Override
+ public VNativeButton getWidgetForPaintable() {
+ return (VNativeButton) super.getWidgetForPaintable();
+ }
+} \ No newline at end of file
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VPopupCalendar.java b/src/com/vaadin/terminal/gwt/client/ui/VPopupCalendar.java
index 7de1658c5d..44fb9ac69c 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VPopupCalendar.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VPopupCalendar.java
@@ -1,462 +1,474 @@
-/*
-@VaadinApache2LicenseForJavaFiles@
- */
-
-package com.vaadin.terminal.gwt.client.ui;
-
-import java.util.Date;
-
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.event.dom.client.ClickEvent;
-import com.google.gwt.event.dom.client.ClickHandler;
-import com.google.gwt.event.dom.client.DomEvent;
-import com.google.gwt.event.dom.client.KeyCodes;
-import com.google.gwt.event.logical.shared.CloseEvent;
-import com.google.gwt.event.logical.shared.CloseHandler;
-import com.google.gwt.user.client.DOM;
-import com.google.gwt.user.client.Element;
-import com.google.gwt.user.client.Event;
-import com.google.gwt.user.client.Timer;
-import com.google.gwt.user.client.Window;
-import com.google.gwt.user.client.ui.Button;
-import com.google.gwt.user.client.ui.PopupPanel;
-import com.google.gwt.user.client.ui.PopupPanel.PositionCallback;
-import com.vaadin.terminal.gwt.client.ApplicationConnection;
-import com.vaadin.terminal.gwt.client.BrowserInfo;
-import com.vaadin.terminal.gwt.client.DateTimeService;
-import com.vaadin.terminal.gwt.client.VPaintableWidget;
-import com.vaadin.terminal.gwt.client.UIDL;
-import com.vaadin.terminal.gwt.client.VConsole;
-import com.vaadin.terminal.gwt.client.ui.VCalendarPanel.FocusChangeListener;
-import com.vaadin.terminal.gwt.client.ui.VCalendarPanel.FocusOutListener;
-import com.vaadin.terminal.gwt.client.ui.VCalendarPanel.SubmitListener;
-import com.vaadin.terminal.gwt.client.ui.VCalendarPanel.TimeChangeListener;
-
-/**
- * Represents a date selection component with a text field and a popup date
- * selector.
- *
- * <b>Note:</b> To change the keyboard assignments used in the popup dialog you
- * should extend <code>com.vaadin.terminal.gwt.client.ui.VCalendarPanel</code>
- * and then pass set it by calling the
- * <code>setCalendarPanel(VCalendarPanel panel)</code> method.
- *
- */
-public class VPopupCalendar extends VTextualDate implements VPaintableWidget,
- Field, ClickHandler, CloseHandler<PopupPanel>, SubPartAware {
-
- private final Button calendarToggle;
-
- private VCalendarPanel calendar;
-
- private final VOverlay popup;
- private boolean open = false;
- private boolean parsable = true;
-
- public VPopupCalendar() {
- super();
-
- calendarToggle = new Button();
- calendarToggle.setStyleName(CLASSNAME + "-button");
- calendarToggle.setText("");
- calendarToggle.addClickHandler(this);
- // -2 instead of -1 to avoid FocusWidget.onAttach to reset it
- calendarToggle.getElement().setTabIndex(-2);
- add(calendarToggle);
-
- calendar = GWT.create(VCalendarPanel.class);
- calendar.setFocusOutListener(new FocusOutListener() {
- public boolean onFocusOut(DomEvent<?> event) {
- event.preventDefault();
- closeCalendarPanel();
- return true;
- }
- });
-
- calendar.setSubmitListener(new SubmitListener() {
- public void onSubmit() {
- // Update internal value and send valuechange event if immediate
- updateValue(calendar.getDate());
-
- // Update text field (a must when not immediate).
- buildDate(true);
-
- closeCalendarPanel();
- }
-
- public void onCancel() {
- closeCalendarPanel();
- }
- });
-
- popup = new VOverlay(true, true, true);
- popup.setStyleName(VDateField.CLASSNAME + "-popup");
- popup.setWidget(calendar);
- popup.addCloseHandler(this);
-
- DOM.setElementProperty(calendar.getElement(), "id",
- "PID_VAADIN_POPUPCAL");
-
- sinkEvents(Event.ONKEYDOWN);
-
- }
-
- @SuppressWarnings("deprecation")
- private void updateValue(Date newDate) {
- Date currentDate = getCurrentDate();
- if (currentDate == null || newDate.getTime() != currentDate.getTime()) {
- setCurrentDate((Date) newDate.clone());
- getClient().updateVariable(getId(), "year",
- newDate.getYear() + 1900, false);
- if (getCurrentResolution() > VDateField.RESOLUTION_YEAR) {
- getClient().updateVariable(getId(), "month",
- newDate.getMonth() + 1, false);
- if (getCurrentResolution() > RESOLUTION_MONTH) {
- getClient().updateVariable(getId(), "day",
- newDate.getDate(), false);
- if (getCurrentResolution() > RESOLUTION_DAY) {
- getClient().updateVariable(getId(), "hour",
- newDate.getHours(), false);
- if (getCurrentResolution() > RESOLUTION_HOUR) {
- getClient().updateVariable(getId(), "min",
- newDate.getMinutes(), false);
- if (getCurrentResolution() > RESOLUTION_MIN) {
- getClient().updateVariable(getId(), "sec",
- newDate.getSeconds(), false);
- }
- }
- }
- }
- }
- if (isImmediate()) {
- getClient().sendPendingVariableChanges();
- }
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * com.vaadin.terminal.gwt.client.ui.VTextualDate#updateFromUIDL(com.vaadin
- * .terminal.gwt.client.UIDL,
- * com.vaadin.terminal.gwt.client.ApplicationConnection)
- */
- @Override
- @SuppressWarnings("deprecation")
- public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
- boolean lastReadOnlyState = readonly;
- parsable = uidl.getBooleanAttribute("parsable");
-
- super.updateFromUIDL(uidl, client);
-
- popup.setStyleName(VDateField.CLASSNAME + "-popup "
- + VDateField.CLASSNAME + "-"
- + resolutionToString(currentResolution));
- calendar.setDateTimeService(getDateTimeService());
- calendar.setShowISOWeekNumbers(isShowISOWeekNumbers());
- if (calendar.getResolution() != currentResolution) {
- calendar.setResolution(currentResolution);
- if (calendar.getDate() != null) {
- calendar.setDate((Date) getCurrentDate().clone());
- // force re-render when changing resolution only
- calendar.renderCalendar();
- }
- }
- calendarToggle.setEnabled(enabled);
-
- if (currentResolution <= RESOLUTION_MONTH) {
- calendar.setFocusChangeListener(new FocusChangeListener() {
- public void focusChanged(Date date) {
- updateValue(date);
- buildDate();
- Date date2 = calendar.getDate();
- date2.setYear(date.getYear());
- date2.setMonth(date.getMonth());
- }
- });
- } else {
- calendar.setFocusChangeListener(null);
- }
-
- if (currentResolution > RESOLUTION_DAY) {
- calendar.setTimeChangeListener(new TimeChangeListener() {
- public void changed(int hour, int min, int sec, int msec) {
- Date d = getDate();
- if (d == null) {
- // date currently null, use the value from calendarPanel
- // (~ client time at the init of the widget)
- d = (Date) calendar.getDate().clone();
- }
- d.setHours(hour);
- d.setMinutes(min);
- d.setSeconds(sec);
- DateTimeService.setMilliseconds(d, msec);
-
- // Always update time changes to the server
- updateValue(d);
-
- // Update text field
- buildDate();
- }
- });
- }
-
- if (readonly) {
- calendarToggle.addStyleName(CLASSNAME + "-button-readonly");
- } else {
- calendarToggle.removeStyleName(CLASSNAME + "-button-readonly");
- }
-
- if (lastReadOnlyState != readonly) {
- updateWidth();
- }
-
- calendarToggle.setEnabled(true);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * com.google.gwt.user.client.ui.UIObject#setStyleName(java.lang.String)
- */
- @Override
- public void setStyleName(String style) {
- // make sure the style is there before size calculation
- super.setStyleName(style + " " + CLASSNAME + "-popupcalendar");
- }
-
- /**
- * Opens the calendar panel popup
- */
- public void openCalendarPanel() {
-
- if (!open && !readonly) {
- open = true;
-
- if (getCurrentDate() != null) {
- calendar.setDate((Date) getCurrentDate().clone());
- } else {
- calendar.setDate(new Date());
- }
-
- // clear previous values
- popup.setWidth("");
- popup.setHeight("");
- popup.setPopupPositionAndShow(new PositionCallback() {
- public void setPosition(int offsetWidth, int offsetHeight) {
- final int w = offsetWidth;
- final int h = offsetHeight;
- final int browserWindowWidth = Window.getClientWidth()
- + Window.getScrollLeft();
- final int browserWindowHeight = Window.getClientHeight()
- + Window.getScrollTop();
- int t = calendarToggle.getAbsoluteTop();
- int l = calendarToggle.getAbsoluteLeft();
-
- // Add a little extra space to the right to avoid
- // problems with IE7 scrollbars and to make it look
- // nicer.
- int extraSpace = 30;
-
- boolean overflowRight = false;
- if (l + +w + extraSpace > browserWindowWidth) {
- overflowRight = true;
- // Part of the popup is outside the browser window
- // (to the right)
- l = browserWindowWidth - w - extraSpace;
- }
-
- if (t + h + calendarToggle.getOffsetHeight() + 30 > browserWindowHeight) {
- // Part of the popup is outside the browser window
- // (below)
- t = browserWindowHeight - h
- - calendarToggle.getOffsetHeight() - 30;
- if (!overflowRight) {
- // Show to the right of the popup button unless we
- // are in the lower right corner of the screen
- l += calendarToggle.getOffsetWidth();
- }
- }
-
- // fix size
- popup.setWidth(w + "px");
- popup.setHeight(h + "px");
-
- popup.setPopupPosition(l,
- t + calendarToggle.getOffsetHeight() + 2);
-
- /*
- * We have to wait a while before focusing since the popup
- * needs to be opened before we can focus
- */
- Timer focusTimer = new Timer() {
- @Override
- public void run() {
- setFocus(true);
- }
- };
-
- focusTimer.schedule(100);
- }
- });
- } else {
- VConsole.error("Cannot reopen popup, it is already open!");
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * com.google.gwt.event.dom.client.ClickHandler#onClick(com.google.gwt.event
- * .dom.client.ClickEvent)
- */
- public void onClick(ClickEvent event) {
- if (event.getSource() == calendarToggle && isEnabled()) {
- openCalendarPanel();
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * com.google.gwt.event.logical.shared.CloseHandler#onClose(com.google.gwt
- * .event.logical.shared.CloseEvent)
- */
- public void onClose(CloseEvent<PopupPanel> event) {
- if (event.getSource() == popup) {
- buildDate();
- if (!BrowserInfo.get().isTouchDevice()) {
- /*
- * Move focus to textbox, unless on touch device (avoids opening
- * virtual keyboard).
- */
- focus();
- }
-
- // TODO resolve what the "Sigh." is all about and document it here
- // Sigh.
- Timer t = new Timer() {
- @Override
- public void run() {
- open = false;
- }
- };
- t.schedule(100);
- }
- }
-
- /**
- * Sets focus to Calendar panel.
- *
- * @param focus
- */
- public void setFocus(boolean focus) {
- calendar.setFocus(focus);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.vaadin.terminal.gwt.client.ui.VTextualDate#getFieldExtraWidth()
- */
- @Override
- protected int getFieldExtraWidth() {
- if (fieldExtraWidth < 0) {
- fieldExtraWidth = super.getFieldExtraWidth();
- fieldExtraWidth += calendarToggle.getOffsetWidth();
- }
- return fieldExtraWidth;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.vaadin.terminal.gwt.client.ui.VTextualDate#buildDate()
- */
- @Override
- protected void buildDate() {
- // Save previous value
- String previousValue = getText();
- super.buildDate();
-
- // Restore previous value if the input could not be parsed
- if (!parsable) {
- setText(previousValue);
- }
- }
-
- /**
- * Update the text field contents from the date. See {@link #buildDate()}.
- *
- * @param forceValid
- * true to force the text field to be updated, false to only
- * update if the parsable flag is true.
- */
- protected void buildDate(boolean forceValid) {
- if (forceValid) {
- parsable = true;
- }
- buildDate();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * com.vaadin.terminal.gwt.client.ui.VDateField#onBrowserEvent(com.google
- * .gwt.user.client.Event)
- */
- @Override
- public void onBrowserEvent(com.google.gwt.user.client.Event event) {
- super.onBrowserEvent(event);
- if (DOM.eventGetType(event) == Event.ONKEYDOWN
- && event.getKeyCode() == getOpenCalenderPanelKey()) {
- openCalendarPanel();
- event.preventDefault();
- }
- }
-
- /**
- * Get the key code that opens the calendar panel. By default it is the down
- * key but you can override this to be whatever you like
- *
- * @return
- */
- protected int getOpenCalenderPanelKey() {
- return KeyCodes.KEY_DOWN;
- }
-
- /**
- * Closes the open popup panel
- */
- public void closeCalendarPanel() {
- if (open) {
- popup.hide(true);
- }
- }
-
- private final String CALENDAR_TOGGLE_ID = "popupButton";
-
- @Override
- public Element getSubPartElement(String subPart) {
- if (subPart.equals(CALENDAR_TOGGLE_ID)) {
- return calendarToggle.getElement();
- }
-
- return super.getSubPartElement(subPart);
- }
-
- @Override
- public String getSubPartName(Element subElement) {
- if (calendarToggle.getElement().isOrHasChild(subElement)) {
- return CALENDAR_TOGGLE_ID;
- }
-
- return super.getSubPartName(subElement);
- }
-
-}
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.terminal.gwt.client.ui;
+
+import java.util.Date;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.event.dom.client.DomEvent;
+import com.google.gwt.event.dom.client.KeyCodes;
+import com.google.gwt.event.logical.shared.CloseEvent;
+import com.google.gwt.event.logical.shared.CloseHandler;
+import com.google.gwt.user.client.DOM;
+import com.google.gwt.user.client.Element;
+import com.google.gwt.user.client.Event;
+import com.google.gwt.user.client.Timer;
+import com.google.gwt.user.client.Window;
+import com.google.gwt.user.client.ui.Button;
+import com.google.gwt.user.client.ui.PopupPanel;
+import com.google.gwt.user.client.ui.PopupPanel.PositionCallback;
+import com.vaadin.terminal.gwt.client.ApplicationConnection;
+import com.vaadin.terminal.gwt.client.BrowserInfo;
+import com.vaadin.terminal.gwt.client.DateTimeService;
+import com.vaadin.terminal.gwt.client.VPaintableWidget;
+import com.vaadin.terminal.gwt.client.UIDL;
+import com.vaadin.terminal.gwt.client.VConsole;
+import com.vaadin.terminal.gwt.client.ui.VCalendarPanel.FocusChangeListener;
+import com.vaadin.terminal.gwt.client.ui.VCalendarPanel.FocusOutListener;
+import com.vaadin.terminal.gwt.client.ui.VCalendarPanel.SubmitListener;
+import com.vaadin.terminal.gwt.client.ui.VCalendarPanel.TimeChangeListener;
+
+/**
+ * Represents a date selection component with a text field and a popup date
+ * selector.
+ *
+ * <b>Note:</b> To change the keyboard assignments used in the popup dialog you
+ * should extend <code>com.vaadin.terminal.gwt.client.ui.VCalendarPanel</code>
+ * and then pass set it by calling the
+ * <code>setCalendarPanel(VCalendarPanel panel)</code> method.
+ *
+ */
+public class VPopupCalendar extends VTextualDate implements VPaintableWidget,
+ Field, ClickHandler, CloseHandler<PopupPanel>, SubPartAware {
+
+ private static final String POPUP_PRIMARY_STYLE_NAME = VDateField.CLASSNAME
+ + "-popup";
+
+ private final Button calendarToggle;
+
+ private VCalendarPanel calendar;
+
+ private final VOverlay popup;
+ private boolean open = false;
+ private boolean parsable = true;
+
+ public VPopupCalendar() {
+ super();
+
+ calendarToggle = new Button();
+ calendarToggle.setStyleName(CLASSNAME + "-button");
+ calendarToggle.setText("");
+ calendarToggle.addClickHandler(this);
+ // -2 instead of -1 to avoid FocusWidget.onAttach to reset it
+ calendarToggle.getElement().setTabIndex(-2);
+ add(calendarToggle);
+
+ calendar = GWT.create(VCalendarPanel.class);
+ calendar.setFocusOutListener(new FocusOutListener() {
+ public boolean onFocusOut(DomEvent<?> event) {
+ event.preventDefault();
+ closeCalendarPanel();
+ return true;
+ }
+ });
+
+ calendar.setSubmitListener(new SubmitListener() {
+ public void onSubmit() {
+ // Update internal value and send valuechange event if immediate
+ updateValue(calendar.getDate());
+
+ // Update text field (a must when not immediate).
+ buildDate(true);
+
+ closeCalendarPanel();
+ }
+
+ public void onCancel() {
+ closeCalendarPanel();
+ }
+ });
+
+ popup = new VOverlay(true, true, true);
+ popup.setStyleName(POPUP_PRIMARY_STYLE_NAME);
+ popup.setWidget(calendar);
+ popup.addCloseHandler(this);
+
+ DOM.setElementProperty(calendar.getElement(), "id",
+ "PID_VAADIN_POPUPCAL");
+
+ sinkEvents(Event.ONKEYDOWN);
+
+ }
+
+ @SuppressWarnings("deprecation")
+ private void updateValue(Date newDate) {
+ Date currentDate = getCurrentDate();
+ if (currentDate == null || newDate.getTime() != currentDate.getTime()) {
+ setCurrentDate((Date) newDate.clone());
+ getClient().updateVariable(getId(), "year",
+ newDate.getYear() + 1900, false);
+ if (getCurrentResolution() > VDateField.RESOLUTION_YEAR) {
+ getClient().updateVariable(getId(), "month",
+ newDate.getMonth() + 1, false);
+ if (getCurrentResolution() > RESOLUTION_MONTH) {
+ getClient().updateVariable(getId(), "day",
+ newDate.getDate(), false);
+ if (getCurrentResolution() > RESOLUTION_DAY) {
+ getClient().updateVariable(getId(), "hour",
+ newDate.getHours(), false);
+ if (getCurrentResolution() > RESOLUTION_HOUR) {
+ getClient().updateVariable(getId(), "min",
+ newDate.getMinutes(), false);
+ if (getCurrentResolution() > RESOLUTION_MIN) {
+ getClient().updateVariable(getId(), "sec",
+ newDate.getSeconds(), false);
+ }
+ }
+ }
+ }
+ }
+ if (isImmediate()) {
+ getClient().sendPendingVariableChanges();
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * com.vaadin.terminal.gwt.client.ui.VTextualDate#updateFromUIDL(com.vaadin
+ * .terminal.gwt.client.UIDL,
+ * com.vaadin.terminal.gwt.client.ApplicationConnection)
+ */
+ @Override
+ @SuppressWarnings("deprecation")
+ public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
+ boolean lastReadOnlyState = readonly;
+ boolean lastEnabledState = isEnabled();
+
+ parsable = uidl.getBooleanAttribute("parsable");
+
+ super.updateFromUIDL(uidl, client);
+
+ 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) {
+ calendar.setResolution(currentResolution);
+ if (calendar.getDate() != null) {
+ calendar.setDate((Date) getCurrentDate().clone());
+ // force re-render when changing resolution only
+ calendar.renderCalendar();
+ }
+ }
+ calendarToggle.setEnabled(enabled);
+
+ if (currentResolution <= RESOLUTION_MONTH) {
+ calendar.setFocusChangeListener(new FocusChangeListener() {
+ public void focusChanged(Date date) {
+ updateValue(date);
+ buildDate();
+ Date date2 = calendar.getDate();
+ date2.setYear(date.getYear());
+ date2.setMonth(date.getMonth());
+ }
+ });
+ } else {
+ calendar.setFocusChangeListener(null);
+ }
+
+ if (currentResolution > RESOLUTION_DAY) {
+ calendar.setTimeChangeListener(new TimeChangeListener() {
+ public void changed(int hour, int min, int sec, int msec) {
+ Date d = getDate();
+ if (d == null) {
+ // date currently null, use the value from calendarPanel
+ // (~ client time at the init of the widget)
+ d = (Date) calendar.getDate().clone();
+ }
+ d.setHours(hour);
+ d.setMinutes(min);
+ d.setSeconds(sec);
+ DateTimeService.setMilliseconds(d, msec);
+
+ // Always update time changes to the server
+ updateValue(d);
+
+ // Update text field
+ buildDate();
+ }
+ });
+ }
+
+ if (readonly) {
+ calendarToggle.addStyleName(CLASSNAME + "-button-readonly");
+ } else {
+ calendarToggle.removeStyleName(CLASSNAME + "-button-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();
+ }
+
+ calendarToggle.setEnabled(true);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * com.google.gwt.user.client.ui.UIObject#setStyleName(java.lang.String)
+ */
+ @Override
+ public void setStyleName(String style) {
+ // make sure the style is there before size calculation
+ super.setStyleName(style + " " + CLASSNAME + "-popupcalendar");
+ }
+
+ /**
+ * Opens the calendar panel popup
+ */
+ public void openCalendarPanel() {
+
+ if (!open && !readonly) {
+ open = true;
+
+ if (getCurrentDate() != null) {
+ calendar.setDate((Date) getCurrentDate().clone());
+ } else {
+ calendar.setDate(new Date());
+ }
+
+ // clear previous values
+ popup.setWidth("");
+ popup.setHeight("");
+ popup.setPopupPositionAndShow(new PositionCallback() {
+ public void setPosition(int offsetWidth, int offsetHeight) {
+ final int w = offsetWidth;
+ final int h = offsetHeight;
+ final int browserWindowWidth = Window.getClientWidth()
+ + Window.getScrollLeft();
+ final int browserWindowHeight = Window.getClientHeight()
+ + Window.getScrollTop();
+ int t = calendarToggle.getAbsoluteTop();
+ int l = calendarToggle.getAbsoluteLeft();
+
+ // Add a little extra space to the right to avoid
+ // problems with IE7 scrollbars and to make it look
+ // nicer.
+ int extraSpace = 30;
+
+ boolean overflowRight = false;
+ if (l + +w + extraSpace > browserWindowWidth) {
+ overflowRight = true;
+ // Part of the popup is outside the browser window
+ // (to the right)
+ l = browserWindowWidth - w - extraSpace;
+ }
+
+ if (t + h + calendarToggle.getOffsetHeight() + 30 > browserWindowHeight) {
+ // Part of the popup is outside the browser window
+ // (below)
+ t = browserWindowHeight - h
+ - calendarToggle.getOffsetHeight() - 30;
+ if (!overflowRight) {
+ // Show to the right of the popup button unless we
+ // are in the lower right corner of the screen
+ l += calendarToggle.getOffsetWidth();
+ }
+ }
+
+ // fix size
+ popup.setWidth(w + "px");
+ popup.setHeight(h + "px");
+
+ popup.setPopupPosition(l,
+ t + calendarToggle.getOffsetHeight() + 2);
+
+ /*
+ * We have to wait a while before focusing since the popup
+ * needs to be opened before we can focus
+ */
+ Timer focusTimer = new Timer() {
+ @Override
+ public void run() {
+ setFocus(true);
+ }
+ };
+
+ focusTimer.schedule(100);
+ }
+ });
+ } else {
+ VConsole.error("Cannot reopen popup, it is already open!");
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * com.google.gwt.event.dom.client.ClickHandler#onClick(com.google.gwt.event
+ * .dom.client.ClickEvent)
+ */
+ public void onClick(ClickEvent event) {
+ if (event.getSource() == calendarToggle && isEnabled()) {
+ openCalendarPanel();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * com.google.gwt.event.logical.shared.CloseHandler#onClose(com.google.gwt
+ * .event.logical.shared.CloseEvent)
+ */
+ public void onClose(CloseEvent<PopupPanel> event) {
+ if (event.getSource() == popup) {
+ buildDate();
+ if (!BrowserInfo.get().isTouchDevice()) {
+ /*
+ * Move focus to textbox, unless on touch device (avoids opening
+ * virtual keyboard).
+ */
+ focus();
+ }
+
+ // TODO resolve what the "Sigh." is all about and document it here
+ // Sigh.
+ Timer t = new Timer() {
+ @Override
+ public void run() {
+ open = false;
+ }
+ };
+ t.schedule(100);
+ }
+ }
+
+ /**
+ * Sets focus to Calendar panel.
+ *
+ * @param focus
+ */
+ public void setFocus(boolean focus) {
+ calendar.setFocus(focus);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.terminal.gwt.client.ui.VTextualDate#getFieldExtraWidth()
+ */
+ @Override
+ protected int getFieldExtraWidth() {
+ if (fieldExtraWidth < 0) {
+ fieldExtraWidth = super.getFieldExtraWidth();
+ fieldExtraWidth += calendarToggle.getOffsetWidth();
+ }
+ return fieldExtraWidth;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.terminal.gwt.client.ui.VTextualDate#buildDate()
+ */
+ @Override
+ protected void buildDate() {
+ // Save previous value
+ String previousValue = getText();
+ super.buildDate();
+
+ // Restore previous value if the input could not be parsed
+ if (!parsable) {
+ setText(previousValue);
+ }
+ }
+
+ /**
+ * Update the text field contents from the date. See {@link #buildDate()}.
+ *
+ * @param forceValid
+ * true to force the text field to be updated, false to only
+ * update if the parsable flag is true.
+ */
+ protected void buildDate(boolean forceValid) {
+ if (forceValid) {
+ parsable = true;
+ }
+ buildDate();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * com.vaadin.terminal.gwt.client.ui.VDateField#onBrowserEvent(com.google
+ * .gwt.user.client.Event)
+ */
+ @Override
+ public void onBrowserEvent(com.google.gwt.user.client.Event event) {
+ super.onBrowserEvent(event);
+ if (DOM.eventGetType(event) == Event.ONKEYDOWN
+ && event.getKeyCode() == getOpenCalenderPanelKey()) {
+ openCalendarPanel();
+ event.preventDefault();
+ }
+ }
+
+ /**
+ * Get the key code that opens the calendar panel. By default it is the down
+ * key but you can override this to be whatever you like
+ *
+ * @return
+ */
+ protected int getOpenCalenderPanelKey() {
+ return KeyCodes.KEY_DOWN;
+ }
+
+ /**
+ * Closes the open popup panel
+ */
+ public void closeCalendarPanel() {
+ if (open) {
+ popup.hide(true);
+ }
+ }
+
+ private final String CALENDAR_TOGGLE_ID = "popupButton";
+
+ @Override
+ public Element getSubPartElement(String subPart) {
+ if (subPart.equals(CALENDAR_TOGGLE_ID)) {
+ return calendarToggle.getElement();
+ }
+
+ return super.getSubPartElement(subPart);
+ }
+
+ @Override
+ public String getSubPartName(Element subElement) {
+ if (calendarToggle.getElement().isOrHasChild(subElement)) {
+ return CALENDAR_TOGGLE_ID;
+ }
+
+ return super.getSubPartName(subElement);
+ }
+
+}
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java
index 736635ecd0..de68ae96a4 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java
@@ -52,6 +52,7 @@ import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.FlowPanel;
+import com.google.gwt.user.client.ui.HasWidgets;
import com.google.gwt.user.client.ui.Panel;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.UIObject;
@@ -103,17 +104,31 @@ import com.vaadin.terminal.gwt.client.ui.label.VLabel;
*
* TODO implement unregistering for child components in Cells
*/
-public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
- VHasDropHandler, FocusHandler, BlurHandler, Focusable, ActionOwner {
+public class VScrollTable extends FlowPanel implements HasWidgets,
+ ScrollHandler, VHasDropHandler, FocusHandler, BlurHandler, Focusable,
+ ActionOwner {
- public static final String ATTRIBUTE_PAGEBUFFER_FIRST = "pb-ft";
- public static final String ATTRIBUTE_PAGEBUFFER_LAST = "pb-l";
+ public enum SelectMode {
+ NONE(0), SINGLE(1), MULTI(2);
+ private int id;
+
+ private SelectMode(int id) {
+ this.id = id;
+ }
+
+ public int getId() {
+ return id;
+ }
+ }
private static final String ROW_HEADER_COLUMN_KEY = "0";
public static final String CLASSNAME = "v-table";
public static final String CLASSNAME_SELECTION_FOCUS = CLASSNAME + "-focus";
+ public static final String ATTRIBUTE_PAGEBUFFER_FIRST = "pb-ft";
+ public static final String ATTRIBUTE_PAGEBUFFER_LAST = "pb-l";
+
public static final String ITEM_CLICK_EVENT_ID = "itemClick";
public static final String HEADER_CLICK_EVENT_ID = "handleHeaderClick";
public static final String FOOTER_CLICK_EVENT_ID = "handleFooterClick";
@@ -162,10 +177,10 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
protected ApplicationConnection client;
protected String paintableId;
- private boolean immediate;
+ boolean immediate;
private boolean nullSelectionAllowed = true;
- private int selectMode = Table.SELECT_MODE_NONE;
+ private SelectMode selectMode = SelectMode.NONE;
private final HashSet<String> selectedRowKeys = new HashSet<String>();
@@ -178,15 +193,15 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
/*
* These are used when jumping between pages when pressing Home and End
*/
- private boolean selectLastItemInNextRender = false;
- private boolean selectFirstItemInNextRender = false;
- private boolean focusFirstItemInNextRender = false;
- private boolean focusLastItemInNextRender = false;
+ boolean selectLastItemInNextRender = false;
+ boolean selectFirstItemInNextRender = false;
+ boolean focusFirstItemInNextRender = false;
+ boolean focusLastItemInNextRender = false;
/*
* The currently focused row
*/
- private VScrollTableRow focusedRow;
+ VScrollTableRow focusedRow;
/*
* Helper to store selection range start in when using the keyboard
@@ -197,7 +212,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
* Flag for notifying when the selection has changed and should be sent to
* the server
*/
- private boolean selectionChanged = false;
+ boolean selectionChanged = false;
/*
* The speed (in pixels) which the scrolling scrolls vertically/horizontally
@@ -206,7 +221,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
private Timer scrollingVelocityTimer = null;
- private String[] bodyActionKeys;
+ String[] bodyActionKeys;
private boolean enableDebug = false;
@@ -282,19 +297,18 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
private final HashSet<SelectionRange> selectedRowRanges = new HashSet<SelectionRange>();
- private boolean initializedAndAttached = false;
+ boolean initializedAndAttached = false;
/**
* Flag to indicate if a column width recalculation is needed due update.
*/
- private boolean headerChangedDuringUpdate = false;
+ boolean headerChangedDuringUpdate = false;
protected final TableHead tHead = new TableHead();
- private final TableFooter tFoot = new TableFooter();
+ final TableFooter tFoot = new TableFooter();
- private final FocusableScrollPanel scrollBodyPanel = new FocusableScrollPanel(
- true);
+ final FocusableScrollPanel scrollBodyPanel = new FocusableScrollPanel(true);
private KeyPressHandler navKeyPressHandler = new KeyPressHandler() {
public void onKeyPress(KeyPressEvent keyPressEvent) {
@@ -383,12 +397,12 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
}
}
};
- private int totalRows;
+ int totalRows;
private Set<String> collapsedColumns;
- private final RowRequestHandler rowRequestHandler;
- private VScrollTableBody scrollBody;
+ final RowRequestHandler rowRequestHandler;
+ VScrollTableBody scrollBody;
private int firstvisible = 0;
private boolean sortAscending;
private String sortColumn;
@@ -403,9 +417,9 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
private String[] visibleColOrder;
private boolean initialContentReceived = false;
private Element scrollPositionElement;
- private boolean enabled;
- private boolean showColHeaders;
- private boolean showColFooters;
+ boolean enabled;
+ boolean showColHeaders;
+ boolean showColFooters;
/** flag to indicate that table body has changed */
private boolean isNewBody = true;
@@ -420,15 +434,15 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
private final ArrayList<Panel> lazyUnregistryBag = new ArrayList<Panel>();
private String height;
private String width = "";
- private boolean rendering = false;
+ boolean rendering = false;
private boolean hasFocus = false;
private int dragmode;
private int multiselectmode;
- private int tabIndex;
+ int tabIndex;
private TouchScrollDelegate touchScrollDelegate;
- private int lastRenderedHeight;
+ int lastRenderedHeight;
/**
* Values (serverCacheFirst+serverCacheLast) sent by server that tells which
@@ -442,8 +456,8 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
* scrolling in the client will cause empty buttons to be rendered
* (cached=true request for non-existing components)
*/
- private int serverCacheFirst = -1;
- private int serverCacheLast = -1;
+ int serverCacheFirst = -1;
+ int serverCacheLast = -1;
public VScrollTable() {
setMultiSelectMode(MULTISELECT_MODE_DEFAULT);
@@ -810,211 +824,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
return KeyCodes.KEY_END;
}
- /*
- * (non-Javadoc)
- *
- * @see
- * com.vaadin.terminal.gwt.client.Paintable#updateFromUIDL(com.vaadin.terminal
- * .gwt.client.UIDL, com.vaadin.terminal.gwt.client.ApplicationConnection)
- */
- public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
- rendering = true;
-
- if (uidl.hasAttribute(ATTRIBUTE_PAGEBUFFER_FIRST)) {
- serverCacheFirst = uidl.getIntAttribute(ATTRIBUTE_PAGEBUFFER_FIRST);
- serverCacheLast = uidl.getIntAttribute(ATTRIBUTE_PAGEBUFFER_LAST);
- } else {
- serverCacheFirst = -1;
- serverCacheLast = -1;
- }
- /*
- * We need to do this before updateComponent since updateComponent calls
- * this.setHeight() which will calculate a new body height depending on
- * the space available.
- */
- if (uidl.hasAttribute("colfooters")) {
- showColFooters = uidl.getBooleanAttribute("colfooters");
- }
-
- tFoot.setVisible(showColFooters);
-
- if (client.updateComponent(this, uidl, true)) {
- rendering = false;
- return;
- }
-
- enabled = !uidl.hasAttribute("disabled");
-
- if (BrowserInfo.get().isIE8() && !enabled) {
- /*
- * The disabled shim will not cover the table body if it is relative
- * in IE8. See #7324
- */
- scrollBodyPanel.getElement().getStyle()
- .setPosition(Position.STATIC);
- } else if (BrowserInfo.get().isIE8()) {
- scrollBodyPanel.getElement().getStyle()
- .setPosition(Position.RELATIVE);
- }
-
- this.client = client;
- paintableId = uidl.getStringAttribute("id");
- immediate = uidl.getBooleanAttribute("immediate");
-
- int previousTotalRows = totalRows;
- updateTotalRows(uidl);
- boolean totalRowsChanged = (totalRows != previousTotalRows);
-
- updateDragMode(uidl);
-
- updateSelectionProperties(uidl);
-
- if (uidl.hasAttribute("alb")) {
- bodyActionKeys = uidl.getStringArrayAttribute("alb");
- } else {
- // Need to clear the actions if the action handlers have been
- // removed
- bodyActionKeys = null;
- }
-
- setCacheRateFromUIDL(uidl);
-
- recalcWidths = uidl.hasAttribute("recalcWidths");
- if (recalcWidths) {
- tHead.clear();
- tFoot.clear();
- }
-
- updatePageLength(uidl);
-
- updateFirstVisibleAndScrollIfNeeded(uidl);
-
- showRowHeaders = uidl.getBooleanAttribute("rowheaders");
- showColHeaders = uidl.getBooleanAttribute("colheaders");
-
- updateSortingProperties(uidl);
-
- boolean keyboardSelectionOverRowFetchInProgress = selectSelectedRows(uidl);
-
- updateActionMap(uidl);
-
- updateColumnProperties(uidl);
-
- UIDL ac = uidl.getChildByTagName("-ac");
- if (ac == null) {
- if (dropHandler != null) {
- // remove dropHandler if not present anymore
- dropHandler = null;
- }
- } else {
- if (dropHandler == null) {
- dropHandler = new VScrollTableDropHandler();
- }
- dropHandler.updateAcceptRules(ac);
- }
-
- UIDL partialRowAdditions = uidl.getChildByTagName("prows");
- UIDL partialRowUpdates = uidl.getChildByTagName("urows");
- if (partialRowUpdates != null || partialRowAdditions != null) {
- // we may have pending cache row fetch, cancel it. See #2136
- rowRequestHandler.cancel();
-
- updateRowsInBody(partialRowUpdates);
- addAndRemoveRows(partialRowAdditions);
- } else {
- UIDL rowData = uidl.getChildByTagName("rows");
- if (rowData != null) {
- // we may have pending cache row fetch, cancel it. See #2136
- rowRequestHandler.cancel();
-
- if (!recalcWidths && initializedAndAttached) {
- updateBody(rowData, uidl.getIntAttribute("firstrow"),
- uidl.getIntAttribute("rows"));
- if (headerChangedDuringUpdate) {
- triggerLazyColumnAdjustment(true);
- } else if (!isScrollPositionVisible()
- || totalRowsChanged
- || lastRenderedHeight != scrollBody
- .getOffsetHeight()) {
- // webkits may still bug with their disturbing scrollbar
- // bug, see #3457
- // Run overflow fix for the scrollable area
- // #6698 - If there's a scroll going on, don't abort it
- // by changing overflows as the length of the contents
- // *shouldn't* have changed (unless the number of rows
- // or the height of the widget has also changed)
- Scheduler.get().scheduleDeferred(new Command() {
- public void execute() {
- Util.runWebkitOverflowAutoFix(scrollBodyPanel
- .getElement());
- }
- });
- }
- } else {
- initializeRows(uidl, rowData);
- }
- }
- }
-
- if (!isSelectable()) {
- scrollBody.addStyleName(CLASSNAME + "-body-noselection");
- } else {
- scrollBody.removeStyleName(CLASSNAME + "-body-noselection");
- }
-
- hideScrollPositionAnnotation();
- purgeUnregistryBag();
-
- // selection is no in sync with server, avoid excessive server visits by
- // clearing to flag used during the normal operation
- if (!keyboardSelectionOverRowFetchInProgress) {
- selectionChanged = false;
- }
-
- /*
- * This is called when the Home or page up button has been pressed in
- * selectable mode and the next selected row was not yet rendered in the
- * client
- */
- if (selectFirstItemInNextRender || focusFirstItemInNextRender) {
- selectFirstRenderedRowInViewPort(focusFirstItemInNextRender);
- selectFirstItemInNextRender = focusFirstItemInNextRender = false;
- }
-
- /*
- * This is called when the page down or end button has been pressed in
- * selectable mode and the next selected row was not yet rendered in the
- * client
- */
- if (selectLastItemInNextRender || focusLastItemInNextRender) {
- selectLastRenderedRowInViewPort(focusLastItemInNextRender);
- selectLastItemInNextRender = focusLastItemInNextRender = false;
- }
- multiselectPending = false;
-
- if (focusedRow != null) {
- if (!focusedRow.isAttached() && !rowRequestHandler.isRunning()) {
- // focused row has been orphaned, can't focus
- focusRowFromBody();
- }
- }
-
- tabIndex = uidl.hasAttribute("tabindex") ? uidl
- .getIntAttribute("tabindex") : 0;
- setProperTabIndex();
-
- resizeSortedColumnForSortIndicator();
-
- // Remember this to detect situations where overflow hack might be
- // needed during scrolling
- lastRenderedHeight = scrollBody.getOffsetHeight();
-
- rendering = false;
- headerChangedDuringUpdate = false;
-
- }
-
- private void initializeRows(UIDL uidl, UIDL rowData) {
+ void initializeRows(UIDL uidl, UIDL rowData) {
if (scrollBody != null) {
scrollBody.removeFromParent();
lazyUnregistryBag.add(scrollBody);
@@ -1037,7 +847,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
scrollBody.restoreRowVisibility();
}
- private void updateColumnProperties(UIDL uidl) {
+ void updateColumnProperties(UIDL uidl) {
updateColumnOrder(uidl);
updateCollapsedColumns(uidl);
@@ -1072,7 +882,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
}
}
- private boolean selectSelectedRows(UIDL uidl) {
+ boolean selectSelectedRows(UIDL uidl) {
boolean keyboardSelectionOverRowFetchInProgress = false;
if (uidl.hasVariable("selected")) {
@@ -1109,7 +919,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
return keyboardSelectionOverRowFetchInProgress;
}
- private void updateSortingProperties(UIDL uidl) {
+ void updateSortingProperties(UIDL uidl) {
oldSortColumn = sortColumn;
if (uidl.hasVariable("sortascending")) {
sortAscending = uidl.getBooleanVariable("sortascending");
@@ -1117,7 +927,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
}
}
- private void resizeSortedColumnForSortIndicator() {
+ void resizeSortedColumnForSortIndicator() {
// Force recalculation of the captionContainer element inside the header
// cell to accomodate for the size of the sort arrow.
HeaderCell sortedHeader = tHead.getHeaderCell(sortColumn);
@@ -1132,7 +942,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
}
}
- private void updateFirstVisibleAndScrollIfNeeded(UIDL uidl) {
+ void updateFirstVisibleAndScrollIfNeeded(UIDL uidl) {
firstvisible = uidl.hasVariable("firstvisible") ? uidl
.getIntVariable("firstvisible") : 0;
if (firstvisible != lastRequestedFirstvisible && scrollBody != null) {
@@ -1147,7 +957,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
return (int) (rowIx * scrollBody.getRowHeight());
}
- private void updatePageLength(UIDL uidl) {
+ void updatePageLength(UIDL uidl) {
int oldPageLength = pageLength;
if (uidl.hasAttribute("pagelength")) {
pageLength = uidl.getIntAttribute("pagelength");
@@ -1162,7 +972,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
}
}
- private void updateSelectionProperties(UIDL uidl) {
+ void updateSelectionProperties(UIDL uidl) {
setMultiSelectMode(uidl.hasAttribute("multiselectmode") ? uidl
.getIntAttribute("multiselectmode") : MULTISELECT_MODE_DEFAULT);
@@ -1171,18 +981,18 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
if (uidl.hasAttribute("selectmode")) {
if (uidl.getBooleanAttribute("readonly")) {
- selectMode = Table.SELECT_MODE_NONE;
+ selectMode = SelectMode.NONE;
} else if (uidl.getStringAttribute("selectmode").equals("multi")) {
- selectMode = Table.SELECT_MODE_MULTI;
+ selectMode = SelectMode.MULTI;
} else if (uidl.getStringAttribute("selectmode").equals("single")) {
- selectMode = Table.SELECT_MODE_SINGLE;
+ selectMode = SelectMode.SINGLE;
} else {
- selectMode = Table.SELECT_MODE_NONE;
+ selectMode = SelectMode.NONE;
}
}
}
- private void updateDragMode(UIDL uidl) {
+ void updateDragMode(UIDL uidl) {
dragmode = uidl.hasAttribute("dragmode") ? uidl
.getIntAttribute("dragmode") : 0;
if (BrowserInfo.get().isIE()) {
@@ -1219,7 +1029,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
return totalRows;
}
- private void focusRowFromBody() {
+ void focusRowFromBody() {
if (selectedRowKeys.size() == 1) {
// try to focus a row currently selected and in viewport
String selectedRowKey = selectedRowKeys.iterator().next();
@@ -1247,7 +1057,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
* @param focusOnly
* Should the focus only be moved to the last row
*/
- private void selectLastRenderedRowInViewPort(boolean focusOnly) {
+ void selectLastRenderedRowInViewPort(boolean focusOnly) {
int index = firstRowInViewPort + getFullyVisibleRowCount();
VScrollTableRow lastRowInViewport = scrollBody.getRowByRowIndex(index);
if (lastRowInViewport == null) {
@@ -1272,7 +1082,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
* @param focusOnly
* Should the focus only be moved to the first row
*/
- private void selectFirstRenderedRowInViewPort(boolean focusOnly) {
+ void selectFirstRenderedRowInViewPort(boolean focusOnly) {
int index = firstRowInViewPort;
VScrollTableRow firstInViewport = scrollBody.getRowByRowIndex(index);
if (firstInViewport == null) {
@@ -1286,7 +1096,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
}
}
- private void setCacheRateFromUIDL(UIDL uidl) {
+ void setCacheRateFromUIDL(UIDL uidl) {
setCacheRate(uidl.hasAttribute("cr") ? uidl.getDoubleAttribute("cr")
: CACHE_RATE_DEFAULT);
}
@@ -1303,7 +1113,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
* IScrollTableRows). This is done lazily as Table must survive from
* "subtreecaching" logic.
*/
- private void purgeUnregistryBag() {
+ void purgeUnregistryBag() {
for (Iterator<Panel> iterator = lazyUnregistryBag.iterator(); iterator
.hasNext();) {
VPaintableMap.get(client)
@@ -1312,7 +1122,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
lazyUnregistryBag.clear();
}
- private void updateActionMap(UIDL mainUidl) {
+ void updateActionMap(UIDL mainUidl) {
UIDL actionsUidl = mainUidl.getChildByTagName("actions");
if (actionsUidl == null) {
return;
@@ -1414,7 +1224,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
* @param reqRows
* amount of rows in data set
*/
- private void updateBody(UIDL uidl, int firstRow, int reqRows) {
+ void updateBody(UIDL uidl, int firstRow, int reqRows) {
if (uidl == null || reqRows < 1) {
// container is empty, remove possibly existing rows
if (firstRow <= 0) {
@@ -1431,7 +1241,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
discardRowsOutsideCacheWindow();
}
- private void updateRowsInBody(UIDL partialRowUpdates) {
+ void updateRowsInBody(UIDL partialRowUpdates) {
if (partialRowUpdates == null) {
return;
}
@@ -1564,20 +1374,20 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
}
private boolean isMultiSelectModeSimple() {
- return selectMode == Table.SELECT_MODE_MULTI
+ return selectMode == SelectMode.MULTI
&& multiselectmode == MULTISELECT_MODE_SIMPLE;
}
private boolean isSingleSelectMode() {
- return selectMode == Table.SELECT_MODE_SINGLE;
+ return selectMode == SelectMode.SINGLE;
}
private boolean isMultiSelectModeAny() {
- return selectMode == Table.SELECT_MODE_MULTI;
+ return selectMode == SelectMode.MULTI;
}
private boolean isMultiSelectModeDefault() {
- return selectMode == Table.SELECT_MODE_MULTI
+ return selectMode == SelectMode.MULTI
&& multiselectmode == MULTISELECT_MODE_DEFAULT;
}
@@ -1593,7 +1403,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
}
protected boolean isSelectable() {
- return selectMode > Table.SELECT_MODE_NONE;
+ return selectMode.getId() > SelectMode.NONE.getId();
}
private boolean isCollapsedColumn(String colKey) {
@@ -1769,7 +1579,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
}
}
client.updateVariable(paintableId, "columnorder", columnOrder, false);
- if (client.hasEventListeners(this, COLUMN_REORDER_EVENT_ID)) {
+ if (client.hasWidgetEventListeners(this, COLUMN_REORDER_EVENT_ID)) {
client.sendPendingVariableChanges();
}
}
@@ -2108,19 +1918,19 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
style.setDisplay(Display.BLOCK);
}
- private void hideScrollPositionAnnotation() {
+ void hideScrollPositionAnnotation() {
if (scrollPositionElement != null) {
DOM.setStyleAttribute(scrollPositionElement, "display", "none");
}
}
- private boolean isScrollPositionVisible() {
+ boolean isScrollPositionVisible() {
return scrollPositionElement != null
&& !scrollPositionElement.getStyle().getDisplay()
.equals(Display.NONE.toString());
}
- private class RowRequestHandler extends Timer {
+ class RowRequestHandler extends Timer {
private int reqFirstRow = 0;
private int reqRows = 0;
@@ -2295,26 +2105,16 @@ 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 (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) {
@@ -2512,7 +2312,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
* The click event
*/
private void fireHeaderClickedEvent(Event event) {
- if (client.hasEventListeners(VScrollTable.this,
+ if (client.hasWidgetEventListeners(VScrollTable.this,
HEADER_CLICK_EVENT_ID)) {
MouseEventDetails details = new MouseEventDetails(event);
client.updateVariable(paintableId, "headerClickEvent",
@@ -3543,7 +3343,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
* The click event
*/
private void fireFooterClickedEvent(Event event) {
- if (client.hasEventListeners(VScrollTable.this,
+ if (client.hasWidgetEventListeners(VScrollTable.this,
FOOTER_CLICK_EVENT_ID)) {
MouseEventDetails details = new MouseEventDetails(event);
client.updateVariable(paintableId, "footerClickEvent",
@@ -4295,12 +4095,12 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
final VScrollTableRow toBeRemoved = (VScrollTableRow) renderedRows
.get(index);
// Unregister row tooltip
- client.registerTooltip(VScrollTable.this, toBeRemoved.getElement(),
- null);
+ client.registerWidgetTooltip(VScrollTable.this,
+ toBeRemoved.getElement(), null);
for (int i = 0; i < toBeRemoved.getElement().getChildCount(); i++) {
// Unregister cell tooltips
Element td = toBeRemoved.getElement().getChild(i).cast();
- client.registerTooltip(VScrollTable.this, td, null);
+ client.registerWidgetTooltip(VScrollTable.this, td, null);
}
lazyUnregistryBag.add(toBeRemoved);
tBodyElement.removeChild(toBeRemoved.getElement());
@@ -4559,10 +4359,12 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
String rowDescription = uidl.getStringAttribute("rowdescr");
if (rowDescription != null && !rowDescription.equals("")) {
TooltipInfo info = new TooltipInfo(rowDescription);
- client.registerTooltip(VScrollTable.this, rowElement, info);
+ client.registerWidgetTooltip(VScrollTable.this, rowElement,
+ info);
} else {
// Remove possibly previously set tooltip
- client.registerTooltip(VScrollTable.this, rowElement, null);
+ client.registerWidgetTooltip(VScrollTable.this, rowElement,
+ null);
}
tHead.getColumnAlignments();
@@ -4797,10 +4599,10 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
if (description != null && !description.equals("")) {
TooltipInfo info = new TooltipInfo(description);
- client.registerTooltip(VScrollTable.this, td, info);
+ client.registerWidgetTooltip(VScrollTable.this, td, info);
} else {
// Remove possibly previously set tooltip
- client.registerTooltip(VScrollTable.this, td, null);
+ client.registerWidgetTooltip(VScrollTable.this, td, null);
}
td.appendChild(container);
@@ -4879,7 +4681,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
*/
private boolean handleClickEvent(Event event, Element targetTdOrTr,
boolean immediate) {
- if (!client.hasEventListeners(VScrollTable.this,
+ if (!client.hasWidgetEventListeners(VScrollTable.this,
ITEM_CLICK_EVENT_ID)) {
// Don't send an event if nobody is listening
return false;
@@ -4923,22 +4725,24 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
if (!containsWidget) {
// Only text nodes has tooltips
- if (client.getTooltipTitleInfo(VScrollTable.this,
- target) != null) {
+ if (VPaintableMap.get(client).getWidgetTooltipInfo(
+ VScrollTable.this, target) != null) {
// Cell has description, use it
- client.handleTooltipEvent(event, VScrollTable.this,
- target);
+ client.handleWidgetTooltipEvent(event,
+ VScrollTable.this, target);
} else {
// Cell might have row description, use row
// description
- client.handleTooltipEvent(event, VScrollTable.this,
+ client.handleWidgetTooltipEvent(event,
+ VScrollTable.this,
target.getParentElement());
}
}
} else {
// Table row (tr)
- client.handleTooltipEvent(event, VScrollTable.this, target);
+ client.handleWidgetTooltipEvent(event, VScrollTable.this,
+ target);
}
}
@@ -4954,7 +4758,8 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
showContextMenu(event);
if (enabled
&& (actionKeys != null || client
- .hasEventListeners(VScrollTable.this,
+ .hasWidgetEventListeners(
+ VScrollTable.this,
ITEM_CLICK_EVENT_ID))) {
/*
* Prevent browser context menu only if there are
@@ -5243,7 +5048,8 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
Element targetTdOrTr) {
mDown = true;
VTransferable transferable = new VTransferable();
- transferable.setDragSource(VScrollTable.this);
+ transferable.setDragSource(VPaintableMap.get(client)
+ .getPaintable(VScrollTable.this));
transferable.setData("itemId", "" + rowKey);
NodeList<TableCellElement> cells = rowElement.getCells();
for (int i = 0; i < cells.getLength(); i++) {
@@ -5972,9 +5778,9 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
private int contentAreaBorderHeight = -1;
private int scrollLeft;
private int scrollTop;
- private VScrollTableDropHandler dropHandler;
+ VScrollTableDropHandler dropHandler;
private boolean navKeyDown;
- private boolean multiselectPending;
+ boolean multiselectPending;
/**
* @return border top + border bottom of the scrollable area of table
@@ -6066,7 +5872,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) {
@@ -6315,7 +6129,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
@Override
public VPaintableWidget getPaintable() {
- return VScrollTable.this;
+ return VPaintableMap.get(client).getPaintable(VScrollTable.this);
}
public ApplicationConnection getApplicationConnection() {
@@ -6752,7 +6566,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
* actions may need focus.
*
*/
- private void setProperTabIndex() {
+ void setProperTabIndex() {
int storedScrollTop = 0;
int storedScrollLeft = 0;
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VScrollTablePaintable.java b/src/com/vaadin/terminal/gwt/client/ui/VScrollTablePaintable.java
new file mode 100644
index 0000000000..fa7cc3d4ec
--- /dev/null
+++ b/src/com/vaadin/terminal/gwt/client/ui/VScrollTablePaintable.java
@@ -0,0 +1,254 @@
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+package com.vaadin.terminal.gwt.client.ui;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.core.client.Scheduler;
+import com.google.gwt.dom.client.Style.Position;
+import com.google.gwt.user.client.Command;
+import com.google.gwt.user.client.ui.Widget;
+import com.vaadin.terminal.gwt.client.ApplicationConnection;
+import com.vaadin.terminal.gwt.client.BrowserInfo;
+import com.vaadin.terminal.gwt.client.UIDL;
+import com.vaadin.terminal.gwt.client.Util;
+
+public class VScrollTablePaintable extends VAbstractPaintableWidget {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * com.vaadin.terminal.gwt.client.Paintable#updateFromUIDL(com.vaadin.terminal
+ * .gwt.client.UIDL, com.vaadin.terminal.gwt.client.ApplicationConnection)
+ */
+ public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
+ getWidgetForPaintable().rendering = true;
+
+ if (uidl.hasAttribute(VScrollTable.ATTRIBUTE_PAGEBUFFER_FIRST)) {
+ getWidgetForPaintable().serverCacheFirst = uidl
+ .getIntAttribute(VScrollTable.ATTRIBUTE_PAGEBUFFER_FIRST);
+ getWidgetForPaintable().serverCacheLast = uidl
+ .getIntAttribute(VScrollTable.ATTRIBUTE_PAGEBUFFER_LAST);
+ } else {
+ getWidgetForPaintable().serverCacheFirst = -1;
+ getWidgetForPaintable().serverCacheLast = -1;
+ }
+ /*
+ * We need to do this before updateComponent since updateComponent calls
+ * this.setHeight() which will calculate a new body height depending on
+ * the space available.
+ */
+ if (uidl.hasAttribute("colfooters")) {
+ getWidgetForPaintable().showColFooters = uidl
+ .getBooleanAttribute("colfooters");
+ }
+
+ getWidgetForPaintable().tFoot
+ .setVisible(getWidgetForPaintable().showColFooters);
+
+ if (client.updateComponent(this, uidl, true)) {
+ getWidgetForPaintable().rendering = false;
+ return;
+ }
+
+ getWidgetForPaintable().enabled = !uidl.hasAttribute("disabled");
+
+ if (BrowserInfo.get().isIE8() && !getWidgetForPaintable().enabled) {
+ /*
+ * The disabled shim will not cover the table body if it is relative
+ * in IE8. See #7324
+ */
+ getWidgetForPaintable().scrollBodyPanel.getElement().getStyle()
+ .setPosition(Position.STATIC);
+ } else if (BrowserInfo.get().isIE8()) {
+ getWidgetForPaintable().scrollBodyPanel.getElement().getStyle()
+ .setPosition(Position.RELATIVE);
+ }
+
+ getWidgetForPaintable().client = client;
+ getWidgetForPaintable().paintableId = uidl.getStringAttribute("id");
+ getWidgetForPaintable().immediate = uidl
+ .getBooleanAttribute("immediate");
+
+ int previousTotalRows = getWidgetForPaintable().totalRows;
+ getWidgetForPaintable().updateTotalRows(uidl);
+ boolean totalRowsChanged = (getWidgetForPaintable().totalRows != previousTotalRows);
+
+ getWidgetForPaintable().updateDragMode(uidl);
+
+ getWidgetForPaintable().updateSelectionProperties(uidl);
+
+ if (uidl.hasAttribute("alb")) {
+ getWidgetForPaintable().bodyActionKeys = uidl
+ .getStringArrayAttribute("alb");
+ } else {
+ // Need to clear the actions if the action handlers have been
+ // removed
+ getWidgetForPaintable().bodyActionKeys = null;
+ }
+
+ getWidgetForPaintable().setCacheRateFromUIDL(uidl);
+
+ getWidgetForPaintable().recalcWidths = uidl
+ .hasAttribute("recalcWidths");
+ if (getWidgetForPaintable().recalcWidths) {
+ getWidgetForPaintable().tHead.clear();
+ getWidgetForPaintable().tFoot.clear();
+ }
+
+ getWidgetForPaintable().updatePageLength(uidl);
+
+ getWidgetForPaintable().updateFirstVisibleAndScrollIfNeeded(uidl);
+
+ getWidgetForPaintable().showRowHeaders = uidl
+ .getBooleanAttribute("rowheaders");
+ getWidgetForPaintable().showColHeaders = uidl
+ .getBooleanAttribute("colheaders");
+
+ getWidgetForPaintable().updateSortingProperties(uidl);
+
+ boolean keyboardSelectionOverRowFetchInProgress = getWidgetForPaintable()
+ .selectSelectedRows(uidl);
+
+ getWidgetForPaintable().updateActionMap(uidl);
+
+ getWidgetForPaintable().updateColumnProperties(uidl);
+
+ UIDL ac = uidl.getChildByTagName("-ac");
+ if (ac == null) {
+ if (getWidgetForPaintable().dropHandler != null) {
+ // remove dropHandler if not present anymore
+ getWidgetForPaintable().dropHandler = null;
+ }
+ } else {
+ if (getWidgetForPaintable().dropHandler == null) {
+ getWidgetForPaintable().dropHandler = getWidgetForPaintable().new VScrollTableDropHandler();
+ }
+ getWidgetForPaintable().dropHandler.updateAcceptRules(ac);
+ }
+
+ UIDL partialRowAdditions = uidl.getChildByTagName("prows");
+ UIDL partialRowUpdates = uidl.getChildByTagName("urows");
+ if (partialRowUpdates != null || partialRowAdditions != null) {
+ // we may have pending cache row fetch, cancel it. See #2136
+ getWidgetForPaintable().rowRequestHandler.cancel();
+
+ getWidgetForPaintable().updateRowsInBody(partialRowUpdates);
+ getWidgetForPaintable().addAndRemoveRows(partialRowAdditions);
+ } else {
+ UIDL rowData = uidl.getChildByTagName("rows");
+ if (rowData != null) {
+ // we may have pending cache row fetch, cancel it. See #2136
+ getWidgetForPaintable().rowRequestHandler.cancel();
+
+ if (!getWidgetForPaintable().recalcWidths
+ && getWidgetForPaintable().initializedAndAttached) {
+ getWidgetForPaintable().updateBody(rowData,
+ uidl.getIntAttribute("firstrow"),
+ uidl.getIntAttribute("rows"));
+ if (getWidgetForPaintable().headerChangedDuringUpdate) {
+ getWidgetForPaintable().triggerLazyColumnAdjustment(
+ true);
+ } else if (!getWidgetForPaintable()
+ .isScrollPositionVisible()
+ || totalRowsChanged
+ || getWidgetForPaintable().lastRenderedHeight != getWidgetForPaintable().scrollBody
+ .getOffsetHeight()) {
+ // webkits may still bug with their disturbing scrollbar
+ // bug, see #3457
+ // Run overflow fix for the scrollable area
+ // #6698 - If there's a scroll going on, don't abort it
+ // by changing overflows as the length of the contents
+ // *shouldn't* have changed (unless the number of rows
+ // or the height of the widget has also changed)
+ Scheduler.get().scheduleDeferred(new Command() {
+ public void execute() {
+ Util.runWebkitOverflowAutoFix(getWidgetForPaintable().scrollBodyPanel
+ .getElement());
+ }
+ });
+ }
+ } else {
+ getWidgetForPaintable().initializeRows(uidl, rowData);
+ }
+ }
+ }
+
+ if (!getWidgetForPaintable().isSelectable()) {
+ getWidgetForPaintable().scrollBody
+ .addStyleName(VScrollTable.CLASSNAME + "-body-noselection");
+ } else {
+ getWidgetForPaintable().scrollBody
+ .removeStyleName(VScrollTable.CLASSNAME
+ + "-body-noselection");
+ }
+
+ getWidgetForPaintable().hideScrollPositionAnnotation();
+ getWidgetForPaintable().purgeUnregistryBag();
+
+ // selection is no in sync with server, avoid excessive server visits by
+ // clearing to flag used during the normal operation
+ if (!keyboardSelectionOverRowFetchInProgress) {
+ getWidgetForPaintable().selectionChanged = false;
+ }
+
+ /*
+ * This is called when the Home or page up button has been pressed in
+ * selectable mode and the next selected row was not yet rendered in the
+ * client
+ */
+ if (getWidgetForPaintable().selectFirstItemInNextRender
+ || getWidgetForPaintable().focusFirstItemInNextRender) {
+ getWidgetForPaintable().selectFirstRenderedRowInViewPort(
+ getWidgetForPaintable().focusFirstItemInNextRender);
+ getWidgetForPaintable().selectFirstItemInNextRender = getWidgetForPaintable().focusFirstItemInNextRender = false;
+ }
+
+ /*
+ * This is called when the page down or end button has been pressed in
+ * selectable mode and the next selected row was not yet rendered in the
+ * client
+ */
+ if (getWidgetForPaintable().selectLastItemInNextRender
+ || getWidgetForPaintable().focusLastItemInNextRender) {
+ getWidgetForPaintable().selectLastRenderedRowInViewPort(
+ getWidgetForPaintable().focusLastItemInNextRender);
+ getWidgetForPaintable().selectLastItemInNextRender = getWidgetForPaintable().focusLastItemInNextRender = false;
+ }
+ getWidgetForPaintable().multiselectPending = false;
+
+ if (getWidgetForPaintable().focusedRow != null) {
+ if (!getWidgetForPaintable().focusedRow.isAttached()
+ && !getWidgetForPaintable().rowRequestHandler.isRunning()) {
+ // focused row has been orphaned, can't focus
+ getWidgetForPaintable().focusRowFromBody();
+ }
+ }
+
+ getWidgetForPaintable().tabIndex = uidl.hasAttribute("tabindex") ? uidl
+ .getIntAttribute("tabindex") : 0;
+ getWidgetForPaintable().setProperTabIndex();
+
+ getWidgetForPaintable().resizeSortedColumnForSortIndicator();
+
+ // Remember this to detect situations where overflow hack might be
+ // needed during scrolling
+ getWidgetForPaintable().lastRenderedHeight = getWidgetForPaintable().scrollBody
+ .getOffsetHeight();
+
+ getWidgetForPaintable().rendering = false;
+ getWidgetForPaintable().headerChangedDuringUpdate = false;
+
+ }
+
+ @Override
+ protected Widget createWidget() {
+ return GWT.create(VScrollTable.class);
+ }
+
+ @Override
+ public VScrollTable getWidgetForPaintable() {
+ return (VScrollTable) super.getWidgetForPaintable();
+ }
+}
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VSlider.java b/src/com/vaadin/terminal/gwt/client/ui/VSlider.java
index 6b55fa0802..3632e90956 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VSlider.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VSlider.java
@@ -1,573 +1,569 @@
-/*
-@VaadinApache2LicenseForJavaFiles@
- */
-//
-package com.vaadin.terminal.gwt.client.ui;
-
-import com.google.gwt.core.client.Scheduler;
-import com.google.gwt.core.client.Scheduler.ScheduledCommand;
-import com.google.gwt.event.dom.client.KeyCodes;
-import com.google.gwt.user.client.Command;
-import com.google.gwt.user.client.DOM;
-import com.google.gwt.user.client.Element;
-import com.google.gwt.user.client.Event;
-import com.google.gwt.user.client.Window;
-import com.google.gwt.user.client.ui.HTML;
-import com.google.gwt.user.client.ui.Widget;
-import com.vaadin.terminal.gwt.client.ApplicationConnection;
-import com.vaadin.terminal.gwt.client.BrowserInfo;
-import com.vaadin.terminal.gwt.client.ContainerResizedListener;
-import com.vaadin.terminal.gwt.client.VPaintableWidget;
-import com.vaadin.terminal.gwt.client.UIDL;
-import com.vaadin.terminal.gwt.client.Util;
-import com.vaadin.terminal.gwt.client.VConsole;
-
-public class VSlider extends SimpleFocusablePanel implements VPaintableWidget,
- Field, ContainerResizedListener {
-
- public static final String CLASSNAME = "v-slider";
-
- /**
- * Minimum size (width or height, depending on orientation) of the slider
- * base.
- */
- private static final int MIN_SIZE = 50;
-
- ApplicationConnection client;
-
- String id;
-
- private boolean immediate;
- private boolean disabled;
- private boolean readonly;
-
- private int acceleration = 1;
- private double min;
- private double max;
- private int resolution;
- private Double value;
- private boolean vertical;
-
- private final HTML feedback = new HTML("", false);
- private final VOverlay feedbackPopup = new VOverlay(true, false, true) {
- @Override
- public void show() {
- super.show();
- updateFeedbackPosition();
- }
- };
-
- /* DOM element for slider's base */
- private final Element base;
- private final int BASE_BORDER_WIDTH = 1;
-
- /* DOM element for slider's handle */
- private final Element handle;
-
- /* DOM element for decrement arrow */
- private final Element smaller;
-
- /* DOM element for increment arrow */
- private final Element bigger;
-
- /* Temporary dragging/animation variables */
- private boolean dragging = false;
-
- private VLazyExecutor delayedValueUpdater = new VLazyExecutor(100,
- new ScheduledCommand() {
-
- public void execute() {
- updateValueToServer();
- acceleration = 1;
- }
- });
-
- public VSlider() {
- super();
-
- base = DOM.createDiv();
- handle = DOM.createDiv();
- smaller = DOM.createDiv();
- bigger = DOM.createDiv();
-
- setStyleName(CLASSNAME);
- DOM.setElementProperty(base, "className", CLASSNAME + "-base");
- DOM.setElementProperty(handle, "className", CLASSNAME + "-handle");
- DOM.setElementProperty(smaller, "className", CLASSNAME + "-smaller");
- DOM.setElementProperty(bigger, "className", CLASSNAME + "-bigger");
-
- DOM.appendChild(getElement(), bigger);
- DOM.appendChild(getElement(), smaller);
- DOM.appendChild(getElement(), base);
- DOM.appendChild(base, handle);
-
- // Hide initially
- DOM.setStyleAttribute(smaller, "display", "none");
- DOM.setStyleAttribute(bigger, "display", "none");
- DOM.setStyleAttribute(handle, "visibility", "hidden");
-
- sinkEvents(Event.MOUSEEVENTS | Event.ONMOUSEWHEEL | Event.KEYEVENTS
- | Event.FOCUSEVENTS | Event.TOUCHEVENTS);
-
- feedbackPopup.addStyleName(CLASSNAME + "-feedback");
- feedbackPopup.setWidget(feedback);
- }
-
- public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
-
- this.client = client;
- id = uidl.getId();
-
- // Ensure correct implementation
- if (client.updateComponent(this, uidl, true)) {
- return;
- }
-
- immediate = uidl.getBooleanAttribute("immediate");
- disabled = uidl.getBooleanAttribute("disabled");
- readonly = uidl.getBooleanAttribute("readonly");
-
- vertical = uidl.hasAttribute("vertical");
-
- String style = "";
- if (uidl.hasAttribute("style")) {
- style = uidl.getStringAttribute("style");
- }
-
- if (vertical) {
- addStyleName(CLASSNAME + "-vertical");
- } else {
- removeStyleName(CLASSNAME + "-vertical");
- }
-
- min = uidl.getDoubleAttribute("min");
- max = uidl.getDoubleAttribute("max");
- resolution = uidl.getIntAttribute("resolution");
- value = new Double(uidl.getDoubleVariable("value"));
-
- setFeedbackValue(value);
-
- buildBase();
-
- if (!vertical) {
- // Draw handle with a delay to allow base to gain maximum width
- Scheduler.get().scheduleDeferred(new Command() {
- public void execute() {
- buildHandle();
- setValue(value, false);
- }
- });
- } else {
- buildHandle();
- setValue(value, false);
- }
- }
-
- private void setFeedbackValue(double value) {
- String currentValue = "" + value;
- if (resolution == 0) {
- currentValue = "" + new Double(value).intValue();
- }
- feedback.setText(currentValue);
- }
-
- private void updateFeedbackPosition() {
- if (vertical) {
- feedbackPopup.setPopupPosition(
- DOM.getAbsoluteLeft(handle) + handle.getOffsetWidth(),
- DOM.getAbsoluteTop(handle) + handle.getOffsetHeight() / 2
- - feedbackPopup.getOffsetHeight() / 2);
- } else {
- feedbackPopup.setPopupPosition(
- DOM.getAbsoluteLeft(handle) + handle.getOffsetWidth() / 2
- - feedbackPopup.getOffsetWidth() / 2,
- DOM.getAbsoluteTop(handle)
- - feedbackPopup.getOffsetHeight());
- }
- }
-
- private void buildBase() {
- final String styleAttribute = vertical ? "height" : "width";
- final String domProperty = vertical ? "offsetHeight" : "offsetWidth";
-
- final Element p = DOM.getParent(getElement());
- if (DOM.getElementPropertyInt(p, domProperty) > 50) {
- if (vertical) {
- setHeight();
- } else {
- DOM.setStyleAttribute(base, styleAttribute, "");
- }
- } else {
- // Set minimum size and adjust after all components have
- // (supposedly) been drawn completely.
- DOM.setStyleAttribute(base, styleAttribute, MIN_SIZE + "px");
- Scheduler.get().scheduleDeferred(new Command() {
- public void execute() {
- final Element p = DOM.getParent(getElement());
- if (DOM.getElementPropertyInt(p, domProperty) > (MIN_SIZE + 5)) {
- if (vertical) {
- setHeight();
- } else {
- DOM.setStyleAttribute(base, styleAttribute, "");
- }
- // Ensure correct position
- setValue(value, false);
- }
- }
- });
- }
-
- // TODO attach listeners for focusing and arrow keys
- }
-
- private void buildHandle() {
- final String handleAttribute = vertical ? "marginTop" : "marginLeft";
-
- DOM.setStyleAttribute(handle, handleAttribute, "0");
-
- // Restore visibility
- DOM.setStyleAttribute(handle, "visibility", "visible");
-
- }
-
- private void setValue(Double value, boolean updateToServer) {
- if (value == null) {
- return;
- }
-
- if (value < min) {
- value = min;
- } else if (value > max) {
- value = max;
- }
-
- // Update handle position
- final String styleAttribute = vertical ? "marginTop" : "marginLeft";
- final String domProperty = vertical ? "offsetHeight" : "offsetWidth";
- final int handleSize = Integer.parseInt(DOM.getElementProperty(handle,
- domProperty));
- final int baseSize = Integer.parseInt(DOM.getElementProperty(base,
- domProperty)) - (2 * BASE_BORDER_WIDTH);
-
- final int range = baseSize - handleSize;
- double v = value.doubleValue();
-
- // Round value to resolution
- if (resolution > 0) {
- v = Math.round(v * Math.pow(10, resolution));
- v = v / Math.pow(10, resolution);
- } else {
- v = Math.round(v);
- }
- final double valueRange = max - min;
- double p = 0;
- if (valueRange > 0) {
- p = range * ((v - min) / valueRange);
- }
- if (p < 0) {
- p = 0;
- }
- if (vertical) {
- p = range - p;
- }
- final double pos = p;
-
- DOM.setStyleAttribute(handle, styleAttribute, (Math.round(pos)) + "px");
-
- // Update value
- this.value = new Double(v);
- setFeedbackValue(v);
-
- if (updateToServer) {
- updateValueToServer();
- }
- }
-
- @Override
- public void onBrowserEvent(Event event) {
- if (disabled || readonly) {
- return;
- }
- final Element targ = DOM.eventGetTarget(event);
-
- if (DOM.eventGetType(event) == Event.ONMOUSEWHEEL) {
- processMouseWheelEvent(event);
- } else if (dragging || targ == handle) {
- processHandleEvent(event);
- } else if (targ == smaller) {
- decreaseValue(true);
- } else if (targ == bigger) {
- increaseValue(true);
- } else if (DOM.eventGetType(event) == Event.MOUSEEVENTS) {
- processBaseEvent(event);
- } else if ((BrowserInfo.get().isGecko() && DOM.eventGetType(event) == Event.ONKEYPRESS)
- || (!BrowserInfo.get().isGecko() && DOM.eventGetType(event) == Event.ONKEYDOWN)) {
-
- if (handleNavigation(event.getKeyCode(), event.getCtrlKey(),
- event.getShiftKey())) {
-
- feedbackPopup.show();
-
- delayedValueUpdater.trigger();
-
- DOM.eventPreventDefault(event);
- DOM.eventCancelBubble(event, true);
- }
- } else if (targ.equals(getElement())
- && DOM.eventGetType(event) == Event.ONFOCUS) {
- feedbackPopup.show();
- } else if (targ.equals(getElement())
- && DOM.eventGetType(event) == Event.ONBLUR) {
- feedbackPopup.hide();
- } else if (DOM.eventGetType(event) == Event.ONMOUSEDOWN) {
- feedbackPopup.show();
- }
- if (Util.isTouchEvent(event)) {
- event.preventDefault(); // avoid simulated events
- event.stopPropagation();
- }
- }
-
- private void processMouseWheelEvent(final Event event) {
- final int dir = DOM.eventGetMouseWheelVelocityY(event);
-
- if (dir < 0) {
- increaseValue(false);
- } else {
- decreaseValue(false);
- }
-
- delayedValueUpdater.trigger();
-
- DOM.eventPreventDefault(event);
- DOM.eventCancelBubble(event, true);
- }
-
- private void processHandleEvent(Event event) {
- switch (DOM.eventGetType(event)) {
- case Event.ONMOUSEDOWN:
- case Event.ONTOUCHSTART:
- if (!disabled && !readonly) {
- focus();
- feedbackPopup.show();
- dragging = true;
- DOM.setElementProperty(handle, "className", CLASSNAME
- + "-handle " + CLASSNAME + "-handle-active");
- DOM.setCapture(getElement());
- DOM.eventPreventDefault(event); // prevent selecting text
- DOM.eventCancelBubble(event, true);
- event.stopPropagation();
- VConsole.log("Slider move start");
- }
- break;
- case Event.ONMOUSEMOVE:
- case Event.ONTOUCHMOVE:
- if (dragging) {
- VConsole.log("Slider move");
- setValueByEvent(event, false);
- updateFeedbackPosition();
- event.stopPropagation();
- }
- break;
- case Event.ONTOUCHEND:
- feedbackPopup.hide();
- case Event.ONMOUSEUP:
- // feedbackPopup.hide();
- VConsole.log("Slider move end");
- dragging = false;
- DOM.setElementProperty(handle, "className", CLASSNAME + "-handle");
- DOM.releaseCapture(getElement());
- setValueByEvent(event, true);
- event.stopPropagation();
- break;
- default:
- break;
- }
- }
-
- private void processBaseEvent(Event event) {
- if (DOM.eventGetType(event) == Event.ONMOUSEDOWN) {
- if (!disabled && !readonly && !dragging) {
- setValueByEvent(event, true);
- DOM.eventCancelBubble(event, true);
- }
- } else if (DOM.eventGetType(event) == Event.ONMOUSEDOWN && dragging) {
- dragging = false;
- DOM.releaseCapture(getElement());
- setValueByEvent(event, true);
- }
- }
-
- private void decreaseValue(boolean updateToServer) {
- setValue(new Double(value.doubleValue() - Math.pow(10, -resolution)),
- updateToServer);
- }
-
- private void increaseValue(boolean updateToServer) {
- setValue(new Double(value.doubleValue() + Math.pow(10, -resolution)),
- updateToServer);
- }
-
- private void setValueByEvent(Event event, boolean updateToServer) {
- double v = min; // Fallback to min
-
- final int coord = getEventPosition(event);
-
- final int handleSize, baseSize, baseOffset;
- if (vertical) {
- handleSize = handle.getOffsetHeight();
- baseSize = base.getOffsetHeight();
- baseOffset = base.getAbsoluteTop() - Window.getScrollTop()
- - handleSize / 2;
- } else {
- handleSize = handle.getOffsetWidth();
- baseSize = base.getOffsetWidth();
- baseOffset = base.getAbsoluteLeft() - Window.getScrollLeft()
- + handleSize / 2;
- }
-
- if (vertical) {
- v = ((baseSize - (coord - baseOffset)) / (double) (baseSize - handleSize))
- * (max - min) + min;
- } else {
- v = ((coord - baseOffset) / (double) (baseSize - handleSize))
- * (max - min) + min;
- }
-
- if (v < min) {
- v = min;
- } else if (v > max) {
- v = max;
- }
-
- setValue(v, updateToServer);
- }
-
- /**
- * TODO consider extracting touches support to an impl class specific for
- * webkit (only browser that really supports touches).
- *
- * @param event
- * @return
- */
- protected int getEventPosition(Event event) {
- if (vertical) {
- return Util.getTouchOrMouseClientY(event);
- } else {
- return Util.getTouchOrMouseClientX(event);
- }
- }
-
- public void iLayout() {
- if (vertical) {
- setHeight();
- }
- // Update handle position
- setValue(value, false);
- }
-
- private void setHeight() {
- // Calculate decoration size
- DOM.setStyleAttribute(base, "height", "0");
- DOM.setStyleAttribute(base, "overflow", "hidden");
- int h = DOM.getElementPropertyInt(getElement(), "offsetHeight");
- if (h < MIN_SIZE) {
- h = MIN_SIZE;
- }
- DOM.setStyleAttribute(base, "height", h + "px");
- DOM.setStyleAttribute(base, "overflow", "");
- }
-
- private void updateValueToServer() {
- client.updateVariable(id, "value", value.doubleValue(), immediate);
- }
-
- /**
- * Handles the keyboard events handled by the Slider
- *
- * @param event
- * The keyboard event received
- * @return true iff the navigation event was handled
- */
- public boolean handleNavigation(int keycode, boolean ctrl, boolean shift) {
-
- // No support for ctrl moving
- if (ctrl) {
- return false;
- }
-
- if ((keycode == getNavigationUpKey() && vertical)
- || (keycode == getNavigationRightKey() && !vertical)) {
- if (shift) {
- for (int a = 0; a < acceleration; a++) {
- increaseValue(false);
- }
- acceleration++;
- } else {
- increaseValue(false);
- }
- return true;
- } else if (keycode == getNavigationDownKey() && vertical
- || (keycode == getNavigationLeftKey() && !vertical)) {
- if (shift) {
- for (int a = 0; a < acceleration; a++) {
- decreaseValue(false);
- }
- acceleration++;
- } else {
- decreaseValue(false);
- }
- return true;
- }
-
- return false;
- }
-
- /**
- * Get the key that increases the vertical slider. By default it is the up
- * arrow key but by overriding this you can change the key to whatever you
- * want.
- *
- * @return The keycode of the key
- */
- protected int getNavigationUpKey() {
- return KeyCodes.KEY_UP;
- }
-
- /**
- * Get the key that decreases the vertical slider. By default it is the down
- * arrow key but by overriding this you can change the key to whatever you
- * want.
- *
- * @return The keycode of the key
- */
- protected int getNavigationDownKey() {
- return KeyCodes.KEY_DOWN;
- }
-
- /**
- * Get the key that decreases the horizontal slider. By default it is the
- * left arrow key but by overriding this you can change the key to whatever
- * you want.
- *
- * @return The keycode of the key
- */
- protected int getNavigationLeftKey() {
- return KeyCodes.KEY_LEFT;
- }
-
- /**
- * Get the key that increases the horizontal slider. By default it is the
- * right arrow key but by overriding this you can change the key to whatever
- * you want.
- *
- * @return The keycode of the key
- */
- protected int getNavigationRightKey() {
- return KeyCodes.KEY_RIGHT;
- }
-
- public Widget getWidgetForPaintable() {
- return this;
- }
-}
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+//
+package com.vaadin.terminal.gwt.client.ui;
+
+import com.google.gwt.core.client.Scheduler;
+import com.google.gwt.core.client.Scheduler.ScheduledCommand;
+import com.google.gwt.event.dom.client.KeyCodes;
+import com.google.gwt.user.client.Command;
+import com.google.gwt.user.client.DOM;
+import com.google.gwt.user.client.Element;
+import com.google.gwt.user.client.Event;
+import com.google.gwt.user.client.Window;
+import com.google.gwt.user.client.ui.HTML;
+import com.google.gwt.user.client.ui.Widget;
+import com.vaadin.terminal.gwt.client.ApplicationConnection;
+import com.vaadin.terminal.gwt.client.BrowserInfo;
+import com.vaadin.terminal.gwt.client.ContainerResizedListener;
+import com.vaadin.terminal.gwt.client.VPaintableWidget;
+import com.vaadin.terminal.gwt.client.UIDL;
+import com.vaadin.terminal.gwt.client.Util;
+import com.vaadin.terminal.gwt.client.VConsole;
+
+public class VSlider extends SimpleFocusablePanel implements VPaintableWidget,
+ Field, ContainerResizedListener {
+
+ public static final String CLASSNAME = "v-slider";
+
+ /**
+ * Minimum size (width or height, depending on orientation) of the slider
+ * base.
+ */
+ private static final int MIN_SIZE = 50;
+
+ ApplicationConnection client;
+
+ String id;
+
+ private boolean immediate;
+ private boolean disabled;
+ private boolean readonly;
+
+ private int acceleration = 1;
+ private double min;
+ private double max;
+ private int resolution;
+ private Double value;
+ private boolean vertical;
+
+ private final HTML feedback = new HTML("", false);
+ private final VOverlay feedbackPopup = new VOverlay(true, false, true) {
+ @Override
+ public void show() {
+ super.show();
+ updateFeedbackPosition();
+ }
+ };
+
+ /* DOM element for slider's base */
+ private final Element base;
+ private final int BASE_BORDER_WIDTH = 1;
+
+ /* DOM element for slider's handle */
+ private final Element handle;
+
+ /* DOM element for decrement arrow */
+ private final Element smaller;
+
+ /* DOM element for increment arrow */
+ private final Element bigger;
+
+ /* Temporary dragging/animation variables */
+ private boolean dragging = false;
+
+ private VLazyExecutor delayedValueUpdater = new VLazyExecutor(100,
+ new ScheduledCommand() {
+
+ public void execute() {
+ updateValueToServer();
+ acceleration = 1;
+ }
+ });
+
+ public VSlider() {
+ super();
+
+ base = DOM.createDiv();
+ handle = DOM.createDiv();
+ smaller = DOM.createDiv();
+ bigger = DOM.createDiv();
+
+ setStyleName(CLASSNAME);
+ DOM.setElementProperty(base, "className", CLASSNAME + "-base");
+ DOM.setElementProperty(handle, "className", CLASSNAME + "-handle");
+ DOM.setElementProperty(smaller, "className", CLASSNAME + "-smaller");
+ DOM.setElementProperty(bigger, "className", CLASSNAME + "-bigger");
+
+ DOM.appendChild(getElement(), bigger);
+ DOM.appendChild(getElement(), smaller);
+ DOM.appendChild(getElement(), base);
+ DOM.appendChild(base, handle);
+
+ // Hide initially
+ DOM.setStyleAttribute(smaller, "display", "none");
+ DOM.setStyleAttribute(bigger, "display", "none");
+ DOM.setStyleAttribute(handle, "visibility", "hidden");
+
+ sinkEvents(Event.MOUSEEVENTS | Event.ONMOUSEWHEEL | Event.KEYEVENTS
+ | Event.FOCUSEVENTS | Event.TOUCHEVENTS);
+
+ feedbackPopup.addStyleName(CLASSNAME + "-feedback");
+ feedbackPopup.setWidget(feedback);
+ }
+
+ public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
+
+ this.client = client;
+ id = uidl.getId();
+
+ // Ensure correct implementation
+ if (client.updateComponent(this, uidl, true)) {
+ return;
+ }
+
+ immediate = uidl.getBooleanAttribute("immediate");
+ disabled = uidl.getBooleanAttribute("disabled");
+ readonly = uidl.getBooleanAttribute("readonly");
+
+ vertical = uidl.hasAttribute("vertical");
+
+ String style = "";
+ if (uidl.hasAttribute("style")) {
+ style = uidl.getStringAttribute("style");
+ }
+
+ if (vertical) {
+ addStyleName(CLASSNAME + "-vertical");
+ } else {
+ removeStyleName(CLASSNAME + "-vertical");
+ }
+
+ min = uidl.getDoubleAttribute("min");
+ max = uidl.getDoubleAttribute("max");
+ resolution = uidl.getIntAttribute("resolution");
+ value = new Double(uidl.getDoubleVariable("value"));
+
+ setFeedbackValue(value);
+
+ buildBase();
+
+ if (!vertical) {
+ // Draw handle with a delay to allow base to gain maximum width
+ Scheduler.get().scheduleDeferred(new Command() {
+ public void execute() {
+ buildHandle();
+ setValue(value, false);
+ }
+ });
+ } else {
+ buildHandle();
+ setValue(value, false);
+ }
+ }
+
+ private void setFeedbackValue(double value) {
+ String currentValue = "" + value;
+ if (resolution == 0) {
+ currentValue = "" + new Double(value).intValue();
+ }
+ feedback.setText(currentValue);
+ }
+
+ private void updateFeedbackPosition() {
+ if (vertical) {
+ feedbackPopup.setPopupPosition(
+ DOM.getAbsoluteLeft(handle) + handle.getOffsetWidth(),
+ DOM.getAbsoluteTop(handle) + handle.getOffsetHeight() / 2
+ - feedbackPopup.getOffsetHeight() / 2);
+ } else {
+ feedbackPopup.setPopupPosition(
+ DOM.getAbsoluteLeft(handle) + handle.getOffsetWidth() / 2
+ - feedbackPopup.getOffsetWidth() / 2,
+ DOM.getAbsoluteTop(handle)
+ - feedbackPopup.getOffsetHeight());
+ }
+ }
+
+ private void buildBase() {
+ final String styleAttribute = vertical ? "height" : "width";
+ final String domProperty = vertical ? "offsetHeight" : "offsetWidth";
+
+ final Element p = DOM.getParent(getElement());
+ if (DOM.getElementPropertyInt(p, domProperty) > 50) {
+ if (vertical) {
+ setHeight();
+ } else {
+ DOM.setStyleAttribute(base, styleAttribute, "");
+ }
+ } else {
+ // Set minimum size and adjust after all components have
+ // (supposedly) been drawn completely.
+ DOM.setStyleAttribute(base, styleAttribute, MIN_SIZE + "px");
+ Scheduler.get().scheduleDeferred(new Command() {
+ public void execute() {
+ final Element p = DOM.getParent(getElement());
+ if (DOM.getElementPropertyInt(p, domProperty) > (MIN_SIZE + 5)) {
+ if (vertical) {
+ setHeight();
+ } else {
+ DOM.setStyleAttribute(base, styleAttribute, "");
+ }
+ // Ensure correct position
+ setValue(value, false);
+ }
+ }
+ });
+ }
+
+ // TODO attach listeners for focusing and arrow keys
+ }
+
+ private void buildHandle() {
+ final String handleAttribute = vertical ? "marginTop" : "marginLeft";
+
+ DOM.setStyleAttribute(handle, handleAttribute, "0");
+
+ // Restore visibility
+ DOM.setStyleAttribute(handle, "visibility", "visible");
+
+ }
+
+ private void setValue(Double value, boolean updateToServer) {
+ if (value == null) {
+ return;
+ }
+
+ if (value < min) {
+ value = min;
+ } else if (value > max) {
+ value = max;
+ }
+
+ // Update handle position
+ final String styleAttribute = vertical ? "marginTop" : "marginLeft";
+ final String domProperty = vertical ? "offsetHeight" : "offsetWidth";
+ final int handleSize = Integer.parseInt(DOM.getElementProperty(handle,
+ domProperty));
+ final int baseSize = Integer.parseInt(DOM.getElementProperty(base,
+ domProperty)) - (2 * BASE_BORDER_WIDTH);
+
+ final int range = baseSize - handleSize;
+ double v = value.doubleValue();
+
+ // Round value to resolution
+ if (resolution > 0) {
+ v = Math.round(v * Math.pow(10, resolution));
+ v = v / Math.pow(10, resolution);
+ } else {
+ v = Math.round(v);
+ }
+ final double valueRange = max - min;
+ double p = 0;
+ if (valueRange > 0) {
+ p = range * ((v - min) / valueRange);
+ }
+ if (p < 0) {
+ p = 0;
+ }
+ if (vertical) {
+ p = range - p;
+ }
+ final double pos = p;
+
+ DOM.setStyleAttribute(handle, styleAttribute, (Math.round(pos)) + "px");
+
+ // Update value
+ this.value = new Double(v);
+ setFeedbackValue(v);
+
+ if (updateToServer) {
+ updateValueToServer();
+ }
+ }
+
+ @Override
+ public void onBrowserEvent(Event event) {
+ if (disabled || readonly) {
+ return;
+ }
+ final Element targ = DOM.eventGetTarget(event);
+
+ if (DOM.eventGetType(event) == Event.ONMOUSEWHEEL) {
+ processMouseWheelEvent(event);
+ } else if (dragging || targ == handle) {
+ processHandleEvent(event);
+ } else if (targ == smaller) {
+ decreaseValue(true);
+ } else if (targ == bigger) {
+ increaseValue(true);
+ } else if (DOM.eventGetType(event) == Event.MOUSEEVENTS) {
+ processBaseEvent(event);
+ } else if ((BrowserInfo.get().isGecko() && DOM.eventGetType(event) == Event.ONKEYPRESS)
+ || (!BrowserInfo.get().isGecko() && DOM.eventGetType(event) == Event.ONKEYDOWN)) {
+
+ if (handleNavigation(event.getKeyCode(), event.getCtrlKey(),
+ event.getShiftKey())) {
+
+ feedbackPopup.show();
+
+ delayedValueUpdater.trigger();
+
+ DOM.eventPreventDefault(event);
+ DOM.eventCancelBubble(event, true);
+ }
+ } else if (targ.equals(getElement())
+ && DOM.eventGetType(event) == Event.ONFOCUS) {
+ feedbackPopup.show();
+ } else if (targ.equals(getElement())
+ && DOM.eventGetType(event) == Event.ONBLUR) {
+ feedbackPopup.hide();
+ } else if (DOM.eventGetType(event) == Event.ONMOUSEDOWN) {
+ feedbackPopup.show();
+ }
+ if (Util.isTouchEvent(event)) {
+ event.preventDefault(); // avoid simulated events
+ event.stopPropagation();
+ }
+ }
+
+ private void processMouseWheelEvent(final Event event) {
+ final int dir = DOM.eventGetMouseWheelVelocityY(event);
+
+ if (dir < 0) {
+ increaseValue(false);
+ } else {
+ decreaseValue(false);
+ }
+
+ delayedValueUpdater.trigger();
+
+ DOM.eventPreventDefault(event);
+ DOM.eventCancelBubble(event, true);
+ }
+
+ private void processHandleEvent(Event event) {
+ switch (DOM.eventGetType(event)) {
+ case Event.ONMOUSEDOWN:
+ case Event.ONTOUCHSTART:
+ if (!disabled && !readonly) {
+ focus();
+ feedbackPopup.show();
+ dragging = true;
+ DOM.setElementProperty(handle, "className", CLASSNAME
+ + "-handle " + CLASSNAME + "-handle-active");
+ DOM.setCapture(getElement());
+ DOM.eventPreventDefault(event); // prevent selecting text
+ DOM.eventCancelBubble(event, true);
+ event.stopPropagation();
+ VConsole.log("Slider move start");
+ }
+ break;
+ case Event.ONMOUSEMOVE:
+ case Event.ONTOUCHMOVE:
+ if (dragging) {
+ VConsole.log("Slider move");
+ setValueByEvent(event, false);
+ updateFeedbackPosition();
+ event.stopPropagation();
+ }
+ break;
+ case Event.ONTOUCHEND:
+ feedbackPopup.hide();
+ case Event.ONMOUSEUP:
+ // feedbackPopup.hide();
+ VConsole.log("Slider move end");
+ dragging = false;
+ DOM.setElementProperty(handle, "className", CLASSNAME + "-handle");
+ DOM.releaseCapture(getElement());
+ setValueByEvent(event, true);
+ event.stopPropagation();
+ break;
+ default:
+ break;
+ }
+ }
+
+ private void processBaseEvent(Event event) {
+ if (DOM.eventGetType(event) == Event.ONMOUSEDOWN) {
+ if (!disabled && !readonly && !dragging) {
+ setValueByEvent(event, true);
+ DOM.eventCancelBubble(event, true);
+ }
+ }
+ }
+
+ private void decreaseValue(boolean updateToServer) {
+ setValue(new Double(value.doubleValue() - Math.pow(10, -resolution)),
+ updateToServer);
+ }
+
+ private void increaseValue(boolean updateToServer) {
+ setValue(new Double(value.doubleValue() + Math.pow(10, -resolution)),
+ updateToServer);
+ }
+
+ private void setValueByEvent(Event event, boolean updateToServer) {
+ double v = min; // Fallback to min
+
+ final int coord = getEventPosition(event);
+
+ final int handleSize, baseSize, baseOffset;
+ if (vertical) {
+ handleSize = handle.getOffsetHeight();
+ baseSize = base.getOffsetHeight();
+ baseOffset = base.getAbsoluteTop() - Window.getScrollTop()
+ - handleSize / 2;
+ } else {
+ handleSize = handle.getOffsetWidth();
+ baseSize = base.getOffsetWidth();
+ baseOffset = base.getAbsoluteLeft() - Window.getScrollLeft()
+ + handleSize / 2;
+ }
+
+ if (vertical) {
+ v = ((baseSize - (coord - baseOffset)) / (double) (baseSize - handleSize))
+ * (max - min) + min;
+ } else {
+ v = ((coord - baseOffset) / (double) (baseSize - handleSize))
+ * (max - min) + min;
+ }
+
+ if (v < min) {
+ v = min;
+ } else if (v > max) {
+ v = max;
+ }
+
+ setValue(v, updateToServer);
+ }
+
+ /**
+ * TODO consider extracting touches support to an impl class specific for
+ * webkit (only browser that really supports touches).
+ *
+ * @param event
+ * @return
+ */
+ protected int getEventPosition(Event event) {
+ if (vertical) {
+ return Util.getTouchOrMouseClientY(event);
+ } else {
+ return Util.getTouchOrMouseClientX(event);
+ }
+ }
+
+ public void iLayout() {
+ if (vertical) {
+ setHeight();
+ }
+ // Update handle position
+ setValue(value, false);
+ }
+
+ private void setHeight() {
+ // Calculate decoration size
+ DOM.setStyleAttribute(base, "height", "0");
+ DOM.setStyleAttribute(base, "overflow", "hidden");
+ int h = DOM.getElementPropertyInt(getElement(), "offsetHeight");
+ if (h < MIN_SIZE) {
+ h = MIN_SIZE;
+ }
+ DOM.setStyleAttribute(base, "height", h + "px");
+ DOM.setStyleAttribute(base, "overflow", "");
+ }
+
+ private void updateValueToServer() {
+ client.updateVariable(id, "value", value.doubleValue(), immediate);
+ }
+
+ /**
+ * Handles the keyboard events handled by the Slider
+ *
+ * @param event
+ * The keyboard event received
+ * @return true iff the navigation event was handled
+ */
+ public boolean handleNavigation(int keycode, boolean ctrl, boolean shift) {
+
+ // No support for ctrl moving
+ if (ctrl) {
+ return false;
+ }
+
+ if ((keycode == getNavigationUpKey() && vertical)
+ || (keycode == getNavigationRightKey() && !vertical)) {
+ if (shift) {
+ for (int a = 0; a < acceleration; a++) {
+ increaseValue(false);
+ }
+ acceleration++;
+ } else {
+ increaseValue(false);
+ }
+ return true;
+ } else if (keycode == getNavigationDownKey() && vertical
+ || (keycode == getNavigationLeftKey() && !vertical)) {
+ if (shift) {
+ for (int a = 0; a < acceleration; a++) {
+ decreaseValue(false);
+ }
+ acceleration++;
+ } else {
+ decreaseValue(false);
+ }
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Get the key that increases the vertical slider. By default it is the up
+ * arrow key but by overriding this you can change the key to whatever you
+ * want.
+ *
+ * @return The keycode of the key
+ */
+ protected int getNavigationUpKey() {
+ return KeyCodes.KEY_UP;
+ }
+
+ /**
+ * Get the key that decreases the vertical slider. By default it is the down
+ * arrow key but by overriding this you can change the key to whatever you
+ * want.
+ *
+ * @return The keycode of the key
+ */
+ protected int getNavigationDownKey() {
+ return KeyCodes.KEY_DOWN;
+ }
+
+ /**
+ * Get the key that decreases the horizontal slider. By default it is the
+ * left arrow key but by overriding this you can change the key to whatever
+ * you want.
+ *
+ * @return The keycode of the key
+ */
+ protected int getNavigationLeftKey() {
+ return KeyCodes.KEY_LEFT;
+ }
+
+ /**
+ * Get the key that increases the horizontal slider. By default it is the
+ * right arrow key but by overriding this you can change the key to whatever
+ * you want.
+ *
+ * @return The keycode of the key
+ */
+ protected int getNavigationRightKey() {
+ return KeyCodes.KEY_RIGHT;
+ }
+
+ public Widget getWidgetForPaintable() {
+ return this;
+ }
+}
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VTabsheet.java b/src/com/vaadin/terminal/gwt/client/ui/VTabsheet.java
index 32a9cf3e11..74ff328710 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VTabsheet.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VTabsheet.java
@@ -54,7 +54,7 @@ public class VTabsheet extends VTabsheetBase {
/**
* Representation of a single "tab" shown in the TabBar
- *
+ *
*/
private static class Tab extends SimplePanel {
private static final String TD_CLASSNAME = CLASSNAME + "-tabitemcell";
@@ -64,6 +64,8 @@ public class VTabsheet extends VTabsheetBase {
+ "-selected";
private static final String TD_SELECTED_FIRST_CLASSNAME = TD_SELECTED_CLASSNAME
+ "-first";
+ private static final String TD_DISABLED_CLASSNAME = TD_CLASSNAME
+ + "-disabled";
private static final String DIV_CLASSNAME = CLASSNAME + "-tabitem";
private static final String DIV_SELECTED_CLASSNAME = DIV_CLASSNAME
@@ -116,6 +118,7 @@ public class VTabsheet extends VTabsheetBase {
public void setEnabledOnServer(boolean enabled) {
enabledOnServer = enabled;
+ setStyleName(td, TD_DISABLED_CLASSNAME, !enabled);
}
public void addClickHandler(ClickHandler handler) {
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/VTextField.java b/src/com/vaadin/terminal/gwt/client/ui/VTextField.java
index 26c7430e74..80dad78e58 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VTextField.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VTextField.java
@@ -90,12 +90,6 @@ public class VTextField extends TextBoxBase implements VPaintableWidget, Field,
protected VTextField(Element node) {
super(node);
- if (BrowserInfo.get().getIEVersion() > 0
- && BrowserInfo.get().getIEVersion() < 8) {
- // Fixes IE margin problem (#2058)
- DOM.setStyleAttribute(node, "marginTop", "-1px");
- DOM.setStyleAttribute(node, "marginBottom", "-1px");
- }
setStyleName(CLASSNAME);
addChangeHandler(this);
if (BrowserInfo.get().isIE()) {
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VTextualDate.java b/src/com/vaadin/terminal/gwt/client/ui/VTextualDate.java
index ed4953d463..a522c79736 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VTextualDate.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VTextualDate.java
@@ -20,12 +20,12 @@ import com.vaadin.terminal.gwt.client.EventId;
import com.vaadin.terminal.gwt.client.Focusable;
import com.vaadin.terminal.gwt.client.LocaleNotLoadedException;
import com.vaadin.terminal.gwt.client.LocaleService;
-import com.vaadin.terminal.gwt.client.VPaintableWidget;
import com.vaadin.terminal.gwt.client.UIDL;
import com.vaadin.terminal.gwt.client.VConsole;
+import com.vaadin.terminal.gwt.client.VPaintableWidget;
-public class VTextualDate extends VDateField implements VPaintableWidget, Field,
- ChangeHandler, ContainerResizedListener, Focusable, SubPartAware {
+public class VTextualDate extends VDateField implements VPaintableWidget,
+ Field, ChangeHandler, ContainerResizedListener, Focusable, SubPartAware {
private static final String PARSE_ERROR_CLASSNAME = CLASSNAME
+ "-parseerror";
@@ -331,7 +331,8 @@ public class VTextualDate extends VDateField implements VPaintableWidget, Field,
@Override
public void setWidth(String newWidth) {
- if (!"".equals(newWidth) && (width == null || !newWidth.equals(width))) {
+ if (!"".equals(newWidth)
+ && (isUndefinedWidth() || !newWidth.equals(width))) {
needLayout = true;
width = newWidth;
super.setWidth(width);
@@ -340,16 +341,18 @@ public class VTextualDate extends VDateField implements VPaintableWidget, Field,
needLayout = false;
}
} else {
- if ("".equals(newWidth) && width != null && !"".equals(width)) {
+ if ("".equals(newWidth) && !isUndefinedWidth()) {
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.
*
@@ -363,14 +366,26 @@ public class VTextualDate extends VDateField implements VPaintableWidget, 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() {
+ 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/src/com/vaadin/terminal/gwt/client/ui/VTreeTable.java b/src/com/vaadin/terminal/gwt/client/ui/VTreeTable.java
index 77dd1cc39e..0eddca0ed3 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VTreeTable.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VTreeTable.java
@@ -24,21 +24,19 @@ import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.Widget;
-import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.BrowserInfo;
import com.vaadin.terminal.gwt.client.ComputedStyle;
import com.vaadin.terminal.gwt.client.RenderSpace;
import com.vaadin.terminal.gwt.client.UIDL;
import com.vaadin.terminal.gwt.client.Util;
-import com.vaadin.terminal.gwt.client.ui.VScrollTable.VScrollTableBody.VScrollTableRow;
import com.vaadin.terminal.gwt.client.ui.VTreeTable.VTreeTableScrollBody.VTreeTableRow;
public class VTreeTable extends VScrollTable {
- private static class PendingNavigationEvent {
- private final int keycode;
- private final boolean ctrl;
- private final boolean shift;
+ static class PendingNavigationEvent {
+ final int keycode;
+ final boolean ctrl;
+ final boolean shift;
public PendingNavigationEvent(int keycode, boolean ctrl, boolean shift) {
this.keycode = keycode;
@@ -59,82 +57,14 @@ public class VTreeTable extends VScrollTable {
}
}
- public static final String ATTRIBUTE_HIERARCHY_COLUMN_INDEX = "hci";
- private boolean collapseRequest;
+ boolean collapseRequest;
private boolean selectionPending;
- private int colIndexOfHierarchy;
- private String collapsedRowKey;
- private VTreeTableScrollBody scrollBody;
- private boolean animationsEnabled;
- private LinkedList<PendingNavigationEvent> pendingNavigationEvents = new LinkedList<VTreeTable.PendingNavigationEvent>();
- private boolean focusParentResponsePending;
-
- @Override
- public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
- FocusableScrollPanel widget = null;
- int scrollPosition = 0;
- if (collapseRequest) {
- widget = (FocusableScrollPanel) getWidget(1);
- scrollPosition = widget.getScrollPosition();
- }
- animationsEnabled = uidl.getBooleanAttribute("animate");
- colIndexOfHierarchy = uidl
- .hasAttribute(ATTRIBUTE_HIERARCHY_COLUMN_INDEX) ? uidl
- .getIntAttribute(ATTRIBUTE_HIERARCHY_COLUMN_INDEX) : 0;
- int oldTotalRows = getTotalRows();
- super.updateFromUIDL(uidl, client);
- if (collapseRequest) {
- if (collapsedRowKey != null && scrollBody != null) {
- VScrollTableRow row = getRenderedRowByKey(collapsedRowKey);
- if (row != null) {
- setRowFocus(row);
- focus();
- }
- }
-
- int scrollPosition2 = widget.getScrollPosition();
- if (scrollPosition != scrollPosition2) {
- widget.setScrollPosition(scrollPosition);
- }
-
- // check which rows are needed from the server and initiate a
- // deferred fetch
- onScroll(null);
- }
- // Recalculate table size if collapse request, or if page length is zero
- // (not sent by server) and row count changes (#7908).
- if (collapseRequest
- || (!uidl.hasAttribute("pagelength") && getTotalRows() != oldTotalRows)) {
- /*
- * Ensure that possibly removed/added scrollbars are considered.
- * Triggers row calculations, removes cached rows etc. Basically
- * cleans up state. Be careful if touching this, you will break
- * pageLength=0 if you remove this.
- */
- triggerLazyColumnAdjustment(true);
-
- collapseRequest = false;
- }
- if (uidl.hasAttribute("focusedRow")) {
- String key = uidl.getStringAttribute("focusedRow");
- setRowFocus(getRenderedRowByKey(key));
- focusParentResponsePending = false;
- } else if (uidl.hasAttribute("clearFocusPending")) {
- // Special case to detect a response to a focusParent request that
- // does not return any focusedRow because the selected node has no
- // parent
- focusParentResponsePending = false;
- }
-
- while (!collapseRequest && !focusParentResponsePending
- && !pendingNavigationEvents.isEmpty()) {
- // Keep replaying any queued events as long as we don't have any
- // potential content changes pending
- PendingNavigationEvent event = pendingNavigationEvents
- .removeFirst();
- handleNavigation(event.keycode, event.ctrl, event.shift);
- }
- }
+ int colIndexOfHierarchy;
+ String collapsedRowKey;
+ VTreeTableScrollBody scrollBody;
+ boolean animationsEnabled;
+ LinkedList<PendingNavigationEvent> pendingNavigationEvents = new LinkedList<VTreeTable.PendingNavigationEvent>();
+ boolean focusParentResponsePending;
@Override
protected VScrollTableBody createScrollBody() {
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VTreeTablePaintable.java b/src/com/vaadin/terminal/gwt/client/ui/VTreeTablePaintable.java
new file mode 100644
index 0000000000..9b6f03f612
--- /dev/null
+++ b/src/com/vaadin/terminal/gwt/client/ui/VTreeTablePaintable.java
@@ -0,0 +1,101 @@
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+package com.vaadin.terminal.gwt.client.ui;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.user.client.ui.Widget;
+import com.vaadin.terminal.gwt.client.ApplicationConnection;
+import com.vaadin.terminal.gwt.client.UIDL;
+import com.vaadin.terminal.gwt.client.ui.VScrollTable.VScrollTableBody.VScrollTableRow;
+import com.vaadin.terminal.gwt.client.ui.VTreeTable.PendingNavigationEvent;
+
+public class VTreeTablePaintable extends VScrollTablePaintable {
+ public static final String ATTRIBUTE_HIERARCHY_COLUMN_INDEX = "hci";
+
+ @Override
+ public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
+ FocusableScrollPanel widget = null;
+ int scrollPosition = 0;
+ if (getWidgetForPaintable().collapseRequest) {
+ widget = (FocusableScrollPanel) getWidgetForPaintable()
+ .getWidget(1);
+ scrollPosition = widget.getScrollPosition();
+ }
+ getWidgetForPaintable().animationsEnabled = uidl
+ .getBooleanAttribute("animate");
+ getWidgetForPaintable().colIndexOfHierarchy = uidl
+ .hasAttribute(ATTRIBUTE_HIERARCHY_COLUMN_INDEX) ? uidl
+ .getIntAttribute(ATTRIBUTE_HIERARCHY_COLUMN_INDEX) : 0;
+ int oldTotalRows = getWidgetForPaintable().getTotalRows();
+ super.updateFromUIDL(uidl, client);
+ if (getWidgetForPaintable().collapseRequest) {
+ if (getWidgetForPaintable().collapsedRowKey != null
+ && getWidgetForPaintable().scrollBody != null) {
+ VScrollTableRow row = getWidgetForPaintable()
+ .getRenderedRowByKey(
+ getWidgetForPaintable().collapsedRowKey);
+ if (row != null) {
+ getWidgetForPaintable().setRowFocus(row);
+ getWidgetForPaintable().focus();
+ }
+ }
+
+ int scrollPosition2 = widget.getScrollPosition();
+ if (scrollPosition != scrollPosition2) {
+ widget.setScrollPosition(scrollPosition);
+ }
+
+ // check which rows are needed from the server and initiate a
+ // deferred fetch
+ getWidgetForPaintable().onScroll(null);
+ }
+ // Recalculate table size if collapse request, or if page length is zero
+ // (not sent by server) and row count changes (#7908).
+ if (getWidgetForPaintable().collapseRequest
+ || (!uidl.hasAttribute("pagelength") && getWidgetForPaintable()
+ .getTotalRows() != oldTotalRows)) {
+ /*
+ * Ensure that possibly removed/added scrollbars are considered.
+ * Triggers row calculations, removes cached rows etc. Basically
+ * cleans up state. Be careful if touching this, you will break
+ * pageLength=0 if you remove this.
+ */
+ getWidgetForPaintable().triggerLazyColumnAdjustment(true);
+
+ getWidgetForPaintable().collapseRequest = false;
+ }
+ if (uidl.hasAttribute("focusedRow")) {
+ String key = uidl.getStringAttribute("focusedRow");
+ getWidgetForPaintable().setRowFocus(
+ getWidgetForPaintable().getRenderedRowByKey(key));
+ getWidgetForPaintable().focusParentResponsePending = false;
+ } else if (uidl.hasAttribute("clearFocusPending")) {
+ // Special case to detect a response to a focusParent request that
+ // does not return any focusedRow because the selected node has no
+ // parent
+ getWidgetForPaintable().focusParentResponsePending = false;
+ }
+
+ while (!getWidgetForPaintable().collapseRequest
+ && !getWidgetForPaintable().focusParentResponsePending
+ && !getWidgetForPaintable().pendingNavigationEvents.isEmpty()) {
+ // Keep replaying any queued events as long as we don't have any
+ // potential content changes pending
+ PendingNavigationEvent event = getWidgetForPaintable().pendingNavigationEvents
+ .removeFirst();
+ getWidgetForPaintable().handleNavigation(event.keycode, event.ctrl,
+ event.shift);
+ }
+ }
+
+ @Override
+ protected Widget createWidget() {
+ return GWT.create(VTreeTable.class);
+ }
+
+ @Override
+ public VTreeTable getWidgetForPaintable() {
+ return (VTreeTable) super.getWidgetForPaintable();
+ }
+}
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VUpload.java b/src/com/vaadin/terminal/gwt/client/ui/VUpload.java
index 3d49b8d9d1..66894417f3 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VUpload.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VUpload.java
@@ -24,9 +24,9 @@ import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.BrowserInfo;
-import com.vaadin.terminal.gwt.client.VPaintableWidget;
import com.vaadin.terminal.gwt.client.UIDL;
import com.vaadin.terminal.gwt.client.VConsole;
+import com.vaadin.terminal.gwt.client.VPaintableWidget;
import com.vaadin.terminal.gwt.client.VTooltip;
/**
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VView.java b/src/com/vaadin/terminal/gwt/client/ui/VView.java
index 8eabf6c625..e3aba21096 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VView.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VView.java
@@ -640,6 +640,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);
@@ -678,6 +683,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/terminal/gwt/client/ui/VWindow.java b/src/com/vaadin/terminal/gwt/client/ui/VWindow.java
index c1ef2bbac4..95ab0dc773 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VWindow.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VWindow.java
@@ -140,6 +140,7 @@ public class VWindow extends VOverlay implements Container,
private Element modalityCurtain;
private Element draggingCurtain;
+ private Element resizingCurtain;
private Element headerText;
@@ -568,12 +569,17 @@ public class VWindow extends VOverlay implements Container,
this.draggable = draggable;
+ setCursorProperties();
+ }
+
+ private void setCursorProperties() {
if (!this.draggable) {
header.getStyle().setProperty("cursor", "default");
+ footer.getStyle().setProperty("cursor", "default");
} else {
header.getStyle().setProperty("cursor", "");
+ footer.getStyle().setProperty("cursor", "");
}
-
}
private void setNaturalWidth() {
@@ -703,28 +709,62 @@ public class VWindow extends VOverlay implements Container,
}
/*
- * Shows (or hides) an empty div on top of all other content; used when
- * resizing or moving, so that iframes (etc) do not steal event.
+ * Shows an empty div on top of all other content; used when moving, so that
+ * iframes (etc) do not steal event.
*/
- private void showDraggingCurtain(boolean show) {
- if (show && draggingCurtain == null) {
+ private void showDraggingCurtain() {
+ DOM.appendChild(RootPanel.getBodyElement(), getDraggingCurtain());
+ }
- draggingCurtain = DOM.createDiv();
- DOM.setStyleAttribute(draggingCurtain, "position", "absolute");
- DOM.setStyleAttribute(draggingCurtain, "top", "0px");
- DOM.setStyleAttribute(draggingCurtain, "left", "0px");
- DOM.setStyleAttribute(draggingCurtain, "width", "100%");
- DOM.setStyleAttribute(draggingCurtain, "height", "100%");
- DOM.setStyleAttribute(draggingCurtain, "zIndex", ""
- + VOverlay.Z_INDEX);
+ private void hideDraggingCurtain() {
+ if (draggingCurtain != null) {
+ DOM.removeChild(RootPanel.getBodyElement(), draggingCurtain);
+ }
+ }
- DOM.appendChild(RootPanel.getBodyElement(), draggingCurtain);
- } else if (!show && draggingCurtain != null) {
+ /*
+ * Shows an empty div on top of all other content; used when resizing, so
+ * that iframes (etc) do not steal event.
+ */
+ private void showResizingCurtain() {
+ DOM.appendChild(RootPanel.getBodyElement(), getResizingCurtain());
+ }
- DOM.removeChild(RootPanel.getBodyElement(), draggingCurtain);
- draggingCurtain = null;
+ private void hideResizingCurtain() {
+ if (resizingCurtain != null) {
+ DOM.removeChild(RootPanel.getBodyElement(), resizingCurtain);
}
+ }
+
+ private Element getDraggingCurtain() {
+ if (draggingCurtain == null) {
+ draggingCurtain = createCurtain();
+ draggingCurtain.setClassName(CLASSNAME + "-draggingCurtain");
+ }
+
+ return draggingCurtain;
+ }
+
+ private Element getResizingCurtain() {
+ if (resizingCurtain == null) {
+ resizingCurtain = createCurtain();
+ resizingCurtain.setClassName(CLASSNAME + "-resizingCurtain");
+ }
+
+ return resizingCurtain;
+ }
+
+ private Element createCurtain() {
+ Element curtain = DOM.createDiv();
+
+ DOM.setStyleAttribute(curtain, "position", "absolute");
+ DOM.setStyleAttribute(curtain, "top", "0px");
+ DOM.setStyleAttribute(curtain, "left", "0px");
+ DOM.setStyleAttribute(curtain, "width", "100%");
+ DOM.setStyleAttribute(curtain, "height", "100%");
+ DOM.setStyleAttribute(curtain, "zIndex", "" + VOverlay.Z_INDEX);
+ return curtain;
}
private void setResizable(boolean resizability) {
@@ -844,7 +884,7 @@ public class VWindow extends VOverlay implements Container,
if (!isActive()) {
bringToFront();
}
- showDraggingCurtain(true);
+ showResizingCurtain();
if (BrowserInfo.get().isIE()) {
DOM.setStyleAttribute(resizeBox, "visibility", "hidden");
}
@@ -862,7 +902,7 @@ public class VWindow extends VOverlay implements Container,
case Event.ONTOUCHCANCEL:
DOM.releaseCapture(getElement());
case Event.ONLOSECAPTURE:
- showDraggingCurtain(false);
+ hideResizingCurtain();
if (BrowserInfo.get().isIE()) {
DOM.setStyleAttribute(resizeBox, "visibility", "");
}
@@ -1097,7 +1137,7 @@ public class VWindow extends VOverlay implements Container,
private void beginMovingWindow(Event event) {
if (draggable) {
- showDraggingCurtain(true);
+ showDraggingCurtain();
dragging = true;
startX = Util.getTouchOrMouseClientX(event);
startY = Util.getTouchOrMouseClientY(event);
@@ -1110,7 +1150,7 @@ public class VWindow extends VOverlay implements Container,
private void stopMovingWindow() {
dragging = false;
- showDraggingCurtain(false);
+ hideDraggingCurtain();
DOM.releaseCapture(getElement());
}
diff --git a/src/com/vaadin/terminal/gwt/client/ui/label/VLabel.java b/src/com/vaadin/terminal/gwt/client/ui/label/VLabel.java
index 09f435227d..8828582b57 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/label/VLabel.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/label/VLabel.java
@@ -34,15 +34,10 @@ public class VLabel extends HTML {
public void onBrowserEvent(Event event) {
super.onBrowserEvent(event);
if (event.getTypeInt() == Event.ONLOAD) {
- // FIXME: Should not be here but in paintable
Util.notifyParentOfSizeChange(this, true);
- event.cancelBubble(true);
+ event.stopPropagation();
return;
}
- // FIXME: Move to paintable
- // if (client != null) {
- // client.handleTooltipEvent(event, this);
- // }
}
@Override
diff --git a/src/com/vaadin/terminal/gwt/client/ui/label/VLabelPaintable.java b/src/com/vaadin/terminal/gwt/client/ui/label/VLabelPaintable.java
index 796bce265e..269afde25d 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/label/VLabelPaintable.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/label/VLabelPaintable.java
@@ -6,27 +6,21 @@ package com.vaadin.terminal.gwt.client.ui.label;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.PreElement;
+import com.google.gwt.user.client.ui.Widget;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.UIDL;
import com.vaadin.terminal.gwt.client.Util;
-import com.vaadin.terminal.gwt.client.VPaintableWidget;
-
-public class VLabelPaintable implements VPaintableWidget {
-
- private VLabel widget = GWT.create(VLabel.class);
- private ApplicationConnection client;
+import com.vaadin.terminal.gwt.client.ui.VAbstractPaintableWidget;
+public class VLabelPaintable extends VAbstractPaintableWidget {
public VLabelPaintable() {
}
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
-
- if (client.updateComponent(getWidgetForPaintable(), uidl, true)) {
+ if (client.updateComponent(this, uidl, true)) {
return;
}
- this.client = client;
-
boolean sinkOnloads = false;
final String mode = uidl.getStringAttribute("mode");
@@ -64,8 +58,14 @@ public class VLabelPaintable implements VPaintableWidget {
}
}
+ @Override
+ protected Widget createWidget() {
+ return GWT.create(VLabel.class);
+ }
+
+ @Override
public VLabel getWidgetForPaintable() {
- return widget;
+ return (VLabel) super.getWidgetForPaintable();
}
}
diff --git a/src/com/vaadin/ui/AbstractComponent.java b/src/com/vaadin/ui/AbstractComponent.java
index de114e996e..318bcd7ea2 100644
--- a/src/com/vaadin/ui/AbstractComponent.java
+++ b/src/com/vaadin/ui/AbstractComponent.java
@@ -1334,9 +1334,12 @@ public abstract class AbstractComponent implements Component, MethodEventSource
/*
* (non-Javadoc)
*
- * @see com.vaadin.terminal.Sizeable#setHeight(float, int)
+ * @see com.vaadin.terminal.Sizeable#setHeight(float, Unit)
*/
public void setHeight(float height, Unit unit) {
+ if (unit == null) {
+ throw new IllegalArgumentException("Unit can not be null");
+ }
this.height = height;
heightUnit = unit;
requestRepaint();
@@ -1366,9 +1369,12 @@ public abstract class AbstractComponent implements Component, MethodEventSource
/*
* (non-Javadoc)
*
- * @see com.vaadin.terminal.Sizeable#setWidth(float, int)
+ * @see com.vaadin.terminal.Sizeable#setWidth(float, Unit)
*/
public void setWidth(float width, Unit unit) {
+ if (unit == null) {
+ throw new IllegalArgumentException("Unit can not be null");
+ }
this.width = width;
widthUnit = unit;
requestRepaint();
diff --git a/src/com/vaadin/ui/AbstractSelect.java b/src/com/vaadin/ui/AbstractSelect.java
index b65cb61450..5e086f0b8d 100644
--- a/src/com/vaadin/ui/AbstractSelect.java
+++ b/src/com/vaadin/ui/AbstractSelect.java
@@ -61,41 +61,85 @@ public abstract class AbstractSelect extends AbstractField<Object> implements
Container.PropertySetChangeNotifier, Container.ItemSetChangeNotifier,
Container.ItemSetChangeListener {
+ public enum ItemCaptionMode {
+ /**
+ * Item caption mode: Item's ID's <code>String</code> representation is
+ * used as caption.
+ */
+ ID,
+ /**
+ * Item caption mode: Item's <code>String</code> representation is used
+ * as caption.
+ */
+ ITEM,
+ /**
+ * Item caption mode: Index of the item is used as caption. The index
+ * mode can only be used with the containers implementing the
+ * {@link com.vaadin.data.Container.Indexed} interface.
+ */
+ INDEX,
+ /**
+ * Item caption mode: If an Item has a caption it's used, if not, Item's
+ * ID's <code>String</code> representation is used as caption. <b>This
+ * is the default</b>.
+ */
+ EXPLICIT_DEFAULTS_ID,
+ /**
+ * Item caption mode: Captions must be explicitly specified.
+ */
+ EXPLICIT,
+ /**
+ * Item caption mode: Only icons are shown, captions are hidden.
+ */
+ ICON_ONLY,
+ /**
+ * Item caption mode: Item captions are read from property specified
+ * with <code>setItemCaptionPropertyId</code>.
+ */
+ PROPERTY;
+ }
+
/**
- * Item caption mode: Item's ID's <code>String</code> representation is used
- * as caption.
+ * @deprecated from 7.0, use {@link ItemCaptionMode.ID} instead
*/
- public static final int ITEM_CAPTION_MODE_ID = 0;
+ @Deprecated
+ public static final ItemCaptionMode ITEM_CAPTION_MODE_ID = ItemCaptionMode.ID;
+
/**
- * Item caption mode: Item's <code>String</code> representation is used as
- * caption.
+ * @deprecated from 7.0, use {@link ItemCaptionMode.ID} instead
*/
- public static final int ITEM_CAPTION_MODE_ITEM = 1;
+ @Deprecated
+ public static final ItemCaptionMode ITEM_CAPTION_MODE_ITEM = ItemCaptionMode.ITEM;
+
/**
- * Item caption mode: Index of the item is used as caption. The index mode
- * can only be used with the containers implementing the
- * {@link com.vaadin.data.Container.Indexed} interface.
+ * @deprecated from 7.0, use {@link ItemCaptionMode.ID} instead
*/
- public static final int ITEM_CAPTION_MODE_INDEX = 2;
+ @Deprecated
+ public static final ItemCaptionMode ITEM_CAPTION_MODE_INDEX = ItemCaptionMode.INDEX;
+
/**
- * Item caption mode: If an Item has a caption it's used, if not, Item's
- * ID's <code>String</code> representation is used as caption. <b>This is
- * the default</b>.
+ * @deprecated from 7.0, use {@link ItemCaptionMode.ID} instead
*/
- public static final int ITEM_CAPTION_MODE_EXPLICIT_DEFAULTS_ID = 3;
+ @Deprecated
+ public static final ItemCaptionMode ITEM_CAPTION_MODE_EXPLICIT_DEFAULTS_ID = ItemCaptionMode.EXPLICIT_DEFAULTS_ID;
+
/**
- * Item caption mode: Captions must be explicitly specified.
+ * @deprecated from 7.0, use {@link ItemCaptionMode.ID} instead
*/
- public static final int ITEM_CAPTION_MODE_EXPLICIT = 4;
+ @Deprecated
+ public static final ItemCaptionMode ITEM_CAPTION_MODE_EXPLICIT = ItemCaptionMode.EXPLICIT;
+
/**
- * Item caption mode: Only icons are shown, captions are hidden.
+ * @deprecated from 7.0, use {@link ItemCaptionMode.ID} instead
*/
- public static final int ITEM_CAPTION_MODE_ICON_ONLY = 5;
+ @Deprecated
+ public static final ItemCaptionMode ITEM_CAPTION_MODE_ICON_ONLY = ItemCaptionMode.ICON_ONLY;
+
/**
- * Item caption mode: Item captions are read from property specified with
- * <code>setItemCaptionPropertyId</code>.
+ * @deprecated from 7.0, use {@link ItemCaptionMode.ID} instead
*/
- public static final int ITEM_CAPTION_MODE_PROPERTY = 6;
+ @Deprecated
+ public static final ItemCaptionMode ITEM_CAPTION_MODE_PROPERTY = ItemCaptionMode.PROPERTY;
/**
* Interface for option filtering, used to filter options based on user
@@ -175,7 +219,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements
/**
* Item caption mode.
*/
- private int itemCaptionMode = ITEM_CAPTION_MODE_EXPLICIT_DEFAULTS_ID;
+ private ItemCaptionMode itemCaptionMode = ItemCaptionMode.EXPLICIT_DEFAULTS_ID;
/**
* Item caption source property id.
@@ -1038,11 +1082,11 @@ public abstract class AbstractSelect extends AbstractField<Object> implements
switch (getItemCaptionMode()) {
- case ITEM_CAPTION_MODE_ID:
+ case ID:
caption = itemId.toString();
break;
- case ITEM_CAPTION_MODE_INDEX:
+ case INDEX:
if (items instanceof Container.Indexed) {
caption = String.valueOf(((Container.Indexed) items)
.indexOfId(itemId));
@@ -1051,25 +1095,25 @@ public abstract class AbstractSelect extends AbstractField<Object> implements
}
break;
- case ITEM_CAPTION_MODE_ITEM:
+ case ITEM:
final Item i = getItem(itemId);
if (i != null) {
caption = i.toString();
}
break;
- case ITEM_CAPTION_MODE_EXPLICIT:
+ case EXPLICIT:
caption = itemCaptions.get(itemId);
break;
- case ITEM_CAPTION_MODE_EXPLICIT_DEFAULTS_ID:
+ case EXPLICIT_DEFAULTS_ID:
caption = itemCaptions.get(itemId);
if (caption == null) {
caption = itemId.toString();
}
break;
- case ITEM_CAPTION_MODE_PROPERTY:
+ case PROPERTY:
final Property<?> p = getContainerProperty(itemId,
getItemCaptionPropertyId());
if (p != null) {
@@ -1086,7 +1130,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements
}
/**
- * Sets the icon for an item.
+ * Sets tqhe icon for an item.
*
* @param itemId
* the id of the item to be assigned an icon.
@@ -1163,8 +1207,8 @@ public abstract class AbstractSelect extends AbstractField<Object> implements
* @param mode
* the One of the modes listed above.
*/
- public void setItemCaptionMode(int mode) {
- if (ITEM_CAPTION_MODE_ID <= mode && mode <= ITEM_CAPTION_MODE_PROPERTY) {
+ public void setItemCaptionMode(ItemCaptionMode mode) {
+ if (mode != null) {
itemCaptionMode = mode;
requestRepaint();
}
@@ -1198,7 +1242,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements
*
* @return the One of the modes listed above.
*/
- public int getItemCaptionMode() {
+ public ItemCaptionMode getItemCaptionMode() {
return itemCaptionMode;
}
@@ -1689,7 +1733,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements
public void addNotifierForItem(Object itemId) {
switch (getItemCaptionMode()) {
- case ITEM_CAPTION_MODE_ITEM:
+ case ITEM:
final Item i = getItem(itemId);
if (i == null) {
return;
@@ -1713,7 +1757,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements
}
break;
- case ITEM_CAPTION_MODE_PROPERTY:
+ case PROPERTY:
final Property<?> p = getContainerProperty(itemId,
getItemCaptionPropertyId());
if (p != null && p instanceof Property.ValueChangeNotifier) {
diff --git a/src/com/vaadin/ui/Button.java b/src/com/vaadin/ui/Button.java
index 7c0811008a..9910f3a4c4 100644
--- a/src/com/vaadin/ui/Button.java
+++ b/src/com/vaadin/ui/Button.java
@@ -24,6 +24,7 @@ import com.vaadin.terminal.PaintTarget;
import com.vaadin.terminal.gwt.client.MouseEventDetails;
import com.vaadin.terminal.gwt.client.ui.VButton;
import com.vaadin.terminal.gwt.client.ui.VButton.ButtonClientToServerRpc;
+import com.vaadin.terminal.gwt.client.ui.VButtonPaintable;
import com.vaadin.terminal.gwt.server.RpcTarget;
import com.vaadin.tools.ReflectTools;
import com.vaadin.ui.ClientWidget.LoadStyle;
@@ -38,7 +39,7 @@ import com.vaadin.ui.Component.Focusable;
* @since 3.0
*/
@SuppressWarnings("serial")
-@ClientWidget(value = VButton.class, loadStyle = LoadStyle.EAGER)
+@ClientWidget(value = VButtonPaintable.class, loadStyle = LoadStyle.EAGER)
public class Button extends AbstractComponent implements
FieldEvents.BlurNotifier, FieldEvents.FocusNotifier, Focusable,
Action.ShortcutNotifier, RpcTarget {
diff --git a/src/com/vaadin/ui/Component.java b/src/com/vaadin/ui/Component.java
index 53fdfdb4ff..1289b57bd9 100644
--- a/src/com/vaadin/ui/Component.java
+++ b/src/com/vaadin/ui/Component.java
@@ -11,7 +11,6 @@ import java.util.EventObject;
import java.util.Locale;
import com.vaadin.Application;
-import com.vaadin.data.Property;
import com.vaadin.event.FieldEvents;
import com.vaadin.terminal.ErrorMessage;
import com.vaadin.terminal.Paintable;
@@ -363,12 +362,6 @@ public interface Component extends Paintable, VariableOwner, Sizeable,
* </p>
*
* <p>
- * The read-only status affects only the user; the value can still be
- * changed programmatically, for example, with
- * {@link Property#setValue(Object)}.
- * </p>
- *
- * <p>
* The method will return {@code true} if the component or any of its
* parents is in the read-only mode.
* </p>
@@ -396,12 +389,6 @@ public interface Component extends Paintable, VariableOwner, Sizeable,
* </p>
*
* <p>
- * The read-only status affects only the user; the value can still be
- * changed programmatically, for example, with
- * {@link Property#setValue(Object)}.
- * </p>
- *
- * <p>
* This method will trigger a
* {@link com.vaadin.terminal.Paintable.RepaintRequestEvent
* RepaintRequestEvent}.
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/src/com/vaadin/ui/MenuBar.java b/src/com/vaadin/ui/MenuBar.java
index 7ed432a12b..54a094a4e7 100644
--- a/src/com/vaadin/ui/MenuBar.java
+++ b/src/com/vaadin/ui/MenuBar.java
@@ -14,6 +14,7 @@ import com.vaadin.terminal.PaintException;
import com.vaadin.terminal.PaintTarget;
import com.vaadin.terminal.Resource;
import com.vaadin.terminal.gwt.client.ui.VMenuBar;
+import com.vaadin.terminal.gwt.client.ui.VMenuBarPaintable;
import com.vaadin.ui.ClientWidget.LoadStyle;
/**
@@ -24,7 +25,7 @@ import com.vaadin.ui.ClientWidget.LoadStyle;
* </p>
*/
@SuppressWarnings("serial")
-@ClientWidget(value = VMenuBar.class, loadStyle = LoadStyle.LAZY)
+@ClientWidget(value = VMenuBarPaintable.class, loadStyle = LoadStyle.LAZY)
public class MenuBar extends AbstractComponent {
// Items of the top-level menu
diff --git a/src/com/vaadin/ui/NativeButton.java b/src/com/vaadin/ui/NativeButton.java
index 46d13c4150..b7b7fcb38c 100644
--- a/src/com/vaadin/ui/NativeButton.java
+++ b/src/com/vaadin/ui/NativeButton.java
@@ -3,10 +3,10 @@
*/
package com.vaadin.ui;
-import com.vaadin.terminal.gwt.client.ui.VNativeButton;
+import com.vaadin.terminal.gwt.client.ui.VNativeButtonPaintable;
@SuppressWarnings("serial")
-@ClientWidget(VNativeButton.class)
+@ClientWidget(VNativeButtonPaintable.class)
public class NativeButton extends Button {
public NativeButton() {
diff --git a/src/com/vaadin/ui/Table.java b/src/com/vaadin/ui/Table.java
index 8b9dc3ef81..003ef6978c 100644
--- a/src/com/vaadin/ui/Table.java
+++ b/src/com/vaadin/ui/Table.java
@@ -47,6 +47,7 @@ import com.vaadin.terminal.PaintTarget;
import com.vaadin.terminal.Resource;
import com.vaadin.terminal.gwt.client.MouseEventDetails;
import com.vaadin.terminal.gwt.client.ui.VScrollTable;
+import com.vaadin.terminal.gwt.client.ui.VScrollTablePaintable;
import com.vaadin.terminal.gwt.client.ui.dd.VLazyInitItemIdentifiers;
/**
@@ -73,7 +74,7 @@ import com.vaadin.terminal.gwt.client.ui.dd.VLazyInitItemIdentifiers;
* @since 3.0
*/
@SuppressWarnings({ "deprecation" })
-@ClientWidget(VScrollTable.class)
+@ClientWidget(VScrollTablePaintable.class)
public class Table extends AbstractSelect implements Action.Container,
Container.Ordered, Container.Sortable, ItemClickSource,
ItemClickNotifier, DragSource, DropTarget {
@@ -115,91 +116,215 @@ public class Table extends AbstractSelect implements Action.Container,
protected static final int CELL_FIRSTCOL = 5;
+ public enum Align {
+ /**
+ * Left column alignment. <b>This is the default behaviour. </b>
+ */
+ LEFT("b"),
+
+ /**
+ * Center column alignment.
+ */
+ CENTER("c"),
+
+ /**
+ * Right column alignment.
+ */
+ RIGHT("e");
+
+ private String alignment;
+
+ private Align(String alignment) {
+ this.alignment = alignment;
+ }
+
+ @Override
+ public String toString() {
+ return alignment;
+ }
+
+ public Align convertStringToAlign(String string) {
+ if (string == null) {
+ return null;
+ }
+ if (string.equals("b")) {
+ return Align.LEFT;
+ } else if (string.equals("c")) {
+ return Align.CENTER;
+ } else if (string.equals("e")) {
+ return Align.RIGHT;
+ } else {
+ return null;
+ }
+ }
+ }
+
/**
- * Left column alignment. <b>This is the default behaviour. </b>
+ * @deprecated from 7.0, use {@link Align#LEFT} instead
*/
- public static final String ALIGN_LEFT = "b";
+ @Deprecated
+ public static final Align ALIGN_LEFT = Align.LEFT;
/**
- * Center column alignment.
+ * @deprecated from 7.0, use {@link Align#CENTER} instead
*/
- public static final String ALIGN_CENTER = "c";
+ @Deprecated
+ public static final Align ALIGN_CENTER = Align.CENTER;
/**
- * Right column alignment.
+ * @deprecated from 7.0, use {@link Align#RIGHT} instead
*/
- public static final String ALIGN_RIGHT = "e";
+ @Deprecated
+ public static final Align ALIGN_RIGHT = Align.RIGHT;
+
+ public enum ColumnHeaderMode {
+ /**
+ * Column headers are hidden.
+ */
+ HIDDEN,
+ /**
+ * Property ID:s are used as column headers.
+ */
+ ID,
+ /**
+ * Column headers are explicitly specified with
+ * {@link #setColumnHeaders(String[])}.
+ */
+ EXPLICIT,
+ /**
+ * Column headers are explicitly specified with
+ * {@link #setColumnHeaders(String[])}. If a header is not specified for
+ * a given property, its property id is used instead.
+ * <p>
+ * <b>This is the default behavior. </b>
+ */
+ EXPLICIT_DEFAULTS_ID
+ }
/**
- * Column header mode: Column headers are hidden.
+ * @deprecated from 7.0, use {@link ColumnHeaderMode#HIDDEN} instead
*/
- public static final int COLUMN_HEADER_MODE_HIDDEN = -1;
+ @Deprecated
+ public static final ColumnHeaderMode COLUMN_HEADER_MODE_HIDDEN = ColumnHeaderMode.HIDDEN;
/**
- * Column header mode: Property ID:s are used as column headers.
+ * @deprecated from 7.0, use {@link ColumnHeaderMode#ID} instead
*/
- public static final int COLUMN_HEADER_MODE_ID = 0;
+ @Deprecated
+ public static final ColumnHeaderMode COLUMN_HEADER_MODE_ID = ColumnHeaderMode.ID;
/**
- * Column header mode: Column headers are explicitly specified with
- * {@link #setColumnHeaders(String[])}.
+ * @deprecated from 7.0, use {@link ColumnHeaderMode#EXPLICIT} instead
*/
- public static final int COLUMN_HEADER_MODE_EXPLICIT = 1;
+ @Deprecated
+ public static final ColumnHeaderMode COLUMN_HEADER_MODE_EXPLICIT = ColumnHeaderMode.EXPLICIT;
/**
- * Column header mode: Column headers are explicitly specified with
- * {@link #setColumnHeaders(String[])}. If a header is not specified for a
- * given property, its property id is used instead.
- * <p>
- * <b>This is the default behavior. </b>
+ * @deprecated from 7.0, use {@link ColumnHeaderMode#EXPLICIT_DEFAULTS_ID}
+ * instead
*/
- public static final int COLUMN_HEADER_MODE_EXPLICIT_DEFAULTS_ID = 2;
+ @Deprecated
+ public static final ColumnHeaderMode COLUMN_HEADER_MODE_EXPLICIT_DEFAULTS_ID = ColumnHeaderMode.EXPLICIT_DEFAULTS_ID;
+
+ public enum RowHeaderMode {
+ /**
+ * Row caption mode: The row headers are hidden. <b>This is the default
+ * mode. </b>
+ */
+ HIDDEN(null),
+ /**
+ * Row caption mode: Items Id-objects toString is used as row caption.
+ */
+ ID(ItemCaptionMode.ID),
+ /**
+ * Row caption mode: Item-objects toString is used as row caption.
+ */
+ ITEM(ItemCaptionMode.ITEM),
+ /**
+ * Row caption mode: Index of the item is used as item caption. The
+ * index mode can only be used with the containers implementing the
+ * {@link com.vaadin.data.Container.Indexed} interface.
+ */
+ INDEX(ItemCaptionMode.INDEX),
+ /**
+ * Row caption mode: Item captions are explicitly specified, but if the
+ * caption is missing, the item id objects <code>toString()</code> is
+ * used instead.
+ */
+ EXPLICIT_DEFAULTS_ID(ItemCaptionMode.EXPLICIT_DEFAULTS_ID),
+ /**
+ * Row caption mode: Item captions are explicitly specified.
+ */
+ EXPLICIT(ItemCaptionMode.EXPLICIT),
+ /**
+ * Row caption mode: Only icons are shown, the captions are hidden.
+ */
+ ICON_ONLY(ItemCaptionMode.ICON_ONLY),
+ /**
+ * Row caption mode: Item captions are read from property specified with
+ * {@link #setItemCaptionPropertyId(Object)}.
+ */
+ PROPERTY(ItemCaptionMode.PROPERTY);
+
+ ItemCaptionMode mode;
+
+ private RowHeaderMode(ItemCaptionMode mode) {
+ this.mode = mode;
+ }
+
+ public ItemCaptionMode getItemCaptionMode() {
+ return mode;
+ }
+ }
/**
- * Row caption mode: The row headers are hidden. <b>This is the default
- * mode. </b>
+ * @deprecated from 7.0, use {@link RowHeaderMode#HIDDEN} instead
*/
- public static final int ROW_HEADER_MODE_HIDDEN = -1;
+ @Deprecated
+ public static final RowHeaderMode ROW_HEADER_MODE_HIDDEN = RowHeaderMode.HIDDEN;
/**
- * Row caption mode: Items Id-objects toString is used as row caption.
+ * @deprecated from 7.0, use {@link RowHeaderMode#ID} instead
*/
- public static final int ROW_HEADER_MODE_ID = AbstractSelect.ITEM_CAPTION_MODE_ID;
+ @Deprecated
+ public static final RowHeaderMode ROW_HEADER_MODE_ID = RowHeaderMode.ID;
/**
- * Row caption mode: Item-objects toString is used as row caption.
+ * @deprecated from 7.0, use {@link RowHeaderMode#ITEM} instead
*/
- public static final int ROW_HEADER_MODE_ITEM = AbstractSelect.ITEM_CAPTION_MODE_ITEM;
+ @Deprecated
+ public static final RowHeaderMode ROW_HEADER_MODE_ITEM = RowHeaderMode.ITEM;
/**
- * Row caption mode: Index of the item is used as item caption. The index
- * mode can only be used with the containers implementing Container.Indexed
- * interface.
+ * @deprecated from 7.0, use {@link RowHeaderMode#INDEX} instead
*/
- public static final int ROW_HEADER_MODE_INDEX = AbstractSelect.ITEM_CAPTION_MODE_INDEX;
+ @Deprecated
+ public static final RowHeaderMode ROW_HEADER_MODE_INDEX = RowHeaderMode.INDEX;
/**
- * Row caption mode: Item captions are explicitly specified.
+ * @deprecated from 7.0, use {@link RowHeaderMode#EXPLICIT_DEFAULTS_ID}
+ * instead
*/
- public static final int ROW_HEADER_MODE_EXPLICIT = AbstractSelect.ITEM_CAPTION_MODE_EXPLICIT;
+ @Deprecated
+ public static final RowHeaderMode ROW_HEADER_MODE_EXPLICIT_DEFAULTS_ID = RowHeaderMode.EXPLICIT_DEFAULTS_ID;
/**
- * Row caption mode: Item captions are read from property specified with
- * {@link #setItemCaptionPropertyId(Object)}.
+ * @deprecated from 7.0, use {@link RowHeaderMode#EXPLICIT} instead
*/
- public static final int ROW_HEADER_MODE_PROPERTY = AbstractSelect.ITEM_CAPTION_MODE_PROPERTY;
+ @Deprecated
+ public static final RowHeaderMode ROW_HEADER_MODE_EXPLICIT = RowHeaderMode.EXPLICIT;
/**
- * Row caption mode: Only icons are shown, the captions are hidden.
+ * @deprecated from 7.0, use {@link RowHeaderMode#ICON_ONLY} instead
*/
- public static final int ROW_HEADER_MODE_ICON_ONLY = AbstractSelect.ITEM_CAPTION_MODE_ICON_ONLY;
+ @Deprecated
+ public static final RowHeaderMode ROW_HEADER_MODE_ICON_ONLY = RowHeaderMode.ICON_ONLY;
/**
- * Row caption mode: Item captions are explicitly specified, but if the
- * caption is missing, the item id objects <code>toString()</code> is used
- * instead.
+ * @deprecated from 7.0, use {@link RowHeaderMode#PROPERTY} instead
*/
- public static final int ROW_HEADER_MODE_EXPLICIT_DEFAULTS_ID = AbstractSelect.ITEM_CAPTION_MODE_EXPLICIT_DEFAULTS_ID;
+ @Deprecated
+ public static final RowHeaderMode ROW_HEADER_MODE_PROPERTY = RowHeaderMode.PROPERTY;
/**
* The default rate that table caches rows for smooth scrolling.
@@ -254,7 +379,7 @@ public class Table extends AbstractSelect implements Action.Container,
/**
* Holds alignments for visible columns (by propertyId).
*/
- private HashMap<Object, String> columnAlignments = new HashMap<Object, String>();
+ private HashMap<Object, Align> columnAlignments = new HashMap<Object, Align>();
/**
* Holds column widths in pixels (Integer) or expand ratios (Float) for
@@ -290,17 +415,17 @@ public class Table extends AbstractSelect implements Action.Container,
/**
* Holds value of property columnHeaderMode.
*/
- private int columnHeaderMode = COLUMN_HEADER_MODE_EXPLICIT_DEFAULTS_ID;
+ private ColumnHeaderMode columnHeaderMode = ColumnHeaderMode.EXPLICIT_DEFAULTS_ID;
/**
- * Should the Table footer be visible?
+ * Holds value of property rowHeaderMode.
*/
- private boolean columnFootersVisible = false;
+ private RowHeaderMode rowHeaderMode = RowHeaderMode.EXPLICIT_DEFAULTS_ID;
/**
- * True iff the row captions are hidden.
+ * Should the Table footer be visible?
*/
- private boolean rowCaptionsAreHidden = true;
+ private boolean columnFootersVisible = false;
/**
* Page contents buffer used in buffered mode.
@@ -512,7 +637,7 @@ public class Table extends AbstractSelect implements Action.Container,
final Object col = i.next();
if (!newVC.contains(col)) {
setColumnHeader(col, null);
- setColumnAlignment(col, null);
+ setColumnAlignment(col, (Align) null);
setColumnIcon(col, null);
}
}
@@ -656,21 +781,21 @@ public class Table extends AbstractSelect implements Action.Container,
* {@link #getVisibleColumns()}. The possible values for the alignments
* include:
* <ul>
- * <li>{@link #ALIGN_LEFT}: Left alignment</li>
- * <li>{@link #ALIGN_CENTER}: Centered</li>
- * <li>{@link #ALIGN_RIGHT}: Right alignment</li>
+ * <li>{@link Align#LEFT}: Left alignment</li>
+ * <li>{@link Align#CENTER}: Centered</li>
+ * <li>{@link Align#RIGHT}: Right alignment</li>
* </ul>
- * The alignments default to {@link #ALIGN_LEFT}: any null values are
+ * The alignments default to {@link Align#LEFT}: any null values are
* rendered as align lefts.
* </p>
*
* @return the Column alignments array.
*/
- public String[] getColumnAlignments() {
+ public Align[] getColumnAlignments() {
if (columnAlignments == null) {
return null;
}
- final String[] alignments = new String[visibleColumns.size()];
+ final Align[] alignments = new Align[visibleColumns.size()];
int i = 0;
for (final Iterator<Object> it = visibleColumns.iterator(); it
.hasNext(); i++) {
@@ -684,39 +809,29 @@ public class Table extends AbstractSelect implements Action.Container,
* Sets the column alignments.
*
* <p>
- * The items in the array must match the properties identified by
- * {@link #getVisibleColumns()}. The possible values for the alignments
- * include:
+ * The amount of items in the array must match the amount of properties
+ * identified by {@link #getVisibleColumns()}. The possible values for the
+ * alignments include:
* <ul>
- * <li>{@link #ALIGN_LEFT}: Left alignment</li>
- * <li>{@link #ALIGN_CENTER}: Centered</li>
- * <li>{@link #ALIGN_RIGHT}: Right alignment</li>
+ * <li>{@link Align#LEFT}: Left alignment</li>
+ * <li>{@link Align#CENTER}: Centered</li>
+ * <li>{@link Align#RIGHT}: Right alignment</li>
* </ul>
- * The alignments default to {@link #ALIGN_LEFT}
+ * The alignments default to {@link Align#LEFT}
* </p>
*
* @param columnAlignments
* the Column alignments array.
*/
- public void setColumnAlignments(String[] columnAlignments) {
+ public void setColumnAlignments(Align... columnAlignments) {
if (columnAlignments.length != visibleColumns.size()) {
throw new IllegalArgumentException(
"The length of the alignments array must match the number of visible columns");
}
- // Checks all alignments
- for (int i = 0; i < columnAlignments.length; i++) {
- final String a = columnAlignments[i];
- if (a != null && !a.equals(ALIGN_LEFT) && !a.equals(ALIGN_CENTER)
- && !a.equals(ALIGN_RIGHT)) {
- throw new IllegalArgumentException("Column " + i
- + " aligment '" + a + "' is invalid");
- }
- }
-
// Resets the alignments
- final HashMap<Object, String> newCA = new HashMap<Object, String>();
+ final HashMap<Object, Align> newCA = new HashMap<Object, Align>();
int i = 0;
for (final Iterator<Object> it = visibleColumns.iterator(); it
.hasNext() && i < columnAlignments.length; i++) {
@@ -1034,13 +1149,13 @@ public class Table extends AbstractSelect implements Action.Container,
* @return the header for the specified column if it has one.
*/
public String getColumnHeader(Object propertyId) {
- if (getColumnHeaderMode() == COLUMN_HEADER_MODE_HIDDEN) {
+ if (getColumnHeaderMode() == ColumnHeaderMode.HIDDEN) {
return null;
}
String header = columnHeaders.get(propertyId);
- if ((header == null && getColumnHeaderMode() == COLUMN_HEADER_MODE_EXPLICIT_DEFAULTS_ID)
- || getColumnHeaderMode() == COLUMN_HEADER_MODE_ID) {
+ if ((header == null && getColumnHeaderMode() == ColumnHeaderMode.EXPLICIT_DEFAULTS_ID)
+ || getColumnHeaderMode() == ColumnHeaderMode.ID) {
header = propertyId.toString();
}
@@ -1073,9 +1188,9 @@ public class Table extends AbstractSelect implements Action.Container,
* the propertyID identifying the column.
* @return the specified column's alignment if it as one; null otherwise.
*/
- public String getColumnAlignment(Object propertyId) {
- final String a = columnAlignments.get(propertyId);
- return a == null ? ALIGN_LEFT : a;
+ public Align getColumnAlignment(Object propertyId) {
+ final Align a = columnAlignments.get(propertyId);
+ return a == null ? Align.LEFT : a;
}
/**
@@ -1083,8 +1198,8 @@ public class Table extends AbstractSelect implements Action.Container,
*
* <p>
* Throws IllegalArgumentException if the alignment is not one of the
- * following: {@link #ALIGN_LEFT}, {@link #ALIGN_CENTER} or
- * {@link #ALIGN_RIGHT}
+ * following: {@link Align#LEFT}, {@link Align#CENTER} or
+ * {@link Align#RIGHT}
* </p>
*
* @param propertyId
@@ -1092,17 +1207,8 @@ public class Table extends AbstractSelect implements Action.Container,
* @param alignment
* the desired alignment.
*/
- public void setColumnAlignment(Object propertyId, String alignment) {
-
- // Checks for valid alignments
- if (alignment != null && !alignment.equals(ALIGN_LEFT)
- && !alignment.equals(ALIGN_CENTER)
- && !alignment.equals(ALIGN_RIGHT)) {
- throw new IllegalArgumentException("Column alignment '" + alignment
- + "' is not supported.");
- }
-
- if (alignment == null || alignment.equals(ALIGN_LEFT)) {
+ public void setColumnAlignment(Object propertyId, Align alignment) {
+ if (alignment == null || alignment == Align.LEFT) {
columnAlignments.remove(propertyId);
} else {
columnAlignments.put(propertyId, alignment);
@@ -1397,7 +1503,7 @@ public class Table extends AbstractSelect implements Action.Container,
*
* @return the Value of property columnHeaderMode.
*/
- public int getColumnHeaderMode() {
+ public ColumnHeaderMode getColumnHeaderMode() {
return columnHeaderMode;
}
@@ -1407,10 +1513,12 @@ public class Table extends AbstractSelect implements Action.Container,
* @param columnHeaderMode
* the New value of property columnHeaderMode.
*/
- public void setColumnHeaderMode(int columnHeaderMode) {
- if (columnHeaderMode != this.columnHeaderMode
- && columnHeaderMode >= COLUMN_HEADER_MODE_HIDDEN
- && columnHeaderMode <= COLUMN_HEADER_MODE_EXPLICIT_DEFAULTS_ID) {
+ public void setColumnHeaderMode(ColumnHeaderMode columnHeaderMode) {
+ if (columnHeaderMode == null) {
+ throw new IllegalArgumentException(
+ "Column header mode can not be null");
+ }
+ if (columnHeaderMode != this.columnHeaderMode) {
this.columnHeaderMode = columnHeaderMode;
requestRepaint();
}
@@ -1750,7 +1858,7 @@ public class Table extends AbstractSelect implements Action.Container,
}
}
- final int headmode = getRowHeaderMode();
+ final RowHeaderMode headmode = getRowHeaderMode();
final boolean[] iscomponent = new boolean[cols];
for (int i = 0; i < cols; i++) {
iscomponent[i] = columnGenerators.containsKey(colids[i])
@@ -1771,7 +1879,7 @@ public class Table extends AbstractSelect implements Action.Container,
cells[CELL_KEY][i] = itemIdMapper.key(id);
if (headmode != ROW_HEADER_MODE_HIDDEN) {
switch (headmode) {
- case ROW_HEADER_MODE_INDEX:
+ case INDEX:
cells[CELL_HEADER][i] = String.valueOf(i + firstIndex + 1);
break;
default:
@@ -2070,17 +2178,17 @@ public class Table extends AbstractSelect implements Action.Container,
* @param mode
* the One of the modes listed above.
*/
- public void setRowHeaderMode(int mode) {
- if (ROW_HEADER_MODE_HIDDEN == mode) {
- rowCaptionsAreHidden = true;
- } else {
- rowCaptionsAreHidden = false;
- setItemCaptionMode(mode);
+ public void setRowHeaderMode(RowHeaderMode mode) {
+ if (mode != null) {
+ rowHeaderMode = mode;
+ if (mode != RowHeaderMode.HIDDEN) {
+ setItemCaptionMode(mode.getItemCaptionMode());
+ }
+ // Assures the visual refresh. No need to reset the page buffer
+ // before
+ // as the content has not changed, only the alignments.
+ refreshRenderedCells();
}
-
- // Assures the visual refresh. No need to reset the page buffer before
- // as the content has not changed, only the alignments.
- refreshRenderedCells();
}
/**
@@ -2089,9 +2197,8 @@ public class Table extends AbstractSelect implements Action.Container,
* @return the Row header mode.
* @see #setRowHeaderMode(int)
*/
- public int getRowHeaderMode() {
- return rowCaptionsAreHidden ? ROW_HEADER_MODE_HIDDEN
- : getItemCaptionMode();
+ public RowHeaderMode getRowHeaderMode() {
+ return rowHeaderMode;
}
/**
@@ -2928,7 +3035,7 @@ public class Table extends AbstractSelect implements Action.Container,
}
private boolean areColumnHeadersEnabled() {
- return getColumnHeaderMode() != COLUMN_HEADER_MODE_HIDDEN;
+ return getColumnHeaderMode() != ColumnHeaderMode.HIDDEN;
}
private void paintVisibleColumns(PaintTarget target) throws PaintException {
@@ -2959,8 +3066,9 @@ public class Table extends AbstractSelect implements Action.Container,
target.addAttribute("sortable", true);
}
}
- if (!ALIGN_LEFT.equals(getColumnAlignment(colId))) {
- target.addAttribute("align", getColumnAlignment(colId));
+ if (!Align.LEFT.equals(getColumnAlignment(colId))) {
+ target.addAttribute("align", getColumnAlignment(colId)
+ .toString());
}
paintColumnWidth(target, colId);
target.endTag("column");
@@ -3051,6 +3159,9 @@ public class Table extends AbstractSelect implements Action.Container,
if (start > cells[CELL_ITEMID].length || start < 0) {
start = 0;
}
+ if (end > cells[CELL_ITEMID].length) {
+ end = cells[CELL_ITEMID].length;
+ }
for (int indexInRowbuffer = start; indexInRowbuffer < end; indexInRowbuffer++) {
final Object itemId = cells[CELL_ITEMID][indexInRowbuffer];
@@ -3721,7 +3832,7 @@ public class Table extends AbstractSelect implements Action.Container,
*/
public boolean addContainerProperty(Object propertyId, Class<?> type,
Object defaultValue, String columnHeader, Resource columnIcon,
- String columnAlignment) throws UnsupportedOperationException {
+ Align columnAlignment) throws UnsupportedOperationException {
if (!this.addContainerProperty(propertyId, type, defaultValue)) {
return false;
}
@@ -5187,4 +5298,13 @@ public class Table extends AbstractSelect implements Action.Container,
return propertyValueConverters.get(propertyId);
}
+ @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/src/com/vaadin/ui/TreeTable.java b/src/com/vaadin/ui/TreeTable.java
index 43bc7a80fe..09417e1e16 100644
--- a/src/com/vaadin/ui/TreeTable.java
+++ b/src/com/vaadin/ui/TreeTable.java
@@ -22,7 +22,7 @@ import com.vaadin.data.util.HierarchicalContainer;
import com.vaadin.terminal.PaintException;
import com.vaadin.terminal.PaintTarget;
import com.vaadin.terminal.Resource;
-import com.vaadin.terminal.gwt.client.ui.VTreeTable;
+import com.vaadin.terminal.gwt.client.ui.VTreeTablePaintable;
import com.vaadin.ui.Tree.CollapseEvent;
import com.vaadin.ui.Tree.CollapseListener;
import com.vaadin.ui.Tree.ExpandEvent;
@@ -48,7 +48,7 @@ import com.vaadin.ui.treetable.HierarchicalContainerOrderedWrapper;
* share UI state in the container.
*/
@SuppressWarnings({ "serial" })
-@ClientWidget(VTreeTable.class)
+@ClientWidget(VTreeTablePaintable.class)
public class TreeTable extends Table implements Hierarchical {
private static final Logger logger = Logger.getLogger(TreeTable.class
@@ -454,7 +454,8 @@ public class TreeTable extends Table implements Hierarchical {
Object object = visibleColumns2[i];
if (hierarchyColumnId.equals(object)) {
target.addAttribute(
- VTreeTable.ATTRIBUTE_HIERARCHY_COLUMN_INDEX, i);
+ VTreeTablePaintable.ATTRIBUTE_HIERARCHY_COLUMN_INDEX,
+ i);
break;
}
}
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 60e4882044..1b37347ddd 100644
--- a/tests/integration_tests.xml
+++ b/tests/integration_tests.xml
@@ -7,20 +7,20 @@
<import file="../build/common.xml" />
<!-- Target deploying demo.war -->
- <fail unless="test.integration.server" message="test.integration.server must be set for integration tests to run"/>
-
- <fail unless="test.integration.user" message="test.integration.user must be set for integration tests to run"/>
- <fail unless="test.integration.antfile" message="test.integration.antfile must be set for integration tests to run"/>
+ <fail unless="test.integration.server" message="test.integration.server must be set for integration tests to run" />
+
+ <fail unless="test.integration.user" message="test.integration.user must be set for integration tests to run" />
+ <fail unless="test.integration.antfile" message="test.integration.antfile must be set for integration tests to run" />
<!-- Test with these browsers -->
<property name="test_browsers" value="winxp-firefox9" />
<!-- Path to key file. Default value -->
<property name="sshkey.file" value="id_dsa" />
-
+
<!-- path and name for demo.war to be deployed -->
- <property name="demo.war" value="demo.war"/>
-
+ <property name="demo.war" value="demo.war" />
+
<!-- Host running Testbench RC or Testbench Hub. Default value -->
<property name="com.vaadin.testbench.tester.host" value="127.0.0.1" />
@@ -36,7 +36,7 @@
<target name="integration-test-upload-demo">
<scp file="${demo.war}" todir="${user}@${test.integration.server}:integration-tests/servers/demo.war" keyfile="${sshkey.file}" passphrase="${passphrase}" />
</target>
-
+
<!-- Run basic integration test test -->
<target name="integration-test-servlet">
<fileset dir="integration-testscripts" id="html-test-files" includes="integration-test-${server-name}-servlet.html" />
@@ -50,11 +50,11 @@
<property name="testfiles" value="${testfiles}" />
<property name="test-output-dir" value="../build/integration-test-output/${server-name}" />
<property name="retries" value="0" />
-
+
<fileset dir="." includes="test.xml" />
</subant>
</target>
-
+
<target name="integration-test-theme">
<subant target="run-tests" failonerror="false" antfile="test.xml">
<property name="com.vaadin.testbench.lib.dir" value="${com.vaadin.testbench.lib.dir}" />
@@ -63,16 +63,16 @@
<property name="server.start.succeeded" value="1" />
<property name="testfiles" value="${testfiles-theme}" />
<property name="test-output-dir" value="../build/integration-test-output/${server-name}" />
-
+
<fileset dir="." includes="test.xml" />
</subant>
</target>
-
+
<!-- Run integration test on GAE -->
<target name="integration-test-test-GAE">
<fileset dir="integration-testscripts" id="html-test-files" includes="GoogleAppEngine/integration-test-GAE.html" />
<pathconvert pathsep=" " property="test-GAE" refid="html-test-files" />
-
+
<subant target="run-tests" failonerror="false" antfile="test.xml">
<property name="com.vaadin.testbench.lib.dir" value="${com.vaadin.testbench.lib.dir}" />
<property name="com.vaadin.testbench.tester.host" value="${com.vaadin.testbench.tester.host}" />
@@ -81,119 +81,123 @@
<property name="browsers" value="${test_browsers}" />
<property name="testfiles" value="${test-GAE}" />
<property name="test-output-dir" value="../build/integration-test-gae-output" />
-
+
<fileset dir="." includes="test.xml" />
</subant>
</target>
-
+
<target name="integration-test-deploy-to-GAE">
<sshexec host="${test.integration.server}" username="${user}" keyfile="${sshkey.file}" command="ant -f ${ant.hub} deploy-to-GAE" />
</target>
-
-
+
+
<target name="integration-test-tomcat7">
<antcall target="run-generic-integration-test">
- <param name="startDelay" value="300" />
+ <param name="startDelay" value="10" />
<param name="target-server" value="tomcat7" />
</antcall>
</target>
-
<target name="integration-test-tomcat5">
<antcall target="run-generic-integration-test">
- <param name="startDelay" value="300" />
+ <param name="startDelay" value="10" />
<param name="target-server" value="tomcat5" />
</antcall>
- </target>
-
+ </target>
+
<target name="integration-test-tomcat6">
<antcall target="run-generic-integration-test">
- <param name="startDelay" value="300" />
+ <param name="startDelay" value="10" />
<param name="target-server" value="tomcat6" />
</antcall>
- </target>
-
+ </target>
+
<target name="integration-test-jetty5">
<antcall target="run-generic-integration-test">
- <param name="startDelay" value="300" />
<param name="target-server" value="jetty5" />
</antcall>
</target>
-
+
<target name="integration-test-jetty6">
<antcall target="run-generic-integration-test">
- <param name="startDelay" value="300" />
<param name="target-server" value="jetty6" />
</antcall>
</target>
-
+
<target name="integration-test-jetty7">
<antcall target="run-generic-integration-test">
- <param name="startDelay" value="300" />
<param name="target-server" value="jetty7" />
</antcall>
</target>
-
+
+ <target name="integration-test-jetty8">
+ <antcall target="run-generic-integration-test">
+ <param name="target-server" value="jetty8" />
+ </antcall>
+ </target>
+
<target name="integration-test-jboss4">
<antcall target="run-generic-integration-test">
- <param name="startDelay" value="300" />
+ <param name="startDelay" value="10" />
<param name="target-server" value="jboss4" />
</antcall>
</target>
-
+
<target name="integration-test-jboss5">
<antcall target="run-generic-integration-test">
- <param name="startDelay" value="300" />
+ <param name="startDelay" value="10" />
<param name="target-server" value="jboss5" />
</antcall>
</target>
-
+
<target name="integration-test-jboss6">
<antcall target="run-generic-integration-test">
- <param name="startDelay" value="300" />
+ <param name="startDelay" value="10" />
<param name="target-server" value="jboss6" />
</antcall>
</target>
-
+
<target name="integration-test-jboss7">
<antcall target="run-generic-integration-test">
- <param name="startDelay" value="300" />
+ <param name="startDelay" value="10" />
<param name="target-server" value="jboss7" />
</antcall>
</target>
-
+
<target name="integration-test-glassfish2">
<antcall target="run-generic-integration-test">
- <param name="startDelay" value="300" />
+ <param name="startDelay" value="10" />
<param name="target-server" value="glassfish2" />
</antcall>
</target>
-
+
<target name="integration-test-glassfish3">
<antcall target="run-generic-integration-test">
- <param name="startDelay" value="300" />
+ <param name="startDelay" value="10" />
<param name="target-server" value="glassfish3" />
</antcall>
</target>
-
-
+
+
<target name="integration-test-liferay6">
<fileset dir="integration-testscripts" id="html-test-files" includes="Liferay-6/integration-test-liferay-6.0.5.html" />
<pathconvert pathsep=" " property="testfiles" refid="html-test-files" />
-
+
<fileset dir="integration-testscripts" id="html-theme-files" includes="Liferay-6/Liferay6-theme.html" />
<pathconvert pathsep=" " property="testfiles-theme" refid="html-theme-files" />
-
-
+
+
<antcall target="run-generic-integration-test">
+ <param name="startDelay" value="600" />
<param name="target-server" value="liferay6" />
</antcall>
</target>
-
+
<target name="integration-test-liferay5">
<fileset dir="integration-testscripts" id="html-test-files" includes="Liferay-5/integration-test-liferay-5.2.3-portlet2.html" />
<pathconvert pathsep=" " property="testfiles" refid="html-test-files" />
-
+
<antcall target="run-generic-integration-test">
+ <param name="startDelay" value="600" />
<param name="target-server" value="liferay5" />
</antcall>
</target>
@@ -201,65 +205,77 @@
<target name="integration-test-liferay6ee">
<fileset dir="integration-testscripts" id="html-test-files" includes="Liferay-6EE/integration-test-liferay-6ee.html" />
<pathconvert pathsep=" " property="testfiles" refid="html-test-files" />
-
+
<fileset dir="integration-testscripts" id="html-theme-files" includes="Liferay-6EE/Liferay6EE-theme.html" />
<pathconvert pathsep=" " property="testfiles-theme" refid="html-theme-files" />
-
+
<antcall target="run-generic-integration-test">
+ <param name="startDelay" value="600" />
<param name="target-server" value="liferay6ee" />
- </antcall>
+ </antcall>
</target>
-
+
<target name="integration-test-gatein3">
<fileset dir="integration-testscripts" id="html-test-files" includes="GateIn-3/integration-test-GateIn-3.1.0-portlet2.html" />
<pathconvert pathsep=" " property="testfiles" refid="html-test-files" />
<antcall target="run-generic-integration-test">
+ <param name="startDelay" value="600" />
<param name="test_browsers" value="winxp-firefox36" />
<param name="target-server" value="gatein3" />
</antcall>
</target>
-
+
<target name="integration-test-exo3">
<fileset dir="integration-testscripts" id="html-test-files" includes="eXo-3/integration-test-eXo-3.0.3-portlet2.html" />
<pathconvert pathsep=" " property="testfiles" refid="html-test-files" />
<antcall target="run-generic-integration-test">
+ <param name="startDelay" value="600" />
<param name="test_browsers" value="winxp-firefox36" />
<param name="target-server" value="exo3" />
</antcall>
</target>
-
+
<target name="integration-test-weblogic9">
<antcall target="run-generic-integration-test">
+ <param name="startDelay" value="600" />
<param name="target-port" value="7001" />
<param name="target-server" value="weblogic9" />
</antcall>
</target>
-
+
<target name="integration-test-weblogic10">
<antcall target="run-generic-integration-test">
+ <param name="startDelay" value="600" />
<param name="target-port" value="7001" />
<param name="target-server" value="weblogic10" />
</antcall>
</target>
-
-
+
+ <target name="integration-test-weblogic12">
+ <antcall target="run-generic-integration-test">
+ <param name="startDelay" value="600" />
+ <param name="target-port" value="7001" />
+ <param name="target-server" value="weblogic12" />
+ </antcall>
+ </target>
+
<target name="integration-test-weblogicPortal">
<fileset dir="integration-testscripts" id="html-test-files" includes="weblogic-portal/integration-test-WebLogic-Portal-10.3.2-portlet2.html" />
<pathconvert pathsep=" " property="testfiles" refid="html-test-files" />
<antcall target="run-generic-integration-test">
+ <param name="startDelay" value="600" />
<param name="target-port" value="7001" />
<param name="target-server" value="weblogicportal" />
</antcall>
</target>
-
+
<target name="integration-test-GAE">
- <antcall target="integration-test-deploy-to-GAE"/>
+ <antcall target="integration-test-deploy-to-GAE" />
<antcall target="integration-test-test-GAE" />
</target>
-
+
<!-- Upload demo, clean error screenshots and test deployment on all servers -->
<target name="integration-test-all" depends="common.init-deps">
-
<parallel>
<antcontrib:trycatch property="tried">
<try>
@@ -268,22 +284,21 @@
<antcall target="integration-test-get-lock" />
<echo message="Got lock" />
<antcall target="integration-test-upload-demo" />
-
+
<antcall target="run-integration-test">
- <param name="target-server" value="GAE"/>
+ <param name="target-server" value="GAE" />
</antcall>
-
+
<antcall target="integration-test-clean" />
<echo message="Getting lock" />
<antcall target="integration-test-release-lock" />
<echo message="Lock released" />
-
+
</try>
<catch>
<echo message="Uploading of demo.war failed. ${tried}" />
</catch>
</antcontrib:trycatch>
-
<antcall target="integration-test-liferay6" />
<antcall target="integration-test-liferay6ee" />
<antcall target="integration-test-exo3" />
@@ -291,6 +306,7 @@
<antcall target="integration-test-liferay5" />
<antcall target="integration-test-weblogic9" />
<antcall target="integration-test-weblogic10" />
+ <antcall target="integration-test-weblogic12" />
<antcall target="integration-test-gatein3" />
<antcall target="integration-test-glassfish2" />
<antcall target="integration-test-glassfish3" />
@@ -301,26 +317,26 @@
<antcall target="integration-test-jetty5" />
<antcall target="integration-test-jetty6" />
<antcall target="integration-test-jetty7" />
+ <antcall target="integration-test-jetty8" />
<antcall target="integration-test-tomcat5" />
<antcall target="integration-test-tomcat6" />
<antcall target="integration-test-tomcat7" />
-
+
</parallel>
-
+
</target>
-
+
<target name="do-run-generic-test">
<property name="target-host" value="${target-server}.devnet.vaadin.com" />
<property name="target-port" value="8080" />
-
<antcontrib:if>
<isset property="startDelay" />
<then>
<antcontrib:math result="sleepTime" datatype="int">
<op op="rint">
<op op="*">
- <num value="${startDelay}"/>
- <op op="random"/>
+ <num value="${startDelay}" />
+ <op op="random" />
</op>
</op>
</antcontrib:math>
@@ -334,7 +350,7 @@
<include name="*" />
</fileset>
</scp>
-
+
<!-- trycatch probably not needed any more as it just fails with the original message and doesn't do anything in the finally block -->
<antcontrib:trycatch property="error_message">
<try>
@@ -346,14 +362,14 @@
</antcall>
<scp file="${demo.war}" todir="${user}@${target-host}:demo.war" keyfile="${sshkey.file}" trust="yes" passphrase="${passphrase}" />
-
+
<!-- timeout in 15 minutes -->
<sshexec host="${target-host}" outputproperty="start-output" timeout="900000" username="${user}" keyfile="${sshkey.file}" trust="yes" command="ant -f deploy.xml startup-and-deploy" failonerror="false" />
<antcall target="echo-prefix">
<param name="prefix" value="${target-server}: " />
<param name="message" value="${start-output}" />
</antcall>
-
+
<fail message="${start-output}">
<condition>
<not>
@@ -367,7 +383,7 @@
<param name="server-name" value="${target-server}" />
<param name="deployment.url" value="http://${target-host}:${target-port}" />
</antcall>
-
+
<!-- Run theme tests in all browsers if there's a property with the test files -->
<antcontrib:if>
<isset property="testfiles-theme" />
@@ -380,7 +396,7 @@
</antcontrib:if>
<!-- timeout in five minutes -->
- <sshexec host="${target-host}" outputproperty="stop-output" timeout="300000" username="${user}" keyfile="${sshkey.file}" trust="yes" command="ant -f deploy.xml shutdown-and-cleanup" failonerror="false" />
+ <sshexec host="${target-host}" outputproperty="stop-output" timeout="600000" username="${user}" keyfile="${sshkey.file}" trust="yes" command="ant -f deploy.xml shutdown-and-cleanup" failonerror="false" />
<antcall target="echo-prefix">
<param name="prefix" value="${target-server}: " />
<param name="message" value="${stop-output}" />
@@ -391,12 +407,12 @@
</catch>
</antcontrib:trycatch>
</target>
-
+
<target name="echo-prefix">
<antcontrib:propertyregex property="message-prefixed" input="${prefix}${message}" regexp="\n" replace="\0${prefix}" global="true" defaultValue="${prefix}${message}" />
<echo message="${message-prefixed}" />
</target>
-
+
<target name="run-generic-integration-test">
<concat>##teamcity[testStarted name='${target-server}' flowId='${target-server}']</concat>
<antcontrib:trycatch property="tried">
@@ -412,20 +428,20 @@
</catch>
</antcontrib:trycatch>
<concat>##teamcity[testFinished name='${target-server}' flowId='${target-server}']"</concat>
- </target>
+ </target>
<target name="teamcity-escape">
<property name="returnTo" value="return" />
-
+
<!-- Should also perform other escaping (\u0085, \u2028 and \u2029) - see http://confluence.jetbrains.net/display/TCD65/Build+Script+Interaction+with+TeamCity -->
<!-- Immutable properties -> needs to create a new one every time -->
<antcontrib:propertyregex property="details-escaped1" input="${message}" regexp="['|\[\]]" replace="|\0" global="true" defaultValue="${message}" />
<antcontrib:propertyregex property="details-escaped2" input="${details-escaped1}" regexp="\n" replace="|n" global="true" defaultValue="${details-escaped1}" />
<antcontrib:propertyregex property="details-escaped3" input="${details-escaped2}" regexp="\r" replace="|r" global="true" defaultValue="${details-escaped2}" />
-
+
<property name="${returnTo}" value="${details-escaped3}" />
</target>
-
+
<target name="run-integration-test">
<concat>##teamcity[testStarted name='${target-server}' flowId='${target-server}']</concat>
<antcontrib:trycatch property="tried">
@@ -442,15 +458,15 @@
</antcontrib:trycatch>
<concat>##teamcity[testFinished name='${target-server}' flowId='${target-server}']"</concat>
</target>
-
+
<target name="integration-test-get-lock">
<sshexec host="${test.integration.server}" username="${user}" keyfile="${sshkey.file}" command="ant -f ${ant.hub} get-lock" />
</target>
-
+
<target name="integration-test-release-lock">
<sshexec host="${test.integration.server}" username="${user}" keyfile="${sshkey.file}" command="ant -f ${ant.hub} release-lock" />
</target>
-
+
<!-- Remove demo.war -->
<target name="integration-test-clean">
<sshexec host="${test.integration.server}" username="${user}" keyfile="${sshkey.file}" command="ant -f ${ant.hub} clean" />
diff --git a/tests/testbench/com/vaadin/tests/VaadinClasses.java b/tests/server-side/com/vaadin/tests/VaadinClasses.java
index cb430d9e3a..707fc020b6 100644
--- a/tests/testbench/com/vaadin/tests/VaadinClasses.java
+++ b/tests/server-side/com/vaadin/tests/VaadinClasses.java
@@ -18,7 +18,6 @@ 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;
@@ -115,11 +114,13 @@ public class VaadinClasses {
}
@SuppressWarnings({ "unchecked", "rawtypes" })
- public static List<Class<? extends AbstractComponentTest<?>>> getBasicComponentTests() {
+ public static List<Class<?>> getBasicComponentTests() {
try {
- return (List) findClasses(AbstractComponentTest.class,
+ // 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 (IOException e) {
+ } catch (Exception e) {
e.printStackTrace();
return null;
}
diff --git a/tests/testbench/com/vaadin/tests/components/datefield/ResolutionTest.java b/tests/server-side/com/vaadin/tests/server/component/datefield/ResolutionTest.java
index e54e1cd418..88dceca9e7 100644
--- a/tests/testbench/com/vaadin/tests/components/datefield/ResolutionTest.java
+++ b/tests/server-side/com/vaadin/tests/server/component/datefield/ResolutionTest.java
@@ -1,4 +1,4 @@
-package com.vaadin.tests.components.datefield;
+package com.vaadin.tests.server.component.datefield;
import java.util.ArrayList;
diff --git a/tests/server-side/com/vaadin/tests/server/component/table/TableColumnAlignments.java b/tests/server-side/com/vaadin/tests/server/component/table/TableColumnAlignments.java
index 04f436f5c4..299f9c79d4 100644
--- a/tests/server-side/com/vaadin/tests/server/component/table/TableColumnAlignments.java
+++ b/tests/server-side/com/vaadin/tests/server/component/table/TableColumnAlignments.java
@@ -5,6 +5,7 @@ import static org.junit.Assert.assertArrayEquals;
import org.junit.Test;
import com.vaadin.ui.Table;
+import com.vaadin.ui.Table.Align;
public class TableColumnAlignments {
@@ -15,7 +16,7 @@ public class TableColumnAlignments {
properties, 10);
Object[] expected = new Object[properties];
for (int i = 0; i < properties; i++) {
- expected[i] = Table.ALIGN_LEFT;
+ expected[i] = Align.LEFT;
}
org.junit.Assert.assertArrayEquals("getColumnAlignments", expected,
t.getColumnAlignments());
@@ -27,9 +28,8 @@ public class TableColumnAlignments {
int properties = 5;
Table t = TableGenerator
.createTableWithDefaultContainer(properties, 10);
- String[] explicitAlignments = new String[] { Table.ALIGN_CENTER,
- Table.ALIGN_LEFT, Table.ALIGN_RIGHT, Table.ALIGN_RIGHT,
- Table.ALIGN_LEFT };
+ Align[] explicitAlignments = new Align[] { Align.CENTER, Align.LEFT,
+ Align.RIGHT, Align.RIGHT, Align.LEFT };
t.setColumnAlignments(explicitAlignments);
@@ -40,28 +40,10 @@ public class TableColumnAlignments {
@Test
public void invalidColumnAlignmentStrings() {
Table t = TableGenerator.createTableWithDefaultContainer(3, 7);
- String[] defaultAlignments = new String[] { Table.ALIGN_LEFT,
- Table.ALIGN_LEFT, Table.ALIGN_LEFT };
+ Align[] defaultAlignments = new Align[] { Align.LEFT, Align.LEFT,
+ Align.LEFT };
try {
- t.setColumnAlignments(new String[] { "a", "b", "c" });
- junit.framework.Assert
- .fail("No exception thrown for invalid array length");
- } catch (IllegalArgumentException e) {
- // Ok, expected
- }
-
- assertArrayEquals("Invalid change affected alignments",
- defaultAlignments, t.getColumnAlignments());
-
- }
-
- @Test
- public void invalidColumnAlignmentString() {
- Table t = TableGenerator.createTableWithDefaultContainer(3, 7);
- String[] defaultAlignments = new String[] { Table.ALIGN_LEFT,
- Table.ALIGN_LEFT, Table.ALIGN_LEFT };
- try {
- t.setColumnAlignment("Property 1", "a");
+ t.setColumnAlignments(new Align[] { Align.RIGHT, Align.RIGHT });
junit.framework.Assert
.fail("No exception thrown for invalid array length");
} catch (IllegalArgumentException e) {
@@ -76,10 +58,10 @@ public class TableColumnAlignments {
@Test
public void columnAlignmentForPropertyNotInContainer() {
Table t = TableGenerator.createTableWithDefaultContainer(3, 7);
- String[] defaultAlignments = new String[] { Table.ALIGN_LEFT,
- Table.ALIGN_LEFT, Table.ALIGN_LEFT };
+ Align[] defaultAlignments = new Align[] { Align.LEFT, Align.LEFT,
+ Align.LEFT };
try {
- t.setColumnAlignment("Property 1200", Table.ALIGN_LEFT);
+ t.setColumnAlignment("Property 1200", Align.LEFT);
// FIXME: Uncomment as there should be an exception (#6475)
// junit.framework.Assert
// .fail("No exception thrown for property not in container");
@@ -100,12 +82,11 @@ public class TableColumnAlignments {
@Test
public void invalidColumnAlignmentsLength() {
Table t = TableGenerator.createTableWithDefaultContainer(7, 7);
- String[] defaultAlignments = new String[] { Table.ALIGN_LEFT,
- Table.ALIGN_LEFT, Table.ALIGN_LEFT, Table.ALIGN_LEFT,
- Table.ALIGN_LEFT, Table.ALIGN_LEFT, Table.ALIGN_LEFT };
+ Align[] defaultAlignments = new Align[] { Align.LEFT, Align.LEFT,
+ Align.LEFT, Align.LEFT, Align.LEFT, Align.LEFT, Align.LEFT };
try {
- t.setColumnAlignments(new String[] { Table.ALIGN_LEFT });
+ t.setColumnAlignments(new Align[] { Align.LEFT });
junit.framework.Assert
.fail("No exception thrown for invalid array length");
} catch (IllegalArgumentException e) {
@@ -115,7 +96,7 @@ public class TableColumnAlignments {
defaultAlignments, t.getColumnAlignments());
try {
- t.setColumnAlignments(new String[] {});
+ t.setColumnAlignments(new Align[] {});
junit.framework.Assert
.fail("No exception thrown for invalid array length");
} catch (IllegalArgumentException e) {
@@ -125,10 +106,9 @@ public class TableColumnAlignments {
defaultAlignments, t.getColumnAlignments());
try {
- t.setColumnAlignments(new String[] { Table.ALIGN_LEFT,
- Table.ALIGN_LEFT, Table.ALIGN_LEFT, Table.ALIGN_LEFT,
- Table.ALIGN_LEFT, Table.ALIGN_LEFT, Table.ALIGN_LEFT,
- Table.ALIGN_LEFT });
+ t.setColumnAlignments(new Align[] { Align.LEFT, Align.LEFT,
+ Align.LEFT, Align.LEFT, Align.LEFT, Align.LEFT, Align.LEFT,
+ Align.LEFT });
junit.framework.Assert
.fail("No exception thrown for invalid array length");
} catch (IllegalArgumentException e) {
@@ -144,13 +124,11 @@ public class TableColumnAlignments {
int properties = 5;
Table t = TableGenerator
.createTableWithDefaultContainer(properties, 10);
- String[] explicitAlignments = new String[] { Table.ALIGN_CENTER,
- Table.ALIGN_LEFT, Table.ALIGN_RIGHT, Table.ALIGN_RIGHT,
- Table.ALIGN_LEFT };
+ Align[] explicitAlignments = new Align[] { Align.CENTER, Align.LEFT,
+ Align.RIGHT, Align.RIGHT, Align.LEFT };
- String[] currentAlignments = new String[] { Table.ALIGN_LEFT,
- Table.ALIGN_LEFT, Table.ALIGN_LEFT, Table.ALIGN_LEFT,
- Table.ALIGN_LEFT };
+ Align[] currentAlignments = new Align[] { Align.LEFT, Align.LEFT,
+ Align.LEFT, Align.LEFT, Align.LEFT };
for (int i = 0; i < properties; i++) {
t.setColumnAlignment("Property " + i, explicitAlignments[i]);
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();
+ }
+
+}
diff --git a/tests/test.xml b/tests/test.xml
index d4a8f5918c..9d060c9a29 100644
--- a/tests/test.xml
+++ b/tests/test.xml
@@ -94,7 +94,7 @@
<include name="**/**.java" />
</fileset>
- <antcontrib:for threadCount="40" parallel="true" keepgoing="true" param="target">
+ <antcontrib:for threadCount="30" parallel="true" keepgoing="true" param="target">
<path>
<fileset refid="tests-fileset" />
</path>
diff --git a/src/com/vaadin/launcher/util/BrowserLauncher.java b/tests/testbench/com/vaadin/launcher/util/BrowserLauncher.java
index 55692cb251..55692cb251 100644
--- a/src/com/vaadin/launcher/util/BrowserLauncher.java
+++ b/tests/testbench/com/vaadin/launcher/util/BrowserLauncher.java
diff --git a/tests/testbench/com/vaadin/tests/Components.java b/tests/testbench/com/vaadin/tests/Components.java
index 414c97c951..6bc6860607 100644
--- a/tests/testbench/com/vaadin/tests/Components.java
+++ b/tests/testbench/com/vaadin/tests/Components.java
@@ -33,7 +33,7 @@ import com.vaadin.ui.VerticalLayout;
public class Components extends Application.LegacyApplication {
private static final Object CAPTION = "c";
- private Map<Class<? extends AbstractComponentTest<?>>, String> tests = new HashMap<Class<? extends AbstractComponentTest<?>>, String>();
+ private Map<Class<? extends AbstractComponentTest>, String> tests = new HashMap<Class<? extends AbstractComponentTest>, String>();
private Tree naviTree;
private HorizontalSplitPanel sp;
private LegacyWindow mainWindow;
@@ -42,10 +42,9 @@ public class Components extends Application.LegacyApplication {
private List<Class<? extends Component>> componentsWithoutTests = new ArrayList<Class<? extends Component>>();
{
- 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<Class<? extends Component>> componentsWithoutTest = VaadinClasses
@@ -172,7 +171,7 @@ public class Components extends Application.LegacyApplication {
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 });
@@ -227,13 +226,13 @@ public class Components extends Application.LegacyApplication {
}
@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 ..
@@ -250,9 +249,9 @@ public class Components extends Application.LegacyApplication {
}
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/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
@@ -102,11 +102,15 @@
<td>enter</td>
</tr>
<tr>
+ <td>pause</td>
+ <td>100</td>
+ <td></td>
+</tr>
+<tr>
<td>assertText</td>
<td>vaadin=runcomvaadintestscomponentscomboboxComboBoxIdenticalItems::PID_SLog_row_0</td>
<td>4. Item one-1 selected</td>
</tr>
-
</tbody></table>
</body>
</html>
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 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="selenium.base" href="" />
+<title>New Test</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">New Test</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.components.datefield.DatePopupStyleName?&amp;restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentsdatefieldDatePopupStyleName::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VPopupCalendar[0]#popupButton</td>
+ <td>4,10</td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td>styled-popup</td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
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 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="selenium.base" href="" />
+<title>New Test</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">New Test</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.components.datefield.WidthRecalculationOnEnableStateChange?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentsdatefieldWidthRecalculationOnEnableStateChange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td>disabled</td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentsdatefieldWidthRecalculationOnEnableStateChange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td>enabled</td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentsdatefieldWidthRecalculationOnEnableStateChange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td>readonly</td>
+</tr>
+</tbody></table>
+</body>
+</html>
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.<br><br>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 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="selenium.base" href="" />
+<title>New Test</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">New Test</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.components.formlayout.FormLayoutCaptionStyles?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertCSSClass</td>
+ <td>vaadin=runcomvaadintestscomponentsformlayoutFormLayoutCaptionStyles::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VFormLayout[0]/domChild[0]/domChild[1]/domChild[2]/domChild[0]/domChild[0]</td>
+ <td>v-caption-bold</td>
+</tr>
+<tr>
+ <td>assertCSSClass</td>
+ <td>vaadin=runcomvaadintestscomponentsformlayoutFormLayoutCaptionStyles::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[1]</td>
+ <td>bold</td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentsformlayoutFormLayoutCaptionStyles::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertNotCSSClass</td>
+ <td>vaadin=runcomvaadintestscomponentsformlayoutFormLayoutCaptionStyles::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[1]</td>
+ <td>bold</td>
+</tr>
+<tr>
+ <td>assertNotCSSClass</td>
+ <td>vaadin=runcomvaadintestscomponentsformlayoutFormLayoutCaptionStyles::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VFormLayout[0]/domChild[0]/domChild[1]/domChild[2]/domChild[0]/domChild[0]</td>
+ <td>v-caption-bold</td>
+</tr>
+</tbody></table>
+</body>
+</html>
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 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="selenium.base" href="" />
+<title>New Test</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">New Test</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.components.orderedlayout.OrderedLayoutCases?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentsorderedlayoutOrderedLayoutCases::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td>1-undefined-without-relative</td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentsorderedlayoutOrderedLayoutCases::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td>2-undefined-with-relative</td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentsorderedlayoutOrderedLayoutCases::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td>3-fixed-with-overflow</td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentsorderedlayoutOrderedLayoutCases::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[3]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td>4-fixed-with-extra-space</td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentsorderedlayoutOrderedLayoutCases::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[7]/VButton[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<!-- Going in the reverse direction from here to avoid some bugs where state is not properly updated -->
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td>8-undefined-relative-height</td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentsorderedlayoutOrderedLayoutCases::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[6]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td>7-fixed-relative-height</td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentsorderedlayoutOrderedLayoutCases::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[5]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td>6-multiple-expands</td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentsorderedlayoutOrderedLayoutCases::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[4]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td>5-expand-with-alignment</td>
+</tr>
+</tbody></table>
+</body>
+</html>
diff --git a/tests/testbench/com/vaadin/tests/components/orderedlayout/OrderedLayoutCases.java b/tests/testbench/com/vaadin/tests/components/orderedlayout/OrderedLayoutCases.java
index 85cc6ca5e1..447b5b4be6 100644
--- a/tests/testbench/com/vaadin/tests/components/orderedlayout/OrderedLayoutCases.java
+++ b/tests/testbench/com/vaadin/tests/components/orderedlayout/OrderedLayoutCases.java
@@ -12,17 +12,21 @@ import com.vaadin.tests.components.AbstractTestRoot;
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 AbstractTestRoot {
- 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) {
@@ -102,18 +106,24 @@ public class OrderedLayoutCases extends AbstractTestRoot {
}
private AbstractOrderedLayout currentLayout;
+ private HorizontalLayout sizeBar;
@Override
protected void setup(WrappedRequest request) {
- TestUtils.injectCSS(getRoot(),
- ".showBorders {border: 1px solid black};");
+ TestUtils
+ .injectCSS(
+ getRoot(),
+ ".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",
@@ -130,6 +140,20 @@ public class OrderedLayoutCases extends AbstractTestRoot {
.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) {
@@ -146,7 +170,7 @@ public class OrderedLayoutCases extends AbstractTestRoot {
newLayout.addComponent(currentLayout
.getComponent(0));
}
- newLayout.setStyleName("showBorders");
+ newLayout.setStyleName("theLayout");
newLayout.setHeight(currentLayout.getHeight(),
currentLayout.getHeightUnits());
@@ -158,6 +182,112 @@ public class OrderedLayoutCases extends AbstractTestRoot {
}
}, "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);
+ // Alignment: bottom left to right child
+ setChildState(2, 4, 7);
+ }
+ }));
+
+ 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);
+ // Alignment: bottom left to right child
+ setChildState(2, 4, 7);
+ }
+ }));
+
+ caseBar.setSpacing(true);
+
+ addComponent(caseBar);
addComponent(sizeBar);
addComponent(currentLayout);
@@ -167,6 +297,34 @@ public class OrderedLayoutCases extends AbstractTestRoot {
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<Object>(select.getItemIds()).get(value));
+ }
+
private static NativeSelect createSimpleSelector(String caption,
ValueChangeListener listener, String... values) {
return createSimpleSelector(caption, listener, Arrays.asList(values),
@@ -185,14 +343,13 @@ public class OrderedLayoutCases extends AbstractTestRoot {
}
@Override
- protected String getTestDescription() {
- return "Tester application for exploring how Horizontal/VerticalLayout reacts to various settings ";
+ protected Integer getTicketNumber() {
+ return null;
}
@Override
- protected Integer getTicketNumber() {
- // TODO Auto-generated method stub
- return null;
+ protected String getTestDescription() {
+ return "Tester application for exploring how Horizontal/VerticalLayout reacts to various settings ";
}
}
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 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="selenium.base" href="" />
+<title>New Test</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">New Test</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.components.orderedlayout.VerticalLayoutTest?restartApplication</td>
+ <td></td>
+</tr>
+<!--Hide event log-->
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::PID_Smenu#item1</td>
+ <td>28,5</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::Root/VOverlay[0]/VMenuBar[0]#item0</td>
+ <td>30,8</td>
+</tr>
+<!--Add components-->
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::PID_Smenu#item0</td>
+ <td>41,8</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::Root/VOverlay[0]/VMenuBar[0]#item3</td>
+ <td>84,6</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::Root/VOverlay[1]/VMenuBar[0]#item0</td>
+ <td>43,6</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::Root/VOverlay[2]/VMenuBar[0]#item0</td>
+ <td>68,8</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::Root/VOverlay[3]/VMenuBar[0]#item0</td>
+ <td>30,11</td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td>auto-auto-one-button</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::PID_Smenu#item0</td>
+ <td>35,11</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::Root/VOverlay[0]/VMenuBar[0]#item3</td>
+ <td>85,5</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::Root/VOverlay[1]/VMenuBar[0]#item0</td>
+ <td>83,3</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::Root/VOverlay[2]/VMenuBar[0]#item1</td>
+ <td>28,7</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::Root/VOverlay[3]/VMenuBar[0]#item1</td>
+ <td>40,10</td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td>auto-auto-two-buttons</td>
+</tr>
+<!--Component 0 -> 100%-->
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::PID_Smenu#item0</td>
+ <td>42,6</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::Root/VOverlay[0]/VMenuBar[0]#item3</td>
+ <td>77,6</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::Root/VOverlay[1]/VMenuBar[0]#item2</td>
+ <td>115,7</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::Root/VOverlay[2]/VMenuBar[0]#item0</td>
+ <td>72,8</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::Root/VOverlay[3]/VMenuBar[0]#item4</td>
+ <td>14,2</td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td>auto-auto-two-buttons-equal-width</td>
+</tr>
+<!--Component 1 -> 200px height-->
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::PID_Smenu#item0</td>
+ <td>22,9</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::Root/VOverlay[0]/VMenuBar[0]#item3</td>
+ <td>117,9</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::Root/VOverlay[1]/VMenuBar[0]#item3</td>
+ <td>104,8</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::Root/VOverlay[2]/VMenuBar[0]#item1</td>
+ <td>74,12</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::Root/VOverlay[3]/VMenuBar[0]#item2</td>
+ <td>23,8</td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td>auto-auto-two-buttons-lower-higher</td>
+</tr>
+<!--Back to what we had before-->
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::PID_Smenu#item0</td>
+ <td>24,11</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::Root/VOverlay[0]/VMenuBar[0]#item3</td>
+ <td>104,12</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::Root/VOverlay[1]/VMenuBar[0]#item2</td>
+ <td>114,10</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::Root/VOverlay[2]/VMenuBar[0]#item0</td>
+ <td>87,11</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::Root/VOverlay[3]/VMenuBar[0]#item0</td>
+ <td>17,8</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::PID_Smenu#item0</td>
+ <td>28,3</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::Root/VOverlay[0]/VMenuBar[0]#item3</td>
+ <td>77,8</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::Root/VOverlay[1]/VMenuBar[0]#item3</td>
+ <td>96,6</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::Root/VOverlay[2]/VMenuBar[0]#item1</td>
+ <td>75,10</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentsorderedlayoutVerticalLayoutTest::Root/VOverlay[3]/VMenuBar[0]#item0</td>
+ <td>19,3</td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td>auto-auto-two-buttons</td>
+</tr>
+</tbody></table>
+</body>
+</html>
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..3b0234d805
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/components/table/ScrollDetachSynchronization.java
@@ -0,0 +1,88 @@
+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;
+
+public class ScrollDetachSynchronization extends TestBase {
+
+ @Override
+ public void setup() {
+ getMainWindow().setContent(buildLayout());
+ }
+
+ @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 8540e39c8c..bce96ebced 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);
+ }
LegacyWindow 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 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="selenium.base" href="" />
+<title>New Test</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">New Test</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.components.table.TableRepaintWhenMadeVisibile?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentstableTableRepaintWhenMadeVisibile::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.components.table.TableRepaintWhenMadeVisibile</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentstableTableRepaintWhenMadeVisibile::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td>hidden-then-shown</td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
diff --git a/tests/testbench/com/vaadin/tests/components/table/Tables.java b/tests/testbench/com/vaadin/tests/components/table/Tables.java
index afdf72bb83..3b13c9136b 100644
--- a/tests/testbench/com/vaadin/tests/components/table/Tables.java
+++ b/tests/testbench/com/vaadin/tests/components/table/Tables.java
@@ -15,8 +15,10 @@ import com.vaadin.ui.Button;
import com.vaadin.ui.Label;
import com.vaadin.ui.Label.ContentMode;
import com.vaadin.ui.Table;
+import com.vaadin.ui.Table.Align;
import com.vaadin.ui.Table.CellStyleGenerator;
import com.vaadin.ui.Table.ColumnGenerator;
+import com.vaadin.ui.Table.ColumnHeaderMode;
import com.vaadin.ui.Table.ColumnResizeEvent;
import com.vaadin.ui.Table.ColumnResizeListener;
import com.vaadin.ui.Table.FooterClickEvent;
@@ -25,6 +27,7 @@ import com.vaadin.ui.Table.GeneratedRow;
import com.vaadin.ui.Table.HeaderClickEvent;
import com.vaadin.ui.Table.HeaderClickListener;
import com.vaadin.ui.Table.RowGenerator;
+import com.vaadin.ui.Table.RowHeaderMode;
public class Tables<T extends Table> extends AbstractSelectTestCase<T>
implements ItemClickListener, HeaderClickListener, FooterClickListener,
@@ -42,9 +45,9 @@ public class Tables<T extends Table> extends AbstractSelectTestCase<T>
}
/* COMMANDS */
- private Command<T, String> columnAlignmentCommand = new Command<T, String>() {
+ private Command<T, Align> columnAlignmentCommand = new Command<T, Align>() {
- public void execute(T c, String alignment, Object propertyId) {
+ public void execute(T c, Align alignment, Object propertyId) {
c.setColumnAlignment(propertyId, alignment);
}
@@ -108,10 +111,10 @@ public class Tables<T extends Table> extends AbstractSelectTestCase<T>
}
};
- protected Command<T, Integer> rowHeaderModeCommand = new Command<T, Integer>() {
+ protected Command<T, RowHeaderMode> rowHeaderModeCommand = new Command<T, RowHeaderMode>() {
- public void execute(Table c, Integer value, Object data) {
- if (value == Table.ROW_HEADER_MODE_PROPERTY) {
+ public void execute(Table c, RowHeaderMode value, Object data) {
+ if (value == RowHeaderMode.PROPERTY) {
c.setItemCaptionPropertyId("Property 3");
}
c.setRowHeaderMode(value);
@@ -135,7 +138,7 @@ public class Tables<T extends Table> extends AbstractSelectTestCase<T>
protected Command<T, Object> alignColumnLeftCommand = new Command<T, Object>() {
public void execute(T c, Object propertyId, Object data) {
- c.setColumnAlignment(propertyId, (String) data);
+ c.setColumnAlignment(propertyId, (Align) data);
}
};
@@ -174,9 +177,9 @@ public class Tables<T extends Table> extends AbstractSelectTestCase<T>
}
};
- private Command<T, Integer> columnHeaderModeCommand = new Command<T, Integer>() {
+ private Command<T, ColumnHeaderMode> columnHeaderModeCommand = new Command<T, ColumnHeaderMode>() {
- public void execute(T c, Integer columnHeaderMode, Object data) {
+ public void execute(T c, ColumnHeaderMode columnHeaderMode, Object data) {
c.setColumnHeaderMode(columnHeaderMode);
}
@@ -477,13 +480,12 @@ public class Tables<T extends Table> extends AbstractSelectTestCase<T>
}
private void createColumnHeaderMode(String category) {
- LinkedHashMap<String, Integer> columnHeaderModeOptions = new LinkedHashMap<String, Integer>();
- columnHeaderModeOptions.put("Hidden", Table.COLUMN_HEADER_MODE_HIDDEN);
- columnHeaderModeOptions.put("Id", Table.COLUMN_HEADER_MODE_ID);
- columnHeaderModeOptions.put("Explicit",
- Table.COLUMN_HEADER_MODE_EXPLICIT);
+ LinkedHashMap<String, ColumnHeaderMode> columnHeaderModeOptions = new LinkedHashMap<String, ColumnHeaderMode>();
+ columnHeaderModeOptions.put("Hidden", ColumnHeaderMode.HIDDEN);
+ columnHeaderModeOptions.put("Id", ColumnHeaderMode.ID);
+ columnHeaderModeOptions.put("Explicit", ColumnHeaderMode.EXPLICIT);
columnHeaderModeOptions.put("Explicit defaults id",
- Table.COLUMN_HEADER_MODE_EXPLICIT_DEFAULTS_ID);
+ ColumnHeaderMode.EXPLICIT_DEFAULTS_ID);
createSelectAction("Column header mode", category,
columnHeaderModeOptions, "Explicit defaults id",
@@ -603,10 +605,10 @@ public class Tables<T extends Table> extends AbstractSelectTestCase<T>
createBooleanAction("Collapsed", category, false, columnCollapsed,
propertyId);
t.log("Collapsed");
- LinkedHashMap<String, String> options = new LinkedHashMap<String, String>();
- options.put("Left", Table.ALIGN_LEFT);
- options.put("Center", Table.ALIGN_CENTER);
- options.put("Right", Table.ALIGN_RIGHT);
+ LinkedHashMap<String, Align> options = new LinkedHashMap<String, Align>();
+ options.put("Left", Align.LEFT);
+ options.put("Center", Align.CENTER);
+ options.put("Right", Align.RIGHT);
createSelectAction("Alignment", category, options, "Left",
columnAlignmentCommand, propertyId);
@@ -652,16 +654,15 @@ public class Tables<T extends Table> extends AbstractSelectTestCase<T>
}
private void createRowHeaderModeSelect(String category) {
- LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
- options.put("Explicit", Table.ROW_HEADER_MODE_EXPLICIT);
- options.put("Explicit defaults id",
- Table.ROW_HEADER_MODE_EXPLICIT_DEFAULTS_ID);
- options.put("Hidden", Table.ROW_HEADER_MODE_HIDDEN);
- options.put("Icon only", Table.ROW_HEADER_MODE_ICON_ONLY);
- options.put("Id", Table.ROW_HEADER_MODE_ID);
- options.put("Index", Table.ROW_HEADER_MODE_INDEX);
- options.put("Item", Table.ROW_HEADER_MODE_ITEM);
- options.put("'Property 3' property", Table.ROW_HEADER_MODE_PROPERTY);
+ LinkedHashMap<String, RowHeaderMode> options = new LinkedHashMap<String, RowHeaderMode>();
+ options.put("Explicit", RowHeaderMode.EXPLICIT);
+ options.put("Explicit defaults id", RowHeaderMode.EXPLICIT_DEFAULTS_ID);
+ options.put("Hidden", RowHeaderMode.HIDDEN);
+ options.put("Icon only", RowHeaderMode.ICON_ONLY);
+ options.put("Id", RowHeaderMode.ID);
+ options.put("Index", RowHeaderMode.INDEX);
+ options.put("Item", RowHeaderMode.ITEM);
+ options.put("'Property 3' property", RowHeaderMode.PROPERTY);
createSelectAction("Row header mode", category, options, "Hidden",
rowHeaderModeCommand);
@@ -741,17 +742,17 @@ public class Tables<T extends Table> extends AbstractSelectTestCase<T>
}
protected void createHeaderVisibilitySelect(String category) {
- LinkedHashMap<String, Integer> options = new LinkedHashMap<String, Integer>();
- options.put("Explicit", Table.COLUMN_HEADER_MODE_EXPLICIT);
+ LinkedHashMap<String, ColumnHeaderMode> options = new LinkedHashMap<String, ColumnHeaderMode>();
+ options.put("Explicit", ColumnHeaderMode.EXPLICIT);
options.put("Explicit defaults id",
- Table.COLUMN_HEADER_MODE_EXPLICIT_DEFAULTS_ID);
- options.put("Id", Table.COLUMN_HEADER_MODE_ID);
- options.put("Hidden", Table.COLUMN_HEADER_MODE_HIDDEN);
+ ColumnHeaderMode.EXPLICIT_DEFAULTS_ID);
+ options.put("Id", ColumnHeaderMode.ID);
+ options.put("Hidden", ColumnHeaderMode.HIDDEN);
createSelectAction("Header mode", category, options,
- "Explicit defaults id", new Command<T, Integer>() {
+ "Explicit defaults id", new Command<T, ColumnHeaderMode>() {
- public void execute(T c, Integer value, Object data) {
+ public void execute(T c, ColumnHeaderMode value, Object data) {
c.setColumnHeaderMode(value);
}
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..c04c9d6c13
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/components/textfield/TextFieldInputPromptAndClickShortcut.java
@@ -0,0 +1,59 @@
+package com.vaadin.tests.components.textfield;
+
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+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");
+ inputPromptSelection.setImmediate(true);
+ inputPromptSelection.addListener(new ValueChangeListener() {
+ public void valueChange(ValueChangeEvent event) {
+ if (event.getProperty().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;
+ }
+
+}