diff options
71 files changed, 706 insertions, 921 deletions
diff --git a/WebContent/VAADIN/themes/base/dragwrapper/dragwrapper.scss b/WebContent/VAADIN/themes/base/dragwrapper/dragwrapper.scss index 558b305742..9d60bf0618 100644 --- a/WebContent/VAADIN/themes/base/dragwrapper/dragwrapper.scss +++ b/WebContent/VAADIN/themes/base/dragwrapper/dragwrapper.scss @@ -110,7 +110,7 @@ .v-ddwrapper-over-left:before, .v-ddwrapper-over-right:before { display: block; - content: ""; + position: absolute; width: 6px; height: 6px; diff --git a/WebContent/VAADIN/themes/base/layout/layout.scss b/WebContent/VAADIN/themes/base/layout/layout.scss index 04df35872e..d4f636e6d6 100644 --- a/WebContent/VAADIN/themes/base/layout/layout.scss +++ b/WebContent/VAADIN/themes/base/layout/layout.scss @@ -54,7 +54,7 @@ TODO .v-vertical, .v-horizontal { - display: inline-block; + display: block; } div.v-layout.v-horizontal.v-widget { @@ -79,12 +79,12 @@ div.v-layout.v-horizontal.v-widget { /* Clear any floats inside the slot, to prevent unwanted collapsing */ .v-vertical > .v-slot:after { - content: ""; display: inline-block; clear: both; width: 0; height: 0; overflow: hidden; + line-height:0; } .v-vertical > .v-slot, diff --git a/WebContent/VAADIN/themes/base/panel/panel.scss b/WebContent/VAADIN/themes/base/panel/panel.scss index 93d82cd615..202e75c226 100644 --- a/WebContent/VAADIN/themes/base/panel/panel.scss +++ b/WebContent/VAADIN/themes/base/panel/panel.scss @@ -21,6 +21,7 @@ } .v-panel-caption span { vertical-align: middle; + display: table-row; } .v-panel-caption { white-space: nowrap; diff --git a/WebContent/VAADIN/themes/base/select/select.scss b/WebContent/VAADIN/themes/base/select/select.scss index d6ef6d3585..d2d9e8a663 100644 --- a/WebContent/VAADIN/themes/base/select/select.scss +++ b/WebContent/VAADIN/themes/base/select/select.scss @@ -98,6 +98,10 @@ .v-filterselect-suggestmenu table { border-collapse: collapse; border: none; + vertical-align:top; +} +.v-filterselect-suggestmenu tr{ + line-height:0; } .v-filterselect-suggestmenu .gwt-MenuItem { white-space: nowrap; diff --git a/WebContent/VAADIN/themes/base/table/table.scss b/WebContent/VAADIN/themes/base/table/table.scss index d521b5ebae..fd3c0af0e1 100644 --- a/WebContent/VAADIN/themes/base/table/table.scss +++ b/WebContent/VAADIN/themes/base/table/table.scss @@ -267,7 +267,7 @@ .v-table-row-drag-top .v-table-cell-content:first-child:before, .v-table-row-drag-bottom .v-table-cell-content:first-child:after { display: block; - content: ""; + position: absolute; width: 6px; height: 6px; diff --git a/WebContent/VAADIN/themes/base/tree/tree.scss b/WebContent/VAADIN/themes/base/tree/tree.scss index 0319bbe994..2e34053ad5 100644 --- a/WebContent/VAADIN/themes/base/tree/tree.scss +++ b/WebContent/VAADIN/themes/base/tree/tree.scss @@ -58,7 +58,7 @@ div.v-tree-node-leaf { .v-tree .v-tree-node-drag-bottom:after, .v-tree .v-tree-node-caption-drag-center:after { display: block; - content: ""; + position: absolute; width: 6px; height: 6px; diff --git a/WebContent/VAADIN/themes/runo/panel/panel.scss b/WebContent/VAADIN/themes/runo/panel/panel.scss index 5963f73434..3d6b00173b 100644 --- a/WebContent/VAADIN/themes/runo/panel/panel.scss +++ b/WebContent/VAADIN/themes/runo/panel/panel.scss @@ -38,7 +38,7 @@ } .v-panel-deco:before { display: block; - content: ""; + width: 9px; height: 9px; margin-left: -9px; diff --git a/WebContent/VAADIN/themes/runo/tabsheet/tabsheet.scss b/WebContent/VAADIN/themes/runo/tabsheet/tabsheet.scss index 683eb35f4c..ec6bdd5b0f 100644 --- a/WebContent/VAADIN/themes/runo/tabsheet/tabsheet.scss +++ b/WebContent/VAADIN/themes/runo/tabsheet/tabsheet.scss @@ -117,7 +117,7 @@ } .v-tabsheet-deco:before { display: block; - content: ""; + width: 9px; height: 9px; margin-left: -9px; diff --git a/WebContent/VAADIN/vaadinBootstrap.js b/WebContent/VAADIN/vaadinBootstrap.js index 36cf2ec8eb..96c1b0e014 100644 --- a/WebContent/VAADIN/vaadinBootstrap.js +++ b/WebContent/VAADIN/vaadinBootstrap.js @@ -106,7 +106,10 @@ url += "&rootId=" + rootId; } - url += '&initialPath=' + encodeURIComponent(getConfig("initialPath")); + var initialPath = getConfig("initialPath"); + if (initialPath === null) { + url += '&initialPath=' + encodeURIComponent(initialPath); + } url += '&initialParams=' + encodeURIComponent(JSON.stringify(getConfig("initialParams"))); url += '&' + vaadin.getBrowserDetailsParameters(appId); @@ -131,6 +134,8 @@ // Try bootstrapping again, this time without fetching missing info bootstrapApp(false); + } else if (r.status == 500) { + document.write(r.responseText); } else { log('Error', r.statusText); } diff --git a/client-compiler/src/com/vaadin/server/widgetsetutils/CustomWidgetMapGenerator.java b/client-compiler/src/com/vaadin/server/widgetsetutils/CustomWidgetMapGenerator.java deleted file mode 100644 index 250bfbb4a1..0000000000 --- a/client-compiler/src/com/vaadin/server/widgetsetutils/CustomWidgetMapGenerator.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright 2011 Vaadin Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.vaadin.server.widgetsetutils; - -import java.util.Collection; -import java.util.HashSet; - -import com.vaadin.client.ComponentConnector; -import com.vaadin.client.ServerConnector; -import com.vaadin.shared.ui.Connect; -import com.vaadin.shared.ui.Connect.LoadStyle; - -/** - * An abstract helper class that can be used to easily build a widgetset with - * customized load styles for each components. In three abstract methods one can - * override the default values given in {@link Connect} annotations. - * - * @see WidgetMapGenerator - * - */ -public abstract class CustomWidgetMapGenerator extends WidgetMapGenerator { - - private Collection<Class<? extends ComponentConnector>> eagerPaintables = new HashSet<Class<? extends ComponentConnector>>(); - private Collection<Class<? extends ComponentConnector>> lazyPaintables = new HashSet<Class<? extends ComponentConnector>>(); - private Collection<Class<? extends ComponentConnector>> deferredPaintables = new HashSet<Class<? extends ComponentConnector>>(); - - @Override - protected LoadStyle getLoadStyle(Class<? extends ServerConnector> connector) { - if (eagerPaintables == null) { - init(); - } - if (eagerPaintables.contains(connector)) { - return LoadStyle.EAGER; - } - if (lazyPaintables.contains(connector)) { - return LoadStyle.LAZY; - } - if (deferredPaintables.contains(connector)) { - return LoadStyle.DEFERRED; - } - return super.getLoadStyle(connector); - } - - private void init() { - Class<? extends ComponentConnector>[] eagerComponents = getEagerComponents(); - if (eagerComponents != null) { - for (Class<? extends ComponentConnector> class1 : eagerComponents) { - eagerPaintables.add(class1); - } - } - Class<? extends ComponentConnector>[] lazyComponents = getEagerComponents(); - if (lazyComponents != null) { - for (Class<? extends ComponentConnector> class1 : lazyComponents) { - lazyPaintables.add(class1); - } - } - Class<? extends ComponentConnector>[] deferredComponents = getEagerComponents(); - if (deferredComponents != null) { - for (Class<? extends ComponentConnector> class1 : deferredComponents) { - deferredPaintables.add(class1); - } - } - } - - /** - * @return an array of components whose load style should be overridden to - * {@link LoadStyle#EAGER} - */ - protected abstract Class<? extends ComponentConnector>[] getEagerComponents(); - - /** - * @return an array of components whose load style should be overridden to - * {@link LoadStyle#LAZY} - */ - protected abstract Class<? extends ComponentConnector>[] getLazyComponents(); - - /** - * @return an array of components whose load style should be overridden to - * {@link LoadStyle#DEFERRED} - */ - protected abstract Class<? extends ComponentConnector>[] getDeferredComponents(); - -} diff --git a/client-compiler/src/com/vaadin/server/widgetsetutils/EagerWidgetMapGenerator.java b/client-compiler/src/com/vaadin/server/widgetsetutils/EagerWidgetMapGenerator.java deleted file mode 100644 index 568dc939e7..0000000000 --- a/client-compiler/src/com/vaadin/server/widgetsetutils/EagerWidgetMapGenerator.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2011 Vaadin Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.vaadin.server.widgetsetutils; - -import com.vaadin.client.ServerConnector; -import com.vaadin.shared.ui.Connect.LoadStyle; - -/** - * WidgetMap generator that builds a widgetset that packs all included widgets - * into a single JavaScript file loaded at application initialization. Initially - * loaded data will be relatively large, but minimal amount of server requests - * will be done. - * <p> - * This is the default generator in version 6.4 and produces similar type of - * widgetset as in previous versions of Vaadin. To activate "code splitting", - * use the {@link WidgetMapGenerator} instead, that loads most components - * deferred. - * - * @see WidgetMapGenerator - * - */ -public class EagerWidgetMapGenerator extends WidgetMapGenerator { - - @Override - protected LoadStyle getLoadStyle(Class<? extends ServerConnector> connector) { - return LoadStyle.EAGER; - } -} diff --git a/client-compiler/src/com/vaadin/server/widgetsetutils/WidgetMapGenerator.java b/client-compiler/src/com/vaadin/server/widgetsetutils/WidgetMapGenerator.java deleted file mode 100644 index c1fb6df883..0000000000 --- a/client-compiler/src/com/vaadin/server/widgetsetutils/WidgetMapGenerator.java +++ /dev/null @@ -1,434 +0,0 @@ -/* - * Copyright 2011 Vaadin Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.vaadin.server.widgetsetutils; - -import java.io.PrintWriter; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.Map; -import java.util.TreeSet; - -import com.google.gwt.core.ext.Generator; -import com.google.gwt.core.ext.GeneratorContext; -import com.google.gwt.core.ext.TreeLogger; -import com.google.gwt.core.ext.TreeLogger.Type; -import com.google.gwt.core.ext.UnableToCompleteException; -import com.google.gwt.core.ext.typeinfo.JClassType; -import com.google.gwt.core.ext.typeinfo.TypeOracle; -import com.google.gwt.user.rebind.ClassSourceFileComposerFactory; -import com.google.gwt.user.rebind.SourceWriter; -import com.vaadin.client.ServerConnector; -import com.vaadin.client.ui.UnknownComponentConnector; -import com.vaadin.client.ui.ui.UIConnector; -import com.vaadin.server.ClientConnector; -import com.vaadin.shared.Connector; -import com.vaadin.shared.ui.Connect; -import com.vaadin.shared.ui.Connect.LoadStyle; - -/** - * WidgetMapGenerator's are GWT generator to build WidgetMapImpl dynamically - * based on {@link Connect} annotations available in workspace. By modifying the - * generator it is possible to do some fine tuning for the generated widgetset - * (aka client side engine). The components to be included in the client side - * engine can modified be overriding {@link #getUsedConnectors()}. - * <p> - * The generator also decides how the client side component implementations are - * loaded to the browser. The default generator is - * {@link EagerWidgetMapGenerator} that builds a monolithic client side engine - * that loads all widget implementation on application initialization. This has - * been the only option until Vaadin 6.4. - * <p> - * This generator uses the loadStyle hints from the {@link Connect} annotations. - * Depending on the {@link LoadStyle} used, the widget may be included in the - * initially loaded JavaScript, loaded when the application has started and - * there is no communication to server or lazy loaded when the implementation is - * absolutely needed. - * <p> - * The GWT module description file of the widgetset ( - * <code>...Widgetset.gwt.xml</code>) can be used to define the - * WidgetMapGenarator. An example that defines this generator to be used: - * - * <pre> - * <code> - * <generate-with - * class="com.vaadin.server.widgetsetutils.MyWidgetMapGenerator"> - * <when-type-is class="com.vaadin.client.WidgetMap" /> - * </generate-with> - * - * </code> - * </pre> - * - * <p> - * Vaadin package also includes {@link LazyWidgetMapGenerator}, which is a good - * option if the transferred data should be minimized, and - * {@link CustomWidgetMapGenerator} for easy overriding of loading strategies. - * - */ -public class WidgetMapGenerator extends Generator { - - private static String serverConnectorClassName = ServerConnector.class - .getName(); - - private String packageName; - private String className; - - @Override - public String generate(TreeLogger logger, GeneratorContext context, - String typeName) throws UnableToCompleteException { - - try { - TypeOracle typeOracle = context.getTypeOracle(); - - // get classType and save instance variables - JClassType classType = typeOracle.getType(typeName); - packageName = classType.getPackage().getName(); - className = classType.getSimpleSourceName() + "Impl"; - // Generate class source code - generateClass(logger, context); - } catch (Exception e) { - logger.log(TreeLogger.ERROR, "WidgetMap creation failed", e); - } - // return the fully qualifed name of the class generated - return packageName + "." + className; - } - - /** - * Generate source code for WidgetMapImpl - * - * @param logger - * Logger object - * @param context - * Generator context - * @throws UnableToCompleteException - */ - private void generateClass(TreeLogger logger, GeneratorContext context) - throws UnableToCompleteException { - // get print writer that receives the source code - PrintWriter printWriter = null; - printWriter = context.tryCreate(logger, packageName, className); - // print writer if null, source code has ALREADY been generated, - // return (WidgetMap is equal to all permutations atm) - if (printWriter == null) { - return; - } - logger.log(Type.INFO, - "Detecting Vaadin connectors in classpath to generate WidgetMapImpl.java ..."); - Date date = new Date(); - - // init composer, set class properties, create source writer - ClassSourceFileComposerFactory composer = null; - composer = new ClassSourceFileComposerFactory(packageName, className); - composer.addImport("com.google.gwt.core.client.GWT"); - composer.addImport("java.util.HashMap"); - composer.addImport("com.google.gwt.core.client.RunAsyncCallback"); - composer.setSuperclass("com.vaadin.client.WidgetMap"); - SourceWriter sourceWriter = composer.createSourceWriter(context, - printWriter); - - Collection<Class<? extends ServerConnector>> connectors = getUsedConnectors(context - .getTypeOracle()); - - validateConnectors(logger, connectors); - logConnectors(logger, context, connectors); - - // generator constructor source code - generateImplementationDetector(logger, sourceWriter, connectors); - generateInstantiatorMethod(sourceWriter, connectors); - // close generated class - sourceWriter.outdent(); - sourceWriter.println("}"); - // commit generated class - context.commit(logger, printWriter); - logger.log(Type.INFO, - "Done. (" + (new Date().getTime() - date.getTime()) / 1000 - + "seconds)"); - - } - - private void validateConnectors(TreeLogger logger, - Collection<Class<? extends ServerConnector>> connectors) { - - Iterator<Class<? extends ServerConnector>> iter = connectors.iterator(); - while (iter.hasNext()) { - Class<? extends ServerConnector> connectorClass = iter.next(); - Connect annotation = connectorClass.getAnnotation(Connect.class); - if (!ClientConnector.class.isAssignableFrom(annotation.value())) { - logger.log( - Type.WARN, - "Connector class " - + annotation.value().getName() - + " defined in @Connect annotation is not a subclass of " - + ClientConnector.class.getName() - + ". The component connector " - + connectorClass.getName() - + " will not be included in the widgetset."); - iter.remove(); - } - } - - } - - private void logConnectors(TreeLogger logger, GeneratorContext context, - Collection<Class<? extends ServerConnector>> connectors) { - logger.log(Type.INFO, - "Widget set will contain implementations for following component connectors: "); - - TreeSet<String> classNames = new TreeSet<String>(); - HashMap<String, String> loadStyle = new HashMap<String, String>(); - for (Class<? extends ServerConnector> connectorClass : connectors) { - String className = connectorClass.getCanonicalName(); - classNames.add(className); - if (getLoadStyle(connectorClass) == LoadStyle.DEFERRED) { - loadStyle.put(className, "DEFERRED"); - } else if (getLoadStyle(connectorClass) == LoadStyle.LAZY) { - loadStyle.put(className, "LAZY"); - } - - } - for (String className : classNames) { - String msg = className; - if (loadStyle.containsKey(className)) { - msg += " (load style: " + loadStyle.get(className) + ")"; - } - logger.log(Type.INFO, "\t" + msg); - } - } - - /** - * This method is protected to allow creation of optimized widgetsets. The - * Widgetset will contain only implementation returned by this function. If - * one knows which widgets are needed for the application, returning only - * them here will significantly optimize the size of the produced JS. - * - * @return a collections of Vaadin components that will be added to - * widgetset - */ - @SuppressWarnings("unchecked") - private Collection<Class<? extends ServerConnector>> getUsedConnectors( - TypeOracle typeOracle) { - JClassType connectorType = typeOracle.findType(Connector.class - .getName()); - Collection<Class<? extends ServerConnector>> connectors = new HashSet<Class<? extends ServerConnector>>(); - for (JClassType jClassType : connectorType.getSubtypes()) { - Connect annotation = jClassType.getAnnotation(Connect.class); - if (annotation != null) { - try { - Class<? extends ServerConnector> clazz = (Class<? extends ServerConnector>) Class - .forName(jClassType.getQualifiedSourceName()); - connectors.add(clazz); - } catch (ClassNotFoundException e) { - throw new RuntimeException(e); - } - } - } - return connectors; - } - - /** - * Returns true if the widget for given component will be lazy loaded by the - * client. The default implementation reads the information from the - * {@link Connect} annotation. - * <p> - * The method can be overridden to optimize the widget loading mechanism. If - * the Widgetset is wanted to be optimized for a network with a high latency - * or for a one with a very fast throughput, it may be good to return false - * for every component. - * - * @param connector - * @return true iff the widget for given component should be lazy loaded by - * the client side engine - */ - protected LoadStyle getLoadStyle(Class<? extends ServerConnector> connector) { - Connect annotation = connector.getAnnotation(Connect.class); - return annotation.loadStyle(); - } - - private void generateInstantiatorMethod( - SourceWriter sourceWriter, - Collection<Class<? extends ServerConnector>> connectorsHavingComponentAnnotation) { - - Collection<Class<?>> deferredWidgets = new LinkedList<Class<?>>(); - - // TODO detect if it would be noticably faster to instantiate with a - // lookup with index than with the hashmap - - sourceWriter.println("public void ensureInstantiator(Class<? extends " - + serverConnectorClassName + "> classType) {"); - sourceWriter.println("if(!instmap.containsKey(classType)){"); - boolean first = true; - - ArrayList<Class<? extends ServerConnector>> lazyLoadedConnectors = new ArrayList<Class<? extends ServerConnector>>(); - - HashSet<Class<? extends ServerConnector>> connectorsWithInstantiator = new HashSet<Class<? extends ServerConnector>>(); - - for (Class<? extends ServerConnector> class1 : connectorsHavingComponentAnnotation) { - Class<? extends ServerConnector> clientClass = class1; - if (connectorsWithInstantiator.contains(clientClass)) { - continue; - } - if (clientClass == UIConnector.class) { - // Roots are not instantiated by widgetset - continue; - } - if (!first) { - sourceWriter.print(" else "); - } else { - first = false; - } - sourceWriter.print("if( classType == " + clientClass.getName() - + ".class) {"); - - String instantiator = "new WidgetInstantiator() {\n public " - + serverConnectorClassName - + " get() {\n return GWT.create(" + clientClass.getName() - + ".class );\n}\n}\n"; - - LoadStyle loadStyle = getLoadStyle(class1); - - if (loadStyle != LoadStyle.EAGER) { - sourceWriter - .print("ApplicationConfiguration.startWidgetLoading();\n" - + "GWT.runAsync( \n" - + "new WidgetLoader() { void addInstantiator() {instmap.put(" - + clientClass.getName() - + ".class," - + instantiator + ");}});\n"); - lazyLoadedConnectors.add(class1); - - if (loadStyle == LoadStyle.DEFERRED) { - deferredWidgets.add(class1); - } - - } else { - // widget implementation in initially loaded js script - sourceWriter.print("instmap.put("); - sourceWriter.print(clientClass.getName()); - sourceWriter.print(".class, "); - sourceWriter.print(instantiator); - sourceWriter.print(");"); - } - sourceWriter.print("}"); - connectorsWithInstantiator.add(clientClass); - } - - sourceWriter.println("}"); - - sourceWriter.println("}"); - - sourceWriter.println("public Class<? extends " - + serverConnectorClassName - + ">[] getDeferredLoadedConnectors() {"); - - sourceWriter.println("return new Class[] {"); - first = true; - for (Class<?> class2 : deferredWidgets) { - if (!first) { - sourceWriter.println(","); - } - first = false; - sourceWriter.print(class2.getName() + ".class"); - } - - sourceWriter.println("};"); - sourceWriter.println("}"); - - // in constructor add a "thread" that lazyly loads lazy loaded widgets - // if communication to server idles - - // TODO an array of lazy loaded widgets - - // TODO an index of last ensured widget in array - - sourceWriter.println("public " + serverConnectorClassName - + " instantiate(Class<? extends " + serverConnectorClassName - + "> classType) {"); - sourceWriter.indent(); - sourceWriter.println(serverConnectorClassName - + " p = super.instantiate(classType); if(p!= null) return p;"); - sourceWriter.println("return instmap.get(classType).get();"); - - sourceWriter.outdent(); - sourceWriter.println("}"); - - } - - /** - * - * @param logger - * logger to print messages to - * @param sourceWriter - * Source writer to output source code - * @param paintablesHavingWidgetAnnotation - * @throws UnableToCompleteException - */ - private void generateImplementationDetector( - TreeLogger logger, - SourceWriter sourceWriter, - Collection<Class<? extends ServerConnector>> paintablesHavingWidgetAnnotation) - throws UnableToCompleteException { - sourceWriter - .println("public Class<? extends " - + serverConnectorClassName - + "> " - + "getConnectorClassForServerSideClassName(String fullyQualifiedName) {"); - sourceWriter.indent(); - sourceWriter - .println("fullyQualifiedName = fullyQualifiedName.intern();"); - - // Keep track of encountered mappings to detect conflicts - Map<Class<? extends ClientConnector>, Class<? extends ServerConnector>> mappings = new HashMap<Class<? extends ClientConnector>, Class<? extends ServerConnector>>(); - - for (Class<? extends ServerConnector> connectorClass : paintablesHavingWidgetAnnotation) { - Class<? extends ClientConnector> clientConnectorClass = getClientConnectorClass(connectorClass); - - // Check for conflicts - Class<? extends ServerConnector> prevousMapping = mappings.put( - clientConnectorClass, connectorClass); - if (prevousMapping != null) { - logger.log(Type.ERROR, - "Both " + connectorClass.getName() + " and " - + prevousMapping.getName() - + " have @Connect referring to " - + clientConnectorClass.getName() + "."); - throw new UnableToCompleteException(); - } - - sourceWriter.print("if ( fullyQualifiedName == \""); - sourceWriter.print(clientConnectorClass.getName()); - sourceWriter.print("\" ) { ensureInstantiator(" - + connectorClass.getName() + ".class); return "); - sourceWriter.print(connectorClass.getName()); - sourceWriter.println(".class;}"); - sourceWriter.print("else "); - } - sourceWriter.println("return " - + UnknownComponentConnector.class.getName() + ".class;"); - sourceWriter.outdent(); - sourceWriter.println("}"); - - } - - private static Class<? extends ClientConnector> getClientConnectorClass( - Class<? extends ServerConnector> connectorClass) { - Connect annotation = connectorClass.getAnnotation(Connect.class); - return (Class<? extends ClientConnector>) annotation.value(); - } -} diff --git a/server/src/com/vaadin/data/Validatable.java b/server/src/com/vaadin/data/Validatable.java index a454e6f821..0b43a8bbcb 100644 --- a/server/src/com/vaadin/data/Validatable.java +++ b/server/src/com/vaadin/data/Validatable.java @@ -58,12 +58,22 @@ public interface Validatable extends Serializable { void removeValidator(Validator validator); /** + * Removes all validators from this object, as if + * {@link #removeValidator(Validator) removeValidator} was called for each + * registered validator. + */ + void removeAllValidators(); + + /** * <p> - * Lists all validators currently registered for the object. If no - * validators are registered, returns <code>null</code>. + * Returns a collection of all validators currently registered for the + * object. The collection may be immutable. Calling + * <code>removeValidator</code> for this Validatable while iterating over + * the collection may be unsafe (e.g. may throw + * <code>ConcurrentModificationException</code>.) * </p> * - * @return collection of validators or <code>null</code> + * @return A collection of validators */ public Collection<Validator> getValidators(); diff --git a/server/src/com/vaadin/navigator/NavigationStateManager.java b/server/src/com/vaadin/navigator/NavigationStateManager.java index cbbeb59c30..c3f1f0f11e 100644 --- a/server/src/com/vaadin/navigator/NavigationStateManager.java +++ b/server/src/com/vaadin/navigator/NavigationStateManager.java @@ -19,15 +19,15 @@ package com.vaadin.navigator; import java.io.Serializable; /** - * An interface for handling interaction between Navigator and the browser - * location URI or other similar view identification and bookmarking system. The - * state is limited to a single string because in the usual cases it forms a - * part of a URI. + * An interface for handling interaction between {@link Navigator} and the + * browser location URI or other similar view identification and bookmarking + * system. The state is limited to a single string because in the usual cases it + * forms a part of a URI. * <p> * Different implementations can be created for hashbang URIs, HTML5 pushState, * portlet URL navigation and other similar systems. * <p> - * This interface is mostly for internal use by {@link Navigator}. + * This interface is mostly for internal use by Navigator. * * @author Vaadin Ltd * @since 7.0 @@ -42,11 +42,22 @@ public interface NavigationStateManager extends Serializable { public String getState(); /** - * Set the current navigation state in the location URI or similar location, - * including view name and any optional parameters. + * Sets the current navigation state in the location URI or similar + * location, including view name and any optional parameters. + * <p> + * This method should be only called by a Navigator. * * @param fragment * new view and parameter string, not null */ public void setState(String state); + + /** + * Sets the Navigator used with this state manager. The state manager should + * notify the provided navigator of user-triggered navigation state changes + * by invoking <code>navigator.navigateTo(getState())</code>. + * <p> + * This method should only be called by a Navigator. + */ + public void setNavigator(Navigator navigator); }
\ No newline at end of file diff --git a/server/src/com/vaadin/navigator/Navigator.java b/server/src/com/vaadin/navigator/Navigator.java index a3b0ad89a0..df9e5059fa 100644 --- a/server/src/com/vaadin/navigator/Navigator.java +++ b/server/src/com/vaadin/navigator/Navigator.java @@ -87,7 +87,7 @@ public class Navigator implements Serializable { public static class UriFragmentManager implements NavigationStateManager, FragmentChangedListener { private final Page page; - private final Navigator navigator; + private Navigator navigator; /** * Creates a new URIFragmentManager and attach it to listen to URI @@ -95,20 +95,20 @@ public class Navigator implements Serializable { * * @param page * page whose URI fragment to get and modify - * @param navigator - * {@link Navigator} to notify of fragment changes (using - * {@link Navigator#navigateTo(String)} */ - public UriFragmentManager(Page page, Navigator navigator) { + public UriFragmentManager(Page page) { this.page = page; - this.navigator = navigator; - page.addFragmentChangedListener(this); } @Override + public void setNavigator(Navigator navigator) { + this.navigator = navigator; + } + + @Override public String getState() { - String fragment = page.getFragment(); + String fragment = getFragment(); if (fragment.startsWith("!")) { return fragment.substring(1); } else { @@ -118,13 +118,32 @@ public class Navigator implements Serializable { @Override public void setState(String state) { - page.setFragment("!" + state, false); + setFragment("!" + state); } @Override public void fragmentChanged(FragmentChangedEvent event) { navigator.navigateTo(getState()); } + + /** + * Returns the current URI fragment tracked by this UriFragentManager. + * + * @return The URI fragment. + */ + protected String getFragment() { + return page.getFragment(); + } + + /** + * Sets the URI fragment to the given string. + * + * @param fragment + * The new URI fragment. + */ + protected void setFragment(String fragment) { + page.setFragment(fragment, false); + } } /** @@ -379,10 +398,7 @@ public class Navigator implements Serializable { * The ViewDisplay used to display the views. */ public Navigator(UI ui, ViewDisplay display) { - this.ui = ui; - this.ui.setNavigator(this); - this.display = display; - stateManager = new UriFragmentManager(ui.getPage(), this); + this(ui, new UriFragmentManager(ui.getPage()), display); } /** @@ -409,8 +425,9 @@ public class Navigator implements Serializable { ViewDisplay display) { this.ui = ui; this.ui.setNavigator(this); - this.display = display; this.stateManager = stateManager; + this.stateManager.setNavigator(this); + this.display = display; } /** diff --git a/server/src/com/vaadin/server/AbstractCommunicationManager.java b/server/src/com/vaadin/server/AbstractCommunicationManager.java index c631043507..3d334e11a5 100644 --- a/server/src/com/vaadin/server/AbstractCommunicationManager.java +++ b/server/src/com/vaadin/server/AbstractCommunicationManager.java @@ -185,7 +185,7 @@ public abstract class AbstractCommunicationManager implements Serializable { requireLocale(session.getLocale().toString()); } - protected VaadinSession getVaadinSession() { + protected VaadinSession getSession() { return session; } @@ -379,7 +379,7 @@ public abstract class AbstractCommunicationManager implements Serializable { "StreamVariable for the post not found"); } - final VaadinSession session = getVaadinSession(); + final VaadinSession session = getSession(); OutputStream out = null; int totalBytes = 0; @@ -593,7 +593,7 @@ public abstract class AbstractCommunicationManager implements Serializable { if (!handleVariables(request, response, callback, session, uI)) { // var inconsistency; the client is probably out-of-sync - SystemMessages ci = response.getVaadinService() + SystemMessages ci = response.getService() .getSystemMessages(); String msg = ci.getOutOfSyncMessage(); String cap = ci.getOutOfSyncCaption(); @@ -1050,7 +1050,7 @@ public abstract class AbstractCommunicationManager implements Serializable { } } - SystemMessages ci = request.getVaadinService().getSystemMessages(); + SystemMessages ci = request.getService().getSystemMessages(); // meta instruction for client to enable auto-forward to // sessionExpiredURL after timer expires. @@ -2460,12 +2460,15 @@ public abstract class AbstractCommunicationManager implements Serializable { } private UI getBrowserDetailsUI(VaadinRequest request) { - VaadinService vaadinService = request.getVaadinService(); + VaadinService vaadinService = request.getService(); VaadinSession session = VaadinSession.getForSession(request .getWrappedSession()); List<UIProvider> uiProviders = vaadinService.getUIProviders(session); + UIClassSelectionEvent classSelectionEvent = new UIClassSelectionEvent( + request); + UIProvider provider = null; Class<? extends UI> uiClass = null; for (UIProvider p : uiProviders) { @@ -2473,14 +2476,15 @@ public abstract class AbstractCommunicationManager implements Serializable { if (p instanceof LegacyApplicationUIProvider) { LegacyApplicationUIProvider legacyProvider = (LegacyApplicationUIProvider) p; - UI existingUi = legacyProvider.getExistingUI(request); + UI existingUi = legacyProvider + .getExistingUI(classSelectionEvent); if (existingUi != null) { UI.setCurrent(existingUi); return existingUi; } } - uiClass = p.getUIClass(request); + uiClass = p.getUIClass(classSelectionEvent); if (uiClass != null) { provider = p; break; @@ -2521,16 +2525,18 @@ public abstract class AbstractCommunicationManager implements Serializable { // No existing UI found - go on by creating and initializing one + Integer uiId = Integer.valueOf(session.getNextUIid()); + // Explicit Class.cast to detect if the UIProvider does something // unexpected - UI ui = uiClass.cast(provider.createInstance(request, uiClass)); + UICreateEvent event = new UICreateEvent(request, uiClass, uiId); + UI ui = uiClass.cast(provider.createInstance(event)); // Initialize some fields for a newly created UI if (ui.getSession() != session) { // Session already set for LegacyWindow ui.setSession(session); } - Integer uiId = Integer.valueOf(session.getNextUIid()); // Set thread local here so it is available in init UI.setCurrent(ui); @@ -2540,7 +2546,7 @@ public abstract class AbstractCommunicationManager implements Serializable { session.addUI(ui); // Remember if it should be remembered - if (vaadinService.preserveUIOnRefresh(request, ui, provider)) { + if (vaadinService.preserveUIOnRefresh(provider, event)) { // Remember this UI String windowName = request.getBrowserDetails().getWindowName(); if (windowName == null) { @@ -2608,7 +2614,7 @@ public abstract class AbstractCommunicationManager implements Serializable { .substring(ApplicationConstants.CONNECTOR_RESOURCE_PREFIX .length() + 2); - final String mimetype = response.getVaadinService().getMimeType( + final String mimetype = response.getService().getMimeType( resourceName); // Security check: avoid accidentally serving from the UI of the diff --git a/server/src/com/vaadin/server/AddonContext.java b/server/src/com/vaadin/server/AddonContext.java index 6c7cb9bf98..513d56150b 100644 --- a/server/src/com/vaadin/server/AddonContext.java +++ b/server/src/com/vaadin/server/AddonContext.java @@ -61,7 +61,7 @@ public class AddonContext implements Serializable { VaadinSessionInitializeEvent event) throws ServiceException { for (BootstrapListener l : bootstrapListeners) { - event.getVaadinSession().addBootstrapListener(l); + event.getSession().addBootstrapListener(l); } } }); @@ -73,7 +73,7 @@ public class AddonContext implements Serializable { * * @return the vaadin service */ - public VaadinService getVaadinService() { + public VaadinService getService() { return vaadinService; } diff --git a/server/src/com/vaadin/server/BootstrapHandler.java b/server/src/com/vaadin/server/BootstrapHandler.java index 8721550a41..a6c72b9885 100644 --- a/server/src/com/vaadin/server/BootstrapHandler.java +++ b/server/src/com/vaadin/server/BootstrapHandler.java @@ -76,8 +76,8 @@ public abstract class BootstrapHandler implements RequestHandler { return bootstrapResponse.getRequest(); } - public VaadinSession getVaadinSession() { - return bootstrapResponse.getVaadinSession(); + public VaadinSession getSession() { + return bootstrapResponse.getSession(); } public Class<? extends UI> getUIClass() { @@ -116,14 +116,17 @@ public abstract class BootstrapHandler implements RequestHandler { VaadinResponse response) throws IOException { try { - List<UIProvider> uiProviders = request.getVaadinService() - .getUIProviders(session); + List<UIProvider> uiProviders = request.getService().getUIProviders( + session); + + UIClassSelectionEvent classSelectionEvent = new UIClassSelectionEvent( + request); // Find UI provider and UI class Class<? extends UI> uiClass = null; UIProvider provider = null; for (UIProvider p : uiProviders) { - uiClass = p.getUIClass(request); + uiClass = p.getUIClass(classSelectionEvent); // If we found something if (uiClass != null) { provider = p; @@ -159,7 +162,7 @@ public abstract class BootstrapHandler implements RequestHandler { private String getBootstrapHtml(BootstrapContext context) { VaadinRequest request = context.getRequest(); VaadinResponse response = context.getResponse(); - VaadinService vaadinService = request.getVaadinService(); + VaadinService vaadinService = request.getService(); BootstrapFragmentResponse fragmentResponse = context .getBootstrapResponse(); @@ -168,9 +171,8 @@ public abstract class BootstrapHandler implements RequestHandler { Map<String, Object> headers = new LinkedHashMap<String, Object>(); Document document = Document.createShell(""); BootstrapPageResponse pageResponse = new BootstrapPageResponse( - this, request, context.getVaadinSession(), - context.getUIClass(), document, headers, - fragmentResponse.getUIProvider()); + this, request, context.getSession(), context.getUIClass(), + document, headers, fragmentResponse.getUIProvider()); List<Node> fragmentNodes = fragmentResponse.getFragmentNodes(); Element body = document.body(); for (Node node : fragmentNodes) { @@ -178,7 +180,7 @@ public abstract class BootstrapHandler implements RequestHandler { } setupStandaloneDocument(context, pageResponse); - context.getVaadinSession().modifyBootstrapResponse(pageResponse); + context.getSession().modifyBootstrapResponse(pageResponse); sendBootstrapHeaders(response, headers); @@ -229,12 +231,9 @@ public abstract class BootstrapHandler implements RequestHandler { Document document = response.getDocument(); - DocumentType doctype = new DocumentType("html", - "-//W3C//DTD XHTML 1.0 Transitional//EN", - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd", + DocumentType doctype = new DocumentType("html", "", "", document.baseUri()); document.child(0).before(doctype); - document.body().parent().attr("xmlns", "http://www.w3.org/1999/xhtml"); Element head = document.head(); head.appendElement("meta").attr("http-equiv", "Content-Type") @@ -246,7 +245,7 @@ public abstract class BootstrapHandler implements RequestHandler { .attr("content", "chrome=1"); String title = response.getUIProvider().getPageTitle( - context.getRequest(), context.getUIClass()); + new UICreateEvent(context.getRequest(), context.getUIClass())); if (title != null) { head.appendElement("title").appendText(title); } @@ -288,11 +287,12 @@ public abstract class BootstrapHandler implements RequestHandler { public String getWidgetsetForUI(BootstrapContext context) { VaadinRequest request = context.getRequest(); + UICreateEvent event = new UICreateEvent(context.getRequest(), + context.getUIClass()); String widgetset = context.getBootstrapResponse().getUIProvider() - .getWidgetset(context.getRequest(), context.getUIClass()); + .getWidgetset(event); if (widgetset == null) { - widgetset = request.getVaadinService().getConfiguredWidgetset( - request); + widgetset = request.getService().getConfiguredWidgetset(request); } widgetset = VaadinServlet.stripSpecialChars(widgetset); @@ -325,7 +325,7 @@ public abstract class BootstrapHandler implements RequestHandler { */ String appClass = "v-app-" - + context.getVaadinSession().getClass().getSimpleName(); + + context.getSession().getClass().getSimpleName(); String classNames = "v-app " + appClass; List<Node> fragmentNodes = context.getBootstrapResponse() @@ -344,7 +344,7 @@ public abstract class BootstrapHandler implements RequestHandler { VaadinRequest request = context.getRequest(); - VaadinService vaadinService = request.getVaadinService(); + VaadinService vaadinService = request.getService(); String staticFileLocation = vaadinService .getStaticFileLocation(request); @@ -383,7 +383,7 @@ public abstract class BootstrapHandler implements RequestHandler { JSONObject defaults = getDefaultParameters(context); JSONObject appConfig = getApplicationParameters(context); - boolean isDebug = !context.getVaadinSession().getConfiguration() + boolean isDebug = !context.getSession().getConfiguration() .isProductionMode(); builder.append("vaadin.setDefaults("); @@ -440,8 +440,8 @@ public abstract class BootstrapHandler implements RequestHandler { JSONObject defaults = new JSONObject(); VaadinRequest request = context.getRequest(); - VaadinSession session = context.getVaadinSession(); - VaadinService vaadinService = request.getVaadinService(); + VaadinSession session = context.getSession(); + VaadinService vaadinService = request.getService(); // Get system messages SystemMessages systemMessages = vaadinService.getSystemMessages(); @@ -503,7 +503,7 @@ public abstract class BootstrapHandler implements RequestHandler { */ public String getThemeUri(BootstrapContext context, String themeName) { VaadinRequest request = context.getRequest(); - final String staticFilePath = request.getVaadinService() + final String staticFilePath = request.getService() .getStaticFileLocation(request); return staticFilePath + "/" + VaadinServlet.THEME_DIRECTORY_PATH + themeName; @@ -516,8 +516,9 @@ public abstract class BootstrapHandler implements RequestHandler { * @return */ public String getThemeName(BootstrapContext context) { - return context.getBootstrapResponse().getUIProvider() - .getTheme(context.getRequest(), context.getUIClass()); + UICreateEvent event = new UICreateEvent(context.getRequest(), + context.getUIClass()); + return context.getBootstrapResponse().getUIProvider().getTheme(event); } /** @@ -530,7 +531,7 @@ public abstract class BootstrapHandler implements RequestHandler { String themeName = getThemeName(context); if (themeName == null) { VaadinRequest request = context.getRequest(); - themeName = request.getVaadinService().getConfiguredTheme(request); + themeName = request.getService().getConfiguredTheme(request); } // XSS preventation, theme names shouldn't contain special chars anyway. diff --git a/server/src/com/vaadin/server/BootstrapResponse.java b/server/src/com/vaadin/server/BootstrapResponse.java index c6e5fdc2ad..7b12085a7b 100644 --- a/server/src/com/vaadin/server/BootstrapResponse.java +++ b/server/src/com/vaadin/server/BootstrapResponse.java @@ -86,7 +86,7 @@ public abstract class BootstrapResponse extends EventObject { * * @return the vaadin session */ - public VaadinSession getVaadinSession() { + public VaadinSession getSession() { return session; } diff --git a/server/src/com/vaadin/server/CombinedRequest.java b/server/src/com/vaadin/server/CombinedRequest.java index b3569a249c..589596136b 100644 --- a/server/src/com/vaadin/server/CombinedRequest.java +++ b/server/src/com/vaadin/server/CombinedRequest.java @@ -183,8 +183,8 @@ public class CombinedRequest implements VaadinRequest { } @Override - public VaadinService getVaadinService() { - return secondRequest.getVaadinService(); + public VaadinService getService() { + return secondRequest.getService(); } @Override diff --git a/server/src/com/vaadin/server/CommunicationManager.java b/server/src/com/vaadin/server/CommunicationManager.java index 7e55396592..8dc490c36a 100644 --- a/server/src/com/vaadin/server/CommunicationManager.java +++ b/server/src/com/vaadin/server/CommunicationManager.java @@ -83,7 +83,7 @@ public class CommunicationManager extends AbstractCommunicationManager { URL url; try { - url = context.getRequest().getVaadinService() + url = context.getRequest().getService() .getApplicationUrl(context.getRequest()); } catch (MalformedURLException e) { throw new RuntimeException(e); diff --git a/server/src/com/vaadin/server/DefaultUIProvider.java b/server/src/com/vaadin/server/DefaultUIProvider.java index 85fc10e716..7769747906 100644 --- a/server/src/com/vaadin/server/DefaultUIProvider.java +++ b/server/src/com/vaadin/server/DefaultUIProvider.java @@ -21,15 +21,23 @@ import com.vaadin.ui.UI; public class DefaultUIProvider extends UIProvider { @Override - public Class<? extends UI> getUIClass(VaadinRequest request) { - Object uiClassNameObj = request.getVaadinService() + public Class<? extends UI> getUIClass(UIClassSelectionEvent event) { + VaadinRequest request = event.getRequest(); + + // Only use UI from web.xml for requests to the root + String pathInfo = request.getRequestPathInfo(); + if (pathInfo != null && !"/".equals(pathInfo)) { + return null; + } + + Object uiClassNameObj = request.getService() .getDeploymentConfiguration().getInitParameters() .getProperty(VaadinSession.UI_PARAMETER); if (uiClassNameObj instanceof String) { String uiClassName = uiClassNameObj.toString(); - ClassLoader classLoader = request.getVaadinService() + ClassLoader classLoader = request.getService() .getClassLoader(); if (classLoader == null) { classLoader = getClass().getClassLoader(); diff --git a/server/src/com/vaadin/server/GAEVaadinServlet.java b/server/src/com/vaadin/server/GAEVaadinServlet.java index df7daedfb8..2849dc73a0 100644 --- a/server/src/com/vaadin/server/GAEVaadinServlet.java +++ b/server/src/com/vaadin/server/GAEVaadinServlet.java @@ -172,9 +172,9 @@ public class GAEVaadinServlet extends VaadinServlet { HttpServletResponse unwrappedResponse) throws ServletException, IOException { VaadinServletRequest request = new VaadinServletRequest( - unwrappedRequest, getVaadinService()); + unwrappedRequest, getService()); VaadinServletResponse response = new VaadinServletResponse( - unwrappedResponse, getVaadinService()); + unwrappedResponse, getService()); if (isCleanupRequest(request)) { cleanDatastore(); @@ -199,7 +199,7 @@ public class GAEVaadinServlet extends VaadinServlet { return; } - final HttpSession session = request.getSession(getVaadinService() + final HttpSession session = request.getSession(getService() .requestCanCreateSession(request)); if (session == null) { handleServiceSessionExpired(request, response); @@ -341,7 +341,7 @@ public class GAEVaadinServlet extends VaadinServlet { // will create new context if the above did not try { - return getVaadinService().findVaadinSession( + return getService().findVaadinSession( createVaadinRequest(request)); } catch (Exception e) { throw new ServletException(e); diff --git a/server/src/com/vaadin/server/LegacyApplicationUIProvider.java b/server/src/com/vaadin/server/LegacyApplicationUIProvider.java index a8c7cd230b..1b7161e33f 100644 --- a/server/src/com/vaadin/server/LegacyApplicationUIProvider.java +++ b/server/src/com/vaadin/server/LegacyApplicationUIProvider.java @@ -39,8 +39,8 @@ public abstract class LegacyApplicationUIProvider extends UIProvider { .compile("^/?([^/]+).*"); @Override - public Class<? extends UI> getUIClass(VaadinRequest request) { - UI uiInstance = getUIInstance(request); + public Class<? extends UI> getUIClass(UIClassSelectionEvent event) { + UI uiInstance = getUIInstance(event); if (uiInstance != null) { return uiInstance.getClass(); } @@ -48,12 +48,12 @@ public abstract class LegacyApplicationUIProvider extends UIProvider { } @Override - public UI createInstance(VaadinRequest request, Class<? extends UI> type) { - return getUIInstance(request); + public UI createInstance(UICreateEvent event) { + return getUIInstance(event); } @Override - public String getTheme(VaadinRequest request, Class<? extends UI> uiClass) { + public String getTheme(UICreateEvent event) { LegacyApplication application = getApplication(); if (application != null) { return application.getTheme(); @@ -63,17 +63,17 @@ public abstract class LegacyApplicationUIProvider extends UIProvider { } @Override - public String getPageTitle(VaadinRequest request, - Class<? extends UI> uiClass) { - UI uiInstance = getUIInstance(request); + public String getPageTitle(UICreateEvent event) { + UI uiInstance = getUIInstance(event); if (uiInstance != null) { return uiInstance.getCaption(); } else { - return super.getPageTitle(request, uiClass); + return super.getPageTitle(event); } } - private UI getUIInstance(VaadinRequest request) { + private UI getUIInstance(UIProviderEvent event) { + VaadinRequest request = event.getRequest(); String pathInfo = request.getRequestPathInfo(); String name = null; if (pathInfo != null && pathInfo.length() > 0) { @@ -99,11 +99,11 @@ public abstract class LegacyApplicationUIProvider extends UIProvider { * Hack used to return existing LegacyWindow instances without regard for * out-of-sync problems. * - * @param request + * @param event * @return */ - public UI getExistingUI(VaadinRequest request) { - UI uiInstance = getUIInstance(request); + public UI getExistingUI(UIClassSelectionEvent event) { + UI uiInstance = getUIInstance(event); if (uiInstance == null || uiInstance.getUIId() == -1) { // Not initialized -> Let go through createUIInstance to make it // initialized diff --git a/server/src/com/vaadin/server/LegacyVaadinPortlet.java b/server/src/com/vaadin/server/LegacyVaadinPortlet.java index f433b14478..a91a82076e 100644 --- a/server/src/com/vaadin/server/LegacyVaadinPortlet.java +++ b/server/src/com/vaadin/server/LegacyVaadinPortlet.java @@ -16,6 +16,7 @@ package com.vaadin.server; +import javax.portlet.PortletConfig; import javax.portlet.PortletException; import javax.portlet.PortletRequest; @@ -44,10 +45,10 @@ public class LegacyVaadinPortlet extends VaadinPortlet { }; @Override - public void init() throws PortletException { - super.init(); + public void init(PortletConfig portletConfig) throws PortletException { + super.init(portletConfig); - getVaadinService().addVaadinSessionInitializationListener( + getService().addVaadinSessionInitializationListener( new VaadinSessionInitializationListener() { @Override public void vaadinSessionInitialized( @@ -56,8 +57,7 @@ public class LegacyVaadinPortlet extends VaadinPortlet { try { onVaadinSessionStarted(VaadinPortletRequest .cast(event.getRequest()), - (VaadinPortletSession) event - .getVaadinSession()); + (VaadinPortletSession) event.getSession()); } catch (PortletException e) { throw new ServiceException(e); } @@ -68,8 +68,7 @@ public class LegacyVaadinPortlet extends VaadinPortlet { protected Class<? extends LegacyApplication> getApplicationClass() throws ClassNotFoundException { try { - return ServletPortletHelper - .getLegacyApplicationClass(getVaadinService()); + return ServletPortletHelper.getLegacyApplicationClass(getService()); } catch (ServiceException e) { throw new RuntimeException(e); } @@ -87,7 +86,7 @@ public class LegacyVaadinPortlet extends VaadinPortlet { private void onVaadinSessionStarted(VaadinPortletRequest request, VaadinPortletSession session) throws PortletException { - getVaadinService().addUIProvider(session, provider); + getService().addUIProvider(session, provider); } protected boolean shouldCreateApplication(PortletRequest request) { diff --git a/server/src/com/vaadin/server/LegacyVaadinServlet.java b/server/src/com/vaadin/server/LegacyVaadinServlet.java index 3a44df517d..1209ca8419 100644 --- a/server/src/com/vaadin/server/LegacyVaadinServlet.java +++ b/server/src/com/vaadin/server/LegacyVaadinServlet.java @@ -49,7 +49,7 @@ public class LegacyVaadinServlet extends VaadinServlet { public void init(ServletConfig servletConfig) throws ServletException { super.init(servletConfig); - getVaadinService().addVaadinSessionInitializationListener( + getService().addVaadinSessionInitializationListener( new VaadinSessionInitializationListener() { @Override public void vaadinSessionInitialized( @@ -57,7 +57,7 @@ public class LegacyVaadinServlet extends VaadinServlet { throws ServiceException { try { onVaadinSessionStarted(event.getRequest(), - event.getVaadinSession()); + event.getSession()); } catch (ServletException e) { throw new ServiceException(e); } @@ -69,7 +69,7 @@ public class LegacyVaadinServlet extends VaadinServlet { throws ClassNotFoundException { try { return ServletPortletHelper - .getLegacyApplicationClass(getVaadinService()); + .getLegacyApplicationClass(getService()); } catch (ServiceException e) { throw new RuntimeException(e); } @@ -92,7 +92,7 @@ public class LegacyVaadinServlet extends VaadinServlet { private void onVaadinSessionStarted(VaadinRequest request, VaadinSession session) throws ServletException { - getVaadinService().addUIProvider(session, provider); + getService().addUIProvider(session, provider); } } diff --git a/server/src/com/vaadin/server/Page.java b/server/src/com/vaadin/server/Page.java index e17643eb81..b6a2b2f776 100644 --- a/server/src/com/vaadin/server/Page.java +++ b/server/src/com/vaadin/server/Page.java @@ -415,6 +415,15 @@ public class Page implements Serializable { return uI.getSession().getBrowser(); } + /** + * Updates the internal state with the given values. Does not resize the + * Page or browser window. + * + * @param width + * The new width + * @param height + * The new height + */ public void setBrowserWindowSize(int width, int height) { boolean fireEvent = false; diff --git a/server/src/com/vaadin/server/PortletCommunicationManager.java b/server/src/com/vaadin/server/PortletCommunicationManager.java index 449d39b38b..8636c7e6e1 100644 --- a/server/src/com/vaadin/server/PortletCommunicationManager.java +++ b/server/src/com/vaadin/server/PortletCommunicationManager.java @@ -98,12 +98,6 @@ public class PortletCommunicationManager extends AbstractCommunicationManager { */ JSONObject defaults = super.getDefaultParameters(context); - ResourceURL portletResourceUrl = getRenderResponse(context) - .createResourceURL(); - portletResourceUrl.setResourceID(VaadinPortlet.RESOURCE_URL_ID); - defaults.put(ApplicationConstants.PORTLET_RESOUCE_URL_BASE, - portletResourceUrl.toString()); - defaults.put("pathInfo", ""); return defaults; @@ -131,8 +125,7 @@ public class PortletCommunicationManager extends AbstractCommunicationManager { @Override protected String getMainDivStyle(BootstrapContext context) { - VaadinService vaadinService = context.getRequest() - .getVaadinService(); + VaadinService vaadinService = context.getRequest().getService(); return vaadinService.getDeploymentConfiguration() .getApplicationOrSystemProperty( VaadinPortlet.PORTLET_PARAMETER_STYLE, null); @@ -150,6 +143,13 @@ public class PortletCommunicationManager extends AbstractCommunicationManager { ResourceURL resourceURL = portletResponse.createResourceURL(); resourceURL.setResourceID("browserDetails"); parameters.put("browserDetailsUrl", resourceURL.toString()); + + ResourceURL portletResourceUrl = getRenderResponse(context) + .createResourceURL(); + portletResourceUrl.setResourceID(VaadinPortlet.RESOURCE_URL_ID); + parameters.put(ApplicationConstants.PORTLET_RESOUCE_URL_BASE, + portletResourceUrl.toString()); + return parameters; } diff --git a/client-compiler/src/com/vaadin/server/widgetsetutils/LazyWidgetMapGenerator.java b/server/src/com/vaadin/server/UIClassSelectionEvent.java index 9e46b6d9dd..401801e691 100644 --- a/client-compiler/src/com/vaadin/server/widgetsetutils/LazyWidgetMapGenerator.java +++ b/server/src/com/vaadin/server/UIClassSelectionEvent.java @@ -13,23 +13,27 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.vaadin.server.widgetsetutils; -import com.vaadin.client.ServerConnector; -import com.vaadin.shared.ui.Connect.LoadStyle; +package com.vaadin.server; /** - * WidgetMap generator that builds a widgetset that optimizes the transferred - * data. Widgets are loaded only when used if the widgetset is built with this - * generator. - * - * @see WidgetMapGenerator + * Contains information used by + * {@link UIProvider#getUIClass(UIClassSelectionEvent)} to choose a UI class to + * use in a specific situation. * + * @author Vaadin Ltd + * @since 7.0.0 */ -public class LazyWidgetMapGenerator extends WidgetMapGenerator { - @Override - protected LoadStyle getLoadStyle(Class<? extends ServerConnector> connector) { - return LoadStyle.LAZY; +public class UIClassSelectionEvent extends UIProviderEvent { + + /** + * Creates a new event for a specific request. + * + * @param request + * the Vaadin request for which a UI class is wanted. + */ + public UIClassSelectionEvent(VaadinRequest request) { + super(request); } } diff --git a/server/src/com/vaadin/server/UICreateEvent.java b/server/src/com/vaadin/server/UICreateEvent.java new file mode 100644 index 0000000000..a608b5eb19 --- /dev/null +++ b/server/src/com/vaadin/server/UICreateEvent.java @@ -0,0 +1,87 @@ +/* + * Copyright 2011 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package com.vaadin.server; + +import com.vaadin.ui.UI; + +/** + * Contains data used by various methods in {@link UIProvider} for determining + * information about a new UI that is about to be created. + * + * @author Vaadin Ltd + * @since 7.0.0 + */ +public class UICreateEvent extends UIProviderEvent { + + private final Class<? extends UI> uiClass; + private final Integer uiId; + + /** + * Creates a new UI create event for a given VaadinRequest and UI class but + * without a UI id. + * + * @param request + * the request for which the UI will be created + * @param uiClass + * the UI class that will be created + */ + public UICreateEvent(VaadinRequest request, Class<? extends UI> uiClass) { + this(request, uiClass, null); + } + + /** + * Creates a new UI create event for a given VaadinRequest, UI class and UI + * id + * + * @param request + * the request for which the UI will be created + * @param uiClass + * the UI class that will be created + * @param uiId + * the id reserved for the UI; or <code>null</code> if no id has + * yet been allocated. + */ + public UICreateEvent(VaadinRequest request, Class<? extends UI> uiClass, + Integer uiId) { + super(request); + this.uiClass = uiClass; + this.uiId = uiId; + } + + /** + * Gets the UI class that will be created. + * + * @return the UI class + */ + public Class<? extends UI> getUIClass() { + return uiClass; + } + + /** + * Gets the id of the UI about to be created. This might be + * <code>null</code> if the id has not yet been determined. + * <p> + * The UI id is generally only available in + * {@link UIProvider#createInstance(UICreateEvent)} + * + * @return the UI id; or <code>null</code> if the UI id is not yet known. + */ + public Integer getUiId() { + return uiId; + } + +} diff --git a/server/src/com/vaadin/server/UIProvider.java b/server/src/com/vaadin/server/UIProvider.java index 812c2588da..e9ec25c326 100644 --- a/server/src/com/vaadin/server/UIProvider.java +++ b/server/src/com/vaadin/server/UIProvider.java @@ -26,11 +26,11 @@ import com.vaadin.annotations.Widgetset; import com.vaadin.ui.UI; public abstract class UIProvider implements Serializable { - public abstract Class<? extends UI> getUIClass(VaadinRequest request); + public abstract Class<? extends UI> getUIClass(UIClassSelectionEvent event); - public UI createInstance(VaadinRequest request, Class<? extends UI> type) { + public UI createInstance(UICreateEvent event) { try { - return type.newInstance(); + return event.getUIClass().newInstance(); } catch (InstantiationException e) { throw new RuntimeException("Could not instantiate root class", e); } catch (IllegalAccessException e) { @@ -40,20 +40,20 @@ public abstract class UIProvider implements Serializable { /** * Helper to get an annotation for a class. If the annotation is not present - * on the target class, it's superclasses and implemented interfaces are + * on the target class, its super classes and implemented interfaces are * also searched for the annotation. * - * @param type - * the target class from which the annotation should be found + * @param clazz + * the class from which the annotation should be found * @param annotationType * the annotation type to look for * @return an annotation of the given type, or <code>null</code> if the * annotation is not present on the class */ - protected static <T extends Annotation> T getAnnotationFor(Class<?> type, + protected static <T extends Annotation> T getAnnotationFor(Class<?> clazz, Class<T> annotationType) { // Find from the class hierarchy - Class<?> currentType = type; + Class<?> currentType = clazz; while (currentType != Object.class) { T annotation = currentType.getAnnotation(annotationType); if (annotation != null) { @@ -64,7 +64,7 @@ public abstract class UIProvider implements Serializable { } // Find from an implemented interface - for (Class<?> iface : type.getInterfaces()) { + for (Class<?> iface : clazz.getInterfaces()) { T annotation = iface.getAnnotation(annotationType); if (annotation != null) { return annotation; @@ -77,17 +77,19 @@ public abstract class UIProvider implements Serializable { /** * Finds the theme to use for a specific UI. If no specific theme is * required, <code>null</code> is returned. + * <p> + * The default implementation checks for a @{@link Theme} annotation on the + * UI class. * - * TODO Tell what the default implementation does once it does something. - * - * @param uI - * the UI to get a theme for + * @param event + * the UI create event with information about the UI and the + * current request. * @return the name of the theme, or <code>null</code> if the default theme * should be used * */ - public String getTheme(VaadinRequest request, Class<? extends UI> uiClass) { - Theme uiTheme = getAnnotationFor(uiClass, Theme.class); + public String getTheme(UICreateEvent event) { + Theme uiTheme = getAnnotationFor(event.getUIClass(), Theme.class); if (uiTheme != null) { return uiTheme.value(); } else { @@ -102,17 +104,16 @@ public abstract class UIProvider implements Serializable { * The default implementation uses the @{@link Widgetset} annotation if it's * defined for the UI class. * - * @param request - * the Vaadin request for which to get a widgetset - * @param uiClass - * the UI class to get a widgetset for + * @param event + * the UI create event with information about the UI and the + * current request. * @return the name of the widgetset, or <code>null</code> if the default * widgetset should be used * */ - public String getWidgetset(VaadinRequest request, - Class<? extends UI> uiClass) { - Widgetset uiWidgetset = getAnnotationFor(uiClass, Widgetset.class); + public String getWidgetset(UICreateEvent event) { + Widgetset uiWidgetset = getAnnotationFor(event.getUIClass(), + Widgetset.class); if (uiWidgetset != null) { return uiWidgetset.value(); } else { @@ -126,22 +127,22 @@ public abstract class UIProvider implements Serializable { * previously been open. The framework attempts to discover this by checking * the value of window.name in the browser. * - * @param request - * @param uiClass + * @param event + * the UI create event with information about the UI and the + * current request. * * @return <code>true</code>if the same UI instance should be reused e.g. * when the browser window is refreshed. */ - public boolean isPreservedOnRefresh(VaadinRequest request, - Class<? extends UI> uiClass) { - PreserveOnRefresh preserveOnRefresh = getAnnotationFor(uiClass, - PreserveOnRefresh.class); + public boolean isPreservedOnRefresh(UICreateEvent event) { + PreserveOnRefresh preserveOnRefresh = getAnnotationFor( + event.getUIClass(), PreserveOnRefresh.class); return preserveOnRefresh != null; } - public String getPageTitle(VaadinRequest request, - Class<? extends UI> uiClass) { - Title titleAnnotation = getAnnotationFor(uiClass, Title.class); + public String getPageTitle(UICreateEvent event) { + Title titleAnnotation = getAnnotationFor(event.getUIClass(), + Title.class); if (titleAnnotation == null) { return null; } else { diff --git a/server/src/com/vaadin/server/UIProviderEvent.java b/server/src/com/vaadin/server/UIProviderEvent.java new file mode 100644 index 0000000000..c0a41846c3 --- /dev/null +++ b/server/src/com/vaadin/server/UIProviderEvent.java @@ -0,0 +1,63 @@ +/* + * Copyright 2011 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package com.vaadin.server; + +import java.io.Serializable; +import java.util.EventObject; + +/** + * Base class for the events that are sent to various methods in UIProvider. + * + * @see UIProvider + * + * @author Vaadin Ltd + * @since 7.0.0 + */ +public class UIProviderEvent extends EventObject implements Serializable { + + private final VaadinRequest request; + + /** + * Creates a new UI provider event. + * + * @param request + * the request for which the event is UI provider is invoked + */ + public UIProviderEvent(VaadinRequest request) { + super(request.getService()); + this.request = request; + } + + /** + * Gets the Vaadin service from which the event originates. + * + * @return the Vaadin service + */ + public VaadinService getService() { + return (VaadinService) getSource(); + } + + /** + * Gets the request associated with this event. + * + * @return the Vaadin request + */ + public VaadinRequest getRequest() { + return request; + } + +} diff --git a/server/src/com/vaadin/server/VaadinPortlet.java b/server/src/com/vaadin/server/VaadinPortlet.java index d862a13945..cdf7030f98 100644 --- a/server/src/com/vaadin/server/VaadinPortlet.java +++ b/server/src/com/vaadin/server/VaadinPortlet.java @@ -360,9 +360,9 @@ public class VaadinPortlet extends GenericPortlet implements Constants { VaadinPortletRequest vaadinRequest = createVaadinRequest(request); VaadinPortletResponse vaadinResponse = new VaadinPortletResponse( - response, getVaadinService()); + response, getService()); - getVaadinService().setCurrentInstances(vaadinRequest, + getService().setCurrentInstances(vaadinRequest, vaadinResponse); RequestType requestType = getRequestType(vaadinRequest); @@ -393,7 +393,7 @@ public class VaadinPortlet extends GenericPortlet implements Constants { // TODO What about PARAM_UNLOADBURST & // redirectToApplication?? - vaadinSession = (VaadinPortletSession) getVaadinService() + vaadinSession = (VaadinPortletSession) getService() .findVaadinSession(vaadinRequest); if (vaadinSession == null) { return; @@ -423,7 +423,7 @@ public class VaadinPortlet extends GenericPortlet implements Constants { // Finds the right UI UI uI = null; if (requestType == RequestType.UIDL) { - uI = getVaadinService().findUI(vaadinRequest); + uI = getService().findUI(vaadinRequest); } // TODO Should this happen before or after the transaction @@ -506,16 +506,16 @@ public class VaadinPortlet extends GenericPortlet implements Constants { String portalInfo = request.getPortalContext().getPortalInfo() .toLowerCase(); if (portalInfo.contains("liferay")) { - return new VaadinLiferayRequest(request, getVaadinService()); + return new VaadinLiferayRequest(request, getService()); } else if (portalInfo.contains("gatein")) { - return new VaadinGateinRequest(request, getVaadinService()); + return new VaadinGateinRequest(request, getService()); } else { - return new VaadinPortletRequest(request, getVaadinService()); + return new VaadinPortletRequest(request, getService()); } } - protected VaadinPortletService getVaadinService() { + protected VaadinPortletService getService() { return vaadinService; } @@ -635,7 +635,7 @@ public class VaadinPortlet extends GenericPortlet implements Constants { // if this was an UIDL request, response UIDL back to client if (getRequestType(request) == RequestType.UIDL) { - SystemMessages ci = getVaadinService().getSystemMessages(); + SystemMessages ci = getService().getSystemMessages(); criticalNotification(request, response, ci.getInternalErrorCaption(), ci.getInternalErrorMessage(), null, ci.getInternalErrorURL()); diff --git a/server/src/com/vaadin/server/VaadinPortletRequest.java b/server/src/com/vaadin/server/VaadinPortletRequest.java index 3290c49950..63d5d1f467 100644 --- a/server/src/com/vaadin/server/VaadinPortletRequest.java +++ b/server/src/com/vaadin/server/VaadinPortletRequest.java @@ -202,7 +202,7 @@ public class VaadinPortletRequest implements VaadinRequest { } @Override - public VaadinPortletService getVaadinService() { + public VaadinPortletService getService() { return vaadinService; } diff --git a/server/src/com/vaadin/server/VaadinPortletResponse.java b/server/src/com/vaadin/server/VaadinPortletResponse.java index efec091bb3..c59af2f2b0 100644 --- a/server/src/com/vaadin/server/VaadinPortletResponse.java +++ b/server/src/com/vaadin/server/VaadinPortletResponse.java @@ -115,7 +115,7 @@ public class VaadinPortletResponse implements VaadinResponse { } @Override - public VaadinPortletService getVaadinService() { + public VaadinPortletService getService() { return vaadinService; } }
\ No newline at end of file diff --git a/server/src/com/vaadin/server/VaadinPortletService.java b/server/src/com/vaadin/server/VaadinPortletService.java index 9940cb5a79..8025fa7713 100644 --- a/server/src/com/vaadin/server/VaadinPortletService.java +++ b/server/src/com/vaadin/server/VaadinPortletService.java @@ -25,7 +25,6 @@ import javax.portlet.PortletContext; import javax.portlet.PortletRequest; import com.vaadin.server.VaadinPortlet.RequestType; -import com.vaadin.ui.UI; public class VaadinPortletService extends VaadinService { private final VaadinPortlet portlet; @@ -52,6 +51,13 @@ public class VaadinPortletService extends VaadinService { // portal property widgetset = VaadinPortletRequest.cast(request).getPortalProperty( VaadinPortlet.PORTAL_PARAMETER_VAADIN_WIDGETSET); + if ("com.vaadin.portal.gwt.PortalDefaultWidgetSet" + .equals(widgetset)) { + // For backwards compatibility - automatically map old portal + // default widget set to default widget set + widgetset = VaadinPortlet.DEFAULT_WIDGETSET; + + } } if (widgetset == null) { @@ -214,8 +220,7 @@ public class VaadinPortletService extends VaadinService { * Always preserve UIs in portlets to make portlet actions work. */ @Override - public boolean preserveUIOnRefresh(VaadinRequest request, UI ui, - UIProvider provider) { + public boolean preserveUIOnRefresh(UIProvider provider, UICreateEvent event) { return true; } }
\ No newline at end of file diff --git a/server/src/com/vaadin/server/VaadinPortletSession.java b/server/src/com/vaadin/server/VaadinPortletSession.java index e5b512588d..4a2cf04dc3 100644 --- a/server/src/com/vaadin/server/VaadinPortletSession.java +++ b/server/src/com/vaadin/server/VaadinPortletSession.java @@ -87,7 +87,7 @@ public class VaadinPortletSession extends VaadinSession { public PortletConfig getPortletConfig() { VaadinPortletResponse response = (VaadinPortletResponse) CurrentInstance .get(VaadinResponse.class); - return response.getVaadinService().getPortlet().getPortletConfig(); + return response.getService().getPortlet().getPortletConfig(); } public void addPortletListener(PortletListener listener) { diff --git a/server/src/com/vaadin/server/VaadinRequest.java b/server/src/com/vaadin/server/VaadinRequest.java index e48b9ede84..7e2ae75850 100644 --- a/server/src/com/vaadin/server/VaadinRequest.java +++ b/server/src/com/vaadin/server/VaadinRequest.java @@ -285,6 +285,6 @@ public interface VaadinRequest extends Serializable { * * @see VaadinService */ - public VaadinService getVaadinService(); + public VaadinService getService(); } diff --git a/server/src/com/vaadin/server/VaadinResponse.java b/server/src/com/vaadin/server/VaadinResponse.java index bfa36015a3..d1b2ac1254 100644 --- a/server/src/com/vaadin/server/VaadinResponse.java +++ b/server/src/com/vaadin/server/VaadinResponse.java @@ -155,5 +155,5 @@ public interface VaadinResponse extends Serializable { * * @see VaadinService */ - public VaadinService getVaadinService(); + public VaadinService getService(); } diff --git a/server/src/com/vaadin/server/VaadinService.java b/server/src/com/vaadin/server/VaadinService.java index b3f9cd3ecf..2c0331c65e 100644 --- a/server/src/com/vaadin/server/VaadinService.java +++ b/server/src/com/vaadin/server/VaadinService.java @@ -110,7 +110,7 @@ public abstract class VaadinService implements Serializable { * * @return the Vaadin service that htis data belongs to */ - public VaadinService getVaadinService() { + public VaadinService getService() { return vaadinService; } @@ -651,7 +651,7 @@ public abstract class VaadinService implements Serializable { * @return an unmodifiable list of UI providers */ public List<UIProvider> getUIProviders(VaadinSession session) { - return session.getVaadinServiceData(this).getUIProviders(); + return session.getServiceData(this).getUIProviders(); } /** @@ -696,7 +696,7 @@ public abstract class VaadinService implements Serializable { * the UI provider that should be added */ public void addUIProvider(VaadinSession vaadinSession, UIProvider uiProvider) { - vaadinSession.getVaadinServiceData(this).addUIProvider(uiProvider); + vaadinSession.getServiceData(this).addUIProvider(uiProvider); } /** @@ -709,7 +709,7 @@ public abstract class VaadinService implements Serializable { */ public void removeUIProvider(VaadinSession vaadinSession, UIProvider uiProvider) { - vaadinSession.getVaadinServiceData(this).removeUIProvider(uiProvider); + vaadinSession.getServiceData(this).removeUIProvider(uiProvider); } /** @@ -719,19 +719,16 @@ public abstract class VaadinService implements Serializable { * typically checks the @{@link PreserveOnRefresh} annotation but UI * providers and ultimately VaadinService implementations may choose to * override the defaults. - * - * @param request - * the Vaadin request used to initialize the UI - * @param ui - * the UI for which the preserve setting should be returned * @param provider * the UI provider responsible for the UI + * @param event + * the UI create event with details about the UI + * * @return <code>true</code> if the UI should be preserved on refresh; * <code>false</code> if a new UI instance should be initialized on * refreshed. */ - public boolean preserveUIOnRefresh(VaadinRequest request, UI ui, - UIProvider provider) { - return provider.isPreservedOnRefresh(request, ui.getClass()); + public boolean preserveUIOnRefresh(UIProvider provider, UICreateEvent event) { + return provider.isPreservedOnRefresh(event); } } diff --git a/server/src/com/vaadin/server/VaadinServlet.java b/server/src/com/vaadin/server/VaadinServlet.java index c8f85020d5..633cffab2a 100644 --- a/server/src/com/vaadin/server/VaadinServlet.java +++ b/server/src/com/vaadin/server/VaadinServlet.java @@ -217,7 +217,7 @@ public class VaadinServlet extends HttpServlet implements Constants { RequestTimer requestTimer = new RequestTimer(); requestTimer.start(); - getVaadinService().setCurrentInstances(request, response); + getService().setCurrentInstances(request, response); AbstractApplicationServletWrapper servletWrapper = new AbstractApplicationServletWrapper( this); @@ -249,13 +249,13 @@ public class VaadinServlet extends HttpServlet implements Constants { && request.getParameterMap().containsKey( ApplicationConstants.PARAM_UNLOADBURST) && request.getContentLength() < 1 - && getVaadinService().getExistingSession(request, false) == null) { + && getService().getExistingSession(request, false) == null) { redirectToApplication(request, response); return; } // Find out the Vaadin session this request is related to - vaadinSession = (VaadinServletSession) getVaadinService() + vaadinSession = (VaadinServletSession) getService() .findVaadinSession(request); if (vaadinSession == null) { return; @@ -285,7 +285,7 @@ public class VaadinServlet extends HttpServlet implements Constants { response); return; } else if (requestType == RequestType.UIDL) { - UI uI = getVaadinService().findUI(request); + UI uI = getService().findUI(request); if (uI == null) { throw new ServletException(ERROR_NO_UI_FOUND); } @@ -303,7 +303,9 @@ public class VaadinServlet extends HttpServlet implements Constants { if (communicationManager.handleOtherRequest(request, response)) { return; } - // TODO Should return 404 error here and not do anything more + + // Request not handled by any RequestHandler -> 404 + response.sendError(HttpServletResponse.SC_NOT_FOUND); } catch (final SessionExpiredException e) { // Session has expired, notify user @@ -328,7 +330,7 @@ public class VaadinServlet extends HttpServlet implements Constants { private VaadinServletResponse createVaadinResponse( HttpServletResponse response) { - return new VaadinServletResponse(response, getVaadinService()); + return new VaadinServletResponse(response, getService()); } /** @@ -341,7 +343,7 @@ public class VaadinServlet extends HttpServlet implements Constants { */ protected VaadinServletRequest createVaadinRequest( HttpServletRequest request) { - return new VaadinServletRequest(request, getVaadinService()); + return new VaadinServletRequest(request, getService()); } /** @@ -349,7 +351,7 @@ public class VaadinServlet extends HttpServlet implements Constants { * * @return the vaadin service */ - protected VaadinServletService getVaadinService() { + protected VaadinServletService getService() { return servletService; } @@ -376,7 +378,7 @@ public class VaadinServlet extends HttpServlet implements Constants { // This can be removed if cookieless mode (#3228) is supported if (request.getRequestedSessionId() == null) { // User has cookies disabled - SystemMessages systemMessages = getVaadinService() + SystemMessages systemMessages = getService() .getSystemMessages(); criticalNotification(request, response, systemMessages.getCookiesDisabledCaption(), @@ -533,7 +535,7 @@ public class VaadinServlet extends HttpServlet implements Constants { Throwable e) throws IOException, ServletException { // if this was an UIDL request, response UIDL back to client if (getRequestType(request) == RequestType.UIDL) { - SystemMessages ci = getVaadinService().getSystemMessages(); + SystemMessages ci = getService().getSystemMessages(); criticalNotification(request, response, ci.getInternalErrorCaption(), ci.getInternalErrorMessage(), null, ci.getInternalErrorURL()); @@ -608,7 +610,7 @@ public class VaadinServlet extends HttpServlet implements Constants { } try { - SystemMessages ci = getVaadinService().getSystemMessages(); + SystemMessages ci = getService().getSystemMessages(); RequestType requestType = getRequestType(request); if (requestType == RequestType.UIDL) { /* @@ -653,7 +655,7 @@ public class VaadinServlet extends HttpServlet implements Constants { } try { - SystemMessages ci = getVaadinService().getSystemMessages(); + SystemMessages ci = getService().getSystemMessages(); RequestType requestType = getRequestType(request); if (requestType == RequestType.UIDL) { // send uidl redirect @@ -820,7 +822,7 @@ public class VaadinServlet extends HttpServlet implements Constants { * cache timeout can be configured by setting the resourceCacheTime * parameter in web.xml */ - int resourceCacheTime = getVaadinService() + int resourceCacheTime = getService() .getDeploymentConfiguration().getResourceCacheTime(); response.setHeader("Cache-Control", "max-age= " + String.valueOf(resourceCacheTime)); @@ -848,7 +850,7 @@ public class VaadinServlet extends HttpServlet implements Constants { filename = filename.substring(1); } - resourceUrl = getVaadinService().getClassLoader().getResource( + resourceUrl = getService().getClassLoader().getResource( filename); } return resourceUrl; @@ -857,7 +859,7 @@ public class VaadinServlet extends HttpServlet implements Constants { private boolean serveOnTheFlyCompiledScss(String filename, HttpServletRequest request, HttpServletResponse response, ServletContext sc) throws IOException { - if (getVaadinService().getDeploymentConfiguration().isProductionMode()) { + if (getService().getDeploymentConfiguration().isProductionMode()) { // This is not meant for production mode. return false; } @@ -907,7 +909,7 @@ public class VaadinServlet extends HttpServlet implements Constants { // This is for development mode only so instruct the browser to never // cache it response.setHeader("Cache-Control", "no-cache"); - final String mimetype = getVaadinService().getMimeType(filename); + final String mimetype = getService().getMimeType(filename); writeResponse(response, mimetype, scss.toString()); return true; diff --git a/server/src/com/vaadin/server/VaadinServletRequest.java b/server/src/com/vaadin/server/VaadinServletRequest.java index ece7d187bc..6526766b0f 100644 --- a/server/src/com/vaadin/server/VaadinServletRequest.java +++ b/server/src/com/vaadin/server/VaadinServletRequest.java @@ -79,7 +79,7 @@ public class VaadinServletRequest extends HttpServletRequestWrapper implements } @Override - public VaadinServletService getVaadinService() { + public VaadinServletService getService() { return vaadinService; } diff --git a/server/src/com/vaadin/server/VaadinServletResponse.java b/server/src/com/vaadin/server/VaadinServletResponse.java index f999a470dd..72d1207ac5 100644 --- a/server/src/com/vaadin/server/VaadinServletResponse.java +++ b/server/src/com/vaadin/server/VaadinServletResponse.java @@ -79,7 +79,7 @@ public class VaadinServletResponse extends HttpServletResponseWrapper implements } @Override - public VaadinServletService getVaadinService() { + public VaadinServletService getService() { return vaadinService; } }
\ No newline at end of file diff --git a/server/src/com/vaadin/server/VaadinSession.java b/server/src/com/vaadin/server/VaadinSession.java index 0bf5f8616b..febdc5dad5 100644 --- a/server/src/com/vaadin/server/VaadinSession.java +++ b/server/src/com/vaadin/server/VaadinSession.java @@ -212,7 +212,7 @@ public class VaadinSession implements HttpSessionBindingListener, Serializable { // closing // Notify all services that have used this session. for (VaadinServiceData vaadinServiceData : serviceData.values()) { - vaadinServiceData.getVaadinService().fireSessionDestroy(this); + vaadinServiceData.getService().fireSessionDestroy(this); } } @@ -1057,7 +1057,7 @@ public class VaadinSession implements HttpSessionBindingListener, Serializable { * the passed Vaadin service; otherwise <code>false</code> */ public boolean hasVaadinServiceData(VaadinService vaadinService) { - return getVaadinServiceData(vaadinService) != null; + return getServiceData(vaadinService) != null; } /** @@ -1071,21 +1071,21 @@ public class VaadinSession implements HttpSessionBindingListener, Serializable { * @return the Vaadin service data for the provided Vaadin service; or * <code>null</code> if there is no data for the service */ - public VaadinServiceData getVaadinServiceData(VaadinService vaadinService) { + public VaadinServiceData getServiceData(VaadinService vaadinService) { return serviceData.get(getServiceKey(vaadinService)); } /** * Adds Vaadin service specific data to this session. * - * @see #getVaadinServiceData(VaadinService) + * @see #getServiceData(VaadinService) * @see VaadinServiceData * * @param serviceData * the Vaadin service data to add */ public void addVaadinServiceData(VaadinServiceData serviceData) { - VaadinService vaadinService = serviceData.getVaadinService(); + VaadinService vaadinService = serviceData.getService(); assert !hasVaadinServiceData(vaadinService); this.serviceData.put(getServiceKey(vaadinService), serviceData); diff --git a/server/src/com/vaadin/server/VaadinSessionDestroyEvent.java b/server/src/com/vaadin/server/VaadinSessionDestroyEvent.java index 3916f756e9..9dc877863f 100644 --- a/server/src/com/vaadin/server/VaadinSessionDestroyEvent.java +++ b/server/src/com/vaadin/server/VaadinSessionDestroyEvent.java @@ -54,7 +54,7 @@ public class VaadinSessionDestroyEvent extends EventObject { * * @return the Vaadin service */ - public VaadinService getVaadinService() { + public VaadinService getService() { return getSource(); } @@ -63,7 +63,7 @@ public class VaadinSessionDestroyEvent extends EventObject { * * @return the Vaadin session */ - public VaadinSession getVaadinSession() { + public VaadinSession getSession() { return session; } diff --git a/server/src/com/vaadin/server/VaadinSessionInitializeEvent.java b/server/src/com/vaadin/server/VaadinSessionInitializeEvent.java index 217e3d8f7d..a05b40a7dc 100644 --- a/server/src/com/vaadin/server/VaadinSessionInitializeEvent.java +++ b/server/src/com/vaadin/server/VaadinSessionInitializeEvent.java @@ -64,7 +64,7 @@ public class VaadinSessionInitializeEvent extends EventObject { * * @return the Vaadin service instance */ - public VaadinService getVaadinService() { + public VaadinService getService() { return getSource(); } @@ -73,7 +73,7 @@ public class VaadinSessionInitializeEvent extends EventObject { * * @return the Vaadin session */ - public VaadinSession getVaadinSession() { + public VaadinSession getSession() { return session; } diff --git a/server/src/com/vaadin/ui/AbstractField.java b/server/src/com/vaadin/ui/AbstractField.java index e7d6d9a4ec..d6dd03c171 100644 --- a/server/src/com/vaadin/ui/AbstractField.java +++ b/server/src/com/vaadin/ui/AbstractField.java @@ -776,15 +776,16 @@ public abstract class AbstractField<T> extends AbstractComponent implements /** * Gets the validators of the field. * - * @return the Unmodifiable collection that holds all validators for the + * @return An unmodifiable collection that holds all validators for the * field. */ @Override public Collection<Validator> getValidators() { - if (validators == null || validators.isEmpty()) { - return null; + if (validators == null) { + return Collections.emptyList(); + } else { + return Collections.unmodifiableCollection(validators); } - return Collections.unmodifiableCollection(validators); } /** @@ -804,6 +805,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements /** * Removes all validators from the field. */ + @Override public void removeAllValidators() { if (validators != null) { validators.clear(); diff --git a/server/src/com/vaadin/ui/LoginForm.java b/server/src/com/vaadin/ui/LoginForm.java index 661c24bf56..a748d8d4c5 100644 --- a/server/src/com/vaadin/ui/LoginForm.java +++ b/server/src/com/vaadin/ui/LoginForm.java @@ -27,9 +27,9 @@ import java.util.Map; import com.vaadin.server.ConnectorResource; import com.vaadin.server.DownloadStream; import com.vaadin.server.RequestHandler; -import com.vaadin.server.VaadinSession; import com.vaadin.server.VaadinRequest; import com.vaadin.server.VaadinResponse; +import com.vaadin.server.VaadinSession; import com.vaadin.shared.ApplicationConstants; /** @@ -49,7 +49,11 @@ import com.vaadin.shared.ApplicationConstants; * default component tries to guess the right place for theme css. * * @since 5.3 + * @deprecated as of Vaadin 7.0. This component no longer fulfills its duty + * reliably in the supported browsers and a {@link VerticalLayout} + * with two {@link TextField}s can be used instead. */ +@Deprecated public class LoginForm extends CustomComponent { private String usernameCaption = "Username"; @@ -161,7 +165,7 @@ public class LoginForm extends CustomComponent { + "\">" + "<div class='v-app v-app-loginpage' style=\"background:transparent;\">" + "<iframe name='logintarget' style='width:0;height:0;" - + "border:0;margin:0;padding:0;'></iframe>" + + "border:0;margin:0;padding:0;display:block'></iframe>" + "<form id='loginf' target='logintarget' onkeypress=\"submitOnEnter(event)\" method=\"post\">" + "<div>" + usernameCaption diff --git a/server/tests/src/com/vaadin/server/TestAbstractApplicationServletStaticFilesLocation.java b/server/tests/src/com/vaadin/server/TestAbstractApplicationServletStaticFilesLocation.java index 18f7fae166..533bcc8422 100644 --- a/server/tests/src/com/vaadin/server/TestAbstractApplicationServletStaticFilesLocation.java +++ b/server/tests/src/com/vaadin/server/TestAbstractApplicationServletStaticFilesLocation.java @@ -78,7 +78,7 @@ public class TestAbstractApplicationServletStaticFilesLocation extends TestCase // Set request into replay mode replay(request); - String location = servlet.getVaadinService().getStaticFileLocation( + String location = servlet.getService().getStaticFileLocation( servlet.createVaadinRequest(request)); return location; } @@ -91,7 +91,7 @@ public class TestAbstractApplicationServletStaticFilesLocation extends TestCase // Set request into replay mode replay(request); - String location = servlet.getVaadinService().getStaticFileLocation( + String location = servlet.getService().getStaticFileLocation( servlet.createVaadinRequest(request)); return location; } diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractfield/AbstractFieldValidators.java b/server/tests/src/com/vaadin/tests/server/component/abstractfield/AbstractFieldValidators.java new file mode 100644 index 0000000000..19c58fe6d3 --- /dev/null +++ b/server/tests/src/com/vaadin/tests/server/component/abstractfield/AbstractFieldValidators.java @@ -0,0 +1,64 @@ +package com.vaadin.tests.server.component.abstractfield; + +import junit.framework.TestCase; + +import org.easymock.EasyMock; + +import com.vaadin.data.Validator; +import com.vaadin.ui.AbstractField; +import com.vaadin.ui.Field; + +public class AbstractFieldValidators extends TestCase { + + Field<Object> field = new AbstractField<Object>() { + @Override + public Class getType() { + return Object.class; + } + }; + + Validator validator = EasyMock.createMock(Validator.class); + Validator validator2 = EasyMock.createMock(Validator.class); + + public void testAddValidator() { + assertNotNull(field.getValidators()); + assertEquals(0, field.getValidators().size()); + + field.addValidator(validator); + assertEquals(1, field.getValidators().size()); + assertTrue(field.getValidators().contains(validator)); + + field.addValidator(validator2); + assertEquals(2, field.getValidators().size()); + assertTrue(field.getValidators().contains(validator)); + assertTrue(field.getValidators().contains(validator2)); + } + + public void testRemoveValidator() { + field.addValidator(validator); + field.addValidator(validator2); + + field.removeValidator(validator); + assertNotNull(field.getValidators()); + assertEquals(1, field.getValidators().size()); + assertFalse(field.getValidators().contains(validator)); + assertTrue(field.getValidators().contains(validator2)); + + field.removeValidator(validator2); + assertNotNull(field.getValidators()); + assertEquals(0, field.getValidators().size()); + assertFalse(field.getValidators().contains(validator)); + assertFalse(field.getValidators().contains(validator2)); + } + + public void testRemoveAllValidators() { + field.addValidator(validator); + field.addValidator(validator2); + + field.removeAllValidators(); + assertNotNull(field.getValidators()); + assertEquals(0, field.getValidators().size()); + assertFalse(field.getValidators().contains(validator)); + assertFalse(field.getValidators().contains(validator2)); + } +} diff --git a/server/tests/src/com/vaadin/tests/server/component/root/CustomUIClassLoader.java b/server/tests/src/com/vaadin/tests/server/component/root/CustomUIClassLoader.java index 858a18b223..c7730e9294 100644 --- a/server/tests/src/com/vaadin/tests/server/component/root/CustomUIClassLoader.java +++ b/server/tests/src/com/vaadin/tests/server/component/root/CustomUIClassLoader.java @@ -11,6 +11,7 @@ import org.easymock.EasyMock; import com.vaadin.DefaultDeploymentConfiguration; import com.vaadin.server.DefaultUIProvider; import com.vaadin.server.DeploymentConfiguration; +import com.vaadin.server.UIClassSelectionEvent; import com.vaadin.server.VaadinRequest; import com.vaadin.server.VaadinService; import com.vaadin.server.VaadinSession; @@ -59,7 +60,7 @@ public class CustomUIClassLoader extends TestCase { DefaultUIProvider uiProvider = new DefaultUIProvider(); Class<? extends UI> uiClass = uiProvider - .getUIClass(createRequestMock(null)); + .getUIClass(new UIClassSelectionEvent(createRequestMock(null))); assertEquals(MyUI.class, uiClass); } @@ -80,7 +81,7 @@ public class CustomUIClassLoader extends TestCase { // Mock a VaadinRequest to give the mocked vaadin service VaadinRequest requestMock = EasyMock.createMock(VaadinRequest.class); - EasyMock.expect(requestMock.getVaadinService()).andReturn( + EasyMock.expect(requestMock.getService()).andReturn( configurationMock); EasyMock.replay(configurationMock, requestMock); @@ -103,7 +104,7 @@ public class CustomUIClassLoader extends TestCase { DefaultUIProvider uiProvider = new DefaultUIProvider(); Class<? extends UI> uiClass = uiProvider - .getUIClass(createRequestMock(loggingClassLoader)); + .getUIClass(new UIClassSelectionEvent(createRequestMock(null))); assertEquals(MyUI.class, uiClass); assertEquals(1, loggingClassLoader.requestedClasses.size()); diff --git a/server/tests/src/com/vaadin/tests/server/component/window/AttachDetachWindow.java b/server/tests/src/com/vaadin/tests/server/component/window/AttachDetachWindow.java index a41b200664..09cb75a9eb 100644 --- a/server/tests/src/com/vaadin/tests/server/component/window/AttachDetachWindow.java +++ b/server/tests/src/com/vaadin/tests/server/component/window/AttachDetachWindow.java @@ -238,12 +238,12 @@ public class AttachDetachWindow { private void assertUnattached(TestContainer win) { assertSame("window not detached", win.getSession(), null); assertSame("window content not detached", - getVaadinSession(win.getTestContent()), null); + getSession(win.getTestContent()), null); assertSame("window children not detached", - getVaadinSession(win.getTestContent().child), null); + getSession(win.getTestContent().child), null); } - private VaadinSession getVaadinSession(ClientConnector testContainer) { + private VaadinSession getSession(ClientConnector testContainer) { UI ui = testContainer.getUI(); if (ui != null) { return ui.getSession(); diff --git a/server/tests/src/com/vaadin/tests/server/navigator/NavigatorTest.java b/server/tests/src/com/vaadin/tests/server/navigator/NavigatorTest.java index fc36c77e56..cf8a2870a9 100644 --- a/server/tests/src/com/vaadin/tests/server/navigator/NavigatorTest.java +++ b/server/tests/src/com/vaadin/tests/server/navigator/NavigatorTest.java @@ -33,6 +33,7 @@ import com.vaadin.navigator.ViewDisplay; import com.vaadin.navigator.ViewProvider; import com.vaadin.tests.server.navigator.ClassBasedViewProviderTest.TestView; import com.vaadin.tests.server.navigator.ClassBasedViewProviderTest.TestView2; +import com.vaadin.ui.UI; public class NavigatorTest extends TestCase { @@ -56,6 +57,11 @@ public class NavigatorTest extends TestCase { public void setState(String fragment) { // do nothing } + + @Override + public void setNavigator(Navigator navigator) { + // do nothing + } } public static class TestDisplay implements ViewDisplay { @@ -73,7 +79,7 @@ public class NavigatorTest extends TestCase { public static class TestNavigator extends Navigator { public TestNavigator() { - super(null, new NullFragmentManager(), new TestDisplay()); + super(createMockUI(), new NullFragmentManager(), new TestDisplay()); } public View getView(String viewAndParameters) { @@ -190,6 +196,18 @@ public class NavigatorTest extends TestCase { return null; } + private static UI createMockUI() { + UI ui = EasyMock.createMock(UI.class); + ui.setNavigator(EasyMock.anyObject(Navigator.class)); + EasyMock.replay(ui); + return ui; + } + + private static Navigator createNavigator(NavigationStateManager manager, + ViewDisplay display) { + return new Navigator(createMockUI(), manager, display); + } + public void testBasicNavigation() { IMocksControl control = EasyMock.createControl(); NavigationStateManager manager = control @@ -200,6 +218,8 @@ public class NavigatorTest extends TestCase { View view2 = control.createMock(View.class); // prepare mocks: what to expect + manager.setNavigator(EasyMock.anyObject(Navigator.class)); + EasyMock.expect(provider.getViewName("test1")).andReturn("test1"); EasyMock.expect(provider.getView("test1")).andReturn(view1); EasyMock.expect(manager.getState()).andReturn(""); @@ -225,7 +245,7 @@ public class NavigatorTest extends TestCase { control.replay(); // create and test navigator - Navigator navigator = new Navigator(null, manager, display); + Navigator navigator = createNavigator(manager, display); navigator.addProvider(provider); navigator.navigateTo("test1"); @@ -243,6 +263,8 @@ public class NavigatorTest extends TestCase { View view2 = control.createMock(View.class); // prepare mocks: what to expect + manager.setNavigator(EasyMock.anyObject(Navigator.class)); + EasyMock.expect(provider.getViewName("test2")).andReturn("test2"); EasyMock.expect(provider.getView("test2")).andReturn(view2); EasyMock.expect(manager.getState()).andReturn("view1"); @@ -268,7 +290,7 @@ public class NavigatorTest extends TestCase { control.replay(); // create and test navigator - Navigator navigator = new Navigator(null, manager, display); + Navigator navigator = createNavigator(manager, display); navigator.addProvider(provider); navigator.navigateTo("test2"); @@ -287,7 +309,7 @@ public class NavigatorTest extends TestCase { ViewChangeTestListener listener = new ViewChangeTestListener(); // create navigator to test - Navigator navigator = new Navigator(null, manager, display); + Navigator navigator = createNavigator(manager, display); // prepare mocks: what to expect EasyMock.expect(provider.getViewName("test1")).andReturn("test1"); @@ -337,7 +359,7 @@ public class NavigatorTest extends TestCase { ViewChangeTestListener listener1 = new ViewChangeTestListener(); ViewChangeTestListener listener2 = new ViewChangeTestListener(); - Navigator navigator = new Navigator(null, manager, display); + Navigator navigator = createNavigator(manager, display); // prepare mocks: what to expect // first listener blocks first view change @@ -471,8 +493,7 @@ public class NavigatorTest extends TestCase { } public void testAddViewWithNullName() throws Exception { - Navigator navigator = new Navigator(null, new NullFragmentManager(), - new NullDisplay()); + Navigator navigator = new TestNavigator(); try { navigator.addView(null, new TestView()); @@ -487,8 +508,7 @@ public class NavigatorTest extends TestCase { } public void testAddViewWithNullInstance() throws Exception { - Navigator navigator = new Navigator(null, new NullFragmentManager(), - new NullDisplay()); + Navigator navigator = new TestNavigator(); try { navigator.addView("test", (View) null); @@ -498,8 +518,7 @@ public class NavigatorTest extends TestCase { } public void testAddViewWithNullClass() throws Exception { - Navigator navigator = new Navigator(null, new NullFragmentManager(), - new NullDisplay()); + Navigator navigator = new TestNavigator(); try { navigator.addView("test", (Class<View>) null); diff --git a/server/tests/src/com/vaadin/tests/server/navigator/UriFragmentManagerTest.java b/server/tests/src/com/vaadin/tests/server/navigator/UriFragmentManagerTest.java index 905ddb529b..41bebfcf0c 100644 --- a/server/tests/src/com/vaadin/tests/server/navigator/UriFragmentManagerTest.java +++ b/server/tests/src/com/vaadin/tests/server/navigator/UriFragmentManagerTest.java @@ -30,12 +30,12 @@ public class UriFragmentManagerTest extends TestCase { public void testGetSetFragment() { Page page = EasyMock.createMock(Page.class); - UriFragmentManager manager = new UriFragmentManager(page, null); + UriFragmentManager manager = new UriFragmentManager(page); // prepare mock EasyMock.expect(page.getFragment()).andReturn(""); - page.setFragment("test", false); - EasyMock.expect(page.getFragment()).andReturn("test"); + page.setFragment("!test", false); + EasyMock.expect(page.getFragment()).andReturn("!test"); EasyMock.replay(page); // test manager using the mock @@ -50,9 +50,10 @@ public class UriFragmentManagerTest extends TestCase { Navigator navigator = control.createMock(Navigator.class); Page page = control.createMock(Page.class); - UriFragmentManager manager = new UriFragmentManager(page, navigator); + UriFragmentManager manager = new UriFragmentManager(page); + manager.setNavigator(navigator); - EasyMock.expect(page.getFragment()).andReturn("test"); + EasyMock.expect(page.getFragment()).andReturn("!test"); navigator.navigateTo("test"); control.replay(); diff --git a/shared/src/com/vaadin/shared/ui/slider/SliderState.java b/shared/src/com/vaadin/shared/ui/slider/SliderState.java index 7236672b31..ca18f72b7a 100644 --- a/shared/src/com/vaadin/shared/ui/slider/SliderState.java +++ b/shared/src/com/vaadin/shared/ui/slider/SliderState.java @@ -6,15 +6,15 @@ public class SliderState extends AbstractFieldState { public double value; - public double maxValue; - public double minValue; + public double maxValue = 100; + public double minValue = 0; /** * The number of fractional digits that are considered significant. Must be * non-negative. */ - public int resolution; + public int resolution = 0; - public SliderOrientation orientation; + public SliderOrientation orientation = SliderOrientation.HORIZONTAL; } diff --git a/theme-compiler/src/com/vaadin/sass/ScssServlet.java b/theme-compiler/src/com/vaadin/sass/ScssServlet.java deleted file mode 100644 index a345ca1583..0000000000 --- a/theme-compiler/src/com/vaadin/sass/ScssServlet.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2011 Vaadin Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ - -package com.vaadin.sass; - -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.IOException; -import java.io.OutputStream; -import java.io.OutputStreamWriter; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -public class ScssServlet extends HttpServlet { - @Override - protected void doGet(HttpServletRequest req, HttpServletResponse resp) - throws ServletException, IOException { - String cssPath = req.getRequestURI(); - if (cssPath.endsWith(".css")) { - File cssFile = new File(cssPath); - if (cssFile.exists()) { - - } else { - String scssPath = cssPath.replace(".css", ".scss"); - File scssFile = new File(scssPath); - if (scssFile.exists()) { - ScssStylesheet scss = ScssStylesheet.get(cssPath); - try { - scss.compile(); - } catch (Exception e) { - e.printStackTrace(); - } - resp.setContentType("text/css"); - OutputStream fout = resp.getOutputStream(); - OutputStream bos = new BufferedOutputStream(fout); - OutputStreamWriter outputwriter = new OutputStreamWriter( - bos); - outputwriter.write(scss.toString()); - } - - } - } - } -} diff --git a/uitest/src/com/vaadin/launcher/ApplicationRunnerServlet.java b/uitest/src/com/vaadin/launcher/ApplicationRunnerServlet.java index b121ae7992..269080a59c 100644 --- a/uitest/src/com/vaadin/launcher/ApplicationRunnerServlet.java +++ b/uitest/src/com/vaadin/launcher/ApplicationRunnerServlet.java @@ -30,10 +30,10 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.vaadin.LegacyApplication; -import com.vaadin.server.UIProvider; import com.vaadin.server.DeploymentConfiguration; import com.vaadin.server.LegacyVaadinServlet; import com.vaadin.server.ServiceException; +import com.vaadin.server.UIClassSelectionEvent; import com.vaadin.server.UIProvider; import com.vaadin.server.VaadinRequest; import com.vaadin.server.VaadinServletRequest; @@ -64,7 +64,7 @@ public class ApplicationRunnerServlet extends LegacyVaadinServlet { Collections.addAll(defaultPackages, initParameter.split(",")); } String str = TestBase.class.getName().replace('.', '/') + ".class"; - URL url = getVaadinService().getClassLoader().getResource(str); + URL url = getService().getClassLoader().getResource(str); if ("file".equals(url.getProtocol())) { File comVaadinTests = new File(url.getPath()).getParentFile() .getParentFile(); @@ -76,14 +76,14 @@ public class ApplicationRunnerServlet extends LegacyVaadinServlet { @Override protected void servletInitialized() { super.servletInitialized(); - getVaadinService().addVaadinSessionInitializationListener( + getService().addVaadinSessionInitializationListener( new VaadinSessionInitializationListener() { @Override public void vaadinSessionInitialized( VaadinSessionInitializeEvent event) throws ServiceException { onVaadinSessionStarted(event.getRequest(), - event.getVaadinSession()); + event.getSession()); } }); } @@ -144,18 +144,17 @@ public class ApplicationRunnerServlet extends LegacyVaadinServlet { try { final Class<?> classToRun = getClassToRun(); if (UI.class.isAssignableFrom(classToRun)) { - getVaadinService().addUIProvider(session, - new UIProvider() { - @Override - public Class<? extends UI> getUIClass( - VaadinRequest request) { - return (Class<? extends UI>) classToRun; - } - }); + getService().addUIProvider(session, new UIProvider() { + @Override + public Class<? extends UI> getUIClass( + UIClassSelectionEvent event) { + return (Class<? extends UI>) classToRun; + } + }); } else if (LegacyApplication.class.isAssignableFrom(classToRun)) { // Avoid using own UIProvider for legacy Application } else if (UIProvider.class.isAssignableFrom(classToRun)) { - getVaadinService().addUIProvider(session, + getService().addUIProvider(session, (UIProvider) classToRun.newInstance()); } else { throw new ServiceException(classToRun.getCanonicalName() @@ -312,7 +311,7 @@ public class ApplicationRunnerServlet extends LegacyVaadinServlet { @Override protected VaadinServletRequest createVaadinRequest( HttpServletRequest request) { - return new VaadinServletRequest(request, getVaadinService()) { + return new VaadinServletRequest(request, getService()) { @Override public String getRequestPathInfo() { return ApplicationRunnerServlet.this.getRequestPathInfo(this); diff --git a/uitest/src/com/vaadin/tests/applicationservlet/InitParamUIProvider.java b/uitest/src/com/vaadin/tests/applicationservlet/InitParamUIProvider.java index 6a2f5c500b..b4f29dda06 100644 --- a/uitest/src/com/vaadin/tests/applicationservlet/InitParamUIProvider.java +++ b/uitest/src/com/vaadin/tests/applicationservlet/InitParamUIProvider.java @@ -16,6 +16,7 @@ package com.vaadin.tests.applicationservlet; +import com.vaadin.server.UIClassSelectionEvent; import com.vaadin.server.UIProvider; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.javascriptcomponent.BasicJavaScriptComponent; @@ -24,7 +25,8 @@ import com.vaadin.ui.UI; public class InitParamUIProvider extends UIProvider { @Override - public Class<? extends UI> getUIClass(VaadinRequest request) { + public Class<? extends UI> getUIClass(UIClassSelectionEvent event) { + VaadinRequest request = event.getRequest(); String pathInfo = request.getRequestPathInfo(); if ("/test".equals(pathInfo)) { return BasicJavaScriptComponent.class; diff --git a/uitest/src/com/vaadin/tests/components/combobox/ComboBoxDataSourceChange.java b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxDataSourceChange.java index a475c86ca0..1f2973ccb7 100644 --- a/uitest/src/com/vaadin/tests/components/combobox/ComboBoxDataSourceChange.java +++ b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxDataSourceChange.java @@ -86,7 +86,8 @@ public class ComboBoxDataSourceChange extends TestBase { cb2.addListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { - currentValue.setValue(event.getProperty().getValue()); + currentValue + .setValue(event.getProperty().getValue().toString()); } }); } diff --git a/uitest/src/com/vaadin/tests/components/label/LabelTest.java b/uitest/src/com/vaadin/tests/components/label/LabelTest.java index 4b213b7a42..5db2669f95 100644 --- a/uitest/src/com/vaadin/tests/components/label/LabelTest.java +++ b/uitest/src/com/vaadin/tests/components/label/LabelTest.java @@ -12,10 +12,10 @@ import com.vaadin.ui.Label; public class LabelTest extends AbstractComponentTest<Label> implements ValueChangeListener { - private Command<Label, Object> setValueCommand = new Command<Label, Object>() { + private Command<Label, String> setValueCommand = new Command<Label, String>() { @Override - public void execute(Label c, Object value, Object data) { + public void execute(Label c, String value, Object data) { c.setValue(value); } }; diff --git a/uitest/src/com/vaadin/tests/components/orderedlayout/VerticalRelativeChildren.html b/uitest/src/com/vaadin/tests/components/orderedlayout/VerticalRelativeChildren.html new file mode 100644 index 0000000000..bcff408592 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/orderedlayout/VerticalRelativeChildren.html @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<link rel="selenium.base" href="" /> +<title>New Test</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">New Test</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.orderedlayout.VerticalRelativeChildren?restartApplication</td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td></td> +</tr> + +</tbody></table> +</body> +</html> diff --git a/uitest/src/com/vaadin/tests/components/orderedlayout/VerticalRelativeChildren.java b/uitest/src/com/vaadin/tests/components/orderedlayout/VerticalRelativeChildren.java new file mode 100644 index 0000000000..260bfb02a4 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/orderedlayout/VerticalRelativeChildren.java @@ -0,0 +1,59 @@ +package com.vaadin.tests.components.orderedlayout; + +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.Alignment; +import com.vaadin.ui.TextArea; +import com.vaadin.ui.VerticalLayout; + +public class VerticalRelativeChildren extends TestBase { + + @Override + protected void setup() { + + VerticalLayout vl = new VerticalLayout(); + vl.setWidth("300px"); + + TextArea areaUndefined = new TextArea(); + areaUndefined.setSizeUndefined(); + areaUndefined.setValue("Undefined height"); + vl.addComponent(areaUndefined); + + TextArea areaDefined = new TextArea(); + areaDefined.setWidth("200px"); + areaDefined.setValue("200px width"); + vl.addComponent(areaDefined); + + TextArea areaRelativeBottom = new TextArea(); + areaRelativeBottom.setWidth("50%"); + areaRelativeBottom.setValue("50% width, right align"); + vl.addComponent(areaRelativeBottom); + vl.setComponentAlignment(areaRelativeBottom, Alignment.TOP_RIGHT); + + TextArea areaRelativeCenter = new TextArea(); + areaRelativeCenter.setWidth("50%"); + areaRelativeCenter.setValue("50% width, center align"); + vl.addComponent(areaRelativeCenter); + vl.setComponentAlignment(areaRelativeCenter, Alignment.TOP_CENTER); + + TextArea areaRelativeTop = new TextArea(); + areaRelativeTop.setWidth("50%"); + areaRelativeTop.setValue("50% width, left align"); + vl.addComponent(areaRelativeTop); + vl.setComponentAlignment(areaRelativeTop, Alignment.TOP_LEFT); + + addComponent(vl); + } + + @Override + protected String getDescription() { + // TODO Auto-generated method stub + return null; + } + + @Override + protected Integer getTicketNumber() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/textarea/TextAreaCursorPosition.java b/uitest/src/com/vaadin/tests/components/textarea/TextAreaCursorPosition.java index 992f20843b..756970898e 100644 --- a/uitest/src/com/vaadin/tests/components/textarea/TextAreaCursorPosition.java +++ b/uitest/src/com/vaadin/tests/components/textarea/TextAreaCursorPosition.java @@ -37,7 +37,8 @@ public class TextAreaCursorPosition extends TestBase { public void textChange(TextChangeEvent event) { AbstractTextField component = (AbstractTextField) event .getComponent(); - cursorPosition.setValue(component.getCursorPosition()); + cursorPosition.setValue(String.valueOf(component + .getCursorPosition())); } }); } diff --git a/uitest/src/com/vaadin/tests/components/tree/CtrlShiftMultiselect.java b/uitest/src/com/vaadin/tests/components/tree/CtrlShiftMultiselect.java index 03645557f2..3ce2e38eba 100644 --- a/uitest/src/com/vaadin/tests/components/tree/CtrlShiftMultiselect.java +++ b/uitest/src/com/vaadin/tests/components/tree/CtrlShiftMultiselect.java @@ -39,10 +39,10 @@ public class CtrlShiftMultiselect extends TestBase { if (itemIds.size() == 0) { valueLbl.setValue("No selection"); } else { - valueLbl.setValue(itemIds); + valueLbl.setValue(itemIds.toString()); } } else { - valueLbl.setValue(tree.getValue()); + valueLbl.setValue(tree.getValue().toString()); } } }); diff --git a/uitest/src/com/vaadin/tests/components/tree/ExpandCollapseTree.java b/uitest/src/com/vaadin/tests/components/tree/ExpandCollapseTree.java index d5c3654b4e..81e177c39b 100644 --- a/uitest/src/com/vaadin/tests/components/tree/ExpandCollapseTree.java +++ b/uitest/src/com/vaadin/tests/components/tree/ExpandCollapseTree.java @@ -39,10 +39,10 @@ public class ExpandCollapseTree extends TestBase { if (itemIds.size() == 0) { valueLbl.setValue("No selection"); } else { - valueLbl.setValue(itemIds); + valueLbl.setValue(itemIds.toString()); } } else { - valueLbl.setValue(tree.getValue()); + valueLbl.setValue(tree.getValue().toString()); } } }); diff --git a/uitest/src/com/vaadin/tests/components/tree/TreeContainerChange.java b/uitest/src/com/vaadin/tests/components/tree/TreeContainerChange.java index f4374ca2ee..2dde7bbb30 100644 --- a/uitest/src/com/vaadin/tests/components/tree/TreeContainerChange.java +++ b/uitest/src/com/vaadin/tests/components/tree/TreeContainerChange.java @@ -86,7 +86,8 @@ public class TreeContainerChange extends TestBase { tree.addListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { - currentValue.setValue(event.getProperty().getValue()); + currentValue + .setValue(event.getProperty().getValue().toString()); } }); } diff --git a/uitest/src/com/vaadin/tests/components/ui/LazyInitUIs.java b/uitest/src/com/vaadin/tests/components/ui/LazyInitUIs.java index d405a4c138..9524a41cd8 100644 --- a/uitest/src/com/vaadin/tests/components/ui/LazyInitUIs.java +++ b/uitest/src/com/vaadin/tests/components/ui/LazyInitUIs.java @@ -1,8 +1,11 @@ package com.vaadin.tests.components.ui; import com.vaadin.server.ExternalResource; -import com.vaadin.server.VaadinSession; +import com.vaadin.server.UIClassSelectionEvent; +import com.vaadin.server.UICreateEvent; +import com.vaadin.server.UIProviderEvent; import com.vaadin.server.VaadinRequest; +import com.vaadin.server.VaadinSession; import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.tests.components.AbstractTestUIProvider; import com.vaadin.ui.Label; @@ -20,17 +23,17 @@ public class LazyInitUIs extends AbstractTestUIProvider { } @Override - public UI createInstance(VaadinRequest request, - Class<? extends UI> type) { - return getUI(request); + public UI createInstance(UICreateEvent event) { + return getUI(event); } @Override - public Class<? extends UI> getUIClass(VaadinRequest request) { - return getUI(request).getClass(); + public Class<? extends UI> getUIClass(UIClassSelectionEvent event) { + return getUI(event).getClass(); } - private UI getUI(VaadinRequest request) { + private UI getUI(UIProviderEvent event) { + VaadinRequest request = event.getRequest(); if (request.getParameter("lazyCreate") != null) { // UI created on second request UI uI = new UI() { diff --git a/uitest/src/com/vaadin/tests/components/ui/UIsInMultipleTabs.java b/uitest/src/com/vaadin/tests/components/ui/UIsInMultipleTabs.java index c5d997cfd4..942e5ed1ef 100644 --- a/uitest/src/com/vaadin/tests/components/ui/UIsInMultipleTabs.java +++ b/uitest/src/com/vaadin/tests/components/ui/UIsInMultipleTabs.java @@ -3,8 +3,9 @@ package com.vaadin.tests.components.ui; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicInteger; -import com.vaadin.server.VaadinSession; +import com.vaadin.server.UIClassSelectionEvent; import com.vaadin.server.VaadinRequest; +import com.vaadin.server.VaadinSession; import com.vaadin.tests.components.AbstractTestUIProvider; import com.vaadin.ui.Label; import com.vaadin.ui.UI; @@ -32,7 +33,7 @@ public class UIsInMultipleTabs extends AbstractTestUIProvider { } @Override - public Class<? extends UI> getUIClass(VaadinRequest request) { + public Class<? extends UI> getUIClass(UIClassSelectionEvent event) { return TabUI.class; } diff --git a/uitest/src/com/vaadin/tests/integration/IntegrationTestApplication.java b/uitest/src/com/vaadin/tests/integration/IntegrationTestApplication.java index 03af8bbd52..41b7b020f5 100644 --- a/uitest/src/com/vaadin/tests/integration/IntegrationTestApplication.java +++ b/uitest/src/com/vaadin/tests/integration/IntegrationTestApplication.java @@ -38,7 +38,7 @@ public class IntegrationTestApplication extends LegacyApplication { table.addListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { - selectedLabel.setValue(table.getValue()); + selectedLabel.setValue(table.getValue().toString()); } }); window.addComponent(selectedLabel); diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7a1/DifferentFeaturesForDifferentClients.java b/uitest/src/com/vaadin/tests/minitutorials/v7a1/DifferentFeaturesForDifferentClients.java index dd152232f1..ad3a30d4ca 100644 --- a/uitest/src/com/vaadin/tests/minitutorials/v7a1/DifferentFeaturesForDifferentClients.java +++ b/uitest/src/com/vaadin/tests/minitutorials/v7a1/DifferentFeaturesForDifferentClients.java @@ -16,9 +16,11 @@ package com.vaadin.tests.minitutorials.v7a1; +import com.vaadin.server.UIClassSelectionEvent; +import com.vaadin.server.UICreateEvent; import com.vaadin.server.UIProvider; -import com.vaadin.server.WebBrowser; import com.vaadin.server.VaadinRequest; +import com.vaadin.server.WebBrowser; import com.vaadin.ui.Label; import com.vaadin.ui.UI; @@ -33,9 +35,9 @@ import com.vaadin.ui.UI; public class DifferentFeaturesForDifferentClients extends UIProvider { @Override - public Class<? extends UI> getUIClass(VaadinRequest request) { + public Class<? extends UI> getUIClass(UIClassSelectionEvent event) { // could also use browser version etc. - if (request.getHeader("user-agent").contains("mobile")) { + if (event.getRequest().getHeader("user-agent").contains("mobile")) { return TouchRoot.class; } else { return DefaultRoot.class; @@ -45,10 +47,9 @@ public class DifferentFeaturesForDifferentClients extends UIProvider { // Must override as default implementation isn't allowed to // instantiate our non-public classes @Override - public UI createInstance(VaadinRequest request, - Class<? extends UI> type) { + public UI createInstance(UICreateEvent event) { try { - return type.newInstance(); + return event.getUIClass().newInstance(); } catch (Exception e) { throw new RuntimeException(e); } diff --git a/uitest/src/com/vaadin/tests/tickets/Ticket1581.java b/uitest/src/com/vaadin/tests/tickets/Ticket1581.java index 5f278a44f5..a29fba9bff 100644 --- a/uitest/src/com/vaadin/tests/tickets/Ticket1581.java +++ b/uitest/src/com/vaadin/tests/tickets/Ticket1581.java @@ -35,7 +35,7 @@ public class Ticket1581 extends com.vaadin.LegacyApplication { public void run() { super.run(); while (true) { - time.setValue(new Date()); + time.setValue(new Date().toString()); try { sleep(200); } catch (InterruptedException e) { |