From 1a7d126e358d92850a41060b06d53309f2ac58f0 Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Fri, 17 Aug 2012 18:11:54 +0300 Subject: Initial ConnectorBundle implementation (#9371) --- .../ConnectorBundleLoaderFactory.java | 280 +++++++++++++++++++++ .../GeneratedRpcMethodProviderGenerator.java | 2 +- .../gwt/widgetsetutils/SerializerGenerator.java | 2 +- .../gwt/widgetsetutils/SerializerMapGenerator.java | 2 +- .../widgetsetutils/metadata/ConnectorBundle.java | 116 +++++++++ .../metadata/ConnectorInitVisitor.java | 32 +++ .../gwt/widgetsetutils/metadata/TypeVisitor.java | 15 ++ client/src/com/vaadin/Vaadin.gwt.xml | 9 +- .../gwt/client/ApplicationConfiguration.java | 132 +++------- .../terminal/gwt/client/ApplicationConnection.java | 2 +- .../com/vaadin/terminal/gwt/client/WidgetSet.java | 48 ++-- .../client/communication/DiffJSONSerializer.java | 1 + .../gwt/client/communication/JSONSerializer.java | 1 + .../gwt/client/communication/JsonDecoder.java | 1 + .../gwt/client/communication/RpcManager.java | 1 + .../gwt/client/communication/RpcMethod.java | 1 + .../communication/URLReference_Serializer.java | 1 + .../gwt/client/metadata/AsyncBundleLoader.java | 86 +++++++ .../gwt/client/metadata/BundleLoadCallback.java | 11 + .../gwt/client/metadata/ConnectorBundleLoader.java | 97 +++++++ .../terminal/gwt/client/metadata/Invoker.java | 9 + .../terminal/gwt/client/metadata/Method.java | 54 ++++ .../terminal/gwt/client/metadata/Property.java | 53 ++++ .../vaadin/terminal/gwt/client/metadata/Type.java | 79 ++++++ .../terminal/gwt/client/metadata/TypeData.java | 20 ++ .../gwt/client/metadata/TypeDataBundle.java | 33 +++ .../gwt/client/metadata/TypeDataStore.java | 64 +++++ 27 files changed, 1028 insertions(+), 124 deletions(-) create mode 100644 client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorBundleLoaderFactory.java create mode 100644 client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ConnectorBundle.java create mode 100644 client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ConnectorInitVisitor.java create mode 100644 client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/TypeVisitor.java create mode 100644 client/src/com/vaadin/terminal/gwt/client/metadata/AsyncBundleLoader.java create mode 100644 client/src/com/vaadin/terminal/gwt/client/metadata/BundleLoadCallback.java create mode 100644 client/src/com/vaadin/terminal/gwt/client/metadata/ConnectorBundleLoader.java create mode 100644 client/src/com/vaadin/terminal/gwt/client/metadata/Invoker.java create mode 100644 client/src/com/vaadin/terminal/gwt/client/metadata/Method.java create mode 100644 client/src/com/vaadin/terminal/gwt/client/metadata/Property.java create mode 100644 client/src/com/vaadin/terminal/gwt/client/metadata/Type.java create mode 100644 client/src/com/vaadin/terminal/gwt/client/metadata/TypeData.java create mode 100644 client/src/com/vaadin/terminal/gwt/client/metadata/TypeDataBundle.java create mode 100644 client/src/com/vaadin/terminal/gwt/client/metadata/TypeDataStore.java diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorBundleLoaderFactory.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorBundleLoaderFactory.java new file mode 100644 index 0000000000..cb967dff86 --- /dev/null +++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorBundleLoaderFactory.java @@ -0,0 +1,280 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ + +package com.vaadin.terminal.gwt.widgetsetutils; + +import java.io.PrintWriter; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.google.gwt.core.client.GWT; +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.NotFoundException; +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.shared.communication.ClientRpc; +import com.vaadin.shared.communication.ServerRpc; +import com.vaadin.shared.ui.Connect; +import com.vaadin.shared.ui.Connect.LoadStyle; +import com.vaadin.terminal.gwt.client.ServerConnector; +import com.vaadin.terminal.gwt.client.metadata.ConnectorBundleLoader; +import com.vaadin.terminal.gwt.client.metadata.TypeDataBundle; +import com.vaadin.terminal.gwt.client.metadata.TypeDataStore; +import com.vaadin.terminal.gwt.widgetsetutils.metadata.ConnectorBundle; +import com.vaadin.terminal.gwt.widgetsetutils.metadata.ConnectorInitVisitor; +import com.vaadin.terminal.gwt.widgetsetutils.metadata.TypeVisitor; + +public class ConnectorBundleLoaderFactory extends Generator { + + @Override + public String generate(TreeLogger logger, GeneratorContext context, + String typeName) throws UnableToCompleteException { + TypeOracle typeOracle = context.getTypeOracle(); + + try { + JClassType classType = typeOracle.getType(typeName); + String packageName = classType.getPackage().getName(); + String className = classType.getSimpleSourceName() + "Impl"; + + generateClass(logger, context, packageName, className, typeName); + + return packageName + "." + className; + } catch (UnableToCompleteException e) { + // Just rethrow + throw e; + } catch (Exception e) { + logger.log(Type.ERROR, getClass() + " failed", e); + throw new UnableToCompleteException(); + } + + } + + private void generateClass(TreeLogger logger, GeneratorContext context, + String packageName, String className, String requestedType) + throws Exception { + PrintWriter printWriter = context.tryCreate(logger, packageName, + className); + if (printWriter == null) { + return; + } + + List bundles = buildBundles(logger, + context.getTypeOracle()); + + ClassSourceFileComposerFactory composer = new ClassSourceFileComposerFactory( + packageName, className); + composer.setSuperclass(requestedType); + + SourceWriter w = composer.createSourceWriter(context, printWriter); + + w.println("public void init() {"); + w.indent(); + + for (ConnectorBundle bundle : bundles) { + String name = bundle.getName(); + boolean isEager = name + .equals(ConnectorBundleLoader.EAGER_BUNDLE_NAME); + + w.print("addAsyncBlockLoader(new AsyncBundleLoader(\""); + w.print(escape(name)); + w.print("\", "); + + w.print("new String[] {"); + for (Entry> entry : bundle.getIdentifiers() + .entrySet()) { + Set identifiers = entry.getValue(); + for (String id : identifiers) { + w.print("\""); + w.print(escape(id)); + w.print("\","); + } + } + w.println("}) {"); + w.indent(); + + w.print("protected void load(final "); + w.print(TypeDataStore.class.getName()); + w.println(" store) {"); + w.indent(); + + if (!isEager) { + w.print(GWT.class.getName()); + w.print(".runAsync("); + } + + w.print("new "); + w.print(TypeDataBundle.class.getName()); + w.println("(getName()) {"); + w.indent(); + + w.println("public void load() {"); + w.indent(); + + printBundleData(w, bundle); + + // Close load method + w.outdent(); + w.println("}"); + + // Close new TypeDataBundle() {} + w.outdent(); + w.print("}"); + + if (isEager) { + w.println(".onSuccess();"); + } else { + w.println(");"); + } + + // Close load method + w.outdent(); + w.println("}"); + + // Close add(new ... + w.outdent(); + w.println("});"); + } + + w.outdent(); + w.println("}"); + + w.commit(logger); + } + + private void printBundleData(SourceWriter w, ConnectorBundle bundle) { + writeIdentifiers(w, bundle); + writeGwtConstructors(w, bundle); + } + + private void writeGwtConstructors(SourceWriter w, ConnectorBundle bundle) { + Set constructors = bundle.getGwtConstructors(); + for (JClassType type : constructors) { + w.print("store.setConstructor("); + printClassLiteral(w, type); + w.print(", new Invoker() {"); + w.indent(); + + w.println("public Object invoke(Object target, Object[] params) {"); + w.indent(); + + w.print("return "); + w.print(GWT.class.getName()); + w.print(".create("); + printClassLiteral(w, type); + w.println(");"); + + w.outdent(); + w.println("}"); + + w.outdent(); + w.println("});"); + } + } + + private void printClassLiteral(SourceWriter w, JClassType type) { + w.print(type.getQualifiedSourceName()); + w.print(".class"); + } + + private void writeIdentifiers(SourceWriter w, ConnectorBundle bundle) { + Map> identifiers = bundle.getIdentifiers(); + for (Entry> entry : identifiers.entrySet()) { + Set ids = entry.getValue(); + JClassType type = entry.getKey(); + for (String id : ids) { + w.print("store.setClass(\""); + w.print(escape(id)); + w.print("\", "); + printClassLiteral(w, type); + w.println(");"); + } + } + } + + private List buildBundles(TreeLogger logger, + TypeOracle typeOracle) throws NotFoundException { + + Map> connectorsByLoadStyle = new HashMap>(); + for (LoadStyle loadStyle : LoadStyle.values()) { + connectorsByLoadStyle.put(loadStyle, new ArrayList()); + } + + JClassType connectorType = typeOracle.getType(ServerConnector.class + .getName()); + JClassType[] subtypes = connectorType.getSubtypes(); + for (JClassType connectorSubtype : subtypes) { + if (!connectorSubtype.isAnnotationPresent(Connect.class)) { + continue; + } + LoadStyle loadStyle = getLoadStyle(connectorSubtype); + if (loadStyle != null) { + connectorsByLoadStyle.get(loadStyle).add(connectorSubtype); + } + } + + List bundles = new ArrayList(); + + Collection visitors = getVisitors(typeOracle); + + ConnectorBundle eagerBundle = new ConnectorBundle( + ConnectorBundleLoader.EAGER_BUNDLE_NAME, null); + + // Eager connectors and all RPC interfaces are loaded by default + eagerBundle.visitTypes(connectorsByLoadStyle.get(LoadStyle.EAGER), + visitors); + eagerBundle.visitSubTypes( + typeOracle.getType(ClientRpc.class.getName()), visitors); + eagerBundle.visitSubTypes( + typeOracle.getType(ServerRpc.class.getName()), visitors); + + bundles.add(eagerBundle); + + ConnectorBundle deferredBundle = new ConnectorBundle( + ConnectorBundleLoader.DEFERRED_BUNDLE_NAME, eagerBundle); + deferredBundle.visitTypes( + connectorsByLoadStyle.get(LoadStyle.DEFERRED), visitors); + + bundles.add(deferredBundle); + + Collection lazy = connectorsByLoadStyle.get(LoadStyle.LAZY); + for (JClassType type : lazy) { + ConnectorBundle bundle = new ConnectorBundle(type.getName(), + deferredBundle); + bundle.visitTypes(Collections.singleton(type), visitors); + + bundles.add(bundle); + } + + return bundles; + } + + private Collection getVisitors(TypeOracle oracle) + throws NotFoundException { + List visitors = Arrays + . asList(new ConnectorInitVisitor()); + for (TypeVisitor typeVisitor : visitors) { + typeVisitor.init(oracle); + } + return visitors; + } + + protected LoadStyle getLoadStyle(JClassType connectorType) { + Connect annotation = connectorType.getAnnotation(Connect.class); + return annotation.loadStyle(); + } + +} diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/GeneratedRpcMethodProviderGenerator.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/GeneratedRpcMethodProviderGenerator.java index 47062d9abb..c6cf28db28 100644 --- a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/GeneratedRpcMethodProviderGenerator.java +++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/GeneratedRpcMethodProviderGenerator.java @@ -104,7 +104,7 @@ public class GeneratedRpcMethodProviderGenerator extends Generator { composer.addImport("com.google.gwt.core.client.GWT"); composer.addImport(RpcMethod.class.getName()); composer.addImport(ClientRpc.class.getName()); - composer.addImport(com.vaadin.terminal.gwt.client.communication.Type.class + composer.addImport(com.vaadin.terminal.gwt.client.metadata.Type.class .getName()); composer.addImplementedInterface(GeneratedRpcMethodProvider.class .getName()); diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/SerializerGenerator.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/SerializerGenerator.java index cc92551846..c7cc7bf7cb 100644 --- a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/SerializerGenerator.java +++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/SerializerGenerator.java @@ -125,7 +125,7 @@ public class SerializerGenerator extends Generator { serializerClassName); composer.addImport(GWT.class.getName()); composer.addImport(JSONValue.class.getName()); - composer.addImport(com.vaadin.terminal.gwt.client.communication.Type.class + composer.addImport(com.vaadin.terminal.gwt.client.metadata.Type.class .getName()); // composer.addImport(JSONObject.class.getName()); // composer.addImport(VPaintableMap.class.getName()); diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/SerializerMapGenerator.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/SerializerMapGenerator.java index 9e91763b9f..ac22aa2e8a 100644 --- a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/SerializerMapGenerator.java +++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/SerializerMapGenerator.java @@ -142,7 +142,7 @@ public class SerializerMapGenerator extends Generator { .findType(JSONSerializer.class.getName()); JType[] deserializeParamTypes = new JType[] { typeOracle - .findType(com.vaadin.terminal.gwt.client.communication.Type.class + .findType(com.vaadin.terminal.gwt.client.metadata.Type.class .getName()), typeOracle.findType(JSONValue.class.getName()), typeOracle.findType(ApplicationConnection.class.getName()) }; diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ConnectorBundle.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ConnectorBundle.java new file mode 100644 index 0000000000..3155ab4474 --- /dev/null +++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ConnectorBundle.java @@ -0,0 +1,116 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ + +package com.vaadin.terminal.gwt.widgetsetutils.metadata; + +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import com.google.gwt.core.ext.typeinfo.JClassType; + +public class ConnectorBundle { + private final String name; + private final ConnectorBundle previousBundle; + + private final Set needsGwtConstructor = new HashSet(); + private final Map> identifiers = new HashMap>(); + private final Set visitedTypes = new HashSet(); + private final Set visitQueue = new HashSet(); + + public ConnectorBundle(String name, ConnectorBundle previousBundle) { + this.name = name; + this.previousBundle = previousBundle; + } + + public void setNeedsGwtConstructor(JClassType type) { + if (!needsGwtConstructor(type)) { + needsGwtConstructor.add(type); + } + } + + private boolean needsGwtConstructor(JClassType type) { + if (needsGwtConstructor.contains(type)) { + return true; + } else { + return previousBundle != null + && previousBundle.needsGwtConstructor(type); + } + } + + public void setIdentifier(JClassType type, String identifier) { + if (!hasIdentifier(type, identifier)) { + Set set = identifiers.get(type); + if (set == null) { + set = new HashSet(); + identifiers.put(type, set); + } + set.add(identifier); + } + } + + private boolean hasIdentifier(JClassType type, String identifier) { + if (identifiers.containsKey(type) + && identifiers.get(type).contains(identifier)) { + return true; + } else { + return previousBundle != null + && previousBundle.hasIdentifier(type, identifier); + } + } + + public ConnectorBundle getPreviousBundle() { + return previousBundle; + } + + public String getName() { + return name; + } + + public Map> getIdentifiers() { + return Collections.unmodifiableMap(identifiers); + } + + public Set getGwtConstructors() { + return Collections.unmodifiableSet(needsGwtConstructor); + } + + public void visitTypes(Collection types, + Collection visitors) { + for (JClassType type : types) { + if (!isTypeVisited(type)) { + visitQueue.add(type); + } + } + visitQueue(visitors); + } + + private boolean isTypeVisited(JClassType type) { + if (visitedTypes.contains(type)) { + return true; + } else { + return previousBundle != null + && previousBundle.isTypeVisited(type); + } + } + + private void visitQueue(Collection visitors) { + while (!visitQueue.isEmpty()) { + JClassType type = visitQueue.iterator().next(); + for (TypeVisitor typeVisitor : visitors) { + typeVisitor.visit(type, this); + } + visitQueue.remove(type); + visitedTypes.add(type); + } + } + + public void visitSubTypes(JClassType type, Collection visitors) { + visitTypes(Arrays.asList(type.getSubtypes()), visitors); + } +} \ No newline at end of file diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ConnectorInitVisitor.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ConnectorInitVisitor.java new file mode 100644 index 0000000000..a6e71c70d9 --- /dev/null +++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ConnectorInitVisitor.java @@ -0,0 +1,32 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ + +package com.vaadin.terminal.gwt.widgetsetutils.metadata; + +import com.google.gwt.core.ext.typeinfo.JClassType; +import com.google.gwt.core.ext.typeinfo.NotFoundException; +import com.google.gwt.core.ext.typeinfo.TypeOracle; +import com.vaadin.shared.ui.Connect; +import com.vaadin.terminal.gwt.client.ServerConnector; + +public class ConnectorInitVisitor implements TypeVisitor { + + private JClassType serverConnector; + + @Override + public void init(TypeOracle oracle) throws NotFoundException { + serverConnector = oracle.getType(ServerConnector.class.getName()); + } + + @Override + public void visit(JClassType type, ConnectorBundle bundle) { + Connect connectAnnotation = type.getAnnotation(Connect.class); + if (connectAnnotation != null && serverConnector.isAssignableFrom(type)) { + bundle.setIdentifier(type, connectAnnotation.value() + .getCanonicalName()); + bundle.setNeedsGwtConstructor(type); + } + } + +} diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/TypeVisitor.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/TypeVisitor.java new file mode 100644 index 0000000000..6ed791fe86 --- /dev/null +++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/TypeVisitor.java @@ -0,0 +1,15 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ + +package com.vaadin.terminal.gwt.widgetsetutils.metadata; + +import com.google.gwt.core.ext.typeinfo.JClassType; +import com.google.gwt.core.ext.typeinfo.NotFoundException; +import com.google.gwt.core.ext.typeinfo.TypeOracle; + +public interface TypeVisitor { + public void init(TypeOracle oracle) throws NotFoundException; + + public void visit(JClassType type, ConnectorBundle bundle); +} diff --git a/client/src/com/vaadin/Vaadin.gwt.xml b/client/src/com/vaadin/Vaadin.gwt.xml index 07d7c941e6..5a9909a29c 100644 --- a/client/src/com/vaadin/Vaadin.gwt.xml +++ b/client/src/com/vaadin/Vaadin.gwt.xml @@ -35,11 +35,6 @@ - - - - + + + + diff --git a/client/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java b/client/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java index eea60b04ea..8f6697288c 100644 --- a/client/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java +++ b/client/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java @@ -29,9 +29,11 @@ import com.google.gwt.core.client.JsArrayString; import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.user.client.Command; -import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.Window; import com.vaadin.shared.ApplicationConstants; +import com.vaadin.terminal.gwt.client.metadata.BundleLoadCallback; +import com.vaadin.terminal.gwt.client.metadata.ConnectorBundleLoader; +import com.vaadin.terminal.gwt.client.metadata.TypeData; import com.vaadin.terminal.gwt.client.ui.UnknownComponentConnector; public class ApplicationConfiguration implements EntryPoint { @@ -207,7 +209,7 @@ public class ApplicationConfiguration implements EntryPoint { private HashMap unknownComponents; - private Class[] classes = new Class[1024]; + private Map> classes = new HashMap>(); private boolean browserDetailsSent = false; private boolean widgetsetVersionSent = false; @@ -390,12 +392,26 @@ public class ApplicationConfiguration implements EntryPoint { public Class getConnectorClassByEncodedTag( int tag) { - try { - return classes[tag]; - } catch (Exception e) { - // component was not present in mappings - return UnknownComponentConnector.class; + Class type = classes.get(tag); + if (type == null && !classes.containsKey(tag)) { + // Initialize if not already loaded + Integer currentTag = Integer.valueOf(tag); + while (type == null && currentTag != null) { + String serverSideClassNameForTag = getServerSideClassNameForTag(currentTag); + type = (Class) TypeData + .getClass(serverSideClassNameForTag); + currentTag = getParentTag(currentTag.intValue()); + } + if (type == null) { + type = UnknownComponentConnector.class; + if (unknownComponents == null) { + unknownComponents = new HashMap(); + } + unknownComponents.put(tag, getServerSideClassNameForTag(tag)); + } + classes.put(tag, type); } + return type; } public void addComponentInheritanceInfo(ValueMap valueMap) { @@ -418,13 +434,7 @@ public class ApplicationConfiguration implements EntryPoint { for (int i = 0; i < keyArray.length(); i++) { String key = keyArray.get(i).intern(); int value = valueMap.getInt(key); - classes[value] = widgetSet.getConnectorClassByTag(value, this); - if (classes[value] == UnknownComponentConnector.class) { - if (unknownComponents == null) { - unknownComponents = new HashMap(); - } - unknownComponents.put(value, key); - } + widgetSet.ensureConnectorLoaded(value, this); } } @@ -466,86 +476,25 @@ public class ApplicationConfiguration implements EntryPoint { cmd.execute(); } callbacks.clear(); - } else if (dependenciesLoading == 0 && deferredWidgetLoader != null) { - deferredWidgetLoader.trigger(); + } else if (dependenciesLoading == 0 + && !ConnectorBundleLoader.get().isBundleLoaded( + ConnectorBundleLoader.DEFERRED_BUNDLE_NAME)) { + ConnectorBundleLoader.get().loadBundle( + ConnectorBundleLoader.DEFERRED_BUNDLE_NAME, + new BundleLoadCallback() { + @Override + public void loaded() { + // Nothing to do + } + + @Override + public void failed(Throwable reason) { + VConsole.error(reason); + } + }); } - } - /* - * This loop loads widget implementation that should be loaded deferred. - */ - static class DeferredWidgetLoader extends Timer { - private static final int FREE_LIMIT = 4; - private static final int FREE_CHECK_TIMEOUT = 100; - - int communicationFree = 0; - int nextWidgetIndex = 0; - private boolean pending; - - public DeferredWidgetLoader() { - schedule(5000); - } - - public void trigger() { - if (!pending) { - schedule(FREE_CHECK_TIMEOUT); - } - } - - @Override - public void schedule(int delayMillis) { - super.schedule(delayMillis); - pending = true; - } - - @Override - public void run() { - pending = false; - if (!isBusy()) { - Class nextType = getNextType(); - if (nextType == null) { - // ensured that all widgets are loaded - deferredWidgetLoader = null; - } else { - communicationFree = 0; - widgetSet.loadImplementation(nextType); - } - } else { - schedule(FREE_CHECK_TIMEOUT); - } - } - - private Class getNextType() { - Class[] deferredLoadedConnectors = widgetSet - .getDeferredLoadedConnectors(); - if (deferredLoadedConnectors.length <= nextWidgetIndex) { - return null; - } else { - return deferredLoadedConnectors[nextWidgetIndex++]; - } - } - - private boolean isBusy() { - if (dependenciesLoading > 0) { - communicationFree = 0; - return true; - } - for (ApplicationConnection app : runningApplications) { - if (app.hasActiveRequest()) { - // if an UIDL request or widget loading is active, mark as - // busy - communicationFree = 0; - return true; - } - } - communicationFree++; - return communicationFree < FREE_LIMIT; - } - } - - private static DeferredWidgetLoader deferredWidgetLoader; - @Override public void onModuleLoad() { @@ -582,7 +531,6 @@ public class ApplicationConfiguration implements EntryPoint { return; } registerCallback(GWT.getModuleName()); - deferredWidgetLoader = new DeferredWidgetLoader(); } /** diff --git a/client/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java b/client/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java index 32b15d6d87..9a14e5434e 100644 --- a/client/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java +++ b/client/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java @@ -67,8 +67,8 @@ import com.vaadin.terminal.gwt.client.communication.JsonEncoder; import com.vaadin.terminal.gwt.client.communication.RpcManager; import com.vaadin.terminal.gwt.client.communication.SerializerMap; import com.vaadin.terminal.gwt.client.communication.StateChangeEvent; -import com.vaadin.terminal.gwt.client.communication.Type; import com.vaadin.terminal.gwt.client.extensions.AbstractExtensionConnector; +import com.vaadin.terminal.gwt.client.metadata.Type; import com.vaadin.terminal.gwt.client.ui.AbstractComponentConnector; import com.vaadin.terminal.gwt.client.ui.VContextMenu; import com.vaadin.terminal.gwt.client.ui.dd.VDragAndDropManager; diff --git a/client/src/com/vaadin/terminal/gwt/client/WidgetSet.java b/client/src/com/vaadin/terminal/gwt/client/WidgetSet.java index fbcfbb68d9..776436f5f0 100644 --- a/client/src/com/vaadin/terminal/gwt/client/WidgetSet.java +++ b/client/src/com/vaadin/terminal/gwt/client/WidgetSet.java @@ -18,17 +18,12 @@ package com.vaadin.terminal.gwt.client; import com.google.gwt.core.client.GWT; import com.vaadin.terminal.gwt.client.communication.HasJavaScriptConnectorHelper; +import com.vaadin.terminal.gwt.client.metadata.BundleLoadCallback; +import com.vaadin.terminal.gwt.client.metadata.ConnectorBundleLoader; +import com.vaadin.terminal.gwt.client.metadata.TypeData; import com.vaadin.terminal.gwt.client.ui.UnknownComponentConnector; public class WidgetSet { - - /** - * WidgetSet (and its extensions) delegate instantiation of widgets and - * client-server matching to WidgetMap. The actual implementations are - * generated with gwts generators/deferred binding. - */ - private WidgetMap widgetMap = GWT.create(WidgetMap.class); - /** * Create an uninitialized connector that best matches given UIDL. The * connector must implement {@link ServerConnector}. @@ -65,7 +60,8 @@ public class WidgetSet { /* * let the auto generated code instantiate this type */ - ServerConnector connector = widgetMap.instantiate(classType); + ServerConnector connector = (ServerConnector) TypeData.getType( + classType).createInstance(); if (connector instanceof HasJavaScriptConnectorHelper) { ((HasJavaScriptConnectorHelper) connector) .getJavascriptConnectorHelper().setTag(tag); @@ -102,26 +98,32 @@ public class WidgetSet { * @param applicationConfiguration * @return */ - public Class getConnectorClassByTag(int tag, - ApplicationConfiguration conf) { - Class connectorClass = null; + public void ensureConnectorLoaded(int tag, ApplicationConfiguration conf) { + ConnectorBundleLoader loader = ConnectorBundleLoader.get(); + String bundleName = null; Integer t = tag; do { String serverSideClassName = conf.getServerSideClassNameForTag(t); - connectorClass = widgetMap - .getConnectorClassForServerSideClassName(serverSideClassName); - t = conf.getParentTag(t); - } while (connectorClass == UnknownComponentConnector.class && t != null); + bundleName = loader.getBundleForIdentifier(serverSideClassName); - return connectorClass; - } + t = conf.getParentTag(t); + } while (bundleName == null && t != null); - public Class[] getDeferredLoadedConnectors() { - return widgetMap.getDeferredLoadedConnectors(); - } + if (bundleName != null && !loader.isBundleLoaded(bundleName)) { + ApplicationConfiguration.startDependencyLoading(); + loader.loadBundle(bundleName, new BundleLoadCallback() { + @Override + public void loaded() { + ApplicationConfiguration.endDependencyLoading(); + } - public void loadImplementation(Class nextType) { - widgetMap.ensureInstantiator(nextType); + @Override + public void failed(Throwable reason) { + VConsole.error(reason); + ApplicationConfiguration.endDependencyLoading(); + } + }); + } } } diff --git a/client/src/com/vaadin/terminal/gwt/client/communication/DiffJSONSerializer.java b/client/src/com/vaadin/terminal/gwt/client/communication/DiffJSONSerializer.java index a3b96a6cb2..1d5415263f 100644 --- a/client/src/com/vaadin/terminal/gwt/client/communication/DiffJSONSerializer.java +++ b/client/src/com/vaadin/terminal/gwt/client/communication/DiffJSONSerializer.java @@ -17,6 +17,7 @@ package com.vaadin.terminal.gwt.client.communication; import com.google.gwt.json.client.JSONValue; import com.vaadin.terminal.gwt.client.ApplicationConnection; +import com.vaadin.terminal.gwt.client.metadata.Type; public interface DiffJSONSerializer extends JSONSerializer { /** diff --git a/client/src/com/vaadin/terminal/gwt/client/communication/JSONSerializer.java b/client/src/com/vaadin/terminal/gwt/client/communication/JSONSerializer.java index a8fe2c7ccc..c6b814a5c1 100644 --- a/client/src/com/vaadin/terminal/gwt/client/communication/JSONSerializer.java +++ b/client/src/com/vaadin/terminal/gwt/client/communication/JSONSerializer.java @@ -20,6 +20,7 @@ import com.google.gwt.json.client.JSONObject; import com.google.gwt.json.client.JSONValue; import com.vaadin.terminal.gwt.client.ApplicationConnection; import com.vaadin.terminal.gwt.client.ConnectorMap; +import com.vaadin.terminal.gwt.client.metadata.Type; /** * Implementors of this interface knows how to serialize an Object of a given diff --git a/client/src/com/vaadin/terminal/gwt/client/communication/JsonDecoder.java b/client/src/com/vaadin/terminal/gwt/client/communication/JsonDecoder.java index 7d2046982c..ef5090ec18 100644 --- a/client/src/com/vaadin/terminal/gwt/client/communication/JsonDecoder.java +++ b/client/src/com/vaadin/terminal/gwt/client/communication/JsonDecoder.java @@ -31,6 +31,7 @@ import com.google.gwt.json.client.JSONValue; import com.vaadin.shared.Connector; import com.vaadin.terminal.gwt.client.ApplicationConnection; import com.vaadin.terminal.gwt.client.ConnectorMap; +import com.vaadin.terminal.gwt.client.metadata.Type; /** * Client side decoder for decodeing shared state and other values from JSON diff --git a/client/src/com/vaadin/terminal/gwt/client/communication/RpcManager.java b/client/src/com/vaadin/terminal/gwt/client/communication/RpcManager.java index 04d0e3f56f..537cc34185 100644 --- a/client/src/com/vaadin/terminal/gwt/client/communication/RpcManager.java +++ b/client/src/com/vaadin/terminal/gwt/client/communication/RpcManager.java @@ -29,6 +29,7 @@ import com.vaadin.terminal.gwt.client.ApplicationConnection; import com.vaadin.terminal.gwt.client.ConnectorMap; import com.vaadin.terminal.gwt.client.ServerConnector; import com.vaadin.terminal.gwt.client.VConsole; +import com.vaadin.terminal.gwt.client.metadata.Type; /** * Client side RPC manager that can invoke methods based on RPC calls received diff --git a/client/src/com/vaadin/terminal/gwt/client/communication/RpcMethod.java b/client/src/com/vaadin/terminal/gwt/client/communication/RpcMethod.java index a47fa5eab2..1759fbb97f 100644 --- a/client/src/com/vaadin/terminal/gwt/client/communication/RpcMethod.java +++ b/client/src/com/vaadin/terminal/gwt/client/communication/RpcMethod.java @@ -16,6 +16,7 @@ package com.vaadin.terminal.gwt.client.communication; import com.vaadin.shared.communication.ClientRpc; +import com.vaadin.terminal.gwt.client.metadata.Type; public abstract class RpcMethod { private String interfaceName; diff --git a/client/src/com/vaadin/terminal/gwt/client/communication/URLReference_Serializer.java b/client/src/com/vaadin/terminal/gwt/client/communication/URLReference_Serializer.java index f77553d3c0..3d2e4f3804 100644 --- a/client/src/com/vaadin/terminal/gwt/client/communication/URLReference_Serializer.java +++ b/client/src/com/vaadin/terminal/gwt/client/communication/URLReference_Serializer.java @@ -20,6 +20,7 @@ import com.google.gwt.json.client.JSONObject; import com.google.gwt.json.client.JSONValue; import com.vaadin.shared.communication.URLReference; import com.vaadin.terminal.gwt.client.ApplicationConnection; +import com.vaadin.terminal.gwt.client.metadata.Type; public class URLReference_Serializer implements JSONSerializer { diff --git a/client/src/com/vaadin/terminal/gwt/client/metadata/AsyncBundleLoader.java b/client/src/com/vaadin/terminal/gwt/client/metadata/AsyncBundleLoader.java new file mode 100644 index 0000000000..e92e51b40d --- /dev/null +++ b/client/src/com/vaadin/terminal/gwt/client/metadata/AsyncBundleLoader.java @@ -0,0 +1,86 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ + +package com.vaadin.terminal.gwt.client.metadata; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +public abstract class AsyncBundleLoader { + public enum State { + NOT_STARTED, LOADING, LOADED, ERROR; + } + + private State state = State.NOT_STARTED; + + private Throwable error = null; + + private List callbacks = new ArrayList(); + + private final String packageName; + + private final String[] indentifiers; + + public AsyncBundleLoader(String packageName, String[] indentifiers) { + this.packageName = packageName; + this.indentifiers = indentifiers; + } + + protected abstract void load(TypeDataStore store); + + public List setError(Throwable error) { + assert state == State.LOADING; + state = State.ERROR; + this.error = error; + + return clearCallbacks(); + } + + public Throwable getError() { + return error; + } + + public State getState() { + return state; + } + + public List getCallback() { + return Collections.unmodifiableList(callbacks); + } + + public void load(BundleLoadCallback callback, TypeDataStore store) { + assert state == State.NOT_STARTED; + state = State.LOADING; + callbacks.add(callback); + load(store); + } + + public void addCallback(BundleLoadCallback callback) { + assert state == State.LOADING; + callbacks.add(callback); + } + + public List setLoaded() { + assert state == State.LOADING; + state = State.LOADED; + + return clearCallbacks(); + } + + private List clearCallbacks() { + List callbacks = this.callbacks; + this.callbacks = null; + return callbacks; + } + + public String getName() { + return packageName; + } + + public String[] getIndentifiers() { + return indentifiers; + } + +} diff --git a/client/src/com/vaadin/terminal/gwt/client/metadata/BundleLoadCallback.java b/client/src/com/vaadin/terminal/gwt/client/metadata/BundleLoadCallback.java new file mode 100644 index 0000000000..c7fc735829 --- /dev/null +++ b/client/src/com/vaadin/terminal/gwt/client/metadata/BundleLoadCallback.java @@ -0,0 +1,11 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ + +package com.vaadin.terminal.gwt.client.metadata; + +public interface BundleLoadCallback { + public void loaded(); + + public void failed(Throwable reason); +} diff --git a/client/src/com/vaadin/terminal/gwt/client/metadata/ConnectorBundleLoader.java b/client/src/com/vaadin/terminal/gwt/client/metadata/ConnectorBundleLoader.java new file mode 100644 index 0000000000..48a8430312 --- /dev/null +++ b/client/src/com/vaadin/terminal/gwt/client/metadata/ConnectorBundleLoader.java @@ -0,0 +1,97 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ + +package com.vaadin.terminal.gwt.client.metadata; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.google.gwt.core.shared.GWT; +import com.vaadin.terminal.gwt.client.metadata.AsyncBundleLoader.State; + +public abstract class ConnectorBundleLoader { + public static final String EAGER_BUNDLE_NAME = "__eager"; + public static final String DEFERRED_BUNDLE_NAME = "__deferred"; + + private static ConnectorBundleLoader impl; + + private Map asyncBlockLoaders = new HashMap(); + private Map identifierToBundle = new HashMap(); + + private final TypeDataStore datStore = new TypeDataStore(); + + public ConnectorBundleLoader() { + init(); + } + + public TypeDataStore getTypeDataStore() { + return datStore; + } + + public static ConnectorBundleLoader get() { + if (impl == null) { + impl = GWT.create(ConnectorBundleLoader.class); + } + return impl; + } + + public void loadBundle(String packageName, BundleLoadCallback callback) { + AsyncBundleLoader loader = asyncBlockLoaders.get(packageName); + switch (loader.getState()) { + case NOT_STARTED: + loader.load(callback, getTypeDataStore()); + break; + case LOADING: + loader.addCallback(callback); + break; + case LOADED: + callback.loaded(); + break; + case ERROR: + callback.failed(loader.getError()); + } + } + + public boolean isBundleLoaded(String bundleName) { + AsyncBundleLoader loader = asyncBlockLoaders.get(bundleName); + if (loader == null) { + throw new IllegalArgumentException("Bundle " + bundleName + + " not recognized"); + } + return loader.getState() == State.LOADED; + } + + public void setLoaded(String packageName) { + List callbacks = asyncBlockLoaders.get(packageName) + .setLoaded(); + for (BundleLoadCallback callback : callbacks) { + callback.loaded(); + } + } + + public void setLoadFailure(String bundleName, Throwable reason) { + List callbacks = asyncBlockLoaders.get(bundleName) + .setError(reason); + for (BundleLoadCallback callback : callbacks) { + callback.failed(reason); + } + } + + public String getBundleForIdentifier(String identifier) { + return identifierToBundle.get(identifier); + } + + protected void addAsyncBlockLoader(AsyncBundleLoader loader) { + String name = loader.getName(); + asyncBlockLoaders.put(name, loader); + String[] indentifiers = loader.getIndentifiers(); + for (String identifier : indentifiers) { + identifierToBundle.put(identifier, name); + } + } + + public abstract void init(); + +} diff --git a/client/src/com/vaadin/terminal/gwt/client/metadata/Invoker.java b/client/src/com/vaadin/terminal/gwt/client/metadata/Invoker.java new file mode 100644 index 0000000000..5f6a839da6 --- /dev/null +++ b/client/src/com/vaadin/terminal/gwt/client/metadata/Invoker.java @@ -0,0 +1,9 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ + +package com.vaadin.terminal.gwt.client.metadata; + +public interface Invoker { + public Object invoke(Object target, Object[] params); +} diff --git a/client/src/com/vaadin/terminal/gwt/client/metadata/Method.java b/client/src/com/vaadin/terminal/gwt/client/metadata/Method.java new file mode 100644 index 0000000000..f164bc4bcf --- /dev/null +++ b/client/src/com/vaadin/terminal/gwt/client/metadata/Method.java @@ -0,0 +1,54 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ + +package com.vaadin.terminal.gwt.client.metadata; + +public class Method { + + private final Type type; + private final String name; + + public Method(Type type, String name) { + this.type = type; + this.name = name; + } + + public Type getType() { + return type; + } + + public String getName() { + return name; + } + + public Type getReturnType() { + return TypeDataStore.getReturnType(this); + } + + public void invoke(Object target, Object... params) { + TypeDataStore.getInvoker(this).invoke(target, params); + } + + public String getSignature() { + return type.toString() + "." + name; + } + + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } else if (obj instanceof Method) { + Method other = (Method) obj; + return other.getSignature().equals(getSignature()); + } else { + return false; + } + } + + @Override + public int hashCode() { + return getSignature().hashCode(); + } + +} diff --git a/client/src/com/vaadin/terminal/gwt/client/metadata/Property.java b/client/src/com/vaadin/terminal/gwt/client/metadata/Property.java new file mode 100644 index 0000000000..5f2b1ffb41 --- /dev/null +++ b/client/src/com/vaadin/terminal/gwt/client/metadata/Property.java @@ -0,0 +1,53 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ + +package com.vaadin.terminal.gwt.client.metadata; + +public class Property { + private final Type type; + private final String name; + + public Property(Type type, String name) { + this.type = type; + this.name = name; + } + + public Object getValue(Object bean) { + return TypeDataStore.getGetter(this).invoke(bean, null); + } + + public String getDelegateToWidgetMethod() { + String value = TypeDataStore.getDelegateToWidget(this); + if (value == null) { + return null; + } else if (value.isEmpty()) { + return "set" + Character.toUpperCase(value.charAt(0)) + + value.substring(1); + } else { + return value; + } + } + + public String getSignature() { + return type.toString() + "." + name; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } else if (obj instanceof Property) { + Property other = (Property) obj; + return getSignature().equals(other.getSignature()); + } else { + return false; + } + } + + @Override + public int hashCode() { + return getSignature().hashCode(); + } + +} diff --git a/client/src/com/vaadin/terminal/gwt/client/metadata/Type.java b/client/src/com/vaadin/terminal/gwt/client/metadata/Type.java new file mode 100644 index 0000000000..4fab296441 --- /dev/null +++ b/client/src/com/vaadin/terminal/gwt/client/metadata/Type.java @@ -0,0 +1,79 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ +package com.vaadin.terminal.gwt.client.metadata; + +public class Type { + private final String name; + private final Type[] parameterTypes; + + public Type(Class clazz) { + name = clazz.getName(); + parameterTypes = null; + } + + public Type(String baseTypeName, Type[] parameterTypes) { + name = baseTypeName; + this.parameterTypes = parameterTypes; + } + + public String getBaseTypeName() { + return name; + } + + public Type[] getParameterTypes() { + return parameterTypes; + } + + public Object createInstance() { + Invoker invoker = TypeDataStore.getConstructor(this); + return invoker.invoke(null, null); + } + + public Method getMethod(String name) { + return new Method(this, name); + } + + public Property getProperty(String propertyName) { + return new Property(this, propertyName); + } + + public String getSignature() { + String string = name; + if (parameterTypes != null) { + string += '<'; + for (int i = 0; i < parameterTypes.length; i++) { + if (i != 0) { + string += ','; + } + string += parameterTypes[i].toString(); + } + string += '>'; + } + + return string; + } + + @Override + public String toString() { + return getSignature(); + } + + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } else if (obj instanceof Type) { + Type other = (Type) obj; + return other.getSignature().equals(getSignature()); + } else { + return false; + } + } + + @Override + public int hashCode() { + return getSignature().hashCode(); + } + +} diff --git a/client/src/com/vaadin/terminal/gwt/client/metadata/TypeData.java b/client/src/com/vaadin/terminal/gwt/client/metadata/TypeData.java new file mode 100644 index 0000000000..6ee0b4ede0 --- /dev/null +++ b/client/src/com/vaadin/terminal/gwt/client/metadata/TypeData.java @@ -0,0 +1,20 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ + +package com.vaadin.terminal.gwt.client.metadata; + +public class TypeData { + + public static Type getType(Class type) { + return TypeDataStore.getType(type); + } + + public static Type getType(String identifier) { + return TypeDataStore.getType(getClass(identifier)); + } + + public static Class getClass(String identifier) { + return TypeDataStore.getClass(identifier); + } +} diff --git a/client/src/com/vaadin/terminal/gwt/client/metadata/TypeDataBundle.java b/client/src/com/vaadin/terminal/gwt/client/metadata/TypeDataBundle.java new file mode 100644 index 0000000000..cbde338ff2 --- /dev/null +++ b/client/src/com/vaadin/terminal/gwt/client/metadata/TypeDataBundle.java @@ -0,0 +1,33 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ + +package com.vaadin.terminal.gwt.client.metadata; + +import com.google.gwt.core.client.RunAsyncCallback; + +public abstract class TypeDataBundle implements RunAsyncCallback { + private final String name; + + public TypeDataBundle(String name) { + this.name = name; + } + + @Override + public void onSuccess() { + ConnectorBundleLoader loader = ConnectorBundleLoader.get(); + load(); + loader.setLoaded(getName()); + } + + @Override + public void onFailure(Throwable reason) { + ConnectorBundleLoader.get().setLoadFailure(getName(), reason); + } + + public abstract void load(); + + public String getName() { + return name; + } +} diff --git a/client/src/com/vaadin/terminal/gwt/client/metadata/TypeDataStore.java b/client/src/com/vaadin/terminal/gwt/client/metadata/TypeDataStore.java new file mode 100644 index 0000000000..4b224721e6 --- /dev/null +++ b/client/src/com/vaadin/terminal/gwt/client/metadata/TypeDataStore.java @@ -0,0 +1,64 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ + +package com.vaadin.terminal.gwt.client.metadata; + +import java.util.HashMap; +import java.util.Map; + +public class TypeDataStore { + private static final String CONSTRUCTOR_NAME = "!new"; + + private final Map> identifiers = new HashMap>(); + + private final Map returnTypes = new HashMap(); + private final Map invokers = new HashMap(); + + private final Map getters = new HashMap(); + private final Map delegateToWidget = new HashMap(); + + public static TypeDataStore get() { + return ConnectorBundleLoader.get().getTypeDataStore(); + } + + public void setClass(String identifier, Class type) { + identifiers.put(identifier, type); + } + + public static Class getClass(String identifier) { + return get().identifiers.get(identifier); + } + + public static Type getType(Class clazz) { + return new Type(clazz); + } + + public static Type getReturnType(Method method) { + return get().returnTypes.get(method); + } + + public static Invoker getInvoker(Method method) { + return get().invokers.get(method); + } + + public static Invoker getConstructor(Type type) { + return get().invokers.get(new Method(type, CONSTRUCTOR_NAME)); + } + + public static Invoker getGetter(Property property) { + return get().getters.get(property); + } + + public static String getDelegateToWidget(Property property) { + return get().delegateToWidget.get(property); + } + + public void setReturnType(Class type, String methodName, Type returnType) { + returnTypes.put(new Method(getType(type), methodName), returnType); + } + + public void setConstructor(Class type, Invoker constructor) { + invokers.put(new Method(getType(type), CONSTRUCTOR_NAME), constructor); + } +} -- cgit v1.2.3 From a34ddd875812ca2c3d1006555a33b72a4e438da3 Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Fri, 17 Aug 2012 19:22:16 +0300 Subject: Use ConnectorBundle for creating state and widget (#9371) --- ...bstractConnectorClassBasedFactoryGenerator.java | 157 --------------------- .../ConnectorBundleLoaderFactory.java | 47 ++++-- .../ConnectorStateFactoryGenerator.java | 41 ------ .../ConnectorWidgetFactoryGenerator.java | 41 ------ .../widgetsetutils/metadata/ConnectorBundle.java | 66 +++++++-- .../metadata/ConnectorInitVisitor.java | 16 +-- .../widgetsetutils/metadata/StateInitVisitor.java | 25 ++++ .../gwt/widgetsetutils/metadata/TypeVisitor.java | 51 ++++++- .../widgetsetutils/metadata/WidgetInitVisitor.java | 25 ++++ client/src/com/vaadin/Vaadin.gwt.xml | 12 -- .../terminal/gwt/client/ApplicationConnection.java | 5 + .../gwt/client/metadata/ConnectorBundleLoader.java | 4 +- .../gwt/client/ui/AbstractComponentConnector.java | 7 +- .../terminal/gwt/client/ui/AbstractConnector.java | 7 +- .../gwt/client/ui/ConnectorClassBasedFactory.java | 52 ------- .../gwt/client/ui/ConnectorStateFactory.java | 43 ------ .../gwt/client/ui/ConnectorWidgetFactory.java | 55 -------- 17 files changed, 216 insertions(+), 438 deletions(-) delete mode 100644 client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/AbstractConnectorClassBasedFactoryGenerator.java delete mode 100644 client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorStateFactoryGenerator.java delete mode 100644 client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorWidgetFactoryGenerator.java create mode 100644 client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/StateInitVisitor.java create mode 100644 client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/WidgetInitVisitor.java delete mode 100644 client/src/com/vaadin/terminal/gwt/client/ui/ConnectorClassBasedFactory.java delete mode 100644 client/src/com/vaadin/terminal/gwt/client/ui/ConnectorStateFactory.java delete mode 100644 client/src/com/vaadin/terminal/gwt/client/ui/ConnectorWidgetFactory.java diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/AbstractConnectorClassBasedFactoryGenerator.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/AbstractConnectorClassBasedFactoryGenerator.java deleted file mode 100644 index 78579b7e54..0000000000 --- a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/AbstractConnectorClassBasedFactoryGenerator.java +++ /dev/null @@ -1,157 +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.terminal.gwt.widgetsetutils; - -import java.io.PrintWriter; -import java.util.Date; - -import com.google.gwt.core.client.GWT; -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.JMethod; -import com.google.gwt.core.ext.typeinfo.JType; -import com.google.gwt.core.ext.typeinfo.NotFoundException; -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.terminal.gwt.client.ServerConnector; -import com.vaadin.terminal.gwt.client.ui.ConnectorClassBasedFactory; -import com.vaadin.terminal.gwt.client.ui.ConnectorClassBasedFactory.Creator; - -/** - * GWT generator that creates a lookup method for - * {@link ConnectorClassBasedFactory} instances. - * - * @since 7.0 - */ -public abstract class AbstractConnectorClassBasedFactoryGenerator extends - Generator { - - @Override - public String generate(TreeLogger logger, GeneratorContext context, - String typeName) throws UnableToCompleteException { - - try { - // get classType and save instance variables - return generateConnectorClassBasedFactory(typeName, logger, context); - } catch (Exception e) { - logger.log(TreeLogger.ERROR, typeName + " creation failed", e); - throw new UnableToCompleteException(); - } - } - - private String generateConnectorClassBasedFactory(String typeName, - TreeLogger logger, GeneratorContext context) - throws NotFoundException { - TypeOracle typeOracle = context.getTypeOracle(); - - JClassType classType = typeOracle.getType(typeName); - String superName = classType.getSimpleSourceName(); - String packageName = classType.getPackage().getName(); - String className = superName + "Impl"; - - // 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 - if (printWriter == null) { - return packageName + "." + className; - } - - Date date = new Date(); - - // init composer, set class properties, create source writer - ClassSourceFileComposerFactory composer = null; - composer = new ClassSourceFileComposerFactory(packageName, className); - composer.addImport(GWT.class.getName()); - composer.addImport(Creator.class.getCanonicalName()); - composer.setSuperclass(superName); - - SourceWriter sourceWriter = composer.createSourceWriter(context, - printWriter); - sourceWriter.indent(); - - // public ConnectorStateFactoryImpl() { - sourceWriter.println("public " + className + "() {"); - sourceWriter.indent(); - - JClassType serverConnectorType = typeOracle.getType(getConnectorType() - .getCanonicalName()); - for (JClassType connector : serverConnectorType.getSubtypes()) { - // addCreator(TextAreaConnector.class, new Creator() { - if (connector.isInterface() != null || connector.isAbstract()) { - continue; - } - - JClassType targetType = getTargetType(connector); - if (targetType.isAbstract()) { - continue; - } - - sourceWriter.println("addCreator(" - + connector.getQualifiedSourceName() - + ".class, new Creator<" - + targetType.getQualifiedSourceName() + ">() {"); - // public SharedState create() { - sourceWriter.println("public " - + targetType.getQualifiedSourceName() + " create() {"); - // return GWT.create(TextAreaState.class); - sourceWriter.println("return GWT.create(" - + targetType.getQualifiedSourceName() + ".class);"); - // } - sourceWriter.println("}"); - // }); - sourceWriter.println("});"); - } - - // End of constructor - sourceWriter.outdent(); - sourceWriter.println("}"); - - // 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)"); - return packageName + "." + className; - - } - - protected abstract Class getConnectorType(); - - protected abstract JClassType getTargetType(JClassType connectorType); - - protected JClassType getGetterReturnType(JClassType connector, - String getterName) { - try { - JMethod getMethod = connector.getMethod(getterName, new JType[] {}); - return (JClassType) getMethod.getReturnType(); - } catch (NotFoundException e) { - return getGetterReturnType(connector.getSuperclass(), getterName); - } - - } - -} diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorBundleLoaderFactory.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorBundleLoaderFactory.java index cb967dff86..893bebfd0d 100644 --- a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorBundleLoaderFactory.java +++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorBundleLoaderFactory.java @@ -22,6 +22,7 @@ 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.JMethod; import com.google.gwt.core.ext.typeinfo.NotFoundException; import com.google.gwt.core.ext.typeinfo.TypeOracle; import com.google.gwt.user.rebind.ClassSourceFileComposerFactory; @@ -36,7 +37,9 @@ import com.vaadin.terminal.gwt.client.metadata.TypeDataBundle; import com.vaadin.terminal.gwt.client.metadata.TypeDataStore; import com.vaadin.terminal.gwt.widgetsetutils.metadata.ConnectorBundle; import com.vaadin.terminal.gwt.widgetsetutils.metadata.ConnectorInitVisitor; +import com.vaadin.terminal.gwt.widgetsetutils.metadata.StateInitVisitor; import com.vaadin.terminal.gwt.widgetsetutils.metadata.TypeVisitor; +import com.vaadin.terminal.gwt.widgetsetutils.metadata.WidgetInitVisitor; public class ConnectorBundleLoaderFactory extends Generator { @@ -158,6 +161,30 @@ public class ConnectorBundleLoaderFactory extends Generator { private void printBundleData(SourceWriter w, ConnectorBundle bundle) { writeIdentifiers(w, bundle); writeGwtConstructors(w, bundle); + writeReturnTypes(w, bundle); + } + + private void writeReturnTypes(SourceWriter w, ConnectorBundle bundle) { + Map> methodReturnTypes = bundle + .getMethodReturnTypes(); + for (Entry> entry : methodReturnTypes + .entrySet()) { + JClassType type = entry.getKey(); + + Set methods = entry.getValue(); + for (JMethod method : methods) { + // setReturnType(Class type, String methodName, Type + // returnType) + w.print("store.setReturnType("); + printClassLiteral(w, type); + w.print(", \""); + w.print(method.getName()); + w.print("\", "); + GeneratedRpcMethodProviderGenerator.writeTypeCreator(w, + method.getReturnType()); + w.println(");"); + } + } } private void writeGwtConstructors(SourceWriter w, ConnectorBundle bundle) { @@ -206,7 +233,8 @@ public class ConnectorBundleLoaderFactory extends Generator { } private List buildBundles(TreeLogger logger, - TypeOracle typeOracle) throws NotFoundException { + TypeOracle typeOracle) throws NotFoundException, + UnableToCompleteException { Map> connectorsByLoadStyle = new HashMap>(); for (LoadStyle loadStyle : LoadStyle.values()) { @@ -234,18 +262,18 @@ public class ConnectorBundleLoaderFactory extends Generator { ConnectorBundleLoader.EAGER_BUNDLE_NAME, null); // Eager connectors and all RPC interfaces are loaded by default - eagerBundle.visitTypes(connectorsByLoadStyle.get(LoadStyle.EAGER), - visitors); - eagerBundle.visitSubTypes( + eagerBundle.visitTypes(logger, + connectorsByLoadStyle.get(LoadStyle.EAGER), visitors); + eagerBundle.visitSubTypes(logger, typeOracle.getType(ClientRpc.class.getName()), visitors); - eagerBundle.visitSubTypes( + eagerBundle.visitSubTypes(logger, typeOracle.getType(ServerRpc.class.getName()), visitors); bundles.add(eagerBundle); ConnectorBundle deferredBundle = new ConnectorBundle( ConnectorBundleLoader.DEFERRED_BUNDLE_NAME, eagerBundle); - deferredBundle.visitTypes( + deferredBundle.visitTypes(logger, connectorsByLoadStyle.get(LoadStyle.DEFERRED), visitors); bundles.add(deferredBundle); @@ -254,7 +282,7 @@ public class ConnectorBundleLoaderFactory extends Generator { for (JClassType type : lazy) { ConnectorBundle bundle = new ConnectorBundle(type.getName(), deferredBundle); - bundle.visitTypes(Collections.singleton(type), visitors); + bundle.visitTypes(logger, Collections.singleton(type), visitors); bundles.add(bundle); } @@ -264,8 +292,9 @@ public class ConnectorBundleLoaderFactory extends Generator { private Collection getVisitors(TypeOracle oracle) throws NotFoundException { - List visitors = Arrays - . asList(new ConnectorInitVisitor()); + List visitors = Arrays. asList( + new ConnectorInitVisitor(), new StateInitVisitor(), + new WidgetInitVisitor()); for (TypeVisitor typeVisitor : visitors) { typeVisitor.init(oracle); } diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorStateFactoryGenerator.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorStateFactoryGenerator.java deleted file mode 100644 index 136ea3360e..0000000000 --- a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorStateFactoryGenerator.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.terminal.gwt.widgetsetutils; - -import com.google.gwt.core.ext.typeinfo.JClassType; -import com.vaadin.terminal.gwt.client.ServerConnector; - -/** - * GWT generator that creates a SharedState class for a given Connector class, - * based on the return type of getState() - * - * @since 7.0 - */ -public class ConnectorStateFactoryGenerator extends - AbstractConnectorClassBasedFactoryGenerator { - - @Override - protected JClassType getTargetType(JClassType connectorType) { - return getGetterReturnType(connectorType, "getState"); - } - - @Override - protected Class getConnectorType() { - return ServerConnector.class; - } - -} diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorWidgetFactoryGenerator.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorWidgetFactoryGenerator.java deleted file mode 100644 index 32693369f2..0000000000 --- a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorWidgetFactoryGenerator.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.terminal.gwt.widgetsetutils; - -import com.google.gwt.core.ext.typeinfo.JClassType; -import com.vaadin.terminal.gwt.client.ComponentConnector; -import com.vaadin.terminal.gwt.client.ServerConnector; - -/** - * GWT generator that creates a Widget class for a given Connector class, based - * on the return type of getWidget() - * - * @since 7.0 - */ -public class ConnectorWidgetFactoryGenerator extends - AbstractConnectorClassBasedFactoryGenerator { - @Override - protected JClassType getTargetType(JClassType connectorType) { - return getGetterReturnType(connectorType, "getWidget"); - } - - @Override - protected Class getConnectorType() { - return ComponentConnector.class; - } - -} \ No newline at end of file diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ConnectorBundle.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ConnectorBundle.java index 3155ab4474..f734b77101 100644 --- a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ConnectorBundle.java +++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ConnectorBundle.java @@ -12,7 +12,12 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; +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.JMethod; +import com.google.gwt.core.ext.typeinfo.NotFoundException; public class ConnectorBundle { private final String name; @@ -22,6 +27,9 @@ public class ConnectorBundle { private final Map> identifiers = new HashMap>(); private final Set visitedTypes = new HashSet(); private final Set visitQueue = new HashSet(); + private final Map> needsReturnType = new HashMap>(); + + private boolean visiting = false; public ConnectorBundle(String name, ConnectorBundle previousBundle) { this.name = name; @@ -30,6 +38,9 @@ public class ConnectorBundle { public void setNeedsGwtConstructor(JClassType type) { if (!needsGwtConstructor(type)) { + if (!isTypeVisited(type)) { + visitQueue.add(type); + } needsGwtConstructor.add(type); } } @@ -45,6 +56,9 @@ public class ConnectorBundle { public void setIdentifier(JClassType type, String identifier) { if (!hasIdentifier(type, identifier)) { + if (!isTypeVisited(type)) { + visitQueue.add(type); + } Set set = identifiers.get(type); if (set == null) { set = new HashSet(); @@ -80,37 +94,71 @@ public class ConnectorBundle { return Collections.unmodifiableSet(needsGwtConstructor); } - public void visitTypes(Collection types, - Collection visitors) { + public void visitTypes(TreeLogger logger, Collection types, + Collection visitors) throws UnableToCompleteException { for (JClassType type : types) { if (!isTypeVisited(type)) { visitQueue.add(type); } } - visitQueue(visitors); + visitQueue(logger, visitors); } private boolean isTypeVisited(JClassType type) { if (visitedTypes.contains(type)) { return true; } else { - return previousBundle != null - && previousBundle.isTypeVisited(type); + return previousBundle != null && previousBundle.isTypeVisited(type); } } - private void visitQueue(Collection visitors) { + private void visitQueue(TreeLogger logger, Collection visitors) + throws UnableToCompleteException { while (!visitQueue.isEmpty()) { JClassType type = visitQueue.iterator().next(); for (TypeVisitor typeVisitor : visitors) { - typeVisitor.visit(type, this); + try { + typeVisitor.visit(type, this); + } catch (NotFoundException e) { + logger.log(Type.ERROR, e.getMessage(), e); + throw new UnableToCompleteException(); + } } visitQueue.remove(type); visitedTypes.add(type); } } - public void visitSubTypes(JClassType type, Collection visitors) { - visitTypes(Arrays.asList(type.getSubtypes()), visitors); + public void visitSubTypes(TreeLogger logger, JClassType type, + Collection visitors) throws UnableToCompleteException { + visitTypes(logger, Arrays.asList(type.getSubtypes()), visitors); + } + + public void setNeedsReturnType(JClassType type, JMethod method) { + if (!isNeedsReturnType(type, method)) { + if (!isTypeVisited(type)) { + visitQueue.add(type); + } + Set set = needsReturnType.get(type); + if (set == null) { + set = new HashSet(); + needsReturnType.put(type, set); + } + set.add(method); + } + } + + private boolean isNeedsReturnType(JClassType type, JMethod method) { + if (needsReturnType.containsKey(type) + && needsReturnType.get(type).contains(method)) { + return true; + } else { + return previousBundle != null + && previousBundle.isNeedsReturnType(type, method); + } + } + + public Map> getMethodReturnTypes() { + return Collections.unmodifiableMap(needsReturnType); } } \ No newline at end of file diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ConnectorInitVisitor.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ConnectorInitVisitor.java index a6e71c70d9..6dd840d612 100644 --- a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ConnectorInitVisitor.java +++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ConnectorInitVisitor.java @@ -5,24 +5,14 @@ package com.vaadin.terminal.gwt.widgetsetutils.metadata; import com.google.gwt.core.ext.typeinfo.JClassType; -import com.google.gwt.core.ext.typeinfo.NotFoundException; -import com.google.gwt.core.ext.typeinfo.TypeOracle; import com.vaadin.shared.ui.Connect; -import com.vaadin.terminal.gwt.client.ServerConnector; -public class ConnectorInitVisitor implements TypeVisitor { - - private JClassType serverConnector; - - @Override - public void init(TypeOracle oracle) throws NotFoundException { - serverConnector = oracle.getType(ServerConnector.class.getName()); - } +public class ConnectorInitVisitor extends TypeVisitor { @Override public void visit(JClassType type, ConnectorBundle bundle) { - Connect connectAnnotation = type.getAnnotation(Connect.class); - if (connectAnnotation != null && serverConnector.isAssignableFrom(type)) { + if (isConnectedConnector(type)) { + Connect connectAnnotation = type.getAnnotation(Connect.class); bundle.setIdentifier(type, connectAnnotation.value() .getCanonicalName()); bundle.setNeedsGwtConstructor(type); diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/StateInitVisitor.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/StateInitVisitor.java new file mode 100644 index 0000000000..b88afdf37a --- /dev/null +++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/StateInitVisitor.java @@ -0,0 +1,25 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ + +package com.vaadin.terminal.gwt.widgetsetutils.metadata; + +import com.google.gwt.core.ext.typeinfo.JClassType; +import com.google.gwt.core.ext.typeinfo.JMethod; +import com.google.gwt.core.ext.typeinfo.JType; +import com.google.gwt.core.ext.typeinfo.NotFoundException; + +public class StateInitVisitor extends TypeVisitor { + @Override + public void visit(JClassType type, ConnectorBundle bundle) + throws NotFoundException { + if (isConnectedConnector(type)) { + JMethod getState = getInheritedMethod(type, "getState"); + bundle.setNeedsReturnType(type, getState); + + JType stateType = getState.getReturnType(); + bundle.setNeedsGwtConstructor(stateType.isClass()); + } + } + +} diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/TypeVisitor.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/TypeVisitor.java index 6ed791fe86..163eda0675 100644 --- a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/TypeVisitor.java +++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/TypeVisitor.java @@ -5,11 +5,56 @@ package com.vaadin.terminal.gwt.widgetsetutils.metadata; import com.google.gwt.core.ext.typeinfo.JClassType; +import com.google.gwt.core.ext.typeinfo.JMethod; +import com.google.gwt.core.ext.typeinfo.JType; import com.google.gwt.core.ext.typeinfo.NotFoundException; import com.google.gwt.core.ext.typeinfo.TypeOracle; +import com.vaadin.shared.ui.Connect; +import com.vaadin.terminal.gwt.client.ComponentConnector; +import com.vaadin.terminal.gwt.client.ServerConnector; -public interface TypeVisitor { - public void init(TypeOracle oracle) throws NotFoundException; +public abstract class TypeVisitor { + private JClassType serverConnector; + private JClassType componentConnector; - public void visit(JClassType type, ConnectorBundle bundle); + public void init(TypeOracle oracle) throws NotFoundException { + serverConnector = oracle.getType(ServerConnector.class.getName()); + componentConnector = oracle.getType(ComponentConnector.class.getName()); + } + + public abstract void visit(JClassType type, ConnectorBundle bundle) + throws NotFoundException; + + protected boolean isConnectedConnector(JClassType type) { + return serverConnector.isAssignableFrom(type) + && type.isAnnotationPresent(Connect.class); + } + + protected boolean isConnectedComponentConnector(JClassType type) { + return componentConnector.isAssignableFrom(type) + && type.isAnnotationPresent(Connect.class); + } + + protected JMethod getInheritedMethod(JClassType type, String methodName, + JType... params) throws NotFoundException { + + JClassType currentType = type; + while (currentType != null) { + JMethod method = currentType.findMethod(methodName, params); + if (method != null) { + return method; + } + currentType = currentType.getSuperclass(); + } + + JClassType[] interfaces = type.getImplementedInterfaces(); + for (JClassType iface : interfaces) { + JMethod method = iface.findMethod(methodName, params); + if (method != null) { + return method; + } + } + + throw new NotFoundException(methodName + " not found in " + type); + } } diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/WidgetInitVisitor.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/WidgetInitVisitor.java new file mode 100644 index 0000000000..be6f303c5b --- /dev/null +++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/WidgetInitVisitor.java @@ -0,0 +1,25 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ + +package com.vaadin.terminal.gwt.widgetsetutils.metadata; + +import com.google.gwt.core.ext.typeinfo.JClassType; +import com.google.gwt.core.ext.typeinfo.JMethod; +import com.google.gwt.core.ext.typeinfo.JType; +import com.google.gwt.core.ext.typeinfo.NotFoundException; + +public class WidgetInitVisitor extends TypeVisitor { + + @Override + public void visit(JClassType type, ConnectorBundle bundle) + throws NotFoundException { + if (isConnectedComponentConnector(type)) { + JMethod getWidget = getInheritedMethod(type, "getWidget"); + bundle.setNeedsReturnType(type, getWidget); + + JType widgetType = getWidget.getReturnType(); + bundle.setNeedsGwtConstructor(widgetType.isClass()); + } + } +} diff --git a/client/src/com/vaadin/Vaadin.gwt.xml b/client/src/com/vaadin/Vaadin.gwt.xml index 5a9909a29c..4bac60b472 100644 --- a/client/src/com/vaadin/Vaadin.gwt.xml +++ b/client/src/com/vaadin/Vaadin.gwt.xml @@ -61,18 +61,6 @@ - - - - - - - - diff --git a/client/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java b/client/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java index 9a14e5434e..8ba8f0afab 100644 --- a/client/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java +++ b/client/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java @@ -68,6 +68,7 @@ import com.vaadin.terminal.gwt.client.communication.RpcManager; import com.vaadin.terminal.gwt.client.communication.SerializerMap; import com.vaadin.terminal.gwt.client.communication.StateChangeEvent; import com.vaadin.terminal.gwt.client.extensions.AbstractExtensionConnector; +import com.vaadin.terminal.gwt.client.metadata.ConnectorBundleLoader; import com.vaadin.terminal.gwt.client.metadata.Type; import com.vaadin.terminal.gwt.client.ui.AbstractComponentConnector; import com.vaadin.terminal.gwt.client.ui.VContextMenu; @@ -240,6 +241,10 @@ public class ApplicationConnection { initializeClientHooks(); + // Assuming Root data is eagerly loaded + ConnectorBundleLoader.get().loadBundle( + ConnectorBundleLoader.EAGER_BUNDLE_NAME, null); + rootConnector.init(cnf.getRootPanelId(), this); showLoadingIndicator(); } diff --git a/client/src/com/vaadin/terminal/gwt/client/metadata/ConnectorBundleLoader.java b/client/src/com/vaadin/terminal/gwt/client/metadata/ConnectorBundleLoader.java index 48a8430312..ab1462efc1 100644 --- a/client/src/com/vaadin/terminal/gwt/client/metadata/ConnectorBundleLoader.java +++ b/client/src/com/vaadin/terminal/gwt/client/metadata/ConnectorBundleLoader.java @@ -67,7 +67,9 @@ public abstract class ConnectorBundleLoader { List callbacks = asyncBlockLoaders.get(packageName) .setLoaded(); for (BundleLoadCallback callback : callbacks) { - callback.loaded(); + if (callback != null) { + callback.loaded(); + } } } diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/AbstractComponentConnector.java b/client/src/com/vaadin/terminal/gwt/client/ui/AbstractComponentConnector.java index 48842e29a0..4f14ee550b 100644 --- a/client/src/com/vaadin/terminal/gwt/client/ui/AbstractComponentConnector.java +++ b/client/src/com/vaadin/terminal/gwt/client/ui/AbstractComponentConnector.java @@ -37,6 +37,8 @@ import com.vaadin.terminal.gwt.client.UIDL; import com.vaadin.terminal.gwt.client.Util; import com.vaadin.terminal.gwt.client.VConsole; import com.vaadin.terminal.gwt.client.communication.StateChangeEvent; +import com.vaadin.terminal.gwt.client.metadata.Type; +import com.vaadin.terminal.gwt.client.metadata.TypeData; import com.vaadin.terminal.gwt.client.ui.datefield.PopupDateFieldConnector; import com.vaadin.terminal.gwt.client.ui.root.RootConnector; @@ -77,7 +79,10 @@ public abstract class AbstractComponentConnector extends AbstractConnector * @return */ protected Widget createWidget() { - return ConnectorWidgetFactory.createWidget(getClass()); + Type type = TypeData.getType(getClass()); + Type widgetType = type.getMethod("getWidget").getReturnType(); + Object instance = widgetType.createInstance(); + return (Widget) instance; } /** diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/AbstractConnector.java b/client/src/com/vaadin/terminal/gwt/client/ui/AbstractConnector.java index 435fff8a5b..9efa7bad0d 100644 --- a/client/src/com/vaadin/terminal/gwt/client/ui/AbstractConnector.java +++ b/client/src/com/vaadin/terminal/gwt/client/ui/AbstractConnector.java @@ -33,6 +33,8 @@ import com.vaadin.terminal.gwt.client.Util; import com.vaadin.terminal.gwt.client.VConsole; import com.vaadin.terminal.gwt.client.communication.StateChangeEvent; import com.vaadin.terminal.gwt.client.communication.StateChangeEvent.StateChangeHandler; +import com.vaadin.terminal.gwt.client.metadata.Type; +import com.vaadin.terminal.gwt.client.metadata.TypeData; /** * An abstract implementation of Connector. @@ -265,7 +267,10 @@ public abstract class AbstractConnector implements ServerConnector, * @return A new state object */ protected SharedState createState() { - return ConnectorStateFactory.createState(getClass()); + Type connectorType = TypeData.getType(getClass()); + Type stateType = connectorType.getMethod("getState").getReturnType(); + Object stateInstance = stateType.createInstance(); + return (SharedState) stateInstance; } @Override diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/ConnectorClassBasedFactory.java b/client/src/com/vaadin/terminal/gwt/client/ui/ConnectorClassBasedFactory.java deleted file mode 100644 index 698d8e6e61..0000000000 --- a/client/src/com/vaadin/terminal/gwt/client/ui/ConnectorClassBasedFactory.java +++ /dev/null @@ -1,52 +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.terminal.gwt.client.ui; - -import java.util.HashMap; -import java.util.Map; - -import com.vaadin.shared.Connector; - -public abstract class ConnectorClassBasedFactory { - public interface Creator { - public T create(); - } - - private Map, Creator> creators = new HashMap, Creator>(); - - protected void addCreator(Class cls, - Creator creator) { - creators.put(cls, creator); - } - - /** - * Creates a widget using GWT.create for the given connector, based on its - * {@link AbstractComponentConnector#getWidget()} return type. - * - * @param connector - * @return - */ - public T create(Class connector) { - Creator foo = creators.get(connector); - if (foo == null) { - throw new RuntimeException(getClass().getName() - + " could not find a creator for connector of type " - + connector.getName()); - } - return foo.create(); - } - -} diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/ConnectorStateFactory.java b/client/src/com/vaadin/terminal/gwt/client/ui/ConnectorStateFactory.java deleted file mode 100644 index b04daa6910..0000000000 --- a/client/src/com/vaadin/terminal/gwt/client/ui/ConnectorStateFactory.java +++ /dev/null @@ -1,43 +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.terminal.gwt.client.ui; - -import com.google.gwt.core.client.GWT; -import com.vaadin.shared.Connector; -import com.vaadin.shared.communication.SharedState; - -public abstract class ConnectorStateFactory extends - ConnectorClassBasedFactory { - private static ConnectorStateFactory impl = null; - - /** - * Creates a SharedState using GWT.create for the given connector, based on - * its {@link AbstractComponentConnector#getSharedState ()} return type. - * - * @param connector - * @return - */ - public static SharedState createState(Class connector) { - return getImpl().create(connector); - } - - private static ConnectorStateFactory getImpl() { - if (impl == null) { - impl = GWT.create(ConnectorStateFactory.class); - } - return impl; - } -} diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/ConnectorWidgetFactory.java b/client/src/com/vaadin/terminal/gwt/client/ui/ConnectorWidgetFactory.java deleted file mode 100644 index 073e36cabb..0000000000 --- a/client/src/com/vaadin/terminal/gwt/client/ui/ConnectorWidgetFactory.java +++ /dev/null @@ -1,55 +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.terminal.gwt.client.ui; - -import com.google.gwt.core.client.GWT; -import com.google.gwt.user.client.ui.Widget; -import com.vaadin.terminal.gwt.client.ui.textfield.TextFieldConnector; -import com.vaadin.terminal.gwt.client.ui.textfield.VTextField; - -public abstract class ConnectorWidgetFactory extends - ConnectorClassBasedFactory { - private static ConnectorWidgetFactory impl = null; - - // TODO Move to generator - { - addCreator(TextFieldConnector.class, new Creator() { - @Override - public Widget create() { - return GWT.create(VTextField.class); - } - }); - } - - /** - * Creates a widget using GWT.create for the given connector, based on its - * {@link AbstractComponentConnector#getWidget()} return type. - * - * @param connector - * @return - */ - public static Widget createWidget( - Class connector) { - return getImpl().create(connector); - } - - private static ConnectorWidgetFactory getImpl() { - if (impl == null) { - impl = GWT.create(ConnectorWidgetFactory.class); - } - return impl; - } -} -- cgit v1.2.3 From d51dcf18b8d7f64f763163c5965ca30b8c33070d Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Tue, 21 Aug 2012 09:06:21 +0300 Subject: Add logging and tweak visitor API (#9371) --- .../ConnectorBundleLoaderFactory.java | 27 +++-- .../widgetsetutils/metadata/ConnectorBundle.java | 122 ++++++++++++++++----- .../metadata/ConnectorInitVisitor.java | 16 +-- .../widgetsetutils/metadata/StateInitVisitor.java | 16 ++- .../gwt/widgetsetutils/metadata/TypeVisitor.java | 35 +++--- .../widgetsetutils/metadata/WidgetInitVisitor.java | 10 +- 6 files changed, 145 insertions(+), 81 deletions(-) diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorBundleLoaderFactory.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorBundleLoaderFactory.java index 893bebfd0d..e0c88ced66 100644 --- a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorBundleLoaderFactory.java +++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorBundleLoaderFactory.java @@ -8,7 +8,6 @@ import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; -import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -259,22 +258,26 @@ public class ConnectorBundleLoaderFactory extends Generator { Collection visitors = getVisitors(typeOracle); ConnectorBundle eagerBundle = new ConnectorBundle( - ConnectorBundleLoader.EAGER_BUNDLE_NAME, null); + ConnectorBundleLoader.EAGER_BUNDLE_NAME, visitors); + TreeLogger eagerLogger = logger.branch(Type.TRACE, + "Populating eager bundle"); // Eager connectors and all RPC interfaces are loaded by default - eagerBundle.visitTypes(logger, - connectorsByLoadStyle.get(LoadStyle.EAGER), visitors); - eagerBundle.visitSubTypes(logger, - typeOracle.getType(ClientRpc.class.getName()), visitors); - eagerBundle.visitSubTypes(logger, - typeOracle.getType(ServerRpc.class.getName()), visitors); + eagerBundle.processTypes(eagerLogger, + connectorsByLoadStyle.get(LoadStyle.EAGER)); + eagerBundle.processSubTypes(eagerLogger, + typeOracle.getType(ClientRpc.class.getName())); + eagerBundle.processSubTypes(eagerLogger, + typeOracle.getType(ServerRpc.class.getName())); bundles.add(eagerBundle); ConnectorBundle deferredBundle = new ConnectorBundle( ConnectorBundleLoader.DEFERRED_BUNDLE_NAME, eagerBundle); - deferredBundle.visitTypes(logger, - connectorsByLoadStyle.get(LoadStyle.DEFERRED), visitors); + TreeLogger deferredLogger = logger.branch(Type.TRACE, + "Populating deferred bundle"); + deferredBundle.processTypes(deferredLogger, + connectorsByLoadStyle.get(LoadStyle.DEFERRED)); bundles.add(deferredBundle); @@ -282,7 +285,9 @@ public class ConnectorBundleLoaderFactory extends Generator { for (JClassType type : lazy) { ConnectorBundle bundle = new ConnectorBundle(type.getName(), deferredBundle); - bundle.visitTypes(logger, Collections.singleton(type), visitors); + TreeLogger subLogger = logger.branch(Type.TRACE, "Populating " + + type.getName() + " bundle"); + bundle.processType(subLogger, type); bundles.add(bundle); } diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ConnectorBundle.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ConnectorBundle.java index f734b77101..26e293351c 100644 --- a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ConnectorBundle.java +++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ConnectorBundle.java @@ -9,6 +9,7 @@ import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; +import java.util.Iterator; import java.util.Map; import java.util.Set; @@ -18,6 +19,11 @@ import com.google.gwt.core.ext.UnableToCompleteException; import com.google.gwt.core.ext.typeinfo.JClassType; import com.google.gwt.core.ext.typeinfo.JMethod; import com.google.gwt.core.ext.typeinfo.NotFoundException; +import com.vaadin.shared.communication.ClientRpc; +import com.vaadin.shared.communication.ServerRpc; +import com.vaadin.shared.ui.Connect; +import com.vaadin.terminal.gwt.client.ComponentConnector; +import com.vaadin.terminal.gwt.client.ServerConnector; public class ConnectorBundle { private final String name; @@ -29,18 +35,26 @@ public class ConnectorBundle { private final Set visitQueue = new HashSet(); private final Map> needsReturnType = new HashMap>(); - private boolean visiting = false; + private final Collection visitors; - public ConnectorBundle(String name, ConnectorBundle previousBundle) { + private ConnectorBundle(String name, ConnectorBundle previousBundle, + Collection visitors) { this.name = name; this.previousBundle = previousBundle; + this.visitors = visitors; + } + + public ConnectorBundle(String name, ConnectorBundle previousBundle) { + this(name, previousBundle, previousBundle.visitors); + } + + public ConnectorBundle(String name, Collection visitors) { + this(name, null, visitors); } public void setNeedsGwtConstructor(JClassType type) { if (!needsGwtConstructor(type)) { - if (!isTypeVisited(type)) { - visitQueue.add(type); - } + ensureVisited(type); needsGwtConstructor.add(type); } } @@ -56,9 +70,7 @@ public class ConnectorBundle { public void setIdentifier(JClassType type, String identifier) { if (!hasIdentifier(type, identifier)) { - if (!isTypeVisited(type)) { - visitQueue.add(type); - } + ensureVisited(type); Set set = identifiers.get(type); if (set == null) { set = new HashSet(); @@ -94,14 +106,17 @@ public class ConnectorBundle { return Collections.unmodifiableSet(needsGwtConstructor); } - public void visitTypes(TreeLogger logger, Collection types, - Collection visitors) throws UnableToCompleteException { + public void processTypes(TreeLogger logger, Collection types) + throws UnableToCompleteException { for (JClassType type : types) { - if (!isTypeVisited(type)) { - visitQueue.add(type); - } + processType(logger, type); } - visitQueue(logger, visitors); + } + + public void processType(TreeLogger logger, JClassType type) + throws UnableToCompleteException { + ensureVisited(type); + purgeQueue(logger); } private boolean isTypeVisited(JClassType type) { @@ -112,33 +127,50 @@ public class ConnectorBundle { } } - private void visitQueue(TreeLogger logger, Collection visitors) - throws UnableToCompleteException { + private void ensureVisited(JClassType type) { + if (!isTypeVisited(type)) { + visitQueue.add(type); + } + } + + private void purgeQueue(TreeLogger logger) throws UnableToCompleteException { while (!visitQueue.isEmpty()) { - JClassType type = visitQueue.iterator().next(); + Iterator iterator = visitQueue.iterator(); + JClassType type = iterator.next(); + iterator.remove(); + + if (isTypeVisited(type)) { + continue; + } for (TypeVisitor typeVisitor : visitors) { - try { - typeVisitor.visit(type, this); - } catch (NotFoundException e) { - logger.log(Type.ERROR, e.getMessage(), e); - throw new UnableToCompleteException(); - } + invokeVisitor(logger, type, typeVisitor); } - visitQueue.remove(type); visitedTypes.add(type); } } - public void visitSubTypes(TreeLogger logger, JClassType type, - Collection visitors) throws UnableToCompleteException { - visitTypes(logger, Arrays.asList(type.getSubtypes()), visitors); + private void invokeVisitor(TreeLogger logger, JClassType type, + TypeVisitor typeVisitor) throws UnableToCompleteException { + TreeLogger subLogger = logger.branch(Type.TRACE, + "Visiting " + type.getName() + " with " + + typeVisitor.getClass().getSimpleName()); + if (isConnectedConnector(type)) { + typeVisitor.visitConnector(subLogger, type, this); + } else if (isClientRpc(type)) { + typeVisitor.visitClientRpc(subLogger, type, this); + } else if (isServerRpc(type)) { + typeVisitor.visitServerRpc(subLogger, type, this); + } + } + + public void processSubTypes(TreeLogger logger, JClassType type) + throws UnableToCompleteException { + processTypes(logger, Arrays.asList(type.getSubtypes())); } public void setNeedsReturnType(JClassType type, JMethod method) { if (!isNeedsReturnType(type, method)) { - if (!isTypeVisited(type)) { - visitQueue.add(type); - } + ensureVisited(type); Set set = needsReturnType.get(type); if (set == null) { set = new HashSet(); @@ -161,4 +193,34 @@ public class ConnectorBundle { public Map> getMethodReturnTypes() { return Collections.unmodifiableMap(needsReturnType); } + + private static boolean isClientRpc(JClassType type) { + return isType(type, ClientRpc.class); + } + + private static boolean isServerRpc(JClassType type) { + return isType(type, ServerRpc.class); + } + + public static boolean isConnectedConnector(JClassType type) { + return isConnected(type) && isType(type, ServerConnector.class); + } + + private static boolean isConnected(JClassType type) { + return type.isAnnotationPresent(Connect.class); + } + + public static boolean isConnectedComponentConnector(JClassType type) { + return isConnected(type) && isType(type, ComponentConnector.class); + } + + private static boolean isType(JClassType type, Class class1) { + try { + return type.getOracle().getType(class1.getName()) + .isAssignableFrom(type); + } catch (NotFoundException e) { + throw new RuntimeException("Could not find " + class1.getName(), e); + } + } + } \ No newline at end of file diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ConnectorInitVisitor.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ConnectorInitVisitor.java index 6dd840d612..09cdaddc31 100644 --- a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ConnectorInitVisitor.java +++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ConnectorInitVisitor.java @@ -4,19 +4,21 @@ package com.vaadin.terminal.gwt.widgetsetutils.metadata; +import com.google.gwt.core.ext.TreeLogger; +import com.google.gwt.core.ext.TreeLogger.Type; import com.google.gwt.core.ext.typeinfo.JClassType; import com.vaadin.shared.ui.Connect; public class ConnectorInitVisitor extends TypeVisitor { @Override - public void visit(JClassType type, ConnectorBundle bundle) { - if (isConnectedConnector(type)) { - Connect connectAnnotation = type.getAnnotation(Connect.class); - bundle.setIdentifier(type, connectAnnotation.value() - .getCanonicalName()); - bundle.setNeedsGwtConstructor(type); - } + public void visitConnector(TreeLogger logger, JClassType type, + ConnectorBundle bundle) { + logger.log(Type.INFO, type.getName() + " will be in the " + + bundle.getName().replaceAll("^_*", "") + " bundle"); + Connect connectAnnotation = type.getAnnotation(Connect.class); + bundle.setIdentifier(type, connectAnnotation.value().getCanonicalName()); + bundle.setNeedsGwtConstructor(type); } } diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/StateInitVisitor.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/StateInitVisitor.java index b88afdf37a..d22f03635b 100644 --- a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/StateInitVisitor.java +++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/StateInitVisitor.java @@ -4,22 +4,20 @@ package com.vaadin.terminal.gwt.widgetsetutils.metadata; +import com.google.gwt.core.ext.TreeLogger; import com.google.gwt.core.ext.typeinfo.JClassType; import com.google.gwt.core.ext.typeinfo.JMethod; import com.google.gwt.core.ext.typeinfo.JType; -import com.google.gwt.core.ext.typeinfo.NotFoundException; public class StateInitVisitor extends TypeVisitor { @Override - public void visit(JClassType type, ConnectorBundle bundle) - throws NotFoundException { - if (isConnectedConnector(type)) { - JMethod getState = getInheritedMethod(type, "getState"); - bundle.setNeedsReturnType(type, getState); + public void visitConnector(TreeLogger logger, JClassType type, + ConnectorBundle bundle) { + JMethod getState = findInheritedMethod(type, "getState"); + bundle.setNeedsReturnType(type, getState); - JType stateType = getState.getReturnType(); - bundle.setNeedsGwtConstructor(stateType.isClass()); - } + JType stateType = getState.getReturnType(); + bundle.setNeedsGwtConstructor(stateType.isClass()); } } diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/TypeVisitor.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/TypeVisitor.java index 163eda0675..976eb6417a 100644 --- a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/TypeVisitor.java +++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/TypeVisitor.java @@ -4,39 +4,35 @@ package com.vaadin.terminal.gwt.widgetsetutils.metadata; +import com.google.gwt.core.ext.TreeLogger; import com.google.gwt.core.ext.typeinfo.JClassType; import com.google.gwt.core.ext.typeinfo.JMethod; import com.google.gwt.core.ext.typeinfo.JType; import com.google.gwt.core.ext.typeinfo.NotFoundException; import com.google.gwt.core.ext.typeinfo.TypeOracle; -import com.vaadin.shared.ui.Connect; -import com.vaadin.terminal.gwt.client.ComponentConnector; -import com.vaadin.terminal.gwt.client.ServerConnector; public abstract class TypeVisitor { - private JClassType serverConnector; - private JClassType componentConnector; - public void init(TypeOracle oracle) throws NotFoundException { - serverConnector = oracle.getType(ServerConnector.class.getName()); - componentConnector = oracle.getType(ComponentConnector.class.getName()); + // Default does nothing } - public abstract void visit(JClassType type, ConnectorBundle bundle) - throws NotFoundException; + public void visitConnector(TreeLogger logger, JClassType type, + ConnectorBundle bundle) { + // Default does nothing + } - protected boolean isConnectedConnector(JClassType type) { - return serverConnector.isAssignableFrom(type) - && type.isAnnotationPresent(Connect.class); + public void visitClientRpc(TreeLogger logger, JClassType type, + ConnectorBundle bundle) { + // Default does nothing } - protected boolean isConnectedComponentConnector(JClassType type) { - return componentConnector.isAssignableFrom(type) - && type.isAnnotationPresent(Connect.class); + public void visitServerRpc(TreeLogger logger, JClassType type, + ConnectorBundle bundle) { + // Default does nothing } - protected JMethod getInheritedMethod(JClassType type, String methodName, - JType... params) throws NotFoundException { + protected JMethod findInheritedMethod(JClassType type, String methodName, + JType... params) { JClassType currentType = type; while (currentType != null) { @@ -55,6 +51,7 @@ public abstract class TypeVisitor { } } - throw new NotFoundException(methodName + " not found in " + type); + return null; } + } diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/WidgetInitVisitor.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/WidgetInitVisitor.java index be6f303c5b..50ea60a3c6 100644 --- a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/WidgetInitVisitor.java +++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/WidgetInitVisitor.java @@ -4,18 +4,18 @@ package com.vaadin.terminal.gwt.widgetsetutils.metadata; +import com.google.gwt.core.ext.TreeLogger; import com.google.gwt.core.ext.typeinfo.JClassType; import com.google.gwt.core.ext.typeinfo.JMethod; import com.google.gwt.core.ext.typeinfo.JType; -import com.google.gwt.core.ext.typeinfo.NotFoundException; public class WidgetInitVisitor extends TypeVisitor { @Override - public void visit(JClassType type, ConnectorBundle bundle) - throws NotFoundException { - if (isConnectedComponentConnector(type)) { - JMethod getWidget = getInheritedMethod(type, "getWidget"); + public void visitConnector(TreeLogger logger, JClassType type, + ConnectorBundle bundle) { + if (ConnectorBundle.isConnectedComponentConnector(type)) { + JMethod getWidget = findInheritedMethod(type, "getWidget"); bundle.setNeedsReturnType(type, getWidget); JType widgetType = getWidget.getReturnType(); -- cgit v1.2.3 From bcef4d5e716a275f3a3588cd9e50885129d38eb7 Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Tue, 21 Aug 2012 12:33:32 +0300 Subject: Use ConnectorBundle for ClientRpc handling (#9371) --- .../ConnectorBundleLoaderFactory.java | 116 ++++++++++- .../GeneratedRpcMethodProviderGenerator.java | 223 --------------------- .../gwt/widgetsetutils/SerializerGenerator.java | 6 +- .../widgetsetutils/metadata/ClientRpcVisitor.java | 39 ++++ .../widgetsetutils/metadata/ConnectorBundle.java | 79 ++++++-- client/src/com/vaadin/Vaadin.gwt.xml | 7 - .../gwt/client/ApplicationConfiguration.java | 11 +- .../com/vaadin/terminal/gwt/client/WidgetSet.java | 21 +- .../communication/GeneratedRpcMethodProvider.java | 32 --- .../gwt/client/communication/RpcManager.java | 53 +++-- .../gwt/client/communication/RpcMethod.java | 47 ----- .../terminal/gwt/client/metadata/Method.java | 13 +- .../gwt/client/metadata/NoDataException.java | 25 +++ .../terminal/gwt/client/metadata/Property.java | 2 +- .../vaadin/terminal/gwt/client/metadata/Type.java | 4 +- .../terminal/gwt/client/metadata/TypeData.java | 8 +- .../gwt/client/metadata/TypeDataStore.java | 67 ++++++- .../gwt/client/ui/AbstractComponentConnector.java | 15 +- .../terminal/gwt/client/ui/AbstractConnector.java | 17 +- 19 files changed, 389 insertions(+), 396 deletions(-) delete mode 100644 client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/GeneratedRpcMethodProviderGenerator.java create mode 100644 client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ClientRpcVisitor.java delete mode 100644 client/src/com/vaadin/terminal/gwt/client/communication/GeneratedRpcMethodProvider.java delete mode 100644 client/src/com/vaadin/terminal/gwt/client/communication/RpcMethod.java create mode 100644 client/src/com/vaadin/terminal/gwt/client/metadata/NoDataException.java diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorBundleLoaderFactory.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorBundleLoaderFactory.java index e0c88ced66..b6a6e0bff4 100644 --- a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorBundleLoaderFactory.java +++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorBundleLoaderFactory.java @@ -22,6 +22,8 @@ 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.JMethod; +import com.google.gwt.core.ext.typeinfo.JParameterizedType; +import com.google.gwt.core.ext.typeinfo.JType; import com.google.gwt.core.ext.typeinfo.NotFoundException; import com.google.gwt.core.ext.typeinfo.TypeOracle; import com.google.gwt.user.rebind.ClassSourceFileComposerFactory; @@ -34,6 +36,7 @@ import com.vaadin.terminal.gwt.client.ServerConnector; import com.vaadin.terminal.gwt.client.metadata.ConnectorBundleLoader; import com.vaadin.terminal.gwt.client.metadata.TypeDataBundle; import com.vaadin.terminal.gwt.client.metadata.TypeDataStore; +import com.vaadin.terminal.gwt.widgetsetutils.metadata.ClientRpcVisitor; import com.vaadin.terminal.gwt.widgetsetutils.metadata.ConnectorBundle; import com.vaadin.terminal.gwt.widgetsetutils.metadata.ConnectorInitVisitor; import com.vaadin.terminal.gwt.widgetsetutils.metadata.StateInitVisitor; @@ -161,6 +164,85 @@ public class ConnectorBundleLoaderFactory extends Generator { writeIdentifiers(w, bundle); writeGwtConstructors(w, bundle); writeReturnTypes(w, bundle); + writeInvokers(w, bundle); + writeParamTypes(w, bundle); + } + + private void writeParamTypes(SourceWriter w, ConnectorBundle bundle) { + Map> needsParamTypes = bundle + .getNeedsParamTypes(); + for (Entry> entry : needsParamTypes.entrySet()) { + JClassType type = entry.getKey(); + + Set methods = entry.getValue(); + for (JMethod method : methods) { + w.println("store.setParamTypes("); + printClassLiteral(w, type); + w.print(", \""); + w.print(escape(method.getName())); + w.println("\", new Type[] {"); + + for (JType parameter : method.getParameterTypes()) { + ConnectorBundleLoaderFactory.writeTypeCreator(w, parameter); + w.print(", "); + } + + w.println("});"); + + } + } + } + + private void writeInvokers(SourceWriter w, ConnectorBundle bundle) { + Map> needsInvoker = bundle.getNeedsInvoker(); + for (Entry> entry : needsInvoker.entrySet()) { + JClassType type = entry.getKey(); + + Set methods = entry.getValue(); + for (JMethod method : methods) { + w.print("store.setInvoker("); + printClassLiteral(w, type); + w.print(", \""); + w.print(escape(method.getName())); + w.println("\", new Invoker() {"); + w.indent(); + + w.println("public Object invoke(Object target, Object[] params) {"); + w.indent(); + + JType returnType = method.getReturnType(); + boolean hasReturnType = !"void".equals(returnType + .getQualifiedSourceName()); + if (hasReturnType) { + w.print("return "); + } + + JType[] parameterTypes = method.getParameterTypes(); + + w.print("((" + type.getQualifiedSourceName() + ") target)." + + method.getName() + "("); + for (int i = 0; i < parameterTypes.length; i++) { + JType parameterType = parameterTypes[i]; + if (i != 0) { + w.print(", "); + } + String parameterTypeName = getBoxedTypeName(parameterType); + w.print("(" + parameterTypeName + ") params[" + i + "]"); + } + w.println(");"); + + if (!hasReturnType) { + w.println("return null;"); + } + + w.outdent(); + w.println("}"); + + w.outdent(); + w.println("});"); + + } + } } private void writeReturnTypes(SourceWriter w, ConnectorBundle bundle) { @@ -177,10 +259,9 @@ public class ConnectorBundleLoaderFactory extends Generator { w.print("store.setReturnType("); printClassLiteral(w, type); w.print(", \""); - w.print(method.getName()); + w.print(escape(method.getName())); w.print("\", "); - GeneratedRpcMethodProviderGenerator.writeTypeCreator(w, - method.getReturnType()); + writeTypeCreator(w, method.getReturnType()); w.println(");"); } } @@ -299,7 +380,7 @@ public class ConnectorBundleLoaderFactory extends Generator { throws NotFoundException { List visitors = Arrays. asList( new ConnectorInitVisitor(), new StateInitVisitor(), - new WidgetInitVisitor()); + new WidgetInitVisitor(), new ClientRpcVisitor()); for (TypeVisitor typeVisitor : visitors) { typeVisitor.init(oracle); } @@ -311,4 +392,31 @@ public class ConnectorBundleLoaderFactory extends Generator { return annotation.loadStyle(); } + public static String getBoxedTypeName(JType type) { + if (type.isPrimitive() != null) { + // Used boxed types for primitives + return type.isPrimitive().getQualifiedBoxedSourceName(); + } else { + return type.getErasedType().getQualifiedSourceName(); + } + } + + public static void writeTypeCreator(SourceWriter sourceWriter, JType type) { + String typeName = ConnectorBundleLoaderFactory.getBoxedTypeName(type); + sourceWriter.print("new Type(\"" + typeName + "\", "); + JParameterizedType parameterized = type.isParameterized(); + if (parameterized != null) { + sourceWriter.print("new Type[] {"); + JClassType[] typeArgs = parameterized.getTypeArgs(); + for (JClassType jClassType : typeArgs) { + writeTypeCreator(sourceWriter, jClassType); + sourceWriter.print(", "); + } + sourceWriter.print("}"); + } else { + sourceWriter.print("null"); + } + sourceWriter.print(")"); + } + } diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/GeneratedRpcMethodProviderGenerator.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/GeneratedRpcMethodProviderGenerator.java deleted file mode 100644 index c6cf28db28..0000000000 --- a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/GeneratedRpcMethodProviderGenerator.java +++ /dev/null @@ -1,223 +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.terminal.gwt.widgetsetutils; - -import java.io.PrintWriter; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -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.JMethod; -import com.google.gwt.core.ext.typeinfo.JParameterizedType; -import com.google.gwt.core.ext.typeinfo.JType; -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.shared.communication.ClientRpc; -import com.vaadin.terminal.gwt.client.communication.GeneratedRpcMethodProvider; -import com.vaadin.terminal.gwt.client.communication.RpcManager; -import com.vaadin.terminal.gwt.client.communication.RpcMethod; - -/** - * GWT generator that creates an implementation for {@link RpcManager} on the - * client side classes for executing RPC calls received from the the server. - * - * @since 7.0 - */ -public class GeneratedRpcMethodProviderGenerator extends Generator { - - @Override - public String generate(TreeLogger logger, GeneratorContext context, - String typeName) throws UnableToCompleteException { - - String packageName = null; - String className = null; - 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 for SerializerMapImpl - generateClass(logger, context, packageName, className); - } catch (Exception e) { - logger.log(TreeLogger.ERROR, - "SerializerMapGenerator creation failed", e); - } - // return the fully qualifed name of the class generated - return packageName + "." + className; - } - - /** - * Generate source code for RpcManagerImpl - * - * @param logger - * Logger object - * @param context - * Generator context - * @param packageName - * package name for the class to generate - * @param className - * class name for the class to generate - */ - private void generateClass(TreeLogger logger, GeneratorContext context, - String packageName, String className) { - // 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 - if (printWriter == null) { - return; - } - logger.log(Type.INFO, - "Detecting server to client RPC interface types..."); - Date date = new Date(); - TypeOracle typeOracle = context.getTypeOracle(); - JClassType serverToClientRpcType = typeOracle.findType(ClientRpc.class - .getName()); - JClassType[] rpcInterfaceSubtypes = serverToClientRpcType.getSubtypes(); - - // 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(RpcMethod.class.getName()); - composer.addImport(ClientRpc.class.getName()); - composer.addImport(com.vaadin.terminal.gwt.client.metadata.Type.class - .getName()); - composer.addImplementedInterface(GeneratedRpcMethodProvider.class - .getName()); - SourceWriter sourceWriter = composer.createSourceWriter(context, - printWriter); - sourceWriter.indent(); - - List rpcMethods = new ArrayList(); - - sourceWriter - .println("public java.util.Collection getGeneratedRpcMethods() {"); - sourceWriter.indent(); - - sourceWriter - .println("java.util.ArrayList list = new java.util.ArrayList();"); - - // iterate over RPC interfaces and create helper methods for each - // interface - for (JClassType type : rpcInterfaceSubtypes) { - if (null == type.isInterface()) { - // only interested in interfaces here, not implementations - continue; - } - - // loop over the methods of the interface and its superinterfaces - // methods - for (JClassType currentType : type.getFlattenedSupertypeHierarchy()) { - for (JMethod method : currentType.getMethods()) { - - // RpcMethod(String interfaceName, String methodName, - // Type... parameterTypes) - sourceWriter.print("list.add(new RpcMethod(\"" - + type.getQualifiedSourceName() + "\", \"" - + method.getName() + "\""); - JType[] parameterTypes = method.getParameterTypes(); - for (JType parameter : parameterTypes) { - sourceWriter.print(", "); - writeTypeCreator(sourceWriter, parameter); - } - sourceWriter.println(") {"); - sourceWriter.indent(); - - sourceWriter - .println("public void applyInvocation(ClientRpc target, Object... parameters) {"); - sourceWriter.indent(); - - sourceWriter.print("((" + type.getQualifiedSourceName() - + ")target)." + method.getName() + "("); - for (int i = 0; i < parameterTypes.length; i++) { - JType parameterType = parameterTypes[i]; - if (i != 0) { - sourceWriter.print(", "); - } - String parameterTypeName = getBoxedTypeName(parameterType); - sourceWriter.print("(" + parameterTypeName - + ") parameters[" + i + "]"); - } - sourceWriter.println(");"); - - sourceWriter.outdent(); - sourceWriter.println("}"); - - sourceWriter.outdent(); - sourceWriter.println("});"); - } - } - } - - sourceWriter.println("return list;"); - - sourceWriter.outdent(); - sourceWriter.println("}"); - sourceWriter.println(); - - // 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)"); - - } - - public static void writeTypeCreator(SourceWriter sourceWriter, JType type) { - String typeName = getBoxedTypeName(type); - sourceWriter.print("new Type(\"" + typeName + "\", "); - JParameterizedType parameterized = type.isParameterized(); - if (parameterized != null) { - sourceWriter.print("new Type[] {"); - JClassType[] typeArgs = parameterized.getTypeArgs(); - for (JClassType jClassType : typeArgs) { - writeTypeCreator(sourceWriter, jClassType); - sourceWriter.print(", "); - } - sourceWriter.print("}"); - } else { - sourceWriter.print("null"); - } - sourceWriter.print(")"); - } - - public static String getBoxedTypeName(JType type) { - if (type.isPrimitive() != null) { - // Used boxed types for primitives - return type.isPrimitive().getQualifiedBoxedSourceName(); - } else { - return type.getErasedType().getQualifiedSourceName(); - } - } - - private String getInvokeMethodName(JClassType type) { - return "invoke" + type.getQualifiedSourceName().replaceAll("\\.", "_"); - } -} diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/SerializerGenerator.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/SerializerGenerator.java index c7cc7bf7cb..83e1c17881 100644 --- a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/SerializerGenerator.java +++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/SerializerGenerator.java @@ -256,10 +256,10 @@ public class SerializerGenerator extends Generator { JType componentType = type.getComponentType(); sourceWriter.print("value[i] = (" - + GeneratedRpcMethodProviderGenerator + + ConnectorBundleLoaderFactory .getBoxedTypeName(componentType) + ") " + JsonDecoder.class.getName() + ".decodeValue("); - GeneratedRpcMethodProviderGenerator.writeTypeCreator(sourceWriter, + ConnectorBundleLoaderFactory.writeTypeCreator(sourceWriter, componentType); sourceWriter.print(", jsonArray.get(i), null, connection)"); @@ -320,7 +320,7 @@ public class SerializerGenerator extends Generator { // connection)); sourceWriter.print("target." + setterName + "((" + fieldType + ") " + JsonDecoder.class.getName() + ".decodeValue("); - GeneratedRpcMethodProviderGenerator.writeTypeCreator(sourceWriter, + ConnectorBundleLoaderFactory.writeTypeCreator(sourceWriter, setterParameterType); sourceWriter.println(", " + jsonFieldName + ", referenceValue, connection));"); diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ClientRpcVisitor.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ClientRpcVisitor.java new file mode 100644 index 0000000000..2f628b76cb --- /dev/null +++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ClientRpcVisitor.java @@ -0,0 +1,39 @@ +/* + * 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.terminal.gwt.widgetsetutils.metadata; + +import java.util.Set; + +import com.google.gwt.core.ext.TreeLogger; +import com.google.gwt.core.ext.typeinfo.JClassType; +import com.google.gwt.core.ext.typeinfo.JMethod; + +public class ClientRpcVisitor extends TypeVisitor { + @Override + public void visitClientRpc(TreeLogger logger, JClassType type, + ConnectorBundle bundle) { + Set hierarchy = type + .getFlattenedSupertypeHierarchy(); + for (JClassType subType : hierarchy) { + JMethod[] methods = subType.getMethods(); + for (JMethod method : methods) { + bundle.setNeedsInvoker(type, method); + bundle.setNeedsParamTypes(type, method); + } + } + } +} diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ConnectorBundle.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ConnectorBundle.java index 26e293351c..3302fbc4fa 100644 --- a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ConnectorBundle.java +++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ConnectorBundle.java @@ -36,6 +36,8 @@ public class ConnectorBundle { private final Map> needsReturnType = new HashMap>(); private final Collection visitors; + private final Map> needsInvoker = new HashMap>(); + private final Map> needsParamTypes = new HashMap>(); private ConnectorBundle(String name, ConnectorBundle previousBundle, Collection visitors) { @@ -71,18 +73,12 @@ public class ConnectorBundle { public void setIdentifier(JClassType type, String identifier) { if (!hasIdentifier(type, identifier)) { ensureVisited(type); - Set set = identifiers.get(type); - if (set == null) { - set = new HashSet(); - identifiers.put(type, set); - } - set.add(identifier); + addMapping(identifiers, type, identifier); } } private boolean hasIdentifier(JClassType type, String identifier) { - if (identifiers.containsKey(type) - && identifiers.get(type).contains(identifier)) { + if (hasMapping(identifiers, type, identifier)) { return true; } else { return previousBundle != null @@ -142,10 +138,13 @@ public class ConnectorBundle { if (isTypeVisited(type)) { continue; } + + // Mark as visited before visiting to avoid adding to queue again + visitedTypes.add(type); + for (TypeVisitor typeVisitor : visitors) { invokeVisitor(logger, type, typeVisitor); } - visitedTypes.add(type); } } @@ -171,18 +170,12 @@ public class ConnectorBundle { public void setNeedsReturnType(JClassType type, JMethod method) { if (!isNeedsReturnType(type, method)) { ensureVisited(type); - Set set = needsReturnType.get(type); - if (set == null) { - set = new HashSet(); - needsReturnType.put(type, set); - } - set.add(method); + addMapping(needsReturnType, type, method); } } private boolean isNeedsReturnType(JClassType type, JMethod method) { - if (needsReturnType.containsKey(type) - && needsReturnType.get(type).contains(method)) { + if (hasMapping(needsReturnType, type, method)) { return true; } else { return previousBundle != null @@ -223,4 +216,56 @@ public class ConnectorBundle { } } + public void setNeedsInvoker(JClassType type, JMethod method) { + if (!isNeedsInvoker(type, method)) { + ensureVisited(type); + addMapping(needsInvoker, type, method); + } + } + + private void addMapping(Map> map, K key, V value) { + Set set = map.get(key); + if (set == null) { + set = new HashSet(); + map.put(key, set); + } + set.add(value); + } + + private boolean hasMapping(Map> map, K key, V value) { + return map.containsKey(key) && map.get(key).contains(value); + } + + private boolean isNeedsInvoker(JClassType type, JMethod method) { + if (hasMapping(needsInvoker, type, method)) { + return true; + } else { + return previousBundle != null + && previousBundle.isNeedsInvoker(type, method); + } + } + + public Map> getNeedsInvoker() { + return Collections.unmodifiableMap(needsInvoker); + } + + public void setNeedsParamTypes(JClassType type, JMethod method) { + if (!isNeedsParamTypes(type, method)) { + ensureVisited(type); + addMapping(needsParamTypes, type, method); + } + } + + private boolean isNeedsParamTypes(JClassType type, JMethod method) { + if (hasMapping(needsParamTypes, type, method)) { + return true; + } else { + return previousBundle != null + && previousBundle.isNeedsParamTypes(type, method); + } + } + + public Map> getNeedsParamTypes() { + return Collections.unmodifiableMap(needsParamTypes); + } } \ No newline at end of file diff --git a/client/src/com/vaadin/Vaadin.gwt.xml b/client/src/com/vaadin/Vaadin.gwt.xml index 4bac60b472..e25c812e5b 100644 --- a/client/src/com/vaadin/Vaadin.gwt.xml +++ b/client/src/com/vaadin/Vaadin.gwt.xml @@ -54,13 +54,6 @@ - - - - - diff --git a/client/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java b/client/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java index 8f6697288c..8bb4f37324 100644 --- a/client/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java +++ b/client/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java @@ -33,6 +33,7 @@ import com.google.gwt.user.client.Window; import com.vaadin.shared.ApplicationConstants; import com.vaadin.terminal.gwt.client.metadata.BundleLoadCallback; import com.vaadin.terminal.gwt.client.metadata.ConnectorBundleLoader; +import com.vaadin.terminal.gwt.client.metadata.NoDataException; import com.vaadin.terminal.gwt.client.metadata.TypeData; import com.vaadin.terminal.gwt.client.ui.UnknownComponentConnector; @@ -398,8 +399,14 @@ public class ApplicationConfiguration implements EntryPoint { Integer currentTag = Integer.valueOf(tag); while (type == null && currentTag != null) { String serverSideClassNameForTag = getServerSideClassNameForTag(currentTag); - type = (Class) TypeData - .getClass(serverSideClassNameForTag); + if (TypeData.hasIdentifier(serverSideClassNameForTag)) { + try { + type = (Class) TypeData + .getClass(serverSideClassNameForTag); + } catch (NoDataException e) { + throw new RuntimeException(e); + } + } currentTag = getParentTag(currentTag.intValue()); } if (type == null) { diff --git a/client/src/com/vaadin/terminal/gwt/client/WidgetSet.java b/client/src/com/vaadin/terminal/gwt/client/WidgetSet.java index 776436f5f0..8245371161 100644 --- a/client/src/com/vaadin/terminal/gwt/client/WidgetSet.java +++ b/client/src/com/vaadin/terminal/gwt/client/WidgetSet.java @@ -20,6 +20,7 @@ import com.google.gwt.core.client.GWT; import com.vaadin.terminal.gwt.client.communication.HasJavaScriptConnectorHelper; import com.vaadin.terminal.gwt.client.metadata.BundleLoadCallback; import com.vaadin.terminal.gwt.client.metadata.ConnectorBundleLoader; +import com.vaadin.terminal.gwt.client.metadata.NoDataException; import com.vaadin.terminal.gwt.client.metadata.TypeData; import com.vaadin.terminal.gwt.client.ui.UnknownComponentConnector; @@ -60,13 +61,21 @@ public class WidgetSet { /* * let the auto generated code instantiate this type */ - ServerConnector connector = (ServerConnector) TypeData.getType( - classType).createInstance(); - if (connector instanceof HasJavaScriptConnectorHelper) { - ((HasJavaScriptConnectorHelper) connector) - .getJavascriptConnectorHelper().setTag(tag); + try { + ServerConnector connector = (ServerConnector) TypeData.getType( + classType).createInstance(); + if (connector instanceof HasJavaScriptConnectorHelper) { + ((HasJavaScriptConnectorHelper) connector) + .getJavascriptConnectorHelper().setTag(tag); + } + return connector; + } catch (NoDataException e) { + throw new IllegalStateException( + "There is no information about " + + classType + + ". Did you remember to compile the right widgetset?", + e); } - return connector; } } diff --git a/client/src/com/vaadin/terminal/gwt/client/communication/GeneratedRpcMethodProvider.java b/client/src/com/vaadin/terminal/gwt/client/communication/GeneratedRpcMethodProvider.java deleted file mode 100644 index e865dbc1b1..0000000000 --- a/client/src/com/vaadin/terminal/gwt/client/communication/GeneratedRpcMethodProvider.java +++ /dev/null @@ -1,32 +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.terminal.gwt.client.communication; - -import java.util.Collection; - -/** - * Provides runtime data about client side RPC calls received from the server to - * the client-side code. - * - * A GWT generator is used to create an implementation of this class at - * run-time. - * - * @since 7.0 - */ -public interface GeneratedRpcMethodProvider { - - public Collection getGeneratedRpcMethods(); -} diff --git a/client/src/com/vaadin/terminal/gwt/client/communication/RpcManager.java b/client/src/com/vaadin/terminal/gwt/client/communication/RpcManager.java index 537cc34185..45939eb54e 100644 --- a/client/src/com/vaadin/terminal/gwt/client/communication/RpcManager.java +++ b/client/src/com/vaadin/terminal/gwt/client/communication/RpcManager.java @@ -17,10 +17,7 @@ package com.vaadin.terminal.gwt.client.communication; import java.util.Collection; -import java.util.HashMap; -import java.util.Map; -import com.google.gwt.core.client.GWT; import com.google.gwt.json.client.JSONArray; import com.google.gwt.json.client.JSONString; import com.vaadin.shared.communication.ClientRpc; @@ -29,6 +26,8 @@ import com.vaadin.terminal.gwt.client.ApplicationConnection; import com.vaadin.terminal.gwt.client.ConnectorMap; import com.vaadin.terminal.gwt.client.ServerConnector; import com.vaadin.terminal.gwt.client.VConsole; +import com.vaadin.terminal.gwt.client.metadata.Method; +import com.vaadin.terminal.gwt.client.metadata.NoDataException; import com.vaadin.terminal.gwt.client.metadata.Type; /** @@ -42,19 +41,6 @@ import com.vaadin.terminal.gwt.client.metadata.Type; */ public class RpcManager { - private final Map methodMap = new HashMap(); - - public RpcManager() { - GeneratedRpcMethodProvider provider = GWT - .create(GeneratedRpcMethodProvider.class); - Collection methods = provider.getGeneratedRpcMethods(); - for (RpcMethod rpcMethod : methods) { - methodMap.put( - rpcMethod.getInterfaceName() + "." - + rpcMethod.getMethodName(), rpcMethod); - } - } - /** * Perform server to client RPC invocation. * @@ -63,24 +49,25 @@ public class RpcManager { */ public void applyInvocation(MethodInvocation invocation, ServerConnector connector) { - String signature = getSignature(invocation); + Method method = getMethod(invocation); - RpcMethod rpcMethod = getRpcMethod(signature); Collection implementations = connector .getRpcImplementations(invocation.getInterfaceName()); - for (ClientRpc clientRpc : implementations) { - rpcMethod.applyInvocation(clientRpc, invocation.getParameters()); + try { + for (ClientRpc clientRpc : implementations) { + method.invoke(clientRpc, invocation.getParameters()); + } + } catch (NoDataException e) { + throw new IllegalStateException("There is no information about " + + method.getSignature() + + ". Did you remember to compile the right widgetset?", e); } } - private RpcMethod getRpcMethod(String signature) { - RpcMethod rpcMethod = methodMap.get(signature); - if (rpcMethod == null) { - throw new IllegalStateException("There is no information about " - + signature - + ". Did you remember to compile the right widgetset?"); - } - return rpcMethod; + private Method getMethod(MethodInvocation invocation) { + Type type = new Type(invocation.getInterfaceName(), null); + Method method = type.getMethod(invocation.getMethodName()); + return method; } private static String getSignature(MethodInvocation invocation) { @@ -88,7 +75,15 @@ public class RpcManager { } public Type[] getParameterTypes(MethodInvocation invocation) { - return getRpcMethod(getSignature(invocation)).getParameterTypes(); + Method method = getMethod(invocation); + Type[] parameterTypes = method.getParameterTypes(); + if (parameterTypes == null) { + throw new IllegalStateException("There is no information about " + + method.getSignature() + + ". Did you remember to compile the right widgetset?"); + + } + return parameterTypes; } public void parseAndApplyInvocation(JSONArray rpcCall, diff --git a/client/src/com/vaadin/terminal/gwt/client/communication/RpcMethod.java b/client/src/com/vaadin/terminal/gwt/client/communication/RpcMethod.java deleted file mode 100644 index 1759fbb97f..0000000000 --- a/client/src/com/vaadin/terminal/gwt/client/communication/RpcMethod.java +++ /dev/null @@ -1,47 +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.terminal.gwt.client.communication; - -import com.vaadin.shared.communication.ClientRpc; -import com.vaadin.terminal.gwt.client.metadata.Type; - -public abstract class RpcMethod { - private String interfaceName; - private String methodName; - private Type[] parameterTypes; - - public RpcMethod(String interfaceName, String methodName, - Type... parameterTypes) { - this.interfaceName = interfaceName; - this.methodName = methodName; - this.parameterTypes = parameterTypes; - } - - public String getInterfaceName() { - return interfaceName; - } - - public String getMethodName() { - return methodName; - } - - public Type[] getParameterTypes() { - return parameterTypes; - } - - public abstract void applyInvocation(ClientRpc target, Object... parameters); - -} diff --git a/client/src/com/vaadin/terminal/gwt/client/metadata/Method.java b/client/src/com/vaadin/terminal/gwt/client/metadata/Method.java index f164bc4bcf..588e736da3 100644 --- a/client/src/com/vaadin/terminal/gwt/client/metadata/Method.java +++ b/client/src/com/vaadin/terminal/gwt/client/metadata/Method.java @@ -22,11 +22,11 @@ public class Method { return name; } - public Type getReturnType() { + public Type getReturnType() throws NoDataException { return TypeDataStore.getReturnType(this); } - public void invoke(Object target, Object... params) { + public void invoke(Object target, Object... params) throws NoDataException { TypeDataStore.getInvoker(this).invoke(target, params); } @@ -46,9 +46,18 @@ public class Method { } } + @Override + public String toString() { + return getSignature(); + } + @Override public int hashCode() { return getSignature().hashCode(); } + public Type[] getParameterTypes() { + return TypeDataStore.getParamTypes(this); + } + } diff --git a/client/src/com/vaadin/terminal/gwt/client/metadata/NoDataException.java b/client/src/com/vaadin/terminal/gwt/client/metadata/NoDataException.java new file mode 100644 index 0000000000..717b92edaf --- /dev/null +++ b/client/src/com/vaadin/terminal/gwt/client/metadata/NoDataException.java @@ -0,0 +1,25 @@ +/* + * 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.terminal.gwt.client.metadata; + +public class NoDataException extends Exception { + + public NoDataException(String message) { + super(message); + } + +} diff --git a/client/src/com/vaadin/terminal/gwt/client/metadata/Property.java b/client/src/com/vaadin/terminal/gwt/client/metadata/Property.java index 5f2b1ffb41..30d864a43f 100644 --- a/client/src/com/vaadin/terminal/gwt/client/metadata/Property.java +++ b/client/src/com/vaadin/terminal/gwt/client/metadata/Property.java @@ -13,7 +13,7 @@ public class Property { this.name = name; } - public Object getValue(Object bean) { + public Object getValue(Object bean) throws NoDataException { return TypeDataStore.getGetter(this).invoke(bean, null); } diff --git a/client/src/com/vaadin/terminal/gwt/client/metadata/Type.java b/client/src/com/vaadin/terminal/gwt/client/metadata/Type.java index 4fab296441..dfd504983c 100644 --- a/client/src/com/vaadin/terminal/gwt/client/metadata/Type.java +++ b/client/src/com/vaadin/terminal/gwt/client/metadata/Type.java @@ -25,7 +25,7 @@ public class Type { return parameterTypes; } - public Object createInstance() { + public Object createInstance() throws NoDataException { Invoker invoker = TypeDataStore.getConstructor(this); return invoker.invoke(null, null); } @@ -40,7 +40,7 @@ public class Type { public String getSignature() { String string = name; - if (parameterTypes != null) { + if (parameterTypes != null && parameterTypes.length != 0) { string += '<'; for (int i = 0; i < parameterTypes.length; i++) { if (i != 0) { diff --git a/client/src/com/vaadin/terminal/gwt/client/metadata/TypeData.java b/client/src/com/vaadin/terminal/gwt/client/metadata/TypeData.java index 6ee0b4ede0..ec2a8f191c 100644 --- a/client/src/com/vaadin/terminal/gwt/client/metadata/TypeData.java +++ b/client/src/com/vaadin/terminal/gwt/client/metadata/TypeData.java @@ -10,11 +10,11 @@ public class TypeData { return TypeDataStore.getType(type); } - public static Type getType(String identifier) { - return TypeDataStore.getType(getClass(identifier)); + public static Class getClass(String identifier) throws NoDataException { + return TypeDataStore.getClass(identifier); } - public static Class getClass(String identifier) { - return TypeDataStore.getClass(identifier); + public static boolean hasIdentifier(String identifier) { + return TypeDataStore.hasIdentifier(identifier); } } diff --git a/client/src/com/vaadin/terminal/gwt/client/metadata/TypeDataStore.java b/client/src/com/vaadin/terminal/gwt/client/metadata/TypeDataStore.java index 4b224721e6..4b99250465 100644 --- a/client/src/com/vaadin/terminal/gwt/client/metadata/TypeDataStore.java +++ b/client/src/com/vaadin/terminal/gwt/client/metadata/TypeDataStore.java @@ -14,6 +14,7 @@ public class TypeDataStore { private final Map returnTypes = new HashMap(); private final Map invokers = new HashMap(); + private final Map paramTypes = new HashMap(); private final Map getters = new HashMap(); private final Map delegateToWidget = new HashMap(); @@ -26,28 +27,55 @@ public class TypeDataStore { identifiers.put(identifier, type); } - public static Class getClass(String identifier) { - return get().identifiers.get(identifier); + public static Class getClass(String identifier) throws NoDataException { + Class class1 = get().identifiers.get(identifier); + if (class1 == null) { + throw new NoDataException("There is not class for identifier " + + identifier); + } + return class1; } public static Type getType(Class clazz) { return new Type(clazz); } - public static Type getReturnType(Method method) { - return get().returnTypes.get(method); + public static Type getReturnType(Method method) throws NoDataException { + Type type = get().returnTypes.get(method); + if (type == null) { + throw new NoDataException("There is return type for " + + method.getSignature()); + } + return type; } - public static Invoker getInvoker(Method method) { - return get().invokers.get(method); + public static Invoker getInvoker(Method method) throws NoDataException { + Invoker invoker = get().invokers.get(method); + if (invoker == null) { + throw new NoDataException("There is invoker for " + + method.getSignature()); + } + return invoker; } - public static Invoker getConstructor(Type type) { - return get().invokers.get(new Method(type, CONSTRUCTOR_NAME)); + public static Invoker getConstructor(Type type) throws NoDataException { + Invoker invoker = get().invokers + .get(new Method(type, CONSTRUCTOR_NAME)); + if (invoker == null) { + throw new NoDataException("There is constructor for " + + type.getSignature()); + } + return invoker; } - public static Invoker getGetter(Property property) { - return get().getters.get(property); + public static Invoker getGetter(Property property) throws NoDataException { + Invoker getter = get().getters.get(property); + if (getter == null) { + throw new NoDataException("There is getter for " + + property.getSignature()); + } + + return getter; } public static String getDelegateToWidget(Property property) { @@ -59,6 +87,23 @@ public class TypeDataStore { } public void setConstructor(Class type, Invoker constructor) { - invokers.put(new Method(getType(type), CONSTRUCTOR_NAME), constructor); + setInvoker(type, CONSTRUCTOR_NAME, constructor); + } + + public void setInvoker(Class type, String methodName, Invoker invoker) { + invokers.put(new Method(getType(type), methodName), invoker); + } + + public static Type[] getParamTypes(Method method) { + return get().paramTypes.get(method); + } + + public void setParamTypes(Class type, String methodName, + Type[] paramTypes) { + this.paramTypes.put(new Method(getType(type), methodName), paramTypes); + } + + public static boolean hasIdentifier(String identifier) { + return get().identifiers.containsKey(identifier); } } diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/AbstractComponentConnector.java b/client/src/com/vaadin/terminal/gwt/client/ui/AbstractComponentConnector.java index 4f14ee550b..faded22260 100644 --- a/client/src/com/vaadin/terminal/gwt/client/ui/AbstractComponentConnector.java +++ b/client/src/com/vaadin/terminal/gwt/client/ui/AbstractComponentConnector.java @@ -37,6 +37,7 @@ import com.vaadin.terminal.gwt.client.UIDL; import com.vaadin.terminal.gwt.client.Util; import com.vaadin.terminal.gwt.client.VConsole; import com.vaadin.terminal.gwt.client.communication.StateChangeEvent; +import com.vaadin.terminal.gwt.client.metadata.NoDataException; import com.vaadin.terminal.gwt.client.metadata.Type; import com.vaadin.terminal.gwt.client.metadata.TypeData; import com.vaadin.terminal.gwt.client.ui.datefield.PopupDateFieldConnector; @@ -80,9 +81,17 @@ public abstract class AbstractComponentConnector extends AbstractConnector */ protected Widget createWidget() { Type type = TypeData.getType(getClass()); - Type widgetType = type.getMethod("getWidget").getReturnType(); - Object instance = widgetType.createInstance(); - return (Widget) instance; + try { + Type widgetType = type.getMethod("getWidget").getReturnType(); + Object instance = widgetType.createInstance(); + return (Widget) instance; + } catch (NoDataException e) { + throw new IllegalStateException( + "There is no information about the widget for " + + Util.getSimpleName(this) + + ". Did you remember to compile the right widgetset?", + e); + } } /** diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/AbstractConnector.java b/client/src/com/vaadin/terminal/gwt/client/ui/AbstractConnector.java index 9efa7bad0d..b861ade0bf 100644 --- a/client/src/com/vaadin/terminal/gwt/client/ui/AbstractConnector.java +++ b/client/src/com/vaadin/terminal/gwt/client/ui/AbstractConnector.java @@ -33,6 +33,7 @@ import com.vaadin.terminal.gwt.client.Util; import com.vaadin.terminal.gwt.client.VConsole; import com.vaadin.terminal.gwt.client.communication.StateChangeEvent; import com.vaadin.terminal.gwt.client.communication.StateChangeEvent.StateChangeHandler; +import com.vaadin.terminal.gwt.client.metadata.NoDataException; import com.vaadin.terminal.gwt.client.metadata.Type; import com.vaadin.terminal.gwt.client.metadata.TypeData; @@ -268,9 +269,19 @@ public abstract class AbstractConnector implements ServerConnector, */ protected SharedState createState() { Type connectorType = TypeData.getType(getClass()); - Type stateType = connectorType.getMethod("getState").getReturnType(); - Object stateInstance = stateType.createInstance(); - return (SharedState) stateInstance; + try { + Type stateType = connectorType.getMethod("getState") + .getReturnType(); + Object stateInstance = stateType.createInstance(); + return (SharedState) stateInstance; + } catch (NoDataException e) { + throw new IllegalStateException( + "There is no information about the state for " + + Util.getSimpleName(this) + + ". Did you remember to compile the right widgetset?", + e); + } + } @Override -- cgit v1.2.3 From 1e4c5b995f4dc797104b9d92dddd93df75689cb2 Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Tue, 21 Aug 2012 12:35:37 +0300 Subject: Don't generate widget creator if there's a createWidget method (#9371) --- .../gwt/widgetsetutils/metadata/WidgetInitVisitor.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/WidgetInitVisitor.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/WidgetInitVisitor.java index 50ea60a3c6..4d63703151 100644 --- a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/WidgetInitVisitor.java +++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/WidgetInitVisitor.java @@ -8,6 +8,7 @@ import com.google.gwt.core.ext.TreeLogger; import com.google.gwt.core.ext.typeinfo.JClassType; import com.google.gwt.core.ext.typeinfo.JMethod; import com.google.gwt.core.ext.typeinfo.JType; +import com.vaadin.terminal.gwt.client.ui.AbstractComponentConnector; public class WidgetInitVisitor extends TypeVisitor { @@ -15,6 +16,16 @@ public class WidgetInitVisitor extends TypeVisitor { public void visitConnector(TreeLogger logger, JClassType type, ConnectorBundle bundle) { if (ConnectorBundle.isConnectedComponentConnector(type)) { + JClassType createWidgetClass = findInheritedMethod(type, + "createWidget").getEnclosingType(); + boolean createWidgetOverridden = !createWidgetClass + .getQualifiedSourceName() + .equals(AbstractComponentConnector.class.getCanonicalName()); + if (createWidgetOverridden) { + // Don't generate if createWidget is already overridden + return; + } + JMethod getWidget = findInheritedMethod(type, "getWidget"); bundle.setNeedsReturnType(type, getWidget); -- cgit v1.2.3 From b3a2c24e88456d958af9804f940ff9bfc2621fae Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Tue, 21 Aug 2012 14:03:08 +0300 Subject: Make lazy depend on eager as deferred is maybe not yet loaded (#9371) --- .../terminal/gwt/widgetsetutils/ConnectorBundleLoaderFactory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorBundleLoaderFactory.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorBundleLoaderFactory.java index b6a6e0bff4..8cb04d9370 100644 --- a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorBundleLoaderFactory.java +++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorBundleLoaderFactory.java @@ -365,7 +365,7 @@ public class ConnectorBundleLoaderFactory extends Generator { Collection lazy = connectorsByLoadStyle.get(LoadStyle.LAZY); for (JClassType type : lazy) { ConnectorBundle bundle = new ConnectorBundle(type.getName(), - deferredBundle); + eagerBundle); TreeLogger subLogger = logger.branch(Type.TRACE, "Populating " + type.getName() + " bundle"); bundle.processType(subLogger, type); -- cgit v1.2.3 From e345e1820aa0e0fe551cca86d6d28b906beb8937 Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Tue, 21 Aug 2012 16:51:33 +0300 Subject: Use ConnectorBundle for ServerRpc handling (#9371) --- .../ConnectorBundleLoaderFactory.java | 120 +++++++++++++++- .../widgetsetutils/RpcProxyCreatorGenerator.java | 138 ------------------ .../gwt/widgetsetutils/RpcProxyGenerator.java | 159 --------------------- .../widgetsetutils/metadata/ConnectorBundle.java | 43 ++++++ .../widgetsetutils/metadata/ServerRpcVisitor.java | 42 ++++++ client/src/com/vaadin/Vaadin.gwt.xml | 14 -- .../terminal/gwt/client/ApplicationConnection.java | 7 +- .../communication/InitializableServerRpc.java | 39 ----- .../gwt/client/communication/RpcManager.java | 10 +- .../gwt/client/communication/RpcProxy.java | 51 ++++--- .../gwt/client/metadata/InvokationHandler.java | 21 +++ .../terminal/gwt/client/metadata/Method.java | 10 +- .../terminal/gwt/client/metadata/ProxyHandler.java | 23 +++ .../vaadin/terminal/gwt/client/metadata/Type.java | 6 + .../gwt/client/metadata/TypeDataStore.java | 46 +++++- 15 files changed, 346 insertions(+), 383 deletions(-) delete mode 100644 client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/RpcProxyCreatorGenerator.java delete mode 100644 client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/RpcProxyGenerator.java create mode 100644 client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ServerRpcVisitor.java delete mode 100644 client/src/com/vaadin/terminal/gwt/client/communication/InitializableServerRpc.java create mode 100644 client/src/com/vaadin/terminal/gwt/client/metadata/InvokationHandler.java create mode 100644 client/src/com/vaadin/terminal/gwt/client/metadata/ProxyHandler.java diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorBundleLoaderFactory.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorBundleLoaderFactory.java index 8cb04d9370..9f830d4a8d 100644 --- a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorBundleLoaderFactory.java +++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorBundleLoaderFactory.java @@ -28,17 +28,22 @@ import com.google.gwt.core.ext.typeinfo.NotFoundException; 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.shared.annotations.Delayed; import com.vaadin.shared.communication.ClientRpc; import com.vaadin.shared.communication.ServerRpc; import com.vaadin.shared.ui.Connect; import com.vaadin.shared.ui.Connect.LoadStyle; import com.vaadin.terminal.gwt.client.ServerConnector; import com.vaadin.terminal.gwt.client.metadata.ConnectorBundleLoader; +import com.vaadin.terminal.gwt.client.metadata.InvokationHandler; +import com.vaadin.terminal.gwt.client.metadata.ProxyHandler; +import com.vaadin.terminal.gwt.client.metadata.TypeData; import com.vaadin.terminal.gwt.client.metadata.TypeDataBundle; import com.vaadin.terminal.gwt.client.metadata.TypeDataStore; import com.vaadin.terminal.gwt.widgetsetutils.metadata.ClientRpcVisitor; import com.vaadin.terminal.gwt.widgetsetutils.metadata.ConnectorBundle; import com.vaadin.terminal.gwt.widgetsetutils.metadata.ConnectorInitVisitor; +import com.vaadin.terminal.gwt.widgetsetutils.metadata.ServerRpcVisitor; import com.vaadin.terminal.gwt.widgetsetutils.metadata.StateInitVisitor; import com.vaadin.terminal.gwt.widgetsetutils.metadata.TypeVisitor; import com.vaadin.terminal.gwt.widgetsetutils.metadata.WidgetInitVisitor; @@ -166,6 +171,112 @@ public class ConnectorBundleLoaderFactory extends Generator { writeReturnTypes(w, bundle); writeInvokers(w, bundle); writeParamTypes(w, bundle); + writeProxys(w, bundle); + wirteDelayedInfo(w, bundle); + } + + private void wirteDelayedInfo(SourceWriter w, ConnectorBundle bundle) { + Map> needsDelayedInfo = bundle + .getNeedsDelayedInfo(); + Set>> entrySet = needsDelayedInfo + .entrySet(); + for (Entry> entry : entrySet) { + JClassType type = entry.getKey(); + Set methods = entry.getValue(); + for (JMethod method : methods) { + Delayed annotation = method.getAnnotation(Delayed.class); + if (annotation != null) { + w.print("store.setDelayed("); + printClassLiteral(w, type); + w.print(", \""); + w.print(escape(method.getName())); + w.println("\");"); + + if (annotation.lastonly()) { + w.print("store.setLastonly("); + printClassLiteral(w, type); + w.print(", \""); + w.print(escape(method.getName())); + w.println("\");"); + } + } + } + } + } + + private void writeProxys(SourceWriter w, ConnectorBundle bundle) { + Set needsProxySupport = bundle.getNeedsProxySupport(); + for (JClassType type : needsProxySupport) { + w.print("store.setProxyHandler("); + printClassLiteral(w, type); + w.print(", new "); + w.print(ProxyHandler.class.getCanonicalName()); + w.println("() {"); + w.indent(); + + w.println("public Object createProxy(final " + + InvokationHandler.class.getName() + " handler) {"); + w.indent(); + + w.print("return new "); + w.print(type.getQualifiedSourceName()); + w.println("() {"); + w.indent(); + + JMethod[] methods = type.getOverridableMethods(); + for (JMethod method : methods) { + if (method.isAbstract()) { + w.print("public "); + w.print(method.getReturnType().getQualifiedSourceName()); + w.print(" "); + w.print(method.getName()); + w.print("("); + + JType[] types = method.getParameterTypes(); + for (int i = 0; i < types.length; i++) { + if (i != 0) { + w.print(", "); + } + w.print(types[i].getQualifiedSourceName()); + w.print(" p"); + w.print(Integer.toString(i)); + } + + w.println(") {"); + w.indent(); + + if (!method.getReturnType().getQualifiedSourceName() + .equals("void")) { + w.print("return "); + } + + w.print("handler.invoke(this, "); + w.print(TypeData.class.getCanonicalName()); + w.print(".getType("); + printClassLiteral(w, type); + w.print(").getMethod(\""); + w.print(escape(method.getName())); + w.print("\"), new Object [] {"); + for (int i = 0; i < types.length; i++) { + w.print("p" + i + ", "); + } + w.println("});"); + + w.outdent(); + w.println("}"); + } + } + + w.outdent(); + w.println("};"); + + w.outdent(); + w.println("}"); + + w.outdent(); + w.println("});"); + + } } private void writeParamTypes(SourceWriter w, ConnectorBundle bundle) { @@ -176,11 +287,11 @@ public class ConnectorBundleLoaderFactory extends Generator { Set methods = entry.getValue(); for (JMethod method : methods) { - w.println("store.setParamTypes("); + w.print("store.setParamTypes("); printClassLiteral(w, type); w.print(", \""); w.print(escape(method.getName())); - w.println("\", new Type[] {"); + w.print("\", new Type[] {"); for (JType parameter : method.getParameterTypes()) { ConnectorBundleLoaderFactory.writeTypeCreator(w, parameter); @@ -272,7 +383,7 @@ public class ConnectorBundleLoaderFactory extends Generator { for (JClassType type : constructors) { w.print("store.setConstructor("); printClassLiteral(w, type); - w.print(", new Invoker() {"); + w.println(", new Invoker() {"); w.indent(); w.println("public Object invoke(Object target, Object[] params) {"); @@ -380,7 +491,8 @@ public class ConnectorBundleLoaderFactory extends Generator { throws NotFoundException { List visitors = Arrays. asList( new ConnectorInitVisitor(), new StateInitVisitor(), - new WidgetInitVisitor(), new ClientRpcVisitor()); + new WidgetInitVisitor(), new ClientRpcVisitor(), + new ServerRpcVisitor()); for (TypeVisitor typeVisitor : visitors) { typeVisitor.init(oracle); } diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/RpcProxyCreatorGenerator.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/RpcProxyCreatorGenerator.java deleted file mode 100644 index eccc6461c9..0000000000 --- a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/RpcProxyCreatorGenerator.java +++ /dev/null @@ -1,138 +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.terminal.gwt.widgetsetutils; - -import java.io.PrintWriter; -import java.util.Date; - -import com.google.gwt.core.client.GWT; -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.shared.communication.ServerRpc; -import com.vaadin.terminal.gwt.client.ServerConnector; -import com.vaadin.terminal.gwt.client.communication.InitializableServerRpc; -import com.vaadin.terminal.gwt.client.communication.RpcProxy.RpcProxyCreator; - -public class RpcProxyCreatorGenerator extends Generator { - - @Override - public String generate(TreeLogger logger, GeneratorContext ctx, - String requestedClassName) throws UnableToCompleteException { - logger.log(TreeLogger.DEBUG, "Running RpcProxyCreatorGenerator"); - TypeOracle typeOracle = ctx.getTypeOracle(); - assert (typeOracle != null); - - JClassType requestedType = typeOracle.findType(requestedClassName); - if (requestedType == null) { - logger.log(TreeLogger.ERROR, "Unable to find metadata for type '" - + requestedClassName + "'", null); - throw new UnableToCompleteException(); - } - String packageName = requestedType.getPackage().getName(); - String className = requestedType.getSimpleSourceName() + "Impl"; - - createType(logger, ctx, packageName, className); - return packageName + "." + className; - } - - private void createType(TreeLogger logger, GeneratorContext context, - String packageName, String className) { - ClassSourceFileComposerFactory composer = new ClassSourceFileComposerFactory( - packageName, className); - - PrintWriter printWriter = context.tryCreate(logger, - composer.getCreatedPackage(), - composer.getCreatedClassShortName()); - if (printWriter == null) { - // print writer is null if source code has already been generated - return; - } - Date date = new Date(); - TypeOracle typeOracle = context.getTypeOracle(); - - // init composer, set class properties, create source writer - composer.addImport(GWT.class.getCanonicalName()); - composer.addImport(ServerRpc.class.getCanonicalName()); - composer.addImport(ServerConnector.class.getCanonicalName()); - composer.addImport(InitializableServerRpc.class.getCanonicalName()); - composer.addImport(IllegalArgumentException.class.getCanonicalName()); - composer.addImplementedInterface(RpcProxyCreator.class - .getCanonicalName()); - - SourceWriter sourceWriter = composer.createSourceWriter(context, - printWriter); - sourceWriter.indent(); - - sourceWriter - .println("public T create(Class rpcInterface, ServerConnector connector) {"); - sourceWriter.indent(); - - sourceWriter - .println("if (rpcInterface == null || connector == null) {"); - sourceWriter.indent(); - sourceWriter - .println("throw new IllegalArgumentException(\"RpcInterface and/or connector cannot be null\");"); - sourceWriter.outdent(); - - JClassType initializableInterface = typeOracle.findType(ServerRpc.class - .getCanonicalName()); - - for (JClassType rpcType : initializableInterface.getSubtypes()) { - String rpcClassName = rpcType.getQualifiedSourceName(); - if (InitializableServerRpc.class.getCanonicalName().equals( - rpcClassName)) { - // InitializableClientToServerRpc is a special marker interface - // that should not get a generated class - continue; - } - sourceWriter.println("} else if (rpcInterface == " + rpcClassName - + ".class) {"); - sourceWriter.indent(); - sourceWriter.println(rpcClassName + " rpc = GWT.create(" - + rpcClassName + ".class);"); - sourceWriter.println("((" + InitializableServerRpc.class.getName() - + ") rpc).initRpc(connector);"); - sourceWriter.println("return (T) rpc;"); - sourceWriter.outdent(); - } - - sourceWriter.println("} else {"); - sourceWriter.indent(); - sourceWriter - .println("throw new IllegalArgumentException(\"No RpcInterface of type \"+ rpcInterface.getName() + \" was found.\");"); - sourceWriter.outdent(); - // End of if - sourceWriter.println("}"); - // End of method - sourceWriter.println("}"); - - // close generated class - sourceWriter.outdent(); - sourceWriter.println("}"); - // commit generated class - context.commit(logger, printWriter); - logger.log(Type.INFO, composer.getCreatedClassName() + " created in " - + (new Date().getTime() - date.getTime()) / 1000 + "seconds"); - - } -} diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/RpcProxyGenerator.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/RpcProxyGenerator.java deleted file mode 100644 index 6d322c734e..0000000000 --- a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/RpcProxyGenerator.java +++ /dev/null @@ -1,159 +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.terminal.gwt.widgetsetutils; - -import java.io.PrintWriter; - -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.JMethod; -import com.google.gwt.core.ext.typeinfo.JParameter; -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.shared.annotations.Delayed; -import com.vaadin.shared.communication.MethodInvocation; -import com.vaadin.shared.communication.ServerRpc; -import com.vaadin.terminal.gwt.client.ApplicationConnection; -import com.vaadin.terminal.gwt.client.ServerConnector; -import com.vaadin.terminal.gwt.client.communication.InitializableServerRpc; - -/** - * GWT generator that creates client side proxy classes for making RPC calls - * from the client to the server. - * - * GWT.create() calls for interfaces extending {@link ServerRpc} are affected, - * and a proxy implementation is created. Note that the init(...) method of the - * proxy must be called before the proxy is used. - * - * @since 7.0 - */ -public class RpcProxyGenerator extends Generator { - @Override - public String generate(TreeLogger logger, GeneratorContext ctx, - String requestedClassName) throws UnableToCompleteException { - logger.log(TreeLogger.DEBUG, "Running RpcProxyGenerator", null); - - TypeOracle typeOracle = ctx.getTypeOracle(); - assert (typeOracle != null); - - JClassType requestedType = typeOracle.findType(requestedClassName); - if (requestedType == null) { - logger.log(TreeLogger.ERROR, "Unable to find metadata for type '" - + requestedClassName + "'", null); - throw new UnableToCompleteException(); - } - - String generatedClassName = "ServerRpc_" - + requestedType.getName().replaceAll("[$.]", "_"); - - JClassType initializableInterface = typeOracle - .findType(InitializableServerRpc.class.getCanonicalName()); - - ClassSourceFileComposerFactory composer = new ClassSourceFileComposerFactory( - requestedType.getPackage().getName(), generatedClassName); - composer.addImplementedInterface(requestedType.getQualifiedSourceName()); - composer.addImplementedInterface(initializableInterface - .getQualifiedSourceName()); - composer.addImport(MethodInvocation.class.getCanonicalName()); - - PrintWriter printWriter = ctx.tryCreate(logger, - composer.getCreatedPackage(), - composer.getCreatedClassShortName()); - if (printWriter != null) { - logger.log(Type.INFO, "Generating client proxy for RPC interface '" - + requestedType.getQualifiedSourceName() + "'"); - SourceWriter writer = composer.createSourceWriter(ctx, printWriter); - - // constructor - writer.println("public " + generatedClassName + "() {}"); - - // initialization etc. - writeCommonFieldsAndMethods(logger, writer, typeOracle); - - // actual proxy methods forwarding calls to the server - writeRemoteProxyMethods(logger, writer, typeOracle, requestedType, - requestedType.isClassOrInterface().getInheritableMethods()); - - // End of class - writer.outdent(); - writer.println("}"); - - ctx.commit(logger, printWriter); - } - - return composer.getCreatedClassName(); - } - - private void writeCommonFieldsAndMethods(TreeLogger logger, - SourceWriter writer, TypeOracle typeOracle) { - JClassType applicationConnectionClass = typeOracle - .findType(ApplicationConnection.class.getCanonicalName()); - - // fields - writer.println("private " + ServerConnector.class.getName() - + " connector;"); - - // init method from the RPC interface - writer.println("public void initRpc(" + ServerConnector.class.getName() - + " connector) {"); - writer.indent(); - writer.println("this.connector = connector;"); - writer.outdent(); - writer.println("}"); - } - - private static void writeRemoteProxyMethods(TreeLogger logger, - SourceWriter writer, TypeOracle typeOracle, - JClassType requestedType, JMethod[] methods) { - for (JMethod m : methods) { - writer.print(m.getReadableDeclaration(false, false, false, false, - true)); - writer.println(" {"); - writer.indent(); - - Delayed delayedAnnotation = m.getAnnotation(Delayed.class); - boolean delayed = delayedAnnotation != null; - boolean lastonly = delayed && delayedAnnotation.lastonly(); - - writer.print("this.connector.getConnection().addMethodInvocationToQueue(new MethodInvocation(this.connector.getConnectorId(), \"" - + requestedType.getQualifiedBinaryName() + "\", \""); - writer.print(m.getName()); - writer.print("\", new Object[] {"); - // new Object[] { ... } for parameters - autoboxing etc. by the - // compiler - JParameter[] parameters = m.getParameters(); - boolean first = true; - for (JParameter p : parameters) { - if (!first) { - writer.print(", "); - } - first = false; - - writer.print(p.getName()); - } - writer.println("}), " + delayed + ", " + lastonly + ");"); - - writer.outdent(); - writer.println("}"); - } - } -} diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ConnectorBundle.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ConnectorBundle.java index 3302fbc4fa..e93c72aa2f 100644 --- a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ConnectorBundle.java +++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ConnectorBundle.java @@ -36,8 +36,11 @@ public class ConnectorBundle { private final Map> needsReturnType = new HashMap>(); private final Collection visitors; + + private final Set needsProxySupport = new HashSet(); private final Map> needsInvoker = new HashMap>(); private final Map> needsParamTypes = new HashMap>(); + private final Map> needsDelayedInfo = new HashMap>(); private ConnectorBundle(String name, ConnectorBundle previousBundle, Collection visitors) { @@ -268,4 +271,44 @@ public class ConnectorBundle { public Map> getNeedsParamTypes() { return Collections.unmodifiableMap(needsParamTypes); } + + public void setNeedsProxySupport(JClassType type) { + if (!isNeedsProxySupport(type)) { + ensureVisited(type); + needsProxySupport.add(type); + } + } + + private boolean isNeedsProxySupport(JClassType type) { + if (needsProxySupport.contains(type)) { + return true; + } else { + return previousBundle != null + && previousBundle.isNeedsProxySupport(type); + } + } + + public Set getNeedsProxySupport() { + return Collections.unmodifiableSet(needsProxySupport); + } + + public void setNeedsDelayedInfo(JClassType type, JMethod method) { + if (!isNeedsDelayedInfo(type, method)) { + ensureVisited(type); + addMapping(needsDelayedInfo, type, method); + } + } + + private boolean isNeedsDelayedInfo(JClassType type, JMethod method) { + if (hasMapping(needsDelayedInfo, type, method)) { + return true; + } else { + return previousBundle != null + && previousBundle.isNeedsDelayedInfo(type, method); + } + } + + public Map> getNeedsDelayedInfo() { + return Collections.unmodifiableMap(needsDelayedInfo); + } } \ No newline at end of file diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ServerRpcVisitor.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ServerRpcVisitor.java new file mode 100644 index 0000000000..5505c70dc3 --- /dev/null +++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ServerRpcVisitor.java @@ -0,0 +1,42 @@ +/* + * 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.terminal.gwt.widgetsetutils.metadata; + +import java.util.Set; + +import com.google.gwt.core.ext.TreeLogger; +import com.google.gwt.core.ext.typeinfo.JClassType; +import com.google.gwt.core.ext.typeinfo.JMethod; + +public class ServerRpcVisitor extends TypeVisitor { + @Override + public void visitServerRpc(TreeLogger logger, JClassType type, + ConnectorBundle bundle) { + bundle.setNeedsProxySupport(type); + + Set superTypes = type + .getFlattenedSupertypeHierarchy(); + for (JClassType subType : superTypes) { + if (subType.isInterface() != null) { + JMethod[] methods = subType.getMethods(); + for (JMethod method : methods) { + bundle.setNeedsDelayedInfo(type, method); + } + } + } + } +} diff --git a/client/src/com/vaadin/Vaadin.gwt.xml b/client/src/com/vaadin/Vaadin.gwt.xml index e25c812e5b..fe9643232e 100644 --- a/client/src/com/vaadin/Vaadin.gwt.xml +++ b/client/src/com/vaadin/Vaadin.gwt.xml @@ -41,20 +41,6 @@ class="com.vaadin.terminal.gwt.client.ui.dd.VAcceptCriterionFactory" /> - - - - - - - - - - diff --git a/client/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java b/client/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java index 8ba8f0afab..9b58eb1295 100644 --- a/client/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java +++ b/client/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java @@ -208,6 +208,9 @@ public class ApplicationConnection { } public ApplicationConnection() { + // Assuming Root data is eagerly loaded + ConnectorBundleLoader.get().loadBundle( + ConnectorBundleLoader.EAGER_BUNDLE_NAME, null); rootConnector = GWT.create(RootConnector.class); rpcManager = GWT.create(RpcManager.class); layoutManager = GWT.create(LayoutManager.class); @@ -241,10 +244,6 @@ public class ApplicationConnection { initializeClientHooks(); - // Assuming Root data is eagerly loaded - ConnectorBundleLoader.get().loadBundle( - ConnectorBundleLoader.EAGER_BUNDLE_NAME, null); - rootConnector.init(cnf.getRootPanelId(), this); showLoadingIndicator(); } diff --git a/client/src/com/vaadin/terminal/gwt/client/communication/InitializableServerRpc.java b/client/src/com/vaadin/terminal/gwt/client/communication/InitializableServerRpc.java deleted file mode 100644 index 65887bf62e..0000000000 --- a/client/src/com/vaadin/terminal/gwt/client/communication/InitializableServerRpc.java +++ /dev/null @@ -1,39 +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.terminal.gwt.client.communication; - -import com.vaadin.shared.communication.ServerRpc; -import com.vaadin.terminal.gwt.client.ServerConnector; - -/** - * Initialization support for client to server RPC interfaces. - * - * This is in a separate interface used by the GWT generator class. The init - * method is not in {@link ServerRpc} because then also server side proxies - * would have to implement the initialization method. - * - * @since 7.0 - */ -public interface InitializableServerRpc extends ServerRpc { - /** - * Associates the RPC proxy with a connector. Called by generated code. - * Should never be called manually. - * - * @param connector - * The connector the ServerRPC instance is assigned to. - */ - public void initRpc(ServerConnector connector); -} \ No newline at end of file diff --git a/client/src/com/vaadin/terminal/gwt/client/communication/RpcManager.java b/client/src/com/vaadin/terminal/gwt/client/communication/RpcManager.java index 45939eb54e..5b9bcff6a4 100644 --- a/client/src/com/vaadin/terminal/gwt/client/communication/RpcManager.java +++ b/client/src/com/vaadin/terminal/gwt/client/communication/RpcManager.java @@ -76,14 +76,14 @@ public class RpcManager { public Type[] getParameterTypes(MethodInvocation invocation) { Method method = getMethod(invocation); - Type[] parameterTypes = method.getParameterTypes(); - if (parameterTypes == null) { + try { + Type[] parameterTypes = method.getParameterTypes(); + return parameterTypes; + } catch (NoDataException e) { throw new IllegalStateException("There is no information about " + method.getSignature() - + ". Did you remember to compile the right widgetset?"); - + + ". Did you remember to compile the right widgetset?", e); } - return parameterTypes; } public void parseAndApplyInvocation(JSONArray rpcCall, diff --git a/client/src/com/vaadin/terminal/gwt/client/communication/RpcProxy.java b/client/src/com/vaadin/terminal/gwt/client/communication/RpcProxy.java index 226594adc6..e9dc6ab7fd 100644 --- a/client/src/com/vaadin/terminal/gwt/client/communication/RpcProxy.java +++ b/client/src/com/vaadin/terminal/gwt/client/communication/RpcProxy.java @@ -15,9 +15,13 @@ */ package com.vaadin.terminal.gwt.client.communication; -import com.google.gwt.core.client.GWT; +import com.vaadin.shared.communication.MethodInvocation; import com.vaadin.shared.communication.ServerRpc; import com.vaadin.terminal.gwt.client.ServerConnector; +import com.vaadin.terminal.gwt.client.metadata.InvokationHandler; +import com.vaadin.terminal.gwt.client.metadata.Method; +import com.vaadin.terminal.gwt.client.metadata.NoDataException; +import com.vaadin.terminal.gwt.client.metadata.TypeData; /** * Class for creating proxy instances for Client to Server RPC. @@ -26,25 +30,38 @@ import com.vaadin.terminal.gwt.client.ServerConnector; */ public class RpcProxy { - private static RpcProxyCreator impl = GWT.create(RpcProxyCreator.class); - - /** - * Create a proxy class for the given Rpc interface and assign it to the - * given connector. - * - * @param rpcInterface - * The rpc interface to construct a proxy for - * @param connector - * The connector this proxy is connected to - * @return A proxy class used for calling Rpc methods. - */ public static T create(Class rpcInterface, ServerConnector connector) { - return impl.create(rpcInterface, connector); + try { + return (T) TypeData.getType(rpcInterface).createProxy( + new RpcInvokationHandler(rpcInterface, connector)); + } catch (NoDataException e) { + throw new IllegalStateException("There is no information about " + + rpcInterface + + ". Did you forget to compile the widgetset?"); + } } - public interface RpcProxyCreator { - T create(Class rpcInterface, - ServerConnector connector); + private static final class RpcInvokationHandler implements + InvokationHandler { + private final Class rpcInterface; + private final ServerConnector connector; + + private RpcInvokationHandler(Class rpcInterface, + ServerConnector connector) { + this.rpcInterface = rpcInterface; + this.connector = connector; + } + + @Override + public Object invoke(Object target, Method method, Object[] params) { + MethodInvocation invocation = new MethodInvocation( + connector.getConnectorId(), rpcInterface.getName(), + method.getName(), params); + connector.getConnection().addMethodInvocationToQueue(invocation, + method.isDelayed(), method.isLastonly()); + // No RPC iface should have a return value + return null; + } } } diff --git a/client/src/com/vaadin/terminal/gwt/client/metadata/InvokationHandler.java b/client/src/com/vaadin/terminal/gwt/client/metadata/InvokationHandler.java new file mode 100644 index 0000000000..2b1153ad97 --- /dev/null +++ b/client/src/com/vaadin/terminal/gwt/client/metadata/InvokationHandler.java @@ -0,0 +1,21 @@ +/* + * 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.terminal.gwt.client.metadata; + +public interface InvokationHandler { + public Object invoke(Object target, Method method, Object[] params); +} diff --git a/client/src/com/vaadin/terminal/gwt/client/metadata/Method.java b/client/src/com/vaadin/terminal/gwt/client/metadata/Method.java index 588e736da3..527e8a29d2 100644 --- a/client/src/com/vaadin/terminal/gwt/client/metadata/Method.java +++ b/client/src/com/vaadin/terminal/gwt/client/metadata/Method.java @@ -56,8 +56,16 @@ public class Method { return getSignature().hashCode(); } - public Type[] getParameterTypes() { + public Type[] getParameterTypes() throws NoDataException { return TypeDataStore.getParamTypes(this); } + public boolean isDelayed() { + return TypeDataStore.isDelayed(this); + } + + public boolean isLastonly() { + return TypeDataStore.isLastonly(this); + } + } diff --git a/client/src/com/vaadin/terminal/gwt/client/metadata/ProxyHandler.java b/client/src/com/vaadin/terminal/gwt/client/metadata/ProxyHandler.java new file mode 100644 index 0000000000..cc8168a8ff --- /dev/null +++ b/client/src/com/vaadin/terminal/gwt/client/metadata/ProxyHandler.java @@ -0,0 +1,23 @@ +/* + * 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.terminal.gwt.client.metadata; + +public interface ProxyHandler { + + Object createProxy(InvokationHandler invokationHandler); + +} diff --git a/client/src/com/vaadin/terminal/gwt/client/metadata/Type.java b/client/src/com/vaadin/terminal/gwt/client/metadata/Type.java index dfd504983c..2dc5182845 100644 --- a/client/src/com/vaadin/terminal/gwt/client/metadata/Type.java +++ b/client/src/com/vaadin/terminal/gwt/client/metadata/Type.java @@ -76,4 +76,10 @@ public class Type { return getSignature().hashCode(); } + public Object createProxy(InvokationHandler invokationHandler) + throws NoDataException { + return TypeDataStore.get().getProxyHandler(this) + .createProxy(invokationHandler); + } + } diff --git a/client/src/com/vaadin/terminal/gwt/client/metadata/TypeDataStore.java b/client/src/com/vaadin/terminal/gwt/client/metadata/TypeDataStore.java index 4b99250465..f056e46d2d 100644 --- a/client/src/com/vaadin/terminal/gwt/client/metadata/TypeDataStore.java +++ b/client/src/com/vaadin/terminal/gwt/client/metadata/TypeDataStore.java @@ -5,13 +5,20 @@ package com.vaadin.terminal.gwt.client.metadata; import java.util.HashMap; +import java.util.HashSet; import java.util.Map; +import java.util.Set; public class TypeDataStore { private static final String CONSTRUCTOR_NAME = "!new"; private final Map> identifiers = new HashMap>(); + private final Map proxyHandlers = new HashMap(); + + private final Set delayedMethods = new HashSet(); + private final Set lastonlyMethods = new HashSet(); + private final Map returnTypes = new HashMap(); private final Map invokers = new HashMap(); private final Map paramTypes = new HashMap(); @@ -94,8 +101,13 @@ public class TypeDataStore { invokers.put(new Method(getType(type), methodName), invoker); } - public static Type[] getParamTypes(Method method) { - return get().paramTypes.get(method); + public static Type[] getParamTypes(Method method) throws NoDataException { + Type[] types = get().paramTypes.get(method); + if (types == null) { + throw new NoDataException("There are no parameter type data for " + + method.getSignature()); + } + return types; } public void setParamTypes(Class type, String methodName, @@ -106,4 +118,34 @@ public class TypeDataStore { public static boolean hasIdentifier(String identifier) { return get().identifiers.containsKey(identifier); } + + public static ProxyHandler getProxyHandler(Type type) + throws NoDataException { + ProxyHandler proxyHandler = get().proxyHandlers.get(type); + if (proxyHandler == null) { + throw new NoDataException("No proxy handler for " + + type.getSignature()); + } + return proxyHandler; + } + + public void setProxyHandler(Class type, ProxyHandler proxyHandler) { + proxyHandlers.put(getType(type), proxyHandler); + } + + public static boolean isDelayed(Method method) { + return get().delayedMethods.contains(method); + } + + public void setDelayed(Class type, String methodName) { + delayedMethods.add(getType(type).getMethod(methodName)); + } + + public static boolean isLastonly(Method method) { + return get().lastonlyMethods.contains(method); + } + + public void setLastonly(Class clazz, String methodName) { + lastonlyMethods.add(getType(clazz).getMethod(methodName)); + } } -- cgit v1.2.3 From 02878bd07a38dc69fe415c7f60238817d2a7c434 Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Wed, 22 Aug 2012 17:07:22 +0300 Subject: Use ConnectorBundle for JSON encoding and decoding (#9371) --- .../ConnectorBundleLoaderFactory.java | 163 ++++++- .../gwt/widgetsetutils/SerializerGenerator.java | 484 --------------------- .../gwt/widgetsetutils/SerializerMapGenerator.java | 377 ---------------- .../widgetsetutils/metadata/ArraySerializer.java | 90 ++++ .../widgetsetutils/metadata/ClientRpcVisitor.java | 6 + .../widgetsetutils/metadata/ConnectorBundle.java | 345 +++++++++++++-- .../widgetsetutils/metadata/CustomSerializer.java | 43 ++ .../widgetsetutils/metadata/EnumSerializer.java | 58 +++ .../metadata/GeneratedSerializer.java | 26 ++ .../widgetsetutils/metadata/JsonSerializer.java | 88 ++++ .../widgetsetutils/metadata/MethodProperty.java | 124 ++++++ .../gwt/widgetsetutils/metadata/Property.java | 84 ++++ .../widgetsetutils/metadata/ServerRpcVisitor.java | 6 + .../widgetsetutils/metadata/StateInitVisitor.java | 2 + client/src/com/vaadin/Vaadin.gwt.xml | 8 - .../terminal/gwt/client/ApplicationConnection.java | 8 - .../gwt/client/communication/JsonDecoder.java | 48 +- .../gwt/client/communication/JsonEncoder.java | 34 +- .../gwt/client/communication/SerializerMap.java | 44 -- .../terminal/gwt/client/communication/Type.java | 52 --- .../terminal/gwt/client/metadata/Invoker.java | 2 +- .../terminal/gwt/client/metadata/Property.java | 27 +- .../vaadin/terminal/gwt/client/metadata/Type.java | 14 +- .../gwt/client/metadata/TypeDataStore.java | 69 +++ 24 files changed, 1154 insertions(+), 1048 deletions(-) delete mode 100644 client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/SerializerGenerator.java delete mode 100644 client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/SerializerMapGenerator.java create mode 100644 client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ArraySerializer.java create mode 100644 client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/CustomSerializer.java create mode 100644 client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/EnumSerializer.java create mode 100644 client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/GeneratedSerializer.java create mode 100644 client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/JsonSerializer.java create mode 100644 client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/MethodProperty.java create mode 100644 client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/Property.java delete mode 100644 client/src/com/vaadin/terminal/gwt/client/communication/SerializerMap.java delete mode 100644 client/src/com/vaadin/terminal/gwt/client/communication/Type.java diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorBundleLoaderFactory.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorBundleLoaderFactory.java index 9f830d4a8d..9a5b83f460 100644 --- a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorBundleLoaderFactory.java +++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorBundleLoaderFactory.java @@ -9,6 +9,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -43,6 +44,8 @@ import com.vaadin.terminal.gwt.client.metadata.TypeDataStore; import com.vaadin.terminal.gwt.widgetsetutils.metadata.ClientRpcVisitor; import com.vaadin.terminal.gwt.widgetsetutils.metadata.ConnectorBundle; import com.vaadin.terminal.gwt.widgetsetutils.metadata.ConnectorInitVisitor; +import com.vaadin.terminal.gwt.widgetsetutils.metadata.GeneratedSerializer; +import com.vaadin.terminal.gwt.widgetsetutils.metadata.Property; import com.vaadin.terminal.gwt.widgetsetutils.metadata.ServerRpcVisitor; import com.vaadin.terminal.gwt.widgetsetutils.metadata.StateInitVisitor; import com.vaadin.terminal.gwt.widgetsetutils.metadata.TypeVisitor; @@ -134,7 +137,7 @@ public class ConnectorBundleLoaderFactory extends Generator { w.println("public void load() {"); w.indent(); - printBundleData(w, bundle); + printBundleData(logger, w, bundle); // Close load method w.outdent(); @@ -165,7 +168,8 @@ public class ConnectorBundleLoaderFactory extends Generator { w.commit(logger); } - private void printBundleData(SourceWriter w, ConnectorBundle bundle) { + private void printBundleData(TreeLogger logger, SourceWriter w, + ConnectorBundle bundle) throws UnableToCompleteException { writeIdentifiers(w, bundle); writeGwtConstructors(w, bundle); writeReturnTypes(w, bundle); @@ -173,6 +177,133 @@ public class ConnectorBundleLoaderFactory extends Generator { writeParamTypes(w, bundle); writeProxys(w, bundle); wirteDelayedInfo(w, bundle); + writeProperites(logger, w, bundle); + writePropertyTypes(w, bundle); + writeSetters(logger, w, bundle); + writeGetters(logger, w, bundle); + writeSerializers(logger, w, bundle); + } + + private void writeSerializers(TreeLogger logger, SourceWriter w, + ConnectorBundle bundle) throws UnableToCompleteException { + Map serializers = bundle.getSerializers(); + for (Entry entry : serializers.entrySet()) { + JType type = entry.getKey(); + GeneratedSerializer serializer = entry.getValue(); + + w.print("store.setSerializerFactory("); + writeClassLiteral(w, type); + w.print(", "); + w.println("new Invoker() {"); + w.indent(); + + w.println("public Object invoke(Object target, Object[] params) {"); + w.indent(); + + serializer.writeSerializerInstantiator(logger, w); + + w.outdent(); + w.println("}"); + + w.outdent(); + w.print("}"); + w.println(");"); + } + } + + private void writeGetters(TreeLogger logger, SourceWriter w, + ConnectorBundle bundle) { + Set properties = bundle.getNeedsSetter(); + for (Property property : properties) { + w.print("store.setGetter("); + writeClassLiteral(w, property.getBeanType()); + w.print(", \""); + w.print(escape(property.getName())); + w.print("\", new Invoker() {"); + w.indent(); + + w.println("public Object invoke(Object bean, Object[] params) {"); + w.indent(); + + property.writeGetterBody(logger, w, "bean"); + w.println(); + + w.outdent(); + w.println("}"); + + w.outdent(); + w.println("});"); + } + } + + private void writeSetters(TreeLogger logger, SourceWriter w, + ConnectorBundle bundle) { + Set properties = bundle.getNeedsSetter(); + for (Property property : properties) { + w.print("store.setSetter("); + writeClassLiteral(w, property.getBeanType()); + w.print(", \""); + w.print(escape(property.getName())); + w.println("\", new Invoker() {"); + w.indent(); + + w.println("public Object invoke(Object bean, Object[] params) {"); + w.indent(); + + property.writeSetterBody(logger, w, "bean", "params[0]"); + + w.println("return null;"); + + w.outdent(); + w.println("}"); + + w.outdent(); + w.println("});"); + } + } + + private void writePropertyTypes(SourceWriter w, ConnectorBundle bundle) { + Set properties = bundle.getNeedsType(); + for (Property property : properties) { + w.print("store.setPropertyType("); + writeClassLiteral(w, property.getBeanType()); + w.print(", \""); + w.print(escape(property.getName())); + w.print("\", "); + writeTypeCreator(w, property.getPropertyType()); + w.println(");"); + } + } + + private void writeProperites(TreeLogger logger, SourceWriter w, + ConnectorBundle bundle) throws UnableToCompleteException { + Set needsPropertyListing = bundle.getNeedsPropertyListing(); + for (JClassType type : needsPropertyListing) { + w.print("store.setProperties("); + writeClassLiteral(w, type); + w.print(", new String[] {"); + + Set usedPropertyNames = new HashSet(); + Collection properties = bundle.getProperties(type); + for (Property property : properties) { + String name = property.getName(); + if (!usedPropertyNames.add(name)) { + logger.log( + Type.ERROR, + type.getQualifiedSourceName() + + " has multiple properties with the name " + + name + + ". This can happen if there are multiple setters with identical names exect casing."); + throw new UnableToCompleteException(); + } + + w.print("\""); + w.print(name); + w.print("\", "); + } + + w.println("});"); + } } private void wirteDelayedInfo(SourceWriter w, ConnectorBundle bundle) { @@ -187,14 +318,14 @@ public class ConnectorBundleLoaderFactory extends Generator { Delayed annotation = method.getAnnotation(Delayed.class); if (annotation != null) { w.print("store.setDelayed("); - printClassLiteral(w, type); + writeClassLiteral(w, type); w.print(", \""); w.print(escape(method.getName())); w.println("\");"); if (annotation.lastonly()) { w.print("store.setLastonly("); - printClassLiteral(w, type); + writeClassLiteral(w, type); w.print(", \""); w.print(escape(method.getName())); w.println("\");"); @@ -208,7 +339,7 @@ public class ConnectorBundleLoaderFactory extends Generator { Set needsProxySupport = bundle.getNeedsProxySupport(); for (JClassType type : needsProxySupport) { w.print("store.setProxyHandler("); - printClassLiteral(w, type); + writeClassLiteral(w, type); w.print(", new "); w.print(ProxyHandler.class.getCanonicalName()); w.println("() {"); @@ -253,7 +384,7 @@ public class ConnectorBundleLoaderFactory extends Generator { w.print("handler.invoke(this, "); w.print(TypeData.class.getCanonicalName()); w.print(".getType("); - printClassLiteral(w, type); + writeClassLiteral(w, type); w.print(").getMethod(\""); w.print(escape(method.getName())); w.print("\"), new Object [] {"); @@ -288,7 +419,7 @@ public class ConnectorBundleLoaderFactory extends Generator { Set methods = entry.getValue(); for (JMethod method : methods) { w.print("store.setParamTypes("); - printClassLiteral(w, type); + writeClassLiteral(w, type); w.print(", \""); w.print(escape(method.getName())); w.print("\", new Type[] {"); @@ -312,7 +443,7 @@ public class ConnectorBundleLoaderFactory extends Generator { Set methods = entry.getValue(); for (JMethod method : methods) { w.print("store.setInvoker("); - printClassLiteral(w, type); + writeClassLiteral(w, type); w.print(", \""); w.print(escape(method.getName())); w.println("\", new Invoker() {"); @@ -368,7 +499,7 @@ public class ConnectorBundleLoaderFactory extends Generator { // setReturnType(Class type, String methodName, Type // returnType) w.print("store.setReturnType("); - printClassLiteral(w, type); + writeClassLiteral(w, type); w.print(", \""); w.print(escape(method.getName())); w.print("\", "); @@ -382,7 +513,7 @@ public class ConnectorBundleLoaderFactory extends Generator { Set constructors = bundle.getGwtConstructors(); for (JClassType type : constructors) { w.print("store.setConstructor("); - printClassLiteral(w, type); + writeClassLiteral(w, type); w.println(", new Invoker() {"); w.indent(); @@ -392,7 +523,7 @@ public class ConnectorBundleLoaderFactory extends Generator { w.print("return "); w.print(GWT.class.getName()); w.print(".create("); - printClassLiteral(w, type); + writeClassLiteral(w, type); w.println(");"); w.outdent(); @@ -403,7 +534,7 @@ public class ConnectorBundleLoaderFactory extends Generator { } } - private void printClassLiteral(SourceWriter w, JClassType type) { + public static void writeClassLiteral(SourceWriter w, JType type) { w.print(type.getQualifiedSourceName()); w.print(".class"); } @@ -417,7 +548,7 @@ public class ConnectorBundleLoaderFactory extends Generator { w.print("store.setClass(\""); w.print(escape(id)); w.print("\", "); - printClassLiteral(w, type); + writeClassLiteral(w, type); w.println(");"); } } @@ -450,7 +581,7 @@ public class ConnectorBundleLoaderFactory extends Generator { Collection visitors = getVisitors(typeOracle); ConnectorBundle eagerBundle = new ConnectorBundle( - ConnectorBundleLoader.EAGER_BUNDLE_NAME, visitors); + ConnectorBundleLoader.EAGER_BUNDLE_NAME, visitors, typeOracle); TreeLogger eagerLogger = logger.branch(Type.TRACE, "Populating eager bundle"); @@ -515,9 +646,9 @@ public class ConnectorBundleLoaderFactory extends Generator { public static void writeTypeCreator(SourceWriter sourceWriter, JType type) { String typeName = ConnectorBundleLoaderFactory.getBoxedTypeName(type); - sourceWriter.print("new Type(\"" + typeName + "\", "); JParameterizedType parameterized = type.isParameterized(); if (parameterized != null) { + sourceWriter.print("new Type(\"" + typeName + "\", "); sourceWriter.print("new Type[] {"); JClassType[] typeArgs = parameterized.getTypeArgs(); for (JClassType jClassType : typeArgs) { @@ -526,7 +657,7 @@ public class ConnectorBundleLoaderFactory extends Generator { } sourceWriter.print("}"); } else { - sourceWriter.print("null"); + sourceWriter.print("new Type(" + typeName + ".class"); } sourceWriter.print(")"); } diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/SerializerGenerator.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/SerializerGenerator.java deleted file mode 100644 index 83e1c17881..0000000000 --- a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/SerializerGenerator.java +++ /dev/null @@ -1,484 +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.terminal.gwt.widgetsetutils; - -import java.io.PrintWriter; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; - -import com.google.gwt.core.client.GWT; -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.JArrayType; -import com.google.gwt.core.ext.typeinfo.JClassType; -import com.google.gwt.core.ext.typeinfo.JEnumConstant; -import com.google.gwt.core.ext.typeinfo.JEnumType; -import com.google.gwt.core.ext.typeinfo.JMethod; -import com.google.gwt.core.ext.typeinfo.JPackage; -import com.google.gwt.core.ext.typeinfo.JPrimitiveType; -import com.google.gwt.core.ext.typeinfo.JType; -import com.google.gwt.core.ext.typeinfo.TypeOracleException; -import com.google.gwt.json.client.JSONArray; -import com.google.gwt.json.client.JSONObject; -import com.google.gwt.json.client.JSONString; -import com.google.gwt.json.client.JSONValue; -import com.google.gwt.user.rebind.ClassSourceFileComposerFactory; -import com.google.gwt.user.rebind.SourceWriter; -import com.vaadin.terminal.gwt.client.ApplicationConnection; -import com.vaadin.terminal.gwt.client.communication.DiffJSONSerializer; -import com.vaadin.terminal.gwt.client.communication.JSONSerializer; -import com.vaadin.terminal.gwt.client.communication.JsonDecoder; -import com.vaadin.terminal.gwt.client.communication.JsonEncoder; -import com.vaadin.terminal.gwt.client.communication.SerializerMap; - -/** - * GWT generator for creating serializer classes for custom classes sent from - * server to client. - * - * Only fields with a correspondingly named setter are deserialized. - * - * @since 7.0 - */ -public class SerializerGenerator extends Generator { - - private static final String SUBTYPE_SEPARATOR = "___"; - - @Override - public String generate(TreeLogger logger, GeneratorContext context, - String typeName) throws UnableToCompleteException { - JClassType type; - try { - type = (JClassType) context.getTypeOracle().parse(typeName); - } catch (TypeOracleException e1) { - logger.log(Type.ERROR, "Could not find type " + typeName, e1); - throw new UnableToCompleteException(); - } - String serializerClassName = getSerializerSimpleClassName(type); - try { - // Generate class source code - generateClass(logger, context, type, - getSerializerPackageName(type), serializerClassName); - } catch (Exception e) { - logger.log(TreeLogger.ERROR, "SerializerGenerator failed for " - + type.getQualifiedSourceName(), e); - throw new UnableToCompleteException(); - } - - // return the fully qualifed name of the class generated - return getFullyQualifiedSerializerClassName(type); - } - - /** - * Generate source code for a VaadinSerializer implementation. - * - * @param logger - * Logger object - * @param context - * Generator context - * @param type - * @param beanTypeName - * bean type for which the serializer is to be generated - * @param beanSerializerTypeName - * name of the serializer class to generate - * @throws UnableToCompleteException - */ - private void generateClass(TreeLogger logger, GeneratorContext context, - JClassType type, String serializerPackageName, - String serializerClassName) throws UnableToCompleteException { - // get print writer that receives the source code - PrintWriter printWriter = null; - printWriter = context.tryCreate(logger, serializerPackageName, - serializerClassName); - - // print writer if null, source code has ALREADY been generated - if (printWriter == null) { - return; - } - boolean isEnum = (type.isEnum() != null); - boolean isArray = (type.isArray() != null); - - String qualifiedSourceName = type.getQualifiedSourceName(); - logger.log(Type.DEBUG, "Processing serializable type " - + qualifiedSourceName + "..."); - - // init composer, set class properties, create source writer - ClassSourceFileComposerFactory composer = null; - composer = new ClassSourceFileComposerFactory(serializerPackageName, - serializerClassName); - composer.addImport(GWT.class.getName()); - composer.addImport(JSONValue.class.getName()); - composer.addImport(com.vaadin.terminal.gwt.client.metadata.Type.class - .getName()); - // composer.addImport(JSONObject.class.getName()); - // composer.addImport(VPaintableMap.class.getName()); - composer.addImport(JsonDecoder.class.getName()); - // composer.addImport(VaadinSerializer.class.getName()); - - if (isEnum || isArray) { - composer.addImplementedInterface(JSONSerializer.class.getName() - + "<" + qualifiedSourceName + ">"); - } else { - composer.addImplementedInterface(DiffJSONSerializer.class.getName() - + "<" + qualifiedSourceName + ">"); - } - - SourceWriter sourceWriter = composer.createSourceWriter(context, - printWriter); - sourceWriter.indent(); - - // Serializer - - // public JSONValue serialize(Object value, - // ApplicationConnection connection) { - sourceWriter.println("public " + JSONValue.class.getName() - + " serialize(" + qualifiedSourceName + " value, " - + ApplicationConnection.class.getName() + " connection) {"); - sourceWriter.indent(); - // MouseEventDetails castedValue = (MouseEventDetails) value; - sourceWriter.println(qualifiedSourceName + " castedValue = (" - + qualifiedSourceName + ") value;"); - - if (isEnum) { - writeEnumSerializer(logger, sourceWriter, type); - } else if (isArray) { - writeArraySerializer(logger, sourceWriter, type.isArray()); - } else { - writeBeanSerializer(logger, sourceWriter, type); - } - // } - sourceWriter.outdent(); - sourceWriter.println("}"); - sourceWriter.println(); - - // Updater - // public void update(T target, Type type, JSONValue jsonValue, - // ApplicationConnection connection); - if (!isEnum && !isArray) { - sourceWriter.println("public void update(" + qualifiedSourceName - + " target, Type type, " + JSONValue.class.getName() - + " jsonValue, " + ApplicationConnection.class.getName() - + " connection) {"); - sourceWriter.indent(); - - writeBeanDeserializer(logger, sourceWriter, type); - - sourceWriter.outdent(); - sourceWriter.println("}"); - } - - // Deserializer - // T deserialize(Type type, JSONValue jsonValue, ApplicationConnection - // connection); - sourceWriter.println("public " + qualifiedSourceName - + " deserialize(Type type, " + JSONValue.class.getName() - + " jsonValue, " + ApplicationConnection.class.getName() - + " connection) {"); - sourceWriter.indent(); - - if (isEnum) { - writeEnumDeserializer(logger, sourceWriter, type.isEnum()); - } else if (isArray) { - writeArrayDeserializer(logger, sourceWriter, type.isArray()); - } else { - sourceWriter.println(qualifiedSourceName + " target = GWT.create(" - + qualifiedSourceName + ".class);"); - sourceWriter - .println("update(target, type, jsonValue, connection);"); - // return target; - sourceWriter.println("return target;"); - } - sourceWriter.outdent(); - sourceWriter.println("}"); - - // End of class - sourceWriter.outdent(); - sourceWriter.println("}"); - - // commit generated class - context.commit(logger, printWriter); - logger.log(TreeLogger.INFO, "Generated Serializer class " - + getFullyQualifiedSerializerClassName(type)); - } - - private void writeEnumDeserializer(TreeLogger logger, - SourceWriter sourceWriter, JEnumType enumType) { - sourceWriter.println("String enumIdentifier = ((" - + JSONString.class.getName() + ")jsonValue).stringValue();"); - for (JEnumConstant e : enumType.getEnumConstants()) { - sourceWriter.println("if (\"" + e.getName() - + "\".equals(enumIdentifier)) {"); - sourceWriter.indent(); - sourceWriter.println("return " + enumType.getQualifiedSourceName() - + "." + e.getName() + ";"); - sourceWriter.outdent(); - sourceWriter.println("}"); - } - sourceWriter.println("return null;"); - } - - private void writeArrayDeserializer(TreeLogger logger, - SourceWriter sourceWriter, JArrayType type) { - JType leafType = type.getLeafType(); - int rank = type.getRank(); - - sourceWriter.println(JSONArray.class.getName() - + " jsonArray = jsonValue.isArray();"); - - // Type value = new Type[jsonArray.size()][][]; - sourceWriter.print(type.getQualifiedSourceName() + " value = new " - + leafType.getQualifiedSourceName() + "[jsonArray.size()]"); - for (int i = 1; i < rank; i++) { - sourceWriter.print("[]"); - } - sourceWriter.println(";"); - - sourceWriter.println("for(int i = 0 ; i < value.length; i++) {"); - sourceWriter.indent(); - - JType componentType = type.getComponentType(); - - sourceWriter.print("value[i] = (" - + ConnectorBundleLoaderFactory - .getBoxedTypeName(componentType) + ") " - + JsonDecoder.class.getName() + ".decodeValue("); - ConnectorBundleLoaderFactory.writeTypeCreator(sourceWriter, - componentType); - sourceWriter.print(", jsonArray.get(i), null, connection)"); - - sourceWriter.println(";"); - - sourceWriter.outdent(); - sourceWriter.println("}"); - - sourceWriter.println("return value;"); - } - - private void writeBeanDeserializer(TreeLogger logger, - SourceWriter sourceWriter, JClassType beanType) { - String beanQualifiedSourceName = beanType.getQualifiedSourceName(); - - // JSONOBject json = (JSONObject)jsonValue; - sourceWriter.println(JSONObject.class.getName() + " json = (" - + JSONObject.class.getName() + ")jsonValue;"); - - for (JMethod method : getSetters(beanType)) { - String setterName = method.getName(); - String baseName = setterName.substring(3); - String fieldName = getTransportFieldName(baseName); // setZIndex() - // -> zIndex - JType setterParameterType = method.getParameterTypes()[0]; - - logger.log(Type.DEBUG, "* Processing field " + fieldName + " in " - + beanQualifiedSourceName + " (" + beanType.getName() + ")"); - - // if (json.containsKey("height")) { - sourceWriter.println("if (json.containsKey(\"" + fieldName - + "\")) {"); - sourceWriter.indent(); - String jsonFieldName = "json_" + fieldName; - // JSONValue json_Height = json.get("height"); - sourceWriter.println("JSONValue " + jsonFieldName - + " = json.get(\"" + fieldName + "\");"); - - String fieldType; - String getterName = "get" + baseName; - JPrimitiveType primitiveType = setterParameterType.isPrimitive(); - if (primitiveType != null) { - // This is a primitive type -> must used the boxed type - fieldType = primitiveType.getQualifiedBoxedSourceName(); - if (primitiveType == JPrimitiveType.BOOLEAN) { - getterName = "is" + baseName; - } - } else { - fieldType = setterParameterType.getQualifiedSourceName(); - } - - // String referenceValue = target.getHeight(); - sourceWriter.println(fieldType + " referenceValue = target." - + getterName + "();"); - - // target.setHeight((String) - // JsonDecoder.decodeValue(jsonFieldValue,referenceValue, idMapper, - // connection)); - sourceWriter.print("target." + setterName + "((" + fieldType + ") " - + JsonDecoder.class.getName() + ".decodeValue("); - ConnectorBundleLoaderFactory.writeTypeCreator(sourceWriter, - setterParameterType); - sourceWriter.println(", " + jsonFieldName - + ", referenceValue, connection));"); - - // } ... end of if contains - sourceWriter.outdent(); - sourceWriter.println("}"); - } - } - - private void writeEnumSerializer(TreeLogger logger, - SourceWriter sourceWriter, JClassType beanType) { - // return new JSONString(castedValue.name()); - sourceWriter.println("return new " + JSONString.class.getName() - + "(castedValue.name());"); - } - - private void writeArraySerializer(TreeLogger logger, - SourceWriter sourceWriter, JArrayType array) { - sourceWriter.println(JSONArray.class.getName() + " values = new " - + JSONArray.class.getName() + "();"); - JType componentType = array.getComponentType(); - // JPrimitiveType primitive = componentType.isPrimitive(); - sourceWriter.println("for (int i = 0; i < castedValue.length; i++) {"); - sourceWriter.indent(); - sourceWriter.print("values.set(i, "); - sourceWriter.print(JsonEncoder.class.getName() - + ".encode(castedValue[i], false, connection)"); - sourceWriter.println(");"); - sourceWriter.outdent(); - sourceWriter.println("}"); - sourceWriter.println("return values;"); - } - - private void writeBeanSerializer(TreeLogger logger, - SourceWriter sourceWriter, JClassType beanType) - throws UnableToCompleteException { - - // JSONObject json = new JSONObject(); - sourceWriter.println(JSONObject.class.getName() + " json = new " - + JSONObject.class.getName() + "();"); - - HashSet usedFieldNames = new HashSet(); - - for (JMethod setterMethod : getSetters(beanType)) { - String setterName = setterMethod.getName(); - String fieldName = getTransportFieldName(setterName.substring(3)); // setZIndex() - // -> zIndex - if (!usedFieldNames.add(fieldName)) { - logger.log( - TreeLogger.ERROR, - "Can't encode " - + beanType.getQualifiedSourceName() - + " as it has multiple fields with the name " - + fieldName.toLowerCase() - + ". This can happen if only casing distinguishes one property name from another."); - throw new UnableToCompleteException(); - } - String getterName = findGetter(beanType, setterMethod); - - if (getterName == null) { - logger.log(TreeLogger.ERROR, "No getter found for " + fieldName - + ". Serialization will likely fail"); - } - // json.put("button", - // JsonEncoder.encode(castedValue.getButton(), false, idMapper, - // connection)); - sourceWriter.println("json.put(\"" + fieldName + "\", " - + JsonEncoder.class.getName() + ".encode(castedValue." - + getterName + "(), false, connection));"); - } - // return json; - sourceWriter.println("return json;"); - - } - - private static String getTransportFieldName(String baseName) { - return Character.toLowerCase(baseName.charAt(0)) - + baseName.substring(1); - } - - private String findGetter(JClassType beanType, JMethod setterMethod) { - JType setterParameterType = setterMethod.getParameterTypes()[0]; - String fieldName = setterMethod.getName().substring(3); - if (setterParameterType.getQualifiedSourceName().equals( - boolean.class.getName())) { - return "is" + fieldName; - } else { - return "get" + fieldName; - } - } - - /** - * Returns a list of all setters found in the beanType or its parent class - * - * @param beanType - * The type to check - * @return A list of setter methods from the class and its parents - */ - protected static List getSetters(JClassType beanType) { - - List setterMethods = new ArrayList(); - - while (beanType != null - && !beanType.getQualifiedSourceName().equals( - Object.class.getName())) { - for (JMethod method : beanType.getMethods()) { - // Process all setters that have corresponding fields - if (!method.isPublic() || method.isStatic() - || !method.getName().startsWith("set") - || method.getParameterTypes().length != 1) { - // Not setter, skip to next method - continue; - } - setterMethods.add(method); - } - beanType = beanType.getSuperclass(); - } - - return setterMethods; - } - - private static String getSerializerSimpleClassName(JClassType beanType) { - return getSimpleClassName(beanType) + "_Serializer"; - } - - private static String getSimpleClassName(JType type) { - JArrayType arrayType = type.isArray(); - if (arrayType != null) { - return "Array" + getSimpleClassName(arrayType.getComponentType()); - } - JClassType classType = type.isClass(); - if (classType != null && classType.isMemberType()) { - // Assumed to be static sub class - String baseName = getSimpleClassName(classType.getEnclosingType()); - String name = baseName + SUBTYPE_SEPARATOR - + type.getSimpleSourceName(); - return name; - } - return type.getSimpleSourceName(); - } - - public static String getFullyQualifiedSerializerClassName(JClassType type) { - return getSerializerPackageName(type) + "." - + getSerializerSimpleClassName(type); - } - - private static String getSerializerPackageName(JClassType type) { - JPackage typePackage = type.getPackage(); - if (typePackage == null) { - return SerializerMap.class.getPackage().getName(); - } else { - String packageName = typePackage.getName(); - // Dev mode classloader gets unhappy for some java packages - if (packageName.startsWith("java.")) { - packageName = "com.vaadin." + packageName; - } - return packageName; - } - } -} diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/SerializerMapGenerator.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/SerializerMapGenerator.java deleted file mode 100644 index ac22aa2e8a..0000000000 --- a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/SerializerMapGenerator.java +++ /dev/null @@ -1,377 +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.terminal.gwt.widgetsetutils; - -import java.io.PrintWriter; -import java.io.Serializable; -import java.util.Date; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -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.JArrayType; -import com.google.gwt.core.ext.typeinfo.JClassType; -import com.google.gwt.core.ext.typeinfo.JMethod; -import com.google.gwt.core.ext.typeinfo.JParameterizedType; -import com.google.gwt.core.ext.typeinfo.JType; -import com.google.gwt.core.ext.typeinfo.NotFoundException; -import com.google.gwt.core.ext.typeinfo.TypeOracle; -import com.google.gwt.json.client.JSONValue; -import com.google.gwt.user.rebind.ClassSourceFileComposerFactory; -import com.google.gwt.user.rebind.SourceWriter; -import com.vaadin.shared.communication.ClientRpc; -import com.vaadin.shared.communication.ServerRpc; -import com.vaadin.shared.communication.SharedState; -import com.vaadin.terminal.gwt.client.ApplicationConnection; -import com.vaadin.terminal.gwt.client.communication.JSONSerializer; -import com.vaadin.terminal.gwt.client.communication.SerializerMap; - -/** - * GWT generator that creates a {@link SerializerMap} implementation (mapper - * from type string to serializer instance) and serializer classes for all - * subclasses of {@link SharedState}. - * - * @since 7.0 - */ -public class SerializerMapGenerator extends Generator { - - private static final String FAIL_IF_NOT_SERIALIZABLE = "vFailIfNotSerializable"; - private String packageName; - private String className; - - @Override - public String generate(TreeLogger logger, GeneratorContext context, - String typeName) throws UnableToCompleteException { - - try { - TypeOracle typeOracle = context.getTypeOracle(); - Set typesNeedingSerializers = findTypesNeedingSerializers( - typeOracle, logger); - checkForUnserializableTypes(typesNeedingSerializers, typeOracle, - logger); - Set typesWithExistingSerializers = findTypesWithExistingSerializers( - typeOracle, logger); - Set serializerMappings = new HashSet(); - serializerMappings.addAll(typesNeedingSerializers); - serializerMappings.addAll(typesWithExistingSerializers); - // get classType and save instance variables - JClassType classType = typeOracle.getType(typeName); - packageName = classType.getPackage().getName(); - className = classType.getSimpleSourceName() + "Impl"; - // Generate class source code for SerializerMapImpl - generateSerializerMap(serializerMappings, logger, context); - - SerializerGenerator sg = new SerializerGenerator(); - for (JClassType type : typesNeedingSerializers) { - sg.generate(logger, context, type.getQualifiedSourceName()); - } - } catch (Exception e) { - logger.log(TreeLogger.ERROR, - "SerializerMapGenerator creation failed", e); - throw new UnableToCompleteException(); - } - // return the fully qualifed name of the class generated - return packageName + "." + className; - } - - /** - * Emits a warning for all classes that are used in communication but do not - * implement java.io.Serializable. Implementing java.io.Serializable is not - * needed for communication but for the server side Application to be - * serializable i.e. work in GAE for instance. - * - * @param typesNeedingSerializers - * @param typeOracle - * @param logger - * @throws UnableToCompleteException - */ - private void checkForUnserializableTypes( - Set typesNeedingSerializers, TypeOracle typeOracle, - TreeLogger logger) throws UnableToCompleteException { - JClassType javaSerializable = typeOracle.findType(Serializable.class - .getName()); - for (JClassType type : typesNeedingSerializers) { - if (type.isArray() != null) { - // Don't check for arrays - continue; - } - boolean serializable = type.isAssignableTo(javaSerializable); - if (!serializable) { - boolean abortCompile = "true".equals(System - .getProperty(FAIL_IF_NOT_SERIALIZABLE)); - logger.log( - abortCompile ? Type.ERROR : Type.WARN, - type - + " is used in RPC or shared state but does not implement " - + Serializable.class.getName() - + ". Communication will work but the Application on server side cannot be serialized if it refers to objects of this type. " - + "If the system property " - + FAIL_IF_NOT_SERIALIZABLE - + " is set to \"true\", this causes the compilation to fail instead of just emitting a warning."); - if (abortCompile) { - throw new UnableToCompleteException(); - } - } - } - } - - private Set findTypesWithExistingSerializers( - TypeOracle typeOracle, TreeLogger logger) - throws UnableToCompleteException { - JClassType serializerInterface = typeOracle - .findType(JSONSerializer.class.getName()); - JType[] deserializeParamTypes = new JType[] { - typeOracle - .findType(com.vaadin.terminal.gwt.client.metadata.Type.class - .getName()), - typeOracle.findType(JSONValue.class.getName()), - typeOracle.findType(ApplicationConnection.class.getName()) }; - String deserializeMethodName = "deserialize"; - try { - serializerInterface.getMethod(deserializeMethodName, - deserializeParamTypes); - } catch (NotFoundException e) { - logger.log(Type.ERROR, "Could not find " + deserializeMethodName - + " in " + serializerInterface); - throw new UnableToCompleteException(); - } - - Set types = new HashSet(); - for (JClassType serializer : serializerInterface.getSubtypes()) { - JMethod deserializeMethod = serializer.findMethod( - deserializeMethodName, deserializeParamTypes); - if (deserializeMethod == null) { - logger.log(Type.DEBUG, "Could not find " - + deserializeMethodName + " in " + serializer); - continue; - } - JType returnType = deserializeMethod.getReturnType(); - logger.log(Type.DEBUG, "Found " + deserializeMethodName - + " with return type " + returnType + " in " + serializer); - - types.add(returnType.isClass()); - } - return types; - } - - /** - * Generate source code for SerializerMapImpl - * - * @param typesNeedingSerializers - * - * @param logger - * Logger object - * @param context - * Generator context - */ - private void generateSerializerMap(Set typesNeedingSerializers, - TreeLogger logger, GeneratorContext context) { - // 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 - if (printWriter == null) { - return; - } - Date date = new Date(); - TypeOracle typeOracle = context.getTypeOracle(); - - // 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.addImplementedInterface(SerializerMap.class.getName()); - SourceWriter sourceWriter = composer.createSourceWriter(context, - printWriter); - sourceWriter.indent(); - - sourceWriter.println("public " + JSONSerializer.class.getName() - + " getSerializer(String type) {"); - sourceWriter.indent(); - - // TODO cache serializer instances in a map - for (JClassType type : typesNeedingSerializers) { - sourceWriter.print("if (type.equals(\"" - + type.getQualifiedSourceName() + "\")"); - if (type instanceof JArrayType) { - // Also add binary name to support encoding based on - // object.getClass().getName() - sourceWriter.print("||type.equals(\"" + type.getJNISignature() - + "\")"); - } - sourceWriter.println(") {"); - sourceWriter.indent(); - String serializerName = SerializerGenerator - .getFullyQualifiedSerializerClassName(type); - sourceWriter.println("return GWT.create(" + serializerName - + ".class);"); - sourceWriter.outdent(); - sourceWriter.println("}"); - logger.log(Type.INFO, "Configured serializer (" + serializerName - + ") for " + type.getName()); - } - sourceWriter - .println("throw new RuntimeException(\"No serializer found for class \"+type);"); - sourceWriter.outdent(); - sourceWriter.println("}"); - - // 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)"); - - } - - public Set findTypesNeedingSerializers(TypeOracle typeOracle, - TreeLogger logger) { - logger.log(Type.DEBUG, "Detecting serializable data types..."); - - HashSet types = new HashSet(); - - // Generate serializer classes for each subclass of SharedState - JClassType serializerType = typeOracle.findType(SharedState.class - .getName()); - types.add(serializerType); - JClassType[] serializerSubtypes = serializerType.getSubtypes(); - for (JClassType type : serializerSubtypes) { - types.add(type); - } - - // Serializer classes might also be needed for RPC methods - for (Class cls : new Class[] { ServerRpc.class, ClientRpc.class }) { - JClassType rpcType = typeOracle.findType(cls.getName()); - JClassType[] serverRpcSubtypes = rpcType.getSubtypes(); - for (JClassType type : serverRpcSubtypes) { - addMethodParameterTypes(type, types, logger); - } - } - - // Add all types used from/in the types - for (Object t : types.toArray()) { - findSubTypesNeedingSerializers((JClassType) t, types); - } - logger.log(Type.DEBUG, "Serializable data types: " + types.toString()); - - return types; - } - - private void addMethodParameterTypes(JClassType classContainingMethods, - Set types, TreeLogger logger) { - for (JMethod method : classContainingMethods.getMethods()) { - if (method.getName().equals("initRpc")) { - continue; - } - for (JType type : method.getParameterTypes()) { - addTypeIfNeeded(types, type); - } - } - } - - public void findSubTypesNeedingSerializers(JClassType type, - Set serializableTypes) { - // Find all setters and look at their parameter type to determine if a - // new serializer is needed - for (JMethod setterMethod : SerializerGenerator.getSetters(type)) { - // The one and only parameter for the setter - JType setterType = setterMethod.getParameterTypes()[0]; - addTypeIfNeeded(serializableTypes, setterType); - } - } - - private void addTypeIfNeeded(Set serializableTypes, JType type) { - if (serializableTypes.contains(type)) { - return; - } - JParameterizedType parametrized = type.isParameterized(); - if (parametrized != null) { - for (JClassType parameterType : parametrized.getTypeArgs()) { - addTypeIfNeeded(serializableTypes, parameterType); - } - } - - if (serializationHandledByFramework(type)) { - return; - } - - if (serializableTypes.contains(type)) { - return; - } - - JClassType typeClass = type.isClass(); - if (typeClass != null) { - // setterTypeClass is null at least for List. It is - // possible that we need to handle the cases somehow, for - // instance for List. - serializableTypes.add(typeClass); - findSubTypesNeedingSerializers(typeClass, serializableTypes); - } - - // Generate (n-1)-dimensional array serializer for n-dimensional array - JArrayType arrayType = type.isArray(); - if (arrayType != null) { - serializableTypes.add(arrayType); - addTypeIfNeeded(serializableTypes, arrayType.getComponentType()); - } - - } - - Set> frameworkHandledTypes = new HashSet>(); - { - frameworkHandledTypes.add(String.class); - frameworkHandledTypes.add(Boolean.class); - frameworkHandledTypes.add(Integer.class); - frameworkHandledTypes.add(Float.class); - frameworkHandledTypes.add(Double.class); - frameworkHandledTypes.add(Long.class); - frameworkHandledTypes.add(Enum.class); - frameworkHandledTypes.add(String[].class); - frameworkHandledTypes.add(Object[].class); - frameworkHandledTypes.add(Map.class); - frameworkHandledTypes.add(List.class); - frameworkHandledTypes.add(Set.class); - frameworkHandledTypes.add(Byte.class); - frameworkHandledTypes.add(Character.class); - - } - - private boolean serializationHandledByFramework(JType setterType) { - // Some types are handled by the framework at the moment. See #8449 - // This method should be removed at some point. - if (setterType.isPrimitive() != null) { - return true; - } - - String qualifiedName = setterType.getQualifiedSourceName(); - for (Class cls : frameworkHandledTypes) { - if (qualifiedName.equals(cls.getName())) { - return true; - } - } - - return false; - } -} diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ArraySerializer.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ArraySerializer.java new file mode 100644 index 0000000000..1c729e9841 --- /dev/null +++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ArraySerializer.java @@ -0,0 +1,90 @@ +/* + * 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.terminal.gwt.widgetsetutils.metadata; + +import com.google.gwt.core.ext.TreeLogger; +import com.google.gwt.core.ext.typeinfo.JArrayType; +import com.google.gwt.core.ext.typeinfo.JType; +import com.google.gwt.json.client.JSONArray; +import com.google.gwt.user.rebind.SourceWriter; +import com.vaadin.terminal.gwt.client.communication.JsonDecoder; +import com.vaadin.terminal.gwt.client.communication.JsonEncoder; +import com.vaadin.terminal.gwt.widgetsetutils.ConnectorBundleLoaderFactory; + +public class ArraySerializer extends JsonSerializer { + + private final JArrayType arrayType; + + public ArraySerializer(JArrayType arrayType) { + super(arrayType); + this.arrayType = arrayType; + } + + @Override + protected void printDeserializerBody(TreeLogger logger, SourceWriter w, + String type, String jsonValue, String connection) { + JType leafType = arrayType.getLeafType(); + int rank = arrayType.getRank(); + + w.println(JSONArray.class.getName() + " jsonArray = " + jsonValue + + ".isArray();"); + + // Type value = new Type[jsonArray.size()][][]; + w.print(arrayType.getQualifiedSourceName() + " value = new " + + leafType.getQualifiedSourceName() + "[jsonArray.size()]"); + for (int i = 1; i < rank; i++) { + w.print("[]"); + } + w.println(";"); + + w.println("for(int i = 0 ; i < value.length; i++) {"); + w.indent(); + + JType componentType = arrayType.getComponentType(); + + w.print("value[i] = (" + + ConnectorBundleLoaderFactory.getBoxedTypeName(componentType) + + ") " + JsonDecoder.class.getName() + ".decodeValue("); + ConnectorBundleLoaderFactory.writeTypeCreator(w, componentType); + w.print(", jsonArray.get(i), null, " + connection + ")"); + + w.println(";"); + + w.outdent(); + w.println("}"); + + w.println("return value;"); + } + + @Override + protected void printSerializerBody(TreeLogger logger, SourceWriter w, + String value, String applicationConnection) { + w.println(JSONArray.class.getName() + " values = new " + + JSONArray.class.getName() + "();"); + // JPrimitiveType primitive = componentType.isPrimitive(); + w.println("for (int i = 0; i < " + value + ".length; i++) {"); + w.indent(); + w.print("values.set(i, "); + w.print(JsonEncoder.class.getName() + ".encode(" + value + + "[i], false, " + applicationConnection + ")"); + w.println(");"); + w.outdent(); + w.println("}"); + w.println("return values;"); + } + +} diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ClientRpcVisitor.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ClientRpcVisitor.java index 2f628b76cb..d5a78b86b9 100644 --- a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ClientRpcVisitor.java +++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ClientRpcVisitor.java @@ -21,6 +21,7 @@ import java.util.Set; import com.google.gwt.core.ext.TreeLogger; import com.google.gwt.core.ext.typeinfo.JClassType; import com.google.gwt.core.ext.typeinfo.JMethod; +import com.google.gwt.core.ext.typeinfo.JType; public class ClientRpcVisitor extends TypeVisitor { @Override @@ -33,6 +34,11 @@ public class ClientRpcVisitor extends TypeVisitor { for (JMethod method : methods) { bundle.setNeedsInvoker(type, method); bundle.setNeedsParamTypes(type, method); + + JType[] parameterTypes = method.getParameterTypes(); + for (JType paramType : parameterTypes) { + bundle.setNeedsSerialize(paramType); + } } } } diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ConnectorBundle.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ConnectorBundle.java index e93c72aa2f..ad6b1eb102 100644 --- a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ConnectorBundle.java +++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ConnectorBundle.java @@ -4,62 +4,114 @@ package com.vaadin.terminal.gwt.widgetsetutils.metadata; +import java.io.Serializable; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.List; import java.util.Map; import java.util.Set; 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.JArrayType; import com.google.gwt.core.ext.typeinfo.JClassType; +import com.google.gwt.core.ext.typeinfo.JEnumType; import com.google.gwt.core.ext.typeinfo.JMethod; +import com.google.gwt.core.ext.typeinfo.JParameterizedType; +import com.google.gwt.core.ext.typeinfo.JType; import com.google.gwt.core.ext.typeinfo.NotFoundException; +import com.google.gwt.core.ext.typeinfo.TypeOracle; +import com.google.gwt.json.client.JSONValue; import com.vaadin.shared.communication.ClientRpc; import com.vaadin.shared.communication.ServerRpc; import com.vaadin.shared.ui.Connect; +import com.vaadin.terminal.gwt.client.ApplicationConnection; import com.vaadin.terminal.gwt.client.ComponentConnector; import com.vaadin.terminal.gwt.client.ServerConnector; +import com.vaadin.terminal.gwt.client.communication.JSONSerializer; public class ConnectorBundle { + private static final String FAIL_IF_NOT_SERIALIZABLE = "vFailIfNotSerializable"; + private final String name; private final ConnectorBundle previousBundle; + private final Collection visitors; + private final Map customSerializers; + private final Set hasSerializeSupport = new HashSet(); + private final Set needsSerializeSupport = new HashSet(); + private final Map serializers = new HashMap(); + + private final Set needsPropertyList = new HashSet(); private final Set needsGwtConstructor = new HashSet(); - private final Map> identifiers = new HashMap>(); private final Set visitedTypes = new HashSet(); - private final Set visitQueue = new HashSet(); - private final Map> needsReturnType = new HashMap>(); - - private final Collection visitors; - private final Set needsProxySupport = new HashSet(); + + private final Map> identifiers = new HashMap>(); + private final Map> needsReturnType = new HashMap>(); private final Map> needsInvoker = new HashMap>(); private final Map> needsParamTypes = new HashMap>(); private final Map> needsDelayedInfo = new HashMap>(); + private final Set needsSetter = new HashSet(); + private final Set needsType = new HashSet(); + private final Set needsGetter = new HashSet(); + private ConnectorBundle(String name, ConnectorBundle previousBundle, - Collection visitors) { + Collection visitors, + Map customSerializers) { this.name = name; this.previousBundle = previousBundle; this.visitors = visitors; + this.customSerializers = customSerializers; } public ConnectorBundle(String name, ConnectorBundle previousBundle) { - this(name, previousBundle, previousBundle.visitors); - } + this(name, previousBundle, previousBundle.visitors, + previousBundle.customSerializers); + } + + public ConnectorBundle(String name, Collection visitors, + TypeOracle oracle) throws NotFoundException { + this(name, null, visitors, findCustomSerializers(oracle)); + } + + private static Map findCustomSerializers( + TypeOracle oracle) throws NotFoundException { + Map serializers = new HashMap(); + + JClassType serializerInterface = oracle.findType(JSONSerializer.class + .getName()); + JType[] deserializeParamTypes = new JType[] { + oracle.findType(com.vaadin.terminal.gwt.client.metadata.Type.class + .getName()), + oracle.findType(JSONValue.class.getName()), + oracle.findType(ApplicationConnection.class.getName()) }; + String deserializeMethodName = "deserialize"; + // Just test that the method exists + serializerInterface.getMethod(deserializeMethodName, + deserializeParamTypes); + + for (JClassType serializer : serializerInterface.getSubtypes()) { + JMethod deserializeMethod = serializer.findMethod( + deserializeMethodName, deserializeParamTypes); + if (deserializeMethod == null) { + continue; + } + JType returnType = deserializeMethod.getReturnType(); - public ConnectorBundle(String name, Collection visitors) { - this(name, null, visitors); + serializers.put(returnType, serializer); + } + return serializers; } public void setNeedsGwtConstructor(JClassType type) { if (!needsGwtConstructor(type)) { - ensureVisited(type); needsGwtConstructor.add(type); } } @@ -75,7 +127,6 @@ public class ConnectorBundle { public void setIdentifier(JClassType type, String identifier) { if (!hasIdentifier(type, identifier)) { - ensureVisited(type); addMapping(identifiers, type, identifier); } } @@ -114,8 +165,13 @@ public class ConnectorBundle { public void processType(TreeLogger logger, JClassType type) throws UnableToCompleteException { - ensureVisited(type); - purgeQueue(logger); + if (!isTypeVisited(type)) { + for (TypeVisitor typeVisitor : visitors) { + invokeVisitor(logger, type, typeVisitor); + } + visitedTypes.add(type); + purgeSerializeSupportQueue(logger); + } } private boolean isTypeVisited(JClassType type) { @@ -126,31 +182,200 @@ public class ConnectorBundle { } } - private void ensureVisited(JClassType type) { - if (!isTypeVisited(type)) { - visitQueue.add(type); + private void purgeSerializeSupportQueue(TreeLogger logger) + throws UnableToCompleteException { + while (!needsSerializeSupport.isEmpty()) { + Iterator iterator = needsSerializeSupport.iterator(); + JType type = iterator.next(); + iterator.remove(); + + if (hasSserializeSupport(type)) { + continue; + } + + addSerializeSupport(logger, type); } } - private void purgeQueue(TreeLogger logger) throws UnableToCompleteException { - while (!visitQueue.isEmpty()) { - Iterator iterator = visitQueue.iterator(); - JClassType type = iterator.next(); - iterator.remove(); + private void addSerializeSupport(TreeLogger logger, JType type) + throws UnableToCompleteException { + hasSerializeSupport.add(type); - if (isTypeVisited(type)) { - continue; + JParameterizedType parametrized = type.isParameterized(); + if (parametrized != null) { + for (JClassType parameterType : parametrized.getTypeArgs()) { + setNeedsSerialize(parameterType); } + } - // Mark as visited before visiting to avoid adding to queue again - visitedTypes.add(type); + if (serializationHandledByFramework(type)) { + return; + } - for (TypeVisitor typeVisitor : visitors) { - invokeVisitor(logger, type, typeVisitor); + JClassType customSerializer = customSerializers.get(type); + JClassType typeAsClass = type.isClass(); + JEnumType enumType = type.isEnum(); + JArrayType arrayType = type.isArray(); + + if (customSerializer != null) { + logger.log(Type.INFO, "Will serialize " + type + " using " + + customSerializer.getName()); + setSerializer(type, new CustomSerializer(customSerializer)); + } else if (arrayType != null) { + logger.log(Type.INFO, "Will serialize " + type + " as an array"); + setSerializer(type, new ArraySerializer(arrayType)); + setNeedsSerialize(arrayType.getComponentType()); + } else if (enumType != null) { + logger.log(Type.INFO, "Will serialize " + type + " as an enum"); + setSerializer(type, new EnumSerializer(enumType)); + } else if (typeAsClass != null) { + // Bean + checkSerializable(logger, typeAsClass); + + logger.log(Type.INFO, "Will serialize " + type + " as a bean"); + + setNeedsPropertyList(typeAsClass); + + for (Property property : getProperties(typeAsClass)) { + setNeedsGwtConstructor(property.getBeanType()); + setNeedsSetter(property); + + // Getters needed for reading previous value that should be + // passed to sub encoder + setNeedsGetter(property); + setNeedsType(property); + + JType propertyType = property.getPropertyType(); + setNeedsSerialize(propertyType); } } } + private void checkSerializable(TreeLogger logger, JClassType type) + throws UnableToCompleteException { + JClassType javaSerializable = type.getOracle().findType( + Serializable.class.getName()); + boolean serializable = type.isAssignableTo(javaSerializable); + if (!serializable) { + boolean abortCompile = "true".equals(System + .getProperty(FAIL_IF_NOT_SERIALIZABLE)); + logger.log( + abortCompile ? Type.ERROR : Type.WARN, + type + + " is used in RPC or shared state but does not implement " + + Serializable.class.getName() + + ". Communication will work but the Application on server side cannot be serialized if it refers to objects of this type. " + + "If the system property " + + FAIL_IF_NOT_SERIALIZABLE + + " is set to \"true\", this causes the compilation to fail instead of just emitting a warning."); + if (abortCompile) { + throw new UnableToCompleteException(); + } + } + } + + private void setSerializer(JType type, GeneratedSerializer serializer) { + if (!hasSerializer(type)) { + serializers.put(type, serializer); + } + } + + private boolean hasSerializer(JType type) { + if (serializers.containsKey(type)) { + return true; + } else { + return previousBundle != null && previousBundle.hasSerializer(type); + } + } + + public Map getSerializers() { + return Collections.unmodifiableMap(serializers); + } + + private void setNeedsGetter(Property property) { + if (!isNeedsGetter(property)) { + needsGetter.add(property); + } + } + + private boolean isNeedsGetter(Property property) { + if (needsGetter.contains(property)) { + return true; + } else { + return previousBundle != null + && previousBundle.isNeedsGetter(property); + } + } + + public Set getNeedsGetter() { + return Collections.unmodifiableSet(needsGetter); + } + + private void setNeedsType(Property property) { + if (!isNeedsType(property)) { + needsType.add(property); + } + } + + public Set getNeedsType() { + return Collections.unmodifiableSet(needsType); + } + + private boolean isNeedsType(Property property) { + if (needsType.contains(property)) { + return true; + } else { + return previousBundle != null + && previousBundle.isNeedsType(property); + } + } + + public void setNeedsSetter(Property property) { + if (!isNeedsSetter(property)) { + needsSetter.add(property); + } + } + + private boolean isNeedsSetter(Property property) { + if (needsSetter.contains(property)) { + return true; + } else { + return previousBundle != null + && previousBundle.isNeedsSetter(property); + } + } + + public Set getNeedsSetter() { + return Collections.unmodifiableSet(needsSetter); + } + + private void setNeedsPropertyList(JClassType type) { + if (!isNeedsPropertyList(type)) { + needsPropertyList.add(type); + } + } + + private boolean isNeedsPropertyList(JClassType type) { + if (needsPropertyList.contains(type)) { + return true; + } else { + return previousBundle != null + && previousBundle.isNeedsPropertyList(type); + } + } + + public Set getNeedsPropertyListing() { + return Collections.unmodifiableSet(needsPropertyList); + } + + public Collection getProperties(JClassType type) { + HashSet properties = new HashSet(); + + properties.addAll(MethodProperty.findProperties(type)); + + return properties; + } + private void invokeVisitor(TreeLogger logger, JClassType type, TypeVisitor typeVisitor) throws UnableToCompleteException { TreeLogger subLogger = logger.branch(Type.TRACE, @@ -158,9 +383,11 @@ public class ConnectorBundle { + typeVisitor.getClass().getSimpleName()); if (isConnectedConnector(type)) { typeVisitor.visitConnector(subLogger, type, this); - } else if (isClientRpc(type)) { + } + if (isClientRpc(type)) { typeVisitor.visitClientRpc(subLogger, type, this); - } else if (isServerRpc(type)) { + } + if (isServerRpc(type)) { typeVisitor.visitServerRpc(subLogger, type, this); } } @@ -172,7 +399,6 @@ public class ConnectorBundle { public void setNeedsReturnType(JClassType type, JMethod method) { if (!isNeedsReturnType(type, method)) { - ensureVisited(type); addMapping(needsReturnType, type, method); } } @@ -221,7 +447,6 @@ public class ConnectorBundle { public void setNeedsInvoker(JClassType type, JMethod method) { if (!isNeedsInvoker(type, method)) { - ensureVisited(type); addMapping(needsInvoker, type, method); } } @@ -254,7 +479,6 @@ public class ConnectorBundle { public void setNeedsParamTypes(JClassType type, JMethod method) { if (!isNeedsParamTypes(type, method)) { - ensureVisited(type); addMapping(needsParamTypes, type, method); } } @@ -274,7 +498,6 @@ public class ConnectorBundle { public void setNeedsProxySupport(JClassType type) { if (!isNeedsProxySupport(type)) { - ensureVisited(type); needsProxySupport.add(type); } } @@ -294,7 +517,6 @@ public class ConnectorBundle { public void setNeedsDelayedInfo(JClassType type, JMethod method) { if (!isNeedsDelayedInfo(type, method)) { - ensureVisited(type); addMapping(needsDelayedInfo, type, method); } } @@ -311,4 +533,55 @@ public class ConnectorBundle { public Map> getNeedsDelayedInfo() { return Collections.unmodifiableMap(needsDelayedInfo); } + + public void setNeedsSerialize(JType type) { + if (!hasSserializeSupport(type)) { + needsSerializeSupport.add(type); + } + } + + private static Set> frameworkHandledTypes = new HashSet>(); + { + frameworkHandledTypes.add(String.class); + frameworkHandledTypes.add(Boolean.class); + frameworkHandledTypes.add(Integer.class); + frameworkHandledTypes.add(Float.class); + frameworkHandledTypes.add(Double.class); + frameworkHandledTypes.add(Long.class); + frameworkHandledTypes.add(Enum.class); + frameworkHandledTypes.add(String[].class); + frameworkHandledTypes.add(Object[].class); + frameworkHandledTypes.add(Map.class); + frameworkHandledTypes.add(List.class); + frameworkHandledTypes.add(Set.class); + frameworkHandledTypes.add(Byte.class); + frameworkHandledTypes.add(Character.class); + + } + + private boolean serializationHandledByFramework(JType setterType) { + // Some types are handled by the framework at the moment. See #8449 + // This method should be removed at some point. + if (setterType.isPrimitive() != null) { + return true; + } + + String qualifiedName = setterType.getQualifiedSourceName(); + for (Class cls : frameworkHandledTypes) { + if (qualifiedName.equals(cls.getName())) { + return true; + } + } + + return false; + } + + private boolean hasSserializeSupport(JType type) { + if (hasSerializeSupport.contains(type)) { + return true; + } else { + return previousBundle != null + && previousBundle.hasSserializeSupport(type); + } + } } \ No newline at end of file diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/CustomSerializer.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/CustomSerializer.java new file mode 100644 index 0000000000..11252c4acb --- /dev/null +++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/CustomSerializer.java @@ -0,0 +1,43 @@ +/* + * 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.terminal.gwt.widgetsetutils.metadata; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.core.ext.TreeLogger; +import com.google.gwt.core.ext.UnableToCompleteException; +import com.google.gwt.core.ext.typeinfo.JClassType; +import com.google.gwt.user.rebind.SourceWriter; +import com.vaadin.terminal.gwt.widgetsetutils.ConnectorBundleLoaderFactory; + +public class CustomSerializer implements GeneratedSerializer { + + private final JClassType serializerType; + + public CustomSerializer(JClassType serializerType) { + this.serializerType = serializerType; + } + + @Override + public void writeSerializerInstantiator(TreeLogger logger, SourceWriter w) + throws UnableToCompleteException { + w.print("return "); + w.print(GWT.class.getCanonicalName()); + w.print(".create("); + ConnectorBundleLoaderFactory.writeClassLiteral(w, serializerType); + w.println(");"); + } +} diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/EnumSerializer.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/EnumSerializer.java new file mode 100644 index 0000000000..324b555300 --- /dev/null +++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/EnumSerializer.java @@ -0,0 +1,58 @@ +/* + * 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.terminal.gwt.widgetsetutils.metadata; + +import com.google.gwt.core.ext.TreeLogger; +import com.google.gwt.core.ext.typeinfo.JEnumConstant; +import com.google.gwt.core.ext.typeinfo.JEnumType; +import com.google.gwt.json.client.JSONString; +import com.google.gwt.user.rebind.SourceWriter; + +public class EnumSerializer extends JsonSerializer { + + private final JEnumType enumType; + + public EnumSerializer(JEnumType type) { + super(type); + enumType = type; + } + + @Override + protected void printDeserializerBody(TreeLogger logger, SourceWriter w, + String type, String jsonValue, String connection) { + w.println("String enumIdentifier = ((" + JSONString.class.getName() + + ")" + jsonValue + ").stringValue();"); + for (JEnumConstant e : enumType.getEnumConstants()) { + w.println("if (\"" + e.getName() + "\".equals(enumIdentifier)) {"); + w.indent(); + w.println("return " + enumType.getQualifiedSourceName() + "." + + e.getName() + ";"); + w.outdent(); + w.println("}"); + } + w.println("return null;"); + } + + @Override + protected void printSerializerBody(TreeLogger logger, SourceWriter w, + String value, String applicationConnection) { + // return new JSONString(castedValue.name()); + w.println("return new " + JSONString.class.getName() + "(" + value + + ".name());"); + } + +} diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/GeneratedSerializer.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/GeneratedSerializer.java new file mode 100644 index 0000000000..0cfde7748c --- /dev/null +++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/GeneratedSerializer.java @@ -0,0 +1,26 @@ +/* + * 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.terminal.gwt.widgetsetutils.metadata; + +import com.google.gwt.core.ext.TreeLogger; +import com.google.gwt.core.ext.UnableToCompleteException; +import com.google.gwt.user.rebind.SourceWriter; + +public interface GeneratedSerializer { + public void writeSerializerInstantiator(TreeLogger logger, SourceWriter w) + throws UnableToCompleteException; +} diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/JsonSerializer.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/JsonSerializer.java new file mode 100644 index 0000000000..accee84fe7 --- /dev/null +++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/JsonSerializer.java @@ -0,0 +1,88 @@ +/* + * 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.terminal.gwt.widgetsetutils.metadata; + +import com.google.gwt.core.ext.TreeLogger; +import com.google.gwt.core.ext.UnableToCompleteException; +import com.google.gwt.core.ext.typeinfo.JType; +import com.google.gwt.json.client.JSONValue; +import com.google.gwt.user.rebind.SourceWriter; +import com.vaadin.terminal.gwt.client.ApplicationConnection; +import com.vaadin.terminal.gwt.client.communication.JSONSerializer; + +public abstract class JsonSerializer implements GeneratedSerializer { + + private final JType type; + + public JsonSerializer(JType type) { + this.type = type; + } + + @Override + public void writeSerializerInstantiator(TreeLogger logger, SourceWriter w) + throws UnableToCompleteException { + + w.print("return new "); + w.print(JSONSerializer.class.getCanonicalName()); + w.print("<"); + w.print(type.getQualifiedSourceName()); + w.println(">() {"); + w.indent(); + + writeSerializerBody(logger, w); + + w.outdent(); + w.println("};"); + } + + protected void writeSerializerBody(TreeLogger logger, SourceWriter w) { + String qualifiedSourceName = type.getQualifiedSourceName(); + w.println("public " + JSONValue.class.getName() + " serialize(" + + qualifiedSourceName + " value, " + + ApplicationConnection.class.getName() + " connection) {"); + w.indent(); + // MouseEventDetails castedValue = (MouseEventDetails) value; + w.println(qualifiedSourceName + " castedValue = (" + + qualifiedSourceName + ") value;"); + + printSerializerBody(logger, w, "castedValue", "connection"); + + // End of serializer method + w.outdent(); + w.println("}"); + + // Deserializer + // T deserialize(Type type, JSONValue jsonValue, ApplicationConnection + // connection); + w.println("public " + qualifiedSourceName + " deserialize(Type type, " + + JSONValue.class.getName() + " jsonValue, " + + ApplicationConnection.class.getName() + " connection) {"); + w.indent(); + + printDeserializerBody(logger, w, "type", "jsonValue", "connection"); + + w.outdent(); + w.println("}"); + } + + protected abstract void printDeserializerBody(TreeLogger logger, + SourceWriter w, String type, String jsonValue, String connection); + + protected abstract void printSerializerBody(TreeLogger logger, + SourceWriter w, String value, String applicationConnection); + +} diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/MethodProperty.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/MethodProperty.java new file mode 100644 index 0000000000..f422205175 --- /dev/null +++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/MethodProperty.java @@ -0,0 +1,124 @@ +/* + * 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.terminal.gwt.widgetsetutils.metadata; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import com.google.gwt.core.ext.TreeLogger; +import com.google.gwt.core.ext.typeinfo.JClassType; +import com.google.gwt.core.ext.typeinfo.JMethod; +import com.google.gwt.core.ext.typeinfo.JType; +import com.google.gwt.user.rebind.SourceWriter; + +public class MethodProperty extends Property { + + private final JMethod setter; + + private MethodProperty(JClassType beanType, JMethod setter) { + super(getTransportFieldName(setter), beanType, setter + .getParameterTypes()[0]); + this.setter = setter; + } + + public static Collection findProperties(JClassType type) { + Collection properties = new ArrayList(); + + List setters = getSetters(type); + for (JMethod setter : setters) { + properties.add(new MethodProperty(type, setter)); + } + + return properties; + } + + /** + * Returns a list of all setters found in the beanType or its parent class + * + * @param beanType + * The type to check + * @return A list of setter methods from the class and its parents + */ + private static List getSetters(JClassType beanType) { + List setterMethods = new ArrayList(); + + while (beanType != null + && !beanType.getQualifiedSourceName().equals( + Object.class.getName())) { + for (JMethod method : beanType.getMethods()) { + // Process all setters that have corresponding fields + if (!method.isPublic() || method.isStatic() + || !method.getName().startsWith("set") + || method.getParameterTypes().length != 1) { + // Not setter, skip to next method + continue; + } + setterMethods.add(method); + } + beanType = beanType.getSuperclass(); + } + + return setterMethods; + } + + @Override + public void writeSetterBody(TreeLogger logger, SourceWriter w, + String beanVariable, String valueVariable) { + w.print("(("); + w.print(getBeanType().getQualifiedSourceName()); + w.print(") "); + w.print(beanVariable); + w.print(")."); + w.print(setter.getName()); + w.print("(("); + w.print(getUnboxedPropertyTypeName()); + w.print(") "); + w.print(valueVariable); + w.println(");"); + } + + @Override + public void writeGetterBody(TreeLogger logger, SourceWriter w, + String beanVariable) { + w.print("return (("); + w.print(getBeanType().getQualifiedSourceName()); + w.print(") "); + w.print(beanVariable); + w.print(")."); + w.print(findGetter(getBeanType(), setter)); + w.print("();"); + } + + private String findGetter(JClassType beanType, JMethod setterMethod) { + JType setterParameterType = setterMethod.getParameterTypes()[0]; + String fieldName = setterMethod.getName().substring(3); + if (setterParameterType.getQualifiedSourceName().equals( + boolean.class.getName())) { + return "is" + fieldName; + } else { + return "get" + fieldName; + } + } + + private static String getTransportFieldName(JMethod setter) { + String baseName = setter.getName().substring(3); + return Character.toLowerCase(baseName.charAt(0)) + + baseName.substring(1); + } + +} diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/Property.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/Property.java new file mode 100644 index 0000000000..1714489db5 --- /dev/null +++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/Property.java @@ -0,0 +1,84 @@ +/* + * 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.terminal.gwt.widgetsetutils.metadata; + +import com.google.gwt.core.ext.TreeLogger; +import com.google.gwt.core.ext.typeinfo.JClassType; +import com.google.gwt.core.ext.typeinfo.JPrimitiveType; +import com.google.gwt.core.ext.typeinfo.JType; +import com.google.gwt.user.rebind.SourceWriter; + +public abstract class Property { + private final String name; + private final JClassType beanType; + private final JType propertyType; + + protected Property(String name, JClassType beanType, JType propertyType) { + this.name = name; + this.beanType = beanType; + this.propertyType = propertyType; + } + + public String getName() { + return name; + } + + public JType getPropertyType() { + return propertyType; + } + + public String getUnboxedPropertyTypeName() { + JType propertyType = getPropertyType(); + JPrimitiveType primitive = propertyType.isPrimitive(); + if (primitive != null) { + return primitive.getQualifiedBoxedSourceName(); + } else { + return propertyType.getQualifiedSourceName(); + } + } + + public JClassType getBeanType() { + return beanType; + } + + public abstract void writeSetterBody(TreeLogger logger, SourceWriter w, + String beanVariable, String valueVariable); + + public abstract void writeGetterBody(TreeLogger logger, SourceWriter w, + String beanVariable); + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } else if (obj instanceof Property) { + Property other = (Property) obj; + return other.getClass() == getClass() + && other.getBeanType().equals(getBeanType()) + && other.getName().equals(getName()); + } else { + return false; + } + } + + @Override + public int hashCode() { + return getClass().hashCode() * 31 ^ 2 + getBeanType().hashCode() * 31 + + getName().hashCode(); + } + +} diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ServerRpcVisitor.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ServerRpcVisitor.java index 5505c70dc3..4c0fc94500 100644 --- a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ServerRpcVisitor.java +++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ServerRpcVisitor.java @@ -21,6 +21,7 @@ import java.util.Set; import com.google.gwt.core.ext.TreeLogger; import com.google.gwt.core.ext.typeinfo.JClassType; import com.google.gwt.core.ext.typeinfo.JMethod; +import com.google.gwt.core.ext.typeinfo.JType; public class ServerRpcVisitor extends TypeVisitor { @Override @@ -35,6 +36,11 @@ public class ServerRpcVisitor extends TypeVisitor { JMethod[] methods = subType.getMethods(); for (JMethod method : methods) { bundle.setNeedsDelayedInfo(type, method); + + JType[] parameterTypes = method.getParameterTypes(); + for (JType paramType : parameterTypes) { + bundle.setNeedsSerialize(paramType); + } } } } diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/StateInitVisitor.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/StateInitVisitor.java index d22f03635b..49cf687412 100644 --- a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/StateInitVisitor.java +++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/StateInitVisitor.java @@ -16,6 +16,8 @@ public class StateInitVisitor extends TypeVisitor { JMethod getState = findInheritedMethod(type, "getState"); bundle.setNeedsReturnType(type, getState); + bundle.setNeedsSerialize(getState.getReturnType()); + JType stateType = getState.getReturnType(); bundle.setNeedsGwtConstructor(stateType.isClass()); } diff --git a/client/src/com/vaadin/Vaadin.gwt.xml b/client/src/com/vaadin/Vaadin.gwt.xml index fe9643232e..44357b24a0 100644 --- a/client/src/com/vaadin/Vaadin.gwt.xml +++ b/client/src/com/vaadin/Vaadin.gwt.xml @@ -23,14 +23,6 @@ - - - - - diff --git a/client/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java b/client/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java index 9b58eb1295..7e1c505fe9 100644 --- a/client/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java +++ b/client/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java @@ -65,7 +65,6 @@ import com.vaadin.terminal.gwt.client.communication.HasJavaScriptConnectorHelper import com.vaadin.terminal.gwt.client.communication.JsonDecoder; import com.vaadin.terminal.gwt.client.communication.JsonEncoder; import com.vaadin.terminal.gwt.client.communication.RpcManager; -import com.vaadin.terminal.gwt.client.communication.SerializerMap; import com.vaadin.terminal.gwt.client.communication.StateChangeEvent; import com.vaadin.terminal.gwt.client.extensions.AbstractExtensionConnector; import com.vaadin.terminal.gwt.client.metadata.ConnectorBundleLoader; @@ -106,8 +105,6 @@ public class ApplicationConnection { public static final char VAR_ESCAPE_CHARACTER = '\u001b'; - private static SerializerMap serializerMap; - /** * A string that, if found in a non-JSON response to a UIDL request, will * cause the browser to refresh the page. If followed by a colon, optional @@ -215,7 +212,6 @@ public class ApplicationConnection { rpcManager = GWT.create(RpcManager.class); layoutManager = GWT.create(LayoutManager.class); layoutManager.setConnection(this); - serializerMap = GWT.create(SerializerMap.class); } public void init(WidgetSet widgetSet, ApplicationConfiguration cnf) { @@ -2577,8 +2573,4 @@ public class ApplicationConnection { LayoutManager getLayoutManager() { return layoutManager; } - - public SerializerMap getSerializerMap() { - return serializerMap; - } } diff --git a/client/src/com/vaadin/terminal/gwt/client/communication/JsonDecoder.java b/client/src/com/vaadin/terminal/gwt/client/communication/JsonDecoder.java index ef5090ec18..a98d08c368 100644 --- a/client/src/com/vaadin/terminal/gwt/client/communication/JsonDecoder.java +++ b/client/src/com/vaadin/terminal/gwt/client/communication/JsonDecoder.java @@ -31,6 +31,8 @@ import com.google.gwt.json.client.JSONValue; import com.vaadin.shared.Connector; import com.vaadin.terminal.gwt.client.ApplicationConnection; import com.vaadin.terminal.gwt.client.ConnectorMap; +import com.vaadin.terminal.gwt.client.metadata.NoDataException; +import com.vaadin.terminal.gwt.client.metadata.Property; import com.vaadin.terminal.gwt.client.metadata.Type; /** @@ -106,18 +108,42 @@ public class JsonDecoder { private static Object decodeObject(Type type, JSONValue jsonValue, Object target, ApplicationConnection connection) { - JSONSerializer serializer = connection.getSerializerMap() - .getSerializer(type.getBaseTypeName()); - // TODO handle case with no serializer found - // Currently getSerializer throws exception if not found - - if (target != null && serializer instanceof DiffJSONSerializer) { - DiffJSONSerializer diffSerializer = (DiffJSONSerializer) serializer; - diffSerializer.update(target, type, jsonValue, connection); - return target; + JSONSerializer serializer = (JSONSerializer) type + .findSerializer(); + if (serializer != null) { + if (target != null && serializer instanceof DiffJSONSerializer) { + DiffJSONSerializer diffSerializer = (DiffJSONSerializer) serializer; + diffSerializer.update(target, type, jsonValue, connection); + return target; + } else { + Object object = serializer.deserialize(type, jsonValue, + connection); + return object; + } } else { - Object object = serializer.deserialize(type, jsonValue, connection); - return object; + try { + Collection properties = type.getProperties(); + if (target == null) { + target = type.createInstance(); + } + JSONObject jsonObject = jsonValue.isObject(); + + for (Property property : properties) { + JSONValue encodedPropertyValue = jsonObject.get(property + .getName()); + if (encodedPropertyValue == null) { + continue; + } + Object propertyReference = property.getValue(target); + Object decodedValue = decodeValue(property.getType(), + encodedPropertyValue, propertyReference, connection); + property.setValue(target, decodedValue); + } + return target; + } catch (NoDataException e) { + throw new RuntimeException("Can not deserialize " + + type.getSignature(), e); + } } } diff --git a/client/src/com/vaadin/terminal/gwt/client/communication/JsonEncoder.java b/client/src/com/vaadin/terminal/gwt/client/communication/JsonEncoder.java index 3730cad4c3..9b28da8b34 100644 --- a/client/src/com/vaadin/terminal/gwt/client/communication/JsonEncoder.java +++ b/client/src/com/vaadin/terminal/gwt/client/communication/JsonEncoder.java @@ -33,6 +33,9 @@ import com.vaadin.shared.Connector; import com.vaadin.shared.JsonConstants; import com.vaadin.shared.communication.UidlValue; import com.vaadin.terminal.gwt.client.ApplicationConnection; +import com.vaadin.terminal.gwt.client.metadata.NoDataException; +import com.vaadin.terminal.gwt.client.metadata.Property; +import com.vaadin.terminal.gwt.client.metadata.Type; /** * Encoder for converting RPC parameters and other values to JSON for transfer @@ -99,12 +102,33 @@ public class JsonEncoder { } else { // Try to find a generated serializer object, class name is the // type - transportType = value.getClass().getName(); - JSONSerializer serializer = connection.getSerializerMap() - .getSerializer(transportType); + Type type = new Type(value.getClass()); + + JSONSerializer serializer = (JSONSerializer) type + .findSerializer(); + if (serializer != null) { + return serializer.serialize(value, connection); + } else { + try { + Collection properties = type.getProperties(); + + JSONObject jsonObject = new JSONObject(); + for (Property property : properties) { + Object propertyValue = property.getValue(value); + JSONValue encodedPropertyValue = encode( + propertyValue, restrictToInternalTypes, + connection); + jsonObject.put(property.getName(), + encodedPropertyValue); + } + return jsonObject; + + } catch (NoDataException e) { + throw new RuntimeException("Can not encode " + + type.getSignature(), e); + } + } - // TODO handle case with no serializer found - return serializer.serialize(value, connection); } } } diff --git a/client/src/com/vaadin/terminal/gwt/client/communication/SerializerMap.java b/client/src/com/vaadin/terminal/gwt/client/communication/SerializerMap.java deleted file mode 100644 index 77df4c7b08..0000000000 --- a/client/src/com/vaadin/terminal/gwt/client/communication/SerializerMap.java +++ /dev/null @@ -1,44 +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.terminal.gwt.client.communication; - -/** - * Provide a mapping from a type (communicated between the server and the - * client) and a {@link JSONSerializer} instance. - * - * An implementation of this class is created at GWT compilation time by - * SerializerMapGenerator, so this interface can be instantiated with - * GWT.create(). - * - * @since 7.0 - */ -public interface SerializerMap { - - /** - * Returns a serializer instance for a given type. - * - * @param type - * type communicated on between the server and the client - * (currently fully qualified class name) - * @return serializer instance, not null - * @throws RuntimeException - * if no serializer is found - */ - // TODO better error handling in javadoc and in generator - public JSONSerializer getSerializer(String type); - -} diff --git a/client/src/com/vaadin/terminal/gwt/client/communication/Type.java b/client/src/com/vaadin/terminal/gwt/client/communication/Type.java deleted file mode 100644 index ff93234a1d..0000000000 --- a/client/src/com/vaadin/terminal/gwt/client/communication/Type.java +++ /dev/null @@ -1,52 +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.terminal.gwt.client.communication; - -public class Type { - private final String baseTypeName; - private final Type[] parameterTypes; - - public Type(String baseTypeName, Type[] parameterTypes) { - this.baseTypeName = baseTypeName; - this.parameterTypes = parameterTypes; - } - - public String getBaseTypeName() { - return baseTypeName; - } - - public Type[] getParameterTypes() { - return parameterTypes; - } - - @Override - public String toString() { - String string = baseTypeName; - if (parameterTypes != null) { - string += '<'; - for (int i = 0; i < parameterTypes.length; i++) { - if (i != 0) { - string += ','; - } - string += parameterTypes[i].toString(); - } - string += '>'; - } - - return string; - } - -} diff --git a/client/src/com/vaadin/terminal/gwt/client/metadata/Invoker.java b/client/src/com/vaadin/terminal/gwt/client/metadata/Invoker.java index 5f6a839da6..33e8776429 100644 --- a/client/src/com/vaadin/terminal/gwt/client/metadata/Invoker.java +++ b/client/src/com/vaadin/terminal/gwt/client/metadata/Invoker.java @@ -5,5 +5,5 @@ package com.vaadin.terminal.gwt.client.metadata; public interface Invoker { - public Object invoke(Object target, Object[] params); + public Object invoke(Object target, Object... params); } diff --git a/client/src/com/vaadin/terminal/gwt/client/metadata/Property.java b/client/src/com/vaadin/terminal/gwt/client/metadata/Property.java index 30d864a43f..082d032e64 100644 --- a/client/src/com/vaadin/terminal/gwt/client/metadata/Property.java +++ b/client/src/com/vaadin/terminal/gwt/client/metadata/Property.java @@ -5,16 +5,20 @@ package com.vaadin.terminal.gwt.client.metadata; public class Property { - private final Type type; + private final Type bean; private final String name; - public Property(Type type, String name) { - this.type = type; + public Property(Type bean, String name) { + this.bean = bean; this.name = name; } public Object getValue(Object bean) throws NoDataException { - return TypeDataStore.getGetter(this).invoke(bean, null); + return TypeDataStore.getGetter(this).invoke(bean); + } + + public void setValue(Object bean, Object value) throws NoDataException { + TypeDataStore.getSetter(this).invoke(bean, value); } public String getDelegateToWidgetMethod() { @@ -29,8 +33,12 @@ public class Property { } } + public Type getType() throws NoDataException { + return TypeDataStore.getType(this); + } + public String getSignature() { - return type.toString() + "." + name; + return bean.toString() + "." + name; } @Override @@ -50,4 +58,13 @@ public class Property { return getSignature().hashCode(); } + public String getName() { + return name; + } + + @Override + public String toString() { + return getSignature(); + } + } diff --git a/client/src/com/vaadin/terminal/gwt/client/metadata/Type.java b/client/src/com/vaadin/terminal/gwt/client/metadata/Type.java index 2dc5182845..d869cc2599 100644 --- a/client/src/com/vaadin/terminal/gwt/client/metadata/Type.java +++ b/client/src/com/vaadin/terminal/gwt/client/metadata/Type.java @@ -3,6 +3,10 @@ */ package com.vaadin.terminal.gwt.client.metadata; +import java.util.Collection; + +import com.vaadin.terminal.gwt.client.communication.JSONSerializer; + public class Type { private final String name; private final Type[] parameterTypes; @@ -27,13 +31,17 @@ public class Type { public Object createInstance() throws NoDataException { Invoker invoker = TypeDataStore.getConstructor(this); - return invoker.invoke(null, null); + return invoker.invoke(null); } public Method getMethod(String name) { return new Method(this, name); } + public Collection getProperties() throws NoDataException { + return TypeDataStore.getProperties(this); + } + public Property getProperty(String propertyName) { return new Property(this, propertyName); } @@ -82,4 +90,8 @@ public class Type { .createProxy(invokationHandler); } + public JSONSerializer findSerializer() { + return TypeDataStore.findSerializer(this); + } + } diff --git a/client/src/com/vaadin/terminal/gwt/client/metadata/TypeDataStore.java b/client/src/com/vaadin/terminal/gwt/client/metadata/TypeDataStore.java index f056e46d2d..55740f69da 100644 --- a/client/src/com/vaadin/terminal/gwt/client/metadata/TypeDataStore.java +++ b/client/src/com/vaadin/terminal/gwt/client/metadata/TypeDataStore.java @@ -4,17 +4,23 @@ package com.vaadin.terminal.gwt.client.metadata; +import java.util.Collection; +import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; +import com.vaadin.terminal.gwt.client.communication.JSONSerializer; + public class TypeDataStore { private static final String CONSTRUCTOR_NAME = "!new"; private final Map> identifiers = new HashMap>(); + private final Map serializerFactories = new HashMap(); private final Map proxyHandlers = new HashMap(); + private final Map> properties = new HashMap>(); private final Set delayedMethods = new HashSet(); private final Set lastonlyMethods = new HashSet(); @@ -23,6 +29,8 @@ public class TypeDataStore { private final Map invokers = new HashMap(); private final Map paramTypes = new HashMap(); + private final Map propertyTypes = new HashMap(); + private final Map setters = new HashMap(); private final Map getters = new HashMap(); private final Map delegateToWidget = new HashMap(); @@ -85,6 +93,10 @@ public class TypeDataStore { return getter; } + public void setGetter(Class clazz, String propertyName, Invoker invoker) { + getters.put(new Property(getType(clazz), propertyName), invoker); + } + public static String getDelegateToWidget(Property property) { return get().delegateToWidget.get(property); } @@ -148,4 +160,61 @@ public class TypeDataStore { public void setLastonly(Class clazz, String methodName) { lastonlyMethods.add(getType(clazz).getMethod(methodName)); } + + public static Collection getProperties(Type type) + throws NoDataException { + Collection properties = get().properties.get(type); + if (properties == null) { + throw new NoDataException("No property list for " + + type.getSignature()); + } + return properties; + } + + public void setProperties(Class clazz, String[] propertyNames) { + Set properties = new HashSet(); + Type type = getType(clazz); + for (String name : propertyNames) { + properties.add(new Property(type, name)); + } + this.properties.put(type, Collections.unmodifiableSet(properties)); + } + + public static Type getType(Property property) throws NoDataException { + Type type = get().propertyTypes.get(property); + if (type == null) { + throw new NoDataException("No return type for " + + property.getSignature()); + } + return type; + } + + public void setPropertyType(Class clazz, String propertName, Type type) { + propertyTypes.put(new Property(getType(clazz), propertName), type); + } + + public static Invoker getSetter(Property property) throws NoDataException { + Invoker setter = get().setters.get(property); + if (setter == null) { + throw new NoDataException("No setter for " + + property.getSignature()); + } + return setter; + } + + public void setSetter(Class clazz, String propertyName, Invoker setter) { + setters.put(new Property(getType(clazz), propertyName), setter); + } + + public void setSerializerFactory(Class clazz, Invoker factory) { + serializerFactories.put(getType(clazz), factory); + } + + public static JSONSerializer findSerializer(Type type) { + Invoker factoryCreator = get().serializerFactories.get(type); + if (factoryCreator == null) { + return null; + } + return (JSONSerializer) factoryCreator.invoke(null); + } } -- cgit v1.2.3 From 38358ae25543433f8cc381101bc340adc7e5c67f Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Wed, 22 Aug 2012 20:14:30 +0300 Subject: Support using public fields in state classes (#9324) --- .../ConnectorBundleLoaderFactory.java | 2 +- .../widgetsetutils/metadata/ConnectorBundle.java | 1 + .../gwt/widgetsetutils/metadata/FieldProperty.java | 77 ++++++++++ .../gwt/client/ui/label/LabelConnector.java | 8 +- .../com/vaadin/terminal/gwt/server/JsonCodec.java | 170 +++++++++++++++------ server/src/com/vaadin/ui/Label.java | 10 +- .../src/com/vaadin/shared/ui/label/LabelState.java | 21 +-- .../orderedlayout/AbstractOrderedLayoutState.java | 2 +- .../terminal/gwt/server/JSONSerializerTest.java | 18 +-- 9 files changed, 218 insertions(+), 91 deletions(-) create mode 100644 client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/FieldProperty.java diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorBundleLoaderFactory.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorBundleLoaderFactory.java index 9a5b83f460..a2e61947e8 100644 --- a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorBundleLoaderFactory.java +++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorBundleLoaderFactory.java @@ -219,7 +219,7 @@ public class ConnectorBundleLoaderFactory extends Generator { writeClassLiteral(w, property.getBeanType()); w.print(", \""); w.print(escape(property.getName())); - w.print("\", new Invoker() {"); + w.println("\", new Invoker() {"); w.indent(); w.println("public Object invoke(Object bean, Object[] params) {"); diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ConnectorBundle.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ConnectorBundle.java index ad6b1eb102..7515124a5a 100644 --- a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ConnectorBundle.java +++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ConnectorBundle.java @@ -372,6 +372,7 @@ public class ConnectorBundle { HashSet properties = new HashSet(); properties.addAll(MethodProperty.findProperties(type)); + properties.addAll(FieldProperty.findProperties(type)); return properties; } diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/FieldProperty.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/FieldProperty.java new file mode 100644 index 0000000000..31555cc30b --- /dev/null +++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/FieldProperty.java @@ -0,0 +1,77 @@ +/* + * 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.terminal.gwt.widgetsetutils.metadata; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import com.google.gwt.core.ext.TreeLogger; +import com.google.gwt.core.ext.typeinfo.JClassType; +import com.google.gwt.core.ext.typeinfo.JField; +import com.google.gwt.user.rebind.SourceWriter; + +public class FieldProperty extends Property { + + private FieldProperty(JClassType beanType, JField field) { + super(field.getName(), beanType, field.getType()); + } + + @Override + public void writeSetterBody(TreeLogger logger, SourceWriter w, + String beanVariable, String valueVariable) { + w.print("((%s) %s).%s = (%s)%s;", getBeanType() + .getQualifiedSourceName(), beanVariable, getName(), + getUnboxedPropertyTypeName(), valueVariable); + } + + @Override + public void writeGetterBody(TreeLogger logger, SourceWriter w, + String beanVariable) { + w.print("return ((%s) %s).%s;", getBeanType().getQualifiedSourceName(), + beanVariable, getName()); + } + + public static Collection findProperties(JClassType type) { + Collection properties = new ArrayList(); + + List fields = getPublicFields(type); + for (JField field : fields) { + properties.add(new FieldProperty(type, field)); + } + + return properties; + } + + private static List getPublicFields(JClassType type) { + Set names = new HashSet(); + ArrayList fields = new ArrayList(); + for (JClassType subType : type.getFlattenedSupertypeHierarchy()) { + JField[] subFields = subType.getFields(); + for (JField field : subFields) { + if (field.isPublic() && !field.isStatic() + && names.add(field.getName())) { + fields.add(field); + } + } + } + return fields; + } + +} diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/label/LabelConnector.java b/client/src/com/vaadin/terminal/gwt/client/ui/label/LabelConnector.java index 4280db8bc9..57f8c16952 100644 --- a/client/src/com/vaadin/terminal/gwt/client/ui/label/LabelConnector.java +++ b/client/src/com/vaadin/terminal/gwt/client/ui/label/LabelConnector.java @@ -43,10 +43,10 @@ public class LabelConnector extends AbstractComponentConnector { public void onStateChanged(StateChangeEvent stateChangeEvent) { super.onStateChanged(stateChangeEvent); boolean sinkOnloads = false; - switch (getState().getContentMode()) { + switch (getState().contentMode) { case PREFORMATTED: PreElement preElement = Document.get().createPreElement(); - preElement.setInnerText(getState().getText()); + preElement.setInnerText(getState().text); // clear existing content getWidget().setHTML(""); // add preformatted text to dom @@ -54,14 +54,14 @@ public class LabelConnector extends AbstractComponentConnector { break; case TEXT: - getWidget().setText(getState().getText()); + getWidget().setText(getState().text); break; case XHTML: case RAW: sinkOnloads = true; case XML: - getWidget().setHTML(getState().getText()); + getWidget().setHTML(getState().text); break; default: getWidget().setText(""); diff --git a/server/src/com/vaadin/terminal/gwt/server/JsonCodec.java b/server/src/com/vaadin/terminal/gwt/server/JsonCodec.java index 892f7ec526..1eee9c4f52 100644 --- a/server/src/com/vaadin/terminal/gwt/server/JsonCodec.java +++ b/server/src/com/vaadin/terminal/gwt/server/JsonCodec.java @@ -21,9 +21,10 @@ import java.beans.Introspector; import java.beans.PropertyDescriptor; import java.io.Serializable; import java.lang.reflect.Array; +import java.lang.reflect.Field; import java.lang.reflect.GenericArrayType; -import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.lang.reflect.Modifier; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import java.lang.reflect.WildcardType; @@ -55,6 +56,107 @@ import com.vaadin.ui.ConnectorTracker; */ public class JsonCodec implements Serializable { + public static interface BeanProperty { + public Object getValue(Object bean) throws Exception; + + public void setValue(Object bean, Object value) throws Exception; + + public String getName(); + + public Type getType(); + } + + private static class FieldProperty implements BeanProperty { + private final Field field; + + public FieldProperty(Field field) { + this.field = field; + } + + @Override + public Object getValue(Object bean) throws Exception { + return field.get(bean); + } + + @Override + public void setValue(Object bean, Object value) throws Exception { + field.set(bean, value); + } + + @Override + public String getName() { + return field.getName(); + } + + @Override + public Type getType() { + return field.getGenericType(); + } + + public static Collection find(Class type) + throws IntrospectionException { + Collection properties = new ArrayList(); + + Field[] fields = type.getFields(); + for (Field field : fields) { + if (!Modifier.isStatic(field.getModifiers())) { + properties.add(new FieldProperty(field)); + } + } + + return properties; + } + + } + + private static class MethodProperty implements BeanProperty { + private final PropertyDescriptor pd; + + public MethodProperty(PropertyDescriptor pd) { + this.pd = pd; + } + + @Override + public Object getValue(Object bean) throws Exception { + Method readMethod = pd.getReadMethod(); + return readMethod.invoke(bean); + } + + @Override + public void setValue(Object bean, Object value) throws Exception { + pd.getWriteMethod().invoke(bean, value); + } + + @Override + public String getName() { + String fieldName = pd.getWriteMethod().getName().substring(3); + fieldName = Character.toLowerCase(fieldName.charAt(0)) + + fieldName.substring(1); + return fieldName; + } + + public static Collection find(Class type) + throws IntrospectionException { + Collection properties = new ArrayList(); + + for (PropertyDescriptor pd : Introspector.getBeanInfo(type) + .getPropertyDescriptors()) { + if (pd.getReadMethod() == null || pd.getWriteMethod() == null) { + continue; + } + + properties.add(new MethodProperty(pd)); + } + return properties; + } + + @Override + public Type getType() { + return pd.getReadMethod().getGenericReturnType(); + } + + } + private static Map, String> typeToTransportType = new HashMap, String>(); /** @@ -468,27 +570,6 @@ public class JsonCodec implements Serializable { return set; } - /** - * Returns the name that should be used as field name in the JSON. We strip - * "set" from the setter, keeping the result - this is easy to do on both - * server and client, avoiding some issues with cASE. E.g setZIndex() - * becomes "zIndex". Also ensures that both getter and setter are present, - * returning null otherwise. - * - * @param pd - * @return the name to be used or null if both getter and setter are not - * found. - */ - static String getTransportFieldName(PropertyDescriptor pd) { - if (pd.getReadMethod() == null || pd.getWriteMethod() == null) { - return null; - } - String fieldName = pd.getWriteMethod().getName().substring(3); - fieldName = Character.toLowerCase(fieldName.charAt(0)) - + fieldName.substring(1); - return fieldName; - } - private static Object decodeObject(Type targetType, JSONObject serializedObject, ConnectorTracker connectorTracker) throws JSONException { @@ -497,31 +578,19 @@ public class JsonCodec implements Serializable { try { Object decodedObject = targetClass.newInstance(); - for (PropertyDescriptor pd : Introspector.getBeanInfo(targetClass) - .getPropertyDescriptors()) { + for (BeanProperty property : getProperties(targetClass)) { - String fieldName = getTransportFieldName(pd); - if (fieldName == null) { - continue; - } + String fieldName = property.getName(); Object encodedFieldValue = serializedObject.get(fieldName); - Type fieldType = pd.getReadMethod().getGenericReturnType(); + Type fieldType = property.getType(); Object decodedFieldValue = decodeInternalOrCustomType( fieldType, encodedFieldValue, connectorTracker); - pd.getWriteMethod().invoke(decodedObject, decodedFieldValue); + property.setValue(decodedObject, decodedFieldValue); } return decodedObject; - } catch (IllegalArgumentException e) { - throw new JSONException(e); - } catch (IllegalAccessException e) { - throw new JSONException(e); - } catch (InvocationTargetException e) { - throw new JSONException(e); - } catch (InstantiationException e) { - throw new JSONException(e); - } catch (IntrospectionException e) { + } catch (Exception e) { throw new JSONException(e); } } @@ -602,22 +671,27 @@ public class JsonCodec implements Serializable { return JSONObject.NULL; } + public static Collection getProperties(Class type) + throws IntrospectionException { + Collection properties = new ArrayList(); + + properties.addAll(MethodProperty.find(type)); + properties.addAll(FieldProperty.find(type)); + + return properties; + } + private static Object encodeObject(Object value, JSONObject diffState, ConnectorTracker connectorTracker) throws JSONException { JSONObject jsonMap = new JSONObject(); try { - for (PropertyDescriptor pd : Introspector.getBeanInfo( - value.getClass()).getPropertyDescriptors()) { - String fieldName = getTransportFieldName(pd); - if (fieldName == null) { - continue; - } - Method getterMethod = pd.getReadMethod(); + for (BeanProperty property : getProperties(value.getClass())) { + String fieldName = property.getName(); // We can't use PropertyDescriptor.getPropertyType() as it does // not support generics - Type fieldType = getterMethod.getGenericReturnType(); - Object fieldValue = getterMethod.invoke(value, (Object[]) null); + Type fieldType = property.getType(); + Object fieldValue = property.getValue(value); boolean equals = false; Object diffStateValue = null; if (diffState != null && diffState.has(fieldName)) { diff --git a/server/src/com/vaadin/ui/Label.java b/server/src/com/vaadin/ui/Label.java index 668b99a74c..10fa741058 100644 --- a/server/src/com/vaadin/ui/Label.java +++ b/server/src/com/vaadin/ui/Label.java @@ -168,7 +168,7 @@ public class Label extends AbstractComponent implements Property, public String getValue() { if (getPropertyDataSource() == null) { // Use internal value if we are running without a data source - return getState().getText(); + return getState().text; } return ConverterUtil.convertFromModel(getPropertyDataSource() .getValue(), String.class, getConverter(), getLocale()); @@ -189,7 +189,7 @@ public class Label extends AbstractComponent implements Property, + String.class.getName()); } if (getPropertyDataSource() == null) { - getState().setText((String) newStringValue); + getState().text = (String) newStringValue; requestRepaint(); } else { throw new IllegalStateException( @@ -277,7 +277,7 @@ public class Label extends AbstractComponent implements Property, * @see ContentMode */ public ContentMode getContentMode() { - return getState().getContentMode(); + return getState().contentMode; } /** @@ -293,7 +293,7 @@ public class Label extends AbstractComponent implements Property, throw new IllegalArgumentException("Content mode can not be null"); } - getState().setContentMode(contentMode); + getState().contentMode = contentMode; requestRepaint(); } @@ -384,7 +384,7 @@ public class Label extends AbstractComponent implements Property, @Override public void valueChange(Property.ValueChangeEvent event) { // Update the internal value from the data source - getState().setText(getValue()); + getState().text = getValue(); requestRepaint(); fireValueChange(); diff --git a/shared/src/com/vaadin/shared/ui/label/LabelState.java b/shared/src/com/vaadin/shared/ui/label/LabelState.java index 35e27bc63d..a91aeb0aa1 100644 --- a/shared/src/com/vaadin/shared/ui/label/LabelState.java +++ b/shared/src/com/vaadin/shared/ui/label/LabelState.java @@ -18,23 +18,6 @@ package com.vaadin.shared.ui.label; import com.vaadin.shared.ComponentState; public class LabelState extends ComponentState { - private ContentMode contentMode = ContentMode.TEXT; - private String text = ""; - - public ContentMode getContentMode() { - return contentMode; - } - - public void setContentMode(ContentMode contentMode) { - this.contentMode = contentMode; - } - - public String getText() { - return text; - } - - public void setText(String text) { - this.text = text; - } - + public ContentMode contentMode = ContentMode.TEXT; + public String text = ""; } diff --git a/shared/src/com/vaadin/shared/ui/orderedlayout/AbstractOrderedLayoutState.java b/shared/src/com/vaadin/shared/ui/orderedlayout/AbstractOrderedLayoutState.java index 3fa2ad771c..35456ab9ac 100644 --- a/shared/src/com/vaadin/shared/ui/orderedlayout/AbstractOrderedLayoutState.java +++ b/shared/src/com/vaadin/shared/ui/orderedlayout/AbstractOrderedLayoutState.java @@ -25,7 +25,7 @@ import com.vaadin.shared.ui.AlignmentInfo; public class AbstractOrderedLayoutState extends AbstractLayoutState { private boolean spacing = false; - public HashMap childData = new HashMap(); + private HashMap childData = new HashMap(); private int marginsBitmask = 0; diff --git a/tests/client-side/com/vaadin/terminal/gwt/server/JSONSerializerTest.java b/tests/client-side/com/vaadin/terminal/gwt/server/JSONSerializerTest.java index 16cc0ede98..7775b667a1 100644 --- a/tests/client-side/com/vaadin/terminal/gwt/server/JSONSerializerTest.java +++ b/tests/client-side/com/vaadin/terminal/gwt/server/JSONSerializerTest.java @@ -1,7 +1,7 @@ package com.vaadin.terminal.gwt.server; /* - * Copyright 2011 Vaadin Ltd. + * 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 @@ -15,9 +15,6 @@ package com.vaadin.terminal.gwt.server; * License for the specific language governing permissions and limitations under * the License. */ -import java.beans.BeanInfo; -import java.beans.Introspector; -import java.beans.PropertyDescriptor; import java.lang.reflect.Type; import java.util.Collection; import java.util.HashMap; @@ -28,6 +25,7 @@ import junit.framework.TestCase; import com.vaadin.shared.ui.splitpanel.AbstractSplitPanelState; import com.vaadin.terminal.gwt.client.communication.JsonDecoder; import com.vaadin.terminal.gwt.client.communication.JsonEncoder; +import com.vaadin.terminal.gwt.server.JsonCodec.BeanProperty; /** * Tests for {@link JsonCodec}, {@link JsonEncoder}, {@link JsonDecoder} @@ -118,15 +116,9 @@ public class JSONSerializerTest extends TestCase { } private boolean equalsBean(Object o1, Object o2) throws Exception { - BeanInfo beanInfo = Introspector.getBeanInfo(o1.getClass()); - for (PropertyDescriptor pd : beanInfo.getPropertyDescriptors()) { - String fieldName = JsonCodec.getTransportFieldName(pd); - if (fieldName == null) { - continue; - } - - Object c1 = pd.getReadMethod().invoke(o1); - Object c2 = pd.getReadMethod().invoke(o2); + for (BeanProperty property : JsonCodec.getProperties(o1.getClass())) { + Object c1 = property.getValue(o1); + Object c2 = property.getValue(o2); if (!equals(c1, c2)) { return false; } -- cgit v1.2.3 From 050bec8a443b916e45adf4bf7ea91241690d37e2 Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Wed, 22 Aug 2012 21:12:47 +0300 Subject: Make the (server-side) getState method protected (#9315) --- .../terminal/gwt/client/ServerConnector.java | 10 +++ .../vaadin/terminal/AbstractClientConnector.java | 11 ++- .../terminal/AbstractJavaScriptExtension.java | 2 +- .../gwt/server/AbstractCommunicationManager.java | 83 +++++++++++----------- .../terminal/gwt/server/ClientConnector.java | 14 ++++ .../terminal/gwt/server/DragAndDropService.java | 14 ++-- server/src/com/vaadin/ui/AbsoluteLayout.java | 2 +- server/src/com/vaadin/ui/AbstractComponent.java | 2 +- server/src/com/vaadin/ui/AbstractField.java | 2 +- .../com/vaadin/ui/AbstractJavaScriptComponent.java | 9 +-- server/src/com/vaadin/ui/AbstractLayout.java | 2 +- server/src/com/vaadin/ui/AbstractMedia.java | 2 +- .../src/com/vaadin/ui/AbstractOrderedLayout.java | 5 +- server/src/com/vaadin/ui/AbstractSplitPanel.java | 2 +- server/src/com/vaadin/ui/AbstractTextField.java | 2 +- server/src/com/vaadin/ui/Button.java | 2 +- server/src/com/vaadin/ui/CheckBox.java | 2 +- server/src/com/vaadin/ui/Component.java | 14 ---- server/src/com/vaadin/ui/CssLayout.java | 2 +- server/src/com/vaadin/ui/CustomLayout.java | 2 +- server/src/com/vaadin/ui/Form.java | 2 +- server/src/com/vaadin/ui/GridLayout.java | 2 +- server/src/com/vaadin/ui/JavaScript.java | 2 +- server/src/com/vaadin/ui/Label.java | 2 +- server/src/com/vaadin/ui/Panel.java | 2 +- server/src/com/vaadin/ui/Root.java | 2 +- server/src/com/vaadin/ui/TextArea.java | 2 +- server/src/com/vaadin/ui/Video.java | 2 +- server/src/com/vaadin/ui/Window.java | 2 +- shared/src/com/vaadin/shared/Connector.java | 11 --- 30 files changed, 113 insertions(+), 100 deletions(-) diff --git a/client/src/com/vaadin/terminal/gwt/client/ServerConnector.java b/client/src/com/vaadin/terminal/gwt/client/ServerConnector.java index 8788de74bf..d988c5f4a2 100644 --- a/client/src/com/vaadin/terminal/gwt/client/ServerConnector.java +++ b/client/src/com/vaadin/terminal/gwt/client/ServerConnector.java @@ -22,6 +22,7 @@ import com.google.gwt.event.shared.GwtEvent; import com.google.web.bindery.event.shared.HandlerRegistration; import com.vaadin.shared.Connector; import com.vaadin.shared.communication.ClientRpc; +import com.vaadin.shared.communication.SharedState; import com.vaadin.terminal.gwt.client.communication.StateChangeEvent.StateChangeHandler; /** @@ -142,4 +143,13 @@ public interface ServerConnector extends Connector { public void setChildren(List children); public List getChildren(); + + /** + * Gets the current shared state of the connector. + * + * @since 7.0. + * @return state The shared state object. Can be any sub type of + * {@link SharedState}. Never null. + */ + public SharedState getState(); } diff --git a/server/src/com/vaadin/terminal/AbstractClientConnector.java b/server/src/com/vaadin/terminal/AbstractClientConnector.java index bc1cd2af1a..a8da553a62 100644 --- a/server/src/com/vaadin/terminal/AbstractClientConnector.java +++ b/server/src/com/vaadin/terminal/AbstractClientConnector.java @@ -31,9 +31,12 @@ import java.util.NoSuchElementException; import java.util.logging.Logger; import com.vaadin.Application; +import com.vaadin.external.json.JSONException; +import com.vaadin.external.json.JSONObject; import com.vaadin.shared.communication.ClientRpc; import com.vaadin.shared.communication.ServerRpc; import com.vaadin.shared.communication.SharedState; +import com.vaadin.terminal.gwt.server.AbstractCommunicationManager; import com.vaadin.terminal.gwt.server.ClientConnector; import com.vaadin.terminal.gwt.server.ClientMethodInvocation; import com.vaadin.terminal.gwt.server.RpcManager; @@ -137,14 +140,18 @@ public abstract class AbstractClientConnector implements ClientConnector { registerRpc(implementation, type); } - @Override - public SharedState getState() { + protected SharedState getState() { if (null == sharedState) { sharedState = createState(); } return sharedState; } + @Override + public JSONObject encodeState() throws JSONException { + return AbstractCommunicationManager.encodeState(this, getState()); + } + /** * Creates the shared state bean to be used in server to client * communication. diff --git a/server/src/com/vaadin/terminal/AbstractJavaScriptExtension.java b/server/src/com/vaadin/terminal/AbstractJavaScriptExtension.java index aae71640aa..1def6df697 100644 --- a/server/src/com/vaadin/terminal/AbstractJavaScriptExtension.java +++ b/server/src/com/vaadin/terminal/AbstractJavaScriptExtension.java @@ -166,7 +166,7 @@ public abstract class AbstractJavaScriptExtension extends AbstractExtension { } @Override - public JavaScriptExtensionState getState() { + protected JavaScriptExtensionState getState() { return (JavaScriptExtensionState) super.getState(); } } diff --git a/server/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java b/server/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java index 99376ffd1f..7ea4a7d097 100644 --- a/server/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java +++ b/server/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java @@ -880,49 +880,19 @@ public abstract class AbstractCommunicationManager implements Serializable { // processing. JSONObject sharedStates = new JSONObject(); for (ClientConnector connector : dirtyVisibleConnectors) { - SharedState state = connector.getState(); - if (null != state) { - // encode and send shared state - try { - Class stateType = connector - .getStateType(); - Object diffState = rootConnectorTracker - .getDiffState(connector); - if (diffState == null) { - diffState = new JSONObject(); - // Use an empty state object as reference for full - // repaints - boolean emptyInitialState = JavaScriptConnectorState.class - .isAssignableFrom(stateType); - if (!emptyInitialState) { - try { - SharedState referenceState = stateType - .newInstance(); - diffState = JsonCodec.encode(referenceState, - null, stateType, - root.getConnectorTracker()); - } catch (Exception e) { - getLogger().log( - Level.WARNING, - "Error creating reference object for state of type " - + stateType.getName()); - } - } - rootConnectorTracker.setDiffState(connector, diffState); - } - JSONObject stateJson = (JSONObject) JsonCodec.encode(state, - diffState, stateType, root.getConnectorTracker()); + // encode and send shared state + try { + JSONObject stateJson = connector.encodeState(); - if (stateJson.length() != 0) { - sharedStates.put(connector.getConnectorId(), stateJson); - } - } catch (JSONException e) { - throw new PaintException( - "Failed to serialize shared state for connector " - + connector.getClass().getName() + " (" - + connector.getConnectorId() + "): " - + e.getMessage(), e); + if (stateJson != null && stateJson.length() != 0) { + sharedStates.put(connector.getConnectorId(), stateJson); } + } catch (JSONException e) { + throw new PaintException( + "Failed to serialize shared state for connector " + + connector.getClass().getName() + " (" + + connector.getConnectorId() + "): " + + e.getMessage(), e); } } outWriter.print("\"state\":"); @@ -1273,6 +1243,37 @@ public abstract class AbstractCommunicationManager implements Serializable { writePerformanceData(outWriter); } + public static JSONObject encodeState(ClientConnector connector, + SharedState state) throws JSONException { + Root root = connector.getRoot(); + ConnectorTracker connectorTracker = root.getConnectorTracker(); + Class stateType = connector.getStateType(); + Object diffState = connectorTracker.getDiffState(connector); + if (diffState == null) { + diffState = new JSONObject(); + // Use an empty state object as reference for full + // repaints + boolean emptyInitialState = JavaScriptConnectorState.class + .isAssignableFrom(stateType); + if (!emptyInitialState) { + try { + SharedState referenceState = stateType.newInstance(); + diffState = JsonCodec.encode(referenceState, null, + stateType, root.getConnectorTracker()); + } catch (Exception e) { + getLogger().log( + Level.WARNING, + "Error creating reference object for state of type " + + stateType.getName()); + } + } + connectorTracker.setDiffState(connector, diffState); + } + JSONObject stateJson = (JSONObject) JsonCodec.encode(state, diffState, + stateType, root.getConnectorTracker()); + return stateJson; + } + /** * Resolves a resource URI, registering the URI with this * {@code AbstractCommunicationManager} if needed and returns a fully diff --git a/server/src/com/vaadin/terminal/gwt/server/ClientConnector.java b/server/src/com/vaadin/terminal/gwt/server/ClientConnector.java index c9fe2563f9..87524fe28f 100644 --- a/server/src/com/vaadin/terminal/gwt/server/ClientConnector.java +++ b/server/src/com/vaadin/terminal/gwt/server/ClientConnector.java @@ -18,6 +18,8 @@ package com.vaadin.terminal.gwt.server; import java.util.Collection; import java.util.List; +import com.vaadin.external.json.JSONException; +import com.vaadin.external.json.JSONObject; import com.vaadin.shared.Connector; import com.vaadin.shared.communication.SharedState; import com.vaadin.terminal.AbstractClientConnector; @@ -177,4 +179,16 @@ public interface ClientConnector extends Connector, RpcTarget { * @since 7.0 */ public void beforeClientResponse(boolean initial); + + /** + * Called by the framework to encode the state to a JSONObject. This is + * typically done by calling the static method + * {@link AbstractCommunicationManager#encodeState(ClientConnector, SharedState)} + * . + * + * @return a JSON object with the encoded connector state + * @throws JSONException + * if the state can not be encoded + */ + public JSONObject encodeState() throws JSONException; } diff --git a/server/src/com/vaadin/terminal/gwt/server/DragAndDropService.java b/server/src/com/vaadin/terminal/gwt/server/DragAndDropService.java index 56d5ed1393..981d2569d1 100644 --- a/server/src/com/vaadin/terminal/gwt/server/DragAndDropService.java +++ b/server/src/com/vaadin/terminal/gwt/server/DragAndDropService.java @@ -31,6 +31,8 @@ import com.vaadin.event.dd.DropTarget; import com.vaadin.event.dd.TargetDetails; import com.vaadin.event.dd.TargetDetailsImpl; import com.vaadin.event.dd.acceptcriteria.AcceptCriterion; +import com.vaadin.external.json.JSONException; +import com.vaadin.external.json.JSONObject; import com.vaadin.shared.ApplicationConstants; import com.vaadin.shared.communication.SharedState; import com.vaadin.shared.ui.dd.DragEventType; @@ -234,12 +236,6 @@ public class DragAndDropService implements VariableOwner, ClientConnector { return false; } - @Override - public SharedState getState() { - // TODO Auto-generated method stub - return null; - } - @Override public String getConnectorId() { return ApplicationConstants.DRAG_AND_DROP_CONNECTOR_ID; @@ -327,4 +323,10 @@ public class DragAndDropService implements VariableOwner, ClientConnector { public void beforeClientResponse(boolean initial) { // Nothing to do } + + @Override + public JSONObject encodeState() throws JSONException { + // TODO Auto-generated method stub + return null; + } } diff --git a/server/src/com/vaadin/ui/AbsoluteLayout.java b/server/src/com/vaadin/ui/AbsoluteLayout.java index a3bc577fe3..8981895717 100644 --- a/server/src/com/vaadin/ui/AbsoluteLayout.java +++ b/server/src/com/vaadin/ui/AbsoluteLayout.java @@ -61,7 +61,7 @@ public class AbsoluteLayout extends AbstractLayout implements } @Override - public AbsoluteLayoutState getState() { + protected AbsoluteLayoutState getState() { return (AbsoluteLayoutState) super.getState(); } diff --git a/server/src/com/vaadin/ui/AbstractComponent.java b/server/src/com/vaadin/ui/AbstractComponent.java index cde5217ca1..1eb95311cd 100644 --- a/server/src/com/vaadin/ui/AbstractComponent.java +++ b/server/src/com/vaadin/ui/AbstractComponent.java @@ -713,7 +713,7 @@ public abstract class AbstractComponent extends AbstractClientConnector * @return updated component shared state */ @Override - public ComponentState getState() { + protected ComponentState getState() { return (ComponentState) super.getState(); } diff --git a/server/src/com/vaadin/ui/AbstractField.java b/server/src/com/vaadin/ui/AbstractField.java index b914fb4c46..8ac7b21daf 100644 --- a/server/src/com/vaadin/ui/AbstractField.java +++ b/server/src/com/vaadin/ui/AbstractField.java @@ -1615,7 +1615,7 @@ public abstract class AbstractField extends AbstractComponent implements } @Override - public AbstractFieldState getState() { + protected AbstractFieldState getState() { return (AbstractFieldState) super.getState(); } diff --git a/server/src/com/vaadin/ui/AbstractJavaScriptComponent.java b/server/src/com/vaadin/ui/AbstractJavaScriptComponent.java index c442bf2204..67b6447ef9 100644 --- a/server/src/com/vaadin/ui/AbstractJavaScriptComponent.java +++ b/server/src/com/vaadin/ui/AbstractJavaScriptComponent.java @@ -17,6 +17,8 @@ package com.vaadin.ui; import com.vaadin.shared.ui.JavaScriptComponentState; import com.vaadin.terminal.JavaScriptCallbackHelper; +import com.vaadin.terminal.gwt.client.ApplicationConnection; +import com.vaadin.terminal.gwt.client.ui.JavaScriptWidget; /** * Base class for Components with all client-side logic implemented using @@ -90,9 +92,8 @@ import com.vaadin.terminal.JavaScriptCallbackHelper; * {@link #addFunction(String, JavaScriptFunction)} on the server will * automatically be present as a function that triggers the registered function * on the server. - *
  • Any field name referred to using - * {@link #callFunction(String, Object...)} on the server will be called if a - * function has been assigned to the field.
  • + *
  • Any field name referred to using {@link #callFunction(String, Object...)} + * on the server will be called if a function has been assigned to the field.
  • * *

    * @@ -168,7 +169,7 @@ public abstract class AbstractJavaScriptComponent extends AbstractComponent { } @Override - public JavaScriptComponentState getState() { + protected JavaScriptComponentState getState() { return (JavaScriptComponentState) super.getState(); } } diff --git a/server/src/com/vaadin/ui/AbstractLayout.java b/server/src/com/vaadin/ui/AbstractLayout.java index dd1d5eab12..6743b09211 100644 --- a/server/src/com/vaadin/ui/AbstractLayout.java +++ b/server/src/com/vaadin/ui/AbstractLayout.java @@ -29,7 +29,7 @@ public abstract class AbstractLayout extends AbstractComponentContainer implements Layout { @Override - public AbstractLayoutState getState() { + protected AbstractLayoutState getState() { return (AbstractLayoutState) super.getState(); } diff --git a/server/src/com/vaadin/ui/AbstractMedia.java b/server/src/com/vaadin/ui/AbstractMedia.java index 51a3bcd2be..7a29c8f4ce 100644 --- a/server/src/com/vaadin/ui/AbstractMedia.java +++ b/server/src/com/vaadin/ui/AbstractMedia.java @@ -33,7 +33,7 @@ import com.vaadin.terminal.gwt.server.ResourceReference; public abstract class AbstractMedia extends AbstractComponent { @Override - public AbstractMediaState getState() { + protected AbstractMediaState getState() { return (AbstractMediaState) super.getState(); } diff --git a/server/src/com/vaadin/ui/AbstractOrderedLayout.java b/server/src/com/vaadin/ui/AbstractOrderedLayout.java index 3ac4e76bdb..cac9c05fb8 100644 --- a/server/src/com/vaadin/ui/AbstractOrderedLayout.java +++ b/server/src/com/vaadin/ui/AbstractOrderedLayout.java @@ -63,7 +63,7 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements } @Override - public AbstractOrderedLayoutState getState() { + protected AbstractOrderedLayoutState getState() { return (AbstractOrderedLayoutState) super.getState(); } @@ -394,6 +394,7 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements return components.get(index); } + @Override public void setMargin(boolean enabled) { setMargin(new MarginInfo(enabled)); } @@ -403,6 +404,7 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements * * @see com.vaadin.ui.Layout.MarginHandler#getMargin() */ + @Override public MarginInfo getMargin() { return new MarginInfo(getState().getMarginsBitmask()); } @@ -412,6 +414,7 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements * * @see com.vaadin.ui.Layout.MarginHandler#setMargin(MarginInfo) */ + @Override public void setMargin(MarginInfo marginInfo) { getState().setMarginsBitmask(marginInfo.getBitMask()); requestRepaint(); diff --git a/server/src/com/vaadin/ui/AbstractSplitPanel.java b/server/src/com/vaadin/ui/AbstractSplitPanel.java index 03e8a2dfb6..68964e2c35 100644 --- a/server/src/com/vaadin/ui/AbstractSplitPanel.java +++ b/server/src/com/vaadin/ui/AbstractSplitPanel.java @@ -520,7 +520,7 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer { } @Override - public AbstractSplitPanelState getState() { + protected AbstractSplitPanelState getState() { return (AbstractSplitPanelState) super.getState(); } diff --git a/server/src/com/vaadin/ui/AbstractTextField.java b/server/src/com/vaadin/ui/AbstractTextField.java index 86315f801f..54d15eff26 100644 --- a/server/src/com/vaadin/ui/AbstractTextField.java +++ b/server/src/com/vaadin/ui/AbstractTextField.java @@ -92,7 +92,7 @@ public abstract class AbstractTextField extends AbstractField implements } @Override - public AbstractTextFieldState getState() { + protected AbstractTextFieldState getState() { return (AbstractTextFieldState) super.getState(); } diff --git a/server/src/com/vaadin/ui/Button.java b/server/src/com/vaadin/ui/Button.java index f568d770e8..c55a955679 100644 --- a/server/src/com/vaadin/ui/Button.java +++ b/server/src/com/vaadin/ui/Button.java @@ -509,7 +509,7 @@ public class Button extends AbstractComponent implements } @Override - public ButtonState getState() { + protected ButtonState getState() { return (ButtonState) super.getState(); } diff --git a/server/src/com/vaadin/ui/CheckBox.java b/server/src/com/vaadin/ui/CheckBox.java index 158c9d0032..6da86b9711 100644 --- a/server/src/com/vaadin/ui/CheckBox.java +++ b/server/src/com/vaadin/ui/CheckBox.java @@ -106,7 +106,7 @@ public class CheckBox extends AbstractField { } @Override - public CheckBoxState getState() { + protected CheckBoxState getState() { return (CheckBoxState) super.getState(); } diff --git a/server/src/com/vaadin/ui/Component.java b/server/src/com/vaadin/ui/Component.java index ff7ed47930..89e282d4e1 100644 --- a/server/src/com/vaadin/ui/Component.java +++ b/server/src/com/vaadin/ui/Component.java @@ -23,7 +23,6 @@ import java.util.Locale; import com.vaadin.Application; import com.vaadin.event.FieldEvents; -import com.vaadin.shared.ComponentState; import com.vaadin.terminal.ErrorMessage; import com.vaadin.terminal.Resource; import com.vaadin.terminal.Sizeable; @@ -623,19 +622,6 @@ public interface Component extends ClientConnector, Sizeable, Serializable { */ public Locale getLocale(); - /** - * Returns the current shared state bean for the component. The state (or - * changes to it) is communicated from the server to the client. - * - * Subclasses can use a more specific return type for this method. - * - * @return The state object for the component - * - * @since 7.0 - */ - @Override - public ComponentState getState(); - /** * Adds an unique id for component that get's transferred to terminal for * testing purposes. Keeping identifiers unique is the responsibility of the diff --git a/server/src/com/vaadin/ui/CssLayout.java b/server/src/com/vaadin/ui/CssLayout.java index 0192debc4a..c80986b768 100644 --- a/server/src/com/vaadin/ui/CssLayout.java +++ b/server/src/com/vaadin/ui/CssLayout.java @@ -211,7 +211,7 @@ public class CssLayout extends AbstractLayout implements LayoutClickNotifier { } @Override - public CssLayoutState getState() { + protected CssLayoutState getState() { return (CssLayoutState) super.getState(); } diff --git a/server/src/com/vaadin/ui/CustomLayout.java b/server/src/com/vaadin/ui/CustomLayout.java index d47b2f92b3..0948a92e5b 100644 --- a/server/src/com/vaadin/ui/CustomLayout.java +++ b/server/src/com/vaadin/ui/CustomLayout.java @@ -123,7 +123,7 @@ public class CustomLayout extends AbstractLayout implements Vaadin6Component { } @Override - public CustomLayoutState getState() { + protected CustomLayoutState getState() { return (CustomLayoutState) super.getState(); } diff --git a/server/src/com/vaadin/ui/Form.java b/server/src/com/vaadin/ui/Form.java index a1ec0f9917..8efd85009c 100644 --- a/server/src/com/vaadin/ui/Form.java +++ b/server/src/com/vaadin/ui/Form.java @@ -200,7 +200,7 @@ public class Form extends AbstractField implements Item.Editor, } @Override - public FormState getState() { + protected FormState getState() { return (FormState) super.getState(); } diff --git a/server/src/com/vaadin/ui/GridLayout.java b/server/src/com/vaadin/ui/GridLayout.java index b31ab82741..52aef4c253 100644 --- a/server/src/com/vaadin/ui/GridLayout.java +++ b/server/src/com/vaadin/ui/GridLayout.java @@ -141,7 +141,7 @@ public class GridLayout extends AbstractLayout implements } @Override - public GridLayoutState getState() { + protected GridLayoutState getState() { return (GridLayoutState) super.getState(); } diff --git a/server/src/com/vaadin/ui/JavaScript.java b/server/src/com/vaadin/ui/JavaScript.java index 35cc1893f6..5984c63e7a 100644 --- a/server/src/com/vaadin/ui/JavaScript.java +++ b/server/src/com/vaadin/ui/JavaScript.java @@ -66,7 +66,7 @@ public class JavaScript extends AbstractExtension { } @Override - public JavaScriptManagerState getState() { + protected JavaScriptManagerState getState() { return (JavaScriptManagerState) super.getState(); } diff --git a/server/src/com/vaadin/ui/Label.java b/server/src/com/vaadin/ui/Label.java index 10fa741058..d0a6059865 100644 --- a/server/src/com/vaadin/ui/Label.java +++ b/server/src/com/vaadin/ui/Label.java @@ -151,7 +151,7 @@ public class Label extends AbstractComponent implements Property, } @Override - public LabelState getState() { + protected LabelState getState() { return (LabelState) super.getState(); } diff --git a/server/src/com/vaadin/ui/Panel.java b/server/src/com/vaadin/ui/Panel.java index ba68238707..985eed8a28 100644 --- a/server/src/com/vaadin/ui/Panel.java +++ b/server/src/com/vaadin/ui/Panel.java @@ -489,7 +489,7 @@ public class Panel extends AbstractComponentContainer implements Scrollable, } @Override - public PanelState getState() { + protected PanelState getState() { return (PanelState) super.getState(); } diff --git a/server/src/com/vaadin/ui/Root.java b/server/src/com/vaadin/ui/Root.java index 020ff869fa..4b90d613bb 100644 --- a/server/src/com/vaadin/ui/Root.java +++ b/server/src/com/vaadin/ui/Root.java @@ -498,7 +498,7 @@ public abstract class Root extends AbstractComponentContainer implements } @Override - public RootState getState() { + protected RootState getState() { return (RootState) super.getState(); } diff --git a/server/src/com/vaadin/ui/TextArea.java b/server/src/com/vaadin/ui/TextArea.java index fed06b561a..f885781d46 100644 --- a/server/src/com/vaadin/ui/TextArea.java +++ b/server/src/com/vaadin/ui/TextArea.java @@ -81,7 +81,7 @@ public class TextArea extends AbstractTextField { } @Override - public TextAreaState getState() { + protected TextAreaState getState() { return (TextAreaState) super.getState(); } diff --git a/server/src/com/vaadin/ui/Video.java b/server/src/com/vaadin/ui/Video.java index 95a38c59d5..04ecc9af06 100644 --- a/server/src/com/vaadin/ui/Video.java +++ b/server/src/com/vaadin/ui/Video.java @@ -44,7 +44,7 @@ import com.vaadin.terminal.gwt.server.ResourceReference; public class Video extends AbstractMedia { @Override - public VideoState getState() { + protected VideoState getState() { return (VideoState) super.getState(); } diff --git a/server/src/com/vaadin/ui/Window.java b/server/src/com/vaadin/ui/Window.java index d1d2c25d8b..705e093bce 100644 --- a/server/src/com/vaadin/ui/Window.java +++ b/server/src/com/vaadin/ui/Window.java @@ -838,7 +838,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, } @Override - public WindowState getState() { + protected WindowState getState() { return (WindowState) super.getState(); } } diff --git a/shared/src/com/vaadin/shared/Connector.java b/shared/src/com/vaadin/shared/Connector.java index 5a00f6cca2..5927d08d79 100644 --- a/shared/src/com/vaadin/shared/Connector.java +++ b/shared/src/com/vaadin/shared/Connector.java @@ -17,8 +17,6 @@ package com.vaadin.shared; import java.io.Serializable; -import com.vaadin.shared.communication.SharedState; - /** * Interface implemented by all classes that are capable of communicating with * the server or the client side. @@ -40,15 +38,6 @@ import com.vaadin.shared.communication.SharedState; * @since 7.0.0 */ public interface Connector extends Serializable { - /** - * Gets the current shared state of the connector. - * - * @since 7.0. - * @return state The shared state object. Can be any sub type of - * {@link SharedState}. Never null. - */ - public SharedState getState(); - /** * Returns the id for this connector. This is set by the framework and does * not change during the lifetime of a connector. -- cgit v1.2.3 From 098957c08507449e34fd64618d4964ee0b030eba Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Wed, 22 Aug 2012 21:18:01 +0300 Subject: Made Root.getCurrent() work in LoginForm LoginListener (#9372) --- server/src/com/vaadin/ui/LoginForm.java | 3 ++ .../loginform/LoginFormRootInLoginHandler.java | 52 ++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100755 tests/testbench/com/vaadin/tests/components/loginform/LoginFormRootInLoginHandler.java diff --git a/server/src/com/vaadin/ui/LoginForm.java b/server/src/com/vaadin/ui/LoginForm.java index c8634ea81a..bb7767084c 100644 --- a/server/src/com/vaadin/ui/LoginForm.java +++ b/server/src/com/vaadin/ui/LoginForm.java @@ -99,6 +99,9 @@ public class LoginForm extends CustomComponent { throws IOException { String requestPathInfo = request.getRequestPathInfo(); if ("/loginHandler".equals(requestPathInfo)) { + // Ensure Root.getCurrent() works in listeners + Root.setCurrent(getRoot()); + response.setCacheTime(-1); response.setContentType("text/html; charset=utf-8"); response.getWriter() diff --git a/tests/testbench/com/vaadin/tests/components/loginform/LoginFormRootInLoginHandler.java b/tests/testbench/com/vaadin/tests/components/loginform/LoginFormRootInLoginHandler.java new file mode 100755 index 0000000000..2c0a8744fc --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/loginform/LoginFormRootInLoginHandler.java @@ -0,0 +1,52 @@ +package com.vaadin.tests.components.loginform; + +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.Label; +import com.vaadin.ui.LoginForm; +import com.vaadin.ui.LoginForm.LoginEvent; +import com.vaadin.ui.LoginForm.LoginListener; +import com.vaadin.ui.Root; + +public class LoginFormRootInLoginHandler extends TestBase { + + @Override + protected void setup() { + LoginForm lf = new LoginForm(); + lf.addListener(new LoginListener() { + + @Override + public void onLogin(LoginEvent event) { + Root r1 = Root.getCurrent(); + if (r1 != null) { + addComponent(new Label("Root.getCurrent().data: " + + r1.getData())); + } else { + addComponent(new Label("Root.getCurrent() is null")); + } + Root r2 = ((LoginForm) event.getSource()).getRoot(); + if (r2 != null) { + addComponent(new Label("event.getSource().data: " + + r2.getData())); + } else { + addComponent(new Label( + "event.getSource().getRoot() is null")); + } + } + }); + addComponent(lf); + getLayout().getRoot().setData("This root"); + } + + @Override + protected String getDescription() { + // TODO Auto-generated method stub + return null; + } + + @Override + protected Integer getTicketNumber() { + // TODO Auto-generated method stub + return null; + } + +} -- cgit v1.2.3 From af2638fc57cf3d9f6dc84957bb6ee4b256ec60e7 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Wed, 22 Aug 2012 21:57:12 +0300 Subject: Removed readThrough/writeThrough in favor of buffered (#8180) --- server/src/com/vaadin/data/Buffered.java | 76 ------------- server/src/com/vaadin/ui/AbstractField.java | 125 +++------------------ server/src/com/vaadin/ui/Form.java | 62 ++-------- .../components/AbstractTestFieldValueChange.java | 50 +-------- .../components/TestTextFieldValueChange.java | 53 --------- .../AbstractFieldCommitWithInvalidValues.java | 2 +- .../tests/components/customfield/AddressField.java | 2 +- .../components/customfield/NestedPersonForm.java | 2 +- .../tests/components/datefield/CommitInvalid.java | 6 +- .../components/datefield/DateFieldInSubWindow.java | 2 +- .../datefield/DateFieldRangeValidation.java | 3 +- .../components/select/SelectDisplaysOldValue.java | 6 +- .../OutOfSyncIssueWithKeyboardShortcut.java | 2 +- .../sqlcontainer/CheckboxUpdateProblem.java | 2 +- .../vaadin/tests/layouts/TestAbsoluteLayout.java | 4 +- .../com/vaadin/tests/tickets/Ticket1806.java | 3 +- 16 files changed, 48 insertions(+), 352 deletions(-) diff --git a/server/src/com/vaadin/data/Buffered.java b/server/src/com/vaadin/data/Buffered.java index 2472524bbc..0b59c9ff97 100644 --- a/server/src/com/vaadin/data/Buffered.java +++ b/server/src/com/vaadin/data/Buffered.java @@ -76,82 +76,6 @@ public interface Buffered extends Serializable { */ public void discard() throws SourceException; - /** - * Tests if the object is in write-through mode. If the object is in - * write-through mode, all modifications to it will result in - * commit being called after the modification. - * - * @return true if the object is in write-through mode, - * false if it's not. - * @deprecated As of 7.0, use {@link #setBuffered(boolean)} instead. Note - * that setReadThrough(true), setWriteThrough(true) equals - * setBuffered(false) - */ - @Deprecated - public boolean isWriteThrough(); - - /** - * Sets the object's write-through mode to the specified status. When - * switching the write-through mode on, the commit operation - * will be performed. - * - * @param writeThrough - * Boolean value to indicate if the object should be in - * write-through mode after the call. - * @throws SourceException - * If the operation fails because of an exception is thrown by - * the data source. - * @throws InvalidValueException - * If the implicit commit operation fails because of a - * validation error. - * - * @deprecated As of 7.0, use {@link #setBuffered(boolean)} instead. Note - * that setReadThrough(true), setWriteThrough(true) equals - * setBuffered(false) - */ - @Deprecated - public void setWriteThrough(boolean writeThrough) throws SourceException, - InvalidValueException; - - /** - * Tests if the object is in read-through mode. If the object is in - * read-through mode, retrieving its value will result in the value being - * first updated from the data source to the object. - *

    - * The only exception to this rule is that when the object is not in - * write-through mode and it's buffer contains a modified value, the value - * retrieved from the object will be the locally modified value in the - * buffer which may differ from the value in the data source. - *

    - * - * @return true if the object is in read-through mode, - * false if it's not. - * @deprecated As of 7.0, use {@link #isBuffered(boolean)} instead. Note - * that setReadThrough(true), setWriteThrough(true) equals - * setBuffered(false) - */ - @Deprecated - public boolean isReadThrough(); - - /** - * Sets the object's read-through mode to the specified status. When - * switching read-through mode on, the object's value is updated from the - * data source. - * - * @param readThrough - * Boolean value to indicate if the object should be in - * read-through mode after the call. - * - * @throws SourceException - * If the operation fails because of an exception is thrown by - * the data source. The cause is included in the exception. - * @deprecated As of 7.0, use {@link #setBuffered(boolean)} instead. Note - * that setReadThrough(true), setWriteThrough(true) equals - * setBuffered(false) - */ - @Deprecated - public void setReadThrough(boolean readThrough) throws SourceException; - /** * Sets the object's buffered mode to the specified status. *

    diff --git a/server/src/com/vaadin/ui/AbstractField.java b/server/src/com/vaadin/ui/AbstractField.java index 8ac7b21daf..f13c6a3138 100644 --- a/server/src/com/vaadin/ui/AbstractField.java +++ b/server/src/com/vaadin/ui/AbstractField.java @@ -97,14 +97,9 @@ public abstract class AbstractField extends AbstractComponent implements private LinkedList validators = null; /** - * Auto commit mode. + * True if field is in buffered mode, false otherwise */ - private boolean writeThroughMode = true; - - /** - * Reads the value from data-source, when it is not modified. - */ - private boolean readThroughMode = true; + private boolean buffered; /** * Flag to indicate that the field is currently committing its value to the @@ -345,7 +340,7 @@ public abstract class AbstractField extends AbstractComponent implements */ private T getFieldValue() { // Give the value from abstract buffers if the field if possible - if (dataSource == null || !isReadThrough() || isModified()) { + if (dataSource == null || isBuffered() || isModified()) { return getInternalValue(); } @@ -368,91 +363,6 @@ public abstract class AbstractField extends AbstractComponent implements requestRepaint(); } - /* - * Tests if the field is in write-through mode. Don't add a JavaDoc comment - * here, we use the default documentation from the implemented interface. - */ - @Override - public boolean isWriteThrough() { - return writeThroughMode; - } - - /** - * Sets the field's write-through mode to the specified status. When - * switching the write-through mode on, a {@link #commit()} will be - * performed. - * - * @see #setBuffered(boolean) for an easier way to control read through and - * write through modes - * - * @param writeThrough - * Boolean value to indicate if the object should be in - * write-through mode after the call. - * @throws SourceException - * If the operation fails because of an exception is thrown by - * the data source. - * @throws InvalidValueException - * If the implicit commit operation fails because of a - * validation error. - * @deprecated As of 7.0, use {@link #setBuffered(boolean)} instead. Note - * that setReadThrough(true), setWriteThrough(true) equals - * setBuffered(false) - */ - @Override - @Deprecated - public void setWriteThrough(boolean writeThrough) - throws Buffered.SourceException, InvalidValueException { - if (writeThroughMode == writeThrough) { - return; - } - writeThroughMode = writeThrough; - if (writeThroughMode) { - commit(); - } - } - - /* - * Tests if the field is in read-through mode. Don't add a JavaDoc comment - * here, we use the default documentation from the implemented interface. - */ - @Override - public boolean isReadThrough() { - return readThroughMode; - } - - /** - * Sets the field's read-through mode to the specified status. When - * switching read-through mode on, the object's value is updated from the - * data source. - * - * @see #setBuffered(boolean) for an easier way to control read through and - * write through modes - * - * @param readThrough - * Boolean value to indicate if the object should be in - * read-through mode after the call. - * - * @throws SourceException - * If the operation fails because of an exception is thrown by - * the data source. The cause is included in the exception. - * @deprecated As of 7.0, use {@link #setBuffered(boolean)} instead. Note - * that setReadThrough(true), setWriteThrough(true) equals - * setBuffered(false) - */ - @Override - @Deprecated - public void setReadThrough(boolean readThrough) - throws Buffered.SourceException { - if (readThroughMode == readThrough) { - return; - } - readThroughMode = readThrough; - if (!isModified() && readThroughMode && getPropertyDataSource() != null) { - setInternalValue(convertFromDataSource(getDataSourceValue())); - fireValueChange(false); - } - } - /** * Sets the buffered mode of this Field. *

    @@ -460,34 +370,35 @@ public abstract class AbstractField extends AbstractComponent implements * property data source until {@link #commit()} is called. *

    *

    - * Changing buffered mode will change the read through and write through - * state for the field. + * Setting buffered mode from true to false will commit any pending changes. *

    *

    - * Mixing calls to {@link #setBuffered(boolean)} and - * {@link #setReadThrough(boolean)} or {@link #setWriteThrough(boolean)} is - * generally a bad idea. + * *

    * + * @since 7.0.0 * @param buffered * true if buffered mode should be turned on, false otherwise */ @Override public void setBuffered(boolean buffered) { - setReadThrough(!buffered); - setWriteThrough(!buffered); + if (this.buffered == buffered) { + return; + } + this.buffered = buffered; + if (!buffered) { + commit(); + } } /** * Checks the buffered mode of this Field. - *

    - * This method only returns true if both read and write buffering is used. * * @return true if buffered mode is on, false otherwise */ @Override public boolean isBuffered() { - return !isReadThrough() && !isWriteThrough(); + return buffered; } /* Property interface implementation */ @@ -607,8 +518,8 @@ public abstract class AbstractField extends AbstractComponent implements setModified(dataSource != null); valueWasModifiedByDataSourceDuringCommit = false; - // In write through mode , try to commit - if (isWriteThrough() && dataSource != null + // In not buffering, try to commit + if (!isBuffered() && dataSource != null && (isInvalidCommitted() || isValid())) { try { @@ -1267,7 +1178,7 @@ public abstract class AbstractField extends AbstractComponent implements */ @Override public void valueChange(Property.ValueChangeEvent event) { - if (isReadThrough()) { + if (!isBuffered()) { if (committingValueToDataSource) { boolean propertyNotifiesOfTheBufferedValue = equals(event .getProperty().getValue(), getInternalValue()); @@ -1371,7 +1282,7 @@ public abstract class AbstractField extends AbstractComponent implements if (!isListeningToPropertyEvents) { addPropertyListeners(); - if (!isModified() && isReadThrough()) { + if (!isModified() && !isBuffered()) { // Update value from data source discard(); } diff --git a/server/src/com/vaadin/ui/Form.java b/server/src/com/vaadin/ui/Form.java index 8efd85009c..689a088c41 100644 --- a/server/src/com/vaadin/ui/Form.java +++ b/server/src/com/vaadin/ui/Form.java @@ -99,14 +99,9 @@ public class Form extends AbstractField implements Item.Editor, private Buffered.SourceException currentBufferedSourceException = null; /** - * Is the form in write trough mode. + * Is the form in buffered mode. */ - private boolean writeThrough = true; - - /** - * Is the form in read trough mode. - */ - private boolean readThrough = true; + private boolean buffered = false; /** * Mapping from propertyName to corresponding field. @@ -427,50 +422,15 @@ public class Form extends AbstractField implements Item.Editor, } /* - * Is the editor in a read-through mode? Don't add a JavaDoc comment here, - * we use the default one from the interface. - */ - @Override - @Deprecated - public boolean isReadThrough() { - return readThrough; - } - - /* - * Is the editor in a write-through mode? Don't add a JavaDoc comment here, - * we use the default one from the interface. - */ - @Override - @Deprecated - public boolean isWriteThrough() { - return writeThrough; - } - - /* - * Sets the editor's read-through mode to the specified status. Don't add a - * JavaDoc comment here, we use the default one from the interface. - */ - @Override - public void setReadThrough(boolean readThrough) { - if (readThrough != this.readThrough) { - this.readThrough = readThrough; - for (final Iterator i = propertyIds.iterator(); i.hasNext();) { - (fields.get(i.next())).setReadThrough(readThrough); - } - } - } - - /* - * Sets the editor's read-through mode to the specified status. Don't add a + * Sets the editor's buffered mode to the specified status. Don't add a * JavaDoc comment here, we use the default one from the interface. */ @Override - public void setWriteThrough(boolean writeThrough) throws SourceException, - InvalidValueException { - if (writeThrough != this.writeThrough) { - this.writeThrough = writeThrough; + public void setBuffered(boolean buffered) { + if (buffered != this.buffered) { + this.buffered = buffered; for (final Iterator i = propertyIds.iterator(); i.hasNext();) { - (fields.get(i.next())).setWriteThrough(writeThrough); + (fields.get(i.next())).setBuffered(buffered); } } } @@ -560,11 +520,10 @@ public class Form extends AbstractField implements Item.Editor, propertyIds.addLast(propertyId); } - // Update the read and write through status and immediate to match the + // Update the buffered mode and immediate to match the // form. // Should this also include invalidCommitted (#3993)? - field.setReadThrough(readThrough); - field.setWriteThrough(writeThrough); + field.setBuffered(buffered); if (isImmediate() && field instanceof AbstractComponent) { ((AbstractComponent) field).setImmediate(true); } @@ -949,8 +908,7 @@ public class Form extends AbstractField implements Item.Editor, : new Select(); newField.setCaption(oldField.getCaption()); newField.setReadOnly(oldField.isReadOnly()); - newField.setReadThrough(oldField.isReadThrough()); - newField.setWriteThrough(oldField.isWriteThrough()); + newField.setBuffered(oldField.isBuffered()); // Creates the options list newField.addContainerProperty("desc", String.class, ""); diff --git a/tests/server-side/com/vaadin/tests/server/components/AbstractTestFieldValueChange.java b/tests/server-side/com/vaadin/tests/server/components/AbstractTestFieldValueChange.java index 3512f555c9..f2de4f3c04 100644 --- a/tests/server-side/com/vaadin/tests/server/components/AbstractTestFieldValueChange.java +++ b/tests/server-side/com/vaadin/tests/server/components/AbstractTestFieldValueChange.java @@ -42,8 +42,7 @@ public abstract class AbstractTestFieldValueChange extends TestCase { */ public void testRemoveListener() { getField().setPropertyDataSource(new ObjectProperty("")); - getField().setWriteThrough(true); - getField().setReadThrough(true); + getField().setBuffered(false); // Expectations and start test listener.valueChange(EasyMock.isA(ValueChangeEvent.class)); @@ -76,10 +75,9 @@ public abstract class AbstractTestFieldValueChange extends TestCase { * Field value change notifications closely mirror value changes of the data * source behind the field. */ - public void testWriteThroughReadThrough() { + public void testNonBuffered() { getField().setPropertyDataSource(new ObjectProperty("")); - getField().setWriteThrough(true); - getField().setReadThrough(true); + getField().setBuffered(false); expectValueChangeFromSetValueNotCommit(); } @@ -91,47 +89,9 @@ public abstract class AbstractTestFieldValueChange extends TestCase { * Field value change notifications reflect the buffered value in the field, * not the original data source value changes. */ - public void testNoWriteThroughNoReadThrough() { + public void testBuffered() { getField().setPropertyDataSource(new ObjectProperty("")); - getField().setWriteThrough(false); - getField().setReadThrough(false); - - expectValueChangeFromSetValueNotCommit(); - } - - /** - * Less common partly buffered case: writeThrough (auto-commit) is on and - * readThrough is off. Calling commit() should not cause notifications. - * - * Without readThrough activated, changes to the data source that do not - * cause notifications are not reflected by the field value. - * - * Field value change notifications correspond to changes made to the data - * source value through the text field or the (notifying) property. - */ - public void testWriteThroughNoReadThrough() { - getField().setPropertyDataSource(new ObjectProperty("")); - getField().setWriteThrough(true); - getField().setReadThrough(false); - - expectValueChangeFromSetValueNotCommit(); - } - - /** - * Partly buffered use where the data source is read but not nor modified - * during editing, and is updated at commit(). - * - * When used like this, a field is updated from the data source if necessary - * when its value is requested and the property value has changed but the - * field has not been modified in its buffer. - * - * Field value change notifications reflect the buffered value in the field, - * not the original data source value changes. - */ - public void testNoWriteThroughReadThrough() { - getField().setPropertyDataSource(new ObjectProperty("")); - getField().setWriteThrough(false); - getField().setReadThrough(true); + getField().setBuffered(true); expectValueChangeFromSetValueNotCommit(); } diff --git a/tests/server-side/com/vaadin/tests/server/components/TestTextFieldValueChange.java b/tests/server-side/com/vaadin/tests/server/components/TestTextFieldValueChange.java index f5db67be97..de838e339c 100644 --- a/tests/server-side/com/vaadin/tests/server/components/TestTextFieldValueChange.java +++ b/tests/server-side/com/vaadin/tests/server/components/TestTextFieldValueChange.java @@ -77,59 +77,6 @@ public class TestTextFieldValueChange extends EasyMock.verify(getListener()); } - /** - * If read through is on and value has been modified, but not committed, the - * value should not propagate similar to - * {@link #testValueChangeEventPropagationWithReadThrough()} - * - * TODO make test field type agnostic (eg. combobox) - */ - public void testValueChangePropagationWithReadThroughWithModifiedValue() { - final String initialValue = "initial"; - ObjectProperty property = new ObjectProperty( - initialValue); - getField().setPropertyDataSource(property); - - // write buffering on, read buffering off - getField().setWriteThrough(false); - getField().setReadThrough(true); - - // Expect no value changes calls to listener - EasyMock.replay(getListener()); - - // first set the value (note, write through false -> not forwarded to - // property) - setValue(getField()); - - Assert.assertTrue(getField().isModified()); - - // Add listener and set the value -> should end up in listener once - getField().addListener(getListener()); - - // modify property value, should not fire value change in field as the - // field has uncommitted value (aka isModified() == true) - property.setValue("Foo"); - - // Ensure listener was called once - EasyMock.verify(getListener()); - - // get value should not fire value change again - Object value = getField().getValue(); - // Ensure listener still has been called only once - EasyMock.verify(getListener()); - - // field value should be different from the original value and current - // proeprty value - boolean isValueEqualToInitial = value.equals(initialValue); - Assert.assertFalse(isValueEqualToInitial); - boolean isValueEqualToPropertyValue = value.equals(property.getValue()); - Assert.assertFalse(isValueEqualToPropertyValue); - - // Ensure listener has not been called - EasyMock.verify(getListener()); - - } - /** * Value change events from property should not propagate if read through is * false. Execpt when the property is being set. diff --git a/tests/testbench/com/vaadin/tests/components/abstractfield/AbstractFieldCommitWithInvalidValues.java b/tests/testbench/com/vaadin/tests/components/abstractfield/AbstractFieldCommitWithInvalidValues.java index aa630c79fd..0aaa7c5f13 100644 --- a/tests/testbench/com/vaadin/tests/components/abstractfield/AbstractFieldCommitWithInvalidValues.java +++ b/tests/testbench/com/vaadin/tests/components/abstractfield/AbstractFieldCommitWithInvalidValues.java @@ -28,7 +28,7 @@ public class AbstractFieldCommitWithInvalidValues extends TestBase { tf = new TextField("A field, must contain 1-2 chars", new ObjectProperty("a")); tf.addValidator(new StringLengthValidator("Invalid length", 1, 2, false)); - tf.setWriteThrough(false); + tf.setBuffered(true); tf.setRequired(true); Button b = new Button("Commit", new ClickListener() { diff --git a/tests/testbench/com/vaadin/tests/components/customfield/AddressField.java b/tests/testbench/com/vaadin/tests/components/customfield/AddressField.java index a3ee89b3ee..2daeb7bf25 100644 --- a/tests/testbench/com/vaadin/tests/components/customfield/AddressField.java +++ b/tests/testbench/com/vaadin/tests/components/customfield/AddressField.java @@ -34,7 +34,7 @@ public class AddressField extends CustomField
    { addressForm = new Form(); } addressForm.setCaption("Address"); - addressForm.setWriteThrough(false); + addressForm.setBuffered(true); // make sure field changes are sent early addressForm.setImmediate(true); diff --git a/tests/testbench/com/vaadin/tests/components/customfield/NestedPersonForm.java b/tests/testbench/com/vaadin/tests/components/customfield/NestedPersonForm.java index 0655c09102..9b40074433 100644 --- a/tests/testbench/com/vaadin/tests/components/customfield/NestedPersonForm.java +++ b/tests/testbench/com/vaadin/tests/components/customfield/NestedPersonForm.java @@ -31,7 +31,7 @@ public class NestedPersonForm extends Form { beanItem = new BeanItem(person); setCaption("Update person details"); - setWriteThrough(false); + setBuffered(true); setFormFieldFactory(new PersonFieldFactory()); // set the data source and the visible fields // Note that if the nested form is the first or last field in the parent diff --git a/tests/testbench/com/vaadin/tests/components/datefield/CommitInvalid.java b/tests/testbench/com/vaadin/tests/components/datefield/CommitInvalid.java index c4f001ac41..e24f4753ff 100644 --- a/tests/testbench/com/vaadin/tests/components/datefield/CommitInvalid.java +++ b/tests/testbench/com/vaadin/tests/components/datefield/CommitInvalid.java @@ -41,7 +41,7 @@ public class CommitInvalid extends TestBase { * Create and configure form. */ final Form form = new Form(); - form.setWriteThrough(false); // set write buffering on + form.setBuffered(true); // set write buffering on form.setImmediate(true); // make form (and especially its fields // immediate) @@ -132,8 +132,8 @@ public class CommitInvalid extends TestBase { } private void printState() { - log.log("Date. Field: " + f((Date) dateField.getValue()) - + " Property: " + f(dateProperty.getValue())); + log.log("Date. Field: " + f(dateField.getValue()) + " Property: " + + f(dateProperty.getValue())); log.log("Integer: Field: " + integerField.getValue() + " Property: " + integerProperty.getValue()); } diff --git a/tests/testbench/com/vaadin/tests/components/datefield/DateFieldInSubWindow.java b/tests/testbench/com/vaadin/tests/components/datefield/DateFieldInSubWindow.java index 2a7807670b..85f1c80a08 100644 --- a/tests/testbench/com/vaadin/tests/components/datefield/DateFieldInSubWindow.java +++ b/tests/testbench/com/vaadin/tests/components/datefield/DateFieldInSubWindow.java @@ -88,7 +88,7 @@ public class DateFieldInSubWindow extends AbstractTestCase { final Form generalForm = new Form(); { generalForm.setCaption("My form"); - generalForm.setWriteThrough(true); + generalForm.setBuffered(false); generalForm.setFormFieldFactory(fieldFactory); BeanItem myBeanItem = new BeanItem(myBean); diff --git a/tests/testbench/com/vaadin/tests/components/datefield/DateFieldRangeValidation.java b/tests/testbench/com/vaadin/tests/components/datefield/DateFieldRangeValidation.java index befdd65693..484b9cfee8 100644 --- a/tests/testbench/com/vaadin/tests/components/datefield/DateFieldRangeValidation.java +++ b/tests/testbench/com/vaadin/tests/components/datefield/DateFieldRangeValidation.java @@ -125,8 +125,7 @@ public class DateFieldRangeValidation extends TestBase { PopupDateField df = new PopupDateField(); df.setLocale(new Locale("en", "US")); df.setResolution(Resolution.DAY); - df.setWriteThrough(true); - df.setReadThrough(true); + df.setBuffered(false); df.setImmediate(true); return df; } diff --git a/tests/testbench/com/vaadin/tests/components/select/SelectDisplaysOldValue.java b/tests/testbench/com/vaadin/tests/components/select/SelectDisplaysOldValue.java index b9ae958a03..77c187ff60 100644 --- a/tests/testbench/com/vaadin/tests/components/select/SelectDisplaysOldValue.java +++ b/tests/testbench/com/vaadin/tests/components/select/SelectDisplaysOldValue.java @@ -121,8 +121,7 @@ public class SelectDisplaysOldValue extends TestBase { controllerComboBox.setNullSelectionAllowed(false); controllerComboBox.setNewItemsAllowed(false); controllerComboBox.setImmediate(true); - controllerComboBox.setWriteThrough(false); - controllerComboBox.setReadThrough(false); + controllerComboBox.setBuffered(true); } @@ -131,8 +130,7 @@ public class SelectDisplaysOldValue extends TestBase { slaveComboBox.setNullSelectionAllowed(false); slaveComboBox.setNewItemsAllowed(false); slaveComboBox.setImmediate(true); - slaveComboBox.setWriteThrough(false); - slaveComboBox.setReadThrough(false); + slaveComboBox.setBuffered(true); } private void refreshSlaveDropdown(Integer masterId) { diff --git a/tests/testbench/com/vaadin/tests/components/textfield/OutOfSyncIssueWithKeyboardShortcut.java b/tests/testbench/com/vaadin/tests/components/textfield/OutOfSyncIssueWithKeyboardShortcut.java index 89f9ffda40..955a9c2772 100644 --- a/tests/testbench/com/vaadin/tests/components/textfield/OutOfSyncIssueWithKeyboardShortcut.java +++ b/tests/testbench/com/vaadin/tests/components/textfield/OutOfSyncIssueWithKeyboardShortcut.java @@ -70,7 +70,7 @@ public class OutOfSyncIssueWithKeyboardShortcut extends TestBase { form.setImmediate(true); // this is critical for the problem to occur - form.setWriteThrough(false); + form.setBuffered(true); HorizontalLayout footer = new HorizontalLayout(); footer.setSpacing(true); diff --git a/tests/testbench/com/vaadin/tests/containers/sqlcontainer/CheckboxUpdateProblem.java b/tests/testbench/com/vaadin/tests/containers/sqlcontainer/CheckboxUpdateProblem.java index f34c12607a..537c9be973 100644 --- a/tests/testbench/com/vaadin/tests/containers/sqlcontainer/CheckboxUpdateProblem.java +++ b/tests/testbench/com/vaadin/tests/containers/sqlcontainer/CheckboxUpdateProblem.java @@ -76,7 +76,7 @@ public class CheckboxUpdateProblem extends Application.LegacyApplication private TestForm() { setSizeFull(); - setWriteThrough(false); + setBuffered(true); setInvalidCommitted(false); save = new Button("Save", this); diff --git a/tests/testbench/com/vaadin/tests/layouts/TestAbsoluteLayout.java b/tests/testbench/com/vaadin/tests/layouts/TestAbsoluteLayout.java index d2f14c114e..33fa0558e7 100644 --- a/tests/testbench/com/vaadin/tests/layouts/TestAbsoluteLayout.java +++ b/tests/testbench/com/vaadin/tests/layouts/TestAbsoluteLayout.java @@ -271,14 +271,14 @@ public class TestAbsoluteLayout extends TestBase { addComponent(addComp); componentEditor = new Form(); - componentEditor.setWriteThrough(false); + componentEditor.setBuffered(true); componentEditor.setCaption("Component properties:"); componentEditor.setFormFieldFactory(MFieldFactory.get()); addComponent(componentEditor); positionEditor = new Form(); positionEditor.setCaption("Component position"); - positionEditor.setWriteThrough(false); + positionEditor.setBuffered(true); positionEditor.setFormFieldFactory(MFieldFactory.get()); addComponent(positionEditor); diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1806.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1806.java index 2c979f4600..fa572039aa 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1806.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1806.java @@ -17,8 +17,7 @@ public class Ticket1806 extends com.vaadin.Application.LegacyApplication { final ObjectProperty prop = new ObjectProperty(""); final TextField tf1 = new TextField( "Buffered TextField bound to ObjectProperty"); - tf1.setWriteThrough(false); - tf1.setReadThrough(false); + tf1.setBuffered(true); tf1.setPropertyDataSource(prop); main.addComponent(tf1); main.addComponent(new Button( -- cgit v1.2.3 From 8d2d0adb625f478658b7115ae2dfb007aad079b5 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Wed, 22 Aug 2012 21:48:34 +0300 Subject: Removed API deprecated in Vaadin 6 (#9071) --- .../terminal/gwt/client/ApplicationConnection.java | 39 +- .../gwt/client/ClientExceptionHandler.java | 42 -- .../vaadin/terminal/gwt/client/ui/dd/DDUtil.java | 33 +- .../terminal/gwt/client/ui/dd/VHtml5DragEvent.java | 8 - .../src/com/vaadin/data/util/QueryContainer.java | 685 --------------------- .../data/util/sqlcontainer/ColumnProperty.java | 6 +- server/src/com/vaadin/ui/AbstractComponent.java | 28 - .../src/com/vaadin/ui/AbstractOrderedLayout.java | 13 - server/src/com/vaadin/ui/DragAndDropWrapper.java | 16 - server/src/com/vaadin/ui/GridLayout.java | 46 -- server/src/com/vaadin/ui/Layout.java | 69 --- server/src/com/vaadin/ui/PopupView.java | 16 - server/src/com/vaadin/ui/RichTextArea.java | 71 +-- server/src/com/vaadin/ui/Select.java | 34 - server/src/com/vaadin/ui/TabSheet.java | 81 +-- server/src/com/vaadin/ui/Table.java | 35 -- server/src/com/vaadin/ui/Upload.java | 27 - server/src/com/vaadin/ui/themes/BaseTheme.java | 12 - server/src/com/vaadin/ui/themes/Reindeer.java | 18 - .../com/vaadin/tests/tickets/Ticket1710.java | 78 ++- 20 files changed, 57 insertions(+), 1300 deletions(-) delete mode 100644 client/src/com/vaadin/terminal/gwt/client/ClientExceptionHandler.java delete mode 100644 server/src/com/vaadin/data/util/QueryContainer.java diff --git a/client/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java b/client/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java index 7e1c505fe9..58357ae3fc 100644 --- a/client/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java +++ b/client/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java @@ -395,32 +395,6 @@ public class ApplicationConnection { } }-*/; - /** - * Get the active Console for writing debug messages. May return an actual - * logging console, or the NullConsole if debugging is not turned on. - * - * @deprecated Developers should use {@link VConsole} since 6.4.5 - * - * @return the active Console - */ - @Deprecated - public static Console getConsole() { - return VConsole.getImplementation(); - } - - /** - * Checks if client side is in debug mode. Practically this is invoked by - * adding ?debug parameter to URI. - * - * @deprecated use ApplicationConfiguration isDebugMode instead. - * - * @return true if client side is currently been debugged - */ - @Deprecated - public static boolean isDebugMode() { - return ApplicationConfiguration.isDebugMode(); - } - /** * Gets the application base URI. Using this other than as the download * action URI can cause problems in Portlet 2.0 deployments. @@ -2468,7 +2442,8 @@ public class ApplicationConnection { * The identifier for the event * @return true if at least one listener has been registered on server side * for the event identified by eventIdentifier. - * @deprecated Use {@link ComponentState#hasEventListener(String)} instead + * @deprecated as of Vaadin 7. Use + * {@link ComponentState#hasEventListener(String)} instead */ @Deprecated public boolean hasEventListeners(ComponentConnector paintable, @@ -2521,11 +2496,13 @@ public class ApplicationConnection { return connectorMap; } + /** + * @deprecated No longer needed in Vaadin 7 + */ @Deprecated public void unregisterPaintable(ServerConnector p) { - System.out.println("unregisterPaintable (unnecessarily) called for " + VConsole.log("unregisterPaintable (unnecessarily) called for " + Util.getConnectorString(p)); - // connectorMap.unregisterConnector(p); } /** @@ -2564,6 +2541,10 @@ public class ApplicationConnection { return false; } + /** + * @deprecated as of Vaadin 7. Use + * {@link ComponentState#hasEventListener(String)} instead + */ @Deprecated public boolean hasEventListeners(Widget widget, String eventIdentifier) { return hasEventListeners(getConnectorMap().getConnector(widget), diff --git a/client/src/com/vaadin/terminal/gwt/client/ClientExceptionHandler.java b/client/src/com/vaadin/terminal/gwt/client/ClientExceptionHandler.java deleted file mode 100644 index d8c7e67638..0000000000 --- a/client/src/com/vaadin/terminal/gwt/client/ClientExceptionHandler.java +++ /dev/null @@ -1,42 +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.terminal.gwt.client; - -import com.google.gwt.core.client.GWT; - -@Deprecated -public class ClientExceptionHandler { - - public static void displayError(Throwable e) { - displayError(e.getClass().getName() + ": " + e.getMessage()); - - GWT.log(e.getMessage(), e); - } - - @Deprecated - public static void displayError(String msg) { - VConsole.error(msg); - GWT.log(msg); - } - - @Deprecated - public static void displayError(String msg, Throwable e) { - displayError(msg); - displayError(e); - - } - -} diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/dd/DDUtil.java b/client/src/com/vaadin/terminal/gwt/client/ui/dd/DDUtil.java index b6012eded1..a4d00f59de 100644 --- a/client/src/com/vaadin/terminal/gwt/client/ui/dd/DDUtil.java +++ b/client/src/com/vaadin/terminal/gwt/client/ui/dd/DDUtil.java @@ -24,23 +24,6 @@ import com.vaadin.terminal.gwt.client.Util; public class DDUtil { - /** - * @deprecated use the version with the actual event instead of detected - * clientY value - * - * @param element - * @param clientY - * @param topBottomRatio - * @return - */ - @Deprecated - public static VerticalDropLocation getVerticalDropLocation(Element element, - int clientY, double topBottomRatio) { - int offsetHeight = element.getOffsetHeight(); - return getVerticalDropLocation(element, offsetHeight, clientY, - topBottomRatio); - } - public static VerticalDropLocation getVerticalDropLocation(Element element, NativeEvent event, double topBottomRatio) { int offsetHeight = element.getOffsetHeight(); @@ -76,21 +59,7 @@ public class DDUtil { public static HorizontalDropLocation getHorizontalDropLocation( Element element, NativeEvent event, double leftRightRatio) { - int touchOrMouseClientX = Util.getTouchOrMouseClientX(event); - return getHorizontalDropLocation(element, touchOrMouseClientX, - leftRightRatio); - } - - /** - * @deprecated use the version with the actual event - * @param element - * @param clientX - * @param leftRightRatio - * @return - */ - @Deprecated - public static HorizontalDropLocation getHorizontalDropLocation( - Element element, int clientX, double leftRightRatio) { + int clientX = Util.getTouchOrMouseClientX(event); // Event coordinates are relative to the viewport, element absolute // position is relative to the document. Make element position relative diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/dd/VHtml5DragEvent.java b/client/src/com/vaadin/terminal/gwt/client/ui/dd/VHtml5DragEvent.java index 32abc787da..34bdb28c91 100644 --- a/client/src/com/vaadin/terminal/gwt/client/ui/dd/VHtml5DragEvent.java +++ b/client/src/com/vaadin/terminal/gwt/client/ui/dd/VHtml5DragEvent.java @@ -53,14 +53,6 @@ public class VHtml5DragEvent extends NativeEvent { return null; }-*/; - /** - * @deprecated As of Vaadin 6.8, replaced by {@link #setDropEffect(String)}. - */ - @Deprecated - public final void setDragEffect(String effect) { - setDropEffect(effect); - } - public final native void setDropEffect(String effect) /*-{ try { diff --git a/server/src/com/vaadin/data/util/QueryContainer.java b/server/src/com/vaadin/data/util/QueryContainer.java deleted file mode 100644 index add93c25ee..0000000000 --- a/server/src/com/vaadin/data/util/QueryContainer.java +++ /dev/null @@ -1,685 +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.data.util; - -import java.sql.Connection; -import java.sql.ResultSet; -import java.sql.ResultSetMetaData; -import java.sql.SQLException; -import java.sql.Statement; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; - -import com.vaadin.data.Container; -import com.vaadin.data.Item; -import com.vaadin.data.Property; - -/** - *

    - * The QueryContainer is the specialized form of Container which is - * Ordered and Indexed. This is used to represent the contents of relational - * database tables accessed through the JDBC Connection in the Vaadin Table. - * This creates Items based on the queryStatement provided to the container. - *

    - * - *

    - * The QueryContainer can be visualized as a representation of a - * relational database table.Each Item in the container represents the row - * fetched by the query.All cells in a column have same data type and the data - * type information is retrieved from the metadata of the resultset. - *

    - * - *

    - * Note : If data in the tables gets modified, Container will not get reflected - * with the updates, we have to explicity invoke QueryContainer.refresh method. - * {@link com.vaadin.data.util.QueryContainer#refresh() refresh()} - *

    - * - * @see com.vaadin.data.Container - * - * @author Vaadin Ltd. - * @since 4.0 - * - * @deprecated will be removed in the future, use the SQLContainer add-on - */ - -@Deprecated -@SuppressWarnings("serial") -public class QueryContainer implements Container, Container.Ordered, - Container.Indexed { - - // default ResultSet type - public static final int DEFAULT_RESULTSET_TYPE = ResultSet.TYPE_SCROLL_INSENSITIVE; - - // default ResultSet concurrency - public static final int DEFAULT_RESULTSET_CONCURRENCY = ResultSet.CONCUR_READ_ONLY; - - private int resultSetType = DEFAULT_RESULTSET_TYPE; - - private int resultSetConcurrency = DEFAULT_RESULTSET_CONCURRENCY; - - private final String queryStatement; - - private final Connection connection; - - private ResultSet result; - - private Collection propertyIds; - - private final HashMap> propertyTypes = new HashMap>(); - - private int size = -1; - - private Statement statement; - - /** - * Constructs new QueryContainer with the specified - * queryStatement. - * - * @param queryStatement - * Database query - * @param connection - * Connection object - * @param resultSetType - * @param resultSetConcurrency - * @throws SQLException - * when database operation fails - */ - public QueryContainer(String queryStatement, Connection connection, - int resultSetType, int resultSetConcurrency) throws SQLException { - this.queryStatement = queryStatement; - this.connection = connection; - this.resultSetType = resultSetType; - this.resultSetConcurrency = resultSetConcurrency; - init(); - } - - /** - * Constructs new QueryContainer with the specified - * queryStatement using the default resultset type and default resultset - * concurrency. - * - * @param queryStatement - * Database query - * @param connection - * Connection object - * @see QueryContainer#DEFAULT_RESULTSET_TYPE - * @see QueryContainer#DEFAULT_RESULTSET_CONCURRENCY - * @throws SQLException - * when database operation fails - */ - public QueryContainer(String queryStatement, Connection connection) - throws SQLException { - this(queryStatement, connection, DEFAULT_RESULTSET_TYPE, - DEFAULT_RESULTSET_CONCURRENCY); - } - - /** - * Fills the Container with the items and properties. Invoked by the - * constructor. - * - * @throws SQLException - * when parameter initialization fails. - * @see QueryContainer#QueryContainer(String, Connection, int, int). - */ - private void init() throws SQLException { - refresh(); - ResultSetMetaData metadata; - metadata = result.getMetaData(); - final int count = metadata.getColumnCount(); - final ArrayList list = new ArrayList(count); - for (int i = 1; i <= count; i++) { - final String columnName = metadata.getColumnName(i); - list.add(columnName); - final Property p = getContainerProperty(new Integer(1), - columnName); - propertyTypes.put(columnName, - p == null ? Object.class : p.getType()); - } - propertyIds = Collections.unmodifiableCollection(list); - } - - /** - *

    - * Restores items in the container. This method will update the latest data - * to the container. - *

    - * Note: This method should be used to update the container with the latest - * items. - * - * @throws SQLException - * when database operation fails - * - */ - - public void refresh() throws SQLException { - close(); - statement = connection.createStatement(resultSetType, - resultSetConcurrency); - result = statement.executeQuery(queryStatement); - result.last(); - size = result.getRow(); - } - - /** - * Releases and nullifies the statement. - * - * @throws SQLException - * when database operation fails - */ - - public void close() throws SQLException { - if (statement != null) { - statement.close(); - } - statement = null; - } - - /** - * Gets the Item with the given Item ID from the Container. - * - * @param id - * ID of the Item to retrieve - * @return Item Id. - */ - - @Override - public Item getItem(Object id) { - return new Row(id); - } - - /** - * Gets the collection of propertyId from the Container. - * - * @return Collection of Property ID. - */ - - @Override - public Collection getContainerPropertyIds() { - return propertyIds; - } - - /** - * Gets an collection of all the item IDs in the container. - * - * @return collection of Item IDs - */ - @Override - public Collection getItemIds() { - final Collection c = new ArrayList(size); - for (int i = 1; i <= size; i++) { - c.add(new Integer(i)); - } - return c; - } - - /** - * Gets the property identified by the given itemId and propertyId from the - * container. If the container does not contain the property - * null is returned. - * - * @param itemId - * ID of the Item which contains the Property - * @param propertyId - * ID of the Property to retrieve - * - * @return Property with the given ID if exists; null - * otherwise. - */ - - @Override - public synchronized Property getContainerProperty(Object itemId, - Object propertyId) { - if (!(itemId instanceof Integer && propertyId instanceof String)) { - return null; - } - Object value; - try { - result.absolute(((Integer) itemId).intValue()); - value = result.getObject((String) propertyId); - } catch (final Exception e) { - return null; - } - - // Handle also null values from the database - return new ObjectProperty(value != null ? value - : new String("")); - } - - /** - * Gets the data type of all properties identified by the given type ID. - * - * @param id - * ID identifying the Properties - * - * @return data type of the Properties - */ - - @Override - public Class getType(Object id) { - return propertyTypes.get(id); - } - - /** - * Gets the number of items in the container. - * - * @return the number of items in the container. - */ - @Override - public int size() { - return size; - } - - /** - * Tests if the list contains the specified Item. - * - * @param id - * ID the of Item to be tested. - * @return true if given id is in the container; - * false otherwise. - */ - @Override - public boolean containsId(Object id) { - if (!(id instanceof Integer)) { - return false; - } - final int i = ((Integer) id).intValue(); - if (i < 1) { - return false; - } - if (i > size) { - return false; - } - return true; - } - - /** - * Creates new Item with the given ID into the Container. - * - * @param itemId - * ID of the Item to be created. - * - * @return Created new Item, or null if it fails. - * - * @throws UnsupportedOperationException - * if the addItem method is not supported. - */ - @Override - public Item addItem(Object itemId) throws UnsupportedOperationException { - throw new UnsupportedOperationException(); - } - - /** - * Creates a new Item into the Container, and assign it an ID. - * - * @return ID of the newly created Item, or null if it fails. - * @throws UnsupportedOperationException - * if the addItem method is not supported. - */ - @Override - public Object addItem() throws UnsupportedOperationException { - throw new UnsupportedOperationException(); - } - - /** - * Removes the Item identified by ItemId from the Container. - * - * @param itemId - * ID of the Item to remove. - * @return true if the operation succeeded; false - * otherwise. - * @throws UnsupportedOperationException - * if the removeItem method is not supported. - */ - @Override - public boolean removeItem(Object itemId) - throws UnsupportedOperationException { - throw new UnsupportedOperationException(); - } - - /** - * Adds new Property to all Items in the Container. - * - * @param propertyId - * ID of the Property - * @param type - * Data type of the new Property - * @param defaultValue - * The value all created Properties are initialized to. - * @return true if the operation succeeded; false - * otherwise. - * @throws UnsupportedOperationException - * if the addContainerProperty method is not supported. - */ - @Override - public boolean addContainerProperty(Object propertyId, Class type, - Object defaultValue) throws UnsupportedOperationException { - throw new UnsupportedOperationException(); - } - - /** - * Removes a Property specified by the given Property ID from the Container. - * - * @param propertyId - * ID of the Property to remove - * @return true if the operation succeeded; false - * otherwise. - * @throws UnsupportedOperationException - * if the removeContainerProperty method is not supported. - */ - @Override - public boolean removeContainerProperty(Object propertyId) - throws UnsupportedOperationException { - throw new UnsupportedOperationException(); - } - - /** - * Removes all Items from the Container. - * - * @return true if the operation succeeded; false - * otherwise. - * @throws UnsupportedOperationException - * if the removeAllItems method is not supported. - */ - @Override - public boolean removeAllItems() throws UnsupportedOperationException { - throw new UnsupportedOperationException(); - } - - /** - * Adds new item after the given item. - * - * @param previousItemId - * Id of the previous item in ordered container. - * @param newItemId - * Id of the new item to be added. - * @return Returns new item or null if the operation fails. - * @throws UnsupportedOperationException - * if the addItemAfter method is not supported. - */ - @Override - public Item addItemAfter(Object previousItemId, Object newItemId) - throws UnsupportedOperationException { - throw new UnsupportedOperationException(); - } - - /** - * Adds new item after the given item. - * - * @param previousItemId - * Id of the previous item in ordered container. - * @return Returns item id created new item or null if the - * operation fails. - * @throws UnsupportedOperationException - * if the addItemAfter method is not supported. - */ - @Override - public Object addItemAfter(Object previousItemId) - throws UnsupportedOperationException { - throw new UnsupportedOperationException(); - } - - /** - * Returns id of first item in the Container. - * - * @return ID of the first Item in the list. - */ - @Override - public Object firstItemId() { - if (size < 1) { - return null; - } - return new Integer(1); - } - - /** - * Returns true if given id is first id at first index. - * - * @param id - * ID of an Item in the Container. - */ - @Override - public boolean isFirstId(Object id) { - return size > 0 && (id instanceof Integer) - && ((Integer) id).intValue() == 1; - } - - /** - * Returns true if given id is last id at last index. - * - * @param id - * ID of an Item in the Container - * - */ - @Override - public boolean isLastId(Object id) { - return size > 0 && (id instanceof Integer) - && ((Integer) id).intValue() == size; - } - - /** - * Returns id of last item in the Container. - * - * @return ID of the last Item. - */ - @Override - public Object lastItemId() { - if (size < 1) { - return null; - } - return new Integer(size); - } - - /** - * Returns id of next item in container at next index. - * - * @param id - * ID of an Item in the Container. - * @return ID of the next Item or null. - */ - @Override - public Object nextItemId(Object id) { - if (size < 1 || !(id instanceof Integer)) { - return null; - } - final int i = ((Integer) id).intValue(); - if (i >= size) { - return null; - } - return new Integer(i + 1); - } - - /** - * Returns id of previous item in container at previous index. - * - * @param id - * ID of an Item in the Container. - * @return ID of the previous Item or null. - */ - @Override - public Object prevItemId(Object id) { - if (size < 1 || !(id instanceof Integer)) { - return null; - } - final int i = ((Integer) id).intValue(); - if (i <= 1) { - return null; - } - return new Integer(i - 1); - } - - /** - * The Row class implements methods of Item. - * - * @author Vaadin Ltd. - * @since 4.0 - */ - class Row implements Item { - - Object id; - - private Row(Object rowId) { - id = rowId; - } - - /** - * Adds the item property. - * - * @param id - * ID of the new Property. - * @param property - * Property to be added and associated with ID. - * @return true if the operation succeeded; - * false otherwise. - * @throws UnsupportedOperationException - * if the addItemProperty method is not supported. - */ - @Override - public boolean addItemProperty(Object id, Property property) - throws UnsupportedOperationException { - throw new UnsupportedOperationException(); - } - - /** - * Gets the property corresponding to the given property ID stored in - * the Item. - * - * @param propertyId - * identifier of the Property to get - * @return the Property with the given ID or null - */ - @Override - public Property getItemProperty(Object propertyId) { - return getContainerProperty(id, propertyId); - } - - /** - * Gets the collection of property IDs stored in the Item. - * - * @return unmodifiable collection containing IDs of the Properties - * stored the Item. - */ - @Override - public Collection getItemPropertyIds() { - return propertyIds; - } - - /** - * Removes given item property. - * - * @param id - * ID of the Property to be removed. - * @return true if the item property is removed; - * false otherwise. - * @throws UnsupportedOperationException - * if the removeItemProperty is not supported. - */ - @Override - public boolean removeItemProperty(Object id) - throws UnsupportedOperationException { - throw new UnsupportedOperationException(); - } - - } - - /** - * Closes the statement. - * - * @see #close() - */ - @Override - public void finalize() { - try { - close(); - } catch (final SQLException ignored) { - - } - } - - /** - * Adds the given item at the position of given index. - * - * @param index - * Index to add the new item. - * @param newItemId - * Id of the new item to be added. - * @return new item or null if the operation fails. - * @throws UnsupportedOperationException - * if the addItemAt is not supported. - */ - @Override - public Item addItemAt(int index, Object newItemId) - throws UnsupportedOperationException { - throw new UnsupportedOperationException(); - } - - /** - * Adds item at the position of provided index in the container. - * - * @param index - * Index to add the new item. - * @return item id created new item or null if the operation - * fails. - * - * @throws UnsupportedOperationException - * if the addItemAt is not supported. - */ - - @Override - public Object addItemAt(int index) throws UnsupportedOperationException { - throw new UnsupportedOperationException(); - } - - /** - * Gets the Index id in the container. - * - * @param index - * Index Id. - * @return ID in the given index. - */ - @Override - public Object getIdByIndex(int index) { - if (size < 1 || index < 0 || index >= size) { - return null; - } - return new Integer(index + 1); - } - - /** - * Gets the index of the Item corresponding to id in the container. - * - * @param id - * ID of an Item in the Container - * @return index of the Item, or -1 if the Container does not include the - * Item - */ - - @Override - public int indexOfId(Object id) { - if (size < 1 || !(id instanceof Integer)) { - return -1; - } - final int i = ((Integer) id).intValue(); - if (i >= size || i < 1) { - return -1; - } - return i - 1; - } - -} diff --git a/server/src/com/vaadin/data/util/sqlcontainer/ColumnProperty.java b/server/src/com/vaadin/data/util/sqlcontainer/ColumnProperty.java index 0146c92b5c..6e5ba0dc57 100644 --- a/server/src/com/vaadin/data/util/sqlcontainer/ColumnProperty.java +++ b/server/src/com/vaadin/data/util/sqlcontainer/ColumnProperty.java @@ -69,7 +69,9 @@ final public class ColumnProperty implements Property { * @param value * @param type * - * @deprecated + * @deprecated as of 7.0. Use + * {@link #ColumnProperty(String, boolean, boolean, boolean, boolean, Object, Class) + * instead */ @Deprecated public ColumnProperty(String propertyId, boolean readOnly, @@ -144,7 +146,7 @@ final public class ColumnProperty implements Property { @Override public void setValue(Object newValue) throws ReadOnlyException, - ConversionException { + ConversionException { if (newValue == null && !nullable) { throw new NotNullableException( "Null values are not allowed for this property."); diff --git a/server/src/com/vaadin/ui/AbstractComponent.java b/server/src/com/vaadin/ui/AbstractComponent.java index 1eb95311cd..585e3e2513 100644 --- a/server/src/com/vaadin/ui/AbstractComponent.java +++ b/server/src/com/vaadin/ui/AbstractComponent.java @@ -121,34 +121,6 @@ public abstract class AbstractComponent extends AbstractClientConnector return getState().getDebugId(); } - /** - * Gets style for component. Multiple styles are joined with spaces. - * - * @return the component's styleValue of property style. - * @deprecated Use getStyleName() instead; renamed for consistency and to - * indicate that "style" should not be used to switch client - * side implementation, only to style the component. - */ - @Deprecated - public String getStyle() { - return getStyleName(); - } - - /** - * Sets and replaces all previous style names of the component. This method - * will trigger a {@link RepaintRequestEvent}. - * - * @param style - * the new style of the component. - * @deprecated Use setStyleName() instead; renamed for consistency and to - * indicate that "style" should not be used to switch client - * side implementation, only to style the component. - */ - @Deprecated - public void setStyle(String style) { - setStyleName(style); - } - /* * Gets the component's style. Don't add a JavaDoc comment here, we use the * default documentation from implemented interface. diff --git a/server/src/com/vaadin/ui/AbstractOrderedLayout.java b/server/src/com/vaadin/ui/AbstractOrderedLayout.java index cac9c05fb8..ce6a3eafbd 100644 --- a/server/src/com/vaadin/ui/AbstractOrderedLayout.java +++ b/server/src/com/vaadin/ui/AbstractOrderedLayout.java @@ -232,19 +232,6 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements } } - /* - * (non-Javadoc) - * - * @see com.vaadin.ui.Layout.AlignmentHandler#setComponentAlignment(com - * .vaadin.ui.Component, int, int) - */ - @Override - public void setComponentAlignment(Component childComponent, - int horizontalAlignment, int verticalAlignment) { - Alignment a = new Alignment(horizontalAlignment + verticalAlignment); - setComponentAlignment(childComponent, a); - } - @Override public void setComponentAlignment(Component childComponent, Alignment alignment) { diff --git a/server/src/com/vaadin/ui/DragAndDropWrapper.java b/server/src/com/vaadin/ui/DragAndDropWrapper.java index 3fd94210d8..1c41de81a0 100644 --- a/server/src/com/vaadin/ui/DragAndDropWrapper.java +++ b/server/src/com/vaadin/ui/DragAndDropWrapper.java @@ -156,22 +156,6 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget, .valueOf((String) getData("horizontalLocation")); } - /** - * @deprecated use {@link #getVerticalDropLocation()} instead - */ - @Deprecated - public VerticalDropLocation verticalDropLocation() { - return getVerticalDropLocation(); - } - - /** - * @deprecated use {@link #getHorizontalDropLocation()} instead - */ - @Deprecated - public HorizontalDropLocation horizontalDropLocation() { - return getHorizontalDropLocation(); - } - } public enum DragStartMode { diff --git a/server/src/com/vaadin/ui/GridLayout.java b/server/src/com/vaadin/ui/GridLayout.java index 52aef4c253..5abfb1a22e 100644 --- a/server/src/com/vaadin/ui/GridLayout.java +++ b/server/src/com/vaadin/ui/GridLayout.java @@ -805,14 +805,6 @@ public class GridLayout extends AbstractLayout implements component = newComponent; } - /** - * @deprecated Use {@link #getColumn1()} instead. - */ - @Deprecated - public int getX1() { - return getColumn1(); - } - /** * Gets the column of the top-left corner cell. * @@ -822,14 +814,6 @@ public class GridLayout extends AbstractLayout implements return column1; } - /** - * @deprecated Use {@link #getColumn2()} instead. - */ - @Deprecated - public int getX2() { - return getColumn2(); - } - /** * Gets the column of the bottom-right corner cell. * @@ -839,14 +823,6 @@ public class GridLayout extends AbstractLayout implements return column2; } - /** - * @deprecated Use {@link #getRow1()} instead. - */ - @Deprecated - public int getY1() { - return getRow1(); - } - /** * Gets the row of the top-left corner cell. * @@ -856,14 +832,6 @@ public class GridLayout extends AbstractLayout implements return row1; } - /** - * @deprecated Use {@link #getRow2()} instead. - */ - @Deprecated - public int getY2() { - return getRow2(); - } - /** * Gets the row of the bottom-right corner cell. * @@ -1149,20 +1117,6 @@ public class GridLayout extends AbstractLayout implements cursorY = 0; } - /* - * (non-Javadoc) - * - * @see com.vaadin.ui.Layout.AlignmentHandler#setComponentAlignment(com - * .vaadin.ui.Component, int, int) - */ - @Override - public void setComponentAlignment(Component childComponent, - int horizontalAlignment, int verticalAlignment) { - componentToAlignment.put(childComponent, new Alignment( - horizontalAlignment + verticalAlignment)); - requestRepaint(); - } - @Override public void setComponentAlignment(Component childComponent, Alignment alignment) { diff --git a/server/src/com/vaadin/ui/Layout.java b/server/src/com/vaadin/ui/Layout.java index 9c7cd2b477..b32cf8c47d 100644 --- a/server/src/com/vaadin/ui/Layout.java +++ b/server/src/com/vaadin/ui/Layout.java @@ -18,7 +18,6 @@ package com.vaadin.ui; import java.io.Serializable; -import com.vaadin.shared.ui.AlignmentInfo.Bits; import com.vaadin.shared.ui.MarginInfo; /** @@ -38,74 +37,6 @@ public interface Layout extends ComponentContainer, Serializable { */ public interface AlignmentHandler extends Serializable { - /** - * Contained component should be aligned horizontally to the left. - * - * @deprecated Use of {@link Alignment} class and its constants - */ - @Deprecated - public static final int ALIGNMENT_LEFT = Bits.ALIGNMENT_LEFT; - - /** - * Contained component should be aligned horizontally to the right. - * - * @deprecated Use of {@link Alignment} class and its constants - */ - @Deprecated - public static final int ALIGNMENT_RIGHT = Bits.ALIGNMENT_RIGHT; - - /** - * Contained component should be aligned vertically to the top. - * - * @deprecated Use of {@link Alignment} class and its constants - */ - @Deprecated - public static final int ALIGNMENT_TOP = Bits.ALIGNMENT_TOP; - - /** - * Contained component should be aligned vertically to the bottom. - * - * @deprecated Use of {@link Alignment} class and its constants - */ - @Deprecated - public static final int ALIGNMENT_BOTTOM = Bits.ALIGNMENT_BOTTOM; - - /** - * Contained component should be horizontally aligned to center. - * - * @deprecated Use of {@link Alignment} class and its constants - */ - @Deprecated - public static final int ALIGNMENT_HORIZONTAL_CENTER = Bits.ALIGNMENT_HORIZONTAL_CENTER; - - /** - * Contained component should be vertically aligned to center. - * - * @deprecated Use of {@link Alignment} class and its constants - */ - @Deprecated - public static final int ALIGNMENT_VERTICAL_CENTER = Bits.ALIGNMENT_VERTICAL_CENTER; - - /** - * Set alignment for one contained component in this layout. Alignment - * is calculated as a bit mask of the two passed values. - * - * @deprecated Use {@link #setComponentAlignment(Component, Alignment)} - * instead - * - * @param childComponent - * the component to align within it's layout cell. - * @param horizontalAlignment - * the horizontal alignment for the child component (left, - * center, right). Use ALIGNMENT constants. - * @param verticalAlignment - * the vertical alignment for the child component (top, - * center, bottom). Use ALIGNMENT constants. - */ - @Deprecated - public void setComponentAlignment(Component childComponent, - int horizontalAlignment, int verticalAlignment); - /** * Set alignment for one contained component in this layout. Use * predefined alignments from Alignment class. diff --git a/server/src/com/vaadin/ui/PopupView.java b/server/src/com/vaadin/ui/PopupView.java index 4a5814f660..198ba00ed2 100644 --- a/server/src/com/vaadin/ui/PopupView.java +++ b/server/src/com/vaadin/ui/PopupView.java @@ -159,22 +159,6 @@ public class PopupView extends AbstractComponentContainer implements return content; } - /** - * @deprecated Use {@link #setPopupVisible()} instead. - */ - @Deprecated - public void setPopupVisibility(boolean visible) { - setPopupVisible(visible); - } - - /** - * @deprecated Use {@link #isPopupVisible()} instead. - */ - @Deprecated - public boolean getPopupVisibility() { - return isPopupVisible(); - } - /** * Set the visibility of the popup. Does not hide the minimal * representation. diff --git a/server/src/com/vaadin/ui/RichTextArea.java b/server/src/com/vaadin/ui/RichTextArea.java index e3d1168559..e954f78700 100644 --- a/server/src/com/vaadin/ui/RichTextArea.java +++ b/server/src/com/vaadin/ui/RichTextArea.java @@ -16,7 +16,6 @@ package com.vaadin.ui; -import java.text.Format; import java.util.Map; import com.vaadin.data.Property; @@ -34,12 +33,6 @@ import com.vaadin.terminal.Vaadin6Component; public class RichTextArea extends AbstractField implements Vaadin6Component { - /** - * Value formatter used to format the string contents. - */ - @Deprecated - private Format format; - /** * Null representation. */ @@ -123,7 +116,7 @@ public class RichTextArea extends AbstractField implements } // Adds the content as variable - String value = getFormattedValue(); + String value = getValue(); if (value == null) { value = getNullRepresentation(); } @@ -167,37 +160,6 @@ public class RichTextArea extends AbstractField implements requestRepaint(); } - /** - * Gets the formatted string value. Sets the field value by using the - * assigned Format. - * - * @return the Formatted value. - * @see #setFormat(Format) - * @see Format - * @deprecated - */ - @Deprecated - protected String getFormattedValue() { - Object v = getValue(); - if (v == null) { - return null; - } - return v.toString(); - } - - @Override - public String getValue() { - String v = super.getValue(); - if (format == null || v == null) { - return v; - } - try { - return format.format(v); - } catch (final IllegalArgumentException e) { - return v; - } - } - @Override public void changeVariables(Object source, Map variables) { // Sets the text @@ -207,7 +169,7 @@ public class RichTextArea extends AbstractField implements // has been updated String newValue = (String) variables.get("text"); - final String oldValue = getFormattedValue(); + final String oldValue = getValue(); if (newValue != null && (oldValue == null || isNullSettingAllowed()) && newValue.equals(getNullRepresentation())) { @@ -218,9 +180,9 @@ public class RichTextArea extends AbstractField implements boolean wasModified = isModified(); setValue(newValue, true); - // If the modified status changes, or if we have a formatter, + // If the modified status changes, // repaint is needed after all. - if (format != null || wasModified != isModified()) { + if (wasModified != isModified()) { requestRepaint(); } } @@ -323,31 +285,6 @@ public class RichTextArea extends AbstractField implements this.nullSettingAllowed = nullSettingAllowed; } - /** - * Gets the value formatter of TextField. - * - * @return the Format used to format the value. - * @deprecated replaced by {@link com.vaadin.data.util.PropertyFormatter} - */ - @Deprecated - public Format getFormat() { - return format; - } - - /** - * Gets the value formatter of TextField. - * - * @param format - * the Format used to format the value. Null disables the - * formatting. - * @deprecated replaced by {@link com.vaadin.data.util.PropertyFormatter} - */ - @Deprecated - public void setFormat(Format format) { - this.format = format; - requestRepaint(); - } - @Override protected boolean isEmpty() { return super.isEmpty() || getValue().length() == 0; diff --git a/server/src/com/vaadin/ui/Select.java b/server/src/com/vaadin/ui/Select.java index 698350cb30..898728b9cd 100644 --- a/server/src/com/vaadin/ui/Select.java +++ b/server/src/com/vaadin/ui/Select.java @@ -697,40 +697,6 @@ public class Select extends AbstractSelect implements AbstractSelect.Filtering, return filteringMode; } - /** - * Note, one should use more generic setWidth(String) method instead of - * this. This now days actually converts columns to width with em css unit. - * - * Sets the number of columns in the editor. If the number of columns is set - * 0, the actual number of displayed columns is determined implicitly by the - * adapter. - * - * @deprecated - * - * @param columns - * the number of columns to set. - */ - @Deprecated - public void setColumns(int columns) { - if (columns < 0) { - columns = 0; - } - if (this.columns != columns) { - this.columns = columns; - setWidth(columns, Select.UNITS_EM); - requestRepaint(); - } - } - - /** - * @deprecated see setter function - * @return - */ - @Deprecated - public int getColumns() { - return columns; - } - @Override public void addListener(BlurListener listener) { addListener(BlurEvent.EVENT_ID, BlurEvent.class, listener, diff --git a/server/src/com/vaadin/ui/TabSheet.java b/server/src/com/vaadin/ui/TabSheet.java index 5a1aa02845..868d97a09c 100644 --- a/server/src/com/vaadin/ui/TabSheet.java +++ b/server/src/com/vaadin/ui/TabSheet.java @@ -361,8 +361,9 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, String caption = null; Resource icon = null; if (TabSheet.class.isAssignableFrom(source.getClass())) { - caption = ((TabSheet) source).getTabCaption(c); - icon = ((TabSheet) source).getTabIcon(c); + Tab tab = ((TabSheet) source).getTab(c); + caption = tab.getCaption(); + icon = tab.getIcon(); } source.removeComponent(c); addTab(c, caption, icon); @@ -477,82 +478,6 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, requestRepaint(); } - /** - * Gets tab caption. The tab is identified by the tab content component. - * - * @param c - * the component in the tab - * @deprecated Use {@link #getTab(Component)} and {@link Tab#getCaption()} - * instead. - */ - @Deprecated - public String getTabCaption(Component c) { - Tab info = tabs.get(c); - if (info == null) { - return ""; - } else { - return info.getCaption(); - } - } - - /** - * Sets tab caption. The tab is identified by the tab content component. - * - * @param c - * the component in the tab - * @param caption - * the caption to set. - * @deprecated Use {@link #getTab(Component)} and - * {@link Tab#setCaption(String)} instead. - */ - @Deprecated - public void setTabCaption(Component c, String caption) { - Tab info = tabs.get(c); - if (info != null) { - info.setCaption(caption); - requestRepaint(); - } - } - - /** - * Gets the icon for a tab. The tab is identified by the tab content - * component. - * - * @param c - * the component in the tab - * @deprecated Use {@link #getTab(Component)} and {@link Tab#getIcon()} - * instead. - */ - @Deprecated - public Resource getTabIcon(Component c) { - Tab info = tabs.get(c); - if (info == null) { - return null; - } else { - return info.getIcon(); - } - } - - /** - * Sets icon for the given component. The tab is identified by the tab - * content component. - * - * @param c - * the component in the tab - * @param icon - * the icon to set - * @deprecated Use {@link #getTab(Component)} and - * {@link Tab#setIcon(Resource)} instead. - */ - @Deprecated - public void setTabIcon(Component c, Resource icon) { - Tab info = tabs.get(c); - if (info != null) { - info.setIcon(icon); - requestRepaint(); - } - } - /** * Returns the {@link Tab} (metadata) for a component. The {@link Tab} * object can be used for setting caption,icon, etc for the tab. diff --git a/server/src/com/vaadin/ui/Table.java b/server/src/com/vaadin/ui/Table.java index 2bbb69beaf..120d1f9810 100644 --- a/server/src/com/vaadin/ui/Table.java +++ b/server/src/com/vaadin/ui/Table.java @@ -1506,31 +1506,6 @@ public class Table extends AbstractSelect implements Action.Container, setCurrentPageFirstItemIndex(newIndex, true); } - /** - * Getter for property pageBuffering. - * - * @deprecated functionality is not needed in ajax rendering model - * - * @return the Value of property pageBuffering. - */ - @Deprecated - public boolean isPageBufferingEnabled() { - return true; - } - - /** - * Setter for property pageBuffering. - * - * @deprecated functionality is not needed in ajax rendering model - * - * @param pageBuffering - * the New value of property pageBuffering. - */ - @Deprecated - public void setPageBufferingEnabled(boolean pageBuffering) { - - } - /** * Getter for property selectable. * @@ -2229,16 +2204,6 @@ public class Table extends AbstractSelect implements Action.Container, } } - /** - * Refreshes the current page contents. - * - * @deprecated should not need to be used - */ - @Deprecated - public void refreshCurrentPage() { - - } - /** * Sets the row header mode. *

    diff --git a/server/src/com/vaadin/ui/Upload.java b/server/src/com/vaadin/ui/Upload.java index c4f15ebea9..b50ba03835 100644 --- a/server/src/com/vaadin/ui/Upload.java +++ b/server/src/com/vaadin/ui/Upload.java @@ -855,33 +855,6 @@ public class Upload extends AbstractComponent implements Component.Focusable, return contentLength; } - /** - * This method is deprecated, use addListener(ProgressListener) instead. - * - * @deprecated Use addListener(ProgressListener) instead. - * @param progressListener - */ - @Deprecated - public void setProgressListener(ProgressListener progressListener) { - addListener(progressListener); - } - - /** - * This method is deprecated. - * - * @deprecated Replaced with addListener/removeListener - * @return listener - * - */ - @Deprecated - public ProgressListener getProgressListener() { - if (progressListeners == null || progressListeners.isEmpty()) { - return null; - } else { - return progressListeners.iterator().next(); - } - } - /** * ProgressListener receives events to track progress of upload. */ diff --git a/server/src/com/vaadin/ui/themes/BaseTheme.java b/server/src/com/vaadin/ui/themes/BaseTheme.java index bdb0087d2e..9e95627eec 100644 --- a/server/src/com/vaadin/ui/themes/BaseTheme.java +++ b/server/src/com/vaadin/ui/themes/BaseTheme.java @@ -44,18 +44,6 @@ public class BaseTheme { */ public static final String BUTTON_LINK = "link"; - /** - * Removes extra decorations from the panel. - * - * @deprecated Base theme does not implement this style, but it is defined - * here since it has been a part of the framework before - * multiple themes were available. Use the constant provided by - * the theme you're using instead, e.g. - * {@link Reindeer#PANEL_LIGHT} or {@link Runo#PANEL_LIGHT}. - */ - @Deprecated - public static final String PANEL_LIGHT = "light"; - /** * Adds the connector lines between a parent node and its child nodes to * indicate the tree hierarchy better. diff --git a/server/src/com/vaadin/ui/themes/Reindeer.java b/server/src/com/vaadin/ui/themes/Reindeer.java index 7bc6720465..037f59d7b4 100644 --- a/server/src/com/vaadin/ui/themes/Reindeer.java +++ b/server/src/com/vaadin/ui/themes/Reindeer.java @@ -48,12 +48,6 @@ public class Reindeer extends BaseTheme { */ public static final String LABEL_SMALL = "light"; - /** - * @deprecated Use {@link #LABEL_SMALL} instead. - */ - @Deprecated - public static final String LABEL_LIGHT = "small"; - /*************************************************************************** * * Button styles @@ -67,12 +61,6 @@ public class Reindeer extends BaseTheme { */ public static final String BUTTON_DEFAULT = "primary"; - /** - * @deprecated Use {@link #BUTTON_DEFAULT} instead - */ - @Deprecated - public static final String BUTTON_PRIMARY = BUTTON_DEFAULT; - /** * Small sized button, use for context specific actions for example */ @@ -128,12 +116,6 @@ public class Reindeer extends BaseTheme { */ public static final String TABSHEET_SMALL = "bar"; - /** - * @deprecated Use {@link #TABSHEET_SMALL} instead. - */ - @Deprecated - public static final String TABSHEET_BAR = TABSHEET_SMALL; - /** * Removes borders and background color from the tab sheet. The tabs are * presented with minimal lines indicating the selected tab. diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1710.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1710.java index 1f2c9624c3..6547572e6d 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1710.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1710.java @@ -5,10 +5,12 @@ import java.util.Iterator; import com.vaadin.data.Property; import com.vaadin.data.Property.ValueChangeEvent; import com.vaadin.data.util.MethodProperty; +import com.vaadin.shared.ui.AlignmentInfo.Bits; import com.vaadin.shared.ui.MarginInfo; import com.vaadin.terminal.SystemError; import com.vaadin.terminal.ThemeResource; import com.vaadin.ui.AbstractComponent; +import com.vaadin.ui.Alignment; import com.vaadin.ui.Button; import com.vaadin.ui.CheckBox; import com.vaadin.ui.Component; @@ -320,76 +322,66 @@ public class Ticket1710 extends com.vaadin.Application.LegacyApplication { hAlign.setNullSelectionAllowed(false); vAlign.setNullSelectionAllowed(false); - vAlign.addItem(new Integer(Layout.AlignmentHandler.ALIGNMENT_TOP)); - vAlign.setItemCaption(new Integer( - Layout.AlignmentHandler.ALIGNMENT_TOP), "top"); - vAlign.addItem(new Integer( - Layout.AlignmentHandler.ALIGNMENT_VERTICAL_CENTER)); - vAlign.setItemCaption(new Integer( - Layout.AlignmentHandler.ALIGNMENT_VERTICAL_CENTER), + vAlign.addItem(new Integer(Bits.ALIGNMENT_TOP)); + vAlign.setItemCaption(new Integer(Bits.ALIGNMENT_TOP), "top"); + vAlign.addItem(new Integer(Bits.ALIGNMENT_VERTICAL_CENTER)); + vAlign.setItemCaption(new Integer(Bits.ALIGNMENT_VERTICAL_CENTER), "center"); - vAlign.addItem(new Integer(Layout.AlignmentHandler.ALIGNMENT_BOTTOM)); - vAlign.setItemCaption(new Integer( - Layout.AlignmentHandler.ALIGNMENT_BOTTOM), "bottom"); - - hAlign.addItem(new Integer(Layout.AlignmentHandler.ALIGNMENT_LEFT)); - hAlign.setItemCaption(new Integer( - Layout.AlignmentHandler.ALIGNMENT_LEFT), "left"); - hAlign.addItem(new Integer( - Layout.AlignmentHandler.ALIGNMENT_HORIZONTAL_CENTER)); - hAlign.setItemCaption(new Integer( - Layout.AlignmentHandler.ALIGNMENT_HORIZONTAL_CENTER), - "center"); - hAlign.addItem(new Integer(Layout.AlignmentHandler.ALIGNMENT_RIGHT)); - hAlign.setItemCaption(new Integer( - Layout.AlignmentHandler.ALIGNMENT_RIGHT), "right"); + vAlign.addItem(new Integer(Bits.ALIGNMENT_BOTTOM)); + vAlign.setItemCaption(new Integer(Bits.ALIGNMENT_BOTTOM), "bottom"); + + hAlign.addItem(new Integer(Bits.ALIGNMENT_LEFT)); + hAlign.setItemCaption(new Integer(Bits.ALIGNMENT_LEFT), "left"); + hAlign.addItem(new Integer(Bits.ALIGNMENT_HORIZONTAL_CENTER)); + hAlign.setItemCaption( + new Integer(Bits.ALIGNMENT_HORIZONTAL_CENTER), "center"); + hAlign.addItem(new Integer(Bits.ALIGNMENT_RIGHT)); + hAlign.setItemCaption(new Integer(Bits.ALIGNMENT_RIGHT), "right"); Property.ValueChangeListener alignmentChangeListener = new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { - updateAlignments(((Integer) hAlign.getValue()).intValue(), - ((Integer) vAlign.getValue()).intValue()); + Integer h = ((Integer) hAlign.getValue()).intValue(); + int v = ((Integer) vAlign.getValue()).intValue(); + + updateAlignments(new Alignment(h + v)); } }; - hAlign.setValue(new Integer(Layout.AlignmentHandler.ALIGNMENT_LEFT)); + hAlign.setValue(new Integer(Bits.ALIGNMENT_LEFT)); vAlign.addListener(alignmentChangeListener); hAlign.addListener(alignmentChangeListener); - vAlign.setValue(new Integer(Layout.AlignmentHandler.ALIGNMENT_TOP)); + vAlign.setValue(new Integer(Bits.ALIGNMENT_TOP)); controls.addComponent(new Label("layout alignment")); final NativeSelect lAlign = new NativeSelect(); controls.addComponent(lAlign); lAlign.setNullSelectionAllowed(false); - lAlign.addItem(new Integer(Layout.AlignmentHandler.ALIGNMENT_LEFT)); - lAlign.setItemCaption(new Integer( - Layout.AlignmentHandler.ALIGNMENT_LEFT), "left"); - lAlign.addItem(new Integer( - Layout.AlignmentHandler.ALIGNMENT_HORIZONTAL_CENTER)); - lAlign.setItemCaption(new Integer( - Layout.AlignmentHandler.ALIGNMENT_HORIZONTAL_CENTER), - "center"); - lAlign.addItem(new Integer(Layout.AlignmentHandler.ALIGNMENT_RIGHT)); - lAlign.setItemCaption(new Integer( - Layout.AlignmentHandler.ALIGNMENT_RIGHT), "right"); + lAlign.addItem(new Integer(Bits.ALIGNMENT_LEFT)); + lAlign.setItemCaption(new Integer(Bits.ALIGNMENT_LEFT), "left"); + lAlign.addItem(new Integer(Bits.ALIGNMENT_HORIZONTAL_CENTER)); + lAlign.setItemCaption( + new Integer(Bits.ALIGNMENT_HORIZONTAL_CENTER), "center"); + lAlign.addItem(new Integer(Bits.ALIGNMENT_RIGHT)); + lAlign.setItemCaption(new Integer(Bits.ALIGNMENT_RIGHT), "right"); lAlign.addListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { - testPanelLayout.setComponentAlignment(testedLayout, - ((Integer) lAlign.getValue()).intValue(), - VerticalLayout.ALIGNMENT_TOP); + testPanelLayout.setComponentAlignment( + testedLayout, + new Alignment(((Integer) lAlign.getValue()) + .intValue() + Bits.ALIGNMENT_TOP)); } }); } - @SuppressWarnings("deprecation") - private void updateAlignments(int h, int v) { + private void updateAlignments(Alignment a) { for (Iterator i = testedLayout.getComponentIterator(); i .hasNext();) { ((Layout.AlignmentHandler) testedLayout).setComponentAlignment( - i.next(), h, v); + i.next(), a); } } -- cgit v1.2.3 From 05422d4a9ab485e9130ed1205b52acdeb2295a37 Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Thu, 23 Aug 2012 09:14:55 +0300 Subject: Don't import client classes for javadocs --- server/src/com/vaadin/ui/AbstractJavaScriptComponent.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/server/src/com/vaadin/ui/AbstractJavaScriptComponent.java b/server/src/com/vaadin/ui/AbstractJavaScriptComponent.java index 67b6447ef9..e19bdf1b2b 100644 --- a/server/src/com/vaadin/ui/AbstractJavaScriptComponent.java +++ b/server/src/com/vaadin/ui/AbstractJavaScriptComponent.java @@ -17,8 +17,6 @@ package com.vaadin.ui; import com.vaadin.shared.ui.JavaScriptComponentState; import com.vaadin.terminal.JavaScriptCallbackHelper; -import com.vaadin.terminal.gwt.client.ApplicationConnection; -import com.vaadin.terminal.gwt.client.ui.JavaScriptWidget; /** * Base class for Components with all client-side logic implemented using @@ -36,9 +34,10 @@ import com.vaadin.terminal.gwt.client.ui.JavaScriptWidget; * , then com_example_SuperComponent will also be attempted if * com_example_MyComponent has not been defined. *

    - * JavaScript components have a very simple GWT widget ({@link JavaScriptWidget} - * ) just consisting of a div element to which the JavaScript code - * should initialize its own user interface. + * JavaScript components have a very simple GWT widget ( + * {@link com.vaadin.terminal.gwt.client.ui.JavaScriptWidget} ) just consisting + * of a div element to which the JavaScript code should initialize + * its own user interface. *

    * The initialization function will be called with this pointing to * a connector wrapper object providing integration to Vaadin with the following @@ -81,7 +80,8 @@ import com.vaadin.terminal.gwt.client.ui.JavaScriptWidget; * functions is described bellow. *

  • translateVaadinUri(uri) - Translates a Vaadin URI to a URL * that can be used in the browser. This is just way of accessing - * {@link ApplicationConnection#translateVaadinUri(String)}
  • + * {@link com.vaadin.terminal.gwt.client.ApplicationConnection#translateVaadinUri(String)} + * * * The connector wrapper also supports these special functions: *
      -- cgit v1.2.3 From 034304bda81dfe65725c37a6eae3fbcdf7496082 Mon Sep 17 00:00:00 2001 From: John Ahlroos Date: Thu, 23 Aug 2012 10:30:09 +0300 Subject: GWT build version is now replaced with GWT-VAADIN build version. --- build/build.xml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/build/build.xml b/build/build.xml index 2988218c4d..d905bb9c6f 100644 --- a/build/build.xml +++ b/build/build.xml @@ -129,6 +129,7 @@ + @@ -848,9 +849,12 @@ ${version.full} + + + gwt.version=${gwt-version}.vaadin${version.full} + compress="true" manifest="build/package/META-INF/MANIFEST.MF" duplicate="preserve" index="true" > @@ -874,6 +878,7 @@ + @@ -899,7 +904,7 @@ - + - + + + -- cgit v1.2.3 From fad5360a76b9f4f93b99f9775ad01997899859ab Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Thu, 23 Aug 2012 10:32:07 +0300 Subject: Make getStateType() find for protected getState methods (#9315) --- server/src/com/vaadin/terminal/AbstractClientConnector.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/server/src/com/vaadin/terminal/AbstractClientConnector.java b/server/src/com/vaadin/terminal/AbstractClientConnector.java index a8da553a62..1025297a4f 100644 --- a/server/src/com/vaadin/terminal/AbstractClientConnector.java +++ b/server/src/com/vaadin/terminal/AbstractClientConnector.java @@ -187,7 +187,16 @@ public abstract class AbstractClientConnector implements ClientConnector { @Override public Class getStateType() { try { - Method m = getClass().getMethod("getState", (Class[]) null); + Method m = null; + Class class1 = getClass(); + while (m == null && class1 != null) { + m = class1.getDeclaredMethod("getState", (Class[]) null); + class1 = class1.getSuperclass(); + } + if (m == null) { + throw new NoSuchMethodException(getClass().getCanonicalName() + + ".getState()"); + } Class type = m.getReturnType(); return type.asSubclass(SharedState.class); } catch (Exception e) { -- cgit v1.2.3 From 8606feb8596ed8f6cd3ed41160706b692f6f4679 Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Thu, 23 Aug 2012 10:46:17 +0300 Subject: Make getStateType() find getState methods in superclases (#9315) Also cache the result as the finding logic could be quite expensive with multiple exceptions thrown and caught. --- .../vaadin/terminal/AbstractClientConnector.java | 39 +++++++++++++--------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/server/src/com/vaadin/terminal/AbstractClientConnector.java b/server/src/com/vaadin/terminal/AbstractClientConnector.java index 1025297a4f..53b3bb1c9d 100644 --- a/server/src/com/vaadin/terminal/AbstractClientConnector.java +++ b/server/src/com/vaadin/terminal/AbstractClientConnector.java @@ -71,6 +71,8 @@ public abstract class AbstractClientConnector implements ClientConnector { */ private SharedState sharedState; + private Class stateType; + /** * Pending RPC method invocations to be sent. */ @@ -179,26 +181,33 @@ public abstract class AbstractClientConnector implements ClientConnector { } } - /* - * (non-Javadoc) - * - * @see com.vaadin.terminal.gwt.server.ClientConnector#getStateType() - */ @Override public Class getStateType() { + // Lazy load because finding type can be expensive because of the + // exceptions flying around + if (stateType == null) { + stateType = findStateType(); + } + + return stateType; + } + + private Class findStateType() { try { - Method m = null; Class class1 = getClass(); - while (m == null && class1 != null) { - m = class1.getDeclaredMethod("getState", (Class[]) null); - class1 = class1.getSuperclass(); - } - if (m == null) { - throw new NoSuchMethodException(getClass().getCanonicalName() - + ".getState()"); + while (class1 != null) { + try { + Method m = class1.getDeclaredMethod("getState", + (Class[]) null); + Class type = m.getReturnType(); + return type.asSubclass(SharedState.class); + } catch (NoSuchMethodException nsme) { + // Try in superclass instead + class1 = class1.getSuperclass(); + } } - Class type = m.getReturnType(); - return type.asSubclass(SharedState.class); + throw new NoSuchMethodException(getClass().getCanonicalName() + + ".getState()"); } catch (Exception e) { throw new RuntimeException("Error finding state type for " + getClass().getName(), e); -- cgit v1.2.3 From af8afede9f0d196a28792dea9e587a1eac829902 Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Thu, 23 Aug 2012 11:23:10 +0300 Subject: Handle requestRepaint automatically (#9325) --- .../vaadin/terminal/AbstractClientConnector.java | 10 ++++- .../vaadin/terminal/JavaScriptCallbackHelper.java | 6 +-- server/src/com/vaadin/ui/AbstractComponent.java | 26 +----------- server/src/com/vaadin/ui/AbstractField.java | 4 -- server/src/com/vaadin/ui/AbstractMedia.java | 6 --- .../src/com/vaadin/ui/AbstractOrderedLayout.java | 9 +---- server/src/com/vaadin/ui/AbstractTextField.java | 3 -- server/src/com/vaadin/ui/Button.java | 7 +--- server/src/com/vaadin/ui/ConnectorTracker.java | 4 ++ server/src/com/vaadin/ui/CustomLayout.java | 5 --- server/src/com/vaadin/ui/Form.java | 9 ----- server/src/com/vaadin/ui/GridLayout.java | 6 --- server/src/com/vaadin/ui/JavaScript.java | 8 +--- server/src/com/vaadin/ui/Label.java | 3 -- server/src/com/vaadin/ui/Panel.java | 3 -- server/src/com/vaadin/ui/Root.java | 2 - server/src/com/vaadin/ui/TextArea.java | 2 - server/src/com/vaadin/ui/Video.java | 1 - server/src/com/vaadin/ui/Window.java | 46 +--------------------- 19 files changed, 20 insertions(+), 140 deletions(-) diff --git a/server/src/com/vaadin/terminal/AbstractClientConnector.java b/server/src/com/vaadin/terminal/AbstractClientConnector.java index 53b3bb1c9d..2b96c5fb35 100644 --- a/server/src/com/vaadin/terminal/AbstractClientConnector.java +++ b/server/src/com/vaadin/terminal/AbstractClientConnector.java @@ -146,6 +146,12 @@ public abstract class AbstractClientConnector implements ClientConnector { if (null == sharedState) { sharedState = createState(); } + + Root root = getRoot(); + if (root != null && !root.getConnectorTracker().isDirty(this)) { + requestRepaint(); + } + return sharedState; } @@ -280,8 +286,6 @@ public abstract class AbstractClientConnector implements ClientConnector { public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { addMethodInvocationToQueue(rpcInterfaceName, method, args); - // TODO no need to do full repaint if only RPC calls - requestRepaint(); return null; } @@ -304,6 +308,8 @@ public abstract class AbstractClientConnector implements ClientConnector { // add to queue pendingInvocations.add(new ClientMethodInvocation(this, interfaceName, method, parameters)); + // TODO no need to do full repaint if only RPC calls + requestRepaint(); } /** diff --git a/server/src/com/vaadin/terminal/JavaScriptCallbackHelper.java b/server/src/com/vaadin/terminal/JavaScriptCallbackHelper.java index 6153cf2619..f0063a8708 100644 --- a/server/src/com/vaadin/terminal/JavaScriptCallbackHelper.java +++ b/server/src/com/vaadin/terminal/JavaScriptCallbackHelper.java @@ -60,9 +60,7 @@ public class JavaScriptCallbackHelper implements Serializable { JavaScriptFunction javaScriptCallback) { callbacks.put(functionName, javaScriptCallback); JavaScriptConnectorState state = getConnectorState(); - if (state.getCallbackNames().add(functionName)) { - connector.requestRepaint(); - } + state.getCallbackNames().add(functionName); ensureRpc(); } @@ -100,7 +98,6 @@ public class JavaScriptCallbackHelper implements Serializable { connector.addMethodInvocationToQueue( JavaScriptCallbackRpc.class.getName(), CALL_METHOD, new Object[] { name, args }); - connector.requestRepaint(); } public void registerRpc(Class rpcInterfaceType) { @@ -119,7 +116,6 @@ public class JavaScriptCallbackHelper implements Serializable { } rpcInterfaces.put(interfaceName, methodNames); - connector.requestRepaint(); } } diff --git a/server/src/com/vaadin/ui/AbstractComponent.java b/server/src/com/vaadin/ui/AbstractComponent.java index 585e3e2513..a799c5d679 100644 --- a/server/src/com/vaadin/ui/AbstractComponent.java +++ b/server/src/com/vaadin/ui/AbstractComponent.java @@ -148,7 +148,6 @@ public abstract class AbstractComponent extends AbstractClientConnector public void setStyleName(String style) { if (style == null || "".equals(style)) { getState().setStyles(null); - requestRepaint(); return; } if (getState().getStyles() == null) { @@ -162,7 +161,6 @@ public abstract class AbstractComponent extends AbstractClientConnector styles.add(part); } } - requestRepaint(); } @Override @@ -184,7 +182,6 @@ public abstract class AbstractComponent extends AbstractClientConnector List styles = getState().getStyles(); if (!styles.contains(style)) { styles.add(style); - requestRepaint(); } } @@ -197,7 +194,6 @@ public abstract class AbstractComponent extends AbstractClientConnector getState().getStyles().remove(part); } } - requestRepaint(); } } @@ -221,7 +217,6 @@ public abstract class AbstractComponent extends AbstractClientConnector @Override public void setCaption(String caption) { getState().setCaption(caption); - requestRepaint(); } /* @@ -289,7 +284,6 @@ public abstract class AbstractComponent extends AbstractClientConnector @Override public void setIcon(Resource icon) { getState().setIcon(ResourceReference.create(icon)); - requestRepaint(); } /* @@ -309,10 +303,7 @@ public abstract class AbstractComponent extends AbstractClientConnector */ @Override public void setEnabled(boolean enabled) { - if (getState().isEnabled() != enabled) { - getState().setEnabled(enabled); - requestRepaint(); - } + getState().setEnabled(enabled); } /* @@ -355,7 +346,6 @@ public abstract class AbstractComponent extends AbstractClientConnector */ public void setImmediate(boolean immediate) { getState().setImmediate(immediate); - requestRepaint(); } /* @@ -380,7 +370,6 @@ public abstract class AbstractComponent extends AbstractClientConnector } getState().setVisible(visible); - requestRepaint(); if (getParent() != null) { // Must always repaint the parent (at least the hierarchy) when // visibility of a child component changes. @@ -463,7 +452,6 @@ public abstract class AbstractComponent extends AbstractClientConnector */ public void setDescription(String description) { getState().setDescription(description); - requestRepaint(); } /* @@ -566,7 +554,6 @@ public abstract class AbstractComponent extends AbstractClientConnector @Override public void setReadOnly(boolean readOnly) { getState().setReadOnly(readOnly); - requestRepaint(); } /* @@ -718,17 +705,6 @@ public abstract class AbstractComponent extends AbstractClientConnector } } - /* Documentation copied from interface */ - @Override - public void requestRepaint() { - // Invisible components (by flag in this particular component) do not - // need repaints - if (!getState().isVisible()) { - return; - } - super.requestRepaint(); - } - /* General event framework */ private static final Method COMPONENT_EVENT_METHOD = ReflectTools diff --git a/server/src/com/vaadin/ui/AbstractField.java b/server/src/com/vaadin/ui/AbstractField.java index f13c6a3138..23481eca9e 100644 --- a/server/src/com/vaadin/ui/AbstractField.java +++ b/server/src/com/vaadin/ui/AbstractField.java @@ -360,7 +360,6 @@ public abstract class AbstractField extends AbstractComponent implements private void setModified(boolean modified) { getState().setModified(modified); - requestRepaint(); } /** @@ -1101,7 +1100,6 @@ public abstract class AbstractField extends AbstractComponent implements @Override public void readOnlyStatusChange(Property.ReadOnlyStatusChangeEvent event) { getState().setPropertyReadOnly(event.getProperty().isReadOnly()); - requestRepaint(); } /** @@ -1233,7 +1231,6 @@ public abstract class AbstractField extends AbstractComponent implements @Override public void setTabIndex(int tabIndex) { getState().setTabIndex(tabIndex); - requestRepaint(); } /** @@ -1336,7 +1333,6 @@ public abstract class AbstractField extends AbstractComponent implements @Override public void setRequired(boolean required) { getState().setRequired(required); - requestRepaint(); } /** diff --git a/server/src/com/vaadin/ui/AbstractMedia.java b/server/src/com/vaadin/ui/AbstractMedia.java index 7a29c8f4ce..77c12ac045 100644 --- a/server/src/com/vaadin/ui/AbstractMedia.java +++ b/server/src/com/vaadin/ui/AbstractMedia.java @@ -66,7 +66,6 @@ public abstract class AbstractMedia extends AbstractComponent { if (source != null) { getState().getSources().add(new ResourceReference(source)); getState().getSourceTypes().add(source.getMIMEType()); - requestRepaint(); } } @@ -103,7 +102,6 @@ public abstract class AbstractMedia extends AbstractComponent { */ public void setShowControls(boolean showControls) { getState().setShowControls(showControls); - requestRepaint(); } /** @@ -126,7 +124,6 @@ public abstract class AbstractMedia extends AbstractComponent { */ public void setAltText(String altText) { getState().setAltText(altText); - requestRepaint(); } /** @@ -145,7 +142,6 @@ public abstract class AbstractMedia extends AbstractComponent { */ public void setHtmlContentAllowed(boolean htmlContentAllowed) { getState().setHtmlContentAllowed(htmlContentAllowed); - requestRepaint(); } /** @@ -164,7 +160,6 @@ public abstract class AbstractMedia extends AbstractComponent { */ public void setAutoplay(boolean autoplay) { getState().setAutoplay(autoplay); - requestRepaint(); } /** @@ -181,7 +176,6 @@ public abstract class AbstractMedia extends AbstractComponent { */ public void setMuted(boolean muted) { getState().setMuted(muted); - requestRepaint(); } /** diff --git a/server/src/com/vaadin/ui/AbstractOrderedLayout.java b/server/src/com/vaadin/ui/AbstractOrderedLayout.java index ce6a3eafbd..0a57cb98c4 100644 --- a/server/src/com/vaadin/ui/AbstractOrderedLayout.java +++ b/server/src/com/vaadin/ui/AbstractOrderedLayout.java @@ -144,13 +144,10 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements private void componentRemoved(Component c) { getState().getChildData().remove(c); - requestRepaint(); } private void componentAdded(Component c) { getState().getChildData().put(c, new ChildComponentData()); - requestRepaint(); - } /** @@ -240,7 +237,6 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements if (childData != null) { // Alignments are bit masks childData.setAlignmentBitmask(alignment.getBitMask()); - requestRepaint(); } else { throw new IllegalArgumentException( "Component must be added to layout before using setComponentAlignment()"); @@ -274,7 +270,6 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements @Override public void setSpacing(boolean spacing) { getState().setSpacing(spacing); - requestRepaint(); } /* @@ -324,8 +319,7 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements } childData.setExpandRatio(ratio); - requestRepaint(); - }; + } /** * Returns the expand ratio of given component. @@ -404,6 +398,5 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements @Override public void setMargin(MarginInfo marginInfo) { getState().setMarginsBitmask(marginInfo.getBitMask()); - requestRepaint(); } } diff --git a/server/src/com/vaadin/ui/AbstractTextField.java b/server/src/com/vaadin/ui/AbstractTextField.java index 54d15eff26..51d5449fdd 100644 --- a/server/src/com/vaadin/ui/AbstractTextField.java +++ b/server/src/com/vaadin/ui/AbstractTextField.java @@ -324,7 +324,6 @@ public abstract class AbstractTextField extends AbstractField implements */ public void setMaxLength(int maxLength) { getState().setMaxLength(maxLength); - requestRepaint(); } /** @@ -351,7 +350,6 @@ public abstract class AbstractTextField extends AbstractField implements columns = 0; } getState().setColumns(columns); - requestRepaint(); } /** @@ -372,7 +370,6 @@ public abstract class AbstractTextField extends AbstractField implements */ public void setInputPrompt(String inputPrompt) { getState().setInputPrompt(inputPrompt); - requestRepaint(); } /* ** Text Change Events ** */ diff --git a/server/src/com/vaadin/ui/Button.java b/server/src/com/vaadin/ui/Button.java index c55a955679..8546d8f830 100644 --- a/server/src/com/vaadin/ui/Button.java +++ b/server/src/com/vaadin/ui/Button.java @@ -478,7 +478,6 @@ public class Button extends AbstractComponent implements */ public void setDisableOnClick(boolean disableOnClick) { getState().setDisableOnClick(disableOnClick); - requestRepaint(); } /* @@ -499,7 +498,6 @@ public class Button extends AbstractComponent implements @Override public void setTabIndex(int tabIndex) { getState().setTabIndex(tabIndex); - requestRepaint(); } @Override @@ -526,10 +524,7 @@ public class Button extends AbstractComponent implements * false otherwise */ public void setHtmlContentAllowed(boolean htmlContentAllowed) { - if (getState().isHtmlContentAllowed() != htmlContentAllowed) { - getState().setHtmlContentAllowed(htmlContentAllowed); - requestRepaint(); - } + getState().setHtmlContentAllowed(htmlContentAllowed); } /** diff --git a/server/src/com/vaadin/ui/ConnectorTracker.java b/server/src/com/vaadin/ui/ConnectorTracker.java index 2afe7f9025..72879e0a25 100644 --- a/server/src/com/vaadin/ui/ConnectorTracker.java +++ b/server/src/com/vaadin/ui/ConnectorTracker.java @@ -385,4 +385,8 @@ public class ConnectorTracker implements Serializable { diffStates.put(connector, diffState); } + public boolean isDirty(ClientConnector connector) { + return dirtyConnectors.contains(connector); + } + } diff --git a/server/src/com/vaadin/ui/CustomLayout.java b/server/src/com/vaadin/ui/CustomLayout.java index 0948a92e5b..54308b99c3 100644 --- a/server/src/com/vaadin/ui/CustomLayout.java +++ b/server/src/com/vaadin/ui/CustomLayout.java @@ -145,7 +145,6 @@ public class CustomLayout extends AbstractLayout implements Vaadin6Component { getState().getChildLocations().put(c, location); c.setParent(this); fireComponentAttachEvent(c); - requestRepaint(); } /** @@ -176,7 +175,6 @@ public class CustomLayout extends AbstractLayout implements Vaadin6Component { slots.values().remove(c); getState().getChildLocations().remove(c); super.removeComponent(c); - requestRepaint(); } /** @@ -251,7 +249,6 @@ public class CustomLayout extends AbstractLayout implements Vaadin6Component { slots.put(oldLocation, newComponent); getState().getChildLocations().put(newComponent, oldLocation); getState().getChildLocations().put(oldComponent, newLocation); - requestRepaint(); } } @@ -277,7 +274,6 @@ public class CustomLayout extends AbstractLayout implements Vaadin6Component { public void setTemplateName(String templateName) { getState().setTemplateName(templateName); getState().setTemplateContents(null); - requestRepaint(); } /** @@ -288,7 +284,6 @@ public class CustomLayout extends AbstractLayout implements Vaadin6Component { public void setTemplateContents(String templateContents) { getState().setTemplateContents(templateContents); getState().setTemplateName(null); - requestRepaint(); } @Override diff --git a/server/src/com/vaadin/ui/Form.java b/server/src/com/vaadin/ui/Form.java index 689a088c41..8f63ad511a 100644 --- a/server/src/com/vaadin/ui/Form.java +++ b/server/src/com/vaadin/ui/Form.java @@ -820,10 +820,6 @@ public class Form extends AbstractField implements Item.Editor, // Replace the previous layout layout.setParent(this); getState().setLayout(layout); - - // Hierarchy has changed so we need to repaint (this could be a - // hierarchy repaint only) - requestRepaint(); } /** @@ -1239,11 +1235,6 @@ public class Form extends AbstractField implements Item.Editor, getState().setFooter(footer); footer.setParent(this); - - // Hierarchy has changed so we need to repaint (this could be a - // hierarchy repaint only) - requestRepaint(); - } @Override diff --git a/server/src/com/vaadin/ui/GridLayout.java b/server/src/com/vaadin/ui/GridLayout.java index 5abfb1a22e..5de6cc79c7 100644 --- a/server/src/com/vaadin/ui/GridLayout.java +++ b/server/src/com/vaadin/ui/GridLayout.java @@ -962,8 +962,6 @@ public class GridLayout extends AbstractLayout implements } getState().setColumns(columns); - - requestRepaint(); } /** @@ -1006,8 +1004,6 @@ public class GridLayout extends AbstractLayout implements } getState().setRows(rows); - - requestRepaint(); } /** @@ -1132,7 +1128,6 @@ public class GridLayout extends AbstractLayout implements @Override public void setSpacing(boolean spacing) { getState().setSpacing(spacing); - requestRepaint(); } /* @@ -1391,7 +1386,6 @@ public class GridLayout extends AbstractLayout implements @Override public void setMargin(MarginInfo marginInfo) { getState().setMarginsBitmask(marginInfo.getBitMask()); - requestRepaint(); } /* diff --git a/server/src/com/vaadin/ui/JavaScript.java b/server/src/com/vaadin/ui/JavaScript.java index 5984c63e7a..e34ccae82a 100644 --- a/server/src/com/vaadin/ui/JavaScript.java +++ b/server/src/com/vaadin/ui/JavaScript.java @@ -93,9 +93,7 @@ public class JavaScript extends AbstractExtension { */ public void addFunction(String name, JavaScriptFunction function) { functions.put(name, function); - if (getState().getNames().add(name)) { - requestRepaint(); - } + getState().getNames().add(name); } /** @@ -111,9 +109,7 @@ public class JavaScript extends AbstractExtension { */ public void removeFunction(String name) { functions.remove(name); - if (getState().getNames().remove(name)) { - requestRepaint(); - } + getState().getNames().remove(name); } /** diff --git a/server/src/com/vaadin/ui/Label.java b/server/src/com/vaadin/ui/Label.java index d0a6059865..5055c7e573 100644 --- a/server/src/com/vaadin/ui/Label.java +++ b/server/src/com/vaadin/ui/Label.java @@ -190,7 +190,6 @@ public class Label extends AbstractComponent implements Property, } if (getPropertyDataSource() == null) { getState().text = (String) newStringValue; - requestRepaint(); } else { throw new IllegalStateException( "Label is only a Property.Viewer and cannot update its data source"); @@ -294,7 +293,6 @@ public class Label extends AbstractComponent implements Property, } getState().contentMode = contentMode; - requestRepaint(); } /* Value change events */ @@ -385,7 +383,6 @@ public class Label extends AbstractComponent implements Property, public void valueChange(Property.ValueChangeEvent event) { // Update the internal value from the data source getState().text = getValue(); - requestRepaint(); fireValueChange(); } diff --git a/server/src/com/vaadin/ui/Panel.java b/server/src/com/vaadin/ui/Panel.java index 985eed8a28..1f3b8580f8 100644 --- a/server/src/com/vaadin/ui/Panel.java +++ b/server/src/com/vaadin/ui/Panel.java @@ -318,7 +318,6 @@ public class Panel extends AbstractComponentContainer implements Scrollable, "Scroll offset must be at least 0"); } getState().setScrollLeft(scrollLeft); - requestRepaint(); } /* @@ -333,7 +332,6 @@ public class Panel extends AbstractComponentContainer implements Scrollable, "Scroll offset must be at least 0"); } getState().setScrollTop(scrollTop); - requestRepaint(); } /* Documented in superclass */ @@ -465,7 +463,6 @@ public class Panel extends AbstractComponentContainer implements Scrollable, @Override public void setTabIndex(int tabIndex) { getState().setTabIndex(tabIndex); - requestRepaint(); } /** diff --git a/server/src/com/vaadin/ui/Root.java b/server/src/com/vaadin/ui/Root.java index 4b90d613bb..f96fa1dc5a 100644 --- a/server/src/com/vaadin/ui/Root.java +++ b/server/src/com/vaadin/ui/Root.java @@ -860,8 +860,6 @@ public abstract class Root extends AbstractComponentContainer implements if (content != null) { super.addComponent(content); } - - requestRepaint(); } /** diff --git a/server/src/com/vaadin/ui/TextArea.java b/server/src/com/vaadin/ui/TextArea.java index f885781d46..0dc9722eb3 100644 --- a/server/src/com/vaadin/ui/TextArea.java +++ b/server/src/com/vaadin/ui/TextArea.java @@ -96,7 +96,6 @@ public class TextArea extends AbstractTextField { rows = 0; } getState().setRows(rows); - requestRepaint(); } /** @@ -117,7 +116,6 @@ public class TextArea extends AbstractTextField { */ public void setWordwrap(boolean wordwrap) { getState().setWordwrap(wordwrap); - requestRepaint(); } /** diff --git a/server/src/com/vaadin/ui/Video.java b/server/src/com/vaadin/ui/Video.java index 04ecc9af06..b54d404da6 100644 --- a/server/src/com/vaadin/ui/Video.java +++ b/server/src/com/vaadin/ui/Video.java @@ -80,7 +80,6 @@ public class Video extends AbstractMedia { */ public void setPoster(Resource poster) { getState().setPoster(ResourceReference.create(poster)); - requestRepaint(); } /** diff --git a/server/src/com/vaadin/ui/Window.java b/server/src/com/vaadin/ui/Window.java index 705e093bce..902d33bc64 100644 --- a/server/src/com/vaadin/ui/Window.java +++ b/server/src/com/vaadin/ui/Window.java @@ -174,14 +174,14 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, final int x = positionx.intValue(); // This is information from the client so it is already using the // position. No need to repaint. - setPositionX(x < 0 ? -1 : x, false); + setPositionX(x < 0 ? -1 : x); } final Integer positiony = (Integer) variables.get("positiony"); if (positiony != null) { final int y = positiony.intValue(); // This is information from the client so it is already using the // position. No need to repaint. - setPositionY(y < 0 ? -1 : y, false); + setPositionY(y < 0 ? -1 : y); } if (isClosable()) { @@ -255,26 +255,8 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, * @since 4.0.0 */ public void setPositionX(int positionX) { - setPositionX(positionX, true); - } - - /** - * Sets the distance of Window left border in pixels from left border of the - * containing (main window). - * - * @param positionX - * the Distance of Window left border in pixels from left border - * of the containing (main window). or -1 if unspecified. - * @param repaintRequired - * true if the window needs to be repainted, false otherwise - * @since 6.3.4 - */ - private void setPositionX(int positionX, boolean repaintRequired) { getState().setPositionX(positionX); getState().setCentered(false); - if (repaintRequired) { - requestRepaint(); - } } /** @@ -301,27 +283,8 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, * @since 4.0.0 */ public void setPositionY(int positionY) { - setPositionY(positionY, true); - } - - /** - * Sets the distance of Window top border in pixels from top border of the - * containing (main window). - * - * @param positionY - * the Distance of Window top border in pixels from top border of - * the containing (main window). or -1 if unspecified - * @param repaintRequired - * true if the window needs to be repainted, false otherwise - * - * @since 6.3.4 - */ - private void setPositionY(int positionY, boolean repaintRequired) { getState().setPositionY(positionY); getState().setCentered(false); - if (repaintRequired) { - requestRepaint(); - } } private static final Method WINDOW_CLOSE_METHOD; @@ -543,7 +506,6 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, public void setModal(boolean modal) { getState().setModal(modal); center(); - requestRepaint(); } /** @@ -561,7 +523,6 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, */ public void setResizable(boolean resizable) { getState().setResizable(resizable); - requestRepaint(); } /** @@ -595,7 +556,6 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, */ public void setResizeLazy(boolean resizeLazy) { getState().setResizeLazy(resizeLazy); - requestRepaint(); } /** @@ -609,7 +569,6 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, */ public void center() { getState().setCentered(true); - requestRepaint(); } /** @@ -674,7 +633,6 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, */ public void setDraggable(boolean draggable) { getState().setDraggable(draggable); - requestRepaint(); } /* -- cgit v1.2.3 From bc6786f0dc865b88dd2eeb0614534bfce80dee35 Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Thu, 23 Aug 2012 12:09:48 +0300 Subject: Rename requestRepaint to markAsDirty (#9378) Also remove some requestRepaint calls that are no longer needed (#9325) --- server/src/com/vaadin/event/ActionManager.java | 2 +- .../vaadin/terminal/AbstractClientConnector.java | 23 ++++++-- server/src/com/vaadin/terminal/Page.java | 10 ++-- .../src/com/vaadin/terminal/Vaadin6Component.java | 11 ++++ .../terminal/gwt/server/ClientConnector.java | 28 ++++++++- .../terminal/gwt/server/DragAndDropService.java | 12 ++++ server/src/com/vaadin/ui/AbsoluteLayout.java | 34 +++++------ server/src/com/vaadin/ui/AbstractComponent.java | 12 ++-- .../com/vaadin/ui/AbstractComponentContainer.java | 9 +-- server/src/com/vaadin/ui/AbstractField.java | 26 ++++----- .../src/com/vaadin/ui/AbstractOrderedLayout.java | 2 +- server/src/com/vaadin/ui/AbstractSelect.java | 36 ++++++------ server/src/com/vaadin/ui/AbstractSplitPanel.java | 12 +--- server/src/com/vaadin/ui/AbstractTextField.java | 14 ++--- server/src/com/vaadin/ui/ComboBox.java | 4 +- server/src/com/vaadin/ui/CssLayout.java | 10 ++-- server/src/com/vaadin/ui/CustomComponent.java | 2 +- server/src/com/vaadin/ui/CustomField.java | 4 +- server/src/com/vaadin/ui/DateField.java | 18 +++--- server/src/com/vaadin/ui/DragAndDropWrapper.java | 8 +-- server/src/com/vaadin/ui/Embedded.java | 22 ++++---- server/src/com/vaadin/ui/Form.java | 16 +++--- server/src/com/vaadin/ui/GridLayout.java | 16 +++--- server/src/com/vaadin/ui/Label.java | 4 +- server/src/com/vaadin/ui/Link.java | 10 ++-- server/src/com/vaadin/ui/ListSelect.java | 4 +- server/src/com/vaadin/ui/MenuBar.java | 40 ++++++------- server/src/com/vaadin/ui/NativeSelect.java | 2 +- server/src/com/vaadin/ui/OptionGroup.java | 10 ++-- server/src/com/vaadin/ui/Panel.java | 2 +- server/src/com/vaadin/ui/PopupDateField.java | 2 +- server/src/com/vaadin/ui/PopupView.java | 4 +- server/src/com/vaadin/ui/ProgressIndicator.java | 4 +- server/src/com/vaadin/ui/RichTextArea.java | 4 +- server/src/com/vaadin/ui/Root.java | 10 ++-- server/src/com/vaadin/ui/Select.java | 10 +++- server/src/com/vaadin/ui/Slider.java | 8 +-- server/src/com/vaadin/ui/TabSheet.java | 34 +++++------ server/src/com/vaadin/ui/Table.java | 66 ++++++++++++++-------- server/src/com/vaadin/ui/Tree.java | 38 ++++++------- server/src/com/vaadin/ui/TreeTable.java | 6 +- server/src/com/vaadin/ui/TwinColSelect.java | 8 +-- server/src/com/vaadin/ui/Upload.java | 14 ++--- server/src/com/vaadin/ui/Window.java | 2 +- .../textfield/TextFieldWithPropertyFormatter.java | 4 +- .../PerformanceTestLabelsAndOrderedLayouts.java | 2 +- .../com/vaadin/tests/TestSizeableIncomponents.java | 4 +- ...eComponentsFromAbsoluteLayoutToInnerLayout.java | 2 +- .../datefield/DateFieldRangeValidation.java | 2 +- .../datefield/DisabledDateFieldWidth.java | 2 +- .../components/embedded/EmbeddedImageRefresh.java | 4 +- .../MoveComponentsFromGridLayoutToInnerLayout.java | 2 +- .../splitpanel/SplitPanelExtraScrollbars.java | 4 +- .../tests/components/table/EditableTableLeak.java | 2 +- .../table/TableClickValueChangeInteraction.java | 2 +- .../table/TableColumnResizeContentsWidth.java | 4 +- .../tests/components/tree/TreeFiltering.java | 2 +- .../components/treetable/KeepAllItemsVisible.java | 2 +- .../vaadin/tests/dd/NotPaintedAcceptSource.java | 2 +- .../tests/extensions/HelloWorldExtension.java | 1 - .../extensions/SimpleJavaScriptExtensionTest.java | 1 - .../vaadin/tests/layouts/CssLayoutCustomCss.java | 2 +- .../v7a2/ComponentInStateComponent.java | 1 - .../tests/minitutorials/v7a2/MyComponent.java | 1 - .../tests/minitutorials/v7a2/WidgetContainer.java | 6 +- .../com/vaadin/tests/minitutorials/v7a3/Flot.java | 2 - .../tests/tickets/Ticket1834PanelScrolling.java | 2 +- .../com/vaadin/tests/tickets/Ticket1983.java | 2 +- .../com/vaadin/tests/tickets/Ticket2060.java | 6 +- 69 files changed, 371 insertions(+), 306 deletions(-) diff --git a/server/src/com/vaadin/event/ActionManager.java b/server/src/com/vaadin/event/ActionManager.java index 50ddef6265..296d12ba92 100644 --- a/server/src/com/vaadin/event/ActionManager.java +++ b/server/src/com/vaadin/event/ActionManager.java @@ -67,7 +67,7 @@ public class ActionManager implements Action.Container, Action.Handler, private void requestRepaint() { if (viewer != null) { - viewer.requestRepaint(); + viewer.markAsDirty(); } } diff --git a/server/src/com/vaadin/terminal/AbstractClientConnector.java b/server/src/com/vaadin/terminal/AbstractClientConnector.java index 2b96c5fb35..d2490225fb 100644 --- a/server/src/com/vaadin/terminal/AbstractClientConnector.java +++ b/server/src/com/vaadin/terminal/AbstractClientConnector.java @@ -85,8 +85,15 @@ public abstract class AbstractClientConnector implements ClientConnector { private ClientConnector parent; /* Documentation copied from interface */ + @Deprecated @Override public void requestRepaint() { + markAsDirty(); + } + + /* Documentation copied from interface */ + @Override + public void markAsDirty() { Root root = getRoot(); if (root != null) { root.getConnectorTracker().markDirty(this); @@ -389,11 +396,17 @@ public abstract class AbstractClientConnector implements ClientConnector { } @Override + @Deprecated public void requestRepaintAll() { - requestRepaint(); + markAsDirtyRecursive(); + } + + @Override + public void markAsDirtyRecursive() { + markAsDirty(); for (ClientConnector connector : getAllChildrenIterable(this)) { - connector.requestRepaintAll(); + connector.markAsDirtyRecursive(); } } @@ -469,14 +482,14 @@ public abstract class AbstractClientConnector implements ClientConnector { extensions.add(extension); extension.setParent(this); - requestRepaint(); + markAsDirty(); } @Override public void removeExtension(Extension extension) { extension.setParent(null); extensions.remove(extension); - requestRepaint(); + markAsDirty(); } @Override @@ -513,7 +526,7 @@ public abstract class AbstractClientConnector implements ClientConnector { @Override public void attach() { - requestRepaint(); + markAsDirty(); getRoot().getConnectorTracker().registerConnector(this); diff --git a/server/src/com/vaadin/terminal/Page.java b/server/src/com/vaadin/terminal/Page.java index 8eb77b7d0d..d41d500bb0 100644 --- a/server/src/com/vaadin/terminal/Page.java +++ b/server/src/com/vaadin/terminal/Page.java @@ -332,7 +332,7 @@ public class Page implements Serializable { if (fireEvents) { fireEvent(new FragmentChangedEvent(this, newFragment)); } - root.requestRepaint(); + root.markAsDirty(); } } @@ -523,7 +523,7 @@ public class Page implements Serializable { */ public void open(Resource resource) { openList.add(new OpenResource(resource, null, -1, -1, BORDER_DEFAULT)); - root.requestRepaint(); + root.markAsDirty(); } /** @@ -566,7 +566,7 @@ public class Page implements Serializable { public void open(Resource resource, String windowName) { openList.add(new OpenResource(resource, windowName, -1, -1, BORDER_DEFAULT)); - root.requestRepaint(); + root.markAsDirty(); } /** @@ -589,7 +589,7 @@ public class Page implements Serializable { int height, BorderStyle border) { openList.add(new OpenResource(resource, windowName, width, height, border)); - root.requestRepaint(); + root.markAsDirty(); } /** @@ -603,7 +603,7 @@ public class Page implements Serializable { notifications = new LinkedList(); } notifications.add(notification); - root.requestRepaint(); + root.markAsDirty(); } /** diff --git a/server/src/com/vaadin/terminal/Vaadin6Component.java b/server/src/com/vaadin/terminal/Vaadin6Component.java index 048000e31d..eb169c90f9 100644 --- a/server/src/com/vaadin/terminal/Vaadin6Component.java +++ b/server/src/com/vaadin/terminal/Vaadin6Component.java @@ -52,4 +52,15 @@ public interface Vaadin6Component extends VariableOwner, Component, */ public void paintContent(PaintTarget target) throws PaintException; + /** + * (non-Javadoc) {@inheritDoc} + *

      + * For a Vaadin6Component, markAsDirty will also cause + * {@link #paintContent(PaintTarget)} to be called before sending changes to + * the client. + * + * @see com.vaadin.terminal.gwt.server.ClientConnector#markAsDirty() + */ + @Override + public void markAsDirty(); } diff --git a/server/src/com/vaadin/terminal/gwt/server/ClientConnector.java b/server/src/com/vaadin/terminal/gwt/server/ClientConnector.java index 87524fe28f..24675c9e45 100644 --- a/server/src/com/vaadin/terminal/gwt/server/ClientConnector.java +++ b/server/src/com/vaadin/terminal/gwt/server/ClientConnector.java @@ -65,17 +65,39 @@ public interface ClientConnector extends Connector, RpcTarget { public ClientConnector getParent(); /** - * Requests that the connector should be repainted as soon as possible. + * @deprecated As of 7.0.0, use {@link #markAsDirty()} instead */ + @Deprecated public void requestRepaint(); /** - * Causes a repaint of this connector, and all connectors below it. + * Marks that this connector's state might have changed. When the framework + * is about to send new data to the client-side, it will run + * {@link #beforeClientResponse(boolean)} followed by {@link #encodeState()} + * for all connectors that are marked as dirty and send any updated state + * info to the client. * + * @since 7.0.0 + */ + public void markAsDirty(); + + /** + * @deprecated As of 7.0.0, use {@link #markAsDirtyRecursive()} instead + */ + @Deprecated + public void requestRepaintAll(); + + /** + * Causes this connector and all connectors below it to be marked as dirty. + *

      * This should only be used in special cases, e.g when the state of a * descendant depends on the state of an ancestor. + * + * @see #markAsDirty() + * + * @since 7.0.0 */ - public void requestRepaintAll(); + public void markAsDirtyRecursive(); /** * Sets the parent connector of the connector. diff --git a/server/src/com/vaadin/terminal/gwt/server/DragAndDropService.java b/server/src/com/vaadin/terminal/gwt/server/DragAndDropService.java index 981d2569d1..221598171c 100644 --- a/server/src/com/vaadin/terminal/gwt/server/DragAndDropService.java +++ b/server/src/com/vaadin/terminal/gwt/server/DragAndDropService.java @@ -264,7 +264,13 @@ public class DragAndDropService implements VariableOwner, ClientConnector { } @Override + @Deprecated public void requestRepaint() { + markAsDirty(); + } + + @Override + public void markAsDirty() { // TODO Auto-generated method stub } @@ -276,7 +282,13 @@ public class DragAndDropService implements VariableOwner, ClientConnector { } @Override + @Deprecated public void requestRepaintAll() { + markAsDirtyRecursive(); + } + + @Override + public void markAsDirtyRecursive() { // TODO Auto-generated method stub } diff --git a/server/src/com/vaadin/ui/AbsoluteLayout.java b/server/src/com/vaadin/ui/AbsoluteLayout.java index 8981895717..56bbd19852 100644 --- a/server/src/com/vaadin/ui/AbsoluteLayout.java +++ b/server/src/com/vaadin/ui/AbsoluteLayout.java @@ -153,7 +153,7 @@ public class AbsoluteLayout extends AbstractLayout implements internalRemoveComponent(c); throw e; } - requestRepaint(); + markAsDirty(); } /** @@ -197,7 +197,7 @@ public class AbsoluteLayout extends AbstractLayout implements public void removeComponent(Component c) { internalRemoveComponent(c); super.removeComponent(c); - requestRepaint(); + markAsDirty(); } /** @@ -245,7 +245,7 @@ public class AbsoluteLayout extends AbstractLayout implements private void internalSetPosition(Component component, ComponentPosition position) { componentToCoordinates.put(component, position); - requestRepaint(); + markAsDirty(); } /** @@ -322,7 +322,7 @@ public class AbsoluteLayout extends AbstractLayout implements } } } - requestRepaint(); + markAsDirty(); } /** @@ -363,7 +363,7 @@ public class AbsoluteLayout extends AbstractLayout implements public void setTop(Float topValue, Unit topUnits) { this.topValue = topValue; this.topUnits = topUnits; - requestRepaint(); + markAsDirty(); } /** @@ -379,7 +379,7 @@ public class AbsoluteLayout extends AbstractLayout implements public void setRight(Float rightValue, Unit rightUnits) { this.rightValue = rightValue; this.rightUnits = rightUnits; - requestRepaint(); + markAsDirty(); } /** @@ -395,7 +395,7 @@ public class AbsoluteLayout extends AbstractLayout implements public void setBottom(Float bottomValue, Unit bottomUnits) { this.bottomValue = bottomValue; this.bottomUnits = bottomUnits; - requestRepaint(); + markAsDirty(); } /** @@ -411,7 +411,7 @@ public class AbsoluteLayout extends AbstractLayout implements public void setLeft(Float leftValue, Unit leftUnits) { this.leftValue = leftValue; this.leftUnits = leftUnits; - requestRepaint(); + markAsDirty(); } /** @@ -422,7 +422,7 @@ public class AbsoluteLayout extends AbstractLayout implements */ public void setZIndex(int zIndex) { this.zIndex = zIndex; - requestRepaint(); + markAsDirty(); } /** @@ -434,7 +434,7 @@ public class AbsoluteLayout extends AbstractLayout implements */ public void setTopValue(Float topValue) { this.topValue = topValue; - requestRepaint(); + markAsDirty(); } /** @@ -468,7 +468,7 @@ public class AbsoluteLayout extends AbstractLayout implements */ public void setRightValue(Float rightValue) { this.rightValue = rightValue; - requestRepaint(); + markAsDirty(); } /** @@ -492,7 +492,7 @@ public class AbsoluteLayout extends AbstractLayout implements */ public void setBottomValue(Float bottomValue) { this.bottomValue = bottomValue; - requestRepaint(); + markAsDirty(); } /** @@ -516,7 +516,7 @@ public class AbsoluteLayout extends AbstractLayout implements */ public void setLeftValue(Float leftValue) { this.leftValue = leftValue; - requestRepaint(); + markAsDirty(); } /** @@ -538,7 +538,7 @@ public class AbsoluteLayout extends AbstractLayout implements */ public void setTopUnits(Unit topUnits) { this.topUnits = topUnits; - requestRepaint(); + markAsDirty(); } /** @@ -560,7 +560,7 @@ public class AbsoluteLayout extends AbstractLayout implements */ public void setRightUnits(Unit rightUnits) { this.rightUnits = rightUnits; - requestRepaint(); + markAsDirty(); } /** @@ -582,7 +582,7 @@ public class AbsoluteLayout extends AbstractLayout implements */ public void setBottomUnits(Unit bottomUnits) { this.bottomUnits = bottomUnits; - requestRepaint(); + markAsDirty(); } /** @@ -604,7 +604,7 @@ public class AbsoluteLayout extends AbstractLayout implements */ public void setLeftUnits(Unit leftUnits) { this.leftUnits = leftUnits; - requestRepaint(); + markAsDirty(); } /** diff --git a/server/src/com/vaadin/ui/AbstractComponent.java b/server/src/com/vaadin/ui/AbstractComponent.java index a799c5d679..b1393488f7 100644 --- a/server/src/com/vaadin/ui/AbstractComponent.java +++ b/server/src/com/vaadin/ui/AbstractComponent.java @@ -262,7 +262,7 @@ public abstract class AbstractComponent extends AbstractClientConnector this.locale = locale; // FIXME: Reload value if there is a converter - requestRepaint(); + markAsDirty(); } /* @@ -373,7 +373,7 @@ public abstract class AbstractComponent extends AbstractClientConnector if (getParent() != null) { // Must always repaint the parent (at least the hierarchy) when // visibility of a child component changes. - getParent().requestRepaint(); + getParent().markAsDirty(); } } @@ -535,7 +535,7 @@ public abstract class AbstractComponent extends AbstractClientConnector public void setComponentError(ErrorMessage componentError) { this.componentError = componentError; fireComponentErrorEvent(); - requestRepaint(); + markAsDirty(); } /* @@ -751,7 +751,6 @@ public abstract class AbstractComponent extends AbstractClientConnector if (needRepaint) { getState().addRegisteredEventListener(eventIdentifier); - requestRepaint(); } } @@ -800,7 +799,6 @@ public abstract class AbstractComponent extends AbstractClientConnector eventRouter.removeListener(eventType, target); if (!eventRouter.hasListeners(eventType)) { getState().removeRegisteredEventListener(eventIdentifier); - requestRepaint(); } } } @@ -1107,7 +1105,7 @@ public abstract class AbstractComponent extends AbstractClientConnector } this.height = height; heightUnit = unit; - requestRepaint(); + markAsDirty(); // ComponentSizeValidator.setHeightLocation(this); } @@ -1145,7 +1143,7 @@ public abstract class AbstractComponent extends AbstractClientConnector } this.width = width; widthUnit = unit; - requestRepaint(); + markAsDirty(); // ComponentSizeValidator.setWidthLocation(this); } diff --git a/server/src/com/vaadin/ui/AbstractComponentContainer.java b/server/src/com/vaadin/ui/AbstractComponentContainer.java index 7450c76fda..4939eb1265 100644 --- a/server/src/com/vaadin/ui/AbstractComponentContainer.java +++ b/server/src/com/vaadin/ui/AbstractComponentContainer.java @@ -212,7 +212,7 @@ public abstract class AbstractComponentContainer extends AbstractComponent // If the visibility state is toggled it might affect all children // aswell, e.g. make container visible should make children visible if // they were only hidden because the container was hidden. - requestRepaintAll(); + markAsDirtyRecursive(); } @Override @@ -306,12 +306,7 @@ public abstract class AbstractComponentContainer extends AbstractComponent private void repaintChildTrees(Collection dirtyChildren) { for (Component c : dirtyChildren) { - if (c instanceof ComponentContainer) { - ComponentContainer cc = (ComponentContainer) c; - cc.requestRepaintAll(); - } else { - c.requestRepaint(); - } + c.markAsDirtyRecursive(); } } diff --git a/server/src/com/vaadin/ui/AbstractField.java b/server/src/com/vaadin/ui/AbstractField.java index 23481eca9e..5123d08da9 100644 --- a/server/src/com/vaadin/ui/AbstractField.java +++ b/server/src/com/vaadin/ui/AbstractField.java @@ -301,7 +301,7 @@ public abstract class AbstractField extends AbstractComponent implements // Sets the buffering state currentBufferedSourceException = new Buffered.SourceException( this, e); - requestRepaint(); + markAsDirty(); // Throws the source exception throw currentBufferedSourceException; @@ -316,7 +316,7 @@ public abstract class AbstractField extends AbstractComponent implements fireValueChange(false); } else if (wasModified) { // If the value did not change, but the modification status did - requestRepaint(); + markAsDirty(); } } } @@ -535,7 +535,7 @@ public abstract class AbstractField extends AbstractComponent implements // Sets the buffering state currentBufferedSourceException = new Buffered.SourceException( this, e); - requestRepaint(); + markAsDirty(); // Throws the source exception throw currentBufferedSourceException; @@ -805,7 +805,7 @@ public abstract class AbstractField extends AbstractComponent implements validators = new LinkedList(); } validators.add(validator); - requestRepaint(); + markAsDirty(); } /** @@ -833,7 +833,7 @@ public abstract class AbstractField extends AbstractComponent implements if (validators != null) { validators.remove(validator); } - requestRepaint(); + markAsDirty(); } /** @@ -843,7 +843,7 @@ public abstract class AbstractField extends AbstractComponent implements if (validators != null) { validators.clear(); } - requestRepaint(); + markAsDirty(); } /** @@ -1070,7 +1070,7 @@ public abstract class AbstractField extends AbstractComponent implements protected void fireValueChange(boolean repaintIsNotNeeded) { fireEvent(new AbstractField.ValueChangeEvent(this)); if (!repaintIsNotNeeded) { - requestRepaint(); + markAsDirty(); } } @@ -1264,7 +1264,7 @@ public abstract class AbstractField extends AbstractComponent implements protected void setInternalValue(T newValue) { value = newValue; if (validators != null && !validators.isEmpty()) { - requestRepaint(); + markAsDirty(); } } @@ -1347,7 +1347,7 @@ public abstract class AbstractField extends AbstractComponent implements @Override public void setRequiredError(String requiredMessage) { requiredError = requiredMessage; - requestRepaint(); + markAsDirty(); } @Override @@ -1375,7 +1375,7 @@ public abstract class AbstractField extends AbstractComponent implements */ public void setConversionError(String valueConversionError) { this.conversionError = valueConversionError; - requestRepaint(); + markAsDirty(); } /** @@ -1417,7 +1417,7 @@ public abstract class AbstractField extends AbstractComponent implements */ public void setValidationVisible(boolean validateAutomatically) { if (validationVisible != validateAutomatically) { - requestRepaint(); + markAsDirty(); validationVisible = validateAutomatically; } } @@ -1430,7 +1430,7 @@ public abstract class AbstractField extends AbstractComponent implements public void setCurrentBufferedSourceException( Buffered.SourceException currentBufferedSourceException) { this.currentBufferedSourceException = currentBufferedSourceException; - requestRepaint(); + markAsDirty(); } /** @@ -1518,7 +1518,7 @@ public abstract class AbstractField extends AbstractComponent implements */ public void setConverter(Converter converter) { this.converter = (Converter) converter; - requestRepaint(); + markAsDirty(); } @Override diff --git a/server/src/com/vaadin/ui/AbstractOrderedLayout.java b/server/src/com/vaadin/ui/AbstractOrderedLayout.java index 0a57cb98c4..596bbb7ee2 100644 --- a/server/src/com/vaadin/ui/AbstractOrderedLayout.java +++ b/server/src/com/vaadin/ui/AbstractOrderedLayout.java @@ -225,7 +225,7 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements components.add(newLocation, oldComponent); } - requestRepaint(); + markAsDirty(); } } diff --git a/server/src/com/vaadin/ui/AbstractSelect.java b/server/src/com/vaadin/ui/AbstractSelect.java index 19a74782c4..21ff7ba948 100644 --- a/server/src/com/vaadin/ui/AbstractSelect.java +++ b/server/src/com/vaadin/ui/AbstractSelect.java @@ -462,7 +462,7 @@ public abstract class AbstractSelect extends AbstractField implements if (!isNullSelectionAllowed() && (id == null || id == getNullSelectionItemId())) { // skip empty selection if nullselection is not allowed - requestRepaint(); + markAsDirty(); } else if (id != null && containsId(id)) { acceptedSelections.add(id); } @@ -470,7 +470,7 @@ public abstract class AbstractSelect extends AbstractField implements if (!isNullSelectionAllowed() && acceptedSelections.size() < 1) { // empty selection not allowed, keep old value - requestRepaint(); + markAsDirty(); return; } @@ -498,7 +498,7 @@ public abstract class AbstractSelect extends AbstractField implements if (!isNullSelectionAllowed() && (clientSideSelectedKeys.length == 0 || clientSideSelectedKeys[0] == null || clientSideSelectedKeys[0] == getNullSelectionItemId())) { - requestRepaint(); + markAsDirty(); return; } if (clientSideSelectedKeys.length == 0) { @@ -513,7 +513,7 @@ public abstract class AbstractSelect extends AbstractField implements final Object id = itemIdMapper .get(clientSideSelectedKeys[0]); if (!isNullSelectionAllowed() && id == null) { - requestRepaint(); + markAsDirty(); } else if (id != null && id.equals(getNullSelectionItemId())) { setValue(null, true); @@ -975,7 +975,7 @@ public abstract class AbstractSelect extends AbstractField implements */ setValue(null); - requestRepaint(); + markAsDirty(); } } @@ -1042,7 +1042,7 @@ public abstract class AbstractSelect extends AbstractField implements } } - requestRepaint(); + markAsDirty(); } } @@ -1071,7 +1071,7 @@ public abstract class AbstractSelect extends AbstractField implements this.allowNewOptions = allowNewOptions; - requestRepaint(); + markAsDirty(); } } @@ -1087,7 +1087,7 @@ public abstract class AbstractSelect extends AbstractField implements public void setItemCaption(Object itemId, String caption) { if (itemId != null) { itemCaptions.put(itemId, caption); - requestRepaint(); + markAsDirty(); } } @@ -1173,7 +1173,7 @@ public abstract class AbstractSelect extends AbstractField implements } else { itemIcons.put(itemId, icon); } - requestRepaint(); + markAsDirty(); } } @@ -1239,7 +1239,7 @@ public abstract class AbstractSelect extends AbstractField implements public void setItemCaptionMode(ItemCaptionMode mode) { if (mode != null) { itemCaptionMode = mode; - requestRepaint(); + markAsDirty(); } } @@ -1302,13 +1302,13 @@ public abstract class AbstractSelect extends AbstractField implements if (propertyId != null) { itemCaptionPropertyId = propertyId; setItemCaptionMode(ITEM_CAPTION_MODE_PROPERTY); - requestRepaint(); + markAsDirty(); } else { itemCaptionPropertyId = null; if (getItemCaptionMode() == ITEM_CAPTION_MODE_PROPERTY) { setItemCaptionMode(ITEM_CAPTION_MODE_EXPLICIT_DEFAULTS_ID); } - requestRepaint(); + markAsDirty(); } } @@ -1360,7 +1360,7 @@ public abstract class AbstractSelect extends AbstractField implements throw new IllegalArgumentException( "Property type must be assignable to Resource"); } - requestRepaint(); + markAsDirty(); } /** @@ -1579,7 +1579,7 @@ public abstract class AbstractSelect extends AbstractField implements .containerPropertySetChange(event); } } - requestRepaint(); + markAsDirty(); } /** @@ -1594,7 +1594,7 @@ public abstract class AbstractSelect extends AbstractField implements .containerItemSetChange(event); } } - requestRepaint(); + markAsDirty(); } /** @@ -1665,7 +1665,7 @@ public abstract class AbstractSelect extends AbstractField implements public void setNullSelectionAllowed(boolean nullSelectionAllowed) { if (nullSelectionAllowed != this.nullSelectionAllowed) { this.nullSelectionAllowed = nullSelectionAllowed; - requestRepaint(); + markAsDirty(); } } @@ -1824,13 +1824,13 @@ public abstract class AbstractSelect extends AbstractField implements @Override public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) { - requestRepaint(); + markAsDirty(); } @Override public void itemPropertySetChange( com.vaadin.data.Item.PropertySetChangeEvent event) { - requestRepaint(); + markAsDirty(); } } diff --git a/server/src/com/vaadin/ui/AbstractSplitPanel.java b/server/src/com/vaadin/ui/AbstractSplitPanel.java index 68964e2c35..8b7499115c 100644 --- a/server/src/com/vaadin/ui/AbstractSplitPanel.java +++ b/server/src/com/vaadin/ui/AbstractSplitPanel.java @@ -154,8 +154,6 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer { if (c != null) { super.addComponent(c); } - - requestRepaint(); } /** @@ -179,7 +177,6 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer { if (c != null) { super.addComponent(c); } - requestRepaint(); } /** @@ -217,7 +214,7 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer { } else if (c == getSecondComponent()) { getState().setSecondChild(null); } - requestRepaint(); + markAsDirty(); } /* @@ -259,7 +256,7 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer { } else if (oldComponent == getSecondComponent()) { setSecondComponent(newComponent); } - requestRepaint(); + markAsDirty(); } /** @@ -329,8 +326,6 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer { splitterState.setPositionUnit(unit.getSymbol()); splitterState.setPositionReversed(reverse); posUnit = unit; - - requestRepaint(); } /** @@ -452,8 +447,6 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer { state.setMaxPosition(maxPos); state.setMaxPositionUnit(maxPosUnit.getSymbol()); posMaxUnit = maxPosUnit; - - requestRepaint(); } /** @@ -465,7 +458,6 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer { */ public void setLocked(boolean locked) { getSplitterState().setLocked(locked); - requestRepaint(); } /** diff --git a/server/src/com/vaadin/ui/AbstractTextField.java b/server/src/com/vaadin/ui/AbstractTextField.java index 51d5449fdd..1bd61023a4 100644 --- a/server/src/com/vaadin/ui/AbstractTextField.java +++ b/server/src/com/vaadin/ui/AbstractTextField.java @@ -184,7 +184,7 @@ public abstract class AbstractTextField extends AbstractField implements // If the modified status changes, or if we have a // formatter, repaint is needed after all. if (wasModified != isModified()) { - requestRepaint(); + markAsDirty(); } } } @@ -271,7 +271,7 @@ public abstract class AbstractTextField extends AbstractField implements */ public void setNullRepresentation(String nullRepresentation) { this.nullRepresentation = nullRepresentation; - requestRepaint(); + markAsDirty(); } /** @@ -297,7 +297,7 @@ public abstract class AbstractTextField extends AbstractField implements */ public void setNullSettingAllowed(boolean nullSettingAllowed) { this.nullSettingAllowed = nullSettingAllowed; - requestRepaint(); + markAsDirty(); } @Override @@ -440,7 +440,7 @@ public abstract class AbstractTextField extends AbstractField implements */ if (lastKnownTextContent != null) { lastKnownTextContent = null; - requestRepaint(); + markAsDirty(); } } @@ -465,7 +465,7 @@ public abstract class AbstractTextField extends AbstractField implements */ public void setTextChangeEventMode(TextChangeEventMode inputEventMode) { textChangeEventMode = inputEventMode; - requestRepaint(); + markAsDirty(); } /** @@ -536,7 +536,7 @@ public abstract class AbstractTextField extends AbstractField implements */ public void setTextChangeTimeout(int timeout) { textChangeEventTimeout = timeout; - requestRepaint(); + markAsDirty(); } /** @@ -627,7 +627,7 @@ public abstract class AbstractTextField extends AbstractField implements selectionPosition = pos; selectionLength = length; focus(); - requestRepaint(); + markAsDirty(); } /** diff --git a/server/src/com/vaadin/ui/ComboBox.java b/server/src/com/vaadin/ui/ComboBox.java index e2655be405..af19ca5b96 100644 --- a/server/src/com/vaadin/ui/ComboBox.java +++ b/server/src/com/vaadin/ui/ComboBox.java @@ -81,7 +81,7 @@ public class ComboBox extends Select { */ public void setInputPrompt(String inputPrompt) { this.inputPrompt = inputPrompt; - requestRepaint(); + markAsDirty(); } @Override @@ -110,7 +110,7 @@ public class ComboBox extends Select { */ public void setTextInputAllowed(boolean textInputAllowed) { this.textInputAllowed = textInputAllowed; - requestRepaint(); + markAsDirty(); } /** diff --git a/server/src/com/vaadin/ui/CssLayout.java b/server/src/com/vaadin/ui/CssLayout.java index c80986b768..b16bcf31df 100644 --- a/server/src/com/vaadin/ui/CssLayout.java +++ b/server/src/com/vaadin/ui/CssLayout.java @@ -102,7 +102,7 @@ public class CssLayout extends AbstractLayout implements LayoutClickNotifier { components.add(c); try { super.addComponent(c); - requestRepaint(); + markAsDirty(); } catch (IllegalArgumentException e) { components.remove(c); throw e; @@ -125,7 +125,7 @@ public class CssLayout extends AbstractLayout implements LayoutClickNotifier { components.addFirst(c); try { super.addComponent(c); - requestRepaint(); + markAsDirty(); } catch (IllegalArgumentException e) { components.remove(c); throw e; @@ -154,7 +154,7 @@ public class CssLayout extends AbstractLayout implements LayoutClickNotifier { components.add(index, c); try { super.addComponent(c); - requestRepaint(); + markAsDirty(); } catch (IllegalArgumentException e) { components.remove(c); throw e; @@ -171,7 +171,7 @@ public class CssLayout extends AbstractLayout implements LayoutClickNotifier { public void removeComponent(Component c) { components.remove(c); super.removeComponent(c); - requestRepaint(); + markAsDirty(); } /** @@ -276,7 +276,7 @@ public class CssLayout extends AbstractLayout implements LayoutClickNotifier { components.add(newLocation, oldComponent); } - requestRepaint(); + markAsDirty(); } } diff --git a/server/src/com/vaadin/ui/CustomComponent.java b/server/src/com/vaadin/ui/CustomComponent.java index 88f7b162c1..b67fa89ecb 100644 --- a/server/src/com/vaadin/ui/CustomComponent.java +++ b/server/src/com/vaadin/ui/CustomComponent.java @@ -100,7 +100,7 @@ public class CustomComponent extends AbstractComponentContainer { super.addComponent(compositionRoot); } root = compositionRoot; - requestRepaint(); + markAsDirty(); } } diff --git a/server/src/com/vaadin/ui/CustomField.java b/server/src/com/vaadin/ui/CustomField.java index 794e472dae..9ac5e2defb 100644 --- a/server/src/com/vaadin/ui/CustomField.java +++ b/server/src/com/vaadin/ui/CustomField.java @@ -120,13 +120,13 @@ public abstract class CustomField extends AbstractField implements @Override public void setHeight(float height, Unit unit) { super.setHeight(height, unit); - requestRepaintAll(); + markAsDirtyRecursive(); } @Override public void setWidth(float height, Unit unit) { super.setWidth(height, unit); - requestRepaintAll(); + markAsDirtyRecursive(); } // ComponentContainer methods diff --git a/server/src/com/vaadin/ui/DateField.java b/server/src/com/vaadin/ui/DateField.java index 790f3568d5..828fa3b21d 100644 --- a/server/src/com/vaadin/ui/DateField.java +++ b/server/src/com/vaadin/ui/DateField.java @@ -429,7 +429,7 @@ public class DateField extends AbstractField implements * if handleUnparsableDateString throws an exception. In * this case the invalid text remains in the DateField. */ - requestRepaint(); + markAsDirty(); } catch (Converter.ConversionException e) { /* @@ -471,7 +471,7 @@ public class DateField extends AbstractField implements * change and form depends on this implementation detail. */ notifyFormOfValidityChange(); - requestRepaint(); + markAsDirty(); } } else if (newDate != oldDate && (newDate == null || !newDate.equals(oldDate))) { @@ -562,7 +562,7 @@ public class DateField extends AbstractField implements * this. */ notifyFormOfValidityChange(); - requestRepaint(); + markAsDirty(); return; } @@ -588,7 +588,7 @@ public class DateField extends AbstractField implements * thing as form does in its value change listener that * it registers to all fields. */ - f.requestRepaint(); + f.markAsDirty(); formFound = true; break; } @@ -639,7 +639,7 @@ public class DateField extends AbstractField implements */ public void setResolution(Resolution resolution) { this.resolution = resolution; - requestRepaint(); + markAsDirty(); } /** @@ -699,7 +699,7 @@ public class DateField extends AbstractField implements */ public void setDateFormat(String dateFormat) { this.dateFormat = dateFormat; - requestRepaint(); + markAsDirty(); } /** @@ -725,7 +725,7 @@ public class DateField extends AbstractField implements */ public void setLenient(boolean lenient) { this.lenient = lenient; - requestRepaint(); + markAsDirty(); } /** @@ -781,7 +781,7 @@ public class DateField extends AbstractField implements */ public void setShowISOWeekNumbers(boolean showWeekNumbers) { showISOWeekNumbers = showWeekNumbers; - requestRepaint(); + markAsDirty(); } /** @@ -850,7 +850,7 @@ public class DateField extends AbstractField implements */ public void setTimeZone(TimeZone timeZone) { this.timeZone = timeZone; - requestRepaint(); + markAsDirty(); } /** diff --git a/server/src/com/vaadin/ui/DragAndDropWrapper.java b/server/src/com/vaadin/ui/DragAndDropWrapper.java index 1c41de81a0..ec805ecf46 100644 --- a/server/src/com/vaadin/ui/DragAndDropWrapper.java +++ b/server/src/com/vaadin/ui/DragAndDropWrapper.java @@ -60,7 +60,7 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget, String id = (String) rawVariables.get("fi" + i); files[i] = file; receivers.put(id, file); - requestRepaint(); // paint Receivers + markAsDirty(); // paint Receivers } } } @@ -207,7 +207,7 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget, */ public void setHTML5DataFlavor(String type, Object value) { html5DataFlavors.put(type, value); - requestRepaint(); + markAsDirty(); } @Override @@ -254,7 +254,7 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget, public void setDropHandler(DropHandler dropHandler) { this.dropHandler = dropHandler; - requestRepaint(); + markAsDirty(); } @Override @@ -270,7 +270,7 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget, public void setDragStartMode(DragStartMode dragStartMode) { this.dragStartMode = dragStartMode; - requestRepaint(); + markAsDirty(); } public DragStartMode getDragStartMode() { diff --git a/server/src/com/vaadin/ui/Embedded.java b/server/src/com/vaadin/ui/Embedded.java index d019ea3b0b..41b93d0b27 100644 --- a/server/src/com/vaadin/ui/Embedded.java +++ b/server/src/com/vaadin/ui/Embedded.java @@ -196,7 +196,7 @@ public class Embedded extends AbstractComponent implements Vaadin6Component { if (altText != this.altText || (altText != null && !altText.equals(this.altText))) { this.altText = altText; - requestRepaint(); + markAsDirty(); } } @@ -222,7 +222,7 @@ public class Embedded extends AbstractComponent implements Vaadin6Component { */ public void setParameter(String name, String value) { parameters.put(name, value); - requestRepaint(); + markAsDirty(); } /** @@ -244,7 +244,7 @@ public class Embedded extends AbstractComponent implements Vaadin6Component { */ public void removeParameter(String name) { parameters.remove(name); - requestRepaint(); + markAsDirty(); } /** @@ -307,7 +307,7 @@ public class Embedded extends AbstractComponent implements Vaadin6Component { if (codebase != this.codebase || (codebase != null && !codebase.equals(this.codebase))) { this.codebase = codebase; - requestRepaint(); + markAsDirty(); } } @@ -325,7 +325,7 @@ public class Embedded extends AbstractComponent implements Vaadin6Component { if (codetype != this.codetype || (codetype != null && !codetype.equals(this.codetype))) { this.codetype = codetype; - requestRepaint(); + markAsDirty(); } } @@ -350,7 +350,7 @@ public class Embedded extends AbstractComponent implements Vaadin6Component { setParameter("wmode", "transparent"); } } - requestRepaint(); + markAsDirty(); } } @@ -365,7 +365,7 @@ public class Embedded extends AbstractComponent implements Vaadin6Component { if (standby != this.standby || (standby != null && !standby.equals(this.standby))) { this.standby = standby; - requestRepaint(); + markAsDirty(); } } @@ -390,7 +390,7 @@ public class Embedded extends AbstractComponent implements Vaadin6Component { if (classId != this.classId || (classId != null && !classId.equals(this.classId))) { this.classId = classId; - requestRepaint(); + markAsDirty(); } } @@ -443,7 +443,7 @@ public class Embedded extends AbstractComponent implements Vaadin6Component { } else { // Keep previous type } - requestRepaint(); + markAsDirty(); } } @@ -467,7 +467,7 @@ public class Embedded extends AbstractComponent implements Vaadin6Component { } if (type != this.type) { this.type = type; - requestRepaint(); + markAsDirty(); } } @@ -502,7 +502,7 @@ public class Embedded extends AbstractComponent implements Vaadin6Component { if (archive != this.archive || (archive != null && !archive.equals(this.archive))) { this.archive = archive; - requestRepaint(); + markAsDirty(); } } diff --git a/server/src/com/vaadin/ui/Form.java b/server/src/com/vaadin/ui/Form.java index 8f63ad511a..55404b2e6b 100644 --- a/server/src/com/vaadin/ui/Form.java +++ b/server/src/com/vaadin/ui/Form.java @@ -133,7 +133,7 @@ public class Form extends AbstractField implements Item.Editor, private final ValueChangeListener fieldValueChangeListener = new ValueChangeListener() { @Override public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) { - requestRepaint(); + markAsDirty(); } }; @@ -342,7 +342,7 @@ public class Form extends AbstractField implements Item.Editor, if (problems == null) { if (currentBufferedSourceException != null) { currentBufferedSourceException = null; - requestRepaint(); + markAsDirty(); } return; } @@ -357,7 +357,7 @@ public class Form extends AbstractField implements Item.Editor, final Buffered.SourceException e = new Buffered.SourceException(this, causes); currentBufferedSourceException = e; - requestRepaint(); + markAsDirty(); throw e; } @@ -386,7 +386,7 @@ public class Form extends AbstractField implements Item.Editor, if (problems == null) { if (currentBufferedSourceException != null) { currentBufferedSourceException = null; - requestRepaint(); + markAsDirty(); } return; } @@ -401,7 +401,7 @@ public class Form extends AbstractField implements Item.Editor, final Buffered.SourceException e = new Buffered.SourceException(this, causes); currentBufferedSourceException = e; - requestRepaint(); + markAsDirty(); throw e; } @@ -491,7 +491,7 @@ public class Form extends AbstractField implements Item.Editor, public void addField(Object propertyId, Field field) { registerField(propertyId, field); attachField(propertyId, field); - requestRepaint(); + markAsDirty(); } /** @@ -720,7 +720,7 @@ public class Form extends AbstractField implements Item.Editor, // If the new datasource is null, just set null datasource if (itemDatasource == null) { - requestRepaint(); + markAsDirty(); return; } @@ -1244,7 +1244,7 @@ public class Form extends AbstractField implements Item.Editor, // some ancestor still disabled, don't update children return; } else { - getLayout().requestRepaintAll(); + getLayout().markAsDirtyRecursive(); } } diff --git a/server/src/com/vaadin/ui/GridLayout.java b/server/src/com/vaadin/ui/GridLayout.java index 5de6cc79c7..3870b71611 100644 --- a/server/src/com/vaadin/ui/GridLayout.java +++ b/server/src/com/vaadin/ui/GridLayout.java @@ -254,7 +254,7 @@ public class GridLayout extends AbstractLayout implements } } - requestRepaint(); + markAsDirty(); } /** @@ -400,7 +400,7 @@ public class GridLayout extends AbstractLayout implements super.removeComponent(component); - requestRepaint(); + markAsDirty(); } /** @@ -1096,7 +1096,7 @@ public class GridLayout extends AbstractLayout implements } else { oldLocation.setComponent(newComponent); newLocation.setComponent(oldComponent); - requestRepaint(); + markAsDirty(); } } @@ -1117,7 +1117,7 @@ public class GridLayout extends AbstractLayout implements public void setComponentAlignment(Component childComponent, Alignment alignment) { componentToAlignment.put(childComponent, alignment); - requestRepaint(); + markAsDirty(); } /* @@ -1173,7 +1173,7 @@ public class GridLayout extends AbstractLayout implements setRows(getRows() + 1); structuralChange = true; - requestRepaint(); + markAsDirty(); } /** @@ -1232,7 +1232,7 @@ public class GridLayout extends AbstractLayout implements } structuralChange = true; - requestRepaint(); + markAsDirty(); } @@ -1257,7 +1257,7 @@ public class GridLayout extends AbstractLayout implements */ public void setColumnExpandRatio(int columnIndex, float ratio) { columnExpandRatio.put(columnIndex, ratio); - requestRepaint(); + markAsDirty(); } /** @@ -1295,7 +1295,7 @@ public class GridLayout extends AbstractLayout implements */ public void setRowExpandRatio(int rowIndex, float ratio) { rowExpandRatio.put(rowIndex, ratio); - requestRepaint(); + markAsDirty(); } /** diff --git a/server/src/com/vaadin/ui/Label.java b/server/src/com/vaadin/ui/Label.java index 5055c7e573..81a343e937 100644 --- a/server/src/com/vaadin/ui/Label.java +++ b/server/src/com/vaadin/ui/Label.java @@ -265,7 +265,7 @@ public class Label extends AbstractComponent implements Property, .isAssignableFrom(dataSource.getClass())) { ((Property.ValueChangeNotifier) dataSource).addListener(this); } - requestRepaint(); + markAsDirty(); } /** @@ -482,7 +482,7 @@ public class Label extends AbstractComponent implements Property, */ public void setConverter(Converter converter) { this.converter = (Converter) converter; - requestRepaint(); + markAsDirty(); } } diff --git a/server/src/com/vaadin/ui/Link.java b/server/src/com/vaadin/ui/Link.java index ae2934f878..f98a2b0d2d 100644 --- a/server/src/com/vaadin/ui/Link.java +++ b/server/src/com/vaadin/ui/Link.java @@ -188,7 +188,7 @@ public class Link extends AbstractComponent implements Vaadin6Component { */ public void setTargetBorder(BorderStyle targetBorder) { this.targetBorder = targetBorder; - requestRepaint(); + markAsDirty(); } /** @@ -199,7 +199,7 @@ public class Link extends AbstractComponent implements Vaadin6Component { */ public void setTargetHeight(int targetHeight) { this.targetHeight = targetHeight; - requestRepaint(); + markAsDirty(); } /** @@ -210,7 +210,7 @@ public class Link extends AbstractComponent implements Vaadin6Component { */ public void setTargetName(String targetName) { this.targetName = targetName; - requestRepaint(); + markAsDirty(); } /** @@ -221,7 +221,7 @@ public class Link extends AbstractComponent implements Vaadin6Component { */ public void setTargetWidth(int targetWidth) { this.targetWidth = targetWidth; - requestRepaint(); + markAsDirty(); } /** @@ -241,7 +241,7 @@ public class Link extends AbstractComponent implements Vaadin6Component { */ public void setResource(Resource resource) { this.resource = resource; - requestRepaint(); + markAsDirty(); } @Override diff --git a/server/src/com/vaadin/ui/ListSelect.java b/server/src/com/vaadin/ui/ListSelect.java index eb54183164..da78e24fa8 100644 --- a/server/src/com/vaadin/ui/ListSelect.java +++ b/server/src/com/vaadin/ui/ListSelect.java @@ -62,7 +62,7 @@ public class ListSelect extends AbstractSelect { } if (this.columns != columns) { this.columns = columns; - requestRepaint(); + markAsDirty(); } } @@ -88,7 +88,7 @@ public class ListSelect extends AbstractSelect { } if (this.rows != rows) { this.rows = rows; - requestRepaint(); + markAsDirty(); } } diff --git a/server/src/com/vaadin/ui/MenuBar.java b/server/src/com/vaadin/ui/MenuBar.java index 37728ee69b..51c06cf934 100644 --- a/server/src/com/vaadin/ui/MenuBar.java +++ b/server/src/com/vaadin/ui/MenuBar.java @@ -223,7 +223,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component { } MenuItem newItem = new MenuItem(caption, icon, command); menuItems.add(newItem); - requestRepaint(); + markAsDirty(); return newItem; @@ -259,7 +259,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component { menuItems.add(newItem); } - requestRepaint(); + markAsDirty(); return newItem; } @@ -283,7 +283,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component { if (item != null) { menuItems.remove(item); } - requestRepaint(); + markAsDirty(); } /** @@ -291,7 +291,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component { */ public void removeItems() { menuItems.clear(); - requestRepaint(); + markAsDirty(); } /** @@ -318,7 +318,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component { } else { moreItem = new MenuItem("", null, null); } - requestRepaint(); + markAsDirty(); } /** @@ -345,7 +345,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component { public void setAutoOpen(boolean autoOpenTopLevelMenu) { if (autoOpenTopLevelMenu != openRootOnHover) { openRootOnHover = autoOpenTopLevelMenu; - requestRepaint(); + markAsDirty(); } } @@ -373,7 +373,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component { */ public void setHtmlContentAllowed(boolean htmlContentAllowed) { this.htmlContentAllowed = htmlContentAllowed; - requestRepaint(); + markAsDirty(); } /** @@ -521,7 +521,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component { newItem.setParent(this); itsChildren.add(newItem); - requestRepaint(); + markAsDirty(); return newItem; } @@ -560,7 +560,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component { newItem = addItem(caption, icon, command); } - requestRepaint(); + markAsDirty(); return newItem; } @@ -651,7 +651,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component { */ public void setIcon(Resource icon) { itsIcon = icon; - requestRepaint(); + markAsDirty(); } /** @@ -664,7 +664,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component { if (text != null) { itsText = text; } - requestRepaint(); + markAsDirty(); } /** @@ -679,7 +679,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component { if (itsChildren.isEmpty()) { itsChildren = null; } - requestRepaint(); + markAsDirty(); } } @@ -690,7 +690,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component { if (itsChildren != null) { itsChildren.clear(); itsChildren = null; - requestRepaint(); + markAsDirty(); } } @@ -706,7 +706,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component { public void setEnabled(boolean enabled) { this.enabled = enabled; - requestRepaint(); + markAsDirty(); } public boolean isEnabled() { @@ -715,7 +715,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component { public void setVisible(boolean visible) { this.visible = visible; - requestRepaint(); + markAsDirty(); } public boolean isVisible() { @@ -724,7 +724,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component { private void setSeparator(boolean isSeparator) { this.isSeparator = isSeparator; - requestRepaint(); + markAsDirty(); } public boolean isSeparator() { @@ -733,7 +733,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component { public void setStyleName(String styleName) { this.styleName = styleName; - requestRepaint(); + markAsDirty(); } public String getStyleName() { @@ -750,7 +750,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component { */ public void setDescription(String description) { this.description = description; - requestRepaint(); + markAsDirty(); } /** @@ -855,7 +855,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component { "A menu item with children cannot be checkable"); } this.checkable = checkable; - requestRepaint(); + markAsDirty(); } /** @@ -897,7 +897,7 @@ public class MenuBar extends AbstractComponent implements Vaadin6Component { */ public void setChecked(boolean checked) { this.checked = checked; - requestRepaint(); + markAsDirty(); } }// class MenuItem diff --git a/server/src/com/vaadin/ui/NativeSelect.java b/server/src/com/vaadin/ui/NativeSelect.java index 53c225a256..c2969874b0 100644 --- a/server/src/com/vaadin/ui/NativeSelect.java +++ b/server/src/com/vaadin/ui/NativeSelect.java @@ -64,7 +64,7 @@ public class NativeSelect extends AbstractSelect { } if (this.columns != columns) { this.columns = columns; - requestRepaint(); + markAsDirty(); } } diff --git a/server/src/com/vaadin/ui/OptionGroup.java b/server/src/com/vaadin/ui/OptionGroup.java index dfb5019331..12507442c9 100644 --- a/server/src/com/vaadin/ui/OptionGroup.java +++ b/server/src/com/vaadin/ui/OptionGroup.java @@ -125,14 +125,14 @@ public class OptionGroup extends AbstractSelect implements Set newValueSet = (Set) newValue; for (Object itemId : currentValueSet) { if (!isItemEnabled(itemId) && !newValueSet.contains(itemId)) { - requestRepaint(); + markAsDirty(); return; } } for (Object itemId : newValueSet) { if (!isItemEnabled(itemId) && !currentValueSet.contains(itemId)) { - requestRepaint(); + markAsDirty(); return; } } @@ -141,7 +141,7 @@ public class OptionGroup extends AbstractSelect implements newValue = getNullSelectionItemId(); } if (!isItemEnabled(newValue)) { - requestRepaint(); + markAsDirty(); return; } } @@ -169,7 +169,7 @@ public class OptionGroup extends AbstractSelect implements } else { disabledItemIds.add(itemId); } - requestRepaint(); + markAsDirty(); } } @@ -200,7 +200,7 @@ public class OptionGroup extends AbstractSelect implements */ public void setHtmlContentAllowed(boolean htmlContentAllowed) { this.htmlContentAllowed = htmlContentAllowed; - requestRepaint(); + markAsDirty(); } /** diff --git a/server/src/com/vaadin/ui/Panel.java b/server/src/com/vaadin/ui/Panel.java index 1f3b8580f8..00810b83db 100644 --- a/server/src/com/vaadin/ui/Panel.java +++ b/server/src/com/vaadin/ui/Panel.java @@ -176,7 +176,7 @@ public class Panel extends AbstractComponentContainer implements Scrollable, .addListener((ComponentContainer.ComponentDetachListener) this); content = newContent; - requestRepaint(); + markAsDirty(); } /** diff --git a/server/src/com/vaadin/ui/PopupDateField.java b/server/src/com/vaadin/ui/PopupDateField.java index a4304faaf9..acff49a142 100644 --- a/server/src/com/vaadin/ui/PopupDateField.java +++ b/server/src/com/vaadin/ui/PopupDateField.java @@ -84,7 +84,7 @@ public class PopupDateField extends DateField { */ public void setInputPrompt(String inputPrompt) { this.inputPrompt = inputPrompt; - requestRepaint(); + markAsDirty(); } } diff --git a/server/src/com/vaadin/ui/PopupView.java b/server/src/com/vaadin/ui/PopupView.java index 198ba00ed2..786257c240 100644 --- a/server/src/com/vaadin/ui/PopupView.java +++ b/server/src/com/vaadin/ui/PopupView.java @@ -147,7 +147,7 @@ public class PopupView extends AbstractComponentContainer implements throw new IllegalArgumentException("Content must not be null"); } content = newContent; - requestRepaint(); + markAsDirty(); } /** @@ -179,7 +179,7 @@ public class PopupView extends AbstractComponentContainer implements visibleComponent = null; } fireEvent(new PopupVisibilityEvent(this)); - requestRepaint(); + markAsDirty(); } } diff --git a/server/src/com/vaadin/ui/ProgressIndicator.java b/server/src/com/vaadin/ui/ProgressIndicator.java index d3e292a3e1..528c404ab9 100644 --- a/server/src/com/vaadin/ui/ProgressIndicator.java +++ b/server/src/com/vaadin/ui/ProgressIndicator.java @@ -226,7 +226,7 @@ public class ProgressIndicator extends AbstractField implements */ public void setIndeterminate(boolean newValue) { indeterminate = newValue; - requestRepaint(); + markAsDirty(); } /** @@ -246,7 +246,7 @@ public class ProgressIndicator extends AbstractField implements */ public void setPollingInterval(int newValue) { pollingInterval = newValue; - requestRepaint(); + markAsDirty(); } /** diff --git a/server/src/com/vaadin/ui/RichTextArea.java b/server/src/com/vaadin/ui/RichTextArea.java index e954f78700..51caa82136 100644 --- a/server/src/com/vaadin/ui/RichTextArea.java +++ b/server/src/com/vaadin/ui/RichTextArea.java @@ -157,7 +157,7 @@ public class RichTextArea extends AbstractField implements */ selectAll = true; focus(); - requestRepaint(); + markAsDirty(); } @Override @@ -183,7 +183,7 @@ public class RichTextArea extends AbstractField implements // If the modified status changes, // repaint is needed after all. if (wasModified != isModified()) { - requestRepaint(); + markAsDirty(); } } } diff --git a/server/src/com/vaadin/ui/Root.java b/server/src/com/vaadin/ui/Root.java index f96fa1dc5a..35517044c0 100644 --- a/server/src/com/vaadin/ui/Root.java +++ b/server/src/com/vaadin/ui/Root.java @@ -723,7 +723,7 @@ public abstract class Root extends AbstractComponentContainer implements private void attachWindow(Window w) { windows.add(w); w.setParent(this); - requestRepaint(); + markAsDirty(); } /** @@ -746,7 +746,7 @@ public abstract class Root extends AbstractComponentContainer implements } window.setParent(null); window.fireClose(); - requestRepaint(); + markAsDirty(); return true; } @@ -788,7 +788,7 @@ public abstract class Root extends AbstractComponentContainer implements */ public void setFocusedComponent(Focusable focusable) { pendingFocus = focusable; - requestRepaint(); + markAsDirty(); } /** @@ -808,7 +808,7 @@ public abstract class Root extends AbstractComponentContainer implements "The component where to scroll must belong to this root."); } scrollIntoView = component; - requestRepaint(); + markAsDirty(); } /** @@ -1013,7 +1013,7 @@ public abstract class Root extends AbstractComponentContainer implements */ public void setResizeLazy(boolean resizeLazy) { this.resizeLazy = resizeLazy; - requestRepaint(); + markAsDirty(); } /** diff --git a/server/src/com/vaadin/ui/Select.java b/server/src/com/vaadin/ui/Select.java index 898728b9cd..20345b55e0 100644 --- a/server/src/com/vaadin/ui/Select.java +++ b/server/src/com/vaadin/ui/Select.java @@ -676,15 +676,21 @@ public class Select extends AbstractSelect implements AbstractSelect.Filtering, } @Override + @Deprecated public void requestRepaint() { - super.requestRepaint(); + markAsDirty(); + } + + @Override + public void markAsDirty() { + super.markAsDirty(); optionRequest = false; prevfilterstring = filterstring; filterstring = null; } private void optionRepaint() { - super.requestRepaint(); + super.markAsDirty(); } @Override diff --git a/server/src/com/vaadin/ui/Slider.java b/server/src/com/vaadin/ui/Slider.java index f7672f617c..d4e2db4853 100644 --- a/server/src/com/vaadin/ui/Slider.java +++ b/server/src/com/vaadin/ui/Slider.java @@ -174,7 +174,7 @@ public class Slider extends AbstractField implements Vaadin6Component { if (getValue() > max) { setValue(max); } - requestRepaint(); + markAsDirty(); } /** @@ -198,7 +198,7 @@ public class Slider extends AbstractField implements Vaadin6Component { if (getValue() < min) { setValue(min); } - requestRepaint(); + markAsDirty(); } /** @@ -220,7 +220,7 @@ public class Slider extends AbstractField implements Vaadin6Component { */ public void setOrientation(int orientation) { this.orientation = orientation; - requestRepaint(); + markAsDirty(); } /** @@ -244,7 +244,7 @@ public class Slider extends AbstractField implements Vaadin6Component { return; } this.resolution = resolution; - requestRepaint(); + markAsDirty(); } /** diff --git a/server/src/com/vaadin/ui/TabSheet.java b/server/src/com/vaadin/ui/TabSheet.java index 868d97a09c..82faedcc41 100644 --- a/server/src/com/vaadin/ui/TabSheet.java +++ b/server/src/com/vaadin/ui/TabSheet.java @@ -176,7 +176,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, fireSelectedTabChange(); } } - requestRepaint(); + markAsDirty(); } } @@ -301,7 +301,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, fireSelectedTabChange(); } super.addComponent(c); - requestRepaint(); + markAsDirty(); return tab; } } @@ -475,7 +475,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, */ public void hideTabs(boolean tabsHidden) { this.tabsHidden = tabsHidden; - requestRepaint(); + markAsDirty(); } /** @@ -519,7 +519,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, setSelected(c); updateSelection(); fireSelectedTabChange(); - requestRepaint(); + markAsDirty(); } } @@ -537,13 +537,13 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, // "cached" update even though the client knows nothing about the // connector if (selected instanceof ComponentContainer) { - ((ComponentContainer) selected).requestRepaintAll(); + ((ComponentContainer) selected).markAsDirtyRecursive(); } else if (selected instanceof Table) { // Workaround until there's a generic way of telling a component // that there is no client side state to rely on. See #8642 ((Table) selected).refreshRowCache(); } else if (selected != null) { - selected.requestRepaint(); + selected.markAsDirty(); } } @@ -716,7 +716,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, copyTabMetadata(oldTab, newTab); copyTabMetadata(tmp, oldTab); - requestRepaint(); + markAsDirty(); } } @@ -1028,7 +1028,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, @Override public void setCaption(String caption) { this.caption = caption; - requestRepaint(); + markAsDirty(); } @Override @@ -1039,7 +1039,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, @Override public void setIcon(Resource icon) { this.icon = icon; - requestRepaint(); + markAsDirty(); } @Override @@ -1053,7 +1053,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, if (updateSelection()) { fireSelectedTabChange(); } - requestRepaint(); + markAsDirty(); } @Override @@ -1067,7 +1067,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, if (updateSelection()) { fireSelectedTabChange(); } - requestRepaint(); + markAsDirty(); } @Override @@ -1078,7 +1078,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, @Override public void setClosable(boolean closable) { this.closable = closable; - requestRepaint(); + markAsDirty(); } public void close() { @@ -1093,7 +1093,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, @Override public void setDescription(String description) { this.description = description; - requestRepaint(); + markAsDirty(); } @Override @@ -1104,7 +1104,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, @Override public void setComponentError(ErrorMessage componentError) { this.componentError = componentError; - requestRepaint(); + markAsDirty(); } @Override @@ -1120,7 +1120,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, @Override public void setStyleName(String styleName) { this.styleName = styleName; - requestRepaint(); + markAsDirty(); } @Override @@ -1180,7 +1180,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, int oldPosition = getTabPosition(tab); components.remove(oldPosition); components.add(position, tab.getComponent()); - requestRepaint(); + markAsDirty(); } /** @@ -1207,7 +1207,7 @@ public class TabSheet extends AbstractComponentContainer implements Focusable, @Override public void setTabIndex(int tabIndex) { this.tabIndex = tabIndex; - requestRepaint(); + markAsDirty(); } @Override diff --git a/server/src/com/vaadin/ui/Table.java b/server/src/com/vaadin/ui/Table.java index 120d1f9810..8fc3fc2572 100644 --- a/server/src/com/vaadin/ui/Table.java +++ b/server/src/com/vaadin/ui/Table.java @@ -729,7 +729,7 @@ public class Table extends AbstractSelect implements Action.Container, this.columnHeaders.put(it.next(), columnHeaders[i]); } - requestRepaint(); + markAsDirty(); } /** @@ -788,7 +788,7 @@ public class Table extends AbstractSelect implements Action.Container, this.columnIcons.put(it.next(), columnIcons[i]); } - requestRepaint(); + markAsDirty(); } /** @@ -888,7 +888,7 @@ public class Table extends AbstractSelect implements Action.Container, } else { columnWidths.put(propertyId, Integer.valueOf(width)); } - requestRepaint(); + markAsDirty(); } /** @@ -1026,7 +1026,7 @@ public class Table extends AbstractSelect implements Action.Container, } if (this.cacheRate != cacheRate) { this.cacheRate = cacheRate; - requestRepaint(); + markAsDirty(); } } @@ -1158,7 +1158,7 @@ public class Table extends AbstractSelect implements Action.Container, columnIcons.put(propertyId, icon); } - requestRepaint(); + markAsDirty(); } /** @@ -1198,7 +1198,7 @@ public class Table extends AbstractSelect implements Action.Container, columnHeaders.put(propertyId, header); } - requestRepaint(); + markAsDirty(); } /** @@ -1361,7 +1361,7 @@ public class Table extends AbstractSelect implements Action.Container, public void setColumnReorderingAllowed(boolean columnReorderingAllowed) { if (columnReorderingAllowed != this.columnReorderingAllowed) { this.columnReorderingAllowed = columnReorderingAllowed; - requestRepaint(); + markAsDirty(); } } @@ -1532,7 +1532,7 @@ public class Table extends AbstractSelect implements Action.Container, public void setSelectable(boolean selectable) { if (this.selectable != selectable) { this.selectable = selectable; - requestRepaint(); + markAsDirty(); } } @@ -1558,7 +1558,7 @@ public class Table extends AbstractSelect implements Action.Container, } if (columnHeaderMode != this.columnHeaderMode) { this.columnHeaderMode = columnHeaderMode; - requestRepaint(); + markAsDirty(); } } @@ -1627,7 +1627,7 @@ public class Table extends AbstractSelect implements Action.Container, } setRowCacheInvalidated(true); - requestRepaint(); + markAsDirty(); } /** @@ -1636,17 +1636,39 @@ public class Table extends AbstractSelect implements Action.Container, * Note that a {@code Table} does not necessarily repaint its contents when * this method has been called. See {@link #refreshRowCache()} for forcing * an update of the contents. + * + * @deprecated As of 7.0.0, use {@link #markAsDirty()} instead */ + @Deprecated @Override public void requestRepaint() { + markAsDirty(); + } + + /** + * Requests that the Table should be repainted as soon as possible. + * + * Note that a {@code Table} does not necessarily repaint its contents when + * this method has been called. See {@link #refreshRowCache()} for forcing + * an update of the contents. + */ + + @Override + public void markAsDirty() { // Overridden only for javadoc - super.requestRepaint(); + super.markAsDirty(); } + @Deprecated @Override public void requestRepaintAll() { - super.requestRepaintAll(); + markAsDirtyRecursive(); + } + + @Override + public void markAsDirtyRecursive() { + super.markAsDirtyRecursive(); // Avoid sending a partial repaint (#8714) refreshRowCache(); @@ -2436,7 +2458,7 @@ public class Table extends AbstractSelect implements Action.Container, if (!isNullSelectionAllowed() && (id == null || id == getNullSelectionItemId())) { // skip empty selection if nullselection is not allowed - requestRepaint(); + markAsDirty(); } else if (id != null && containsId(id)) { newValue.add(id); renderedButNotSelectedItemIds.remove(id); @@ -2463,7 +2485,7 @@ public class Table extends AbstractSelect implements Action.Container, if (!isNullSelectionAllowed() && newValue.isEmpty()) { // empty selection not allowed, keep old value - requestRepaint(); + markAsDirty(); return; } @@ -2802,7 +2824,7 @@ public class Table extends AbstractSelect implements Action.Container, if (refreshContent) { refreshRenderedCells(); // Ensure that client gets a response - requestRepaint(); + markAsDirty(); } } @@ -3751,7 +3773,7 @@ public class Table extends AbstractSelect implements Action.Container, refreshRowCache(); containerChangeToBeRendered = true; } - requestRepaint(); + markAsDirty(); } /** @@ -4476,7 +4498,7 @@ public class Table extends AbstractSelect implements Action.Container, public void setSortEnabled(boolean sortEnabled) { if (this.sortEnabled != sortEnabled) { this.sortEnabled = sortEnabled; - requestRepaint(); + markAsDirty(); } } @@ -4573,7 +4595,7 @@ public class Table extends AbstractSelect implements Action.Container, // some ancestor still disabled, don't update children return; } else { - requestRepaintAll(); + markAsDirtyRecursive(); } } @@ -4585,7 +4607,7 @@ public class Table extends AbstractSelect implements Action.Container, */ public void setDragMode(TableDragMode newDragMode) { dragMode = newDragMode; - requestRepaint(); + markAsDirty(); } /** @@ -4669,7 +4691,7 @@ public class Table extends AbstractSelect implements Action.Container, */ public void setMultiSelectMode(MultiSelectMode mode) { multiSelectMode = mode; - requestRepaint(); + markAsDirty(); } /** @@ -4977,7 +4999,7 @@ public class Table extends AbstractSelect implements Action.Container, columnFooters.put(propertyId, footer); } - requestRepaint(); + markAsDirty(); } /** @@ -4993,7 +5015,7 @@ public class Table extends AbstractSelect implements Action.Container, public void setFooterVisible(boolean visible) { if (visible != columnFootersVisible) { columnFootersVisible = visible; - requestRepaint(); + markAsDirty(); } } diff --git a/server/src/com/vaadin/ui/Tree.java b/server/src/com/vaadin/ui/Tree.java index dda0a78aff..2d6673a67d 100644 --- a/server/src/com/vaadin/ui/Tree.java +++ b/server/src/com/vaadin/ui/Tree.java @@ -184,7 +184,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, */ public boolean expandItem(Object itemId) { boolean success = expandItem(itemId, true); - requestRepaint(); + markAsDirty(); return success; } @@ -215,7 +215,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, expandedItemId = itemId; if (initialPaint) { - requestRepaint(); + markAsDirty(); } else if (sendChildTree) { requestPartialRepaint(); } @@ -225,13 +225,13 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, } @Override - public void requestRepaint() { - super.requestRepaint(); + public void markAsDirty() { + super.markAsDirty(); partialUpdate = false; } private void requestPartialRepaint() { - super.requestRepaint(); + super.markAsDirty(); partialUpdate = true; } @@ -262,7 +262,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, todo.addAll(getChildren(id)); } } - requestRepaint(); + markAsDirty(); return result; } @@ -282,7 +282,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, // Collapse expanded.remove(itemId); - requestRepaint(); + markAsDirty(); fireCollapseEvent(itemId); return true; @@ -349,7 +349,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, public void setSelectable(boolean selectable) { if (this.selectable != selectable) { this.selectable = selectable; - requestRepaint(); + markAsDirty(); } } @@ -362,7 +362,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, public void setMultiselectMode(MultiSelectMode mode) { if (multiSelectMode != mode && mode != null) { multiSelectMode = mode; - requestRepaint(); + markAsDirty(); } } @@ -478,7 +478,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, if (!isNullSelectionAllowed() && (id == null || id == getNullSelectionItemId())) { // skip empty selection if nullselection is not allowed - requestRepaint(); + markAsDirty(); } else if (id != null && containsId(id)) { s.add(id); } @@ -486,7 +486,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, if (!isNullSelectionAllowed() && s.size() < 1) { // empty selection not allowed, keep old value - requestRepaint(); + markAsDirty(); return; } @@ -796,7 +796,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, final boolean success = ((Container.Hierarchical) items) .setChildrenAllowed(itemId, areChildrenAllowed); if (success) { - requestRepaint(); + markAsDirty(); } return success; } @@ -812,7 +812,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, final boolean success = ((Container.Hierarchical) items).setParent( itemId, newParentId); if (success) { - requestRepaint(); + markAsDirty(); } return success; } @@ -1036,7 +1036,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, if (!actionHandlers.contains(actionHandler)) { actionHandlers.add(actionHandler); - requestRepaint(); + markAsDirty(); } } } @@ -1058,7 +1058,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, actionMapper = null; } - requestRepaint(); + markAsDirty(); } } @@ -1068,7 +1068,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, public void removeAllActionHandlers() { actionHandlers = null; actionMapper = null; - requestRepaint(); + markAsDirty(); } /** @@ -1182,7 +1182,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, public void setItemStyleGenerator(ItemStyleGenerator itemStyleGenerator) { if (this.itemStyleGenerator != itemStyleGenerator) { this.itemStyleGenerator = itemStyleGenerator; - requestRepaint(); + markAsDirty(); } } @@ -1342,7 +1342,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, */ public void setDragMode(TreeDragMode dragMode) { this.dragMode = dragMode; - requestRepaint(); + markAsDirty(); } /** @@ -1601,7 +1601,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, public void setItemDescriptionGenerator(ItemDescriptionGenerator generator) { if (generator != itemDescriptionGenerator) { itemDescriptionGenerator = generator; - requestRepaint(); + markAsDirty(); } } diff --git a/server/src/com/vaadin/ui/TreeTable.java b/server/src/com/vaadin/ui/TreeTable.java index 7548a4840b..05757a6d09 100644 --- a/server/src/com/vaadin/ui/TreeTable.java +++ b/server/src/com/vaadin/ui/TreeTable.java @@ -463,7 +463,7 @@ public class TreeTable extends Table implements Hierarchical { // been processed clearFocusedRowPending = true; } - requestRepaint(); + markAsDirty(); } @Override @@ -561,7 +561,7 @@ public class TreeTable extends Table implements Hierarchical { } if (containerSupportsPartialUpdates && !forceFullRefresh) { - requestRepaint(); + markAsDirty(); } else { // For containers that do not send item set change events, always do // full repaint instead of partial row update. @@ -826,7 +826,7 @@ public class TreeTable extends Table implements Hierarchical { */ public void setAnimationsEnabled(boolean animationsEnabled) { this.animationsEnabled = animationsEnabled; - requestRepaint(); + markAsDirty(); } private static final Logger getLogger() { diff --git a/server/src/com/vaadin/ui/TwinColSelect.java b/server/src/com/vaadin/ui/TwinColSelect.java index 80f4ae49c8..891e695a5f 100644 --- a/server/src/com/vaadin/ui/TwinColSelect.java +++ b/server/src/com/vaadin/ui/TwinColSelect.java @@ -79,7 +79,7 @@ public class TwinColSelect extends AbstractSelect { } if (this.columns != columns) { this.columns = columns; - requestRepaint(); + markAsDirty(); } } @@ -111,7 +111,7 @@ public class TwinColSelect extends AbstractSelect { } if (this.rows != rows) { this.rows = rows; - requestRepaint(); + markAsDirty(); } } @@ -159,7 +159,7 @@ public class TwinColSelect extends AbstractSelect { */ public void setRightColumnCaption(String rightColumnCaption) { this.rightColumnCaption = rightColumnCaption; - requestRepaint(); + markAsDirty(); } /** @@ -179,7 +179,7 @@ public class TwinColSelect extends AbstractSelect { */ public void setLeftColumnCaption(String leftColumnCaption) { this.leftColumnCaption = leftColumnCaption; - requestRepaint(); + markAsDirty(); } /** diff --git a/server/src/com/vaadin/ui/Upload.java b/server/src/com/vaadin/ui/Upload.java index b50ba03835..619db07eea 100644 --- a/server/src/com/vaadin/ui/Upload.java +++ b/server/src/com/vaadin/ui/Upload.java @@ -138,7 +138,7 @@ public class Upload extends AbstractComponent implements Component.Focusable, int id = (Integer) variables.get("pollForStart"); if (!isUploading && id == nextid) { notStarted = true; - requestRepaint(); + markAsDirty(); } else { } } @@ -829,7 +829,7 @@ public class Upload extends AbstractComponent implements Component.Focusable, isUploading = false; contentLength = -1; interrupted = false; - requestRepaint(); + markAsDirty(); } public boolean isUploading() { @@ -901,7 +901,7 @@ public class Upload extends AbstractComponent implements Component.Focusable, */ public void setButtonCaption(String buttonCaption) { this.buttonCaption = buttonCaption; - requestRepaint(); + markAsDirty(); } /** @@ -922,14 +922,14 @@ public class Upload extends AbstractComponent implements Component.Focusable, * fired. */ public void submitUpload() { - requestRepaint(); + markAsDirty(); forceSubmit = true; } @Override - public void requestRepaint() { + public void markAsDirty() { forceSubmit = false; - super.requestRepaint(); + super.markAsDirty(); } /* @@ -982,7 +982,7 @@ public class Upload extends AbstractComponent implements Component.Focusable, fireUploadSuccess(event.getFileName(), event.getMimeType(), event.getContentLength()); endUpload(); - requestRepaint(); + markAsDirty(); } @Override diff --git a/server/src/com/vaadin/ui/Window.java b/server/src/com/vaadin/ui/Window.java index 902d33bc64..d79588cc63 100644 --- a/server/src/com/vaadin/ui/Window.java +++ b/server/src/com/vaadin/ui/Window.java @@ -493,7 +493,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, } } bringToFront = Integer.valueOf(maxBringToFront + 1); - requestRepaint(); + markAsDirty(); } /** diff --git a/tests/server-side/com/vaadin/tests/server/component/textfield/TextFieldWithPropertyFormatter.java b/tests/server-side/com/vaadin/tests/server/component/textfield/TextFieldWithPropertyFormatter.java index bd6dd6c7b1..4bb0177a18 100644 --- a/tests/server-side/com/vaadin/tests/server/component/textfield/TextFieldWithPropertyFormatter.java +++ b/tests/server-side/com/vaadin/tests/server/component/textfield/TextFieldWithPropertyFormatter.java @@ -30,9 +30,9 @@ public class TextFieldWithPropertyFormatter extends TestCase { field = new TextField() { @Override - public void requestRepaint() { + public void markAsDirty() { repainted++; - super.requestRepaint(); + super.markAsDirty(); } }; diff --git a/tests/testbench/com/vaadin/tests/PerformanceTestLabelsAndOrderedLayouts.java b/tests/testbench/com/vaadin/tests/PerformanceTestLabelsAndOrderedLayouts.java index aa8814ce4c..8002059227 100644 --- a/tests/testbench/com/vaadin/tests/PerformanceTestLabelsAndOrderedLayouts.java +++ b/tests/testbench/com/vaadin/tests/PerformanceTestLabelsAndOrderedLayouts.java @@ -62,7 +62,7 @@ public class PerformanceTestLabelsAndOrderedLayouts extends CustomComponent { new ClickListener() { @Override public void buttonClick(ClickEvent event) { - testContainer.requestRepaint(); + testContainer.markAsDirty(); } })); diff --git a/tests/testbench/com/vaadin/tests/TestSizeableIncomponents.java b/tests/testbench/com/vaadin/tests/TestSizeableIncomponents.java index 50cbe0778b..f33132a709 100644 --- a/tests/testbench/com/vaadin/tests/TestSizeableIncomponents.java +++ b/tests/testbench/com/vaadin/tests/TestSizeableIncomponents.java @@ -78,7 +78,7 @@ public class TestSizeableIncomponents extends Application.LegacyApplication { getMainWindow().showNotification( "Selected test:" + prev.getTestableName()); select.setValue(prev); - select.requestRepaint(); + select.markAsDirty(); } } }); @@ -94,7 +94,7 @@ public class TestSizeableIncomponents extends Application.LegacyApplication { getMainWindow().showNotification( "Selected test:" + next.getTestableName()); select.setValue(next); - select.requestRepaint(); + select.markAsDirty(); } } }); diff --git a/tests/testbench/com/vaadin/tests/components/absolutelayout/MoveComponentsFromAbsoluteLayoutToInnerLayout.java b/tests/testbench/com/vaadin/tests/components/absolutelayout/MoveComponentsFromAbsoluteLayoutToInnerLayout.java index 826b7cee07..c14cda58f1 100644 --- a/tests/testbench/com/vaadin/tests/components/absolutelayout/MoveComponentsFromAbsoluteLayoutToInnerLayout.java +++ b/tests/testbench/com/vaadin/tests/components/absolutelayout/MoveComponentsFromAbsoluteLayoutToInnerLayout.java @@ -40,7 +40,7 @@ public class MoveComponentsFromAbsoluteLayoutToInnerLayout extends TestBase { @Override public void buttonClick(ClickEvent event) { - vl.requestRepaint(); + vl.markAsDirty(); } }); diff --git a/tests/testbench/com/vaadin/tests/components/datefield/DateFieldRangeValidation.java b/tests/testbench/com/vaadin/tests/components/datefield/DateFieldRangeValidation.java index 484b9cfee8..c085088917 100644 --- a/tests/testbench/com/vaadin/tests/components/datefield/DateFieldRangeValidation.java +++ b/tests/testbench/com/vaadin/tests/components/datefield/DateFieldRangeValidation.java @@ -58,7 +58,7 @@ public class DateFieldRangeValidation extends TestBase { @Override public void valueChange(ValueChangeEvent event) { - actualDateField.requestRepaint(); + actualDateField.markAsDirty(); } }; diff --git a/tests/testbench/com/vaadin/tests/components/datefield/DisabledDateFieldWidth.java b/tests/testbench/com/vaadin/tests/components/datefield/DisabledDateFieldWidth.java index 4e256aa947..403b82a2a7 100644 --- a/tests/testbench/com/vaadin/tests/components/datefield/DisabledDateFieldWidth.java +++ b/tests/testbench/com/vaadin/tests/components/datefield/DisabledDateFieldWidth.java @@ -18,7 +18,7 @@ public class DisabledDateFieldWidth extends TestBase { new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { - dateField1.requestRepaint(); + dateField1.markAsDirty(); } }); diff --git a/tests/testbench/com/vaadin/tests/components/embedded/EmbeddedImageRefresh.java b/tests/testbench/com/vaadin/tests/components/embedded/EmbeddedImageRefresh.java index e316fcc5ec..3020942844 100644 --- a/tests/testbench/com/vaadin/tests/components/embedded/EmbeddedImageRefresh.java +++ b/tests/testbench/com/vaadin/tests/components/embedded/EmbeddedImageRefresh.java @@ -47,7 +47,7 @@ public class EmbeddedImageRefresh extends TestBase { button.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { - embedded.requestRepaint(); + embedded.markAsDirty(); } }); addComponent(button); @@ -57,7 +57,7 @@ public class EmbeddedImageRefresh extends TestBase { public void buttonClick(ClickEvent event) { ((StreamResource) embedded.getSource()).setFilename(new Date() .getTime() + ".png"); - embedded.requestRepaint(); + embedded.markAsDirty(); } }); addComponent(button); diff --git a/tests/testbench/com/vaadin/tests/components/gridlayout/MoveComponentsFromGridLayoutToInnerLayout.java b/tests/testbench/com/vaadin/tests/components/gridlayout/MoveComponentsFromGridLayoutToInnerLayout.java index 1c10b1d9d7..0106f2e218 100644 --- a/tests/testbench/com/vaadin/tests/components/gridlayout/MoveComponentsFromGridLayoutToInnerLayout.java +++ b/tests/testbench/com/vaadin/tests/components/gridlayout/MoveComponentsFromGridLayoutToInnerLayout.java @@ -40,7 +40,7 @@ public class MoveComponentsFromGridLayoutToInnerLayout extends TestBase { @Override public void buttonClick(ClickEvent event) { - vl.requestRepaint(); + vl.markAsDirty(); } }); diff --git a/tests/testbench/com/vaadin/tests/components/splitpanel/SplitPanelExtraScrollbars.java b/tests/testbench/com/vaadin/tests/components/splitpanel/SplitPanelExtraScrollbars.java index 05e10397ac..00012522ca 100644 --- a/tests/testbench/com/vaadin/tests/components/splitpanel/SplitPanelExtraScrollbars.java +++ b/tests/testbench/com/vaadin/tests/components/splitpanel/SplitPanelExtraScrollbars.java @@ -62,8 +62,8 @@ public class SplitPanelExtraScrollbars extends AbstractTestCase implements } // Sending all changes in one repaint triggers the bug - hl.requestRepaint(); - sp.requestRepaint(); + hl.markAsDirty(); + sp.markAsDirty(); } } diff --git a/tests/testbench/com/vaadin/tests/components/table/EditableTableLeak.java b/tests/testbench/com/vaadin/tests/components/table/EditableTableLeak.java index 88c7c76889..26ac23d5be 100644 --- a/tests/testbench/com/vaadin/tests/components/table/EditableTableLeak.java +++ b/tests/testbench/com/vaadin/tests/components/table/EditableTableLeak.java @@ -114,7 +114,7 @@ public class EditableTableLeak extends TestBase { addComponent(new Button("Show size of the table", new ClickListener() { @Override public void buttonClick(ClickEvent event) { - table.requestRepaintAll(); + table.markAsDirtyRecursive(); updateSize(); } diff --git a/tests/testbench/com/vaadin/tests/components/table/TableClickValueChangeInteraction.java b/tests/testbench/com/vaadin/tests/components/table/TableClickValueChangeInteraction.java index 00df9fa3c3..a37cf48579 100644 --- a/tests/testbench/com/vaadin/tests/components/table/TableClickValueChangeInteraction.java +++ b/tests/testbench/com/vaadin/tests/components/table/TableClickValueChangeInteraction.java @@ -63,7 +63,7 @@ public class TableClickValueChangeInteraction extends TestBase { @Override public void itemClick(ItemClickEvent event) { - table.requestRepaint(); + table.markAsDirty(); clickLabel.setValue("Click " + event.getItemId()); } }); diff --git a/tests/testbench/com/vaadin/tests/components/table/TableColumnResizeContentsWidth.java b/tests/testbench/com/vaadin/tests/components/table/TableColumnResizeContentsWidth.java index 1895191cc4..0b695b41c7 100644 --- a/tests/testbench/com/vaadin/tests/components/table/TableColumnResizeContentsWidth.java +++ b/tests/testbench/com/vaadin/tests/components/table/TableColumnResizeContentsWidth.java @@ -34,14 +34,14 @@ public class TableColumnResizeContentsWidth extends TestBase { @Override public void buttonClick(ClickEvent event) { table.setColumnWidth(COL1, table.getColumnWidth(COL1) + 20); - table.requestRepaint(); + table.markAsDirty(); } })); addComponent(new Button("Decrease width", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { table.setColumnWidth(COL1, table.getColumnWidth(COL1) - 40); - table.requestRepaint(); + table.markAsDirty(); } })); } diff --git a/tests/testbench/com/vaadin/tests/components/tree/TreeFiltering.java b/tests/testbench/com/vaadin/tests/components/tree/TreeFiltering.java index bd7984cdeb..be65a335be 100644 --- a/tests/testbench/com/vaadin/tests/components/tree/TreeFiltering.java +++ b/tests/testbench/com/vaadin/tests/components/tree/TreeFiltering.java @@ -51,7 +51,7 @@ public class TreeFiltering extends TestBase { public void valueChange(ValueChangeEvent event) { cont.setIncludeParentsWhenFiltering((Boolean) ((CheckBox) event .getProperty()).getValue()); - ccTree.requestRepaint(); + ccTree.markAsDirty(); } }); addComponent(filterType); diff --git a/tests/testbench/com/vaadin/tests/components/treetable/KeepAllItemsVisible.java b/tests/testbench/com/vaadin/tests/components/treetable/KeepAllItemsVisible.java index 799537f923..f444b781dd 100644 --- a/tests/testbench/com/vaadin/tests/components/treetable/KeepAllItemsVisible.java +++ b/tests/testbench/com/vaadin/tests/components/treetable/KeepAllItemsVisible.java @@ -40,7 +40,7 @@ public class KeepAllItemsVisible extends TestBase implements ExpandListener, @Override public void valueChange(ValueChangeEvent event) { recalculatePageLength(tt); - tt.requestRepaint(); + tt.markAsDirty(); } }); addComponent(tt); diff --git a/tests/testbench/com/vaadin/tests/dd/NotPaintedAcceptSource.java b/tests/testbench/com/vaadin/tests/dd/NotPaintedAcceptSource.java index abe8553267..020a6b56c5 100644 --- a/tests/testbench/com/vaadin/tests/dd/NotPaintedAcceptSource.java +++ b/tests/testbench/com/vaadin/tests/dd/NotPaintedAcceptSource.java @@ -64,7 +64,7 @@ public class NotPaintedAcceptSource extends TestBase { } else { horizontalLayout.replaceComponent(source2, source1); } - target.requestRepaint(); + target.markAsDirty(); } })); diff --git a/tests/testbench/com/vaadin/tests/extensions/HelloWorldExtension.java b/tests/testbench/com/vaadin/tests/extensions/HelloWorldExtension.java index de028cf0c3..60db95827c 100644 --- a/tests/testbench/com/vaadin/tests/extensions/HelloWorldExtension.java +++ b/tests/testbench/com/vaadin/tests/extensions/HelloWorldExtension.java @@ -39,7 +39,6 @@ public class HelloWorldExtension extends AbstractExtension { public void setGreeting(String greeting) { getState().setGreeting(greeting); - requestRepaint(); } public String getGreeting() { diff --git a/tests/testbench/com/vaadin/tests/extensions/SimpleJavaScriptExtensionTest.java b/tests/testbench/com/vaadin/tests/extensions/SimpleJavaScriptExtensionTest.java index b33162d714..7d4f41cfb3 100644 --- a/tests/testbench/com/vaadin/tests/extensions/SimpleJavaScriptExtensionTest.java +++ b/tests/testbench/com/vaadin/tests/extensions/SimpleJavaScriptExtensionTest.java @@ -84,7 +84,6 @@ public class SimpleJavaScriptExtensionTest extends AbstractTestRoot { public void setPrefix(String prefix) { getState().setPrefix(prefix); - requestRepaint(); } public void greetRpc(String message) { diff --git a/tests/testbench/com/vaadin/tests/layouts/CssLayoutCustomCss.java b/tests/testbench/com/vaadin/tests/layouts/CssLayoutCustomCss.java index ed35d39ef7..2f717d2b64 100644 --- a/tests/testbench/com/vaadin/tests/layouts/CssLayoutCustomCss.java +++ b/tests/testbench/com/vaadin/tests/layouts/CssLayoutCustomCss.java @@ -85,7 +85,7 @@ public class CssLayoutCustomCss extends TestBase implements ClickListener { css.remove(b); b.setCaption("not " + b.getCaption()); } - layout.requestRepaint(); + layout.markAsDirty(); } diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a2/ComponentInStateComponent.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a2/ComponentInStateComponent.java index c6109eebcd..061eb7a23e 100644 --- a/tests/testbench/com/vaadin/tests/minitutorials/v7a2/ComponentInStateComponent.java +++ b/tests/testbench/com/vaadin/tests/minitutorials/v7a2/ComponentInStateComponent.java @@ -29,7 +29,6 @@ public class ComponentInStateComponent extends AbstractComponent { public void setOtherComponent(Component component) { getState().setOtherComponent(component); - requestRepaint(); } public Component getOtherComponent() { diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a2/MyComponent.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a2/MyComponent.java index b85d49172b..292ac62125 100644 --- a/tests/testbench/com/vaadin/tests/minitutorials/v7a2/MyComponent.java +++ b/tests/testbench/com/vaadin/tests/minitutorials/v7a2/MyComponent.java @@ -51,7 +51,6 @@ public class MyComponent extends AbstractComponent { public void setText(String text) { getState().setText(text); - requestRepaint(); } public String getText() { diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a2/WidgetContainer.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a2/WidgetContainer.java index 40bb7b68b8..5c519dbdfe 100644 --- a/tests/testbench/com/vaadin/tests/minitutorials/v7a2/WidgetContainer.java +++ b/tests/testbench/com/vaadin/tests/minitutorials/v7a2/WidgetContainer.java @@ -15,14 +15,14 @@ public class WidgetContainer extends AbstractComponentContainer { public void addComponent(Component c) { children.add(c); super.addComponent(c); - requestRepaint(); + markAsDirty(); } @Override public void removeComponent(Component c) { children.remove(c); super.removeComponent(c); - requestRepaint(); + markAsDirty(); } @Override @@ -33,7 +33,7 @@ public class WidgetContainer extends AbstractComponentContainer { children.add(index, newComponent); fireComponentDetachEvent(oldComponent); fireComponentAttachEvent(newComponent); - requestRepaint(); + markAsDirty(); } } diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a3/Flot.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a3/Flot.java index 99e6418fdc..816c60cfe5 100644 --- a/tests/testbench/com/vaadin/tests/minitutorials/v7a3/Flot.java +++ b/tests/testbench/com/vaadin/tests/minitutorials/v7a3/Flot.java @@ -58,8 +58,6 @@ public class Flot extends AbstractJavaScriptComponent { } getState().getSeries().add(pointList); - - requestRepaint(); } public void highlight(int seriesIndex, int dataIndex) { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1834PanelScrolling.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1834PanelScrolling.java index de91b04c1c..e31748ec2f 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1834PanelScrolling.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1834PanelScrolling.java @@ -66,7 +66,7 @@ public class Ticket1834PanelScrolling extends b.addListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { - p.requestRepaint(); + p.markAsDirty(); } }); diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1983.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1983.java index 4deb5020ab..4db82c3371 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1983.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1983.java @@ -107,7 +107,7 @@ public class Ticket1983 extends Application.LegacyApplication { isLong = true; } // Works the same way with or without repaint request - table.requestRepaint(); + table.markAsDirty(); } }); diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2060.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2060.java index 1d7d8bb006..88404b6ef1 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2060.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2060.java @@ -33,9 +33,9 @@ public class Ticket2060 extends Application.LegacyApplication { @Override public void buttonClick(ClickEvent event) { - button1.requestRepaint(); - button2.requestRepaint(); - button3.requestRepaint(); + button1.markAsDirty(); + button2.markAsDirty(); + button3.markAsDirty(); } -- cgit v1.2.3 From f4f3a563942a9264fada9275991b5fd9dce73868 Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Thu, 23 Aug 2012 12:12:29 +0300 Subject: Update test case for #9274 --- .../vaadin/tests/vaadincontext/BoostrapModify.html | 36 ------------------- .../tests/vaadincontext/BoostrapModifyRoot.java | 40 ---------------------- .../tests/vaadincontext/BootstrapModify.html | 36 +++++++++++++++++++ .../tests/vaadincontext/BootstrapModifyRoot.java | 40 ++++++++++++++++++++++ .../vaadincontext/TestAddonContextListener.java | 2 +- 5 files changed, 77 insertions(+), 77 deletions(-) delete mode 100644 tests/testbench/com/vaadin/tests/vaadincontext/BoostrapModify.html delete mode 100644 tests/testbench/com/vaadin/tests/vaadincontext/BoostrapModifyRoot.java create mode 100644 tests/testbench/com/vaadin/tests/vaadincontext/BootstrapModify.html create mode 100644 tests/testbench/com/vaadin/tests/vaadincontext/BootstrapModifyRoot.java diff --git a/tests/testbench/com/vaadin/tests/vaadincontext/BoostrapModify.html b/tests/testbench/com/vaadin/tests/vaadincontext/BoostrapModify.html deleted file mode 100644 index 84c02254b4..0000000000 --- a/tests/testbench/com/vaadin/tests/vaadincontext/BoostrapModify.html +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - -New Test - - - - - - - - - - - - - - - - - - - - - - - - - - -
      New Test
      open/run/com.vaadin.tests.vaadincontext.BoostrapModifyRoot?restartApplication
      assertTextvaadin=runcomvaadintestsvaadincontextBoostrapModifyRoot::/VVerticalLayout[0]/VLabel[0]There should be a static h1 in the HTML of the bootstrap page for this Root
      assertText//div[1]Added by modifyBootstrapPage
      assertText//div[2]Added by modifyBootstrapFragment
      - - diff --git a/tests/testbench/com/vaadin/tests/vaadincontext/BoostrapModifyRoot.java b/tests/testbench/com/vaadin/tests/vaadincontext/BoostrapModifyRoot.java deleted file mode 100644 index ede8d51192..0000000000 --- a/tests/testbench/com/vaadin/tests/vaadincontext/BoostrapModifyRoot.java +++ /dev/null @@ -1,40 +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.tests.vaadincontext; - -import com.vaadin.terminal.WrappedRequest; -import com.vaadin.tests.components.AbstractTestRoot; - -public class BoostrapModifyRoot extends AbstractTestRoot { - - @Override - protected void setup(WrappedRequest request) { - // TODO Auto-generated method stub - - } - - @Override - protected String getTestDescription() { - return "There should be a static h1 in the HTML of the bootstrap page for this Root"; - } - - @Override - protected Integer getTicketNumber() { - return Integer.valueOf(9274); - } - -} diff --git a/tests/testbench/com/vaadin/tests/vaadincontext/BootstrapModify.html b/tests/testbench/com/vaadin/tests/vaadincontext/BootstrapModify.html new file mode 100644 index 0000000000..8888f95d15 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/vaadincontext/BootstrapModify.html @@ -0,0 +1,36 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + + + + + + + + + + + +
      New Test
      open/run/com.vaadin.tests.vaadincontext.BootstrapModifyRoot?restartApplication
      assertTextvaadin=runcomvaadintestsvaadincontextBootstrapModifyRoot::/VVerticalLayout[0]/VLabel[0]There should be two additional divs in the HTML of the bootstrap page for this Root
      assertText//div[1]Added by modifyBootstrapPage
      assertText//div[2]Added by modifyBootstrapFragment
      + + diff --git a/tests/testbench/com/vaadin/tests/vaadincontext/BootstrapModifyRoot.java b/tests/testbench/com/vaadin/tests/vaadincontext/BootstrapModifyRoot.java new file mode 100644 index 0000000000..6c17c3005e --- /dev/null +++ b/tests/testbench/com/vaadin/tests/vaadincontext/BootstrapModifyRoot.java @@ -0,0 +1,40 @@ +/* + * 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.tests.vaadincontext; + +import com.vaadin.terminal.WrappedRequest; +import com.vaadin.tests.components.AbstractTestRoot; + +public class BootstrapModifyRoot extends AbstractTestRoot { + + @Override + protected void setup(WrappedRequest request) { + // TODO Auto-generated method stub + + } + + @Override + protected String getTestDescription() { + return "There should be two additional divs in the HTML of the bootstrap page for this Root"; + } + + @Override + protected Integer getTicketNumber() { + return Integer.valueOf(9274); + } + +} diff --git a/tests/testbench/com/vaadin/tests/vaadincontext/TestAddonContextListener.java b/tests/testbench/com/vaadin/tests/vaadincontext/TestAddonContextListener.java index 4c93d70b36..da058892b4 100644 --- a/tests/testbench/com/vaadin/tests/vaadincontext/TestAddonContextListener.java +++ b/tests/testbench/com/vaadin/tests/vaadincontext/TestAddonContextListener.java @@ -44,7 +44,7 @@ public class TestAddonContextListener implements AddonContextListener { private boolean shouldModify(BootstrapResponse response) { Root root = response.getRoot(); boolean shouldModify = root != null - && root.getClass() == BoostrapModifyRoot.class; + && root.getClass() == BootstrapModifyRoot.class; return shouldModify; } -- cgit v1.2.3 From 52986fdf881260994e5465012af2afd80447b8b6 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Thu, 23 Aug 2012 10:41:24 +0300 Subject: Changed Notification type and position to enum (#9072) --- .../gwt/client/ui/notification/VNotification.java | 36 ++++++------ server/src/com/vaadin/terminal/Page.java | 4 +- server/src/com/vaadin/ui/Notification.java | 66 ++++++++++++++-------- server/src/com/vaadin/ui/Root.java | 9 +-- shared/src/com/vaadin/shared/Position.java | 20 +++++++ .../components/notification/Notifications.java | 4 +- 6 files changed, 90 insertions(+), 49 deletions(-) create mode 100755 shared/src/com/vaadin/shared/Position.java diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/notification/VNotification.java b/client/src/com/vaadin/terminal/gwt/client/ui/notification/VNotification.java index 6e253c9137..b4cea2dc72 100644 --- a/client/src/com/vaadin/terminal/gwt/client/ui/notification/VNotification.java +++ b/client/src/com/vaadin/terminal/gwt/client/ui/notification/VNotification.java @@ -29,6 +29,7 @@ import com.google.gwt.user.client.Event; import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.Widget; +import com.vaadin.shared.Position; import com.vaadin.shared.ui.root.RootConstants; import com.vaadin.terminal.gwt.client.ApplicationConnection; import com.vaadin.terminal.gwt.client.BrowserInfo; @@ -38,13 +39,13 @@ import com.vaadin.terminal.gwt.client.ui.VOverlay; public class VNotification extends VOverlay { - public static final int CENTERED = 1; - public static final int CENTERED_TOP = 2; - public static final int CENTERED_BOTTOM = 3; - public static final int TOP_LEFT = 4; - public static final int TOP_RIGHT = 5; - public static final int BOTTOM_LEFT = 6; - public static final int BOTTOM_RIGHT = 7; + public static final Position CENTERED = Position.MIDDLE_CENTER; + public static final Position CENTERED_TOP = Position.TOP_CENTER; + public static final Position CENTERED_BOTTOM = Position.BOTTOM_CENTER; + public static final Position TOP_LEFT = Position.TOP_LEFT; + public static final Position TOP_RIGHT = Position.TOP_RIGHT; + public static final Position BOTTOM_LEFT = Position.BOTTOM_LEFT; + public static final Position BOTTOM_RIGHT = Position.BOTTOM_RIGHT; public static final int DELAY_FOREVER = -1; public static final int DELAY_NONE = 0; @@ -144,21 +145,21 @@ public class VNotification extends VOverlay { show(CENTERED, style); } - public void show(int position) { + public void show(com.vaadin.shared.Position position) { show(position, null); } - public void show(Widget widget, int position, String style) { + public void show(Widget widget, Position position, String style) { setWidget(widget); show(position, style); } - public void show(String html, int position, String style) { + public void show(String html, Position position, String style) { setWidget(new HTML(html)); show(position, style); } - public void show(int position, String style) { + public void show(Position position, String style) { setOpacity(getElement(), startOpacity); if (style != null) { temporaryStyle = style; @@ -231,7 +232,7 @@ public class VNotification extends VOverlay { } } - public void setPosition(int position) { + public void setPosition(com.vaadin.shared.Position position) { final Element el = getElement(); DOM.setStyleAttribute(el, "top", ""); DOM.setStyleAttribute(el, "left", ""); @@ -260,17 +261,17 @@ public class VNotification extends VOverlay { DOM.setStyleAttribute(el, "bottom", "0px"); DOM.setStyleAttribute(el, "left", "0px"); break; - case CENTERED_TOP: + case TOP_CENTER: center(); DOM.setStyleAttribute(el, "top", "0px"); break; - case CENTERED_BOTTOM: + case BOTTOM_CENTER: center(); DOM.setStyleAttribute(el, "top", ""); DOM.setStyleAttribute(el, "bottom", "0px"); break; default: - case CENTERED: + case MIDDLE_CENTER: center(); break; } @@ -417,8 +418,11 @@ public class VNotification extends VOverlay { .hasAttribute(RootConstants.ATTRIBUTE_NOTIFICATION_STYLE) ? notification .getStringAttribute(RootConstants.ATTRIBUTE_NOTIFICATION_STYLE) : null; - final int position = notification + + final int pos = notification .getIntAttribute(RootConstants.ATTRIBUTE_NOTIFICATION_POSITION); + Position position = Position.values()[pos]; + final int delay = notification .getIntAttribute(RootConstants.ATTRIBUTE_NOTIFICATION_DELAY); createNotification(delay).show(html, position, style); diff --git a/server/src/com/vaadin/terminal/Page.java b/server/src/com/vaadin/terminal/Page.java index d41d500bb0..41ab8cc8b6 100644 --- a/server/src/com/vaadin/terminal/Page.java +++ b/server/src/com/vaadin/terminal/Page.java @@ -493,8 +493,8 @@ public class Page implements Serializable { true); } target.addAttribute( - RootConstants.ATTRIBUTE_NOTIFICATION_POSITION, - n.getPosition()); + RootConstants.ATTRIBUTE_NOTIFICATION_POSITION, n + .getPosition().ordinal()); target.addAttribute(RootConstants.ATTRIBUTE_NOTIFICATION_DELAY, n.getDelayMsec()); if (n.getStyleName() != null) { diff --git a/server/src/com/vaadin/ui/Notification.java b/server/src/com/vaadin/ui/Notification.java index d408889519..22ad31dffe 100644 --- a/server/src/com/vaadin/ui/Notification.java +++ b/server/src/com/vaadin/ui/Notification.java @@ -18,6 +18,7 @@ package com.vaadin.ui; import java.io.Serializable; +import com.vaadin.shared.Position; import com.vaadin.terminal.Page; import com.vaadin.terminal.Resource; @@ -61,18 +62,33 @@ import com.vaadin.terminal.Resource; * */ public class Notification implements Serializable { - public static final int TYPE_HUMANIZED_MESSAGE = 1; - public static final int TYPE_WARNING_MESSAGE = 2; - public static final int TYPE_ERROR_MESSAGE = 3; - public static final int TYPE_TRAY_NOTIFICATION = 4; - - public static final int POSITION_CENTERED = 1; - public static final int POSITION_CENTERED_TOP = 2; - public static final int POSITION_CENTERED_BOTTOM = 3; - public static final int POSITION_TOP_LEFT = 4; - public static final int POSITION_TOP_RIGHT = 5; - public static final int POSITION_BOTTOM_LEFT = 6; - public static final int POSITION_BOTTOM_RIGHT = 7; + public enum Type { + HUMANIZED_MESSAGE, WARNING_MESSAGE, ERROR_MESSAGE, TRAY_NOTIFICATION; + } + + @Deprecated + public static final Type TYPE_HUMANIZED_MESSAGE = Type.HUMANIZED_MESSAGE; + @Deprecated + public static final Type TYPE_WARNING_MESSAGE = Type.WARNING_MESSAGE; + @Deprecated + public static final Type TYPE_ERROR_MESSAGE = Type.ERROR_MESSAGE; + @Deprecated + public static final Type TYPE_TRAY_NOTIFICATION = Type.TRAY_NOTIFICATION; + + @Deprecated + public static final Position POSITION_CENTERED = Position.MIDDLE_CENTER; + @Deprecated + public static final Position POSITION_CENTERED_TOP = Position.TOP_CENTER; + @Deprecated + public static final Position POSITION_CENTERED_BOTTOM = Position.BOTTOM_CENTER; + @Deprecated + public static final Position POSITION_TOP_LEFT = Position.TOP_LEFT; + @Deprecated + public static final Position POSITION_TOP_RIGHT = Position.TOP_RIGHT; + @Deprecated + public static final Position POSITION_BOTTOM_LEFT = Position.BOTTOM_LEFT; + @Deprecated + public static final Position POSITION_BOTTOM_RIGHT = Position.BOTTOM_RIGHT; public static final int DELAY_FOREVER = -1; public static final int DELAY_NONE = 0; @@ -80,7 +96,7 @@ public class Notification implements Serializable { private String caption; private String description; private Resource icon; - private int position = POSITION_CENTERED; + private Position position = Position.MIDDLE_CENTER; private int delayMsec = 0; private String styleName; private boolean htmlContentAllowed; @@ -107,7 +123,7 @@ public class Notification implements Serializable { * @param type * The type of message */ - public Notification(String caption, int type) { + public Notification(String caption, Type type) { this(caption, null, type); } @@ -141,7 +157,7 @@ public class Notification implements Serializable { * @param type * The type of message */ - public Notification(String caption, String description, int type) { + public Notification(String caption, String description, Type type) { this(caption, description, type, false); } @@ -161,7 +177,7 @@ public class Notification implements Serializable { * Whether html in the caption and description should be * displayed as html or as plain text */ - public Notification(String caption, String description, int type, + public Notification(String caption, String description, Type type, boolean htmlContentAllowed) { this.caption = caption; this.description = description; @@ -169,22 +185,22 @@ public class Notification implements Serializable { setType(type); } - private void setType(int type) { + private void setType(Type type) { switch (type) { - case TYPE_WARNING_MESSAGE: + case WARNING_MESSAGE: delayMsec = 1500; styleName = "warning"; break; - case TYPE_ERROR_MESSAGE: + case ERROR_MESSAGE: delayMsec = -1; styleName = "error"; break; - case TYPE_TRAY_NOTIFICATION: + case TRAY_NOTIFICATION: delayMsec = 3000; - position = POSITION_BOTTOM_RIGHT; + position = Position.BOTTOM_RIGHT; styleName = "tray"; - case TYPE_HUMANIZED_MESSAGE: + case HUMANIZED_MESSAGE: default: break; } @@ -233,7 +249,7 @@ public class Notification implements Serializable { * * @return The position */ - public int getPosition() { + public Position getPosition() { return position; } @@ -243,7 +259,7 @@ public class Notification implements Serializable { * @param position * The desired notification position */ - public void setPosition(int position) { + public void setPosition(Position position) { this.position = position; } @@ -373,7 +389,7 @@ public class Notification implements Serializable { * @param type * The message type */ - public static void show(String caption, int type) { + public static void show(String caption, Type type) { new Notification(caption, type).show(Page.getCurrent()); } } \ No newline at end of file diff --git a/server/src/com/vaadin/ui/Root.java b/server/src/com/vaadin/ui/Root.java index 35517044c0..67f2e04a65 100644 --- a/server/src/com/vaadin/ui/Root.java +++ b/server/src/com/vaadin/ui/Root.java @@ -1124,7 +1124,7 @@ public abstract class Root extends AbstractComponentContainer implements * Notification.show does not allow HTML. */ @Deprecated - public void showNotification(String caption, int type) { + public void showNotification(String caption, Notification.Type type) { Notification notification = new Notification(caption, type); notification.setHtmlContentAllowed(true);// Backwards compatibility getPage().showNotification(notification); @@ -1179,7 +1179,8 @@ public abstract class Root extends AbstractComponentContainer implements * be aware that HTML by default not allowed. */ @Deprecated - public void showNotification(String caption, String description, int type) { + public void showNotification(String caption, String description, + Notification.Type type) { Notification notification = new Notification(caption, description, type); notification.setHtmlContentAllowed(true);// Backwards compatibility getPage().showNotification(notification); @@ -1210,8 +1211,8 @@ public abstract class Root extends AbstractComponentContainer implements * @deprecated As of 7.0, use new Notification(...).show(Page). */ @Deprecated - public void showNotification(String caption, String description, int type, - boolean htmlContentAllowed) { + public void showNotification(String caption, String description, + Notification.Type type, boolean htmlContentAllowed) { getPage() .showNotification( new Notification(caption, description, type, diff --git a/shared/src/com/vaadin/shared/Position.java b/shared/src/com/vaadin/shared/Position.java new file mode 100755 index 0000000000..89d6a4261c --- /dev/null +++ b/shared/src/com/vaadin/shared/Position.java @@ -0,0 +1,20 @@ +/* + * 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.shared; + +public enum Position { + TOP_LEFT, TOP_CENTER, TOP_RIGHT, MIDDLE_LEFT, MIDDLE_CENTER, MIDDLE_RIGHT, BOTTOM_LEFT, BOTTOM_CENTER, BOTTOM_RIGHT; +} diff --git a/tests/testbench/com/vaadin/tests/components/notification/Notifications.java b/tests/testbench/com/vaadin/tests/components/notification/Notifications.java index ab632a2a57..97e038dc1a 100644 --- a/tests/testbench/com/vaadin/tests/components/notification/Notifications.java +++ b/tests/testbench/com/vaadin/tests/components/notification/Notifications.java @@ -7,6 +7,7 @@ import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.NativeSelect; import com.vaadin.ui.Notification; +import com.vaadin.ui.Notification.Type; import com.vaadin.ui.TextArea; public class Notifications extends TestBase implements ClickListener { @@ -52,8 +53,7 @@ public class Notifications extends TestBase implements ClickListener { @Override public void buttonClick(ClickEvent event) { - Notification n = new Notification(tf.getValue(), - (Integer) type.getValue()); + Notification n = new Notification(tf.getValue(), (Type) type.getValue()); n.setHtmlContentAllowed(true); n.show(Page.getCurrent()); } -- cgit v1.2.3 From 38ffd4a097094a01c35fbd5b79563e6c8ea02e92 Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Fri, 24 Aug 2012 11:25:05 +0300 Subject: Make it possible to delegate state changes to widget (#9297) --- .../ConnectorBundleLoaderFactory.java | 20 ++++++- .../widgetsetutils/metadata/ConnectorBundle.java | 20 +++++++ .../gwt/widgetsetutils/metadata/FieldProperty.java | 9 ++++ .../widgetsetutils/metadata/MethodProperty.java | 6 +++ .../gwt/widgetsetutils/metadata/Property.java | 5 ++ .../gwt/widgetsetutils/metadata/TypeVisitor.java | 3 +- .../widgetsetutils/metadata/WidgetInitVisitor.java | 45 ++++++++++++++-- .../terminal/gwt/client/ApplicationConnection.java | 61 ++++++++++++++++++++++ .../terminal/gwt/client/metadata/Property.java | 9 ++-- .../gwt/client/metadata/TypeDataStore.java | 6 +++ .../terminal/gwt/client/ui/MediaBaseConnector.java | 3 -- .../ui/splitpanel/AbstractSplitPanelConnector.java | 3 -- .../gwt/client/ui/textarea/TextAreaConnector.java | 9 ---- .../shared/annotations/DelegateToWidget.java | 25 +++++++++ .../com/vaadin/shared/ui/AbstractMediaState.java | 4 ++ .../ui/splitpanel/AbstractSplitPanelState.java | 3 ++ .../vaadin/shared/ui/textarea/TextAreaState.java | 3 ++ .../tests/serialization/DelegateToWidgetTest.html | 26 +++++++++ .../tests/serialization/DelegateToWidgetTest.java | 42 +++++++++++++++ .../vaadin/tests/widgetset/TestingWidgetSet.java | 21 ++++++++ .../tests/widgetset/client/DelegateConnector.java | 34 ++++++++++++ .../tests/widgetset/client/DelegateState.java | 50 ++++++++++++++++++ .../tests/widgetset/client/DelegateWidget.java | 50 ++++++++++++++++++ .../server/DelegateToWidgetComponent.java | 35 +++++++++++++ 24 files changed, 465 insertions(+), 27 deletions(-) create mode 100644 shared/src/com/vaadin/shared/annotations/DelegateToWidget.java create mode 100644 tests/testbench/com/vaadin/tests/serialization/DelegateToWidgetTest.html create mode 100644 tests/testbench/com/vaadin/tests/serialization/DelegateToWidgetTest.java create mode 100644 tests/testbench/com/vaadin/tests/widgetset/TestingWidgetSet.java create mode 100644 tests/testbench/com/vaadin/tests/widgetset/client/DelegateConnector.java create mode 100644 tests/testbench/com/vaadin/tests/widgetset/client/DelegateState.java create mode 100644 tests/testbench/com/vaadin/tests/widgetset/client/DelegateWidget.java create mode 100644 tests/testbench/com/vaadin/tests/widgetset/server/DelegateToWidgetComponent.java diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorBundleLoaderFactory.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorBundleLoaderFactory.java index a2e61947e8..752f290a42 100644 --- a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorBundleLoaderFactory.java +++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/ConnectorBundleLoaderFactory.java @@ -30,6 +30,7 @@ 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.shared.annotations.Delayed; +import com.vaadin.shared.annotations.DelegateToWidget; import com.vaadin.shared.communication.ClientRpc; import com.vaadin.shared.communication.ServerRpc; import com.vaadin.shared.ui.Connect; @@ -182,6 +183,18 @@ public class ConnectorBundleLoaderFactory extends Generator { writeSetters(logger, w, bundle); writeGetters(logger, w, bundle); writeSerializers(logger, w, bundle); + writeDelegateToWidget(logger, w, bundle); + } + + private void writeDelegateToWidget(TreeLogger logger, SourceWriter w, + ConnectorBundle bundle) { + Set needsDelegateToWidget = bundle.getNeedsDelegateToWidget(); + for (Property property : needsDelegateToWidget) { + w.println("store.setDelegateToWidget(%s, \"%s\", \"%s\");", + getClassLiteralString(property.getBeanType()), + property.getName(), + property.getAnnotation(DelegateToWidget.class).value()); + } } private void writeSerializers(TreeLogger logger, SourceWriter w, @@ -535,8 +548,11 @@ public class ConnectorBundleLoaderFactory extends Generator { } public static void writeClassLiteral(SourceWriter w, JType type) { - w.print(type.getQualifiedSourceName()); - w.print(".class"); + w.print(getClassLiteralString(type)); + } + + public static String getClassLiteralString(JType type) { + return type.getQualifiedSourceName() + ".class"; } private void writeIdentifiers(SourceWriter w, ConnectorBundle bundle) { diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ConnectorBundle.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ConnectorBundle.java index 7515124a5a..1db551ed9a 100644 --- a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ConnectorBundle.java +++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/ConnectorBundle.java @@ -61,6 +61,7 @@ public class ConnectorBundle { private final Set needsSetter = new HashSet(); private final Set needsType = new HashSet(); private final Set needsGetter = new HashSet(); + private final Set needsDelegateToWidget = new HashSet(); private ConnectorBundle(String name, ConnectorBundle previousBundle, Collection visitors, @@ -585,4 +586,23 @@ public class ConnectorBundle { && previousBundle.hasSserializeSupport(type); } } + + public void setNeedsDelegateToWidget(Property property) { + if (!isNeedsDelegateToWidget(property)) { + needsDelegateToWidget.add(property); + } + } + + private boolean isNeedsDelegateToWidget(Property property) { + if (needsDelegateToWidget.contains(property)) { + return true; + } else { + return previousBundle != null + && previousBundle.isNeedsDelegateToWidget(property); + } + } + + public Set getNeedsDelegateToWidget() { + return Collections.unmodifiableSet(needsDelegateToWidget); + } } \ No newline at end of file diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/FieldProperty.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/FieldProperty.java index 31555cc30b..c4c2a50e1c 100644 --- a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/FieldProperty.java +++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/FieldProperty.java @@ -16,6 +16,7 @@ package com.vaadin.terminal.gwt.widgetsetutils.metadata; +import java.lang.annotation.Annotation; import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; @@ -29,8 +30,11 @@ import com.google.gwt.user.rebind.SourceWriter; public class FieldProperty extends Property { + private final JField field; + private FieldProperty(JClassType beanType, JField field) { super(field.getName(), beanType, field.getType()); + this.field = field; } @Override @@ -74,4 +78,9 @@ public class FieldProperty extends Property { return fields; } + @Override + public T getAnnotation(Class annotationClass) { + return field.getAnnotation(annotationClass); + } + } diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/MethodProperty.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/MethodProperty.java index f422205175..431ead7f96 100644 --- a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/MethodProperty.java +++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/MethodProperty.java @@ -16,6 +16,7 @@ package com.vaadin.terminal.gwt.widgetsetutils.metadata; +import java.lang.annotation.Annotation; import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -121,4 +122,9 @@ public class MethodProperty extends Property { + baseName.substring(1); } + @Override + public T getAnnotation(Class annotationClass) { + return setter.getAnnotation(annotationClass); + } + } diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/Property.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/Property.java index 1714489db5..5ef0293688 100644 --- a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/Property.java +++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/Property.java @@ -16,6 +16,8 @@ package com.vaadin.terminal.gwt.widgetsetutils.metadata; +import java.lang.annotation.Annotation; + import com.google.gwt.core.ext.TreeLogger; import com.google.gwt.core.ext.typeinfo.JClassType; import com.google.gwt.core.ext.typeinfo.JPrimitiveType; @@ -81,4 +83,7 @@ public abstract class Property { + getName().hashCode(); } + public abstract T getAnnotation( + Class annotationClass); + } diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/TypeVisitor.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/TypeVisitor.java index 976eb6417a..cda849f564 100644 --- a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/TypeVisitor.java +++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/TypeVisitor.java @@ -5,6 +5,7 @@ package com.vaadin.terminal.gwt.widgetsetutils.metadata; import com.google.gwt.core.ext.TreeLogger; +import com.google.gwt.core.ext.UnableToCompleteException; import com.google.gwt.core.ext.typeinfo.JClassType; import com.google.gwt.core.ext.typeinfo.JMethod; import com.google.gwt.core.ext.typeinfo.JType; @@ -17,7 +18,7 @@ public abstract class TypeVisitor { } public void visitConnector(TreeLogger logger, JClassType type, - ConnectorBundle bundle) { + ConnectorBundle bundle) throws UnableToCompleteException { // Default does nothing } diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/WidgetInitVisitor.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/WidgetInitVisitor.java index 4d63703151..2b0e3e1f61 100644 --- a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/WidgetInitVisitor.java +++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/metadata/WidgetInitVisitor.java @@ -4,17 +4,21 @@ package com.vaadin.terminal.gwt.widgetsetutils.metadata; +import java.util.Collection; + 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.JMethod; -import com.google.gwt.core.ext.typeinfo.JType; +import com.vaadin.shared.annotations.DelegateToWidget; import com.vaadin.terminal.gwt.client.ui.AbstractComponentConnector; public class WidgetInitVisitor extends TypeVisitor { @Override public void visitConnector(TreeLogger logger, JClassType type, - ConnectorBundle bundle) { + ConnectorBundle bundle) throws UnableToCompleteException { if (ConnectorBundle.isConnectedComponentConnector(type)) { JClassType createWidgetClass = findInheritedMethod(type, "createWidget").getEnclosingType(); @@ -29,8 +33,41 @@ public class WidgetInitVisitor extends TypeVisitor { JMethod getWidget = findInheritedMethod(type, "getWidget"); bundle.setNeedsReturnType(type, getWidget); - JType widgetType = getWidget.getReturnType(); - bundle.setNeedsGwtConstructor(widgetType.isClass()); + JClassType widgetType = getWidget.getReturnType().isClass(); + bundle.setNeedsGwtConstructor(widgetType); + + JMethod getState = findInheritedMethod(type, "getState"); + JClassType stateType = getState.getReturnType().isClass(); + + Collection properties = bundle.getProperties(stateType); + for (Property property : properties) { + DelegateToWidget delegateToWidget = property + .getAnnotation(DelegateToWidget.class); + if (delegateToWidget != null) { + bundle.setNeedsDelegateToWidget(property); + String methodName = DelegateToWidget.Helper + .getDelegateTarget(property.getName(), + delegateToWidget.value()); + JMethod delegatedSetter = findInheritedMethod(widgetType, + methodName, property.getPropertyType()); + if (delegatedSetter == null) { + logger.log( + Type.ERROR, + widgetType.getName() + + "." + + methodName + + "(" + + property.getPropertyType() + .getSimpleSourceName() + + ") required by @DelegateToWidget for " + + stateType.getName() + "." + + property.getName() + + " can not be found."); + throw new UnableToCompleteException(); + } + bundle.setNeedsInvoker(widgetType, delegatedSetter); + } + } } } } diff --git a/client/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java b/client/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java index 58357ae3fc..10f63d0f51 100644 --- a/client/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java +++ b/client/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java @@ -68,7 +68,10 @@ import com.vaadin.terminal.gwt.client.communication.RpcManager; import com.vaadin.terminal.gwt.client.communication.StateChangeEvent; import com.vaadin.terminal.gwt.client.extensions.AbstractExtensionConnector; import com.vaadin.terminal.gwt.client.metadata.ConnectorBundleLoader; +import com.vaadin.terminal.gwt.client.metadata.NoDataException; +import com.vaadin.terminal.gwt.client.metadata.Property; import com.vaadin.terminal.gwt.client.metadata.Type; +import com.vaadin.terminal.gwt.client.metadata.TypeData; import com.vaadin.terminal.gwt.client.ui.AbstractComponentConnector; import com.vaadin.terminal.gwt.client.ui.VContextMenu; import com.vaadin.terminal.gwt.client.ui.dd.VDragAndDropManager; @@ -1148,6 +1151,8 @@ public class ApplicationConnection { " * Hierarchy state change event processing completed", 10); + delegateToWidget(pendingStateChangeEvents); + // Fire state change events. sendStateChangeEvents(pendingStateChangeEvents); @@ -1264,6 +1269,62 @@ public class ApplicationConnection { } + private void delegateToWidget( + Collection pendingStateChangeEvents) { + VConsole.log(" * Running @DelegateToWidget"); + + for (StateChangeEvent sce : pendingStateChangeEvents) { + ServerConnector connector = sce.getConnector(); + if (connector instanceof ComponentConnector) { + ComponentConnector component = (ComponentConnector) connector; + Type type = TypeData.getType(component.getClass()); + + Type stateType; + try { + stateType = type.getMethod("getState") + .getReturnType(); + } catch (NoDataException e) { + throw new RuntimeException( + "Can not find the state type for " + + type.getSignature(), e); + } + + Set changedProperties = sce + .getChangedProperties(); + for (String propertyName : changedProperties) { + Property property = stateType + .getProperty(propertyName); + String method = property + .getDelegateToWidgetMethodName(); + if (method != null) { + doDelegateToWidget(component, property, method); + } + } + + } + } + } + + private void doDelegateToWidget(ComponentConnector component, + Property property, String methodName) { + Type type = TypeData.getType(component.getClass()); + try { + Type widgetType = type.getMethod("getWidget") + .getReturnType(); + Widget widget = component.getWidget(); + + Object propertyValue = property.getValue(component + .getState()); + + widgetType.getMethod(methodName).invoke(widget, + propertyValue); + } catch (NoDataException e) { + throw new RuntimeException( + "Missing data needed to invoke @DelegateToWidget for " + + Util.getSimpleName(component), e); + } + } + /** * Sends the state change events created while updating the state * information. diff --git a/client/src/com/vaadin/terminal/gwt/client/metadata/Property.java b/client/src/com/vaadin/terminal/gwt/client/metadata/Property.java index 082d032e64..69e41ce75d 100644 --- a/client/src/com/vaadin/terminal/gwt/client/metadata/Property.java +++ b/client/src/com/vaadin/terminal/gwt/client/metadata/Property.java @@ -4,6 +4,8 @@ package com.vaadin.terminal.gwt.client.metadata; +import com.vaadin.shared.annotations.DelegateToWidget; + public class Property { private final Type bean; private final String name; @@ -21,15 +23,12 @@ public class Property { TypeDataStore.getSetter(this).invoke(bean, value); } - public String getDelegateToWidgetMethod() { + public String getDelegateToWidgetMethodName() { String value = TypeDataStore.getDelegateToWidget(this); if (value == null) { return null; - } else if (value.isEmpty()) { - return "set" + Character.toUpperCase(value.charAt(0)) - + value.substring(1); } else { - return value; + return DelegateToWidget.Helper.getDelegateTarget(getName(), value); } } diff --git a/client/src/com/vaadin/terminal/gwt/client/metadata/TypeDataStore.java b/client/src/com/vaadin/terminal/gwt/client/metadata/TypeDataStore.java index 55740f69da..9c19410c88 100644 --- a/client/src/com/vaadin/terminal/gwt/client/metadata/TypeDataStore.java +++ b/client/src/com/vaadin/terminal/gwt/client/metadata/TypeDataStore.java @@ -101,6 +101,12 @@ public class TypeDataStore { return get().delegateToWidget.get(property); } + public void setDelegateToWidget(Class clazz, String propertyName, + String delegateValue) { + delegateToWidget.put(new Property(getType(clazz), propertyName), + delegateValue); + } + public void setReturnType(Class type, String methodName, Type returnType) { returnTypes.put(new Method(getType(type), methodName), returnType); } diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/MediaBaseConnector.java b/client/src/com/vaadin/terminal/gwt/client/ui/MediaBaseConnector.java index 2f52971aeb..33d97f4ed8 100644 --- a/client/src/com/vaadin/terminal/gwt/client/ui/MediaBaseConnector.java +++ b/client/src/com/vaadin/terminal/gwt/client/ui/MediaBaseConnector.java @@ -49,9 +49,6 @@ public abstract class MediaBaseConnector extends AbstractComponentConnector { public void onStateChanged(StateChangeEvent stateChangeEvent) { super.onStateChanged(stateChangeEvent); - getWidget().setControls(getState().isShowControls()); - getWidget().setAutoplay(getState().isAutoplay()); - getWidget().setMuted(getState().isMuted()); for (int i = 0; i < getState().getSources().size(); i++) { URLReference source = getState().getSources().get(i); String sourceType = getState().getSourceTypes().get(i); diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/splitpanel/AbstractSplitPanelConnector.java b/client/src/com/vaadin/terminal/gwt/client/ui/splitpanel/AbstractSplitPanelConnector.java index 9f4df02380..912f9a7c83 100644 --- a/client/src/com/vaadin/terminal/gwt/client/ui/splitpanel/AbstractSplitPanelConnector.java +++ b/client/src/com/vaadin/terminal/gwt/client/ui/splitpanel/AbstractSplitPanelConnector.java @@ -138,9 +138,6 @@ public abstract class AbstractSplitPanelConnector extends // Splitter updates SplitterState splitterState = getState().getSplitterState(); - getWidget().setLocked(splitterState.isLocked()); - getWidget().setPositionReversed(splitterState.isPositionReversed()); - getWidget().setStylenames(); getWidget().minimumPosition = splitterState.getMinPosition() diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/textarea/TextAreaConnector.java b/client/src/com/vaadin/terminal/gwt/client/ui/textarea/TextAreaConnector.java index 5fb7f97044..d5abed4fa9 100644 --- a/client/src/com/vaadin/terminal/gwt/client/ui/textarea/TextAreaConnector.java +++ b/client/src/com/vaadin/terminal/gwt/client/ui/textarea/TextAreaConnector.java @@ -18,7 +18,6 @@ package com.vaadin.terminal.gwt.client.ui.textarea; import com.vaadin.shared.ui.Connect; import com.vaadin.shared.ui.textarea.TextAreaState; -import com.vaadin.terminal.gwt.client.communication.StateChangeEvent; import com.vaadin.terminal.gwt.client.ui.textfield.TextFieldConnector; import com.vaadin.ui.TextArea; @@ -30,14 +29,6 @@ public class TextAreaConnector extends TextFieldConnector { return (TextAreaState) super.getState(); } - @Override - public void onStateChanged(StateChangeEvent stateChangeEvent) { - super.onStateChanged(stateChangeEvent); - - getWidget().setRows(getState().getRows()); - getWidget().setWordwrap(getState().isWordwrap()); - } - @Override public VTextArea getWidget() { return (VTextArea) super.getWidget(); diff --git a/shared/src/com/vaadin/shared/annotations/DelegateToWidget.java b/shared/src/com/vaadin/shared/annotations/DelegateToWidget.java new file mode 100644 index 0000000000..0ac16ecea9 --- /dev/null +++ b/shared/src/com/vaadin/shared/annotations/DelegateToWidget.java @@ -0,0 +1,25 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ + +package com.vaadin.shared.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; + +@Target({ ElementType.METHOD, ElementType.FIELD }) +public @interface DelegateToWidget { + public String value() default ""; + + public static class Helper { + public static String getDelegateTarget(String propertyName, + String annotationValue) { + String name = annotationValue; + if (name.isEmpty()) { + name = "set" + Character.toUpperCase(propertyName.charAt(0)) + + propertyName.substring(1); + } + return name; + } + } +} diff --git a/shared/src/com/vaadin/shared/ui/AbstractMediaState.java b/shared/src/com/vaadin/shared/ui/AbstractMediaState.java index 2731529caf..80d41dd797 100644 --- a/shared/src/com/vaadin/shared/ui/AbstractMediaState.java +++ b/shared/src/com/vaadin/shared/ui/AbstractMediaState.java @@ -19,6 +19,7 @@ import java.util.ArrayList; import java.util.List; import com.vaadin.shared.ComponentState; +import com.vaadin.shared.annotations.DelegateToWidget; import com.vaadin.shared.communication.URLReference; public class AbstractMediaState extends ComponentState { @@ -39,6 +40,7 @@ public class AbstractMediaState extends ComponentState { return showControls; } + @DelegateToWidget("setControls") public void setShowControls(boolean showControls) { this.showControls = showControls; } @@ -63,6 +65,7 @@ public class AbstractMediaState extends ComponentState { return autoplay; } + @DelegateToWidget public void setAutoplay(boolean autoplay) { this.autoplay = autoplay; } @@ -71,6 +74,7 @@ public class AbstractMediaState extends ComponentState { return muted; } + @DelegateToWidget public void setMuted(boolean muted) { this.muted = muted; } diff --git a/shared/src/com/vaadin/shared/ui/splitpanel/AbstractSplitPanelState.java b/shared/src/com/vaadin/shared/ui/splitpanel/AbstractSplitPanelState.java index 46eb851edd..71f789b70d 100644 --- a/shared/src/com/vaadin/shared/ui/splitpanel/AbstractSplitPanelState.java +++ b/shared/src/com/vaadin/shared/ui/splitpanel/AbstractSplitPanelState.java @@ -19,6 +19,7 @@ import java.io.Serializable; import com.vaadin.shared.ComponentState; import com.vaadin.shared.Connector; +import com.vaadin.shared.annotations.DelegateToWidget; public class AbstractSplitPanelState extends ComponentState { @@ -120,6 +121,7 @@ public class AbstractSplitPanelState extends ComponentState { return positionReversed; } + @DelegateToWidget public void setPositionReversed(boolean positionReversed) { this.positionReversed = positionReversed; } @@ -128,6 +130,7 @@ public class AbstractSplitPanelState extends ComponentState { return locked; } + @DelegateToWidget public void setLocked(boolean locked) { this.locked = locked; } diff --git a/shared/src/com/vaadin/shared/ui/textarea/TextAreaState.java b/shared/src/com/vaadin/shared/ui/textarea/TextAreaState.java index 31cec77554..50dc1393a3 100644 --- a/shared/src/com/vaadin/shared/ui/textarea/TextAreaState.java +++ b/shared/src/com/vaadin/shared/ui/textarea/TextAreaState.java @@ -15,6 +15,7 @@ */ package com.vaadin.shared.ui.textarea; +import com.vaadin.shared.annotations.DelegateToWidget; import com.vaadin.shared.ui.textfield.AbstractTextFieldState; public class TextAreaState extends AbstractTextFieldState { @@ -33,6 +34,7 @@ public class TextAreaState extends AbstractTextFieldState { return rows; } + @DelegateToWidget public void setRows(int rows) { this.rows = rows; } @@ -41,6 +43,7 @@ public class TextAreaState extends AbstractTextFieldState { return wordwrap; } + @DelegateToWidget public void setWordwrap(boolean wordwrap) { this.wordwrap = wordwrap; } diff --git a/tests/testbench/com/vaadin/tests/serialization/DelegateToWidgetTest.html b/tests/testbench/com/vaadin/tests/serialization/DelegateToWidgetTest.html new file mode 100644 index 0000000000..12228eb9f0 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/serialization/DelegateToWidgetTest.html @@ -0,0 +1,26 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + +
      New Test
      open/run/com.vaadin.tests.serialization.DelegateToWidgetTest?restartApplication
      assertTextvaadin=runcomvaadintestsserializationDelegateToWidgetTest::/VVerticalLayout[0]/VVerticalLayout[0]/DelegateWidget[0]My String
      42
      true
      3.141592653589793
      + + diff --git a/tests/testbench/com/vaadin/tests/serialization/DelegateToWidgetTest.java b/tests/testbench/com/vaadin/tests/serialization/DelegateToWidgetTest.java new file mode 100644 index 0000000000..54170c880f --- /dev/null +++ b/tests/testbench/com/vaadin/tests/serialization/DelegateToWidgetTest.java @@ -0,0 +1,42 @@ +/* + * 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.tests.serialization; + +import com.vaadin.annotations.Widgetset; +import com.vaadin.terminal.WrappedRequest; +import com.vaadin.tests.components.AbstractTestRoot; +import com.vaadin.tests.widgetset.TestingWidgetSet; +import com.vaadin.tests.widgetset.server.DelegateToWidgetComponent; + +@Widgetset(TestingWidgetSet.NAME) +public class DelegateToWidgetTest extends AbstractTestRoot { + @Override + protected void setup(WrappedRequest request) { + addComponent(new DelegateToWidgetComponent()); + } + + @Override + protected String getTestDescription() { + return "Verifies that @DelegateToWidget has the desired effect"; + } + + @Override + protected Integer getTicketNumber() { + return Integer.valueOf(9297); + } + +} diff --git a/tests/testbench/com/vaadin/tests/widgetset/TestingWidgetSet.java b/tests/testbench/com/vaadin/tests/widgetset/TestingWidgetSet.java new file mode 100644 index 0000000000..0464a53a95 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/widgetset/TestingWidgetSet.java @@ -0,0 +1,21 @@ +/* + * 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.tests.widgetset; + +public class TestingWidgetSet { + public static final String NAME = "com.vaadin.tests.widgetset.TestingWidgetSet"; +} diff --git a/tests/testbench/com/vaadin/tests/widgetset/client/DelegateConnector.java b/tests/testbench/com/vaadin/tests/widgetset/client/DelegateConnector.java new file mode 100644 index 0000000000..c711be232f --- /dev/null +++ b/tests/testbench/com/vaadin/tests/widgetset/client/DelegateConnector.java @@ -0,0 +1,34 @@ +/* + * 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.tests.widgetset.client; + +import com.vaadin.shared.ui.Connect; +import com.vaadin.terminal.gwt.client.ui.AbstractComponentConnector; +import com.vaadin.tests.widgetset.server.DelegateToWidgetComponent; + +@Connect(DelegateToWidgetComponent.class) +public class DelegateConnector extends AbstractComponentConnector { + @Override + public DelegateWidget getWidget() { + return (DelegateWidget) super.getWidget(); + } + + @Override + public DelegateState getState() { + return (DelegateState) super.getState(); + } +} diff --git a/tests/testbench/com/vaadin/tests/widgetset/client/DelegateState.java b/tests/testbench/com/vaadin/tests/widgetset/client/DelegateState.java new file mode 100644 index 0000000000..e9ac8a1e61 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/widgetset/client/DelegateState.java @@ -0,0 +1,50 @@ +/* + * 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.tests.widgetset.client; + +import com.vaadin.shared.ComponentState; +import com.vaadin.shared.annotations.DelegateToWidget; + +public class DelegateState extends ComponentState { + @DelegateToWidget + public String value1; + + @DelegateToWidget("setValue2") + public int renamedValue2; + + private Boolean value3; + + private double renamedValue4; + + @DelegateToWidget + public void setValue3(Boolean value3) { + this.value3 = value3; + } + + public Boolean getValue3() { + return value3; + } + + @DelegateToWidget("setValue4") + public void setRenamedValue4(double renamedValue4) { + this.renamedValue4 = renamedValue4; + } + + public double getRenamedValue4() { + return renamedValue4; + } +} diff --git a/tests/testbench/com/vaadin/tests/widgetset/client/DelegateWidget.java b/tests/testbench/com/vaadin/tests/widgetset/client/DelegateWidget.java new file mode 100644 index 0000000000..4776eced9a --- /dev/null +++ b/tests/testbench/com/vaadin/tests/widgetset/client/DelegateWidget.java @@ -0,0 +1,50 @@ +/* + * 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.tests.widgetset.client; + +import com.google.gwt.user.client.ui.HTML; + +public class DelegateWidget extends HTML { + private String value1; + private int value2; + private Boolean value3; + private double value4; + + public void setValue1(String value1) { + this.value1 = value1; + updateText(); + } + + public void setValue2(int value2) { + this.value2 = value2; + updateText(); + } + + public void setValue3(Boolean value3) { + this.value3 = value3; + updateText(); + } + + public void setValue4(double value4) { + this.value4 = value4; + } + + private void updateText() { + setHTML(value1 + "
      " + value2 + "
      " + value3 + "
      " + + value4 + "
      "); + } +} diff --git a/tests/testbench/com/vaadin/tests/widgetset/server/DelegateToWidgetComponent.java b/tests/testbench/com/vaadin/tests/widgetset/server/DelegateToWidgetComponent.java new file mode 100644 index 0000000000..34c9699f7f --- /dev/null +++ b/tests/testbench/com/vaadin/tests/widgetset/server/DelegateToWidgetComponent.java @@ -0,0 +1,35 @@ +/* + * 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.tests.widgetset.server; + +import com.vaadin.tests.widgetset.client.DelegateState; +import com.vaadin.ui.AbstractComponent; + +public class DelegateToWidgetComponent extends AbstractComponent { + public DelegateToWidgetComponent() { + DelegateState state = getState(); + state.value1 = "My String"; + state.renamedValue2 = 42; + state.setValue3(Boolean.TRUE); + state.setRenamedValue4(Math.PI); + } + + @Override + protected DelegateState getState() { + return (DelegateState) super.getState(); + } +} -- cgit v1.2.3 From 58cec95f137f1f7d464c5dde8198245c10a4e32e Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Fri, 24 Aug 2012 11:28:14 +0300 Subject: Explicit test case for #8683 --- .../serialization/SerializerNamespaceTest.html | 31 ++++++++++++++++++++++ .../serialization/SerializerNamespaceTest.java | 5 ++-- 2 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 tests/testbench/com/vaadin/tests/serialization/SerializerNamespaceTest.html diff --git a/tests/testbench/com/vaadin/tests/serialization/SerializerNamespaceTest.html b/tests/testbench/com/vaadin/tests/serialization/SerializerNamespaceTest.html new file mode 100644 index 0000000000..70d0e905f5 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/serialization/SerializerNamespaceTest.html @@ -0,0 +1,31 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + + + + + + +
      New Test
      open/run/com.vaadin.tests.serialization.SerializerNamespaceTest?restartApplication
      assertTextvaadin=runcomvaadintestsserializationSerializerNamespaceTest::/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[0]The real label
      assertTextvaadin=runcomvaadintestsserializationSerializerNamespaceTest::/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[1]The dummy label
      + + diff --git a/tests/testbench/com/vaadin/tests/serialization/SerializerNamespaceTest.java b/tests/testbench/com/vaadin/tests/serialization/SerializerNamespaceTest.java index 6a873a6be3..110475e5a9 100644 --- a/tests/testbench/com/vaadin/tests/serialization/SerializerNamespaceTest.java +++ b/tests/testbench/com/vaadin/tests/serialization/SerializerNamespaceTest.java @@ -19,10 +19,11 @@ package com.vaadin.tests.serialization; import com.vaadin.annotations.Widgetset; import com.vaadin.terminal.WrappedRequest; import com.vaadin.tests.components.AbstractTestRoot; +import com.vaadin.tests.widgetset.TestingWidgetSet; import com.vaadin.tests.widgetset.server.DummyLabel; import com.vaadin.ui.Label; -@Widgetset("com.vaadin.tests.widgetset.TestingWidgetSet") +@Widgetset(TestingWidgetSet.NAME) public class SerializerNamespaceTest extends AbstractTestRoot { @Override @@ -33,7 +34,7 @@ public class SerializerNamespaceTest extends AbstractTestRoot { @Override protected String getTestDescription() { - return "Using connectors with different state classes having the same simple name should not cause any clietn-side exceptions"; + return "Using connectors with different state classes having the same simple name should not cause any client-side exceptions"; } @Override -- cgit v1.2.3 From 86bbe59bb855b6cf57486322bca92e2ace88e8a2 Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Fri, 24 Aug 2012 11:46:23 +0300 Subject: Don't ever send state diffs for JavaScript connectors (#9026) --- .../vaadin/terminal/gwt/server/AbstractCommunicationManager.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/server/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java b/server/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java index 7ea4a7d097..b2436b2ce4 100644 --- a/server/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java +++ b/server/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java @@ -1250,12 +1250,13 @@ public abstract class AbstractCommunicationManager implements Serializable { Class stateType = connector.getStateType(); Object diffState = connectorTracker.getDiffState(connector); if (diffState == null) { - diffState = new JSONObject(); // Use an empty state object as reference for full // repaints - boolean emptyInitialState = JavaScriptConnectorState.class + + boolean supportsDiffState = !JavaScriptConnectorState.class .isAssignableFrom(stateType); - if (!emptyInitialState) { + if (supportsDiffState) { + diffState = new JSONObject(); try { SharedState referenceState = stateType.newInstance(); diffState = JsonCodec.encode(referenceState, null, @@ -1266,8 +1267,8 @@ public abstract class AbstractCommunicationManager implements Serializable { "Error creating reference object for state of type " + stateType.getName()); } + connectorTracker.setDiffState(connector, diffState); } - connectorTracker.setDiffState(connector, diffState); } JSONObject stateJson = (JSONObject) JsonCodec.encode(state, diffState, stateType, root.getConnectorTracker()); -- cgit v1.2.3 From da176c32c4d92676424021712a7f6d7ee8cedf76 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Fri, 24 Aug 2012 08:44:20 +0300 Subject: Renamed Root to UI, automatic rename (#8908) Automatic rename in Eclipse of the class Root to UI with all rename options enabled, rename also embedded "Root" in variable and method names. The following classes/methods were excluded in the rename: - BootstrapHandler.getApplicationCSSClassName() - ComponentLocator - ConnectorMap - ItemClickEvent - KeepAllItemsVisible - MenuBarTest - MenuBarTooltips - TreeTableTest - TreeWithIcons - Trees - VDebugConsole.printLayoutProblems() --- .../gwt/client/ApplicationConfiguration.java | 2 +- .../terminal/gwt/client/ApplicationConnection.java | 2 +- .../terminal/gwt/client/ui/root/RootConnector.java | 6 +- server/src/com/vaadin/Application.java | 154 +-- server/src/com/vaadin/annotations/EagerInit.java | 6 +- server/src/com/vaadin/annotations/Theme.java | 4 +- server/src/com/vaadin/annotations/Widgetset.java | 4 +- .../vaadin/terminal/AbstractClientConnector.java | 30 +- .../com/vaadin/terminal/AbstractRootProvider.java | 6 +- .../com/vaadin/terminal/DefaultRootProvider.java | 8 +- .../vaadin/terminal/DeploymentConfiguration.java | 2 +- server/src/com/vaadin/terminal/Page.java | 60 +- server/src/com/vaadin/terminal/RootProvider.java | 8 +- server/src/com/vaadin/terminal/WrappedRequest.java | 4 +- .../gwt/server/AbstractApplicationPortlet.java | 24 +- .../gwt/server/AbstractApplicationServlet.java | 12 +- .../gwt/server/AbstractCommunicationManager.java | 120 +- .../gwt/server/BootstrapFragmentResponse.java | 2 +- .../terminal/gwt/server/BootstrapHandler.java | 32 +- .../terminal/gwt/server/BootstrapPageResponse.java | 2 +- .../terminal/gwt/server/BootstrapResponse.java | 18 +- .../terminal/gwt/server/ClientConnector.java | 8 +- .../gwt/server/ClientMethodInvocation.java | 2 +- .../terminal/gwt/server/CommunicationManager.java | 10 +- .../terminal/gwt/server/DragAndDropService.java | 4 +- .../gwt/server/PortletApplicationContext2.java | 44 +- .../gwt/server/PortletCommunicationManager.java | 10 +- .../terminal/gwt/server/ServletPortletHelper.java | 6 +- server/src/com/vaadin/ui/AbstractComponent.java | 6 +- server/src/com/vaadin/ui/Component.java | 14 +- server/src/com/vaadin/ui/ConnectorTracker.java | 36 +- server/src/com/vaadin/ui/LoginForm.java | 4 +- server/src/com/vaadin/ui/Root.java | 1241 -------------------- server/src/com/vaadin/ui/UI.java | 1241 ++++++++++++++++++++ server/src/com/vaadin/ui/Window.java | 20 +- server/src/org/jsoup/select/Evaluator.java | 2 +- .../com/vaadin/tests/VaadinClasses.java | 4 +- .../tests/server/TestStreamVariableMapping.java | 8 +- .../abstractfield/RemoveListenersOnDetach.java | 8 +- .../component/root/CustomRootClassLoader.java | 18 +- .../component/window/AddRemoveSubWindow.java | 8 +- .../component/window/AttachDetachWindow.java | 4 +- .../vaadin/tests/server/components/TestWindow.java | 2 +- .../vaadin/launcher/ApplicationRunnerServlet.java | 14 +- tests/testbench/com/vaadin/tests/Components.java | 2 +- .../com/vaadin/tests/CustomLayoutDemo.java | 2 +- tests/testbench/com/vaadin/tests/LayoutDemo.java | 2 +- .../testbench/com/vaadin/tests/ListenerOrder.java | 2 +- tests/testbench/com/vaadin/tests/ModalWindow.java | 2 +- .../com/vaadin/tests/NativeWindowing.java | 2 +- tests/testbench/com/vaadin/tests/Parameters.java | 2 +- .../com/vaadin/tests/RandomLayoutStress.java | 2 +- .../com/vaadin/tests/ScrollbarStressTest.java | 2 +- tests/testbench/com/vaadin/tests/TestBench.java | 2 +- ...ApplicationLayoutThatUsesWholeBrosersSpace.java | 2 +- .../com/vaadin/tests/TestForNativeWindowing.java | 2 +- .../com/vaadin/tests/TestForStyledUpload.java | 2 +- .../com/vaadin/tests/TestForWindowOpen.java | 8 +- .../com/vaadin/tests/TestForWindowing.java | 4 +- .../com/vaadin/tests/TestSetVisibleAndCaching.java | 2 +- .../com/vaadin/tests/TestSizeableIncomponents.java | 2 +- .../testbench/com/vaadin/tests/TestSplitPanel.java | 2 +- .../testbench/com/vaadin/tests/TreeFilesystem.java | 2 +- .../com/vaadin/tests/TreeFilesystemContainer.java | 2 +- .../com/vaadin/tests/UpgradingSample.java | 2 +- .../com/vaadin/tests/UsingObjectsInSelect.java | 2 +- .../com/vaadin/tests/appengine/GAESyncTest.java | 2 +- .../tests/application/ErrorInUnloadEvent.java | 2 +- .../tests/application/RefreshStatePreserve.java | 8 +- .../application/TerminalErrorNotification.java | 4 +- .../tests/application/ThreadLocalInstances.java | 16 +- .../tests/applicationcontext/ChangeSessionId.java | 2 +- .../vaadin/tests/components/AbstractTestRoot.java | 4 +- .../com/vaadin/tests/components/TestBase.java | 2 +- .../components/abstractcomponent/EnableState.java | 2 +- .../button/ButtonsInHorizontalLayout.java | 2 +- .../combobox/ComboBoxReapperingOldValue.java | 2 +- .../combobox/GridLayoutComboBoxZoomOut.java | 4 +- .../components/datefield/DateFieldInSubWindow.java | 2 +- .../datefield/DateFieldPopupOffScreen.java | 2 +- .../UndefinedWideFormWithRelativeWideFooter.java | 2 +- .../TableInFormLayoutCausesScrolling.java | 2 +- .../loginform/LoginFormRootInLoginHandler.java | 10 +- .../loginform/LoginFormWithMultipleWindows.java | 6 +- .../components/menubar/MenuBarInSplitPanel.java | 2 +- .../menubar/MenuBarRunsOutOfBrowser.java | 2 +- .../VerticalLayoutWidthCalculation.java | 2 +- .../tests/components/root/LazyInitRoots.java | 20 +- .../tests/components/root/RootsInMultipleTabs.java | 8 +- .../tests/components/root/TestRootTheme.java | 2 +- .../splitpanel/SplitPanelExtraScrollbars.java | 2 +- .../splitpanel/SplitPanelWidthOnResize.java | 2 +- .../components/table/ScrollCausesRequestLoop.java | 2 +- .../tests/components/table/SortLongTable.java | 2 +- .../components/table/TableExtraScrollbars.java | 2 +- .../components/table/TableFirstRowFlicker.java | 2 +- .../tests/components/table/TableHeaderZoom.java | 2 +- .../table/TableHeightWhenHidingHeaders.java | 2 +- .../components/table/TableToggleVisibility.java | 2 +- .../components/table/TestCurrentPageFirstItem.java | 2 +- .../tests/components/tabsheet/TabsheetNPE.java | 2 +- .../textfield/TextFieldInLayoutInTable.java | 2 +- .../tests/components/tree/TreePerformanceTest.java | 2 +- .../tests/components/tree/TreeScrolling.java | 2 +- .../treetable/DisappearingComponents.java | 2 +- .../window/AttachShouldBeCalledForSubWindows.java | 4 +- .../tests/components/window/ExecuteJavaScript.java | 2 +- .../tests/components/window/LazyWindowResize.java | 2 +- .../window/SubWindowFocusAndBlurListeners.java | 4 +- .../tests/components/window/SubWindowOrder.java | 4 +- .../window/WindowScrollingComponentIntoView.java | 2 +- .../tests/components/window/WindowScrollingUp.java | 2 +- .../sqlcontainer/CheckboxUpdateProblem.java | 2 +- .../sqlcontainer/ComboBoxUpdateProblem.java | 4 +- .../sqlcontainer/MassInsertMemoryLeakTestApp.java | 2 +- tests/testbench/com/vaadin/tests/dd/DDTest2.java | 4 +- tests/testbench/com/vaadin/tests/dd/DDTest4.java | 4 +- tests/testbench/com/vaadin/tests/dd/DDTest5.java | 4 +- tests/testbench/com/vaadin/tests/dd/DDTest7.java | 4 +- .../vaadin/tests/integration/EmbedSizeTest.java | 2 +- .../integration/IntegrationTestApplication.java | 2 +- .../integration/JSR286PortletApplication.java | 12 +- .../vaadin/tests/integration/LiferayThemeDemo.java | 2 +- ...tletSizeInLiferayFreeformLayoutApplication.java | 2 +- .../ComplexGLColumnExpansionWithColSpan.java | 2 +- .../vaadin/tests/layouts/GridLayoutCaptions.java | 2 +- .../layouts/GridLayoutExpandRatioModification.java | 2 +- .../tests/layouts/GridLayoutInsidePanel2.java | 2 +- .../MovingComponentsWhileOldParentInvisible.java | 4 +- .../tests/layouts/TestLayoutClickListeners.java | 2 +- .../tests/layouts/TreeWithBordersInLayout.java | 2 +- .../VerticalLayoutExpandRatioModification.java | 2 +- .../layouttester/LayoutTesterApplication.java | 2 +- .../minitutorials/v7a1/AutoGeneratingForm.java | 4 +- .../tests/minitutorials/v7a1/BasicApplication.java | 4 +- .../minitutorials/v7a1/CreatingPreserveState.java | 4 +- .../tests/minitutorials/v7a1/DefineRootTheme.java | 4 +- .../v7a1/DifferentFeaturesForDifferentClients.java | 8 +- .../v7a1/FindCurrentRootAndApplication.java | 8 +- .../minitutorials/v7a1/MultiTabApplication.java | 4 +- .../minitutorials/v7a1/UsingBeanValidation.java | 4 +- .../minitutorials/v7a1/UsingUriFragments.java | 4 +- .../v7a1/UsingXyzWhenInitializing.java | 4 +- .../minitutorials/v7a2/ComponentInStateRoot.java | 4 +- .../tests/minitutorials/v7a2/MyComponentRoot.java | 4 +- .../minitutorials/v7a2/ResourceInStateRoot.java | 4 +- .../minitutorials/v7a2/WidgetcontainerRoot.java | 4 +- .../vaadin/tests/minitutorials/v7a3/Analytics.java | 8 +- .../tests/minitutorials/v7a3/AnalyticsRoot.java | 4 +- .../minitutorials/v7a3/ComplexTypesComponent.java | 4 +- .../tests/minitutorials/v7a3/ComplexTypesRoot.java | 4 +- .../minitutorials/v7a3/FlotJavaScriptRoot.java | 4 +- .../tests/minitutorials/v7a3/RedButtonRoot.java | 4 +- .../com/vaadin/tests/themes/ButtonsTest.java | 6 +- .../com/vaadin/tests/tickets/Ticket1225.java | 2 +- .../com/vaadin/tests/tickets/Ticket1230.java | 2 +- .../com/vaadin/tests/tickets/Ticket124.java | 2 +- .../com/vaadin/tests/tickets/Ticket1245.java | 2 +- .../com/vaadin/tests/tickets/Ticket1365.java | 2 +- .../com/vaadin/tests/tickets/Ticket1368.java | 2 +- .../com/vaadin/tests/tickets/Ticket1397.java | 2 +- .../com/vaadin/tests/tickets/Ticket1435.java | 2 +- .../com/vaadin/tests/tickets/Ticket1444.java | 2 +- .../tests/tickets/Ticket1465ModalNotification.java | 2 +- .../com/vaadin/tests/tickets/Ticket1519.java | 2 +- .../com/vaadin/tests/tickets/Ticket1572.java | 2 +- .../com/vaadin/tests/tickets/Ticket1581.java | 2 +- .../com/vaadin/tests/tickets/Ticket1589.java | 2 +- .../com/vaadin/tests/tickets/Ticket1598.java | 2 +- .../com/vaadin/tests/tickets/Ticket161.java | 2 +- .../com/vaadin/tests/tickets/Ticket1632.java | 2 +- .../com/vaadin/tests/tickets/Ticket1659.java | 2 +- .../com/vaadin/tests/tickets/Ticket1663.java | 2 +- .../com/vaadin/tests/tickets/Ticket1673.java | 2 +- .../com/vaadin/tests/tickets/Ticket1710.java | 2 +- .../com/vaadin/tests/tickets/Ticket1737.java | 2 +- .../com/vaadin/tests/tickets/Ticket1767.java | 2 +- .../com/vaadin/tests/tickets/Ticket1772.java | 2 +- .../com/vaadin/tests/tickets/Ticket1775.java | 2 +- .../com/vaadin/tests/tickets/Ticket1804.java | 2 +- .../com/vaadin/tests/tickets/Ticket1805.java | 2 +- .../com/vaadin/tests/tickets/Ticket1806.java | 2 +- .../com/vaadin/tests/tickets/Ticket1811.java | 2 +- .../com/vaadin/tests/tickets/Ticket1819.java | 2 +- .../tests/tickets/Ticket1834PanelScrolling.java | 2 +- .../com/vaadin/tests/tickets/Ticket1857.java | 2 +- .../com/vaadin/tests/tickets/Ticket1868.java | 2 +- .../com/vaadin/tests/tickets/Ticket1869.java | 2 +- .../com/vaadin/tests/tickets/Ticket1878.java | 2 +- .../com/vaadin/tests/tickets/Ticket1900.java | 2 +- .../com/vaadin/tests/tickets/Ticket1904.java | 2 +- .../com/vaadin/tests/tickets/Ticket1916.java | 2 +- .../com/vaadin/tests/tickets/Ticket1919.java | 2 +- .../com/vaadin/tests/tickets/Ticket1921.java | 2 +- .../com/vaadin/tests/tickets/Ticket1923.java | 2 +- .../com/vaadin/tests/tickets/Ticket1925.java | 2 +- .../com/vaadin/tests/tickets/Ticket1939.java | 2 +- .../com/vaadin/tests/tickets/Ticket1940.java | 2 +- .../com/vaadin/tests/tickets/Ticket1953.java | 2 +- .../com/vaadin/tests/tickets/Ticket1966.java | 2 +- .../com/vaadin/tests/tickets/Ticket1966_2.java | 2 +- .../com/vaadin/tests/tickets/Ticket1966_3.java | 2 +- .../com/vaadin/tests/tickets/Ticket1969.java | 2 +- .../com/vaadin/tests/tickets/Ticket1970.java | 2 +- .../com/vaadin/tests/tickets/Ticket1972.java | 2 +- .../com/vaadin/tests/tickets/Ticket1973.java | 2 +- .../com/vaadin/tests/tickets/Ticket1973_2.java | 2 +- .../com/vaadin/tests/tickets/Ticket1975.java | 2 +- .../com/vaadin/tests/tickets/Ticket1982.java | 2 +- .../com/vaadin/tests/tickets/Ticket1983.java | 2 +- .../com/vaadin/tests/tickets/Ticket1986.java | 2 +- .../com/vaadin/tests/tickets/Ticket1991.java | 2 +- .../com/vaadin/tests/tickets/Ticket1995.java | 2 +- .../com/vaadin/tests/tickets/Ticket20.java | 2 +- .../com/vaadin/tests/tickets/Ticket2001.java | 2 +- .../com/vaadin/tests/tickets/Ticket2002.java | 2 +- .../com/vaadin/tests/tickets/Ticket2007.java | 2 +- .../com/vaadin/tests/tickets/Ticket2009.java | 2 +- .../com/vaadin/tests/tickets/Ticket2011.java | 2 +- .../com/vaadin/tests/tickets/Ticket2014.java | 2 +- .../com/vaadin/tests/tickets/Ticket2021.java | 2 +- .../com/vaadin/tests/tickets/Ticket2022.java | 2 +- .../com/vaadin/tests/tickets/Ticket2023.java | 2 +- .../com/vaadin/tests/tickets/Ticket2024.java | 2 +- .../com/vaadin/tests/tickets/Ticket2026.java | 2 +- .../com/vaadin/tests/tickets/Ticket2029.java | 2 +- .../com/vaadin/tests/tickets/Ticket2037.java | 2 +- .../com/vaadin/tests/tickets/Ticket2038.java | 2 +- .../com/vaadin/tests/tickets/Ticket2040.java | 2 +- .../com/vaadin/tests/tickets/Ticket2042.java | 2 +- .../com/vaadin/tests/tickets/Ticket2043.java | 2 +- .../com/vaadin/tests/tickets/Ticket2048.java | 2 +- .../com/vaadin/tests/tickets/Ticket2051.java | 2 +- .../com/vaadin/tests/tickets/Ticket2053.java | 2 +- .../com/vaadin/tests/tickets/Ticket2060.java | 2 +- .../com/vaadin/tests/tickets/Ticket2061.java | 2 +- .../com/vaadin/tests/tickets/Ticket2061b.java | 2 +- .../com/vaadin/tests/tickets/Ticket2061c.java | 2 +- .../com/vaadin/tests/tickets/Ticket2062.java | 2 +- .../com/vaadin/tests/tickets/Ticket2083.java | 2 +- .../com/vaadin/tests/tickets/Ticket2090.java | 2 +- .../com/vaadin/tests/tickets/Ticket2095.java | 2 +- .../com/vaadin/tests/tickets/Ticket2098.java | 2 +- .../com/vaadin/tests/tickets/Ticket2099.java | 2 +- .../com/vaadin/tests/tickets/Ticket2101.java | 2 +- .../com/vaadin/tests/tickets/Ticket2103.java | 2 +- .../com/vaadin/tests/tickets/Ticket2104.java | 14 +- .../com/vaadin/tests/tickets/Ticket2106.java | 2 +- .../com/vaadin/tests/tickets/Ticket2107.java | 2 +- .../com/vaadin/tests/tickets/Ticket2117.java | 2 +- .../com/vaadin/tests/tickets/Ticket2119.java | 2 +- .../com/vaadin/tests/tickets/Ticket2125.java | 2 +- .../com/vaadin/tests/tickets/Ticket2126.java | 2 +- .../com/vaadin/tests/tickets/Ticket2151.java | 2 +- .../com/vaadin/tests/tickets/Ticket2157.java | 2 +- .../com/vaadin/tests/tickets/Ticket2178.java | 2 +- .../com/vaadin/tests/tickets/Ticket2179.java | 2 +- .../com/vaadin/tests/tickets/Ticket2180.java | 2 +- .../com/vaadin/tests/tickets/Ticket2181.java | 2 +- .../com/vaadin/tests/tickets/Ticket2186.java | 2 +- .../com/vaadin/tests/tickets/Ticket2204.java | 2 +- .../com/vaadin/tests/tickets/Ticket2208.java | 2 +- .../com/vaadin/tests/tickets/Ticket2209.java | 2 +- .../com/vaadin/tests/tickets/Ticket2209OL.java | 2 +- .../com/vaadin/tests/tickets/Ticket2209OL2.java | 2 +- .../com/vaadin/tests/tickets/Ticket2215.java | 2 +- .../com/vaadin/tests/tickets/Ticket2221.java | 2 +- .../com/vaadin/tests/tickets/Ticket2222.java | 2 +- .../tickets/Ticket2227OrderedlayoutInTable.java | 2 +- .../com/vaadin/tests/tickets/Ticket2231.java | 2 +- .../com/vaadin/tests/tickets/Ticket2232.java | 2 +- .../com/vaadin/tests/tickets/Ticket2234.java | 2 +- .../com/vaadin/tests/tickets/Ticket2235.java | 2 +- .../com/vaadin/tests/tickets/Ticket2240.java | 2 +- .../com/vaadin/tests/tickets/Ticket2242.java | 2 +- .../com/vaadin/tests/tickets/Ticket2244.java | 2 +- .../com/vaadin/tests/tickets/Ticket2245.java | 2 +- .../com/vaadin/tests/tickets/Ticket2267.java | 2 +- .../com/vaadin/tests/tickets/Ticket2271.java | 2 +- .../com/vaadin/tests/tickets/Ticket2282.java | 2 +- .../com/vaadin/tests/tickets/Ticket2283.java | 2 +- .../com/vaadin/tests/tickets/Ticket2287.java | 2 +- .../com/vaadin/tests/tickets/Ticket2289.java | 2 +- .../com/vaadin/tests/tickets/Ticket2292.java | 2 +- .../com/vaadin/tests/tickets/Ticket2294.java | 2 +- .../com/vaadin/tests/tickets/Ticket2296.java | 2 +- .../com/vaadin/tests/tickets/Ticket2297.java | 2 +- .../com/vaadin/tests/tickets/Ticket2303.java | 2 +- .../com/vaadin/tests/tickets/Ticket2304.java | 2 +- .../com/vaadin/tests/tickets/Ticket2310.java | 2 +- .../com/vaadin/tests/tickets/Ticket2319.java | 2 +- .../com/vaadin/tests/tickets/Ticket2323.java | 2 +- .../com/vaadin/tests/tickets/Ticket2325.java | 2 +- .../com/vaadin/tests/tickets/Ticket2329.java | 2 +- .../com/vaadin/tests/tickets/Ticket2337.java | 2 +- .../com/vaadin/tests/tickets/Ticket2339.java | 2 +- .../com/vaadin/tests/tickets/Ticket2341.java | 2 +- .../com/vaadin/tests/tickets/Ticket2344.java | 2 +- .../com/vaadin/tests/tickets/Ticket2347.java | 2 +- .../com/vaadin/tests/tickets/Ticket2364.java | 2 +- .../com/vaadin/tests/tickets/Ticket2365.java | 2 +- .../com/vaadin/tests/tickets/Ticket2398.java | 2 +- .../com/vaadin/tests/tickets/Ticket2404.java | 2 +- .../com/vaadin/tests/tickets/Ticket2405.java | 2 +- .../com/vaadin/tests/tickets/Ticket2406.java | 2 +- .../com/vaadin/tests/tickets/Ticket2407.java | 2 +- .../com/vaadin/tests/tickets/Ticket2411.java | 2 +- .../com/vaadin/tests/tickets/Ticket2415.java | 2 +- .../com/vaadin/tests/tickets/Ticket2420.java | 2 +- .../com/vaadin/tests/tickets/Ticket2425.java | 2 +- .../com/vaadin/tests/tickets/Ticket2426.java | 2 +- .../com/vaadin/tests/tickets/Ticket2431.java | 2 +- .../com/vaadin/tests/tickets/Ticket2432.java | 2 +- .../com/vaadin/tests/tickets/Ticket2434.java | 2 +- .../com/vaadin/tests/tickets/Ticket2436.java | 2 +- .../com/vaadin/tests/tickets/Ticket2526.java | 2 +- .../com/vaadin/tests/tickets/Ticket2742.java | 2 +- .../com/vaadin/tests/tickets/Ticket2901.java | 2 +- .../com/vaadin/tests/tickets/Ticket2998.java | 2 +- .../com/vaadin/tests/tickets/Ticket3146.java | 2 +- .../com/vaadin/tests/tickets/Ticket34.java | 2 +- .../com/vaadin/tests/tickets/Ticket5053.java | 2 +- .../com/vaadin/tests/tickets/Ticket5157.java | 2 +- .../com/vaadin/tests/tickets/Ticket5952.java | 2 +- .../com/vaadin/tests/tickets/Ticket6002.java | 2 +- .../com/vaadin/tests/tickets/Ticket677.java | 2 +- .../com/vaadin/tests/tickets/Ticket695.java | 2 +- .../com/vaadin/tests/tickets/Ticket736.java | 2 +- .../com/vaadin/tests/tickets/Ticket8291.java | 4 +- .../com/vaadin/tests/tickets/Ticket846.java | 2 +- .../com/vaadin/tests/tickets/Ticket932.java | 2 +- .../com/vaadin/tests/util/SampleDirectory.java | 8 +- .../testbench/com/vaadin/tests/util/TestUtils.java | 4 +- .../tests/vaadincontext/BootstrapModifyRoot.java | 2 +- .../vaadincontext/TestAddonContextListener.java | 8 +- .../tests/validation/RequiredErrorMessage.java | 2 +- 336 files changed, 1993 insertions(+), 1993 deletions(-) delete mode 100644 server/src/com/vaadin/ui/Root.java create mode 100644 server/src/com/vaadin/ui/UI.java diff --git a/client/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java b/client/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java index 8bb4f37324..aa7a9fc72a 100644 --- a/client/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java +++ b/client/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java @@ -284,7 +284,7 @@ public class ApplicationConfiguration implements EntryPoint { /** * Gets the root if of this application instance. The root id should be * included in every request originating from this instance in order to - * associate it with the right Root instance on the server. + * associate it with the right UI instance on the server. * * @return the root id */ diff --git a/client/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java b/client/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java index 10f63d0f51..4e8871b8ac 100644 --- a/client/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java +++ b/client/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java @@ -208,7 +208,7 @@ public class ApplicationConnection { } public ApplicationConnection() { - // Assuming Root data is eagerly loaded + // Assuming UI data is eagerly loaded ConnectorBundleLoader.get().loadBundle( ConnectorBundleLoader.EAGER_BUNDLE_NAME, null); rootConnector = GWT.create(RootConnector.class); diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/root/RootConnector.java b/client/src/com/vaadin/terminal/gwt/client/ui/root/RootConnector.java index b3490effa7..3321b07146 100644 --- a/client/src/com/vaadin/terminal/gwt/client/ui/root/RootConnector.java +++ b/client/src/com/vaadin/terminal/gwt/client/ui/root/RootConnector.java @@ -58,9 +58,9 @@ import com.vaadin.terminal.gwt.client.ui.ShortcutActionHandler; import com.vaadin.terminal.gwt.client.ui.layout.MayScrollChildren; import com.vaadin.terminal.gwt.client.ui.notification.VNotification; import com.vaadin.terminal.gwt.client.ui.window.WindowConnector; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; -@Connect(value = Root.class, loadStyle = LoadStyle.EAGER) +@Connect(value = UI.class, loadStyle = LoadStyle.EAGER) public class RootConnector extends AbstractComponentContainerConnector implements Paintable, MayScrollChildren { @@ -359,7 +359,7 @@ public class RootConnector extends AbstractComponentContainerConnector } /** - * Checks if the given sub window is a child of this Root Connector + * Checks if the given sub window is a child of this UI Connector * * @deprecated Should be replaced by a more generic mechanism for getting * non-ComponentConnector children diff --git a/server/src/com/vaadin/Application.java b/server/src/com/vaadin/Application.java index d2924eb716..23d407e4f3 100644 --- a/server/src/com/vaadin/Application.java +++ b/server/src/com/vaadin/Application.java @@ -74,7 +74,7 @@ import com.vaadin.terminal.gwt.server.WebApplicationContext; import com.vaadin.tools.ReflectTools; import com.vaadin.ui.AbstractComponent; import com.vaadin.ui.AbstractField; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; import com.vaadin.ui.Table; import com.vaadin.ui.Window; @@ -134,7 +134,7 @@ public class Application implements Terminal.ErrorListener, Serializable { /** * The name of the parameter that is by default used in e.g. web.xml to - * define the name of the default {@link Root} class. + * define the name of the default {@link UI} class. */ public static final String ROOT_PARAMETER = "root"; @@ -164,10 +164,10 @@ public class Application implements Terminal.ErrorListener, Serializable { private static final Pattern WINDOW_NAME_PATTERN = Pattern .compile("^/?([^/]+).*"); - private Root.LegacyWindow mainWindow; + private UI.LegacyWindow mainWindow; private String theme; - private Map legacyRootNames = new HashMap(); + private Map legacyRootNames = new HashMap(); /** * Sets the main window of this application. Setting window as a main @@ -176,7 +176,7 @@ public class Application implements Terminal.ErrorListener, Serializable { * @param mainWindow * the root to set as the default window */ - public void setMainWindow(Root.LegacyWindow mainWindow) { + public void setMainWindow(UI.LegacyWindow mainWindow) { if (this.mainWindow != null) { throw new IllegalStateException( "mainWindow has already been set"); @@ -203,7 +203,7 @@ public class Application implements Terminal.ErrorListener, Serializable { * * @return the root used as the default window */ - public Root.LegacyWindow getMainWindow() { + public UI.LegacyWindow getMainWindow() { return mainWindow; } @@ -219,7 +219,7 @@ public class Application implements Terminal.ErrorListener, Serializable { */ @Override - public Root.LegacyWindow getRoot(WrappedRequest request) { + public UI.LegacyWindow getRoot(WrappedRequest request) { String pathInfo = request.getRequestPathInfo(); String name = null; if (pathInfo != null && pathInfo.length() > 0) { @@ -229,7 +229,7 @@ public class Application implements Terminal.ErrorListener, Serializable { name = matcher.group(1); } } - Root.LegacyWindow window = getWindow(name); + UI.LegacyWindow window = getWindow(name); if (window != null) { return window; } @@ -240,7 +240,7 @@ public class Application implements Terminal.ErrorListener, Serializable { * Sets the application's theme. *

      * Note that this theme can be overridden for a specific root with - * {@link Application#getThemeForRoot(Root)}. Setting theme to be + * {@link Application#getThemeForRoot(UI)}. Setting theme to be * null selects the default theme. For the available theme * names, see the contents of the VAADIN/themes directory. *

      @@ -254,7 +254,7 @@ public class Application implements Terminal.ErrorListener, Serializable { /** * Gets the application's theme. The application's theme is the default - * theme used by all the roots for which a theme is not explicitly + * theme used by all the uIs for which a theme is not explicitly * defined. If the application theme is not explicitly set, * null is returned. * @@ -272,7 +272,7 @@ public class Application implements Terminal.ErrorListener, Serializable { */ @Override - public String getThemeForRoot(Root root) { + public String getThemeForRoot(UI uI) { return theme; } @@ -288,7 +288,7 @@ public class Application implements Terminal.ErrorListener, Serializable { * @return a root corresponding to the name, or null to use * the default window */ - public Root.LegacyWindow getWindow(String name) { + public UI.LegacyWindow getWindow(String name) { return legacyRootNames.get(name); } @@ -299,42 +299,42 @@ public class Application implements Terminal.ErrorListener, Serializable { /** * Adds a new browser level window to this application. Please note that - * Root doesn't have a name that is used in the URL - to add a named - * window you should instead use {@link #addWindow(Root, String)} + * UI doesn't have a name that is used in the URL - to add a named + * window you should instead use {@link #addWindow(UI, String)} * - * @param root + * @param uI * the root window to add to the application * @return returns the name that has been assigned to the window * - * @see #addWindow(Root, String) + * @see #addWindow(UI, String) */ - public void addWindow(Root.LegacyWindow root) { - if (root.getName() == null) { + public void addWindow(UI.LegacyWindow uI) { + if (uI.getName() == null) { String name = Integer.toString(namelessRootIndex++); - root.setName(name); + uI.setName(name); } - legacyRootNames.put(root.getName(), root); - root.setApplication(this); + legacyRootNames.put(uI.getName(), uI); + uI.setApplication(this); } /** * Removes the specified window from the application. This also removes * all name mappings for the window (see - * {@link #addWindow(Root, String) and #getWindowName(Root)}. + * {@link #addWindow(UI, String) and #getWindowName(UI)}. * *

      * Note that removing window from the application does not close the * browser window - the window is only removed from the server-side. *

      * - * @param root + * @param uI * the root to remove */ - public void removeWindow(Root.LegacyWindow root) { - for (Entry entry : legacyRootNames + public void removeWindow(UI.LegacyWindow uI) { + for (Entry entry : legacyRootNames .entrySet()) { - if (entry.getValue() == root) { + if (entry.getValue() == uI) { legacyRootNames.remove(entry.getKey()); } } @@ -349,7 +349,7 @@ public class Application implements Terminal.ErrorListener, Serializable { * * @return the unmodifiable collection of windows. */ - public Collection getWindows() { + public Collection getWindows() { return Collections.unmodifiableCollection(legacyRootNames.values()); } } @@ -490,14 +490,14 @@ public class Application implements Terminal.ErrorListener, Serializable { private LinkedList requestHandlers = new LinkedList(); private int nextRootId = 0; - private Map roots = new HashMap(); + private Map uIs = new HashMap(); private final Map retainOnRefreshRoots = new HashMap(); private final EventRouter eventRouter = new EventRouter(); /** - * Keeps track of which roots have been inited. + * Keeps track of which uIs have been inited. *

      * TODO Investigate whether this might be derived from the different states * in getRootForRrequest. @@ -1844,7 +1844,7 @@ public class Application implements Terminal.ErrorListener, Serializable { *

      * *

      - * If {@link BrowserDetails} are required to create a Root, the + * If {@link BrowserDetails} are required to create a UI, the * implementation can throw a {@link RootRequiresMoreInformationException} * exception. In this case, the framework will instruct the browser to send * the additional details, whereupon this method is invoked again with the @@ -1854,10 +1854,10 @@ public class Application implements Terminal.ErrorListener, Serializable { * *

      * The default implementation in {@link Application} creates a new instance - * of the Root class returned by {@link #getRootClassName(WrappedRequest)}, + * of the UI class returned by {@link #getRootClassName(WrappedRequest)}, * which in turn uses the {@value #ROOT_PARAMETER} parameter from web.xml. * If {@link DeploymentConfiguration#getClassLoader()} for the request - * returns a {@link ClassLoader}, it is used for loading the Root class. + * returns a {@link ClassLoader}, it is used for loading the UI class. * Otherwise the {@link ClassLoader} used to load this class is used. *

      * @@ -1869,20 +1869,20 @@ public class Application implements Terminal.ErrorListener, Serializable { * {@link BrowserDetails} are required to create a root * * @see #getRootClassName(WrappedRequest) - * @see Root + * @see UI * @see RootRequiresMoreInformationException * @see WrappedRequest#getBrowserDetails() * * @since 7.0 */ - protected Root getRoot(WrappedRequest request) + protected UI getRoot(WrappedRequest request) throws RootRequiresMoreInformationException { // Iterate in reverse order - test check newest provider first for (int i = rootProviders.size() - 1; i >= 0; i--) { RootProvider provider = rootProviders.get(i); - Class rootClass = provider.getRootClass(this, + Class rootClass = provider.getRootClass(this, request); if (rootClass != null) { @@ -1900,15 +1900,15 @@ public class Application implements Terminal.ErrorListener, Serializable { * * TODO Tell what the default implementation does once it does something. * - * @param root + * @param uI * the root to get a theme for * @return the name of the theme, or null if the default theme * should be used * * @since 7.0 */ - public String getThemeForRoot(Root root) { - Theme rootTheme = getAnnotationFor(root.getClass(), Theme.class); + public String getThemeForRoot(UI uI) { + Theme rootTheme = getAnnotationFor(uI.getClass(), Theme.class); if (rootTheme != null) { return rootTheme.value(); } else { @@ -1922,15 +1922,15 @@ public class Application implements Terminal.ErrorListener, Serializable { * * TODO Tell what the default implementation does once it does something. * - * @param root + * @param uI * the root to get a widgetset for * @return the name of the widgetset, or null if the default * widgetset should be used * * @since 7.0 */ - public String getWidgetsetForRoot(Root root) { - Widgetset rootWidgetset = getAnnotationFor(root.getClass(), + public String getWidgetsetForRoot(UI uI) { + Widgetset rootWidgetset = getAnnotationFor(uI.getClass(), Widgetset.class); if (rootWidgetset != null) { return rootWidgetset.value(); @@ -2148,16 +2148,16 @@ public class Application implements Terminal.ErrorListener, Serializable { } /** - * Finds the {@link Root} to which a particular request belongs. If the - * request originates from an existing Root, that root is returned. In other + * Finds the {@link UI} to which a particular request belongs. If the + * request originates from an existing UI, that root is returned. In other * cases, the method attempts to create and initialize a new root and might * throw a {@link RootRequiresMoreInformationException} if all required * information is not available. *

      * Please note that this method can also return a newly created - * Root which has not yet been initialized. You can use + * UI which has not yet been initialized. You can use * {@link #isRootInitPending(int)} with the root's id ( - * {@link Root#getRootId()} to check whether the initialization is still + * {@link UI#getRootId()} to check whether the initialization is still * pending. *

      * @@ -2173,11 +2173,11 @@ public class Application implements Terminal.ErrorListener, Serializable { * * @since 7.0 */ - public Root getRootForRequest(WrappedRequest request) + public UI getRootForRequest(WrappedRequest request) throws RootRequiresMoreInformationException { - Root root = Root.getCurrent(); - if (root != null) { - return root; + UI uI = UI.getCurrent(); + if (uI != null) { + return uI; } Integer rootId = getRootId(request); @@ -2186,9 +2186,9 @@ public class Application implements Terminal.ErrorListener, Serializable { boolean hasBrowserDetails = browserDetails != null && browserDetails.getUriFragment() != null; - root = roots.get(rootId); + uI = uIs.get(rootId); - if (root == null && isRootPreserved()) { + if (uI == null && isRootPreserved()) { // Check for a known root if (!retainOnRefreshRoots.isEmpty()) { @@ -2202,39 +2202,39 @@ public class Application implements Terminal.ErrorListener, Serializable { if (retainedRootId != null) { rootId = retainedRootId; - root = roots.get(rootId); + uI = uIs.get(rootId); } } } - if (root == null) { + if (uI == null) { // Throws exception if root can not yet be created - root = getRoot(request); + uI = getRoot(request); // Initialize some fields for a newly created root - if (root.getApplication() == null) { - root.setApplication(this); + if (uI.getApplication() == null) { + uI.setApplication(this); } - if (root.getRootId() < 0) { + if (uI.getRootId() < 0) { if (rootId == null) { // Get the next id if none defined rootId = Integer.valueOf(nextRootId++); } - root.setRootId(rootId.intValue()); - roots.put(rootId, root); + uI.setRootId(rootId.intValue()); + uIs.put(rootId, uI); } } // Set thread local here so it is available in init - Root.setCurrent(root); + UI.setCurrent(uI); if (!initedRoots.contains(rootId)) { boolean initRequiresBrowserDetails = isRootPreserved() - || !root.getClass() + || !uI.getClass() .isAnnotationPresent(EagerInit.class); if (!initRequiresBrowserDetails || hasBrowserDetails) { - root.doInit(request); + uI.doInit(request); // Remember that this root has been initialized initedRoots.add(rootId); @@ -2250,7 +2250,7 @@ public class Application implements Terminal.ErrorListener, Serializable { } } // end synchronized block - return root; + return uI; } /** @@ -2276,7 +2276,7 @@ public class Application implements Terminal.ErrorListener, Serializable { } /** - * Sets whether the same Root state should be reused if the framework can + * Sets whether the same UI state should be reused if the framework can * detect that the application is opened in a browser window where it has * previously been open. The framework attempts to discover this by checking * the value of window.name in the browser. @@ -2286,7 +2286,7 @@ public class Application implements Terminal.ErrorListener, Serializable { *

      * * @param rootPreserved - * trueif the same Root instance should be reused + * trueif the same UI instance should be reused * e.g. when the browser window is refreshed. */ public void setRootPreserved(boolean rootPreserved) { @@ -2297,12 +2297,12 @@ public class Application implements Terminal.ErrorListener, Serializable { } /** - * Checks whether the same Root state should be reused if the framework can + * Checks whether the same UI state should be reused if the framework can * detect that the application is opened in a browser window where it has * previously been open. The framework attempts to discover this by checking * the value of window.name in the browser. * - * @return trueif the same Root instance should be reused e.g. + * @return trueif the same UI instance should be reused e.g. * when the browser window is refreshed. */ public boolean isRootPreserved() { @@ -2326,21 +2326,21 @@ public class Application implements Terminal.ErrorListener, Serializable { } /** - * Gets all the roots of this application. This includes roots that have - * been requested but not yet initialized. Please note, that roots are not + * Gets all the uIs of this application. This includes uIs that have + * been requested but not yet initialized. Please note, that uIs are not * automatically removed e.g. if the browser window is closed and that there - * is no way to manually remove a root. Inactive roots will thus not be + * is no way to manually remove a root. Inactive uIs will thus not be * released for GC until the entire application is released when the session * has timed out (unless there are dangling references). Improved support - * for releasing unused roots is planned for an upcoming alpha release of + * for releasing unused uIs is planned for an upcoming alpha release of * Vaadin 7. * - * @return a collection of roots belonging to this application + * @return a collection of uIs belonging to this application * * @since 7.0 */ - public Collection getRoots() { - return Collections.unmodifiableCollection(roots.values()); + public Collection getRoots() { + return Collections.unmodifiableCollection(uIs.values()); } private int connectorIdSequence = 0; @@ -2362,7 +2362,7 @@ public class Application implements Terminal.ErrorListener, Serializable { } /** - * Returns a Root with the given id. + * Returns a UI with the given id. *

      * This is meant for framework internal use. *

      @@ -2371,8 +2371,8 @@ public class Application implements Terminal.ErrorListener, Serializable { * The root id * @return The root with the given id or null if not found */ - public Root getRootById(int rootId) { - return roots.get(rootId); + public UI getRootById(int rootId) { + return uIs.get(rootId); } /** diff --git a/server/src/com/vaadin/annotations/EagerInit.java b/server/src/com/vaadin/annotations/EagerInit.java index 5131a79576..462c6bb5ac 100644 --- a/server/src/com/vaadin/annotations/EagerInit.java +++ b/server/src/com/vaadin/annotations/EagerInit.java @@ -21,15 +21,15 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import com.vaadin.terminal.WrappedRequest; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; /** - * Indicates that the init method in a Root class can be called before full + * Indicates that the init method in a UI class can be called before full * browser details ({@link WrappedRequest#getBrowserDetails()}) are available. * This will make the UI appear more quickly, as ensuring the availability of * this information typically requires an additional round trip to the client. * - * @see Root#init(com.vaadin.terminal.WrappedRequest) + * @see UI#init(com.vaadin.terminal.WrappedRequest) * @see WrappedRequest#getBrowserDetails() * * @since 7.0 diff --git a/server/src/com/vaadin/annotations/Theme.java b/server/src/com/vaadin/annotations/Theme.java index e2610d2b3f..052bc245fd 100644 --- a/server/src/com/vaadin/annotations/Theme.java +++ b/server/src/com/vaadin/annotations/Theme.java @@ -21,10 +21,10 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; /** - * Defines a specific theme for a {@link Root}. + * Defines a specific theme for a {@link UI}. */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) diff --git a/server/src/com/vaadin/annotations/Widgetset.java b/server/src/com/vaadin/annotations/Widgetset.java index e80f887691..69e3e19319 100644 --- a/server/src/com/vaadin/annotations/Widgetset.java +++ b/server/src/com/vaadin/annotations/Widgetset.java @@ -21,10 +21,10 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; /** - * Defines a specific theme for a {@link Root}. + * Defines a specific theme for a {@link UI}. */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) diff --git a/server/src/com/vaadin/terminal/AbstractClientConnector.java b/server/src/com/vaadin/terminal/AbstractClientConnector.java index d2490225fb..87e1dbaa38 100644 --- a/server/src/com/vaadin/terminal/AbstractClientConnector.java +++ b/server/src/com/vaadin/terminal/AbstractClientConnector.java @@ -43,7 +43,7 @@ import com.vaadin.terminal.gwt.server.RpcManager; import com.vaadin.terminal.gwt.server.RpcTarget; import com.vaadin.terminal.gwt.server.ServerRpcManager; import com.vaadin.ui.HasComponents; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; /** * An abstract base class for ClientConnector implementations. This class @@ -94,9 +94,9 @@ public abstract class AbstractClientConnector implements ClientConnector { /* Documentation copied from interface */ @Override public void markAsDirty() { - Root root = getRoot(); - if (root != null) { - root.getConnectorTracker().markDirty(this); + UI uI = getRoot(); + if (uI != null) { + uI.getConnectorTracker().markDirty(this); } } @@ -154,8 +154,8 @@ public abstract class AbstractClientConnector implements ClientConnector { sharedState = createState(); } - Root root = getRoot(); - if (root != null && !root.getConnectorTracker().isDirty(this)) { + UI uI = getRoot(); + if (uI != null && !uI.getConnectorTracker().isDirty(this)) { requestRepaint(); } @@ -363,28 +363,28 @@ public abstract class AbstractClientConnector implements ClientConnector { * @return The connector's application, or null if not attached */ protected Application getApplication() { - Root root = getRoot(); - if (root == null) { + UI uI = getRoot(); + if (uI == null) { return null; } else { - return root.getApplication(); + return uI.getApplication(); } } /** - * Finds a Root ancestor of this connector. null is returned if - * no Root ancestor is found (typically because the connector is not + * Finds a UI ancestor of this connector. null is returned if + * no UI ancestor is found (typically because the connector is not * attached to a proper hierarchy). * - * @return the Root ancestor of this connector, or null if none + * @return the UI ancestor of this connector, or null if none * is found. */ @Override - public Root getRoot() { + public UI getRoot() { ClientConnector connector = this; while (connector != null) { - if (connector instanceof Root) { - return (Root) connector; + if (connector instanceof UI) { + return (UI) connector; } connector = connector.getParent(); } diff --git a/server/src/com/vaadin/terminal/AbstractRootProvider.java b/server/src/com/vaadin/terminal/AbstractRootProvider.java index 0b63003440..b340c62448 100644 --- a/server/src/com/vaadin/terminal/AbstractRootProvider.java +++ b/server/src/com/vaadin/terminal/AbstractRootProvider.java @@ -17,13 +17,13 @@ package com.vaadin.terminal; import com.vaadin.Application; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; public abstract class AbstractRootProvider implements RootProvider { @Override - public Root instantiateRoot(Application application, - Class type, WrappedRequest request) { + public UI instantiateRoot(Application application, + Class type, WrappedRequest request) { try { return type.newInstance(); } catch (InstantiationException e) { diff --git a/server/src/com/vaadin/terminal/DefaultRootProvider.java b/server/src/com/vaadin/terminal/DefaultRootProvider.java index cbf8c98828..07533949a0 100644 --- a/server/src/com/vaadin/terminal/DefaultRootProvider.java +++ b/server/src/com/vaadin/terminal/DefaultRootProvider.java @@ -18,12 +18,12 @@ package com.vaadin.terminal; import com.vaadin.Application; import com.vaadin.RootRequiresMoreInformationException; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; public class DefaultRootProvider extends AbstractRootProvider { @Override - public Class getRootClass(Application application, + public Class getRootClass(Application application, WrappedRequest request) throws RootRequiresMoreInformationException { Object rootClassNameObj = application .getProperty(Application.ROOT_PARAMETER); @@ -37,8 +37,8 @@ public class DefaultRootProvider extends AbstractRootProvider { classLoader = getClass().getClassLoader(); } try { - Class rootClass = Class.forName(rootClassName, - true, classLoader).asSubclass(Root.class); + Class rootClass = Class.forName(rootClassName, + true, classLoader).asSubclass(UI.class); return rootClass; } catch (ClassNotFoundException e) { diff --git a/server/src/com/vaadin/terminal/DeploymentConfiguration.java b/server/src/com/vaadin/terminal/DeploymentConfiguration.java index 14a5a3724f..8da088969d 100644 --- a/server/src/com/vaadin/terminal/DeploymentConfiguration.java +++ b/server/src/com/vaadin/terminal/DeploymentConfiguration.java @@ -97,7 +97,7 @@ public interface DeploymentConfiguration extends Serializable { /** * Get the class loader to use for loading classes loaded by name, e.g. - * custom Root classes. null indicates that the default class + * custom UI classes. null indicates that the default class * loader should be used. * * @return the class loader to use, or null diff --git a/server/src/com/vaadin/terminal/Page.java b/server/src/com/vaadin/terminal/Page.java index 41ab8cc8b6..95f9a7b3ec 100644 --- a/server/src/com/vaadin/terminal/Page.java +++ b/server/src/com/vaadin/terminal/Page.java @@ -33,19 +33,19 @@ import com.vaadin.terminal.gwt.server.WebBrowser; import com.vaadin.tools.ReflectTools; import com.vaadin.ui.JavaScript; import com.vaadin.ui.Notification; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; public class Page implements Serializable { /** * Listener that gets notified when the size of the browser window - * containing the root has changed. + * containing the uI has changed. * - * @see Root#addListener(BrowserWindowResizeListener) + * @see UI#addListener(BrowserWindowResizeListener) */ public interface BrowserWindowResizeListener extends Serializable { /** - * Invoked when the browser window containing a Root has been resized. + * Invoked when the browser window containing a UI has been resized. * * @param event * a browser window resize event @@ -54,7 +54,7 @@ public class Page implements Serializable { } /** - * Event that is fired when a browser window containing a root is resized. + * Event that is fired when a browser window containing a uI is resized. */ public class BrowserWindowResizeEvent extends EventObject { @@ -65,7 +65,7 @@ public class Page implements Serializable { * Creates a new event * * @param source - * the root for which the browser window has been resized + * the uI for which the browser window has been resized * @param width * the new width of the browser window * @param height @@ -254,9 +254,9 @@ public class Page implements Serializable { } /** - * Gets the root in which the fragment has changed. + * Gets the uI in which the fragment has changed. * - * @return the root in which the fragment has changed + * @return the uI in which the fragment has changed */ public Page getPage() { return (Page) getSource(); @@ -279,15 +279,15 @@ public class Page implements Serializable { */ private String fragment; - private final Root root; + private final UI uI; private int browserWindowWidth = -1; private int browserWindowHeight = -1; private JavaScript javaScript; - public Page(Root root) { - this.root = root; + public Page(UI uI) { + this.uI = uI; } private void addListener(Class eventType, Object target, Method method) { @@ -332,7 +332,7 @@ public class Page implements Serializable { if (fireEvents) { fireEvent(new FragmentChangedEvent(this, newFragment)); } - root.markAsDirty(); + uI.markAsDirty(); } } @@ -374,7 +374,7 @@ public class Page implements Serializable { } public WebBrowser getWebBrowser() { - return ((WebApplicationContext) root.getApplication().getContext()) + return ((WebApplicationContext) uI.getApplication().getContext()) .getBrowser(); } @@ -399,8 +399,8 @@ public class Page implements Serializable { } /** - * Adds a new {@link BrowserWindowResizeListener} to this root. The listener - * will be notified whenever the browser window within which this root + * Adds a new {@link BrowserWindowResizeListener} to this uI. The listener + * will be notified whenever the browser window within which this uI * resides is resized. * * @param resizeListener @@ -415,7 +415,7 @@ public class Page implements Serializable { } /** - * Removes a {@link BrowserWindowResizeListener} from this root. The + * Removes a {@link BrowserWindowResizeListener} from this uI. The * listener will no longer be notified when the browser window is resized. * * @param resizeListener @@ -427,7 +427,7 @@ public class Page implements Serializable { } /** - * Gets the last known height of the browser window in which this root + * Gets the last known height of the browser window in which this uI * resides. * * @return the browser window height in pixels @@ -437,7 +437,7 @@ public class Page implements Serializable { } /** - * Gets the last known width of the browser window in which this root + * Gets the last known width of the browser window in which this uI * resides. * * @return the browser window width in pixels @@ -450,7 +450,7 @@ public class Page implements Serializable { if (javaScript == null) { // Create and attach on first use javaScript = new JavaScript(); - javaScript.extend(root); + javaScript.extend(uI); } return javaScript; @@ -515,15 +515,15 @@ public class Page implements Serializable { } /** - * Opens the given resource in this root. The contents of this Root is + * Opens the given resource in this uI. The contents of this UI is * replaced by the {@code Resource}. * * @param resource - * the resource to show in this root + * the resource to show in this uI */ public void open(Resource resource) { openList.add(new OpenResource(resource, null, -1, -1, BORDER_DEFAULT)); - root.markAsDirty(); + uI.markAsDirty(); } /** @@ -566,7 +566,7 @@ public class Page implements Serializable { public void open(Resource resource, String windowName) { openList.add(new OpenResource(resource, windowName, -1, -1, BORDER_DEFAULT)); - root.markAsDirty(); + uI.markAsDirty(); } /** @@ -589,7 +589,7 @@ public class Page implements Serializable { int height, BorderStyle border) { openList.add(new OpenResource(resource, windowName, width, height, border)); - root.markAsDirty(); + uI.markAsDirty(); } /** @@ -603,7 +603,7 @@ public class Page implements Serializable { notifications = new LinkedList(); } notifications.add(notification); - root.markAsDirty(); + uI.markAsDirty(); } /** @@ -622,17 +622,17 @@ public class Page implements Serializable { } /** - * Gets the Page to which the current root belongs. This is automatically + * Gets the Page to which the current uI belongs. This is automatically * defined when processing requests to the server. In other cases, (e.g. - * from background threads), the current root is not automatically defined. + * from background threads), the current uI is not automatically defined. * - * @see Root#getCurrent() + * @see UI#getCurrent() * * @return the current page instance if available, otherwise * null */ public static Page getCurrent() { - Root currentRoot = Root.getCurrent(); + UI currentRoot = UI.getCurrent(); if (currentRoot == null) { return null; } @@ -647,7 +647,7 @@ public class Page implements Serializable { * the new page title to set */ public void setTitle(String title) { - root.getRpcProxy(PageClientRpc.class).setTitle(title); + uI.getRpcProxy(PageClientRpc.class).setTitle(title); } } diff --git a/server/src/com/vaadin/terminal/RootProvider.java b/server/src/com/vaadin/terminal/RootProvider.java index 476cf1bd78..53173b6b94 100644 --- a/server/src/com/vaadin/terminal/RootProvider.java +++ b/server/src/com/vaadin/terminal/RootProvider.java @@ -18,12 +18,12 @@ package com.vaadin.terminal; import com.vaadin.Application; import com.vaadin.RootRequiresMoreInformationException; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; public interface RootProvider { - public Class getRootClass(Application application, + public Class getRootClass(Application application, WrappedRequest request) throws RootRequiresMoreInformationException; - public Root instantiateRoot(Application application, - Class type, WrappedRequest request); + public UI instantiateRoot(Application application, + Class type, WrappedRequest request); } diff --git a/server/src/com/vaadin/terminal/WrappedRequest.java b/server/src/com/vaadin/terminal/WrappedRequest.java index c317eae048..1186d678b0 100644 --- a/server/src/com/vaadin/terminal/WrappedRequest.java +++ b/server/src/com/vaadin/terminal/WrappedRequest.java @@ -30,7 +30,7 @@ import com.vaadin.Application; import com.vaadin.RootRequiresMoreInformationException; import com.vaadin.annotations.EagerInit; import com.vaadin.terminal.gwt.server.WebBrowser; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; /** * A generic request to the server, wrapping a more specific request type, e.g. @@ -221,7 +221,7 @@ public interface WrappedRequest extends Serializable { * This information is only guaranteed to be available in some special * cases, for instance when {@link Application#getRoot} is called again * after throwing {@link RootRequiresMoreInformationException} or in - * {@link Root#init(WrappedRequest)} for a Root class not annotated with + * {@link UI#init(WrappedRequest)} for a UI class not annotated with * {@link EagerInit} * * @return the browser details, or null if details are not diff --git a/server/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java b/server/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java index bd39504237..2315a9c1d6 100644 --- a/server/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java +++ b/server/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java @@ -62,7 +62,7 @@ import com.vaadin.terminal.Terminal; import com.vaadin.terminal.WrappedRequest; import com.vaadin.terminal.WrappedResponse; import com.vaadin.terminal.gwt.server.AbstractCommunicationManager.Callback; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; /** * Portlet 2.0 base class. This replaces the servlet in servlet/portlet 1.0 @@ -488,17 +488,17 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet /* Notify listeners */ // Finds the window within the application - Root root = null; + UI uI = null; synchronized (application) { if (application.isRunning()) { switch (requestType) { case RENDER: case ACTION: // Both action requests and render requests are ok - // without a Root as they render the initial HTML + // without a UI as they render the initial HTML // and then do a second request try { - root = application + uI = application .getRootForRequest(wrappedRequest); } catch (RootRequiresMoreInformationException e) { // Ignore problem and continue without root @@ -516,7 +516,7 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet // root = application.getRoot(); break; default: - root = application + uI = application .getRootForRequest(wrappedRequest); } // if window not found, not a problem - use null @@ -527,25 +527,25 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet // starts? if (request instanceof RenderRequest) { applicationContext.firePortletRenderRequest(application, - root, (RenderRequest) request, + uI, (RenderRequest) request, (RenderResponse) response); } else if (request instanceof ActionRequest) { applicationContext.firePortletActionRequest(application, - root, (ActionRequest) request, + uI, (ActionRequest) request, (ActionResponse) response); } else if (request instanceof EventRequest) { applicationContext.firePortletEventRequest(application, - root, (EventRequest) request, + uI, (EventRequest) request, (EventResponse) response); } else if (request instanceof ResourceRequest) { applicationContext.firePortletResourceRequest(application, - root, (ResourceRequest) request, + uI, (ResourceRequest) request, (ResourceResponse) response); } /* Handle the request */ if (requestType == RequestType.FILE_UPLOAD) { - // Root is resolved in handleFileUpload by + // UI is resolved in handleFileUpload by // PortletCommunicationManager applicationManager.handleFileUpload(application, wrappedRequest, wrappedResponse); @@ -557,7 +557,7 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet } else if (requestType == RequestType.UIDL) { // Handles AJAX UIDL requests applicationManager.handleUidlRequest(wrappedRequest, - wrappedResponse, portletWrapper, root); + wrappedResponse, portletWrapper, uI); return; } else { /* @@ -599,7 +599,7 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet } } finally { - Root.setCurrent(null); + UI.setCurrent(null); Application.setCurrent(null); PortletSession session = request diff --git a/server/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java b/server/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java index 062ba6cdf7..b17ef20cde 100644 --- a/server/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java +++ b/server/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java @@ -56,7 +56,7 @@ import com.vaadin.terminal.ThemeResource; import com.vaadin.terminal.WrappedRequest; import com.vaadin.terminal.WrappedResponse; import com.vaadin.terminal.gwt.server.AbstractCommunicationManager.Callback; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; /** * Abstract implementation of the ApplicationServlet which handles all @@ -314,18 +314,18 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements /* Handle the request */ if (requestType == RequestType.FILE_UPLOAD) { - // Root is resolved in communication manager + // UI is resolved in communication manager applicationManager.handleFileUpload(application, request, response); return; } else if (requestType == RequestType.UIDL) { - Root root = application.getRootForRequest(request); - if (root == null) { + UI uI = application.getRootForRequest(request); + if (uI == null) { throw new ServletException(ERROR_NO_ROOT_FOUND); } // Handles AJAX UIDL requests applicationManager.handleUidlRequest(request, response, - servletWrapper, root); + servletWrapper, uI); return; } else if (requestType == RequestType.BROWSER_DETAILS) { // Browser details - not related to a specific root @@ -369,7 +369,7 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements .onRequestEnd(request, response); } } finally { - Root.setCurrent(null); + UI.setCurrent(null); Application.setCurrent(null); HttpSession session = request.getSession(false); diff --git a/server/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java b/server/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java index b2436b2ce4..39475f3131 100644 --- a/server/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java +++ b/server/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java @@ -97,7 +97,7 @@ import com.vaadin.ui.AbstractField; import com.vaadin.ui.Component; import com.vaadin.ui.ConnectorTracker; import com.vaadin.ui.HasComponents; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; import com.vaadin.ui.Window; /** @@ -506,7 +506,7 @@ public abstract class AbstractCommunicationManager implements Serializable { * Internally process a UIDL request from the client. * * This method calls - * {@link #handleVariables(WrappedRequest, WrappedResponse, Callback, Application, Root)} + * {@link #handleVariables(WrappedRequest, WrappedResponse, Callback, Application, UI)} * to process any changes to variables by the client and then repaints * affected components using {@link #paintAfterVariableChanges()}. * @@ -520,7 +520,7 @@ public abstract class AbstractCommunicationManager implements Serializable { * @param request * @param response * @param callback - * @param root + * @param uI * target window for the UIDL request, can be null if target not * found * @throws IOException @@ -528,7 +528,7 @@ public abstract class AbstractCommunicationManager implements Serializable { * @throws JSONException */ public void handleUidlRequest(WrappedRequest request, - WrappedResponse response, Callback callback, Root root) + WrappedResponse response, Callback callback, UI uI) throws IOException, InvalidUIDLSecurityKeyException, JSONException { checkWidgetsetVersion(request); @@ -550,7 +550,7 @@ public abstract class AbstractCommunicationManager implements Serializable { if (request.getParameter(GET_PARAM_HIGHLIGHT_COMPONENT) != null) { String pid = request .getParameter(GET_PARAM_HIGHLIGHT_COMPONENT); - highlightedConnector = root.getConnectorTracker().getConnector( + highlightedConnector = uI.getConnectorTracker().getConnector( pid); highlightConnector(highlightedConnector); } @@ -567,7 +567,7 @@ public abstract class AbstractCommunicationManager implements Serializable { // Finds the window within the application if (application.isRunning()) { // Returns if no window found - if (root == null) { + if (uI == null) { // This should not happen, no windows exists but // application is still open. getLogger().warning("Could not get root for application"); @@ -580,7 +580,7 @@ public abstract class AbstractCommunicationManager implements Serializable { } // Change all variables based on request parameters - if (!handleVariables(request, response, callback, application, root)) { + if (!handleVariables(request, response, callback, application, uI)) { // var inconsistency; the client is probably out-of-sync SystemMessages ci = null; @@ -611,8 +611,8 @@ public abstract class AbstractCommunicationManager implements Serializable { } paintAfterVariableChanges(request, response, callback, repaintAll, - outWriter, root, analyzeLayouts); - postPaint(root); + outWriter, uI, analyzeLayouts); + postPaint(uI); } outWriter.close(); @@ -645,20 +645,20 @@ public abstract class AbstractCommunicationManager implements Serializable { * Method called after the paint phase while still being synchronized on the * application * - * @param root + * @param uI * */ - protected void postPaint(Root root) { + protected void postPaint(UI uI) { // Remove connectors that have been detached from the application during // handling of the request - root.getConnectorTracker().cleanConnectorMap(); + uI.getConnectorTracker().cleanConnectorMap(); if (pidToNameToStreamVariable != null) { Iterator iterator = pidToNameToStreamVariable.keySet() .iterator(); while (iterator.hasNext()) { String connectorId = iterator.next(); - if (root.getConnectorTracker().getConnector(connectorId) == null) { + if (uI.getConnectorTracker().getConnector(connectorId) == null) { // Owner is no longer attached to the application Map removed = pidToNameToStreamVariable .get(connectorId); @@ -746,7 +746,7 @@ public abstract class AbstractCommunicationManager implements Serializable { */ private void paintAfterVariableChanges(WrappedRequest request, WrappedResponse response, Callback callback, boolean repaintAll, - final PrintWriter outWriter, Root root, boolean analyzeLayouts) + final PrintWriter outWriter, UI uI, boolean analyzeLayouts) throws PaintException, IOException, JSONException { // Removes application if it has stopped during variable changes @@ -765,7 +765,7 @@ public abstract class AbstractCommunicationManager implements Serializable { outWriter.print(getSecurityKeyUIDL(request)); } - writeUidlResponse(request, repaintAll, outWriter, root, analyzeLayouts); + writeUidlResponse(request, repaintAll, outWriter, uI, analyzeLayouts); closeJsonMessage(outWriter); @@ -810,15 +810,15 @@ public abstract class AbstractCommunicationManager implements Serializable { @SuppressWarnings("unchecked") public void writeUidlResponse(WrappedRequest request, boolean repaintAll, - final PrintWriter outWriter, Root root, boolean analyzeLayouts) + final PrintWriter outWriter, UI uI, boolean analyzeLayouts) throws PaintException, JSONException { ArrayList dirtyVisibleConnectors = new ArrayList(); - Application application = root.getApplication(); + Application application = uI.getApplication(); // Paints components - ConnectorTracker rootConnectorTracker = root.getConnectorTracker(); + ConnectorTracker rootConnectorTracker = uI.getConnectorTracker(); getLogger().log(Level.FINE, "* Creating response to client"); if (repaintAll) { - getClientCache(root).clear(); + getClientCache(uI).clear(); rootConnectorTracker.markAllConnectorsDirty(); rootConnectorTracker.markAllClientSidesUninitialized(); @@ -851,12 +851,12 @@ public abstract class AbstractCommunicationManager implements Serializable { if (analyzeLayouts) { invalidComponentRelativeSizes = ComponentSizeValidator - .validateComponentRelativeSizes(root.getContent(), null, + .validateComponentRelativeSizes(uI.getContent(), null, null); // Also check any existing subwindows - if (root.getWindows() != null) { - for (Window subWindow : root.getWindows()) { + if (uI.getWindows() != null) { + for (Window subWindow : uI.getWindows()) { invalidComponentRelativeSizes = ComponentSizeValidator .validateComponentRelativeSizes( subWindow.getContent(), @@ -985,7 +985,7 @@ public abstract class AbstractCommunicationManager implements Serializable { // } paramJson.put(JsonCodec.encode( invocation.getParameters()[i], referenceParameter, - parameterType, root.getConnectorTracker())); + parameterType, uI.getConnectorTracker())); } invocationJson.put(paramJson); rpcCalls.put(invocationJson); @@ -1087,7 +1087,7 @@ public abstract class AbstractCommunicationManager implements Serializable { final String resource = (String) i.next(); InputStream is = null; try { - is = getThemeResourceAsStream(root, getTheme(root), resource); + is = getThemeResourceAsStream(uI, getTheme(uI), resource); } catch (final Exception e) { // FIXME: Handle exception getLogger().log(Level.FINER, @@ -1124,7 +1124,7 @@ public abstract class AbstractCommunicationManager implements Serializable { Collection> usedClientConnectors = paintTarget .getUsedClientConnectors(); boolean typeMappingsOpen = false; - ClientCache clientCache = getClientCache(root); + ClientCache clientCache = getClientCache(uI); List> newConnectorTypes = new ArrayList>(); @@ -1245,8 +1245,8 @@ public abstract class AbstractCommunicationManager implements Serializable { public static JSONObject encodeState(ClientConnector connector, SharedState state) throws JSONException { - Root root = connector.getRoot(); - ConnectorTracker connectorTracker = root.getConnectorTracker(); + UI uI = connector.getRoot(); + ConnectorTracker connectorTracker = uI.getConnectorTracker(); Class stateType = connector.getStateType(); Object diffState = connectorTracker.getDiffState(connector); if (diffState == null) { @@ -1260,7 +1260,7 @@ public abstract class AbstractCommunicationManager implements Serializable { try { SharedState referenceState = stateType.newInstance(); diffState = JsonCodec.encode(referenceState, null, - stateType, root.getConnectorTracker()); + stateType, uI.getConnectorTracker()); } catch (Exception e) { getLogger().log( Level.WARNING, @@ -1271,7 +1271,7 @@ public abstract class AbstractCommunicationManager implements Serializable { } } JSONObject stateJson = (JSONObject) JsonCodec.encode(state, diffState, - stateType, root.getConnectorTracker()); + stateType, uI.getConnectorTracker()); return stateJson; } @@ -1389,8 +1389,8 @@ public abstract class AbstractCommunicationManager implements Serializable { } - private ClientCache getClientCache(Root root) { - Integer rootId = Integer.valueOf(root.getRootId()); + private ClientCache getClientCache(UI uI) { + Integer rootId = Integer.valueOf(uI.getRootId()); ClientCache cache = rootToClientCache.get(rootId); if (cache == null) { cache = new ClientCache(); @@ -1440,7 +1440,7 @@ public abstract class AbstractCommunicationManager implements Serializable { HasComponents parent = child.getParent(); if (parent == null) { - if (child instanceof Root) { + if (child instanceof UI) { return child.isVisible(); } else { return false; @@ -1507,15 +1507,15 @@ public abstract class AbstractCommunicationManager implements Serializable { return pendingInvocations; } - protected abstract InputStream getThemeResourceAsStream(Root root, + protected abstract InputStream getThemeResourceAsStream(UI uI, String themeName, String resource); private int getTimeoutInterval() { return maxInactiveInterval; } - private String getTheme(Root root) { - String themeName = root.getApplication().getThemeForRoot(root); + private String getTheme(UI uI) { + String themeName = uI.getApplication().getThemeForRoot(uI); String requestThemeName = getRequestTheme(); if (requestThemeName != null) { @@ -1554,7 +1554,7 @@ public abstract class AbstractCommunicationManager implements Serializable { */ private boolean handleVariables(WrappedRequest request, WrappedResponse response, Callback callback, - Application application2, Root root) throws IOException, + Application application2, UI uI) throws IOException, InvalidUIDLSecurityKeyException, JSONException { boolean success = true; @@ -1590,7 +1590,7 @@ public abstract class AbstractCommunicationManager implements Serializable { for (int bi = 1; bi < bursts.length; bi++) { // unescape any encoded separator characters in the burst final String burst = unescapeBurst(bursts[bi]); - success &= handleBurst(request, root, burst); + success &= handleBurst(request, uI, burst); // In case that there were multiple bursts, we know that this is // a special synchronous case for closing window. Thus we are @@ -1605,7 +1605,7 @@ public abstract class AbstractCommunicationManager implements Serializable { new CharArrayWriter()); paintAfterVariableChanges(request, response, callback, - true, outWriter, root, false); + true, outWriter, uI, false); } @@ -1632,23 +1632,23 @@ public abstract class AbstractCommunicationManager implements Serializable { * directly. * * @param source - * @param root + * @param uI * the root receiving the burst * @param burst * the content of the burst as a String to be parsed * @return true if the processing of the burst was successful and there were * no messages to non-existent components */ - public boolean handleBurst(WrappedRequest source, Root root, + public boolean handleBurst(WrappedRequest source, UI uI, final String burst) { boolean success = true; try { Set enabledConnectors = new HashSet(); List invocations = parseInvocations( - root.getConnectorTracker(), burst); + uI.getConnectorTracker(), burst); for (MethodInvocation invocation : invocations) { - final ClientConnector connector = getConnector(root, + final ClientConnector connector = getConnector(uI, invocation.getConnectorId()); if (connector != null && connector.isConnectorEnabled()) { @@ -1659,7 +1659,7 @@ public abstract class AbstractCommunicationManager implements Serializable { for (int i = 0; i < invocations.size(); i++) { MethodInvocation invocation = invocations.get(i); - final ClientConnector connector = getConnector(root, + final ClientConnector connector = getConnector(uI, invocation.getConnectorId()); if (connector == null) { @@ -1715,7 +1715,7 @@ public abstract class AbstractCommunicationManager implements Serializable { if (connector instanceof Component) { errorComponent = (Component) connector; } - handleChangeVariablesError(root.getApplication(), + handleChangeVariablesError(uI.getApplication(), errorComponent, realException, null); } } else { @@ -1747,7 +1747,7 @@ public abstract class AbstractCommunicationManager implements Serializable { errorComponent = (Component) dropHandlerOwner; } } - handleChangeVariablesError(root.getApplication(), + handleChangeVariablesError(uI.getApplication(), errorComponent, e, changes); } } @@ -1877,8 +1877,8 @@ public abstract class AbstractCommunicationManager implements Serializable { owner.changeVariables(source, m); } - protected ClientConnector getConnector(Root root, String connectorId) { - ClientConnector c = root.getConnectorTracker() + protected ClientConnector getConnector(UI uI, String connectorId) { + ClientConnector c = uI.getConnectorTracker() .getConnector(connectorId); if (c == null && connectorId.equals(getDragAndDropService().getConnectorId())) { @@ -2417,18 +2417,18 @@ public abstract class AbstractCommunicationManager implements Serializable { // if we do not yet have a currentRoot, it should be initialized // shortly, and we should send the initial UIDL - boolean sendUIDL = Root.getCurrent() == null; + boolean sendUIDL = UI.getCurrent() == null; try { CombinedRequest combinedRequest = new CombinedRequest(request); - Root root = application.getRootForRequest(combinedRequest); + UI uI = application.getRootForRequest(combinedRequest); response.setContentType("application/json; charset=UTF-8"); // Use the same logic as for determined roots BootstrapHandler bootstrapHandler = getBootstrapHandler(); BootstrapContext context = bootstrapHandler.createContext( - combinedRequest, response, application, root.getRootId()); + combinedRequest, response, application, uI.getRootId()); String widgetset = context.getWidgetsetName(); String theme = context.getThemeName(); @@ -2439,10 +2439,10 @@ public abstract class AbstractCommunicationManager implements Serializable { JSONObject params = new JSONObject(); params.put("widgetset", widgetset); params.put("themeUri", themeUri); - // Root id might have changed based on e.g. window.name - params.put(ApplicationConstants.ROOT_ID_PARAMETER, root.getRootId()); + // UI id might have changed based on e.g. window.name + params.put(ApplicationConstants.ROOT_ID_PARAMETER, uI.getRootId()); if (sendUIDL) { - String initialUIDL = getInitialUIDL(combinedRequest, root); + String initialUIDL = getInitialUIDL(combinedRequest, uI); params.put("uidl", initialUIDL); } @@ -2473,7 +2473,7 @@ public abstract class AbstractCommunicationManager implements Serializable { * * @param request * the request that caused the initialization - * @param root + * @param uI * the root for which the UIDL should be generated * @return a string with the initial UIDL message * @throws PaintException @@ -2481,16 +2481,16 @@ public abstract class AbstractCommunicationManager implements Serializable { * @throws JSONException * if an exception occurs while encoding output */ - protected String getInitialUIDL(WrappedRequest request, Root root) + protected String getInitialUIDL(WrappedRequest request, UI uI) throws PaintException, JSONException { // TODO maybe unify writeUidlResponse()? StringWriter sWriter = new StringWriter(); PrintWriter pWriter = new PrintWriter(sWriter); pWriter.print("{"); - if (isXSRFEnabled(root.getApplication())) { + if (isXSRFEnabled(uI.getApplication())) { pWriter.print(getSecurityKeyUIDL(request)); } - writeUidlResponse(request, true, pWriter, root, false); + writeUidlResponse(request, true, pWriter, uI, false); pWriter.print("}"); String initialUIDL = sWriter.toString(); getLogger().log(Level.FINE, "Initial UIDL:" + initialUIDL); @@ -2628,15 +2628,15 @@ public abstract class AbstractCommunicationManager implements Serializable { String rootId = parts[0]; String connectorId = parts[1]; String variableName = parts[2]; - Root root = application.getRootById(Integer.parseInt(rootId)); - Root.setCurrent(root); + UI uI = application.getRootById(Integer.parseInt(rootId)); + UI.setCurrent(uI); StreamVariable streamVariable = getStreamVariable(connectorId, variableName); String secKey = streamVariableToSeckey.get(streamVariable); if (secKey.equals(parts[3])) { - ClientConnector source = getConnector(root, connectorId); + ClientConnector source = getConnector(uI, connectorId); String contentType = request.getContentType(); if (contentType.contains("boundary")) { // Multipart requests contain boundary string diff --git a/server/src/com/vaadin/terminal/gwt/server/BootstrapFragmentResponse.java b/server/src/com/vaadin/terminal/gwt/server/BootstrapFragmentResponse.java index fabb69784f..df77600150 100644 --- a/server/src/com/vaadin/terminal/gwt/server/BootstrapFragmentResponse.java +++ b/server/src/com/vaadin/terminal/gwt/server/BootstrapFragmentResponse.java @@ -49,7 +49,7 @@ public class BootstrapFragmentResponse extends BootstrapResponse { * the application for which the bootstrap page should be * generated * @param rootId - * the generated id of the Root that will be displayed on the + * the generated id of the UI that will be displayed on the * page * @param fragmentNodes * a mutable list containing the DOM nodes that will make up the diff --git a/server/src/com/vaadin/terminal/gwt/server/BootstrapHandler.java b/server/src/com/vaadin/terminal/gwt/server/BootstrapHandler.java index fad80cacaa..b6953da35e 100644 --- a/server/src/com/vaadin/terminal/gwt/server/BootstrapHandler.java +++ b/server/src/com/vaadin/terminal/gwt/server/BootstrapHandler.java @@ -47,7 +47,7 @@ import com.vaadin.terminal.PaintException; import com.vaadin.terminal.RequestHandler; import com.vaadin.terminal.WrappedRequest; import com.vaadin.terminal.WrappedResponse; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; public abstract class BootstrapHandler implements RequestHandler { @@ -82,14 +82,14 @@ public abstract class BootstrapHandler implements RequestHandler { return bootstrapResponse.getRootId(); } - public Root getRoot() { + public UI getRoot() { return bootstrapResponse.getRoot(); } public String getWidgetsetName() { if (widgetsetName == null) { - Root root = getRoot(); - if (root != null) { + UI uI = getRoot(); + if (uI != null) { widgetsetName = getWidgetsetForRoot(this); } } @@ -98,8 +98,8 @@ public abstract class BootstrapHandler implements RequestHandler { public String getThemeName() { if (themeName == null) { - Root root = getRoot(); - if (root != null) { + UI uI = getRoot(); + if (uI != null) { themeName = findAndEscapeThemeName(this); } } @@ -127,13 +127,13 @@ public abstract class BootstrapHandler implements RequestHandler { // TODO Should all urls be handled here? Integer rootId = null; try { - Root root = application.getRootForRequest(request); - if (root == null) { - writeError(response, new Throwable("No Root found")); + UI uI = application.getRootForRequest(request); + if (uI == null) { + writeError(response, new Throwable("No UI found")); return true; } - rootId = Integer.valueOf(root.getRootId()); + rootId = Integer.valueOf(uI.getRootId()); } catch (RootRequiresMoreInformationException e) { // Just keep going without rootId } @@ -246,8 +246,8 @@ public abstract class BootstrapHandler implements RequestHandler { head.appendElement("meta").attr("http-equiv", "X-UA-Compatible") .attr("content", "chrome=1"); - Root root = context.getRoot(); - String title = ((root == null || root.getCaption() == null) ? "" : root + UI uI = context.getRoot(); + String title = ((uI == null || uI.getCaption() == null) ? "" : uI .getCaption()); head.appendElement("title").appendText(title); @@ -294,10 +294,10 @@ public abstract class BootstrapHandler implements RequestHandler { protected abstract String getApplicationId(BootstrapContext context); public String getWidgetsetForRoot(BootstrapContext context) { - Root root = context.getRoot(); + UI uI = context.getRoot(); WrappedRequest request = context.getRequest(); - String widgetset = root.getApplication().getWidgetsetForRoot(root); + String widgetset = uI.getApplication().getWidgetsetForRoot(uI); if (widgetset == null) { widgetset = request.getDeploymentConfiguration() .getConfiguredWidgetset(request); @@ -568,7 +568,7 @@ public abstract class BootstrapHandler implements RequestHandler { * * @param request * the originating request - * @param root + * @param uI * the root for which the UIDL should be generated * @return a string with the initial UIDL message * @throws PaintException @@ -576,7 +576,7 @@ public abstract class BootstrapHandler implements RequestHandler { * @throws JSONException * if an exception occurs while formatting the output */ - protected abstract String getInitialUIDL(WrappedRequest request, Root root) + protected abstract String getInitialUIDL(WrappedRequest request, UI uI) throws PaintException, JSONException; } diff --git a/server/src/com/vaadin/terminal/gwt/server/BootstrapPageResponse.java b/server/src/com/vaadin/terminal/gwt/server/BootstrapPageResponse.java index e7440f4c22..535ab23c92 100644 --- a/server/src/com/vaadin/terminal/gwt/server/BootstrapPageResponse.java +++ b/server/src/com/vaadin/terminal/gwt/server/BootstrapPageResponse.java @@ -52,7 +52,7 @@ public class BootstrapPageResponse extends BootstrapResponse { * the application for which the bootstrap page should be * generated * @param rootId - * the generated id of the Root that will be displayed on the + * the generated id of the UI that will be displayed on the * page * @param document * the DOM document making up the HTML page diff --git a/server/src/com/vaadin/terminal/gwt/server/BootstrapResponse.java b/server/src/com/vaadin/terminal/gwt/server/BootstrapResponse.java index 10f97e7e79..4f69dda48b 100644 --- a/server/src/com/vaadin/terminal/gwt/server/BootstrapResponse.java +++ b/server/src/com/vaadin/terminal/gwt/server/BootstrapResponse.java @@ -21,7 +21,7 @@ import java.util.EventObject; import com.vaadin.Application; import com.vaadin.RootRequiresMoreInformationException; import com.vaadin.terminal.WrappedRequest; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; /** * Base class providing common functionality used in different bootstrap @@ -47,7 +47,7 @@ public abstract class BootstrapResponse extends EventObject { * the application for which the bootstrap page should be * generated * @param rootId - * the generated id of the Root that will be displayed on the + * the generated id of the UI that will be displayed on the * page */ public BootstrapResponse(BootstrapHandler handler, WrappedRequest request, @@ -93,7 +93,7 @@ public abstract class BootstrapResponse extends EventObject { /** * Gets the root id that has been generated for this response. Please note * that if {@link Application#isRootPreserved()} is enabled, a previously - * created Root with a different id might eventually end up being used. + * created UI with a different id might eventually end up being used. * * @return the root id */ @@ -102,21 +102,21 @@ public abstract class BootstrapResponse extends EventObject { } /** - * Gets the Root for which this page is being rendered, if available. Some - * features of the framework will postpone the Root selection until after + * Gets the UI for which this page is being rendered, if available. Some + * features of the framework will postpone the UI selection until after * the bootstrap page has been rendered and required information from the * browser has been sent back. This method will return null if - * no Root instance is yet available. + * no UI instance is yet available. * * @see Application#isRootPreserved() * @see Application#getRoot(WrappedRequest) * @see RootRequiresMoreInformationException * - * @return The Root that will be displayed in the page being generated, or + * @return The UI that will be displayed in the page being generated, or * null if all required information is not yet * available. */ - public Root getRoot() { - return Root.getCurrent(); + public UI getRoot() { + return UI.getCurrent(); } } diff --git a/server/src/com/vaadin/terminal/gwt/server/ClientConnector.java b/server/src/com/vaadin/terminal/gwt/server/ClientConnector.java index 24675c9e45..3a18dbd6f4 100644 --- a/server/src/com/vaadin/terminal/gwt/server/ClientConnector.java +++ b/server/src/com/vaadin/terminal/gwt/server/ClientConnector.java @@ -26,7 +26,7 @@ import com.vaadin.terminal.AbstractClientConnector; import com.vaadin.terminal.Extension; import com.vaadin.ui.Component; import com.vaadin.ui.ComponentContainer; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; /** * Interface implemented by all connectors that are capable of communicating @@ -177,10 +177,10 @@ public interface ClientConnector extends Connector, RpcTarget { /** * Returns the root this connector is attached to * - * @return The Root this connector is attached to or null if it is not - * attached to any Root + * @return The UI this connector is attached to or null if it is not + * attached to any UI */ - public Root getRoot(); + public UI getRoot(); /** * Called before the shared state and RPC invocations are sent to the diff --git a/server/src/com/vaadin/terminal/gwt/server/ClientMethodInvocation.java b/server/src/com/vaadin/terminal/gwt/server/ClientMethodInvocation.java index 25d0b23725..7cc5159bc0 100644 --- a/server/src/com/vaadin/terminal/gwt/server/ClientMethodInvocation.java +++ b/server/src/com/vaadin/terminal/gwt/server/ClientMethodInvocation.java @@ -34,7 +34,7 @@ public class ClientMethodInvocation implements Serializable, private final Object[] parameters; private Type[] parameterTypes; - // used for sorting calls between different connectors in the same Root + // used for sorting calls between different connectors in the same UI private final long sequenceNumber; // TODO may cause problems when clustering etc. private static long counter = 0; diff --git a/server/src/com/vaadin/terminal/gwt/server/CommunicationManager.java b/server/src/com/vaadin/terminal/gwt/server/CommunicationManager.java index e0386b51b4..7551e849a1 100644 --- a/server/src/com/vaadin/terminal/gwt/server/CommunicationManager.java +++ b/server/src/com/vaadin/terminal/gwt/server/CommunicationManager.java @@ -25,7 +25,7 @@ import com.vaadin.Application; import com.vaadin.external.json.JSONException; import com.vaadin.terminal.PaintException; import com.vaadin.terminal.WrappedRequest; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; /** * Application manager processes changes and paints for single application @@ -111,17 +111,17 @@ public class CommunicationManager extends AbstractCommunicationManager { } @Override - protected String getInitialUIDL(WrappedRequest request, Root root) + protected String getInitialUIDL(WrappedRequest request, UI uI) throws PaintException, JSONException { - return CommunicationManager.this.getInitialUIDL(request, root); + return CommunicationManager.this.getInitialUIDL(request, uI); } }; } @Override - protected InputStream getThemeResourceAsStream(Root root, String themeName, + protected InputStream getThemeResourceAsStream(UI uI, String themeName, String resource) { - WebApplicationContext context = (WebApplicationContext) root + WebApplicationContext context = (WebApplicationContext) uI .getApplication().getContext(); ServletContext servletContext = context.getHttpSession() .getServletContext(); diff --git a/server/src/com/vaadin/terminal/gwt/server/DragAndDropService.java b/server/src/com/vaadin/terminal/gwt/server/DragAndDropService.java index 221598171c..42312b72fd 100644 --- a/server/src/com/vaadin/terminal/gwt/server/DragAndDropService.java +++ b/server/src/com/vaadin/terminal/gwt/server/DragAndDropService.java @@ -40,7 +40,7 @@ import com.vaadin.terminal.Extension; import com.vaadin.terminal.PaintException; import com.vaadin.terminal.VariableOwner; import com.vaadin.ui.Component; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; public class DragAndDropService implements VariableOwner, ClientConnector { @@ -327,7 +327,7 @@ public class DragAndDropService implements VariableOwner, ClientConnector { } @Override - public Root getRoot() { + public UI getRoot() { return null; } diff --git a/server/src/com/vaadin/terminal/gwt/server/PortletApplicationContext2.java b/server/src/com/vaadin/terminal/gwt/server/PortletApplicationContext2.java index eba7d6e3a3..a5a3e94954 100644 --- a/server/src/com/vaadin/terminal/gwt/server/PortletApplicationContext2.java +++ b/server/src/com/vaadin/terminal/gwt/server/PortletApplicationContext2.java @@ -46,7 +46,7 @@ import javax.xml.namespace.QName; import com.vaadin.Application; import com.vaadin.terminal.ExternalResource; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; /** * TODO Write documentation, fix JavaDoc tags. @@ -180,18 +180,18 @@ public class PortletApplicationContext2 extends AbstractWebApplicationContext { } } - public void firePortletRenderRequest(Application app, Root root, + public void firePortletRenderRequest(Application app, UI uI, RenderRequest request, RenderResponse response) { Set listeners = portletListeners.get(app); if (listeners != null) { for (PortletListener l : listeners) { l.handleRenderRequest(request, new RestrictedRenderResponse( - response), root); + response), uI); } } } - public void firePortletActionRequest(Application app, Root root, + public void firePortletActionRequest(Application app, UI uI, ActionRequest request, ActionResponse response) { String key = request.getParameter(ActionRequest.ACTION_NAME); if (eventActionDestinationMap.containsKey(key)) { @@ -213,28 +213,28 @@ public class PortletApplicationContext2 extends AbstractWebApplicationContext { Set listeners = portletListeners.get(app); if (listeners != null) { for (PortletListener l : listeners) { - l.handleActionRequest(request, response, root); + l.handleActionRequest(request, response, uI); } } } } - public void firePortletEventRequest(Application app, Root root, + public void firePortletEventRequest(Application app, UI uI, EventRequest request, EventResponse response) { Set listeners = portletListeners.get(app); if (listeners != null) { for (PortletListener l : listeners) { - l.handleEventRequest(request, response, root); + l.handleEventRequest(request, response, uI); } } } - public void firePortletResourceRequest(Application app, Root root, + public void firePortletResourceRequest(Application app, UI uI, ResourceRequest request, ResourceResponse response) { Set listeners = portletListeners.get(app); if (listeners != null) { for (PortletListener l : listeners) { - l.handleResourceRequest(request, response, root); + l.handleResourceRequest(request, response, uI); } } } @@ -242,16 +242,16 @@ public class PortletApplicationContext2 extends AbstractWebApplicationContext { public interface PortletListener extends Serializable { public void handleRenderRequest(RenderRequest request, - RenderResponse response, Root root); + RenderResponse response, UI uI); public void handleActionRequest(ActionRequest request, - ActionResponse response, Root root); + ActionResponse response, UI uI); public void handleEventRequest(EventRequest request, - EventResponse response, Root root); + EventResponse response, UI uI); public void handleResourceRequest(ResourceRequest request, - ResourceResponse response, Root root); + ResourceResponse response, UI uI); } /** @@ -295,7 +295,7 @@ public class PortletApplicationContext2 extends AbstractWebApplicationContext { * Event names for events sent and received by a portlet need to be declared * in portlet.xml . * - * @param root + * @param uI * a window in which a temporary action URL can be opened if * necessary * @param name @@ -304,7 +304,7 @@ public class PortletApplicationContext2 extends AbstractWebApplicationContext { * event value object that is Serializable and, if appropriate, * has a valid JAXB annotation */ - public void sendPortletEvent(Root root, QName name, Serializable value) + public void sendPortletEvent(UI uI, QName name, Serializable value) throws IllegalStateException { if (response instanceof MimeResponse) { String actionKey = "" + System.currentTimeMillis(); @@ -315,7 +315,7 @@ public class PortletApplicationContext2 extends AbstractWebApplicationContext { if (actionUrl != null) { eventActionDestinationMap.put(actionKey, name); eventActionValueMap.put(actionKey, value); - root.getPage().open(new ExternalResource(actionUrl.toString())); + uI.getPage().open(new ExternalResource(actionUrl.toString())); } else { // this should never happen as we already know the response is a // MimeResponse @@ -342,7 +342,7 @@ public class PortletApplicationContext2 extends AbstractWebApplicationContext { * Shared parameters set or read by a portlet need to be declared in * portlet.xml . * - * @param root + * @param uI * a window in which a temporary action URL can be opened if * necessary * @param name @@ -350,7 +350,7 @@ public class PortletApplicationContext2 extends AbstractWebApplicationContext { * @param value * parameter value */ - public void setSharedRenderParameter(Root root, String name, String value) + public void setSharedRenderParameter(UI uI, String name, String value) throws IllegalStateException { if (response instanceof MimeResponse) { String actionKey = "" + System.currentTimeMillis(); @@ -361,7 +361,7 @@ public class PortletApplicationContext2 extends AbstractWebApplicationContext { if (actionUrl != null) { sharedParameterActionNameMap.put(actionKey, name); sharedParameterActionValueMap.put(actionKey, value); - root.getPage().open(new ExternalResource(actionUrl.toString())); + uI.getPage().open(new ExternalResource(actionUrl.toString())); } else { // this should never happen as we already know the response is a // MimeResponse @@ -381,7 +381,7 @@ public class PortletApplicationContext2 extends AbstractWebApplicationContext { * * Portlet modes used by a portlet need to be declared in portlet.xml . * - * @param root + * @param uI * a window in which the render URL can be opened if necessary * @param portletMode * the portlet mode to switch to @@ -389,12 +389,12 @@ public class PortletApplicationContext2 extends AbstractWebApplicationContext { * if the portlet mode is not allowed for some reason * (configuration, permissions etc.) */ - public void setPortletMode(Root root, PortletMode portletMode) + public void setPortletMode(UI uI, PortletMode portletMode) throws IllegalStateException, PortletModeException { if (response instanceof MimeResponse) { PortletURL url = ((MimeResponse) response).createRenderURL(); url.setPortletMode(portletMode); - throw new RuntimeException("Root.open has not yet been implemented"); + throw new RuntimeException("UI.open has not yet been implemented"); // root.open(new ExternalResource(url.toString())); } else if (response instanceof StateAwareResponse) { ((StateAwareResponse) response).setPortletMode(portletMode); diff --git a/server/src/com/vaadin/terminal/gwt/server/PortletCommunicationManager.java b/server/src/com/vaadin/terminal/gwt/server/PortletCommunicationManager.java index b6fbbec298..e127425786 100644 --- a/server/src/com/vaadin/terminal/gwt/server/PortletCommunicationManager.java +++ b/server/src/com/vaadin/terminal/gwt/server/PortletCommunicationManager.java @@ -34,7 +34,7 @@ import com.vaadin.terminal.DeploymentConfiguration; import com.vaadin.terminal.PaintException; import com.vaadin.terminal.WrappedRequest; import com.vaadin.terminal.WrappedResponse; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; /** * TODO document me! @@ -142,10 +142,10 @@ public class PortletCommunicationManager extends AbstractCommunicationManager { } @Override - protected String getInitialUIDL(WrappedRequest request, Root root) + protected String getInitialUIDL(WrappedRequest request, UI uI) throws PaintException, JSONException { return PortletCommunicationManager.this.getInitialUIDL(request, - root); + uI); } @Override @@ -168,9 +168,9 @@ public class PortletCommunicationManager extends AbstractCommunicationManager { } @Override - protected InputStream getThemeResourceAsStream(Root root, String themeName, + protected InputStream getThemeResourceAsStream(UI uI, String themeName, String resource) { - PortletApplicationContext2 context = (PortletApplicationContext2) root + PortletApplicationContext2 context = (PortletApplicationContext2) uI .getApplication().getContext(); PortletContext portletContext = context.getPortletSession() .getPortletContext(); diff --git a/server/src/com/vaadin/terminal/gwt/server/ServletPortletHelper.java b/server/src/com/vaadin/terminal/gwt/server/ServletPortletHelper.java index 200f9a9103..13d558e66e 100644 --- a/server/src/com/vaadin/terminal/gwt/server/ServletPortletHelper.java +++ b/server/src/com/vaadin/terminal/gwt/server/ServletPortletHelper.java @@ -6,7 +6,7 @@ import com.vaadin.Application; import com.vaadin.shared.ApplicationConstants; import com.vaadin.terminal.DeploymentConfiguration; import com.vaadin.terminal.WrappedRequest; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; /* * Copyright 2011 Vaadin Ltd. @@ -76,9 +76,9 @@ class ServletPortletHelper implements Serializable { // Check that the root layout class can be found try { Class rootClass = classLoader.loadClass(className); - if (!Root.class.isAssignableFrom(rootClass)) { + if (!UI.class.isAssignableFrom(rootClass)) { throw new ApplicationClassException(className - + " does not implement Root"); + + " does not implement UI"); } // Try finding a default constructor, else throw exception rootClass.getConstructor(); diff --git a/server/src/com/vaadin/ui/AbstractComponent.java b/server/src/com/vaadin/ui/AbstractComponent.java index b1393488f7..147034fe6b 100644 --- a/server/src/com/vaadin/ui/AbstractComponent.java +++ b/server/src/com/vaadin/ui/AbstractComponent.java @@ -561,7 +561,7 @@ public abstract class AbstractComponent extends AbstractClientConnector * here, we use the default documentation from implemented interface. */ @Override - public Root getRoot() { + public UI getRoot() { // Just make method from implemented Component interface public return super.getRoot(); } @@ -588,9 +588,9 @@ public abstract class AbstractComponent extends AbstractClientConnector public void detach() { super.detach(); if (actionManager != null) { - // Remove any existing viewer. Root cast is just to make the + // Remove any existing viewer. UI cast is just to make the // compiler happy - actionManager.setViewer((Root) null); + actionManager.setViewer((UI) null); } } diff --git a/server/src/com/vaadin/ui/Component.java b/server/src/com/vaadin/ui/Component.java index 89e282d4e1..7406303af9 100644 --- a/server/src/com/vaadin/ui/Component.java +++ b/server/src/com/vaadin/ui/Component.java @@ -507,18 +507,18 @@ public interface Component extends ClientConnector, Sizeable, Serializable { public void setIcon(Resource icon); /** - * Gets the Root the component is attached to. + * Gets the UI the component is attached to. * *

      - * If the component is not attached to a Root through a component + * If the component is not attached to a UI through a component * containment hierarchy, null is returned. *

      * - * @return the Root of the component or null if it is not - * attached to a Root + * @return the UI of the component or null if it is not + * attached to a UI */ @Override - public Root getRoot(); + public UI getRoot(); /** * Gets the application object to which the component is attached. @@ -574,8 +574,8 @@ public interface Component extends ClientConnector, Sizeable, Serializable { * {@link #setParent(Component)}. *

      *

      - * This method must call {@link Root#componentAttached(Component)} to let - * the Root know that a new Component has been attached. + * This method must call {@link UI#componentAttached(Component)} to let + * the UI know that a new Component has been attached. *

      * * diff --git a/server/src/com/vaadin/ui/ConnectorTracker.java b/server/src/com/vaadin/ui/ConnectorTracker.java index 72879e0a25..3a6e1e4ea8 100644 --- a/server/src/com/vaadin/ui/ConnectorTracker.java +++ b/server/src/com/vaadin/ui/ConnectorTracker.java @@ -30,7 +30,7 @@ import com.vaadin.terminal.gwt.server.ClientConnector; /** * A class which takes care of book keeping of {@link ClientConnector}s for a - * Root. + * UI. *

      * Provides {@link #getConnector(String)} which can be used to lookup a * connector from its id. This is for framework use only and should not be @@ -54,7 +54,7 @@ public class ConnectorTracker implements Serializable { private Set dirtyConnectors = new HashSet(); private Set uninitializedConnectors = new HashSet(); - private Root root; + private UI uI; private Map diffStates = new HashMap(); /** @@ -68,15 +68,15 @@ public class ConnectorTracker implements Serializable { } /** - * Creates a new ConnectorTracker for the given root. A tracker is always - * attached to a root and the root cannot be changed during the lifetime of + * Creates a new ConnectorTracker for the given uI. A tracker is always + * attached to a uI and the uI cannot be changed during the lifetime of * a {@link ConnectorTracker}. * - * @param root - * The root to attach to. Cannot be null. + * @param uI + * The uI to attach to. Cannot be null. */ - public ConnectorTracker(Root root) { - this.root = root; + public ConnectorTracker(UI uI) { + this.uI = uI; } /** @@ -210,8 +210,8 @@ public class ConnectorTracker implements Serializable { while (iterator.hasNext()) { String connectorId = iterator.next(); ClientConnector connector = connectorIdToConnector.get(connectorId); - if (getRootForConnector(connector) != root) { - // If connector is no longer part of this root, + if (getRootForConnector(connector) != uI) { + // If connector is no longer part of this uI, // remove it from the map. If it is re-attached to the // application at some point it will be re-added through // registerConnector(connector) @@ -232,14 +232,14 @@ public class ConnectorTracker implements Serializable { } /** - * Finds the root that the connector is attached to. + * Finds the uI that the connector is attached to. * * @param connector * The connector to lookup - * @return The root the connector is attached to or null if it is not - * attached to any root. + * @return The uI the connector is attached to or null if it is not + * attached to any uI. */ - private Root getRootForConnector(ClientConnector connector) { + private UI getRootForConnector(ClientConnector connector) { if (connector == null) { return null; } @@ -330,15 +330,15 @@ public class ConnectorTracker implements Serializable { } /** - * Mark all connectors in this root as dirty. + * Mark all connectors in this uI as dirty. */ public void markAllConnectorsDirty() { - markConnectorsDirtyRecursively(root); + markConnectorsDirtyRecursively(uI); getLogger().fine("All connectors are now dirty"); } /** - * Mark all connectors in this root as clean. + * Mark all connectors in this uI as clean. */ public void markAllConnectorsClean() { dirtyConnectors.clear(); @@ -370,7 +370,7 @@ public class ConnectorTracker implements Serializable { * client in the following request. *

      * - * @return A collection of all dirty connectors for this root. This list may + * @return A collection of all dirty connectors for this uI. This list may * contain invisible connectors. */ public Collection getDirtyConnectors() { diff --git a/server/src/com/vaadin/ui/LoginForm.java b/server/src/com/vaadin/ui/LoginForm.java index bb7767084c..f127a2705b 100644 --- a/server/src/com/vaadin/ui/LoginForm.java +++ b/server/src/com/vaadin/ui/LoginForm.java @@ -99,8 +99,8 @@ public class LoginForm extends CustomComponent { throws IOException { String requestPathInfo = request.getRequestPathInfo(); if ("/loginHandler".equals(requestPathInfo)) { - // Ensure Root.getCurrent() works in listeners - Root.setCurrent(getRoot()); + // Ensure UI.getCurrent() works in listeners + UI.setCurrent(getRoot()); response.setCacheTime(-1); response.setContentType("text/html; charset=utf-8"); diff --git a/server/src/com/vaadin/ui/Root.java b/server/src/com/vaadin/ui/Root.java deleted file mode 100644 index 67f2e04a65..0000000000 --- a/server/src/com/vaadin/ui/Root.java +++ /dev/null @@ -1,1241 +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.ui; - -import java.net.MalformedURLException; -import java.net.URL; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Iterator; -import java.util.LinkedHashSet; -import java.util.Map; - -import com.vaadin.Application; -import com.vaadin.annotations.EagerInit; -import com.vaadin.event.Action; -import com.vaadin.event.Action.Handler; -import com.vaadin.event.ActionManager; -import com.vaadin.event.MouseEvents.ClickEvent; -import com.vaadin.event.MouseEvents.ClickListener; -import com.vaadin.shared.EventId; -import com.vaadin.shared.MouseEventDetails; -import com.vaadin.shared.ui.BorderStyle; -import com.vaadin.shared.ui.root.RootConstants; -import com.vaadin.shared.ui.root.RootServerRpc; -import com.vaadin.shared.ui.root.RootState; -import com.vaadin.terminal.Page; -import com.vaadin.terminal.Page.BrowserWindowResizeEvent; -import com.vaadin.terminal.Page.BrowserWindowResizeListener; -import com.vaadin.terminal.PaintException; -import com.vaadin.terminal.PaintTarget; -import com.vaadin.terminal.Resource; -import com.vaadin.terminal.Vaadin6Component; -import com.vaadin.terminal.WrappedRequest; -import com.vaadin.terminal.WrappedRequest.BrowserDetails; -import com.vaadin.ui.Window.CloseListener; - -/** - * The topmost component in any component hierarchy. There is one root for every - * Vaadin instance in a browser window. A root may either represent an entire - * browser window (or tab) or some part of a html page where a Vaadin - * application is embedded. - *

      - * The root is the server side entry point for various client side features that - * are not represented as components added to a layout, e.g notifications, sub - * windows, and executing javascript in the browser. - *

      - *

      - * When a new application instance is needed, typically because the user opens - * the application in a browser window, - * {@link Application#gerRoot(WrappedRequest)} is invoked to get a root. That - * method does by default create a root according to the - * {@value Application#ROOT_PARAMETER} parameter from web.xml. - *

      - *

      - * After a root has been created by the application, it is initialized using - * {@link #init(WrappedRequest)}. This method is intended to be overridden by - * the developer to add components to the user interface and initialize - * non-component functionality. The component hierarchy is initialized by - * passing a {@link ComponentContainer} with the main layout of the view to - * {@link #setContent(ComponentContainer)}. - *

      - *

      - * If a {@link EagerInit} annotation is present on a class extending - * Root, the framework will use a faster initialization method - * which will not ensure that {@link BrowserDetails} are present in the - * {@link WrappedRequest} passed to the init method. - *

      - * - * @see #init(WrappedRequest) - * @see Application#getRoot(WrappedRequest) - * - * @since 7.0 - */ -public abstract class Root extends AbstractComponentContainer implements - Action.Container, Action.Notifier, Vaadin6Component { - - /** - * Helper class to emulate the main window from Vaadin 6 using roots. This - * class should be used in the same way as Window used as a browser level - * window in Vaadin 6 with {@link com.vaadin.Application.LegacyApplication} - */ - @Deprecated - @EagerInit - public static class LegacyWindow extends Root { - private String name; - - /** - * Create a new legacy window - */ - public LegacyWindow() { - super(); - } - - /** - * Creates a new legacy window with the given caption - * - * @param caption - * the caption of the window - */ - public LegacyWindow(String caption) { - super(caption); - } - - /** - * Creates a legacy window with the given caption and content layout - * - * @param caption - * @param content - */ - public LegacyWindow(String caption, ComponentContainer content) { - super(caption, content); - } - - @Override - protected void init(WrappedRequest request) { - // Just empty - } - - /** - * Gets the unique name of the window. The name of the window is used to - * uniquely identify it. - *

      - * The name also determines the URL that can be used for direct access - * to a window. All windows can be accessed through - * {@code http://host:port/app/win} where {@code http://host:port/app} - * is the application URL (as returned by {@link Application#getURL()} - * and {@code win} is the window name. - *

      - *

      - * Note! Portlets do not support direct window access through URLs. - *

      - * - * @return the Name of the Window. - */ - public String getName() { - return name; - } - - /** - * Sets the unique name of the window. The name of the window is used to - * uniquely identify it inside the application. - *

      - * The name also determines the URL that can be used for direct access - * to a window. All windows can be accessed through - * {@code http://host:port/app/win} where {@code http://host:port/app} - * is the application URL (as returned by {@link Application#getURL()} - * and {@code win} is the window name. - *

      - *

      - * This method can only be called before the window is added to an - * application. - *

      - * Note! Portlets do not support direct window access through URLs. - *

      - * - * @param name - * the new name for the window or null if the application - * should automatically assign a name to it - * @throws IllegalStateException - * if the window is attached to an application - */ - public void setName(String name) { - this.name = name; - // The name can not be changed in application - if (getApplication() != null) { - throw new IllegalStateException( - "Window name can not be changed while " - + "the window is in application"); - } - - } - - /** - * Gets the full URL of the window. The returned URL is window specific - * and can be used to directly refer to the window. - *

      - * Note! This method can not be used for portlets. - *

      - * - * @return the URL of the window or null if the window is not attached - * to an application - */ - public URL getURL() { - Application application = getApplication(); - if (application == null) { - return null; - } - - try { - return new URL(application.getURL(), getName() + "/"); - } catch (MalformedURLException e) { - throw new RuntimeException( - "Internal problem getting window URL, please report"); - } - } - - /** - * Opens the given resource in this root. The contents of this Root is - * replaced by the {@code Resource}. - * - * @param resource - * the resource to show in this root - * - * @deprecated As of 7.0, use getPage().open instead - */ - @Deprecated - public void open(Resource resource) { - getPage().open(resource); - } - - /* ********************************************************************* */ - - /** - * Opens the given resource in a window with the given name. - *

      - * The supplied {@code windowName} is used as the target name in a - * window.open call in the client. This means that special values such - * as "_blank", "_self", "_top", "_parent" have special meaning. An - * empty or null window name is also a special case. - *

      - *

      - * "", null and "_self" as {@code windowName} all causes the resource to - * be opened in the current window, replacing any old contents. For - * downloadable content you should avoid "_self" as "_self" causes the - * client to skip rendering of any other changes as it considers them - * irrelevant (the page will be replaced by the resource). This can - * speed up the opening of a resource, but it might also put the client - * side into an inconsistent state if the window content is not - * completely replaced e.g., if the resource is downloaded instead of - * displayed in the browser. - *

      - *

      - * "_blank" as {@code windowName} causes the resource to always be - * opened in a new window or tab (depends on the browser and browser - * settings). - *

      - *

      - * "_top" and "_parent" as {@code windowName} works as specified by the - * HTML standard. - *

      - *

      - * Any other {@code windowName} will open the resource in a window with - * that name, either by opening a new window/tab in the browser or by - * replacing the contents of an existing window with that name. - *

      - * - * @param resource - * the resource. - * @param windowName - * the name of the window. - * @deprecated As of 7.0, use getPage().open instead - */ - @Deprecated - public void open(Resource resource, String windowName) { - getPage().open(resource, windowName); - } - - /** - * Opens the given resource in a window with the given size, border and - * name. For more information on the meaning of {@code windowName}, see - * {@link #open(Resource, String)}. - * - * @param resource - * the resource. - * @param windowName - * the name of the window. - * @param width - * the width of the window in pixels - * @param height - * the height of the window in pixels - * @param border - * the border style of the window. - * @deprecated As of 7.0, use getPage().open instead - */ - @Deprecated - public void open(Resource resource, String windowName, int width, - int height, BorderStyle border) { - getPage().open(resource, windowName, width, height, border); - } - - /** - * Adds a new {@link BrowserWindowResizeListener} to this root. The - * listener will be notified whenever the browser window within which - * this root resides is resized. - * - * @param resizeListener - * the listener to add - * - * @see BrowserWindowResizeListener#browserWindowResized(BrowserWindowResizeEvent) - * @see #setResizeLazy(boolean) - * - * @deprecated As of 7.0, use the similarly named api in Page instead - */ - @Deprecated - public void addListener(BrowserWindowResizeListener resizeListener) { - getPage().addListener(resizeListener); - } - - /** - * Removes a {@link BrowserWindowResizeListener} from this root. The - * listener will no longer be notified when the browser window is - * resized. - * - * @param resizeListener - * the listener to remove - * @deprecated As of 7.0, use the similarly named api in Page instead - */ - @Deprecated - public void removeListener(BrowserWindowResizeListener resizeListener) { - getPage().removeListener(resizeListener); - } - - /** - * Gets the last known height of the browser window in which this root - * resides. - * - * @return the browser window height in pixels - * @deprecated As of 7.0, use the similarly named api in Page instead - */ - @Deprecated - public int getBrowserWindowHeight() { - return getPage().getBrowserWindowHeight(); - } - - /** - * Gets the last known width of the browser window in which this root - * resides. - * - * @return the browser window width in pixels - * - * @deprecated As of 7.0, use the similarly named api in Page instead - */ - @Deprecated - public int getBrowserWindowWidth() { - return getPage().getBrowserWindowWidth(); - } - - /** - * Executes JavaScript in this window. - * - *

      - * This method allows one to inject javascript from the server to - * client. A client implementation is not required to implement this - * functionality, but currently all web-based clients do implement this. - *

      - * - *

      - * Executing javascript this way often leads to cross-browser - * compatibility issues and regressions that are hard to resolve. Use of - * this method should be avoided and instead it is recommended to create - * new widgets with GWT. For more info on creating own, reusable - * client-side widgets in Java, read the corresponding chapter in Book - * of Vaadin. - *

      - * - * @param script - * JavaScript snippet that will be executed. - * - * @deprecated as of 7.0, use JavaScript.getCurrent().execute(String) - * instead - */ - @Deprecated - public void executeJavaScript(String script) { - getPage().getJavaScript().execute(script); - } - - @Override - public void setCaption(String caption) { - // Override to provide backwards compatibility - getState().setCaption(caption); - getPage().setTitle(caption); - } - - } - - /** - * The application to which this root belongs - */ - private Application application; - - /** - * List of windows in this root. - */ - private final LinkedHashSet windows = new LinkedHashSet(); - - /** - * The component that should be scrolled into view after the next repaint. - * Null if nothing should be scrolled into view. - */ - private Component scrollIntoView; - - /** - * The id of this root, used to find the server side instance of the root - * form which a request originates. A negative value indicates that the root - * id has not yet been assigned by the Application. - * - * @see Application#nextRootId - */ - private int rootId = -1; - - /** - * Keeps track of the Actions added to this component, and manages the - * painting and handling as well. - */ - protected ActionManager actionManager; - - /** - * Thread local for keeping track of the current root. - */ - private static final ThreadLocal currentRoot = new ThreadLocal(); - - /** Identifies the click event */ - private ConnectorTracker connectorTracker = new ConnectorTracker(this); - - private Page page = new Page(this); - - private RootServerRpc rpc = new RootServerRpc() { - @Override - public void click(MouseEventDetails mouseDetails) { - fireEvent(new ClickEvent(Root.this, mouseDetails)); - } - - @Override - public void resize(int viewWidth, int viewHeight, int windowWidth, - int windowHeight) { - // TODO We're not doing anything with the view dimensions - getPage().setBrowserWindowSize(windowWidth, windowHeight); - } - }; - - /** - * Creates a new empty root without a caption. This root will have a - * {@link VerticalLayout} with margins enabled as its content. - */ - public Root() { - this((ComponentContainer) null); - } - - /** - * Creates a new root with the given component container as its content. - * - * @param content - * the content container to use as this roots content. - * - * @see #setContent(ComponentContainer) - */ - public Root(ComponentContainer content) { - registerRpc(rpc); - setSizeFull(); - setContent(content); - } - - /** - * Creates a new empty root with the given caption. This root will have a - * {@link VerticalLayout} with margins enabled as its content. - * - * @param caption - * the caption of the root, used as the page title if there's - * nothing but the application on the web page - * - * @see #setCaption(String) - */ - public Root(String caption) { - this((ComponentContainer) null); - setCaption(caption); - } - - /** - * Creates a new root with the given caption and content. - * - * @param caption - * the caption of the root, used as the page title if there's - * nothing but the application on the web page - * @param content - * the content container to use as this roots content. - * - * @see #setContent(ComponentContainer) - * @see #setCaption(String) - */ - public Root(String caption, ComponentContainer content) { - this(content); - setCaption(caption); - } - - @Override - protected RootState getState() { - return (RootState) super.getState(); - } - - @Override - public Class getStateType() { - // This is a workaround for a problem with creating the correct state - // object during build - return RootState.class; - } - - /** - * Overridden to return a value instead of referring to the parent. - * - * @return this root - * - * @see com.vaadin.ui.AbstractComponent#getRoot() - */ - @Override - public Root getRoot() { - return this; - } - - @Override - public void replaceComponent(Component oldComponent, Component newComponent) { - throw new UnsupportedOperationException(); - } - - @Override - public Application getApplication() { - return application; - } - - @Override - public void paintContent(PaintTarget target) throws PaintException { - page.paintContent(target); - - if (scrollIntoView != null) { - target.addAttribute("scrollTo", scrollIntoView); - scrollIntoView = null; - } - - if (pendingFocus != null) { - // ensure focused component is still attached to this main window - if (pendingFocus.getRoot() == this - || (pendingFocus.getRoot() != null && pendingFocus - .getRoot().getParent() == this)) { - target.addAttribute("focused", pendingFocus); - } - pendingFocus = null; - } - - if (actionManager != null) { - actionManager.paintActions(null, target); - } - - if (isResizeLazy()) { - target.addAttribute(RootConstants.RESIZE_LAZY, true); - } - } - - /** - * Fire a click event to all click listeners. - * - * @param object - * The raw "value" of the variable change from the client side. - */ - private void fireClick(Map parameters) { - MouseEventDetails mouseDetails = MouseEventDetails - .deSerialize((String) parameters.get("mouseDetails")); - fireEvent(new ClickEvent(this, mouseDetails)); - } - - @Override - @SuppressWarnings("unchecked") - public void changeVariables(Object source, Map variables) { - if (variables.containsKey(EventId.CLICK_EVENT_IDENTIFIER)) { - fireClick((Map) variables - .get(EventId.CLICK_EVENT_IDENTIFIER)); - } - - // Actions - if (actionManager != null) { - actionManager.handleActions(variables, this); - } - - if (variables.containsKey(RootConstants.FRAGMENT_VARIABLE)) { - String fragment = (String) variables - .get(RootConstants.FRAGMENT_VARIABLE); - getPage().setFragment(fragment, true); - } - } - - /* - * (non-Javadoc) - * - * @see com.vaadin.ui.ComponentContainer#getComponentIterator() - */ - @Override - public Iterator getComponentIterator() { - // TODO could directly create some kind of combined iterator instead of - // creating a new ArrayList - ArrayList components = new ArrayList(); - - if (getContent() != null) { - components.add(getContent()); - } - - components.addAll(windows); - - return components.iterator(); - } - - /* - * (non-Javadoc) - * - * @see com.vaadin.ui.ComponentContainer#getComponentCount() - */ - @Override - public int getComponentCount() { - return windows.size() + (getContent() == null ? 0 : 1); - } - - /** - * Sets the application to which this root is assigned. It is not legal to - * change the application once it has been set nor to set a - * null application. - *

      - * This method is mainly intended for internal use by the framework. - *

      - * - * @param application - * the application to set - * - * @throws IllegalStateException - * if the application has already been set - * - * @see #getApplication() - */ - public void setApplication(Application application) { - if ((application == null) == (this.application == null)) { - throw new IllegalStateException("Application has already been set"); - } else { - this.application = application; - } - - if (application != null) { - attach(); - } else { - detach(); - } - } - - /** - * Sets the id of this root within its application. The root id is used to - * route requests to the right root. - *

      - * This method is mainly intended for internal use by the framework. - *

      - * - * @param rootId - * the id of this root - * - * @throws IllegalStateException - * if the root id has already been set - * - * @see #getRootId() - */ - public void setRootId(int rootId) { - if (this.rootId != -1) { - throw new IllegalStateException("Root id has already been defined"); - } - this.rootId = rootId; - } - - /** - * Gets the id of the root, used to identify this root within its - * application when processing requests. The root id should be present in - * every request to the server that originates from this root. - * {@link Application#getRootForRequest(WrappedRequest)} uses this id to - * find the route to which the request belongs. - * - * @return - */ - public int getRootId() { - return rootId; - } - - /** - * Adds a window as a subwindow inside this root. To open a new browser - * window or tab, you should instead use {@link open(Resource)} with an url - * pointing to this application and ensure - * {@link Application#getRoot(WrappedRequest)} returns an appropriate root - * for the request. - * - * @param window - * @throws IllegalArgumentException - * if the window is already added to an application - * @throws NullPointerException - * if the given Window is null. - */ - public void addWindow(Window window) throws IllegalArgumentException, - NullPointerException { - - if (window == null) { - throw new NullPointerException("Argument must not be null"); - } - - if (window.getApplication() != null) { - throw new IllegalArgumentException( - "Window is already attached to an application."); - } - - attachWindow(window); - } - - /** - * Helper method to attach a window. - * - * @param w - * the window to add - */ - private void attachWindow(Window w) { - windows.add(w); - w.setParent(this); - markAsDirty(); - } - - /** - * Remove the given subwindow from this root. - * - * Since Vaadin 6.5, {@link CloseListener}s are called also when explicitly - * removing a window by calling this method. - * - * Since Vaadin 6.5, returns a boolean indicating if the window was removed - * or not. - * - * @param window - * Window to be removed. - * @return true if the subwindow was removed, false otherwise - */ - public boolean removeWindow(Window window) { - if (!windows.remove(window)) { - // Window window is not a subwindow of this root. - return false; - } - window.setParent(null); - window.fireClose(); - markAsDirty(); - - return true; - } - - /** - * Gets all the windows added to this root. - * - * @return an unmodifiable collection of windows - */ - public Collection getWindows() { - return Collections.unmodifiableCollection(windows); - } - - @Override - public void focus() { - super.focus(); - } - - /** - * Component that should be focused after the next repaint. Null if no focus - * change should take place. - */ - private Focusable pendingFocus; - - private boolean resizeLazy = false; - - /** - * This method is used by Component.Focusable objects to request focus to - * themselves. Focus renders must be handled at window level (instead of - * Component.Focusable) due we want the last focused component to be focused - * in client too. Not the one that is rendered last (the case we'd get if - * implemented in Focusable only). - * - * To focus component from Vaadin application, use Focusable.focus(). See - * {@link Focusable}. - * - * @param focusable - * to be focused on next paint - */ - public void setFocusedComponent(Focusable focusable) { - pendingFocus = focusable; - markAsDirty(); - } - - /** - * Scrolls any component between the component and root to a suitable - * position so the component is visible to the user. The given component - * must belong to this root. - * - * @param component - * the component to be scrolled into view - * @throws IllegalArgumentException - * if {@code component} does not belong to this root - */ - public void scrollIntoView(Component component) - throws IllegalArgumentException { - if (component.getRoot() != this) { - throw new IllegalArgumentException( - "The component where to scroll must belong to this root."); - } - scrollIntoView = component; - markAsDirty(); - } - - /** - * Gets the content of this root. The content is a component container that - * serves as the outermost item of the visual contents of this root. - * - * @return a component container to use as content - * - * @see #setContent(ComponentContainer) - * @see #createDefaultLayout() - */ - public ComponentContainer getContent() { - return (ComponentContainer) getState().getContent(); - } - - /** - * Helper method to create the default content layout that is used if no - * content has not been explicitly defined. - * - * @return a newly created layout - */ - private static VerticalLayout createDefaultLayout() { - VerticalLayout layout = new VerticalLayout(); - layout.setMargin(true); - return layout; - } - - /** - * Sets the content of this root. The content is a component container that - * serves as the outermost item of the visual contents of this root. If no - * content has been set, a {@link VerticalLayout} with margins enabled will - * be used by default - see {@link #createDefaultLayout()}. The content can - * also be set in a constructor. - * - * @return a component container to use as content - * - * @see #Root(ComponentContainer) - * @see #createDefaultLayout() - */ - public void setContent(ComponentContainer content) { - if (content == null) { - content = createDefaultLayout(); - } - - if (getState().getContent() != null) { - super.removeComponent((Component) getState().getContent()); - } - getState().setContent(content); - if (content != null) { - super.addComponent(content); - } - } - - /** - * Adds a component to this root. The component is not added directly to the - * root, but instead to the content container ({@link #getContent()}). - * - * @param component - * the component to add to this root - * - * @see #getContent() - */ - @Override - public void addComponent(Component component) { - getContent().addComponent(component); - } - - /** - * This implementation removes the component from the content container ( - * {@link #getContent()}) instead of from the actual root. - */ - @Override - public void removeComponent(Component component) { - getContent().removeComponent(component); - } - - /** - * This implementation removes the components from the content container ( - * {@link #getContent()}) instead of from the actual root. - */ - @Override - public void removeAllComponents() { - getContent().removeAllComponents(); - } - - /** - * Internal initialization method, should not be overridden. This method is - * not declared as final because that would break compatibility with e.g. - * CDI. - * - * @param request - * the initialization request - */ - public void doInit(WrappedRequest request) { - getPage().init(request); - - // Call the init overridden by the application developer - init(request); - } - - /** - * Initializes this root. This method is intended to be overridden by - * subclasses to build the view and configure non-component functionality. - * Performing the initialization in a constructor is not suggested as the - * state of the root is not properly set up when the constructor is invoked. - *

      - * The {@link WrappedRequest} can be used to get information about the - * request that caused this root to be created. By default, the - * {@link BrowserDetails} will be available in the request. If the browser - * details are not required, loading the application in the browser can take - * some shortcuts giving a faster initial rendering. This can be indicated - * by adding the {@link EagerInit} annotation to the Root class. - *

      - * - * @param request - * the wrapped request that caused this root to be created - */ - protected abstract void init(WrappedRequest request); - - /** - * Sets the thread local for the current root. This method is used by the - * framework to set the current application whenever a new request is - * processed and it is cleared when the request has been processed. - *

      - * The application developer can also use this method to define the current - * root outside the normal request handling, e.g. when initiating custom - * background threads. - *

      - * - * @param root - * the root to register as the current root - * - * @see #getCurrent() - * @see ThreadLocal - */ - public static void setCurrent(Root root) { - currentRoot.set(root); - } - - /** - * Gets the currently used root. The current root is automatically defined - * when processing requests to the server. In other cases, (e.g. from - * background threads), the current root is not automatically defined. - * - * @return the current root instance if available, otherwise - * null - * - * @see #setCurrent(Root) - */ - public static Root getCurrent() { - return currentRoot.get(); - } - - public void setScrollTop(int scrollTop) { - throw new RuntimeException("Not yet implemented"); - } - - @Override - protected ActionManager getActionManager() { - if (actionManager == null) { - actionManager = new ActionManager(this); - } - return actionManager; - } - - @Override - public void addAction( - T action) { - getActionManager().addAction(action); - } - - @Override - public void removeAction( - T action) { - if (actionManager != null) { - actionManager.removeAction(action); - } - } - - @Override - public void addActionHandler(Handler actionHandler) { - getActionManager().addActionHandler(actionHandler); - } - - @Override - public void removeActionHandler(Handler actionHandler) { - if (actionManager != null) { - actionManager.removeActionHandler(actionHandler); - } - } - - /** - * Should resize operations be lazy, i.e. should there be a delay before - * layout sizes are recalculated. Speeds up resize operations in slow UIs - * with the penalty of slightly decreased usability. - *

      - * Default value: false - * - * @param resizeLazy - * true to use a delay before recalculating sizes, false to - * calculate immediately. - */ - public void setResizeLazy(boolean resizeLazy) { - this.resizeLazy = resizeLazy; - markAsDirty(); - } - - /** - * Checks whether lazy resize is enabled. - * - * @return true if lazy resize is enabled, false - * if lazy resize is not enabled - */ - public boolean isResizeLazy() { - return resizeLazy; - } - - /** - * Add a click listener to the Root. The listener is called whenever the - * user clicks inside the Root. Also when the click targets a component - * inside the Root, provided the targeted component does not prevent the - * click event from propagating. - * - * Use {@link #removeListener(ClickListener)} to remove the listener. - * - * @param listener - * The listener to add - */ - public void addListener(ClickListener listener) { - addListener(EventId.CLICK_EVENT_IDENTIFIER, ClickEvent.class, listener, - ClickListener.clickMethod); - } - - /** - * Remove a click listener from the Root. The listener should earlier have - * been added using {@link #addListener(ClickListener)}. - * - * @param listener - * The listener to remove - */ - public void removeListener(ClickListener listener) { - removeListener(EventId.CLICK_EVENT_IDENTIFIER, ClickEvent.class, - listener); - } - - @Override - public boolean isConnectorEnabled() { - // TODO How can a Root be invisible? What does it mean? - return isVisible() && isEnabled(); - } - - public ConnectorTracker getConnectorTracker() { - return connectorTracker; - } - - public Page getPage() { - return page; - } - - /** - * Setting the caption of a Root is not supported. To set the title of the - * HTML page, use Page.setTitle - * - * @deprecated as of 7.0.0, use {@link Page#setTitle(String)} - */ - @Override - @Deprecated - public void setCaption(String caption) { - throw new IllegalStateException( - "You can not set the title of a Root. To set the title of the HTML page, use Page.setTitle"); - } - - /** - * Shows a notification message on the middle of the root. The message - * automatically disappears ("humanized message"). - * - * Care should be taken to to avoid XSS vulnerabilities as the caption is - * rendered as html. - * - * @see #showNotification(Notification) - * @see Notification - * - * @param caption - * The message - * - * @deprecated As of 7.0, use Notification.show instead but be aware that - * Notification.show does not allow HTML. - */ - @Deprecated - public void showNotification(String caption) { - Notification notification = new Notification(caption); - notification.setHtmlContentAllowed(true);// Backwards compatibility - getPage().showNotification(notification); - } - - /** - * Shows a notification message the root. The position and behavior of the - * message depends on the type, which is one of the basic types defined in - * {@link Notification}, for instance Notification.TYPE_WARNING_MESSAGE. - * - * Care should be taken to to avoid XSS vulnerabilities as the caption is - * rendered as html. - * - * @see #showNotification(Notification) - * @see Notification - * - * @param caption - * The message - * @param type - * The message type - * - * @deprecated As of 7.0, use Notification.show instead but be aware that - * Notification.show does not allow HTML. - */ - @Deprecated - public void showNotification(String caption, Notification.Type type) { - Notification notification = new Notification(caption, type); - notification.setHtmlContentAllowed(true);// Backwards compatibility - getPage().showNotification(notification); - } - - /** - * Shows a notification consisting of a bigger caption and a smaller - * description on the middle of the root. The message automatically - * disappears ("humanized message"). - * - * Care should be taken to to avoid XSS vulnerabilities as the caption and - * description are rendered as html. - * - * @see #showNotification(Notification) - * @see Notification - * - * @param caption - * The caption of the message - * @param description - * The message description - * - * @deprecated As of 7.0, use new Notification(...).show(Page) instead but - * be aware that HTML by default not allowed. - */ - @Deprecated - public void showNotification(String caption, String description) { - Notification notification = new Notification(caption, description); - notification.setHtmlContentAllowed(true);// Backwards compatibility - getPage().showNotification(notification); - } - - /** - * Shows a notification consisting of a bigger caption and a smaller - * description. The position and behavior of the message depends on the - * type, which is one of the basic types defined in {@link Notification} , - * for instance Notification.TYPE_WARNING_MESSAGE. - * - * Care should be taken to to avoid XSS vulnerabilities as the caption and - * description are rendered as html. - * - * @see #showNotification(Notification) - * @see Notification - * - * @param caption - * The caption of the message - * @param description - * The message description - * @param type - * The message type - * - * @deprecated As of 7.0, use new Notification(...).show(Page) instead but - * be aware that HTML by default not allowed. - */ - @Deprecated - public void showNotification(String caption, String description, - Notification.Type type) { - Notification notification = new Notification(caption, description, type); - notification.setHtmlContentAllowed(true);// Backwards compatibility - getPage().showNotification(notification); - } - - /** - * Shows a notification consisting of a bigger caption and a smaller - * description. The position and behavior of the message depends on the - * type, which is one of the basic types defined in {@link Notification} , - * for instance Notification.TYPE_WARNING_MESSAGE. - * - * Care should be taken to avoid XSS vulnerabilities if html content is - * allowed. - * - * @see #showNotification(Notification) - * @see Notification - * - * @param caption - * The message caption - * @param description - * The message description - * @param type - * The type of message - * @param htmlContentAllowed - * Whether html in the caption and description should be - * displayed as html or as plain text - * - * @deprecated As of 7.0, use new Notification(...).show(Page). - */ - @Deprecated - public void showNotification(String caption, String description, - Notification.Type type, boolean htmlContentAllowed) { - getPage() - .showNotification( - new Notification(caption, description, type, - htmlContentAllowed)); - } - - /** - * Shows a notification message. - * - * @see Notification - * @see #showNotification(String) - * @see #showNotification(String, int) - * @see #showNotification(String, String) - * @see #showNotification(String, String, int) - * - * @param notification - * The notification message to show - * - * @deprecated As of 7.0, use Notification.show instead - */ - @Deprecated - public void showNotification(Notification notification) { - getPage().showNotification(notification); - } - -} diff --git a/server/src/com/vaadin/ui/UI.java b/server/src/com/vaadin/ui/UI.java new file mode 100644 index 0000000000..33eefff485 --- /dev/null +++ b/server/src/com/vaadin/ui/UI.java @@ -0,0 +1,1241 @@ +/* + * 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.ui; + +import java.net.MalformedURLException; +import java.net.URL; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Iterator; +import java.util.LinkedHashSet; +import java.util.Map; + +import com.vaadin.Application; +import com.vaadin.annotations.EagerInit; +import com.vaadin.event.Action; +import com.vaadin.event.Action.Handler; +import com.vaadin.event.ActionManager; +import com.vaadin.event.MouseEvents.ClickEvent; +import com.vaadin.event.MouseEvents.ClickListener; +import com.vaadin.shared.EventId; +import com.vaadin.shared.MouseEventDetails; +import com.vaadin.shared.ui.BorderStyle; +import com.vaadin.shared.ui.root.RootConstants; +import com.vaadin.shared.ui.root.RootServerRpc; +import com.vaadin.shared.ui.root.RootState; +import com.vaadin.terminal.Page; +import com.vaadin.terminal.Page.BrowserWindowResizeEvent; +import com.vaadin.terminal.Page.BrowserWindowResizeListener; +import com.vaadin.terminal.PaintException; +import com.vaadin.terminal.PaintTarget; +import com.vaadin.terminal.Resource; +import com.vaadin.terminal.Vaadin6Component; +import com.vaadin.terminal.WrappedRequest; +import com.vaadin.terminal.WrappedRequest.BrowserDetails; +import com.vaadin.ui.Window.CloseListener; + +/** + * The topmost component in any component hierarchy. There is one root for every + * Vaadin instance in a browser window. A root may either represent an entire + * browser window (or tab) or some part of a html page where a Vaadin + * application is embedded. + *

      + * The root is the server side entry point for various client side features that + * are not represented as components added to a layout, e.g notifications, sub + * windows, and executing javascript in the browser. + *

      + *

      + * When a new application instance is needed, typically because the user opens + * the application in a browser window, + * {@link Application#gerRoot(WrappedRequest)} is invoked to get a root. That + * method does by default create a root according to the + * {@value Application#ROOT_PARAMETER} parameter from web.xml. + *

      + *

      + * After a root has been created by the application, it is initialized using + * {@link #init(WrappedRequest)}. This method is intended to be overridden by + * the developer to add components to the user interface and initialize + * non-component functionality. The component hierarchy is initialized by + * passing a {@link ComponentContainer} with the main layout of the view to + * {@link #setContent(ComponentContainer)}. + *

      + *

      + * If a {@link EagerInit} annotation is present on a class extending + * UI, the framework will use a faster initialization method + * which will not ensure that {@link BrowserDetails} are present in the + * {@link WrappedRequest} passed to the init method. + *

      + * + * @see #init(WrappedRequest) + * @see Application#getRoot(WrappedRequest) + * + * @since 7.0 + */ +public abstract class UI extends AbstractComponentContainer implements + Action.Container, Action.Notifier, Vaadin6Component { + + /** + * Helper class to emulate the main window from Vaadin 6 using roots. This + * class should be used in the same way as Window used as a browser level + * window in Vaadin 6 with {@link com.vaadin.Application.LegacyApplication} + */ + @Deprecated + @EagerInit + public static class LegacyWindow extends UI { + private String name; + + /** + * Create a new legacy window + */ + public LegacyWindow() { + super(); + } + + /** + * Creates a new legacy window with the given caption + * + * @param caption + * the caption of the window + */ + public LegacyWindow(String caption) { + super(caption); + } + + /** + * Creates a legacy window with the given caption and content layout + * + * @param caption + * @param content + */ + public LegacyWindow(String caption, ComponentContainer content) { + super(caption, content); + } + + @Override + protected void init(WrappedRequest request) { + // Just empty + } + + /** + * Gets the unique name of the window. The name of the window is used to + * uniquely identify it. + *

      + * The name also determines the URL that can be used for direct access + * to a window. All windows can be accessed through + * {@code http://host:port/app/win} where {@code http://host:port/app} + * is the application URL (as returned by {@link Application#getURL()} + * and {@code win} is the window name. + *

      + *

      + * Note! Portlets do not support direct window access through URLs. + *

      + * + * @return the Name of the Window. + */ + public String getName() { + return name; + } + + /** + * Sets the unique name of the window. The name of the window is used to + * uniquely identify it inside the application. + *

      + * The name also determines the URL that can be used for direct access + * to a window. All windows can be accessed through + * {@code http://host:port/app/win} where {@code http://host:port/app} + * is the application URL (as returned by {@link Application#getURL()} + * and {@code win} is the window name. + *

      + *

      + * This method can only be called before the window is added to an + * application. + *

      + * Note! Portlets do not support direct window access through URLs. + *

      + * + * @param name + * the new name for the window or null if the application + * should automatically assign a name to it + * @throws IllegalStateException + * if the window is attached to an application + */ + public void setName(String name) { + this.name = name; + // The name can not be changed in application + if (getApplication() != null) { + throw new IllegalStateException( + "Window name can not be changed while " + + "the window is in application"); + } + + } + + /** + * Gets the full URL of the window. The returned URL is window specific + * and can be used to directly refer to the window. + *

      + * Note! This method can not be used for portlets. + *

      + * + * @return the URL of the window or null if the window is not attached + * to an application + */ + public URL getURL() { + Application application = getApplication(); + if (application == null) { + return null; + } + + try { + return new URL(application.getURL(), getName() + "/"); + } catch (MalformedURLException e) { + throw new RuntimeException( + "Internal problem getting window URL, please report"); + } + } + + /** + * Opens the given resource in this root. The contents of this UI is + * replaced by the {@code Resource}. + * + * @param resource + * the resource to show in this root + * + * @deprecated As of 7.0, use getPage().open instead + */ + @Deprecated + public void open(Resource resource) { + getPage().open(resource); + } + + /* ********************************************************************* */ + + /** + * Opens the given resource in a window with the given name. + *

      + * The supplied {@code windowName} is used as the target name in a + * window.open call in the client. This means that special values such + * as "_blank", "_self", "_top", "_parent" have special meaning. An + * empty or null window name is also a special case. + *

      + *

      + * "", null and "_self" as {@code windowName} all causes the resource to + * be opened in the current window, replacing any old contents. For + * downloadable content you should avoid "_self" as "_self" causes the + * client to skip rendering of any other changes as it considers them + * irrelevant (the page will be replaced by the resource). This can + * speed up the opening of a resource, but it might also put the client + * side into an inconsistent state if the window content is not + * completely replaced e.g., if the resource is downloaded instead of + * displayed in the browser. + *

      + *

      + * "_blank" as {@code windowName} causes the resource to always be + * opened in a new window or tab (depends on the browser and browser + * settings). + *

      + *

      + * "_top" and "_parent" as {@code windowName} works as specified by the + * HTML standard. + *

      + *

      + * Any other {@code windowName} will open the resource in a window with + * that name, either by opening a new window/tab in the browser or by + * replacing the contents of an existing window with that name. + *

      + * + * @param resource + * the resource. + * @param windowName + * the name of the window. + * @deprecated As of 7.0, use getPage().open instead + */ + @Deprecated + public void open(Resource resource, String windowName) { + getPage().open(resource, windowName); + } + + /** + * Opens the given resource in a window with the given size, border and + * name. For more information on the meaning of {@code windowName}, see + * {@link #open(Resource, String)}. + * + * @param resource + * the resource. + * @param windowName + * the name of the window. + * @param width + * the width of the window in pixels + * @param height + * the height of the window in pixels + * @param border + * the border style of the window. + * @deprecated As of 7.0, use getPage().open instead + */ + @Deprecated + public void open(Resource resource, String windowName, int width, + int height, BorderStyle border) { + getPage().open(resource, windowName, width, height, border); + } + + /** + * Adds a new {@link BrowserWindowResizeListener} to this root. The + * listener will be notified whenever the browser window within which + * this root resides is resized. + * + * @param resizeListener + * the listener to add + * + * @see BrowserWindowResizeListener#browserWindowResized(BrowserWindowResizeEvent) + * @see #setResizeLazy(boolean) + * + * @deprecated As of 7.0, use the similarly named api in Page instead + */ + @Deprecated + public void addListener(BrowserWindowResizeListener resizeListener) { + getPage().addListener(resizeListener); + } + + /** + * Removes a {@link BrowserWindowResizeListener} from this root. The + * listener will no longer be notified when the browser window is + * resized. + * + * @param resizeListener + * the listener to remove + * @deprecated As of 7.0, use the similarly named api in Page instead + */ + @Deprecated + public void removeListener(BrowserWindowResizeListener resizeListener) { + getPage().removeListener(resizeListener); + } + + /** + * Gets the last known height of the browser window in which this root + * resides. + * + * @return the browser window height in pixels + * @deprecated As of 7.0, use the similarly named api in Page instead + */ + @Deprecated + public int getBrowserWindowHeight() { + return getPage().getBrowserWindowHeight(); + } + + /** + * Gets the last known width of the browser window in which this root + * resides. + * + * @return the browser window width in pixels + * + * @deprecated As of 7.0, use the similarly named api in Page instead + */ + @Deprecated + public int getBrowserWindowWidth() { + return getPage().getBrowserWindowWidth(); + } + + /** + * Executes JavaScript in this window. + * + *

      + * This method allows one to inject javascript from the server to + * client. A client implementation is not required to implement this + * functionality, but currently all web-based clients do implement this. + *

      + * + *

      + * Executing javascript this way often leads to cross-browser + * compatibility issues and regressions that are hard to resolve. Use of + * this method should be avoided and instead it is recommended to create + * new widgets with GWT. For more info on creating own, reusable + * client-side widgets in Java, read the corresponding chapter in Book + * of Vaadin. + *

      + * + * @param script + * JavaScript snippet that will be executed. + * + * @deprecated as of 7.0, use JavaScript.getCurrent().execute(String) + * instead + */ + @Deprecated + public void executeJavaScript(String script) { + getPage().getJavaScript().execute(script); + } + + @Override + public void setCaption(String caption) { + // Override to provide backwards compatibility + getState().setCaption(caption); + getPage().setTitle(caption); + } + + } + + /** + * The application to which this root belongs + */ + private Application application; + + /** + * List of windows in this root. + */ + private final LinkedHashSet windows = new LinkedHashSet(); + + /** + * The component that should be scrolled into view after the next repaint. + * Null if nothing should be scrolled into view. + */ + private Component scrollIntoView; + + /** + * The id of this root, used to find the server side instance of the root + * form which a request originates. A negative value indicates that the root + * id has not yet been assigned by the Application. + * + * @see Application#nextRootId + */ + private int rootId = -1; + + /** + * Keeps track of the Actions added to this component, and manages the + * painting and handling as well. + */ + protected ActionManager actionManager; + + /** + * Thread local for keeping track of the current root. + */ + private static final ThreadLocal currentRoot = new ThreadLocal(); + + /** Identifies the click event */ + private ConnectorTracker connectorTracker = new ConnectorTracker(this); + + private Page page = new Page(this); + + private RootServerRpc rpc = new RootServerRpc() { + @Override + public void click(MouseEventDetails mouseDetails) { + fireEvent(new ClickEvent(UI.this, mouseDetails)); + } + + @Override + public void resize(int viewWidth, int viewHeight, int windowWidth, + int windowHeight) { + // TODO We're not doing anything with the view dimensions + getPage().setBrowserWindowSize(windowWidth, windowHeight); + } + }; + + /** + * Creates a new empty root without a caption. This root will have a + * {@link VerticalLayout} with margins enabled as its content. + */ + public UI() { + this((ComponentContainer) null); + } + + /** + * Creates a new root with the given component container as its content. + * + * @param content + * the content container to use as this roots content. + * + * @see #setContent(ComponentContainer) + */ + public UI(ComponentContainer content) { + registerRpc(rpc); + setSizeFull(); + setContent(content); + } + + /** + * Creates a new empty root with the given caption. This root will have a + * {@link VerticalLayout} with margins enabled as its content. + * + * @param caption + * the caption of the root, used as the page title if there's + * nothing but the application on the web page + * + * @see #setCaption(String) + */ + public UI(String caption) { + this((ComponentContainer) null); + setCaption(caption); + } + + /** + * Creates a new root with the given caption and content. + * + * @param caption + * the caption of the root, used as the page title if there's + * nothing but the application on the web page + * @param content + * the content container to use as this roots content. + * + * @see #setContent(ComponentContainer) + * @see #setCaption(String) + */ + public UI(String caption, ComponentContainer content) { + this(content); + setCaption(caption); + } + + @Override + protected RootState getState() { + return (RootState) super.getState(); + } + + @Override + public Class getStateType() { + // This is a workaround for a problem with creating the correct state + // object during build + return RootState.class; + } + + /** + * Overridden to return a value instead of referring to the parent. + * + * @return this root + * + * @see com.vaadin.ui.AbstractComponent#getRoot() + */ + @Override + public UI getRoot() { + return this; + } + + @Override + public void replaceComponent(Component oldComponent, Component newComponent) { + throw new UnsupportedOperationException(); + } + + @Override + public Application getApplication() { + return application; + } + + @Override + public void paintContent(PaintTarget target) throws PaintException { + page.paintContent(target); + + if (scrollIntoView != null) { + target.addAttribute("scrollTo", scrollIntoView); + scrollIntoView = null; + } + + if (pendingFocus != null) { + // ensure focused component is still attached to this main window + if (pendingFocus.getRoot() == this + || (pendingFocus.getRoot() != null && pendingFocus + .getRoot().getParent() == this)) { + target.addAttribute("focused", pendingFocus); + } + pendingFocus = null; + } + + if (actionManager != null) { + actionManager.paintActions(null, target); + } + + if (isResizeLazy()) { + target.addAttribute(RootConstants.RESIZE_LAZY, true); + } + } + + /** + * Fire a click event to all click listeners. + * + * @param object + * The raw "value" of the variable change from the client side. + */ + private void fireClick(Map parameters) { + MouseEventDetails mouseDetails = MouseEventDetails + .deSerialize((String) parameters.get("mouseDetails")); + fireEvent(new ClickEvent(this, mouseDetails)); + } + + @Override + @SuppressWarnings("unchecked") + public void changeVariables(Object source, Map variables) { + if (variables.containsKey(EventId.CLICK_EVENT_IDENTIFIER)) { + fireClick((Map) variables + .get(EventId.CLICK_EVENT_IDENTIFIER)); + } + + // Actions + if (actionManager != null) { + actionManager.handleActions(variables, this); + } + + if (variables.containsKey(RootConstants.FRAGMENT_VARIABLE)) { + String fragment = (String) variables + .get(RootConstants.FRAGMENT_VARIABLE); + getPage().setFragment(fragment, true); + } + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.ui.ComponentContainer#getComponentIterator() + */ + @Override + public Iterator getComponentIterator() { + // TODO could directly create some kind of combined iterator instead of + // creating a new ArrayList + ArrayList components = new ArrayList(); + + if (getContent() != null) { + components.add(getContent()); + } + + components.addAll(windows); + + return components.iterator(); + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.ui.ComponentContainer#getComponentCount() + */ + @Override + public int getComponentCount() { + return windows.size() + (getContent() == null ? 0 : 1); + } + + /** + * Sets the application to which this root is assigned. It is not legal to + * change the application once it has been set nor to set a + * null application. + *

      + * This method is mainly intended for internal use by the framework. + *

      + * + * @param application + * the application to set + * + * @throws IllegalStateException + * if the application has already been set + * + * @see #getApplication() + */ + public void setApplication(Application application) { + if ((application == null) == (this.application == null)) { + throw new IllegalStateException("Application has already been set"); + } else { + this.application = application; + } + + if (application != null) { + attach(); + } else { + detach(); + } + } + + /** + * Sets the id of this root within its application. The root id is used to + * route requests to the right root. + *

      + * This method is mainly intended for internal use by the framework. + *

      + * + * @param rootId + * the id of this root + * + * @throws IllegalStateException + * if the root id has already been set + * + * @see #getRootId() + */ + public void setRootId(int rootId) { + if (this.rootId != -1) { + throw new IllegalStateException("UI id has already been defined"); + } + this.rootId = rootId; + } + + /** + * Gets the id of the root, used to identify this root within its + * application when processing requests. The root id should be present in + * every request to the server that originates from this root. + * {@link Application#getRootForRequest(WrappedRequest)} uses this id to + * find the route to which the request belongs. + * + * @return + */ + public int getRootId() { + return rootId; + } + + /** + * Adds a window as a subwindow inside this root. To open a new browser + * window or tab, you should instead use {@link open(Resource)} with an url + * pointing to this application and ensure + * {@link Application#getRoot(WrappedRequest)} returns an appropriate root + * for the request. + * + * @param window + * @throws IllegalArgumentException + * if the window is already added to an application + * @throws NullPointerException + * if the given Window is null. + */ + public void addWindow(Window window) throws IllegalArgumentException, + NullPointerException { + + if (window == null) { + throw new NullPointerException("Argument must not be null"); + } + + if (window.getApplication() != null) { + throw new IllegalArgumentException( + "Window is already attached to an application."); + } + + attachWindow(window); + } + + /** + * Helper method to attach a window. + * + * @param w + * the window to add + */ + private void attachWindow(Window w) { + windows.add(w); + w.setParent(this); + markAsDirty(); + } + + /** + * Remove the given subwindow from this root. + * + * Since Vaadin 6.5, {@link CloseListener}s are called also when explicitly + * removing a window by calling this method. + * + * Since Vaadin 6.5, returns a boolean indicating if the window was removed + * or not. + * + * @param window + * Window to be removed. + * @return true if the subwindow was removed, false otherwise + */ + public boolean removeWindow(Window window) { + if (!windows.remove(window)) { + // Window window is not a subwindow of this root. + return false; + } + window.setParent(null); + window.fireClose(); + markAsDirty(); + + return true; + } + + /** + * Gets all the windows added to this root. + * + * @return an unmodifiable collection of windows + */ + public Collection getWindows() { + return Collections.unmodifiableCollection(windows); + } + + @Override + public void focus() { + super.focus(); + } + + /** + * Component that should be focused after the next repaint. Null if no focus + * change should take place. + */ + private Focusable pendingFocus; + + private boolean resizeLazy = false; + + /** + * This method is used by Component.Focusable objects to request focus to + * themselves. Focus renders must be handled at window level (instead of + * Component.Focusable) due we want the last focused component to be focused + * in client too. Not the one that is rendered last (the case we'd get if + * implemented in Focusable only). + * + * To focus component from Vaadin application, use Focusable.focus(). See + * {@link Focusable}. + * + * @param focusable + * to be focused on next paint + */ + public void setFocusedComponent(Focusable focusable) { + pendingFocus = focusable; + markAsDirty(); + } + + /** + * Scrolls any component between the component and root to a suitable + * position so the component is visible to the user. The given component + * must belong to this root. + * + * @param component + * the component to be scrolled into view + * @throws IllegalArgumentException + * if {@code component} does not belong to this root + */ + public void scrollIntoView(Component component) + throws IllegalArgumentException { + if (component.getRoot() != this) { + throw new IllegalArgumentException( + "The component where to scroll must belong to this root."); + } + scrollIntoView = component; + markAsDirty(); + } + + /** + * Gets the content of this root. The content is a component container that + * serves as the outermost item of the visual contents of this root. + * + * @return a component container to use as content + * + * @see #setContent(ComponentContainer) + * @see #createDefaultLayout() + */ + public ComponentContainer getContent() { + return (ComponentContainer) getState().getContent(); + } + + /** + * Helper method to create the default content layout that is used if no + * content has not been explicitly defined. + * + * @return a newly created layout + */ + private static VerticalLayout createDefaultLayout() { + VerticalLayout layout = new VerticalLayout(); + layout.setMargin(true); + return layout; + } + + /** + * Sets the content of this root. The content is a component container that + * serves as the outermost item of the visual contents of this root. If no + * content has been set, a {@link VerticalLayout} with margins enabled will + * be used by default - see {@link #createDefaultLayout()}. The content can + * also be set in a constructor. + * + * @return a component container to use as content + * + * @see #UI(ComponentContainer) + * @see #createDefaultLayout() + */ + public void setContent(ComponentContainer content) { + if (content == null) { + content = createDefaultLayout(); + } + + if (getState().getContent() != null) { + super.removeComponent((Component) getState().getContent()); + } + getState().setContent(content); + if (content != null) { + super.addComponent(content); + } + } + + /** + * Adds a component to this root. The component is not added directly to the + * root, but instead to the content container ({@link #getContent()}). + * + * @param component + * the component to add to this root + * + * @see #getContent() + */ + @Override + public void addComponent(Component component) { + getContent().addComponent(component); + } + + /** + * This implementation removes the component from the content container ( + * {@link #getContent()}) instead of from the actual root. + */ + @Override + public void removeComponent(Component component) { + getContent().removeComponent(component); + } + + /** + * This implementation removes the components from the content container ( + * {@link #getContent()}) instead of from the actual root. + */ + @Override + public void removeAllComponents() { + getContent().removeAllComponents(); + } + + /** + * Internal initialization method, should not be overridden. This method is + * not declared as final because that would break compatibility with e.g. + * CDI. + * + * @param request + * the initialization request + */ + public void doInit(WrappedRequest request) { + getPage().init(request); + + // Call the init overridden by the application developer + init(request); + } + + /** + * Initializes this root. This method is intended to be overridden by + * subclasses to build the view and configure non-component functionality. + * Performing the initialization in a constructor is not suggested as the + * state of the root is not properly set up when the constructor is invoked. + *

      + * The {@link WrappedRequest} can be used to get information about the + * request that caused this root to be created. By default, the + * {@link BrowserDetails} will be available in the request. If the browser + * details are not required, loading the application in the browser can take + * some shortcuts giving a faster initial rendering. This can be indicated + * by adding the {@link EagerInit} annotation to the UI class. + *

      + * + * @param request + * the wrapped request that caused this root to be created + */ + protected abstract void init(WrappedRequest request); + + /** + * Sets the thread local for the current root. This method is used by the + * framework to set the current application whenever a new request is + * processed and it is cleared when the request has been processed. + *

      + * The application developer can also use this method to define the current + * root outside the normal request handling, e.g. when initiating custom + * background threads. + *

      + * + * @param uI + * the root to register as the current root + * + * @see #getCurrent() + * @see ThreadLocal + */ + public static void setCurrent(UI uI) { + currentRoot.set(uI); + } + + /** + * Gets the currently used root. The current root is automatically defined + * when processing requests to the server. In other cases, (e.g. from + * background threads), the current root is not automatically defined. + * + * @return the current root instance if available, otherwise + * null + * + * @see #setCurrent(UI) + */ + public static UI getCurrent() { + return currentRoot.get(); + } + + public void setScrollTop(int scrollTop) { + throw new RuntimeException("Not yet implemented"); + } + + @Override + protected ActionManager getActionManager() { + if (actionManager == null) { + actionManager = new ActionManager(this); + } + return actionManager; + } + + @Override + public void addAction( + T action) { + getActionManager().addAction(action); + } + + @Override + public void removeAction( + T action) { + if (actionManager != null) { + actionManager.removeAction(action); + } + } + + @Override + public void addActionHandler(Handler actionHandler) { + getActionManager().addActionHandler(actionHandler); + } + + @Override + public void removeActionHandler(Handler actionHandler) { + if (actionManager != null) { + actionManager.removeActionHandler(actionHandler); + } + } + + /** + * Should resize operations be lazy, i.e. should there be a delay before + * layout sizes are recalculated. Speeds up resize operations in slow UIs + * with the penalty of slightly decreased usability. + *

      + * Default value: false + * + * @param resizeLazy + * true to use a delay before recalculating sizes, false to + * calculate immediately. + */ + public void setResizeLazy(boolean resizeLazy) { + this.resizeLazy = resizeLazy; + markAsDirty(); + } + + /** + * Checks whether lazy resize is enabled. + * + * @return true if lazy resize is enabled, false + * if lazy resize is not enabled + */ + public boolean isResizeLazy() { + return resizeLazy; + } + + /** + * Add a click listener to the UI. The listener is called whenever the + * user clicks inside the UI. Also when the click targets a component + * inside the UI, provided the targeted component does not prevent the + * click event from propagating. + * + * Use {@link #removeListener(ClickListener)} to remove the listener. + * + * @param listener + * The listener to add + */ + public void addListener(ClickListener listener) { + addListener(EventId.CLICK_EVENT_IDENTIFIER, ClickEvent.class, listener, + ClickListener.clickMethod); + } + + /** + * Remove a click listener from the UI. The listener should earlier have + * been added using {@link #addListener(ClickListener)}. + * + * @param listener + * The listener to remove + */ + public void removeListener(ClickListener listener) { + removeListener(EventId.CLICK_EVENT_IDENTIFIER, ClickEvent.class, + listener); + } + + @Override + public boolean isConnectorEnabled() { + // TODO How can a UI be invisible? What does it mean? + return isVisible() && isEnabled(); + } + + public ConnectorTracker getConnectorTracker() { + return connectorTracker; + } + + public Page getPage() { + return page; + } + + /** + * Setting the caption of a UI is not supported. To set the title of the + * HTML page, use Page.setTitle + * + * @deprecated as of 7.0.0, use {@link Page#setTitle(String)} + */ + @Override + @Deprecated + public void setCaption(String caption) { + throw new IllegalStateException( + "You can not set the title of a UI. To set the title of the HTML page, use Page.setTitle"); + } + + /** + * Shows a notification message on the middle of the root. The message + * automatically disappears ("humanized message"). + * + * Care should be taken to to avoid XSS vulnerabilities as the caption is + * rendered as html. + * + * @see #showNotification(Notification) + * @see Notification + * + * @param caption + * The message + * + * @deprecated As of 7.0, use Notification.show instead but be aware that + * Notification.show does not allow HTML. + */ + @Deprecated + public void showNotification(String caption) { + Notification notification = new Notification(caption); + notification.setHtmlContentAllowed(true);// Backwards compatibility + getPage().showNotification(notification); + } + + /** + * Shows a notification message the root. The position and behavior of the + * message depends on the type, which is one of the basic types defined in + * {@link Notification}, for instance Notification.TYPE_WARNING_MESSAGE. + * + * Care should be taken to to avoid XSS vulnerabilities as the caption is + * rendered as html. + * + * @see #showNotification(Notification) + * @see Notification + * + * @param caption + * The message + * @param type + * The message type + * + * @deprecated As of 7.0, use Notification.show instead but be aware that + * Notification.show does not allow HTML. + */ + @Deprecated + public void showNotification(String caption, Notification.Type type) { + Notification notification = new Notification(caption, type); + notification.setHtmlContentAllowed(true);// Backwards compatibility + getPage().showNotification(notification); + } + + /** + * Shows a notification consisting of a bigger caption and a smaller + * description on the middle of the root. The message automatically + * disappears ("humanized message"). + * + * Care should be taken to to avoid XSS vulnerabilities as the caption and + * description are rendered as html. + * + * @see #showNotification(Notification) + * @see Notification + * + * @param caption + * The caption of the message + * @param description + * The message description + * + * @deprecated As of 7.0, use new Notification(...).show(Page) instead but + * be aware that HTML by default not allowed. + */ + @Deprecated + public void showNotification(String caption, String description) { + Notification notification = new Notification(caption, description); + notification.setHtmlContentAllowed(true);// Backwards compatibility + getPage().showNotification(notification); + } + + /** + * Shows a notification consisting of a bigger caption and a smaller + * description. The position and behavior of the message depends on the + * type, which is one of the basic types defined in {@link Notification} , + * for instance Notification.TYPE_WARNING_MESSAGE. + * + * Care should be taken to to avoid XSS vulnerabilities as the caption and + * description are rendered as html. + * + * @see #showNotification(Notification) + * @see Notification + * + * @param caption + * The caption of the message + * @param description + * The message description + * @param type + * The message type + * + * @deprecated As of 7.0, use new Notification(...).show(Page) instead but + * be aware that HTML by default not allowed. + */ + @Deprecated + public void showNotification(String caption, String description, + Notification.Type type) { + Notification notification = new Notification(caption, description, type); + notification.setHtmlContentAllowed(true);// Backwards compatibility + getPage().showNotification(notification); + } + + /** + * Shows a notification consisting of a bigger caption and a smaller + * description. The position and behavior of the message depends on the + * type, which is one of the basic types defined in {@link Notification} , + * for instance Notification.TYPE_WARNING_MESSAGE. + * + * Care should be taken to avoid XSS vulnerabilities if html content is + * allowed. + * + * @see #showNotification(Notification) + * @see Notification + * + * @param caption + * The message caption + * @param description + * The message description + * @param type + * The type of message + * @param htmlContentAllowed + * Whether html in the caption and description should be + * displayed as html or as plain text + * + * @deprecated As of 7.0, use new Notification(...).show(Page). + */ + @Deprecated + public void showNotification(String caption, String description, + Notification.Type type, boolean htmlContentAllowed) { + getPage() + .showNotification( + new Notification(caption, description, type, + htmlContentAllowed)); + } + + /** + * Shows a notification message. + * + * @see Notification + * @see #showNotification(String) + * @see #showNotification(String, int) + * @see #showNotification(String, String) + * @see #showNotification(String, String, int) + * + * @param notification + * The notification message to show + * + * @deprecated As of 7.0, use Notification.show instead + */ + @Deprecated + public void showNotification(Notification notification) { + getPage().showNotification(notification); + } + +} diff --git a/server/src/com/vaadin/ui/Window.java b/server/src/com/vaadin/ui/Window.java index d79588cc63..335f7fd67d 100644 --- a/server/src/com/vaadin/ui/Window.java +++ b/server/src/com/vaadin/ui/Window.java @@ -40,8 +40,8 @@ import com.vaadin.terminal.Vaadin6Component; /** * A component that represents a floating popup window that can be added to a - * {@link Root}. A window is added to a {@code Root} using - * {@link Root#addWindow(Window)}.

      + * {@link UI}. A window is added to a {@code UI} using + * {@link UI#addWindow(Window)}.

      *

      * The contents of a window is set using {@link #setContent(ComponentContainer)} * or by using the {@link #Window(String, ComponentContainer)} constructor. The @@ -57,7 +57,7 @@ import com.vaadin.terminal.Vaadin6Component; *

      *

      * In Vaadin versions prior to 7.0.0, Window was also used as application level - * windows. This function is now covered by the {@link Root} class. + * windows. This function is now covered by the {@link UI} class. *

      * * @author Vaadin Ltd. @@ -222,14 +222,14 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, *

      */ public void close() { - Root root = getRoot(); + UI uI = getRoot(); // Don't do anything if not attached to a root - if (root != null) { + if (uI != null) { // focus is restored to the parent window - root.focus(); + uI.focus(); // subwindow is removed from the root - root.removeWindow(this); + uI.removeWindow(this); } } @@ -476,13 +476,13 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, *

      */ public void bringToFront() { - Root root = getRoot(); - if (root == null) { + UI uI = getRoot(); + if (uI == null) { throw new IllegalStateException( "Window must be attached to parent before calling bringToFront method."); } int maxBringToFront = -1; - for (Window w : root.getWindows()) { + for (Window w : uI.getWindows()) { if (!isModal() && w.isModal()) { throw new IllegalStateException( "The root contains modal windows, non-modal window cannot be brought to front."); diff --git a/server/src/org/jsoup/select/Evaluator.java b/server/src/org/jsoup/select/Evaluator.java index 16a083bd77..bd0cee481d 100644 --- a/server/src/org/jsoup/select/Evaluator.java +++ b/server/src/org/jsoup/select/Evaluator.java @@ -18,7 +18,7 @@ public abstract class Evaluator { /** * Test if the element meets the evaluator's requirements. * - * @param root Root of the matching subtree + * @param root UI of the matching subtree * @param element tested element */ public abstract boolean matches(Element root, Element element); diff --git a/tests/server-side/com/vaadin/tests/VaadinClasses.java b/tests/server-side/com/vaadin/tests/VaadinClasses.java index 2f937bf58d..5d9e38398c 100644 --- a/tests/server-side/com/vaadin/tests/VaadinClasses.java +++ b/tests/server-side/com/vaadin/tests/VaadinClasses.java @@ -24,7 +24,7 @@ import com.vaadin.ui.Field; import com.vaadin.ui.HorizontalSplitPanel; import com.vaadin.ui.LoginForm; import com.vaadin.ui.PopupView; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; import com.vaadin.ui.VerticalSplitPanel; import com.vaadin.ui.Window; import com.vaadin.ui.themes.BaseTheme; @@ -107,7 +107,7 @@ public class VaadinClasses { classes.remove(DragAndDropWrapper.class); classes.remove(CustomComponent.class); classes.remove(LoginForm.class); - classes.remove(Root.class); + classes.remove(UI.class); return classes; } diff --git a/tests/server-side/com/vaadin/tests/server/TestStreamVariableMapping.java b/tests/server-side/com/vaadin/tests/server/TestStreamVariableMapping.java index ca1bb45330..4e26ffaf45 100644 --- a/tests/server-side/com/vaadin/tests/server/TestStreamVariableMapping.java +++ b/tests/server-side/com/vaadin/tests/server/TestStreamVariableMapping.java @@ -8,7 +8,7 @@ import com.vaadin.Application; import com.vaadin.terminal.StreamVariable; import com.vaadin.terminal.WrappedRequest; import com.vaadin.terminal.gwt.server.CommunicationManager; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; import com.vaadin.ui.Upload; public class TestStreamVariableMapping extends TestCase { @@ -22,7 +22,7 @@ public class TestStreamVariableMapping extends TestCase { @Override protected void setUp() throws Exception { final Application application = new Application(); - final Root root = new Root() { + final UI uI = new UI() { @Override protected void init(WrappedRequest request) { // TODO Auto-generated method stub @@ -36,8 +36,8 @@ public class TestStreamVariableMapping extends TestCase { }; owner = new Upload() { @Override - public Root getRoot() { - return root; + public UI getRoot() { + return uI; } }; streamVariable = EasyMock.createMock(StreamVariable.class); diff --git a/tests/server-side/com/vaadin/tests/server/component/abstractfield/RemoveListenersOnDetach.java b/tests/server-side/com/vaadin/tests/server/component/abstractfield/RemoveListenersOnDetach.java index f66f523770..dd1675c75d 100644 --- a/tests/server-side/com/vaadin/tests/server/component/abstractfield/RemoveListenersOnDetach.java +++ b/tests/server-side/com/vaadin/tests/server/component/abstractfield/RemoveListenersOnDetach.java @@ -10,7 +10,7 @@ import com.vaadin.data.util.AbstractProperty; import com.vaadin.data.util.converter.Converter.ConversionException; import com.vaadin.terminal.WrappedRequest; import com.vaadin.ui.AbstractField; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; public class RemoveListenersOnDetach { @@ -18,7 +18,7 @@ public class RemoveListenersOnDetach { int numReadOnlyChanges = 0; AbstractField field = new AbstractField() { - private Root root = new Root() { + private UI uI = new UI() { @Override protected void init(WrappedRequest request) { @@ -49,8 +49,8 @@ public class RemoveListenersOnDetach { } @Override - public com.vaadin.ui.Root getRoot() { - return root; + public com.vaadin.ui.UI getRoot() { + return uI; }; @Override diff --git a/tests/server-side/com/vaadin/tests/server/component/root/CustomRootClassLoader.java b/tests/server-side/com/vaadin/tests/server/component/root/CustomRootClassLoader.java index 74770f8652..9fe486f85e 100644 --- a/tests/server-side/com/vaadin/tests/server/component/root/CustomRootClassLoader.java +++ b/tests/server-side/com/vaadin/tests/server/component/root/CustomRootClassLoader.java @@ -14,14 +14,14 @@ import com.vaadin.RootRequiresMoreInformationException; import com.vaadin.terminal.DefaultRootProvider; import com.vaadin.terminal.DeploymentConfiguration; import com.vaadin.terminal.WrappedRequest; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; public class CustomRootClassLoader extends TestCase { /** * Stub root */ - public static class MyRoot extends Root { + public static class MyRoot extends UI { @Override protected void init(WrappedRequest request) { // Nothing to see here @@ -45,7 +45,7 @@ public class CustomRootClassLoader extends TestCase { } /** - * Tests that a Root class can be loaded even if no classloader has been + * Tests that a UI class can be loaded even if no classloader has been * provided. * * @throws Exception @@ -56,8 +56,8 @@ public class CustomRootClassLoader extends TestCase { application.start(new ApplicationStartEvent(null, createConfigurationMock(), null)); - Root root = application.getRootForRequest(createRequestMock(null)); - assertTrue(root instanceof MyRoot); + UI uI = application.getRootForRequest(createRequestMock(null)); + assertTrue(uI instanceof MyRoot); } private static DeploymentConfiguration createConfigurationMock() { @@ -89,7 +89,7 @@ public class CustomRootClassLoader extends TestCase { /** * Tests that the ClassLoader passed in the ApplicationStartEvent is used to - * load Root classes. + * load UI classes. * * @throws Exception * if thrown @@ -101,9 +101,9 @@ public class CustomRootClassLoader extends TestCase { application.start(new ApplicationStartEvent(null, createConfigurationMock(), null)); - Root root = application + UI uI = application .getRootForRequest(createRequestMock(loggingClassLoader)); - assertTrue(root instanceof MyRoot); + assertTrue(uI instanceof MyRoot); assertEquals(1, loggingClassLoader.requestedClasses.size()); assertEquals(MyRoot.class.getName(), loggingClassLoader.requestedClasses.get(0)); @@ -126,7 +126,7 @@ public class CustomRootClassLoader extends TestCase { } @Override - public Root getRootForRequest(WrappedRequest request) + public UI getRootForRequest(WrappedRequest request) throws RootRequiresMoreInformationException { // Always create a new root for testing (can't directly use // getRoot as it's protected) diff --git a/tests/server-side/com/vaadin/tests/server/component/window/AddRemoveSubWindow.java b/tests/server-side/com/vaadin/tests/server/component/window/AddRemoveSubWindow.java index f8901803c3..88bc28bbc8 100644 --- a/tests/server-side/com/vaadin/tests/server/component/window/AddRemoveSubWindow.java +++ b/tests/server-side/com/vaadin/tests/server/component/window/AddRemoveSubWindow.java @@ -7,8 +7,8 @@ import static org.junit.Assert.assertTrue; import org.junit.Test; import com.vaadin.Application; -import com.vaadin.ui.Root; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Window; public class AddRemoveSubWindow { @@ -27,7 +27,7 @@ public class AddRemoveSubWindow { TestApp app = new TestApp(); app.init(); Window subWindow = new Window("Sub window"); - Root mainWindow = app.getMainWindow(); + UI mainWindow = app.getMainWindow(); mainWindow.addWindow(subWindow); // Added to main window so the parent of the sub window should be the @@ -61,7 +61,7 @@ public class AddRemoveSubWindow { TestApp app = new TestApp(); app.init(); Window subWindow = new Window("Sub window"); - Root mainWindow = app.getMainWindow(); + UI mainWindow = app.getMainWindow(); mainWindow.addWindow(subWindow); // Added to main window so the parent of the sub window should be the diff --git a/tests/server-side/com/vaadin/tests/server/component/window/AttachDetachWindow.java b/tests/server-side/com/vaadin/tests/server/component/window/AttachDetachWindow.java index e1435ea2ab..e2db224f08 100644 --- a/tests/server-side/com/vaadin/tests/server/component/window/AttachDetachWindow.java +++ b/tests/server-side/com/vaadin/tests/server/component/window/AttachDetachWindow.java @@ -8,7 +8,7 @@ import org.junit.Test; import com.vaadin.Application; import com.vaadin.terminal.WrappedRequest; import com.vaadin.ui.Label; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; @@ -100,7 +100,7 @@ public class AttachDetachWindow { } } - private class TestRoot extends Root implements TestContainer { + private class TestRoot extends UI implements TestContainer { boolean rootAttachCalled = false; boolean rootDetachCalled = false; private TestContent testContent = new TestContent();; diff --git a/tests/server-side/com/vaadin/tests/server/components/TestWindow.java b/tests/server-side/com/vaadin/tests/server/components/TestWindow.java index 7713f69f68..12d3a3c8f5 100644 --- a/tests/server-side/com/vaadin/tests/server/components/TestWindow.java +++ b/tests/server-side/com/vaadin/tests/server/components/TestWindow.java @@ -7,7 +7,7 @@ import junit.framework.TestCase; import org.easymock.EasyMock; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Window; import com.vaadin.ui.Window.CloseEvent; import com.vaadin.ui.Window.CloseListener; diff --git a/tests/testbench/com/vaadin/launcher/ApplicationRunnerServlet.java b/tests/testbench/com/vaadin/launcher/ApplicationRunnerServlet.java index bb37082d30..2ac447cee3 100644 --- a/tests/testbench/com/vaadin/launcher/ApplicationRunnerServlet.java +++ b/tests/testbench/com/vaadin/launcher/ApplicationRunnerServlet.java @@ -36,7 +36,7 @@ import com.vaadin.terminal.WrappedRequest; import com.vaadin.terminal.gwt.server.AbstractApplicationServlet; import com.vaadin.terminal.gwt.server.WrappedHttpServletRequest; import com.vaadin.tests.components.TestBase; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; @SuppressWarnings("serial") public class ApplicationRunnerServlet extends AbstractApplicationServlet { @@ -110,15 +110,15 @@ public class ApplicationRunnerServlet extends AbstractApplicationServlet { // Creates a new application instance try { final Class classToRun = getClassToRun(); - if (Root.class.isAssignableFrom(classToRun)) { + if (UI.class.isAssignableFrom(classToRun)) { Application application = new Application(); application.addRootProvider(new AbstractRootProvider() { @Override - public Class getRootClass( + public Class getRootClass( Application application, WrappedRequest request) throws RootRequiresMoreInformationException { - return (Class) classToRun; + return (Class) classToRun; } }); return application; @@ -126,7 +126,7 @@ public class ApplicationRunnerServlet extends AbstractApplicationServlet { return (Application) classToRun.newInstance(); } else { throw new ServletException(classToRun.getCanonicalName() - + " is neither an Application nor a Root"); + + " is neither an Application nor a UI"); } } catch (final IllegalAccessException e) { throw new ServletException(e); @@ -215,13 +215,13 @@ public class ApplicationRunnerServlet extends AbstractApplicationServlet { protected Class getApplicationClass() throws ClassNotFoundException { Class classToRun = getClassToRun(); - if (Root.class.isAssignableFrom(classToRun)) { + if (UI.class.isAssignableFrom(classToRun)) { return Application.class; } else if (Application.class.isAssignableFrom(classToRun)) { return classToRun.asSubclass(Application.class); } else { throw new ClassCastException(classToRun.getCanonicalName() - + " is not an Application nor a Root"); + + " is not an Application nor a UI"); } } diff --git a/tests/testbench/com/vaadin/tests/Components.java b/tests/testbench/com/vaadin/tests/Components.java index f4fa1b6608..66e693a1de 100644 --- a/tests/testbench/com/vaadin/tests/Components.java +++ b/tests/testbench/com/vaadin/tests/Components.java @@ -25,7 +25,7 @@ import com.vaadin.ui.ComponentContainer; import com.vaadin.ui.Embedded; import com.vaadin.ui.HorizontalSplitPanel; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Tree; import com.vaadin.ui.Tree.ItemStyleGenerator; import com.vaadin.ui.VerticalLayout; diff --git a/tests/testbench/com/vaadin/tests/CustomLayoutDemo.java b/tests/testbench/com/vaadin/tests/CustomLayoutDemo.java index ce99f6e70f..833340f678 100644 --- a/tests/testbench/com/vaadin/tests/CustomLayoutDemo.java +++ b/tests/testbench/com/vaadin/tests/CustomLayoutDemo.java @@ -26,7 +26,7 @@ import com.vaadin.ui.Field; import com.vaadin.ui.Label; import com.vaadin.ui.Panel; import com.vaadin.ui.PasswordField; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TextField; import com.vaadin.ui.Tree; diff --git a/tests/testbench/com/vaadin/tests/LayoutDemo.java b/tests/testbench/com/vaadin/tests/LayoutDemo.java index 1a3801aecc..23997ac084 100644 --- a/tests/testbench/com/vaadin/tests/LayoutDemo.java +++ b/tests/testbench/com/vaadin/tests/LayoutDemo.java @@ -25,7 +25,7 @@ import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.ui.Layout; import com.vaadin.ui.Panel; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TabSheet; import com.vaadin.ui.VerticalLayout; diff --git a/tests/testbench/com/vaadin/tests/ListenerOrder.java b/tests/testbench/com/vaadin/tests/ListenerOrder.java index 7f136b10ed..ab364a8781 100644 --- a/tests/testbench/com/vaadin/tests/ListenerOrder.java +++ b/tests/testbench/com/vaadin/tests/ListenerOrder.java @@ -13,7 +13,7 @@ import com.vaadin.data.Property.ValueChangeListener; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Select; public class ListenerOrder extends com.vaadin.Application.LegacyApplication diff --git a/tests/testbench/com/vaadin/tests/ModalWindow.java b/tests/testbench/com/vaadin/tests/ModalWindow.java index 84fa761eb4..6153f14285 100644 --- a/tests/testbench/com/vaadin/tests/ModalWindow.java +++ b/tests/testbench/com/vaadin/tests/ModalWindow.java @@ -20,7 +20,7 @@ import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TextField; import com.vaadin.ui.Window; diff --git a/tests/testbench/com/vaadin/tests/NativeWindowing.java b/tests/testbench/com/vaadin/tests/NativeWindowing.java index 70f978a8b1..4bce92b668 100644 --- a/tests/testbench/com/vaadin/tests/NativeWindowing.java +++ b/tests/testbench/com/vaadin/tests/NativeWindowing.java @@ -24,7 +24,7 @@ import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Window; public class NativeWindowing extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/Parameters.java b/tests/testbench/com/vaadin/tests/Parameters.java index e9824d9c40..d6bc9007ed 100644 --- a/tests/testbench/com/vaadin/tests/Parameters.java +++ b/tests/testbench/com/vaadin/tests/Parameters.java @@ -30,7 +30,7 @@ import com.vaadin.ui.Label; import com.vaadin.ui.Layout.MarginHandler; import com.vaadin.ui.Link; import com.vaadin.ui.Panel; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Table; import com.vaadin.ui.VerticalLayout; diff --git a/tests/testbench/com/vaadin/tests/RandomLayoutStress.java b/tests/testbench/com/vaadin/tests/RandomLayoutStress.java index 711e79a28d..0161a2a20e 100644 --- a/tests/testbench/com/vaadin/tests/RandomLayoutStress.java +++ b/tests/testbench/com/vaadin/tests/RandomLayoutStress.java @@ -29,7 +29,7 @@ import com.vaadin.ui.Label; import com.vaadin.ui.Layout; import com.vaadin.ui.Link; import com.vaadin.ui.Panel; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Select; import com.vaadin.ui.TabSheet; import com.vaadin.ui.TextField; diff --git a/tests/testbench/com/vaadin/tests/ScrollbarStressTest.java b/tests/testbench/com/vaadin/tests/ScrollbarStressTest.java index 9cd27e9d5c..7436bfc539 100644 --- a/tests/testbench/com/vaadin/tests/ScrollbarStressTest.java +++ b/tests/testbench/com/vaadin/tests/ScrollbarStressTest.java @@ -10,7 +10,7 @@ import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.ui.OptionGroup; import com.vaadin.ui.Panel; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TabSheet; import com.vaadin.ui.Table; import com.vaadin.ui.VerticalLayout; diff --git a/tests/testbench/com/vaadin/tests/TestBench.java b/tests/testbench/com/vaadin/tests/TestBench.java index b58df225bc..32fff09455 100644 --- a/tests/testbench/com/vaadin/tests/TestBench.java +++ b/tests/testbench/com/vaadin/tests/TestBench.java @@ -37,7 +37,7 @@ import com.vaadin.ui.Label; import com.vaadin.ui.Layout; import com.vaadin.ui.Link; import com.vaadin.ui.Panel; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Tree; import com.vaadin.ui.VerticalLayout; diff --git a/tests/testbench/com/vaadin/tests/TestForApplicationLayoutThatUsesWholeBrosersSpace.java b/tests/testbench/com/vaadin/tests/TestForApplicationLayoutThatUsesWholeBrosersSpace.java index 78ab9f61ca..c3fa269fba 100644 --- a/tests/testbench/com/vaadin/tests/TestForApplicationLayoutThatUsesWholeBrosersSpace.java +++ b/tests/testbench/com/vaadin/tests/TestForApplicationLayoutThatUsesWholeBrosersSpace.java @@ -19,7 +19,7 @@ package com.vaadin.tests; import com.vaadin.Application; import com.vaadin.ui.HorizontalSplitPanel; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Table; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.VerticalSplitPanel; diff --git a/tests/testbench/com/vaadin/tests/TestForNativeWindowing.java b/tests/testbench/com/vaadin/tests/TestForNativeWindowing.java index 628c3cc4e8..41b3309c57 100644 --- a/tests/testbench/com/vaadin/tests/TestForNativeWindowing.java +++ b/tests/testbench/com/vaadin/tests/TestForNativeWindowing.java @@ -24,7 +24,7 @@ import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Window; public class TestForNativeWindowing extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/TestForStyledUpload.java b/tests/testbench/com/vaadin/tests/TestForStyledUpload.java index 120cf9a59a..af41ccc37b 100644 --- a/tests/testbench/com/vaadin/tests/TestForStyledUpload.java +++ b/tests/testbench/com/vaadin/tests/TestForStyledUpload.java @@ -36,7 +36,7 @@ import com.vaadin.ui.Layout; import com.vaadin.ui.Link; import com.vaadin.ui.Panel; import com.vaadin.ui.ProgressIndicator; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Upload; import com.vaadin.ui.Upload.FailedEvent; import com.vaadin.ui.Upload.FailedListener; diff --git a/tests/testbench/com/vaadin/tests/TestForWindowOpen.java b/tests/testbench/com/vaadin/tests/TestForWindowOpen.java index 621bdbfee2..3b5c7404e7 100644 --- a/tests/testbench/com/vaadin/tests/TestForWindowOpen.java +++ b/tests/testbench/com/vaadin/tests/TestForWindowOpen.java @@ -20,7 +20,7 @@ import com.vaadin.terminal.ExternalResource; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.CustomComponent; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; import com.vaadin.ui.VerticalLayout; public class TestForWindowOpen extends CustomComponent { @@ -37,7 +37,7 @@ public class TestForWindowOpen extends CustomComponent { public void buttonClick(ClickEvent event) { final ExternalResource r = new ExternalResource( "http://www.google.com"); - Root.getCurrent().getPage().open(r); + UI.getCurrent().getPage().open(r); } @@ -50,7 +50,7 @@ public class TestForWindowOpen extends CustomComponent { public void buttonClick(ClickEvent event) { final ExternalResource r = new ExternalResource( "http://www.google.com"); - Root.getCurrent().getPage().open(r, "mytarget"); + UI.getCurrent().getPage().open(r, "mytarget"); } @@ -63,7 +63,7 @@ public class TestForWindowOpen extends CustomComponent { public void buttonClick(ClickEvent event) { final ExternalResource r = new ExternalResource( "http://www.google.com"); - Root.getCurrent().getPage().open(r, "secondtarget"); + UI.getCurrent().getPage().open(r, "secondtarget"); } diff --git a/tests/testbench/com/vaadin/tests/TestForWindowing.java b/tests/testbench/com/vaadin/tests/TestForWindowing.java index 9a3362af8b..a59323b97c 100644 --- a/tests/testbench/com/vaadin/tests/TestForWindowing.java +++ b/tests/testbench/com/vaadin/tests/TestForWindowing.java @@ -26,7 +26,7 @@ import com.vaadin.ui.CheckBox; import com.vaadin.ui.CustomComponent; import com.vaadin.ui.Label; import com.vaadin.ui.OptionGroup; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; import com.vaadin.ui.Select; import com.vaadin.ui.Slider; import com.vaadin.ui.VerticalLayout; @@ -99,7 +99,7 @@ public class TestForWindowing extends CustomComponent { w.addComponent(s); - Root.getCurrent().addWindow(w); + UI.getCurrent().addWindow(w); } diff --git a/tests/testbench/com/vaadin/tests/TestSetVisibleAndCaching.java b/tests/testbench/com/vaadin/tests/TestSetVisibleAndCaching.java index 5b3a93e065..6bb8bac200 100644 --- a/tests/testbench/com/vaadin/tests/TestSetVisibleAndCaching.java +++ b/tests/testbench/com/vaadin/tests/TestSetVisibleAndCaching.java @@ -21,7 +21,7 @@ import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Label; import com.vaadin.ui.Panel; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class TestSetVisibleAndCaching extends com.vaadin.Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/TestSizeableIncomponents.java b/tests/testbench/com/vaadin/tests/TestSizeableIncomponents.java index f33132a709..a0ff6f0fc7 100644 --- a/tests/testbench/com/vaadin/tests/TestSizeableIncomponents.java +++ b/tests/testbench/com/vaadin/tests/TestSizeableIncomponents.java @@ -37,7 +37,7 @@ import com.vaadin.ui.Embedded; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.ui.Panel; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Table; import com.vaadin.ui.VerticalLayout; diff --git a/tests/testbench/com/vaadin/tests/TestSplitPanel.java b/tests/testbench/com/vaadin/tests/TestSplitPanel.java index d1a6ede53c..4b0b47ed74 100644 --- a/tests/testbench/com/vaadin/tests/TestSplitPanel.java +++ b/tests/testbench/com/vaadin/tests/TestSplitPanel.java @@ -17,7 +17,7 @@ package com.vaadin.tests; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.VerticalSplitPanel; public class TestSplitPanel extends com.vaadin.Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/TreeFilesystem.java b/tests/testbench/com/vaadin/tests/TreeFilesystem.java index b311ae32b1..f2a0d97b08 100644 --- a/tests/testbench/com/vaadin/tests/TreeFilesystem.java +++ b/tests/testbench/com/vaadin/tests/TreeFilesystem.java @@ -23,7 +23,7 @@ import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.tests.util.SampleDirectory; import com.vaadin.ui.Label; import com.vaadin.ui.Panel; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Tree; import com.vaadin.ui.Tree.ExpandEvent; diff --git a/tests/testbench/com/vaadin/tests/TreeFilesystemContainer.java b/tests/testbench/com/vaadin/tests/TreeFilesystemContainer.java index 52dd61dbee..672c518ea8 100644 --- a/tests/testbench/com/vaadin/tests/TreeFilesystemContainer.java +++ b/tests/testbench/com/vaadin/tests/TreeFilesystemContainer.java @@ -26,7 +26,7 @@ import com.vaadin.ui.Component.Listener; import com.vaadin.ui.Field; import com.vaadin.ui.Label; import com.vaadin.ui.Panel; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Tree; import com.vaadin.ui.VerticalLayout; diff --git a/tests/testbench/com/vaadin/tests/UpgradingSample.java b/tests/testbench/com/vaadin/tests/UpgradingSample.java index cf2516fbff..48e2222d7e 100644 --- a/tests/testbench/com/vaadin/tests/UpgradingSample.java +++ b/tests/testbench/com/vaadin/tests/UpgradingSample.java @@ -31,7 +31,7 @@ import com.vaadin.ui.CustomComponent; import com.vaadin.ui.GridLayout; import com.vaadin.ui.Label; import com.vaadin.ui.Panel; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TextField; import com.vaadin.ui.Tree; import com.vaadin.ui.VerticalLayout; diff --git a/tests/testbench/com/vaadin/tests/UsingObjectsInSelect.java b/tests/testbench/com/vaadin/tests/UsingObjectsInSelect.java index 42a9d358c5..c5a836b4f1 100644 --- a/tests/testbench/com/vaadin/tests/UsingObjectsInSelect.java +++ b/tests/testbench/com/vaadin/tests/UsingObjectsInSelect.java @@ -24,7 +24,7 @@ import com.vaadin.data.Property.ValueChangeListener; import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.ui.Label; import com.vaadin.ui.Panel; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Select; public class UsingObjectsInSelect extends diff --git a/tests/testbench/com/vaadin/tests/appengine/GAESyncTest.java b/tests/testbench/com/vaadin/tests/appengine/GAESyncTest.java index fbf9e7b46e..7a06dedd63 100644 --- a/tests/testbench/com/vaadin/tests/appengine/GAESyncTest.java +++ b/tests/testbench/com/vaadin/tests/appengine/GAESyncTest.java @@ -12,7 +12,7 @@ import com.vaadin.ui.Embedded; import com.vaadin.ui.GridLayout; import com.vaadin.ui.Label; import com.vaadin.ui.Notification; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TextField; public class GAESyncTest extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/application/ErrorInUnloadEvent.java b/tests/testbench/com/vaadin/tests/application/ErrorInUnloadEvent.java index 690df3f360..2e6c188331 100644 --- a/tests/testbench/com/vaadin/tests/application/ErrorInUnloadEvent.java +++ b/tests/testbench/com/vaadin/tests/application/ErrorInUnloadEvent.java @@ -10,7 +10,7 @@ import com.vaadin.ui.FormLayout; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.ui.PasswordField; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; diff --git a/tests/testbench/com/vaadin/tests/application/RefreshStatePreserve.java b/tests/testbench/com/vaadin/tests/application/RefreshStatePreserve.java index bd2aea3756..023a93438d 100644 --- a/tests/testbench/com/vaadin/tests/application/RefreshStatePreserve.java +++ b/tests/testbench/com/vaadin/tests/application/RefreshStatePreserve.java @@ -6,16 +6,16 @@ import com.vaadin.terminal.AbstractRootProvider; import com.vaadin.terminal.WrappedRequest; import com.vaadin.tests.components.AbstractTestApplication; import com.vaadin.ui.Label; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; public class RefreshStatePreserve extends AbstractTestApplication { - public static class RefreshStateRoot extends Root { + public static class RefreshStateRoot extends UI { @Override public void init(WrappedRequest request) { getContent().addComponent( new Label("window.name: " + request.getBrowserDetails().getWindowName())); - getContent().addComponent(new Label("Root id: " + getRootId())); + getContent().addComponent(new Label("UI id: " + getRootId())); } } @@ -25,7 +25,7 @@ public class RefreshStatePreserve extends AbstractTestApplication { setRootPreserved(true); addRootProvider(new AbstractRootProvider() { @Override - public Class getRootClass(Application application, + public Class getRootClass(Application application, WrappedRequest request) throws RootRequiresMoreInformationException { return RefreshStateRoot.class; diff --git a/tests/testbench/com/vaadin/tests/application/TerminalErrorNotification.java b/tests/testbench/com/vaadin/tests/application/TerminalErrorNotification.java index 77596da0f9..992a3afbca 100644 --- a/tests/testbench/com/vaadin/tests/application/TerminalErrorNotification.java +++ b/tests/testbench/com/vaadin/tests/application/TerminalErrorNotification.java @@ -19,7 +19,7 @@ import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Notification; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; public class TerminalErrorNotification extends TestBase { @@ -41,7 +41,7 @@ public class TerminalErrorNotification extends TestBase { public void terminalError(com.vaadin.terminal.Terminal.ErrorEvent event) { event.getThrowable().printStackTrace(); - Root mainWindow = getMainWindow(); + UI mainWindow = getMainWindow(); if (mainWindow != null) { Throwable throwable = event.getThrowable(); diff --git a/tests/testbench/com/vaadin/tests/application/ThreadLocalInstances.java b/tests/testbench/com/vaadin/tests/application/ThreadLocalInstances.java index def68a7357..3323e3bb28 100644 --- a/tests/testbench/com/vaadin/tests/application/ThreadLocalInstances.java +++ b/tests/testbench/com/vaadin/tests/application/ThreadLocalInstances.java @@ -12,14 +12,14 @@ import com.vaadin.tests.util.Log; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Embedded; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; public class ThreadLocalInstances extends AbstractTestApplication { private static final Application staticInitApplication = Application .getCurrent(); - private static final Root staticInitRoot = Root.getCurrent(); + private static final UI staticInitRoot = UI.getCurrent(); - private final Root mainWindow = new Root() { + private final UI mainWindow = new UI() { boolean paintReported = false; @Override @@ -77,14 +77,14 @@ public class ThreadLocalInstances extends AbstractTestApplication { } @Override - protected Root getRoot(WrappedRequest request) + protected UI getRoot(WrappedRequest request) throws RootRequiresMoreInformationException { return mainWindow; } @Override protected String getTestDescription() { - return "Tests the precence of Application.getCurrentApplication() and Root.getCurrentRoot() from different contexts"; + return "Tests the precence of Application.getCurrentApplication() and UI.getCurrentRoot() from different contexts"; } @Override @@ -93,12 +93,12 @@ public class ThreadLocalInstances extends AbstractTestApplication { } private void reportCurrentStatus(String phase) { - reportStatus(phase, Application.getCurrent(), Root.getCurrent()); + reportStatus(phase, Application.getCurrent(), UI.getCurrent()); } - private void reportStatus(String phase, Application application, Root root) { + private void reportStatus(String phase, Application application, UI uI) { log.log(getState(application, this) + " app in " + phase); - log.log(getState(root, mainWindow) + " root in " + phase); + log.log(getState(uI, mainWindow) + " root in " + phase); } private static String getState(Object value, Object reference) { diff --git a/tests/testbench/com/vaadin/tests/applicationcontext/ChangeSessionId.java b/tests/testbench/com/vaadin/tests/applicationcontext/ChangeSessionId.java index abcdf232cd..3169806f27 100644 --- a/tests/testbench/com/vaadin/tests/applicationcontext/ChangeSessionId.java +++ b/tests/testbench/com/vaadin/tests/applicationcontext/ChangeSessionId.java @@ -6,7 +6,7 @@ import com.vaadin.tests.util.Log; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class ChangeSessionId extends AbstractTestCase { diff --git a/tests/testbench/com/vaadin/tests/components/AbstractTestRoot.java b/tests/testbench/com/vaadin/tests/components/AbstractTestRoot.java index d20f7a4a21..cf4bfac426 100644 --- a/tests/testbench/com/vaadin/tests/components/AbstractTestRoot.java +++ b/tests/testbench/com/vaadin/tests/components/AbstractTestRoot.java @@ -8,10 +8,10 @@ import com.vaadin.terminal.gwt.server.AbstractWebApplicationContext; import com.vaadin.terminal.gwt.server.WebBrowser; import com.vaadin.ui.Component; import com.vaadin.ui.Label; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; import com.vaadin.ui.VerticalLayout; -public abstract class AbstractTestRoot extends Root { +public abstract class AbstractTestRoot extends UI { @Override public void init(WrappedRequest request) { diff --git a/tests/testbench/com/vaadin/tests/components/TestBase.java b/tests/testbench/com/vaadin/tests/components/TestBase.java index a66f0efe64..19c6826977 100644 --- a/tests/testbench/com/vaadin/tests/components/TestBase.java +++ b/tests/testbench/com/vaadin/tests/components/TestBase.java @@ -3,7 +3,7 @@ package com.vaadin.tests.components; import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.ui.Component; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.VerticalLayout; public abstract class TestBase extends AbstractTestCase { diff --git a/tests/testbench/com/vaadin/tests/components/abstractcomponent/EnableState.java b/tests/testbench/com/vaadin/tests/components/abstractcomponent/EnableState.java index f8931ecdea..e93529fad4 100644 --- a/tests/testbench/com/vaadin/tests/components/abstractcomponent/EnableState.java +++ b/tests/testbench/com/vaadin/tests/components/abstractcomponent/EnableState.java @@ -6,7 +6,7 @@ import com.vaadin.tests.components.AbstractTestCase; import com.vaadin.ui.Button; import com.vaadin.ui.CheckBox; import com.vaadin.ui.Panel; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class EnableState extends AbstractTestCase { @Override diff --git a/tests/testbench/com/vaadin/tests/components/button/ButtonsInHorizontalLayout.java b/tests/testbench/com/vaadin/tests/components/button/ButtonsInHorizontalLayout.java index bdabed3032..3a0afdce50 100644 --- a/tests/testbench/com/vaadin/tests/components/button/ButtonsInHorizontalLayout.java +++ b/tests/testbench/com/vaadin/tests/components/button/ButtonsInHorizontalLayout.java @@ -3,7 +3,7 @@ package com.vaadin.tests.components.button; import com.vaadin.tests.components.AbstractTestCase; import com.vaadin.ui.Button; import com.vaadin.ui.HorizontalLayout; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.themes.BaseTheme; diff --git a/tests/testbench/com/vaadin/tests/components/combobox/ComboBoxReapperingOldValue.java b/tests/testbench/com/vaadin/tests/components/combobox/ComboBoxReapperingOldValue.java index 5dc5a2efbd..10afb05ae3 100644 --- a/tests/testbench/com/vaadin/tests/components/combobox/ComboBoxReapperingOldValue.java +++ b/tests/testbench/com/vaadin/tests/components/combobox/ComboBoxReapperingOldValue.java @@ -8,7 +8,7 @@ import com.vaadin.data.util.IndexedContainer; import com.vaadin.ui.AbstractSelect; import com.vaadin.ui.ComboBox; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.VerticalLayout; @SuppressWarnings("serial") diff --git a/tests/testbench/com/vaadin/tests/components/combobox/GridLayoutComboBoxZoomOut.java b/tests/testbench/com/vaadin/tests/components/combobox/GridLayoutComboBoxZoomOut.java index 37b0fe21a1..f64fd6f5fa 100644 --- a/tests/testbench/com/vaadin/tests/components/combobox/GridLayoutComboBoxZoomOut.java +++ b/tests/testbench/com/vaadin/tests/components/combobox/GridLayoutComboBoxZoomOut.java @@ -5,7 +5,7 @@ import com.vaadin.ui.ComboBox; import com.vaadin.ui.GridLayout; import com.vaadin.ui.Label; import com.vaadin.ui.Layout; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; import com.vaadin.ui.Select; @SuppressWarnings("serial") @@ -13,7 +13,7 @@ public class GridLayoutComboBoxZoomOut extends AbstractTestCase { @Override public void init() { - Root.LegacyWindow mainWindow = new Root.LegacyWindow( + UI.LegacyWindow mainWindow = new UI.LegacyWindow( "Gridlayoutbug Application"); setMainWindow(mainWindow); diff --git a/tests/testbench/com/vaadin/tests/components/datefield/DateFieldInSubWindow.java b/tests/testbench/com/vaadin/tests/components/datefield/DateFieldInSubWindow.java index 85f1c80a08..4cf7b98679 100644 --- a/tests/testbench/com/vaadin/tests/components/datefield/DateFieldInSubWindow.java +++ b/tests/testbench/com/vaadin/tests/components/datefield/DateFieldInSubWindow.java @@ -13,7 +13,7 @@ import com.vaadin.ui.DefaultFieldFactory; import com.vaadin.ui.Field; import com.vaadin.ui.Form; import com.vaadin.ui.HorizontalLayout; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; diff --git a/tests/testbench/com/vaadin/tests/components/datefield/DateFieldPopupOffScreen.java b/tests/testbench/com/vaadin/tests/components/datefield/DateFieldPopupOffScreen.java index b87c458c01..ac3296724b 100644 --- a/tests/testbench/com/vaadin/tests/components/datefield/DateFieldPopupOffScreen.java +++ b/tests/testbench/com/vaadin/tests/components/datefield/DateFieldPopupOffScreen.java @@ -8,7 +8,7 @@ import com.vaadin.ui.Alignment; import com.vaadin.ui.DateField; import com.vaadin.ui.DateField.Resolution; import com.vaadin.ui.GridLayout; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class DateFieldPopupOffScreen extends AbstractTestCase { diff --git a/tests/testbench/com/vaadin/tests/components/form/UndefinedWideFormWithRelativeWideFooter.java b/tests/testbench/com/vaadin/tests/components/form/UndefinedWideFormWithRelativeWideFooter.java index 21430d8936..b34db2170e 100644 --- a/tests/testbench/com/vaadin/tests/components/form/UndefinedWideFormWithRelativeWideFooter.java +++ b/tests/testbench/com/vaadin/tests/components/form/UndefinedWideFormWithRelativeWideFooter.java @@ -5,7 +5,7 @@ import com.vaadin.ui.Alignment; import com.vaadin.ui.Button; import com.vaadin.ui.Form; import com.vaadin.ui.HorizontalLayout; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TextField; @SuppressWarnings("serial") diff --git a/tests/testbench/com/vaadin/tests/components/formlayout/TableInFormLayoutCausesScrolling.java b/tests/testbench/com/vaadin/tests/components/formlayout/TableInFormLayoutCausesScrolling.java index bbe88b1770..360c559086 100644 --- a/tests/testbench/com/vaadin/tests/components/formlayout/TableInFormLayoutCausesScrolling.java +++ b/tests/testbench/com/vaadin/tests/components/formlayout/TableInFormLayoutCausesScrolling.java @@ -2,7 +2,7 @@ package com.vaadin.tests.components.formlayout; import com.vaadin.tests.components.AbstractTestCase; import com.vaadin.ui.FormLayout; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Table; import com.vaadin.ui.TextField; diff --git a/tests/testbench/com/vaadin/tests/components/loginform/LoginFormRootInLoginHandler.java b/tests/testbench/com/vaadin/tests/components/loginform/LoginFormRootInLoginHandler.java index 2c0a8744fc..db64df936f 100755 --- a/tests/testbench/com/vaadin/tests/components/loginform/LoginFormRootInLoginHandler.java +++ b/tests/testbench/com/vaadin/tests/components/loginform/LoginFormRootInLoginHandler.java @@ -5,7 +5,7 @@ import com.vaadin.ui.Label; import com.vaadin.ui.LoginForm; import com.vaadin.ui.LoginForm.LoginEvent; import com.vaadin.ui.LoginForm.LoginListener; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; public class LoginFormRootInLoginHandler extends TestBase { @@ -16,14 +16,14 @@ public class LoginFormRootInLoginHandler extends TestBase { @Override public void onLogin(LoginEvent event) { - Root r1 = Root.getCurrent(); + UI r1 = UI.getCurrent(); if (r1 != null) { - addComponent(new Label("Root.getCurrent().data: " + addComponent(new Label("UI.getCurrent().data: " + r1.getData())); } else { - addComponent(new Label("Root.getCurrent() is null")); + addComponent(new Label("UI.getCurrent() is null")); } - Root r2 = ((LoginForm) event.getSource()).getRoot(); + UI r2 = ((LoginForm) event.getSource()).getRoot(); if (r2 != null) { addComponent(new Label("event.getSource().data: " + r2.getData())); diff --git a/tests/testbench/com/vaadin/tests/components/loginform/LoginFormWithMultipleWindows.java b/tests/testbench/com/vaadin/tests/components/loginform/LoginFormWithMultipleWindows.java index 83f89f0214..515734338b 100644 --- a/tests/testbench/com/vaadin/tests/components/loginform/LoginFormWithMultipleWindows.java +++ b/tests/testbench/com/vaadin/tests/components/loginform/LoginFormWithMultipleWindows.java @@ -5,14 +5,14 @@ import com.vaadin.terminal.WrappedRequest; import com.vaadin.ui.LoginForm; import com.vaadin.ui.LoginForm.LoginEvent; import com.vaadin.ui.LoginForm.LoginListener; -import com.vaadin.ui.Root; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI; +import com.vaadin.ui.UI.LegacyWindow; @SuppressWarnings("serial") public class LoginFormWithMultipleWindows extends Application { @Override - protected Root getRoot(WrappedRequest request) { + protected UI getRoot(WrappedRequest request) { return new LoginFormWindow(); } diff --git a/tests/testbench/com/vaadin/tests/components/menubar/MenuBarInSplitPanel.java b/tests/testbench/com/vaadin/tests/components/menubar/MenuBarInSplitPanel.java index 2a6f952c0a..59aebd0bd7 100644 --- a/tests/testbench/com/vaadin/tests/components/menubar/MenuBarInSplitPanel.java +++ b/tests/testbench/com/vaadin/tests/components/menubar/MenuBarInSplitPanel.java @@ -4,7 +4,7 @@ import com.vaadin.tests.components.AbstractTestCase; import com.vaadin.ui.HorizontalSplitPanel; import com.vaadin.ui.Label; import com.vaadin.ui.MenuBar; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Tree; import com.vaadin.ui.VerticalLayout; diff --git a/tests/testbench/com/vaadin/tests/components/menubar/MenuBarRunsOutOfBrowser.java b/tests/testbench/com/vaadin/tests/components/menubar/MenuBarRunsOutOfBrowser.java index 33e6c0b4a9..2c4a975f9b 100644 --- a/tests/testbench/com/vaadin/tests/components/menubar/MenuBarRunsOutOfBrowser.java +++ b/tests/testbench/com/vaadin/tests/components/menubar/MenuBarRunsOutOfBrowser.java @@ -4,7 +4,7 @@ import com.vaadin.terminal.ThemeResource; import com.vaadin.tests.components.AbstractTestCase; import com.vaadin.ui.Alignment; import com.vaadin.ui.MenuBar; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.VerticalLayout; public class MenuBarRunsOutOfBrowser extends AbstractTestCase { diff --git a/tests/testbench/com/vaadin/tests/components/orderedlayout/VerticalLayoutWidthCalculation.java b/tests/testbench/com/vaadin/tests/components/orderedlayout/VerticalLayoutWidthCalculation.java index 945ccf0e28..bc76a0c0ce 100644 --- a/tests/testbench/com/vaadin/tests/components/orderedlayout/VerticalLayoutWidthCalculation.java +++ b/tests/testbench/com/vaadin/tests/components/orderedlayout/VerticalLayoutWidthCalculation.java @@ -4,7 +4,7 @@ import com.vaadin.tests.components.AbstractTestCase; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.HorizontalLayout; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; diff --git a/tests/testbench/com/vaadin/tests/components/root/LazyInitRoots.java b/tests/testbench/com/vaadin/tests/components/root/LazyInitRoots.java index 254410a549..aca7211aec 100644 --- a/tests/testbench/com/vaadin/tests/components/root/LazyInitRoots.java +++ b/tests/testbench/com/vaadin/tests/components/root/LazyInitRoots.java @@ -9,12 +9,12 @@ import com.vaadin.terminal.WrappedRequest.BrowserDetails; import com.vaadin.tests.components.AbstractTestApplication; import com.vaadin.ui.Label; import com.vaadin.ui.Link; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; public class LazyInitRoots extends AbstractTestApplication { @EagerInit - private static class EagerInitRoot extends Root { + private static class EagerInitRoot extends UI { @Override public void init(WrappedRequest request) { addComponent(getRequestInfo("EagerInitRoot", request)); @@ -22,29 +22,29 @@ public class LazyInitRoots extends AbstractTestApplication { } @Override - public Root getRoot(WrappedRequest request) + public UI getRoot(WrappedRequest request) throws RootRequiresMoreInformationException { if (request.getParameter("lazyCreate") != null) { - // Root created on second request + // UI created on second request BrowserDetails browserDetails = request.getBrowserDetails(); if (browserDetails == null || browserDetails.getUriFragment() == null) { throw new RootRequiresMoreInformationException(); } else { - Root root = new Root() { + UI uI = new UI() { @Override protected void init(WrappedRequest request) { addComponent(getRequestInfo("LazyCreateRoot", request)); } }; - return root; + return uI; } } else if (request.getParameter("eagerInit") != null) { - // Root inited on first request + // UI inited on first request return new EagerInitRoot(); } else { // The standard root - Root root = new Root() { + UI uI = new UI() { @Override protected void init(WrappedRequest request) { addComponent(getRequestInfo("NormalRoot", request)); @@ -63,7 +63,7 @@ public class LazyInitRoots extends AbstractTestApplication { } }; - return root; + return uI; } } @@ -78,7 +78,7 @@ public class LazyInitRoots extends AbstractTestApplication { @Override protected String getTestDescription() { - return "BrowserDetails should be available in Application.getRoot if RootRequiresMoreInformation has been thrown and in Root.init if the root has the @RootInitRequiresBrowserDetals annotation"; + return "BrowserDetails should be available in Application.getRoot if RootRequiresMoreInformation has been thrown and in UI.init if the root has the @RootInitRequiresBrowserDetals annotation"; } @Override diff --git a/tests/testbench/com/vaadin/tests/components/root/RootsInMultipleTabs.java b/tests/testbench/com/vaadin/tests/components/root/RootsInMultipleTabs.java index ae3182401d..4309b6e942 100644 --- a/tests/testbench/com/vaadin/tests/components/root/RootsInMultipleTabs.java +++ b/tests/testbench/com/vaadin/tests/components/root/RootsInMultipleTabs.java @@ -6,12 +6,12 @@ import com.vaadin.terminal.AbstractRootProvider; import com.vaadin.terminal.WrappedRequest; import com.vaadin.tests.components.AbstractTestApplication; import com.vaadin.ui.Label; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; public class RootsInMultipleTabs extends AbstractTestApplication { private int numberOfRootsOpened; - public static class TabRoot extends Root { + public static class TabRoot extends UI { @Override protected void init(WrappedRequest request) { RootsInMultipleTabs application = (RootsInMultipleTabs) getApplication(); @@ -25,7 +25,7 @@ public class RootsInMultipleTabs extends AbstractTestApplication { public RootsInMultipleTabs() { addRootProvider(new AbstractRootProvider() { @Override - public Class getRootClass(Application application, + public Class getRootClass(Application application, WrappedRequest request) throws RootRequiresMoreInformationException { return TabRoot.class; @@ -35,7 +35,7 @@ public class RootsInMultipleTabs extends AbstractTestApplication { @Override protected String getTestDescription() { - return "Opening the same application again (e.g. in a new tab) should create a new Root."; + return "Opening the same application again (e.g. in a new tab) should create a new UI."; } @Override diff --git a/tests/testbench/com/vaadin/tests/components/root/TestRootTheme.java b/tests/testbench/com/vaadin/tests/components/root/TestRootTheme.java index 77c0bdb150..7a734e8497 100644 --- a/tests/testbench/com/vaadin/tests/components/root/TestRootTheme.java +++ b/tests/testbench/com/vaadin/tests/components/root/TestRootTheme.java @@ -17,7 +17,7 @@ public class TestRootTheme extends AbstractTestRoot { @Override public String getTestDescription() { - return "Root with @RootTheme(\"tests-tickets\")"; + return "UI with @RootTheme(\"tests-tickets\")"; } @Override diff --git a/tests/testbench/com/vaadin/tests/components/splitpanel/SplitPanelExtraScrollbars.java b/tests/testbench/com/vaadin/tests/components/splitpanel/SplitPanelExtraScrollbars.java index 00012522ca..5554b2b9f3 100644 --- a/tests/testbench/com/vaadin/tests/components/splitpanel/SplitPanelExtraScrollbars.java +++ b/tests/testbench/com/vaadin/tests/components/splitpanel/SplitPanelExtraScrollbars.java @@ -8,7 +8,7 @@ import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.HorizontalSplitPanel; import com.vaadin.ui.NativeButton; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class SplitPanelExtraScrollbars extends AbstractTestCase implements ClickListener { diff --git a/tests/testbench/com/vaadin/tests/components/splitpanel/SplitPanelWidthOnResize.java b/tests/testbench/com/vaadin/tests/components/splitpanel/SplitPanelWidthOnResize.java index e80ad29426..3cdc0c8913 100644 --- a/tests/testbench/com/vaadin/tests/components/splitpanel/SplitPanelWidthOnResize.java +++ b/tests/testbench/com/vaadin/tests/components/splitpanel/SplitPanelWidthOnResize.java @@ -5,7 +5,7 @@ import com.vaadin.tests.components.AbstractTestCase; import com.vaadin.ui.Button; import com.vaadin.ui.HorizontalSplitPanel; import com.vaadin.ui.NativeButton; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; diff --git a/tests/testbench/com/vaadin/tests/components/table/ScrollCausesRequestLoop.java b/tests/testbench/com/vaadin/tests/components/table/ScrollCausesRequestLoop.java index 75468af247..edd524d657 100644 --- a/tests/testbench/com/vaadin/tests/components/table/ScrollCausesRequestLoop.java +++ b/tests/testbench/com/vaadin/tests/components/table/ScrollCausesRequestLoop.java @@ -7,7 +7,7 @@ import com.vaadin.data.util.BeanItemContainer; import com.vaadin.tests.components.AbstractTestCase; import com.vaadin.tests.util.Person; import com.vaadin.ui.HorizontalLayout; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Table; public class ScrollCausesRequestLoop extends AbstractTestCase { diff --git a/tests/testbench/com/vaadin/tests/components/table/SortLongTable.java b/tests/testbench/com/vaadin/tests/components/table/SortLongTable.java index 15872aa849..afc63c0eda 100644 --- a/tests/testbench/com/vaadin/tests/components/table/SortLongTable.java +++ b/tests/testbench/com/vaadin/tests/components/table/SortLongTable.java @@ -1,7 +1,7 @@ package com.vaadin.tests.components.table; import com.vaadin.tests.components.AbstractTestCase; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Table; import com.vaadin.ui.VerticalLayout; diff --git a/tests/testbench/com/vaadin/tests/components/table/TableExtraScrollbars.java b/tests/testbench/com/vaadin/tests/components/table/TableExtraScrollbars.java index 010093bf8f..f8fb624c0b 100644 --- a/tests/testbench/com/vaadin/tests/components/table/TableExtraScrollbars.java +++ b/tests/testbench/com/vaadin/tests/components/table/TableExtraScrollbars.java @@ -4,7 +4,7 @@ import com.vaadin.data.Container; import com.vaadin.data.Item; import com.vaadin.data.util.IndexedContainer; import com.vaadin.tests.components.AbstractTestCase; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Table; import com.vaadin.ui.VerticalLayout; diff --git a/tests/testbench/com/vaadin/tests/components/table/TableFirstRowFlicker.java b/tests/testbench/com/vaadin/tests/components/table/TableFirstRowFlicker.java index 3101615cfd..90df5610eb 100644 --- a/tests/testbench/com/vaadin/tests/components/table/TableFirstRowFlicker.java +++ b/tests/testbench/com/vaadin/tests/components/table/TableFirstRowFlicker.java @@ -5,7 +5,7 @@ import com.vaadin.data.Container; import com.vaadin.data.util.IndexedContainer; import com.vaadin.ui.Label; import com.vaadin.ui.ProgressIndicator; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Table; import com.vaadin.ui.VerticalLayout; diff --git a/tests/testbench/com/vaadin/tests/components/table/TableHeaderZoom.java b/tests/testbench/com/vaadin/tests/components/table/TableHeaderZoom.java index bce96ebced..26f8e25d3b 100644 --- a/tests/testbench/com/vaadin/tests/components/table/TableHeaderZoom.java +++ b/tests/testbench/com/vaadin/tests/components/table/TableHeaderZoom.java @@ -2,7 +2,7 @@ package com.vaadin.tests.components.table; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.CssLayout; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Table; public class TableHeaderZoom extends TestBase { diff --git a/tests/testbench/com/vaadin/tests/components/table/TableHeightWhenHidingHeaders.java b/tests/testbench/com/vaadin/tests/components/table/TableHeightWhenHidingHeaders.java index 0173f928dd..6bbf06635a 100644 --- a/tests/testbench/com/vaadin/tests/components/table/TableHeightWhenHidingHeaders.java +++ b/tests/testbench/com/vaadin/tests/components/table/TableHeightWhenHidingHeaders.java @@ -4,7 +4,7 @@ import com.vaadin.data.Property.ValueChangeEvent; import com.vaadin.data.Property.ValueChangeListener; import com.vaadin.tests.components.AbstractTestCase; import com.vaadin.ui.CheckBox; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Table; /** diff --git a/tests/testbench/com/vaadin/tests/components/table/TableToggleVisibility.java b/tests/testbench/com/vaadin/tests/components/table/TableToggleVisibility.java index 0465d2f886..9ca2605cd9 100644 --- a/tests/testbench/com/vaadin/tests/components/table/TableToggleVisibility.java +++ b/tests/testbench/com/vaadin/tests/components/table/TableToggleVisibility.java @@ -7,7 +7,7 @@ import com.vaadin.ui.Button; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.HorizontalSplitPanel; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Table; import com.vaadin.ui.VerticalLayout; diff --git a/tests/testbench/com/vaadin/tests/components/table/TestCurrentPageFirstItem.java b/tests/testbench/com/vaadin/tests/components/table/TestCurrentPageFirstItem.java index d629c9a917..c563312efa 100644 --- a/tests/testbench/com/vaadin/tests/components/table/TestCurrentPageFirstItem.java +++ b/tests/testbench/com/vaadin/tests/components/table/TestCurrentPageFirstItem.java @@ -7,7 +7,7 @@ import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Table; import com.vaadin.ui.VerticalLayout; diff --git a/tests/testbench/com/vaadin/tests/components/tabsheet/TabsheetNPE.java b/tests/testbench/com/vaadin/tests/components/tabsheet/TabsheetNPE.java index 8e4c4d40fb..1934649902 100644 --- a/tests/testbench/com/vaadin/tests/components/tabsheet/TabsheetNPE.java +++ b/tests/testbench/com/vaadin/tests/components/tabsheet/TabsheetNPE.java @@ -5,7 +5,7 @@ import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TabSheet; import com.vaadin.ui.TabSheet.Tab; import com.vaadin.ui.VerticalLayout; diff --git a/tests/testbench/com/vaadin/tests/components/textfield/TextFieldInLayoutInTable.java b/tests/testbench/com/vaadin/tests/components/textfield/TextFieldInLayoutInTable.java index 3e1a709243..903226c87c 100644 --- a/tests/testbench/com/vaadin/tests/components/textfield/TextFieldInLayoutInTable.java +++ b/tests/testbench/com/vaadin/tests/components/textfield/TextFieldInLayoutInTable.java @@ -3,7 +3,7 @@ package com.vaadin.tests.components.textfield; import com.vaadin.Application; import com.vaadin.ui.Component; import com.vaadin.ui.Panel; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Table; import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; diff --git a/tests/testbench/com/vaadin/tests/components/tree/TreePerformanceTest.java b/tests/testbench/com/vaadin/tests/components/tree/TreePerformanceTest.java index 9d58762f60..892b7e669a 100644 --- a/tests/testbench/com/vaadin/tests/components/tree/TreePerformanceTest.java +++ b/tests/testbench/com/vaadin/tests/components/tree/TreePerformanceTest.java @@ -2,7 +2,7 @@ package com.vaadin.tests.components.tree; import com.vaadin.tests.components.AbstractTestCase; import com.vaadin.ui.Layout; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Tree; import com.vaadin.ui.VerticalLayout; diff --git a/tests/testbench/com/vaadin/tests/components/tree/TreeScrolling.java b/tests/testbench/com/vaadin/tests/components/tree/TreeScrolling.java index abc9a5385d..70c2d5d433 100644 --- a/tests/testbench/com/vaadin/tests/components/tree/TreeScrolling.java +++ b/tests/testbench/com/vaadin/tests/components/tree/TreeScrolling.java @@ -2,7 +2,7 @@ package com.vaadin.tests.components.tree; import com.vaadin.tests.components.AbstractTestCase; import com.vaadin.ui.RichTextArea; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TextField; import com.vaadin.ui.Tree; import com.vaadin.ui.VerticalLayout; diff --git a/tests/testbench/com/vaadin/tests/components/treetable/DisappearingComponents.java b/tests/testbench/com/vaadin/tests/components/treetable/DisappearingComponents.java index 329e5d291d..8f9c1deaf5 100644 --- a/tests/testbench/com/vaadin/tests/components/treetable/DisappearingComponents.java +++ b/tests/testbench/com/vaadin/tests/components/treetable/DisappearingComponents.java @@ -3,7 +3,7 @@ package com.vaadin.tests.components.treetable; import com.vaadin.terminal.ExternalResource; import com.vaadin.tests.components.AbstractTestCase; import com.vaadin.ui.Link; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TreeTable; public class DisappearingComponents extends AbstractTestCase { diff --git a/tests/testbench/com/vaadin/tests/components/window/AttachShouldBeCalledForSubWindows.java b/tests/testbench/com/vaadin/tests/components/window/AttachShouldBeCalledForSubWindows.java index 52a94daec7..a2f03212b0 100644 --- a/tests/testbench/com/vaadin/tests/components/window/AttachShouldBeCalledForSubWindows.java +++ b/tests/testbench/com/vaadin/tests/components/window/AttachShouldBeCalledForSubWindows.java @@ -12,7 +12,7 @@ import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Component; import com.vaadin.ui.Label; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; import com.vaadin.ui.Window; public class AttachShouldBeCalledForSubWindows extends AbstractTestCase @@ -26,7 +26,7 @@ public class AttachShouldBeCalledForSubWindows extends AbstractTestCase @Override public void init() { - Root.LegacyWindow mainWindow = new Root.LegacyWindow() { + UI.LegacyWindow mainWindow = new UI.LegacyWindow() { @Override public void attach() { log(this); diff --git a/tests/testbench/com/vaadin/tests/components/window/ExecuteJavaScript.java b/tests/testbench/com/vaadin/tests/components/window/ExecuteJavaScript.java index a9744b2c06..92e0e734ff 100644 --- a/tests/testbench/com/vaadin/tests/components/window/ExecuteJavaScript.java +++ b/tests/testbench/com/vaadin/tests/components/window/ExecuteJavaScript.java @@ -4,7 +4,7 @@ import com.vaadin.tests.components.AbstractTestCase; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Panel; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class ExecuteJavaScript extends AbstractTestCase { diff --git a/tests/testbench/com/vaadin/tests/components/window/LazyWindowResize.java b/tests/testbench/com/vaadin/tests/components/window/LazyWindowResize.java index eb4803630f..80497528ca 100644 --- a/tests/testbench/com/vaadin/tests/components/window/LazyWindowResize.java +++ b/tests/testbench/com/vaadin/tests/components/window/LazyWindowResize.java @@ -10,7 +10,7 @@ import com.vaadin.tests.util.Log; import com.vaadin.tests.util.LoremIpsum; import com.vaadin.ui.CheckBox; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Window; import com.vaadin.ui.Window.ResizeEvent; import com.vaadin.ui.Window.ResizeListener; diff --git a/tests/testbench/com/vaadin/tests/components/window/SubWindowFocusAndBlurListeners.java b/tests/testbench/com/vaadin/tests/components/window/SubWindowFocusAndBlurListeners.java index 061ee7900f..e4a7e288ad 100644 --- a/tests/testbench/com/vaadin/tests/components/window/SubWindowFocusAndBlurListeners.java +++ b/tests/testbench/com/vaadin/tests/components/window/SubWindowFocusAndBlurListeners.java @@ -11,7 +11,7 @@ import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Notification; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; import com.vaadin.ui.TextField; import com.vaadin.ui.Window; @@ -64,7 +64,7 @@ public class SubWindowFocusAndBlurListeners extends TestBase { } }); - Root main = getLayout().getRoot(); + UI main = getLayout().getRoot(); main.addWindow(window); diff --git a/tests/testbench/com/vaadin/tests/components/window/SubWindowOrder.java b/tests/testbench/com/vaadin/tests/components/window/SubWindowOrder.java index 02241476d5..0ca7fd1067 100644 --- a/tests/testbench/com/vaadin/tests/components/window/SubWindowOrder.java +++ b/tests/testbench/com/vaadin/tests/components/window/SubWindowOrder.java @@ -10,7 +10,7 @@ import com.vaadin.ui.ComboBox; import com.vaadin.ui.CssLayout; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; import com.vaadin.ui.Window; public class SubWindowOrder extends TestBase { @@ -20,7 +20,7 @@ public class SubWindowOrder extends TestBase { @Override protected void setup() { - Root mainWindow = getMainWindow(); + UI mainWindow = getMainWindow(); HorizontalLayout controlpanels = new HorizontalLayout(); for (int i = 1; i <= 5; i++) { Window dialog = new Window("Dialog " + i); diff --git a/tests/testbench/com/vaadin/tests/components/window/WindowScrollingComponentIntoView.java b/tests/testbench/com/vaadin/tests/components/window/WindowScrollingComponentIntoView.java index fdeb21d29c..033de48446 100644 --- a/tests/testbench/com/vaadin/tests/components/window/WindowScrollingComponentIntoView.java +++ b/tests/testbench/com/vaadin/tests/components/window/WindowScrollingComponentIntoView.java @@ -8,7 +8,7 @@ import com.vaadin.ui.Component; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.ui.Panel; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Table; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; diff --git a/tests/testbench/com/vaadin/tests/components/window/WindowScrollingUp.java b/tests/testbench/com/vaadin/tests/components/window/WindowScrollingUp.java index 43f8297a5d..0f0db3a028 100644 --- a/tests/testbench/com/vaadin/tests/components/window/WindowScrollingUp.java +++ b/tests/testbench/com/vaadin/tests/components/window/WindowScrollingUp.java @@ -3,7 +3,7 @@ package com.vaadin.tests.components.window; import com.vaadin.tests.components.AbstractTestCase; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Table; public class WindowScrollingUp extends AbstractTestCase { diff --git a/tests/testbench/com/vaadin/tests/containers/sqlcontainer/CheckboxUpdateProblem.java b/tests/testbench/com/vaadin/tests/containers/sqlcontainer/CheckboxUpdateProblem.java index 537c9be973..0c1fdc23f6 100644 --- a/tests/testbench/com/vaadin/tests/containers/sqlcontainer/CheckboxUpdateProblem.java +++ b/tests/testbench/com/vaadin/tests/containers/sqlcontainer/CheckboxUpdateProblem.java @@ -12,7 +12,7 @@ import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Form; import com.vaadin.ui.HorizontalSplitPanel; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Table; public class CheckboxUpdateProblem extends Application.LegacyApplication diff --git a/tests/testbench/com/vaadin/tests/containers/sqlcontainer/ComboBoxUpdateProblem.java b/tests/testbench/com/vaadin/tests/containers/sqlcontainer/ComboBoxUpdateProblem.java index b7d1b8c37e..aec0f0e28e 100644 --- a/tests/testbench/com/vaadin/tests/containers/sqlcontainer/ComboBoxUpdateProblem.java +++ b/tests/testbench/com/vaadin/tests/containers/sqlcontainer/ComboBoxUpdateProblem.java @@ -3,7 +3,7 @@ package com.vaadin.tests.containers.sqlcontainer; import com.vaadin.Application; import com.vaadin.ui.AbstractSelect.Filtering; import com.vaadin.ui.ComboBox; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; /** * See http://dev.vaadin.com/ticket/9155 . @@ -13,7 +13,7 @@ public class ComboBoxUpdateProblem extends Application.LegacyApplication { @Override public void init() { - setMainWindow(new Root.LegacyWindow("Test window")); + setMainWindow(new UI.LegacyWindow("Test window")); ComboBox combo = new ComboBox("Names", databaseHelper.getTestContainer()); diff --git a/tests/testbench/com/vaadin/tests/containers/sqlcontainer/MassInsertMemoryLeakTestApp.java b/tests/testbench/com/vaadin/tests/containers/sqlcontainer/MassInsertMemoryLeakTestApp.java index dc919fdb12..8bb2ba1092 100644 --- a/tests/testbench/com/vaadin/tests/containers/sqlcontainer/MassInsertMemoryLeakTestApp.java +++ b/tests/testbench/com/vaadin/tests/containers/sqlcontainer/MassInsertMemoryLeakTestApp.java @@ -12,7 +12,7 @@ import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.ComponentContainer; import com.vaadin.ui.ProgressIndicator; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.VerticalLayout; // author table in testdb (MySQL) is set out as follows diff --git a/tests/testbench/com/vaadin/tests/dd/DDTest2.java b/tests/testbench/com/vaadin/tests/dd/DDTest2.java index 272be53034..99020d0b5b 100644 --- a/tests/testbench/com/vaadin/tests/dd/DDTest2.java +++ b/tests/testbench/com/vaadin/tests/dd/DDTest2.java @@ -24,7 +24,7 @@ import com.vaadin.ui.AbstractSelect; import com.vaadin.ui.AbstractSelect.AbstractSelectTargetDetails; import com.vaadin.ui.AbstractSelect.AcceptItem; import com.vaadin.ui.HorizontalLayout; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; import com.vaadin.ui.Table; import com.vaadin.ui.Table.TableTransferable; import com.vaadin.ui.Tree; @@ -45,7 +45,7 @@ public class DDTest2 extends TestBase { @Override protected void setup() { - Root w = getLayout().getRoot(); + UI w = getLayout().getRoot(); /* darn reindeer has no icons */ /* Make all trees (their nodes actually) draggable */ diff --git a/tests/testbench/com/vaadin/tests/dd/DDTest4.java b/tests/testbench/com/vaadin/tests/dd/DDTest4.java index c7f0c6960b..bb85dff0b6 100644 --- a/tests/testbench/com/vaadin/tests/dd/DDTest4.java +++ b/tests/testbench/com/vaadin/tests/dd/DDTest4.java @@ -16,7 +16,7 @@ import com.vaadin.tests.util.PersonContainer; import com.vaadin.tests.util.TestUtils; import com.vaadin.ui.AbstractSelect.AbstractSelectTargetDetails; import com.vaadin.ui.HorizontalLayout; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; import com.vaadin.ui.Table; public class DDTest4 extends TestBase { @@ -28,7 +28,7 @@ public class DDTest4 extends TestBase { @Override protected void setup() { - Root w = getLayout().getRoot(); + UI w = getLayout().getRoot(); TestUtils .injectCSS( diff --git a/tests/testbench/com/vaadin/tests/dd/DDTest5.java b/tests/testbench/com/vaadin/tests/dd/DDTest5.java index 63d1e9e3c2..cb99b17da4 100644 --- a/tests/testbench/com/vaadin/tests/dd/DDTest5.java +++ b/tests/testbench/com/vaadin/tests/dd/DDTest5.java @@ -15,7 +15,7 @@ import com.vaadin.ui.DragAndDropWrapper.DragStartMode; import com.vaadin.ui.DragAndDropWrapper.WrapperTransferable; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; public class DDTest5 extends TestBase { @@ -47,7 +47,7 @@ public class DDTest5 extends TestBase { @Override protected void setup() { - Root w = getLayout().getRoot(); + UI w = getLayout().getRoot(); HorizontalSortableCssLayoutWithWrappers verticalSortableCssLayoutWithWrappers = new HorizontalSortableCssLayoutWithWrappers(); w.addWindow(verticalSortableCssLayoutWithWrappers); diff --git a/tests/testbench/com/vaadin/tests/dd/DDTest7.java b/tests/testbench/com/vaadin/tests/dd/DDTest7.java index f9be935b23..2af93c6c72 100644 --- a/tests/testbench/com/vaadin/tests/dd/DDTest7.java +++ b/tests/testbench/com/vaadin/tests/dd/DDTest7.java @@ -16,7 +16,7 @@ import com.vaadin.tests.util.PersonContainer; import com.vaadin.tests.util.TestUtils; import com.vaadin.ui.AbstractSelect.AbstractSelectTargetDetails; import com.vaadin.ui.HorizontalLayout; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; import com.vaadin.ui.Table; public class DDTest7 extends TestBase { @@ -29,7 +29,7 @@ public class DDTest7 extends TestBase { @Override protected void setup() { - Root w = getLayout().getRoot(); + UI w = getLayout().getRoot(); TestUtils .injectCSS( diff --git a/tests/testbench/com/vaadin/tests/integration/EmbedSizeTest.java b/tests/testbench/com/vaadin/tests/integration/EmbedSizeTest.java index f1345bca13..6a9f696e75 100644 --- a/tests/testbench/com/vaadin/tests/integration/EmbedSizeTest.java +++ b/tests/testbench/com/vaadin/tests/integration/EmbedSizeTest.java @@ -7,7 +7,7 @@ import com.vaadin.terminal.Page.BrowserWindowResizeEvent; import com.vaadin.tests.components.TestBase; import com.vaadin.tests.util.Log; import com.vaadin.ui.CheckBox; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class EmbedSizeTest extends TestBase { diff --git a/tests/testbench/com/vaadin/tests/integration/IntegrationTestApplication.java b/tests/testbench/com/vaadin/tests/integration/IntegrationTestApplication.java index c464409153..b3fc9c8ffb 100644 --- a/tests/testbench/com/vaadin/tests/integration/IntegrationTestApplication.java +++ b/tests/testbench/com/vaadin/tests/integration/IntegrationTestApplication.java @@ -7,7 +7,7 @@ import com.vaadin.data.Property.ValueChangeListener; import com.vaadin.terminal.ClassResource; import com.vaadin.terminal.Resource; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Table; public class IntegrationTestApplication extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/integration/JSR286PortletApplication.java b/tests/testbench/com/vaadin/tests/integration/JSR286PortletApplication.java index 3374342947..c2a01b16dd 100644 --- a/tests/testbench/com/vaadin/tests/integration/JSR286PortletApplication.java +++ b/tests/testbench/com/vaadin/tests/integration/JSR286PortletApplication.java @@ -28,8 +28,8 @@ import com.vaadin.ui.Embedded; import com.vaadin.ui.Label; import com.vaadin.ui.Link; import com.vaadin.ui.Notification; -import com.vaadin.ui.Root; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TextField; import com.vaadin.ui.Upload; import com.vaadin.ui.Upload.Receiver; @@ -101,13 +101,13 @@ public class JSR286PortletApplication extends Application.LegacyApplication { @Override public void handleActionRequest(ActionRequest request, - ActionResponse response, Root window) { + ActionResponse response, UI window) { main.addComponent(new Label("Action received")); } @Override public void handleRenderRequest(RenderRequest request, - RenderResponse response, Root window) { + RenderResponse response, UI window) { // Portlet up-and-running, enable stuff portletEdit.setEnabled(true); portletMax.setEnabled(true); @@ -181,13 +181,13 @@ public class JSR286PortletApplication extends Application.LegacyApplication { @Override public void handleEventRequest(EventRequest request, - EventResponse response, Root window) { + EventResponse response, UI window) { // events not used by this test } @Override public void handleResourceRequest(ResourceRequest request, - ResourceResponse response, Root window) { + ResourceResponse response, UI window) { // nothing special to do here } } diff --git a/tests/testbench/com/vaadin/tests/integration/LiferayThemeDemo.java b/tests/testbench/com/vaadin/tests/integration/LiferayThemeDemo.java index a35b78c219..41a3d18f9f 100644 --- a/tests/testbench/com/vaadin/tests/integration/LiferayThemeDemo.java +++ b/tests/testbench/com/vaadin/tests/integration/LiferayThemeDemo.java @@ -39,7 +39,7 @@ import com.vaadin.ui.NativeSelect; import com.vaadin.ui.Notification; import com.vaadin.ui.Panel; import com.vaadin.ui.PopupView; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Slider; import com.vaadin.ui.Slider.ValueOutOfBoundsException; import com.vaadin.ui.TabSheet; diff --git a/tests/testbench/com/vaadin/tests/integration/PortletSizeInLiferayFreeformLayoutApplication.java b/tests/testbench/com/vaadin/tests/integration/PortletSizeInLiferayFreeformLayoutApplication.java index 20967203bc..fc54547890 100644 --- a/tests/testbench/com/vaadin/tests/integration/PortletSizeInLiferayFreeformLayoutApplication.java +++ b/tests/testbench/com/vaadin/tests/integration/PortletSizeInLiferayFreeformLayoutApplication.java @@ -2,7 +2,7 @@ package com.vaadin.tests.integration; import com.vaadin.Application.LegacyApplication; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.VerticalLayout; /** diff --git a/tests/testbench/com/vaadin/tests/layouts/ComplexGLColumnExpansionWithColSpan.java b/tests/testbench/com/vaadin/tests/layouts/ComplexGLColumnExpansionWithColSpan.java index 51f9e2d88e..25821cb92c 100644 --- a/tests/testbench/com/vaadin/tests/layouts/ComplexGLColumnExpansionWithColSpan.java +++ b/tests/testbench/com/vaadin/tests/layouts/ComplexGLColumnExpansionWithColSpan.java @@ -4,7 +4,7 @@ import com.vaadin.terminal.Sizeable; import com.vaadin.tests.components.AbstractTestCase; import com.vaadin.ui.Button; import com.vaadin.ui.GridLayout; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; diff --git a/tests/testbench/com/vaadin/tests/layouts/GridLayoutCaptions.java b/tests/testbench/com/vaadin/tests/layouts/GridLayoutCaptions.java index 8713208dc6..2d5bc8d59a 100644 --- a/tests/testbench/com/vaadin/tests/layouts/GridLayoutCaptions.java +++ b/tests/testbench/com/vaadin/tests/layouts/GridLayoutCaptions.java @@ -15,7 +15,7 @@ import com.vaadin.ui.Form; import com.vaadin.ui.FormFieldFactory; import com.vaadin.ui.GridLayout; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; diff --git a/tests/testbench/com/vaadin/tests/layouts/GridLayoutExpandRatioModification.java b/tests/testbench/com/vaadin/tests/layouts/GridLayoutExpandRatioModification.java index 84f27e5f03..acc5f07103 100644 --- a/tests/testbench/com/vaadin/tests/layouts/GridLayoutExpandRatioModification.java +++ b/tests/testbench/com/vaadin/tests/layouts/GridLayoutExpandRatioModification.java @@ -6,7 +6,7 @@ import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.GridLayout; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; diff --git a/tests/testbench/com/vaadin/tests/layouts/GridLayoutInsidePanel2.java b/tests/testbench/com/vaadin/tests/layouts/GridLayoutInsidePanel2.java index d6ea84e44e..6273b92838 100644 --- a/tests/testbench/com/vaadin/tests/layouts/GridLayoutInsidePanel2.java +++ b/tests/testbench/com/vaadin/tests/layouts/GridLayoutInsidePanel2.java @@ -4,7 +4,7 @@ import com.vaadin.Application; import com.vaadin.ui.GridLayout; import com.vaadin.ui.Label; import com.vaadin.ui.Layout; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class GridLayoutInsidePanel2 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/layouts/MovingComponentsWhileOldParentInvisible.java b/tests/testbench/com/vaadin/tests/layouts/MovingComponentsWhileOldParentInvisible.java index 5f91786571..0621fd5d92 100644 --- a/tests/testbench/com/vaadin/tests/layouts/MovingComponentsWhileOldParentInvisible.java +++ b/tests/testbench/com/vaadin/tests/layouts/MovingComponentsWhileOldParentInvisible.java @@ -14,7 +14,7 @@ import com.vaadin.ui.CustomLayout; import com.vaadin.ui.Label; import com.vaadin.ui.LoginForm; import com.vaadin.ui.PopupView; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; import com.vaadin.ui.Window; public class MovingComponentsWhileOldParentInvisible extends TestBase { @@ -45,7 +45,7 @@ public class MovingComponentsWhileOldParentInvisible extends TestBase { if (cls == LoginForm.class || cls == CustomLayout.class || CustomComponent.class.isAssignableFrom(cls) || cls == PopupView.class || cls == Window.class - || cls == Root.class) { + || cls == UI.class) { // Does not support addComponent continue; } diff --git a/tests/testbench/com/vaadin/tests/layouts/TestLayoutClickListeners.java b/tests/testbench/com/vaadin/tests/layouts/TestLayoutClickListeners.java index b998abeb02..44f40a7d78 100644 --- a/tests/testbench/com/vaadin/tests/layouts/TestLayoutClickListeners.java +++ b/tests/testbench/com/vaadin/tests/layouts/TestLayoutClickListeners.java @@ -13,7 +13,7 @@ import com.vaadin.ui.GridLayout; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.ui.Layout; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TextArea; import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; diff --git a/tests/testbench/com/vaadin/tests/layouts/TreeWithBordersInLayout.java b/tests/testbench/com/vaadin/tests/layouts/TreeWithBordersInLayout.java index 8d506e0884..8786ae282c 100644 --- a/tests/testbench/com/vaadin/tests/layouts/TreeWithBordersInLayout.java +++ b/tests/testbench/com/vaadin/tests/layouts/TreeWithBordersInLayout.java @@ -2,7 +2,7 @@ package com.vaadin.tests.layouts; import com.vaadin.tests.components.AbstractTestCase; import com.vaadin.ui.Layout; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Tree; import com.vaadin.ui.VerticalLayout; diff --git a/tests/testbench/com/vaadin/tests/layouts/VerticalLayoutExpandRatioModification.java b/tests/testbench/com/vaadin/tests/layouts/VerticalLayoutExpandRatioModification.java index 916a82bb85..ef24150762 100644 --- a/tests/testbench/com/vaadin/tests/layouts/VerticalLayoutExpandRatioModification.java +++ b/tests/testbench/com/vaadin/tests/layouts/VerticalLayoutExpandRatioModification.java @@ -5,7 +5,7 @@ import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; diff --git a/tests/testbench/com/vaadin/tests/layouts/layouttester/LayoutTesterApplication.java b/tests/testbench/com/vaadin/tests/layouts/layouttester/LayoutTesterApplication.java index 90193be7cc..e31ecc2498 100644 --- a/tests/testbench/com/vaadin/tests/layouts/layouttester/LayoutTesterApplication.java +++ b/tests/testbench/com/vaadin/tests/layouts/layouttester/LayoutTesterApplication.java @@ -11,7 +11,7 @@ import com.vaadin.ui.GridLayout; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Layout; import com.vaadin.ui.NativeSelect; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.themes.Reindeer; diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a1/AutoGeneratingForm.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a1/AutoGeneratingForm.java index 00d336de92..08556e99d0 100644 --- a/tests/testbench/com/vaadin/tests/minitutorials/v7a1/AutoGeneratingForm.java +++ b/tests/testbench/com/vaadin/tests/minitutorials/v7a1/AutoGeneratingForm.java @@ -20,7 +20,7 @@ import com.vaadin.data.fieldgroup.BeanFieldGroup; import com.vaadin.data.fieldgroup.FieldGroup; import com.vaadin.data.util.BeanItem; import com.vaadin.terminal.WrappedRequest; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; /** * Mini tutorial code for @@ -30,7 +30,7 @@ import com.vaadin.ui.Root; * @author Vaadin Ltd * @since 7.0.0 */ -public class AutoGeneratingForm extends Root { +public class AutoGeneratingForm extends UI { @Override protected void init(WrappedRequest request) { diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a1/BasicApplication.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a1/BasicApplication.java index 43e404b461..f3e6653288 100644 --- a/tests/testbench/com/vaadin/tests/minitutorials/v7a1/BasicApplication.java +++ b/tests/testbench/com/vaadin/tests/minitutorials/v7a1/BasicApplication.java @@ -18,7 +18,7 @@ package com.vaadin.tests.minitutorials.v7a1; import com.vaadin.terminal.WrappedRequest; import com.vaadin.ui.Label; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; import com.vaadin.ui.VerticalLayout; /** @@ -28,7 +28,7 @@ import com.vaadin.ui.VerticalLayout; * @author Vaadin Ltd * @since 7.0.0 */ -public class BasicApplication extends Root { +public class BasicApplication extends UI { @Override protected void init(WrappedRequest request) { diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a1/CreatingPreserveState.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a1/CreatingPreserveState.java index 0a04aead7f..4181c071f0 100644 --- a/tests/testbench/com/vaadin/tests/minitutorials/v7a1/CreatingPreserveState.java +++ b/tests/testbench/com/vaadin/tests/minitutorials/v7a1/CreatingPreserveState.java @@ -17,7 +17,7 @@ package com.vaadin.tests.minitutorials.v7a1; import com.vaadin.terminal.WrappedRequest; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; import com.vaadin.ui.TextField; /** @@ -28,7 +28,7 @@ import com.vaadin.ui.TextField; * @author Vaadin Ltd * @since 7.0.0 */ -public class CreatingPreserveState extends Root { +public class CreatingPreserveState extends UI { private static int windowCounter = 0; @Override diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a1/DefineRootTheme.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a1/DefineRootTheme.java index 5296f03c30..6c9282eb01 100644 --- a/tests/testbench/com/vaadin/tests/minitutorials/v7a1/DefineRootTheme.java +++ b/tests/testbench/com/vaadin/tests/minitutorials/v7a1/DefineRootTheme.java @@ -19,7 +19,7 @@ package com.vaadin.tests.minitutorials.v7a1; import com.vaadin.annotations.Theme; import com.vaadin.terminal.WrappedRequest; import com.vaadin.ui.Label; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; import com.vaadin.ui.VerticalLayout; /** @@ -30,7 +30,7 @@ import com.vaadin.ui.VerticalLayout; * @since 7.0.0 */ @Theme("hello-theme") -public class DefineRootTheme extends Root { +public class DefineRootTheme extends UI { @Override protected void init(WrappedRequest request) { diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a1/DifferentFeaturesForDifferentClients.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a1/DifferentFeaturesForDifferentClients.java index 616fea7ff2..a601ff2eb4 100644 --- a/tests/testbench/com/vaadin/tests/minitutorials/v7a1/DifferentFeaturesForDifferentClients.java +++ b/tests/testbench/com/vaadin/tests/minitutorials/v7a1/DifferentFeaturesForDifferentClients.java @@ -22,7 +22,7 @@ import com.vaadin.terminal.WrappedRequest; import com.vaadin.terminal.WrappedRequest.BrowserDetails; import com.vaadin.terminal.gwt.server.WebBrowser; import com.vaadin.ui.Label; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; /** * Mini tutorial code for @@ -35,7 +35,7 @@ import com.vaadin.ui.Root; public class DifferentFeaturesForDifferentClients extends Application { @Override - protected Root getRoot(WrappedRequest request) + protected UI getRoot(WrappedRequest request) throws RootRequiresMoreInformationException { BrowserDetails browserDetails = request.getBrowserDetails(); // This is a limitation of 7.0.0.alpha1 that there is no better way to @@ -53,7 +53,7 @@ public class DifferentFeaturesForDifferentClients extends Application { } } -class DefaultRoot extends Root { +class DefaultRoot extends UI { @Override protected void init(WrappedRequest request) { getContent().addComponent( @@ -61,7 +61,7 @@ class DefaultRoot extends Root { } } -class TouchRoot extends Root { +class TouchRoot extends UI { @Override protected void init(WrappedRequest request) { WebBrowser webBrowser = request.getBrowserDetails().getWebBrowser(); diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a1/FindCurrentRootAndApplication.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a1/FindCurrentRootAndApplication.java index d53ede3518..a786ecb533 100644 --- a/tests/testbench/com/vaadin/tests/minitutorials/v7a1/FindCurrentRootAndApplication.java +++ b/tests/testbench/com/vaadin/tests/minitutorials/v7a1/FindCurrentRootAndApplication.java @@ -22,7 +22,7 @@ import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Notification; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; /** * Mini tutorial code for @@ -32,7 +32,7 @@ import com.vaadin.ui.Root; * @author Vaadin Ltd * @since 7.0.0 */ -public class FindCurrentRootAndApplication extends Root { +public class FindCurrentRootAndApplication extends UI { @Override protected void init(WrappedRequest request) { @@ -50,8 +50,8 @@ public class FindCurrentRootAndApplication extends Root { helloButton.addListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { - Notification.show("This Root is " - + Root.getCurrent().getClass().getSimpleName()); + Notification.show("This UI is " + + UI.getCurrent().getClass().getSimpleName()); } }); diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a1/MultiTabApplication.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a1/MultiTabApplication.java index d2b1ed95e0..d82f4b1382 100644 --- a/tests/testbench/com/vaadin/tests/minitutorials/v7a1/MultiTabApplication.java +++ b/tests/testbench/com/vaadin/tests/minitutorials/v7a1/MultiTabApplication.java @@ -20,7 +20,7 @@ import com.vaadin.terminal.ExternalResource; import com.vaadin.terminal.WrappedRequest; import com.vaadin.ui.Label; import com.vaadin.ui.Link; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; import com.vaadin.ui.VerticalLayout; /** @@ -30,7 +30,7 @@ import com.vaadin.ui.VerticalLayout; * @author Vaadin Ltd * @since 7.0.0 */ -public class MultiTabApplication extends Root { +public class MultiTabApplication extends UI { private class MainView extends VerticalLayout { public MainView() { diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a1/UsingBeanValidation.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a1/UsingBeanValidation.java index 906ace6f53..c2f983c9bb 100644 --- a/tests/testbench/com/vaadin/tests/minitutorials/v7a1/UsingBeanValidation.java +++ b/tests/testbench/com/vaadin/tests/minitutorials/v7a1/UsingBeanValidation.java @@ -23,7 +23,7 @@ import javax.validation.constraints.Size; import com.vaadin.data.util.BeanItem; import com.vaadin.data.validator.BeanValidator; import com.vaadin.terminal.WrappedRequest; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; import com.vaadin.ui.TextField; /** @@ -34,7 +34,7 @@ import com.vaadin.ui.TextField; * @author Vaadin Ltd * @since 7.0.0 */ -public class UsingBeanValidation extends Root { +public class UsingBeanValidation extends UI { class Person { @Size(min = 5, max = 50) diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a1/UsingUriFragments.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a1/UsingUriFragments.java index db6ee57477..042c02316f 100644 --- a/tests/testbench/com/vaadin/tests/minitutorials/v7a1/UsingUriFragments.java +++ b/tests/testbench/com/vaadin/tests/minitutorials/v7a1/UsingUriFragments.java @@ -22,7 +22,7 @@ import com.vaadin.terminal.WrappedRequest; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Label; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; /** * Mini tutorial code for @@ -31,7 +31,7 @@ import com.vaadin.ui.Root; * @author Vaadin Ltd * @since 7.0.0 */ -public class UsingUriFragments extends Root { +public class UsingUriFragments extends UI { @Override protected void init(WrappedRequest request) { diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a1/UsingXyzWhenInitializing.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a1/UsingXyzWhenInitializing.java index 64b643a185..4a689d8c12 100644 --- a/tests/testbench/com/vaadin/tests/minitutorials/v7a1/UsingXyzWhenInitializing.java +++ b/tests/testbench/com/vaadin/tests/minitutorials/v7a1/UsingXyzWhenInitializing.java @@ -18,7 +18,7 @@ package com.vaadin.tests.minitutorials.v7a1; import com.vaadin.terminal.WrappedRequest; import com.vaadin.ui.Label; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; /** * Mini tutorial code for @@ -28,7 +28,7 @@ import com.vaadin.ui.Root; * @author Vaadin Ltd * @since 7.0.0 */ -public class UsingXyzWhenInitializing extends Root { +public class UsingXyzWhenInitializing extends UI { @Override protected void init(WrappedRequest request) { diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a2/ComponentInStateRoot.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a2/ComponentInStateRoot.java index 0ed4a7781e..b5bf8538ed 100644 --- a/tests/testbench/com/vaadin/tests/minitutorials/v7a2/ComponentInStateRoot.java +++ b/tests/testbench/com/vaadin/tests/minitutorials/v7a2/ComponentInStateRoot.java @@ -3,7 +3,7 @@ package com.vaadin.tests.minitutorials.v7a2; import com.vaadin.annotations.Widgetset; import com.vaadin.terminal.WrappedRequest; import com.vaadin.ui.Label; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; /** * Mini tutorial code for @@ -14,7 +14,7 @@ import com.vaadin.ui.Root; * @since 7.0.0 */ @Widgetset("com.vaadin.tests.widgetset.TestingWidgetSet") -public class ComponentInStateRoot extends Root { +public class ComponentInStateRoot extends UI { @Override protected void init(WrappedRequest request) { ComponentInStateComponent component = new ComponentInStateComponent(); diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a2/MyComponentRoot.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a2/MyComponentRoot.java index ef692ef8a3..87aede8da9 100644 --- a/tests/testbench/com/vaadin/tests/minitutorials/v7a2/MyComponentRoot.java +++ b/tests/testbench/com/vaadin/tests/minitutorials/v7a2/MyComponentRoot.java @@ -18,7 +18,7 @@ package com.vaadin.tests.minitutorials.v7a2; import com.vaadin.annotations.Widgetset; import com.vaadin.terminal.WrappedRequest; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; /** * Mini tutorial code for @@ -33,7 +33,7 @@ import com.vaadin.ui.Root; * @since 7.0.0 */ @Widgetset("com.vaadin.tests.widgetset.TestingWidgetSet") -public class MyComponentRoot extends Root { +public class MyComponentRoot extends UI { @Override protected void init(WrappedRequest request) { diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a2/ResourceInStateRoot.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a2/ResourceInStateRoot.java index 69c2a0d040..04e2cf089e 100644 --- a/tests/testbench/com/vaadin/tests/minitutorials/v7a2/ResourceInStateRoot.java +++ b/tests/testbench/com/vaadin/tests/minitutorials/v7a2/ResourceInStateRoot.java @@ -19,7 +19,7 @@ package com.vaadin.tests.minitutorials.v7a2; import com.vaadin.annotations.Widgetset; import com.vaadin.terminal.ThemeResource; import com.vaadin.terminal.WrappedRequest; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; /** * Mini tutorial code for @@ -30,7 +30,7 @@ import com.vaadin.ui.Root; * @since 7.0.0 */ @Widgetset("com.vaadin.tests.widgetset.TestingWidgetSet") -public class ResourceInStateRoot extends Root { +public class ResourceInStateRoot extends UI { @Override protected void init(WrappedRequest request) { diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a2/WidgetcontainerRoot.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a2/WidgetcontainerRoot.java index fae4265750..38f008d8a0 100644 --- a/tests/testbench/com/vaadin/tests/minitutorials/v7a2/WidgetcontainerRoot.java +++ b/tests/testbench/com/vaadin/tests/minitutorials/v7a2/WidgetcontainerRoot.java @@ -10,10 +10,10 @@ import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.CheckBox; import com.vaadin.ui.Component; import com.vaadin.ui.Label; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; @Widgetset("com.vaadin.tests.widgetset.TestingWidgetSet") -public class WidgetcontainerRoot extends Root { +public class WidgetcontainerRoot extends UI { @Override public void init(WrappedRequest request) { Label label = new Label("Hello Vaadin user"); diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a3/Analytics.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a3/Analytics.java index 6c247cae44..6f2be3c7d7 100644 --- a/tests/testbench/com/vaadin/tests/minitutorials/v7a3/Analytics.java +++ b/tests/testbench/com/vaadin/tests/minitutorials/v7a3/Analytics.java @@ -19,7 +19,7 @@ package com.vaadin.tests.minitutorials.v7a3; import com.vaadin.annotations.JavaScript; import com.vaadin.terminal.AbstractJavaScriptExtension; import com.vaadin.terminal.gwt.server.ClientConnector; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; @JavaScript("analytics_connector.js") public class Analytics extends AbstractJavaScriptExtension { @@ -38,12 +38,12 @@ public class Analytics extends AbstractJavaScriptExtension { callFunction("pushCommand", (Object) commandAndArguments); } - protected void extend(Root root) { - super.extend(root); + protected void extend(UI uI) { + super.extend(uI); } @Override protected Class getSupportedParentType() { - return Root.class; + return UI.class; } } diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a3/AnalyticsRoot.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a3/AnalyticsRoot.java index df588b6f2d..05255d71cb 100644 --- a/tests/testbench/com/vaadin/tests/minitutorials/v7a3/AnalyticsRoot.java +++ b/tests/testbench/com/vaadin/tests/minitutorials/v7a3/AnalyticsRoot.java @@ -19,9 +19,9 @@ package com.vaadin.tests.minitutorials.v7a3; import com.vaadin.terminal.WrappedRequest; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; -public class AnalyticsRoot extends Root { +public class AnalyticsRoot extends UI { @Override protected void init(WrappedRequest request) { diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a3/ComplexTypesComponent.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a3/ComplexTypesComponent.java index 9a477bf6dd..5b6a693389 100644 --- a/tests/testbench/com/vaadin/tests/minitutorials/v7a3/ComplexTypesComponent.java +++ b/tests/testbench/com/vaadin/tests/minitutorials/v7a3/ComplexTypesComponent.java @@ -25,7 +25,7 @@ import java.util.Map; import com.vaadin.annotations.JavaScript; import com.vaadin.shared.Connector; import com.vaadin.ui.AbstractJavaScriptComponent; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; @JavaScript("complex_types_connector.js") public class ComplexTypesComponent extends AbstractJavaScriptComponent { @@ -45,7 +45,7 @@ public class ComplexTypesComponent extends AbstractJavaScriptComponent { Map connectorMap = new HashMap(); connectorMap.put(this, "this"); - connectorMap.put(Root.getCurrent(), "root"); + connectorMap.put(UI.getCurrent(), "root"); boolean[] bits = { true, true, false, true }; diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a3/ComplexTypesRoot.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a3/ComplexTypesRoot.java index 5e19d8ab1a..ffe654d0b3 100644 --- a/tests/testbench/com/vaadin/tests/minitutorials/v7a3/ComplexTypesRoot.java +++ b/tests/testbench/com/vaadin/tests/minitutorials/v7a3/ComplexTypesRoot.java @@ -17,9 +17,9 @@ package com.vaadin.tests.minitutorials.v7a3; import com.vaadin.terminal.WrappedRequest; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; -public class ComplexTypesRoot extends Root { +public class ComplexTypesRoot extends UI { @Override protected void init(WrappedRequest request) { diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a3/FlotJavaScriptRoot.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a3/FlotJavaScriptRoot.java index f0584c2147..a8bf867fb5 100644 --- a/tests/testbench/com/vaadin/tests/minitutorials/v7a3/FlotJavaScriptRoot.java +++ b/tests/testbench/com/vaadin/tests/minitutorials/v7a3/FlotJavaScriptRoot.java @@ -19,9 +19,9 @@ package com.vaadin.tests.minitutorials.v7a3; import com.vaadin.terminal.WrappedRequest; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; -public class FlotJavaScriptRoot extends Root { +public class FlotJavaScriptRoot extends UI { @Override protected void init(WrappedRequest request) { diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a3/RedButtonRoot.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a3/RedButtonRoot.java index 1bf30b0054..73fba3fd7e 100644 --- a/tests/testbench/com/vaadin/tests/minitutorials/v7a3/RedButtonRoot.java +++ b/tests/testbench/com/vaadin/tests/minitutorials/v7a3/RedButtonRoot.java @@ -17,9 +17,9 @@ package com.vaadin.tests.minitutorials.v7a3; import com.vaadin.terminal.WrappedRequest; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; -public class RedButtonRoot extends Root { +public class RedButtonRoot extends UI { @Override protected void init(WrappedRequest request) { addComponent(new RedButton("My red button")); diff --git a/tests/testbench/com/vaadin/tests/themes/ButtonsTest.java b/tests/testbench/com/vaadin/tests/themes/ButtonsTest.java index a2d482dfbf..62160d233a 100644 --- a/tests/testbench/com/vaadin/tests/themes/ButtonsTest.java +++ b/tests/testbench/com/vaadin/tests/themes/ButtonsTest.java @@ -10,13 +10,13 @@ import com.vaadin.ui.CheckBox; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Layout; import com.vaadin.ui.NativeButton; -import com.vaadin.ui.Root; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI; +import com.vaadin.ui.UI.LegacyWindow; @SuppressWarnings("serial") public class ButtonsTest extends com.vaadin.Application.LegacyApplication { - final Root.LegacyWindow main = new LegacyWindow("Button states & themes"); + final UI.LegacyWindow main = new LegacyWindow("Button states & themes"); CheckBox styleToggle; CheckBox iconToggle; diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1225.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1225.java index 299c939043..8c99fe6ebb 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1225.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1225.java @@ -5,7 +5,7 @@ import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.tests.TestForTablesInitialColumnWidthLogicRendering; import com.vaadin.ui.Alignment; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TabSheet; import com.vaadin.ui.Table; import com.vaadin.ui.VerticalLayout; diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1230.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1230.java index b1841b69ba..e11d6ea024 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1230.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1230.java @@ -6,7 +6,7 @@ import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.GridLayout; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Select; public class Ticket1230 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket124.java b/tests/testbench/com/vaadin/tests/tickets/Ticket124.java index 8761db1cc3..4bcf31a366 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket124.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket124.java @@ -7,7 +7,7 @@ import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.GridLayout; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TextField; public class Ticket124 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1245.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1245.java index a5aa8cd2ac..6aa1c1752a 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1245.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1245.java @@ -5,7 +5,7 @@ import com.vaadin.data.Property; import com.vaadin.ui.AbstractSelect; import com.vaadin.ui.CustomComponent; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TextField; import com.vaadin.ui.Tree; import com.vaadin.ui.VerticalLayout; diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1365.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1365.java index 7e9f5dab2c..c617b07248 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1365.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1365.java @@ -4,7 +4,7 @@ import com.vaadin.event.Action; import com.vaadin.event.Action.Handler; import com.vaadin.event.ShortcutAction; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TextField; public class Ticket1365 extends com.vaadin.Application.LegacyApplication diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1368.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1368.java index 92d3598382..16b47a1f31 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1368.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1368.java @@ -3,7 +3,7 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; import com.vaadin.tests.TestForTablesInitialColumnWidthLogicRendering; import com.vaadin.ui.ComboBox; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Table; /** diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1397.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1397.java index 3ba7ae2bfa..e162e96bfa 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1397.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1397.java @@ -10,7 +10,7 @@ import com.vaadin.ui.InlineDateField; import com.vaadin.ui.Label; import com.vaadin.ui.Panel; import com.vaadin.ui.PopupView; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Table; import com.vaadin.ui.TextField; diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1435.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1435.java index d6d3b132c3..d46a56f73a 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1435.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1435.java @@ -12,7 +12,7 @@ import com.vaadin.ui.Label; import com.vaadin.ui.Layout; import com.vaadin.ui.Layout.MarginHandler; import com.vaadin.ui.Panel; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Table; import com.vaadin.ui.VerticalLayout; diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1444.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1444.java index a597a5b242..1da3b5c290 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1444.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1444.java @@ -3,7 +3,7 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.VerticalLayout; public class Ticket1444 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1465ModalNotification.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1465ModalNotification.java index 4b7d4201e0..3c766ef985 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1465ModalNotification.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1465ModalNotification.java @@ -5,7 +5,7 @@ import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Label; import com.vaadin.ui.Notification; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Window; public class Ticket1465ModalNotification extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1519.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1519.java index 1c4156d7ff..8b1736637b 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1519.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1519.java @@ -2,7 +2,7 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; import com.vaadin.ui.CustomLayout; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TabSheet; public class Ticket1519 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1572.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1572.java index 87ea7e86a8..a511bae6d9 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1572.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1572.java @@ -7,7 +7,7 @@ import com.vaadin.ui.GridLayout; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.ui.Panel; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class Ticket1572 extends com.vaadin.Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1581.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1581.java index 6831d4c52d..5025605413 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1581.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1581.java @@ -7,7 +7,7 @@ import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Label; import com.vaadin.ui.ProgressIndicator; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class Ticket1581 extends com.vaadin.Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1589.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1589.java index 95cc918b6e..92a480c3d2 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1589.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1589.java @@ -17,7 +17,7 @@ import com.vaadin.terminal.RequestHandler; import com.vaadin.terminal.WrappedRequest; import com.vaadin.terminal.WrappedResponse; import com.vaadin.ui.Link; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class Ticket1589 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1598.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1598.java index 5cb03e77af..05fd0c3f1f 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1598.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1598.java @@ -8,7 +8,7 @@ import com.vaadin.terminal.ThemeResource; import com.vaadin.ui.MenuBar; import com.vaadin.ui.MenuBar.Command; import com.vaadin.ui.MenuBar.MenuItem; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class Ticket1598 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket161.java b/tests/testbench/com/vaadin/tests/tickets/Ticket161.java index b8bf8deb20..4da1b3a6b4 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket161.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket161.java @@ -5,7 +5,7 @@ import com.vaadin.data.Container; import com.vaadin.tests.TestForTablesInitialColumnWidthLogicRendering; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Table; /** diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1632.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1632.java index 43feab5ab7..bca902a73f 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1632.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1632.java @@ -4,7 +4,7 @@ import com.vaadin.Application; import com.vaadin.data.Item; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Table; /** diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1659.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1659.java index 3c64a49316..55d08069ed 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1659.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1659.java @@ -4,7 +4,7 @@ import com.vaadin.Application; import com.vaadin.terminal.ExternalResource; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class Ticket1659 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1663.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1663.java index 64d53e33f6..b07e9df0e5 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1663.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1663.java @@ -1,7 +1,7 @@ package com.vaadin.tests.tickets; import com.vaadin.terminal.SystemError; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TextField; public class Ticket1663 extends com.vaadin.Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1673.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1673.java index 277096598e..99f213541a 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1673.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1673.java @@ -3,7 +3,7 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class Ticket1673 extends com.vaadin.Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1710.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1710.java index 6547572e6d..d3c2437219 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1710.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1710.java @@ -24,7 +24,7 @@ import com.vaadin.ui.Layout; import com.vaadin.ui.Layout.AlignmentHandler; import com.vaadin.ui.NativeSelect; import com.vaadin.ui.Panel; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1737.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1737.java index ccd649c542..364ad9b6cf 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1737.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1737.java @@ -7,7 +7,7 @@ import com.vaadin.terminal.Resource; import com.vaadin.ui.Embedded; import com.vaadin.ui.Label; import com.vaadin.ui.Panel; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.VerticalLayout; public class Ticket1737 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1767.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1767.java index bf57118a8c..eca0c0f833 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1767.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1767.java @@ -1,7 +1,7 @@ package com.vaadin.tests.tickets; import com.vaadin.ui.ComboBox; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class Ticket1767 extends com.vaadin.Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1772.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1772.java index 2cbb648227..a269acc1e0 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1772.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1772.java @@ -3,7 +3,7 @@ package com.vaadin.tests.tickets; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.GridLayout; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TextField; public class Ticket1772 extends com.vaadin.Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1775.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1775.java index 63af96b1a2..ec28a957bb 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1775.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1775.java @@ -4,7 +4,7 @@ import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.CustomLayout; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class Ticket1775 extends com.vaadin.Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1804.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1804.java index 0a89675fc0..780215aa2a 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1804.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1804.java @@ -11,7 +11,7 @@ import com.vaadin.ui.AbstractField; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Select; import com.vaadin.ui.Window; diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1805.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1805.java index e5fcf59db8..7f5c684479 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1805.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1805.java @@ -7,7 +7,7 @@ import com.vaadin.ui.Button; import com.vaadin.ui.GridLayout; import com.vaadin.ui.Label; import com.vaadin.ui.Layout.MarginHandler; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TextField; public class Ticket1805 extends com.vaadin.Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1806.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1806.java index fa572039aa..8359b024aa 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1806.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1806.java @@ -3,7 +3,7 @@ package com.vaadin.tests.tickets; import com.vaadin.data.util.ObjectProperty; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TextField; public class Ticket1806 extends com.vaadin.Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1811.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1811.java index 695be19300..824c58436f 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1811.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1811.java @@ -9,7 +9,7 @@ import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TextField; import com.vaadin.ui.Window; diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1819.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1819.java index 42474d748d..e16b2c2774 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1819.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1819.java @@ -8,7 +8,7 @@ import com.vaadin.ui.AbstractField; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Select; import com.vaadin.ui.Window; diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1834PanelScrolling.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1834PanelScrolling.java index e31748ec2f..f7329037cc 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1834PanelScrolling.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1834PanelScrolling.java @@ -6,7 +6,7 @@ import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.ui.Panel; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class Ticket1834PanelScrolling extends com.vaadin.Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1857.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1857.java index 4b546de0f6..039f867fff 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1857.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1857.java @@ -7,7 +7,7 @@ import com.vaadin.event.Action; import com.vaadin.event.Action.Handler; import com.vaadin.ui.CheckBox; import com.vaadin.ui.HorizontalLayout; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Table; import com.vaadin.ui.VerticalLayout; diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1868.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1868.java index 1af0ed2041..8bd4a77204 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1868.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1868.java @@ -1,7 +1,7 @@ package com.vaadin.tests.tickets; import com.vaadin.ui.Panel; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class Ticket1868 extends com.vaadin.Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1869.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1869.java index d51c0990ae..741adecae4 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1869.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1869.java @@ -4,7 +4,7 @@ import com.vaadin.ui.Button; import com.vaadin.ui.GridLayout; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Panel; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.VerticalLayout; public class Ticket1869 extends com.vaadin.Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1878.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1878.java index 0a8992c17f..1b60d535cf 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1878.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1878.java @@ -23,7 +23,7 @@ import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Layout; import com.vaadin.ui.Layout.AlignmentHandler; import com.vaadin.ui.Panel; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1900.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1900.java index 9fe8ccd801..136af23474 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1900.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1900.java @@ -4,7 +4,7 @@ import com.vaadin.Application; import com.vaadin.data.Property; import com.vaadin.data.Property.ValueChangeEvent; import com.vaadin.data.Validator; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TextField; public class Ticket1900 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1904.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1904.java index 2837d71e67..f35463f6a8 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1904.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1904.java @@ -5,7 +5,7 @@ import com.vaadin.ui.AbstractOrderedLayout; import com.vaadin.ui.Button; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.VerticalLayout; public class Ticket1904 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1916.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1916.java index 790d3aa931..3b50804938 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1916.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1916.java @@ -4,7 +4,7 @@ import com.vaadin.Application; import com.vaadin.terminal.UserError; import com.vaadin.ui.Alignment; import com.vaadin.ui.HorizontalLayout; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TextField; public class Ticket1916 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1919.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1919.java index 75a2aafb96..8e9e0cb0ba 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1919.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1919.java @@ -5,7 +5,7 @@ import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Component; import com.vaadin.ui.GridLayout; import com.vaadin.ui.Panel; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class Ticket1919 extends com.vaadin.Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1921.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1921.java index 416bb80875..3d79de5d1d 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1921.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1921.java @@ -10,7 +10,7 @@ import com.vaadin.terminal.WrappedResponse; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.VerticalLayout; public class Ticket1921 extends Application.LegacyApplication implements diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1923.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1923.java index 17a7dacf26..2bde4c95ec 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1923.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1923.java @@ -2,7 +2,7 @@ package com.vaadin.tests.tickets; import com.vaadin.ui.Label; import com.vaadin.ui.Panel; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.VerticalLayout; public class Ticket1923 extends com.vaadin.Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1925.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1925.java index 91ea8c0c44..b5d938dbed 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1925.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1925.java @@ -1,7 +1,7 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class Ticket1925 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1939.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1939.java index 48d8ff458c..f65fbf9852 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1939.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1939.java @@ -3,7 +3,7 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1940.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1940.java index 10eebe4cba..1a27e1ad28 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1940.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1940.java @@ -1,7 +1,7 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1953.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1953.java index a832401cd0..9bf4ddee51 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1953.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1953.java @@ -4,7 +4,7 @@ import com.vaadin.Application; import com.vaadin.ui.Button; import com.vaadin.ui.GridLayout; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class Ticket1953 extends Application.LegacyApplication { public static final String cellStyle = "test-cell"; diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1966.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1966.java index d461ffe4e3..9440855bbe 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1966.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1966.java @@ -9,7 +9,7 @@ import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Layout; import com.vaadin.ui.Layout.AlignmentHandler; import com.vaadin.ui.Panel; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.VerticalLayout; public class Ticket1966 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1966_2.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1966_2.java index 85b802d46c..c5442e6473 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1966_2.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1966_2.java @@ -9,7 +9,7 @@ import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Layout; import com.vaadin.ui.Layout.AlignmentHandler; import com.vaadin.ui.Panel; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.VerticalLayout; public class Ticket1966_2 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1966_3.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1966_3.java index cfc9825b58..63634259a3 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1966_3.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1966_3.java @@ -6,7 +6,7 @@ import com.vaadin.terminal.UserError; import com.vaadin.ui.Alignment; import com.vaadin.ui.GridLayout; import com.vaadin.ui.Panel; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1969.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1969.java index 2a29113829..b10ccea992 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1969.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1969.java @@ -5,7 +5,7 @@ import com.vaadin.tests.TestForTablesInitialColumnWidthLogicRendering; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TabSheet; import com.vaadin.ui.Table; import com.vaadin.ui.VerticalLayout; diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1970.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1970.java index f9f098a05a..b07a997f8f 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1970.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1970.java @@ -7,7 +7,7 @@ import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class Ticket1970 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1972.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1972.java index fd77343259..6b406a2f89 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1972.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1972.java @@ -3,7 +3,7 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; import com.vaadin.ui.GridLayout; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class Ticket1972 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1973.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1973.java index 24d11e6569..a3365bedcb 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1973.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1973.java @@ -4,7 +4,7 @@ import com.vaadin.data.Item; import com.vaadin.data.util.IndexedContainer; import com.vaadin.ui.Button; import com.vaadin.ui.Component; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Table; import com.vaadin.ui.VerticalLayout; diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1973_2.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1973_2.java index 68307f7f99..4392c0762a 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1973_2.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1973_2.java @@ -5,7 +5,7 @@ import com.vaadin.data.Item; import com.vaadin.data.util.IndexedContainer; import com.vaadin.ui.Button; import com.vaadin.ui.Component; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Table; import com.vaadin.ui.VerticalLayout; diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1975.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1975.java index e959098765..fda75a409e 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1975.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1975.java @@ -11,7 +11,7 @@ import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.CustomLayout; import com.vaadin.ui.GridLayout; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class Ticket1975 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1982.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1982.java index fe0b636c56..a5953d22af 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1982.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1982.java @@ -10,7 +10,7 @@ import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.GridLayout; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class Ticket1982 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1983.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1983.java index 4db82c3371..0d6a21faac 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1983.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1983.java @@ -9,7 +9,7 @@ import com.vaadin.ui.Button; import com.vaadin.ui.CheckBox; import com.vaadin.ui.HorizontalSplitPanel; import com.vaadin.ui.Layout; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Table; import com.vaadin.ui.VerticalLayout; diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1986.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1986.java index 88ebad933f..fd6665b2fe 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1986.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1986.java @@ -8,7 +8,7 @@ import com.vaadin.ui.GridLayout; import com.vaadin.ui.ListSelect; import com.vaadin.ui.NativeSelect; import com.vaadin.ui.OptionGroup; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TextField; import com.vaadin.ui.TwinColSelect; diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1991.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1991.java index 72866a3ee8..ed60c89c16 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1991.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1991.java @@ -1,7 +1,7 @@ package com.vaadin.tests.tickets; import com.vaadin.ui.CheckBox; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Table; public class Ticket1991 extends com.vaadin.Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket1995.java b/tests/testbench/com/vaadin/tests/tickets/Ticket1995.java index 2aaacef448..04ce9c712d 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket1995.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket1995.java @@ -7,7 +7,7 @@ import com.vaadin.data.Item; import com.vaadin.data.util.filter.SimpleStringFilter; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Table; public class Ticket1995 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket20.java b/tests/testbench/com/vaadin/tests/tickets/Ticket20.java index 061fc0cf16..ea610a3db8 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket20.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket20.java @@ -8,7 +8,7 @@ import com.vaadin.data.validator.CompositeValidator.CombinationMode; import com.vaadin.data.validator.IntegerValidator; import com.vaadin.ui.Button; import com.vaadin.ui.CheckBox; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TextField; public class Ticket20 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2001.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2001.java index 8c7a7ba659..8ff3d952c4 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2001.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2001.java @@ -5,7 +5,7 @@ import com.vaadin.data.Property; import com.vaadin.data.Property.ValueChangeEvent; import com.vaadin.ui.CheckBox; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.VerticalLayout; public class Ticket2001 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2002.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2002.java index 2c4a948cea..aeaf3bfb33 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2002.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2002.java @@ -3,7 +3,7 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; import com.vaadin.data.util.MethodProperty; import com.vaadin.ui.GridLayout; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TextField; public class Ticket2002 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2007.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2007.java index e0b8635f32..0342b87e68 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2007.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2007.java @@ -4,7 +4,7 @@ import com.vaadin.Application; import com.vaadin.terminal.ExternalResource; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class Ticket2007 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2009.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2009.java index 68cf5ef6d4..e79ec8905e 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2009.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2009.java @@ -8,7 +8,7 @@ import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.ui.Panel; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Table; import com.vaadin.ui.TextField; import com.vaadin.ui.Tree; diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2011.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2011.java index e8113b0cea..754036cd5b 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2011.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2011.java @@ -2,7 +2,7 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; import com.vaadin.ui.GridLayout; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Select; public class Ticket2011 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2014.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2014.java index 8d9a5e67d4..bf909acb35 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2014.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2014.java @@ -9,7 +9,7 @@ import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.GridLayout; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Panel; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class Ticket2014 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2021.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2021.java index f6d8ce5e01..c23f031a91 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2021.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2021.java @@ -11,7 +11,7 @@ import com.vaadin.ui.Label; import com.vaadin.ui.Layout; import com.vaadin.ui.Layout.MarginHandler; import com.vaadin.ui.Panel; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TextArea; import com.vaadin.ui.VerticalLayout; diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2022.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2022.java index bc97f906b1..ea142b7e9e 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2022.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2022.java @@ -2,7 +2,7 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; import com.vaadin.ui.CustomLayout; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class Ticket2022 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2023.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2023.java index 427a55391b..c6b2c0f28a 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2023.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2023.java @@ -4,7 +4,7 @@ import com.vaadin.ui.AbstractComponent; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.GridLayout; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class Ticket2023 extends com.vaadin.Application.LegacyApplication implements Button.ClickListener { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2024.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2024.java index e7cabbca95..b1a8b64931 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2024.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2024.java @@ -3,7 +3,7 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; import com.vaadin.ui.GridLayout; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2026.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2026.java index 6d608ad529..0b72073bec 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2026.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2026.java @@ -2,7 +2,7 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; import com.vaadin.ui.GridLayout; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TextField; public class Ticket2026 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2029.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2029.java index 8acf4f1d16..ba8936adfa 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2029.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2029.java @@ -11,7 +11,7 @@ import com.vaadin.ui.Component; import com.vaadin.ui.GridLayout; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Panel; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TextArea; import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2037.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2037.java index c979898299..da47f796a5 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2037.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2037.java @@ -4,7 +4,7 @@ import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Label; import com.vaadin.ui.Layout; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.VerticalLayout; public class Ticket2037 extends com.vaadin.Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2038.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2038.java index fa4cd76f47..c4714783a0 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2038.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2038.java @@ -5,7 +5,7 @@ import com.vaadin.data.Property; import com.vaadin.data.Property.ValueChangeEvent; import com.vaadin.ui.CheckBox; import com.vaadin.ui.Notification; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TextField; public class Ticket2038 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2040.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2040.java index d98656b9ca..a7ca7b179f 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2040.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2040.java @@ -3,7 +3,7 @@ package com.vaadin.tests.tickets; import com.vaadin.ui.Accordion; import com.vaadin.ui.Label; import com.vaadin.ui.Layout.MarginHandler; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TextArea; import com.vaadin.ui.TextField; diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2042.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2042.java index d79f4a1bd6..49e999a601 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2042.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2042.java @@ -7,7 +7,7 @@ import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.GridLayout; import com.vaadin.ui.Label; import com.vaadin.ui.Notification; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class Ticket2042 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2043.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2043.java index 7238462397..2efc66556d 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2043.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2043.java @@ -4,7 +4,7 @@ import com.vaadin.Application; import com.vaadin.terminal.ExternalResource; import com.vaadin.ui.GridLayout; import com.vaadin.ui.Link; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class Ticket2043 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2048.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2048.java index 0b5a537b4d..110db06800 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2048.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2048.java @@ -10,7 +10,7 @@ import com.vaadin.ui.GridLayout; import com.vaadin.ui.Label; import com.vaadin.ui.Layout; import com.vaadin.ui.Panel; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.VerticalLayout; public class Ticket2048 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2051.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2051.java index bd098443f2..1660f00d88 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2051.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2051.java @@ -7,7 +7,7 @@ import com.vaadin.ui.Component; import com.vaadin.ui.DateField; import com.vaadin.ui.GridLayout; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Table; import com.vaadin.ui.TextField; diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2053.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2053.java index fd64d6e35a..362a763c2f 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2053.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2053.java @@ -7,7 +7,7 @@ import com.vaadin.terminal.ExternalResource; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TextField; public class Ticket2053 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2060.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2060.java index 88404b6ef1..c9e91930bf 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2060.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2060.java @@ -6,7 +6,7 @@ import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.GridLayout; import com.vaadin.ui.HorizontalLayout; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class Ticket2060 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2061.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2061.java index 1f633d7337..d86646b865 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2061.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2061.java @@ -8,7 +8,7 @@ import com.vaadin.data.util.HierarchicalContainer; import com.vaadin.ui.Accordion; import com.vaadin.ui.Component; import com.vaadin.ui.CustomComponent; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TabSheet; import com.vaadin.ui.Table; import com.vaadin.ui.VerticalLayout; diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2061b.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2061b.java index e3cd09926e..420d2b7086 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2061b.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2061b.java @@ -12,7 +12,7 @@ import com.vaadin.ui.Component; import com.vaadin.ui.CustomComponent; import com.vaadin.ui.Label; import com.vaadin.ui.Panel; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TabSheet; import com.vaadin.ui.TabSheet.SelectedTabChangeEvent; import com.vaadin.ui.TabSheet.SelectedTabChangeListener; diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2061c.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2061c.java index 082b956fe0..b0897600d3 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2061c.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2061c.java @@ -10,7 +10,7 @@ import com.vaadin.ui.Component; import com.vaadin.ui.CustomComponent; import com.vaadin.ui.Label; import com.vaadin.ui.Panel; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TabSheet; import com.vaadin.ui.TabSheet.SelectedTabChangeEvent; import com.vaadin.ui.TabSheet.SelectedTabChangeListener; diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2062.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2062.java index 5d91240c6a..9b2fe05514 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2062.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2062.java @@ -2,7 +2,7 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; import com.vaadin.ui.HorizontalSplitPanel; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TabSheet; import com.vaadin.ui.Table; import com.vaadin.ui.TextField; diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2083.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2083.java index ea77b6f2e6..87bea00023 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2083.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2083.java @@ -4,7 +4,7 @@ import com.vaadin.Application; import com.vaadin.ui.GridLayout; import com.vaadin.ui.Label; import com.vaadin.ui.Panel; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class Ticket2083 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2090.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2090.java index 2042cf7cad..e48aae7d9f 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2090.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2090.java @@ -6,7 +6,7 @@ import com.vaadin.data.Property.ValueChangeEvent; import com.vaadin.terminal.UserError; import com.vaadin.ui.Button; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TextField; public class Ticket2090 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2095.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2095.java index a27ae7ac4d..258fad05c9 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2095.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2095.java @@ -3,7 +3,7 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; import com.vaadin.terminal.ExternalResource; import com.vaadin.ui.Embedded; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class Ticket2095 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2098.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2098.java index 5dc741eff6..a8a3e22d2b 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2098.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2098.java @@ -2,7 +2,7 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TabSheet; public class Ticket2098 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2099.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2099.java index 0f0c00b05c..2bba0504a5 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2099.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2099.java @@ -6,7 +6,7 @@ import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.GridLayout; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TabSheet; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2101.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2101.java index 67c3c9f331..c29eaaf453 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2101.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2101.java @@ -2,7 +2,7 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; import com.vaadin.ui.Button; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class Ticket2101 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2103.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2103.java index 1fb89eebc4..9017f66158 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2103.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2103.java @@ -5,7 +5,7 @@ import com.vaadin.data.Item; import com.vaadin.data.util.HierarchicalContainer; import com.vaadin.ui.Accordion; import com.vaadin.ui.Component; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Table; import com.vaadin.ui.VerticalLayout; diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2104.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2104.java index b8a6724a41..4da938351d 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2104.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2104.java @@ -11,7 +11,7 @@ import com.vaadin.terminal.ExternalResource; import com.vaadin.ui.CheckBox; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Table; import com.vaadin.ui.Tree; @@ -68,16 +68,16 @@ public class Ticket2104 extends Application.LegacyApplication { main.addComponent(tree); tree.setImmediate(true); tree.setNullSelectionAllowed(false); - tree.addItem("Root 1"); + tree.addItem("UI 1"); tree.addItem("1. Child 1"); - tree.setParent("1. Child 1", "Root 1"); + tree.setParent("1. Child 1", "UI 1"); tree.addItem("1. Child 2"); - tree.setParent("1. Child 2", "Root 1"); - tree.addItem("Root 2"); + tree.setParent("1. Child 2", "UI 1"); + tree.addItem("UI 2"); tree.addItem("2. Child 1"); - tree.setParent("2. Child 1", "Root 2"); + tree.setParent("2. Child 1", "UI 2"); tree.addItem("2. Child 2"); - tree.setParent("2. Child 2", "Root 2"); + tree.setParent("2. Child 2", "UI 2"); tree.addContainerProperty("icon", ExternalResource.class, new ExternalResource( "http://www.itmill.com/res/images/itmill_logo.gif")); diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2106.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2106.java index 6edc625b39..9d6e198f03 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2106.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2106.java @@ -6,7 +6,7 @@ import com.vaadin.Application; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class Ticket2106 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2107.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2107.java index 09ba9fac0b..37d570546b 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2107.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2107.java @@ -6,7 +6,7 @@ import com.vaadin.data.Property.ValueChangeEvent; import com.vaadin.data.Validator; import com.vaadin.ui.CheckBox; import com.vaadin.ui.Notification; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TextField; public class Ticket2107 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2117.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2117.java index 8bbfe0cd07..d5b5041060 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2117.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2117.java @@ -7,7 +7,7 @@ import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class Ticket2117 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2119.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2119.java index b563ec90ef..621b744aa8 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2119.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2119.java @@ -8,7 +8,7 @@ import com.vaadin.terminal.ExternalResource; import com.vaadin.ui.Button; import com.vaadin.ui.Label; import com.vaadin.ui.Layout; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Select; import com.vaadin.ui.VerticalLayout; diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2125.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2125.java index b12a865e80..bc1f886418 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2125.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2125.java @@ -5,7 +5,7 @@ import com.vaadin.data.util.MethodProperty; import com.vaadin.ui.CheckBox; import com.vaadin.ui.Component; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Table; import com.vaadin.ui.Table.CellStyleGenerator; import com.vaadin.ui.Table.ColumnGenerator; diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2126.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2126.java index c9e070bef4..d49c73ea5f 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2126.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2126.java @@ -5,7 +5,7 @@ import com.vaadin.data.util.IndexedContainer; import com.vaadin.ui.Button; import com.vaadin.ui.Component; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Table; /** diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2151.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2151.java index c2fbe1b4f7..721bdf3c9f 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2151.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2151.java @@ -8,7 +8,7 @@ import com.vaadin.ui.AbstractOrderedLayout; import com.vaadin.ui.Button; import com.vaadin.ui.CheckBox; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class Ticket2151 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2157.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2157.java index 23c5b0bcd5..b8f75fc279 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2157.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2157.java @@ -4,7 +4,7 @@ import com.vaadin.Application; import com.vaadin.ui.AbstractOrderedLayout; import com.vaadin.ui.ComboBox; import com.vaadin.ui.Panel; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.VerticalLayout; public class Ticket2157 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2178.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2178.java index 6de42003b4..e64db69ced 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2178.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2178.java @@ -4,7 +4,7 @@ import com.vaadin.Application; import com.vaadin.ui.AbstractOrderedLayout; import com.vaadin.ui.ComboBox; import com.vaadin.ui.Panel; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.VerticalLayout; public class Ticket2178 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2179.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2179.java index 31e1a9a0d6..622488dc0f 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2179.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2179.java @@ -4,7 +4,7 @@ import com.vaadin.Application; import com.vaadin.data.Property; import com.vaadin.data.Property.ValueChangeEvent; import com.vaadin.data.Validator; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TextField; public class Ticket2179 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2180.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2180.java index 7b993cdf24..fb9332d100 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2180.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2180.java @@ -3,7 +3,7 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; import com.vaadin.ui.Button; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TabSheet; public class Ticket2180 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2181.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2181.java index 44893eb531..ceba214dc5 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2181.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2181.java @@ -12,7 +12,7 @@ import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Component; import com.vaadin.ui.OptionGroup; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2186.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2186.java index b7817d2ed7..50b8a1f113 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2186.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2186.java @@ -4,7 +4,7 @@ import com.vaadin.Application; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.ui.Panel; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Table; import com.vaadin.ui.VerticalLayout; diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2204.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2204.java index 4caba62df2..24c4d6e8b9 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2204.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2204.java @@ -26,7 +26,7 @@ import com.vaadin.ui.Label; import com.vaadin.ui.Layout; import com.vaadin.ui.Panel; import com.vaadin.ui.RichTextArea; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TabSheet; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.VerticalSplitPanel; diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2208.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2208.java index 3f0f35bb84..f622f093ee 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2208.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2208.java @@ -4,7 +4,7 @@ import com.vaadin.Application; import com.vaadin.data.Item; import com.vaadin.ui.Component; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Table; import com.vaadin.ui.Table.CellStyleGenerator; import com.vaadin.ui.Table.ColumnGenerator; diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2209.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2209.java index a387781ae3..ecad9a950a 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2209.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2209.java @@ -7,7 +7,7 @@ import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.ComboBox; import com.vaadin.ui.GridLayout; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class Ticket2209 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2209OL.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2209OL.java index 226df8b5e7..6eec0a7704 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2209OL.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2209OL.java @@ -6,7 +6,7 @@ import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.ComboBox; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.VerticalLayout; public class Ticket2209OL extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2209OL2.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2209OL2.java index 921f3b190b..7f4082d0f8 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2209OL2.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2209OL2.java @@ -6,7 +6,7 @@ import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.ComboBox; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.VerticalLayout; public class Ticket2209OL2 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2215.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2215.java index 5b98fe3af3..f7099d88f4 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2215.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2215.java @@ -3,7 +3,7 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; import com.vaadin.ui.Label; import com.vaadin.ui.Panel; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.themes.Reindeer; diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2221.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2221.java index 886aa376c3..e3f1516fb8 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2221.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2221.java @@ -9,7 +9,7 @@ import com.vaadin.ui.Component; import com.vaadin.ui.CustomComponent; import com.vaadin.ui.Layout; import com.vaadin.ui.Panel; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2222.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2222.java index 51ac463a6e..14024fda8b 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2222.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2222.java @@ -5,7 +5,7 @@ import com.vaadin.ui.AbstractOrderedLayout; import com.vaadin.ui.GridLayout; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.VerticalLayout; public class Ticket2222 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2227OrderedlayoutInTable.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2227OrderedlayoutInTable.java index e436bab283..f9c670708e 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2227OrderedlayoutInTable.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2227OrderedlayoutInTable.java @@ -5,7 +5,7 @@ import com.vaadin.data.Item; import com.vaadin.ui.Component; import com.vaadin.ui.Label; import com.vaadin.ui.Layout; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Table; import com.vaadin.ui.VerticalLayout; diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2231.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2231.java index ab0cc82628..21994bff60 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2231.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2231.java @@ -3,7 +3,7 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; import com.vaadin.ui.AbstractOrderedLayout; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class Ticket2231 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2232.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2232.java index ae8a4b0f51..d71134696f 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2232.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2232.java @@ -6,7 +6,7 @@ import com.vaadin.ui.GridLayout; import com.vaadin.ui.Label; import com.vaadin.ui.Layout; import com.vaadin.ui.Layout.SpacingHandler; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.VerticalLayout; public class Ticket2232 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2234.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2234.java index 24a6d2ea77..ccda59bb6a 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2234.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2234.java @@ -4,7 +4,7 @@ import com.vaadin.Application; import com.vaadin.data.Item; import com.vaadin.ui.AbstractOrderedLayout; import com.vaadin.ui.ComboBox; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class Ticket2234 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2235.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2235.java index 10978cad30..fba82956e0 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2235.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2235.java @@ -2,7 +2,7 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; import com.vaadin.ui.AbstractOrderedLayout; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TextArea; public class Ticket2235 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2240.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2240.java index c777d0772f..bb16a40cd7 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2240.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2240.java @@ -4,7 +4,7 @@ import com.vaadin.Application; import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.ui.AbstractOrderedLayout; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TextField; public class Ticket2240 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2242.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2242.java index 4b44ed1a87..77fbfefe1a 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2242.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2242.java @@ -10,7 +10,7 @@ import com.vaadin.ui.AbstractOrderedLayout; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Table; public class Ticket2242 extends Application.LegacyApplication implements diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2244.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2244.java index a360760039..495e3de26a 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2244.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2244.java @@ -8,7 +8,7 @@ import com.vaadin.ui.Form; import com.vaadin.ui.FormLayout; import com.vaadin.ui.GridLayout; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class Ticket2244 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2245.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2245.java index 1586a1966b..ab474fe6f7 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2245.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2245.java @@ -2,7 +2,7 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; import com.vaadin.ui.HorizontalSplitPanel; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class Ticket2245 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2267.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2267.java index b5d6772e7f..41843a9742 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2267.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2267.java @@ -6,7 +6,7 @@ import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.GridLayout; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class Ticket2267 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2271.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2271.java index fb281f22b2..91fb51034b 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2271.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2271.java @@ -4,7 +4,7 @@ import com.vaadin.Application; import com.vaadin.ui.AbstractOrderedLayout; import com.vaadin.ui.Button; import com.vaadin.ui.ComboBox; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.VerticalLayout; public class Ticket2271 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2282.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2282.java index c72b4e15ff..976b06fe32 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2282.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2282.java @@ -5,7 +5,7 @@ import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.FormLayout; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class Ticket2282 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2283.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2283.java index 8375ca648f..5576e48fba 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2283.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2283.java @@ -4,7 +4,7 @@ import com.vaadin.Application; import com.vaadin.ui.Alignment; import com.vaadin.ui.GridLayout; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class Ticket2283 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2287.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2287.java index 716c8af0db..59fc174215 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2287.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2287.java @@ -4,7 +4,7 @@ import java.net.URL; import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class Ticket2287 extends Ticket2292 { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2289.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2289.java index 0ad023450c..c715fafd74 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2289.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2289.java @@ -7,7 +7,7 @@ import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.CustomComponent; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TabSheet; import com.vaadin.ui.VerticalLayout; diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2292.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2292.java index 35e9b8f2c5..e732ea09e0 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2292.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2292.java @@ -19,7 +19,7 @@ import com.vaadin.ui.Button; import com.vaadin.ui.CheckBox; import com.vaadin.ui.Label; import com.vaadin.ui.Link; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class Ticket2292 extends com.vaadin.Application.LegacyApplication implements RequestHandler { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2294.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2294.java index 30392a245d..053534191b 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2294.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2294.java @@ -4,7 +4,7 @@ import com.vaadin.Application; import com.vaadin.ui.AbstractOrderedLayout; import com.vaadin.ui.Alignment; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class Ticket2294 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2296.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2296.java index 31ff4a8353..d059b96953 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2296.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2296.java @@ -3,7 +3,7 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; import com.vaadin.ui.Button; import com.vaadin.ui.CustomLayout; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class Ticket2296 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2297.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2297.java index 1d1f0f1d74..073126ae07 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2297.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2297.java @@ -6,7 +6,7 @@ import java.net.URL; import com.vaadin.ui.CustomLayout; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class Ticket2297 extends Ticket2292 { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2303.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2303.java index bc11a7ea49..fb1c5440ad 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2303.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2303.java @@ -6,7 +6,7 @@ import java.io.IOException; import com.vaadin.Application; import com.vaadin.ui.CustomLayout; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.VerticalLayout; public class Ticket2303 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2304.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2304.java index b767b3661f..ccef7a9a92 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2304.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2304.java @@ -4,7 +4,7 @@ import com.vaadin.Application; import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.ui.Label; import com.vaadin.ui.Panel; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.themes.Reindeer; public class Ticket2304 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2310.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2310.java index 1cad5bde4f..24fbd7a968 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2310.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2310.java @@ -5,7 +5,7 @@ import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Label; import com.vaadin.ui.Panel; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.themes.Reindeer; public class Ticket2310 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2319.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2319.java index ec6d3be801..438d2ff286 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2319.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2319.java @@ -6,7 +6,7 @@ import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.HorizontalSplitPanel; import com.vaadin.ui.Label; import com.vaadin.ui.Panel; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.VerticalSplitPanel; diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2323.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2323.java index 123c154e61..d7b8db86bd 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2323.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2323.java @@ -2,7 +2,7 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; import com.vaadin.ui.RichTextArea; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Window; public class Ticket2323 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2325.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2325.java index c253eb70e6..ecc897d4ba 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2325.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2325.java @@ -1,7 +1,7 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TextArea; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2329.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2329.java index f583a4af4b..2ce42376f9 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2329.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2329.java @@ -3,7 +3,7 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; import com.vaadin.ui.Button; import com.vaadin.ui.Component; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Table; import com.vaadin.ui.Table.ColumnGenerator; import com.vaadin.ui.VerticalLayout; diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2337.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2337.java index f0cae1a59f..3ac381b2d1 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2337.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2337.java @@ -5,7 +5,7 @@ import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.GridLayout; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class Ticket2337 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2339.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2339.java index 81dc3af40f..ce884bada7 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2339.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2339.java @@ -6,7 +6,7 @@ import java.io.IOException; import com.vaadin.Application; import com.vaadin.ui.Button; import com.vaadin.ui.CustomLayout; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class Ticket2339 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2341.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2341.java index a35c27962f..aa2eefcb7e 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2341.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2341.java @@ -3,7 +3,7 @@ package com.vaadin.tests.tickets; import com.vaadin.data.Item; import com.vaadin.ui.Label; import com.vaadin.ui.Layout; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Table; public class Ticket2341 extends com.vaadin.Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2344.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2344.java index d7b1eacd2c..befad78a73 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2344.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2344.java @@ -4,7 +4,7 @@ import java.util.Random; import com.vaadin.Application; import com.vaadin.ui.Button; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Table; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.themes.BaseTheme; diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2347.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2347.java index 5528dfebd6..582b9a95ee 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2347.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2347.java @@ -5,7 +5,7 @@ import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.CustomLayout; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.VerticalLayout; public class Ticket2347 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2364.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2364.java index 8039609339..f7d6f61110 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2364.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2364.java @@ -2,7 +2,7 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; import com.vaadin.ui.Form; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Select; import com.vaadin.ui.VerticalLayout; diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2365.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2365.java index 252406cc2d..b191901356 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2365.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2365.java @@ -4,7 +4,7 @@ import com.vaadin.Application; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Panel; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.VerticalLayout; public class Ticket2365 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2398.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2398.java index 054cc5f0cc..f5b68800e6 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2398.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2398.java @@ -3,7 +3,7 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; import com.vaadin.data.util.IndexedContainer; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Table; public class Ticket2398 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2404.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2404.java index 0da70301d1..30f9d04d3b 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2404.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2404.java @@ -3,7 +3,7 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; import com.vaadin.ui.Button; import com.vaadin.ui.GridLayout; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class Ticket2404 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2405.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2405.java index c5ef9ec0b0..a76f3a711f 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2405.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2405.java @@ -9,7 +9,7 @@ import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.HorizontalSplitPanel; import com.vaadin.ui.Label; import com.vaadin.ui.Layout.MarginHandler; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2406.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2406.java index 0036bdc7b2..dd42727591 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2406.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2406.java @@ -4,7 +4,7 @@ import com.vaadin.Application; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2407.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2407.java index 51ab08188e..df2ae47acd 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2407.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2407.java @@ -1,7 +1,7 @@ package com.vaadin.tests.tickets; import com.vaadin.ui.Form; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2411.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2411.java index 6801bfa88d..2c59493e0c 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2411.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2411.java @@ -3,7 +3,7 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; import com.vaadin.ui.Button; import com.vaadin.ui.GridLayout; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class Ticket2411 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2415.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2415.java index 509f4cf437..f52c1b1ccc 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2415.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2415.java @@ -3,7 +3,7 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; import com.vaadin.data.Property; import com.vaadin.data.Property.ValueChangeEvent; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TextField; public class Ticket2415 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2420.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2420.java index adca729c9e..5d15107053 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2420.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2420.java @@ -2,7 +2,7 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; import com.vaadin.ui.ProgressIndicator; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class Ticket2420 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2425.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2425.java index 8c9be295a0..140fa6f2b6 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2425.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2425.java @@ -3,7 +3,7 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; import com.vaadin.ui.Label; import com.vaadin.ui.Panel; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TabSheet; public class Ticket2425 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2426.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2426.java index 40862e3ccd..fee74b73f7 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2426.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2426.java @@ -3,7 +3,7 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class Ticket2426 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2431.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2431.java index f6e6c1e7b5..cb9eb449bf 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2431.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2431.java @@ -7,7 +7,7 @@ import com.vaadin.event.ShortcutAction; import com.vaadin.event.ShortcutAction.KeyCode; import com.vaadin.event.ShortcutAction.ModifierKey; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class Ticket2431 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2432.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2432.java index 2716038873..f21e6a6752 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2432.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2432.java @@ -8,7 +8,7 @@ import com.vaadin.ui.Label; import com.vaadin.ui.Layout; import com.vaadin.ui.Layout.AlignmentHandler; import com.vaadin.ui.Layout.SpacingHandler; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class Ticket2432 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2434.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2434.java index 79e383393f..6401a98763 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2434.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2434.java @@ -2,7 +2,7 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; import com.vaadin.tests.TestForTablesInitialColumnWidthLogicRendering; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Table; public class Ticket2434 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2436.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2436.java index f48cf7a79a..5367c24b01 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2436.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2436.java @@ -4,7 +4,7 @@ import com.vaadin.Application; import com.vaadin.ui.Button; import com.vaadin.ui.Component; import com.vaadin.ui.PopupView; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class Ticket2436 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2526.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2526.java index 97d096405e..998fe75f8c 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2526.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2526.java @@ -3,7 +3,7 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Window; public class Ticket2526 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2742.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2742.java index 1003ea1c66..733f6ac6f6 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2742.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2742.java @@ -6,7 +6,7 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.NativeSelect; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; /** * @author Risto Yrjänä / Vaadin Ltd. diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2901.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2901.java index ab808501f7..c4352abefe 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2901.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2901.java @@ -2,7 +2,7 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.VerticalSplitPanel; diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket2998.java b/tests/testbench/com/vaadin/tests/tickets/Ticket2998.java index 2d2970d36e..0cd43533fd 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket2998.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket2998.java @@ -23,7 +23,7 @@ import com.vaadin.ui.Layout.MarginHandler; import com.vaadin.ui.ListSelect; import com.vaadin.ui.Notification; import com.vaadin.ui.Panel; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Table; import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket3146.java b/tests/testbench/com/vaadin/tests/tickets/Ticket3146.java index b6e01d912f..7973ffa496 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket3146.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket3146.java @@ -6,7 +6,7 @@ import java.util.HashSet; import com.vaadin.Application; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Table; import com.vaadin.ui.TextField; diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket34.java b/tests/testbench/com/vaadin/tests/tickets/Ticket34.java index e3b90c94b0..15d55ba643 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket34.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket34.java @@ -11,7 +11,7 @@ import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Component; import com.vaadin.ui.Label; import com.vaadin.ui.Panel; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket5053.java b/tests/testbench/com/vaadin/tests/tickets/Ticket5053.java index 35f244e07f..6f8ade15c4 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket5053.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket5053.java @@ -2,7 +2,7 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; import com.vaadin.ui.ComboBox; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; /** * #5053: Last ComboBox item may not be shown if null selection enabled diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket5157.java b/tests/testbench/com/vaadin/tests/tickets/Ticket5157.java index 5902382d01..3102a0a56c 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket5157.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket5157.java @@ -5,7 +5,7 @@ import com.vaadin.event.ShortcutAction.KeyCode; import com.vaadin.event.ShortcutListener; import com.vaadin.ui.Label; import com.vaadin.ui.Panel; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TextField; /** diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket5952.java b/tests/testbench/com/vaadin/tests/tickets/Ticket5952.java index b7caa08b82..92cd0290d6 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket5952.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket5952.java @@ -3,7 +3,7 @@ package com.vaadin.tests.tickets; import com.vaadin.Application; import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class Ticket5952 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket6002.java b/tests/testbench/com/vaadin/tests/tickets/Ticket6002.java index fef7061516..887652aee7 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket6002.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket6002.java @@ -5,7 +5,7 @@ import com.vaadin.data.Property.ValueChangeEvent; import com.vaadin.data.util.ObjectProperty; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket677.java b/tests/testbench/com/vaadin/tests/tickets/Ticket677.java index ca55b8648c..1c66f67ca1 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket677.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket677.java @@ -17,7 +17,7 @@ import com.vaadin.ui.GridLayout; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.ui.Panel; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Table; import com.vaadin.ui.TextField; diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket695.java b/tests/testbench/com/vaadin/tests/tickets/Ticket695.java index c62cee038c..e539f999b3 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket695.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket695.java @@ -7,7 +7,7 @@ import java.io.ObjectOutputStream; import com.vaadin.Application; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; @SuppressWarnings("serial") public class Ticket695 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket736.java b/tests/testbench/com/vaadin/tests/tickets/Ticket736.java index d871c8adc4..1176e87bb4 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket736.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket736.java @@ -15,7 +15,7 @@ import com.vaadin.ui.CheckBox; import com.vaadin.ui.Form; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Panel; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; public class Ticket736 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket8291.java b/tests/testbench/com/vaadin/tests/tickets/Ticket8291.java index 2f094f0bf8..24a98d42e3 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket8291.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket8291.java @@ -11,14 +11,14 @@ import com.vaadin.terminal.WrappedRequest; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.HorizontalLayout; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; import com.vaadin.ui.Table; /** * Test for #8291 and #7666: NegativeArraySizeException when Table scrolled to * the end and its size reduced. */ -public class Ticket8291 extends Root { +public class Ticket8291 extends UI { @Override public void init(WrappedRequest request) { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket846.java b/tests/testbench/com/vaadin/tests/tickets/Ticket846.java index 413d823d2d..407663c6c6 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket846.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket846.java @@ -5,7 +5,7 @@ import com.vaadin.data.util.MethodProperty; import com.vaadin.data.validator.IntegerValidator; import com.vaadin.ui.Button; import com.vaadin.ui.CheckBox; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TextField; public class Ticket846 extends Application.LegacyApplication { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket932.java b/tests/testbench/com/vaadin/tests/tickets/Ticket932.java index f72ff8beec..c12e2fcad3 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket932.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket932.java @@ -4,7 +4,7 @@ import com.vaadin.Application; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Label; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TextArea; import com.vaadin.ui.TextField; diff --git a/tests/testbench/com/vaadin/tests/util/SampleDirectory.java b/tests/testbench/com/vaadin/tests/util/SampleDirectory.java index 8f3f85a075..788415d0fd 100644 --- a/tests/testbench/com/vaadin/tests/util/SampleDirectory.java +++ b/tests/testbench/com/vaadin/tests/util/SampleDirectory.java @@ -23,7 +23,7 @@ import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.terminal.SystemError; import com.vaadin.ui.Label; import com.vaadin.ui.Panel; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; /** * Provides sample directory based on application directory. If this fails then @@ -41,7 +41,7 @@ public class SampleDirectory { * @param application * @return file pointing to sample directory */ - public static File getDirectory(Application application, Root root) { + public static File getDirectory(Application application, UI uI) { String errorMessage = "Access to application " + "context base directory failed, " + "possible security constraint with Application " @@ -79,9 +79,9 @@ public class SampleDirectory { "Cannot provide sample directory")); errorPanel.addComponent(new Label(errorMessage, ContentMode.XHTML)); // Remove all components from applications main window - root.getContent().removeAllComponents(); + uI.getContent().removeAllComponents(); // Add error panel - root.getContent().addComponent(errorPanel); + uI.getContent().addComponent(errorPanel); return null; } } diff --git a/tests/testbench/com/vaadin/tests/util/TestUtils.java b/tests/testbench/com/vaadin/tests/util/TestUtils.java index a9e1518c54..62f2cc0be3 100644 --- a/tests/testbench/com/vaadin/tests/util/TestUtils.java +++ b/tests/testbench/com/vaadin/tests/util/TestUtils.java @@ -2,7 +2,7 @@ package com.vaadin.tests.util; import com.vaadin.data.Item; import com.vaadin.data.util.IndexedContainer; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; public class TestUtils { @@ -102,7 +102,7 @@ public class TestUtils { * * @param cssString */ - public static void injectCSS(Root w, String cssString) { + public static void injectCSS(UI w, String cssString) { String script = "if ('\\v'=='v') /* ie only */ {\n" + " document.createStyleSheet().cssText = '" + cssString diff --git a/tests/testbench/com/vaadin/tests/vaadincontext/BootstrapModifyRoot.java b/tests/testbench/com/vaadin/tests/vaadincontext/BootstrapModifyRoot.java index 6c17c3005e..eefd37522b 100644 --- a/tests/testbench/com/vaadin/tests/vaadincontext/BootstrapModifyRoot.java +++ b/tests/testbench/com/vaadin/tests/vaadincontext/BootstrapModifyRoot.java @@ -29,7 +29,7 @@ public class BootstrapModifyRoot extends AbstractTestRoot { @Override protected String getTestDescription() { - return "There should be two additional divs in the HTML of the bootstrap page for this Root"; + return "There should be two additional divs in the HTML of the bootstrap page for this UI"; } @Override diff --git a/tests/testbench/com/vaadin/tests/vaadincontext/TestAddonContextListener.java b/tests/testbench/com/vaadin/tests/vaadincontext/TestAddonContextListener.java index da058892b4..a525d3139b 100644 --- a/tests/testbench/com/vaadin/tests/vaadincontext/TestAddonContextListener.java +++ b/tests/testbench/com/vaadin/tests/vaadincontext/TestAddonContextListener.java @@ -25,7 +25,7 @@ import com.vaadin.terminal.gwt.server.BootstrapPageResponse; import com.vaadin.terminal.gwt.server.BootstrapResponse; import com.vaadin.terminal.gwt.server.AddonContextEvent; import com.vaadin.terminal.gwt.server.AddonContextListener; -import com.vaadin.ui.Root; +import com.vaadin.ui.UI; public class TestAddonContextListener implements AddonContextListener { @Override @@ -42,9 +42,9 @@ public class TestAddonContextListener implements AddonContextListener { } private boolean shouldModify(BootstrapResponse response) { - Root root = response.getRoot(); - boolean shouldModify = root != null - && root.getClass() == BootstrapModifyRoot.class; + UI uI = response.getRoot(); + boolean shouldModify = uI != null + && uI.getClass() == BootstrapModifyRoot.class; return shouldModify; } diff --git a/tests/testbench/com/vaadin/tests/validation/RequiredErrorMessage.java b/tests/testbench/com/vaadin/tests/validation/RequiredErrorMessage.java index 7b03bc7ec2..b63527ad60 100644 --- a/tests/testbench/com/vaadin/tests/validation/RequiredErrorMessage.java +++ b/tests/testbench/com/vaadin/tests/validation/RequiredErrorMessage.java @@ -2,7 +2,7 @@ package com.vaadin.tests.validation; import com.vaadin.tests.components.AbstractTestCase; import com.vaadin.ui.Form; -import com.vaadin.ui.Root.LegacyWindow; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; -- cgit v1.2.3 From 066491f708fd303c604b2bee7cbd46a8342f71bf Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Fri, 24 Aug 2012 08:52:20 +0300 Subject: Rename Root related classes and package to UI (#8908) Automatic renames in Eclipse of: - package com.vaadin.terminal.gwt.client.ui.root to .UI - RootConnector to UIConnector - RootServerRpc to UIServerRpc - RootState to UIState - VRoot to VUI - RootRequiresMoreInformationException to UIRequiresMoreInformationException --- .../gwt/widgetsetutils/WidgetMapGenerator.java | 4 +- .../terminal/gwt/client/ApplicationConnection.java | 34 +- .../terminal/gwt/client/ComponentLocator.java | 4 +- .../vaadin/terminal/gwt/client/VDebugConsole.java | 4 +- .../gwt/client/ui/AbstractComponentConnector.java | 6 +- .../terminal/gwt/client/ui/UI/UIConnector.java | 457 ++++++++++++++++++++ .../com/vaadin/terminal/gwt/client/ui/UI/VUI.java | 459 +++++++++++++++++++++ .../terminal/gwt/client/ui/root/RootConnector.java | 457 -------------------- .../vaadin/terminal/gwt/client/ui/root/VRoot.java | 459 --------------------- server/src/com/vaadin/Application.java | 18 +- .../RootRequiresMoreInformationException.java | 37 -- .../vaadin/UIRequiresMoreInformationException.java | 37 ++ .../com/vaadin/terminal/DefaultRootProvider.java | 4 +- server/src/com/vaadin/terminal/RootProvider.java | 4 +- server/src/com/vaadin/terminal/WrappedRequest.java | 4 +- .../gwt/server/AbstractApplicationPortlet.java | 4 +- .../gwt/server/AbstractCommunicationManager.java | 4 +- .../terminal/gwt/server/BootstrapHandler.java | 4 +- .../terminal/gwt/server/BootstrapResponse.java | 4 +- server/src/com/vaadin/ui/UI.java | 14 +- .../com/vaadin/shared/ui/root/RootServerRpc.java | 26 -- .../src/com/vaadin/shared/ui/root/RootState.java | 32 -- .../src/com/vaadin/shared/ui/root/UIServerRpc.java | 26 ++ shared/src/com/vaadin/shared/ui/root/UIState.java | 32 ++ .../component/root/CustomRootClassLoader.java | 4 +- .../vaadin/launcher/ApplicationRunnerServlet.java | 4 +- .../tests/application/RefreshStatePreserve.java | 4 +- .../tests/application/ThreadLocalInstances.java | 4 +- .../tests/components/root/LazyInitRoots.java | 6 +- .../tests/components/root/RootsInMultipleTabs.java | 4 +- .../v7a1/DifferentFeaturesForDifferentClients.java | 6 +- 31 files changed, 1083 insertions(+), 1083 deletions(-) create mode 100644 client/src/com/vaadin/terminal/gwt/client/ui/UI/UIConnector.java create mode 100644 client/src/com/vaadin/terminal/gwt/client/ui/UI/VUI.java delete mode 100644 client/src/com/vaadin/terminal/gwt/client/ui/root/RootConnector.java delete mode 100644 client/src/com/vaadin/terminal/gwt/client/ui/root/VRoot.java delete mode 100644 server/src/com/vaadin/RootRequiresMoreInformationException.java create mode 100644 server/src/com/vaadin/UIRequiresMoreInformationException.java delete mode 100644 shared/src/com/vaadin/shared/ui/root/RootServerRpc.java delete mode 100644 shared/src/com/vaadin/shared/ui/root/RootState.java create mode 100644 shared/src/com/vaadin/shared/ui/root/UIServerRpc.java create mode 100644 shared/src/com/vaadin/shared/ui/root/UIState.java diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/WidgetMapGenerator.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/WidgetMapGenerator.java index 1f5b301802..99f3a1d17b 100644 --- a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/WidgetMapGenerator.java +++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/WidgetMapGenerator.java @@ -40,7 +40,7 @@ import com.vaadin.shared.ui.Connect; import com.vaadin.shared.ui.Connect.LoadStyle; import com.vaadin.terminal.gwt.client.ServerConnector; import com.vaadin.terminal.gwt.client.ui.UnknownComponentConnector; -import com.vaadin.terminal.gwt.client.ui.root.RootConnector; +import com.vaadin.terminal.gwt.client.ui.UI.UIConnector; import com.vaadin.terminal.gwt.server.ClientConnector; /** @@ -284,7 +284,7 @@ public class WidgetMapGenerator extends Generator { if (connectorsWithInstantiator.contains(clientClass)) { continue; } - if (clientClass == RootConnector.class) { + if (clientClass == UIConnector.class) { // Roots are not instantiated by widgetset continue; } diff --git a/client/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java b/client/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java index 4e8871b8ac..44f52d3e7f 100644 --- a/client/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java +++ b/client/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java @@ -74,10 +74,10 @@ import com.vaadin.terminal.gwt.client.metadata.Type; import com.vaadin.terminal.gwt.client.metadata.TypeData; import com.vaadin.terminal.gwt.client.ui.AbstractComponentConnector; import com.vaadin.terminal.gwt.client.ui.VContextMenu; +import com.vaadin.terminal.gwt.client.ui.UI.UIConnector; import com.vaadin.terminal.gwt.client.ui.dd.VDragAndDropManager; import com.vaadin.terminal.gwt.client.ui.notification.VNotification; import com.vaadin.terminal.gwt.client.ui.notification.VNotification.HideEvent; -import com.vaadin.terminal.gwt.client.ui.root.RootConnector; import com.vaadin.terminal.gwt.client.ui.window.WindowConnector; /** @@ -156,7 +156,7 @@ public class ApplicationConnection { private Timer loadTimer3; private Element loadElement; - private final RootConnector rootConnector; + private final UIConnector uIConnector; protected boolean applicationRunning = false; @@ -211,7 +211,7 @@ public class ApplicationConnection { // Assuming UI data is eagerly loaded ConnectorBundleLoader.get().loadBundle( ConnectorBundleLoader.EAGER_BUNDLE_NAME, null); - rootConnector = GWT.create(RootConnector.class); + uIConnector = GWT.create(UIConnector.class); rpcManager = GWT.create(RpcManager.class); layoutManager = GWT.create(LayoutManager.class); layoutManager.setConnection(this); @@ -243,7 +243,7 @@ public class ApplicationConnection { initializeClientHooks(); - rootConnector.init(cnf.getRootPanelId(), this); + uIConnector.init(cnf.getRootPanelId(), this); showLoadingIndicator(); } @@ -909,7 +909,7 @@ public class ApplicationConnection { if (loadElement == null) { loadElement = DOM.createDiv(); DOM.setStyleAttribute(loadElement, "position", "absolute"); - DOM.appendChild(rootConnector.getWidget().getElement(), loadElement); + DOM.appendChild(uIConnector.getWidget().getElement(), loadElement); VConsole.log("inserting load indicator"); } DOM.setElementProperty(loadElement, "className", "v-loading-indicator"); @@ -1093,7 +1093,7 @@ public class ApplicationConnection { meta = json.getValueMap("meta"); if (meta.containsKey("repaintAll")) { repaintAll = true; - rootConnector.getWidget().clear(); + uIConnector.getWidget().clear(); getConnectorMap().clear(); if (meta.containsKey("invalidLayouts")) { validatingLayouts = true; @@ -1361,17 +1361,17 @@ public class ApplicationConnection { if (!c.getParent().getChildren().contains(c)) { VConsole.error("ERROR: Connector is connected to a parent but the parent does not contain the connector"); } - } else if ((c instanceof RootConnector && c == getRootConnector())) { - // RootConnector for this connection, leave as-is + } else if ((c instanceof UIConnector && c == getRootConnector())) { + // UIConnector for this connection, leave as-is } else if (c instanceof WindowConnector && getRootConnector().hasSubWindow( (WindowConnector) c)) { - // Sub window attached to this RootConnector, leave + // Sub window attached to this UIConnector, leave // as-is } else { // The connector has been detached from the // hierarchy, unregister it and any possible - // children. The RootConnector should never be + // children. The UIConnector should never be // unregistered even though it has no parent. connectorMap.unregisterConnector(c); unregistered++; @@ -1406,17 +1406,17 @@ public class ApplicationConnection { .getConnectorClassByEncodedTag(connectorType); // Connector does not exist so we must create it - if (connectorClass != RootConnector.class) { + if (connectorClass != UIConnector.class) { // create, initialize and register the paintable getConnector(connectorId, connectorType); } else { - // First RootConnector update. Before this the - // RootConnector has been created but not + // First UIConnector update. Before this the + // UIConnector has been created but not // initialized as the connector id has not been // known connectorMap.registerConnector(connectorId, - rootConnector); - rootConnector.doInit(connectorId, + uIConnector); + uIConnector.doInit(connectorId, ApplicationConnection.this); } } catch (final Throwable e) { @@ -2477,8 +2477,8 @@ public class ApplicationConnection { * * @return the main view */ - public RootConnector getRootConnector() { - return rootConnector; + public UIConnector getRootConnector() { + return uIConnector; } /** diff --git a/client/src/com/vaadin/terminal/gwt/client/ComponentLocator.java b/client/src/com/vaadin/terminal/gwt/client/ComponentLocator.java index 959f03e46d..f1a2b9b925 100644 --- a/client/src/com/vaadin/terminal/gwt/client/ComponentLocator.java +++ b/client/src/com/vaadin/terminal/gwt/client/ComponentLocator.java @@ -28,9 +28,9 @@ import com.vaadin.shared.ComponentState; import com.vaadin.shared.Connector; import com.vaadin.shared.communication.SharedState; import com.vaadin.terminal.gwt.client.ui.SubPartAware; +import com.vaadin.terminal.gwt.client.ui.UI.VUI; import com.vaadin.terminal.gwt.client.ui.gridlayout.VGridLayout; import com.vaadin.terminal.gwt.client.ui.orderedlayout.VMeasuringOrderedLayout; -import com.vaadin.terminal.gwt.client.ui.root.VRoot; import com.vaadin.terminal.gwt.client.ui.tabsheet.VTabsheetPanel; import com.vaadin.terminal.gwt.client.ui.window.VWindow; import com.vaadin.terminal.gwt.client.ui.window.WindowConnector; @@ -385,7 +385,7 @@ public class ComponentLocator { return null; } - if (w instanceof VRoot) { + if (w instanceof VUI) { return ""; } else if (w instanceof VWindow) { Connector windowConnector = ConnectorMap.get(client) diff --git a/client/src/com/vaadin/terminal/gwt/client/VDebugConsole.java b/client/src/com/vaadin/terminal/gwt/client/VDebugConsole.java index 1e2a3062f1..022171f2bb 100644 --- a/client/src/com/vaadin/terminal/gwt/client/VDebugConsole.java +++ b/client/src/com/vaadin/terminal/gwt/client/VDebugConsole.java @@ -70,8 +70,8 @@ import com.google.gwt.user.client.ui.Widget; import com.vaadin.shared.Version; import com.vaadin.terminal.gwt.client.ui.VLazyExecutor; import com.vaadin.terminal.gwt.client.ui.VOverlay; +import com.vaadin.terminal.gwt.client.ui.UI.UIConnector; import com.vaadin.terminal.gwt.client.ui.notification.VNotification; -import com.vaadin.terminal.gwt.client.ui.root.RootConnector; import com.vaadin.terminal.gwt.client.ui.window.WindowConnector; /** @@ -924,7 +924,7 @@ public class VDebugConsole extends VOverlay implements Console { } protected void dumpConnectorInfo(ApplicationConnection a) { - RootConnector root = a.getRootConnector(); + UIConnector root = a.getRootConnector(); log("================"); log("Connector hierarchy for Root: " + root.getState().getCaption() + " (" + root.getConnectorId() + ")"); diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/AbstractComponentConnector.java b/client/src/com/vaadin/terminal/gwt/client/ui/AbstractComponentConnector.java index faded22260..f36107e947 100644 --- a/client/src/com/vaadin/terminal/gwt/client/ui/AbstractComponentConnector.java +++ b/client/src/com/vaadin/terminal/gwt/client/ui/AbstractComponentConnector.java @@ -40,8 +40,8 @@ import com.vaadin.terminal.gwt.client.communication.StateChangeEvent; import com.vaadin.terminal.gwt.client.metadata.NoDataException; import com.vaadin.terminal.gwt.client.metadata.Type; import com.vaadin.terminal.gwt.client.metadata.TypeData; +import com.vaadin.terminal.gwt.client.ui.UI.UIConnector; import com.vaadin.terminal.gwt.client.ui.datefield.PopupDateFieldConnector; -import com.vaadin.terminal.gwt.client.ui.root.RootConnector; public abstract class AbstractComponentConnector extends AbstractConnector implements ComponentConnector { @@ -151,7 +151,7 @@ public abstract class AbstractComponentConnector extends AbstractConnector ServerConnector parent = getParent(); if (parent instanceof ComponentContainerConnector) { ((ComponentContainerConnector) parent).updateCaption(this); - } else if (parent == null && !(this instanceof RootConnector)) { + } else if (parent == null && !(this instanceof UIConnector)) { VConsole.error("Parent of connector " + Util.getConnectorString(this) + " is null. This is typically an indication of a broken component hierarchy"); @@ -181,7 +181,7 @@ public abstract class AbstractComponentConnector extends AbstractConnector ServerConnector parent = getParent(); if (parent instanceof ComponentContainerConnector) { ((ComponentContainerConnector) parent).updateCaption(this); - } else if (parent == null && !(this instanceof RootConnector)) { + } else if (parent == null && !(this instanceof UIConnector)) { VConsole.error("Parent of connector " + Util.getConnectorString(this) + " is null. This is typically an indication of a broken component hierarchy"); diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/UI/UIConnector.java b/client/src/com/vaadin/terminal/gwt/client/ui/UI/UIConnector.java new file mode 100644 index 0000000000..2fb48623fd --- /dev/null +++ b/client/src/com/vaadin/terminal/gwt/client/ui/UI/UIConnector.java @@ -0,0 +1,457 @@ +/* + * 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.terminal.gwt.client.ui.UI; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import com.google.gwt.core.client.Scheduler; +import com.google.gwt.dom.client.NativeEvent; +import com.google.gwt.dom.client.Style; +import com.google.gwt.dom.client.Style.Position; +import com.google.gwt.event.logical.shared.ResizeEvent; +import com.google.gwt.event.logical.shared.ResizeHandler; +import com.google.gwt.user.client.Command; +import com.google.gwt.user.client.DOM; +import com.google.gwt.user.client.Event; +import com.google.gwt.user.client.History; +import com.google.gwt.user.client.Window; +import com.google.gwt.user.client.ui.RootPanel; +import com.google.gwt.user.client.ui.Widget; +import com.google.web.bindery.event.shared.HandlerRegistration; +import com.vaadin.shared.MouseEventDetails; +import com.vaadin.shared.ui.Connect; +import com.vaadin.shared.ui.Connect.LoadStyle; +import com.vaadin.shared.ui.root.PageClientRpc; +import com.vaadin.shared.ui.root.RootConstants; +import com.vaadin.shared.ui.root.UIServerRpc; +import com.vaadin.shared.ui.root.UIState; +import com.vaadin.terminal.gwt.client.ApplicationConnection; +import com.vaadin.terminal.gwt.client.BrowserInfo; +import com.vaadin.terminal.gwt.client.ComponentConnector; +import com.vaadin.terminal.gwt.client.ConnectorHierarchyChangeEvent; +import com.vaadin.terminal.gwt.client.ConnectorMap; +import com.vaadin.terminal.gwt.client.Focusable; +import com.vaadin.terminal.gwt.client.Paintable; +import com.vaadin.terminal.gwt.client.UIDL; +import com.vaadin.terminal.gwt.client.VConsole; +import com.vaadin.terminal.gwt.client.communication.RpcProxy; +import com.vaadin.terminal.gwt.client.communication.StateChangeEvent; +import com.vaadin.terminal.gwt.client.communication.StateChangeEvent.StateChangeHandler; +import com.vaadin.terminal.gwt.client.ui.AbstractComponentContainerConnector; +import com.vaadin.terminal.gwt.client.ui.ClickEventHandler; +import com.vaadin.terminal.gwt.client.ui.ShortcutActionHandler; +import com.vaadin.terminal.gwt.client.ui.layout.MayScrollChildren; +import com.vaadin.terminal.gwt.client.ui.notification.VNotification; +import com.vaadin.terminal.gwt.client.ui.window.WindowConnector; +import com.vaadin.ui.UI; + +@Connect(value = UI.class, loadStyle = LoadStyle.EAGER) +public class UIConnector extends AbstractComponentContainerConnector + implements Paintable, MayScrollChildren { + + private UIServerRpc rpc = RpcProxy.create(UIServerRpc.class, this); + + private HandlerRegistration childStateChangeHandlerRegistration; + + private final StateChangeHandler childStateChangeHandler = new StateChangeHandler() { + @Override + public void onStateChanged(StateChangeEvent stateChangeEvent) { + // TODO Should use a more specific handler that only reacts to + // size changes + onChildSizeChange(); + } + }; + + @Override + protected void init() { + super.init(); + registerRpc(PageClientRpc.class, new PageClientRpc() { + @Override + public void setTitle(String title) { + com.google.gwt.user.client.Window.setTitle(title); + } + }); + getWidget().addResizeHandler(new ResizeHandler() { + @Override + public void onResize(ResizeEvent event) { + rpc.resize(event.getHeight(), event.getWidth(), + Window.getClientWidth(), Window.getClientHeight()); + if (getState().isImmediate()) { + getConnection().sendPendingVariableChanges(); + } + } + }); + } + + @Override + public void updateFromUIDL(final UIDL uidl, ApplicationConnection client) { + ConnectorMap paintableMap = ConnectorMap.get(getConnection()); + getWidget().rendering = true; + getWidget().id = getConnectorId(); + boolean firstPaint = getWidget().connection == null; + getWidget().connection = client; + + getWidget().immediate = getState().isImmediate(); + getWidget().resizeLazy = uidl.hasAttribute(RootConstants.RESIZE_LAZY); + String newTheme = uidl.getStringAttribute("theme"); + if (getWidget().theme != null && !newTheme.equals(getWidget().theme)) { + // Complete page refresh is needed due css can affect layout + // calculations etc + getWidget().reloadHostPage(); + } else { + getWidget().theme = newTheme; + } + // this also implicitly removes old styles + String styles = ""; + styles += getWidget().getStylePrimaryName() + " "; + if (getState().hasStyles()) { + for (String style : getState().getStyles()) { + styles += style + " "; + } + } + if (!client.getConfiguration().isStandalone()) { + styles += getWidget().getStylePrimaryName() + "-embedded"; + } + getWidget().setStyleName(styles.trim()); + + getWidget().makeScrollable(); + + clickEventHandler.handleEventHandlerRegistration(); + + // Process children + int childIndex = 0; + + // Open URL:s + boolean isClosed = false; // was this window closed? + while (childIndex < uidl.getChildCount() + && "open".equals(uidl.getChildUIDL(childIndex).getTag())) { + final UIDL open = uidl.getChildUIDL(childIndex); + final String url = client.translateVaadinUri(open + .getStringAttribute("src")); + final String target = open.getStringAttribute("name"); + if (target == null) { + // source will be opened to this browser window, but we may have + // to finish rendering this window in case this is a download + // (and window stays open). + Scheduler.get().scheduleDeferred(new Command() { + @Override + public void execute() { + VUI.goTo(url); + } + }); + } else if ("_self".equals(target)) { + // This window is closing (for sure). Only other opens are + // relevant in this change. See #3558, #2144 + isClosed = true; + VUI.goTo(url); + } else { + String options; + if (open.hasAttribute("border")) { + if (open.getStringAttribute("border").equals("minimal")) { + options = "menubar=yes,location=no,status=no"; + } else { + options = "menubar=no,location=no,status=no"; + } + + } else { + options = "resizable=yes,menubar=yes,toolbar=yes,directories=yes,location=yes,scrollbars=yes,status=yes"; + } + + if (open.hasAttribute("width")) { + int w = open.getIntAttribute("width"); + options += ",width=" + w; + } + if (open.hasAttribute("height")) { + int h = open.getIntAttribute("height"); + options += ",height=" + h; + } + + Window.open(url, target, options); + } + childIndex++; + } + if (isClosed) { + // don't render the content, something else will be opened to this + // browser view + getWidget().rendering = false; + return; + } + + // Handle other UIDL children + UIDL childUidl; + while ((childUidl = uidl.getChildUIDL(childIndex++)) != null) { + String tag = childUidl.getTag().intern(); + if (tag == "actions") { + if (getWidget().actionHandler == null) { + getWidget().actionHandler = new ShortcutActionHandler( + getWidget().id, client); + } + getWidget().actionHandler.updateActionMap(childUidl); + } else if (tag == "notifications") { + for (final Iterator it = childUidl.getChildIterator(); it + .hasNext();) { + final UIDL notification = (UIDL) it.next(); + VNotification.showNotification(client, notification); + } + } + } + + if (uidl.hasAttribute("focused")) { + // set focused component when render phase is finished + Scheduler.get().scheduleDeferred(new Command() { + @Override + public void execute() { + ComponentConnector paintable = (ComponentConnector) uidl + .getPaintableAttribute("focused", getConnection()); + + final Widget toBeFocused = paintable.getWidget(); + /* + * Two types of Widgets can be focused, either implementing + * GWT HasFocus of a thinner Vaadin specific Focusable + * interface. + */ + if (toBeFocused instanceof com.google.gwt.user.client.ui.Focusable) { + final com.google.gwt.user.client.ui.Focusable toBeFocusedWidget = (com.google.gwt.user.client.ui.Focusable) toBeFocused; + toBeFocusedWidget.setFocus(true); + } else if (toBeFocused instanceof Focusable) { + ((Focusable) toBeFocused).focus(); + } else { + VConsole.log("Could not focus component"); + } + } + }); + } + + // Add window listeners on first paint, to prevent premature + // variablechanges + if (firstPaint) { + Window.addWindowClosingHandler(getWidget()); + Window.addResizeHandler(getWidget()); + } + + // finally set scroll position from UIDL + if (uidl.hasVariable("scrollTop")) { + getWidget().scrollable = true; + getWidget().scrollTop = uidl.getIntVariable("scrollTop"); + DOM.setElementPropertyInt(getWidget().getElement(), "scrollTop", + getWidget().scrollTop); + getWidget().scrollLeft = uidl.getIntVariable("scrollLeft"); + DOM.setElementPropertyInt(getWidget().getElement(), "scrollLeft", + getWidget().scrollLeft); + } else { + getWidget().scrollable = false; + } + + if (uidl.hasAttribute("scrollTo")) { + final ComponentConnector connector = (ComponentConnector) uidl + .getPaintableAttribute("scrollTo", getConnection()); + scrollIntoView(connector); + } + + if (uidl.hasAttribute(RootConstants.FRAGMENT_VARIABLE)) { + getWidget().currentFragment = uidl + .getStringAttribute(RootConstants.FRAGMENT_VARIABLE); + if (!getWidget().currentFragment.equals(History.getToken())) { + History.newItem(getWidget().currentFragment, true); + } + } else { + // Initial request for which the server doesn't yet have a fragment + // (and haven't shown any interest in getting one) + getWidget().currentFragment = History.getToken(); + + // Include current fragment in the next request + client.updateVariable(getWidget().id, + RootConstants.FRAGMENT_VARIABLE, + getWidget().currentFragment, false); + } + + if (firstPaint) { + // Queue the initial window size to be sent with the following + // request. + getWidget().sendClientResized(); + } + getWidget().rendering = false; + } + + public void init(String rootPanelId, + ApplicationConnection applicationConnection) { + DOM.sinkEvents(getWidget().getElement(), Event.ONKEYDOWN + | Event.ONSCROLL); + + // iview is focused when created so element needs tabIndex + // 1 due 0 is at the end of natural tabbing order + DOM.setElementProperty(getWidget().getElement(), "tabIndex", "1"); + + RootPanel root = RootPanel.get(rootPanelId); + + // Remove the v-app-loading or any splash screen added inside the div by + // the user + root.getElement().setInnerHTML(""); + + root.addStyleName("v-theme-" + + applicationConnection.getConfiguration().getThemeName()); + + root.add(getWidget()); + + if (applicationConnection.getConfiguration().isStandalone()) { + // set focus to iview element by default to listen possible keyboard + // shortcuts. For embedded applications this is unacceptable as we + // don't want to steal focus from the main page nor we don't want + // side-effects from focusing (scrollIntoView). + getWidget().getElement().focus(); + } + } + + private ClickEventHandler clickEventHandler = new ClickEventHandler(this) { + + @Override + protected void fireClick(NativeEvent event, + MouseEventDetails mouseDetails) { + rpc.click(mouseDetails); + } + + }; + + @Override + public void updateCaption(ComponentConnector component) { + // NOP The main view never draws caption for its layout + } + + @Override + public VUI getWidget() { + return (VUI) super.getWidget(); + } + + protected ComponentConnector getContent() { + return (ComponentConnector) getState().getContent(); + } + + protected void onChildSizeChange() { + ComponentConnector child = getContent(); + Style childStyle = child.getWidget().getElement().getStyle(); + /* + * Must set absolute position if the child has relative height and + * there's a chance of horizontal scrolling as some browsers will + * otherwise not take the scrollbar into account when calculating the + * height. Assuming v-view does not have an undefined width for now, see + * #8460. + */ + if (child.isRelativeHeight() && !BrowserInfo.get().isIE9()) { + childStyle.setPosition(Position.ABSOLUTE); + } else { + childStyle.clearPosition(); + } + } + + /** + * Checks if the given sub window is a child of this UI Connector + * + * @deprecated Should be replaced by a more generic mechanism for getting + * non-ComponentConnector children + * @param wc + * @return + */ + @Deprecated + public boolean hasSubWindow(WindowConnector wc) { + return getChildComponents().contains(wc); + } + + /** + * Return an iterator for current subwindows. This method is meant for + * testing purposes only. + * + * @return + */ + public List getSubWindows() { + ArrayList windows = new ArrayList(); + for (ComponentConnector child : getChildComponents()) { + if (child instanceof WindowConnector) { + windows.add((WindowConnector) child); + } + } + return windows; + } + + @Override + public UIState getState() { + return (UIState) super.getState(); + } + + @Override + public void onConnectorHierarchyChange(ConnectorHierarchyChangeEvent event) { + super.onConnectorHierarchyChange(event); + + ComponentConnector oldChild = null; + ComponentConnector newChild = getContent(); + + for (ComponentConnector c : event.getOldChildren()) { + if (!(c instanceof WindowConnector)) { + oldChild = c; + break; + } + } + + if (oldChild != newChild) { + if (childStateChangeHandlerRegistration != null) { + childStateChangeHandlerRegistration.removeHandler(); + childStateChangeHandlerRegistration = null; + } + getWidget().setWidget(newChild.getWidget()); + childStateChangeHandlerRegistration = newChild + .addStateChangeHandler(childStateChangeHandler); + // Must handle new child here as state change events are already + // fired + onChildSizeChange(); + } + + for (ComponentConnector c : getChildComponents()) { + if (c instanceof WindowConnector) { + WindowConnector wc = (WindowConnector) c; + wc.setWindowOrderAndPosition(); + } + } + + // Close removed sub windows + for (ComponentConnector c : event.getOldChildren()) { + if (c.getParent() != this && c instanceof WindowConnector) { + ((WindowConnector) c).getWidget().hide(); + } + } + } + + /** + * Tries to scroll the viewport so that the given connector is in view. + * + * @param componentConnector + * The connector which should be visible + * + */ + public void scrollIntoView(final ComponentConnector componentConnector) { + if (componentConnector == null) { + return; + } + + Scheduler.get().scheduleDeferred(new Command() { + @Override + public void execute() { + componentConnector.getWidget().getElement().scrollIntoView(); + } + }); + } + +} diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/UI/VUI.java b/client/src/com/vaadin/terminal/gwt/client/ui/UI/VUI.java new file mode 100644 index 0000000000..cb6b181f1d --- /dev/null +++ b/client/src/com/vaadin/terminal/gwt/client/ui/UI/VUI.java @@ -0,0 +1,459 @@ +/* + * 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.terminal.gwt.client.ui.UI; + +import java.util.ArrayList; + +import com.google.gwt.core.client.Scheduler.ScheduledCommand; +import com.google.gwt.dom.client.Element; +import com.google.gwt.event.logical.shared.HasResizeHandlers; +import com.google.gwt.event.logical.shared.ResizeEvent; +import com.google.gwt.event.logical.shared.ResizeHandler; +import com.google.gwt.event.logical.shared.ValueChangeEvent; +import com.google.gwt.event.logical.shared.ValueChangeHandler; +import com.google.gwt.event.shared.HandlerRegistration; +import com.google.gwt.user.client.DOM; +import com.google.gwt.user.client.Event; +import com.google.gwt.user.client.History; +import com.google.gwt.user.client.Timer; +import com.google.gwt.user.client.Window; +import com.google.gwt.user.client.ui.SimplePanel; +import com.vaadin.shared.ApplicationConstants; +import com.vaadin.shared.ui.root.RootConstants; +import com.vaadin.terminal.gwt.client.ApplicationConnection; +import com.vaadin.terminal.gwt.client.BrowserInfo; +import com.vaadin.terminal.gwt.client.ComponentConnector; +import com.vaadin.terminal.gwt.client.ConnectorMap; +import com.vaadin.terminal.gwt.client.Focusable; +import com.vaadin.terminal.gwt.client.VConsole; +import com.vaadin.terminal.gwt.client.ui.ShortcutActionHandler; +import com.vaadin.terminal.gwt.client.ui.ShortcutActionHandler.ShortcutActionHandlerOwner; +import com.vaadin.terminal.gwt.client.ui.TouchScrollDelegate; +import com.vaadin.terminal.gwt.client.ui.TouchScrollDelegate.TouchScrollHandler; +import com.vaadin.terminal.gwt.client.ui.VLazyExecutor; +import com.vaadin.terminal.gwt.client.ui.textfield.VTextField; + +/** + * + */ +public class VUI extends SimplePanel implements ResizeHandler, + Window.ClosingHandler, ShortcutActionHandlerOwner, Focusable, + HasResizeHandlers { + + private static final String CLASSNAME = "v-view"; + + private static int MONITOR_PARENT_TIMER_INTERVAL = 1000; + + String theme; + + String id; + + ShortcutActionHandler actionHandler; + + /* + * Last known window size used to detect whether VView should be layouted + * again. Detection must check window size, because the VView size might be + * fixed and thus not automatically adapt to changed window sizes. + */ + private int windowWidth; + private int windowHeight; + + /* + * Last know view size used to detect whether new dimensions should be sent + * to the server. + */ + private int viewWidth; + private int viewHeight; + + ApplicationConnection connection; + + /** + * Keep track of possible parent size changes when an embedded application. + * + * Uses {@link #parentWidth} and {@link #parentHeight} as an optimization to + * keep track of when there is a real change. + */ + private Timer resizeTimer; + + /** stored width of parent for embedded application auto-resize */ + private int parentWidth; + + /** stored height of parent for embedded application auto-resize */ + private int parentHeight; + + int scrollTop; + + int scrollLeft; + + boolean rendering; + + boolean scrollable; + + boolean immediate; + + boolean resizeLazy = false; + + private HandlerRegistration historyHandlerRegistration; + + private TouchScrollHandler touchScrollHandler; + + /** + * The current URI fragment, used to avoid sending updates if nothing has + * changed. + */ + String currentFragment; + + /** + * Listener for URI fragment changes. Notifies the server of the new value + * whenever the value changes. + */ + private final ValueChangeHandler historyChangeHandler = new ValueChangeHandler() { + + @Override + public void onValueChange(ValueChangeEvent event) { + String newFragment = event.getValue(); + + // Send the new fragment to the server if it has changed + if (!newFragment.equals(currentFragment) && connection != null) { + currentFragment = newFragment; + connection.updateVariable(id, RootConstants.FRAGMENT_VARIABLE, + newFragment, true); + } + } + }; + + private VLazyExecutor delayedResizeExecutor = new VLazyExecutor(200, + new ScheduledCommand() { + + @Override + public void execute() { + performSizeCheck(); + } + + }); + + public VUI() { + super(); + setStyleName(CLASSNAME); + + // Allow focusing the view by using the focus() method, the view + // should not be in the document focus flow + getElement().setTabIndex(-1); + makeScrollable(); + } + + /** + * Start to periodically monitor for parent element resizes if embedded + * application (e.g. portlet). + */ + @Override + protected void onLoad() { + super.onLoad(); + if (isMonitoringParentSize()) { + resizeTimer = new Timer() { + + @Override + public void run() { + // trigger check to see if parent size has changed, + // recalculate layouts + performSizeCheck(); + resizeTimer.schedule(MONITOR_PARENT_TIMER_INTERVAL); + } + }; + resizeTimer.schedule(MONITOR_PARENT_TIMER_INTERVAL); + } + } + + @Override + protected void onAttach() { + super.onAttach(); + historyHandlerRegistration = History + .addValueChangeHandler(historyChangeHandler); + currentFragment = History.getToken(); + } + + @Override + protected void onDetach() { + super.onDetach(); + historyHandlerRegistration.removeHandler(); + historyHandlerRegistration = null; + } + + /** + * Stop monitoring for parent element resizes. + */ + + @Override + protected void onUnload() { + if (resizeTimer != null) { + resizeTimer.cancel(); + resizeTimer = null; + } + super.onUnload(); + } + + /** + * Called when the window or parent div might have been resized. + * + * This immediately checks the sizes of the window and the parent div (if + * monitoring it) and triggers layout recalculation if they have changed. + */ + protected void performSizeCheck() { + windowSizeMaybeChanged(Window.getClientWidth(), + Window.getClientHeight()); + } + + /** + * Called when the window or parent div might have been resized. + * + * This immediately checks the sizes of the window and the parent div (if + * monitoring it) and triggers layout recalculation if they have changed. + * + * @param newWindowWidth + * The new width of the window + * @param newWindowHeight + * The new height of the window + * + * @deprecated use {@link #performSizeCheck()} + */ + @Deprecated + protected void windowSizeMaybeChanged(int newWindowWidth, + int newWindowHeight) { + boolean changed = false; + ComponentConnector connector = ConnectorMap.get(connection) + .getConnector(this); + if (windowWidth != newWindowWidth) { + windowWidth = newWindowWidth; + changed = true; + connector.getLayoutManager().reportOuterWidth(connector, + newWindowWidth); + VConsole.log("New window width: " + windowWidth); + } + if (windowHeight != newWindowHeight) { + windowHeight = newWindowHeight; + changed = true; + connector.getLayoutManager().reportOuterHeight(connector, + newWindowHeight); + VConsole.log("New window height: " + windowHeight); + } + Element parentElement = getElement().getParentElement(); + if (isMonitoringParentSize() && parentElement != null) { + // check also for parent size changes + int newParentWidth = parentElement.getClientWidth(); + int newParentHeight = parentElement.getClientHeight(); + if (parentWidth != newParentWidth) { + parentWidth = newParentWidth; + changed = true; + VConsole.log("New parent width: " + parentWidth); + } + if (parentHeight != newParentHeight) { + parentHeight = newParentHeight; + changed = true; + VConsole.log("New parent height: " + parentHeight); + } + } + if (changed) { + /* + * If the window size has changed, layout the VView again and send + * new size to the server if the size changed. (Just checking VView + * size would cause us to ignore cases when a relatively sized VView + * should shrink as the content's size is fixed and would thus not + * automatically shrink.) + */ + VConsole.log("Running layout functions due to window or parent resize"); + + // update size to avoid (most) redundant re-layout passes + // there can still be an extra layout recalculation if webkit + // overflow fix updates the size in a deferred block + if (isMonitoringParentSize() && parentElement != null) { + parentWidth = parentElement.getClientWidth(); + parentHeight = parentElement.getClientHeight(); + } + + sendClientResized(); + + connector.getLayoutManager().layoutNow(); + } + } + + public String getTheme() { + return theme; + } + + /** + * Used to reload host page on theme changes. + */ + static native void reloadHostPage() + /*-{ + $wnd.location.reload(); + }-*/; + + /** + * Returns true if the body is NOT generated, i.e if someone else has made + * the page that we're running in. Otherwise we're in charge of the whole + * page. + * + * @return true if we're running embedded + */ + public boolean isEmbedded() { + return !getElement().getOwnerDocument().getBody().getClassName() + .contains(ApplicationConstants.GENERATED_BODY_CLASSNAME); + } + + /** + * Returns true if the size of the parent should be checked periodically and + * the application should react to its changes. + * + * @return true if size of parent should be tracked + */ + protected boolean isMonitoringParentSize() { + // could also perform a more specific check (Liferay portlet) + return isEmbedded(); + } + + @Override + public void onBrowserEvent(Event event) { + super.onBrowserEvent(event); + int type = DOM.eventGetType(event); + if (type == Event.ONKEYDOWN && actionHandler != null) { + actionHandler.handleKeyboardEvent(event); + return; + } else if (scrollable && type == Event.ONSCROLL) { + updateScrollPosition(); + } + } + + /** + * Updates scroll position from DOM and saves variables to server. + */ + private void updateScrollPosition() { + int oldTop = scrollTop; + int oldLeft = scrollLeft; + scrollTop = DOM.getElementPropertyInt(getElement(), "scrollTop"); + scrollLeft = DOM.getElementPropertyInt(getElement(), "scrollLeft"); + if (connection != null && !rendering) { + if (oldTop != scrollTop) { + connection.updateVariable(id, "scrollTop", scrollTop, false); + } + if (oldLeft != scrollLeft) { + connection.updateVariable(id, "scrollLeft", scrollLeft, false); + } + } + } + + /* + * (non-Javadoc) + * + * @see + * com.google.gwt.event.logical.shared.ResizeHandler#onResize(com.google + * .gwt.event.logical.shared.ResizeEvent) + */ + + @Override + public void onResize(ResizeEvent event) { + triggerSizeChangeCheck(); + } + + /** + * Called when a resize event is received. + * + * This may trigger a lazy refresh or perform the size check immediately + * depending on the browser used and whether the server side requests + * resizes to be lazy. + */ + private void triggerSizeChangeCheck() { + /* + * IE (pre IE9 at least) will give us some false resize events due to + * problems with scrollbars. Firefox 3 might also produce some extra + * events. We postpone both the re-layouting and the server side event + * for a while to deal with these issues. + * + * We may also postpone these events to avoid slowness when resizing the + * browser window. Constantly recalculating the layout causes the resize + * operation to be really slow with complex layouts. + */ + boolean lazy = resizeLazy || BrowserInfo.get().isIE8(); + + if (lazy) { + delayedResizeExecutor.trigger(); + } else { + performSizeCheck(); + } + } + + /** + * Send new dimensions to the server. + */ + void sendClientResized() { + Element parentElement = getElement().getParentElement(); + int viewHeight = parentElement.getClientHeight(); + int viewWidth = parentElement.getClientWidth(); + + ResizeEvent.fire(this, viewWidth, viewHeight); + } + + public native static void goTo(String url) + /*-{ + $wnd.location = url; + }-*/; + + @Override + public void onWindowClosing(Window.ClosingEvent event) { + // Change focus on this window in order to ensure that all state is + // collected from textfields + // TODO this is a naive hack, that only works with text fields and may + // cause some odd issues. Should be replaced with a decent solution, see + // also related BeforeShortcutActionListener interface. Same interface + // might be usable here. + VTextField.flushChangesFromFocusedTextField(); + } + + private native static void loadAppIdListFromDOM(ArrayList list) + /*-{ + var j; + for(j in $wnd.vaadin.vaadinConfigurations) { + // $entry not needed as function is not exported + list.@java.util.Collection::add(Ljava/lang/Object;)(j); + } + }-*/; + + @Override + public ShortcutActionHandler getShortcutActionHandler() { + return actionHandler; + } + + @Override + public void focus() { + getElement().focus(); + } + + /** + * Ensures the root is scrollable eg. after style name changes. + */ + void makeScrollable() { + if (touchScrollHandler == null) { + touchScrollHandler = TouchScrollDelegate.enableTouchScrolling(this); + } + touchScrollHandler.addElement(getElement()); + } + + @Override + public HandlerRegistration addResizeHandler(ResizeHandler resizeHandler) { + return addHandler(resizeHandler, ResizeEvent.getType()); + } + +} diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/root/RootConnector.java b/client/src/com/vaadin/terminal/gwt/client/ui/root/RootConnector.java deleted file mode 100644 index 3321b07146..0000000000 --- a/client/src/com/vaadin/terminal/gwt/client/ui/root/RootConnector.java +++ /dev/null @@ -1,457 +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.terminal.gwt.client.ui.root; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import com.google.gwt.core.client.Scheduler; -import com.google.gwt.dom.client.NativeEvent; -import com.google.gwt.dom.client.Style; -import com.google.gwt.dom.client.Style.Position; -import com.google.gwt.event.logical.shared.ResizeEvent; -import com.google.gwt.event.logical.shared.ResizeHandler; -import com.google.gwt.user.client.Command; -import com.google.gwt.user.client.DOM; -import com.google.gwt.user.client.Event; -import com.google.gwt.user.client.History; -import com.google.gwt.user.client.Window; -import com.google.gwt.user.client.ui.RootPanel; -import com.google.gwt.user.client.ui.Widget; -import com.google.web.bindery.event.shared.HandlerRegistration; -import com.vaadin.shared.MouseEventDetails; -import com.vaadin.shared.ui.Connect; -import com.vaadin.shared.ui.Connect.LoadStyle; -import com.vaadin.shared.ui.root.PageClientRpc; -import com.vaadin.shared.ui.root.RootConstants; -import com.vaadin.shared.ui.root.RootServerRpc; -import com.vaadin.shared.ui.root.RootState; -import com.vaadin.terminal.gwt.client.ApplicationConnection; -import com.vaadin.terminal.gwt.client.BrowserInfo; -import com.vaadin.terminal.gwt.client.ComponentConnector; -import com.vaadin.terminal.gwt.client.ConnectorHierarchyChangeEvent; -import com.vaadin.terminal.gwt.client.ConnectorMap; -import com.vaadin.terminal.gwt.client.Focusable; -import com.vaadin.terminal.gwt.client.Paintable; -import com.vaadin.terminal.gwt.client.UIDL; -import com.vaadin.terminal.gwt.client.VConsole; -import com.vaadin.terminal.gwt.client.communication.RpcProxy; -import com.vaadin.terminal.gwt.client.communication.StateChangeEvent; -import com.vaadin.terminal.gwt.client.communication.StateChangeEvent.StateChangeHandler; -import com.vaadin.terminal.gwt.client.ui.AbstractComponentContainerConnector; -import com.vaadin.terminal.gwt.client.ui.ClickEventHandler; -import com.vaadin.terminal.gwt.client.ui.ShortcutActionHandler; -import com.vaadin.terminal.gwt.client.ui.layout.MayScrollChildren; -import com.vaadin.terminal.gwt.client.ui.notification.VNotification; -import com.vaadin.terminal.gwt.client.ui.window.WindowConnector; -import com.vaadin.ui.UI; - -@Connect(value = UI.class, loadStyle = LoadStyle.EAGER) -public class RootConnector extends AbstractComponentContainerConnector - implements Paintable, MayScrollChildren { - - private RootServerRpc rpc = RpcProxy.create(RootServerRpc.class, this); - - private HandlerRegistration childStateChangeHandlerRegistration; - - private final StateChangeHandler childStateChangeHandler = new StateChangeHandler() { - @Override - public void onStateChanged(StateChangeEvent stateChangeEvent) { - // TODO Should use a more specific handler that only reacts to - // size changes - onChildSizeChange(); - } - }; - - @Override - protected void init() { - super.init(); - registerRpc(PageClientRpc.class, new PageClientRpc() { - @Override - public void setTitle(String title) { - com.google.gwt.user.client.Window.setTitle(title); - } - }); - getWidget().addResizeHandler(new ResizeHandler() { - @Override - public void onResize(ResizeEvent event) { - rpc.resize(event.getHeight(), event.getWidth(), - Window.getClientWidth(), Window.getClientHeight()); - if (getState().isImmediate()) { - getConnection().sendPendingVariableChanges(); - } - } - }); - } - - @Override - public void updateFromUIDL(final UIDL uidl, ApplicationConnection client) { - ConnectorMap paintableMap = ConnectorMap.get(getConnection()); - getWidget().rendering = true; - getWidget().id = getConnectorId(); - boolean firstPaint = getWidget().connection == null; - getWidget().connection = client; - - getWidget().immediate = getState().isImmediate(); - getWidget().resizeLazy = uidl.hasAttribute(RootConstants.RESIZE_LAZY); - String newTheme = uidl.getStringAttribute("theme"); - if (getWidget().theme != null && !newTheme.equals(getWidget().theme)) { - // Complete page refresh is needed due css can affect layout - // calculations etc - getWidget().reloadHostPage(); - } else { - getWidget().theme = newTheme; - } - // this also implicitly removes old styles - String styles = ""; - styles += getWidget().getStylePrimaryName() + " "; - if (getState().hasStyles()) { - for (String style : getState().getStyles()) { - styles += style + " "; - } - } - if (!client.getConfiguration().isStandalone()) { - styles += getWidget().getStylePrimaryName() + "-embedded"; - } - getWidget().setStyleName(styles.trim()); - - getWidget().makeScrollable(); - - clickEventHandler.handleEventHandlerRegistration(); - - // Process children - int childIndex = 0; - - // Open URL:s - boolean isClosed = false; // was this window closed? - while (childIndex < uidl.getChildCount() - && "open".equals(uidl.getChildUIDL(childIndex).getTag())) { - final UIDL open = uidl.getChildUIDL(childIndex); - final String url = client.translateVaadinUri(open - .getStringAttribute("src")); - final String target = open.getStringAttribute("name"); - if (target == null) { - // source will be opened to this browser window, but we may have - // to finish rendering this window in case this is a download - // (and window stays open). - Scheduler.get().scheduleDeferred(new Command() { - @Override - public void execute() { - VRoot.goTo(url); - } - }); - } else if ("_self".equals(target)) { - // This window is closing (for sure). Only other opens are - // relevant in this change. See #3558, #2144 - isClosed = true; - VRoot.goTo(url); - } else { - String options; - if (open.hasAttribute("border")) { - if (open.getStringAttribute("border").equals("minimal")) { - options = "menubar=yes,location=no,status=no"; - } else { - options = "menubar=no,location=no,status=no"; - } - - } else { - options = "resizable=yes,menubar=yes,toolbar=yes,directories=yes,location=yes,scrollbars=yes,status=yes"; - } - - if (open.hasAttribute("width")) { - int w = open.getIntAttribute("width"); - options += ",width=" + w; - } - if (open.hasAttribute("height")) { - int h = open.getIntAttribute("height"); - options += ",height=" + h; - } - - Window.open(url, target, options); - } - childIndex++; - } - if (isClosed) { - // don't render the content, something else will be opened to this - // browser view - getWidget().rendering = false; - return; - } - - // Handle other UIDL children - UIDL childUidl; - while ((childUidl = uidl.getChildUIDL(childIndex++)) != null) { - String tag = childUidl.getTag().intern(); - if (tag == "actions") { - if (getWidget().actionHandler == null) { - getWidget().actionHandler = new ShortcutActionHandler( - getWidget().id, client); - } - getWidget().actionHandler.updateActionMap(childUidl); - } else if (tag == "notifications") { - for (final Iterator it = childUidl.getChildIterator(); it - .hasNext();) { - final UIDL notification = (UIDL) it.next(); - VNotification.showNotification(client, notification); - } - } - } - - if (uidl.hasAttribute("focused")) { - // set focused component when render phase is finished - Scheduler.get().scheduleDeferred(new Command() { - @Override - public void execute() { - ComponentConnector paintable = (ComponentConnector) uidl - .getPaintableAttribute("focused", getConnection()); - - final Widget toBeFocused = paintable.getWidget(); - /* - * Two types of Widgets can be focused, either implementing - * GWT HasFocus of a thinner Vaadin specific Focusable - * interface. - */ - if (toBeFocused instanceof com.google.gwt.user.client.ui.Focusable) { - final com.google.gwt.user.client.ui.Focusable toBeFocusedWidget = (com.google.gwt.user.client.ui.Focusable) toBeFocused; - toBeFocusedWidget.setFocus(true); - } else if (toBeFocused instanceof Focusable) { - ((Focusable) toBeFocused).focus(); - } else { - VConsole.log("Could not focus component"); - } - } - }); - } - - // Add window listeners on first paint, to prevent premature - // variablechanges - if (firstPaint) { - Window.addWindowClosingHandler(getWidget()); - Window.addResizeHandler(getWidget()); - } - - // finally set scroll position from UIDL - if (uidl.hasVariable("scrollTop")) { - getWidget().scrollable = true; - getWidget().scrollTop = uidl.getIntVariable("scrollTop"); - DOM.setElementPropertyInt(getWidget().getElement(), "scrollTop", - getWidget().scrollTop); - getWidget().scrollLeft = uidl.getIntVariable("scrollLeft"); - DOM.setElementPropertyInt(getWidget().getElement(), "scrollLeft", - getWidget().scrollLeft); - } else { - getWidget().scrollable = false; - } - - if (uidl.hasAttribute("scrollTo")) { - final ComponentConnector connector = (ComponentConnector) uidl - .getPaintableAttribute("scrollTo", getConnection()); - scrollIntoView(connector); - } - - if (uidl.hasAttribute(RootConstants.FRAGMENT_VARIABLE)) { - getWidget().currentFragment = uidl - .getStringAttribute(RootConstants.FRAGMENT_VARIABLE); - if (!getWidget().currentFragment.equals(History.getToken())) { - History.newItem(getWidget().currentFragment, true); - } - } else { - // Initial request for which the server doesn't yet have a fragment - // (and haven't shown any interest in getting one) - getWidget().currentFragment = History.getToken(); - - // Include current fragment in the next request - client.updateVariable(getWidget().id, - RootConstants.FRAGMENT_VARIABLE, - getWidget().currentFragment, false); - } - - if (firstPaint) { - // Queue the initial window size to be sent with the following - // request. - getWidget().sendClientResized(); - } - getWidget().rendering = false; - } - - public void init(String rootPanelId, - ApplicationConnection applicationConnection) { - DOM.sinkEvents(getWidget().getElement(), Event.ONKEYDOWN - | Event.ONSCROLL); - - // iview is focused when created so element needs tabIndex - // 1 due 0 is at the end of natural tabbing order - DOM.setElementProperty(getWidget().getElement(), "tabIndex", "1"); - - RootPanel root = RootPanel.get(rootPanelId); - - // Remove the v-app-loading or any splash screen added inside the div by - // the user - root.getElement().setInnerHTML(""); - - root.addStyleName("v-theme-" - + applicationConnection.getConfiguration().getThemeName()); - - root.add(getWidget()); - - if (applicationConnection.getConfiguration().isStandalone()) { - // set focus to iview element by default to listen possible keyboard - // shortcuts. For embedded applications this is unacceptable as we - // don't want to steal focus from the main page nor we don't want - // side-effects from focusing (scrollIntoView). - getWidget().getElement().focus(); - } - } - - private ClickEventHandler clickEventHandler = new ClickEventHandler(this) { - - @Override - protected void fireClick(NativeEvent event, - MouseEventDetails mouseDetails) { - rpc.click(mouseDetails); - } - - }; - - @Override - public void updateCaption(ComponentConnector component) { - // NOP The main view never draws caption for its layout - } - - @Override - public VRoot getWidget() { - return (VRoot) super.getWidget(); - } - - protected ComponentConnector getContent() { - return (ComponentConnector) getState().getContent(); - } - - protected void onChildSizeChange() { - ComponentConnector child = getContent(); - Style childStyle = child.getWidget().getElement().getStyle(); - /* - * Must set absolute position if the child has relative height and - * there's a chance of horizontal scrolling as some browsers will - * otherwise not take the scrollbar into account when calculating the - * height. Assuming v-view does not have an undefined width for now, see - * #8460. - */ - if (child.isRelativeHeight() && !BrowserInfo.get().isIE9()) { - childStyle.setPosition(Position.ABSOLUTE); - } else { - childStyle.clearPosition(); - } - } - - /** - * Checks if the given sub window is a child of this UI Connector - * - * @deprecated Should be replaced by a more generic mechanism for getting - * non-ComponentConnector children - * @param wc - * @return - */ - @Deprecated - public boolean hasSubWindow(WindowConnector wc) { - return getChildComponents().contains(wc); - } - - /** - * Return an iterator for current subwindows. This method is meant for - * testing purposes only. - * - * @return - */ - public List getSubWindows() { - ArrayList windows = new ArrayList(); - for (ComponentConnector child : getChildComponents()) { - if (child instanceof WindowConnector) { - windows.add((WindowConnector) child); - } - } - return windows; - } - - @Override - public RootState getState() { - return (RootState) super.getState(); - } - - @Override - public void onConnectorHierarchyChange(ConnectorHierarchyChangeEvent event) { - super.onConnectorHierarchyChange(event); - - ComponentConnector oldChild = null; - ComponentConnector newChild = getContent(); - - for (ComponentConnector c : event.getOldChildren()) { - if (!(c instanceof WindowConnector)) { - oldChild = c; - break; - } - } - - if (oldChild != newChild) { - if (childStateChangeHandlerRegistration != null) { - childStateChangeHandlerRegistration.removeHandler(); - childStateChangeHandlerRegistration = null; - } - getWidget().setWidget(newChild.getWidget()); - childStateChangeHandlerRegistration = newChild - .addStateChangeHandler(childStateChangeHandler); - // Must handle new child here as state change events are already - // fired - onChildSizeChange(); - } - - for (ComponentConnector c : getChildComponents()) { - if (c instanceof WindowConnector) { - WindowConnector wc = (WindowConnector) c; - wc.setWindowOrderAndPosition(); - } - } - - // Close removed sub windows - for (ComponentConnector c : event.getOldChildren()) { - if (c.getParent() != this && c instanceof WindowConnector) { - ((WindowConnector) c).getWidget().hide(); - } - } - } - - /** - * Tries to scroll the viewport so that the given connector is in view. - * - * @param componentConnector - * The connector which should be visible - * - */ - public void scrollIntoView(final ComponentConnector componentConnector) { - if (componentConnector == null) { - return; - } - - Scheduler.get().scheduleDeferred(new Command() { - @Override - public void execute() { - componentConnector.getWidget().getElement().scrollIntoView(); - } - }); - } - -} diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/root/VRoot.java b/client/src/com/vaadin/terminal/gwt/client/ui/root/VRoot.java deleted file mode 100644 index 162e7c55a8..0000000000 --- a/client/src/com/vaadin/terminal/gwt/client/ui/root/VRoot.java +++ /dev/null @@ -1,459 +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.terminal.gwt.client.ui.root; - -import java.util.ArrayList; - -import com.google.gwt.core.client.Scheduler.ScheduledCommand; -import com.google.gwt.dom.client.Element; -import com.google.gwt.event.logical.shared.HasResizeHandlers; -import com.google.gwt.event.logical.shared.ResizeEvent; -import com.google.gwt.event.logical.shared.ResizeHandler; -import com.google.gwt.event.logical.shared.ValueChangeEvent; -import com.google.gwt.event.logical.shared.ValueChangeHandler; -import com.google.gwt.event.shared.HandlerRegistration; -import com.google.gwt.user.client.DOM; -import com.google.gwt.user.client.Event; -import com.google.gwt.user.client.History; -import com.google.gwt.user.client.Timer; -import com.google.gwt.user.client.Window; -import com.google.gwt.user.client.ui.SimplePanel; -import com.vaadin.shared.ApplicationConstants; -import com.vaadin.shared.ui.root.RootConstants; -import com.vaadin.terminal.gwt.client.ApplicationConnection; -import com.vaadin.terminal.gwt.client.BrowserInfo; -import com.vaadin.terminal.gwt.client.ComponentConnector; -import com.vaadin.terminal.gwt.client.ConnectorMap; -import com.vaadin.terminal.gwt.client.Focusable; -import com.vaadin.terminal.gwt.client.VConsole; -import com.vaadin.terminal.gwt.client.ui.ShortcutActionHandler; -import com.vaadin.terminal.gwt.client.ui.ShortcutActionHandler.ShortcutActionHandlerOwner; -import com.vaadin.terminal.gwt.client.ui.TouchScrollDelegate; -import com.vaadin.terminal.gwt.client.ui.TouchScrollDelegate.TouchScrollHandler; -import com.vaadin.terminal.gwt.client.ui.VLazyExecutor; -import com.vaadin.terminal.gwt.client.ui.textfield.VTextField; - -/** - * - */ -public class VRoot extends SimplePanel implements ResizeHandler, - Window.ClosingHandler, ShortcutActionHandlerOwner, Focusable, - HasResizeHandlers { - - private static final String CLASSNAME = "v-view"; - - private static int MONITOR_PARENT_TIMER_INTERVAL = 1000; - - String theme; - - String id; - - ShortcutActionHandler actionHandler; - - /* - * Last known window size used to detect whether VView should be layouted - * again. Detection must check window size, because the VView size might be - * fixed and thus not automatically adapt to changed window sizes. - */ - private int windowWidth; - private int windowHeight; - - /* - * Last know view size used to detect whether new dimensions should be sent - * to the server. - */ - private int viewWidth; - private int viewHeight; - - ApplicationConnection connection; - - /** - * Keep track of possible parent size changes when an embedded application. - * - * Uses {@link #parentWidth} and {@link #parentHeight} as an optimization to - * keep track of when there is a real change. - */ - private Timer resizeTimer; - - /** stored width of parent for embedded application auto-resize */ - private int parentWidth; - - /** stored height of parent for embedded application auto-resize */ - private int parentHeight; - - int scrollTop; - - int scrollLeft; - - boolean rendering; - - boolean scrollable; - - boolean immediate; - - boolean resizeLazy = false; - - private HandlerRegistration historyHandlerRegistration; - - private TouchScrollHandler touchScrollHandler; - - /** - * The current URI fragment, used to avoid sending updates if nothing has - * changed. - */ - String currentFragment; - - /** - * Listener for URI fragment changes. Notifies the server of the new value - * whenever the value changes. - */ - private final ValueChangeHandler historyChangeHandler = new ValueChangeHandler() { - - @Override - public void onValueChange(ValueChangeEvent event) { - String newFragment = event.getValue(); - - // Send the new fragment to the server if it has changed - if (!newFragment.equals(currentFragment) && connection != null) { - currentFragment = newFragment; - connection.updateVariable(id, RootConstants.FRAGMENT_VARIABLE, - newFragment, true); - } - } - }; - - private VLazyExecutor delayedResizeExecutor = new VLazyExecutor(200, - new ScheduledCommand() { - - @Override - public void execute() { - performSizeCheck(); - } - - }); - - public VRoot() { - super(); - setStyleName(CLASSNAME); - - // Allow focusing the view by using the focus() method, the view - // should not be in the document focus flow - getElement().setTabIndex(-1); - makeScrollable(); - } - - /** - * Start to periodically monitor for parent element resizes if embedded - * application (e.g. portlet). - */ - @Override - protected void onLoad() { - super.onLoad(); - if (isMonitoringParentSize()) { - resizeTimer = new Timer() { - - @Override - public void run() { - // trigger check to see if parent size has changed, - // recalculate layouts - performSizeCheck(); - resizeTimer.schedule(MONITOR_PARENT_TIMER_INTERVAL); - } - }; - resizeTimer.schedule(MONITOR_PARENT_TIMER_INTERVAL); - } - } - - @Override - protected void onAttach() { - super.onAttach(); - historyHandlerRegistration = History - .addValueChangeHandler(historyChangeHandler); - currentFragment = History.getToken(); - } - - @Override - protected void onDetach() { - super.onDetach(); - historyHandlerRegistration.removeHandler(); - historyHandlerRegistration = null; - } - - /** - * Stop monitoring for parent element resizes. - */ - - @Override - protected void onUnload() { - if (resizeTimer != null) { - resizeTimer.cancel(); - resizeTimer = null; - } - super.onUnload(); - } - - /** - * Called when the window or parent div might have been resized. - * - * This immediately checks the sizes of the window and the parent div (if - * monitoring it) and triggers layout recalculation if they have changed. - */ - protected void performSizeCheck() { - windowSizeMaybeChanged(Window.getClientWidth(), - Window.getClientHeight()); - } - - /** - * Called when the window or parent div might have been resized. - * - * This immediately checks the sizes of the window and the parent div (if - * monitoring it) and triggers layout recalculation if they have changed. - * - * @param newWindowWidth - * The new width of the window - * @param newWindowHeight - * The new height of the window - * - * @deprecated use {@link #performSizeCheck()} - */ - @Deprecated - protected void windowSizeMaybeChanged(int newWindowWidth, - int newWindowHeight) { - boolean changed = false; - ComponentConnector connector = ConnectorMap.get(connection) - .getConnector(this); - if (windowWidth != newWindowWidth) { - windowWidth = newWindowWidth; - changed = true; - connector.getLayoutManager().reportOuterWidth(connector, - newWindowWidth); - VConsole.log("New window width: " + windowWidth); - } - if (windowHeight != newWindowHeight) { - windowHeight = newWindowHeight; - changed = true; - connector.getLayoutManager().reportOuterHeight(connector, - newWindowHeight); - VConsole.log("New window height: " + windowHeight); - } - Element parentElement = getElement().getParentElement(); - if (isMonitoringParentSize() && parentElement != null) { - // check also for parent size changes - int newParentWidth = parentElement.getClientWidth(); - int newParentHeight = parentElement.getClientHeight(); - if (parentWidth != newParentWidth) { - parentWidth = newParentWidth; - changed = true; - VConsole.log("New parent width: " + parentWidth); - } - if (parentHeight != newParentHeight) { - parentHeight = newParentHeight; - changed = true; - VConsole.log("New parent height: " + parentHeight); - } - } - if (changed) { - /* - * If the window size has changed, layout the VView again and send - * new size to the server if the size changed. (Just checking VView - * size would cause us to ignore cases when a relatively sized VView - * should shrink as the content's size is fixed and would thus not - * automatically shrink.) - */ - VConsole.log("Running layout functions due to window or parent resize"); - - // update size to avoid (most) redundant re-layout passes - // there can still be an extra layout recalculation if webkit - // overflow fix updates the size in a deferred block - if (isMonitoringParentSize() && parentElement != null) { - parentWidth = parentElement.getClientWidth(); - parentHeight = parentElement.getClientHeight(); - } - - sendClientResized(); - - connector.getLayoutManager().layoutNow(); - } - } - - public String getTheme() { - return theme; - } - - /** - * Used to reload host page on theme changes. - */ - static native void reloadHostPage() - /*-{ - $wnd.location.reload(); - }-*/; - - /** - * Returns true if the body is NOT generated, i.e if someone else has made - * the page that we're running in. Otherwise we're in charge of the whole - * page. - * - * @return true if we're running embedded - */ - public boolean isEmbedded() { - return !getElement().getOwnerDocument().getBody().getClassName() - .contains(ApplicationConstants.GENERATED_BODY_CLASSNAME); - } - - /** - * Returns true if the size of the parent should be checked periodically and - * the application should react to its changes. - * - * @return true if size of parent should be tracked - */ - protected boolean isMonitoringParentSize() { - // could also perform a more specific check (Liferay portlet) - return isEmbedded(); - } - - @Override - public void onBrowserEvent(Event event) { - super.onBrowserEvent(event); - int type = DOM.eventGetType(event); - if (type == Event.ONKEYDOWN && actionHandler != null) { - actionHandler.handleKeyboardEvent(event); - return; - } else if (scrollable && type == Event.ONSCROLL) { - updateScrollPosition(); - } - } - - /** - * Updates scroll position from DOM and saves variables to server. - */ - private void updateScrollPosition() { - int oldTop = scrollTop; - int oldLeft = scrollLeft; - scrollTop = DOM.getElementPropertyInt(getElement(), "scrollTop"); - scrollLeft = DOM.getElementPropertyInt(getElement(), "scrollLeft"); - if (connection != null && !rendering) { - if (oldTop != scrollTop) { - connection.updateVariable(id, "scrollTop", scrollTop, false); - } - if (oldLeft != scrollLeft) { - connection.updateVariable(id, "scrollLeft", scrollLeft, false); - } - } - } - - /* - * (non-Javadoc) - * - * @see - * com.google.gwt.event.logical.shared.ResizeHandler#onResize(com.google - * .gwt.event.logical.shared.ResizeEvent) - */ - - @Override - public void onResize(ResizeEvent event) { - triggerSizeChangeCheck(); - } - - /** - * Called when a resize event is received. - * - * This may trigger a lazy refresh or perform the size check immediately - * depending on the browser used and whether the server side requests - * resizes to be lazy. - */ - private void triggerSizeChangeCheck() { - /* - * IE (pre IE9 at least) will give us some false resize events due to - * problems with scrollbars. Firefox 3 might also produce some extra - * events. We postpone both the re-layouting and the server side event - * for a while to deal with these issues. - * - * We may also postpone these events to avoid slowness when resizing the - * browser window. Constantly recalculating the layout causes the resize - * operation to be really slow with complex layouts. - */ - boolean lazy = resizeLazy || BrowserInfo.get().isIE8(); - - if (lazy) { - delayedResizeExecutor.trigger(); - } else { - performSizeCheck(); - } - } - - /** - * Send new dimensions to the server. - */ - void sendClientResized() { - Element parentElement = getElement().getParentElement(); - int viewHeight = parentElement.getClientHeight(); - int viewWidth = parentElement.getClientWidth(); - - ResizeEvent.fire(this, viewWidth, viewHeight); - } - - public native static void goTo(String url) - /*-{ - $wnd.location = url; - }-*/; - - @Override - public void onWindowClosing(Window.ClosingEvent event) { - // Change focus on this window in order to ensure that all state is - // collected from textfields - // TODO this is a naive hack, that only works with text fields and may - // cause some odd issues. Should be replaced with a decent solution, see - // also related BeforeShortcutActionListener interface. Same interface - // might be usable here. - VTextField.flushChangesFromFocusedTextField(); - } - - private native static void loadAppIdListFromDOM(ArrayList list) - /*-{ - var j; - for(j in $wnd.vaadin.vaadinConfigurations) { - // $entry not needed as function is not exported - list.@java.util.Collection::add(Ljava/lang/Object;)(j); - } - }-*/; - - @Override - public ShortcutActionHandler getShortcutActionHandler() { - return actionHandler; - } - - @Override - public void focus() { - getElement().focus(); - } - - /** - * Ensures the root is scrollable eg. after style name changes. - */ - void makeScrollable() { - if (touchScrollHandler == null) { - touchScrollHandler = TouchScrollDelegate.enableTouchScrolling(this); - } - touchScrollHandler.addElement(getElement()); - } - - @Override - public HandlerRegistration addResizeHandler(ResizeHandler resizeHandler) { - return addHandler(resizeHandler, ResizeEvent.getType()); - } - -} diff --git a/server/src/com/vaadin/Application.java b/server/src/com/vaadin/Application.java index 23d407e4f3..582e05d3f4 100644 --- a/server/src/com/vaadin/Application.java +++ b/server/src/com/vaadin/Application.java @@ -1845,7 +1845,7 @@ public class Application implements Terminal.ErrorListener, Serializable { * *

      * If {@link BrowserDetails} are required to create a UI, the - * implementation can throw a {@link RootRequiresMoreInformationException} + * implementation can throw a {@link UIRequiresMoreInformationException} * exception. In this case, the framework will instruct the browser to send * the additional details, whereupon this method is invoked again with the * browser details present in the wrapped request. Throwing the exception if @@ -1864,19 +1864,19 @@ public class Application implements Terminal.ErrorListener, Serializable { * @param request * the wrapped request for which a root is needed * @return a root instance to use for the request - * @throws RootRequiresMoreInformationException + * @throws UIRequiresMoreInformationException * may be thrown by an implementation to indicate that * {@link BrowserDetails} are required to create a root * * @see #getRootClassName(WrappedRequest) * @see UI - * @see RootRequiresMoreInformationException + * @see UIRequiresMoreInformationException * @see WrappedRequest#getBrowserDetails() * * @since 7.0 */ protected UI getRoot(WrappedRequest request) - throws RootRequiresMoreInformationException { + throws UIRequiresMoreInformationException { // Iterate in reverse order - test check newest provider first for (int i = rootProviders.size() - 1; i >= 0; i--) { @@ -2151,7 +2151,7 @@ public class Application implements Terminal.ErrorListener, Serializable { * Finds the {@link UI} to which a particular request belongs. If the * request originates from an existing UI, that root is returned. In other * cases, the method attempts to create and initialize a new root and might - * throw a {@link RootRequiresMoreInformationException} if all required + * throw a {@link UIRequiresMoreInformationException} if all required * information is not available. *

      * Please note that this method can also return a newly created @@ -2164,17 +2164,17 @@ public class Application implements Terminal.ErrorListener, Serializable { * @param request * the request for which a root is desired * @return a root belonging to the request - * @throws RootRequiresMoreInformationException + * @throws UIRequiresMoreInformationException * if no existing root could be found and creating a new root * requires additional information from the browser * * @see #getRoot(WrappedRequest) - * @see RootRequiresMoreInformationException + * @see UIRequiresMoreInformationException * * @since 7.0 */ public UI getRootForRequest(WrappedRequest request) - throws RootRequiresMoreInformationException { + throws UIRequiresMoreInformationException { UI uI = UI.getCurrent(); if (uI != null) { return uI; @@ -2194,7 +2194,7 @@ public class Application implements Terminal.ErrorListener, Serializable { Integer retainedRootId; if (!hasBrowserDetails) { - throw new RootRequiresMoreInformationException(); + throw new UIRequiresMoreInformationException(); } else { String windowName = browserDetails.getWindowName(); retainedRootId = retainOnRefreshRoots.get(windowName); diff --git a/server/src/com/vaadin/RootRequiresMoreInformationException.java b/server/src/com/vaadin/RootRequiresMoreInformationException.java deleted file mode 100644 index 74026dd161..0000000000 --- a/server/src/com/vaadin/RootRequiresMoreInformationException.java +++ /dev/null @@ -1,37 +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; - -import com.vaadin.terminal.WrappedRequest; -import com.vaadin.terminal.WrappedRequest.BrowserDetails; - -/** - * Exception that is thrown to indicate that creating or initializing the root - * requires information detailed from the web browser ({@link BrowserDetails}) - * to be present. - * - * This exception may not be thrown if that information is already present in - * the current WrappedRequest. - * - * @see Application#getRoot(WrappedRequest) - * @see WrappedRequest#getBrowserDetails() - * - * @since 7.0 - */ -public class RootRequiresMoreInformationException extends Exception { - // Nothing of interest here -} diff --git a/server/src/com/vaadin/UIRequiresMoreInformationException.java b/server/src/com/vaadin/UIRequiresMoreInformationException.java new file mode 100644 index 0000000000..682d46f207 --- /dev/null +++ b/server/src/com/vaadin/UIRequiresMoreInformationException.java @@ -0,0 +1,37 @@ +/* + * 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; + +import com.vaadin.terminal.WrappedRequest; +import com.vaadin.terminal.WrappedRequest.BrowserDetails; + +/** + * Exception that is thrown to indicate that creating or initializing the root + * requires information detailed from the web browser ({@link BrowserDetails}) + * to be present. + * + * This exception may not be thrown if that information is already present in + * the current WrappedRequest. + * + * @see Application#getRoot(WrappedRequest) + * @see WrappedRequest#getBrowserDetails() + * + * @since 7.0 + */ +public class UIRequiresMoreInformationException extends Exception { + // Nothing of interest here +} diff --git a/server/src/com/vaadin/terminal/DefaultRootProvider.java b/server/src/com/vaadin/terminal/DefaultRootProvider.java index 07533949a0..7e6631be56 100644 --- a/server/src/com/vaadin/terminal/DefaultRootProvider.java +++ b/server/src/com/vaadin/terminal/DefaultRootProvider.java @@ -17,14 +17,14 @@ package com.vaadin.terminal; import com.vaadin.Application; -import com.vaadin.RootRequiresMoreInformationException; +import com.vaadin.UIRequiresMoreInformationException; import com.vaadin.ui.UI; public class DefaultRootProvider extends AbstractRootProvider { @Override public Class getRootClass(Application application, - WrappedRequest request) throws RootRequiresMoreInformationException { + WrappedRequest request) throws UIRequiresMoreInformationException { Object rootClassNameObj = application .getProperty(Application.ROOT_PARAMETER); diff --git a/server/src/com/vaadin/terminal/RootProvider.java b/server/src/com/vaadin/terminal/RootProvider.java index 53173b6b94..229f2ca989 100644 --- a/server/src/com/vaadin/terminal/RootProvider.java +++ b/server/src/com/vaadin/terminal/RootProvider.java @@ -17,12 +17,12 @@ package com.vaadin.terminal; import com.vaadin.Application; -import com.vaadin.RootRequiresMoreInformationException; +import com.vaadin.UIRequiresMoreInformationException; import com.vaadin.ui.UI; public interface RootProvider { public Class getRootClass(Application application, - WrappedRequest request) throws RootRequiresMoreInformationException; + WrappedRequest request) throws UIRequiresMoreInformationException; public UI instantiateRoot(Application application, Class type, WrappedRequest request); diff --git a/server/src/com/vaadin/terminal/WrappedRequest.java b/server/src/com/vaadin/terminal/WrappedRequest.java index 1186d678b0..9ef98fcc41 100644 --- a/server/src/com/vaadin/terminal/WrappedRequest.java +++ b/server/src/com/vaadin/terminal/WrappedRequest.java @@ -27,7 +27,7 @@ import javax.servlet.ServletRequest; import javax.servlet.http.HttpServletRequest; import com.vaadin.Application; -import com.vaadin.RootRequiresMoreInformationException; +import com.vaadin.UIRequiresMoreInformationException; import com.vaadin.annotations.EagerInit; import com.vaadin.terminal.gwt.server.WebBrowser; import com.vaadin.ui.UI; @@ -220,7 +220,7 @@ public interface WrappedRequest extends Serializable { * * This information is only guaranteed to be available in some special * cases, for instance when {@link Application#getRoot} is called again - * after throwing {@link RootRequiresMoreInformationException} or in + * after throwing {@link UIRequiresMoreInformationException} or in * {@link UI#init(WrappedRequest)} for a UI class not annotated with * {@link EagerInit} * diff --git a/server/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java b/server/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java index 2315a9c1d6..86668bd91f 100644 --- a/server/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java +++ b/server/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java @@ -56,7 +56,7 @@ import com.liferay.portal.kernel.util.PropsUtil; import com.vaadin.Application; import com.vaadin.Application.ApplicationStartEvent; import com.vaadin.Application.SystemMessages; -import com.vaadin.RootRequiresMoreInformationException; +import com.vaadin.UIRequiresMoreInformationException; import com.vaadin.terminal.DeploymentConfiguration; import com.vaadin.terminal.Terminal; import com.vaadin.terminal.WrappedRequest; @@ -500,7 +500,7 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet try { uI = application .getRootForRequest(wrappedRequest); - } catch (RootRequiresMoreInformationException e) { + } catch (UIRequiresMoreInformationException e) { // Ignore problem and continue without root } break; diff --git a/server/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java b/server/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java index 39475f3131..48810d2b08 100644 --- a/server/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java +++ b/server/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java @@ -60,7 +60,7 @@ import javax.servlet.http.HttpServletResponse; import com.vaadin.Application; import com.vaadin.Application.SystemMessages; -import com.vaadin.RootRequiresMoreInformationException; +import com.vaadin.UIRequiresMoreInformationException; import com.vaadin.annotations.JavaScript; import com.vaadin.annotations.StyleSheet; import com.vaadin.external.json.JSONArray; @@ -2457,7 +2457,7 @@ public abstract class AbstractCommunicationManager implements Serializable { // NOTE GateIn requires the buffers to be flushed to work outWriter.flush(); out.flush(); - } catch (RootRequiresMoreInformationException e) { + } catch (UIRequiresMoreInformationException e) { // Requiring more information at this point is not allowed // TODO handle in a better way throw new RuntimeException(e); diff --git a/server/src/com/vaadin/terminal/gwt/server/BootstrapHandler.java b/server/src/com/vaadin/terminal/gwt/server/BootstrapHandler.java index b6953da35e..e52c11e2c2 100644 --- a/server/src/com/vaadin/terminal/gwt/server/BootstrapHandler.java +++ b/server/src/com/vaadin/terminal/gwt/server/BootstrapHandler.java @@ -37,7 +37,7 @@ import org.jsoup.nodes.Node; import org.jsoup.parser.Tag; import com.vaadin.Application; -import com.vaadin.RootRequiresMoreInformationException; +import com.vaadin.UIRequiresMoreInformationException; import com.vaadin.external.json.JSONException; import com.vaadin.external.json.JSONObject; import com.vaadin.shared.ApplicationConstants; @@ -134,7 +134,7 @@ public abstract class BootstrapHandler implements RequestHandler { } rootId = Integer.valueOf(uI.getRootId()); - } catch (RootRequiresMoreInformationException e) { + } catch (UIRequiresMoreInformationException e) { // Just keep going without rootId } diff --git a/server/src/com/vaadin/terminal/gwt/server/BootstrapResponse.java b/server/src/com/vaadin/terminal/gwt/server/BootstrapResponse.java index 4f69dda48b..b1a52cf79e 100644 --- a/server/src/com/vaadin/terminal/gwt/server/BootstrapResponse.java +++ b/server/src/com/vaadin/terminal/gwt/server/BootstrapResponse.java @@ -19,7 +19,7 @@ package com.vaadin.terminal.gwt.server; import java.util.EventObject; import com.vaadin.Application; -import com.vaadin.RootRequiresMoreInformationException; +import com.vaadin.UIRequiresMoreInformationException; import com.vaadin.terminal.WrappedRequest; import com.vaadin.ui.UI; @@ -110,7 +110,7 @@ public abstract class BootstrapResponse extends EventObject { * * @see Application#isRootPreserved() * @see Application#getRoot(WrappedRequest) - * @see RootRequiresMoreInformationException + * @see UIRequiresMoreInformationException * * @return The UI that will be displayed in the page being generated, or * null if all required information is not yet diff --git a/server/src/com/vaadin/ui/UI.java b/server/src/com/vaadin/ui/UI.java index 33eefff485..e2facefb33 100644 --- a/server/src/com/vaadin/ui/UI.java +++ b/server/src/com/vaadin/ui/UI.java @@ -36,8 +36,8 @@ import com.vaadin.shared.EventId; import com.vaadin.shared.MouseEventDetails; import com.vaadin.shared.ui.BorderStyle; import com.vaadin.shared.ui.root.RootConstants; -import com.vaadin.shared.ui.root.RootServerRpc; -import com.vaadin.shared.ui.root.RootState; +import com.vaadin.shared.ui.root.UIServerRpc; +import com.vaadin.shared.ui.root.UIState; import com.vaadin.terminal.Page; import com.vaadin.terminal.Page.BrowserWindowResizeEvent; import com.vaadin.terminal.Page.BrowserWindowResizeListener; @@ -429,7 +429,7 @@ public abstract class UI extends AbstractComponentContainer implements private Page page = new Page(this); - private RootServerRpc rpc = new RootServerRpc() { + private UIServerRpc rpc = new UIServerRpc() { @Override public void click(MouseEventDetails mouseDetails) { fireEvent(new ClickEvent(UI.this, mouseDetails)); @@ -498,15 +498,15 @@ public abstract class UI extends AbstractComponentContainer implements } @Override - protected RootState getState() { - return (RootState) super.getState(); + protected UIState getState() { + return (UIState) super.getState(); } @Override - public Class getStateType() { + public Class getStateType() { // This is a workaround for a problem with creating the correct state // object during build - return RootState.class; + return UIState.class; } /** diff --git a/shared/src/com/vaadin/shared/ui/root/RootServerRpc.java b/shared/src/com/vaadin/shared/ui/root/RootServerRpc.java deleted file mode 100644 index df2031f7d5..0000000000 --- a/shared/src/com/vaadin/shared/ui/root/RootServerRpc.java +++ /dev/null @@ -1,26 +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.shared.ui.root; - -import com.vaadin.shared.annotations.Delayed; -import com.vaadin.shared.communication.ServerRpc; -import com.vaadin.shared.ui.ClickRpc; - -public interface RootServerRpc extends ClickRpc, ServerRpc { - @Delayed(lastonly = true) - public void resize(int viewWidth, int viewHeight, int windowWidth, - int windowHeight); -} \ No newline at end of file diff --git a/shared/src/com/vaadin/shared/ui/root/RootState.java b/shared/src/com/vaadin/shared/ui/root/RootState.java deleted file mode 100644 index b7c2c88ce5..0000000000 --- a/shared/src/com/vaadin/shared/ui/root/RootState.java +++ /dev/null @@ -1,32 +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.shared.ui.root; - -import com.vaadin.shared.ComponentState; -import com.vaadin.shared.Connector; - -public class RootState extends ComponentState { - private Connector content; - - public Connector getContent() { - return content; - } - - public void setContent(Connector content) { - this.content = content; - } - -} \ No newline at end of file diff --git a/shared/src/com/vaadin/shared/ui/root/UIServerRpc.java b/shared/src/com/vaadin/shared/ui/root/UIServerRpc.java new file mode 100644 index 0000000000..20cdd48f54 --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/root/UIServerRpc.java @@ -0,0 +1,26 @@ +/* + * 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.shared.ui.root; + +import com.vaadin.shared.annotations.Delayed; +import com.vaadin.shared.communication.ServerRpc; +import com.vaadin.shared.ui.ClickRpc; + +public interface UIServerRpc extends ClickRpc, ServerRpc { + @Delayed(lastonly = true) + public void resize(int viewWidth, int viewHeight, int windowWidth, + int windowHeight); +} \ No newline at end of file diff --git a/shared/src/com/vaadin/shared/ui/root/UIState.java b/shared/src/com/vaadin/shared/ui/root/UIState.java new file mode 100644 index 0000000000..f019d1ce67 --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/root/UIState.java @@ -0,0 +1,32 @@ +/* + * 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.shared.ui.root; + +import com.vaadin.shared.ComponentState; +import com.vaadin.shared.Connector; + +public class UIState extends ComponentState { + private Connector content; + + public Connector getContent() { + return content; + } + + public void setContent(Connector content) { + this.content = content; + } + +} \ No newline at end of file diff --git a/tests/server-side/com/vaadin/tests/server/component/root/CustomRootClassLoader.java b/tests/server-side/com/vaadin/tests/server/component/root/CustomRootClassLoader.java index 9fe486f85e..27d66ca0d0 100644 --- a/tests/server-side/com/vaadin/tests/server/component/root/CustomRootClassLoader.java +++ b/tests/server-side/com/vaadin/tests/server/component/root/CustomRootClassLoader.java @@ -10,7 +10,7 @@ import org.easymock.EasyMock; import com.vaadin.Application; import com.vaadin.Application.ApplicationStartEvent; -import com.vaadin.RootRequiresMoreInformationException; +import com.vaadin.UIRequiresMoreInformationException; import com.vaadin.terminal.DefaultRootProvider; import com.vaadin.terminal.DeploymentConfiguration; import com.vaadin.terminal.WrappedRequest; @@ -127,7 +127,7 @@ public class CustomRootClassLoader extends TestCase { @Override public UI getRootForRequest(WrappedRequest request) - throws RootRequiresMoreInformationException { + throws UIRequiresMoreInformationException { // Always create a new root for testing (can't directly use // getRoot as it's protected) return getRoot(request); diff --git a/tests/testbench/com/vaadin/launcher/ApplicationRunnerServlet.java b/tests/testbench/com/vaadin/launcher/ApplicationRunnerServlet.java index 2ac447cee3..43d4ad699e 100644 --- a/tests/testbench/com/vaadin/launcher/ApplicationRunnerServlet.java +++ b/tests/testbench/com/vaadin/launcher/ApplicationRunnerServlet.java @@ -30,7 +30,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.vaadin.Application; -import com.vaadin.RootRequiresMoreInformationException; +import com.vaadin.UIRequiresMoreInformationException; import com.vaadin.terminal.AbstractRootProvider; import com.vaadin.terminal.WrappedRequest; import com.vaadin.terminal.gwt.server.AbstractApplicationServlet; @@ -117,7 +117,7 @@ public class ApplicationRunnerServlet extends AbstractApplicationServlet { @Override public Class getRootClass( Application application, WrappedRequest request) - throws RootRequiresMoreInformationException { + throws UIRequiresMoreInformationException { return (Class) classToRun; } }); diff --git a/tests/testbench/com/vaadin/tests/application/RefreshStatePreserve.java b/tests/testbench/com/vaadin/tests/application/RefreshStatePreserve.java index 023a93438d..deff2bc486 100644 --- a/tests/testbench/com/vaadin/tests/application/RefreshStatePreserve.java +++ b/tests/testbench/com/vaadin/tests/application/RefreshStatePreserve.java @@ -1,7 +1,7 @@ package com.vaadin.tests.application; import com.vaadin.Application; -import com.vaadin.RootRequiresMoreInformationException; +import com.vaadin.UIRequiresMoreInformationException; import com.vaadin.terminal.AbstractRootProvider; import com.vaadin.terminal.WrappedRequest; import com.vaadin.tests.components.AbstractTestApplication; @@ -27,7 +27,7 @@ public class RefreshStatePreserve extends AbstractTestApplication { @Override public Class getRootClass(Application application, WrappedRequest request) - throws RootRequiresMoreInformationException { + throws UIRequiresMoreInformationException { return RefreshStateRoot.class; } }); diff --git a/tests/testbench/com/vaadin/tests/application/ThreadLocalInstances.java b/tests/testbench/com/vaadin/tests/application/ThreadLocalInstances.java index 3323e3bb28..96380b2185 100644 --- a/tests/testbench/com/vaadin/tests/application/ThreadLocalInstances.java +++ b/tests/testbench/com/vaadin/tests/application/ThreadLocalInstances.java @@ -1,7 +1,7 @@ package com.vaadin.tests.application; import com.vaadin.Application; -import com.vaadin.RootRequiresMoreInformationException; +import com.vaadin.UIRequiresMoreInformationException; import com.vaadin.terminal.ApplicationResource; import com.vaadin.terminal.DownloadStream; import com.vaadin.terminal.PaintException; @@ -78,7 +78,7 @@ public class ThreadLocalInstances extends AbstractTestApplication { @Override protected UI getRoot(WrappedRequest request) - throws RootRequiresMoreInformationException { + throws UIRequiresMoreInformationException { return mainWindow; } diff --git a/tests/testbench/com/vaadin/tests/components/root/LazyInitRoots.java b/tests/testbench/com/vaadin/tests/components/root/LazyInitRoots.java index aca7211aec..3c7862d298 100644 --- a/tests/testbench/com/vaadin/tests/components/root/LazyInitRoots.java +++ b/tests/testbench/com/vaadin/tests/components/root/LazyInitRoots.java @@ -1,6 +1,6 @@ package com.vaadin.tests.components.root; -import com.vaadin.RootRequiresMoreInformationException; +import com.vaadin.UIRequiresMoreInformationException; import com.vaadin.annotations.EagerInit; import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.terminal.ExternalResource; @@ -23,13 +23,13 @@ public class LazyInitRoots extends AbstractTestApplication { @Override public UI getRoot(WrappedRequest request) - throws RootRequiresMoreInformationException { + throws UIRequiresMoreInformationException { if (request.getParameter("lazyCreate") != null) { // UI created on second request BrowserDetails browserDetails = request.getBrowserDetails(); if (browserDetails == null || browserDetails.getUriFragment() == null) { - throw new RootRequiresMoreInformationException(); + throw new UIRequiresMoreInformationException(); } else { UI uI = new UI() { @Override diff --git a/tests/testbench/com/vaadin/tests/components/root/RootsInMultipleTabs.java b/tests/testbench/com/vaadin/tests/components/root/RootsInMultipleTabs.java index 4309b6e942..13bef59fe9 100644 --- a/tests/testbench/com/vaadin/tests/components/root/RootsInMultipleTabs.java +++ b/tests/testbench/com/vaadin/tests/components/root/RootsInMultipleTabs.java @@ -1,7 +1,7 @@ package com.vaadin.tests.components.root; import com.vaadin.Application; -import com.vaadin.RootRequiresMoreInformationException; +import com.vaadin.UIRequiresMoreInformationException; import com.vaadin.terminal.AbstractRootProvider; import com.vaadin.terminal.WrappedRequest; import com.vaadin.tests.components.AbstractTestApplication; @@ -27,7 +27,7 @@ public class RootsInMultipleTabs extends AbstractTestApplication { @Override public Class getRootClass(Application application, WrappedRequest request) - throws RootRequiresMoreInformationException { + throws UIRequiresMoreInformationException { return TabRoot.class; } }); diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a1/DifferentFeaturesForDifferentClients.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a1/DifferentFeaturesForDifferentClients.java index a601ff2eb4..6b25f4674d 100644 --- a/tests/testbench/com/vaadin/tests/minitutorials/v7a1/DifferentFeaturesForDifferentClients.java +++ b/tests/testbench/com/vaadin/tests/minitutorials/v7a1/DifferentFeaturesForDifferentClients.java @@ -17,7 +17,7 @@ package com.vaadin.tests.minitutorials.v7a1; import com.vaadin.Application; -import com.vaadin.RootRequiresMoreInformationException; +import com.vaadin.UIRequiresMoreInformationException; import com.vaadin.terminal.WrappedRequest; import com.vaadin.terminal.WrappedRequest.BrowserDetails; import com.vaadin.terminal.gwt.server.WebBrowser; @@ -36,12 +36,12 @@ public class DifferentFeaturesForDifferentClients extends Application { @Override protected UI getRoot(WrappedRequest request) - throws RootRequiresMoreInformationException { + throws UIRequiresMoreInformationException { BrowserDetails browserDetails = request.getBrowserDetails(); // This is a limitation of 7.0.0.alpha1 that there is no better way to // check if WebBrowser has been fully initialized if (browserDetails.getUriFragment() == null) { - throw new RootRequiresMoreInformationException(); + throw new UIRequiresMoreInformationException(); } // could also use screen size, browser version etc. -- cgit v1.2.3 From ff0761f787f94a157d12af2a37e10e808d43fc59 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Fri, 24 Aug 2012 11:27:11 +0300 Subject: Renamed Application and UI methods and fields from "Root" to "UI" (#8908). --- server/src/com/vaadin/Application.java | 307 ++++++++++----------- .../vaadin/UIRequiresMoreInformationException.java | 2 +- .../com/vaadin/terminal/AbstractRootProvider.java | 4 +- .../com/vaadin/terminal/DefaultRootProvider.java | 4 +- server/src/com/vaadin/terminal/RootProvider.java | 29 -- server/src/com/vaadin/terminal/UIProvider.java | 29 ++ .../gwt/server/AbstractApplicationPortlet.java | 6 +- .../gwt/server/AbstractApplicationServlet.java | 2 +- .../gwt/server/AbstractCommunicationManager.java | 14 +- .../terminal/gwt/server/ApplicationServlet.java | 2 +- .../terminal/gwt/server/BootstrapHandler.java | 10 +- .../terminal/gwt/server/BootstrapResponse.java | 6 +- .../terminal/gwt/server/ServletPortletHelper.java | 4 +- server/src/com/vaadin/ui/UI.java | 198 ++++++------- .../component/root/CustomRootClassLoader.java | 12 +- .../vaadin/launcher/ApplicationRunnerServlet.java | 4 +- .../tests/application/RefreshStatePreserve.java | 8 +- .../tests/application/ThreadLocalInstances.java | 2 +- .../loginform/LoginFormWithMultipleWindows.java | 2 +- .../tests/components/root/LazyInitRoots.java | 2 +- .../tests/components/root/RootsInMultipleTabs.java | 4 +- .../minitutorials/v7a1/CreatingPreserveState.java | 2 +- .../v7a1/DifferentFeaturesForDifferentClients.java | 2 +- 23 files changed, 325 insertions(+), 330 deletions(-) delete mode 100644 server/src/com/vaadin/terminal/RootProvider.java create mode 100644 server/src/com/vaadin/terminal/UIProvider.java diff --git a/server/src/com/vaadin/Application.java b/server/src/com/vaadin/Application.java index 582e05d3f4..1827a55b72 100644 --- a/server/src/com/vaadin/Application.java +++ b/server/src/com/vaadin/Application.java @@ -57,8 +57,8 @@ import com.vaadin.terminal.ApplicationResource; import com.vaadin.terminal.CombinedRequest; import com.vaadin.terminal.DeploymentConfiguration; import com.vaadin.terminal.RequestHandler; -import com.vaadin.terminal.RootProvider; import com.vaadin.terminal.Terminal; +import com.vaadin.terminal.UIProvider; import com.vaadin.terminal.VariableOwner; import com.vaadin.terminal.WrappedRequest; import com.vaadin.terminal.WrappedRequest.BrowserDetails; @@ -74,8 +74,8 @@ import com.vaadin.terminal.gwt.server.WebApplicationContext; import com.vaadin.tools.ReflectTools; import com.vaadin.ui.AbstractComponent; import com.vaadin.ui.AbstractField; -import com.vaadin.ui.UI; import com.vaadin.ui.Table; +import com.vaadin.ui.UI; import com.vaadin.ui.Window; /** @@ -136,7 +136,7 @@ public class Application implements Terminal.ErrorListener, Serializable { * The name of the parameter that is by default used in e.g. web.xml to * define the name of the default {@link UI} class. */ - public static final String ROOT_PARAMETER = "root"; + public static final String UI_PARAMETER = "UI"; private static final Method BOOTSTRAP_FRAGMENT_METHOD = ReflectTools .findMethod(BootstrapListener.class, "modifyBootstrapFragment", @@ -167,14 +167,14 @@ public class Application implements Terminal.ErrorListener, Serializable { private UI.LegacyWindow mainWindow; private String theme; - private Map legacyRootNames = new HashMap(); + private Map legacyUINames = new HashMap(); /** * Sets the main window of this application. Setting window as a main * window of this application also adds the window to this application. * * @param mainWindow - * the root to set as the default window + * the UI to set as the default window */ public void setMainWindow(UI.LegacyWindow mainWindow) { if (this.mainWindow != null) { @@ -201,7 +201,7 @@ public class Application implements Terminal.ErrorListener, Serializable { * Note that each application must have at least one main window. *

      * - * @return the root used as the default window + * @return the UI used as the default window */ public UI.LegacyWindow getMainWindow() { return mainWindow; @@ -215,11 +215,11 @@ public class Application implements Terminal.ErrorListener, Serializable { * {@inheritDoc} * * @see #getWindow(String) - * @see Application#getRoot(WrappedRequest) + * @see Application#getUI(WrappedRequest) */ @Override - public UI.LegacyWindow getRoot(WrappedRequest request) { + public UI.LegacyWindow getUI(WrappedRequest request) { String pathInfo = request.getRequestPathInfo(); String name = null; if (pathInfo != null && pathInfo.length() > 0) { @@ -239,8 +239,8 @@ public class Application implements Terminal.ErrorListener, Serializable { /** * Sets the application's theme. *

      - * Note that this theme can be overridden for a specific root with - * {@link Application#getThemeForRoot(UI)}. Setting theme to be + * Note that this theme can be overridden for a specific UI with + * {@link Application#getThemeForUI(UI)}. Setting theme to be * null selects the default theme. For the available theme * names, see the contents of the VAADIN/themes directory. *

      @@ -272,30 +272,30 @@ public class Application implements Terminal.ErrorListener, Serializable { */ @Override - public String getThemeForRoot(UI uI) { + public String getThemeForUI(UI uI) { return theme; } /** *

      - * Gets a root by name. Returns null if the application is + * Gets a UI by name. Returns null if the application is * not running or it does not contain a window corresponding to the * name. *

      * * @param name * the name of the requested window - * @return a root corresponding to the name, or null to use + * @return a UI corresponding to the name, or null to use * the default window */ public UI.LegacyWindow getWindow(String name) { - return legacyRootNames.get(name); + return legacyUINames.get(name); } /** * Counter to get unique names for windows with no explicit name */ - private int namelessRootIndex = 0; + private int namelessUIIndex = 0; /** * Adds a new browser level window to this application. Please note that @@ -303,25 +303,25 @@ public class Application implements Terminal.ErrorListener, Serializable { * window you should instead use {@link #addWindow(UI, String)} * * @param uI - * the root window to add to the application + * the UI window to add to the application * @return returns the name that has been assigned to the window * * @see #addWindow(UI, String) */ public void addWindow(UI.LegacyWindow uI) { if (uI.getName() == null) { - String name = Integer.toString(namelessRootIndex++); + String name = Integer.toString(namelessUIIndex++); uI.setName(name); } - legacyRootNames.put(uI.getName(), uI); + legacyUINames.put(uI.getName(), uI); uI.setApplication(this); } /** * Removes the specified window from the application. This also removes - * all name mappings for the window (see - * {@link #addWindow(UI, String) and #getWindowName(UI)}. + * all name mappings for the window (see {@link #addWindow(UI, String) + * and #getWindowName(UI)}. * *

      * Note that removing window from the application does not close the @@ -329,13 +329,13 @@ public class Application implements Terminal.ErrorListener, Serializable { *

      * * @param uI - * the root to remove + * the UI to remove */ public void removeWindow(UI.LegacyWindow uI) { - for (Entry entry : legacyRootNames + for (Entry entry : legacyUINames .entrySet()) { if (entry.getValue() == uI) { - legacyRootNames.remove(entry.getKey()); + legacyUINames.remove(entry.getKey()); } } } @@ -350,7 +350,7 @@ public class Application implements Terminal.ErrorListener, Serializable { * @return the unmodifiable collection of windows. */ public Collection getWindows() { - return Collections.unmodifiableCollection(legacyRootNames.values()); + return Collections.unmodifiableCollection(legacyUINames.values()); } } @@ -489,10 +489,10 @@ public class Application implements Terminal.ErrorListener, Serializable { private LinkedList requestHandlers = new LinkedList(); - private int nextRootId = 0; + private int nextUIId = 0; private Map uIs = new HashMap(); - private final Map retainOnRefreshRoots = new HashMap(); + private final Map retainOnRefreshUIs = new HashMap(); private final EventRouter eventRouter = new EventRouter(); @@ -500,12 +500,12 @@ public class Application implements Terminal.ErrorListener, Serializable { * Keeps track of which uIs have been inited. *

      * TODO Investigate whether this might be derived from the different states - * in getRootForRrequest. + * in getUIForRrequest. *

      */ - private Set initedRoots = new HashSet(); + private Set initedUIs = new HashSet(); - private List rootProviders = new LinkedList(); + private List uiProviders = new LinkedList(); /** * Gets the user of the application. @@ -1830,110 +1830,108 @@ public class Application implements Terminal.ErrorListener, Serializable { } /** - * Gets a root for a request for which no root is already known. This method - * is called when the framework processes a request that does not originate - * from an existing root instance. This typically happens when a host page - * is requested. + * Gets a UI for a request for which no UI is already known. This method is + * called when the framework processes a request that does not originate + * from an existing UI instance. This typically happens when a host page is + * requested. * *

      * Subclasses of Application may override this method to provide custom - * logic for choosing how to create a suitable root or for picking an - * already created root. If an existing root is picked, care should be taken - * to avoid keeping the same root open in multiple browser windows, as that - * will cause the states to go out of sync. + * logic for choosing how to create a suitable UI or for picking an already + * created UI. If an existing UI is picked, care should be taken to avoid + * keeping the same UI open in multiple browser windows, as that will cause + * the states to go out of sync. *

      * *

      - * If {@link BrowserDetails} are required to create a UI, the - * implementation can throw a {@link UIRequiresMoreInformationException} - * exception. In this case, the framework will instruct the browser to send - * the additional details, whereupon this method is invoked again with the - * browser details present in the wrapped request. Throwing the exception if - * the browser details are already available is not supported. + * If {@link BrowserDetails} are required to create a UI, the implementation + * can throw a {@link UIRequiresMoreInformationException} exception. In this + * case, the framework will instruct the browser to send the additional + * details, whereupon this method is invoked again with the browser details + * present in the wrapped request. Throwing the exception if the browser + * details are already available is not supported. *

      * *

      * The default implementation in {@link Application} creates a new instance - * of the UI class returned by {@link #getRootClassName(WrappedRequest)}, - * which in turn uses the {@value #ROOT_PARAMETER} parameter from web.xml. - * If {@link DeploymentConfiguration#getClassLoader()} for the request - * returns a {@link ClassLoader}, it is used for loading the UI class. - * Otherwise the {@link ClassLoader} used to load this class is used. + * of the UI class returned by {@link #getUIClassName(WrappedRequest)}, + * which in turn uses the {@value #UI_PARAMETER} parameter from web.xml. If + * {@link DeploymentConfiguration#getClassLoader()} for the request returns + * a {@link ClassLoader}, it is used for loading the UI class. Otherwise the + * {@link ClassLoader} used to load this class is used. *

      * * @param request - * the wrapped request for which a root is needed - * @return a root instance to use for the request + * the wrapped request for which a UI is needed + * @return a UI instance to use for the request * @throws UIRequiresMoreInformationException * may be thrown by an implementation to indicate that - * {@link BrowserDetails} are required to create a root + * {@link BrowserDetails} are required to create a UI * - * @see #getRootClassName(WrappedRequest) + * @see #getUIClassName(WrappedRequest) * @see UI * @see UIRequiresMoreInformationException * @see WrappedRequest#getBrowserDetails() * * @since 7.0 */ - protected UI getRoot(WrappedRequest request) + protected UI getUI(WrappedRequest request) throws UIRequiresMoreInformationException { // Iterate in reverse order - test check newest provider first - for (int i = rootProviders.size() - 1; i >= 0; i--) { - RootProvider provider = rootProviders.get(i); + for (int i = uiProviders.size() - 1; i >= 0; i--) { + UIProvider provider = uiProviders.get(i); - Class rootClass = provider.getRootClass(this, - request); + Class uiClass = provider.getUIClass(this, request); - if (rootClass != null) { - return provider.instantiateRoot(this, rootClass, request); + if (uiClass != null) { + return provider.instantiateUI(this, uiClass, request); } } throw new RuntimeException( - "No root providers available or providers are not able to find root instance"); + "No UI providers available or providers are not able to find UI instance"); } /** - * Finds the theme to use for a specific root. If no specific theme is + * Finds the theme to use for a specific UI. If no specific theme is * required, null is returned. * * TODO Tell what the default implementation does once it does something. * * @param uI - * the root to get a theme for + * the UI to get a theme for * @return the name of the theme, or null if the default theme * should be used * * @since 7.0 */ - public String getThemeForRoot(UI uI) { - Theme rootTheme = getAnnotationFor(uI.getClass(), Theme.class); - if (rootTheme != null) { - return rootTheme.value(); + public String getThemeForUI(UI uI) { + Theme uiTheme = getAnnotationFor(uI.getClass(), Theme.class); + if (uiTheme != null) { + return uiTheme.value(); } else { return null; } } /** - * Finds the widgetset to use for a specific root. If no specific widgetset - * is required, null is returned. + * Finds the widgetset to use for a specific UI. If no specific widgetset is + * required, null is returned. * * TODO Tell what the default implementation does once it does something. * * @param uI - * the root to get a widgetset for + * the UI to get a widgetset for * @return the name of the widgetset, or null if the default * widgetset should be used * * @since 7.0 */ - public String getWidgetsetForRoot(UI uI) { - Widgetset rootWidgetset = getAnnotationFor(uI.getClass(), - Widgetset.class); - if (rootWidgetset != null) { - return rootWidgetset.value(); + public String getWidgetsetForUI(UI uI) { + Widgetset uiWidgetset = getAnnotationFor(uI.getClass(), Widgetset.class); + if (uiWidgetset != null) { + return uiWidgetset.value(); } else { return null; } @@ -2087,7 +2085,7 @@ public class Application implements Terminal.ErrorListener, Serializable { */ private static final ThreadLocal currentApplication = new ThreadLocal(); - private boolean rootPreserved = false; + private boolean uiPreserved = false; /** * Gets the currently used application. The current application is @@ -2139,112 +2137,110 @@ public class Application implements Terminal.ErrorListener, Serializable { return configuration.isProductionMode(); } - public void addRootProvider(RootProvider rootProvider) { - rootProviders.add(rootProvider); + public void addUIProvider(UIProvider uIProvider) { + uiProviders.add(uIProvider); } - public void removeRootProvider(RootProvider rootProvider) { - rootProviders.remove(rootProvider); + public void removeUIProvider(UIProvider uIProvider) { + uiProviders.remove(uIProvider); } /** * Finds the {@link UI} to which a particular request belongs. If the - * request originates from an existing UI, that root is returned. In other - * cases, the method attempts to create and initialize a new root and might + * request originates from an existing UI, that UI is returned. In other + * cases, the method attempts to create and initialize a new UI and might * throw a {@link UIRequiresMoreInformationException} if all required * information is not available. *

      * Please note that this method can also return a newly created * UI which has not yet been initialized. You can use - * {@link #isRootInitPending(int)} with the root's id ( - * {@link UI#getRootId()} to check whether the initialization is still - * pending. + * {@link #isUIInitPending(int)} with the UI's id ( {@link UI#getUIId()} to + * check whether the initialization is still pending. *

      * * @param request - * the request for which a root is desired - * @return a root belonging to the request + * the request for which a UI is desired + * @return a UI belonging to the request * @throws UIRequiresMoreInformationException - * if no existing root could be found and creating a new root + * if no existing UI could be found and creating a new UI * requires additional information from the browser * - * @see #getRoot(WrappedRequest) + * @see #getUI(WrappedRequest) * @see UIRequiresMoreInformationException * * @since 7.0 */ - public UI getRootForRequest(WrappedRequest request) + public UI getUIForRequest(WrappedRequest request) throws UIRequiresMoreInformationException { UI uI = UI.getCurrent(); if (uI != null) { return uI; } - Integer rootId = getRootId(request); + Integer uiId = getUIId(request); synchronized (this) { BrowserDetails browserDetails = request.getBrowserDetails(); boolean hasBrowserDetails = browserDetails != null && browserDetails.getUriFragment() != null; - uI = uIs.get(rootId); + uI = uIs.get(uiId); - if (uI == null && isRootPreserved()) { - // Check for a known root - if (!retainOnRefreshRoots.isEmpty()) { + if (uI == null && isUiPreserved()) { + // Check for a known UI + if (!retainOnRefreshUIs.isEmpty()) { - Integer retainedRootId; + Integer retainedUIId; if (!hasBrowserDetails) { throw new UIRequiresMoreInformationException(); } else { String windowName = browserDetails.getWindowName(); - retainedRootId = retainOnRefreshRoots.get(windowName); + retainedUIId = retainOnRefreshUIs.get(windowName); } - if (retainedRootId != null) { - rootId = retainedRootId; - uI = uIs.get(rootId); + if (retainedUIId != null) { + uiId = retainedUIId; + uI = uIs.get(uiId); } } } if (uI == null) { - // Throws exception if root can not yet be created - uI = getRoot(request); + // Throws exception if UI can not yet be created + uI = getUI(request); - // Initialize some fields for a newly created root + // Initialize some fields for a newly created UI if (uI.getApplication() == null) { uI.setApplication(this); } - if (uI.getRootId() < 0) { + if (uI.getUIId() < 0) { - if (rootId == null) { + if (uiId == null) { // Get the next id if none defined - rootId = Integer.valueOf(nextRootId++); + uiId = Integer.valueOf(nextUIId++); } - uI.setRootId(rootId.intValue()); - uIs.put(rootId, uI); + uI.setUIId(uiId.intValue()); + uIs.put(uiId, uI); } } // Set thread local here so it is available in init UI.setCurrent(uI); - if (!initedRoots.contains(rootId)) { - boolean initRequiresBrowserDetails = isRootPreserved() - || !uI.getClass() - .isAnnotationPresent(EagerInit.class); + if (!initedUIs.contains(uiId)) { + boolean initRequiresBrowserDetails = isUiPreserved() + || !uI.getClass().isAnnotationPresent(EagerInit.class); if (!initRequiresBrowserDetails || hasBrowserDetails) { uI.doInit(request); - // Remember that this root has been initialized - initedRoots.add(rootId); + // Remember that this UI has been initialized + initedUIs.add(uiId); // init() might turn on preserve so do this afterwards - if (isRootPreserved()) { - // Remember this root + if (isUiPreserved()) { + // Remember this UI String windowName = request.getBrowserDetails() .getWindowName(); - retainOnRefreshRoots.put(windowName, rootId); + retainOnRefreshUIs.put(windowName, uiId); } } } @@ -2254,25 +2250,24 @@ public class Application implements Terminal.ErrorListener, Serializable { } /** - * Internal helper to finds the root id for a request. + * Internal helper to finds the UI id for a request. * * @param request - * the request to get the root id for - * @return a root id, or null if no root id is defined + * the request to get the UI id for + * @return a UI id, or null if no UI id is defined * * @since 7.0 */ - private static Integer getRootId(WrappedRequest request) { + private static Integer getUIId(WrappedRequest request) { if (request instanceof CombinedRequest) { - // Combined requests has the rootid parameter in the second request + // Combined requests has the uiId parameter in the second request CombinedRequest combinedRequest = (CombinedRequest) request; request = combinedRequest.getSecondRequest(); } - String rootIdString = request + String uiIdString = request .getParameter(ApplicationConstants.ROOT_ID_PARAMETER); - Integer rootId = rootIdString == null ? null - : new Integer(rootIdString); - return rootId; + Integer uiId = uiIdString == null ? null : new Integer(uiIdString); + return uiId; } /** @@ -2285,14 +2280,14 @@ public class Application implements Terminal.ErrorListener, Serializable { * the UI is already shown, as it might not be retained as intended. *

      * - * @param rootPreserved - * trueif the same UI instance should be reused - * e.g. when the browser window is refreshed. + * @param uiPreserved + * trueif the same UI instance should be reused e.g. + * when the browser window is refreshed. */ - public void setRootPreserved(boolean rootPreserved) { - this.rootPreserved = rootPreserved; - if (!rootPreserved) { - retainOnRefreshRoots.clear(); + public void setUiPreserved(boolean uiPreserved) { + this.uiPreserved = uiPreserved; + if (!uiPreserved) { + retainOnRefreshUIs.clear(); } } @@ -2305,41 +2300,41 @@ public class Application implements Terminal.ErrorListener, Serializable { * @return trueif the same UI instance should be reused e.g. * when the browser window is refreshed. */ - public boolean isRootPreserved() { - return rootPreserved; + public boolean isUiPreserved() { + return uiPreserved; } /** - * Checks whether there's a pending initialization for the root with the - * given id. + * Checks whether there's a pending initialization for the UI with the given + * id. * - * @param rootId - * root id to check for + * @param uiId + * UI id to check for * @return true of the initialization is pending, - * false if the root id is not registered or if the - * root has already been initialized + * false if the UI id is not registered or if the UI + * has already been initialized * - * @see #getRootForRequest(WrappedRequest) + * @see #getUIForRequest(WrappedRequest) */ - public boolean isRootInitPending(int rootId) { - return !initedRoots.contains(Integer.valueOf(rootId)); + public boolean isUIInitPending(int uiId) { + return !initedUIs.contains(Integer.valueOf(uiId)); } /** - * Gets all the uIs of this application. This includes uIs that have - * been requested but not yet initialized. Please note, that uIs are not + * Gets all the uIs of this application. This includes uIs that have been + * requested but not yet initialized. Please note, that uIs are not * automatically removed e.g. if the browser window is closed and that there - * is no way to manually remove a root. Inactive uIs will thus not be - * released for GC until the entire application is released when the session - * has timed out (unless there are dangling references). Improved support - * for releasing unused uIs is planned for an upcoming alpha release of - * Vaadin 7. + * is no way to manually remove a UI. Inactive uIs will thus not be released + * for GC until the entire application is released when the session has + * timed out (unless there are dangling references). Improved support for + * releasing unused uIs is planned for an upcoming alpha release of Vaadin + * 7. * * @return a collection of uIs belonging to this application * * @since 7.0 */ - public Collection getRoots() { + public Collection getUIs() { return Collections.unmodifiableCollection(uIs.values()); } @@ -2367,12 +2362,12 @@ public class Application implements Terminal.ErrorListener, Serializable { * This is meant for framework internal use. *

      * - * @param rootId - * The root id - * @return The root with the given id or null if not found + * @param uiId + * The UI id + * @return The UI with the given id or null if not found */ - public UI getRootById(int rootId) { - return uIs.get(rootId); + public UI getUIById(int uiId) { + return uIs.get(uiId); } /** diff --git a/server/src/com/vaadin/UIRequiresMoreInformationException.java b/server/src/com/vaadin/UIRequiresMoreInformationException.java index 682d46f207..0d491895e5 100644 --- a/server/src/com/vaadin/UIRequiresMoreInformationException.java +++ b/server/src/com/vaadin/UIRequiresMoreInformationException.java @@ -27,7 +27,7 @@ import com.vaadin.terminal.WrappedRequest.BrowserDetails; * This exception may not be thrown if that information is already present in * the current WrappedRequest. * - * @see Application#getRoot(WrappedRequest) + * @see Application#getUI(WrappedRequest) * @see WrappedRequest#getBrowserDetails() * * @since 7.0 diff --git a/server/src/com/vaadin/terminal/AbstractRootProvider.java b/server/src/com/vaadin/terminal/AbstractRootProvider.java index b340c62448..f316a58f15 100644 --- a/server/src/com/vaadin/terminal/AbstractRootProvider.java +++ b/server/src/com/vaadin/terminal/AbstractRootProvider.java @@ -19,10 +19,10 @@ package com.vaadin.terminal; import com.vaadin.Application; import com.vaadin.ui.UI; -public abstract class AbstractRootProvider implements RootProvider { +public abstract class AbstractRootProvider implements UIProvider { @Override - public UI instantiateRoot(Application application, + public UI instantiateUI(Application application, Class type, WrappedRequest request) { try { return type.newInstance(); diff --git a/server/src/com/vaadin/terminal/DefaultRootProvider.java b/server/src/com/vaadin/terminal/DefaultRootProvider.java index 7e6631be56..b201be513d 100644 --- a/server/src/com/vaadin/terminal/DefaultRootProvider.java +++ b/server/src/com/vaadin/terminal/DefaultRootProvider.java @@ -23,10 +23,10 @@ import com.vaadin.ui.UI; public class DefaultRootProvider extends AbstractRootProvider { @Override - public Class getRootClass(Application application, + public Class getUIClass(Application application, WrappedRequest request) throws UIRequiresMoreInformationException { Object rootClassNameObj = application - .getProperty(Application.ROOT_PARAMETER); + .getProperty(Application.UI_PARAMETER); if (rootClassNameObj instanceof String) { String rootClassName = rootClassNameObj.toString(); diff --git a/server/src/com/vaadin/terminal/RootProvider.java b/server/src/com/vaadin/terminal/RootProvider.java deleted file mode 100644 index 229f2ca989..0000000000 --- a/server/src/com/vaadin/terminal/RootProvider.java +++ /dev/null @@ -1,29 +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.terminal; - -import com.vaadin.Application; -import com.vaadin.UIRequiresMoreInformationException; -import com.vaadin.ui.UI; - -public interface RootProvider { - public Class getRootClass(Application application, - WrappedRequest request) throws UIRequiresMoreInformationException; - - public UI instantiateRoot(Application application, - Class type, WrappedRequest request); -} diff --git a/server/src/com/vaadin/terminal/UIProvider.java b/server/src/com/vaadin/terminal/UIProvider.java new file mode 100644 index 0000000000..27b63fbcac --- /dev/null +++ b/server/src/com/vaadin/terminal/UIProvider.java @@ -0,0 +1,29 @@ +/* + * 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.terminal; + +import com.vaadin.Application; +import com.vaadin.UIRequiresMoreInformationException; +import com.vaadin.ui.UI; + +public interface UIProvider { + public Class getUIClass(Application application, + WrappedRequest request) throws UIRequiresMoreInformationException; + + public UI instantiateUI(Application application, + Class type, WrappedRequest request); +} diff --git a/server/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java b/server/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java index 86668bd91f..7a69a4c2b0 100644 --- a/server/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java +++ b/server/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java @@ -499,7 +499,7 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet // and then do a second request try { uI = application - .getRootForRequest(wrappedRequest); + .getUIForRequest(wrappedRequest); } catch (UIRequiresMoreInformationException e) { // Ignore problem and continue without root } @@ -517,7 +517,7 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet break; default: uI = application - .getRootForRequest(wrappedRequest); + .getUIForRequest(wrappedRequest); } // if window not found, not a problem - use null } @@ -895,7 +895,7 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet throws PortletException { try { final Application application = getApplicationClass().newInstance(); - application.setRootPreserved(true); + application.setUiPreserved(true); return application; } catch (final IllegalAccessException e) { throw new PortletException("getNewApplication failed", e); diff --git a/server/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java b/server/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java index b17ef20cde..b71c6ec20c 100644 --- a/server/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java +++ b/server/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java @@ -319,7 +319,7 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements response); return; } else if (requestType == RequestType.UIDL) { - UI uI = application.getRootForRequest(request); + UI uI = application.getUIForRequest(request); if (uI == null) { throw new ServletException(ERROR_NO_ROOT_FOUND); } diff --git a/server/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java b/server/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java index 48810d2b08..7662564233 100644 --- a/server/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java +++ b/server/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java @@ -1390,7 +1390,7 @@ public abstract class AbstractCommunicationManager implements Serializable { } private ClientCache getClientCache(UI uI) { - Integer rootId = Integer.valueOf(uI.getRootId()); + Integer rootId = Integer.valueOf(uI.getUIId()); ClientCache cache = rootToClientCache.get(rootId); if (cache == null) { cache = new ClientCache(); @@ -1515,7 +1515,7 @@ public abstract class AbstractCommunicationManager implements Serializable { } private String getTheme(UI uI) { - String themeName = uI.getApplication().getThemeForRoot(uI); + String themeName = uI.getApplication().getThemeForUI(uI); String requestThemeName = getRequestTheme(); if (requestThemeName != null) { @@ -2353,7 +2353,7 @@ public abstract class AbstractCommunicationManager implements Serializable { * handling post */ String paintableId = owner.getConnectorId(); - int rootId = owner.getRoot().getRootId(); + int rootId = owner.getRoot().getUIId(); String key = rootId + "/" + paintableId + "/" + name; if (pidToNameToStreamVariable == null) { @@ -2422,13 +2422,13 @@ public abstract class AbstractCommunicationManager implements Serializable { try { CombinedRequest combinedRequest = new CombinedRequest(request); - UI uI = application.getRootForRequest(combinedRequest); + UI uI = application.getUIForRequest(combinedRequest); response.setContentType("application/json; charset=UTF-8"); // Use the same logic as for determined roots BootstrapHandler bootstrapHandler = getBootstrapHandler(); BootstrapContext context = bootstrapHandler.createContext( - combinedRequest, response, application, uI.getRootId()); + combinedRequest, response, application, uI.getUIId()); String widgetset = context.getWidgetsetName(); String theme = context.getThemeName(); @@ -2440,7 +2440,7 @@ public abstract class AbstractCommunicationManager implements Serializable { params.put("widgetset", widgetset); params.put("themeUri", themeUri); // UI id might have changed based on e.g. window.name - params.put(ApplicationConstants.ROOT_ID_PARAMETER, uI.getRootId()); + params.put(ApplicationConstants.ROOT_ID_PARAMETER, uI.getUIId()); if (sendUIDL) { String initialUIDL = getInitialUIDL(combinedRequest, uI); params.put("uidl", initialUIDL); @@ -2628,7 +2628,7 @@ public abstract class AbstractCommunicationManager implements Serializable { String rootId = parts[0]; String connectorId = parts[1]; String variableName = parts[2]; - UI uI = application.getRootById(Integer.parseInt(rootId)); + UI uI = application.getUIById(Integer.parseInt(rootId)); UI.setCurrent(uI); StreamVariable streamVariable = getStreamVariable(connectorId, diff --git a/server/src/com/vaadin/terminal/gwt/server/ApplicationServlet.java b/server/src/com/vaadin/terminal/gwt/server/ApplicationServlet.java index 52885f3fbb..14500b01de 100644 --- a/server/src/com/vaadin/terminal/gwt/server/ApplicationServlet.java +++ b/server/src/com/vaadin/terminal/gwt/server/ApplicationServlet.java @@ -70,7 +70,7 @@ public class ApplicationServlet extends AbstractApplicationServlet { // Creates a new application instance try { final Application application = getApplicationClass().newInstance(); - application.addRootProvider(new DefaultRootProvider()); + application.addUIProvider(new DefaultRootProvider()); return application; } catch (final IllegalAccessException e) { diff --git a/server/src/com/vaadin/terminal/gwt/server/BootstrapHandler.java b/server/src/com/vaadin/terminal/gwt/server/BootstrapHandler.java index e52c11e2c2..1dfe9d1685 100644 --- a/server/src/com/vaadin/terminal/gwt/server/BootstrapHandler.java +++ b/server/src/com/vaadin/terminal/gwt/server/BootstrapHandler.java @@ -127,13 +127,13 @@ public abstract class BootstrapHandler implements RequestHandler { // TODO Should all urls be handled here? Integer rootId = null; try { - UI uI = application.getRootForRequest(request); + UI uI = application.getUIForRequest(request); if (uI == null) { writeError(response, new Throwable("No UI found")); return true; } - rootId = Integer.valueOf(uI.getRootId()); + rootId = Integer.valueOf(uI.getUIId()); } catch (UIRequiresMoreInformationException e) { // Just keep going without rootId } @@ -297,7 +297,7 @@ public abstract class BootstrapHandler implements RequestHandler { UI uI = context.getRoot(); WrappedRequest request = context.getRequest(); - String widgetset = uI.getApplication().getWidgetsetForRoot(uI); + String widgetset = uI.getApplication().getWidgetsetForUI(uI); if (widgetset == null) { widgetset = request.getDeploymentConfiguration() .getConfiguredWidgetset(request); @@ -437,7 +437,7 @@ public abstract class BootstrapHandler implements RequestHandler { appConfig.put("widgetset", context.getWidgetsetName()); - if (rootId == null || application.isRootInitPending(rootId.intValue())) { + if (rootId == null || application.isUIInitPending(rootId.intValue())) { appConfig.put("initialPath", context.getRequest() .getRequestPathInfo()); @@ -533,7 +533,7 @@ public abstract class BootstrapHandler implements RequestHandler { * @return */ public String getThemeName(BootstrapContext context) { - return context.getApplication().getThemeForRoot(context.getRoot()); + return context.getApplication().getThemeForUI(context.getRoot()); } /** diff --git a/server/src/com/vaadin/terminal/gwt/server/BootstrapResponse.java b/server/src/com/vaadin/terminal/gwt/server/BootstrapResponse.java index b1a52cf79e..2518f7080e 100644 --- a/server/src/com/vaadin/terminal/gwt/server/BootstrapResponse.java +++ b/server/src/com/vaadin/terminal/gwt/server/BootstrapResponse.java @@ -92,7 +92,7 @@ public abstract class BootstrapResponse extends EventObject { /** * Gets the root id that has been generated for this response. Please note - * that if {@link Application#isRootPreserved()} is enabled, a previously + * that if {@link Application#isUiPreserved()} is enabled, a previously * created UI with a different id might eventually end up being used. * * @return the root id @@ -108,8 +108,8 @@ public abstract class BootstrapResponse extends EventObject { * browser has been sent back. This method will return null if * no UI instance is yet available. * - * @see Application#isRootPreserved() - * @see Application#getRoot(WrappedRequest) + * @see Application#isUiPreserved() + * @see Application#getUI(WrappedRequest) * @see UIRequiresMoreInformationException * * @return The UI that will be displayed in the page being generated, or diff --git a/server/src/com/vaadin/terminal/gwt/server/ServletPortletHelper.java b/server/src/com/vaadin/terminal/gwt/server/ServletPortletHelper.java index 13d558e66e..7e669d939c 100644 --- a/server/src/com/vaadin/terminal/gwt/server/ServletPortletHelper.java +++ b/server/src/com/vaadin/terminal/gwt/server/ServletPortletHelper.java @@ -44,7 +44,7 @@ class ServletPortletHelper implements Serializable { String applicationParameter = deploymentConfiguration .getInitParameters().getProperty("application"); String rootParameter = deploymentConfiguration.getInitParameters() - .getProperty(Application.ROOT_PARAMETER); + .getProperty(Application.UI_PARAMETER); ClassLoader classLoader = deploymentConfiguration.getClassLoader(); if (applicationParameter == null) { @@ -69,7 +69,7 @@ class ServletPortletHelper implements Serializable { private static void verifyRootClass(String className, ClassLoader classLoader) throws ApplicationClassException { if (className == null) { - throw new ApplicationClassException(Application.ROOT_PARAMETER + throw new ApplicationClassException(Application.UI_PARAMETER + " init parameter not defined"); } diff --git a/server/src/com/vaadin/ui/UI.java b/server/src/com/vaadin/ui/UI.java index e2facefb33..957e00385d 100644 --- a/server/src/com/vaadin/ui/UI.java +++ b/server/src/com/vaadin/ui/UI.java @@ -47,27 +47,28 @@ import com.vaadin.terminal.Resource; import com.vaadin.terminal.Vaadin6Component; import com.vaadin.terminal.WrappedRequest; import com.vaadin.terminal.WrappedRequest.BrowserDetails; +import com.vaadin.terminal.gwt.server.AbstractApplicationServlet; import com.vaadin.ui.Window.CloseListener; /** - * The topmost component in any component hierarchy. There is one root for every - * Vaadin instance in a browser window. A root may either represent an entire + * The topmost component in any component hierarchy. There is one UI for every + * Vaadin instance in a browser window. A UI may either represent an entire * browser window (or tab) or some part of a html page where a Vaadin * application is embedded. *

      - * The root is the server side entry point for various client side features that + * The UI is the server side entry point for various client side features that * are not represented as components added to a layout, e.g notifications, sub * windows, and executing javascript in the browser. *

      *

      - * When a new application instance is needed, typically because the user opens - * the application in a browser window, - * {@link Application#gerRoot(WrappedRequest)} is invoked to get a root. That - * method does by default create a root according to the - * {@value Application#ROOT_PARAMETER} parameter from web.xml. + * When a new UI instance is needed, typically because the user opens a URL in a + * browser window which points to {@link AbstractApplicationServlet}, + * {@link Application#getUIForRequest(WrappedRequest)} is invoked to get a UI. + * That method does by default create a root according to the + * {@value Application#UI_PARAMETER} parameter from web.xml. *

      *

      - * After a root has been created by the application, it is initialized using + * After a UI has been created by the application, it is initialized using * {@link #init(WrappedRequest)}. This method is intended to be overridden by * the developer to add components to the user interface and initialize * non-component functionality. The component hierarchy is initialized by @@ -76,13 +77,13 @@ import com.vaadin.ui.Window.CloseListener; *

      *

      * If a {@link EagerInit} annotation is present on a class extending - * UI, the framework will use a faster initialization method - * which will not ensure that {@link BrowserDetails} are present in the + * UI, the framework will use a faster initialization method which + * will not ensure that {@link BrowserDetails} are present in the * {@link WrappedRequest} passed to the init method. *

      * * @see #init(WrappedRequest) - * @see Application#getRoot(WrappedRequest) + * @see Application#getUI(WrappedRequest) * * @since 7.0 */ @@ -90,7 +91,7 @@ public abstract class UI extends AbstractComponentContainer implements Action.Container, Action.Notifier, Vaadin6Component { /** - * Helper class to emulate the main window from Vaadin 6 using roots. This + * Helper class to emulate the main window from Vaadin 6 using UIs. This * class should be used in the same way as Window used as a browser level * window in Vaadin 6 with {@link com.vaadin.Application.LegacyApplication} */ @@ -210,11 +211,11 @@ public abstract class UI extends AbstractComponentContainer implements } /** - * Opens the given resource in this root. The contents of this UI is + * Opens the given resource in this UI. The contents of this UI is * replaced by the {@code Resource}. * * @param resource - * the resource to show in this root + * the resource to show in this UI * * @deprecated As of 7.0, use getPage().open instead */ @@ -294,9 +295,9 @@ public abstract class UI extends AbstractComponentContainer implements } /** - * Adds a new {@link BrowserWindowResizeListener} to this root. The + * Adds a new {@link BrowserWindowResizeListener} to this UI. The * listener will be notified whenever the browser window within which - * this root resides is resized. + * this UI resides is resized. * * @param resizeListener * the listener to add @@ -312,7 +313,7 @@ public abstract class UI extends AbstractComponentContainer implements } /** - * Removes a {@link BrowserWindowResizeListener} from this root. The + * Removes a {@link BrowserWindowResizeListener} from this UI. The * listener will no longer be notified when the browser window is * resized. * @@ -326,7 +327,7 @@ public abstract class UI extends AbstractComponentContainer implements } /** - * Gets the last known height of the browser window in which this root + * Gets the last known height of the browser window in which this UI * resides. * * @return the browser window height in pixels @@ -338,7 +339,7 @@ public abstract class UI extends AbstractComponentContainer implements } /** - * Gets the last known width of the browser window in which this root + * Gets the last known width of the browser window in which this UI * resides. * * @return the browser window width in pixels @@ -389,12 +390,12 @@ public abstract class UI extends AbstractComponentContainer implements } /** - * The application to which this root belongs + * The application to which this UI belongs */ private Application application; /** - * List of windows in this root. + * List of windows in this UI. */ private final LinkedHashSet windows = new LinkedHashSet(); @@ -405,13 +406,13 @@ public abstract class UI extends AbstractComponentContainer implements private Component scrollIntoView; /** - * The id of this root, used to find the server side instance of the root - * form which a request originates. A negative value indicates that the root - * id has not yet been assigned by the Application. + * The id of this UI, used to find the server side instance of the UI form + * which a request originates. A negative value indicates that the UI id has + * not yet been assigned by the Application. * - * @see Application#nextRootId + * @see Application#nextUIId */ - private int rootId = -1; + private int uiId = -1; /** * Keeps track of the Actions added to this component, and manages the @@ -420,9 +421,9 @@ public abstract class UI extends AbstractComponentContainer implements protected ActionManager actionManager; /** - * Thread local for keeping track of the current root. + * Thread local for keeping track of the current UI. */ - private static final ThreadLocal currentRoot = new ThreadLocal(); + private static final ThreadLocal currentUI = new ThreadLocal(); /** Identifies the click event */ private ConnectorTracker connectorTracker = new ConnectorTracker(this); @@ -444,7 +445,7 @@ public abstract class UI extends AbstractComponentContainer implements }; /** - * Creates a new empty root without a caption. This root will have a + * Creates a new empty UI without a caption. This UI will have a * {@link VerticalLayout} with margins enabled as its content. */ public UI() { @@ -452,10 +453,10 @@ public abstract class UI extends AbstractComponentContainer implements } /** - * Creates a new root with the given component container as its content. + * Creates a new UI with the given component container as its content. * * @param content - * the content container to use as this roots content. + * the content container to use as this UIs content. * * @see #setContent(ComponentContainer) */ @@ -466,11 +467,11 @@ public abstract class UI extends AbstractComponentContainer implements } /** - * Creates a new empty root with the given caption. This root will have a + * Creates a new empty UI with the given caption. This UI will have a * {@link VerticalLayout} with margins enabled as its content. * * @param caption - * the caption of the root, used as the page title if there's + * the caption of the UI, used as the page title if there's * nothing but the application on the web page * * @see #setCaption(String) @@ -481,13 +482,13 @@ public abstract class UI extends AbstractComponentContainer implements } /** - * Creates a new root with the given caption and content. + * Creates a new UI with the given caption and content. * * @param caption - * the caption of the root, used as the page title if there's + * the caption of the UI, used as the page title if there's * nothing but the application on the web page * @param content - * the content container to use as this roots content. + * the content container to use as this UIs content. * * @see #setContent(ComponentContainer) * @see #setCaption(String) @@ -512,7 +513,7 @@ public abstract class UI extends AbstractComponentContainer implements /** * Overridden to return a value instead of referring to the parent. * - * @return this root + * @return this UI * * @see com.vaadin.ui.AbstractComponent#getRoot() */ @@ -622,7 +623,7 @@ public abstract class UI extends AbstractComponentContainer implements } /** - * Sets the application to which this root is assigned. It is not legal to + * Sets the application to which this UI is assigned. It is not legal to * change the application once it has been set nor to set a * null application. *

      @@ -652,46 +653,46 @@ public abstract class UI extends AbstractComponentContainer implements } /** - * Sets the id of this root within its application. The root id is used to - * route requests to the right root. + * Sets the id of this UI within its application. The UI id is used to route + * requests to the right UI. *

      * This method is mainly intended for internal use by the framework. *

      * - * @param rootId - * the id of this root + * @param uiId + * the id of this UI * * @throws IllegalStateException - * if the root id has already been set + * if the UI id has already been set * - * @see #getRootId() + * @see #getUIId() */ - public void setRootId(int rootId) { - if (this.rootId != -1) { + public void setUIId(int uiId) { + if (this.uiId != -1) { throw new IllegalStateException("UI id has already been defined"); } - this.rootId = rootId; + this.uiId = uiId; } /** - * Gets the id of the root, used to identify this root within its - * application when processing requests. The root id should be present in - * every request to the server that originates from this root. - * {@link Application#getRootForRequest(WrappedRequest)} uses this id to - * find the route to which the request belongs. + * Gets the id of the UI, used to identify this UI within its application + * when processing requests. The UI id should be present in every request to + * the server that originates from this UI. + * {@link Application#getUIForRequest(WrappedRequest)} uses this id to find + * the route to which the request belongs. * * @return */ - public int getRootId() { - return rootId; + public int getUIId() { + return uiId; } /** - * Adds a window as a subwindow inside this root. To open a new browser - * window or tab, you should instead use {@link open(Resource)} with an url + * Adds a window as a subwindow inside this UI. To open a new browser window + * or tab, you should instead use {@link open(Resource)} with an url * pointing to this application and ensure - * {@link Application#getRoot(WrappedRequest)} returns an appropriate root - * for the request. + * {@link Application#getUI(WrappedRequest)} returns an appropriate UI for + * the request. * * @param window * @throws IllegalArgumentException @@ -727,7 +728,7 @@ public abstract class UI extends AbstractComponentContainer implements } /** - * Remove the given subwindow from this root. + * Remove the given subwindow from this UI. * * Since Vaadin 6.5, {@link CloseListener}s are called also when explicitly * removing a window by calling this method. @@ -741,7 +742,7 @@ public abstract class UI extends AbstractComponentContainer implements */ public boolean removeWindow(Window window) { if (!windows.remove(window)) { - // Window window is not a subwindow of this root. + // Window window is not a subwindow of this UI. return false; } window.setParent(null); @@ -752,7 +753,7 @@ public abstract class UI extends AbstractComponentContainer implements } /** - * Gets all the windows added to this root. + * Gets all the windows added to this UI. * * @return an unmodifiable collection of windows */ @@ -792,28 +793,28 @@ public abstract class UI extends AbstractComponentContainer implements } /** - * Scrolls any component between the component and root to a suitable - * position so the component is visible to the user. The given component - * must belong to this root. + * Scrolls any component between the component and UI to a suitable position + * so the component is visible to the user. The given component must belong + * to this UI. * * @param component * the component to be scrolled into view * @throws IllegalArgumentException - * if {@code component} does not belong to this root + * if {@code component} does not belong to this UI */ public void scrollIntoView(Component component) throws IllegalArgumentException { if (component.getRoot() != this) { throw new IllegalArgumentException( - "The component where to scroll must belong to this root."); + "The component where to scroll must belong to this UI."); } scrollIntoView = component; markAsDirty(); } /** - * Gets the content of this root. The content is a component container that - * serves as the outermost item of the visual contents of this root. + * Gets the content of this UI. The content is a component container that + * serves as the outermost item of the visual contents of this UI. * * @return a component container to use as content * @@ -837,8 +838,8 @@ public abstract class UI extends AbstractComponentContainer implements } /** - * Sets the content of this root. The content is a component container that - * serves as the outermost item of the visual contents of this root. If no + * Sets the content of this UI. The content is a component container that + * serves as the outermost item of the visual contents of this UI. If no * content has been set, a {@link VerticalLayout} with margins enabled will * be used by default - see {@link #createDefaultLayout()}. The content can * also be set in a constructor. @@ -863,11 +864,11 @@ public abstract class UI extends AbstractComponentContainer implements } /** - * Adds a component to this root. The component is not added directly to the - * root, but instead to the content container ({@link #getContent()}). + * Adds a component to this UI. The component is not added directly to the + * UI, but instead to the content container ({@link #getContent()}). * * @param component - * the component to add to this root + * the component to add to this UI * * @see #getContent() */ @@ -878,7 +879,7 @@ public abstract class UI extends AbstractComponentContainer implements /** * This implementation removes the component from the content container ( - * {@link #getContent()}) instead of from the actual root. + * {@link #getContent()}) instead of from the actual UI. */ @Override public void removeComponent(Component component) { @@ -887,7 +888,7 @@ public abstract class UI extends AbstractComponentContainer implements /** * This implementation removes the components from the content container ( - * {@link #getContent()}) instead of from the actual root. + * {@link #getContent()}) instead of from the actual UI. */ @Override public void removeAllComponents() { @@ -910,13 +911,13 @@ public abstract class UI extends AbstractComponentContainer implements } /** - * Initializes this root. This method is intended to be overridden by + * Initializes this UI. This method is intended to be overridden by * subclasses to build the view and configure non-component functionality. * Performing the initialization in a constructor is not suggested as the - * state of the root is not properly set up when the constructor is invoked. + * state of the UI is not properly set up when the constructor is invoked. *

      * The {@link WrappedRequest} can be used to get information about the - * request that caused this root to be created. By default, the + * request that caused this UI to be created. By default, the * {@link BrowserDetails} will be available in the request. If the browser * details are not required, loading the application in the browser can take * some shortcuts giving a faster initial rendering. This can be indicated @@ -924,42 +925,41 @@ public abstract class UI extends AbstractComponentContainer implements *

      * * @param request - * the wrapped request that caused this root to be created + * the wrapped request that caused this UI to be created */ protected abstract void init(WrappedRequest request); /** - * Sets the thread local for the current root. This method is used by the + * Sets the thread local for the current UI. This method is used by the * framework to set the current application whenever a new request is * processed and it is cleared when the request has been processed. *

      * The application developer can also use this method to define the current - * root outside the normal request handling, e.g. when initiating custom + * UI outside the normal request handling, e.g. when initiating custom * background threads. *

      * * @param uI - * the root to register as the current root + * the UI to register as the current UI * * @see #getCurrent() * @see ThreadLocal */ - public static void setCurrent(UI uI) { - currentRoot.set(uI); + public static void setCurrent(UI ui) { + currentUI.set(ui); } /** - * Gets the currently used root. The current root is automatically defined - * when processing requests to the server. In other cases, (e.g. from - * background threads), the current root is not automatically defined. + * Gets the currently used UI. The current UI is automatically defined when + * processing requests to the server. In other cases, (e.g. from background + * threads), the current UI is not automatically defined. * - * @return the current root instance if available, otherwise - * null + * @return the current UI instance if available, otherwise null * * @see #setCurrent(UI) */ public static UI getCurrent() { - return currentRoot.get(); + return currentUI.get(); } public void setScrollTop(int scrollTop) { @@ -1027,10 +1027,10 @@ public abstract class UI extends AbstractComponentContainer implements } /** - * Add a click listener to the UI. The listener is called whenever the - * user clicks inside the UI. Also when the click targets a component - * inside the UI, provided the targeted component does not prevent the - * click event from propagating. + * Add a click listener to the UI. The listener is called whenever the user + * clicks inside the UI. Also when the click targets a component inside the + * UI, provided the targeted component does not prevent the click event from + * propagating. * * Use {@link #removeListener(ClickListener)} to remove the listener. * @@ -1082,7 +1082,7 @@ public abstract class UI extends AbstractComponentContainer implements } /** - * Shows a notification message on the middle of the root. The message + * Shows a notification message on the middle of the UI. The message * automatically disappears ("humanized message"). * * Care should be taken to to avoid XSS vulnerabilities as the caption is @@ -1105,7 +1105,7 @@ public abstract class UI extends AbstractComponentContainer implements } /** - * Shows a notification message the root. The position and behavior of the + * Shows a notification message the UI. The position and behavior of the * message depends on the type, which is one of the basic types defined in * {@link Notification}, for instance Notification.TYPE_WARNING_MESSAGE. * @@ -1132,8 +1132,8 @@ public abstract class UI extends AbstractComponentContainer implements /** * Shows a notification consisting of a bigger caption and a smaller - * description on the middle of the root. The message automatically - * disappears ("humanized message"). + * description on the middle of the UI. The message automatically disappears + * ("humanized message"). * * Care should be taken to to avoid XSS vulnerabilities as the caption and * description are rendered as html. diff --git a/tests/server-side/com/vaadin/tests/server/component/root/CustomRootClassLoader.java b/tests/server-side/com/vaadin/tests/server/component/root/CustomRootClassLoader.java index 27d66ca0d0..59b1299db2 100644 --- a/tests/server-side/com/vaadin/tests/server/component/root/CustomRootClassLoader.java +++ b/tests/server-side/com/vaadin/tests/server/component/root/CustomRootClassLoader.java @@ -56,7 +56,7 @@ public class CustomRootClassLoader extends TestCase { application.start(new ApplicationStartEvent(null, createConfigurationMock(), null)); - UI uI = application.getRootForRequest(createRequestMock(null)); + UI uI = application.getUIForRequest(createRequestMock(null)); assertTrue(uI instanceof MyRoot); } @@ -102,7 +102,7 @@ public class CustomRootClassLoader extends TestCase { createConfigurationMock(), null)); UI uI = application - .getRootForRequest(createRequestMock(loggingClassLoader)); + .getUIForRequest(createRequestMock(loggingClassLoader)); assertTrue(uI instanceof MyRoot); assertEquals(1, loggingClassLoader.requestedClasses.size()); assertEquals(MyRoot.class.getName(), @@ -113,12 +113,12 @@ public class CustomRootClassLoader extends TestCase { private Application createStubApplication() { return new Application() { { - addRootProvider(new DefaultRootProvider()); + addUIProvider(new DefaultRootProvider()); } @Override public String getProperty(String name) { - if (name.equals(ROOT_PARAMETER)) { + if (name.equals(UI_PARAMETER)) { return MyRoot.class.getName(); } else { return super.getProperty(name); @@ -126,11 +126,11 @@ public class CustomRootClassLoader extends TestCase { } @Override - public UI getRootForRequest(WrappedRequest request) + public UI getUIForRequest(WrappedRequest request) throws UIRequiresMoreInformationException { // Always create a new root for testing (can't directly use // getRoot as it's protected) - return getRoot(request); + return getUI(request); } }; } diff --git a/tests/testbench/com/vaadin/launcher/ApplicationRunnerServlet.java b/tests/testbench/com/vaadin/launcher/ApplicationRunnerServlet.java index 43d4ad699e..2611546203 100644 --- a/tests/testbench/com/vaadin/launcher/ApplicationRunnerServlet.java +++ b/tests/testbench/com/vaadin/launcher/ApplicationRunnerServlet.java @@ -112,10 +112,10 @@ public class ApplicationRunnerServlet extends AbstractApplicationServlet { final Class classToRun = getClassToRun(); if (UI.class.isAssignableFrom(classToRun)) { Application application = new Application(); - application.addRootProvider(new AbstractRootProvider() { + application.addUIProvider(new AbstractRootProvider() { @Override - public Class getRootClass( + public Class getUIClass( Application application, WrappedRequest request) throws UIRequiresMoreInformationException { return (Class) classToRun; diff --git a/tests/testbench/com/vaadin/tests/application/RefreshStatePreserve.java b/tests/testbench/com/vaadin/tests/application/RefreshStatePreserve.java index deff2bc486..b9b9c509c1 100644 --- a/tests/testbench/com/vaadin/tests/application/RefreshStatePreserve.java +++ b/tests/testbench/com/vaadin/tests/application/RefreshStatePreserve.java @@ -15,17 +15,17 @@ public class RefreshStatePreserve extends AbstractTestApplication { getContent().addComponent( new Label("window.name: " + request.getBrowserDetails().getWindowName())); - getContent().addComponent(new Label("UI id: " + getRootId())); + getContent().addComponent(new Label("UI id: " + getUIId())); } } @Override public void init() { super.init(); - setRootPreserved(true); - addRootProvider(new AbstractRootProvider() { + setUiPreserved(true); + addUIProvider(new AbstractRootProvider() { @Override - public Class getRootClass(Application application, + public Class getUIClass(Application application, WrappedRequest request) throws UIRequiresMoreInformationException { return RefreshStateRoot.class; diff --git a/tests/testbench/com/vaadin/tests/application/ThreadLocalInstances.java b/tests/testbench/com/vaadin/tests/application/ThreadLocalInstances.java index 96380b2185..fa5ab7d100 100644 --- a/tests/testbench/com/vaadin/tests/application/ThreadLocalInstances.java +++ b/tests/testbench/com/vaadin/tests/application/ThreadLocalInstances.java @@ -77,7 +77,7 @@ public class ThreadLocalInstances extends AbstractTestApplication { } @Override - protected UI getRoot(WrappedRequest request) + protected UI getUI(WrappedRequest request) throws UIRequiresMoreInformationException { return mainWindow; } diff --git a/tests/testbench/com/vaadin/tests/components/loginform/LoginFormWithMultipleWindows.java b/tests/testbench/com/vaadin/tests/components/loginform/LoginFormWithMultipleWindows.java index 515734338b..480c186df7 100644 --- a/tests/testbench/com/vaadin/tests/components/loginform/LoginFormWithMultipleWindows.java +++ b/tests/testbench/com/vaadin/tests/components/loginform/LoginFormWithMultipleWindows.java @@ -12,7 +12,7 @@ import com.vaadin.ui.UI.LegacyWindow; public class LoginFormWithMultipleWindows extends Application { @Override - protected UI getRoot(WrappedRequest request) { + protected UI getUI(WrappedRequest request) { return new LoginFormWindow(); } diff --git a/tests/testbench/com/vaadin/tests/components/root/LazyInitRoots.java b/tests/testbench/com/vaadin/tests/components/root/LazyInitRoots.java index 3c7862d298..89b43d4bdf 100644 --- a/tests/testbench/com/vaadin/tests/components/root/LazyInitRoots.java +++ b/tests/testbench/com/vaadin/tests/components/root/LazyInitRoots.java @@ -22,7 +22,7 @@ public class LazyInitRoots extends AbstractTestApplication { } @Override - public UI getRoot(WrappedRequest request) + public UI getUI(WrappedRequest request) throws UIRequiresMoreInformationException { if (request.getParameter("lazyCreate") != null) { // UI created on second request diff --git a/tests/testbench/com/vaadin/tests/components/root/RootsInMultipleTabs.java b/tests/testbench/com/vaadin/tests/components/root/RootsInMultipleTabs.java index 13bef59fe9..238983d906 100644 --- a/tests/testbench/com/vaadin/tests/components/root/RootsInMultipleTabs.java +++ b/tests/testbench/com/vaadin/tests/components/root/RootsInMultipleTabs.java @@ -23,9 +23,9 @@ public class RootsInMultipleTabs extends AbstractTestApplication { } public RootsInMultipleTabs() { - addRootProvider(new AbstractRootProvider() { + addUIProvider(new AbstractRootProvider() { @Override - public Class getRootClass(Application application, + public Class getUIClass(Application application, WrappedRequest request) throws UIRequiresMoreInformationException { return TabRoot.class; diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a1/CreatingPreserveState.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a1/CreatingPreserveState.java index 4181c071f0..39b11177b6 100644 --- a/tests/testbench/com/vaadin/tests/minitutorials/v7a1/CreatingPreserveState.java +++ b/tests/testbench/com/vaadin/tests/minitutorials/v7a1/CreatingPreserveState.java @@ -36,7 +36,7 @@ public class CreatingPreserveState extends UI { TextField tf = new TextField("Window #" + (++windowCounter)); tf.setImmediate(true); getContent().addComponent(tf); - getApplication().setRootPreserved(true); + getApplication().setUiPreserved(true); } } diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a1/DifferentFeaturesForDifferentClients.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a1/DifferentFeaturesForDifferentClients.java index 6b25f4674d..b0a33c14cf 100644 --- a/tests/testbench/com/vaadin/tests/minitutorials/v7a1/DifferentFeaturesForDifferentClients.java +++ b/tests/testbench/com/vaadin/tests/minitutorials/v7a1/DifferentFeaturesForDifferentClients.java @@ -35,7 +35,7 @@ import com.vaadin.ui.UI; public class DifferentFeaturesForDifferentClients extends Application { @Override - protected UI getRoot(WrappedRequest request) + protected UI getUI(WrappedRequest request) throws UIRequiresMoreInformationException { BrowserDetails browserDetails = request.getBrowserDetails(); // This is a limitation of 7.0.0.alpha1 that there is no better way to -- cgit v1.2.3 From 0b0ddb86876a965f68c6160fe7a499412b6c199d Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Fri, 24 Aug 2012 11:32:49 +0300 Subject: Component.getRoot() -> Component.getUI() (#8908) --- .../src/com/vaadin/terminal/AbstractClientConnector.java | 14 +++++++------- .../terminal/gwt/server/AbstractCommunicationManager.java | 4 ++-- .../com/vaadin/terminal/gwt/server/ClientConnector.java | 2 +- .../com/vaadin/terminal/gwt/server/DragAndDropService.java | 2 +- server/src/com/vaadin/ui/AbstractComponent.java | 10 +++++----- server/src/com/vaadin/ui/Component.java | 4 ++-- server/src/com/vaadin/ui/ConnectorTracker.java | 2 +- server/src/com/vaadin/ui/LoginForm.java | 2 +- server/src/com/vaadin/ui/UI.java | 12 ++++++------ server/src/com/vaadin/ui/Window.java | 4 ++-- .../com/vaadin/tests/server/TestStreamVariableMapping.java | 2 +- .../component/abstractfield/RemoveListenersOnDetach.java | 2 +- .../testbench/com/vaadin/tests/appengine/GAESyncTest.java | 4 ++-- .../com/vaadin/tests/components/TouchScrollables.java | 4 ++-- .../vaadin/tests/components/combobox/ComboBoxInPopup.java | 2 +- .../vaadin/tests/components/embedded/EmbeddedApplet.java | 2 +- .../com/vaadin/tests/components/embedded/EmbeddedPdf.java | 2 +- .../components/loginform/LoginFormRootInLoginHandler.java | 4 ++-- .../tests/components/orderedlayout/OrderedLayoutCases.java | 2 +- .../richtextarea/RichTextAreaWithKeyboardShortcuts.java | 4 ++-- .../com/vaadin/tests/components/table/TableInTabsheet.java | 2 +- .../tests/components/textfield/TextChangeEvents.java | 2 +- .../TextChangeListenerChangingNonTextProperties.java | 2 +- .../vaadin/tests/components/window/ExtraWindowShown.java | 2 +- .../components/window/SubWindowFocusAndBlurListeners.java | 2 +- .../vaadin/tests/components/window/WindowScrollingUp.java | 2 +- tests/testbench/com/vaadin/tests/dd/DDTest2.java | 2 +- tests/testbench/com/vaadin/tests/dd/DDTest4.java | 2 +- tests/testbench/com/vaadin/tests/dd/DDTest5.java | 2 +- tests/testbench/com/vaadin/tests/dd/DDTest6.java | 2 +- tests/testbench/com/vaadin/tests/dd/DDTest7.java | 2 +- .../tests/layouts/ComplexGLColumnExpansionWithColSpan.java | 2 +- .../com/vaadin/tests/serialization/SerializerTest.java | 4 ++-- tests/testbench/com/vaadin/tests/tickets/Ticket34.java | 2 +- 34 files changed, 57 insertions(+), 57 deletions(-) diff --git a/server/src/com/vaadin/terminal/AbstractClientConnector.java b/server/src/com/vaadin/terminal/AbstractClientConnector.java index 87e1dbaa38..157bd17e41 100644 --- a/server/src/com/vaadin/terminal/AbstractClientConnector.java +++ b/server/src/com/vaadin/terminal/AbstractClientConnector.java @@ -94,7 +94,7 @@ public abstract class AbstractClientConnector implements ClientConnector { /* Documentation copied from interface */ @Override public void markAsDirty() { - UI uI = getRoot(); + UI uI = getUI(); if (uI != null) { uI.getConnectorTracker().markDirty(this); } @@ -154,7 +154,7 @@ public abstract class AbstractClientConnector implements ClientConnector { sharedState = createState(); } - UI uI = getRoot(); + UI uI = getUI(); if (uI != null && !uI.getConnectorTracker().isDirty(this)) { requestRepaint(); } @@ -363,7 +363,7 @@ public abstract class AbstractClientConnector implements ClientConnector { * @return The connector's application, or null if not attached */ protected Application getApplication() { - UI uI = getRoot(); + UI uI = getUI(); if (uI == null) { return null; } else { @@ -380,7 +380,7 @@ public abstract class AbstractClientConnector implements ClientConnector { * is found. */ @Override - public UI getRoot() { + public UI getUI() { ClientConnector connector = this; while (connector != null) { if (connector instanceof UI) { @@ -528,7 +528,7 @@ public abstract class AbstractClientConnector implements ClientConnector { public void attach() { markAsDirty(); - getRoot().getConnectorTracker().registerConnector(this); + getUI().getConnectorTracker().registerConnector(this); for (ClientConnector connector : getAllChildrenIterable(this)) { connector.attach(); @@ -540,7 +540,7 @@ public abstract class AbstractClientConnector implements ClientConnector { * {@inheritDoc} * *

      - * The {@link #getApplication()} and {@link #getRoot()} methods might return + * The {@link #getApplication()} and {@link #getUI()} methods might return * null after this method is called. *

      */ @@ -550,7 +550,7 @@ public abstract class AbstractClientConnector implements ClientConnector { connector.detach(); } - getRoot().getConnectorTracker().unregisterConnector(this); + getUI().getConnectorTracker().unregisterConnector(this); } @Override diff --git a/server/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java b/server/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java index 7662564233..e19cfc4de6 100644 --- a/server/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java +++ b/server/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java @@ -1245,7 +1245,7 @@ public abstract class AbstractCommunicationManager implements Serializable { public static JSONObject encodeState(ClientConnector connector, SharedState state) throws JSONException { - UI uI = connector.getRoot(); + UI uI = connector.getUI(); ConnectorTracker connectorTracker = uI.getConnectorTracker(); Class stateType = connector.getStateType(); Object diffState = connectorTracker.getDiffState(connector); @@ -2353,7 +2353,7 @@ public abstract class AbstractCommunicationManager implements Serializable { * handling post */ String paintableId = owner.getConnectorId(); - int rootId = owner.getRoot().getUIId(); + int rootId = owner.getUI().getUIId(); String key = rootId + "/" + paintableId + "/" + name; if (pidToNameToStreamVariable == null) { diff --git a/server/src/com/vaadin/terminal/gwt/server/ClientConnector.java b/server/src/com/vaadin/terminal/gwt/server/ClientConnector.java index 3a18dbd6f4..1a5019a7c1 100644 --- a/server/src/com/vaadin/terminal/gwt/server/ClientConnector.java +++ b/server/src/com/vaadin/terminal/gwt/server/ClientConnector.java @@ -180,7 +180,7 @@ public interface ClientConnector extends Connector, RpcTarget { * @return The UI this connector is attached to or null if it is not * attached to any UI */ - public UI getRoot(); + public UI getUI(); /** * Called before the shared state and RPC invocations are sent to the diff --git a/server/src/com/vaadin/terminal/gwt/server/DragAndDropService.java b/server/src/com/vaadin/terminal/gwt/server/DragAndDropService.java index 42312b72fd..0106f466fc 100644 --- a/server/src/com/vaadin/terminal/gwt/server/DragAndDropService.java +++ b/server/src/com/vaadin/terminal/gwt/server/DragAndDropService.java @@ -327,7 +327,7 @@ public class DragAndDropService implements VariableOwner, ClientConnector { } @Override - public UI getRoot() { + public UI getUI() { return null; } diff --git a/server/src/com/vaadin/ui/AbstractComponent.java b/server/src/com/vaadin/ui/AbstractComponent.java index 147034fe6b..0b97e1667d 100644 --- a/server/src/com/vaadin/ui/AbstractComponent.java +++ b/server/src/com/vaadin/ui/AbstractComponent.java @@ -561,9 +561,9 @@ public abstract class AbstractComponent extends AbstractClientConnector * here, we use the default documentation from implemented interface. */ @Override - public UI getRoot() { + public UI getUI() { // Just make method from implemented Component interface public - return super.getRoot(); + return super.getUI(); } /* @@ -601,7 +601,7 @@ public abstract class AbstractComponent extends AbstractClientConnector if (this instanceof Focusable) { final Application app = getApplication(); if (app != null) { - getRoot().setFocusedComponent((Focusable) this); + getUI().setFocusedComponent((Focusable) this); delayedFocus = false; } else { delayedFocus = true; @@ -1310,13 +1310,13 @@ public abstract class AbstractComponent extends AbstractClientConnector * component. */ private void setActionManagerViewer() { - if (actionManager != null && getRoot() != null) { + if (actionManager != null && getUI() != null) { // Attached and has action manager Window w = findAncestor(Window.class); if (w != null) { actionManager.setViewer(w); } else { - actionManager.setViewer(getRoot()); + actionManager.setViewer(getUI()); } } diff --git a/server/src/com/vaadin/ui/Component.java b/server/src/com/vaadin/ui/Component.java index 7406303af9..400dd66cac 100644 --- a/server/src/com/vaadin/ui/Component.java +++ b/server/src/com/vaadin/ui/Component.java @@ -518,7 +518,7 @@ public interface Component extends ClientConnector, Sizeable, Serializable { * attached to a UI */ @Override - public UI getRoot(); + public UI getUI(); /** * Gets the application object to which the component is attached. @@ -548,7 +548,7 @@ public interface Component extends ClientConnector, Sizeable, Serializable { *

      * Reimplementing the {@code attach()} method is useful for tasks that need * to get a reference to the parent, window, or application object with the - * {@link #getParent()}, {@link #getRoot()}, and {@link #getApplication()} + * {@link #getParent()}, {@link #getUI()}, and {@link #getApplication()} * methods. A component does not yet know these objects in the constructor, * so in such case, the methods will return {@code null}. For example, the * following is invalid: diff --git a/server/src/com/vaadin/ui/ConnectorTracker.java b/server/src/com/vaadin/ui/ConnectorTracker.java index 3a6e1e4ea8..c7c7bc9784 100644 --- a/server/src/com/vaadin/ui/ConnectorTracker.java +++ b/server/src/com/vaadin/ui/ConnectorTracker.java @@ -244,7 +244,7 @@ public class ConnectorTracker implements Serializable { return null; } if (connector instanceof Component) { - return ((Component) connector).getRoot(); + return ((Component) connector).getUI(); } return getRootForConnector(connector.getParent()); diff --git a/server/src/com/vaadin/ui/LoginForm.java b/server/src/com/vaadin/ui/LoginForm.java index f127a2705b..1c154699d8 100644 --- a/server/src/com/vaadin/ui/LoginForm.java +++ b/server/src/com/vaadin/ui/LoginForm.java @@ -100,7 +100,7 @@ public class LoginForm extends CustomComponent { String requestPathInfo = request.getRequestPathInfo(); if ("/loginHandler".equals(requestPathInfo)) { // Ensure UI.getCurrent() works in listeners - UI.setCurrent(getRoot()); + UI.setCurrent(getUI()); response.setCacheTime(-1); response.setContentType("text/html; charset=utf-8"); diff --git a/server/src/com/vaadin/ui/UI.java b/server/src/com/vaadin/ui/UI.java index 957e00385d..c0b3ed9929 100644 --- a/server/src/com/vaadin/ui/UI.java +++ b/server/src/com/vaadin/ui/UI.java @@ -515,10 +515,10 @@ public abstract class UI extends AbstractComponentContainer implements * * @return this UI * - * @see com.vaadin.ui.AbstractComponent#getRoot() + * @see com.vaadin.ui.AbstractComponent#getUI() */ @Override - public UI getRoot() { + public UI getUI() { return this; } @@ -543,9 +543,9 @@ public abstract class UI extends AbstractComponentContainer implements if (pendingFocus != null) { // ensure focused component is still attached to this main window - if (pendingFocus.getRoot() == this - || (pendingFocus.getRoot() != null && pendingFocus - .getRoot().getParent() == this)) { + if (pendingFocus.getUI() == this + || (pendingFocus.getUI() != null && pendingFocus + .getUI().getParent() == this)) { target.addAttribute("focused", pendingFocus); } pendingFocus = null; @@ -804,7 +804,7 @@ public abstract class UI extends AbstractComponentContainer implements */ public void scrollIntoView(Component component) throws IllegalArgumentException { - if (component.getRoot() != this) { + if (component.getUI() != this) { throw new IllegalArgumentException( "The component where to scroll must belong to this UI."); } diff --git a/server/src/com/vaadin/ui/Window.java b/server/src/com/vaadin/ui/Window.java index 335f7fd67d..ad2bbd0576 100644 --- a/server/src/com/vaadin/ui/Window.java +++ b/server/src/com/vaadin/ui/Window.java @@ -222,7 +222,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, *

      */ public void close() { - UI uI = getRoot(); + UI uI = getUI(); // Don't do anything if not attached to a root if (uI != null) { @@ -476,7 +476,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, *

      */ public void bringToFront() { - UI uI = getRoot(); + UI uI = getUI(); if (uI == null) { throw new IllegalStateException( "Window must be attached to parent before calling bringToFront method."); diff --git a/tests/server-side/com/vaadin/tests/server/TestStreamVariableMapping.java b/tests/server-side/com/vaadin/tests/server/TestStreamVariableMapping.java index 4e26ffaf45..5ea4bc52c4 100644 --- a/tests/server-side/com/vaadin/tests/server/TestStreamVariableMapping.java +++ b/tests/server-side/com/vaadin/tests/server/TestStreamVariableMapping.java @@ -36,7 +36,7 @@ public class TestStreamVariableMapping extends TestCase { }; owner = new Upload() { @Override - public UI getRoot() { + public UI getUI() { return uI; } }; diff --git a/tests/server-side/com/vaadin/tests/server/component/abstractfield/RemoveListenersOnDetach.java b/tests/server-side/com/vaadin/tests/server/component/abstractfield/RemoveListenersOnDetach.java index dd1675c75d..3a251ecbb9 100644 --- a/tests/server-side/com/vaadin/tests/server/component/abstractfield/RemoveListenersOnDetach.java +++ b/tests/server-side/com/vaadin/tests/server/component/abstractfield/RemoveListenersOnDetach.java @@ -49,7 +49,7 @@ public class RemoveListenersOnDetach { } @Override - public com.vaadin.ui.UI getRoot() { + public com.vaadin.ui.UI getUI() { return uI; }; diff --git a/tests/testbench/com/vaadin/tests/appengine/GAESyncTest.java b/tests/testbench/com/vaadin/tests/appengine/GAESyncTest.java index 7a06dedd63..9fa716a23e 100644 --- a/tests/testbench/com/vaadin/tests/appengine/GAESyncTest.java +++ b/tests/testbench/com/vaadin/tests/appengine/GAESyncTest.java @@ -93,8 +93,8 @@ public class GAESyncTest extends Application.LegacyApplication { @Override public void buttonClick(ClickEvent event) { - if (getRoot() == getMainWindow()) { - getRoot().getPage().showNotification( + if (getUI() == getMainWindow()) { + getUI().getPage().showNotification( new Notification("main")); try { Thread.sleep((5000)); diff --git a/tests/testbench/com/vaadin/tests/components/TouchScrollables.java b/tests/testbench/com/vaadin/tests/components/TouchScrollables.java index 415f660c62..6c340804af 100644 --- a/tests/testbench/com/vaadin/tests/components/TouchScrollables.java +++ b/tests/testbench/com/vaadin/tests/components/TouchScrollables.java @@ -51,7 +51,7 @@ public class TouchScrollables extends TestBase { TestUtils .injectCSS( - getLayout().getRoot(), + getLayout().getUI(), "body * {-webkit-user-select: none;} .v-table-row-drag-middle .v-table-cell-content {" + " background-color: inherit ; border-bottom: 1px solid cyan;" + "}" @@ -81,7 +81,7 @@ public class TouchScrollables extends TestBase { new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { - getLayout().getRoot().scrollIntoView(l); + getLayout().getUI().scrollIntoView(l); } }); cssLayout.addComponent(button); diff --git a/tests/testbench/com/vaadin/tests/components/combobox/ComboBoxInPopup.java b/tests/testbench/com/vaadin/tests/components/combobox/ComboBoxInPopup.java index c0490c127d..393a8ceb6b 100644 --- a/tests/testbench/com/vaadin/tests/components/combobox/ComboBoxInPopup.java +++ b/tests/testbench/com/vaadin/tests/components/combobox/ComboBoxInPopup.java @@ -25,7 +25,7 @@ public class ComboBoxInPopup extends TestBase { close.setClickShortcut(KeyCode.ESCAPE, null); w.addComponent(close); - getLayout().getRoot().addWindow(w); + getLayout().getUI().addWindow(w); } diff --git a/tests/testbench/com/vaadin/tests/components/embedded/EmbeddedApplet.java b/tests/testbench/com/vaadin/tests/components/embedded/EmbeddedApplet.java index 1bb3e7abe2..5091f3a929 100644 --- a/tests/testbench/com/vaadin/tests/components/embedded/EmbeddedApplet.java +++ b/tests/testbench/com/vaadin/tests/components/embedded/EmbeddedApplet.java @@ -38,6 +38,6 @@ public class EmbeddedApplet extends TestBase { Window window = new Window("Testwindow"); window.addComponent(new Label("I am inside the window")); - applet.getRoot().addWindow(window); + applet.getUI().addWindow(window); } } diff --git a/tests/testbench/com/vaadin/tests/components/embedded/EmbeddedPdf.java b/tests/testbench/com/vaadin/tests/components/embedded/EmbeddedPdf.java index c3854d2420..252229cbe3 100644 --- a/tests/testbench/com/vaadin/tests/components/embedded/EmbeddedPdf.java +++ b/tests/testbench/com/vaadin/tests/components/embedded/EmbeddedPdf.java @@ -35,7 +35,7 @@ public class EmbeddedPdf extends TestBase { } })); - player.getRoot().addWindow(new Window("Testwindow")); + player.getUI().addWindow(new Window("Testwindow")); } } diff --git a/tests/testbench/com/vaadin/tests/components/loginform/LoginFormRootInLoginHandler.java b/tests/testbench/com/vaadin/tests/components/loginform/LoginFormRootInLoginHandler.java index db64df936f..b9076a152d 100755 --- a/tests/testbench/com/vaadin/tests/components/loginform/LoginFormRootInLoginHandler.java +++ b/tests/testbench/com/vaadin/tests/components/loginform/LoginFormRootInLoginHandler.java @@ -23,7 +23,7 @@ public class LoginFormRootInLoginHandler extends TestBase { } else { addComponent(new Label("UI.getCurrent() is null")); } - UI r2 = ((LoginForm) event.getSource()).getRoot(); + UI r2 = ((LoginForm) event.getSource()).getUI(); if (r2 != null) { addComponent(new Label("event.getSource().data: " + r2.getData())); @@ -34,7 +34,7 @@ public class LoginFormRootInLoginHandler extends TestBase { } }); addComponent(lf); - getLayout().getRoot().setData("This root"); + getLayout().getUI().setData("This root"); } @Override diff --git a/tests/testbench/com/vaadin/tests/components/orderedlayout/OrderedLayoutCases.java b/tests/testbench/com/vaadin/tests/components/orderedlayout/OrderedLayoutCases.java index 46fd6ee852..08793e9a9c 100644 --- a/tests/testbench/com/vaadin/tests/components/orderedlayout/OrderedLayoutCases.java +++ b/tests/testbench/com/vaadin/tests/components/orderedlayout/OrderedLayoutCases.java @@ -117,7 +117,7 @@ public class OrderedLayoutCases extends AbstractTestRoot { protected void setup(WrappedRequest request) { TestUtils .injectCSS( - getRoot(), + getUI(), ".sampleChild, .theLayout {border: 1px solid black;}" + ".theLayout > div:first-child {background: aqua;}" + ".theLayout > div:first-child + div {background: yellow;}" diff --git a/tests/testbench/com/vaadin/tests/components/richtextarea/RichTextAreaWithKeyboardShortcuts.java b/tests/testbench/com/vaadin/tests/components/richtextarea/RichTextAreaWithKeyboardShortcuts.java index 73d7a95e9f..6eaffa5cf3 100644 --- a/tests/testbench/com/vaadin/tests/components/richtextarea/RichTextAreaWithKeyboardShortcuts.java +++ b/tests/testbench/com/vaadin/tests/components/richtextarea/RichTextAreaWithKeyboardShortcuts.java @@ -48,7 +48,7 @@ public class RichTextAreaWithKeyboardShortcuts extends TestBase { @Override protected void setup() { - getLayout().getRoot().addActionHandler(actionHandler); + getLayout().getUI().addActionHandler(actionHandler); getLayout().addComponent(createRichTextArea("InMainLayout")); Panel panel = new Panel("RTA Panel"); @@ -61,7 +61,7 @@ public class RichTextAreaWithKeyboardShortcuts extends TestBase { w.addComponent(createRichTextArea("InSubWindow")); w.getContent().setSizeUndefined(); - getLayout().getRoot().addWindow(w); + getLayout().getUI().addWindow(w); } diff --git a/tests/testbench/com/vaadin/tests/components/table/TableInTabsheet.java b/tests/testbench/com/vaadin/tests/components/table/TableInTabsheet.java index 136dcfe9a5..9a94a203f1 100644 --- a/tests/testbench/com/vaadin/tests/components/table/TableInTabsheet.java +++ b/tests/testbench/com/vaadin/tests/components/table/TableInTabsheet.java @@ -18,7 +18,7 @@ public class TableInTabsheet extends AbstractTestRoot { @Override protected void setup(WrappedRequest request) { - getRoot().setCaption("test"); + getUI().setCaption("test"); VerticalLayout vPrinc = new VerticalLayout(); vPrinc.setStyleName(Reindeer.LAYOUT_BLUE); diff --git a/tests/testbench/com/vaadin/tests/components/textfield/TextChangeEvents.java b/tests/testbench/com/vaadin/tests/components/textfield/TextChangeEvents.java index a12a5a8836..b38dd36284 100644 --- a/tests/testbench/com/vaadin/tests/components/textfield/TextChangeEvents.java +++ b/tests/testbench/com/vaadin/tests/components/textfield/TextChangeEvents.java @@ -88,7 +88,7 @@ public class TextChangeEvents extends TestBase { @Override public void attach() { super.attach(); - TestUtils.injectCSS(getRoot(), ".match { background:green ;} " + TestUtils.injectCSS(getUI(), ".match { background:green ;} " + ".nomatch {background:red;}"); } diff --git a/tests/testbench/com/vaadin/tests/components/textfield/TextChangeListenerChangingNonTextProperties.java b/tests/testbench/com/vaadin/tests/components/textfield/TextChangeListenerChangingNonTextProperties.java index 5b84ff20f2..5991ac6ff7 100644 --- a/tests/testbench/com/vaadin/tests/components/textfield/TextChangeListenerChangingNonTextProperties.java +++ b/tests/testbench/com/vaadin/tests/components/textfield/TextChangeListenerChangingNonTextProperties.java @@ -24,7 +24,7 @@ public class TextChangeListenerChangingNonTextProperties extends TestBase { super.attach(); TestUtils .injectCSS( - getRoot(), + getUI(), ".red { background:red;} " + ".green { background:green;} .blue { background:blue;} .cyan { background:cyan;} .magenta { background:magenta;}"); } diff --git a/tests/testbench/com/vaadin/tests/components/window/ExtraWindowShown.java b/tests/testbench/com/vaadin/tests/components/window/ExtraWindowShown.java index fc8d7474af..1cdfdef0b5 100644 --- a/tests/testbench/com/vaadin/tests/components/window/ExtraWindowShown.java +++ b/tests/testbench/com/vaadin/tests/components/window/ExtraWindowShown.java @@ -29,7 +29,7 @@ public class ExtraWindowShown extends TestBase { iconButton .setIcon(new ThemeResource("../runo/icons/16/ok.png")); w.addComponent(iconButton); - event.getButton().getRoot().addWindow(w); + event.getButton().getUI().addWindow(w); } }); diff --git a/tests/testbench/com/vaadin/tests/components/window/SubWindowFocusAndBlurListeners.java b/tests/testbench/com/vaadin/tests/components/window/SubWindowFocusAndBlurListeners.java index e4a7e288ad..273d48514c 100644 --- a/tests/testbench/com/vaadin/tests/components/window/SubWindowFocusAndBlurListeners.java +++ b/tests/testbench/com/vaadin/tests/components/window/SubWindowFocusAndBlurListeners.java @@ -64,7 +64,7 @@ public class SubWindowFocusAndBlurListeners extends TestBase { } }); - UI main = getLayout().getRoot(); + UI main = getLayout().getUI(); main.addWindow(window); diff --git a/tests/testbench/com/vaadin/tests/components/window/WindowScrollingUp.java b/tests/testbench/com/vaadin/tests/components/window/WindowScrollingUp.java index 0f0db3a028..5f55ad8cf3 100644 --- a/tests/testbench/com/vaadin/tests/components/window/WindowScrollingUp.java +++ b/tests/testbench/com/vaadin/tests/components/window/WindowScrollingUp.java @@ -28,7 +28,7 @@ public class WindowScrollingUp extends AbstractTestCase { @Override public void buttonClick(ClickEvent event) { - up.getRoot().setScrollTop(0); + up.getUI().setScrollTop(0); } }); diff --git a/tests/testbench/com/vaadin/tests/dd/DDTest2.java b/tests/testbench/com/vaadin/tests/dd/DDTest2.java index 99020d0b5b..4d649c6056 100644 --- a/tests/testbench/com/vaadin/tests/dd/DDTest2.java +++ b/tests/testbench/com/vaadin/tests/dd/DDTest2.java @@ -45,7 +45,7 @@ public class DDTest2 extends TestBase { @Override protected void setup() { - UI w = getLayout().getRoot(); + UI w = getLayout().getUI(); /* darn reindeer has no icons */ /* Make all trees (their nodes actually) draggable */ diff --git a/tests/testbench/com/vaadin/tests/dd/DDTest4.java b/tests/testbench/com/vaadin/tests/dd/DDTest4.java index bb85dff0b6..044fe1f49a 100644 --- a/tests/testbench/com/vaadin/tests/dd/DDTest4.java +++ b/tests/testbench/com/vaadin/tests/dd/DDTest4.java @@ -28,7 +28,7 @@ public class DDTest4 extends TestBase { @Override protected void setup() { - UI w = getLayout().getRoot(); + UI w = getLayout().getUI(); TestUtils .injectCSS( diff --git a/tests/testbench/com/vaadin/tests/dd/DDTest5.java b/tests/testbench/com/vaadin/tests/dd/DDTest5.java index cb99b17da4..43342fdc35 100644 --- a/tests/testbench/com/vaadin/tests/dd/DDTest5.java +++ b/tests/testbench/com/vaadin/tests/dd/DDTest5.java @@ -47,7 +47,7 @@ public class DDTest5 extends TestBase { @Override protected void setup() { - UI w = getLayout().getRoot(); + UI w = getLayout().getUI(); HorizontalSortableCssLayoutWithWrappers verticalSortableCssLayoutWithWrappers = new HorizontalSortableCssLayoutWithWrappers(); w.addWindow(verticalSortableCssLayoutWithWrappers); diff --git a/tests/testbench/com/vaadin/tests/dd/DDTest6.java b/tests/testbench/com/vaadin/tests/dd/DDTest6.java index c6ac0b1859..f1e31c1452 100644 --- a/tests/testbench/com/vaadin/tests/dd/DDTest6.java +++ b/tests/testbench/com/vaadin/tests/dd/DDTest6.java @@ -164,7 +164,7 @@ public class DDTest6 extends TestBase { getLayout().addComponent(sp); TestUtils .injectCSS( - getLayout().getRoot(), + getLayout().getUI(), "" + ".v-tree .v-icon {height:16px;} " + ".v-tree-node-caption-drag-top {/*border-top: none;*/} " diff --git a/tests/testbench/com/vaadin/tests/dd/DDTest7.java b/tests/testbench/com/vaadin/tests/dd/DDTest7.java index 2af93c6c72..1abf9e379c 100644 --- a/tests/testbench/com/vaadin/tests/dd/DDTest7.java +++ b/tests/testbench/com/vaadin/tests/dd/DDTest7.java @@ -29,7 +29,7 @@ public class DDTest7 extends TestBase { @Override protected void setup() { - UI w = getLayout().getRoot(); + UI w = getLayout().getUI(); TestUtils .injectCSS( diff --git a/tests/testbench/com/vaadin/tests/layouts/ComplexGLColumnExpansionWithColSpan.java b/tests/testbench/com/vaadin/tests/layouts/ComplexGLColumnExpansionWithColSpan.java index 25821cb92c..7877ca3fe3 100644 --- a/tests/testbench/com/vaadin/tests/layouts/ComplexGLColumnExpansionWithColSpan.java +++ b/tests/testbench/com/vaadin/tests/layouts/ComplexGLColumnExpansionWithColSpan.java @@ -73,7 +73,7 @@ public class ComplexGLColumnExpansionWithColSpan extends AbstractTestCase { restart.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { - mainLayout.getRoot().getApplication().close(); + mainLayout.getUI().getApplication().close(); } }); diff --git a/tests/testbench/com/vaadin/tests/serialization/SerializerTest.java b/tests/testbench/com/vaadin/tests/serialization/SerializerTest.java index a301ecf828..3e194010d1 100644 --- a/tests/testbench/com/vaadin/tests/serialization/SerializerTest.java +++ b/tests/testbench/com/vaadin/tests/serialization/SerializerTest.java @@ -98,12 +98,12 @@ public class SerializerTest extends AbstractTestRoot { }, new HashMap() { { put(testExtension, true); - put(getRoot(), false); + put(getUI(), false); } }, new HashMap() { { put(5, testExtension); - put(10, getRoot()); + put(10, getUI()); } }, new HashMap() { { diff --git a/tests/testbench/com/vaadin/tests/tickets/Ticket34.java b/tests/testbench/com/vaadin/tests/tickets/Ticket34.java index 15d55ba643..67db77a5af 100644 --- a/tests/testbench/com/vaadin/tests/tickets/Ticket34.java +++ b/tests/testbench/com/vaadin/tests/tickets/Ticket34.java @@ -95,7 +95,7 @@ public class Ticket34 extends Application.LegacyApplication { public void buttonClick(ClickEvent event) { String viewName = tf.getValue().toString(); // fragmentChangedListener will change the view if possible - event.getButton().getRoot().getPage().setFragment(viewName); + event.getButton().getUI().getPage().setFragment(viewName); } }); -- cgit v1.2.3 From 5c557b50bc5f7f754d60a2ed435907b897b6750b Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Fri, 24 Aug 2012 11:47:50 +0300 Subject: Remaining Root -> UI renames (#8908) --- .../gwt/client/ApplicationConfiguration.java | 10 ++- .../terminal/gwt/client/ApplicationConnection.java | 5 +- .../terminal/gwt/client/ui/UI/UIConnector.java | 16 ++-- .../com/vaadin/terminal/gwt/client/ui/UI/VUI.java | 4 +- .../gwt/client/ui/notification/VNotification.java | 24 +++--- server/src/com/vaadin/Application.java | 5 +- .../vaadin/UIRequiresMoreInformationException.java | 2 +- .../com/vaadin/terminal/AbstractRootProvider.java | 35 --------- .../com/vaadin/terminal/AbstractUIProvider.java | 35 +++++++++ .../com/vaadin/terminal/DefaultRootProvider.java | 51 ------------- .../src/com/vaadin/terminal/DefaultUIProvider.java | 51 +++++++++++++ server/src/com/vaadin/terminal/Page.java | 26 +++---- server/src/com/vaadin/terminal/WrappedRequest.java | 5 +- .../gwt/server/AbstractApplicationPortlet.java | 16 ++-- .../gwt/server/AbstractApplicationServlet.java | 4 +- .../gwt/server/AbstractCommunicationManager.java | 88 +++++++++++----------- .../terminal/gwt/server/ApplicationServlet.java | 4 +- .../gwt/server/BootstrapFragmentResponse.java | 9 +-- .../terminal/gwt/server/BootstrapHandler.java | 57 +++++++------- .../terminal/gwt/server/BootstrapPageResponse.java | 6 +- .../terminal/gwt/server/BootstrapResponse.java | 25 +++--- .../terminal/gwt/server/ClientConnector.java | 2 +- .../com/vaadin/terminal/gwt/server/Constants.java | 2 +- .../gwt/server/PortletApplicationContext2.java | 2 +- .../terminal/gwt/server/ServletPortletHelper.java | 18 ++--- server/src/com/vaadin/ui/AbstractComponent.java | 12 +-- server/src/com/vaadin/ui/ConnectorTracker.java | 6 +- server/src/com/vaadin/ui/UI.java | 18 ++--- server/src/com/vaadin/ui/Window.java | 8 +- .../com/vaadin/shared/ApplicationConstants.java | 4 - .../com/vaadin/shared/ui/root/PageClientRpc.java | 25 ------ .../com/vaadin/shared/ui/root/RootConstants.java | 44 ----------- .../src/com/vaadin/shared/ui/root/UIServerRpc.java | 26 ------- shared/src/com/vaadin/shared/ui/root/UIState.java | 32 -------- .../src/com/vaadin/shared/ui/ui/PageClientRpc.java | 25 ++++++ .../src/com/vaadin/shared/ui/ui/UIConstants.java | 49 ++++++++++++ .../src/com/vaadin/shared/ui/ui/UIServerRpc.java | 26 +++++++ shared/src/com/vaadin/shared/ui/ui/UIState.java | 32 ++++++++ .../component/root/CustomRootClassLoader.java | 4 +- .../vaadin/launcher/ApplicationRunnerServlet.java | 4 +- .../tests/application/RefreshStatePreserve.java | 4 +- .../tests/components/root/RootsInMultipleTabs.java | 4 +- .../vaadincontext/TestAddonContextListener.java | 2 +- 43 files changed, 408 insertions(+), 419 deletions(-) delete mode 100644 server/src/com/vaadin/terminal/AbstractRootProvider.java create mode 100644 server/src/com/vaadin/terminal/AbstractUIProvider.java delete mode 100644 server/src/com/vaadin/terminal/DefaultRootProvider.java create mode 100644 server/src/com/vaadin/terminal/DefaultUIProvider.java delete mode 100644 shared/src/com/vaadin/shared/ui/root/PageClientRpc.java delete mode 100644 shared/src/com/vaadin/shared/ui/root/RootConstants.java delete mode 100644 shared/src/com/vaadin/shared/ui/root/UIServerRpc.java delete mode 100644 shared/src/com/vaadin/shared/ui/root/UIState.java create mode 100644 shared/src/com/vaadin/shared/ui/ui/PageClientRpc.java create mode 100644 shared/src/com/vaadin/shared/ui/ui/UIConstants.java create mode 100644 shared/src/com/vaadin/shared/ui/ui/UIServerRpc.java create mode 100644 shared/src/com/vaadin/shared/ui/ui/UIState.java diff --git a/client/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java b/client/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java index aa7a9fc72a..6621de7f95 100644 --- a/client/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java +++ b/client/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java @@ -31,6 +31,7 @@ import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.user.client.Command; import com.google.gwt.user.client.Window; import com.vaadin.shared.ApplicationConstants; +import com.vaadin.shared.ui.ui.UIConstants; import com.vaadin.terminal.gwt.client.metadata.BundleLoadCallback; import com.vaadin.terminal.gwt.client.metadata.ConnectorBundleLoader; import com.vaadin.terminal.gwt.client.metadata.NoDataException; @@ -202,7 +203,7 @@ public class ApplicationConfiguration implements EntryPoint { private String id; private String themeUri; private String appUri; - private int rootId; + private int uiId; private boolean standalone; private ErrorMessage communicationError; private ErrorMessage authorizationError; @@ -288,8 +289,8 @@ public class ApplicationConfiguration implements EntryPoint { * * @return the root id */ - public int getRootId() { - return rootId; + public int getUIId() { + return uiId; } public JavaScriptObject getVersionInfoJSObject() { @@ -314,7 +315,8 @@ public class ApplicationConfiguration implements EntryPoint { appUri += '/'; } themeUri = jsoConfiguration.getConfigString("themeUri"); - rootId = jsoConfiguration.getConfigInteger("rootId").intValue(); + uiId = jsoConfiguration.getConfigInteger(UIConstants.UI_ID_PARAMETER) + .intValue(); // null -> true useDebugIdInDom = jsoConfiguration.getConfigBoolean("useDebugIdInDom") != Boolean.FALSE; diff --git a/client/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java b/client/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java index 44f52d3e7f..fc063a1908 100644 --- a/client/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java +++ b/client/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java @@ -58,6 +58,7 @@ import com.vaadin.shared.Version; import com.vaadin.shared.communication.LegacyChangeVariablesInvocation; import com.vaadin.shared.communication.MethodInvocation; import com.vaadin.shared.communication.SharedState; +import com.vaadin.shared.ui.ui.UIConstants; import com.vaadin.terminal.gwt.client.ApplicationConfiguration.ErrorMessage; import com.vaadin.terminal.gwt.client.ResourceLoader.ResourceLoadEvent; import com.vaadin.terminal.gwt.client.ResourceLoader.ResourceLoadListener; @@ -495,8 +496,8 @@ public class ApplicationConnection { if (extraParams != null && extraParams.length() > 0) { uri = addGetParameters(uri, extraParams); } - uri = addGetParameters(uri, ApplicationConstants.ROOT_ID_PARAMETER - + "=" + configuration.getRootId()); + uri = addGetParameters(uri, UIConstants.UI_ID_PARAMETER + "=" + + configuration.getUIId()); doUidlRequest(uri, payload, forceSync); diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/UI/UIConnector.java b/client/src/com/vaadin/terminal/gwt/client/ui/UI/UIConnector.java index 2fb48623fd..f260481c3c 100644 --- a/client/src/com/vaadin/terminal/gwt/client/ui/UI/UIConnector.java +++ b/client/src/com/vaadin/terminal/gwt/client/ui/UI/UIConnector.java @@ -36,10 +36,10 @@ import com.google.web.bindery.event.shared.HandlerRegistration; import com.vaadin.shared.MouseEventDetails; import com.vaadin.shared.ui.Connect; import com.vaadin.shared.ui.Connect.LoadStyle; -import com.vaadin.shared.ui.root.PageClientRpc; -import com.vaadin.shared.ui.root.RootConstants; -import com.vaadin.shared.ui.root.UIServerRpc; -import com.vaadin.shared.ui.root.UIState; +import com.vaadin.shared.ui.ui.PageClientRpc; +import com.vaadin.shared.ui.ui.UIConstants; +import com.vaadin.shared.ui.ui.UIServerRpc; +import com.vaadin.shared.ui.ui.UIState; import com.vaadin.terminal.gwt.client.ApplicationConnection; import com.vaadin.terminal.gwt.client.BrowserInfo; import com.vaadin.terminal.gwt.client.ComponentConnector; @@ -107,7 +107,7 @@ public class UIConnector extends AbstractComponentContainerConnector getWidget().connection = client; getWidget().immediate = getState().isImmediate(); - getWidget().resizeLazy = uidl.hasAttribute(RootConstants.RESIZE_LAZY); + getWidget().resizeLazy = uidl.hasAttribute(UIConstants.RESIZE_LAZY); String newTheme = uidl.getStringAttribute("theme"); if (getWidget().theme != null && !newTheme.equals(getWidget().theme)) { // Complete page refresh is needed due css can affect layout @@ -263,9 +263,9 @@ public class UIConnector extends AbstractComponentContainerConnector scrollIntoView(connector); } - if (uidl.hasAttribute(RootConstants.FRAGMENT_VARIABLE)) { + if (uidl.hasAttribute(UIConstants.FRAGMENT_VARIABLE)) { getWidget().currentFragment = uidl - .getStringAttribute(RootConstants.FRAGMENT_VARIABLE); + .getStringAttribute(UIConstants.FRAGMENT_VARIABLE); if (!getWidget().currentFragment.equals(History.getToken())) { History.newItem(getWidget().currentFragment, true); } @@ -276,7 +276,7 @@ public class UIConnector extends AbstractComponentContainerConnector // Include current fragment in the next request client.updateVariable(getWidget().id, - RootConstants.FRAGMENT_VARIABLE, + UIConstants.FRAGMENT_VARIABLE, getWidget().currentFragment, false); } diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/UI/VUI.java b/client/src/com/vaadin/terminal/gwt/client/ui/UI/VUI.java index cb6b181f1d..1c4b69a3b9 100644 --- a/client/src/com/vaadin/terminal/gwt/client/ui/UI/VUI.java +++ b/client/src/com/vaadin/terminal/gwt/client/ui/UI/VUI.java @@ -33,7 +33,7 @@ import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.ui.SimplePanel; import com.vaadin.shared.ApplicationConstants; -import com.vaadin.shared.ui.root.RootConstants; +import com.vaadin.shared.ui.ui.UIConstants; import com.vaadin.terminal.gwt.client.ApplicationConnection; import com.vaadin.terminal.gwt.client.BrowserInfo; import com.vaadin.terminal.gwt.client.ComponentConnector; @@ -130,7 +130,7 @@ public class VUI extends SimplePanel implements ResizeHandler, // Send the new fragment to the server if it has changed if (!newFragment.equals(currentFragment) && connection != null) { currentFragment = newFragment; - connection.updateVariable(id, RootConstants.FRAGMENT_VARIABLE, + connection.updateVariable(id, UIConstants.FRAGMENT_VARIABLE, newFragment, true); } } diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/notification/VNotification.java b/client/src/com/vaadin/terminal/gwt/client/ui/notification/VNotification.java index b4cea2dc72..b668c9a88c 100644 --- a/client/src/com/vaadin/terminal/gwt/client/ui/notification/VNotification.java +++ b/client/src/com/vaadin/terminal/gwt/client/ui/notification/VNotification.java @@ -30,7 +30,7 @@ import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.Widget; import com.vaadin.shared.Position; -import com.vaadin.shared.ui.root.RootConstants; +import com.vaadin.shared.ui.ui.UIConstants; import com.vaadin.terminal.gwt.client.ApplicationConnection; import com.vaadin.terminal.gwt.client.BrowserInfo; import com.vaadin.terminal.gwt.client.UIDL; @@ -384,19 +384,19 @@ public class VNotification extends VOverlay { public static void showNotification(ApplicationConnection client, final UIDL notification) { boolean onlyPlainText = notification - .hasAttribute(RootConstants.NOTIFICATION_HTML_CONTENT_NOT_ALLOWED); + .hasAttribute(UIConstants.NOTIFICATION_HTML_CONTENT_NOT_ALLOWED); String html = ""; if (notification - .hasAttribute(RootConstants.ATTRIBUTE_NOTIFICATION_ICON)) { + .hasAttribute(UIConstants.ATTRIBUTE_NOTIFICATION_ICON)) { final String parsedUri = client .translateVaadinUri(notification - .getStringAttribute(RootConstants.ATTRIBUTE_NOTIFICATION_ICON)); + .getStringAttribute(UIConstants.ATTRIBUTE_NOTIFICATION_ICON)); html += ""; } if (notification - .hasAttribute(RootConstants.ATTRIBUTE_NOTIFICATION_CAPTION)) { + .hasAttribute(UIConstants.ATTRIBUTE_NOTIFICATION_CAPTION)) { String caption = notification - .getStringAttribute(RootConstants.ATTRIBUTE_NOTIFICATION_CAPTION); + .getStringAttribute(UIConstants.ATTRIBUTE_NOTIFICATION_CAPTION); if (onlyPlainText) { caption = Util.escapeHTML(caption); caption = caption.replaceAll("\\n", "
      "); @@ -404,9 +404,9 @@ public class VNotification extends VOverlay { html += "

      " + caption + "

      "; } if (notification - .hasAttribute(RootConstants.ATTRIBUTE_NOTIFICATION_MESSAGE)) { + .hasAttribute(UIConstants.ATTRIBUTE_NOTIFICATION_MESSAGE)) { String message = notification - .getStringAttribute(RootConstants.ATTRIBUTE_NOTIFICATION_MESSAGE); + .getStringAttribute(UIConstants.ATTRIBUTE_NOTIFICATION_MESSAGE); if (onlyPlainText) { message = Util.escapeHTML(message); message = message.replaceAll("\\n", "
      "); @@ -415,16 +415,16 @@ public class VNotification extends VOverlay { } final String style = notification - .hasAttribute(RootConstants.ATTRIBUTE_NOTIFICATION_STYLE) ? notification - .getStringAttribute(RootConstants.ATTRIBUTE_NOTIFICATION_STYLE) + .hasAttribute(UIConstants.ATTRIBUTE_NOTIFICATION_STYLE) ? notification + .getStringAttribute(UIConstants.ATTRIBUTE_NOTIFICATION_STYLE) : null; final int pos = notification - .getIntAttribute(RootConstants.ATTRIBUTE_NOTIFICATION_POSITION); + .getIntAttribute(UIConstants.ATTRIBUTE_NOTIFICATION_POSITION); Position position = Position.values()[pos]; final int delay = notification - .getIntAttribute(RootConstants.ATTRIBUTE_NOTIFICATION_DELAY); + .getIntAttribute(UIConstants.ATTRIBUTE_NOTIFICATION_DELAY); createNotification(delay).show(html, position, style); } diff --git a/server/src/com/vaadin/Application.java b/server/src/com/vaadin/Application.java index 1827a55b72..96d38e31cf 100644 --- a/server/src/com/vaadin/Application.java +++ b/server/src/com/vaadin/Application.java @@ -51,7 +51,7 @@ import com.vaadin.data.util.converter.ConverterFactory; import com.vaadin.data.util.converter.DefaultConverterFactory; import com.vaadin.event.EventRouter; import com.vaadin.service.ApplicationContext; -import com.vaadin.shared.ApplicationConstants; +import com.vaadin.shared.ui.ui.UIConstants; import com.vaadin.terminal.AbstractErrorMessage; import com.vaadin.terminal.ApplicationResource; import com.vaadin.terminal.CombinedRequest; @@ -2264,8 +2264,7 @@ public class Application implements Terminal.ErrorListener, Serializable { CombinedRequest combinedRequest = (CombinedRequest) request; request = combinedRequest.getSecondRequest(); } - String uiIdString = request - .getParameter(ApplicationConstants.ROOT_ID_PARAMETER); + String uiIdString = request.getParameter(UIConstants.UI_ID_PARAMETER); Integer uiId = uiIdString == null ? null : new Integer(uiIdString); return uiId; } diff --git a/server/src/com/vaadin/UIRequiresMoreInformationException.java b/server/src/com/vaadin/UIRequiresMoreInformationException.java index 0d491895e5..493c31acb6 100644 --- a/server/src/com/vaadin/UIRequiresMoreInformationException.java +++ b/server/src/com/vaadin/UIRequiresMoreInformationException.java @@ -20,7 +20,7 @@ import com.vaadin.terminal.WrappedRequest; import com.vaadin.terminal.WrappedRequest.BrowserDetails; /** - * Exception that is thrown to indicate that creating or initializing the root + * Exception that is thrown to indicate that creating or initializing the UI * requires information detailed from the web browser ({@link BrowserDetails}) * to be present. * diff --git a/server/src/com/vaadin/terminal/AbstractRootProvider.java b/server/src/com/vaadin/terminal/AbstractRootProvider.java deleted file mode 100644 index f316a58f15..0000000000 --- a/server/src/com/vaadin/terminal/AbstractRootProvider.java +++ /dev/null @@ -1,35 +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.terminal; - -import com.vaadin.Application; -import com.vaadin.ui.UI; - -public abstract class AbstractRootProvider implements UIProvider { - - @Override - public UI instantiateUI(Application application, - Class type, WrappedRequest request) { - try { - return type.newInstance(); - } catch (InstantiationException e) { - throw new RuntimeException("Could not instantiate root class", e); - } catch (IllegalAccessException e) { - throw new RuntimeException("Could not access root class", e); - } - } -} diff --git a/server/src/com/vaadin/terminal/AbstractUIProvider.java b/server/src/com/vaadin/terminal/AbstractUIProvider.java new file mode 100644 index 0000000000..5bb4d35b30 --- /dev/null +++ b/server/src/com/vaadin/terminal/AbstractUIProvider.java @@ -0,0 +1,35 @@ +/* + * 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.terminal; + +import com.vaadin.Application; +import com.vaadin.ui.UI; + +public abstract class AbstractUIProvider implements UIProvider { + + @Override + public UI instantiateUI(Application application, + Class type, WrappedRequest request) { + try { + return type.newInstance(); + } catch (InstantiationException e) { + throw new RuntimeException("Could not instantiate root class", e); + } catch (IllegalAccessException e) { + throw new RuntimeException("Could not access root class", e); + } + } +} diff --git a/server/src/com/vaadin/terminal/DefaultRootProvider.java b/server/src/com/vaadin/terminal/DefaultRootProvider.java deleted file mode 100644 index b201be513d..0000000000 --- a/server/src/com/vaadin/terminal/DefaultRootProvider.java +++ /dev/null @@ -1,51 +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.terminal; - -import com.vaadin.Application; -import com.vaadin.UIRequiresMoreInformationException; -import com.vaadin.ui.UI; - -public class DefaultRootProvider extends AbstractRootProvider { - - @Override - public Class getUIClass(Application application, - WrappedRequest request) throws UIRequiresMoreInformationException { - Object rootClassNameObj = application - .getProperty(Application.UI_PARAMETER); - - if (rootClassNameObj instanceof String) { - String rootClassName = rootClassNameObj.toString(); - - ClassLoader classLoader = request.getDeploymentConfiguration() - .getClassLoader(); - if (classLoader == null) { - classLoader = getClass().getClassLoader(); - } - try { - Class rootClass = Class.forName(rootClassName, - true, classLoader).asSubclass(UI.class); - - return rootClass; - } catch (ClassNotFoundException e) { - throw new RuntimeException("Could not find root class", e); - } - } - - return null; - } -} diff --git a/server/src/com/vaadin/terminal/DefaultUIProvider.java b/server/src/com/vaadin/terminal/DefaultUIProvider.java new file mode 100644 index 0000000000..8713c45b31 --- /dev/null +++ b/server/src/com/vaadin/terminal/DefaultUIProvider.java @@ -0,0 +1,51 @@ +/* + * 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.terminal; + +import com.vaadin.Application; +import com.vaadin.UIRequiresMoreInformationException; +import com.vaadin.ui.UI; + +public class DefaultUIProvider extends AbstractUIProvider { + + @Override + public Class getUIClass(Application application, + WrappedRequest request) throws UIRequiresMoreInformationException { + Object uiClassNameObj = application + .getProperty(Application.UI_PARAMETER); + + if (uiClassNameObj instanceof String) { + String uiClassName = uiClassNameObj.toString(); + + ClassLoader classLoader = request.getDeploymentConfiguration() + .getClassLoader(); + if (classLoader == null) { + classLoader = getClass().getClassLoader(); + } + try { + Class uiClass = Class.forName(uiClassName, true, + classLoader).asSubclass(UI.class); + + return uiClass; + } catch (ClassNotFoundException e) { + throw new RuntimeException("Could not find UI class", e); + } + } + + return null; + } +} diff --git a/server/src/com/vaadin/terminal/Page.java b/server/src/com/vaadin/terminal/Page.java index 95f9a7b3ec..66ef7da296 100644 --- a/server/src/com/vaadin/terminal/Page.java +++ b/server/src/com/vaadin/terminal/Page.java @@ -25,8 +25,8 @@ import java.util.List; import com.vaadin.event.EventRouter; import com.vaadin.shared.ui.BorderStyle; -import com.vaadin.shared.ui.root.PageClientRpc; -import com.vaadin.shared.ui.root.RootConstants; +import com.vaadin.shared.ui.ui.PageClientRpc; +import com.vaadin.shared.ui.ui.UIConstants; import com.vaadin.terminal.WrappedRequest.BrowserDetails; import com.vaadin.terminal.gwt.server.WebApplicationContext; import com.vaadin.terminal.gwt.server.WebBrowser; @@ -474,32 +474,32 @@ public class Page implements Serializable { target.startTag("notification"); if (n.getCaption() != null) { target.addAttribute( - RootConstants.ATTRIBUTE_NOTIFICATION_CAPTION, + UIConstants.ATTRIBUTE_NOTIFICATION_CAPTION, n.getCaption()); } if (n.getDescription() != null) { target.addAttribute( - RootConstants.ATTRIBUTE_NOTIFICATION_MESSAGE, + UIConstants.ATTRIBUTE_NOTIFICATION_MESSAGE, n.getDescription()); } if (n.getIcon() != null) { target.addAttribute( - RootConstants.ATTRIBUTE_NOTIFICATION_ICON, + UIConstants.ATTRIBUTE_NOTIFICATION_ICON, n.getIcon()); } if (!n.isHtmlContentAllowed()) { target.addAttribute( - RootConstants.NOTIFICATION_HTML_CONTENT_NOT_ALLOWED, + UIConstants.NOTIFICATION_HTML_CONTENT_NOT_ALLOWED, true); } target.addAttribute( - RootConstants.ATTRIBUTE_NOTIFICATION_POSITION, n + UIConstants.ATTRIBUTE_NOTIFICATION_POSITION, n .getPosition().ordinal()); - target.addAttribute(RootConstants.ATTRIBUTE_NOTIFICATION_DELAY, + target.addAttribute(UIConstants.ATTRIBUTE_NOTIFICATION_DELAY, n.getDelayMsec()); if (n.getStyleName() != null) { target.addAttribute( - RootConstants.ATTRIBUTE_NOTIFICATION_STYLE, + UIConstants.ATTRIBUTE_NOTIFICATION_STYLE, n.getStyleName()); } target.endTag("notification"); @@ -509,7 +509,7 @@ public class Page implements Serializable { } if (fragment != null) { - target.addAttribute(RootConstants.FRAGMENT_VARIABLE, fragment); + target.addAttribute(UIConstants.FRAGMENT_VARIABLE, fragment); } } @@ -632,11 +632,11 @@ public class Page implements Serializable { * null */ public static Page getCurrent() { - UI currentRoot = UI.getCurrent(); - if (currentRoot == null) { + UI currentUI = UI.getCurrent(); + if (currentUI == null) { return null; } - return currentRoot.getPage(); + return currentUI.getPage(); } /** diff --git a/server/src/com/vaadin/terminal/WrappedRequest.java b/server/src/com/vaadin/terminal/WrappedRequest.java index 9ef98fcc41..343a60848e 100644 --- a/server/src/com/vaadin/terminal/WrappedRequest.java +++ b/server/src/com/vaadin/terminal/WrappedRequest.java @@ -219,8 +219,9 @@ public interface WrappedRequest extends Serializable { * for instance using javascript in the browser. * * This information is only guaranteed to be available in some special - * cases, for instance when {@link Application#getRoot} is called again - * after throwing {@link UIRequiresMoreInformationException} or in + * cases, for instance when + * {@link Application#getUIForRequest(WrappedRequest)} is called again after + * throwing {@link UIRequiresMoreInformationException} or in * {@link UI#init(WrappedRequest)} for a UI class not annotated with * {@link EagerInit} * diff --git a/server/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java b/server/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java index 7a69a4c2b0..a9e6028090 100644 --- a/server/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java +++ b/server/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java @@ -501,23 +501,22 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet uI = application .getUIForRequest(wrappedRequest); } catch (UIRequiresMoreInformationException e) { - // Ignore problem and continue without root + // Ignore problem and continue without UI } break; case BROWSER_DETAILS: - // Should not try to find a root here as the - // combined request details might change the root + // Should not try to find a UI here as the + // combined request details might change the UI break; case FILE_UPLOAD: // no window break; case APPLICATION_RESOURCE: // use main window - should not need any window - // root = application.getRoot(); + // UI = application.getUI(); break; default: - uI = application - .getUIForRequest(wrappedRequest); + uI = application.getUIForRequest(wrappedRequest); } // if window not found, not a problem - use null } @@ -534,9 +533,8 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet uI, (ActionRequest) request, (ActionResponse) response); } else if (request instanceof EventRequest) { - applicationContext.firePortletEventRequest(application, - uI, (EventRequest) request, - (EventResponse) response); + applicationContext.firePortletEventRequest(application, uI, + (EventRequest) request, (EventResponse) response); } else if (request instanceof ResourceRequest) { applicationContext.firePortletResourceRequest(application, uI, (ResourceRequest) request, diff --git a/server/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java b/server/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java index b71c6ec20c..6cf9b76b0d 100644 --- a/server/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java +++ b/server/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java @@ -321,14 +321,14 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements } else if (requestType == RequestType.UIDL) { UI uI = application.getUIForRequest(request); if (uI == null) { - throw new ServletException(ERROR_NO_ROOT_FOUND); + throw new ServletException(ERROR_NO_UI_FOUND); } // Handles AJAX UIDL requests applicationManager.handleUidlRequest(request, response, servletWrapper, uI); return; } else if (requestType == RequestType.BROWSER_DETAILS) { - // Browser details - not related to a specific root + // Browser details - not related to a specific UI applicationManager.handleBrowserDetailsRequest(request, response, application); return; diff --git a/server/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java b/server/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java index e19cfc4de6..87eadd5df7 100644 --- a/server/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java +++ b/server/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java @@ -74,6 +74,7 @@ import com.vaadin.shared.communication.LegacyChangeVariablesInvocation; import com.vaadin.shared.communication.MethodInvocation; import com.vaadin.shared.communication.SharedState; import com.vaadin.shared.communication.UidlValue; +import com.vaadin.shared.ui.ui.UIConstants; import com.vaadin.terminal.AbstractClientConnector; import com.vaadin.terminal.CombinedRequest; import com.vaadin.terminal.LegacyPaint; @@ -146,7 +147,7 @@ public abstract class AbstractCommunicationManager implements Serializable { public static final char VAR_ESCAPE_CHARACTER = '\u001b'; - private final HashMap rootToClientCache = new HashMap(); + private final HashMap uiToClientCache = new HashMap(); private static final int MAX_BUFFER_SIZE = 64 * 1024; @@ -570,7 +571,7 @@ public abstract class AbstractCommunicationManager implements Serializable { if (uI == null) { // This should not happen, no windows exists but // application is still open. - getLogger().warning("Could not get root for application"); + getLogger().warning("Could not get UI for application"); return; } } else { @@ -810,17 +811,17 @@ public abstract class AbstractCommunicationManager implements Serializable { @SuppressWarnings("unchecked") public void writeUidlResponse(WrappedRequest request, boolean repaintAll, - final PrintWriter outWriter, UI uI, boolean analyzeLayouts) + final PrintWriter outWriter, UI ui, boolean analyzeLayouts) throws PaintException, JSONException { ArrayList dirtyVisibleConnectors = new ArrayList(); - Application application = uI.getApplication(); + Application application = ui.getApplication(); // Paints components - ConnectorTracker rootConnectorTracker = uI.getConnectorTracker(); + ConnectorTracker uiConnectorTracker = ui.getConnectorTracker(); getLogger().log(Level.FINE, "* Creating response to client"); if (repaintAll) { - getClientCache(uI).clear(); - rootConnectorTracker.markAllConnectorsDirty(); - rootConnectorTracker.markAllClientSidesUninitialized(); + getClientCache(ui).clear(); + uiConnectorTracker.markAllConnectorsDirty(); + uiConnectorTracker.markAllClientSidesUninitialized(); // Reset sent locales locales = null; @@ -828,18 +829,18 @@ public abstract class AbstractCommunicationManager implements Serializable { } dirtyVisibleConnectors - .addAll(getDirtyVisibleConnectors(rootConnectorTracker)); + .addAll(getDirtyVisibleConnectors(uiConnectorTracker)); getLogger().log( Level.FINE, "Found " + dirtyVisibleConnectors.size() + " dirty connectors to paint"); for (ClientConnector connector : dirtyVisibleConnectors) { - boolean initialized = rootConnectorTracker + boolean initialized = uiConnectorTracker .isClientSideInitialized(connector); connector.beforeClientResponse(!initialized); } - rootConnectorTracker.markAllConnectorsClean(); + uiConnectorTracker.markAllConnectorsClean(); outWriter.print("\"changes\":["); @@ -851,12 +852,11 @@ public abstract class AbstractCommunicationManager implements Serializable { if (analyzeLayouts) { invalidComponentRelativeSizes = ComponentSizeValidator - .validateComponentRelativeSizes(uI.getContent(), null, - null); + .validateComponentRelativeSizes(ui.getContent(), null, null); // Also check any existing subwindows - if (uI.getWindows() != null) { - for (Window subWindow : uI.getWindows()) { + if (ui.getWindows() != null) { + for (Window subWindow : ui.getWindows()) { invalidComponentRelativeSizes = ComponentSizeValidator .validateComponentRelativeSizes( subWindow.getContent(), @@ -951,10 +951,10 @@ public abstract class AbstractCommunicationManager implements Serializable { outWriter.append(hierarchyInfo.toString()); outWriter.print(", "); // close hierarchy - // send server to client RPC calls for components in the root, in call + // send server to client RPC calls for components in the UI, in call // order - // collect RPC calls from components in the root in the order in + // collect RPC calls from components in the UI in the order in // which they were performed, remove the calls from components LinkedList rpcPendingQueue = new LinkedList( @@ -985,7 +985,7 @@ public abstract class AbstractCommunicationManager implements Serializable { // } paramJson.put(JsonCodec.encode( invocation.getParameters()[i], referenceParameter, - parameterType, uI.getConnectorTracker())); + parameterType, ui.getConnectorTracker())); } invocationJson.put(paramJson); rpcCalls.put(invocationJson); @@ -1087,7 +1087,7 @@ public abstract class AbstractCommunicationManager implements Serializable { final String resource = (String) i.next(); InputStream is = null; try { - is = getThemeResourceAsStream(uI, getTheme(uI), resource); + is = getThemeResourceAsStream(ui, getTheme(ui), resource); } catch (final Exception e) { // FIXME: Handle exception getLogger().log(Level.FINER, @@ -1124,7 +1124,7 @@ public abstract class AbstractCommunicationManager implements Serializable { Collection> usedClientConnectors = paintTarget .getUsedClientConnectors(); boolean typeMappingsOpen = false; - ClientCache clientCache = getClientCache(uI); + ClientCache clientCache = getClientCache(ui); List> newConnectorTypes = new ArrayList>(); @@ -1237,7 +1237,7 @@ public abstract class AbstractCommunicationManager implements Serializable { } for (ClientConnector connector : dirtyVisibleConnectors) { - rootConnectorTracker.markClientSideInitialized(connector); + uiConnectorTracker.markClientSideInitialized(connector); } writePerformanceData(outWriter); @@ -1390,11 +1390,11 @@ public abstract class AbstractCommunicationManager implements Serializable { } private ClientCache getClientCache(UI uI) { - Integer rootId = Integer.valueOf(uI.getUIId()); - ClientCache cache = rootToClientCache.get(rootId); + Integer uiId = Integer.valueOf(uI.getUIId()); + ClientCache cache = uiToClientCache.get(uiId); if (cache == null) { cache = new ClientCache(); - rootToClientCache.put(rootId, cache); + uiToClientCache.put(uiId, cache); } return cache; } @@ -1633,14 +1633,13 @@ public abstract class AbstractCommunicationManager implements Serializable { * * @param source * @param uI - * the root receiving the burst + * the UI receiving the burst * @param burst * the content of the burst as a String to be parsed * @return true if the processing of the burst was successful and there were * no messages to non-existent components */ - public boolean handleBurst(WrappedRequest source, UI uI, - final String burst) { + public boolean handleBurst(WrappedRequest source, UI uI, final String burst) { boolean success = true; try { Set enabledConnectors = new HashSet(); @@ -1878,8 +1877,7 @@ public abstract class AbstractCommunicationManager implements Serializable { } protected ClientConnector getConnector(UI uI, String connectorId) { - ClientConnector c = uI.getConnectorTracker() - .getConnector(connectorId); + ClientConnector c = uI.getConnectorTracker().getConnector(connectorId); if (c == null && connectorId.equals(getDragAndDropService().getConnectorId())) { return getDragAndDropService(); @@ -2231,7 +2229,7 @@ public abstract class AbstractCommunicationManager implements Serializable { * invisible subtrees are omitted. * * @param w - * root window for which dirty components is to be fetched + * UI window for which dirty components is to be fetched * @return */ private ArrayList getDirtyVisibleConnectors( @@ -2344,7 +2342,7 @@ public abstract class AbstractCommunicationManager implements Serializable { * We will use the same APP/* URI space as ApplicationResources but * prefix url with UPLOAD * - * eg. APP/UPLOAD/[ROOTID]/[PID]/[NAME]/[SECKEY] + * eg. APP/UPLOAD/[UIID]/[PID]/[NAME]/[SECKEY] * * SECKEY is created on each paint to make URL's unpredictable (to * prevent CSRF attacks). @@ -2353,8 +2351,8 @@ public abstract class AbstractCommunicationManager implements Serializable { * handling post */ String paintableId = owner.getConnectorId(); - int rootId = owner.getUI().getUIId(); - String key = rootId + "/" + paintableId + "/" + name; + int uiId = owner.getUI().getUIId(); + String key = uiId + "/" + paintableId + "/" + name; if (pidToNameToStreamVariable == null) { pidToNameToStreamVariable = new HashMap>(); @@ -2415,7 +2413,7 @@ public abstract class AbstractCommunicationManager implements Serializable { WrappedResponse response, Application application) throws IOException { - // if we do not yet have a currentRoot, it should be initialized + // if we do not yet have a currentUI, it should be initialized // shortly, and we should send the initial UIDL boolean sendUIDL = UI.getCurrent() == null; @@ -2425,7 +2423,7 @@ public abstract class AbstractCommunicationManager implements Serializable { UI uI = application.getUIForRequest(combinedRequest); response.setContentType("application/json; charset=UTF-8"); - // Use the same logic as for determined roots + // Use the same logic as for determined UIs BootstrapHandler bootstrapHandler = getBootstrapHandler(); BootstrapContext context = bootstrapHandler.createContext( combinedRequest, response, application, uI.getUIId()); @@ -2434,13 +2432,13 @@ public abstract class AbstractCommunicationManager implements Serializable { String theme = context.getThemeName(); String themeUri = bootstrapHandler.getThemeUri(context, theme); - // TODO These are not required if it was only the init of the root + // TODO These are not required if it was only the init of the UI // that was delayed JSONObject params = new JSONObject(); params.put("widgetset", widgetset); params.put("themeUri", themeUri); // UI id might have changed based on e.g. window.name - params.put(ApplicationConstants.ROOT_ID_PARAMETER, uI.getUIId()); + params.put(UIConstants.UI_ID_PARAMETER, uI.getUIId()); if (sendUIDL) { String initialUIDL = getInitialUIDL(combinedRequest, uI); params.put("uidl", initialUIDL); @@ -2474,7 +2472,7 @@ public abstract class AbstractCommunicationManager implements Serializable { * @param request * the request that caused the initialization * @param uI - * the root for which the UIDL should be generated + * the UI for which the UIDL should be generated * @return a string with the initial UIDL message * @throws PaintException * if an exception occurs while painting @@ -2523,7 +2521,7 @@ public abstract class AbstractCommunicationManager implements Serializable { final String mimetype = response.getDeploymentConfiguration() .getMimeType(resourceName); - // Security check: avoid accidentally serving from the root of the + // Security check: avoid accidentally serving from the UI of the // classpath instead of relative to the context class if (resourceName.startsWith("/")) { getLogger().warning( @@ -2598,8 +2596,8 @@ public abstract class AbstractCommunicationManager implements Serializable { /** * Handles file upload request submitted via Upload component. * - * @param root - * The root for this request + * @param UI + * The UI for this request * * @see #getStreamVariableTargetUrl(ReceiverOwner, String, StreamVariable) * @@ -2613,7 +2611,7 @@ public abstract class AbstractCommunicationManager implements Serializable { throws IOException, InvalidUIDLSecurityKeyException { /* - * URI pattern: APP/UPLOAD/[ROOTID]/[PID]/[NAME]/[SECKEY] See + * URI pattern: APP/UPLOAD/[UIID]/[PID]/[NAME]/[SECKEY] See * #createReceiverUrl */ @@ -2623,12 +2621,12 @@ public abstract class AbstractCommunicationManager implements Serializable { .indexOf(ServletPortletHelper.UPLOAD_URL_PREFIX) + ServletPortletHelper.UPLOAD_URL_PREFIX.length(); String uppUri = pathInfo.substring(startOfData); - String[] parts = uppUri.split("/", 4); // 0= rootid, 1 = cid, 2= name, 3 + String[] parts = uppUri.split("/", 4); // 0= UIid, 1 = cid, 2= name, 3 // = sec key - String rootId = parts[0]; + String uiId = parts[0]; String connectorId = parts[1]; String variableName = parts[2]; - UI uI = application.getUIById(Integer.parseInt(rootId)); + UI uI = application.getUIById(Integer.parseInt(uiId)); UI.setCurrent(uI); StreamVariable streamVariable = getStreamVariable(connectorId, diff --git a/server/src/com/vaadin/terminal/gwt/server/ApplicationServlet.java b/server/src/com/vaadin/terminal/gwt/server/ApplicationServlet.java index 14500b01de..857c7c738c 100644 --- a/server/src/com/vaadin/terminal/gwt/server/ApplicationServlet.java +++ b/server/src/com/vaadin/terminal/gwt/server/ApplicationServlet.java @@ -20,7 +20,7 @@ import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import com.vaadin.Application; -import com.vaadin.terminal.DefaultRootProvider; +import com.vaadin.terminal.DefaultUIProvider; import com.vaadin.terminal.gwt.server.ServletPortletHelper.ApplicationClassException; /** @@ -70,7 +70,7 @@ public class ApplicationServlet extends AbstractApplicationServlet { // Creates a new application instance try { final Application application = getApplicationClass().newInstance(); - application.addUIProvider(new DefaultRootProvider()); + application.addUIProvider(new DefaultUIProvider()); return application; } catch (final IllegalAccessException e) { diff --git a/server/src/com/vaadin/terminal/gwt/server/BootstrapFragmentResponse.java b/server/src/com/vaadin/terminal/gwt/server/BootstrapFragmentResponse.java index df77600150..6f69086523 100644 --- a/server/src/com/vaadin/terminal/gwt/server/BootstrapFragmentResponse.java +++ b/server/src/com/vaadin/terminal/gwt/server/BootstrapFragmentResponse.java @@ -48,17 +48,16 @@ public class BootstrapFragmentResponse extends BootstrapResponse { * @param application * the application for which the bootstrap page should be * generated - * @param rootId - * the generated id of the UI that will be displayed on the - * page + * @param uiId + * the generated id of the UI that will be displayed on the page * @param fragmentNodes * a mutable list containing the DOM nodes that will make up the * application HTML */ public BootstrapFragmentResponse(BootstrapHandler handler, - WrappedRequest request, Application application, Integer rootId, + WrappedRequest request, Application application, Integer uiId, List fragmentNodes) { - super(handler, request, application, rootId); + super(handler, request, application, uiId); this.fragmentNodes = fragmentNodes; } diff --git a/server/src/com/vaadin/terminal/gwt/server/BootstrapHandler.java b/server/src/com/vaadin/terminal/gwt/server/BootstrapHandler.java index 1dfe9d1685..d329159d95 100644 --- a/server/src/com/vaadin/terminal/gwt/server/BootstrapHandler.java +++ b/server/src/com/vaadin/terminal/gwt/server/BootstrapHandler.java @@ -42,6 +42,7 @@ import com.vaadin.external.json.JSONException; import com.vaadin.external.json.JSONObject; import com.vaadin.shared.ApplicationConstants; import com.vaadin.shared.Version; +import com.vaadin.shared.ui.ui.UIConstants; import com.vaadin.terminal.DeploymentConfiguration; import com.vaadin.terminal.PaintException; import com.vaadin.terminal.RequestHandler; @@ -78,19 +79,19 @@ public abstract class BootstrapHandler implements RequestHandler { return bootstrapResponse.getApplication(); } - public Integer getRootId() { - return bootstrapResponse.getRootId(); + public Integer getUIId() { + return bootstrapResponse.getUIId(); } - public UI getRoot() { - return bootstrapResponse.getRoot(); + public UI getUI() { + return bootstrapResponse.getUI(); } public String getWidgetsetName() { if (widgetsetName == null) { - UI uI = getRoot(); + UI uI = getUI(); if (uI != null) { - widgetsetName = getWidgetsetForRoot(this); + widgetsetName = getWidgetsetForUI(this); } } return widgetsetName; @@ -98,7 +99,7 @@ public abstract class BootstrapHandler implements RequestHandler { public String getThemeName() { if (themeName == null) { - UI uI = getRoot(); + UI uI = getUI(); if (uI != null) { themeName = findAndEscapeThemeName(this); } @@ -125,7 +126,7 @@ public abstract class BootstrapHandler implements RequestHandler { throws IOException { // TODO Should all urls be handled here? - Integer rootId = null; + Integer uiId = null; try { UI uI = application.getUIForRequest(request); if (uI == null) { @@ -133,14 +134,14 @@ public abstract class BootstrapHandler implements RequestHandler { return true; } - rootId = Integer.valueOf(uI.getUIId()); + uiId = Integer.valueOf(uI.getUIId()); } catch (UIRequiresMoreInformationException e) { - // Just keep going without rootId + // Just keep going without uiId } try { BootstrapContext context = createContext(request, response, - application, rootId); + application, uiId); setupMainDiv(context); BootstrapFragmentResponse fragmentResponse = context @@ -170,8 +171,8 @@ public abstract class BootstrapHandler implements RequestHandler { Map headers = new LinkedHashMap(); Document document = Document.createShell(""); BootstrapPageResponse pageResponse = new BootstrapPageResponse( - this, request, context.getApplication(), context.getRootId(), document, - headers); + this, request, context.getApplication(), context.getUIId(), + document, headers); List fragmentNodes = fragmentResponse.getFragmentNodes(); Element body = document.body(); for (Node node : fragmentNodes) { @@ -246,7 +247,7 @@ public abstract class BootstrapHandler implements RequestHandler { head.appendElement("meta").attr("http-equiv", "X-UA-Compatible") .attr("content", "chrome=1"); - UI uI = context.getRoot(); + UI uI = context.getUI(); String title = ((uI == null || uI.getCaption() == null) ? "" : uI .getCaption()); head.appendElement("title").appendText(title); @@ -272,10 +273,10 @@ public abstract class BootstrapHandler implements RequestHandler { } public BootstrapContext createContext(WrappedRequest request, - WrappedResponse response, Application application, Integer rootId) { + WrappedResponse response, Application application, Integer uiId) { BootstrapContext context = new BootstrapContext(response, - new BootstrapFragmentResponse(this, request, - application, rootId, new ArrayList())); + new BootstrapFragmentResponse(this, request, application, uiId, + new ArrayList())); return context; } @@ -293,8 +294,8 @@ public abstract class BootstrapHandler implements RequestHandler { */ protected abstract String getApplicationId(BootstrapContext context); - public String getWidgetsetForRoot(BootstrapContext context) { - UI uI = context.getRoot(); + public String getWidgetsetForUI(BootstrapContext context) { + UI uI = context.getUI(); WrappedRequest request = context.getRequest(); String widgetset = uI.getApplication().getWidgetsetForUI(uI); @@ -417,12 +418,12 @@ public abstract class BootstrapHandler implements RequestHandler { protected JSONObject getApplicationParameters(BootstrapContext context) throws JSONException, PaintException { Application application = context.getApplication(); - Integer rootId = context.getRootId(); + Integer uiId = context.getUIId(); JSONObject appConfig = new JSONObject(); - if (rootId != null) { - appConfig.put(ApplicationConstants.ROOT_ID_PARAMETER, rootId); + if (uiId != null) { + appConfig.put(UIConstants.UI_ID_PARAMETER, uiId); } if (context.getThemeName() != null) { @@ -437,7 +438,7 @@ public abstract class BootstrapHandler implements RequestHandler { appConfig.put("widgetset", context.getWidgetsetName()); - if (rootId == null || application.isUIInitPending(rootId.intValue())) { + if (uiId == null || application.isUIInitPending(uiId.intValue())) { appConfig.put("initialPath", context.getRequest() .getRequestPathInfo()); @@ -447,7 +448,7 @@ public abstract class BootstrapHandler implements RequestHandler { } else { // write the initial UIDL into the config appConfig.put("uidl", - getInitialUIDL(context.getRequest(), context.getRoot())); + getInitialUIDL(context.getRequest(), context.getUI())); } return appConfig; @@ -533,7 +534,7 @@ public abstract class BootstrapHandler implements RequestHandler { * @return */ public String getThemeName(BootstrapContext context) { - return context.getApplication().getThemeForUI(context.getRoot()); + return context.getApplication().getThemeForUI(context.getUI()); } /** @@ -568,15 +569,15 @@ public abstract class BootstrapHandler implements RequestHandler { * * @param request * the originating request - * @param uI - * the root for which the UIDL should be generated + * @param ui + * the UI for which the UIDL should be generated * @return a string with the initial UIDL message * @throws PaintException * if an exception occurs while painting the components * @throws JSONException * if an exception occurs while formatting the output */ - protected abstract String getInitialUIDL(WrappedRequest request, UI uI) + protected abstract String getInitialUIDL(WrappedRequest request, UI ui) throws PaintException, JSONException; } diff --git a/server/src/com/vaadin/terminal/gwt/server/BootstrapPageResponse.java b/server/src/com/vaadin/terminal/gwt/server/BootstrapPageResponse.java index 535ab23c92..847578ef97 100644 --- a/server/src/com/vaadin/terminal/gwt/server/BootstrapPageResponse.java +++ b/server/src/com/vaadin/terminal/gwt/server/BootstrapPageResponse.java @@ -51,7 +51,7 @@ public class BootstrapPageResponse extends BootstrapResponse { * @param application * the application for which the bootstrap page should be * generated - * @param rootId + * @param uiId * the generated id of the UI that will be displayed on the * page * @param document @@ -60,9 +60,9 @@ public class BootstrapPageResponse extends BootstrapResponse { * a map into which header data can be added */ public BootstrapPageResponse(BootstrapHandler handler, - WrappedRequest request, Application application, Integer rootId, + WrappedRequest request, Application application, Integer uiId, Document document, Map headers) { - super(handler, request, application, rootId); + super(handler, request, application, uiId); this.headers = headers; this.document = document; } diff --git a/server/src/com/vaadin/terminal/gwt/server/BootstrapResponse.java b/server/src/com/vaadin/terminal/gwt/server/BootstrapResponse.java index 2518f7080e..a422cba345 100644 --- a/server/src/com/vaadin/terminal/gwt/server/BootstrapResponse.java +++ b/server/src/com/vaadin/terminal/gwt/server/BootstrapResponse.java @@ -33,7 +33,7 @@ import com.vaadin.ui.UI; public abstract class BootstrapResponse extends EventObject { private final WrappedRequest request; private final Application application; - private final Integer rootId; + private final Integer uiId; /** * Creates a new bootstrap event. @@ -46,16 +46,15 @@ public abstract class BootstrapResponse extends EventObject { * @param application * the application for which the bootstrap page should be * generated - * @param rootId - * the generated id of the UI that will be displayed on the - * page + * @param uiId + * the generated id of the UI that will be displayed on the page */ public BootstrapResponse(BootstrapHandler handler, WrappedRequest request, - Application application, Integer rootId) { + Application application, Integer uiId) { super(handler); this.request = request; this.application = application; - this.rootId = rootId; + this.uiId = uiId; } /** @@ -91,20 +90,20 @@ public abstract class BootstrapResponse extends EventObject { } /** - * Gets the root id that has been generated for this response. Please note + * Gets the UI id that has been generated for this response. Please note * that if {@link Application#isUiPreserved()} is enabled, a previously * created UI with a different id might eventually end up being used. * - * @return the root id + * @return the UI id */ - public Integer getRootId() { - return rootId; + public Integer getUIId() { + return uiId; } /** * Gets the UI for which this page is being rendered, if available. Some - * features of the framework will postpone the UI selection until after - * the bootstrap page has been rendered and required information from the + * features of the framework will postpone the UI selection until after the + * bootstrap page has been rendered and required information from the * browser has been sent back. This method will return null if * no UI instance is yet available. * @@ -116,7 +115,7 @@ public abstract class BootstrapResponse extends EventObject { * null if all required information is not yet * available. */ - public UI getRoot() { + public UI getUI() { return UI.getCurrent(); } } diff --git a/server/src/com/vaadin/terminal/gwt/server/ClientConnector.java b/server/src/com/vaadin/terminal/gwt/server/ClientConnector.java index 1a5019a7c1..c2fbbe37d4 100644 --- a/server/src/com/vaadin/terminal/gwt/server/ClientConnector.java +++ b/server/src/com/vaadin/terminal/gwt/server/ClientConnector.java @@ -175,7 +175,7 @@ public interface ClientConnector extends Connector, RpcTarget { public void removeExtension(Extension extension); /** - * Returns the root this connector is attached to + * Returns the UI this connector is attached to * * @return The UI this connector is attached to or null if it is not * attached to any UI diff --git a/server/src/com/vaadin/terminal/gwt/server/Constants.java b/server/src/com/vaadin/terminal/gwt/server/Constants.java index 78c043da69..40386d6eb7 100644 --- a/server/src/com/vaadin/terminal/gwt/server/Constants.java +++ b/server/src/com/vaadin/terminal/gwt/server/Constants.java @@ -78,7 +78,7 @@ public interface Constants { // Widget set parameter name static final String PARAMETER_WIDGETSET = "widgetset"; - static final String ERROR_NO_ROOT_FOUND = "Application did not return a root for the request and did not request extra information either. Something is wrong."; + static final String ERROR_NO_UI_FOUND = "No UIProvider returned a UI for the request."; static final String DEFAULT_THEME_NAME = "reindeer"; diff --git a/server/src/com/vaadin/terminal/gwt/server/PortletApplicationContext2.java b/server/src/com/vaadin/terminal/gwt/server/PortletApplicationContext2.java index a5a3e94954..8538d42604 100644 --- a/server/src/com/vaadin/terminal/gwt/server/PortletApplicationContext2.java +++ b/server/src/com/vaadin/terminal/gwt/server/PortletApplicationContext2.java @@ -395,7 +395,7 @@ public class PortletApplicationContext2 extends AbstractWebApplicationContext { PortletURL url = ((MimeResponse) response).createRenderURL(); url.setPortletMode(portletMode); throw new RuntimeException("UI.open has not yet been implemented"); - // root.open(new ExternalResource(url.toString())); + // UI.open(new ExternalResource(url.toString())); } else if (response instanceof StateAwareResponse) { ((StateAwareResponse) response).setPortletMode(portletMode); } else { diff --git a/server/src/com/vaadin/terminal/gwt/server/ServletPortletHelper.java b/server/src/com/vaadin/terminal/gwt/server/ServletPortletHelper.java index 7e669d939c..403cffb47c 100644 --- a/server/src/com/vaadin/terminal/gwt/server/ServletPortletHelper.java +++ b/server/src/com/vaadin/terminal/gwt/server/ServletPortletHelper.java @@ -9,7 +9,7 @@ import com.vaadin.terminal.WrappedRequest; import com.vaadin.ui.UI; /* - * Copyright 2011 Vaadin Ltd. + * 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 @@ -43,14 +43,14 @@ class ServletPortletHelper implements Serializable { throws ApplicationClassException { String applicationParameter = deploymentConfiguration .getInitParameters().getProperty("application"); - String rootParameter = deploymentConfiguration.getInitParameters() + String uiParameter = deploymentConfiguration.getInitParameters() .getProperty(Application.UI_PARAMETER); ClassLoader classLoader = deploymentConfiguration.getClassLoader(); if (applicationParameter == null) { // Validate the parameter value - verifyRootClass(rootParameter, classLoader); + verifyUIClass(uiParameter, classLoader); // Application can be used if a valid rootLayout is defined return Application.class; @@ -66,22 +66,22 @@ class ServletPortletHelper implements Serializable { } } - private static void verifyRootClass(String className, - ClassLoader classLoader) throws ApplicationClassException { + private static void verifyUIClass(String className, ClassLoader classLoader) + throws ApplicationClassException { if (className == null) { throw new ApplicationClassException(Application.UI_PARAMETER + " init parameter not defined"); } - // Check that the root layout class can be found + // Check that the UI layout class can be found try { - Class rootClass = classLoader.loadClass(className); - if (!UI.class.isAssignableFrom(rootClass)) { + Class uiClass = classLoader.loadClass(className); + if (!UI.class.isAssignableFrom(uiClass)) { throw new ApplicationClassException(className + " does not implement UI"); } // Try finding a default constructor, else throw exception - rootClass.getConstructor(); + uiClass.getConstructor(); } catch (ClassNotFoundException e) { throw new ApplicationClassException(className + " could not be loaded", e); diff --git a/server/src/com/vaadin/ui/AbstractComponent.java b/server/src/com/vaadin/ui/AbstractComponent.java index 0b97e1667d..a52a07f266 100644 --- a/server/src/com/vaadin/ui/AbstractComponent.java +++ b/server/src/com/vaadin/ui/AbstractComponent.java @@ -556,16 +556,6 @@ public abstract class AbstractComponent extends AbstractClientConnector getState().setReadOnly(readOnly); } - /* - * Gets the parent window of the component. Don't add a JavaDoc comment - * here, we use the default documentation from implemented interface. - */ - @Override - public UI getUI() { - // Just make method from implemented Component interface public - return super.getUI(); - } - /* * Notify the component that it's attached to a window. Don't add a JavaDoc * comment here, we use the default documentation from implemented @@ -1304,7 +1294,7 @@ public abstract class AbstractComponent extends AbstractClientConnector /** * Set a viewer for the action manager to be the parent sub window (if the - * component is in a window) or the root (otherwise). This is still a + * component is in a window) or the UI (otherwise). This is still a * simplification of the real case as this should be handled by the parent * VOverlay (on the client side) if the component is inside an VOverlay * component. diff --git a/server/src/com/vaadin/ui/ConnectorTracker.java b/server/src/com/vaadin/ui/ConnectorTracker.java index c7c7bc9784..ad5990137c 100644 --- a/server/src/com/vaadin/ui/ConnectorTracker.java +++ b/server/src/com/vaadin/ui/ConnectorTracker.java @@ -210,7 +210,7 @@ public class ConnectorTracker implements Serializable { while (iterator.hasNext()) { String connectorId = iterator.next(); ClientConnector connector = connectorIdToConnector.get(connectorId); - if (getRootForConnector(connector) != uI) { + if (getUIForConnector(connector) != uI) { // If connector is no longer part of this uI, // remove it from the map. If it is re-attached to the // application at some point it will be re-added through @@ -239,7 +239,7 @@ public class ConnectorTracker implements Serializable { * @return The uI the connector is attached to or null if it is not * attached to any uI. */ - private UI getRootForConnector(ClientConnector connector) { + private UI getUIForConnector(ClientConnector connector) { if (connector == null) { return null; } @@ -247,7 +247,7 @@ public class ConnectorTracker implements Serializable { return ((Component) connector).getUI(); } - return getRootForConnector(connector.getParent()); + return getUIForConnector(connector.getParent()); } /** diff --git a/server/src/com/vaadin/ui/UI.java b/server/src/com/vaadin/ui/UI.java index c0b3ed9929..aede1af54b 100644 --- a/server/src/com/vaadin/ui/UI.java +++ b/server/src/com/vaadin/ui/UI.java @@ -35,9 +35,9 @@ import com.vaadin.event.MouseEvents.ClickListener; import com.vaadin.shared.EventId; import com.vaadin.shared.MouseEventDetails; import com.vaadin.shared.ui.BorderStyle; -import com.vaadin.shared.ui.root.RootConstants; -import com.vaadin.shared.ui.root.UIServerRpc; -import com.vaadin.shared.ui.root.UIState; +import com.vaadin.shared.ui.ui.UIConstants; +import com.vaadin.shared.ui.ui.UIServerRpc; +import com.vaadin.shared.ui.ui.UIState; import com.vaadin.terminal.Page; import com.vaadin.terminal.Page.BrowserWindowResizeEvent; import com.vaadin.terminal.Page.BrowserWindowResizeListener; @@ -64,7 +64,7 @@ import com.vaadin.ui.Window.CloseListener; * When a new UI instance is needed, typically because the user opens a URL in a * browser window which points to {@link AbstractApplicationServlet}, * {@link Application#getUIForRequest(WrappedRequest)} is invoked to get a UI. - * That method does by default create a root according to the + * That method does by default create a UI according to the * {@value Application#UI_PARAMETER} parameter from web.xml. *

      *

      @@ -544,8 +544,8 @@ public abstract class UI extends AbstractComponentContainer implements if (pendingFocus != null) { // ensure focused component is still attached to this main window if (pendingFocus.getUI() == this - || (pendingFocus.getUI() != null && pendingFocus - .getUI().getParent() == this)) { + || (pendingFocus.getUI() != null && pendingFocus.getUI() + .getParent() == this)) { target.addAttribute("focused", pendingFocus); } pendingFocus = null; @@ -556,7 +556,7 @@ public abstract class UI extends AbstractComponentContainer implements } if (isResizeLazy()) { - target.addAttribute(RootConstants.RESIZE_LAZY, true); + target.addAttribute(UIConstants.RESIZE_LAZY, true); } } @@ -585,9 +585,9 @@ public abstract class UI extends AbstractComponentContainer implements actionManager.handleActions(variables, this); } - if (variables.containsKey(RootConstants.FRAGMENT_VARIABLE)) { + if (variables.containsKey(UIConstants.FRAGMENT_VARIABLE)) { String fragment = (String) variables - .get(RootConstants.FRAGMENT_VARIABLE); + .get(UIConstants.FRAGMENT_VARIABLE); getPage().setFragment(fragment, true); } } diff --git a/server/src/com/vaadin/ui/Window.java b/server/src/com/vaadin/ui/Window.java index ad2bbd0576..6102350566 100644 --- a/server/src/com/vaadin/ui/Window.java +++ b/server/src/com/vaadin/ui/Window.java @@ -224,11 +224,11 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, public void close() { UI uI = getUI(); - // Don't do anything if not attached to a root + // Don't do anything if not attached to a UI if (uI != null) { // focus is restored to the parent window uI.focus(); - // subwindow is removed from the root + // subwindow is removed from the UI uI.removeWindow(this); } } @@ -470,7 +470,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, * If there are currently several windows visible, calling this method makes * this window topmost. *

      - * This method can only be called if this window connected a root. Else an + * This method can only be called if this window connected a UI. Else an * illegal state exception is thrown. Also if there are modal windows and * this window is not modal, and illegal state exception is thrown. *

      @@ -485,7 +485,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, for (Window w : uI.getWindows()) { if (!isModal() && w.isModal()) { throw new IllegalStateException( - "The root contains modal windows, non-modal window cannot be brought to front."); + "The UI contains modal windows, non-modal window cannot be brought to front."); } if (w.bringToFront != null) { maxBringToFront = Math.max(maxBringToFront, diff --git a/shared/src/com/vaadin/shared/ApplicationConstants.java b/shared/src/com/vaadin/shared/ApplicationConstants.java index 31e633a210..ba35ddea50 100644 --- a/shared/src/com/vaadin/shared/ApplicationConstants.java +++ b/shared/src/com/vaadin/shared/ApplicationConstants.java @@ -29,10 +29,6 @@ public class ApplicationConstants { public static final String APP_PROTOCOL_PREFIX = "app://"; public static final String CONNECTOR_PROTOCOL_PREFIX = "connector://"; public static final String UIDL_SECURITY_TOKEN_ID = "Vaadin-Security-Key"; - /** - * Name of the parameter used to transmit root ids back and forth - */ - public static final String ROOT_ID_PARAMETER = "rootId"; public static final String PARAM_UNLOADBURST = "onunloadburst"; diff --git a/shared/src/com/vaadin/shared/ui/root/PageClientRpc.java b/shared/src/com/vaadin/shared/ui/root/PageClientRpc.java deleted file mode 100644 index b7d9419057..0000000000 --- a/shared/src/com/vaadin/shared/ui/root/PageClientRpc.java +++ /dev/null @@ -1,25 +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.shared.ui.root; - -import com.vaadin.shared.communication.ClientRpc; - -public interface PageClientRpc extends ClientRpc { - - public void setTitle(String title); - -} diff --git a/shared/src/com/vaadin/shared/ui/root/RootConstants.java b/shared/src/com/vaadin/shared/ui/root/RootConstants.java deleted file mode 100644 index 34c17ac71f..0000000000 --- a/shared/src/com/vaadin/shared/ui/root/RootConstants.java +++ /dev/null @@ -1,44 +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.shared.ui.root; - -public class RootConstants { - /** - * Attribute name for the lazy resize setting . - */ - @Deprecated - public static final String RESIZE_LAZY = "rL"; - - @Deprecated - public static final String NOTIFICATION_HTML_CONTENT_NOT_ALLOWED = "useplain"; - - @Deprecated - public static final String FRAGMENT_VARIABLE = "fragment"; - - @Deprecated - public static final String ATTRIBUTE_NOTIFICATION_STYLE = "style"; - @Deprecated - public static final String ATTRIBUTE_NOTIFICATION_CAPTION = "caption"; - @Deprecated - public static final String ATTRIBUTE_NOTIFICATION_MESSAGE = "message"; - @Deprecated - public static final String ATTRIBUTE_NOTIFICATION_ICON = "icon"; - @Deprecated - public static final String ATTRIBUTE_NOTIFICATION_POSITION = "position"; - @Deprecated - public static final String ATTRIBUTE_NOTIFICATION_DELAY = "delay"; - -} diff --git a/shared/src/com/vaadin/shared/ui/root/UIServerRpc.java b/shared/src/com/vaadin/shared/ui/root/UIServerRpc.java deleted file mode 100644 index 20cdd48f54..0000000000 --- a/shared/src/com/vaadin/shared/ui/root/UIServerRpc.java +++ /dev/null @@ -1,26 +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.shared.ui.root; - -import com.vaadin.shared.annotations.Delayed; -import com.vaadin.shared.communication.ServerRpc; -import com.vaadin.shared.ui.ClickRpc; - -public interface UIServerRpc extends ClickRpc, ServerRpc { - @Delayed(lastonly = true) - public void resize(int viewWidth, int viewHeight, int windowWidth, - int windowHeight); -} \ No newline at end of file diff --git a/shared/src/com/vaadin/shared/ui/root/UIState.java b/shared/src/com/vaadin/shared/ui/root/UIState.java deleted file mode 100644 index f019d1ce67..0000000000 --- a/shared/src/com/vaadin/shared/ui/root/UIState.java +++ /dev/null @@ -1,32 +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.shared.ui.root; - -import com.vaadin.shared.ComponentState; -import com.vaadin.shared.Connector; - -public class UIState extends ComponentState { - private Connector content; - - public Connector getContent() { - return content; - } - - public void setContent(Connector content) { - this.content = content; - } - -} \ No newline at end of file diff --git a/shared/src/com/vaadin/shared/ui/ui/PageClientRpc.java b/shared/src/com/vaadin/shared/ui/ui/PageClientRpc.java new file mode 100644 index 0000000000..a3cbc10cf6 --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/ui/PageClientRpc.java @@ -0,0 +1,25 @@ +/* + * 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.shared.ui.ui; + +import com.vaadin.shared.communication.ClientRpc; + +public interface PageClientRpc extends ClientRpc { + + public void setTitle(String title); + +} diff --git a/shared/src/com/vaadin/shared/ui/ui/UIConstants.java b/shared/src/com/vaadin/shared/ui/ui/UIConstants.java new file mode 100644 index 0000000000..76413628a4 --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/ui/UIConstants.java @@ -0,0 +1,49 @@ +/* + * 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.shared.ui.ui; + +public class UIConstants { + /** + * Attribute name for the lazy resize setting . + */ + @Deprecated + public static final String RESIZE_LAZY = "rL"; + + @Deprecated + public static final String NOTIFICATION_HTML_CONTENT_NOT_ALLOWED = "useplain"; + + @Deprecated + public static final String FRAGMENT_VARIABLE = "fragment"; + + @Deprecated + public static final String ATTRIBUTE_NOTIFICATION_STYLE = "style"; + @Deprecated + public static final String ATTRIBUTE_NOTIFICATION_CAPTION = "caption"; + @Deprecated + public static final String ATTRIBUTE_NOTIFICATION_MESSAGE = "message"; + @Deprecated + public static final String ATTRIBUTE_NOTIFICATION_ICON = "icon"; + @Deprecated + public static final String ATTRIBUTE_NOTIFICATION_POSITION = "position"; + @Deprecated + public static final String ATTRIBUTE_NOTIFICATION_DELAY = "delay"; + + /** + * Name of the parameter used to transmit UI ids back and forth + */ + public static final String UI_ID_PARAMETER = "uiId"; + +} diff --git a/shared/src/com/vaadin/shared/ui/ui/UIServerRpc.java b/shared/src/com/vaadin/shared/ui/ui/UIServerRpc.java new file mode 100644 index 0000000000..ef28a12415 --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/ui/UIServerRpc.java @@ -0,0 +1,26 @@ +/* + * 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.shared.ui.ui; + +import com.vaadin.shared.annotations.Delayed; +import com.vaadin.shared.communication.ServerRpc; +import com.vaadin.shared.ui.ClickRpc; + +public interface UIServerRpc extends ClickRpc, ServerRpc { + @Delayed(lastonly = true) + public void resize(int viewWidth, int viewHeight, int windowWidth, + int windowHeight); +} \ No newline at end of file diff --git a/shared/src/com/vaadin/shared/ui/ui/UIState.java b/shared/src/com/vaadin/shared/ui/ui/UIState.java new file mode 100644 index 0000000000..01426bd8f3 --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/ui/UIState.java @@ -0,0 +1,32 @@ +/* + * 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.shared.ui.ui; + +import com.vaadin.shared.ComponentState; +import com.vaadin.shared.Connector; + +public class UIState extends ComponentState { + private Connector content; + + public Connector getContent() { + return content; + } + + public void setContent(Connector content) { + this.content = content; + } + +} \ No newline at end of file diff --git a/tests/server-side/com/vaadin/tests/server/component/root/CustomRootClassLoader.java b/tests/server-side/com/vaadin/tests/server/component/root/CustomRootClassLoader.java index 59b1299db2..aa4fa22d06 100644 --- a/tests/server-side/com/vaadin/tests/server/component/root/CustomRootClassLoader.java +++ b/tests/server-side/com/vaadin/tests/server/component/root/CustomRootClassLoader.java @@ -11,7 +11,7 @@ import org.easymock.EasyMock; import com.vaadin.Application; import com.vaadin.Application.ApplicationStartEvent; import com.vaadin.UIRequiresMoreInformationException; -import com.vaadin.terminal.DefaultRootProvider; +import com.vaadin.terminal.DefaultUIProvider; import com.vaadin.terminal.DeploymentConfiguration; import com.vaadin.terminal.WrappedRequest; import com.vaadin.ui.UI; @@ -113,7 +113,7 @@ public class CustomRootClassLoader extends TestCase { private Application createStubApplication() { return new Application() { { - addUIProvider(new DefaultRootProvider()); + addUIProvider(new DefaultUIProvider()); } @Override diff --git a/tests/testbench/com/vaadin/launcher/ApplicationRunnerServlet.java b/tests/testbench/com/vaadin/launcher/ApplicationRunnerServlet.java index 2611546203..8183ed2d0b 100644 --- a/tests/testbench/com/vaadin/launcher/ApplicationRunnerServlet.java +++ b/tests/testbench/com/vaadin/launcher/ApplicationRunnerServlet.java @@ -31,7 +31,7 @@ import javax.servlet.http.HttpServletResponse; import com.vaadin.Application; import com.vaadin.UIRequiresMoreInformationException; -import com.vaadin.terminal.AbstractRootProvider; +import com.vaadin.terminal.AbstractUIProvider; import com.vaadin.terminal.WrappedRequest; import com.vaadin.terminal.gwt.server.AbstractApplicationServlet; import com.vaadin.terminal.gwt.server.WrappedHttpServletRequest; @@ -112,7 +112,7 @@ public class ApplicationRunnerServlet extends AbstractApplicationServlet { final Class classToRun = getClassToRun(); if (UI.class.isAssignableFrom(classToRun)) { Application application = new Application(); - application.addUIProvider(new AbstractRootProvider() { + application.addUIProvider(new AbstractUIProvider() { @Override public Class getUIClass( diff --git a/tests/testbench/com/vaadin/tests/application/RefreshStatePreserve.java b/tests/testbench/com/vaadin/tests/application/RefreshStatePreserve.java index b9b9c509c1..f48ca28dbf 100644 --- a/tests/testbench/com/vaadin/tests/application/RefreshStatePreserve.java +++ b/tests/testbench/com/vaadin/tests/application/RefreshStatePreserve.java @@ -2,7 +2,7 @@ package com.vaadin.tests.application; import com.vaadin.Application; import com.vaadin.UIRequiresMoreInformationException; -import com.vaadin.terminal.AbstractRootProvider; +import com.vaadin.terminal.AbstractUIProvider; import com.vaadin.terminal.WrappedRequest; import com.vaadin.tests.components.AbstractTestApplication; import com.vaadin.ui.Label; @@ -23,7 +23,7 @@ public class RefreshStatePreserve extends AbstractTestApplication { public void init() { super.init(); setUiPreserved(true); - addUIProvider(new AbstractRootProvider() { + addUIProvider(new AbstractUIProvider() { @Override public Class getUIClass(Application application, WrappedRequest request) diff --git a/tests/testbench/com/vaadin/tests/components/root/RootsInMultipleTabs.java b/tests/testbench/com/vaadin/tests/components/root/RootsInMultipleTabs.java index 238983d906..97506f7ad6 100644 --- a/tests/testbench/com/vaadin/tests/components/root/RootsInMultipleTabs.java +++ b/tests/testbench/com/vaadin/tests/components/root/RootsInMultipleTabs.java @@ -2,7 +2,7 @@ package com.vaadin.tests.components.root; import com.vaadin.Application; import com.vaadin.UIRequiresMoreInformationException; -import com.vaadin.terminal.AbstractRootProvider; +import com.vaadin.terminal.AbstractUIProvider; import com.vaadin.terminal.WrappedRequest; import com.vaadin.tests.components.AbstractTestApplication; import com.vaadin.ui.Label; @@ -23,7 +23,7 @@ public class RootsInMultipleTabs extends AbstractTestApplication { } public RootsInMultipleTabs() { - addUIProvider(new AbstractRootProvider() { + addUIProvider(new AbstractUIProvider() { @Override public Class getUIClass(Application application, WrappedRequest request) diff --git a/tests/testbench/com/vaadin/tests/vaadincontext/TestAddonContextListener.java b/tests/testbench/com/vaadin/tests/vaadincontext/TestAddonContextListener.java index a525d3139b..4fa007b11d 100644 --- a/tests/testbench/com/vaadin/tests/vaadincontext/TestAddonContextListener.java +++ b/tests/testbench/com/vaadin/tests/vaadincontext/TestAddonContextListener.java @@ -42,7 +42,7 @@ public class TestAddonContextListener implements AddonContextListener { } private boolean shouldModify(BootstrapResponse response) { - UI uI = response.getRoot(); + UI uI = response.getUI(); boolean shouldModify = uI != null && uI.getClass() == BootstrapModifyRoot.class; return shouldModify; -- cgit v1.2.3 From c90d01c4118239e541ec109e471c9c8af8ed18d0 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Fri, 24 Aug 2012 14:19:09 +0300 Subject: Root -> UI in tests (#8908) --- .../component/root/CustomRootClassLoader.java | 137 --------------------- .../server/component/root/CustomUIClassLoader.java | 137 +++++++++++++++++++++ .../component/window/AttachDetachWindow.java | 6 +- .../tests/application/RefreshStatePreserve.java | 4 +- .../vaadin/tests/components/AbstractTestRoot.java | 69 ----------- .../vaadin/tests/components/AbstractTestUI.java | 69 +++++++++++ .../abstractcomponent/AllComponentTooltipTest.java | 4 +- .../formlayout/FormLayoutErrorHover.java | 4 +- .../BasicJavaScriptComponent.java | 4 +- .../tests/components/label/MarginsInLabels.java | 4 +- .../loginform/LoginFormRootInLoginHandler.java | 52 -------- .../loginform/LoginFormUIInLoginHandler.java | 52 ++++++++ .../orderedlayout/OrderedLayoutCases.java | 4 +- .../components/panel/PanelChangeContents.java | 4 +- .../components/popupview/ReopenPopupView.java | 4 +- .../tests/components/root/LazyInitRoots.html | 46 ------- .../tests/components/root/LazyInitRoots.java | 89 ------------- .../tests/components/root/RootInitException.java | 23 ---- .../vaadin/tests/components/root/RootInitTest.java | 27 ---- .../tests/components/root/RootsInMultipleTabs.html | 47 ------- .../tests/components/root/RootsInMultipleTabs.java | 45 ------- .../tests/components/root/TestRootTheme.html | 27 ---- .../tests/components/root/TestRootTheme.java | 28 ----- .../tests/components/root/TestRootWidgetset.html | 36 ------ .../tests/components/root/TestRootWidgetset.java | 26 ---- .../tests/components/root/TestRootWidgetset2.java | 24 ---- .../tests/components/root/UriFragmentTest.html | 77 ------------ .../tests/components/root/UriFragmentTest.java | 53 -------- .../tests/components/table/TableInTabsheet.java | 4 +- .../vaadin/tests/components/ui/LazyInitUIs.html | 46 +++++++ .../vaadin/tests/components/ui/LazyInitUIs.java | 89 +++++++++++++ .../vaadin/tests/components/ui/TestUITheme.html | 27 ++++ .../vaadin/tests/components/ui/TestUITheme.java | 28 +++++ .../tests/components/ui/TestUIWidgetset.html | 36 ++++++ .../tests/components/ui/TestUIWidgetset.java | 26 ++++ .../tests/components/ui/TestUIWidgetset2.java | 24 ++++ .../tests/components/ui/UIInitException.java | 23 ++++ .../com/vaadin/tests/components/ui/UIInitTest.java | 27 ++++ .../tests/components/ui/UIsInMultipleTabs.html | 47 +++++++ .../tests/components/ui/UIsInMultipleTabs.java | 45 +++++++ .../tests/components/ui/UriFragmentTest.html | 77 ++++++++++++ .../tests/components/ui/UriFragmentTest.java | 53 ++++++++ .../components/window/RepaintWindowContents.java | 4 +- .../tests/components/window/TooltipInWindow.java | 4 +- .../tests/extensions/BasicExtensionTest.java | 4 +- .../tests/extensions/HelloWorldExtensionTest.java | 4 +- .../tests/extensions/JavascriptManagerTest.java | 4 +- .../extensions/SimpleJavaScriptExtensionTest.java | 4 +- .../v7a1/CustomConverterFactoryRoot.java | 33 ----- .../v7a1/CustomConverterFactoryUI.java | 33 +++++ .../tests/minitutorials/v7a1/DefineRootTheme.java | 42 ------- .../tests/minitutorials/v7a1/DefineUITheme.java | 42 +++++++ .../tests/minitutorials/v7a1/DynamicImageRoot.java | 80 ------------ .../tests/minitutorials/v7a1/DynamicImageUI.java | 80 ++++++++++++ .../v7a1/FindCurrentRootAndApplication.java | 61 --------- .../tests/minitutorials/v7a1/FindCurrentUI.java | 61 +++++++++ .../v7a1/FormUsingExistingLayout.java | 4 +- .../tests/minitutorials/v7a1/FormatTableValue.java | 4 +- .../v7a1/IntegerTextFieldDataSource.java | 4 +- .../v7a1/IntegerTextFieldStandalone.java | 4 +- .../minitutorials/v7a1/StringMyTypeConverter.java | 4 +- .../minitutorials/v7a2/ComponentInStateRoot.java | 26 ---- .../minitutorials/v7a2/ComponentInStateUI.java | 26 ++++ .../tests/minitutorials/v7a2/MyComponentRoot.java | 47 ------- .../tests/minitutorials/v7a2/MyComponentUI.java | 47 +++++++ .../minitutorials/v7a2/ResourceInStateRoot.java | 43 ------- .../minitutorials/v7a2/ResourceInStateUI.java | 43 +++++++ .../minitutorials/v7a2/WidgetcontainerRoot.java | 45 ------- .../minitutorials/v7a2/WidgetcontainerUI.java | 45 +++++++ .../tests/minitutorials/v7a3/AnalyticsRoot.java | 39 ------ .../tests/minitutorials/v7a3/AnalyticsUI.java | 39 ++++++ .../tests/minitutorials/v7a3/ComplexTypesRoot.java | 31 ----- .../tests/minitutorials/v7a3/ComplexTypesUI.java | 31 +++++ .../minitutorials/v7a3/FlotJavaScriptRoot.java | 43 ------- .../tests/minitutorials/v7a3/FlotJavaScriptUI.java | 43 +++++++ .../tests/minitutorials/v7a3/RedButtonRoot.java | 27 ---- .../tests/minitutorials/v7a3/RedButtonUI.java | 27 ++++ .../tests/serialization/DelegateToWidgetTest.java | 4 +- .../serialization/SerializerNamespaceTest.java | 4 +- .../vaadin/tests/serialization/SerializerTest.java | 4 +- .../tests/vaadincontext/BootstrapModify.html | 36 ------ .../tests/vaadincontext/BootstrapModifyRoot.java | 40 ------ .../tests/vaadincontext/BootstrapModifyUI.html | 36 ++++++ .../tests/vaadincontext/BootstrapModifyUI.java | 40 ++++++ .../vaadincontext/TestAddonContextListener.java | 2 +- 85 files changed, 1449 insertions(+), 1449 deletions(-) delete mode 100644 tests/server-side/com/vaadin/tests/server/component/root/CustomRootClassLoader.java create mode 100644 tests/server-side/com/vaadin/tests/server/component/root/CustomUIClassLoader.java delete mode 100644 tests/testbench/com/vaadin/tests/components/AbstractTestRoot.java create mode 100644 tests/testbench/com/vaadin/tests/components/AbstractTestUI.java delete mode 100755 tests/testbench/com/vaadin/tests/components/loginform/LoginFormRootInLoginHandler.java create mode 100755 tests/testbench/com/vaadin/tests/components/loginform/LoginFormUIInLoginHandler.java delete mode 100644 tests/testbench/com/vaadin/tests/components/root/LazyInitRoots.html delete mode 100644 tests/testbench/com/vaadin/tests/components/root/LazyInitRoots.java delete mode 100644 tests/testbench/com/vaadin/tests/components/root/RootInitException.java delete mode 100644 tests/testbench/com/vaadin/tests/components/root/RootInitTest.java delete mode 100644 tests/testbench/com/vaadin/tests/components/root/RootsInMultipleTabs.html delete mode 100644 tests/testbench/com/vaadin/tests/components/root/RootsInMultipleTabs.java delete mode 100644 tests/testbench/com/vaadin/tests/components/root/TestRootTheme.html delete mode 100644 tests/testbench/com/vaadin/tests/components/root/TestRootTheme.java delete mode 100644 tests/testbench/com/vaadin/tests/components/root/TestRootWidgetset.html delete mode 100644 tests/testbench/com/vaadin/tests/components/root/TestRootWidgetset.java delete mode 100644 tests/testbench/com/vaadin/tests/components/root/TestRootWidgetset2.java delete mode 100644 tests/testbench/com/vaadin/tests/components/root/UriFragmentTest.html delete mode 100644 tests/testbench/com/vaadin/tests/components/root/UriFragmentTest.java create mode 100644 tests/testbench/com/vaadin/tests/components/ui/LazyInitUIs.html create mode 100644 tests/testbench/com/vaadin/tests/components/ui/LazyInitUIs.java create mode 100644 tests/testbench/com/vaadin/tests/components/ui/TestUITheme.html create mode 100644 tests/testbench/com/vaadin/tests/components/ui/TestUITheme.java create mode 100644 tests/testbench/com/vaadin/tests/components/ui/TestUIWidgetset.html create mode 100644 tests/testbench/com/vaadin/tests/components/ui/TestUIWidgetset.java create mode 100644 tests/testbench/com/vaadin/tests/components/ui/TestUIWidgetset2.java create mode 100644 tests/testbench/com/vaadin/tests/components/ui/UIInitException.java create mode 100644 tests/testbench/com/vaadin/tests/components/ui/UIInitTest.java create mode 100644 tests/testbench/com/vaadin/tests/components/ui/UIsInMultipleTabs.html create mode 100644 tests/testbench/com/vaadin/tests/components/ui/UIsInMultipleTabs.java create mode 100644 tests/testbench/com/vaadin/tests/components/ui/UriFragmentTest.html create mode 100644 tests/testbench/com/vaadin/tests/components/ui/UriFragmentTest.java delete mode 100644 tests/testbench/com/vaadin/tests/minitutorials/v7a1/CustomConverterFactoryRoot.java create mode 100644 tests/testbench/com/vaadin/tests/minitutorials/v7a1/CustomConverterFactoryUI.java delete mode 100644 tests/testbench/com/vaadin/tests/minitutorials/v7a1/DefineRootTheme.java create mode 100644 tests/testbench/com/vaadin/tests/minitutorials/v7a1/DefineUITheme.java delete mode 100644 tests/testbench/com/vaadin/tests/minitutorials/v7a1/DynamicImageRoot.java create mode 100644 tests/testbench/com/vaadin/tests/minitutorials/v7a1/DynamicImageUI.java delete mode 100644 tests/testbench/com/vaadin/tests/minitutorials/v7a1/FindCurrentRootAndApplication.java create mode 100644 tests/testbench/com/vaadin/tests/minitutorials/v7a1/FindCurrentUI.java delete mode 100644 tests/testbench/com/vaadin/tests/minitutorials/v7a2/ComponentInStateRoot.java create mode 100644 tests/testbench/com/vaadin/tests/minitutorials/v7a2/ComponentInStateUI.java delete mode 100644 tests/testbench/com/vaadin/tests/minitutorials/v7a2/MyComponentRoot.java create mode 100644 tests/testbench/com/vaadin/tests/minitutorials/v7a2/MyComponentUI.java delete mode 100644 tests/testbench/com/vaadin/tests/minitutorials/v7a2/ResourceInStateRoot.java create mode 100644 tests/testbench/com/vaadin/tests/minitutorials/v7a2/ResourceInStateUI.java delete mode 100644 tests/testbench/com/vaadin/tests/minitutorials/v7a2/WidgetcontainerRoot.java create mode 100644 tests/testbench/com/vaadin/tests/minitutorials/v7a2/WidgetcontainerUI.java delete mode 100644 tests/testbench/com/vaadin/tests/minitutorials/v7a3/AnalyticsRoot.java create mode 100644 tests/testbench/com/vaadin/tests/minitutorials/v7a3/AnalyticsUI.java delete mode 100644 tests/testbench/com/vaadin/tests/minitutorials/v7a3/ComplexTypesRoot.java create mode 100644 tests/testbench/com/vaadin/tests/minitutorials/v7a3/ComplexTypesUI.java delete mode 100644 tests/testbench/com/vaadin/tests/minitutorials/v7a3/FlotJavaScriptRoot.java create mode 100644 tests/testbench/com/vaadin/tests/minitutorials/v7a3/FlotJavaScriptUI.java delete mode 100644 tests/testbench/com/vaadin/tests/minitutorials/v7a3/RedButtonRoot.java create mode 100644 tests/testbench/com/vaadin/tests/minitutorials/v7a3/RedButtonUI.java delete mode 100644 tests/testbench/com/vaadin/tests/vaadincontext/BootstrapModify.html delete mode 100644 tests/testbench/com/vaadin/tests/vaadincontext/BootstrapModifyRoot.java create mode 100644 tests/testbench/com/vaadin/tests/vaadincontext/BootstrapModifyUI.html create mode 100644 tests/testbench/com/vaadin/tests/vaadincontext/BootstrapModifyUI.java diff --git a/tests/server-side/com/vaadin/tests/server/component/root/CustomRootClassLoader.java b/tests/server-side/com/vaadin/tests/server/component/root/CustomRootClassLoader.java deleted file mode 100644 index aa4fa22d06..0000000000 --- a/tests/server-side/com/vaadin/tests/server/component/root/CustomRootClassLoader.java +++ /dev/null @@ -1,137 +0,0 @@ -package com.vaadin.tests.server.component.root; - -import java.util.ArrayList; -import java.util.List; -import java.util.Properties; - -import junit.framework.TestCase; - -import org.easymock.EasyMock; - -import com.vaadin.Application; -import com.vaadin.Application.ApplicationStartEvent; -import com.vaadin.UIRequiresMoreInformationException; -import com.vaadin.terminal.DefaultUIProvider; -import com.vaadin.terminal.DeploymentConfiguration; -import com.vaadin.terminal.WrappedRequest; -import com.vaadin.ui.UI; - -public class CustomRootClassLoader extends TestCase { - - /** - * Stub root - */ - public static class MyRoot extends UI { - @Override - protected void init(WrappedRequest request) { - // Nothing to see here - } - } - - /** - * Dummy ClassLoader that just saves the name of the requested class before - * delegating to the default implementation. - */ - public class LoggingClassLoader extends ClassLoader { - - private List requestedClasses = new ArrayList(); - - @Override - protected synchronized Class loadClass(String name, boolean resolve) - throws ClassNotFoundException { - requestedClasses.add(name); - return super.loadClass(name, resolve); - } - } - - /** - * Tests that a UI class can be loaded even if no classloader has been - * provided. - * - * @throws Exception - * if thrown - */ - public void testWithNullClassLoader() throws Exception { - Application application = createStubApplication(); - application.start(new ApplicationStartEvent(null, - createConfigurationMock(), null)); - - UI uI = application.getUIForRequest(createRequestMock(null)); - assertTrue(uI instanceof MyRoot); - } - - private static DeploymentConfiguration createConfigurationMock() { - DeploymentConfiguration configurationMock = EasyMock - .createMock(DeploymentConfiguration.class); - EasyMock.expect(configurationMock.isProductionMode()).andReturn(false); - EasyMock.expect(configurationMock.getInitParameters()).andReturn( - new Properties()); - - EasyMock.replay(configurationMock); - return configurationMock; - } - - private static WrappedRequest createRequestMock(ClassLoader classloader) { - // Mock a DeploymentConfiguration to give the passed classloader - DeploymentConfiguration configurationMock = EasyMock - .createMock(DeploymentConfiguration.class); - EasyMock.expect(configurationMock.getClassLoader()).andReturn( - classloader); - - // Mock a WrappedRequest to give the mocked deployment configuration - WrappedRequest requestMock = EasyMock.createMock(WrappedRequest.class); - EasyMock.expect(requestMock.getDeploymentConfiguration()).andReturn( - configurationMock); - - EasyMock.replay(configurationMock, requestMock); - return requestMock; - } - - /** - * Tests that the ClassLoader passed in the ApplicationStartEvent is used to - * load UI classes. - * - * @throws Exception - * if thrown - */ - public void testWithClassLoader() throws Exception { - LoggingClassLoader loggingClassLoader = new LoggingClassLoader(); - - Application application = createStubApplication(); - application.start(new ApplicationStartEvent(null, - createConfigurationMock(), null)); - - UI uI = application - .getUIForRequest(createRequestMock(loggingClassLoader)); - assertTrue(uI instanceof MyRoot); - assertEquals(1, loggingClassLoader.requestedClasses.size()); - assertEquals(MyRoot.class.getName(), - loggingClassLoader.requestedClasses.get(0)); - - } - - private Application createStubApplication() { - return new Application() { - { - addUIProvider(new DefaultUIProvider()); - } - - @Override - public String getProperty(String name) { - if (name.equals(UI_PARAMETER)) { - return MyRoot.class.getName(); - } else { - return super.getProperty(name); - } - } - - @Override - public UI getUIForRequest(WrappedRequest request) - throws UIRequiresMoreInformationException { - // Always create a new root for testing (can't directly use - // getRoot as it's protected) - return getUI(request); - } - }; - } -} diff --git a/tests/server-side/com/vaadin/tests/server/component/root/CustomUIClassLoader.java b/tests/server-side/com/vaadin/tests/server/component/root/CustomUIClassLoader.java new file mode 100644 index 0000000000..9b4d9492a2 --- /dev/null +++ b/tests/server-side/com/vaadin/tests/server/component/root/CustomUIClassLoader.java @@ -0,0 +1,137 @@ +package com.vaadin.tests.server.component.root; + +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; + +import junit.framework.TestCase; + +import org.easymock.EasyMock; + +import com.vaadin.Application; +import com.vaadin.Application.ApplicationStartEvent; +import com.vaadin.UIRequiresMoreInformationException; +import com.vaadin.terminal.DefaultUIProvider; +import com.vaadin.terminal.DeploymentConfiguration; +import com.vaadin.terminal.WrappedRequest; +import com.vaadin.ui.UI; + +public class CustomUIClassLoader extends TestCase { + + /** + * Stub root + */ + public static class MyUI extends UI { + @Override + protected void init(WrappedRequest request) { + // Nothing to see here + } + } + + /** + * Dummy ClassLoader that just saves the name of the requested class before + * delegating to the default implementation. + */ + public class LoggingClassLoader extends ClassLoader { + + private List requestedClasses = new ArrayList(); + + @Override + protected synchronized Class loadClass(String name, boolean resolve) + throws ClassNotFoundException { + requestedClasses.add(name); + return super.loadClass(name, resolve); + } + } + + /** + * Tests that a UI class can be loaded even if no classloader has been + * provided. + * + * @throws Exception + * if thrown + */ + public void testWithNullClassLoader() throws Exception { + Application application = createStubApplication(); + application.start(new ApplicationStartEvent(null, + createConfigurationMock(), null)); + + UI uI = application.getUIForRequest(createRequestMock(null)); + assertTrue(uI instanceof MyUI); + } + + private static DeploymentConfiguration createConfigurationMock() { + DeploymentConfiguration configurationMock = EasyMock + .createMock(DeploymentConfiguration.class); + EasyMock.expect(configurationMock.isProductionMode()).andReturn(false); + EasyMock.expect(configurationMock.getInitParameters()).andReturn( + new Properties()); + + EasyMock.replay(configurationMock); + return configurationMock; + } + + private static WrappedRequest createRequestMock(ClassLoader classloader) { + // Mock a DeploymentConfiguration to give the passed classloader + DeploymentConfiguration configurationMock = EasyMock + .createMock(DeploymentConfiguration.class); + EasyMock.expect(configurationMock.getClassLoader()).andReturn( + classloader); + + // Mock a WrappedRequest to give the mocked deployment configuration + WrappedRequest requestMock = EasyMock.createMock(WrappedRequest.class); + EasyMock.expect(requestMock.getDeploymentConfiguration()).andReturn( + configurationMock); + + EasyMock.replay(configurationMock, requestMock); + return requestMock; + } + + /** + * Tests that the ClassLoader passed in the ApplicationStartEvent is used to + * load UI classes. + * + * @throws Exception + * if thrown + */ + public void testWithClassLoader() throws Exception { + LoggingClassLoader loggingClassLoader = new LoggingClassLoader(); + + Application application = createStubApplication(); + application.start(new ApplicationStartEvent(null, + createConfigurationMock(), null)); + + UI uI = application + .getUIForRequest(createRequestMock(loggingClassLoader)); + assertTrue(uI instanceof MyUI); + assertEquals(1, loggingClassLoader.requestedClasses.size()); + assertEquals(MyUI.class.getName(), + loggingClassLoader.requestedClasses.get(0)); + + } + + private Application createStubApplication() { + return new Application() { + { + addUIProvider(new DefaultUIProvider()); + } + + @Override + public String getProperty(String name) { + if (name.equals(UI_PARAMETER)) { + return MyUI.class.getName(); + } else { + return super.getProperty(name); + } + } + + @Override + public UI getUIForRequest(WrappedRequest request) + throws UIRequiresMoreInformationException { + // Always create a new root for testing (can't directly use + // getRoot as it's protected) + return getUI(request); + } + }; + } +} diff --git a/tests/server-side/com/vaadin/tests/server/component/window/AttachDetachWindow.java b/tests/server-side/com/vaadin/tests/server/component/window/AttachDetachWindow.java index e2db224f08..2a0a733140 100644 --- a/tests/server-side/com/vaadin/tests/server/component/window/AttachDetachWindow.java +++ b/tests/server-side/com/vaadin/tests/server/component/window/AttachDetachWindow.java @@ -100,12 +100,12 @@ public class AttachDetachWindow { } } - private class TestRoot extends UI implements TestContainer { + private class TestUI extends UI implements TestContainer { boolean rootAttachCalled = false; boolean rootDetachCalled = false; private TestContent testContent = new TestContent();; - public TestRoot() { + public TestUI() { setContent(testContent); } @@ -142,7 +142,7 @@ public class AttachDetachWindow { } } - TestRoot main = new TestRoot(); + TestUI main = new TestUI(); TestWindow sub = new TestWindow(); @Test diff --git a/tests/testbench/com/vaadin/tests/application/RefreshStatePreserve.java b/tests/testbench/com/vaadin/tests/application/RefreshStatePreserve.java index f48ca28dbf..1e6509ab85 100644 --- a/tests/testbench/com/vaadin/tests/application/RefreshStatePreserve.java +++ b/tests/testbench/com/vaadin/tests/application/RefreshStatePreserve.java @@ -9,7 +9,7 @@ import com.vaadin.ui.Label; import com.vaadin.ui.UI; public class RefreshStatePreserve extends AbstractTestApplication { - public static class RefreshStateRoot extends UI { + public static class RefreshStateUI extends UI { @Override public void init(WrappedRequest request) { getContent().addComponent( @@ -28,7 +28,7 @@ public class RefreshStatePreserve extends AbstractTestApplication { public Class getUIClass(Application application, WrappedRequest request) throws UIRequiresMoreInformationException { - return RefreshStateRoot.class; + return RefreshStateUI.class; } }); } diff --git a/tests/testbench/com/vaadin/tests/components/AbstractTestRoot.java b/tests/testbench/com/vaadin/tests/components/AbstractTestRoot.java deleted file mode 100644 index cf4bfac426..0000000000 --- a/tests/testbench/com/vaadin/tests/components/AbstractTestRoot.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.vaadin.tests.components; - -import com.vaadin.Application; -import com.vaadin.service.ApplicationContext; -import com.vaadin.shared.ui.label.ContentMode; -import com.vaadin.terminal.WrappedRequest; -import com.vaadin.terminal.gwt.server.AbstractWebApplicationContext; -import com.vaadin.terminal.gwt.server.WebBrowser; -import com.vaadin.ui.Component; -import com.vaadin.ui.Label; -import com.vaadin.ui.UI; -import com.vaadin.ui.VerticalLayout; - -public abstract class AbstractTestRoot extends UI { - - @Override - public void init(WrappedRequest request) { - getPage().setTitle(getClass().getName()); - - Label label = new Label(getTestDescription(), ContentMode.XHTML); - label.setWidth("100%"); - - layout = new VerticalLayout(); - - getContent().addComponent(label); - getContent().addComponent(layout); - ((VerticalLayout) getContent()).setExpandRatio(layout, 1); - - setup(request); - } - - private VerticalLayout layout; - - protected VerticalLayout getLayout() { - return layout; - } - - protected abstract void setup(WrappedRequest request); - - @Override - public void addComponent(Component c) { - getLayout().addComponent(c); - } - - @Override - public void removeComponent(Component c) { - getLayout().removeComponent(c); - } - - @Override - public void replaceComponent(Component oldComponent, Component newComponent) { - getLayout().replaceComponent(oldComponent, newComponent); - } - - protected abstract String getTestDescription(); - - protected abstract Integer getTicketNumber(); - - protected WebBrowser getBrowser() { - ApplicationContext context = Application.getCurrent().getContext(); - if (context instanceof AbstractWebApplicationContext) { - AbstractWebApplicationContext webContext = (AbstractWebApplicationContext) context; - return webContext.getBrowser(); - } - - return null; - } - -} diff --git a/tests/testbench/com/vaadin/tests/components/AbstractTestUI.java b/tests/testbench/com/vaadin/tests/components/AbstractTestUI.java new file mode 100644 index 0000000000..7dd742952f --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/AbstractTestUI.java @@ -0,0 +1,69 @@ +package com.vaadin.tests.components; + +import com.vaadin.Application; +import com.vaadin.service.ApplicationContext; +import com.vaadin.shared.ui.label.ContentMode; +import com.vaadin.terminal.WrappedRequest; +import com.vaadin.terminal.gwt.server.AbstractWebApplicationContext; +import com.vaadin.terminal.gwt.server.WebBrowser; +import com.vaadin.ui.Component; +import com.vaadin.ui.Label; +import com.vaadin.ui.UI; +import com.vaadin.ui.VerticalLayout; + +public abstract class AbstractTestUI extends UI { + + @Override + public void init(WrappedRequest request) { + getPage().setTitle(getClass().getName()); + + Label label = new Label(getTestDescription(), ContentMode.XHTML); + label.setWidth("100%"); + + layout = new VerticalLayout(); + + getContent().addComponent(label); + getContent().addComponent(layout); + ((VerticalLayout) getContent()).setExpandRatio(layout, 1); + + setup(request); + } + + private VerticalLayout layout; + + protected VerticalLayout getLayout() { + return layout; + } + + protected abstract void setup(WrappedRequest request); + + @Override + public void addComponent(Component c) { + getLayout().addComponent(c); + } + + @Override + public void removeComponent(Component c) { + getLayout().removeComponent(c); + } + + @Override + public void replaceComponent(Component oldComponent, Component newComponent) { + getLayout().replaceComponent(oldComponent, newComponent); + } + + protected abstract String getTestDescription(); + + protected abstract Integer getTicketNumber(); + + protected WebBrowser getBrowser() { + ApplicationContext context = Application.getCurrent().getContext(); + if (context instanceof AbstractWebApplicationContext) { + AbstractWebApplicationContext webContext = (AbstractWebApplicationContext) context; + return webContext.getBrowser(); + } + + return null; + } + +} diff --git a/tests/testbench/com/vaadin/tests/components/abstractcomponent/AllComponentTooltipTest.java b/tests/testbench/com/vaadin/tests/components/abstractcomponent/AllComponentTooltipTest.java index 100c30cdc9..34655be91d 100644 --- a/tests/testbench/com/vaadin/tests/components/abstractcomponent/AllComponentTooltipTest.java +++ b/tests/testbench/com/vaadin/tests/components/abstractcomponent/AllComponentTooltipTest.java @@ -17,12 +17,12 @@ package com.vaadin.tests.components.abstractcomponent; import com.vaadin.terminal.WrappedRequest; import com.vaadin.tests.VaadinClasses; -import com.vaadin.tests.components.AbstractTestRoot; +import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.ui.AbstractComponent; import com.vaadin.ui.Component; import com.vaadin.ui.GridLayout; -public class AllComponentTooltipTest extends AbstractTestRoot { +public class AllComponentTooltipTest extends AbstractTestUI { @Override protected void setup(WrappedRequest request) { diff --git a/tests/testbench/com/vaadin/tests/components/formlayout/FormLayoutErrorHover.java b/tests/testbench/com/vaadin/tests/components/formlayout/FormLayoutErrorHover.java index 184f8a9261..a73c88cf73 100644 --- a/tests/testbench/com/vaadin/tests/components/formlayout/FormLayoutErrorHover.java +++ b/tests/testbench/com/vaadin/tests/components/formlayout/FormLayoutErrorHover.java @@ -16,11 +16,11 @@ package com.vaadin.tests.components.formlayout; import com.vaadin.terminal.WrappedRequest; -import com.vaadin.tests.components.AbstractTestRoot; +import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.ui.FormLayout; import com.vaadin.ui.PopupDateField; -public class FormLayoutErrorHover extends AbstractTestRoot { +public class FormLayoutErrorHover extends AbstractTestUI { @Override protected void setup(WrappedRequest request) { diff --git a/tests/testbench/com/vaadin/tests/components/javascriptcomponent/BasicJavaScriptComponent.java b/tests/testbench/com/vaadin/tests/components/javascriptcomponent/BasicJavaScriptComponent.java index 0b732e5948..a0df85a5b3 100644 --- a/tests/testbench/com/vaadin/tests/components/javascriptcomponent/BasicJavaScriptComponent.java +++ b/tests/testbench/com/vaadin/tests/components/javascriptcomponent/BasicJavaScriptComponent.java @@ -29,13 +29,13 @@ import com.vaadin.shared.ui.JavaScriptComponentState; import com.vaadin.terminal.ClassResource; import com.vaadin.terminal.WrappedRequest; import com.vaadin.terminal.gwt.server.ResourceReference; -import com.vaadin.tests.components.AbstractTestRoot; +import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.tests.util.Log; import com.vaadin.ui.AbstractJavaScriptComponent; import com.vaadin.ui.HasComponents; import com.vaadin.ui.JavaScriptFunction; -public class BasicJavaScriptComponent extends AbstractTestRoot { +public class BasicJavaScriptComponent extends AbstractTestUI { public interface TestRpc extends ServerRpc, ClientRpc { public void sendRpc(String message); diff --git a/tests/testbench/com/vaadin/tests/components/label/MarginsInLabels.java b/tests/testbench/com/vaadin/tests/components/label/MarginsInLabels.java index b1cf2957be..18d3b1e8ed 100644 --- a/tests/testbench/com/vaadin/tests/components/label/MarginsInLabels.java +++ b/tests/testbench/com/vaadin/tests/components/label/MarginsInLabels.java @@ -2,7 +2,7 @@ package com.vaadin.tests.components.label; import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.terminal.WrappedRequest; -import com.vaadin.tests.components.AbstractTestRoot; +import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.ui.AbstractLayout; import com.vaadin.ui.Accordion; import com.vaadin.ui.GridLayout; @@ -10,7 +10,7 @@ import com.vaadin.ui.Label; import com.vaadin.ui.TabSheet; import com.vaadin.ui.VerticalLayout; -public class MarginsInLabels extends AbstractTestRoot { +public class MarginsInLabels extends AbstractTestUI { @Override protected void setup(WrappedRequest request) { diff --git a/tests/testbench/com/vaadin/tests/components/loginform/LoginFormRootInLoginHandler.java b/tests/testbench/com/vaadin/tests/components/loginform/LoginFormRootInLoginHandler.java deleted file mode 100755 index b9076a152d..0000000000 --- a/tests/testbench/com/vaadin/tests/components/loginform/LoginFormRootInLoginHandler.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.vaadin.tests.components.loginform; - -import com.vaadin.tests.components.TestBase; -import com.vaadin.ui.Label; -import com.vaadin.ui.LoginForm; -import com.vaadin.ui.LoginForm.LoginEvent; -import com.vaadin.ui.LoginForm.LoginListener; -import com.vaadin.ui.UI; - -public class LoginFormRootInLoginHandler extends TestBase { - - @Override - protected void setup() { - LoginForm lf = new LoginForm(); - lf.addListener(new LoginListener() { - - @Override - public void onLogin(LoginEvent event) { - UI r1 = UI.getCurrent(); - if (r1 != null) { - addComponent(new Label("UI.getCurrent().data: " - + r1.getData())); - } else { - addComponent(new Label("UI.getCurrent() is null")); - } - UI r2 = ((LoginForm) event.getSource()).getUI(); - if (r2 != null) { - addComponent(new Label("event.getSource().data: " - + r2.getData())); - } else { - addComponent(new Label( - "event.getSource().getRoot() is null")); - } - } - }); - addComponent(lf); - getLayout().getUI().setData("This root"); - } - - @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/tests/testbench/com/vaadin/tests/components/loginform/LoginFormUIInLoginHandler.java b/tests/testbench/com/vaadin/tests/components/loginform/LoginFormUIInLoginHandler.java new file mode 100755 index 0000000000..b3ebb02751 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/loginform/LoginFormUIInLoginHandler.java @@ -0,0 +1,52 @@ +package com.vaadin.tests.components.loginform; + +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.Label; +import com.vaadin.ui.LoginForm; +import com.vaadin.ui.LoginForm.LoginEvent; +import com.vaadin.ui.LoginForm.LoginListener; +import com.vaadin.ui.UI; + +public class LoginFormUIInLoginHandler extends TestBase { + + @Override + protected void setup() { + LoginForm lf = new LoginForm(); + lf.addListener(new LoginListener() { + + @Override + public void onLogin(LoginEvent event) { + UI r1 = UI.getCurrent(); + if (r1 != null) { + addComponent(new Label("UI.getCurrent().data: " + + r1.getData())); + } else { + addComponent(new Label("UI.getCurrent() is null")); + } + UI r2 = ((LoginForm) event.getSource()).getUI(); + if (r2 != null) { + addComponent(new Label("event.getSource().data: " + + r2.getData())); + } else { + addComponent(new Label( + "event.getSource().getRoot() is null")); + } + } + }); + addComponent(lf); + getLayout().getUI().setData("This UI"); + } + + @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/tests/testbench/com/vaadin/tests/components/orderedlayout/OrderedLayoutCases.java b/tests/testbench/com/vaadin/tests/components/orderedlayout/OrderedLayoutCases.java index 08793e9a9c..5aaaaec6a6 100644 --- a/tests/testbench/com/vaadin/tests/components/orderedlayout/OrderedLayoutCases.java +++ b/tests/testbench/com/vaadin/tests/components/orderedlayout/OrderedLayoutCases.java @@ -8,7 +8,7 @@ import java.util.List; import com.vaadin.data.Property.ValueChangeEvent; import com.vaadin.data.Property.ValueChangeListener; import com.vaadin.terminal.WrappedRequest; -import com.vaadin.tests.components.AbstractTestRoot; +import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.tests.util.TestUtils; import com.vaadin.ui.AbstractOrderedLayout; import com.vaadin.ui.Alignment; @@ -20,7 +20,7 @@ import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.NativeSelect; import com.vaadin.ui.VerticalLayout; -public class OrderedLayoutCases extends AbstractTestRoot { +public class OrderedLayoutCases extends AbstractTestUI { private static final String[] dimensionValues = { "-1px", "5px", "350px", "800px", "100%", "50%" }; diff --git a/tests/testbench/com/vaadin/tests/components/panel/PanelChangeContents.java b/tests/testbench/com/vaadin/tests/components/panel/PanelChangeContents.java index f822af0779..a4067c3dcb 100644 --- a/tests/testbench/com/vaadin/tests/components/panel/PanelChangeContents.java +++ b/tests/testbench/com/vaadin/tests/components/panel/PanelChangeContents.java @@ -16,7 +16,7 @@ package com.vaadin.tests.components.panel; import com.vaadin.terminal.WrappedRequest; -import com.vaadin.tests.components.AbstractTestRoot; +import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; @@ -25,7 +25,7 @@ import com.vaadin.ui.Label; import com.vaadin.ui.Panel; import com.vaadin.ui.VerticalLayout; -public class PanelChangeContents extends AbstractTestRoot implements +public class PanelChangeContents extends AbstractTestUI implements ClickListener { VerticalLayout stats = new VerticalLayout(); diff --git a/tests/testbench/com/vaadin/tests/components/popupview/ReopenPopupView.java b/tests/testbench/com/vaadin/tests/components/popupview/ReopenPopupView.java index b450bfe811..99bfc7acfb 100644 --- a/tests/testbench/com/vaadin/tests/components/popupview/ReopenPopupView.java +++ b/tests/testbench/com/vaadin/tests/components/popupview/ReopenPopupView.java @@ -16,13 +16,13 @@ package com.vaadin.tests.components.popupview; import com.vaadin.terminal.WrappedRequest; -import com.vaadin.tests.components.AbstractTestRoot; +import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.tests.util.Log; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.PopupView; -public class ReopenPopupView extends AbstractTestRoot { +public class ReopenPopupView extends AbstractTestUI { private final Log log = new Log(5); @Override diff --git a/tests/testbench/com/vaadin/tests/components/root/LazyInitRoots.html b/tests/testbench/com/vaadin/tests/components/root/LazyInitRoots.html deleted file mode 100644 index 5448a24816..0000000000 --- a/tests/testbench/com/vaadin/tests/components/root/LazyInitRoots.html +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - -New Test - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      New Test
      open/run/com.vaadin.tests.components.root.LazyInitRoots/normalPath?restartApplication#normalFragment
      assertTextvaadin=runcomvaadintestscomponentsrootLazyInitRoots::/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]NormalRoot
      pathInfo: /normalPath
      parameters: [restartApplication]
      uri fragment: normalFragment
      open/run/com.vaadin.tests.components.root.LazyInitRoots/lazyCreatePath?lazyCreate#lazyCreateFragment
      assertTextvaadin=runcomvaadintestscomponentsrootLazyInitRoots::/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]LazyCreateRoot
      pathInfo: /lazyCreatePath
      parameters: [lazyCreate]
      uri fragment: lazyCreateFragment
      open/run/com.vaadin.tests.components.root.LazyInitRoots/eagerPath/?eagerInit#eagerFragment
      assertTextvaadin=runcomvaadintestscomponentsrootLazyInitRoots::/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]EagerInitRoot
      pathInfo: /eagerPath/
      parameters: [eagerInit]
      uri fragment: null
      - - diff --git a/tests/testbench/com/vaadin/tests/components/root/LazyInitRoots.java b/tests/testbench/com/vaadin/tests/components/root/LazyInitRoots.java deleted file mode 100644 index 89b43d4bdf..0000000000 --- a/tests/testbench/com/vaadin/tests/components/root/LazyInitRoots.java +++ /dev/null @@ -1,89 +0,0 @@ -package com.vaadin.tests.components.root; - -import com.vaadin.UIRequiresMoreInformationException; -import com.vaadin.annotations.EagerInit; -import com.vaadin.shared.ui.label.ContentMode; -import com.vaadin.terminal.ExternalResource; -import com.vaadin.terminal.WrappedRequest; -import com.vaadin.terminal.WrappedRequest.BrowserDetails; -import com.vaadin.tests.components.AbstractTestApplication; -import com.vaadin.ui.Label; -import com.vaadin.ui.Link; -import com.vaadin.ui.UI; - -public class LazyInitRoots extends AbstractTestApplication { - - @EagerInit - private static class EagerInitRoot extends UI { - @Override - public void init(WrappedRequest request) { - addComponent(getRequestInfo("EagerInitRoot", request)); - } - } - - @Override - public UI getUI(WrappedRequest request) - throws UIRequiresMoreInformationException { - if (request.getParameter("lazyCreate") != null) { - // UI created on second request - BrowserDetails browserDetails = request.getBrowserDetails(); - if (browserDetails == null - || browserDetails.getUriFragment() == null) { - throw new UIRequiresMoreInformationException(); - } else { - UI uI = new UI() { - @Override - protected void init(WrappedRequest request) { - addComponent(getRequestInfo("LazyCreateRoot", request)); - } - }; - return uI; - } - } else if (request.getParameter("eagerInit") != null) { - // UI inited on first request - return new EagerInitRoot(); - } else { - // The standard root - UI uI = new UI() { - @Override - protected void init(WrappedRequest request) { - addComponent(getRequestInfo("NormalRoot", request)); - - Link lazyCreateLink = new Link("Open lazyCreate root", - new ExternalResource(getURL() - + "?lazyCreate#lazyCreate")); - lazyCreateLink.setTargetName("_blank"); - addComponent(lazyCreateLink); - - Link lazyInitLink = new Link("Open eagerInit root", - new ExternalResource(getURL() - + "?eagerInit#eagerInit")); - lazyInitLink.setTargetName("_blank"); - addComponent(lazyInitLink); - } - }; - - return uI; - } - } - - public static Label getRequestInfo(String name, WrappedRequest request) { - String info = name; - info += "
      pathInfo: " + request.getRequestPathInfo(); - info += "
      parameters: " + request.getParameterMap().keySet(); - info += "
      uri fragment: " - + request.getBrowserDetails().getUriFragment(); - return new Label(info, ContentMode.XHTML); - } - - @Override - protected String getTestDescription() { - return "BrowserDetails should be available in Application.getRoot if RootRequiresMoreInformation has been thrown and in UI.init if the root has the @RootInitRequiresBrowserDetals annotation"; - } - - @Override - protected Integer getTicketNumber() { - return Integer.valueOf(7883); // + #7882 + #7884 - } - -} diff --git a/tests/testbench/com/vaadin/tests/components/root/RootInitException.java b/tests/testbench/com/vaadin/tests/components/root/RootInitException.java deleted file mode 100644 index b4cfa2a28d..0000000000 --- a/tests/testbench/com/vaadin/tests/components/root/RootInitException.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.vaadin.tests.components.root; - -import com.vaadin.terminal.WrappedRequest; -import com.vaadin.tests.components.AbstractTestRoot; - -public class RootInitException extends AbstractTestRoot { - - @Override - protected void setup(WrappedRequest request) { - throw new RuntimeException("Catch me if you can"); - } - - @Override - protected String getTestDescription() { - return "Throwing an exception in application code during a browser details request should show a sensible message in the client"; - } - - @Override - protected Integer getTicketNumber() { - return Integer.valueOf(8243); - } - -} diff --git a/tests/testbench/com/vaadin/tests/components/root/RootInitTest.java b/tests/testbench/com/vaadin/tests/components/root/RootInitTest.java deleted file mode 100644 index 16fecc62d2..0000000000 --- a/tests/testbench/com/vaadin/tests/components/root/RootInitTest.java +++ /dev/null @@ -1,27 +0,0 @@ -/* -@ITMillApache2LicenseForJavaFiles@ - */ - -package com.vaadin.tests.components.root; - -import com.vaadin.terminal.WrappedRequest; -import com.vaadin.tests.components.AbstractTestRoot; -import com.vaadin.ui.Label; - -public class RootInitTest extends AbstractTestRoot { - - @Override - protected void setup(WrappedRequest request) { - addComponent(new Label("Hello root")); - } - - @Override - public String getTestDescription() { - return "Testing basic root creation"; - } - - @Override - protected Integer getTicketNumber() { - return Integer.valueOf(3067); - } -} diff --git a/tests/testbench/com/vaadin/tests/components/root/RootsInMultipleTabs.html b/tests/testbench/com/vaadin/tests/components/root/RootsInMultipleTabs.html deleted file mode 100644 index c9b83fdc4e..0000000000 --- a/tests/testbench/com/vaadin/tests/components/root/RootsInMultipleTabs.html +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - -New Test - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      New Test
      open/run/com.vaadin.tests.components.root.RootsInMultipleTabs?restartApplication
      assertTextvaadin=runcomvaadintestscomponentsrootRootsInMultipleTabs::/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]This is root number 1
      open/run/com.vaadin.tests.components.root.RootsInMultipleTabs
      assertTextvaadin=runcomvaadintestscomponentsrootRootsInMultipleTabs::/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]This is root number 2
      open/run/com.vaadin.tests.components.root.RootsInMultipleTabs?restartApplication
      assertTextvaadin=runcomvaadintestscomponentsrootRootsInMultipleTabs::/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]This is root number 1
      - - diff --git a/tests/testbench/com/vaadin/tests/components/root/RootsInMultipleTabs.java b/tests/testbench/com/vaadin/tests/components/root/RootsInMultipleTabs.java deleted file mode 100644 index 97506f7ad6..0000000000 --- a/tests/testbench/com/vaadin/tests/components/root/RootsInMultipleTabs.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.vaadin.tests.components.root; - -import com.vaadin.Application; -import com.vaadin.UIRequiresMoreInformationException; -import com.vaadin.terminal.AbstractUIProvider; -import com.vaadin.terminal.WrappedRequest; -import com.vaadin.tests.components.AbstractTestApplication; -import com.vaadin.ui.Label; -import com.vaadin.ui.UI; - -public class RootsInMultipleTabs extends AbstractTestApplication { - private int numberOfRootsOpened; - - public static class TabRoot extends UI { - @Override - protected void init(WrappedRequest request) { - RootsInMultipleTabs application = (RootsInMultipleTabs) getApplication(); - String message = "This is root number " - + ++application.numberOfRootsOpened; - - addComponent(new Label(message)); - } - } - - public RootsInMultipleTabs() { - addUIProvider(new AbstractUIProvider() { - @Override - public Class getUIClass(Application application, - WrappedRequest request) - throws UIRequiresMoreInformationException { - return TabRoot.class; - } - }); - } - - @Override - protected String getTestDescription() { - return "Opening the same application again (e.g. in a new tab) should create a new UI."; - } - - @Override - protected Integer getTicketNumber() { - return Integer.valueOf(7894); - } -} diff --git a/tests/testbench/com/vaadin/tests/components/root/TestRootTheme.html b/tests/testbench/com/vaadin/tests/components/root/TestRootTheme.html deleted file mode 100644 index 7d0f638325..0000000000 --- a/tests/testbench/com/vaadin/tests/components/root/TestRootTheme.html +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - -New Test - - - - - - - - - - - - - - - - - -
      New Test
      open/run/com.vaadin.tests.components.root.TestRootTheme?restartApplication
      screenCapturethemeLoaded
      - - diff --git a/tests/testbench/com/vaadin/tests/components/root/TestRootTheme.java b/tests/testbench/com/vaadin/tests/components/root/TestRootTheme.java deleted file mode 100644 index 7a734e8497..0000000000 --- a/tests/testbench/com/vaadin/tests/components/root/TestRootTheme.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.vaadin.tests.components.root; - -import com.vaadin.annotations.Theme; -import com.vaadin.terminal.WrappedRequest; -import com.vaadin.tests.components.AbstractTestRoot; -import com.vaadin.ui.Label; - -@Theme("tests-tickets") -public class TestRootTheme extends AbstractTestRoot { - - @Override - protected void setup(WrappedRequest request) { - Label label = new Label("A red label"); - label.setStyleName("red"); - addComponent(label); - } - - @Override - public String getTestDescription() { - return "UI with @RootTheme(\"tests-tickets\")"; - } - - @Override - protected Integer getTicketNumber() { - return Integer.valueOf(7885); - } - -} diff --git a/tests/testbench/com/vaadin/tests/components/root/TestRootWidgetset.html b/tests/testbench/com/vaadin/tests/components/root/TestRootWidgetset.html deleted file mode 100644 index c91d742581..0000000000 --- a/tests/testbench/com/vaadin/tests/components/root/TestRootWidgetset.html +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - -Ticket4607 - - - - - - - - - - - - - - - - - - - - - - - - - - -
      Ticket4607
      open/run/com.vaadin.tests.components.root.TestRootWidgetset
      assertTextvaadin=runcomvaadintestscomponentsrootTestRootWidgetset::/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[0]This component is available in TestingWidgetset, but not in DefaultWidgetset
      open/run/com.vaadin.tests.components.root.TestRootWidgetset2
      assertTextvaadin=runcomvaadintestscomponentsrootTestRootWidgetset2::/VVerticalLayout[0]/VVerticalLayout[0]/VUnknownComponent[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]Widgetset does not contain implementation for com.vaadin.tests.widgetset.server.MissingFromDefaultWidgetsetComponent. Check its component connector's @Connect mapping, widgetsets GWT module description file and re-compile your widgetset. In case you have downloaded a vaadin add-on package, you might want to refer to add-on instructions.
      - - diff --git a/tests/testbench/com/vaadin/tests/components/root/TestRootWidgetset.java b/tests/testbench/com/vaadin/tests/components/root/TestRootWidgetset.java deleted file mode 100644 index b92815eeed..0000000000 --- a/tests/testbench/com/vaadin/tests/components/root/TestRootWidgetset.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.vaadin.tests.components.root; - -import com.vaadin.annotations.Widgetset; -import com.vaadin.terminal.WrappedRequest; -import com.vaadin.tests.components.AbstractTestRoot; -import com.vaadin.tests.widgetset.server.MissingFromDefaultWidgetsetComponent; - -@Widgetset("com.vaadin.tests.widgetset.TestingWidgetSet") -public class TestRootWidgetset extends AbstractTestRoot { - - @Override - protected void setup(WrappedRequest request) { - addComponent(new MissingFromDefaultWidgetsetComponent()); - } - - @Override - public String getTestDescription() { - return "This contents if this root should work as the component is present in TestingWidgetSet"; - } - - @Override - protected Integer getTicketNumber() { - return Integer.valueOf(7885); - } - -} diff --git a/tests/testbench/com/vaadin/tests/components/root/TestRootWidgetset2.java b/tests/testbench/com/vaadin/tests/components/root/TestRootWidgetset2.java deleted file mode 100644 index d3be29215e..0000000000 --- a/tests/testbench/com/vaadin/tests/components/root/TestRootWidgetset2.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.vaadin.tests.components.root; - -import com.vaadin.terminal.WrappedRequest; -import com.vaadin.tests.components.AbstractTestRoot; -import com.vaadin.tests.widgetset.server.MissingFromDefaultWidgetsetComponent; - -public class TestRootWidgetset2 extends AbstractTestRoot { - - @Override - protected void setup(WrappedRequest request) { - addComponent(new MissingFromDefaultWidgetsetComponent()); - } - - @Override - public String getTestDescription() { - return "This contents if this root should not work as the component is not present in DefaultWidgetSet"; - } - - @Override - protected Integer getTicketNumber() { - return Integer.valueOf(7885); - } - -} diff --git a/tests/testbench/com/vaadin/tests/components/root/UriFragmentTest.html b/tests/testbench/com/vaadin/tests/components/root/UriFragmentTest.html deleted file mode 100644 index d4704fea65..0000000000 --- a/tests/testbench/com/vaadin/tests/components/root/UriFragmentTest.html +++ /dev/null @@ -1,77 +0,0 @@ - - - - - - -New Test - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      New Test
      open/run/com.vaadin.tests.components.root.UriFragmentTest?restartApplication#urifragment
      assertTextvaadin=runcomvaadintestscomponentsrootUriFragmentTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]Current URI fragment: urifragment
      clickvaadin=runcomvaadintestscomponentsrootUriFragmentTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
      assertTextvaadin=runcomvaadintestscomponentsrootUriFragmentTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]Current URI fragment: test
      runScripthistory.back()
      pause1000
      waitForVaadin
      assertTextvaadin=runcomvaadintestscomponentsrootUriFragmentTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]Current URI fragment: urifragment
      runScripthistory.forward()
      pause1000
      waitForVaadin
      assertTextvaadin=runcomvaadintestscomponentsrootUriFragmentTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]Current URI fragment: test
      - - diff --git a/tests/testbench/com/vaadin/tests/components/root/UriFragmentTest.java b/tests/testbench/com/vaadin/tests/components/root/UriFragmentTest.java deleted file mode 100644 index d34c7718ce..0000000000 --- a/tests/testbench/com/vaadin/tests/components/root/UriFragmentTest.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.vaadin.tests.components.root; - -import com.vaadin.terminal.Page; -import com.vaadin.terminal.Page.FragmentChangedEvent; -import com.vaadin.terminal.WrappedRequest; -import com.vaadin.tests.components.AbstractTestRoot; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Label; - -public class UriFragmentTest extends AbstractTestRoot { - - private final Label fragmentLabel = new Label(); - - @Override - protected void setup(WrappedRequest request) { - addComponent(fragmentLabel); - updateLabel(); - getPage().addListener(new Page.FragmentChangedListener() { - @Override - public void fragmentChanged(FragmentChangedEvent event) { - updateLabel(); - } - }); - addComponent(new Button("Navigate to #test", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - getPage().setFragment("test"); - } - })); - } - - private void updateLabel() { - String fragment = getPage().getFragment(); - if (fragment == null) { - fragmentLabel.setValue("No URI fragment set"); - } else { - fragmentLabel.setValue("Current URI fragment: " + fragment); - } - } - - @Override - public String getTestDescription() { - return "URI fragment status should be known when the page is loaded and retained while navigating to different fragments or using the back and forward buttons."; - } - - @Override - protected Integer getTicketNumber() { - return Integer.valueOf(8048); - } - -} diff --git a/tests/testbench/com/vaadin/tests/components/table/TableInTabsheet.java b/tests/testbench/com/vaadin/tests/components/table/TableInTabsheet.java index 9a94a203f1..f54f685a1d 100644 --- a/tests/testbench/com/vaadin/tests/components/table/TableInTabsheet.java +++ b/tests/testbench/com/vaadin/tests/components/table/TableInTabsheet.java @@ -4,7 +4,7 @@ import java.net.MalformedURLException; import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.terminal.WrappedRequest; -import com.vaadin.tests.components.AbstractTestRoot; +import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.ui.AbsoluteLayout; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; @@ -14,7 +14,7 @@ import com.vaadin.ui.Table.Align; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.themes.Reindeer; -public class TableInTabsheet extends AbstractTestRoot { +public class TableInTabsheet extends AbstractTestUI { @Override protected void setup(WrappedRequest request) { diff --git a/tests/testbench/com/vaadin/tests/components/ui/LazyInitUIs.html b/tests/testbench/com/vaadin/tests/components/ui/LazyInitUIs.html new file mode 100644 index 0000000000..d7e1544026 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/ui/LazyInitUIs.html @@ -0,0 +1,46 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      New Test
      open/run/com.vaadin.tests.components.ui.LazyInitUIs/normalPath?restartApplication#normalFragment
      assertTextvaadin=runcomvaadintestscomponentsuilazyInitUIs::/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]NormalUI
      pathInfo: /normalPath
      parameters: [restartApplication]
      uri fragment: normalFragment
      open/run/com.vaadin.tests.components.ui.LazyInitUIs/lazyCreatePath?lazyCreate#lazyCreateFragment
      assertTextvaadin=runcomvaadintestscomponentsuilazyInitUIs::/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]LazyCreateUI
      pathInfo: /lazyCreatePath
      parameters: [lazyCreate]
      uri fragment: lazyCreateFragment
      open/run/com.vaadin.tests.components.ui.LazyInitUIs/eagerPath/?eagerInit#eagerFragment
      assertTextvaadin=runcomvaadintestscomponentsuiLazyInitUIs::/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]EagerInitUI
      pathInfo: /eagerPath/
      parameters: [eagerInit]
      uri fragment: null
      + + diff --git a/tests/testbench/com/vaadin/tests/components/ui/LazyInitUIs.java b/tests/testbench/com/vaadin/tests/components/ui/LazyInitUIs.java new file mode 100644 index 0000000000..75a98ba14e --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/ui/LazyInitUIs.java @@ -0,0 +1,89 @@ +package com.vaadin.tests.components.ui; + +import com.vaadin.UIRequiresMoreInformationException; +import com.vaadin.annotations.EagerInit; +import com.vaadin.shared.ui.label.ContentMode; +import com.vaadin.terminal.ExternalResource; +import com.vaadin.terminal.WrappedRequest; +import com.vaadin.terminal.WrappedRequest.BrowserDetails; +import com.vaadin.tests.components.AbstractTestApplication; +import com.vaadin.ui.Label; +import com.vaadin.ui.Link; +import com.vaadin.ui.UI; + +public class LazyInitUIs extends AbstractTestApplication { + + @EagerInit + private static class EagerInitUI extends UI { + @Override + public void init(WrappedRequest request) { + addComponent(getRequestInfo("EagerInitUI", request)); + } + } + + @Override + public UI getUI(WrappedRequest request) + throws UIRequiresMoreInformationException { + if (request.getParameter("lazyCreate") != null) { + // UI created on second request + BrowserDetails browserDetails = request.getBrowserDetails(); + if (browserDetails == null + || browserDetails.getUriFragment() == null) { + throw new UIRequiresMoreInformationException(); + } else { + UI uI = new UI() { + @Override + protected void init(WrappedRequest request) { + addComponent(getRequestInfo("LazyCreateUI", request)); + } + }; + return uI; + } + } else if (request.getParameter("eagerInit") != null) { + // UI inited on first request + return new EagerInitUI(); + } else { + // The standard UI + UI uI = new UI() { + @Override + protected void init(WrappedRequest request) { + addComponent(getRequestInfo("NormalUI", request)); + + Link lazyCreateLink = new Link("Open lazyCreate UI", + new ExternalResource(getURL() + + "?lazyCreate#lazyCreate")); + lazyCreateLink.setTargetName("_blank"); + addComponent(lazyCreateLink); + + Link lazyInitLink = new Link("Open eagerInit UI", + new ExternalResource(getURL() + + "?eagerInit#eagerInit")); + lazyInitLink.setTargetName("_blank"); + addComponent(lazyInitLink); + } + }; + + return uI; + } + } + + public static Label getRequestInfo(String name, WrappedRequest request) { + String info = name; + info += "
      pathInfo: " + request.getRequestPathInfo(); + info += "
      parameters: " + request.getParameterMap().keySet(); + info += "
      uri fragment: " + + request.getBrowserDetails().getUriFragment(); + return new Label(info, ContentMode.XHTML); + } + + @Override + protected String getTestDescription() { + return "BrowserDetails should be available in Application.getUI if UIRequiresMoreInformation has been thrown and in UI.init if the UI has the @UIInitRequiresBrowserDetals annotation"; + } + + @Override + protected Integer getTicketNumber() { + return Integer.valueOf(7883); // + #7882 + #7884 + } + +} diff --git a/tests/testbench/com/vaadin/tests/components/ui/TestUITheme.html b/tests/testbench/com/vaadin/tests/components/ui/TestUITheme.html new file mode 100644 index 0000000000..ed2c0ec971 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/ui/TestUITheme.html @@ -0,0 +1,27 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + + +
      New Test
      open/run/com.vaadin.tests.components.ui.TestUITheme?restartApplication
      screenCapturethemeLoaded
      + + diff --git a/tests/testbench/com/vaadin/tests/components/ui/TestUITheme.java b/tests/testbench/com/vaadin/tests/components/ui/TestUITheme.java new file mode 100644 index 0000000000..39cc598094 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/ui/TestUITheme.java @@ -0,0 +1,28 @@ +package com.vaadin.tests.components.ui; + +import com.vaadin.annotations.Theme; +import com.vaadin.terminal.WrappedRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Label; + +@Theme("tests-tickets") +public class TestUITheme extends AbstractTestUI { + + @Override + protected void setup(WrappedRequest request) { + Label label = new Label("A red label"); + label.setStyleName("red"); + addComponent(label); + } + + @Override + public String getTestDescription() { + return "UI with @Theme(\"tests-tickets\")"; + } + + @Override + protected Integer getTicketNumber() { + return Integer.valueOf(7885); + } + +} diff --git a/tests/testbench/com/vaadin/tests/components/ui/TestUIWidgetset.html b/tests/testbench/com/vaadin/tests/components/ui/TestUIWidgetset.html new file mode 100644 index 0000000000..2f0858b4c7 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/ui/TestUIWidgetset.html @@ -0,0 +1,36 @@ + + + + + + +Ticket4607 + + + + + + + + + + + + + + + + + + + + + + + + + + +
      Ticket4607
      open/run/com.vaadin.tests.components.ui.TestUIWidgetset
      assertTextvaadin=runcomvaadintestscomponentsuiTestUIWidgetset::/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[0]This component is available in TestingWidgetset, but not in DefaultWidgetset
      open/run/com.vaadin.tests.components.ui.TestUIWidgetset2
      assertTextvaadin=runcomvaadintestscomponentsuiTestUIWidgetset2::/VVerticalLayout[0]/VVerticalLayout[0]/VUnknownComponent[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]Widgetset does not contain implementation for com.vaadin.tests.widgetset.server.MissingFromDefaultWidgetsetComponent. Check its component connector's @Connect mapping, widgetsets GWT module description file and re-compile your widgetset. In case you have downloaded a vaadin add-on package, you might want to refer to add-on instructions.
      + + diff --git a/tests/testbench/com/vaadin/tests/components/ui/TestUIWidgetset.java b/tests/testbench/com/vaadin/tests/components/ui/TestUIWidgetset.java new file mode 100644 index 0000000000..f26e94f243 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/ui/TestUIWidgetset.java @@ -0,0 +1,26 @@ +package com.vaadin.tests.components.ui; + +import com.vaadin.annotations.Widgetset; +import com.vaadin.terminal.WrappedRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.tests.widgetset.server.MissingFromDefaultWidgetsetComponent; + +@Widgetset("com.vaadin.tests.widgetset.TestingWidgetSet") +public class TestUIWidgetset extends AbstractTestUI { + + @Override + protected void setup(WrappedRequest request) { + addComponent(new MissingFromDefaultWidgetsetComponent()); + } + + @Override + public String getTestDescription() { + return "This contents if this UI should work as the component is present in TestingWidgetSet"; + } + + @Override + protected Integer getTicketNumber() { + return Integer.valueOf(7885); + } + +} diff --git a/tests/testbench/com/vaadin/tests/components/ui/TestUIWidgetset2.java b/tests/testbench/com/vaadin/tests/components/ui/TestUIWidgetset2.java new file mode 100644 index 0000000000..84c0780240 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/ui/TestUIWidgetset2.java @@ -0,0 +1,24 @@ +package com.vaadin.tests.components.ui; + +import com.vaadin.terminal.WrappedRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.tests.widgetset.server.MissingFromDefaultWidgetsetComponent; + +public class TestUIWidgetset2 extends AbstractTestUI { + + @Override + protected void setup(WrappedRequest request) { + addComponent(new MissingFromDefaultWidgetsetComponent()); + } + + @Override + public String getTestDescription() { + return "This contents if this UI should not work as the component is not present in DefaultWidgetSet"; + } + + @Override + protected Integer getTicketNumber() { + return Integer.valueOf(7885); + } + +} diff --git a/tests/testbench/com/vaadin/tests/components/ui/UIInitException.java b/tests/testbench/com/vaadin/tests/components/ui/UIInitException.java new file mode 100644 index 0000000000..29de6f6ac3 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/ui/UIInitException.java @@ -0,0 +1,23 @@ +package com.vaadin.tests.components.ui; + +import com.vaadin.terminal.WrappedRequest; +import com.vaadin.tests.components.AbstractTestUI; + +public class UIInitException extends AbstractTestUI { + + @Override + protected void setup(WrappedRequest request) { + throw new RuntimeException("Catch me if you can"); + } + + @Override + protected String getTestDescription() { + return "Throwing an exception in application code during a browser details request should show a sensible message in the client"; + } + + @Override + protected Integer getTicketNumber() { + return Integer.valueOf(8243); + } + +} diff --git a/tests/testbench/com/vaadin/tests/components/ui/UIInitTest.java b/tests/testbench/com/vaadin/tests/components/ui/UIInitTest.java new file mode 100644 index 0000000000..6efe1d1b28 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/ui/UIInitTest.java @@ -0,0 +1,27 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + +package com.vaadin.tests.components.ui; + +import com.vaadin.terminal.WrappedRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Label; + +public class UIInitTest extends AbstractTestUI { + + @Override + protected void setup(WrappedRequest request) { + addComponent(new Label("Hello UI")); + } + + @Override + public String getTestDescription() { + return "Testing basic UI creation"; + } + + @Override + protected Integer getTicketNumber() { + return Integer.valueOf(3067); + } +} diff --git a/tests/testbench/com/vaadin/tests/components/ui/UIsInMultipleTabs.html b/tests/testbench/com/vaadin/tests/components/ui/UIsInMultipleTabs.html new file mode 100644 index 0000000000..08561588c4 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/ui/UIsInMultipleTabs.html @@ -0,0 +1,47 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      New Test
      open/run/com.vaadin.tests.components.ui.UIsInMultipleTabs?restartApplication
      assertTextvaadin=runcomvaadintestscomponentsuiUIsInMultipleTabs::/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]This is UI number 1
      open/run/com.vaadin.tests.components.ui.UIsInMultipleTabs
      assertTextvaadin=runcomvaadintestscomponentsuiUIsInMultipleTabs::/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]This is UI number 2
      open/run/com.vaadin.tests.components.ui.UIsInMultipleTabs?restartApplication
      assertTextvaadin=runcomvaadintestscomponentsuiUIsInMultipleTabs::/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]This is UI number 1
      + + diff --git a/tests/testbench/com/vaadin/tests/components/ui/UIsInMultipleTabs.java b/tests/testbench/com/vaadin/tests/components/ui/UIsInMultipleTabs.java new file mode 100644 index 0000000000..8dd303a8e1 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/ui/UIsInMultipleTabs.java @@ -0,0 +1,45 @@ +package com.vaadin.tests.components.ui; + +import com.vaadin.Application; +import com.vaadin.UIRequiresMoreInformationException; +import com.vaadin.terminal.AbstractUIProvider; +import com.vaadin.terminal.WrappedRequest; +import com.vaadin.tests.components.AbstractTestApplication; +import com.vaadin.ui.Label; +import com.vaadin.ui.UI; + +public class UIsInMultipleTabs extends AbstractTestApplication { + private int numberOfUIsOpened; + + public static class TabUI extends UI { + @Override + protected void init(WrappedRequest request) { + UIsInMultipleTabs application = (UIsInMultipleTabs) getApplication(); + String message = "This is UI number " + + ++application.numberOfUIsOpened; + + addComponent(new Label(message)); + } + } + + public UIsInMultipleTabs() { + addUIProvider(new AbstractUIProvider() { + @Override + public Class getUIClass(Application application, + WrappedRequest request) + throws UIRequiresMoreInformationException { + return TabUI.class; + } + }); + } + + @Override + protected String getTestDescription() { + return "Opening the same application again (e.g. in a new tab) should create a new UI."; + } + + @Override + protected Integer getTicketNumber() { + return Integer.valueOf(7894); + } +} diff --git a/tests/testbench/com/vaadin/tests/components/ui/UriFragmentTest.html b/tests/testbench/com/vaadin/tests/components/ui/UriFragmentTest.html new file mode 100644 index 0000000000..bcb9f52afe --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/ui/UriFragmentTest.html @@ -0,0 +1,77 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      New Test
      open/run/com.vaadin.tests.components.ui.UriFragmentTest?restartApplication#urifragment
      assertTextvaadin=runcomvaadintestscomponentsuiUriFragmentTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]Current URI fragment: urifragment
      clickvaadin=runcomvaadintestscomponentsuiUriFragmentTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
      assertTextvaadin=runcomvaadintestscomponentsuiUriFragmentTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]Current URI fragment: test
      runScripthistory.back()
      pause1000
      waitForVaadin
      assertTextvaadin=runcomvaadintestscomponentsuiUriFragmentTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]Current URI fragment: urifragment
      runScripthistory.forward()
      pause1000
      waitForVaadin
      assertTextvaadin=runcomvaadintestscomponentsuiUriFragmentTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]Current URI fragment: test
      + + diff --git a/tests/testbench/com/vaadin/tests/components/ui/UriFragmentTest.java b/tests/testbench/com/vaadin/tests/components/ui/UriFragmentTest.java new file mode 100644 index 0000000000..d2167e67c7 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/ui/UriFragmentTest.java @@ -0,0 +1,53 @@ +package com.vaadin.tests.components.ui; + +import com.vaadin.terminal.Page; +import com.vaadin.terminal.Page.FragmentChangedEvent; +import com.vaadin.terminal.WrappedRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Label; + +public class UriFragmentTest extends AbstractTestUI { + + private final Label fragmentLabel = new Label(); + + @Override + protected void setup(WrappedRequest request) { + addComponent(fragmentLabel); + updateLabel(); + getPage().addListener(new Page.FragmentChangedListener() { + @Override + public void fragmentChanged(FragmentChangedEvent event) { + updateLabel(); + } + }); + addComponent(new Button("Navigate to #test", + new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + getPage().setFragment("test"); + } + })); + } + + private void updateLabel() { + String fragment = getPage().getFragment(); + if (fragment == null) { + fragmentLabel.setValue("No URI fragment set"); + } else { + fragmentLabel.setValue("Current URI fragment: " + fragment); + } + } + + @Override + public String getTestDescription() { + return "URI fragment status should be known when the page is loaded and retained while navigating to different fragments or using the back and forward buttons."; + } + + @Override + protected Integer getTicketNumber() { + return Integer.valueOf(8048); + } + +} diff --git a/tests/testbench/com/vaadin/tests/components/window/RepaintWindowContents.java b/tests/testbench/com/vaadin/tests/components/window/RepaintWindowContents.java index 59cd35c2cb..4d2f118ec7 100644 --- a/tests/testbench/com/vaadin/tests/components/window/RepaintWindowContents.java +++ b/tests/testbench/com/vaadin/tests/components/window/RepaintWindowContents.java @@ -1,7 +1,7 @@ package com.vaadin.tests.components.window; import com.vaadin.terminal.WrappedRequest; -import com.vaadin.tests.components.AbstractTestRoot; +import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; @@ -9,7 +9,7 @@ import com.vaadin.ui.Layout; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; -public class RepaintWindowContents extends AbstractTestRoot { +public class RepaintWindowContents extends AbstractTestUI { private static final long serialVersionUID = 1L; @SuppressWarnings("serial") diff --git a/tests/testbench/com/vaadin/tests/components/window/TooltipInWindow.java b/tests/testbench/com/vaadin/tests/components/window/TooltipInWindow.java index 56be00b923..a77a1f7703 100644 --- a/tests/testbench/com/vaadin/tests/components/window/TooltipInWindow.java +++ b/tests/testbench/com/vaadin/tests/components/window/TooltipInWindow.java @@ -17,11 +17,11 @@ package com.vaadin.tests.components.window; import com.vaadin.terminal.WrappedRequest; -import com.vaadin.tests.components.AbstractTestRoot; +import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.ui.TextField; import com.vaadin.ui.Window; -public class TooltipInWindow extends AbstractTestRoot { +public class TooltipInWindow extends AbstractTestUI { @Override protected void setup(WrappedRequest request) { diff --git a/tests/testbench/com/vaadin/tests/extensions/BasicExtensionTest.java b/tests/testbench/com/vaadin/tests/extensions/BasicExtensionTest.java index e774ee0286..daa2e78353 100644 --- a/tests/testbench/com/vaadin/tests/extensions/BasicExtensionTest.java +++ b/tests/testbench/com/vaadin/tests/extensions/BasicExtensionTest.java @@ -18,14 +18,14 @@ package com.vaadin.tests.extensions; import com.vaadin.annotations.Widgetset; import com.vaadin.terminal.WrappedRequest; -import com.vaadin.tests.components.AbstractTestRoot; +import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Label; @Widgetset("com.vaadin.tests.widgetset.TestingWidgetSet") -public class BasicExtensionTest extends AbstractTestRoot { +public class BasicExtensionTest extends AbstractTestUI { @Override protected void setup(WrappedRequest request) { diff --git a/tests/testbench/com/vaadin/tests/extensions/HelloWorldExtensionTest.java b/tests/testbench/com/vaadin/tests/extensions/HelloWorldExtensionTest.java index b389b77e97..e4646572db 100644 --- a/tests/testbench/com/vaadin/tests/extensions/HelloWorldExtensionTest.java +++ b/tests/testbench/com/vaadin/tests/extensions/HelloWorldExtensionTest.java @@ -17,12 +17,12 @@ package com.vaadin.tests.extensions; import com.vaadin.annotations.Widgetset; import com.vaadin.terminal.WrappedRequest; -import com.vaadin.tests.components.AbstractTestRoot; +import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; @Widgetset("com.vaadin.tests.widgetset.TestingWidgetSet") -public class HelloWorldExtensionTest extends AbstractTestRoot { +public class HelloWorldExtensionTest extends AbstractTestUI { @Override protected void setup(WrappedRequest request) { diff --git a/tests/testbench/com/vaadin/tests/extensions/JavascriptManagerTest.java b/tests/testbench/com/vaadin/tests/extensions/JavascriptManagerTest.java index 9d09436e45..6281f3eff4 100644 --- a/tests/testbench/com/vaadin/tests/extensions/JavascriptManagerTest.java +++ b/tests/testbench/com/vaadin/tests/extensions/JavascriptManagerTest.java @@ -20,12 +20,12 @@ import com.vaadin.external.json.JSONArray; import com.vaadin.external.json.JSONException; import com.vaadin.external.json.JSONObject; import com.vaadin.terminal.WrappedRequest; -import com.vaadin.tests.components.AbstractTestRoot; +import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.tests.util.Log; import com.vaadin.ui.JavaScript; import com.vaadin.ui.JavaScriptFunction; -public class JavascriptManagerTest extends AbstractTestRoot { +public class JavascriptManagerTest extends AbstractTestUI { private Log log = new Log(5); diff --git a/tests/testbench/com/vaadin/tests/extensions/SimpleJavaScriptExtensionTest.java b/tests/testbench/com/vaadin/tests/extensions/SimpleJavaScriptExtensionTest.java index 7d4f41cfb3..c604516b9c 100644 --- a/tests/testbench/com/vaadin/tests/extensions/SimpleJavaScriptExtensionTest.java +++ b/tests/testbench/com/vaadin/tests/extensions/SimpleJavaScriptExtensionTest.java @@ -25,13 +25,13 @@ import com.vaadin.shared.communication.ClientRpc; import com.vaadin.shared.communication.ServerRpc; import com.vaadin.terminal.AbstractJavaScriptExtension; import com.vaadin.terminal.WrappedRequest; -import com.vaadin.tests.components.AbstractTestRoot; +import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.JavaScriptFunction; import com.vaadin.ui.Notification; -public class SimpleJavaScriptExtensionTest extends AbstractTestRoot { +public class SimpleJavaScriptExtensionTest extends AbstractTestUI { public static class SimpleJavaScriptExtensionState extends JavaScriptExtensionState { diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a1/CustomConverterFactoryRoot.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a1/CustomConverterFactoryRoot.java deleted file mode 100644 index 89b4a0f8db..0000000000 --- a/tests/testbench/com/vaadin/tests/minitutorials/v7a1/CustomConverterFactoryRoot.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.vaadin.tests.minitutorials.v7a1; - -import com.vaadin.terminal.WrappedRequest; -import com.vaadin.tests.components.AbstractTestRoot; -import com.vaadin.ui.TextField; - -public class CustomConverterFactoryRoot extends AbstractTestRoot { - @Override - public void setup(WrappedRequest request) { - getApplication().setConverterFactory(new MyConverterFactory()); - - TextField tf = new TextField("This is my double field"); - tf.setImmediate(true); - tf.setConverter(Double.class); - addComponent(tf); - - // As we do not set the locale explicitly for the field we set the value - // after the field has been attached so it uses the application locale - // for conversion - tf.setConvertedValue(50.1); - - } - - @Override - protected String getTestDescription() { - return "Mini tutorial for https://vaadin.com/wiki/-/wiki/Main/Changing%20the%20default%20converters%20for%20an%20application"; - } - - @Override - protected Integer getTicketNumber() { - return null; - } -} diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a1/CustomConverterFactoryUI.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a1/CustomConverterFactoryUI.java new file mode 100644 index 0000000000..eb34747450 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/minitutorials/v7a1/CustomConverterFactoryUI.java @@ -0,0 +1,33 @@ +package com.vaadin.tests.minitutorials.v7a1; + +import com.vaadin.terminal.WrappedRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.TextField; + +public class CustomConverterFactoryUI extends AbstractTestUI { + @Override + public void setup(WrappedRequest request) { + getApplication().setConverterFactory(new MyConverterFactory()); + + TextField tf = new TextField("This is my double field"); + tf.setImmediate(true); + tf.setConverter(Double.class); + addComponent(tf); + + // As we do not set the locale explicitly for the field we set the value + // after the field has been attached so it uses the application locale + // for conversion + tf.setConvertedValue(50.1); + + } + + @Override + protected String getTestDescription() { + return "Mini tutorial for https://vaadin.com/wiki/-/wiki/Main/Changing%20the%20default%20converters%20for%20an%20application"; + } + + @Override + protected Integer getTicketNumber() { + return null; + } +} diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a1/DefineRootTheme.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a1/DefineRootTheme.java deleted file mode 100644 index 6c9282eb01..0000000000 --- a/tests/testbench/com/vaadin/tests/minitutorials/v7a1/DefineRootTheme.java +++ /dev/null @@ -1,42 +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.tests.minitutorials.v7a1; - -import com.vaadin.annotations.Theme; -import com.vaadin.terminal.WrappedRequest; -import com.vaadin.ui.Label; -import com.vaadin.ui.UI; -import com.vaadin.ui.VerticalLayout; - -/** - * Mini tutorial code for - * https://vaadin.com/wiki/-/wiki/Main/Defining%20the%20theme%20for%20a%20Root - * - * @author Vaadin Ltd - * @since 7.0.0 - */ -@Theme("hello-theme") -public class DefineRootTheme extends UI { - - @Override - protected void init(WrappedRequest request) { - VerticalLayout view = new VerticalLayout(); - view.addComponent(new Label("Hello Vaadin")); - setContent(view); - } - -} diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a1/DefineUITheme.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a1/DefineUITheme.java new file mode 100644 index 0000000000..12938f9f12 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/minitutorials/v7a1/DefineUITheme.java @@ -0,0 +1,42 @@ +/* + * 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.tests.minitutorials.v7a1; + +import com.vaadin.annotations.Theme; +import com.vaadin.terminal.WrappedRequest; +import com.vaadin.ui.Label; +import com.vaadin.ui.UI; +import com.vaadin.ui.VerticalLayout; + +/** + * Mini tutorial code for + * https://vaadin.com/wiki/-/wiki/Main/Defining%20the%20theme%20for%20a%20Root + * + * @author Vaadin Ltd + * @since 7.0.0 + */ +@Theme("hello-theme") +public class DefineUITheme extends UI { + + @Override + protected void init(WrappedRequest request) { + VerticalLayout view = new VerticalLayout(); + view.addComponent(new Label("Hello Vaadin")); + setContent(view); + } + +} diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a1/DynamicImageRoot.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a1/DynamicImageRoot.java deleted file mode 100644 index 81f225bc63..0000000000 --- a/tests/testbench/com/vaadin/tests/minitutorials/v7a1/DynamicImageRoot.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.vaadin.tests.minitutorials.v7a1; - -import java.awt.image.BufferedImage; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; - -import javax.imageio.ImageIO; - -import com.vaadin.Application; -import com.vaadin.terminal.ExternalResource; -import com.vaadin.terminal.RequestHandler; -import com.vaadin.terminal.WrappedRequest; -import com.vaadin.terminal.WrappedResponse; -import com.vaadin.tests.components.AbstractTestRoot; -import com.vaadin.ui.Embedded; - -public class DynamicImageRoot extends AbstractTestRoot { - - @Override - public void setup(WrappedRequest request) { - // Add the request handler that handles our dynamic image - getApplication().addRequestHandler(new DynamicImageRequestHandler()); - - // Create a URL that we can handle in DynamicImageRequestHandler - URL imageUrl; - try { - imageUrl = new URL(getApplication().getURL(), - DynamicImageRequestHandler.IMAGE_URL + "?text=Hello!"); - } catch (MalformedURLException e) { - // This should never happen - throw new RuntimeException(e); - } - - // Add an embedded using the created URL - Embedded embedded = new Embedded("A dynamically generated image", - new ExternalResource(imageUrl)); - embedded.setType(Embedded.TYPE_IMAGE); - getContent().addComponent(embedded); - - } - - @Override - protected String getTestDescription() { - return "Mini tutorial for https://vaadin.com/wiki/-/wiki/Main/Generating%20dynamic%20resources%20based%20on%20URI%20or%20parameters"; - } - - @Override - protected Integer getTicketNumber() { - return null; - } -} - -class DynamicImageRequestHandler implements RequestHandler { - - public static final String IMAGE_URL = "myimage.png"; - - @Override - public boolean handleRequest(Application application, - WrappedRequest request, WrappedResponse response) - throws IOException { - String pathInfo = request.getRequestPathInfo(); - if (("/" + IMAGE_URL).equals(pathInfo)) { - // Create an image, draw the "text" parameter to it and output it to - // the browser. - String text = request.getParameter("text"); - BufferedImage bi = new BufferedImage(100, 30, - BufferedImage.TYPE_3BYTE_BGR); - bi.getGraphics().drawChars(text.toCharArray(), 0, text.length(), - 10, 20); - response.setContentType("image/png"); - ImageIO.write(bi, "png", response.getOutputStream()); - - return true; - } - // If the URL did not match our image URL, let the other request - // handlers handle it - return false; - } -} diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a1/DynamicImageUI.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a1/DynamicImageUI.java new file mode 100644 index 0000000000..f3e96aaafc --- /dev/null +++ b/tests/testbench/com/vaadin/tests/minitutorials/v7a1/DynamicImageUI.java @@ -0,0 +1,80 @@ +package com.vaadin.tests.minitutorials.v7a1; + +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; + +import javax.imageio.ImageIO; + +import com.vaadin.Application; +import com.vaadin.terminal.ExternalResource; +import com.vaadin.terminal.RequestHandler; +import com.vaadin.terminal.WrappedRequest; +import com.vaadin.terminal.WrappedResponse; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Embedded; + +public class DynamicImageUI extends AbstractTestUI { + + @Override + public void setup(WrappedRequest request) { + // Add the request handler that handles our dynamic image + getApplication().addRequestHandler(new DynamicImageRequestHandler()); + + // Create a URL that we can handle in DynamicImageRequestHandler + URL imageUrl; + try { + imageUrl = new URL(getApplication().getURL(), + DynamicImageRequestHandler.IMAGE_URL + "?text=Hello!"); + } catch (MalformedURLException e) { + // This should never happen + throw new RuntimeException(e); + } + + // Add an embedded using the created URL + Embedded embedded = new Embedded("A dynamically generated image", + new ExternalResource(imageUrl)); + embedded.setType(Embedded.TYPE_IMAGE); + getContent().addComponent(embedded); + + } + + @Override + protected String getTestDescription() { + return "Mini tutorial for https://vaadin.com/wiki/-/wiki/Main/Generating%20dynamic%20resources%20based%20on%20URI%20or%20parameters"; + } + + @Override + protected Integer getTicketNumber() { + return null; + } +} + +class DynamicImageRequestHandler implements RequestHandler { + + public static final String IMAGE_URL = "myimage.png"; + + @Override + public boolean handleRequest(Application application, + WrappedRequest request, WrappedResponse response) + throws IOException { + String pathInfo = request.getRequestPathInfo(); + if (("/" + IMAGE_URL).equals(pathInfo)) { + // Create an image, draw the "text" parameter to it and output it to + // the browser. + String text = request.getParameter("text"); + BufferedImage bi = new BufferedImage(100, 30, + BufferedImage.TYPE_3BYTE_BGR); + bi.getGraphics().drawChars(text.toCharArray(), 0, text.length(), + 10, 20); + response.setContentType("image/png"); + ImageIO.write(bi, "png", response.getOutputStream()); + + return true; + } + // If the URL did not match our image URL, let the other request + // handlers handle it + return false; + } +} diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a1/FindCurrentRootAndApplication.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a1/FindCurrentRootAndApplication.java deleted file mode 100644 index a786ecb533..0000000000 --- a/tests/testbench/com/vaadin/tests/minitutorials/v7a1/FindCurrentRootAndApplication.java +++ /dev/null @@ -1,61 +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.tests.minitutorials.v7a1; - -import com.vaadin.Application; -import com.vaadin.terminal.WrappedRequest; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; -import com.vaadin.ui.Notification; -import com.vaadin.ui.UI; - -/** - * Mini tutorial code for - * https://vaadin.com/wiki/-/wiki/Main/Finding%20the%20current - * %20Root%20and%20Application - * - * @author Vaadin Ltd - * @since 7.0.0 - */ -public class FindCurrentRootAndApplication extends UI { - - @Override - protected void init(WrappedRequest request) { - Button helloButton = new Button("Say Hello"); - helloButton.addListener(new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - String msg = "Running in "; - msg += Application.getCurrent().isProductionMode() ? "production" - : "debug"; - Notification.show(msg); - } - }); - - helloButton.addListener(new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - Notification.show("This UI is " - + UI.getCurrent().getClass().getSimpleName()); - } - }); - - addComponent(helloButton); - } - -} diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a1/FindCurrentUI.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a1/FindCurrentUI.java new file mode 100644 index 0000000000..9830ee6aeb --- /dev/null +++ b/tests/testbench/com/vaadin/tests/minitutorials/v7a1/FindCurrentUI.java @@ -0,0 +1,61 @@ +/* + * 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.tests.minitutorials.v7a1; + +import com.vaadin.Application; +import com.vaadin.terminal.WrappedRequest; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Button.ClickListener; +import com.vaadin.ui.Notification; +import com.vaadin.ui.UI; + +/** + * Mini tutorial code for + * https://vaadin.com/wiki/-/wiki/Main/Finding%20the%20current + * %20Root%20and%20Application + * + * @author Vaadin Ltd + * @since 7.0.0 + */ +public class FindCurrentUI extends UI { + + @Override + protected void init(WrappedRequest request) { + Button helloButton = new Button("Say Hello"); + helloButton.addListener(new ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + String msg = "Running in "; + msg += Application.getCurrent().isProductionMode() ? "production" + : "debug"; + Notification.show(msg); + } + }); + + helloButton.addListener(new ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + Notification.show("This UI is " + + UI.getCurrent().getClass().getSimpleName()); + } + }); + + addComponent(helloButton); + } + +} diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a1/FormUsingExistingLayout.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a1/FormUsingExistingLayout.java index 1e460b2f6e..2a8b228bc3 100644 --- a/tests/testbench/com/vaadin/tests/minitutorials/v7a1/FormUsingExistingLayout.java +++ b/tests/testbench/com/vaadin/tests/minitutorials/v7a1/FormUsingExistingLayout.java @@ -4,12 +4,12 @@ import com.vaadin.data.fieldgroup.FieldGroup; import com.vaadin.data.fieldgroup.PropertyId; import com.vaadin.data.util.BeanItem; import com.vaadin.terminal.WrappedRequest; -import com.vaadin.tests.components.AbstractTestRoot; +import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.ui.GridLayout; import com.vaadin.ui.TextArea; import com.vaadin.ui.TextField; -public class FormUsingExistingLayout extends AbstractTestRoot { +public class FormUsingExistingLayout extends AbstractTestUI { public static class Notice { String firstName; diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a1/FormatTableValue.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a1/FormatTableValue.java index e487c6d3c4..5dd9322364 100644 --- a/tests/testbench/com/vaadin/tests/minitutorials/v7a1/FormatTableValue.java +++ b/tests/testbench/com/vaadin/tests/minitutorials/v7a1/FormatTableValue.java @@ -5,10 +5,10 @@ import java.util.Locale; import com.vaadin.data.util.converter.StringToNumberConverter; import com.vaadin.terminal.WrappedRequest; -import com.vaadin.tests.components.AbstractTestRoot; +import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.ui.Table; -public class FormatTableValue extends AbstractTestRoot { +public class FormatTableValue extends AbstractTestUI { private static final String PERCENT_PROPERTY = "percent"; private static final String CURRENCY_PROPERTY = "currency"; diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a1/IntegerTextFieldDataSource.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a1/IntegerTextFieldDataSource.java index af60b0e9e3..38a578189a 100644 --- a/tests/testbench/com/vaadin/tests/minitutorials/v7a1/IntegerTextFieldDataSource.java +++ b/tests/testbench/com/vaadin/tests/minitutorials/v7a1/IntegerTextFieldDataSource.java @@ -3,7 +3,7 @@ package com.vaadin.tests.minitutorials.v7a1; import com.vaadin.data.Property; import com.vaadin.data.util.BeanItem; import com.vaadin.terminal.WrappedRequest; -import com.vaadin.tests.components.AbstractTestRoot; +import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; @@ -11,7 +11,7 @@ import com.vaadin.ui.Label; import com.vaadin.ui.Notification; import com.vaadin.ui.TextField; -public class IntegerTextFieldDataSource extends AbstractTestRoot { +public class IntegerTextFieldDataSource extends AbstractTestUI { public class MyBean { private int value; diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a1/IntegerTextFieldStandalone.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a1/IntegerTextFieldStandalone.java index f733b5df40..9d968f360a 100644 --- a/tests/testbench/com/vaadin/tests/minitutorials/v7a1/IntegerTextFieldStandalone.java +++ b/tests/testbench/com/vaadin/tests/minitutorials/v7a1/IntegerTextFieldStandalone.java @@ -3,7 +3,7 @@ package com.vaadin.tests.minitutorials.v7a1; import com.vaadin.data.util.converter.Converter.ConversionException; import com.vaadin.data.util.converter.StringToIntegerConverter; import com.vaadin.terminal.WrappedRequest; -import com.vaadin.tests.components.AbstractTestRoot; +import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; @@ -11,7 +11,7 @@ import com.vaadin.ui.Label; import com.vaadin.ui.Notification; import com.vaadin.ui.TextField; -public class IntegerTextFieldStandalone extends AbstractTestRoot { +public class IntegerTextFieldStandalone extends AbstractTestUI { @Override protected void setup(WrappedRequest request) { diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a1/StringMyTypeConverter.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a1/StringMyTypeConverter.java index c2393300f2..67a795a314 100644 --- a/tests/testbench/com/vaadin/tests/minitutorials/v7a1/StringMyTypeConverter.java +++ b/tests/testbench/com/vaadin/tests/minitutorials/v7a1/StringMyTypeConverter.java @@ -5,14 +5,14 @@ import java.util.Locale; import com.vaadin.data.util.converter.Converter; import com.vaadin.data.util.converter.Converter.ConversionException; import com.vaadin.terminal.WrappedRequest; -import com.vaadin.tests.components.AbstractTestRoot; +import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Notification; import com.vaadin.ui.TextField; -public class StringMyTypeConverter extends AbstractTestRoot { +public class StringMyTypeConverter extends AbstractTestUI { @Override protected void setup(WrappedRequest request) { diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a2/ComponentInStateRoot.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a2/ComponentInStateRoot.java deleted file mode 100644 index b5bf8538ed..0000000000 --- a/tests/testbench/com/vaadin/tests/minitutorials/v7a2/ComponentInStateRoot.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.vaadin.tests.minitutorials.v7a2; - -import com.vaadin.annotations.Widgetset; -import com.vaadin.terminal.WrappedRequest; -import com.vaadin.ui.Label; -import com.vaadin.ui.UI; - -/** - * Mini tutorial code for - * https://vaadin.com/wiki/-/wiki/Main/Using%20Components% - * 20in%20the%20shared%20state - * - * @author Vaadin Ltd - * @since 7.0.0 - */ -@Widgetset("com.vaadin.tests.widgetset.TestingWidgetSet") -public class ComponentInStateRoot extends UI { - @Override - protected void init(WrappedRequest request) { - ComponentInStateComponent component = new ComponentInStateComponent(); - component.setOtherComponent(this); - addComponent(component); - addComponent(new Label("Server-side type of other component: " - + component.getOtherComponent().getClass().getName())); - } -} diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a2/ComponentInStateUI.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a2/ComponentInStateUI.java new file mode 100644 index 0000000000..1bde122dbf --- /dev/null +++ b/tests/testbench/com/vaadin/tests/minitutorials/v7a2/ComponentInStateUI.java @@ -0,0 +1,26 @@ +package com.vaadin.tests.minitutorials.v7a2; + +import com.vaadin.annotations.Widgetset; +import com.vaadin.terminal.WrappedRequest; +import com.vaadin.ui.Label; +import com.vaadin.ui.UI; + +/** + * Mini tutorial code for + * https://vaadin.com/wiki/-/wiki/Main/Using%20Components% + * 20in%20the%20shared%20state + * + * @author Vaadin Ltd + * @since 7.0.0 + */ +@Widgetset("com.vaadin.tests.widgetset.TestingWidgetSet") +public class ComponentInStateUI extends UI { + @Override + protected void init(WrappedRequest request) { + ComponentInStateComponent component = new ComponentInStateComponent(); + component.setOtherComponent(this); + addComponent(component); + addComponent(new Label("Server-side type of other component: " + + component.getOtherComponent().getClass().getName())); + } +} diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a2/MyComponentRoot.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a2/MyComponentRoot.java deleted file mode 100644 index 87aede8da9..0000000000 --- a/tests/testbench/com/vaadin/tests/minitutorials/v7a2/MyComponentRoot.java +++ /dev/null @@ -1,47 +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.tests.minitutorials.v7a2; - -import com.vaadin.annotations.Widgetset; -import com.vaadin.terminal.WrappedRequest; -import com.vaadin.ui.UI; - -/** - * Mini tutorial code for - * https://vaadin.com/wiki/-/wiki/Main/Creating%20a%20simple%20component, - * https://vaadin.com/wiki/-/wiki/Main/Creating%20a%20simple%20component, - * https://vaadin.com/wiki/-/wiki/Main/Sending% - * 20events%20from%20the%20client%20to%20the%20server%20using%20RPC, - * https://vaadin - * .com/wiki/-/wiki/Main/Using%20RPC%20to%20send%20events%20to%20the%20client - * - * @author Vaadin Ltd - * @since 7.0.0 - */ -@Widgetset("com.vaadin.tests.widgetset.TestingWidgetSet") -public class MyComponentRoot extends UI { - - @Override - protected void init(WrappedRequest request) { - MyComponent component = new MyComponent(); - - component.setText("My component text"); - - addComponent(component); - } - -} \ No newline at end of file diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a2/MyComponentUI.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a2/MyComponentUI.java new file mode 100644 index 0000000000..d9091e4287 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/minitutorials/v7a2/MyComponentUI.java @@ -0,0 +1,47 @@ +/* + * 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.tests.minitutorials.v7a2; + +import com.vaadin.annotations.Widgetset; +import com.vaadin.terminal.WrappedRequest; +import com.vaadin.ui.UI; + +/** + * Mini tutorial code for + * https://vaadin.com/wiki/-/wiki/Main/Creating%20a%20simple%20component, + * https://vaadin.com/wiki/-/wiki/Main/Creating%20a%20simple%20component, + * https://vaadin.com/wiki/-/wiki/Main/Sending% + * 20events%20from%20the%20client%20to%20the%20server%20using%20RPC, + * https://vaadin + * .com/wiki/-/wiki/Main/Using%20RPC%20to%20send%20events%20to%20the%20client + * + * @author Vaadin Ltd + * @since 7.0.0 + */ +@Widgetset("com.vaadin.tests.widgetset.TestingWidgetSet") +public class MyComponentUI extends UI { + + @Override + protected void init(WrappedRequest request) { + MyComponent component = new MyComponent(); + + component.setText("My component text"); + + addComponent(component); + } + +} \ No newline at end of file diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a2/ResourceInStateRoot.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a2/ResourceInStateRoot.java deleted file mode 100644 index 04e2cf089e..0000000000 --- a/tests/testbench/com/vaadin/tests/minitutorials/v7a2/ResourceInStateRoot.java +++ /dev/null @@ -1,43 +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.tests.minitutorials.v7a2; - -import com.vaadin.annotations.Widgetset; -import com.vaadin.terminal.ThemeResource; -import com.vaadin.terminal.WrappedRequest; -import com.vaadin.ui.UI; - -/** - * Mini tutorial code for - * https://vaadin.com/wiki/-/wiki/Main/Using%20Resources%20 - * in%20the%20shared%20state - * - * @author Vaadin Ltd - * @since 7.0.0 - */ -@Widgetset("com.vaadin.tests.widgetset.TestingWidgetSet") -public class ResourceInStateRoot extends UI { - - @Override - protected void init(WrappedRequest request) { - ResourceInStateComponent component = new ResourceInStateComponent(); - component.setIcon(new ThemeResource("../runo/icons/32/calendar.png")); - - addComponent(component); - } - -} diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a2/ResourceInStateUI.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a2/ResourceInStateUI.java new file mode 100644 index 0000000000..37f4255cdd --- /dev/null +++ b/tests/testbench/com/vaadin/tests/minitutorials/v7a2/ResourceInStateUI.java @@ -0,0 +1,43 @@ +/* + * 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.tests.minitutorials.v7a2; + +import com.vaadin.annotations.Widgetset; +import com.vaadin.terminal.ThemeResource; +import com.vaadin.terminal.WrappedRequest; +import com.vaadin.ui.UI; + +/** + * Mini tutorial code for + * https://vaadin.com/wiki/-/wiki/Main/Using%20Resources%20 + * in%20the%20shared%20state + * + * @author Vaadin Ltd + * @since 7.0.0 + */ +@Widgetset("com.vaadin.tests.widgetset.TestingWidgetSet") +public class ResourceInStateUI extends UI { + + @Override + protected void init(WrappedRequest request) { + ResourceInStateComponent component = new ResourceInStateComponent(); + component.setIcon(new ThemeResource("../runo/icons/32/calendar.png")); + + addComponent(component); + } + +} diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a2/WidgetcontainerRoot.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a2/WidgetcontainerRoot.java deleted file mode 100644 index 38f008d8a0..0000000000 --- a/tests/testbench/com/vaadin/tests/minitutorials/v7a2/WidgetcontainerRoot.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.vaadin.tests.minitutorials.v7a2; - -import java.util.Random; - -import com.vaadin.annotations.Widgetset; -import com.vaadin.terminal.WrappedRequest; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; -import com.vaadin.ui.CheckBox; -import com.vaadin.ui.Component; -import com.vaadin.ui.Label; -import com.vaadin.ui.UI; - -@Widgetset("com.vaadin.tests.widgetset.TestingWidgetSet") -public class WidgetcontainerRoot extends UI { - @Override - public void init(WrappedRequest request) { - Label label = new Label("Hello Vaadin user"); - addComponent(label); - final WidgetContainer widgetContainer = new WidgetContainer(); - addComponent(widgetContainer); - widgetContainer.addComponent(new Label( - "Click the button to add components to the WidgetContainer.")); - Button button = new Button("Add more components", new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - Random randomGenerator = new Random(); - int random = randomGenerator.nextInt(3); - Component component; - if (random % 3 == 0) { - component = new Label("A new label"); - } else if (random % 3 == 1) { - component = new Button("A button!"); - } else { - component = new CheckBox("A textfield"); - } - widgetContainer.addComponent(component); - } - }); - addComponent(button); - } - -} \ No newline at end of file diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a2/WidgetcontainerUI.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a2/WidgetcontainerUI.java new file mode 100644 index 0000000000..8c728548c0 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/minitutorials/v7a2/WidgetcontainerUI.java @@ -0,0 +1,45 @@ +package com.vaadin.tests.minitutorials.v7a2; + +import java.util.Random; + +import com.vaadin.annotations.Widgetset; +import com.vaadin.terminal.WrappedRequest; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Button.ClickListener; +import com.vaadin.ui.CheckBox; +import com.vaadin.ui.Component; +import com.vaadin.ui.Label; +import com.vaadin.ui.UI; + +@Widgetset("com.vaadin.tests.widgetset.TestingWidgetSet") +public class WidgetcontainerUI extends UI { + @Override + public void init(WrappedRequest request) { + Label label = new Label("Hello Vaadin user"); + addComponent(label); + final WidgetContainer widgetContainer = new WidgetContainer(); + addComponent(widgetContainer); + widgetContainer.addComponent(new Label( + "Click the button to add components to the WidgetContainer.")); + Button button = new Button("Add more components", new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + Random randomGenerator = new Random(); + int random = randomGenerator.nextInt(3); + Component component; + if (random % 3 == 0) { + component = new Label("A new label"); + } else if (random % 3 == 1) { + component = new Button("A button!"); + } else { + component = new CheckBox("A textfield"); + } + widgetContainer.addComponent(component); + } + }); + addComponent(button); + } + +} \ No newline at end of file diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a3/AnalyticsRoot.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a3/AnalyticsRoot.java deleted file mode 100644 index 05255d71cb..0000000000 --- a/tests/testbench/com/vaadin/tests/minitutorials/v7a3/AnalyticsRoot.java +++ /dev/null @@ -1,39 +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.tests.minitutorials.v7a3; - -import com.vaadin.terminal.WrappedRequest; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.UI; - -public class AnalyticsRoot extends UI { - - @Override - protected void init(WrappedRequest request) { - final Analytics analytics = new Analytics("UA-33036133-12"); - analytics.extend(this); - - addComponent(new Button("Track pageview", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - analytics.trackPageview("/fake/url"); - } - })); - } - -} diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a3/AnalyticsUI.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a3/AnalyticsUI.java new file mode 100644 index 0000000000..bae3c4fc9c --- /dev/null +++ b/tests/testbench/com/vaadin/tests/minitutorials/v7a3/AnalyticsUI.java @@ -0,0 +1,39 @@ +/* + * 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.tests.minitutorials.v7a3; + +import com.vaadin.terminal.WrappedRequest; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.UI; + +public class AnalyticsUI extends UI { + + @Override + protected void init(WrappedRequest request) { + final Analytics analytics = new Analytics("UA-33036133-12"); + analytics.extend(this); + + addComponent(new Button("Track pageview", new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + analytics.trackPageview("/fake/url"); + } + })); + } + +} diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a3/ComplexTypesRoot.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a3/ComplexTypesRoot.java deleted file mode 100644 index ffe654d0b3..0000000000 --- a/tests/testbench/com/vaadin/tests/minitutorials/v7a3/ComplexTypesRoot.java +++ /dev/null @@ -1,31 +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.tests.minitutorials.v7a3; - -import com.vaadin.terminal.WrappedRequest; -import com.vaadin.ui.UI; - -public class ComplexTypesRoot extends UI { - - @Override - protected void init(WrappedRequest request) { - ComplexTypesComponent complexTypesComponent = new ComplexTypesComponent(); - complexTypesComponent.sendComplexTypes(); - addComponent(complexTypesComponent); - } - -} diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a3/ComplexTypesUI.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a3/ComplexTypesUI.java new file mode 100644 index 0000000000..093f3269e0 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/minitutorials/v7a3/ComplexTypesUI.java @@ -0,0 +1,31 @@ +/* + * 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.tests.minitutorials.v7a3; + +import com.vaadin.terminal.WrappedRequest; +import com.vaadin.ui.UI; + +public class ComplexTypesUI extends UI { + + @Override + protected void init(WrappedRequest request) { + ComplexTypesComponent complexTypesComponent = new ComplexTypesComponent(); + complexTypesComponent.sendComplexTypes(); + addComponent(complexTypesComponent); + } + +} diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a3/FlotJavaScriptRoot.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a3/FlotJavaScriptRoot.java deleted file mode 100644 index a8bf867fb5..0000000000 --- a/tests/testbench/com/vaadin/tests/minitutorials/v7a3/FlotJavaScriptRoot.java +++ /dev/null @@ -1,43 +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.tests.minitutorials.v7a3; - -import com.vaadin.terminal.WrappedRequest; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.UI; - -public class FlotJavaScriptRoot extends UI { - - @Override - protected void init(WrappedRequest request) { - final Flot flot = new Flot(); - flot.setHeight("300px"); - flot.setWidth("400px"); - - flot.addSeries(1, 2, 4, 8, 16); - addComponent(flot); - - addComponent(new Button("Highlight point", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - flot.highlight(0, 3); - } - })); - } - -} diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a3/FlotJavaScriptUI.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a3/FlotJavaScriptUI.java new file mode 100644 index 0000000000..02bd8a7cce --- /dev/null +++ b/tests/testbench/com/vaadin/tests/minitutorials/v7a3/FlotJavaScriptUI.java @@ -0,0 +1,43 @@ +/* + * 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.tests.minitutorials.v7a3; + +import com.vaadin.terminal.WrappedRequest; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.UI; + +public class FlotJavaScriptUI extends UI { + + @Override + protected void init(WrappedRequest request) { + final Flot flot = new Flot(); + flot.setHeight("300px"); + flot.setWidth("400px"); + + flot.addSeries(1, 2, 4, 8, 16); + addComponent(flot); + + addComponent(new Button("Highlight point", new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + flot.highlight(0, 3); + } + })); + } + +} diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a3/RedButtonRoot.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a3/RedButtonRoot.java deleted file mode 100644 index 73fba3fd7e..0000000000 --- a/tests/testbench/com/vaadin/tests/minitutorials/v7a3/RedButtonRoot.java +++ /dev/null @@ -1,27 +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.tests.minitutorials.v7a3; - -import com.vaadin.terminal.WrappedRequest; -import com.vaadin.ui.UI; - -public class RedButtonRoot extends UI { - @Override - protected void init(WrappedRequest request) { - addComponent(new RedButton("My red button")); - } -} \ No newline at end of file diff --git a/tests/testbench/com/vaadin/tests/minitutorials/v7a3/RedButtonUI.java b/tests/testbench/com/vaadin/tests/minitutorials/v7a3/RedButtonUI.java new file mode 100644 index 0000000000..9384394870 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/minitutorials/v7a3/RedButtonUI.java @@ -0,0 +1,27 @@ +/* + * 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.tests.minitutorials.v7a3; + +import com.vaadin.terminal.WrappedRequest; +import com.vaadin.ui.UI; + +public class RedButtonUI extends UI { + @Override + protected void init(WrappedRequest request) { + addComponent(new RedButton("My red button")); + } +} \ No newline at end of file diff --git a/tests/testbench/com/vaadin/tests/serialization/DelegateToWidgetTest.java b/tests/testbench/com/vaadin/tests/serialization/DelegateToWidgetTest.java index 54170c880f..b775c18f8f 100644 --- a/tests/testbench/com/vaadin/tests/serialization/DelegateToWidgetTest.java +++ b/tests/testbench/com/vaadin/tests/serialization/DelegateToWidgetTest.java @@ -18,12 +18,12 @@ package com.vaadin.tests.serialization; import com.vaadin.annotations.Widgetset; import com.vaadin.terminal.WrappedRequest; -import com.vaadin.tests.components.AbstractTestRoot; +import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.tests.widgetset.TestingWidgetSet; import com.vaadin.tests.widgetset.server.DelegateToWidgetComponent; @Widgetset(TestingWidgetSet.NAME) -public class DelegateToWidgetTest extends AbstractTestRoot { +public class DelegateToWidgetTest extends AbstractTestUI { @Override protected void setup(WrappedRequest request) { addComponent(new DelegateToWidgetComponent()); diff --git a/tests/testbench/com/vaadin/tests/serialization/SerializerNamespaceTest.java b/tests/testbench/com/vaadin/tests/serialization/SerializerNamespaceTest.java index 110475e5a9..0bb3b6c542 100644 --- a/tests/testbench/com/vaadin/tests/serialization/SerializerNamespaceTest.java +++ b/tests/testbench/com/vaadin/tests/serialization/SerializerNamespaceTest.java @@ -18,13 +18,13 @@ package com.vaadin.tests.serialization; import com.vaadin.annotations.Widgetset; import com.vaadin.terminal.WrappedRequest; -import com.vaadin.tests.components.AbstractTestRoot; +import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.tests.widgetset.TestingWidgetSet; import com.vaadin.tests.widgetset.server.DummyLabel; import com.vaadin.ui.Label; @Widgetset(TestingWidgetSet.NAME) -public class SerializerNamespaceTest extends AbstractTestRoot { +public class SerializerNamespaceTest extends AbstractTestUI { @Override protected void setup(WrappedRequest request) { diff --git a/tests/testbench/com/vaadin/tests/serialization/SerializerTest.java b/tests/testbench/com/vaadin/tests/serialization/SerializerTest.java index 3e194010d1..6ad6b6d530 100644 --- a/tests/testbench/com/vaadin/tests/serialization/SerializerTest.java +++ b/tests/testbench/com/vaadin/tests/serialization/SerializerTest.java @@ -30,7 +30,7 @@ import com.vaadin.annotations.Widgetset; import com.vaadin.shared.Connector; import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.terminal.WrappedRequest; -import com.vaadin.tests.components.AbstractTestRoot; +import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.tests.util.Log; import com.vaadin.tests.widgetset.client.ComplexTestBean; import com.vaadin.tests.widgetset.client.SerializerTestRpc; @@ -38,7 +38,7 @@ import com.vaadin.tests.widgetset.client.SimpleTestBean; import com.vaadin.tests.widgetset.server.SerializerTestExtension; @Widgetset("com.vaadin.tests.widgetset.TestingWidgetSet") -public class SerializerTest extends AbstractTestRoot { +public class SerializerTest extends AbstractTestUI { private Log log = new Log(40); diff --git a/tests/testbench/com/vaadin/tests/vaadincontext/BootstrapModify.html b/tests/testbench/com/vaadin/tests/vaadincontext/BootstrapModify.html deleted file mode 100644 index 8888f95d15..0000000000 --- a/tests/testbench/com/vaadin/tests/vaadincontext/BootstrapModify.html +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - -New Test - - - - - - - - - - - - - - - - - - - - - - - - - - -
      New Test
      open/run/com.vaadin.tests.vaadincontext.BootstrapModifyRoot?restartApplication
      assertTextvaadin=runcomvaadintestsvaadincontextBootstrapModifyRoot::/VVerticalLayout[0]/VLabel[0]There should be two additional divs in the HTML of the bootstrap page for this Root
      assertText//div[1]Added by modifyBootstrapPage
      assertText//div[2]Added by modifyBootstrapFragment
      - - diff --git a/tests/testbench/com/vaadin/tests/vaadincontext/BootstrapModifyRoot.java b/tests/testbench/com/vaadin/tests/vaadincontext/BootstrapModifyRoot.java deleted file mode 100644 index eefd37522b..0000000000 --- a/tests/testbench/com/vaadin/tests/vaadincontext/BootstrapModifyRoot.java +++ /dev/null @@ -1,40 +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.tests.vaadincontext; - -import com.vaadin.terminal.WrappedRequest; -import com.vaadin.tests.components.AbstractTestRoot; - -public class BootstrapModifyRoot extends AbstractTestRoot { - - @Override - protected void setup(WrappedRequest request) { - // TODO Auto-generated method stub - - } - - @Override - protected String getTestDescription() { - return "There should be two additional divs in the HTML of the bootstrap page for this UI"; - } - - @Override - protected Integer getTicketNumber() { - return Integer.valueOf(9274); - } - -} diff --git a/tests/testbench/com/vaadin/tests/vaadincontext/BootstrapModifyUI.html b/tests/testbench/com/vaadin/tests/vaadincontext/BootstrapModifyUI.html new file mode 100644 index 0000000000..e6fafb14fa --- /dev/null +++ b/tests/testbench/com/vaadin/tests/vaadincontext/BootstrapModifyUI.html @@ -0,0 +1,36 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + + + + + + + + + + + +
      New Test
      open/run/com.vaadin.tests.vaadincontext.BootstrapModifyUI?restartApplication
      assertTextvaadin=runcomvaadintestsvaadincontextBootstrapModifyUI::/VVerticalLayout[0]/VLabel[0]There should be two additional divs in the HTML of the bootstrap page for this UI
      assertText//div[1]Added by modifyBootstrapPage
      assertText//div[2]Added by modifyBootstrapFragment
      + + diff --git a/tests/testbench/com/vaadin/tests/vaadincontext/BootstrapModifyUI.java b/tests/testbench/com/vaadin/tests/vaadincontext/BootstrapModifyUI.java new file mode 100644 index 0000000000..c197bbde5d --- /dev/null +++ b/tests/testbench/com/vaadin/tests/vaadincontext/BootstrapModifyUI.java @@ -0,0 +1,40 @@ +/* + * 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.tests.vaadincontext; + +import com.vaadin.terminal.WrappedRequest; +import com.vaadin.tests.components.AbstractTestUI; + +public class BootstrapModifyUI extends AbstractTestUI { + + @Override + protected void setup(WrappedRequest request) { + // TODO Auto-generated method stub + + } + + @Override + protected String getTestDescription() { + return "There should be two additional divs in the HTML of the bootstrap page for this UI"; + } + + @Override + protected Integer getTicketNumber() { + return Integer.valueOf(9274); + } + +} diff --git a/tests/testbench/com/vaadin/tests/vaadincontext/TestAddonContextListener.java b/tests/testbench/com/vaadin/tests/vaadincontext/TestAddonContextListener.java index 4fa007b11d..9cd67e24b6 100644 --- a/tests/testbench/com/vaadin/tests/vaadincontext/TestAddonContextListener.java +++ b/tests/testbench/com/vaadin/tests/vaadincontext/TestAddonContextListener.java @@ -44,7 +44,7 @@ public class TestAddonContextListener implements AddonContextListener { private boolean shouldModify(BootstrapResponse response) { UI uI = response.getUI(); boolean shouldModify = uI != null - && uI.getClass() == BootstrapModifyRoot.class; + && uI.getClass() == BootstrapModifyUI.class; return shouldModify; } -- cgit v1.2.3 From e362dec1811c9872419c5ea627c9e157a7abf8a0 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Fri, 24 Aug 2012 14:21:56 +0300 Subject: Test for UI.getCurrent() in LoginHandler (#9372) --- .../loginform/LoginFormUIInLoginHandler.html | 57 ++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100755 tests/testbench/com/vaadin/tests/components/loginform/LoginFormUIInLoginHandler.html diff --git a/tests/testbench/com/vaadin/tests/components/loginform/LoginFormUIInLoginHandler.html b/tests/testbench/com/vaadin/tests/components/loginform/LoginFormUIInLoginHandler.html new file mode 100755 index 0000000000..9a80ce6013 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/loginform/LoginFormUIInLoginHandler.html @@ -0,0 +1,57 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      New Test
      open/run/com.vaadin.tests.components.loginform.LoginFormUIInLoginHandler?restartApplication
      waitForElementPresentusername
      enterCharacterusernameabc
      enterCharacterpassworddef
      click//form[@id='loginf']/div[5]/div/span/span
      pauseAndWait1000
      assertTextvaadin=runcomvaadintestscomponentsloginformLoginFormUIInLoginHandler::/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[0]UI.getCurrent().data: This UI
      assertTextvaadin=runcomvaadintestscomponentsloginformLoginFormUIInLoginHandler::/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[1]event.getSource().data: This UI
      + + -- cgit v1.2.3 From f2cb4a9d9b3d5e89e38446906e7b556946f0a82a Mon Sep 17 00:00:00 2001 From: Johannes Dahlström Date: Thu, 23 Aug 2012 18:58:00 +0300 Subject: Split Embedded into several components, migrate them to Vaadin 7 (#9087) --- .../embeddedbrowser/EmbeddedBrowserConnector.java | 38 ++++ .../ui/embeddedbrowser/VEmbeddedBrowser.java | 120 +++++++++++ .../gwt/client/ui/flash/FlashConnector.java | 44 ++++ .../terminal/gwt/client/ui/flash/VFlash.java | 228 +++++++++++++++++++++ .../gwt/client/ui/image/ImageConnector.java | 67 ++++++ .../terminal/gwt/client/ui/image/VImage.java | 10 + server/src/com/vaadin/ui/AbstractEmbedded.java | 84 ++++++++ server/src/com/vaadin/ui/EmbeddedBrowser.java | 19 ++ server/src/com/vaadin/ui/Flash.java | 136 ++++++++++++ server/src/com/vaadin/ui/Image.java | 94 +++++++++ .../vaadin/shared/ui/AbstractEmbeddedState.java | 27 +++ .../ui/embeddedbrowser/EmbeddedBrowserState.java | 7 + .../src/com/vaadin/shared/ui/flash/FlashState.java | 68 ++++++ .../com/vaadin/shared/ui/image/ImageServerRpc.java | 8 + .../src/com/vaadin/shared/ui/image/ImageState.java | 7 + 15 files changed, 957 insertions(+) create mode 100644 client/src/com/vaadin/terminal/gwt/client/ui/embeddedbrowser/EmbeddedBrowserConnector.java create mode 100644 client/src/com/vaadin/terminal/gwt/client/ui/embeddedbrowser/VEmbeddedBrowser.java create mode 100644 client/src/com/vaadin/terminal/gwt/client/ui/flash/FlashConnector.java create mode 100644 client/src/com/vaadin/terminal/gwt/client/ui/flash/VFlash.java create mode 100644 client/src/com/vaadin/terminal/gwt/client/ui/image/ImageConnector.java create mode 100644 client/src/com/vaadin/terminal/gwt/client/ui/image/VImage.java create mode 100644 server/src/com/vaadin/ui/AbstractEmbedded.java create mode 100644 server/src/com/vaadin/ui/EmbeddedBrowser.java create mode 100644 server/src/com/vaadin/ui/Flash.java create mode 100644 server/src/com/vaadin/ui/Image.java create mode 100644 shared/src/com/vaadin/shared/ui/AbstractEmbeddedState.java create mode 100644 shared/src/com/vaadin/shared/ui/embeddedbrowser/EmbeddedBrowserState.java create mode 100644 shared/src/com/vaadin/shared/ui/flash/FlashState.java create mode 100644 shared/src/com/vaadin/shared/ui/image/ImageServerRpc.java create mode 100644 shared/src/com/vaadin/shared/ui/image/ImageState.java diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/embeddedbrowser/EmbeddedBrowserConnector.java b/client/src/com/vaadin/terminal/gwt/client/ui/embeddedbrowser/EmbeddedBrowserConnector.java new file mode 100644 index 0000000000..61231c4fba --- /dev/null +++ b/client/src/com/vaadin/terminal/gwt/client/ui/embeddedbrowser/EmbeddedBrowserConnector.java @@ -0,0 +1,38 @@ +package com.vaadin.terminal.gwt.client.ui.embeddedbrowser; + +import com.vaadin.shared.ui.Connect; +import com.vaadin.shared.ui.embeddedbrowser.EmbeddedBrowserState; +import com.vaadin.terminal.gwt.client.communication.StateChangeEvent; +import com.vaadin.terminal.gwt.client.ui.AbstractComponentConnector; + +@Connect(com.vaadin.ui.EmbeddedBrowser.class) +public class EmbeddedBrowserConnector extends AbstractComponentConnector { + + @Override + protected void init() { + super.init(); + } + + @Override + public VEmbeddedBrowser getWidget() { + return (VEmbeddedBrowser) super.getWidget(); + } + + @Override + public EmbeddedBrowserState getState() { + return (EmbeddedBrowserState) super.getState(); + } + + @Override + public void onStateChanged(StateChangeEvent stateChangeEvent) { + + super.onStateChanged(stateChangeEvent); + + getWidget().setAlternateText(getState().getAlternateText()); + getWidget().setSource( + getState().getSource() != null ? getState().getSource() + .getURL() : null); + getWidget().setName(getConnectorId()); + } + +} diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/embeddedbrowser/VEmbeddedBrowser.java b/client/src/com/vaadin/terminal/gwt/client/ui/embeddedbrowser/VEmbeddedBrowser.java new file mode 100644 index 0000000000..fffbff049e --- /dev/null +++ b/client/src/com/vaadin/terminal/gwt/client/ui/embeddedbrowser/VEmbeddedBrowser.java @@ -0,0 +1,120 @@ +package com.vaadin.terminal.gwt.client.ui.embeddedbrowser; + +import com.google.gwt.dom.client.Document; +import com.google.gwt.dom.client.Element; +import com.google.gwt.dom.client.IFrameElement; +import com.google.gwt.user.client.ui.Widget; + +public class VEmbeddedBrowser extends Widget { + + protected IFrameElement iframe; + protected Element altElement; + protected String altText; + + public VEmbeddedBrowser() { + Element root = Document.get().createDivElement(); + setElement(root); + + setStylePrimaryName("v-embeddedbrowser"); + + createAltTextElement(); + } + + /** + * Always creates new iframe inside widget. Will replace previous iframe. + * + * @return + */ + protected IFrameElement createIFrameElement(String src) { + String name = null; + + // Remove alt text + if (altElement != null) { + getElement().removeChild(altElement); + altElement = null; + } + + // Remove old iframe + if (iframe != null) { + name = iframe.getAttribute("name"); + getElement().removeChild(iframe); + iframe = null; + } + + iframe = Document.get().createIFrameElement(); + iframe.setSrc(src); + iframe.setFrameBorder(0); + iframe.setAttribute("width", "100%"); + iframe.setAttribute("height", "100%"); + iframe.setAttribute("allowTransparency", "true"); + + getElement().appendChild(iframe); + + // Reset old attributes (except src) + if (name != null) { + iframe.setName(name); + } + + return iframe; + } + + protected void createAltTextElement() { + if (iframe != null) { + return; + } + + if (altElement == null) { + altElement = Document.get().createSpanElement(); + getElement().appendChild(altElement); + } + + if (altText != null) { + altElement.setInnerText(altText); + } else { + altElement.setInnerText(""); + } + } + + public void setAlternateText(String altText) { + if (this.altText != altText) { + this.altText = altText; + if (altElement != null) { + if (altText != null) { + altElement.setInnerText(altText); + } else { + altElement.setInnerText(""); + } + } + } + } + + /** + * Set the source (the "src" attribute) of iframe. Will replace old iframe + * with new. + * + * @param source + * Source of iframe. + */ + public void setSource(String source) { + + if (source == null) { + if (iframe != null) { + getElement().removeChild(iframe); + iframe = null; + } + createAltTextElement(); + setAlternateText(altText); + return; + } + + if (iframe == null || iframe.getSrc() != source) { + createIFrameElement(source); + } + } + + public void setName(String name) { + if (iframe != null) { + iframe.setName(name); + } + } +} diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/flash/FlashConnector.java b/client/src/com/vaadin/terminal/gwt/client/ui/flash/FlashConnector.java new file mode 100644 index 0000000000..a9e7a71013 --- /dev/null +++ b/client/src/com/vaadin/terminal/gwt/client/ui/flash/FlashConnector.java @@ -0,0 +1,44 @@ +package com.vaadin.terminal.gwt.client.ui.flash; + +import com.vaadin.shared.ui.Connect; +import com.vaadin.shared.ui.flash.FlashState; +import com.vaadin.terminal.gwt.client.communication.StateChangeEvent; +import com.vaadin.terminal.gwt.client.ui.AbstractComponentConnector; + +@Connect(com.vaadin.ui.Flash.class) +public class FlashConnector extends AbstractComponentConnector { + + @Override + protected void init() { + super.init(); + } + + @Override + public VFlash getWidget() { + return (VFlash) super.getWidget(); + } + + @Override + public FlashState getState() { + return (FlashState) super.getState(); + } + + @Override + public void onStateChanged(StateChangeEvent stateChangeEvent) { + + super.onStateChanged(stateChangeEvent); + + getWidget().setSource( + getState().getSource() != null ? getState().getSource() + .getURL() : null); + getWidget().setArchive(getState().getArchive()); + getWidget().setClassId(getState().getClassId()); + getWidget().setCodebase(getState().getCodebase()); + getWidget().setCodetype(getState().getCodetype()); + getWidget().setStandby(getState().getStandby()); + getWidget().setAlternateText(getState().getAlternateText()); + getWidget().setEmbedParams(getState().getEmbedParams()); + + getWidget().rebuildIfNeeded(); + } +} diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/flash/VFlash.java b/client/src/com/vaadin/terminal/gwt/client/ui/flash/VFlash.java new file mode 100644 index 0000000000..5d60dc66aa --- /dev/null +++ b/client/src/com/vaadin/terminal/gwt/client/ui/flash/VFlash.java @@ -0,0 +1,228 @@ +package com.vaadin.terminal.gwt.client.ui.flash; + +import java.util.HashMap; +import java.util.Map; + +import com.google.gwt.user.client.ui.HTML; +import com.vaadin.terminal.gwt.client.Util; + +public class VFlash extends HTML { + + protected String source; + protected String altText; + protected String classId; + protected String codebase; + protected String codetype; + protected String standby; + protected String archive; + protected Map embedParams = new HashMap(); + protected boolean needsRebuild = false; + protected String width; + protected String height; + + public VFlash() { + setStylePrimaryName("v-flash"); + } + + public void setSource(String source) { + if (this.source != source) { + this.source = source; + needsRebuild = true; + } + } + + public void setAlternateText(String altText) { + if (this.altText != altText) { + this.altText = altText; + needsRebuild = true; + } + } + + public void setClassId(String classId) { + if (this.classId != classId) { + this.classId = classId; + needsRebuild = true; + } + } + + public void setCodebase(String codebase) { + if (this.codebase != codebase) { + this.codebase = codebase; + needsRebuild = true; + } + } + + public void setCodetype(String codetype) { + if (this.codetype != codetype) { + this.codetype = codetype; + needsRebuild = true; + } + } + + public void setStandby(String standby) { + if (this.standby != standby) { + this.standby = standby; + needsRebuild = true; + } + } + + public void setArchive(String archive) { + if (this.archive != archive) { + this.archive = archive; + needsRebuild = true; + } + } + + /** + * Call this after changing values of widget. It will rebuild embedding + * structure if needed. + */ + public void rebuildIfNeeded() { + if (needsRebuild) { + needsRebuild = false; + this.setHTML(createFlashEmbed()); + } + } + + @Override + public void setWidth(String width) { + // super.setWidth(height); + + if (this.width != width) { + this.width = width; + needsRebuild = true; + } + } + + @Override + public void setHeight(String height) { + // super.setHeight(height); + + if (this.height != height) { + this.height = height; + needsRebuild = true; + } + } + + public void setEmbedParams(Map params) { + if (params == null) { + if (!embedParams.isEmpty()) { + embedParams.clear(); + needsRebuild = true; + } + return; + } + + if (!embedParams.equals(params)) { + embedParams = new HashMap(params); + needsRebuild = true; + } + } + + protected String createFlashEmbed() { + /* + * To ensure cross-browser compatibility we are using the twice-cooked + * method to embed flash i.e. we add a OBJECT tag for IE ActiveX and + * inside it a EMBED for all other browsers. + */ + + StringBuilder html = new StringBuilder(); + + // Start the object tag + html.append(""); + + // Ensure we have an movie parameter + if (embedParams.get("movie") == null) { + embedParams.put("movie", source); + } + + // Add parameters to OBJECT + for (String name : embedParams.keySet()) { + html.append(""); + } + + // Build inner EMBED tag + html.append(""); + + if (altText != null) { + html.append(""); + html.append(altText); + html.append(""); + } + + // End object tag + html.append(""); + + return html.toString(); + } + +} diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/image/ImageConnector.java b/client/src/com/vaadin/terminal/gwt/client/ui/image/ImageConnector.java new file mode 100644 index 0000000000..d36e224a03 --- /dev/null +++ b/client/src/com/vaadin/terminal/gwt/client/ui/image/ImageConnector.java @@ -0,0 +1,67 @@ +package com.vaadin.terminal.gwt.client.ui.image; + +import com.google.gwt.dom.client.NativeEvent; +import com.google.gwt.event.dom.client.LoadEvent; +import com.google.gwt.event.dom.client.LoadHandler; +import com.vaadin.shared.MouseEventDetails; +import com.vaadin.shared.ui.Connect; +import com.vaadin.shared.ui.image.ImageServerRpc; +import com.vaadin.shared.ui.image.ImageState; +import com.vaadin.terminal.gwt.client.communication.RpcProxy; +import com.vaadin.terminal.gwt.client.communication.StateChangeEvent; +import com.vaadin.terminal.gwt.client.ui.AbstractComponentConnector; +import com.vaadin.terminal.gwt.client.ui.ClickEventHandler; + +@Connect(com.vaadin.ui.Image.class) +public class ImageConnector extends AbstractComponentConnector { + + ImageServerRpc rpc; + + @Override + protected void init() { + super.init(); + rpc = RpcProxy.create(ImageServerRpc.class, this); + getWidget().addHandler(new LoadHandler() { + + @Override + public void onLoad(LoadEvent event) { + getLayoutManager().setNeedsMeasure(ImageConnector.this); + } + + }, LoadEvent.getType()); + } + + @Override + public VImage getWidget() { + return (VImage) super.getWidget(); + } + + @Override + public ImageState getState() { + return (ImageState) super.getState(); + } + + @Override + public void onStateChanged(StateChangeEvent stateChangeEvent) { + super.onStateChanged(stateChangeEvent); + + clickEventHandler.handleEventHandlerRegistration(); + + getWidget().setUrl( + getState().getSource() != null ? getState().getSource() + .getURL() : null); + getWidget().setAltText(getState().getAlternateText()); + } + + protected final ClickEventHandler clickEventHandler = new ClickEventHandler( + this) { + + @Override + protected void fireClick(NativeEvent event, + MouseEventDetails mouseDetails) { + rpc.click(mouseDetails); + } + + }; + +} diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/image/VImage.java b/client/src/com/vaadin/terminal/gwt/client/ui/image/VImage.java new file mode 100644 index 0000000000..7e6b77ed4a --- /dev/null +++ b/client/src/com/vaadin/terminal/gwt/client/ui/image/VImage.java @@ -0,0 +1,10 @@ +package com.vaadin.terminal.gwt.client.ui.image; + +import com.google.gwt.user.client.ui.Image; + +public class VImage extends Image { + + public VImage() { + setStylePrimaryName("v-image"); + } +} diff --git a/server/src/com/vaadin/ui/AbstractEmbedded.java b/server/src/com/vaadin/ui/AbstractEmbedded.java new file mode 100644 index 0000000000..9396af5c44 --- /dev/null +++ b/server/src/com/vaadin/ui/AbstractEmbedded.java @@ -0,0 +1,84 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ + +package com.vaadin.ui; + +import com.vaadin.shared.ui.AbstractEmbeddedState; +import com.vaadin.terminal.Resource; +import com.vaadin.terminal.gwt.server.ResourceReference; + +/** + * Abstract base for embedding components. + * + * @author Vaadin Ltd. + * @version + * @VERSION@ + * @since 7.0 + */ +@SuppressWarnings("serial") +public abstract class AbstractEmbedded extends AbstractComponent { + + @Override + public AbstractEmbeddedState getState() { + return (AbstractEmbeddedState) super.getState(); + } + + /** + * Sets the object source resource. The dimensions are assumed if possible. + * The type is guessed from resource. + * + * @param source + * the source to set. + */ + public void setSource(Resource source) { + if (source == null) { + getState().setSource(null); + } else { + getState().setSource(new ResourceReference(source)); + } + requestRepaint(); + } + + /** + * Get the object source resource. + * + * @return the source + */ + public Resource getSource() { + ResourceReference ref = ((ResourceReference) getState().getSource()); + if (ref == null) { + return null; + } else { + return ref.getResource(); + } + } + + /** + * Sets this component's alternate text that can be presented instead of the + * component's normal content for accessibility purposes. + * + * @param altText + * A short, human-readable description of this component's + * content. + */ + public void setAlternateText(String altText) { + if (altText != getState().getAlternateText() + || (altText != null && !altText.equals(getState() + .getAlternateText()))) { + getState().setAlternateText(altText); + requestRepaint(); + } + } + + /** + * Gets this component's alternate text that can be presented instead of the + * component's normal content for accessibility purposes. + * + * @returns Alternate text + */ + public String getAlternateText() { + return getState().getAlternateText(); + } + +} diff --git a/server/src/com/vaadin/ui/EmbeddedBrowser.java b/server/src/com/vaadin/ui/EmbeddedBrowser.java new file mode 100644 index 0000000000..4e2ae18de8 --- /dev/null +++ b/server/src/com/vaadin/ui/EmbeddedBrowser.java @@ -0,0 +1,19 @@ +package com.vaadin.ui; + +import com.vaadin.shared.ui.embeddedbrowser.EmbeddedBrowserState; + +/** + * Component for embedding browser "iframe". + * + * @author Vaadin Ltd. + * @version + * @VERSION@ + * @since 7.0 + */ +public class EmbeddedBrowser extends AbstractEmbedded { + + @Override + public EmbeddedBrowserState getState() { + return (EmbeddedBrowserState) super.getState(); + } +} diff --git a/server/src/com/vaadin/ui/Flash.java b/server/src/com/vaadin/ui/Flash.java new file mode 100644 index 0000000000..0e6cf63a91 --- /dev/null +++ b/server/src/com/vaadin/ui/Flash.java @@ -0,0 +1,136 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ + +package com.vaadin.ui; + +import java.util.HashMap; + +import com.vaadin.shared.ui.flash.FlashState; + +/** + * Component for embedding flash objects. + * + * @author Vaadin Ltd. + * @version + * @VERSION@ + * @since 7.0 + */ +@SuppressWarnings("serial") +public class Flash extends AbstractEmbedded { + + @Override + public FlashState getState() { + return (FlashState) super.getState(); + } + + /** + * This attribute specifies the base path used to resolve relative URIs + * specified by the classid, data, and archive attributes. When absent, its + * default value is the base URI of the current document. + * + * @param codebase + * The base path + */ + public void setCodebase(String codebase) { + if (codebase != getState().getCodebase() + || (codebase != null && !codebase.equals(getState() + .getCodebase()))) { + getState().setCodebase(codebase); + requestRepaint(); + } + } + + /** + * This attribute specifies the content type of data expected when + * downloading the object specified by classid. This attribute is optional + * but recommended when classid is specified since it allows the user agent + * to avoid loading information for unsupported content types. When absent, + * it defaults to the value of the type attribute. + * + * @param codetype + * the codetype to set. + */ + public void setCodetype(String codetype) { + if (codetype != getState().getCodetype() + || (codetype != null && !codetype.equals(getState() + .getCodetype()))) { + getState().setCodetype(codetype); + requestRepaint(); + } + } + + /** + * This attribute may be used to specify a space-separated list of URIs for + * archives containing resources relevant to the object, which may include + * the resources specified by the classid and data attributes. Preloading + * archives will generally result in reduced load times for objects. + * Archives specified as relative URIs should be interpreted relative to the + * codebase attribute. + * + * @param archive + * Space-separated list of URIs with resources relevant to the + * object + */ + public void setArchive(String archive) { + if (archive != getState().getArchive() + || (archive != null && !archive.equals(getState().getArchive()))) { + getState().setArchive(archive); + requestRepaint(); + } + } + + public void setStandby(String standby) { + if (standby != getState().getStandby() + || (standby != null && !standby.equals(getState().getStandby()))) { + getState().setStandby(standby); + requestRepaint(); + } + } + + /** + * Sets an object parameter. Parameters are optional information, and they + * are passed to the instantiated object. Parameters are are stored as name + * value pairs. This overrides the previous value assigned to this + * parameter. + * + * @param name + * the name of the parameter. + * @param value + * the value of the parameter. + */ + public void setParameter(String name, String value) { + if (getState().getEmbedParams() == null) { + getState().setEmbedParams(new HashMap()); + } + getState().getEmbedParams().put(name, value); + requestRepaint(); + } + + /** + * Gets the value of an object parameter. Parameters are optional + * information, and they are passed to the instantiated object. Parameters + * are are stored as name value pairs. + * + * @return the Value of parameter or null if not found. + */ + public String getParameter(String name) { + return getState().getEmbedParams() != null ? getState() + .getEmbedParams().get(name) : null; + } + + /** + * Removes an object parameter from the list. + * + * @param name + * the name of the parameter to remove. + */ + public void removeParameter(String name) { + if (getState().getEmbedParams() == null) { + return; + } + getState().getEmbedParams().remove(name); + requestRepaint(); + } + +} diff --git a/server/src/com/vaadin/ui/Image.java b/server/src/com/vaadin/ui/Image.java new file mode 100644 index 0000000000..b0dbc9e629 --- /dev/null +++ b/server/src/com/vaadin/ui/Image.java @@ -0,0 +1,94 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ + +package com.vaadin.ui; + +import com.vaadin.event.MouseEvents.ClickEvent; +import com.vaadin.event.MouseEvents.ClickListener; +import com.vaadin.shared.EventId; +import com.vaadin.shared.MouseEventDetails; +import com.vaadin.shared.ui.image.ImageServerRpc; +import com.vaadin.shared.ui.image.ImageState; +import com.vaadin.terminal.Resource; + +/** + * Component for embedding images. + * + * @author Vaadin Ltd. + * @version + * @VERSION@ + * @since 7.0 + */ +@SuppressWarnings("serial") +public class Image extends AbstractEmbedded { + + protected ImageServerRpc rpc = new ImageServerRpc() { + @Override + public void click(MouseEventDetails mouseDetails) { + fireEvent(new ClickEvent(Image.this, mouseDetails)); + } + }; + + /** + * Creates a new empty Image. + */ + public Image() { + registerRpc(rpc); + } + + /** + * Creates a new empty Image with caption. + * + * @param caption + */ + public Image(String caption) { + this(); + setCaption(caption); + } + + /** + * Creates a new Image whose contents is loaded from given resource. The + * dimensions are assumed if possible. The type is guessed from resource. + * + * @param caption + * @param source + * the Source of the embedded object. + */ + public Image(String caption, Resource source) { + this(caption); + setSource(source); + } + + @Override + public ImageState getState() { + return (ImageState) super.getState(); + } + + /** + * Add a click listener to the component. The listener is called whenever + * the user clicks inside the component. Depending on the content the event + * may be blocked and in that case no event is fired. + * + * Use {@link #removeListener(ClickListener)} to remove the listener. + * + * @param listener + * The listener to add + */ + public void addListener(ClickListener listener) { + addListener(EventId.CLICK_EVENT_IDENTIFIER, ClickEvent.class, listener, + ClickListener.clickMethod); + } + + /** + * Remove a click listener from the component. The listener should earlier + * have been added using {@link #addListener(ClickListener)}. + * + * @param listener + * The listener to remove + */ + public void removeListener(ClickListener listener) { + removeListener(EventId.CLICK_EVENT_IDENTIFIER, ClickEvent.class, + listener); + } +} diff --git a/shared/src/com/vaadin/shared/ui/AbstractEmbeddedState.java b/shared/src/com/vaadin/shared/ui/AbstractEmbeddedState.java new file mode 100644 index 0000000000..96b785edd0 --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/AbstractEmbeddedState.java @@ -0,0 +1,27 @@ +package com.vaadin.shared.ui; + +import com.vaadin.shared.ComponentState; +import com.vaadin.shared.communication.URLReference; + +public class AbstractEmbeddedState extends ComponentState { + + protected URLReference source; + protected String alternateText; + + public URLReference getSource() { + return source; + } + + public void setSource(URLReference source) { + this.source = source; + } + + public String getAlternateText() { + return alternateText; + } + + public void setAlternateText(String alternateText) { + this.alternateText = alternateText; + } + +} diff --git a/shared/src/com/vaadin/shared/ui/embeddedbrowser/EmbeddedBrowserState.java b/shared/src/com/vaadin/shared/ui/embeddedbrowser/EmbeddedBrowserState.java new file mode 100644 index 0000000000..cca47176a3 --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/embeddedbrowser/EmbeddedBrowserState.java @@ -0,0 +1,7 @@ +package com.vaadin.shared.ui.embeddedbrowser; + +import com.vaadin.shared.ui.AbstractEmbeddedState; + +public class EmbeddedBrowserState extends AbstractEmbeddedState { + +} diff --git a/shared/src/com/vaadin/shared/ui/flash/FlashState.java b/shared/src/com/vaadin/shared/ui/flash/FlashState.java new file mode 100644 index 0000000000..2d33d1a711 --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/flash/FlashState.java @@ -0,0 +1,68 @@ +package com.vaadin.shared.ui.flash; + +import java.util.Map; + +import com.vaadin.shared.ui.AbstractEmbeddedState; + +public class FlashState extends AbstractEmbeddedState { + + protected String classId; + + protected String codebase; + + protected String codetype; + + protected String archive; + + protected String standby; + + protected Map embedParams; + + public String getClassId() { + return classId; + } + + public void setClassId(String classId) { + this.classId = classId; + } + + public String getCodebase() { + return codebase; + } + + public void setCodebase(String codeBase) { + codebase = codebase; + } + + public String getCodetype() { + return codetype; + } + + public void setCodetype(String codetype) { + this.codetype = codetype; + } + + public String getArchive() { + return archive; + } + + public void setArchive(String archive) { + this.archive = archive; + } + + public String getStandby() { + return standby; + } + + public void setStandby(String standby) { + this.standby = standby; + } + + public Map getEmbedParams() { + return embedParams; + } + + public void setEmbedParams(Map embedParams) { + this.embedParams = embedParams; + } +} diff --git a/shared/src/com/vaadin/shared/ui/image/ImageServerRpc.java b/shared/src/com/vaadin/shared/ui/image/ImageServerRpc.java new file mode 100644 index 0000000000..aa48f10e5b --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/image/ImageServerRpc.java @@ -0,0 +1,8 @@ +package com.vaadin.shared.ui.image; + +import com.vaadin.shared.communication.ServerRpc; +import com.vaadin.shared.ui.ClickRpc; + +public interface ImageServerRpc extends ClickRpc, ServerRpc { + +} diff --git a/shared/src/com/vaadin/shared/ui/image/ImageState.java b/shared/src/com/vaadin/shared/ui/image/ImageState.java new file mode 100644 index 0000000000..4296c76847 --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/image/ImageState.java @@ -0,0 +1,7 @@ +package com.vaadin.shared.ui.image; + +import com.vaadin.shared.ui.AbstractEmbeddedState; + +public class ImageState extends AbstractEmbeddedState { + +} -- cgit v1.2.3 From d379f5cb09a8530b9f6f24c600c5cc5acc7f36ea Mon Sep 17 00:00:00 2001 From: Johannes Dahlström Date: Thu, 23 Aug 2012 19:00:33 +0300 Subject: Tests for new componets split from Embedded (#9087) --- .../embeddedbrowser/EmbeddedBrowserIsVisible.html | 67 +++++++++++ .../embeddedbrowser/EmbeddedBrowserIsVisible.java | 112 +++++++++++++++++ .../tests/components/flash/FlashIsVisible.html | 33 +++++ .../tests/components/flash/FlashIsVisible.java | 31 +++++ .../tests/components/flash/FlashPresentation.java | 33 +++++ .../tests/components/image/ImageAltText.html | 42 +++++++ .../tests/components/image/ImageAltText.java | 38 ++++++ .../vaadin/tests/components/image/ImageClicks.html | 57 +++++++++ .../vaadin/tests/components/image/ImageClicks.java | 133 +++++++++++++++++++++ 9 files changed, 546 insertions(+) create mode 100644 tests/testbench/com/vaadin/tests/components/embeddedbrowser/EmbeddedBrowserIsVisible.html create mode 100644 tests/testbench/com/vaadin/tests/components/embeddedbrowser/EmbeddedBrowserIsVisible.java create mode 100644 tests/testbench/com/vaadin/tests/components/flash/FlashIsVisible.html create mode 100644 tests/testbench/com/vaadin/tests/components/flash/FlashIsVisible.java create mode 100644 tests/testbench/com/vaadin/tests/components/flash/FlashPresentation.java create mode 100644 tests/testbench/com/vaadin/tests/components/image/ImageAltText.html create mode 100644 tests/testbench/com/vaadin/tests/components/image/ImageAltText.java create mode 100644 tests/testbench/com/vaadin/tests/components/image/ImageClicks.html create mode 100644 tests/testbench/com/vaadin/tests/components/image/ImageClicks.java diff --git a/tests/testbench/com/vaadin/tests/components/embeddedbrowser/EmbeddedBrowserIsVisible.html b/tests/testbench/com/vaadin/tests/components/embeddedbrowser/EmbeddedBrowserIsVisible.html new file mode 100644 index 0000000000..2d76cd48b2 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/embeddedbrowser/EmbeddedBrowserIsVisible.html @@ -0,0 +1,67 @@ + + + + + + +EmbeddedBrowserIsVisible + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      EmbeddedBrowserIsVisible
      open/run/com.vaadin.tests.components.embeddedbrowser.EmbeddedBrowserIsVisible?restartApplication
      screenCaptureshow_initial
      clickvaadin=runcomvaadintestscomponentsembeddedbrowserEmbeddedBrowserIsVisible::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[0]/VButton[0]/domChild[0]/domChild[0]
      screenCaptureshow_hello
      clickvaadin=runcomvaadintestscomponentsembeddedbrowserEmbeddedBrowserIsVisible::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[0]/VButton[1]/domChild[0]/domChild[0]
      screenCaptureshow_lorem
      clickvaadin=runcomvaadintestscomponentsembeddedbrowserEmbeddedBrowserIsVisible::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[0]/VButton[2]/domChild[0]/domChild[0]
      screenCaptureshow_alternative_text
      clickvaadin=runcomvaadintestscomponentsembeddedbrowserEmbeddedBrowserIsVisible::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[0]/VButton[1]/domChild[0]/domChild[0]
      screenCaptureshow_lorem2
      + + diff --git a/tests/testbench/com/vaadin/tests/components/embeddedbrowser/EmbeddedBrowserIsVisible.java b/tests/testbench/com/vaadin/tests/components/embeddedbrowser/EmbeddedBrowserIsVisible.java new file mode 100644 index 0000000000..fdf9405855 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/embeddedbrowser/EmbeddedBrowserIsVisible.java @@ -0,0 +1,112 @@ +package com.vaadin.tests.components.embeddedbrowser; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.io.UnsupportedEncodingException; + +import com.vaadin.terminal.StreamResource; +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.EmbeddedBrowser; +import com.vaadin.ui.HorizontalLayout; + +public class EmbeddedBrowserIsVisible extends TestBase { + + @Override + protected void setup() { + + HorizontalLayout buttonLayout = new HorizontalLayout(); + addComponent(buttonLayout); + + Button page1 = new Button("Hello World"); + buttonLayout.addComponent(page1); + + Button page2 = new Button("Lorem ipsum"); + buttonLayout.addComponent(page2); + + Button page3 = new Button("null"); + buttonLayout.addComponent(page3); + + final EmbeddedBrowser browser = new EmbeddedBrowser(); + browser.setDebugId("browser"); + browser.setWidth("600px"); + browser.setHeight("300px"); + browser.setAlternateText("Browser alternative text"); + final TextSource textSource = new TextSource("initial"); + final StreamResource textResource = new StreamResource(textSource, + "initial.txt", this); + textResource.setMIMEType("text/plain"); + browser.setSource(textResource); + addComponent(browser); + + page1.addListener(new Button.ClickListener() { + + public void buttonClick(ClickEvent event) { + TextSource helloSource = new TextSource("Hello World"); + StreamResource helloResource = new StreamResource(helloSource, + "helloworld.txt", EmbeddedBrowserIsVisible.this); + helloResource.setMIMEType("text/plain"); + browser.setSource(helloResource); + } + }); + + page2.addListener(new Button.ClickListener() { + + public void buttonClick(ClickEvent event) { + TextSource helloSource = new TextSource("Lorem Ipsum"); + StreamResource helloResource = new StreamResource(helloSource, + "loremipsum.txt", EmbeddedBrowserIsVisible.this); + helloResource.setMIMEType("text/plain"); + browser.setSource(helloResource); + } + }); + + page3.addListener(new Button.ClickListener() { + + public void buttonClick(ClickEvent event) { + browser.setSource(null); + } + }); + } + + @Override + protected String getDescription() { + return "Embedded browser should be visible for all browsers"; + } + + @Override + protected Integer getTicketNumber() { + return null; + } + + public class TextSource implements StreamResource.StreamSource { + private String text; + + public TextSource(String text) { + this.text = text; + } + + public InputStream getStream() { + + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < 200; ++i) { + sb.append(text); + sb.append("\n"); + } + + ByteArrayInputStream istream; + try { + istream = new ByteArrayInputStream(sb.toString().getBytes( + "UTF-8")); + } catch (UnsupportedEncodingException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + return null; + } + return istream; // new DownloadStream (istream,null,null); + + } + } + +} diff --git a/tests/testbench/com/vaadin/tests/components/flash/FlashIsVisible.html b/tests/testbench/com/vaadin/tests/components/flash/FlashIsVisible.html new file mode 100644 index 0000000000..82834cf405 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/flash/FlashIsVisible.html @@ -0,0 +1,33 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + + + + + + + + +
      New Test
      open/run/com.vaadin.tests.components.flash.FlashIsVisible
      pause5000
      screenCapture
      + + diff --git a/tests/testbench/com/vaadin/tests/components/flash/FlashIsVisible.java b/tests/testbench/com/vaadin/tests/components/flash/FlashIsVisible.java new file mode 100644 index 0000000000..66cb8819d4 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/flash/FlashIsVisible.java @@ -0,0 +1,31 @@ +package com.vaadin.tests.components.flash; + +import com.vaadin.terminal.ExternalResource; +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.Flash; + +public class FlashIsVisible extends TestBase { + + @Override + protected void setup() { + Flash player = new Flash(); + player.setWidth("400px"); + player.setHeight("300px"); + String url = "http://www.youtube.com/v/qQ9N742QB4g&autoplay=0"; + player.setSource(new ExternalResource(url)); + addComponent(player); + } + + @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/tests/testbench/com/vaadin/tests/components/flash/FlashPresentation.java b/tests/testbench/com/vaadin/tests/components/flash/FlashPresentation.java new file mode 100644 index 0000000000..843e61ace1 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/flash/FlashPresentation.java @@ -0,0 +1,33 @@ +package com.vaadin.tests.components.flash; + +import com.vaadin.terminal.ExternalResource; +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.Flash; + +public class FlashPresentation extends TestBase { + + @Override + protected String getDescription() { + return "The embedded flash should have the movie parameter set to \"someRandomValue\" and an allowFullScreen parameter set to \"true\"."; + } + + @Override + protected Integer getTicketNumber() { + return 3367; + } + + @Override + public void setup() { + Flash player = new Flash(); + player.setWidth("400px"); + player.setHeight("300px"); + String url = "http://www.youtube.com/v/qQ9N742QB4g&autoplay=1"; + player.setSource(new ExternalResource(url)); + player.setParameter("movie", "someRandomValue"); + player.setParameter("allowFullScreen", "true"); + player.setAlternateText("Flash alternative text"); + + addComponent(player); + } + +} diff --git a/tests/testbench/com/vaadin/tests/components/image/ImageAltText.html b/tests/testbench/com/vaadin/tests/components/image/ImageAltText.html new file mode 100644 index 0000000000..743aa5caaf --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/image/ImageAltText.html @@ -0,0 +1,42 @@ + + + + + + +ImageAltText + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      ImageAltText
      open/run/com.vaadin.tests.components.image.ImageAltText?restartApplication
      assertAttributevaadin=runcomvaadintestscomponentsimageImageAltText::/VVerticalLayout[0]/VVerticalLayout[0]/VImage[0]@altOriginal alt text
      clickvaadin=runcomvaadintestscomponentsimageImageAltText::/VVerticalLayout[0]/VVerticalLayout[0]/VButton[0]/domChild[0]
      assertAttributevaadin=runcomvaadintestscomponentsimageImageAltText::/VVerticalLayout[0]/VVerticalLayout[0]/VImage[0]@altNew alt text!
      screenCaptureimage_alt_text
      + + diff --git a/tests/testbench/com/vaadin/tests/components/image/ImageAltText.java b/tests/testbench/com/vaadin/tests/components/image/ImageAltText.java new file mode 100644 index 0000000000..1f787fd64f --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/image/ImageAltText.java @@ -0,0 +1,38 @@ +package com.vaadin.tests.components.image; + +import com.vaadin.terminal.ThemeResource; +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Image; + +public class ImageAltText extends TestBase { + + @Override + protected void setup() { + final Image image = new Image("Caption", new ThemeResource( + "../runo/icons/64/ok.png")); + image.setDebugId("image"); + image.setAlternateText("Original alt text"); + addComponent(image); + + Button changeAltTexts = new Button("Change alt text", + new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + image.setAlternateText("New alt text!"); + } + }); + addComponent(changeAltTexts); + } + + @Override + protected String getDescription() { + return "Test alternative text of image"; + } + + @Override + protected Integer getTicketNumber() { + return null; + } + +} diff --git a/tests/testbench/com/vaadin/tests/components/image/ImageClicks.html b/tests/testbench/com/vaadin/tests/components/image/ImageClicks.html new file mode 100644 index 0000000000..14afaab98d --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/image/ImageClicks.html @@ -0,0 +1,57 @@ + + + + + + +ImageClicks + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      ImageClicks
      open/run/com.vaadin.tests.components.image.ImageClicks?restartApplication
      screenCapture0_clicks
      mouseClickvaadin=runcomvaadintestscomponentsimageImageClicks::/VVerticalLayout[0]/VVerticalLayout[0]/VImage[0]129,107
      screenCapture1_click
      mouseClickvaadin=runcomvaadintestscomponentsimageImageClicks::/VVerticalLayout[0]/VVerticalLayout[0]/VImage[0]129,107
      screenCapture2_clicks
      mouseClickvaadin=runcomvaadintestscomponentsimageImageClicks::/VVerticalLayout[0]/VVerticalLayout[0]/VImage[0]273,273
      screenCapture3_clicks
      + + diff --git a/tests/testbench/com/vaadin/tests/components/image/ImageClicks.java b/tests/testbench/com/vaadin/tests/components/image/ImageClicks.java new file mode 100644 index 0000000000..394e38a106 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/image/ImageClicks.java @@ -0,0 +1,133 @@ +package com.vaadin.tests.components.image; + +import java.awt.Color; +import java.awt.Graphics; +import java.awt.image.BufferedImage; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; + +import javax.imageio.ImageIO; + +import com.vaadin.event.MouseEvents.ClickEvent; +import com.vaadin.event.MouseEvents.ClickListener; +import com.vaadin.terminal.StreamResource; +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.Image; +import com.vaadin.ui.Label; + +public class ImageClicks extends TestBase { + + private int clickCounter = 0; + + @Override + protected void setup() { + + final Label label = new Label(labelText()); + addComponent(label); + + Image image = new Image(); + final MyImageSource imageSource = new MyImageSource(); + final StreamResource imageResource = new StreamResource(imageSource, + "testimage.png", this); + image.setSource(imageResource); + image.addListener(new ClickListener() { + + public void click(ClickEvent event) { + ++clickCounter; + label.setValue(labelText()); + } + + }); + addComponent(image); + + } + + private String labelText() { + StringBuilder sb = new StringBuilder(); + sb.append("Image clicked "); + sb.append(clickCounter); + sb.append(" times."); + return sb.toString(); + } + + @Override + protected String getDescription() { + return "Test click event handling of images"; + } + + @Override + protected Integer getTicketNumber() { + return null; + } + + public class MyImageSource implements StreamResource.StreamSource { + public MyImageSource() { + } + + int intervalPos(int pos, int resolution, int cells) { + return (int) Math.round(pos * resolution / (cells * 1.0)); + } + + public InputStream getStream() { + // Create an image and draw some background on it. + BufferedImage image = new BufferedImage(300, 300, + BufferedImage.TYPE_INT_RGB); + Graphics drawable = image.getGraphics(); + + // Background + drawable.setColor(Color.white); + drawable.fillRect(0, 0, 300, 300); + + final int rows = 4; + final int cols = 4; + + // Grid + for (int row = 0; row < rows; row++) { + int gridy = intervalPos(row, 300, rows); + int gridynext = intervalPos(row + 1, 300, rows); + + // Horizontal grid line + if (row > 0) { + drawable.setColor(Color.lightGray); + drawable.drawLine(0, gridy, 300 - 1, gridy); + } + + for (int col = 0; col < cols; col++) { + int gridx = intervalPos(col, 300, cols); + int gridxnext = intervalPos(col + 1, 300, cols); + + // Vertical grid line + if (row == 0 && col > 0) { + drawable.setColor(Color.lightGray); + drawable.drawLine(gridx, 0, gridx, 300 - 1); + } + + // Cell + if (Math.random() < 0.5f) { + drawable.setColor(Color.white); + } else { + drawable.setColor(Color.black); + } + drawable.fillRect(gridx + 1, gridy + 1, gridxnext - gridx + - 1, gridynext - gridy - 1); + } + } + + try { + // Write the image to a buffer. + ByteArrayOutputStream imagebuffer = new ByteArrayOutputStream(); + ImageIO.write(image, "png", imagebuffer); + + // Return a stream from the buffer. + ByteArrayInputStream istream = new ByteArrayInputStream( + imagebuffer.toByteArray()); + return istream; // new DownloadStream (istream,null,null); + } catch (IOException e) { + return null; + } + } + + } +} -- cgit v1.2.3 From fc3f7f62b05ae69b242d64084f676d7733962c60 Mon Sep 17 00:00:00 2001 From: Johannes Dahlström Date: Fri, 24 Aug 2012 16:33:15 +0300 Subject: Migrate Slider to Vaadin 7 (#9304) --- .../gwt/client/ui/slider/SliderConnector.java | 89 ++++---- .../terminal/gwt/client/ui/slider/VSlider.java | 251 ++++++++++++++------- server/src/com/vaadin/ui/Slider.java | 172 ++++++-------- .../vaadin/shared/ui/slider/SliderOrientation.java | 5 + .../vaadin/shared/ui/slider/SliderServerRpc.java | 14 ++ .../com/vaadin/shared/ui/slider/SliderState.java | 60 +++++ .../vaadin/tests/components/slider/SliderTest.java | 11 +- .../vaadin/tests/integration/LiferayThemeDemo.java | 5 +- 8 files changed, 359 insertions(+), 248 deletions(-) create mode 100644 shared/src/com/vaadin/shared/ui/slider/SliderOrientation.java create mode 100644 shared/src/com/vaadin/shared/ui/slider/SliderServerRpc.java create mode 100644 shared/src/com/vaadin/shared/ui/slider/SliderState.java diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/slider/SliderConnector.java b/client/src/com/vaadin/terminal/gwt/client/ui/slider/SliderConnector.java index 7e0617b7dc..53f3b8874b 100644 --- a/client/src/com/vaadin/terminal/gwt/client/ui/slider/SliderConnector.java +++ b/client/src/com/vaadin/terminal/gwt/client/ui/slider/SliderConnector.java @@ -15,70 +15,61 @@ */ package com.vaadin.terminal.gwt.client.ui.slider; -import com.google.gwt.core.client.Scheduler; -import com.google.gwt.user.client.Command; +import com.google.gwt.event.logical.shared.ValueChangeEvent; +import com.google.gwt.event.logical.shared.ValueChangeHandler; import com.vaadin.shared.ui.Connect; -import com.vaadin.terminal.gwt.client.ApplicationConnection; -import com.vaadin.terminal.gwt.client.Paintable; -import com.vaadin.terminal.gwt.client.UIDL; +import com.vaadin.shared.ui.slider.SliderServerRpc; +import com.vaadin.shared.ui.slider.SliderState; +import com.vaadin.terminal.gwt.client.communication.RpcProxy; +import com.vaadin.terminal.gwt.client.communication.StateChangeEvent; import com.vaadin.terminal.gwt.client.ui.AbstractFieldConnector; import com.vaadin.ui.Slider; @Connect(Slider.class) public class SliderConnector extends AbstractFieldConnector implements - Paintable { + ValueChangeHandler { - @Override - public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { - - getWidget().client = client; - getWidget().id = uidl.getId(); - - if (!isRealUpdate(uidl)) { - return; - } + protected SliderServerRpc rpc = RpcProxy + .create(SliderServerRpc.class, this); - getWidget().immediate = getState().isImmediate(); - getWidget().disabled = !isEnabled(); - getWidget().readonly = isReadOnly(); + @Override + public void init() { + super.init(); + getWidget().setConnection(getConnection()); + getWidget().addValueChangeHandler(this); + } - getWidget().vertical = uidl.hasAttribute("vertical"); + @Override + public VSlider getWidget() { + return (VSlider) super.getWidget(); + } - // TODO should style names be used? + @Override + public SliderState getState() { + return (SliderState) super.getState(); + } - if (getWidget().vertical) { - getWidget().addStyleName(VSlider.CLASSNAME + "-vertical"); - } else { - getWidget().removeStyleName(VSlider.CLASSNAME + "-vertical"); - } + @Override + public void onValueChange(ValueChangeEvent event) { + rpc.valueChanged(event.getValue()); + } - getWidget().min = uidl.getDoubleAttribute("min"); - getWidget().max = uidl.getDoubleAttribute("max"); - getWidget().resolution = uidl.getIntAttribute("resolution"); - getWidget().value = new Double(uidl.getDoubleVariable("value")); + @Override + public void onStateChanged(StateChangeEvent stateChangeEvent) { + super.onStateChanged(stateChangeEvent); - getWidget().setFeedbackValue(getWidget().value); + getWidget().setId(getConnectorId()); + getWidget().setImmediate(getState().isImmediate()); + getWidget().setDisabled(!isEnabled()); + getWidget().setReadOnly(isReadOnly()); + getWidget().setOrientation(getState().getOrientation()); + getWidget().setMinValue(getState().getMinValue()); + getWidget().setMaxValue(getState().getMaxValue()); + getWidget().setResolution(getState().getResolution()); + getWidget().setValue(getState().getValue(), false); + getWidget().setFeedbackValue(getState().getValue()); getWidget().buildBase(); - - if (!getWidget().vertical) { - // Draw handle with a delay to allow base to gain maximum width - Scheduler.get().scheduleDeferred(new Command() { - @Override - public void execute() { - getWidget().buildHandle(); - getWidget().setValue(getWidget().value, false); - } - }); - } else { - getWidget().buildHandle(); - getWidget().setValue(getWidget().value, false); - } - } - - @Override - public VSlider getWidget() { - return (VSlider) super.getWidget(); } } diff --git a/client/src/com/vaadin/terminal/gwt/client/ui/slider/VSlider.java b/client/src/com/vaadin/terminal/gwt/client/ui/slider/VSlider.java index 9667522eb3..d9801626b4 100644 --- a/client/src/com/vaadin/terminal/gwt/client/ui/slider/VSlider.java +++ b/client/src/com/vaadin/terminal/gwt/client/ui/slider/VSlider.java @@ -19,12 +19,17 @@ package com.vaadin.terminal.gwt.client.ui.slider; import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.event.dom.client.KeyCodes; +import com.google.gwt.event.logical.shared.ValueChangeEvent; +import com.google.gwt.event.logical.shared.ValueChangeHandler; +import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.user.client.Command; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.Event; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.ui.HTML; +import com.google.gwt.user.client.ui.HasValue; +import com.vaadin.shared.ui.slider.SliderOrientation; import com.vaadin.terminal.gwt.client.ApplicationConnection; import com.vaadin.terminal.gwt.client.BrowserInfo; import com.vaadin.terminal.gwt.client.ContainerResizedListener; @@ -36,7 +41,7 @@ import com.vaadin.terminal.gwt.client.ui.VLazyExecutor; import com.vaadin.terminal.gwt.client.ui.VOverlay; public class VSlider extends SimpleFocusablePanel implements Field, - ContainerResizedListener { + ContainerResizedListener, HasValue { public static final String CLASSNAME = "v-slider"; @@ -46,20 +51,22 @@ public class VSlider extends SimpleFocusablePanel implements Field, */ private static final int MIN_SIZE = 50; - ApplicationConnection client; + protected ApplicationConnection client; - String id; + protected String id; - boolean immediate; - boolean disabled; - boolean readonly; + protected boolean immediate; + protected boolean disabled; + protected boolean readonly; private int acceleration = 1; - double min; - double max; - int resolution; - Double value; - boolean vertical; + protected double min; + protected double max; + protected int resolution; + protected Double value; + protected SliderOrientation orientation = SliderOrientation.HORIZONTAL; + + private boolean valueChangeHandlerInitialized = false; private final HTML feedback = new HTML("", false); private final VOverlay feedbackPopup = new VOverlay(true, false, true) { @@ -92,7 +99,7 @@ public class VSlider extends SimpleFocusablePanel implements Field, @Override public void execute() { - updateValueToServer(); + fireValueChanged(); acceleration = 1; } }); @@ -137,7 +144,7 @@ public class VSlider extends SimpleFocusablePanel implements Field, } private void updateFeedbackPosition() { - if (vertical) { + if (isVertical()) { feedbackPopup.setPopupPosition( DOM.getAbsoluteLeft(handle) + handle.getOffsetWidth(), DOM.getAbsoluteTop(handle) + handle.getOffsetHeight() / 2 @@ -152,16 +159,17 @@ public class VSlider extends SimpleFocusablePanel implements Field, } void buildBase() { - final String styleAttribute = vertical ? "height" : "width"; - final String oppositeStyleAttribute = vertical ? "width" : "height"; - final String domProperty = vertical ? "offsetHeight" : "offsetWidth"; + final String styleAttribute = isVertical() ? "height" : "width"; + final String oppositeStyleAttribute = isVertical() ? "width" : "height"; + final String domProperty = isVertical() ? "offsetHeight" + : "offsetWidth"; // clear unnecessary opposite style attribute DOM.setStyleAttribute(base, oppositeStyleAttribute, ""); final Element p = DOM.getParent(getElement()); if (DOM.getElementPropertyInt(p, domProperty) > 50) { - if (vertical) { + if (isVertical()) { setHeight(); } else { DOM.setStyleAttribute(base, styleAttribute, ""); @@ -176,7 +184,7 @@ public class VSlider extends SimpleFocusablePanel implements Field, public void execute() { final Element p = DOM.getParent(getElement()); if (DOM.getElementPropertyInt(p, domProperty) > (MIN_SIZE + 5)) { - if (vertical) { + if (isVertical()) { setHeight(); } else { DOM.setStyleAttribute(base, styleAttribute, ""); @@ -188,12 +196,27 @@ public class VSlider extends SimpleFocusablePanel implements Field, }); } + if (!isVertical()) { + // Draw handle with a delay to allow base to gain maximum width + Scheduler.get().scheduleDeferred(new Command() { + @Override + public void execute() { + buildHandle(); + setValue(value, false); + } + }); + } else { + buildHandle(); + setValue(value, false); + } + // TODO attach listeners for focusing and arrow keys } void buildHandle() { - final String handleAttribute = vertical ? "marginTop" : "marginLeft"; - final String oppositeHandleAttribute = vertical ? "marginLeft" + final String handleAttribute = isVertical() ? "marginTop" + : "marginLeft"; + final String oppositeHandleAttribute = isVertical() ? "marginLeft" : "marginTop"; DOM.setStyleAttribute(handle, handleAttribute, "0"); @@ -206,59 +229,6 @@ public class VSlider extends SimpleFocusablePanel implements Field, } - void setValue(Double value, boolean updateToServer) { - if (value == null) { - return; - } - - if (value < min) { - value = min; - } else if (value > max) { - value = max; - } - - // Update handle position - final String styleAttribute = vertical ? "marginTop" : "marginLeft"; - final String domProperty = vertical ? "offsetHeight" : "offsetWidth"; - final int handleSize = Integer.parseInt(DOM.getElementProperty(handle, - domProperty)); - final int baseSize = Integer.parseInt(DOM.getElementProperty(base, - domProperty)) - (2 * BASE_BORDER_WIDTH); - - final int range = baseSize - handleSize; - double v = value.doubleValue(); - - // Round value to resolution - if (resolution > 0) { - v = Math.round(v * Math.pow(10, resolution)); - v = v / Math.pow(10, resolution); - } else { - v = Math.round(v); - } - final double valueRange = max - min; - double p = 0; - if (valueRange > 0) { - p = range * ((v - min) / valueRange); - } - if (p < 0) { - p = 0; - } - if (vertical) { - p = range - p; - } - final double pos = p; - - DOM.setStyleAttribute(handle, styleAttribute, (Math.round(pos)) + "px"); - - // Update value - this.value = new Double(v); - setFeedbackValue(v); - - if (updateToServer) { - updateValueToServer(); - } - } - @Override public void onBrowserEvent(Event event) { if (disabled || readonly) { @@ -386,7 +356,7 @@ public class VSlider extends SimpleFocusablePanel implements Field, final int coord = getEventPosition(event); final int handleSize, baseSize, baseOffset; - if (vertical) { + if (isVertical()) { handleSize = handle.getOffsetHeight(); baseSize = base.getOffsetHeight(); baseOffset = base.getAbsoluteTop() - Window.getScrollTop() @@ -398,7 +368,7 @@ public class VSlider extends SimpleFocusablePanel implements Field, + handleSize / 2; } - if (vertical) { + if (isVertical()) { v = ((baseSize - (coord - baseOffset)) / (double) (baseSize - handleSize)) * (max - min) + min; } else { @@ -423,7 +393,7 @@ public class VSlider extends SimpleFocusablePanel implements Field, * @return */ protected int getEventPosition(Event event) { - if (vertical) { + if (isVertical()) { return Util.getTouchOrMouseClientY(event); } else { return Util.getTouchOrMouseClientX(event); @@ -432,7 +402,7 @@ public class VSlider extends SimpleFocusablePanel implements Field, @Override public void iLayout() { - if (vertical) { + if (isVertical()) { setHeight(); } // Update handle position @@ -451,8 +421,8 @@ public class VSlider extends SimpleFocusablePanel implements Field, DOM.setStyleAttribute(base, "overflow", ""); } - private void updateValueToServer() { - client.updateVariable(id, "value", value.doubleValue(), immediate); + private void fireValueChanged() { + ValueChangeEvent.fire(VSlider.this, value); } /** @@ -469,8 +439,8 @@ public class VSlider extends SimpleFocusablePanel implements Field, return false; } - if ((keycode == getNavigationUpKey() && vertical) - || (keycode == getNavigationRightKey() && !vertical)) { + if ((keycode == getNavigationUpKey() && isVertical()) + || (keycode == getNavigationRightKey() && !isVertical())) { if (shift) { for (int a = 0; a < acceleration; a++) { increaseValue(false); @@ -480,8 +450,8 @@ public class VSlider extends SimpleFocusablePanel implements Field, increaseValue(false); } return true; - } else if (keycode == getNavigationDownKey() && vertical - || (keycode == getNavigationLeftKey() && !vertical)) { + } else if (keycode == getNavigationDownKey() && isVertical() + || (keycode == getNavigationLeftKey() && !isVertical())) { if (shift) { for (int a = 0; a < acceleration; a++) { decreaseValue(false); @@ -539,4 +509,119 @@ public class VSlider extends SimpleFocusablePanel implements Field, protected int getNavigationRightKey() { return KeyCodes.KEY_RIGHT; } + + public void setConnection(ApplicationConnection client) { + this.client = client; + } + + public void setId(String id) { + this.id = id; + } + + public void setImmediate(boolean immediate) { + this.immediate = immediate; + } + + public void setDisabled(boolean disabled) { + this.disabled = disabled; + } + + public void setReadOnly(boolean readonly) { + this.readonly = readonly; + } + + private boolean isVertical() { + return orientation == SliderOrientation.VERTICAL; + } + + public void setOrientation(SliderOrientation orientation) { + if (this.orientation != orientation) { + this.orientation = orientation; + + if (isVertical()) { + addStyleName(VSlider.CLASSNAME + "-vertical"); + } else { + removeStyleName(VSlider.CLASSNAME + "-vertical"); + } + } + } + + public void setMinValue(double value) { + min = value; + } + + public void setMaxValue(double value) { + max = value; + } + + public void setResolution(int resolution) { + this.resolution = resolution; + } + + public HandlerRegistration addValueChangeHandler( + ValueChangeHandler handler) { + return addHandler(handler, ValueChangeEvent.getType()); + } + + public Double getValue() { + return value; + } + + public void setValue(Double value) { + if (value < min) { + value = min; + } else if (value > max) { + value = max; + } + + // Update handle position + final String styleAttribute = isVertical() ? "marginTop" : "marginLeft"; + final String domProperty = isVertical() ? "offsetHeight" + : "offsetWidth"; + final int handleSize = Integer.parseInt(DOM.getElementProperty(handle, + domProperty)); + final int baseSize = Integer.parseInt(DOM.getElementProperty(base, + domProperty)) - (2 * BASE_BORDER_WIDTH); + + final int range = baseSize - handleSize; + double v = value.doubleValue(); + + // Round value to resolution + if (resolution > 0) { + v = Math.round(v * Math.pow(10, resolution)); + v = v / Math.pow(10, resolution); + } else { + v = Math.round(v); + } + final double valueRange = max - min; + double p = 0; + if (valueRange > 0) { + p = range * ((v - min) / valueRange); + } + if (p < 0) { + p = 0; + } + if (isVertical()) { + p = range - p; + } + final double pos = p; + + DOM.setStyleAttribute(handle, styleAttribute, (Math.round(pos)) + "px"); + + // Update value + this.value = new Double(v); + setFeedbackValue(v); + } + + public void setValue(Double value, boolean fireEvents) { + if (value == null) { + return; + } + + setValue(value); + + if (fireEvents) { + fireValueChanged(); + } + } } diff --git a/server/src/com/vaadin/ui/Slider.java b/server/src/com/vaadin/ui/Slider.java index d4e2db4853..a0b1d01b01 100644 --- a/server/src/com/vaadin/ui/Slider.java +++ b/server/src/com/vaadin/ui/Slider.java @@ -16,11 +16,9 @@ package com.vaadin.ui; -import java.util.Map; - -import com.vaadin.terminal.PaintException; -import com.vaadin.terminal.PaintTarget; -import com.vaadin.terminal.Vaadin6Component; +import com.vaadin.shared.ui.slider.SliderOrientation; +import com.vaadin.shared.ui.slider.SliderServerRpc; +import com.vaadin.shared.ui.slider.SliderState; /** * A component for selecting a numerical value within a range. @@ -41,9 +39,9 @@ import com.vaadin.terminal.Vaadin6Component; * vl.addComponent(volumeIndicator); * volumeIndicator.setValue("Current volume:" + 50.0); * slider.addListener(this); - * + * * } - * + * * public void setVolume(double d) { * volumeIndicator.setValue("Current volume: " + d); * } @@ -58,28 +56,29 @@ import com.vaadin.terminal.Vaadin6Component; * * @author Vaadin Ltd. */ -public class Slider extends AbstractField implements Vaadin6Component { - - public static final int ORIENTATION_HORIZONTAL = 0; - - public static final int ORIENTATION_VERTICAL = 1; +public class Slider extends AbstractField { - /** Minimum value of slider */ - private double min = 0; + private SliderServerRpc rpc = new SliderServerRpc() { - /** Maximum value of slider */ - private double max = 100; + @Override + public void valueChanged(double value) { - /** - * Resolution, how many digits are considered relevant after the decimal - * point. Must be a non-negative value - */ - private int resolution = 0; + try { + setValue(value, true); + } catch (final ValueOutOfBoundsException e) { + // Convert to nearest bound + double out = e.getValue().doubleValue(); + if (out < getState().getMinValue()) { + out = getState().getMinValue(); + } + if (out > getState().getMaxValue()) { + out = getState().getMaxValue(); + } + Slider.super.setValue(new Double(out), false); + } + } - /** - * Slider orientation (horizontal/vertical), defaults . - */ - private int orientation = ORIENTATION_HORIZONTAL; + }; /** * Default slider constructor. Sets all values to defaults and the slide @@ -88,7 +87,8 @@ public class Slider extends AbstractField implements Vaadin6Component { */ public Slider() { super(); - super.setValue(new Double(min)); + registerRpc(rpc); + super.setValue(new Double(getState().getMinValue())); } /** @@ -153,13 +153,18 @@ public class Slider extends AbstractField implements Vaadin6Component { setCaption(caption); } + @Override + public SliderState getState() { + return (SliderState) super.getState(); + } + /** * Gets the maximum slider value * * @return the largest value the slider can have */ public double getMax() { - return max; + return getState().getMaxValue(); } /** @@ -170,11 +175,10 @@ public class Slider extends AbstractField implements Vaadin6Component { * The new maximum slider value */ public void setMax(double max) { - this.max = max; + getState().setMaxValue(max); if (getValue() > max) { setValue(max); } - markAsDirty(); } /** @@ -183,7 +187,7 @@ public class Slider extends AbstractField implements Vaadin6Component { * @return the smallest value the slider can have */ public double getMin() { - return min; + return getState().getMinValue(); } /** @@ -194,33 +198,32 @@ public class Slider extends AbstractField implements Vaadin6Component { * The new minimum slider value */ public void setMin(double min) { - this.min = min; + getState().setMinValue(min); if (getValue() < min) { setValue(min); } - markAsDirty(); } /** * Get the current orientation of the slider (horizontal or vertical). * - * @return {@link #ORIENTATION_HORIZONTAL} or - * {@link #ORIENTATION_HORIZONTAL} + * @return {@link SliderOrientation#HORIZONTAL} or + * {@link SliderOrientation#VERTICAL} */ - public int getOrientation() { - return orientation; + public SliderOrientation getOrientation() { + return getState().getOrientation(); } /** * Set the orientation of the slider. * - * @param The - * new orientation, either {@link #ORIENTATION_HORIZONTAL} or - * {@link #ORIENTATION_VERTICAL} + * @param orientation + * The new orientation, either + * {@link SliderOrientation#HORIZONTAL} or + * {@link SliderOrientation#VERTICAL} */ - public void setOrientation(int orientation) { - this.orientation = orientation; - markAsDirty(); + public void setOrientation(SliderOrientation orientation) { + getState().setOrientation(orientation); } /** @@ -230,21 +233,24 @@ public class Slider extends AbstractField implements Vaadin6Component { * @return resolution */ public int getResolution() { - return resolution; + return getState().getResolution(); } /** * Set a new resolution for the slider. The resolution is the number of * digits after the decimal point. * + * @throws IllegalArgumentException + * if resolution is negative. + * * @param resolution */ public void setResolution(int resolution) { if (resolution < 0) { - return; + throw new IllegalArgumentException( + "Cannot set a negative resolution to Slider"); } - this.resolution = resolution; - markAsDirty(); + getState().setResolution(resolution); } /** @@ -261,87 +267,36 @@ public class Slider extends AbstractField implements Vaadin6Component { @Override protected void setValue(Double value, boolean repaintIsNotNeeded) { final double v = value.doubleValue(); + final int resolution = getResolution(); double newValue; + if (resolution > 0) { // Round up to resolution newValue = (int) (v * Math.pow(10, resolution)); newValue = newValue / Math.pow(10, resolution); - if (min > newValue || max < newValue) { + if (getMin() > newValue || getMax() < newValue) { throw new ValueOutOfBoundsException(value); } } else { newValue = (int) v; - if (min > newValue || max < newValue) { + if (getMin() > newValue || getMax() < newValue) { throw new ValueOutOfBoundsException(value); } } + + getState().setValue(newValue); super.setValue(newValue, repaintIsNotNeeded); } @Override - public void setValue(Object newFieldValue) - throws com.vaadin.data.Property.ReadOnlyException { - if (newFieldValue != null && newFieldValue instanceof Number - && !(newFieldValue instanceof Double)) { + public void setValue(Object newFieldValue) { + if (newFieldValue instanceof Number) { // Support setting all types of Numbers newFieldValue = ((Number) newFieldValue).doubleValue(); } - - super.setValue(newFieldValue); - } - - @Override - public void paintContent(PaintTarget target) throws PaintException { - - target.addAttribute("min", min); - if (max > min) { - target.addAttribute("max", max); - } else { - target.addAttribute("max", min); - } - target.addAttribute("resolution", resolution); - - if (resolution > 0) { - target.addVariable(this, "value", getValue().doubleValue()); - } else { - target.addVariable(this, "value", getValue().intValue()); - } - - if (orientation == ORIENTATION_VERTICAL) { - target.addAttribute("vertical", true); - } - - } - - /** - * Invoked when the value of a variable has changed. Slider listeners are - * notified if the slider value has changed. - * - * @param source - * @param variables - */ - @Override - public void changeVariables(Object source, Map variables) { - if (variables.containsKey("value")) { - final Object value = variables.get("value"); - final Double newValue = new Double(value.toString()); - if (newValue != null && newValue != getValue() - && !newValue.equals(getValue())) { - try { - setValue(newValue, true); - } catch (final ValueOutOfBoundsException e) { - // Convert to nearest bound - double out = e.getValue().doubleValue(); - if (out < min) { - out = min; - } - if (out > max) { - out = max; - } - super.setValue(new Double(out), false); - } - } - } + setValue(newFieldValue); + // The cast is safe if the above call returned without throwing + getState().setValue((Double) newFieldValue); } /** @@ -373,7 +328,6 @@ public class Slider extends AbstractField implements Vaadin6Component { public Double getValue() { return value; } - } @Override diff --git a/shared/src/com/vaadin/shared/ui/slider/SliderOrientation.java b/shared/src/com/vaadin/shared/ui/slider/SliderOrientation.java new file mode 100644 index 0000000000..d130550946 --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/slider/SliderOrientation.java @@ -0,0 +1,5 @@ +package com.vaadin.shared.ui.slider; + +public enum SliderOrientation { + HORIZONTAL, VERTICAL; +} diff --git a/shared/src/com/vaadin/shared/ui/slider/SliderServerRpc.java b/shared/src/com/vaadin/shared/ui/slider/SliderServerRpc.java new file mode 100644 index 0000000000..6ea02f0a95 --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/slider/SliderServerRpc.java @@ -0,0 +1,14 @@ +package com.vaadin.shared.ui.slider; + +import com.vaadin.shared.communication.ServerRpc; + +public interface SliderServerRpc extends ServerRpc { + + /** + * Invoked when the value of a variable has changed. Slider listeners are + * notified if the slider value has changed. + * + * @param value + */ + public void valueChanged(double value); +} diff --git a/shared/src/com/vaadin/shared/ui/slider/SliderState.java b/shared/src/com/vaadin/shared/ui/slider/SliderState.java new file mode 100644 index 0000000000..98168b80af --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/slider/SliderState.java @@ -0,0 +1,60 @@ +package com.vaadin.shared.ui.slider; + +import com.vaadin.shared.AbstractFieldState; + +public class SliderState extends AbstractFieldState { + + protected double value; + + protected double maxValue; + protected double minValue; + + /** + * The number of fractional digits that are considered significant. Must be + * non-negative. + */ + protected int resolution; + + protected SliderOrientation orientation; + + public double getValue() { + return value; + } + + public void setValue(double value) { + this.value = value; + } + + public double getMaxValue() { + return maxValue; + } + + public void setMaxValue(double maxValue) { + this.maxValue = maxValue; + } + + public double getMinValue() { + return minValue; + } + + public void setMinValue(double minValue) { + this.minValue = minValue; + } + + public int getResolution() { + return resolution; + } + + public void setResolution(int resolution) { + this.resolution = resolution; + } + + public SliderOrientation getOrientation() { + return orientation; + } + + public void setOrientation(SliderOrientation orientation) { + this.orientation = orientation; + } + +} diff --git a/tests/testbench/com/vaadin/tests/components/slider/SliderTest.java b/tests/testbench/com/vaadin/tests/components/slider/SliderTest.java index 9be1fea987..0b9c2d6c5a 100644 --- a/tests/testbench/com/vaadin/tests/components/slider/SliderTest.java +++ b/tests/testbench/com/vaadin/tests/components/slider/SliderTest.java @@ -2,6 +2,7 @@ package com.vaadin.tests.components.slider; import java.util.LinkedHashMap; +import com.vaadin.shared.ui.slider.SliderOrientation; import com.vaadin.tests.components.abstractfield.AbstractFieldTest; import com.vaadin.ui.Slider; @@ -21,9 +22,9 @@ public class SliderTest extends AbstractFieldTest { } }; - private Command orientationCommand = new Command() { + private Command orientationCommand = new Command() { @Override - public void execute(Slider c, Integer value, Object data) { + public void execute(Slider c, SliderOrientation value, Object data) { c.setOrientation(value); } }; @@ -56,9 +57,9 @@ public class SliderTest extends AbstractFieldTest { } private void createOrientationSelect(String category) { - LinkedHashMap options = new LinkedHashMap(); - options.put("Horizontal", Slider.ORIENTATION_HORIZONTAL); - options.put("Vertical", Slider.ORIENTATION_VERTICAL); + LinkedHashMap options = new LinkedHashMap(); + options.put("Horizontal", SliderOrientation.HORIZONTAL); + options.put("Vertical", SliderOrientation.VERTICAL); createSelectAction("Orientation", category, options, "Horizontal", orientationCommand); diff --git a/tests/testbench/com/vaadin/tests/integration/LiferayThemeDemo.java b/tests/testbench/com/vaadin/tests/integration/LiferayThemeDemo.java index 41a3d18f9f..a233191070 100644 --- a/tests/testbench/com/vaadin/tests/integration/LiferayThemeDemo.java +++ b/tests/testbench/com/vaadin/tests/integration/LiferayThemeDemo.java @@ -10,6 +10,7 @@ import com.vaadin.data.Property.ValueChangeEvent; import com.vaadin.event.Action; import com.vaadin.shared.ui.MarginInfo; import com.vaadin.shared.ui.label.ContentMode; +import com.vaadin.shared.ui.slider.SliderOrientation; import com.vaadin.terminal.ExternalResource; import com.vaadin.terminal.Page; import com.vaadin.terminal.Resource; @@ -39,7 +40,6 @@ import com.vaadin.ui.NativeSelect; import com.vaadin.ui.Notification; import com.vaadin.ui.Panel; import com.vaadin.ui.PopupView; -import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.Slider; import com.vaadin.ui.Slider.ValueOutOfBoundsException; import com.vaadin.ui.TabSheet; @@ -50,6 +50,7 @@ import com.vaadin.ui.TextArea; import com.vaadin.ui.TextField; import com.vaadin.ui.Tree; import com.vaadin.ui.TwinColSelect; +import com.vaadin.ui.UI.LegacyWindow; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.VerticalSplitPanel; import com.vaadin.ui.Window; @@ -534,7 +535,7 @@ public class LiferayThemeDemo extends Application.LegacyApplication { l.addComponent(new Label("Vertical Slider", ContentMode.XHTML)); s = new Slider(); - s.setOrientation(Slider.ORIENTATION_VERTICAL); + s.setOrientation(SliderOrientation.VERTICAL); s.setHeight("200px"); try { s.setValue(50); -- cgit v1.2.3