* Entry point classes (widgetsets) define <code>onModuleLoad()</code>.
*/
public class ApplicationConnection {
+ // This indicates the whole page is generated by us (not embedded)
+ public static final String GENERATED_BODY_CLASSNAME = "v-generated-body";
+
private static final String MODIFIED_CLASSNAME = "v-modified";
private static final String REQUIRED_CLASSNAME_EXT = "-required";
public static final String UIDL_SECURITY_TOKEN_ID = "Vaadin-Security-Key";
- // This indicates the whole page is generated by us (not embedded)
- public static final String GENERATED_BODY_CLASSNAME = "v-generated-body";
-
/**
* @deprecated use UIDL_SECURITY_TOKEN_ID instead
*/
public static final String ATTRIBUTE_DESCRIPTION = "description";
public static final String ATTRIBUTE_ERROR = "error";
+ // will hold the UIDL security key (for XSS protection) once received
private String uidl_security_key = "init";
private final HashMap<String, String> resourcesMap = new HashMap<String, String>();
}
}-*/;
+ /**
+ * Get the active Console for writing debug messages. May return an actual
+ * logging console, or the NullConsole if debugging is not turned on.
+ *
+ * @return the active Console
+ */
public static Console getConsole() {
return console;
}
return configuration.getApplicationUri();
};
+ /**
+ * Indicates whether or not there are currently active UIDL requests. Used
+ * internally to squence requests properly, seldom needed in Widgets.
+ *
+ * @return true if there are active requests
+ */
public boolean hasActiveRequest() {
return (activeRequests > 0);
}
}
}
+ /**
+ * Determines whether or not the loading indicator is showing.
+ *
+ * @return true if the loading indicator is visible
+ */
public boolean isLoadingIndicatorVisible() {
if (loadElement == null) {
return false;
el.tkPid = pid;
}-*/;
+ /**
+ * Gets the paintableId for a specific paintable (a.k.a Vaadin Widget).
+ * <p>
+ * The paintableId is used in the UIDL to identify a specific widget
+ * instance, effectively linking the widget with it's server side Component.
+ * </p>
+ *
+ * @param paintable
+ * the paintable who's id is needed
+ * @return the id for the given paintable
+ */
public String getPid(Paintable paintable) {
return getPid(((Widget) paintable).getElement());
}
+ /**
+ * Gets the paintableId using a DOM element - the element should be the main
+ * element for a paintable otherwise no id will be found. Use
+ * {@link #getPid(Paintable)} instead whenever possible.
+ *
+ * @see #getPid(Paintable)
+ * @param el
+ * element of the paintable whose pid is desired
+ * @return the pid of the element's paintable, if it's a paintable
+ */
public native String getPid(Element el)
/*-{
return el.tkPid;
}-*/;
+ /**
+ * Gets the main element for the paintable with the given id. The revers of
+ * {@link #getPid(Element)}.
+ *
+ * @param pid
+ * the pid of the widget whose element is desired
+ * @return the element for the paintable corresponding to the pid
+ */
public Element getElementByPid(String pid) {
return ((Widget) getPaintable(pid)).getElement();
}
+ /**
+ * Unregisters the given paintable; always use after removing a paintable.
+ * Does not actually remove the paintable from the DOM.
+ *
+ * @param p
+ * the paintable to remove
+ */
public void unregisterPaintable(Paintable p) {
if (p == null) {
ApplicationConnection.getConsole().error(
}
}
+ /**
+ * Unregisters a paintable and all it's child paintables recursively. Use
+ * when after removing a paintable that contains other paintables. Does not
+ * unregister the given container itself. Does not actually remove the
+ * paintable from the DOM.
+ *
+ * @see #unregisterPaintable(Paintable)
+ * @param container
+ */
public void unregisterChildPaintables(HasWidgets container) {
final Iterator<Widget> it = container.iterator();
while (it.hasNext()) {
makeUidlRequest(req.toString(), false, forceSync, false);
}
+ /**
+ * Sends a new value for the given paintables given variable to the server.
+ * <p>
+ * The update is actually queued to be sent at a suitable time. If immediate
+ * is true, the update is sent as soon as possible. If immediate is false,
+ * the update will be sent along with the next immediate update.
+ * </p>
+ *
+ * @param paintableId
+ * the id of the paintable that owns the variable
+ * @param variableName
+ * the name of the variable
+ * @param newValue
+ * the new value to be sent
+ * @param immediate
+ * true if the update is to be sent as suun as possible
+ */
public void updateVariable(String paintableId, String variableName,
Paintable newValue, boolean immediate) {
String pid = (newValue != null) ? getPid(newValue) : null;
addVariableToQueue(paintableId, variableName, pid, immediate, 'p');
}
+ /**
+ * Sends a new value for the given paintables given variable to the server.
+ * <p>
+ * The update is actually queued to be sent at a suitable time. If immediate
+ * is true, the update is sent as soon as possible. If immediate is false,
+ * the update will be sent along with the next immediate update.
+ * </p>
+ *
+ * @param paintableId
+ * the id of the paintable that owns the variable
+ * @param variableName
+ * the name of the variable
+ * @param newValue
+ * the new value to be sent
+ * @param immediate
+ * true if the update is to be sent as suun as possible
+ */
+
public void updateVariable(String paintableId, String variableName,
String newValue, boolean immediate) {
addVariableToQueue(paintableId, variableName, newValue, immediate, 's');
}
+ /**
+ * Sends a new value for the given paintables given variable to the server.
+ * <p>
+ * The update is actually queued to be sent at a suitable time. If immediate
+ * is true, the update is sent as soon as possible. If immediate is false,
+ * the update will be sent along with the next immediate update.
+ * </p>
+ *
+ * @param paintableId
+ * the id of the paintable that owns the variable
+ * @param variableName
+ * the name of the variable
+ * @param newValue
+ * the new value to be sent
+ * @param immediate
+ * true if the update is to be sent as suun as possible
+ */
+
public void updateVariable(String paintableId, String variableName,
int newValue, boolean immediate) {
addVariableToQueue(paintableId, variableName, "" + newValue, immediate,
'i');
}
+ /**
+ * Sends a new value for the given paintables given variable to the server.
+ * <p>
+ * The update is actually queued to be sent at a suitable time. If immediate
+ * is true, the update is sent as soon as possible. If immediate is false,
+ * the update will be sent along with the next immediate update.
+ * </p>
+ *
+ * @param paintableId
+ * the id of the paintable that owns the variable
+ * @param variableName
+ * the name of the variable
+ * @param newValue
+ * the new value to be sent
+ * @param immediate
+ * true if the update is to be sent as suun as possible
+ */
+
public void updateVariable(String paintableId, String variableName,
long newValue, boolean immediate) {
addVariableToQueue(paintableId, variableName, "" + newValue, immediate,
'l');
}
+ /**
+ * Sends a new value for the given paintables given variable to the server.
+ * <p>
+ * The update is actually queued to be sent at a suitable time. If immediate
+ * is true, the update is sent as soon as possible. If immediate is false,
+ * the update will be sent along with the next immediate update.
+ * </p>
+ *
+ * @param paintableId
+ * the id of the paintable that owns the variable
+ * @param variableName
+ * the name of the variable
+ * @param newValue
+ * the new value to be sent
+ * @param immediate
+ * true if the update is to be sent as suun as possible
+ */
+
public void updateVariable(String paintableId, String variableName,
float newValue, boolean immediate) {
addVariableToQueue(paintableId, variableName, "" + newValue, immediate,
'f');
}
+ /**
+ * Sends a new value for the given paintables given variable to the server.
+ * <p>
+ * The update is actually queued to be sent at a suitable time. If immediate
+ * is true, the update is sent as soon as possible. If immediate is false,
+ * the update will be sent along with the next immediate update.
+ * </p>
+ *
+ * @param paintableId
+ * the id of the paintable that owns the variable
+ * @param variableName
+ * the name of the variable
+ * @param newValue
+ * the new value to be sent
+ * @param immediate
+ * true if the update is to be sent as suun as possible
+ */
+
public void updateVariable(String paintableId, String variableName,
double newValue, boolean immediate) {
addVariableToQueue(paintableId, variableName, "" + newValue, immediate,
'd');
}
+ /**
+ * Sends a new value for the given paintables given variable to the server.
+ * <p>
+ * The update is actually queued to be sent at a suitable time. If immediate
+ * is true, the update is sent as soon as possible. If immediate is false,
+ * the update will be sent along with the next immediate update.
+ * </p>
+ *
+ * @param paintableId
+ * the id of the paintable that owns the variable
+ * @param variableName
+ * the name of the variable
+ * @param newValue
+ * the new value to be sent
+ * @param immediate
+ * true if the update is to be sent as suun as possible
+ */
+
public void updateVariable(String paintableId, String variableName,
boolean newValue, boolean immediate) {
addVariableToQueue(paintableId, variableName, newValue ? "true"
: "false", immediate, 'b');
}
+ /**
+ * Sends a new value for the given paintables given variable to the server.
+ * <p>
+ * The update is actually queued to be sent at a suitable time. If immediate
+ * is true, the update is sent as soon as possible. If immediate is false,
+ * the update will be sent along with the next immediate update.
+ * </p>
+ *
+ * @param paintableId
+ * the id of the paintable that owns the variable
+ * @param variableName
+ * the name of the variable
+ * @param newValue
+ * the new value to be sent
+ * @param immediate
+ * true if the update is to be sent as suun as possible
+ */
public void updateVariable(String paintableId, String variableName,
Map<String, Object> map, boolean immediate) {
final StringBuffer buf = new StringBuffer();
return 'u';
}
+ /**
+ * Sends a new value for the given paintables given variable to the server.
+ * <p>
+ * The update is actually queued to be sent at a suitable time. If immediate
+ * is true, the update is sent as soon as possible. If immediate is false,
+ * the update will be sent along with the next immediate update.
+ * </p>
+ *
+ * @param paintableId
+ * the id of the paintable that owns the variable
+ * @param variableName
+ * the name of the variable
+ * @param newValue
+ * the new value to be sent
+ * @param immediate
+ * true if the update is to be sent as suun as possible
+ */
public void updateVariable(String paintableId, String variableName,
String[] values, boolean immediate) {
final StringBuffer buf = new StringBuffer();
immediate, 'c');
}
+ /**
+ * Sends a new value for the given paintables given variable to the server.
+ * <p>
+ * The update is actually queued to be sent at a suitable time. If immediate
+ * is true, the update is sent as soon as possible. If immediate is false,
+ * the update will be sent along with the next immediate update.
+ * </p>
+ *
+ * @param paintableId
+ * the id of the paintable that owns the variable
+ * @param variableName
+ * the name of the variable
+ * @param newValue
+ * the new value to be sent
+ * @param immediate
+ * true if the update is to be sent as suun as possible
+ */
public void updateVariable(String paintableId, String variableName,
Object[] values, boolean immediate) {
final StringBuffer buf = new StringBuffer();
*/
private boolean runningLayout = false;
+ /**
+ * Causes a re-calculation/re-layout of all paintables in a container.
+ *
+ * @param container
+ */
public void runDescendentsLayout(HasWidgets container) {
if (runningLayout) {
- // getConsole().log(
- // "Already running descendents layout. Not running again for "
- // + Util.getSimpleName(container));
return;
}
runningLayout = true;
}
+ /**
+ * Gets the specified Paintables relative size (percent).
+ *
+ * @param widget
+ * the paintable whose size is needed
+ * @return the the size if the paintable is relatively sized, -1 otherwise
+ */
public FloatSize getRelativeSize(Widget widget) {
return idToPaintableDetail.get(getPid(widget.getElement()))
.getRelativeSize();
return getPaintable(getPid(element));
}
+ /**
+ * Gets a recource that has been pre-loaded via UIDL, such as custom
+ * layouts.
+ *
+ * @param name
+ * identifier of the resource to get
+ * @return the resource
+ */
public String getResource(String name) {
return resourcesMap.get(name);
}
return uidlUri;
}
+ /**
+ * Gets the URI for the current theme. Can be used to reference theme
+ * resources.
+ *
+ * @return URI to the current theme
+ */
public String getThemeUri() {
return configuration.getThemeUri();
}
windowName = newName;
}
+ /**
+ * Use to notify that the given component's caption has changed; layouts may
+ * have to be recalculated.
+ *
+ * @param component
+ * the Paintable whose caption has changed
+ */
public void captionSizeUpdated(Paintable component) {
componentCaptionSizeChanges.add(component);
}
+ /**
+ * Requests an analyze of layouts, to find inconsistensies. Exclusively used
+ * for debugging during develpoment.
+ */
public void analyzeLayouts() {
makeUidlRequest("", true, false, true);
}
+ /**
+ * Gets the main view, a.k.a top-level window.
+ *
+ * @return the main view
+ */
public VView getView() {
return view;
}
componentDetail.putAdditionalTooltip(key, tooltip);
}
+ /**
+ * Gets the {@link ApplicationConfiguration} for the current application.
+ *
+ * @see ApplicationConfiguration
+ * @return the configuration for this application
+ */
public ApplicationConfiguration getConfiguration() {
return configuration;
}