diff --git a/LICENSE.txt b/LICENSE.txt index f433b1a..ade750b 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,177 +1,177 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS diff --git a/pom.xml b/pom.xml index 73d82eb..b140596 100644 --- a/pom.xml +++ b/pom.xml @@ -1,15 +1,20 @@ - - - 4.0.0 - org.vaadin.addons - wizards-for-vaadin-root - pom - 1.1.1 - Wizards for Vaadin Parent - - - wizards-for-vaadin - wizards-for-vaadin-demo - - + + + 4.0.0 + org.vaadin.addons + wizards-for-vaadin-root + pom + 1.1.2 + Wizards for Vaadin Parent + + + wizards-for-vaadin + wizards-for-vaadin-demo + + + + 7.7.9 + ${vaadin.version} + + diff --git a/wizards-for-vaadin-demo/pom.xml b/wizards-for-vaadin-demo/pom.xml index b44cd24..48c79c8 100644 --- a/wizards-for-vaadin-demo/pom.xml +++ b/wizards-for-vaadin-demo/pom.xml @@ -1,200 +1,203 @@ - - - 4.0.0 - org.vaadin.addons - wizards-for-vaadin-demo - 1.1.1 - war - Wizards for Vaadin Demo - - - UTF-8 - 7.1.9 - ${vaadin.version} - - - - - vaadin-addons - http://maven.vaadin.com/vaadin-addons - - - vaadin-snapshots - http://oss.sonatype.org/content/repositories/vaadin-snapshots/ - - false - - - true - - - - - - - vaadin-snapshots - http://oss.sonatype.org/content/repositories/vaadin-snapshots/ - - false - - - true - - - - - - - org.vaadin.addons - wizards-for-vaadin - ${version} - - - com.vaadin - vaadin-client-compiled - ${vaadin.version} - - - com.vaadin - vaadin-themes - ${vaadin.version} - - - javax.servlet - servlet-api - 2.4 - provided - - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.0 - - 1.6 - 1.6 - - - - - maven-clean-plugin - 2.4.1 - - - - - ${basedir}/src/main/webapp/VAADIN/widgetsets - - - - ${basedir}/src/main/webapp/VAADIN/gwt-unitCache - - - - - - - maven-war-plugin - 2.3 - - - **/VAADIN/gwt-unitCache/**, - **/VAADIN/widgetsets/WEB-INF/**, - **/WEB-INF/lib/servlet-api-*.jar, - **/WEB-INF/lib/jetty-*.jar, - **/WEB-INF/lib/ant-*.jar, - **/WEB-INF/classes/gwt-unitCache/**, - **/WEB-INF/classes/themes/**, - **/WEB-INF/classes/widgetsets/** - - false - - - - - com.vaadin - vaadin-maven-plugin - ${vaadin.plugin.version} - - -Xmx512M -Xss1024k - ${basedir}/src/main/webapp/VAADIN/widgetsets - ${basedir}/src/main/webapp/VAADIN/widgetsets - true - ${basedir}/target/tmp/gwt-unitCache - true - true - http://localhost:8080/ - - - - - - - - - resources - update-widgetset - compile - - - - - - - org.mortbay.jetty - jetty-maven-plugin - 8.1.10.v20130312 - - - / - - - - - - - - - - - org.eclipse.m2e - lifecycle-mapping - 1.0.0 - - - - - - com.vaadin - vaadin-maven-plugin - - [${vaadin.plugin.version},) - - - resources - update-widgetset - compile - update-theme - compile-theme - - - - - - - - - - - - - - - - + + + 4.0.0 + org.vaadin.addons + wizards-for-vaadin-demo + war + Wizards for Vaadin Demo + + + org.vaadin.addons + wizards-for-vaadin-root + 1.1.2 + + + + UTF-8 + + + + + vaadin-addons + http://maven.vaadin.com/vaadin-addons + + + vaadin-snapshots + http://oss.sonatype.org/content/repositories/vaadin-snapshots/ + + false + + + true + + + + + + + vaadin-snapshots + http://oss.sonatype.org/content/repositories/vaadin-snapshots/ + + false + + + true + + + + + + + org.vaadin.addons + wizards-for-vaadin + ${project.version} + + + com.vaadin + vaadin-client-compiled + ${vaadin.version} + + + com.vaadin + vaadin-themes + ${vaadin.version} + + + javax.servlet + servlet-api + 2.5 + provided + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.6.1 + + 1.6 + 1.6 + + + + + maven-clean-plugin + 3.0.0 + + + + + ${basedir}/src/main/webapp/VAADIN/widgetsets + + + + ${basedir}/src/main/webapp/VAADIN/gwt-unitCache + + + + + + + maven-war-plugin + 3.0.0 + + + **/VAADIN/gwt-unitCache/**, + **/VAADIN/widgetsets/WEB-INF/**, + **/WEB-INF/lib/servlet-api-*.jar, + **/WEB-INF/lib/jetty-*.jar, + **/WEB-INF/lib/ant-*.jar, + **/WEB-INF/classes/gwt-unitCache/**, + **/WEB-INF/classes/themes/**, + **/WEB-INF/classes/widgetsets/** + + false + + + + + com.vaadin + vaadin-maven-plugin + ${vaadin.plugin.version} + + -Xmx512M -Xss1024k + ${basedir}/src/main/webapp/VAADIN/widgetsets + ${basedir}/src/main/webapp/VAADIN/widgetsets + true + ${basedir}/target/tmp/gwt-unitCache + true + true + http://localhost:8080/ + + + + + + + + + resources + update-widgetset + compile + + + + + + + org.mortbay.jetty + jetty-maven-plugin + 8.1.16.v20140903 + + + / + + + + + + + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + com.vaadin + vaadin-maven-plugin + + [${vaadin.plugin.version},) + + + resources + update-widgetset + compile + update-theme + compile-theme + + + + + + + + + + + + + + + + diff --git a/wizards-for-vaadin-demo/src/main/java/org/vaadin/teemu/wizards/IntroStep.java b/wizards-for-vaadin-demo/src/main/java/org/vaadin/teemu/wizards/IntroStep.java index cf6d33e..160133c 100644 --- a/wizards-for-vaadin-demo/src/main/java/org/vaadin/teemu/wizards/IntroStep.java +++ b/wizards-for-vaadin-demo/src/main/java/org/vaadin/teemu/wizards/IntroStep.java @@ -9,10 +9,12 @@ public class IntroStep implements WizardStep { + @Override public String getCaption() { return "Intro"; } + @Override public Component getContent() { VerticalLayout content = new VerticalLayout(); content.setSizeFull(); @@ -30,12 +32,12 @@ public Component getContent() { private Label getText() { return new Label( "

Wizards for Vaadin add-on

This is a demo application of the " - + "Wizards for Vaadin add-on.

The goal of this add-on is to provide a simple framework for easily creating wizard style " - + "user interfaces. Please use the controls below this content area to navigate " - + "through this wizard that demonstrates the features and usage of this add-on.

Additional information

" - + "", + + "Wizards for Vaadin add-on.

The goal of this add-on is to provide a simple framework for easily creating wizard style " + + "user interfaces. Please use the controls below this content area to navigate " + + "through this wizard that demonstrates the features and usage of this add-on.

Additional information

