From 0ec3379ac00df225766aedb53072839eefd260f8 Mon Sep 17 00:00:00 2001
From: Artur Signell
* If the validation fails, the exception thrown contains the error message with
diff --git a/src/com/vaadin/data/validator/AbstractValidator.java b/src/com/vaadin/data/validator/AbstractValidator.java
index 5cfc8a57e8..94222049a9 100644
--- a/src/com/vaadin/data/validator/AbstractValidator.java
+++ b/src/com/vaadin/data/validator/AbstractValidator.java
@@ -3,8 +3,8 @@ package com.vaadin.data.validator;
import com.vaadin.data.Validator;
/**
- * Default Validator base class. See
- * {@link com.vaadin.data.validator.Validator} for more information.
+ * Default Validator base class. See {@link com.vaadin.data.validator.Validator}
+ * for more information.
*
* If the validation fails, the exception thrown contains the error message with
* its argument 0 replaced with the toString() of the object being validated.
diff --git a/src/com/vaadin/data/validator/EmailValidator.java b/src/com/vaadin/data/validator/EmailValidator.java
index edb7c8ce80..24bfb166d6 100644
--- a/src/com/vaadin/data/validator/EmailValidator.java
+++ b/src/com/vaadin/data/validator/EmailValidator.java
@@ -5,8 +5,8 @@ package com.vaadin.data.validator;
* complete according to RFC 822 but handles the vast majority of valid e-mail
* addresses correctly.
*
- * See {@link com.vaadin.data.validator.AbstractStringValidator} for
- * more information.
+ * See {@link com.vaadin.data.validator.AbstractStringValidator} for more
+ * information.
*
* @author IT Mill Ltd.
* @version
diff --git a/src/com/vaadin/event/FieldEvents.java b/src/com/vaadin/event/FieldEvents.java
index b298590a8c..0280aebb76 100644
--- a/src/com/vaadin/event/FieldEvents.java
+++ b/src/com/vaadin/event/FieldEvents.java
@@ -23,6 +23,7 @@ public interface FieldEvents {
* class really will send the events, or if it just defines the methods to
* be able to implement an interface.
*
* For more information on the inheritable event mechanism see the - * {@link com.vaadin.event com.vaadin.event package - * documentation}. + * {@link com.vaadin.event com.vaadin.event package documentation}. *
* * @author IT Mill Ltd. @@ -35,8 +34,7 @@ public interface MethodEventSource extends Serializable { * ** For more information on the inheritable event mechanism see the - * {@link com.vaadin.event com.vaadin.event package - * documentation}. + * {@link com.vaadin.event com.vaadin.event package documentation}. *
* * @param eventType @@ -69,8 +67,7 @@ public interface MethodEventSource extends Serializable { * ** For more information on the inheritable event mechanism see the - * {@link com.vaadin.event com.vaadin.event package - * documentation}. + * {@link com.vaadin.event com.vaadin.event package documentation}. *
* * @param eventType @@ -95,8 +92,7 @@ public interface MethodEventSource extends Serializable { * ** For more information on the inheritable event mechanism see the - * {@link com.vaadin.event com.vaadin.event package - * documentation}. + * {@link com.vaadin.event com.vaadin.event package documentation}. *
* * @param eventType @@ -114,8 +110,7 @@ public interface MethodEventSource extends Serializable { * ** For more information on the inheritable event mechanism see the - * {@link com.vaadin.event com.vaadin.event package - * documentation}. + * {@link com.vaadin.event com.vaadin.event package documentation}. *
* * @param eventType @@ -145,8 +140,7 @@ public interface MethodEventSource extends Serializable { * ** For more information on the inheritable event mechanism see the - * {@link com.vaadin.event com.vaadin.event package - * documentation}. + * {@link com.vaadin.event com.vaadin.event package documentation}. *
* * @param eventType diff --git a/src/com/vaadin/launcher/util/BrowserLauncher.java b/src/com/vaadin/launcher/util/BrowserLauncher.java index 9775bdc48e..f30a717cf6 100644 --- a/src/com/vaadin/launcher/util/BrowserLauncher.java +++ b/src/com/vaadin/launcher/util/BrowserLauncher.java @@ -35,33 +35,35 @@ public class BrowserLauncher { // See if the default browser is Konqueror by resolving the symlink. boolean isDefaultKonqueror = false; try { - // Find out the location of the x-www-browser link from path. - Process process = runtime.exec("which x-www-browser"); - BufferedInputStream ins = new BufferedInputStream(process.getInputStream()); - BufferedReader bufreader = new BufferedReader(new InputStreamReader(ins)); - String defaultLinkPath = bufreader.readLine(); - ins.close(); - - // The path is null if the link did not exist. - if (defaultLinkPath != null) { - // See if the default browser is Konqueror. - File file = new File(defaultLinkPath); - String canonical = file.getCanonicalPath(); - if (canonical.indexOf("konqueror") != -1) - isDefaultKonqueror = true; - } + // Find out the location of the x-www-browser link from path. + Process process = runtime.exec("which x-www-browser"); + BufferedInputStream ins = new BufferedInputStream(process + .getInputStream()); + BufferedReader bufreader = new BufferedReader( + new InputStreamReader(ins)); + String defaultLinkPath = bufreader.readLine(); + ins.close(); + + // The path is null if the link did not exist. + if (defaultLinkPath != null) { + // See if the default browser is Konqueror. + File file = new File(defaultLinkPath); + String canonical = file.getCanonicalPath(); + if (canonical.indexOf("konqueror") != -1) + isDefaultKonqueror = true; + } } catch (IOException e1) { - // The symlink was probably not found, so this is ok. + // The symlink was probably not found, so this is ok. } // Try x-www-browser, which is symlink to the default browser, // except if we found that it is Konqueror. if (!started && !isDefaultKonqueror) { - try { - runtime.exec("x-www-browser " + url); - started = true; - } catch (final IOException e) { - } + try { + runtime.exec("x-www-browser " + url); + started = true; + } catch (final IOException e) { + } } // Try firefox diff --git a/src/com/vaadin/terminal/Resource.java b/src/com/vaadin/terminal/Resource.java index 07753aad16..2aee741f01 100644 --- a/src/com/vaadin/terminal/Resource.java +++ b/src/com/vaadin/terminal/Resource.java @@ -15,7 +15,7 @@ import java.io.Serializable; * @VERSION@ * @since 3.0 */ -public interface Resource extends Serializable{ +public interface Resource extends Serializable { /** * Gets the MIME type of the resource. diff --git a/src/com/vaadin/terminal/Sizeable.java b/src/com/vaadin/terminal/Sizeable.java index 6c18f746f2..0504451e19 100644 --- a/src/com/vaadin/terminal/Sizeable.java +++ b/src/com/vaadin/terminal/Sizeable.java @@ -15,7 +15,7 @@ import java.io.Serializable; * @VERSION@ * @since 3.0 */ -public interface Sizeable extends Serializable{ +public interface Sizeable extends Serializable { /** * Unit code representing pixels. diff --git a/src/com/vaadin/terminal/Terminal.java b/src/com/vaadin/terminal/Terminal.java index 4494bdc144..2ce013f6be 100644 --- a/src/com/vaadin/terminal/Terminal.java +++ b/src/com/vaadin/terminal/Terminal.java @@ -40,7 +40,7 @@ public interface Terminal extends Serializable { /** * Terminal error event. */ - public interface ErrorEvent extends Serializable{ + public interface ErrorEvent extends Serializable { /** * Gets the contained throwable. @@ -52,7 +52,7 @@ public interface Terminal extends Serializable { /** * Terminal error listener interface. */ - public interface ErrorListener extends Serializable{ + public interface ErrorListener extends Serializable { /** * Invoked when terminal error occurs. diff --git a/src/com/vaadin/terminal/gwt/client/Paintable.java b/src/com/vaadin/terminal/gwt/client/Paintable.java index 54713bd5b7..0cf5571829 100644 --- a/src/com/vaadin/terminal/gwt/client/Paintable.java +++ b/src/com/vaadin/terminal/gwt/client/Paintable.java @@ -8,7 +8,7 @@ package com.vaadin.terminal.gwt.client; * An interface used by client-side widgets or paintable parts to receive * updates from the corresponding server-side components in the form of * {@link UIDL}. - * + * * Updates can be sent back to the server using the * {@link ApplicationConnection#updateVariable()} methods. */ diff --git a/src/com/vaadin/terminal/gwt/client/ui/MenuBar.java b/src/com/vaadin/terminal/gwt/client/ui/MenuBar.java index f950014ad7..5d10044d64 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/MenuBar.java +++ b/src/com/vaadin/terminal/gwt/client/ui/MenuBar.java @@ -42,9 +42,13 @@ import com.google.gwt.user.client.ui.Widget; * * * - **
* Alternatives for implementing similar features are are Servlet {@link Filter}
* s and {@link TransactionListener}s in Vaadin.
- *
+ *
* @since 6.2
* @see PortletRequestListener
*/
@@ -33,7 +33,7 @@ public interface HttpServletRequestListener extends Serializable {
/**
* This method is called before {@link Terminal} applies the request to
* Application.
- *
+ *
* @param request
* @param response
*/
@@ -42,7 +42,7 @@ public interface HttpServletRequestListener extends Serializable {
/**
* This method is called at the end of each request.
- *
+ *
* @param request
* @param response
*/
diff --git a/src/com/vaadin/terminal/gwt/server/HttpUploadStream.java b/src/com/vaadin/terminal/gwt/server/HttpUploadStream.java
index c9e3c77cad..40b5d41004 100644
--- a/src/com/vaadin/terminal/gwt/server/HttpUploadStream.java
+++ b/src/com/vaadin/terminal/gwt/server/HttpUploadStream.java
@@ -15,8 +15,7 @@ import java.io.InputStream;
* @since 5.0
*/
@SuppressWarnings("serial")
-public class HttpUploadStream implements
- com.vaadin.terminal.UploadStream {
+public class HttpUploadStream implements com.vaadin.terminal.UploadStream {
/**
* Holds value of property variableName.
diff --git a/src/com/vaadin/terminal/gwt/server/PortletApplicationContext2.java b/src/com/vaadin/terminal/gwt/server/PortletApplicationContext2.java
index 8effcb6c65..ab1b1da81f 100644
--- a/src/com/vaadin/terminal/gwt/server/PortletApplicationContext2.java
+++ b/src/com/vaadin/terminal/gwt/server/PortletApplicationContext2.java
@@ -34,10 +34,10 @@ import com.vaadin.ui.Window;
/**
* TODO Write documentation, fix JavaDoc tags.
- *
+ *
* This is automatically registered as a {@link HttpSessionBindingListener} when
* {@link PortletSession#setAttribute()} is called with the context as value.
- *
+ *
* @author peholmst
*/
@SuppressWarnings("serial")
@@ -144,7 +144,8 @@ public class PortletApplicationContext2 extends AbstractWebApplicationContext {
Set
* If module definition file contains text "WS Compiler: manually edited", tool
* will skip editing file.
- *
+ *
*/
public class WidgetSetBuilder {
diff --git a/src/com/vaadin/ui/BaseFieldFactory.java b/src/com/vaadin/ui/BaseFieldFactory.java
index 0be76ab2b3..50478f4310 100644
--- a/src/com/vaadin/ui/BaseFieldFactory.java
+++ b/src/com/vaadin/ui/BaseFieldFactory.java
@@ -11,9 +11,10 @@ import com.vaadin.data.Property;
/**
* Default implementation of the the following Field types are used by default:
*
- * Boolean: Button(switchMode:true).
*
* @author IT Mill Ltd.
diff --git a/tests/src/com/vaadin/automatedtests/featurebrowser/GeneratedColumnExample.java b/tests/src/com/vaadin/automatedtests/featurebrowser/GeneratedColumnExample.java
index 095af6c02d..0988715286 100644
--- a/tests/src/com/vaadin/automatedtests/featurebrowser/GeneratedColumnExample.java
+++ b/tests/src/com/vaadin/automatedtests/featurebrowser/GeneratedColumnExample.java
@@ -455,8 +455,8 @@ public class GeneratedColumnExample extends CustomComponent {
null);
table.addContainerProperty("quantity", Double.class, null,
"Quantity (l)", null, null);
- table.addContainerProperty("price", Double.class, null, "Price (€/l)",
- null, null);
+ table.addContainerProperty("price", Double.class, null,
+ "Price (€/l)", null, null);
table.addContainerProperty("total", Double.class, null, "Total (€)",
null, null);
table.addContainerProperty("consumption", Double.class, null,
diff --git a/tests/src/com/vaadin/automatedtests/robustness/Robustness.java b/tests/src/com/vaadin/automatedtests/robustness/Robustness.java
index 13add217cd..1e8a3766f2 100644
--- a/tests/src/com/vaadin/automatedtests/robustness/Robustness.java
+++ b/tests/src/com/vaadin/automatedtests/robustness/Robustness.java
@@ -12,8 +12,8 @@ import com.vaadin.ui.Label;
import com.vaadin.ui.Window;
import com.vaadin.ui.Button.ClickEvent;
-public abstract class Robustness extends com.vaadin.Application
- implements Button.ClickListener {
+public abstract class Robustness extends com.vaadin.Application implements
+ Button.ClickListener {
static int totalCount = 0;
diff --git a/tests/src/com/vaadin/tests/Parameters.java b/tests/src/com/vaadin/tests/Parameters.java
index 6d887b03ad..bb026a8955 100644
--- a/tests/src/com/vaadin/tests/Parameters.java
+++ b/tests/src/com/vaadin/tests/Parameters.java
@@ -26,8 +26,8 @@ import com.vaadin.ui.Window;
*
* @since 3.1.1
*/
-public class Parameters extends com.vaadin.Application implements
- URIHandler, ParameterHandler {
+public class Parameters extends com.vaadin.Application implements URIHandler,
+ ParameterHandler {
private final Label context = new Label();
diff --git a/tests/src/com/vaadin/tests/TestBench.java b/tests/src/com/vaadin/tests/TestBench.java
index a77e60fa65..c3d7155b50 100644
--- a/tests/src/com/vaadin/tests/TestBench.java
+++ b/tests/src/com/vaadin/tests/TestBench.java
@@ -41,292 +41,291 @@ import com.vaadin.ui.UriFragmentUtility.FragmentChangedEvent;
*
*/
public class TestBench extends com.vaadin.Application implements
- Property.ValueChangeListener {
-
- // Add here packages which are used for finding testable classes
- String[] testablePackages = { "com.vaadin.tests",
- "com.vaadin.demo", "com.vaadin.demo.colorpicker",
- "com.vaadin.demo.reservation",
- "com.vaadin.demo.features",
- "com.vaadin.tests.tickets", "com.vaadin.tests.book" };
-
- HierarchicalContainer testables = new HierarchicalContainer();
-
- Window mainWindow = new Window("TestBench window");
-
- // Main layout consists of tree menu and body layout
- SplitPanel mainLayout = new SplitPanel(SplitPanel.ORIENTATION_HORIZONTAL);
-
- Tree menu;
-
- Panel bodyLayout = new Panel();
-
- HashMap itemCaptions = new HashMap();
-
- @Override
- public void init() {
-
- // Add testable classes to hierarchical container
- for (int p = 0; p < testablePackages.length; p++) {
- testables.addItem(testablePackages[p]);
- try {
- final List testableClasses = getTestableClassesForPackage(testablePackages[p]);
- for (final Iterator it = testableClasses.iterator(); it
- .hasNext();) {
- final Class t = (Class) it.next();
- // ignore TestBench itself
- if (t.equals(TestBench.class)) {
- continue;
- }
- try {
- testables.addItem(t);
- itemCaptions.put(t, t.getName());
- testables.setParent(t, testablePackages[p]);
- testables.setChildrenAllowed(t, false);
- continue;
- } catch (final Exception e) {
- try {
- testables.addItem(t);
- itemCaptions.put(t, t.getName());
- testables.setParent(t, testablePackages[p]);
- testables.setChildrenAllowed(t, false);
- continue;
- } catch (final Exception e1) {
- e1.printStackTrace();
- }
- }
- }
- } catch (final Exception e) {
- e.printStackTrace();
- }
- }
-
- menu = new Tree("Testables", testables);
-
- for (final Iterator i = itemCaptions.keySet().iterator(); i.hasNext();) {
- final Class testable = (Class) i.next();
- // simplify captions
- final String name = testable.getName().substring(
- testable.getName().lastIndexOf('.') + 1);
- menu.setItemCaption(testable, name);
- }
- // expand all root items
- for (final Iterator i = menu.rootItemIds().iterator(); i.hasNext();) {
- menu.expandItemsRecursively(i.next());
- }
-
- menu.addListener(this);
- menu.setImmediate(true);
- menu.setNullSelectionAllowed(false);
- VerticalLayout lo = new VerticalLayout();
- lo.addComponent(menu);
-
- UriFragmentUtility uri = new UriFragmentUtility();
- lo.addComponent(uri);
-
- uri.addListener(new UriFragmentUtility.FragmentChangedListener() {
- public void fragmentChanged(FragmentChangedEvent source) {
- String fragment = source.getUriFragmentUtility().getFragment();
- if (fragment != null && !"".equals(fragment)) {
- // try to find a proper test class
-
- // exact match
- Iterator iterator = menu.getItemIds().iterator();
- while (iterator.hasNext()) {
- Object next = iterator.next();
- if (next instanceof Class) {
- Class c = (Class) next;
- String string = c.getName();
- if (string.equals(fragment)) {
- menu.setValue(c);
- mainLayout.setSplitPosition(0);
- return;
- }
- }
- }
-
- // simple name match
- iterator = menu.getItemIds().iterator();
- while (iterator.hasNext()) {
- Object next = iterator.next();
- if (next instanceof Class) {
- Class c = (Class) next;
- String string = c.getSimpleName();
- if (string.equals(fragment)) {
- menu.setValue(c);
- mainLayout.setSplitPosition(0);
- return;
- }
- }
- }
- // ticket match
- iterator = menu.getItemIds().iterator();
- while (iterator.hasNext()) {
- Object next = iterator.next();
- if (next instanceof Class) {
- Class c = (Class) next;
- String string = c.getSimpleName();
- if (string.startsWith("Ticket" + fragment)) {
- menu.setValue(c);
- mainLayout.setSplitPosition(0);
- return;
- }
- }
- }
-
- // just partly mach lowercase
- iterator = menu.getItemIds().iterator();
- while (iterator.hasNext()) {
- Object next = iterator.next();
- if (next instanceof Class) {
- Class c = (Class) next;
- String string = c.getSimpleName();
- if (string.toLowerCase().contains(
- fragment.toLowerCase())) {
- menu.setValue(c);
- mainLayout.setSplitPosition(0);
- return;
- }
- }
- }
-
- getMainWindow().showNotification(
- "No potential matc for #" + fragment);
-
- }
-
- }
- });
-
- mainLayout.addComponent(lo);
-
- bodyLayout.addStyleName("light");
- bodyLayout.setSizeFull();
- bodyLayout.setLayout(new ExpandLayout());
-
- mainLayout.addComponent(bodyLayout);
-
- mainLayout.setSplitPosition(30);
-
- mainWindow.setLayout(mainLayout);
-
- setMainWindow(mainWindow);
- }
-
- private Component createTestable(Class c) {
- try {
- final Application app = (Application) c.newInstance();
- app.init();
- Layout lo = app.getMainWindow().getLayout();
- lo.setParent(null);
- return lo;
- } catch (final Exception e) {
- try {
- final CustomComponent cc = (CustomComponent) c.newInstance();
- cc.setSizeFull();
- return cc;
- } catch (final Exception e1) {
- e1.printStackTrace();
- VerticalLayout lo = new VerticalLayout();
- lo.addComponent(new Label(
- "Cannot create application / custom component: "
- + e1.toString()));
-
- Link l = new Link("Try opening via app runner",
- new ExternalResource("../run/" + c.getName()));
- lo.addComponent(l);
-
- return lo;
- }
- }
- }
-
- // Handle menu selection and update body
- public void valueChange(Property.ValueChangeEvent event) {
- bodyLayout.removeAllComponents();
- bodyLayout.setCaption(null);
-
- final Object o = menu.getValue();
- if (o != null && o instanceof Class) {
- final Class c = (Class) o;
- final String title = c.getName();
- bodyLayout.setCaption(title);
- bodyLayout.addComponent(createTestable(c));
- } else {
- // NOP node selected or deselected tree item
- }
- }
-
- /**
- * Return all testable classes within given package. Class is considered
- * testable if it's superclass is Application or CustomComponent.
- *
- * @param packageName
- * @return
- * @throws ClassNotFoundException
- */
- public static List getTestableClassesForPackage(String packageName)
- throws Exception {
- final ArrayList directories = new ArrayList();
- try {
- final ClassLoader cld = Thread.currentThread()
- .getContextClassLoader();
- if (cld == null) {
- throw new ClassNotFoundException("Can't get class loader.");
- }
- final String path = packageName.replace('.', '/');
- // Ask for all resources for the path
- final Enumeration resources = cld.getResources(path);
- while (resources.hasMoreElements()) {
- final URL url = (URL) resources.nextElement();
- directories.add(new File(url.getFile()));
- }
- } catch (final Exception x) {
- throw new Exception(packageName
- + " does not appear to be a valid package.");
- }
-
- final ArrayList classes = new ArrayList();
- // For every directory identified capture all the .class files
- for (final Iterator it = directories.iterator(); it.hasNext();) {
- final File directory = (File) it.next();
- if (directory.exists()) {
- // Get the list of the files contained in the package
- final String[] files = directory.list();
- for (int j = 0; j < files.length; j++) {
- // we are only interested in .class files
- if (files[j].endsWith(".class")) {
- // removes the .class extension
- final String p = packageName + '.'
- + files[j].substring(0, files[j].length() - 6);
- final Class c = Class.forName(p);
- if (c.getSuperclass() != null) {
- if ((c.getSuperclass()
- .equals(com.vaadin.Application.class))) {
- classes.add(c);
- } else if ((c.getSuperclass()
- .equals(com.vaadin.ui.CustomComponent.class))) {
- classes.add(c);
- }
- }
-
- // for (int i = 0; i < c.getInterfaces().length; i++) {
- // Class cc = c.getInterfaces()[i];
- // if (c.getInterfaces()[i].equals(Testable.class)) {
- // // Class is testable
- // classes.add(c);
- // }
- // }
- }
- }
- } else {
- throw new ClassNotFoundException(packageName + " ("
- + directory.getPath()
- + ") does not appear to be a valid package");
- }
- }
-
- return classes;
- }
+ Property.ValueChangeListener {
+
+ // Add here packages which are used for finding testable classes
+ String[] testablePackages = { "com.vaadin.tests", "com.vaadin.demo",
+ "com.vaadin.demo.colorpicker", "com.vaadin.demo.reservation",
+ "com.vaadin.demo.features", "com.vaadin.tests.tickets",
+ "com.vaadin.tests.book" };
+
+ HierarchicalContainer testables = new HierarchicalContainer();
+
+ Window mainWindow = new Window("TestBench window");
+
+ // Main layout consists of tree menu and body layout
+ SplitPanel mainLayout = new SplitPanel(SplitPanel.ORIENTATION_HORIZONTAL);
+
+ Tree menu;
+
+ Panel bodyLayout = new Panel();
+
+ HashMap itemCaptions = new HashMap();
+
+ @Override
+ public void init() {
+
+ // Add testable classes to hierarchical container
+ for (int p = 0; p < testablePackages.length; p++) {
+ testables.addItem(testablePackages[p]);
+ try {
+ final List testableClasses = getTestableClassesForPackage(testablePackages[p]);
+ for (final Iterator it = testableClasses.iterator(); it
+ .hasNext();) {
+ final Class t = (Class) it.next();
+ // ignore TestBench itself
+ if (t.equals(TestBench.class)) {
+ continue;
+ }
+ try {
+ testables.addItem(t);
+ itemCaptions.put(t, t.getName());
+ testables.setParent(t, testablePackages[p]);
+ testables.setChildrenAllowed(t, false);
+ continue;
+ } catch (final Exception e) {
+ try {
+ testables.addItem(t);
+ itemCaptions.put(t, t.getName());
+ testables.setParent(t, testablePackages[p]);
+ testables.setChildrenAllowed(t, false);
+ continue;
+ } catch (final Exception e1) {
+ e1.printStackTrace();
+ }
+ }
+ }
+ } catch (final Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ menu = new Tree("Testables", testables);
+
+ for (final Iterator i = itemCaptions.keySet().iterator(); i.hasNext();) {
+ final Class testable = (Class) i.next();
+ // simplify captions
+ final String name = testable.getName().substring(
+ testable.getName().lastIndexOf('.') + 1);
+ menu.setItemCaption(testable, name);
+ }
+ // expand all root items
+ for (final Iterator i = menu.rootItemIds().iterator(); i.hasNext();) {
+ menu.expandItemsRecursively(i.next());
+ }
+
+ menu.addListener(this);
+ menu.setImmediate(true);
+ menu.setNullSelectionAllowed(false);
+ VerticalLayout lo = new VerticalLayout();
+ lo.addComponent(menu);
+
+ UriFragmentUtility uri = new UriFragmentUtility();
+ lo.addComponent(uri);
+
+ uri.addListener(new UriFragmentUtility.FragmentChangedListener() {
+ public void fragmentChanged(FragmentChangedEvent source) {
+ String fragment = source.getUriFragmentUtility().getFragment();
+ if (fragment != null && !"".equals(fragment)) {
+ // try to find a proper test class
+
+ // exact match
+ Iterator iterator = menu.getItemIds().iterator();
+ while (iterator.hasNext()) {
+ Object next = iterator.next();
+ if (next instanceof Class) {
+ Class c = (Class) next;
+ String string = c.getName();
+ if (string.equals(fragment)) {
+ menu.setValue(c);
+ mainLayout.setSplitPosition(0);
+ return;
+ }
+ }
+ }
+
+ // simple name match
+ iterator = menu.getItemIds().iterator();
+ while (iterator.hasNext()) {
+ Object next = iterator.next();
+ if (next instanceof Class) {
+ Class c = (Class) next;
+ String string = c.getSimpleName();
+ if (string.equals(fragment)) {
+ menu.setValue(c);
+ mainLayout.setSplitPosition(0);
+ return;
+ }
+ }
+ }
+ // ticket match
+ iterator = menu.getItemIds().iterator();
+ while (iterator.hasNext()) {
+ Object next = iterator.next();
+ if (next instanceof Class) {
+ Class c = (Class) next;
+ String string = c.getSimpleName();
+ if (string.startsWith("Ticket" + fragment)) {
+ menu.setValue(c);
+ mainLayout.setSplitPosition(0);
+ return;
+ }
+ }
+ }
+
+ // just partly mach lowercase
+ iterator = menu.getItemIds().iterator();
+ while (iterator.hasNext()) {
+ Object next = iterator.next();
+ if (next instanceof Class) {
+ Class c = (Class) next;
+ String string = c.getSimpleName();
+ if (string.toLowerCase().contains(
+ fragment.toLowerCase())) {
+ menu.setValue(c);
+ mainLayout.setSplitPosition(0);
+ return;
+ }
+ }
+ }
+
+ getMainWindow().showNotification(
+ "No potential matc for #" + fragment);
+
+ }
+
+ }
+ });
+
+ mainLayout.addComponent(lo);
+
+ bodyLayout.addStyleName("light");
+ bodyLayout.setSizeFull();
+ bodyLayout.setLayout(new ExpandLayout());
+
+ mainLayout.addComponent(bodyLayout);
+
+ mainLayout.setSplitPosition(30);
+
+ mainWindow.setLayout(mainLayout);
+
+ setMainWindow(mainWindow);
+ }
+
+ private Component createTestable(Class c) {
+ try {
+ final Application app = (Application) c.newInstance();
+ app.init();
+ Layout lo = app.getMainWindow().getLayout();
+ lo.setParent(null);
+ return lo;
+ } catch (final Exception e) {
+ try {
+ final CustomComponent cc = (CustomComponent) c.newInstance();
+ cc.setSizeFull();
+ return cc;
+ } catch (final Exception e1) {
+ e1.printStackTrace();
+ VerticalLayout lo = new VerticalLayout();
+ lo.addComponent(new Label(
+ "Cannot create application / custom component: "
+ + e1.toString()));
+
+ Link l = new Link("Try opening via app runner",
+ new ExternalResource("../run/" + c.getName()));
+ lo.addComponent(l);
+
+ return lo;
+ }
+ }
+ }
+
+ // Handle menu selection and update body
+ public void valueChange(Property.ValueChangeEvent event) {
+ bodyLayout.removeAllComponents();
+ bodyLayout.setCaption(null);
+
+ final Object o = menu.getValue();
+ if (o != null && o instanceof Class) {
+ final Class c = (Class) o;
+ final String title = c.getName();
+ bodyLayout.setCaption(title);
+ bodyLayout.addComponent(createTestable(c));
+ } else {
+ // NOP node selected or deselected tree item
+ }
+ }
+
+ /**
+ * Return all testable classes within given package. Class is considered
+ * testable if it's superclass is Application or CustomComponent.
+ *
+ * @param packageName
+ * @return
+ * @throws ClassNotFoundException
+ */
+ public static List getTestableClassesForPackage(String packageName)
+ throws Exception {
+ final ArrayList directories = new ArrayList();
+ try {
+ final ClassLoader cld = Thread.currentThread()
+ .getContextClassLoader();
+ if (cld == null) {
+ throw new ClassNotFoundException("Can't get class loader.");
+ }
+ final String path = packageName.replace('.', '/');
+ // Ask for all resources for the path
+ final Enumeration resources = cld.getResources(path);
+ while (resources.hasMoreElements()) {
+ final URL url = (URL) resources.nextElement();
+ directories.add(new File(url.getFile()));
+ }
+ } catch (final Exception x) {
+ throw new Exception(packageName
+ + " does not appear to be a valid package.");
+ }
+
+ final ArrayList classes = new ArrayList();
+ // For every directory identified capture all the .class files
+ for (final Iterator it = directories.iterator(); it.hasNext();) {
+ final File directory = (File) it.next();
+ if (directory.exists()) {
+ // Get the list of the files contained in the package
+ final String[] files = directory.list();
+ for (int j = 0; j < files.length; j++) {
+ // we are only interested in .class files
+ if (files[j].endsWith(".class")) {
+ // removes the .class extension
+ final String p = packageName + '.'
+ + files[j].substring(0, files[j].length() - 6);
+ final Class c = Class.forName(p);
+ if (c.getSuperclass() != null) {
+ if ((c.getSuperclass()
+ .equals(com.vaadin.Application.class))) {
+ classes.add(c);
+ } else if ((c.getSuperclass()
+ .equals(com.vaadin.ui.CustomComponent.class))) {
+ classes.add(c);
+ }
+ }
+
+ // for (int i = 0; i < c.getInterfaces().length; i++) {
+ // Class cc = c.getInterfaces()[i];
+ // if (c.getInterfaces()[i].equals(Testable.class)) {
+ // // Class is testable
+ // classes.add(c);
+ // }
+ // }
+ }
+ }
+ } else {
+ throw new ClassNotFoundException(packageName + " ("
+ + directory.getPath()
+ + ") does not appear to be a valid package");
+ }
+ }
+
+ return classes;
+ }
}
diff --git a/tests/src/com/vaadin/tests/book/BookTestApplication.java b/tests/src/com/vaadin/tests/book/BookTestApplication.java
index 6d3b653baf..1491898f3d 100644
--- a/tests/src/com/vaadin/tests/book/BookTestApplication.java
+++ b/tests/src/com/vaadin/tests/book/BookTestApplication.java
@@ -64,1721 +64,1727 @@ import com.vaadin.ui.Layout.AlignmentHandler;
import com.vaadin.ui.MenuBar.MenuItem;
public class BookTestApplication extends com.vaadin.Application {
- Window main = new Window("Application window");
-
- TheButton butts1;
- TheButtons butts2;
- TheButtons2 butts3;
-
- Label mylabel1;
- Label mylabel2;
- Label mylabel3;
-
- StreamResource strres;
- VerticalLayout ol;
- int getwincount = 0;
-
- @Override
- public void init() {
- setTheme("tests-book");
-
- setMainWindow(main);
-
- main.getContent().setSizeFull();
-
- // Demo the use of parameter and URI handlers
- main.addParameterHandler(new MyParameterHandler());
- main.addURIHandler(new MyURIHandler());
-
- MyDynamicResource myresource = new MyDynamicResource();
- main.addParameterHandler(myresource);
- main.addURIHandler(myresource);
-
- main.addURIHandler(new BookTestURIHandler());
- }
-
- class MyParameterHandler implements ParameterHandler {
- public void handleParameters(Map parameters) {
- // Print out the parameters to standard output
- for (Iterator it = parameters.keySet().iterator(); it.hasNext();) {
- String key = (String) it.next();
- String value = ((String[]) parameters.get(key))[0];
- System.out.println("Key: " + key + ", value: " + value);
- }
- }
- }
-
- class MyURIHandler implements URIHandler {
- public DownloadStream handleURI(URL context, String relativeUri) {
- System.out.println("Context: " + context.toString()
- + ", relative: " + relativeUri);
- return null; // Let the Application provide the response
- }
- }
-
- class BookTestURIHandler implements URIHandler {
- public DownloadStream handleURI(URL context, String relativeUri) {
- String example;
- String param = null;
-
- final int slashPos = relativeUri.indexOf("/");
- if (slashPos > 0) {
- example = relativeUri.substring(0, slashPos);
- param = relativeUri.substring(slashPos + 1);
- } else {
- example = relativeUri;
- }
-
- /* Remove existing components and windows. */
- main.removeAllComponents();
- final Set childwindows = main.getChildWindows();
- for (final Iterator cwi = childwindows.iterator(); cwi.hasNext();) {
- final Window child = (Window) cwi.next();
- main.removeWindow(child);
- }
-
- // The index is listed inside a grid layout
- main.setLayout(new VerticalLayout());
- GridLayout grid = new GridLayout(4, 4);
- grid.addStyleName("index");
- main.addComponent(grid);
-
- if (example.equals("index")) {
- final String examples[] = { "defaultbutton", "label",
- "labelcontent", "tree", "embedded", "textfield",
- "textfieldvalidation", "datefield", "button",
- "select/select", "select/native", "select/optiongroup",
- "select/twincol", "filterselect", "validator", "table",
- "table/select", "table/component", "table/paging",
- "table/editable", "upload", "link", "gridlayout",
- "orderedlayout", "formlayout", "form", "form/simple",
- "form/layout", "panel", "expandlayout",
- "expandlayout/root", "tabsheet", "alignment",
- "alignment/grid", "window", "window/opener",
- "window/multiple", "classresource", "usererror",
- "progress/window", "progress/thread", "progress",
- "customlayout", "spacing", "margin", "clientinfo",
- "fillinform/templates", "notification", "print",
- "richtextfield", "querycontainer", "menubar",
- "absolutelayout", "layout/intro"};
- for (int i = 0; i < examples.length; i++) {
- grid.addComponent(new Label(""
- + examples[i] + "", Label.CONTENT_XHTML));
- }
- return null;
- }
-
- if (example.equals("defaultbutton")) {
- example_defaultButton(main, param);
- } else if (example.equals("label")) {
- example_Label(main, param);
- } else if (example.equals("labelcontent")) {
- example_LabelContent(main, param);
- } else if (example.equals("tree")) {
- example_Tree(main, param);
- } else if (example.equals("embedded")) {
- example_Embedded(main, param);
- } else if (example.equals("textfield")) {
- example_TextField(main, param);
- } else if (example.equals("textfieldvalidation")) {
- example_TextFieldValidation(main, param);
- } else if (example.equals("usererror")) {
- example_UserError(main, param);
- } else if (example.equals("datefield")) {
- example_DateField(main, param);
- } else if (example.equals("button")) {
- example_Button(main, param);
- } else if (example.equals("checkbox")) {
- example_CheckBox(main, param);
- } else if (example.equals("select")) {
- example_Select(main, param);
- } else if (example.equals("filterselect")) {
- example_FilterSelect(main, param);
- } else if (example.equals("validator")) {
- example_Validator(main, param);
- } else if (example.equals("table")) {
- example_Table(main, param);
- } else if (example.equals("upload")) {
- example_Upload(main, param);
- } else if (example.equals("link")) {
- example_Link(main, param);
- } else if (example.equals("gridlayout")) {
- example_GridLayout(main, param);
- } else if (example.equals("orderedlayout")) {
- example_OrderedLayout(main, param);
- } else if (example.equals("formlayout")) {
- example_FormLayout(main, param);
- } else if (example.equals("form")) {
- example_Form(main, param);
- } else if (example.equals("tabsheet")) {
- example_TabSheet(main, param);
- } else if (example.equals("panel")) {
- example_Panel(main, param);
- } else if (example.equals("expandlayout")) {
- example_ExpandLayout(main, param);
- } else if (example.equals("alignment")) {
- example_Alignment(main, param);
- } else if (example.equals("window")) {
- example_Window(main, param);
- } else if (example.equals("classresource")) {
- example_ClassResource(main, param);
- } else if (example.equals("progress")) {
- example_ProgressIndicator(main, param);
- } else if (example.equals("customlayout")) {
- example_CustomLayout(main, param);
- } else if (example.equals("spacing")) {
- example_Spacing(main, param);
- } else if (example.equals("margin")) {
- example_Margin(main, param);
- } else if (example.equals("clientinfo")) {
- example_ClientInfo(main, param);
- } else if (example.equals("fillinform")) {
- example_FillInForm(main, param);
- } else if (example.equals("notification")) {
- example_Notification(main, param);
- } else if (example.equals("print")) {
- example_Print(main, param);
- } else if (example.equals("richtextfield")) {
- example_RichTextArea(main, param);
- } else if (example.equals("querycontainer")) {
- example_QueryContainer(main, param);
- } else if (example.equals("menubar")) {
- example_MenuBar(main, param);
- } else if (example.equals("absolutelayout")) {
- example_AbsoluteLayout(main, param);
+ Window main = new Window("Application window");
+
+ TheButton butts1;
+ TheButtons butts2;
+ TheButtons2 butts3;
+
+ Label mylabel1;
+ Label mylabel2;
+ Label mylabel3;
+
+ StreamResource strres;
+ VerticalLayout ol;
+ int getwincount = 0;
+
+ @Override
+ public void init() {
+ setTheme("tests-book");
+
+ setMainWindow(main);
+
+ main.getContent().setSizeFull();
+
+ // Demo the use of parameter and URI handlers
+ main.addParameterHandler(new MyParameterHandler());
+ main.addURIHandler(new MyURIHandler());
+
+ MyDynamicResource myresource = new MyDynamicResource();
+ main.addParameterHandler(myresource);
+ main.addURIHandler(myresource);
+
+ main.addURIHandler(new BookTestURIHandler());
+ }
+
+ class MyParameterHandler implements ParameterHandler {
+ public void handleParameters(Map parameters) {
+ // Print out the parameters to standard output
+ for (Iterator it = parameters.keySet().iterator(); it.hasNext();) {
+ String key = (String) it.next();
+ String value = ((String[]) parameters.get(key))[0];
+ System.out.println("Key: " + key + ", value: " + value);
+ }
+ }
+ }
+
+ class MyURIHandler implements URIHandler {
+ public DownloadStream handleURI(URL context, String relativeUri) {
+ System.out.println("Context: " + context.toString()
+ + ", relative: " + relativeUri);
+ return null; // Let the Application provide the response
+ }
+ }
+
+ class BookTestURIHandler implements URIHandler {
+ public DownloadStream handleURI(URL context, String relativeUri) {
+ String example;
+ String param = null;
+
+ final int slashPos = relativeUri.indexOf("/");
+ if (slashPos > 0) {
+ example = relativeUri.substring(0, slashPos);
+ param = relativeUri.substring(slashPos + 1);
+ } else {
+ example = relativeUri;
+ }
+
+ /* Remove existing components and windows. */
+ main.removeAllComponents();
+ final Set childwindows = main.getChildWindows();
+ for (final Iterator cwi = childwindows.iterator(); cwi.hasNext();) {
+ final Window child = (Window) cwi.next();
+ main.removeWindow(child);
+ }
+
+ // The index is listed inside a grid layout
+ main.setLayout(new VerticalLayout());
+ GridLayout grid = new GridLayout(4, 4);
+ grid.addStyleName("index");
+ main.addComponent(grid);
+
+ if (example.equals("index")) {
+ final String examples[] = { "defaultbutton", "label",
+ "labelcontent", "tree", "embedded", "textfield",
+ "textfieldvalidation", "datefield", "button",
+ "select/select", "select/native", "select/optiongroup",
+ "select/twincol", "filterselect", "validator", "table",
+ "table/select", "table/component", "table/paging",
+ "table/editable", "upload", "link", "gridlayout",
+ "orderedlayout", "formlayout", "form", "form/simple",
+ "form/layout", "panel", "expandlayout",
+ "expandlayout/root", "tabsheet", "alignment",
+ "alignment/grid", "window", "window/opener",
+ "window/multiple", "classresource", "usererror",
+ "progress/window", "progress/thread", "progress",
+ "customlayout", "spacing", "margin", "clientinfo",
+ "fillinform/templates", "notification", "print",
+ "richtextfield", "querycontainer", "menubar",
+ "absolutelayout", "layout/intro" };
+ for (int i = 0; i < examples.length; i++) {
+ grid.addComponent(new Label(""
+ + examples[i] + "", Label.CONTENT_XHTML));
+ }
+ return null;
+ }
+
+ if (example.equals("defaultbutton")) {
+ example_defaultButton(main, param);
+ } else if (example.equals("label")) {
+ example_Label(main, param);
+ } else if (example.equals("labelcontent")) {
+ example_LabelContent(main, param);
+ } else if (example.equals("tree")) {
+ example_Tree(main, param);
+ } else if (example.equals("embedded")) {
+ example_Embedded(main, param);
+ } else if (example.equals("textfield")) {
+ example_TextField(main, param);
+ } else if (example.equals("textfieldvalidation")) {
+ example_TextFieldValidation(main, param);
+ } else if (example.equals("usererror")) {
+ example_UserError(main, param);
+ } else if (example.equals("datefield")) {
+ example_DateField(main, param);
+ } else if (example.equals("button")) {
+ example_Button(main, param);
+ } else if (example.equals("checkbox")) {
+ example_CheckBox(main, param);
+ } else if (example.equals("select")) {
+ example_Select(main, param);
+ } else if (example.equals("filterselect")) {
+ example_FilterSelect(main, param);
+ } else if (example.equals("validator")) {
+ example_Validator(main, param);
+ } else if (example.equals("table")) {
+ example_Table(main, param);
+ } else if (example.equals("upload")) {
+ example_Upload(main, param);
+ } else if (example.equals("link")) {
+ example_Link(main, param);
+ } else if (example.equals("gridlayout")) {
+ example_GridLayout(main, param);
+ } else if (example.equals("orderedlayout")) {
+ example_OrderedLayout(main, param);
+ } else if (example.equals("formlayout")) {
+ example_FormLayout(main, param);
+ } else if (example.equals("form")) {
+ example_Form(main, param);
+ } else if (example.equals("tabsheet")) {
+ example_TabSheet(main, param);
+ } else if (example.equals("panel")) {
+ example_Panel(main, param);
+ } else if (example.equals("expandlayout")) {
+ example_ExpandLayout(main, param);
+ } else if (example.equals("alignment")) {
+ example_Alignment(main, param);
+ } else if (example.equals("window")) {
+ example_Window(main, param);
+ } else if (example.equals("classresource")) {
+ example_ClassResource(main, param);
+ } else if (example.equals("progress")) {
+ example_ProgressIndicator(main, param);
+ } else if (example.equals("customlayout")) {
+ example_CustomLayout(main, param);
+ } else if (example.equals("spacing")) {
+ example_Spacing(main, param);
+ } else if (example.equals("margin")) {
+ example_Margin(main, param);
+ } else if (example.equals("clientinfo")) {
+ example_ClientInfo(main, param);
+ } else if (example.equals("fillinform")) {
+ example_FillInForm(main, param);
+ } else if (example.equals("notification")) {
+ example_Notification(main, param);
+ } else if (example.equals("print")) {
+ example_Print(main, param);
+ } else if (example.equals("richtextfield")) {
+ example_RichTextArea(main, param);
+ } else if (example.equals("querycontainer")) {
+ example_QueryContainer(main, param);
+ } else if (example.equals("menubar")) {
+ example_MenuBar(main, param);
+ } else if (example.equals("absolutelayout")) {
+ example_AbsoluteLayout(main, param);
} else if (example.equals("layout")) {
example_Layout(main, param);
- } else {
- ; // main.addComponent(new
- // Label("Unknown test '"+example+"'."));
- }
-
- return null;
- }
- }
-
- /*
- * public Window getWindow(String name) { Window superwin =
- * super.getWindow(name); if (superwin != null) return superwin;
- *
- * main.addComponent(new Label("Request 2 for window '"+name+"'.")); if
- * (name.equals("panel")) { Window window = new Window("Other Window " +
- * getwincount++); example_Panel(window, null); return window; } return
- * null; }
- */
- public void handleButton(Button.ClickEvent event) {
- ol.addStyleName("myLayout2");
- }
-
- void example_defaultButton(Window main, String param) {
- main.addComponent(new DefaultButtonExample());
- }
-
- void example_Label(Window main, String param) {
- /* Some container for the Label. */
- final Panel panel = new Panel("Panel Containing a Label");
- main.addComponent(panel);
-
- panel.addComponent(new Label(
- "This is a Label inside a Panel. There is enough "
- + "text in the label to make the text wrap if it "
- + "exceeds the width of the panel."));
- }
-
- void example_LabelContent(Window main, String param) {
- final GridLayout labelgrid = new GridLayout(2, 1);
- labelgrid.addStyleName("labelgrid");
- labelgrid.addComponent(new Label("CONTENT_DEFAULT"));
- labelgrid.addComponent(new Label(
- "This is a label in default mode: Print this! This rich text area contains some text. Print this! This rich text area contains some text.
Date:
- * DateField(resolution: day).
Item: Form.
default field
- * type: TextField.
+ * Boolean: Button(switchMode:true).
+ * Date: DateField(resolution: day).
+ * Item: Form.
+ * default field type: TextField.
*
It can contain, for example, unbalanced markup.",
- Label.CONTENT_RAW));
- labelgrid.addComponent(new Label("CONTENT_TEXT"));
- labelgrid.addComponent(new Label(
- "This is a label in (plain) text mode", Label.CONTENT_TEXT));
- labelgrid.addComponent(new Label("CONTENT_XHTML"));
- labelgrid.addComponent(new Label(
- "This is an XHTML formatted label",
- Label.CONTENT_XHTML));
- labelgrid.addComponent(new Label("CONTENT_XML"));
- labelgrid.addComponent(new Label(
- "This is an
It can contain, for example, unbalanced markup.",
+ Label.CONTENT_RAW));
+ labelgrid.addComponent(new Label("CONTENT_TEXT"));
+ labelgrid.addComponent(new Label(
+ "This is a label in (plain) text mode", Label.CONTENT_TEXT));
+ labelgrid.addComponent(new Label("CONTENT_XHTML"));
+ labelgrid.addComponent(new Label(
+ "This is an XHTML formatted label",
+ Label.CONTENT_XHTML));
+ labelgrid.addComponent(new Label("CONTENT_XML"));
+ labelgrid.addComponent(new Label(
+ "This is an
This is the last warning",
- Window.Notification.TYPE_WARNING_MESSAGE);
- return;
- } else if (param.equals("pos")) {
- // Create a notification with the default settings for a warning.
- Window.Notification notif = new Window.Notification("Be warned!",
- "This message lurks in the top-left corner!",
- Window.Notification.TYPE_WARNING_MESSAGE);
-
- // Set the position.
- notif.setPosition(Window.Notification.POSITION_TOP_LEFT);
-
- // Let it stay there until the user clicks it
- notif.setDelayMsec(-1);
-
- // Show it in the main window.
- main.showNotification(notif);
- return;
- }
-
- main.setLayout(new HorizontalLayout());
-
- final Integer type_humanized = Window.Notification.TYPE_HUMANIZED_MESSAGE;
- final Integer type_warning = Window.Notification.TYPE_WARNING_MESSAGE;
- final Integer type_error = Window.Notification.TYPE_ERROR_MESSAGE;
- final Integer type_tray = Window.Notification.TYPE_TRAY_NOTIFICATION;
- final NativeSelect types = new NativeSelect();
- main.addComponent(types);
- types.addItem(type_humanized);
- types.addItem(type_warning);
- types.addItem(type_error);
- types.addItem(type_tray);
- types.setItemCaption(type_humanized, "Humanized");
- types.setItemCaption(type_warning, "Warning");
- types.setItemCaption(type_error, "Error");
- types.setItemCaption(type_tray, "Tray");
-
- Button show = new Button("Show Notification");
- main.addComponent(show);
-
- show.addListener(new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- String caption = "";
- String description = "";
- switch (((Integer) types.getValue()).intValue()) {
- case Window.Notification.TYPE_HUMANIZED_MESSAGE:
- caption = "Humanized message";
- description = "
For minimal annoyance";
- break;
- case Window.Notification.TYPE_WARNING_MESSAGE:
- caption = "Warning message";
- description = "
For notifications of medium importance";
- break;
- case Window.Notification.TYPE_ERROR_MESSAGE:
- caption = "Error message";
- description = "
For important notifications";
- break;
- case Window.Notification.TYPE_TRAY_NOTIFICATION:
- caption = "Tray notification";
- description = "
Stays up longer - but away";
- }
- // main.showNotification("The default notification");
- Window.Notification notif = new Window.Notification(caption,
- description, (Integer) types.getValue());
- // notif.setPosition(Window.Notification.POSITION_TOP_LEFT);
- notif.setDelayMsec(-1);
- main.showNotification(notif);
- }
- });
-
- // Notification notif = new Notification("Title");
- }
-
- void example_Print(final Window main, String param) {
- if (param != null && param.equals("simple")) {
- main
- .addComponent(new Label(
- "",
- Label.CONTENT_XHTML));
- return;
- }
-
- // A button to open the printer-friendly page.
- Button printButton = new Button("Click to Print");
- main.addComponent(printButton);
- printButton.addListener(new Button.ClickListener() {
- public void buttonClick(ClickEvent event) {
- // Create a window that contains stuff you want to print.
- Window printWindow = new Window("Window to Print");
-
- // Have some content to print.
- printWindow.addComponent(new Label(
- "Here's some dynamic content."));
-
- // To execute the print() JavaScript, we need to run it
- // from a custom layout.
- CustomLayout scriptLayout = new CustomLayout("printpage");
- printWindow.addComponent(scriptLayout);
-
- // Add the printing window as an application-level window.
- main.getApplication().addWindow(printWindow);
-
- // Open the printing window as a new browser window
- main.open(new ExternalResource(printWindow.getURL()), "_new");
- }
- });
-
- // main.addComponent(new
- // Label("Hello
\n
This is the last warning",
+ Window.Notification.TYPE_WARNING_MESSAGE);
+ return;
+ } else if (param.equals("pos")) {
+ // Create a notification with the default settings for a warning.
+ Window.Notification notif = new Window.Notification("Be warned!",
+ "This message lurks in the top-left corner!",
+ Window.Notification.TYPE_WARNING_MESSAGE);
+
+ // Set the position.
+ notif.setPosition(Window.Notification.POSITION_TOP_LEFT);
+
+ // Let it stay there until the user clicks it
+ notif.setDelayMsec(-1);
+
+ // Show it in the main window.
+ main.showNotification(notif);
+ return;
+ }
+
+ main.setLayout(new HorizontalLayout());
+
+ final Integer type_humanized = Window.Notification.TYPE_HUMANIZED_MESSAGE;
+ final Integer type_warning = Window.Notification.TYPE_WARNING_MESSAGE;
+ final Integer type_error = Window.Notification.TYPE_ERROR_MESSAGE;
+ final Integer type_tray = Window.Notification.TYPE_TRAY_NOTIFICATION;
+ final NativeSelect types = new NativeSelect();
+ main.addComponent(types);
+ types.addItem(type_humanized);
+ types.addItem(type_warning);
+ types.addItem(type_error);
+ types.addItem(type_tray);
+ types.setItemCaption(type_humanized, "Humanized");
+ types.setItemCaption(type_warning, "Warning");
+ types.setItemCaption(type_error, "Error");
+ types.setItemCaption(type_tray, "Tray");
+
+ Button show = new Button("Show Notification");
+ main.addComponent(show);
+
+ show.addListener(new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ String caption = "";
+ String description = "";
+ switch (((Integer) types.getValue()).intValue()) {
+ case Window.Notification.TYPE_HUMANIZED_MESSAGE:
+ caption = "Humanized message";
+ description = "
For minimal annoyance";
+ break;
+ case Window.Notification.TYPE_WARNING_MESSAGE:
+ caption = "Warning message";
+ description = "
For notifications of medium importance";
+ break;
+ case Window.Notification.TYPE_ERROR_MESSAGE:
+ caption = "Error message";
+ description = "
For important notifications";
+ break;
+ case Window.Notification.TYPE_TRAY_NOTIFICATION:
+ caption = "Tray notification";
+ description = "
Stays up longer - but away";
+ }
+ // main.showNotification("The default notification");
+ Window.Notification notif = new Window.Notification(caption,
+ description, (Integer) types.getValue());
+ // notif.setPosition(Window.Notification.POSITION_TOP_LEFT);
+ notif.setDelayMsec(-1);
+ main.showNotification(notif);
+ }
+ });
+
+ // Notification notif = new Notification("Title");
+ }
+
+ void example_Print(final Window main, String param) {
+ if (param != null && param.equals("simple")) {
+ main
+ .addComponent(new Label(
+ "",
+ Label.CONTENT_XHTML));
+ return;
+ }
+
+ // A button to open the printer-friendly page.
+ Button printButton = new Button("Click to Print");
+ main.addComponent(printButton);
+ printButton.addListener(new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ // Create a window that contains stuff you want to print.
+ Window printWindow = new Window("Window to Print");
+
+ // Have some content to print.
+ printWindow.addComponent(new Label(
+ "Here's some dynamic content."));
+
+ // To execute the print() JavaScript, we need to run it
+ // from a custom layout.
+ CustomLayout scriptLayout = new CustomLayout("printpage");
+ printWindow.addComponent(scriptLayout);
+
+ // Add the printing window as an application-level window.
+ main.getApplication().addWindow(printWindow);
+
+ // Open the printing window as a new browser window
+ main.open(new ExternalResource(printWindow.getURL()), "_new");
+ }
+ });
+
+ // main.addComponent(new
+ // Label("Hello
\n