From ff0761f787f94a157d12af2a37e10e808d43fc59 Mon Sep 17 00:00:00 2001
From: Artur Signell
- * 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.
*
- * 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.
*
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* TODO Investigate whether this might be derived from the different states - * in getRootForRrequest. + * in getUIForRrequest. *
*/ - private Set* 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 extends UI> rootClass = provider.getRootClass(this, - request); + Class extends UI> 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
* 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.
*
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
- * true
if the same UI instance should be reused
- * e.g. when the browser window is refreshed.
+ * @param uiPreserved
+ * true
if 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 true
if 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