" + + "", ContentMode.HTML); } @@ -46,12 +48,13 @@ private Embedded getArrow() { return arrow; } + @Override public boolean onAdvance() { return true; } + @Override public boolean onBack() { return true; } - } diff --git a/wizards-for-vaadin-demo/src/main/java/org/vaadin/teemu/wizards/LastStep.java b/wizards-for-vaadin-demo/src/main/java/org/vaadin/teemu/wizards/LastStep.java index ad62c0a..da2ee85 100644 --- a/wizards-for-vaadin-demo/src/main/java/org/vaadin/teemu/wizards/LastStep.java +++ b/wizards-for-vaadin-demo/src/main/java/org/vaadin/teemu/wizards/LastStep.java @@ -1,7 +1,5 @@ package org.vaadin.teemu.wizards; -import java.util.Date; - import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; @@ -10,21 +8,24 @@ import com.vaadin.ui.Label; import com.vaadin.ui.Notification; import com.vaadin.ui.VerticalLayout; +import java.util.Date; public class LastStep implements WizardStep { private CheckBox allowBack; private VerticalLayout layout; - private Wizard owner; + private final Wizard owner; public LastStep(Wizard owner) { this.owner = owner; } + @Override public String getCaption() { return "Need more?"; } + @Override public Component getContent() { if (layout == null) { allowBack = new CheckBox("Allow back?", false); @@ -37,50 +38,57 @@ public Component getContent() { layout.addComponent(new Button("Add new steps", new Button.ClickListener() { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - public void buttonClick(ClickEvent event) { - owner.addStep(new WizardStep() { + @Override + public void buttonClick(ClickEvent event) { + owner.addStep(new WizardStep() { - private final Date createdAt = new Date(); + private final Date createdAt = new Date(); - public boolean onBack() { - return true; - } + @Override + public boolean onBack() { + return true; + } - public boolean onAdvance() { - return true; - } + @Override + public boolean onAdvance() { + return true; + } - public Component getContent() { - VerticalLayout layout = new VerticalLayout(); - layout.setMargin(true); - layout.addComponent(new Label( - "This step was created on " - + createdAt)); - return layout; - } + @Override + public Component getContent() { + VerticalLayout layout = new VerticalLayout(); + layout.setMargin(true); + layout.addComponent(new Label( + "This step was created on " + + createdAt)); + return layout; + } - public String getCaption() { - return "Generated step"; - } - }); + @Override + public String getCaption() { + return "Generated step"; } - })); + }); + } + })); layout.addComponent(new Label( "

Want to go back?

This step is also an example of conditionally allowing you to go back.
" - + "Try to click the back button and then again after checking the checkbox below.

", + + "Try to click the back button and then again after checking the checkbox below.

", ContentMode.HTML)); layout.addComponent(allowBack); } return layout; } + @Override public boolean onAdvance() { return true; } + @Override public boolean onBack() { boolean allowed = allowBack.getValue(); if (!allowed) { diff --git a/wizards-for-vaadin-demo/src/main/java/org/vaadin/teemu/wizards/ListenStep.java b/wizards-for-vaadin-demo/src/main/java/org/vaadin/teemu/wizards/ListenStep.java index fd25b2e..14da812 100644 --- a/wizards-for-vaadin-demo/src/main/java/org/vaadin/teemu/wizards/ListenStep.java +++ b/wizards-for-vaadin-demo/src/main/java/org/vaadin/teemu/wizards/ListenStep.java @@ -9,10 +9,12 @@ public class ListenStep implements WizardStep { + @Override public String getCaption() { return "Listen for Progress"; } + @Override public Component getContent() { VerticalLayout content = new VerticalLayout(); content.setSizeFull(); @@ -30,13 +32,13 @@ public Component getContent() { private Label getText() { return new Label( "

Listen for Progress

The WizardProgressListener provides lifecycle methods to react " - + "on the progress made by user.

By default the add-on displays a default WizardProgressBar (as seen above) for displaying the progress. You " - + "can also use any other implementation of the interface for displaying the progress.

" - + "

To register a new listener, use the addListener method of the Wizard class. For removal there is also removeListener method.

" - + "
WizardProgressListener myListener = new MyProgressListener();\nmyWizard.addListener(myListener);
" - + "

If you don't want to display the default progress bar, you can hide it by calling setHeader(null). " - + "The default progress bar component is also registered as a listener, so a good practice would be also to remove it (unless you want to display it in any other place on your application).

" - + "
Component defaultHeader = myWizard.getHeader();\nif (defaultHeader instanceof WizardProgressListener) {\n    myWizard.removeListener((WizardProgressListener) defaultHeader);\n}\nmyWizard.setHeader(null);
", + + "on the progress made by user.

By default the add-on displays a default WizardProgressBar (as seen above) for displaying the progress. You " + + "can also use any other implementation of the interface for displaying the progress.

" + + "

To register a new listener, use the addListener method of the Wizard class. For removal there is also removeListener method.

" + + "
WizardProgressListener myListener = new MyProgressListener();\nmyWizard.addListener(myListener);
" + + "

If you don't want to display the default progress bar, you can hide it by calling setHeader(null). " + + "The default progress bar component is also registered as a listener, so a good practice would be also to remove it (unless you want to display it in any other place on your application).

" + + "
Component defaultHeader = myWizard.getHeader();\nif (defaultHeader instanceof WizardProgressListener) {\n    myWizard.removeListener((WizardProgressListener) defaultHeader);\n}\nmyWizard.setHeader(null);
", ContentMode.HTML); } @@ -46,12 +48,13 @@ private Embedded getArrow() { return arrow; } + @Override public boolean onAdvance() { return true; } + @Override public boolean onBack() { return true; } - } diff --git a/wizards-for-vaadin-demo/src/main/java/org/vaadin/teemu/wizards/SetupStep.java b/wizards-for-vaadin-demo/src/main/java/org/vaadin/teemu/wizards/SetupStep.java index dbae573..66f1ed0 100644 --- a/wizards-for-vaadin-demo/src/main/java/org/vaadin/teemu/wizards/SetupStep.java +++ b/wizards-for-vaadin-demo/src/main/java/org/vaadin/teemu/wizards/SetupStep.java @@ -7,10 +7,12 @@ public class SetupStep implements WizardStep { + @Override public String getCaption() { return "Initialize the Wizard"; } + @Override public Component getContent() { VerticalLayout content = new VerticalLayout(); content.setSizeFull(); @@ -25,19 +27,20 @@ public Component getContent() { private Label getText() { return new Label( "

Initialize the Wizard

Create an instance of the Wizard by calling the default constructor.

" - + "
Wizard myWizard = new Wizard()

After instantiation you can add some steps to the wizard by " - + "calling the addStep method. The method accepts instances of the WizardStep interface " - + "so you need to implement that in order to display your steps." - + "

myWizard.addStep(new FirstStep());\nmyWizard.addStep(new SecondStep());\nmyWizard.addStep(new ThirdStep());\nmyWizard.addStep(new FourthStep());
", + + "
Wizard myWizard = new Wizard()

After instantiation you can add some steps to the wizard by " + + "calling the addStep method. The method accepts instances of the WizardStep interface " + + "so you need to implement that in order to display your steps." + + "

myWizard.addStep(new FirstStep());\nmyWizard.addStep(new SecondStep());\nmyWizard.addStep(new ThirdStep());\nmyWizard.addStep(new FourthStep());
", ContentMode.HTML); } + @Override public boolean onAdvance() { return true; } + @Override public boolean onBack() { return true; } - } diff --git a/wizards-for-vaadin-demo/src/main/java/org/vaadin/teemu/wizards/WizardsDemoApplication.java b/wizards-for-vaadin-demo/src/main/java/org/vaadin/teemu/wizards/WizardsDemoApplication.java index 34288c6..7b2aed8 100644 --- a/wizards-for-vaadin-demo/src/main/java/org/vaadin/teemu/wizards/WizardsDemoApplication.java +++ b/wizards-for-vaadin-demo/src/main/java/org/vaadin/teemu/wizards/WizardsDemoApplication.java @@ -1,11 +1,5 @@ package org.vaadin.teemu.wizards; -import org.vaadin.teemu.wizards.event.WizardCancelledEvent; -import org.vaadin.teemu.wizards.event.WizardCompletedEvent; -import org.vaadin.teemu.wizards.event.WizardProgressListener; -import org.vaadin.teemu.wizards.event.WizardStepActivationEvent; -import org.vaadin.teemu.wizards.event.WizardStepSetChangedEvent; - import com.vaadin.annotations.Theme; import com.vaadin.server.Page; import com.vaadin.server.VaadinRequest; @@ -16,12 +10,17 @@ import com.vaadin.ui.Notification; import com.vaadin.ui.UI; import com.vaadin.ui.VerticalLayout; +import org.vaadin.teemu.wizards.event.WizardCancelledEvent; +import org.vaadin.teemu.wizards.event.WizardCompletedEvent; +import org.vaadin.teemu.wizards.event.WizardProgressListener; +import org.vaadin.teemu.wizards.event.WizardStepActivationEvent; +import org.vaadin.teemu.wizards.event.WizardStepSetChangedEvent; /** * Demo application for the Wizards for Vaadin * add-on. - * + * * @author Teemu Pöntelin / Vaadin Ltd */ @SuppressWarnings("serial") @@ -55,19 +54,23 @@ protected void init(VaadinRequest request) { mainLayout.setComponentAlignment(wizard, Alignment.TOP_CENTER); } + @Override public void wizardCompleted(WizardCompletedEvent event) { endWizard("Wizard Completed!"); } + @Override public void activeStepChanged(WizardStepActivationEvent event) { // display the step caption as the window title Page.getCurrent().setTitle(event.getActivatedStep().getCaption()); } + @Override public void stepSetChanged(WizardStepSetChangedEvent event) { // NOP, not interested on this event } + @Override public void wizardCancelled(WizardCancelledEvent event) { endWizard("Wizard Cancelled!"); } @@ -78,12 +81,13 @@ private void endWizard(String message) { Page.getCurrent().setTitle(message); Button startOverButton = new Button("Run the demo again", new Button.ClickListener() { - public void buttonClick(ClickEvent event) { - // Close the session and reload the page. - VaadinSession.getCurrent().close(); - Page.getCurrent().setLocation(""); - } - }); + @Override + public void buttonClick(ClickEvent event) { + // Close the session and reload the page. + VaadinSession.getCurrent().close(); + Page.getCurrent().setLocation(""); + } + }); mainLayout.addComponent(startOverButton); mainLayout.setComponentAlignment(startOverButton, Alignment.MIDDLE_CENTER); diff --git a/wizards-for-vaadin-demo/src/main/webapp/META-INF/MANIFEST.MF b/wizards-for-vaadin-demo/src/main/webapp/META-INF/MANIFEST.MF index e41bf7b..4b57a95 100644 --- a/wizards-for-vaadin-demo/src/main/webapp/META-INF/MANIFEST.MF +++ b/wizards-for-vaadin-demo/src/main/webapp/META-INF/MANIFEST.MF @@ -1,2 +1,2 @@ -Manifest-Version: 1.0 +Manifest-Version: 1.0 Class-Path: \ No newline at end of file diff --git a/wizards-for-vaadin-demo/src/main/webapp/META-INF/context.xml b/wizards-for-vaadin-demo/src/main/webapp/META-INF/context.xml index 6955dcb..4b396c0 100644 --- a/wizards-for-vaadin-demo/src/main/webapp/META-INF/context.xml +++ b/wizards-for-vaadin-demo/src/main/webapp/META-INF/context.xml @@ -1,2 +1,2 @@ - + \ No newline at end of file diff --git a/wizards-for-vaadin-demo/src/main/webapp/VAADIN/themes/demo/styles.css b/wizards-for-vaadin-demo/src/main/webapp/VAADIN/themes/demo/styles.css index ab36f91..62628e7 100644 --- a/wizards-for-vaadin-demo/src/main/webapp/VAADIN/themes/demo/styles.css +++ b/wizards-for-vaadin-demo/src/main/webapp/VAADIN/themes/demo/styles.css @@ -1,52 +1,52 @@ -@import url(../reindeer/legacy-styles.css); - -.wizard .v-panel-content pre, -.wizard .v-panel-content code { - font-family: Monaco, Courier, sans-serif; -} - -.wizard .v-panel-content pre { - padding-left: 10px; -} - -.wizard .v-panel-content p.narrow { - width: 400px; -} - -.intro-arrow { - position: absolute; - bottom: 5px; - right: 70px; - -webkit-animation: hovering 2s infinite; - -moz-animation: hovering 2s infinite; -} - -@-webkit-keyframes hovering { - 0% { bottom: 5px; } - 50% { bottom: 10px; } - 100% { bottom: 5px; } -} -@-moz-keyframes hovering { - 0% { bottom: 5px; } - 50% { bottom: 10px; } - 100% { bottom: 5px; } -} - -.listen-arrow { - position: absolute; - top: 5px; - right: 280px; - -webkit-animation: hovering-top 2s infinite; - -moz-animation: hovering-top 2s infinite; -} - -@-webkit-keyframes hovering-top { - 0% { top: 5px; } - 50% { top: 10px; } - 100% { top: 5px; } -} -@-moz-keyframes hovering-top { - 0% { top: 5px; } - 50% { top: 10px; } - 100% { top: 5px; } -} +@import url(../reindeer/legacy-styles.css); + +.wizard .v-panel-content pre, +.wizard .v-panel-content code { + font-family: Monaco, Courier, sans-serif; +} + +.wizard .v-panel-content pre { + padding-left: 10px; +} + +.wizard .v-panel-content p.narrow { + width: 400px; +} + +.intro-arrow { + position: absolute; + bottom: 5px; + right: 70px; + -webkit-animation: hovering 2s infinite; + -moz-animation: hovering 2s infinite; +} + +@-webkit-keyframes hovering { + 0% { bottom: 5px; } + 50% { bottom: 10px; } + 100% { bottom: 5px; } +} +@-moz-keyframes hovering { + 0% { bottom: 5px; } + 50% { bottom: 10px; } + 100% { bottom: 5px; } +} + +.listen-arrow { + position: absolute; + top: 5px; + right: 280px; + -webkit-animation: hovering-top 2s infinite; + -moz-animation: hovering-top 2s infinite; +} + +@-webkit-keyframes hovering-top { + 0% { top: 5px; } + 50% { top: 10px; } + 100% { top: 5px; } +} +@-moz-keyframes hovering-top { + 0% { top: 5px; } + 50% { top: 10px; } + 100% { top: 5px; } +} diff --git a/wizards-for-vaadin/assembly/MANIFEST.MF b/wizards-for-vaadin/assembly/MANIFEST.MF index cd2cda6..8ccd9fc 100644 --- a/wizards-for-vaadin/assembly/MANIFEST.MF +++ b/wizards-for-vaadin/assembly/MANIFEST.MF @@ -1,7 +1,7 @@ -Manifest-Version: 1.0 -Vaadin-Package-Version: 1 -Vaadin-Addon: ${Vaadin-Addon} -Vaadin-License-Title: Apache License 2.0 -Implementation-Vendor: Teemu Pöntelin -Implementation-Title: ${Implementation-Title} -Implementation-Version: ${Implementation-Version} +Manifest-Version: 1.0 +Vaadin-Package-Version: 1 +Vaadin-Addon: ${Vaadin-Addon} +Vaadin-License-Title: Apache License 2.0 +Implementation-Vendor: Teemu Pöntelin +Implementation-Title: ${Implementation-Title} +Implementation-Version: ${Implementation-Version} diff --git a/wizards-for-vaadin/assembly/assembly.xml b/wizards-for-vaadin/assembly/assembly.xml index 22b6e0f..9499795 100644 --- a/wizards-for-vaadin/assembly/assembly.xml +++ b/wizards-for-vaadin/assembly/assembly.xml @@ -1,44 +1,44 @@ - - - addon - - - - - zip - - - - false - - - - .. - - LICENSE.txt - README.md - - - - target - - - *.jar - *.pdf - - - - - - - - assembly/MANIFEST.MF - META-INF - true - - + + + addon + + + + + zip + + + + false + + + + .. + + LICENSE.txt + README.md + + + + target + + + *.jar + *.pdf + + + + + + + + assembly/MANIFEST.MF + META-INF + true + + \ No newline at end of file diff --git a/wizards-for-vaadin/pom.xml b/wizards-for-vaadin/pom.xml index 903dd2f..8b61ba1 100644 --- a/wizards-for-vaadin/pom.xml +++ b/wizards-for-vaadin/pom.xml @@ -1,196 +1,199 @@ - - - 4.0.0 - org.vaadin.addons - wizards-for-vaadin - 1.1.1 - jar - Wizards for Vaadin - - - UTF-8 - 7.1.9 - ${vaadin.version} - - - ${project.version} - - ${project.name} - ${project.organization.name} - ${artifactId}-${project.version}.jar - - - - - Apache 2 - http://www.apache.org/licenses/LICENSE-2.0.txt - repo - - - - - - vaadin-addons - http://maven.vaadin.com/vaadin-addons - - - vaadin-snapshots - http://oss.sonatype.org/content/repositories/vaadin-snapshots/ - - false - - - true - - - - - - - vaadin-snapshots - http://oss.sonatype.org/content/repositories/vaadin-snapshots/ - - false - - - true - - - - - - - com.vaadin - vaadin-server - ${vaadin.version} - - - com.vaadin - vaadin-client - ${vaadin.version} - provided - - - - - junit - junit - 4.8.1 - test - - - org.mockito - mockito-all - 1.9.0 - test - - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.0 - - 1.6 - 1.6 - - - - - org.apache.maven.plugins - maven-jar-plugin - 2.3.1 - - - true - - true - true - - - - 1 - ${Vaadin-License-Title} - - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.9 - - - attach-javadoc - - jar - - - - - - - org.apache.maven.plugins - maven-source-plugin - 2.2.1 - - - attach-sources - - jar - - - - - - - org.apache.maven.plugins - maven-assembly-plugin - 2.2.1 - - false - - assembly/assembly.xml - - - - - - single - - install - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.14.1 - - - - - - - src/main/java - - rebel.xml - - - - src/main/resources - - - - - - + + + 4.0.0 + org.vaadin.addons + wizards-for-vaadin + jar + Wizards for Vaadin + + + org.vaadin.addons + wizards-for-vaadin-root + 1.1.2 + + + + UTF-8 + + + ${project.version} + + ${project.name} + ${project.organization.name} + ${project.artifactId}-${project.version}.jar + + + + + Apache 2 + http://www.apache.org/licenses/LICENSE-2.0.txt + repo + + + + + + vaadin-addons + http://maven.vaadin.com/vaadin-addons + + + vaadin-snapshots + http://oss.sonatype.org/content/repositories/vaadin-snapshots/ + + false + + + true + + + + + + + vaadin-snapshots + http://oss.sonatype.org/content/repositories/vaadin-snapshots/ + + false + + + true + + + + + + + com.vaadin + vaadin-server + ${vaadin.version} + + + com.vaadin + vaadin-client + ${vaadin.version} + provided + + + + + junit + junit + 4.12 + test + + + org.mockito + mockito-all + 1.10.19 + test + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.6.1 + + 1.6 + 1.6 + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.0.2 + + + true + + true + true + + + + 1 + ${Vaadin-License-Title} + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.10.4 + + + attach-javadoc + + jar + + + + + + + org.apache.maven.plugins + maven-source-plugin + 3.0.1 + + + attach-sources + + jar + + + + + + + org.apache.maven.plugins + maven-assembly-plugin + 3.0.0 + + false + + assembly/assembly.xml + + + + + + single + + install + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.18.1 + + + + + + + src/main/java + + rebel.xml + + + + src/main/resources + + + + + + diff --git a/wizards-for-vaadin/src/main/java/org/vaadin/teemu/wizards/Wizard.java b/wizards-for-vaadin/src/main/java/org/vaadin/teemu/wizards/Wizard.java index b35ce89..d42d5be 100644 --- a/wizards-for-vaadin/src/main/java/org/vaadin/teemu/wizards/Wizard.java +++ b/wizards-for-vaadin/src/main/java/org/vaadin/teemu/wizards/Wizard.java @@ -1,18 +1,5 @@ package org.vaadin.teemu.wizards; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.vaadin.teemu.wizards.event.WizardCancelledEvent; -import org.vaadin.teemu.wizards.event.WizardCompletedEvent; -import org.vaadin.teemu.wizards.event.WizardProgressListener; -import org.vaadin.teemu.wizards.event.WizardStepActivationEvent; -import org.vaadin.teemu.wizards.event.WizardStepSetChangedEvent; - import com.vaadin.server.Page; import com.vaadin.server.Page.UriFragmentChangedEvent; import com.vaadin.server.Page.UriFragmentChangedListener; @@ -24,16 +11,27 @@ import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Panel; import com.vaadin.ui.VerticalLayout; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.vaadin.teemu.wizards.event.WizardCancelledEvent; +import org.vaadin.teemu.wizards.event.WizardCompletedEvent; +import org.vaadin.teemu.wizards.event.WizardProgressListener; +import org.vaadin.teemu.wizards.event.WizardStepActivationEvent; +import org.vaadin.teemu.wizards.event.WizardStepSetChangedEvent; /** * Component for displaying multi-step wizard style user interface. - * + * *

* The steps of the wizard must be implementations of the {@link WizardStep} * interface. Use the {@link #addStep(WizardStep)} method to add these steps in * the same order they are supposed to be displayed. *

- * + * *

* The wizard also supports navigation through URI fragments. This feature is * disabled by default, but you can enable it using @@ -42,7 +40,7 @@ * override these with your own identifiers, you can add the steps using the * overloaded {@link #addStep(WizardStep, String)} method. *

- * + * *

* To react on the progress, cancellation or completion of this {@code Wizard} * you should add one or more listeners that implement the @@ -50,7 +48,7 @@ * {@link #addListener(WizardProgressListener)} method and removed with the * {@link #removeListener(WizardProgressListener)}. *

- * + * * @author Teemu Pöntelin / Vaadin Ltd */ @SuppressWarnings("serial") @@ -58,8 +56,10 @@ public class Wizard extends CustomComponent implements UriFragmentChangedListener { protected final List steps = new ArrayList(); - protected final Map idMap = new HashMap(); - private final Map scrollPositions = new HashMap(); + protected final Map idMap + = new HashMap(); + private final Map scrollPositions + = new HashMap(); protected WizardStep currentStep; protected WizardStep lastCompletedStep; @@ -77,6 +77,7 @@ public class Wizard extends CustomComponent implements private Component header; private boolean uriFragmentEnabled; + private WizardProgressBar progressBar; private static final Method WIZARD_ACTIVE_STEP_CHANGED_METHOD; private static final Method WIZARD_STEP_SET_CHANGED_METHOD; @@ -87,16 +88,16 @@ public class Wizard extends CustomComponent implements try { WIZARD_COMPLETED_METHOD = WizardProgressListener.class .getDeclaredMethod("wizardCompleted", - new Class[] { WizardCompletedEvent.class }); + new Class[]{WizardCompletedEvent.class}); WIZARD_STEP_SET_CHANGED_METHOD = WizardProgressListener.class .getDeclaredMethod("stepSetChanged", - new Class[] { WizardStepSetChangedEvent.class }); + new Class[]{WizardStepSetChangedEvent.class}); WIZARD_ACTIVE_STEP_CHANGED_METHOD = WizardProgressListener.class .getDeclaredMethod("activeStepChanged", - new Class[] { WizardStepActivationEvent.class }); + new Class[]{WizardStepActivationEvent.class}); WIZARD_CANCELLED_METHOD = WizardProgressListener.class .getDeclaredMethod("wizardCancelled", - new Class[] { WizardCancelledEvent.class }); + new Class[]{WizardCancelledEvent.class}); } catch (final java.lang.NoSuchMethodException e) { // This should never happen throw new java.lang.RuntimeException( @@ -105,6 +106,7 @@ public class Wizard extends CustomComponent implements } private static final class ScrollPosition { + int scrollTop; int scrollLeft; @@ -114,6 +116,9 @@ public ScrollPosition(int scrollTop, int scrollLeft) { } } + /** + * Default constructor. + */ public Wizard() { setStyleName("wizard"); init(); @@ -149,6 +154,7 @@ private void init() { private void initControlButtons() { nextButton = new Button("Next"); nextButton.addClickListener(new Button.ClickListener() { + @Override public void buttonClick(ClickEvent event) { next(); } @@ -156,6 +162,7 @@ public void buttonClick(ClickEvent event) { backButton = new Button("Back"); backButton.addClickListener(new Button.ClickListener() { + @Override public void buttonClick(ClickEvent event) { back(); } @@ -163,6 +170,7 @@ public void buttonClick(ClickEvent event) { finishButton = new Button("Finish"); finishButton.addClickListener(new Button.ClickListener() { + @Override public void buttonClick(ClickEvent event) { finish(); } @@ -171,6 +179,7 @@ public void buttonClick(ClickEvent event) { cancelButton = new Button("Cancel"); cancelButton.addClickListener(new Button.ClickListener() { + @Override public void buttonClick(ClickEvent event) { cancel(); } @@ -178,7 +187,8 @@ public void buttonClick(ClickEvent event) { } private void initDefaultHeader() { - WizardProgressBar progressBar = new WizardProgressBar(this); + progressBar = new WizardProgressBar(this); + progressBar.setMaxStepsDisplayed(getDisplayedMaxTitles()); addListener(progressBar); setHeader(progressBar); } @@ -199,10 +209,9 @@ public boolean isUriFragmentEnabled() { /** * Sets a {@link Component} that is displayed on top of the actual content. * Set to {@code null} to remove the header altogether. - * - * @param newHeader - * {@link Component} to be displayed on top of the actual content - * or {@code null} to remove the header. + * + * @param newHeader {@link Component} to be displayed on top of the actual + * content or {@code null} to remove the header. */ public void setHeader(Component newHeader) { if (header != null) { @@ -222,14 +231,14 @@ public void setHeader(Component newHeader) { /** * Returns a {@link Component} that is displayed on top of the actual * content or {@code null} if no header is specified. - * + * *

* By default the header is a {@link WizardProgressBar} component that is * also registered as a {@link WizardProgressListener} to this Wizard. *

- * + * * @return {@link Component} that is displayed on top of the actual content - * or {@code null}. + * or {@code null}. */ public Component getHeader() { return header; @@ -240,11 +249,10 @@ public Component getHeader() { * must be unique or an {@link IllegalArgumentException} is thrown. If you * don't wish to explicitly provide an identifier, you can use the * {@link #addStep(WizardStep)} method. - * + * * @param step * @param id - * @throws IllegalStateException - * if the given {@code id} already exists. + * @throws IllegalStateException if the given {@code id} already exists. */ public void addStep(WizardStep step, String id) { if (idMap.containsKey(id)) { @@ -272,7 +280,7 @@ public void addStep(WizardStep step, String id) { * automatically. If you wish to provide an explicit identifier for your * WizardStep, you can use the {@link #addStep(WizardStep, String)} method * instead. - * + * * @param step */ public void addStep(WizardStep step) { @@ -307,9 +315,8 @@ public List getSteps() { /** * Returns {@code true} if the given step is already completed by the user. - * - * @param step - * step to check for completion. + * + * @param step step to check for completion. * @return {@code true} if the given step is already completed. */ public boolean isCompleted(WizardStep step) { @@ -318,9 +325,8 @@ public boolean isCompleted(WizardStep step) { /** * Returns {@code true} if the given step is the currently active step. - * - * @param step - * step to check for. + * + * @param step step to check for. * @return {@code true} if the given step is the currently active step. */ public boolean isActive(WizardStep step) { @@ -361,6 +367,8 @@ protected void activateStep(WizardStep step) { if (currentStep != null) { if (currentStep.equals(step)) { + //Update the content anyway. + contentPanel.setContent(step.getContent()); // already active return; } @@ -429,9 +437,9 @@ protected void activateStep(String id) { // check that we don't go past the lastCompletedStep by using the id int lastCompletedIndex = lastCompletedStep == null ? -1 : steps .indexOf(lastCompletedStep); - int stepIndex = steps.indexOf(step); + int index = steps.indexOf(step); - if (lastCompletedIndex < stepIndex) { + if (lastCompletedIndex < index) { activateStep(lastCompletedStep); } else { activateStep(step); @@ -537,9 +545,8 @@ public void uriFragmentChanged(UriFragmentChangedEvent event) { * Removes the given step from this Wizard. An {@link IllegalStateException} * is thrown if the given step is already completed or is the currently * active step. - * - * @param stepToRemove - * the step to remove. + * + * @param stepToRemove the step to remove. * @see #isCompleted(WizardStep) * @see #isActive(WizardStep) */ @@ -559,9 +566,8 @@ public void removeStep(WizardStep stepToRemove) { * Removes the step with given id from this Wizard. An * {@link IllegalStateException} is thrown if the given step is already * completed or is the currently active step. - * - * @param id - * identifier of the step to remove. + * + * @param id identifier of the step to remove. * @see #isCompleted(WizardStep) * @see #isActive(WizardStep) */ @@ -585,4 +591,32 @@ public void removeStep(String id) { } } + /** + * Get amount of steps to display on the header at a time. A value of -1 + * means all will be displayed. + * + * @return the displayedMaxTitles + */ + public int getDisplayedMaxTitles() { + return progressBar.getMaxStepsDisplayed(); + } + + /** + * Set amount of steps to display on the header at a time. A value of -1 + * means all will be displayed. + * + * @param displayedMaxTitles the displayedMaxTitles to set + */ + public void setDisplayedMaxTitles(int displayedMaxTitles) { + progressBar.setMaxStepsDisplayed(displayedMaxTitles); + } + + /** + * Update de displayed step. + */ + public void updateCurrentStep() { + if (currentStep != null) { + activateStep(currentStep); + } + } } diff --git a/wizards-for-vaadin/src/main/java/org/vaadin/teemu/wizards/WizardProgressBar.java b/wizards-for-vaadin/src/main/java/org/vaadin/teemu/wizards/WizardProgressBar.java index 10cdad8..ddde0a8 100644 --- a/wizards-for-vaadin/src/main/java/org/vaadin/teemu/wizards/WizardProgressBar.java +++ b/wizards-for-vaadin/src/main/java/org/vaadin/teemu/wizards/WizardProgressBar.java @@ -1,19 +1,17 @@ package org.vaadin.teemu.wizards; -import java.util.List; - -import org.vaadin.teemu.wizards.event.WizardCancelledEvent; -import org.vaadin.teemu.wizards.event.WizardCompletedEvent; -import org.vaadin.teemu.wizards.event.WizardProgressListener; -import org.vaadin.teemu.wizards.event.WizardStepActivationEvent; -import org.vaadin.teemu.wizards.event.WizardStepSetChangedEvent; - import com.vaadin.annotations.StyleSheet; import com.vaadin.ui.CustomComponent; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.ui.ProgressBar; import com.vaadin.ui.VerticalLayout; +import java.util.List; +import org.vaadin.teemu.wizards.event.WizardCancelledEvent; +import org.vaadin.teemu.wizards.event.WizardCompletedEvent; +import org.vaadin.teemu.wizards.event.WizardProgressListener; +import org.vaadin.teemu.wizards.event.WizardStepActivationEvent; +import org.vaadin.teemu.wizards.event.WizardStepSetChangedEvent; /** * Displays a progress bar for a {@link Wizard}. @@ -27,6 +25,8 @@ public class WizardProgressBar extends CustomComponent implements private final ProgressBar progressBar = new ProgressBar(); private final HorizontalLayout stepCaptions = new HorizontalLayout(); private int activeStepIndex; + //Amount of steps displayed at a time in the header. + private int maxStepsDisplayed = -1;//Show all public WizardProgressBar(Wizard wizard) { setStyleName("wizard-progress-bar"); @@ -54,10 +54,16 @@ private void updateProgressBar() { private void updateStepCaptions() { stepCaptions.removeAllComponents(); int index = 1; + //Just show 3 at a time for (WizardStep step : wizard.getSteps()) { - Label label = createCaptionLabel(index, step); - stepCaptions.addComponent(label); + if (index > activeStepIndex) { + Label label = createCaptionLabel(index, step); + stepCaptions.addComponent(label); + } index++; + if (maxStepsDisplayed > 0 && index > activeStepIndex + maxStepsDisplayed) { + break; + } } } @@ -109,4 +115,27 @@ public void wizardCompleted(WizardCompletedEvent event) { public void wizardCancelled(WizardCancelledEvent event) { // NOP, no need to react to cancellation } + + /** + * Get amount of steps to display on the header at a time. A value of -1 + * means all will be displayed. + * + * @return the maxStepsDisplayed + */ + public int getMaxStepsDisplayed() { + return maxStepsDisplayed; + } + + /** + * Set the maximum amount of steps to display on the header at a time to + * avoid them being overlapping. + * + * A value of -1 means all will be displayed. + * + * @param maxStepsDisplayed the maxStepsDisplayed to set + */ + public void setMaxStepsDisplayed(int maxStepsDisplayed) { + this.maxStepsDisplayed = maxStepsDisplayed; + updateStepCaptions(); + } } diff --git a/wizards-for-vaadin/src/main/java/org/vaadin/teemu/wizards/WizardStep.java b/wizards-for-vaadin/src/main/java/org/vaadin/teemu/wizards/WizardStep.java index 1dd5ef6..00d12ea 100644 --- a/wizards-for-vaadin/src/main/java/org/vaadin/teemu/wizards/WizardStep.java +++ b/wizards-for-vaadin/src/main/java/org/vaadin/teemu/wizards/WizardStep.java @@ -1,41 +1,41 @@ -package org.vaadin.teemu.wizards; - -import com.vaadin.ui.Component; - -public interface WizardStep { - - /** - * Returns the caption of this WizardStep. - * - * @return the caption of this WizardStep. - */ - public String getCaption(); - - /** - * Returns the {@link Component} that is to be used as the actual content of - * this WizardStep. - * - * @return the content of this WizardStep as a Component. - */ - public Component getContent(); - - /** - * Returns true if user is allowed to navigate forward past this WizardStep. - * Typically this method is called when user clicks the Next button of the - * {@link Wizard}. - * - * @return true if user is allowed to navigate past this WizardStep. - */ - public boolean onAdvance(); - - /** - * Returns true if user is allowed to navigate backwards from this - * WizardStep. Typically this method is called when user clicks the Back - * button of the {@link Wizard}. - * - * @return true if user is allowed to navigate backwards from this - * WizardStep. - */ - public boolean onBack(); - -} +package org.vaadin.teemu.wizards; + +import com.vaadin.ui.Component; + +public interface WizardStep { + + /** + * Returns the caption of this WizardStep. + * + * @return the caption of this WizardStep. + */ + public String getCaption(); + + /** + * Returns the {@link Component} that is to be used as the actual content of + * this WizardStep. + * + * @return the content of this WizardStep as a Component. + */ + public Component getContent(); + + /** + * Returns true if user is allowed to navigate forward past this WizardStep. + * Typically this method is called when user clicks the Next button of the + * {@link Wizard}. + * + * @return true if user is allowed to navigate past this WizardStep. + */ + public boolean onAdvance(); + + /** + * Returns true if user is allowed to navigate backwards from this + * WizardStep. Typically this method is called when user clicks the Back + * button of the {@link Wizard}. + * + * @return true if user is allowed to navigate backwards from this + * WizardStep. + */ + public boolean onBack(); + +} diff --git a/wizards-for-vaadin/src/main/java/org/vaadin/teemu/wizards/event/AbstractWizardEvent.java b/wizards-for-vaadin/src/main/java/org/vaadin/teemu/wizards/event/AbstractWizardEvent.java index 3ec3cea..30c4f52 100644 --- a/wizards-for-vaadin/src/main/java/org/vaadin/teemu/wizards/event/AbstractWizardEvent.java +++ b/wizards-for-vaadin/src/main/java/org/vaadin/teemu/wizards/event/AbstractWizardEvent.java @@ -1,22 +1,22 @@ -package org.vaadin.teemu.wizards.event; - -import org.vaadin.teemu.wizards.Wizard; - -import com.vaadin.ui.Component; - -@SuppressWarnings("serial") -public class AbstractWizardEvent extends Component.Event { - - protected AbstractWizardEvent(Wizard source) { - super(source); - } - - /** - * Returns the {@link Wizard} component that was the source of this event. - * - * @return the source {@link Wizard} of this event. - */ - public Wizard getWizard() { - return (Wizard) getSource(); - } -} +package org.vaadin.teemu.wizards.event; + +import org.vaadin.teemu.wizards.Wizard; + +import com.vaadin.ui.Component; + +@SuppressWarnings("serial") +public class AbstractWizardEvent extends Component.Event { + + protected AbstractWizardEvent(Wizard source) { + super(source); + } + + /** + * Returns the {@link Wizard} component that was the source of this event. + * + * @return the source {@link Wizard} of this event. + */ + public Wizard getWizard() { + return (Wizard) getSource(); + } +} diff --git a/wizards-for-vaadin/src/main/java/org/vaadin/teemu/wizards/event/WizardCancelledEvent.java b/wizards-for-vaadin/src/main/java/org/vaadin/teemu/wizards/event/WizardCancelledEvent.java index c7f210c..b56547b 100644 --- a/wizards-for-vaadin/src/main/java/org/vaadin/teemu/wizards/event/WizardCancelledEvent.java +++ b/wizards-for-vaadin/src/main/java/org/vaadin/teemu/wizards/event/WizardCancelledEvent.java @@ -1,12 +1,12 @@ -package org.vaadin.teemu.wizards.event; - -import org.vaadin.teemu.wizards.Wizard; - -@SuppressWarnings("serial") -public class WizardCancelledEvent extends AbstractWizardEvent { - - public WizardCancelledEvent(Wizard source) { - super(source); - } - -} +package org.vaadin.teemu.wizards.event; + +import org.vaadin.teemu.wizards.Wizard; + +@SuppressWarnings("serial") +public class WizardCancelledEvent extends AbstractWizardEvent { + + public WizardCancelledEvent(Wizard source) { + super(source); + } + +} diff --git a/wizards-for-vaadin/src/main/java/org/vaadin/teemu/wizards/event/WizardCompletedEvent.java b/wizards-for-vaadin/src/main/java/org/vaadin/teemu/wizards/event/WizardCompletedEvent.java index 2e36955..80bad79 100644 --- a/wizards-for-vaadin/src/main/java/org/vaadin/teemu/wizards/event/WizardCompletedEvent.java +++ b/wizards-for-vaadin/src/main/java/org/vaadin/teemu/wizards/event/WizardCompletedEvent.java @@ -1,12 +1,12 @@ -package org.vaadin.teemu.wizards.event; - -import org.vaadin.teemu.wizards.Wizard; - -@SuppressWarnings("serial") -public class WizardCompletedEvent extends AbstractWizardEvent { - - public WizardCompletedEvent(Wizard source) { - super(source); - } - -} +package org.vaadin.teemu.wizards.event; + +import org.vaadin.teemu.wizards.Wizard; + +@SuppressWarnings("serial") +public class WizardCompletedEvent extends AbstractWizardEvent { + + public WizardCompletedEvent(Wizard source) { + super(source); + } + +} diff --git a/wizards-for-vaadin/src/main/java/org/vaadin/teemu/wizards/event/WizardProgressListener.java b/wizards-for-vaadin/src/main/java/org/vaadin/teemu/wizards/event/WizardProgressListener.java index 7b88516..adafadb 100644 --- a/wizards-for-vaadin/src/main/java/org/vaadin/teemu/wizards/event/WizardProgressListener.java +++ b/wizards-for-vaadin/src/main/java/org/vaadin/teemu/wizards/event/WizardProgressListener.java @@ -1,47 +1,47 @@ -package org.vaadin.teemu.wizards.event; - -import org.vaadin.teemu.wizards.Wizard; -import org.vaadin.teemu.wizards.WizardStep; - -public interface WizardProgressListener { - - /** - * Called when the currently active {@link WizardStep} is changed and this - * {@code WizardProgressListener} is expected to update itself accordingly. - * - * @param event - * {@link WizardStepActivationEvent} object containing details - * about the event - */ - void activeStepChanged(WizardStepActivationEvent event); - - /** - * Called when collection {@link WizardStep}s is changed (i.e. a step is - * added or removed) and this {@code WizardProgressListener} is expected to - * update itself accordingly. - * - * @param event - * {@link WizardStepSetChangedEvent} object containing details - * about the event - */ - void stepSetChanged(WizardStepSetChangedEvent event); - - /** - * Called when a {@link Wizard} is completed. - * - * @param event - * {@link WizardCompletedEvent} object containing details about - * the event - */ - void wizardCompleted(WizardCompletedEvent event); - - /** - * Called when a {@link Wizard} is cancelled by the user. - * - * @param event - * {@link WizardCancelledEvent} object containing details about - * the event - */ - void wizardCancelled(WizardCancelledEvent event); - +package org.vaadin.teemu.wizards.event; + +import org.vaadin.teemu.wizards.Wizard; +import org.vaadin.teemu.wizards.WizardStep; + +public interface WizardProgressListener { + + /** + * Called when the currently active {@link WizardStep} is changed and this + * {@code WizardProgressListener} is expected to update itself accordingly. + * + * @param event + * {@link WizardStepActivationEvent} object containing details + * about the event + */ + void activeStepChanged(WizardStepActivationEvent event); + + /** + * Called when collection {@link WizardStep}s is changed (i.e. a step is + * added or removed) and this {@code WizardProgressListener} is expected to + * update itself accordingly. + * + * @param event + * {@link WizardStepSetChangedEvent} object containing details + * about the event + */ + void stepSetChanged(WizardStepSetChangedEvent event); + + /** + * Called when a {@link Wizard} is completed. + * + * @param event + * {@link WizardCompletedEvent} object containing details about + * the event + */ + void wizardCompleted(WizardCompletedEvent event); + + /** + * Called when a {@link Wizard} is cancelled by the user. + * + * @param event + * {@link WizardCancelledEvent} object containing details about + * the event + */ + void wizardCancelled(WizardCancelledEvent event); + } \ No newline at end of file diff --git a/wizards-for-vaadin/src/main/java/org/vaadin/teemu/wizards/event/WizardStepActivationEvent.java b/wizards-for-vaadin/src/main/java/org/vaadin/teemu/wizards/event/WizardStepActivationEvent.java index de681f0..543484a 100644 --- a/wizards-for-vaadin/src/main/java/org/vaadin/teemu/wizards/event/WizardStepActivationEvent.java +++ b/wizards-for-vaadin/src/main/java/org/vaadin/teemu/wizards/event/WizardStepActivationEvent.java @@ -1,25 +1,25 @@ -package org.vaadin.teemu.wizards.event; - -import org.vaadin.teemu.wizards.Wizard; -import org.vaadin.teemu.wizards.WizardStep; - -@SuppressWarnings("serial") -public class WizardStepActivationEvent extends AbstractWizardEvent { - - private final WizardStep activatedStep; - - public WizardStepActivationEvent(Wizard source, WizardStep activatedStep) { - super(source); - this.activatedStep = activatedStep; - } - - /** - * Returns the {@link WizardStep} that was the activated. - * - * @return the activated {@link WizardStep}. - */ - public WizardStep getActivatedStep() { - return activatedStep; - } - +package org.vaadin.teemu.wizards.event; + +import org.vaadin.teemu.wizards.Wizard; +import org.vaadin.teemu.wizards.WizardStep; + +@SuppressWarnings("serial") +public class WizardStepActivationEvent extends AbstractWizardEvent { + + private final WizardStep activatedStep; + + public WizardStepActivationEvent(Wizard source, WizardStep activatedStep) { + super(source); + this.activatedStep = activatedStep; + } + + /** + * Returns the {@link WizardStep} that was the activated. + * + * @return the activated {@link WizardStep}. + */ + public WizardStep getActivatedStep() { + return activatedStep; + } + } \ No newline at end of file diff --git a/wizards-for-vaadin/src/main/java/org/vaadin/teemu/wizards/event/WizardStepSetChangedEvent.java b/wizards-for-vaadin/src/main/java/org/vaadin/teemu/wizards/event/WizardStepSetChangedEvent.java index 8e44a48..2cc4f50 100644 --- a/wizards-for-vaadin/src/main/java/org/vaadin/teemu/wizards/event/WizardStepSetChangedEvent.java +++ b/wizards-for-vaadin/src/main/java/org/vaadin/teemu/wizards/event/WizardStepSetChangedEvent.java @@ -1,12 +1,12 @@ -package org.vaadin.teemu.wizards.event; - -import org.vaadin.teemu.wizards.Wizard; - -@SuppressWarnings("serial") -public class WizardStepSetChangedEvent extends AbstractWizardEvent { - - public WizardStepSetChangedEvent(Wizard source) { - super(source); - } - -} +package org.vaadin.teemu.wizards.event; + +import org.vaadin.teemu.wizards.Wizard; + +@SuppressWarnings("serial") +public class WizardStepSetChangedEvent extends AbstractWizardEvent { + + public WizardStepSetChangedEvent(Wizard source) { + super(source); + } + +} diff --git a/wizards-for-vaadin/src/main/java/org/vaadin/teemu/wizards/wizard-progress-bar.css b/wizards-for-vaadin/src/main/java/org/vaadin/teemu/wizards/wizard-progress-bar.css index 8cb27dc..fee303b 100644 --- a/wizards-for-vaadin/src/main/java/org/vaadin/teemu/wizards/wizard-progress-bar.css +++ b/wizards-for-vaadin/src/main/java/org/vaadin/teemu/wizards/wizard-progress-bar.css @@ -1,26 +1,26 @@ -.wizard-progress-bar .v-progressbar-wrapper { - background: transparent; - border: none; - height: 10px; -} -.wizard-progress-bar .v-progressbar-indicator { - height: 100%; - background: #00b3ef; - background: -webkit-linear-gradient(#20d4ff, #009cd0); - background: linear-gradient(#20d4ff, #009cd0); - -webkit-transition: width 0.5s ease-out 0s; - transition: width 0.5s ease-out 0s; -} -.wizard-progress-bar .v-label-step-caption { - font-size: 13px; - white-space: nowrap; - text-align: center; - color: #bfbfbf; -} -.wizard-progress-bar .v-label-current, -.wizard-progress-bar .v-label-completed { - color: #000; -} -.wizard-progress-bar .v-label-current { - font-weight: bold; +.wizard-progress-bar .v-progressbar-wrapper { + background: transparent; + border: none; + height: 10px; +} +.wizard-progress-bar .v-progressbar-indicator { + height: 100%; + background: #00b3ef; + background: -webkit-linear-gradient(#20d4ff, #009cd0); + background: linear-gradient(#20d4ff, #009cd0); + -webkit-transition: width 0.5s ease-out 0s; + transition: width 0.5s ease-out 0s; +} +.wizard-progress-bar .v-label-step-caption { + font-size: 13px; + white-space: nowrap; + text-align: center; + color: #bfbfbf; +} +.wizard-progress-bar .v-label-current, +.wizard-progress-bar .v-label-completed { + color: #000; +} +.wizard-progress-bar .v-label-current { + font-weight: bold; } \ No newline at end of file diff --git a/wizards-for-vaadin/src/test/java/org/vaadin/teemu/wizards/WizardTests.java b/wizards-for-vaadin/src/test/java/org/vaadin/teemu/wizards/WizardTests.java index 381db6c..d4224fb 100644 --- a/wizards-for-vaadin/src/test/java/org/vaadin/teemu/wizards/WizardTests.java +++ b/wizards-for-vaadin/src/test/java/org/vaadin/teemu/wizards/WizardTests.java @@ -1,44 +1,44 @@ -package org.vaadin.teemu.wizards; - -import junit.framework.Assert; - -import org.junit.Test; -import org.mockito.Mockito; - -public class WizardTests { - - @Test(expected = IllegalArgumentException.class) - public void addStep_duplicateId_exceptionThrown() { - WizardStep step1 = Mockito.mock(WizardStep.class); - WizardStep step2 = Mockito.mock(WizardStep.class); - Wizard wizard = new Wizard(); - wizard.addStep(step1, "duplicateId"); - wizard.addStep(step2, "duplicateId"); - } - - /** - * Test case for a bug reported at Vaadin Forum. - * - * Thanks to Johan Smolders for the bug report. - */ - @Test - public void addStep_removeAndAdd_noDuplicatesSizeIsCorrect() { - WizardStep step1 = Mockito.mock(WizardStep.class); - WizardStep step2 = Mockito.mock(WizardStep.class); - WizardStep step3 = Mockito.mock(WizardStep.class); - WizardStep step4 = Mockito.mock(WizardStep.class); - - Wizard wizard = new Wizard(); - wizard.addStep(step1); - wizard.addStep(step2); - wizard.addStep(step3); - wizard.removeStep(step2); - wizard.addStep(step4); // this should not throw exception - - // check the size - Assert.assertEquals(3, wizard.getSteps().size()); - } - -} +package org.vaadin.teemu.wizards; + +import junit.framework.Assert; + +import org.junit.Test; +import org.mockito.Mockito; + +public class WizardTests { + + @Test(expected = IllegalArgumentException.class) + public void addStep_duplicateId_exceptionThrown() { + WizardStep step1 = Mockito.mock(WizardStep.class); + WizardStep step2 = Mockito.mock(WizardStep.class); + Wizard wizard = new Wizard(); + wizard.addStep(step1, "duplicateId"); + wizard.addStep(step2, "duplicateId"); + } + + /** + * Test case for a bug reported at Vaadin Forum. + * + * Thanks to Johan Smolders for the bug report. + */ + @Test + public void addStep_removeAndAdd_noDuplicatesSizeIsCorrect() { + WizardStep step1 = Mockito.mock(WizardStep.class); + WizardStep step2 = Mockito.mock(WizardStep.class); + WizardStep step3 = Mockito.mock(WizardStep.class); + WizardStep step4 = Mockito.mock(WizardStep.class); + + Wizard wizard = new Wizard(); + wizard.addStep(step1); + wizard.addStep(step2); + wizard.addStep(step3); + wizard.removeStep(step2); + wizard.addStep(step4); // this should not throw exception + + // check the size + Assert.assertEquals(3, wizard.getSteps().size()); + } + +}