diff options
Diffstat (limited to 'shared')
60 files changed, 3055 insertions, 0 deletions
diff --git a/shared/src/com/vaadin/shared/AbstractFieldState.java b/shared/src/com/vaadin/shared/AbstractFieldState.java new file mode 100644 index 0000000000..faba7de89f --- /dev/null +++ b/shared/src/com/vaadin/shared/AbstractFieldState.java @@ -0,0 +1,140 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ +package com.vaadin.shared; + +import com.vaadin.shared.ui.TabIndexState; + +/** + * Shared state for {@link com.vaadin.ui.AbstractField}. + * + * @author Vaadin Ltd + * @version @VERSION@ + * @since 7.0.0 + * + */ +public class AbstractFieldState extends ComponentState implements TabIndexState { + private boolean propertyReadOnly = false; + private boolean hideErrors = false; + private boolean required = false; + private boolean modified = false; + + /** + * The tab order number of this field. + */ + private int tabIndex = 0; + + /** + * Checks if the property data source for the Field is in read only mode. + * This affects the read only state of the field itself. + * + * @return true if there is a property data source and it is set to read + * only, false otherwise + */ + public boolean isPropertyReadOnly() { + return propertyReadOnly; + } + + /** + * Sets the read only state of the property data source. + * + * @param propertyReadOnly + * true if the property data source if read only, false otherwise + */ + public void setPropertyReadOnly(boolean propertyReadOnly) { + this.propertyReadOnly = propertyReadOnly; + } + + /** + * Returns true if the component will hide any errors even if the error + * message is set. + * + * @return true if error messages are disabled + */ + public boolean isHideErrors() { + return hideErrors; + } + + /** + * Sets whether the component should hide any errors even if the error + * message is set. + * + * This is used e.g. on forms to hide error messages for invalid fields + * before the first user actions. + * + * @param hideErrors + * true if error messages should be hidden + */ + public void setHideErrors(boolean hideErrors) { + this.hideErrors = hideErrors; + } + + /** + * Is the field required. Required fields must filled by the user. + * + * See {@link com.vaadin.ui.AbstractField#isRequired()} for more + * information. + * + * @return <code>true</code> if the field is required, otherwise + * <code>false</code>. + */ + public boolean isRequired() { + return required; + } + + /** + * Sets the field required. Required fields must filled by the user. + * + * See {@link com.vaadin.ui.AbstractField#setRequired(boolean)} for more + * information. + * + * @param required + * Is the field required. + */ + public void setRequired(boolean required) { + this.required = required; + } + + /** + * Has the contents of the field been modified, i.e. has the value been + * updated after it was read from the data source. + * + * @return true if the field has been modified, false otherwise + */ + public boolean isModified() { + return modified; + } + + /** + * Setter for the modified flag, toggled when the contents of the field is + * modified by the user. + * + * @param modified + * the new modified state + * + */ + public void setModified(boolean modified) { + this.modified = modified; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.terminal.gwt.client.ComponentState#getTabIndex() + */ + @Override + public int getTabIndex() { + return tabIndex; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.terminal.gwt.client.ui.TabIndexState#setTabIndex(int) + */ + @Override + public void setTabIndex(int tabIndex) { + this.tabIndex = tabIndex; + } + +} diff --git a/shared/src/com/vaadin/shared/ComponentState.java b/shared/src/com/vaadin/shared/ComponentState.java new file mode 100644 index 0000000000..2805d566ad --- /dev/null +++ b/shared/src/com/vaadin/shared/ComponentState.java @@ -0,0 +1,381 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ + +package com.vaadin.shared; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import com.vaadin.shared.communication.SharedState; +import com.vaadin.shared.communication.URLReference; + +/** + * Default shared state implementation for UI components. + * + * State classes of concrete components should extend this class. + * + * @since 7.0 + */ +public class ComponentState extends SharedState { + private String height = ""; + private String width = ""; + private boolean readOnly = false; + private boolean immediate = false; + private String description = ""; + // Note: for the caption, there is a difference between null and an empty + // string! + private String caption = null; + private boolean visible = true; + private URLReference icon = null; + private List<String> styles = null; + private String debugId = null; + /** + * A set of event identifiers with registered listeners. + */ + private Set<String> registeredEventListeners = null; + + // HTML formatted error message for the component + // TODO this could be an object with more information, but currently the UI + // only uses the message + private String errorMessage = null; + + /** + * Returns the component height as set by the server. + * + * Can be relative (containing the percent sign) or absolute, or empty + * string for undefined height. + * + * @return component height as defined by the server, not null + */ + public String getHeight() { + if (height == null) { + return ""; + } + return height; + } + + /** + * Sets the height of the component in the server format. + * + * Can be relative (containing the percent sign) or absolute, or null or + * empty string for undefined height. + * + * @param height + * component height + */ + public void setHeight(String height) { + this.height = height; + } + + /** + * Returns true if the component height is undefined, false if defined + * (absolute or relative). + * + * @return true if component height is undefined + */ + public boolean isUndefinedHeight() { + return "".equals(getHeight()); + } + + /** + * Returns the component width as set by the server. + * + * Can be relative (containing the percent sign) or absolute, or empty + * string for undefined height. + * + * @return component width as defined by the server, not null + */ + public String getWidth() { + if (width == null) { + return ""; + } + return width; + } + + /** + * Sets the width of the component in the server format. + * + * Can be relative (containing the percent sign) or absolute, or null or + * empty string for undefined width. + * + * @param width + * component width + */ + public void setWidth(String width) { + this.width = width; + } + + /** + * Returns true if the component width is undefined, false if defined + * (absolute or relative). + * + * @return true if component width is undefined + */ + public boolean isUndefinedWidth() { + return "".equals(getWidth()); + } + + /** + * Returns true if the component is in read-only mode. + * + * @see com.vaadin.ui.Component#isReadOnly() + * + * @return true if the component is in read-only mode + */ + public boolean isReadOnly() { + return readOnly; + } + + /** + * Sets or resets the read-only mode for a component. + * + * @see com.vaadin.ui.Component#setReadOnly() + * + * @param readOnly + * new mode for the component + */ + public void setReadOnly(boolean readOnly) { + this.readOnly = readOnly; + } + + /** + * Returns true if the component is in immediate mode. + * + * @see com.vaadin.terminal.VariableOwner#isImmediate() + * + * @return true if the component is in immediate mode + */ + public boolean isImmediate() { + return immediate; + } + + /** + * Sets or resets the immediate mode for a component. + * + * @see com.vaadin.terminal.VariableOwner#setImmediate() + * + * @param immediate + * new mode for the component + */ + public void setImmediate(boolean immediate) { + this.immediate = immediate; + } + + /** + * Returns true if the component has user-defined styles. + * + * @return true if the component has user-defined styles + */ + public boolean hasStyles() { + return styles != null && !styles.isEmpty(); + } + + /** + * Gets the description of the component (typically shown as tooltip). + * + * @see com.vaadin.ui.AbstractComponent#getDescription() + * + * @return component description (not null, can be empty string) + */ + public String getDescription() { + return description; + } + + /** + * Sets the description of the component (typically shown as tooltip). + * + * @see com.vaadin.ui.AbstractComponent#setDescription(String) + * + * @param description + * new component description (can be null) + */ + public void setDescription(String description) { + this.description = description; + } + + /** + * Returns true if the component has a description. + * + * @return true if the component has a description + */ + public boolean hasDescription() { + return getDescription() != null && !"".equals(getDescription()); + } + + /** + * Gets the caption of the component (typically shown by the containing + * layout). + * + * @see com.vaadin.ui.Component#getCaption() + * + * @return component caption - can be null (no caption) or empty string + * (reserve space for an empty caption) + */ + public String getCaption() { + return caption; + } + + /** + * Sets the caption of the component (typically shown by the containing + * layout). + * + * @see com.vaadin.ui.Component#setCaption(String) + * + * @param caption + * new component caption - can be null (no caption) or empty + * string (reserve space for an empty caption) + */ + public void setCaption(String caption) { + this.caption = caption; + } + + /** + * Returns the visibility state of the component. Note that this state is + * related to the component only, not its parent. This might differ from + * what {@link com.vaadin.ui.Component#isVisible()} returns as this takes + * the hierarchy into account. + * + * @return The visibility state. + */ + public boolean isVisible() { + return visible; + } + + /** + * Sets the visibility state of the component. + * + * @param visible + * The new visibility state. + */ + public void setVisible(boolean visible) { + this.visible = visible; + } + + public URLReference getIcon() { + return icon; + } + + public void setIcon(URLReference icon) { + this.icon = icon; + } + + /** + * Gets the style names for the component. + * + * @return A List of style names or null if no styles have been set. + */ + public List<String> getStyles() { + return styles; + } + + /** + * Sets the style names for the component. + * + * @param styles + * A list containing style names + */ + public void setStyles(List<String> styles) { + this.styles = styles; + } + + /** + * Gets the debug id for the component. The debugId is added as DOM id for + * the component. + * + * @return The debug id for the component or null if not set + */ + public String getDebugId() { + return debugId; + } + + /** + * Sets the debug id for the component. The debugId is added as DOM id for + * the component. + * + * @param debugId + * The new debugId for the component or null for no debug id + * + */ + public void setDebugId(String debugId) { + this.debugId = debugId; + } + + /** + * Gets the identifiers for the event listeners that have been registered + * for the component (using an event id) + * + * @return A set of event identifiers or null if no identifiers have been + * registered + */ + public Set<String> getRegisteredEventListeners() { + return registeredEventListeners; + } + + /** + * Sets the identifiers for the event listeners that have been registered + * for the component (using an event id) + * + * @param registeredEventListeners + * The new set of identifiers or null if no identifiers have been + * registered + */ + public void setRegisteredEventListeners(Set<String> registeredEventListeners) { + this.registeredEventListeners = registeredEventListeners; + } + + /** + * Adds an event listener id. + * + * @param eventListenerId + * The event identifier to add + */ + public void addRegisteredEventListener(String eventListenerId) { + if (registeredEventListeners == null) { + registeredEventListeners = new HashSet<String>(); + } + registeredEventListeners.add(eventListenerId); + + } + + /** + * Removes an event listener id. + * + * @param eventListenerId + * The event identifier to remove + */ + public void removeRegisteredEventListener(String eventIdentifier) { + if (registeredEventListeners == null) { + return; + } + registeredEventListeners.remove(eventIdentifier); + if (registeredEventListeners.size() == 0) { + registeredEventListeners = null; + } + } + + /** + * Returns the current error message for the component. + * + * @return HTML formatted error message to show for the component or null if + * none + */ + public String getErrorMessage() { + return errorMessage; + } + + /** + * Sets the current error message for the component. + * + * TODO this could use an object with more details about the error + * + * @param errorMessage + * HTML formatted error message to show for the component or null + * for none + */ + public void setErrorMessage(String errorMessage) { + this.errorMessage = errorMessage; + } + +} diff --git a/shared/src/com/vaadin/shared/Connector.java b/shared/src/com/vaadin/shared/Connector.java new file mode 100644 index 0000000000..69f819e881 --- /dev/null +++ b/shared/src/com/vaadin/shared/Connector.java @@ -0,0 +1,57 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ +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. + * <p> + * A connector consists of a shared state (server sets the state and + * automatically communicates changes to the client) and the possibility to do + * RPC calls either from the server to the client or from the client to the + * server. + * </p> + * <p> + * No classes should implement this interface directly, client side classes + * wanting to communicate with server side should implement + * {@link com.vaadin.terminal.gwt.client.ServerConnector} and server side + * classes should implement + * {@link com.vaadin.terminal.gwt.server.ClientConnector}. + * </p> + * + * @author Vaadin Ltd + * @version @VERSION@ + * @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. + * + * @return The id for the connector. + */ + public String getConnectorId(); + + /** + * Gets the parent connector of this connector, or <code>null</code> if the + * connector is not attached to any parent. + * + * @return the parent connector, or <code>null</code> if there is no parent. + */ + public Connector getParent(); + +} diff --git a/shared/src/com/vaadin/shared/EventId.java b/shared/src/com/vaadin/shared/EventId.java new file mode 100644 index 0000000000..616d37dcd0 --- /dev/null +++ b/shared/src/com/vaadin/shared/EventId.java @@ -0,0 +1,9 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ +package com.vaadin.shared; + +public interface EventId { + public static final String BLUR = "blur"; + public static final String FOCUS = "focus"; +} diff --git a/shared/src/com/vaadin/shared/JavaScriptConnectorState.java b/shared/src/com/vaadin/shared/JavaScriptConnectorState.java new file mode 100644 index 0000000000..8371623e68 --- /dev/null +++ b/shared/src/com/vaadin/shared/JavaScriptConnectorState.java @@ -0,0 +1,14 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ + +package com.vaadin.shared; + +import java.util.Map; +import java.util.Set; + +public interface JavaScriptConnectorState { + public Set<String> getCallbackNames(); + + public Map<String, Set<String>> getRpcInterfaces(); +}
\ No newline at end of file diff --git a/shared/src/com/vaadin/shared/JavaScriptExtensionState.java b/shared/src/com/vaadin/shared/JavaScriptExtensionState.java new file mode 100644 index 0000000000..35a7213239 --- /dev/null +++ b/shared/src/com/vaadin/shared/JavaScriptExtensionState.java @@ -0,0 +1,37 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ + +package com.vaadin.shared; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import com.vaadin.shared.communication.SharedState; + +public class JavaScriptExtensionState extends SharedState implements + JavaScriptConnectorState { + + private Set<String> callbackNames = new HashSet<String>(); + private Map<String, Set<String>> rpcInterfaces = new HashMap<String, Set<String>>(); + + @Override + public Set<String> getCallbackNames() { + return callbackNames; + } + + public void setCallbackNames(Set<String> callbackNames) { + this.callbackNames = callbackNames; + } + + @Override + public Map<String, Set<String>> getRpcInterfaces() { + return rpcInterfaces; + } + + public void setRpcInterfaces(Map<String, Set<String>> rpcInterfaces) { + this.rpcInterfaces = rpcInterfaces; + } +} diff --git a/shared/src/com/vaadin/shared/MouseEventDetails.java b/shared/src/com/vaadin/shared/MouseEventDetails.java new file mode 100644 index 0000000000..bc7ede4c60 --- /dev/null +++ b/shared/src/com/vaadin/shared/MouseEventDetails.java @@ -0,0 +1,159 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ +package com.vaadin.shared; + +import java.io.Serializable; + +/** + * Helper class to store and transfer mouse event details. + */ +public class MouseEventDetails implements Serializable { + // From com.google.gwt.dom.client.NativeEvent + public static final int BUTTON_LEFT = 1; + public static final int BUTTON_MIDDLE = 4; + public static final int BUTTON_RIGHT = 2; + + private static final char DELIM = ','; + // From com.google.gwt.user.client.Event + private static final int ONDBLCLICK = 0x00002; + + private int button; + private int clientX; + private int clientY; + private boolean altKey; + private boolean ctrlKey; + private boolean metaKey; + private boolean shiftKey; + private int type; + private int relativeX = -1; + private int relativeY = -1; + + public int getButton() { + return button; + } + + public int getClientX() { + return clientX; + } + + public int getClientY() { + return clientY; + } + + public boolean isAltKey() { + return altKey; + } + + public boolean isCtrlKey() { + return ctrlKey; + } + + public boolean isMetaKey() { + return metaKey; + } + + public boolean isShiftKey() { + return shiftKey; + } + + public int getRelativeX() { + return relativeX; + } + + public int getRelativeY() { + return relativeY; + } + + public void setButton(int button) { + this.button = button; + } + + public void setClientX(int clientX) { + this.clientX = clientX; + } + + public void setClientY(int clientY) { + this.clientY = clientY; + } + + public void setAltKey(boolean altKey) { + this.altKey = altKey; + } + + public void setCtrlKey(boolean ctrlKey) { + this.ctrlKey = ctrlKey; + } + + public void setMetaKey(boolean metaKey) { + this.metaKey = metaKey; + } + + public void setShiftKey(boolean shiftKey) { + this.shiftKey = shiftKey; + } + + public void setType(int type) { + this.type = type; + } + + public void setRelativeX(int relativeX) { + this.relativeX = relativeX; + } + + public void setRelativeY(int relativeY) { + this.relativeY = relativeY; + } + + public MouseEventDetails() { + } + + @Override + public String toString() { + return serialize(); + } + + public String serialize() { + return "" + button + DELIM + clientX + DELIM + clientY + DELIM + altKey + + DELIM + ctrlKey + DELIM + metaKey + DELIM + shiftKey + DELIM + + type + DELIM + relativeX + DELIM + relativeY; + } + + public static MouseEventDetails deSerialize(String serializedString) { + MouseEventDetails instance = new MouseEventDetails(); + String[] fields = serializedString.split(","); + + instance.button = Integer.parseInt(fields[0]); + instance.clientX = Integer.parseInt(fields[1]); + instance.clientY = Integer.parseInt(fields[2]); + instance.altKey = Boolean.valueOf(fields[3]).booleanValue(); + instance.ctrlKey = Boolean.valueOf(fields[4]).booleanValue(); + instance.metaKey = Boolean.valueOf(fields[5]).booleanValue(); + instance.shiftKey = Boolean.valueOf(fields[6]).booleanValue(); + instance.type = Integer.parseInt(fields[7]); + instance.relativeX = Integer.parseInt(fields[8]); + instance.relativeY = Integer.parseInt(fields[9]); + return instance; + } + + public String getButtonName() { + if (button == BUTTON_LEFT) { + return "left"; + } else if (button == BUTTON_RIGHT) { + return "right"; + } else if (button == BUTTON_MIDDLE) { + return "middle"; + } + + return ""; + } + + public int getType() { + return type; + } + + public boolean isDoubleClick() { + return type == ONDBLCLICK; + } + +} diff --git a/shared/src/com/vaadin/shared/VBrowserDetails.java b/shared/src/com/vaadin/shared/VBrowserDetails.java new file mode 100644 index 0000000000..352e598552 --- /dev/null +++ b/shared/src/com/vaadin/shared/VBrowserDetails.java @@ -0,0 +1,465 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ +package com.vaadin.shared; + +import java.io.Serializable; + +/** + * Class that parses the user agent string from the browser and provides + * information about the browser. Used internally by + * {@link com.vaadin.terminal.gwt.client.BrowserInfo} and + * {@link com.vaadin.terminal.gwt.server.WebBrowser}. Should not be used + * directly. + * + * @author Vaadin Ltd. + * @version @VERSION@ + * @since 6.3 + */ +public class VBrowserDetails implements Serializable { + + private boolean isGecko = false; + private boolean isWebKit = false; + private boolean isPresto = false; + + private boolean isChromeFrameCapable = false; + private boolean isChromeFrame = false; + + private boolean isSafari = false; + private boolean isChrome = false; + private boolean isFirefox = false; + private boolean isOpera = false; + private boolean isIE = false; + + private OperatingSystem os = OperatingSystem.UNKNOWN; + + public enum OperatingSystem { + UNKNOWN, WINDOWS, MACOSX, LINUX, IOS, ANDROID; + } + + private float browserEngineVersion = -1; + private int browserMajorVersion = -1; + private int browserMinorVersion = -1; + + private int osMajorVersion = -1; + private int osMinorVersion = -1; + + /** + * Create an instance based on the given user agent. + * + * @param userAgent + * User agent as provided by the browser. + */ + public VBrowserDetails(String userAgent) { + userAgent = userAgent.toLowerCase(); + + // browser engine name + isGecko = userAgent.indexOf("gecko") != -1 + && userAgent.indexOf("webkit") == -1; + isWebKit = userAgent.indexOf("applewebkit") != -1; + isPresto = userAgent.indexOf(" presto/") != -1; + + // browser name + isChrome = userAgent.indexOf(" chrome/") != -1; + isSafari = !isChrome && userAgent.indexOf("safari") != -1; + isOpera = userAgent.indexOf("opera") != -1; + isIE = userAgent.indexOf("msie") != -1 && !isOpera + && (userAgent.indexOf("webtv") == -1); + isFirefox = userAgent.indexOf(" firefox/") != -1; + + // chromeframe + isChromeFrameCapable = userAgent.indexOf("chromeframe") != -1; + isChromeFrame = isChromeFrameCapable && !isChrome; + + // Rendering engine version + try { + if (isGecko) { + int rvPos = userAgent.indexOf("rv:"); + if (rvPos >= 0) { + String tmp = userAgent.substring(rvPos + 3); + tmp = tmp.replaceFirst("(\\.[0-9]+).+", "$1"); + browserEngineVersion = Float.parseFloat(tmp); + } + } else if (isWebKit) { + String tmp = userAgent + .substring(userAgent.indexOf("webkit/") + 7); + tmp = tmp.replaceFirst("([0-9]+)[^0-9].+", "$1"); + browserEngineVersion = Float.parseFloat(tmp); + } + } catch (Exception e) { + // Browser engine version parsing failed + System.err.println("Browser engine version parsing failed for: " + + userAgent); + } + + // Browser version + try { + if (isIE) { + String ieVersionString = userAgent.substring(userAgent + .indexOf("msie ") + 5); + ieVersionString = safeSubstring(ieVersionString, 0, + ieVersionString.indexOf(";")); + parseVersionString(ieVersionString); + } else if (isFirefox) { + int i = userAgent.indexOf(" firefox/") + 9; + parseVersionString(safeSubstring(userAgent, i, i + 5)); + } else if (isChrome) { + int i = userAgent.indexOf(" chrome/") + 8; + parseVersionString(safeSubstring(userAgent, i, i + 5)); + } else if (isSafari) { + int i = userAgent.indexOf(" version/") + 9; + parseVersionString(safeSubstring(userAgent, i, i + 5)); + } else if (isOpera) { + int i = userAgent.indexOf(" version/"); + if (i != -1) { + // Version present in Opera 10 and newer + i += 9; // " version/".length + } else { + i = userAgent.indexOf("opera/") + 6; + } + parseVersionString(safeSubstring(userAgent, i, i + 5)); + } + } catch (Exception e) { + // Browser version parsing failed + System.err.println("Browser version parsing failed for: " + + userAgent); + } + + // Operating system + if (userAgent.contains("windows ")) { + os = OperatingSystem.WINDOWS; + } else if (userAgent.contains("linux")) { + if (userAgent.contains("android")) { + os = OperatingSystem.ANDROID; + parseAndroidVersion(userAgent); + } else { + os = OperatingSystem.LINUX; + + } + } else if (userAgent.contains("macintosh") + || userAgent.contains("mac osx") + || userAgent.contains("mac os x")) { + if (userAgent.contains("ipad") || userAgent.contains("ipod") + || userAgent.contains("iphone")) { + os = OperatingSystem.IOS; + parseIOSVersion(userAgent); + } else { + os = OperatingSystem.MACOSX; + } + } + } + + private void parseAndroidVersion(String userAgent) { + // Android 5.1; + if (!userAgent.contains("android")) { + return; + } + + String osVersionString = safeSubstring(userAgent, + userAgent.indexOf("android ") + "android ".length(), + userAgent.length()); + osVersionString = safeSubstring(osVersionString, 0, + osVersionString.indexOf(";")); + String[] parts = osVersionString.split("\\."); + parseOsVersion(parts); + } + + private void parseIOSVersion(String userAgent) { + // OS 5_1 like Mac OS X + if (!userAgent.contains("os ") || !userAgent.contains(" like mac")) { + return; + } + + String osVersionString = safeSubstring(userAgent, + userAgent.indexOf("os ") + 3, userAgent.indexOf(" like mac")); + String[] parts = osVersionString.split("_"); + parseOsVersion(parts); + } + + private void parseOsVersion(String[] parts) { + osMajorVersion = -1; + osMinorVersion = -1; + + if (parts.length >= 1) { + try { + osMajorVersion = Integer.parseInt(parts[0]); + } catch (Exception e) { + } + } + if (parts.length >= 2) { + try { + osMinorVersion = Integer.parseInt(parts[1]); + } catch (Exception e) { + } + // Some Androids report version numbers as "2.1-update1" + if (osMinorVersion == -1 && parts[1].contains("-")) { + try { + osMinorVersion = Integer.parseInt(parts[1].substring(0, + parts[1].indexOf('-'))); + } catch (Exception ee) { + } + } + } + + } + + private void parseVersionString(String versionString) { + int idx = versionString.indexOf('.'); + if (idx < 0) { + idx = versionString.length(); + } + browserMajorVersion = Integer.parseInt(safeSubstring(versionString, 0, + idx)); + + int idx2 = versionString.indexOf('.', idx + 1); + if (idx2 < 0) { + idx2 = versionString.length(); + } + try { + browserMinorVersion = Integer.parseInt(safeSubstring(versionString, + idx + 1, idx2).replaceAll("[^0-9].*", "")); + } catch (NumberFormatException e) { + // leave the minor version unmodified (-1 = unknown) + } + } + + private String safeSubstring(String string, int beginIndex, int endIndex) { + if (beginIndex < 0) { + beginIndex = 0; + } + if (endIndex < 0 || endIndex > string.length()) { + endIndex = string.length(); + } + return string.substring(beginIndex, endIndex); + } + + /** + * Tests if the browser is Firefox. + * + * @return true if it is Firefox, false otherwise + */ + public boolean isFirefox() { + return isFirefox; + } + + /** + * Tests if the browser is using the Gecko engine + * + * @return true if it is Gecko, false otherwise + */ + public boolean isGecko() { + return isGecko; + } + + /** + * Tests if the browser is using the WebKit engine + * + * @return true if it is WebKit, false otherwise + */ + public boolean isWebKit() { + return isWebKit; + } + + /** + * Tests if the browser is using the Presto engine + * + * @return true if it is Presto, false otherwise + */ + public boolean isPresto() { + return isPresto; + } + + /** + * Tests if the browser is Safari. + * + * @return true if it is Safari, false otherwise + */ + public boolean isSafari() { + return isSafari; + } + + /** + * Tests if the browser is Chrome. + * + * @return true if it is Chrome, false otherwise + */ + public boolean isChrome() { + return isChrome; + } + + /** + * Tests if the browser is capable of running ChromeFrame. + * + * @return true if it has ChromeFrame, false otherwise + */ + public boolean isChromeFrameCapable() { + return isChromeFrameCapable; + } + + /** + * Tests if the browser is running ChromeFrame. + * + * @return true if it is ChromeFrame, false otherwise + */ + public boolean isChromeFrame() { + return isChromeFrame; + } + + /** + * Tests if the browser is Opera. + * + * @return true if it is Opera, false otherwise + */ + public boolean isOpera() { + return isOpera; + } + + /** + * Tests if the browser is Internet Explorer. + * + * @return true if it is Internet Explorer, false otherwise + */ + public boolean isIE() { + return isIE; + } + + /** + * Returns the version of the browser engine. For WebKit this is an integer + * e.g., 532.0. For gecko it is a float e.g., 1.8 or 1.9. + * + * @return The version of the browser engine + */ + public float getBrowserEngineVersion() { + return browserEngineVersion; + } + + /** + * Returns the browser major version e.g., 3 for Firefox 3.5, 4 for Chrome + * 4, 8 for Internet Explorer 8. + * <p> + * Note that Internet Explorer 8 and newer will return the document mode so + * IE8 rendering as IE7 will return 7. + * </p> + * + * @return The major version of the browser. + */ + public final int getBrowserMajorVersion() { + return browserMajorVersion; + } + + /** + * Returns the browser minor version e.g., 5 for Firefox 3.5. + * + * @see #getBrowserMajorVersion() + * + * @return The minor version of the browser, or -1 if not known/parsed. + */ + public final int getBrowserMinorVersion() { + return browserMinorVersion; + } + + /** + * Sets the version for IE based on the documentMode. This is used to return + * the correct the correct IE version when the version from the user agent + * string and the value of the documentMode property do not match. + * + * @param documentMode + * The current document mode + */ + public void setIEMode(int documentMode) { + browserMajorVersion = documentMode; + browserMinorVersion = 0; + } + + /** + * Tests if the browser is run on Windows. + * + * @return true if run on Windows, false otherwise + */ + public boolean isWindows() { + return os == OperatingSystem.WINDOWS; + } + + /** + * Tests if the browser is run on Mac OSX. + * + * @return true if run on Mac OSX, false otherwise + */ + public boolean isMacOSX() { + return os == OperatingSystem.MACOSX; + } + + /** + * Tests if the browser is run on Linux. + * + * @return true if run on Linux, false otherwise + */ + public boolean isLinux() { + return os == OperatingSystem.LINUX; + } + + /** + * Tests if the browser is run on Android. + * + * @return true if run on Android, false otherwise + */ + public boolean isAndroid() { + return os == OperatingSystem.ANDROID; + } + + /** + * Tests if the browser is run in iOS. + * + * @return true if run in iOS, false otherwise + */ + public boolean isIOS() { + return os == OperatingSystem.IOS; + } + + /** + * Returns the major version of the operating system. Currently only + * supported for mobile devices (iOS/Android) + * + * @return The major version or -1 if unknown + */ + public int getOperatingSystemMajorVersion() { + return osMajorVersion; + } + + /** + * Returns the minor version of the operating system. Currently only + * supported for mobile devices (iOS/Android) + * + * @return The minor version or -1 if unknown + */ + public int getOperatingSystemMinorVersion() { + return osMinorVersion; + } + + /** + * Checks if the browser is so old that it simply won't work with a Vaadin + * application. NOTE that the browser might still be capable of running + * Crome Frame, so you might still want to check + * {@link #isChromeFrameCapable()} if this returns true. + * + * @return true if the browser won't work, false if not the browser is + * supported or might work + */ + public boolean isTooOldToFunctionProperly() { + if (isIE() && getBrowserMajorVersion() < 8) { + return true; + } + if (isSafari() && getBrowserMajorVersion() < 5) { + return true; + } + if (isFirefox() && getBrowserMajorVersion() < 4) { + return true; + } + if (isOpera() && getBrowserMajorVersion() < 11) { + return true; + } + + return false; + } + +} diff --git a/shared/src/com/vaadin/shared/communication/ClientRpc.java b/shared/src/com/vaadin/shared/communication/ClientRpc.java new file mode 100644 index 0000000000..d49bc05260 --- /dev/null +++ b/shared/src/com/vaadin/shared/communication/ClientRpc.java @@ -0,0 +1,23 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ + +package com.vaadin.shared.communication; + +import java.io.Serializable; + +/** + * Interface to be extended by all server to client RPC interfaces. + * + * On the server side, proxies of the interface can be obtained from + * AbstractComponent. On the client, RPC implementations can be registered with + * AbstractConnector.registerRpc(). + * + * Note: Currently, each RPC interface may not contain multiple methods with the + * same name, even if their parameter lists would differ. + * + * @since 7.0 + */ +public interface ClientRpc extends Serializable { + +} diff --git a/shared/src/com/vaadin/shared/communication/FieldRpc.java b/shared/src/com/vaadin/shared/communication/FieldRpc.java new file mode 100644 index 0000000000..33e6f01028 --- /dev/null +++ b/shared/src/com/vaadin/shared/communication/FieldRpc.java @@ -0,0 +1,19 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ +package com.vaadin.shared.communication; + +public class FieldRpc { + public interface FocusServerRpc extends ServerRpc { + public void focus(); + } + + public interface BlurServerRpc extends ServerRpc { + public void blur(); + } + + public interface FocusAndBlurServerRpc extends FocusServerRpc, + BlurServerRpc { + + } +} diff --git a/shared/src/com/vaadin/shared/communication/MethodInvocation.java b/shared/src/com/vaadin/shared/communication/MethodInvocation.java new file mode 100644 index 0000000000..589c7b5d9b --- /dev/null +++ b/shared/src/com/vaadin/shared/communication/MethodInvocation.java @@ -0,0 +1,62 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ + +package com.vaadin.shared.communication; + +import java.io.Serializable; +import java.util.Arrays; + +/** + * Information needed by the framework to send an RPC method invocation from the + * client to the server or vice versa. + * + * @since 7.0 + */ +public class MethodInvocation implements Serializable { + + private final String connectorId; + private final String interfaceName; + private final String methodName; + private Object[] parameters; + + public MethodInvocation(String connectorId, String interfaceName, + String methodName) { + this.connectorId = connectorId; + this.interfaceName = interfaceName; + this.methodName = methodName; + } + + public MethodInvocation(String connectorId, String interfaceName, + String methodName, Object[] parameters) { + this(connectorId, interfaceName, methodName); + setParameters(parameters); + } + + public String getConnectorId() { + return connectorId; + } + + public String getInterfaceName() { + return interfaceName; + } + + public String getMethodName() { + return methodName; + } + + public Object[] getParameters() { + return parameters; + } + + public void setParameters(Object[] parameters) { + this.parameters = parameters; + } + + @Override + public String toString() { + return connectorId + ":" + interfaceName + "." + methodName + "(" + + Arrays.toString(parameters) + ")"; + } + +}
\ No newline at end of file diff --git a/shared/src/com/vaadin/shared/communication/ServerRpc.java b/shared/src/com/vaadin/shared/communication/ServerRpc.java new file mode 100644 index 0000000000..5ee42a4bef --- /dev/null +++ b/shared/src/com/vaadin/shared/communication/ServerRpc.java @@ -0,0 +1,15 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ + +package com.vaadin.shared.communication; + +import java.io.Serializable; + +/** + * Interface to be extended by all client to server RPC interfaces. + * + * @since 7.0 + */ +public interface ServerRpc extends Serializable { +} diff --git a/shared/src/com/vaadin/shared/communication/SharedState.java b/shared/src/com/vaadin/shared/communication/SharedState.java new file mode 100644 index 0000000000..692915324e --- /dev/null +++ b/shared/src/com/vaadin/shared/communication/SharedState.java @@ -0,0 +1,64 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ + +package com.vaadin.shared.communication; + +import java.io.Serializable; + +import com.vaadin.shared.Connector; + +/** + * Interface to be implemented by all shared state classes used to communicate + * basic information about a {@link Connector} from server to client. + * + * Shared state classes have to be declared in shared package to be accessible + * both for server and client code. + * + * Shared state objects are only sent from the server to the client, and any + * modifications from the client should be performed via an RPC call that + * modifies the authoritative state on the server. + * + * A shared state class should be a bean with getters and setters for each + * field. Supported data types are simple Java types, other beans and maps and + * arrays of these. + * + * On the client side the connector should override + * {@link com.vaadin.terminal.gwt.client.ui.AbstractConnector#getState()} to + * return the correct state type. This automatically causes a correct state + * object to be created. + * + * Subclasses of a {@link Connector} using shared state should also provide a + * subclass of the shared state class of the parent class to extend the state. A + * single {@link Connector} can only have one shared state object. + * + * @since 7.0 + */ +public class SharedState implements Serializable { + + private boolean enabled = true; + + /** + * Returns true if the component is enabled. + * + * @see com.vaadin.ui.Component#isEnabled() + * + * @return true if the component is enabled + */ + public boolean isEnabled() { + return enabled; + } + + /** + * Enables or disables the component. + * + * @see com.vaadin.ui.Component#setEnabled(boolean) + * + * @param enabled + * new mode for the component + */ + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + +} diff --git a/shared/src/com/vaadin/shared/communication/URLReference.java b/shared/src/com/vaadin/shared/communication/URLReference.java new file mode 100644 index 0000000000..a4868cdb57 --- /dev/null +++ b/shared/src/com/vaadin/shared/communication/URLReference.java @@ -0,0 +1,31 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ +package com.vaadin.shared.communication; + +import java.io.Serializable; + +public class URLReference implements Serializable { + + private String URL; + + /** + * Returns the URL that this object refers to. + * <p> + * Note that the URL can use special protocols like theme:// + * + * @return The URL for this reference or null if unknown. + */ + public String getURL() { + return URL; + } + + /** + * Sets the URL that this object refers to + * + * @param URL + */ + public void setURL(String URL) { + this.URL = URL; + } +}
\ No newline at end of file diff --git a/shared/src/com/vaadin/shared/communication/UidlValue.java b/shared/src/com/vaadin/shared/communication/UidlValue.java new file mode 100644 index 0000000000..0314488ef3 --- /dev/null +++ b/shared/src/com/vaadin/shared/communication/UidlValue.java @@ -0,0 +1,25 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ + +package com.vaadin.shared.communication; + +import java.io.Serializable; + +public class UidlValue implements Serializable { + private Object value; + + public UidlValue(Object value) { + this.value = value; + } + + public Object getValue() { + return value; + } + + @Override + public String toString() { + return "" + value; + } + +} diff --git a/shared/src/com/vaadin/shared/extension/javascriptmanager/ExecuteJavaScriptRpc.java b/shared/src/com/vaadin/shared/extension/javascriptmanager/ExecuteJavaScriptRpc.java new file mode 100644 index 0000000000..097913c37f --- /dev/null +++ b/shared/src/com/vaadin/shared/extension/javascriptmanager/ExecuteJavaScriptRpc.java @@ -0,0 +1,11 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ + +package com.vaadin.shared.extension.javascriptmanager; + +import com.vaadin.shared.communication.ClientRpc; + +public interface ExecuteJavaScriptRpc extends ClientRpc { + public void executeJavaScript(String script); +} diff --git a/shared/src/com/vaadin/shared/extension/javascriptmanager/JavaScriptManagerState.java b/shared/src/com/vaadin/shared/extension/javascriptmanager/JavaScriptManagerState.java new file mode 100644 index 0000000000..85647d0abd --- /dev/null +++ b/shared/src/com/vaadin/shared/extension/javascriptmanager/JavaScriptManagerState.java @@ -0,0 +1,22 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ + +package com.vaadin.shared.extension.javascriptmanager; + +import java.util.HashSet; +import java.util.Set; + +import com.vaadin.shared.communication.SharedState; + +public class JavaScriptManagerState extends SharedState { + private Set<String> names = new HashSet<String>(); + + public Set<String> getNames() { + return names; + } + + public void setNames(Set<String> names) { + this.names = names; + } +} diff --git a/shared/src/com/vaadin/shared/ui/AbstractLayoutState.java b/shared/src/com/vaadin/shared/ui/AbstractLayoutState.java new file mode 100644 index 0000000000..9eaa11a9c6 --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/AbstractLayoutState.java @@ -0,0 +1,19 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ +package com.vaadin.shared.ui; + +import com.vaadin.shared.ComponentState; + +public class AbstractLayoutState extends ComponentState { + private int marginsBitmask; + + public int getMarginsBitmask() { + return marginsBitmask; + } + + public void setMarginsBitmask(int marginsBitmask) { + this.marginsBitmask = marginsBitmask; + } + +}
\ No newline at end of file diff --git a/shared/src/com/vaadin/shared/ui/AbstractMediaState.java b/shared/src/com/vaadin/shared/ui/AbstractMediaState.java new file mode 100644 index 0000000000..8cee16575d --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/AbstractMediaState.java @@ -0,0 +1,82 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ +package com.vaadin.shared.ui; + +import java.util.ArrayList; +import java.util.List; + +import com.vaadin.shared.ComponentState; +import com.vaadin.shared.communication.URLReference; + +public class AbstractMediaState extends ComponentState { + private boolean showControls; + + private String altText; + + private boolean htmlContentAllowed; + + private boolean autoplay; + + private boolean muted; + + private List<URLReference> sources = new ArrayList<URLReference>(); + private List<String> sourceTypes = new ArrayList<String>(); + + public boolean isShowControls() { + return showControls; + } + + public void setShowControls(boolean showControls) { + this.showControls = showControls; + } + + public String getAltText() { + return altText; + } + + public void setAltText(String altText) { + this.altText = altText; + } + + public boolean isHtmlContentAllowed() { + return htmlContentAllowed; + } + + public void setHtmlContentAllowed(boolean htmlContentAllowed) { + this.htmlContentAllowed = htmlContentAllowed; + } + + public boolean isAutoplay() { + return autoplay; + } + + public void setAutoplay(boolean autoplay) { + this.autoplay = autoplay; + } + + public boolean isMuted() { + return muted; + } + + public void setMuted(boolean muted) { + this.muted = muted; + } + + public List<URLReference> getSources() { + return sources; + } + + public void setSources(List<URLReference> sources) { + this.sources = sources; + } + + public List<String> getSourceTypes() { + return sourceTypes; + } + + public void setSourceTypes(List<String> sourceTypes) { + this.sourceTypes = sourceTypes; + } + +} diff --git a/shared/src/com/vaadin/shared/ui/AlignmentInfo.java b/shared/src/com/vaadin/shared/ui/AlignmentInfo.java new file mode 100644 index 0000000000..ff800de646 --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/AlignmentInfo.java @@ -0,0 +1,89 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ + +package com.vaadin.shared.ui; + +public final class AlignmentInfo { + /** Bitmask values for client server communication */ + public static class Bits { + public static final int ALIGNMENT_LEFT = 1; + public static final int ALIGNMENT_RIGHT = 2; + public static final int ALIGNMENT_TOP = 4; + public static final int ALIGNMENT_BOTTOM = 8; + public static final int ALIGNMENT_HORIZONTAL_CENTER = 16; + public static final int ALIGNMENT_VERTICAL_CENTER = 32; + } + + public static final AlignmentInfo LEFT = new AlignmentInfo( + Bits.ALIGNMENT_LEFT); + public static final AlignmentInfo RIGHT = new AlignmentInfo( + Bits.ALIGNMENT_RIGHT); + public static final AlignmentInfo TOP = new AlignmentInfo( + Bits.ALIGNMENT_TOP); + public static final AlignmentInfo BOTTOM = new AlignmentInfo( + Bits.ALIGNMENT_BOTTOM); + public static final AlignmentInfo CENTER = new AlignmentInfo( + Bits.ALIGNMENT_HORIZONTAL_CENTER); + public static final AlignmentInfo MIDDLE = new AlignmentInfo( + Bits.ALIGNMENT_VERTICAL_CENTER); + public static final AlignmentInfo TOP_LEFT = new AlignmentInfo( + Bits.ALIGNMENT_TOP + Bits.ALIGNMENT_LEFT); + + private final int bitMask; + + public AlignmentInfo(int bitMask) { + this.bitMask = bitMask; + } + + public AlignmentInfo(AlignmentInfo horizontal, AlignmentInfo vertical) { + this(horizontal.getBitMask() + vertical.getBitMask()); + } + + public int getBitMask() { + return bitMask; + } + + public boolean isTop() { + return (bitMask & Bits.ALIGNMENT_TOP) == Bits.ALIGNMENT_TOP; + } + + public boolean isBottom() { + return (bitMask & Bits.ALIGNMENT_BOTTOM) == Bits.ALIGNMENT_BOTTOM; + } + + public boolean isLeft() { + return (bitMask & Bits.ALIGNMENT_LEFT) == Bits.ALIGNMENT_LEFT; + } + + public boolean isRight() { + return (bitMask & Bits.ALIGNMENT_RIGHT) == Bits.ALIGNMENT_RIGHT; + } + + public boolean isVerticalCenter() { + return (bitMask & Bits.ALIGNMENT_VERTICAL_CENTER) == Bits.ALIGNMENT_VERTICAL_CENTER; + } + + public boolean isHorizontalCenter() { + return (bitMask & Bits.ALIGNMENT_HORIZONTAL_CENTER) == Bits.ALIGNMENT_HORIZONTAL_CENTER; + } + + public String getVerticalAlignment() { + if (isBottom()) { + return "bottom"; + } else if (isVerticalCenter()) { + return "middle"; + } + return "top"; + } + + public String getHorizontalAlignment() { + if (isRight()) { + return "right"; + } else if (isHorizontalCenter()) { + return "center"; + } + return "left"; + } + +} diff --git a/shared/src/com/vaadin/shared/ui/ClickRpc.java b/shared/src/com/vaadin/shared/ui/ClickRpc.java new file mode 100644 index 0000000000..61bde1a5e9 --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/ClickRpc.java @@ -0,0 +1,18 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ +package com.vaadin.shared.ui; + +import com.vaadin.shared.MouseEventDetails; +import com.vaadin.shared.communication.ServerRpc; + +public interface ClickRpc extends ServerRpc { + /** + * Called when a click event has occurred and there are server side + * listeners for the event. + * + * @param mouseDetails + * Details about the mouse when the event took place + */ + public void click(MouseEventDetails mouseDetails); +}
\ No newline at end of file diff --git a/shared/src/com/vaadin/shared/ui/Connect.java b/shared/src/com/vaadin/shared/ui/Connect.java new file mode 100644 index 0000000000..91b78c586a --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/Connect.java @@ -0,0 +1,93 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ +package com.vaadin.shared.ui; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import com.vaadin.shared.Connector; + +/** + * Annotation defining the server side connector that this ClientSideConnector + * should connect to. The value must always by a class extending + * {@link com.vaadin.terminal.gwt.server.ClientConnector}. + * <p> + * With this annotation client side Vaadin connector is marked to have a server + * side counterpart. The value of the annotation is the class of server side + * implementation. + * + * @since 7.0 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +public @interface Connect { + + /** + * @return the server side counterpart for the annotated component connector + */ + Class<? extends Connector> value(); + + /** + * Depending on the used WidgetMap generator, these optional hints may be + * used to define how the client side components are loaded by the browser. + * The default is to eagerly load all widgets + * {@link com.vaadin.terminal.gwt.widgetsetutils.EagerWidgetMapGenerator}, + * but if the + * {@link com.vaadin.terminal.gwt.widgetsetutils.WidgetMapGenerator} is used + * by the widgetset, these load style hints are respected. + * <p> + * Lazy loading of a widget implementation means the client side component + * is not included in the initial JavaScript application loaded when the + * application starts. Instead the implementation is loaded to the client + * when it is first needed. Lazy loaded widget can be achieved by giving + * {@link LoadStyle#LAZY} value in {@link Connect} annotation. + * <p> + * Lazy loaded widgets don't stress the size and startup time of the client + * side as much as eagerly loaded widgets. On the other hand there is a + * slight latency when lazy loaded widgets are first used as the client side + * needs to visit the server to fetch the client side implementation. + * <p> + * The {@link LoadStyle#DEFERRED} will also not stress the initially loaded + * JavaScript file. If this load style is defined, the widget implementation + * is preemptively loaded to the browser after the application is started + * and the communication to server idles. This load style kind of combines + * the best of both worlds. + * <p> + * Fine tunings to widget loading can also be made by overriding + * {@link com.vaadin.terminal.gwt.widgetsetutils.WidgetMapGenerator} in the + * GWT module. Tunings might be helpful if the end users have slow + * connections and especially if they have high latency in their network. + * The + * {@link com.vaadin.terminal.gwt.widgetsetutils.CustomWidgetMapGenerator} + * is an abstract generator implementation for easy customization. Vaadin + * package also includes + * {@link com.vaadin.terminal.gwt.widgetsetutils.LazyWidgetMapGenerator} + * that makes as many widgets lazily loaded as possible. + * + * @since 6.4 + * + * @return the hint for the widget set generator how the client side + * implementation should be loaded to the browser + */ + LoadStyle loadStyle() default LoadStyle.DEFERRED; + + public enum LoadStyle { + /** + * The widget is included in the initial JS sent to the client. + */ + EAGER, + /** + * Not included in the initial set of widgets, but added to queue from + * which it will be loaded when network is not busy or the + * implementation is required. + */ + DEFERRED, + /** + * Loaded to the client only if needed. + */ + LAZY + } +} diff --git a/shared/src/com/vaadin/shared/ui/JavaScriptComponentState.java b/shared/src/com/vaadin/shared/ui/JavaScriptComponentState.java new file mode 100644 index 0000000000..d20b4701c2 --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/JavaScriptComponentState.java @@ -0,0 +1,39 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ + +package com.vaadin.shared.ui; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import com.vaadin.shared.ComponentState; +import com.vaadin.shared.JavaScriptConnectorState; + +public class JavaScriptComponentState extends ComponentState implements + JavaScriptConnectorState { + + private Set<String> callbackNames = new HashSet<String>(); + private Map<String, Set<String>> rpcInterfaces = new HashMap<String, Set<String>>(); + + @Override + public Set<String> getCallbackNames() { + return callbackNames; + } + + public void setCallbackNames(Set<String> callbackNames) { + this.callbackNames = callbackNames; + } + + @Override + public Map<String, Set<String>> getRpcInterfaces() { + return rpcInterfaces; + } + + public void setRpcInterfaces(Map<String, Set<String>> rpcInterfaces) { + this.rpcInterfaces = rpcInterfaces; + } + +} diff --git a/shared/src/com/vaadin/shared/ui/LayoutClickRpc.java b/shared/src/com/vaadin/shared/ui/LayoutClickRpc.java new file mode 100644 index 0000000000..48e62083b1 --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/LayoutClickRpc.java @@ -0,0 +1,22 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ +package com.vaadin.shared.ui; + +import com.vaadin.shared.Connector; +import com.vaadin.shared.MouseEventDetails; +import com.vaadin.shared.communication.ServerRpc; + +public interface LayoutClickRpc extends ServerRpc { + /** + * Called when a layout click event has occurred and there are server side + * listeners for the event. + * + * @param mouseDetails + * Details about the mouse when the event took place + * @param clickedConnector + * The child component that was the target of the event + */ + public void layoutClick(MouseEventDetails mouseDetails, + Connector clickedConnector); +}
\ No newline at end of file diff --git a/shared/src/com/vaadin/shared/ui/MediaControl.java b/shared/src/com/vaadin/shared/ui/MediaControl.java new file mode 100644 index 0000000000..0a608a1685 --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/MediaControl.java @@ -0,0 +1,24 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ + +package com.vaadin.shared.ui; + +import com.vaadin.shared.communication.ClientRpc; + +/** + * Server to client RPC interface for controlling playback of the media. + * + * @since 7.0 + */ +public interface MediaControl extends ClientRpc { + /** + * Start playing the media. + */ + public void play(); + + /** + * Pause playback of the media. + */ + public void pause(); +}
\ No newline at end of file diff --git a/shared/src/com/vaadin/shared/ui/TabIndexState.java b/shared/src/com/vaadin/shared/ui/TabIndexState.java new file mode 100644 index 0000000000..774c9b33a0 --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/TabIndexState.java @@ -0,0 +1,29 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ +package com.vaadin.shared.ui; + +/** + * Interface implemented by state classes that support tab indexes. + * + * @author Vaadin Ltd + * @version @VERSION@ + * @since 7.0.0 + * + */ +public interface TabIndexState { + /** + * Gets the <i>tabulator index</i> of the field. + * + * @return the tab index for the Field + */ + public int getTabIndex(); + + /** + * Sets the <i>tabulator index</i> of the field. + * + * @param tabIndex + * the tab index to set + */ + public void setTabIndex(int tabIndex); +} diff --git a/shared/src/com/vaadin/shared/ui/VMarginInfo.java b/shared/src/com/vaadin/shared/ui/VMarginInfo.java new file mode 100644 index 0000000000..b17a03626f --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/VMarginInfo.java @@ -0,0 +1,81 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ + +package com.vaadin.shared.ui; + +import java.io.Serializable; + +@SuppressWarnings("serial") +public class VMarginInfo implements Serializable { + + private static final int TOP = 1; + private static final int RIGHT = 2; + private static final int BOTTOM = 4; + private static final int LEFT = 8; + + private int bitMask; + + public VMarginInfo(int bitMask) { + this.bitMask = bitMask; + } + + public VMarginInfo(boolean top, boolean right, boolean bottom, boolean left) { + setMargins(top, right, bottom, left); + } + + public void setMargins(boolean top, boolean right, boolean bottom, + boolean left) { + bitMask = top ? TOP : 0; + bitMask += right ? RIGHT : 0; + bitMask += bottom ? BOTTOM : 0; + bitMask += left ? LEFT : 0; + } + + public void setMargins(VMarginInfo marginInfo) { + bitMask = marginInfo.bitMask; + } + + public boolean hasLeft() { + return (bitMask & LEFT) == LEFT; + } + + public boolean hasRight() { + return (bitMask & RIGHT) == RIGHT; + } + + public boolean hasTop() { + return (bitMask & TOP) == TOP; + } + + public boolean hasBottom() { + return (bitMask & BOTTOM) == BOTTOM; + } + + public int getBitMask() { + return bitMask; + } + + public void setMargins(boolean enabled) { + if (enabled) { + bitMask = TOP + RIGHT + BOTTOM + LEFT; + } else { + bitMask = 0; + } + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof VMarginInfo)) { + return false; + } + + return ((VMarginInfo) obj).bitMask == bitMask; + } + + @Override + public int hashCode() { + return bitMask; + } + +} diff --git a/shared/src/com/vaadin/shared/ui/absolutelayout/AbsoluteLayoutServerRpc.java b/shared/src/com/vaadin/shared/ui/absolutelayout/AbsoluteLayoutServerRpc.java new file mode 100644 index 0000000000..7d1f75f833 --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/absolutelayout/AbsoluteLayoutServerRpc.java @@ -0,0 +1,11 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ +package com.vaadin.shared.ui.absolutelayout; + +import com.vaadin.shared.communication.ServerRpc; +import com.vaadin.shared.ui.LayoutClickRpc; + +public interface AbsoluteLayoutServerRpc extends LayoutClickRpc, ServerRpc { + +}
\ No newline at end of file diff --git a/shared/src/com/vaadin/shared/ui/absolutelayout/AbsoluteLayoutState.java b/shared/src/com/vaadin/shared/ui/absolutelayout/AbsoluteLayoutState.java new file mode 100644 index 0000000000..f57b2c0d67 --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/absolutelayout/AbsoluteLayoutState.java @@ -0,0 +1,29 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ +package com.vaadin.shared.ui.absolutelayout; + +import java.util.HashMap; +import java.util.Map; + +import com.vaadin.shared.Connector; +import com.vaadin.shared.ui.AbstractLayoutState; + +public class AbsoluteLayoutState extends AbstractLayoutState { + // Maps each component to a position + private Map<String, String> connectorToCssPosition = new HashMap<String, String>(); + + public String getConnectorPosition(Connector connector) { + return connectorToCssPosition.get(connector.getConnectorId()); + } + + public Map<String, String> getConnectorToCssPosition() { + return connectorToCssPosition; + } + + public void setConnectorToCssPosition( + Map<String, String> componentToCssPosition) { + connectorToCssPosition = componentToCssPosition; + } + +}
\ No newline at end of file diff --git a/shared/src/com/vaadin/shared/ui/button/ButtonServerRpc.java b/shared/src/com/vaadin/shared/ui/button/ButtonServerRpc.java new file mode 100644 index 0000000000..0e55b07aea --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/button/ButtonServerRpc.java @@ -0,0 +1,28 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ +package com.vaadin.shared.ui.button; + +import com.vaadin.shared.MouseEventDetails; +import com.vaadin.shared.communication.ServerRpc; + +/** + * RPC interface for calls from client to server. + * + * @since 7.0 + */ +public interface ButtonServerRpc extends ServerRpc { + /** + * Button click event. + * + * @param mouseEventDetails + * serialized mouse event details + */ + public void click(MouseEventDetails mouseEventDetails); + + /** + * Indicate to the server that the client has disabled the button as a + * result of a click. + */ + public void disableOnClick(); +}
\ No newline at end of file diff --git a/shared/src/com/vaadin/shared/ui/button/ButtonState.java b/shared/src/com/vaadin/shared/ui/button/ButtonState.java new file mode 100644 index 0000000000..2bdd24ad3a --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/button/ButtonState.java @@ -0,0 +1,122 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ + +package com.vaadin.shared.ui.button; + +import com.vaadin.shared.ComponentState; +import com.vaadin.shared.ui.TabIndexState; + +/** + * Shared state for {@link com.vaadin.ui.Button} and + * {@link com.vaadin.ui.NativeButton}. + * + * @see ComponentState + * + * @since 7.0 + */ +public class ButtonState extends ComponentState implements TabIndexState { + private boolean disableOnClick = false; + private int clickShortcutKeyCode = 0; + /** + * The tab order number of this field. + */ + private int tabIndex = 0; + /** + * If caption should be rendered in HTML + */ + private boolean htmlContentAllowed = false; + + /** + * Checks whether the button should be disabled on the client side on next + * click. + * + * @return true if the button should be disabled on click + */ + public boolean isDisableOnClick() { + return disableOnClick; + } + + /** + * Sets whether the button should be disabled on the client side on next + * click. + * + * @param disableOnClick + * true if the button should be disabled on click + */ + public void setDisableOnClick(boolean disableOnClick) { + this.disableOnClick = disableOnClick; + } + + /** + * Returns the key code for activating the button via a keyboard shortcut. + * + * See {@link com.vaadin.ui.Button#setClickShortcut(int, int...)} for more + * information. + * + * @return key code or 0 for none + */ + public int getClickShortcutKeyCode() { + return clickShortcutKeyCode; + } + + /** + * Sets the key code for activating the button via a keyboard shortcut. + * + * See {@link com.vaadin.ui.Button#setClickShortcut(int, int...)} for more + * information. + * + * @param clickShortcutKeyCode + * key code or 0 for none + */ + public void setClickShortcutKeyCode(int clickShortcutKeyCode) { + this.clickShortcutKeyCode = clickShortcutKeyCode; + } + + /** + * Set whether the caption text is rendered as HTML or not. You might need + * to retheme button to allow higher content than the original text style. + * + * If set to true, the captions are passed to the browser as html and the + * developer is responsible for ensuring no harmful html is used. If set to + * false, the content is passed to the browser as plain text. + * + * @param htmlContentAllowed + * <code>true</code> if caption is rendered as HTML, + * <code>false</code> otherwise + */ + public void setHtmlContentAllowed(boolean htmlContentAllowed) { + this.htmlContentAllowed = htmlContentAllowed; + } + + /** + * Return HTML rendering setting. + * + * @return <code>true</code> if the caption text is to be rendered as HTML, + * <code>false</code> otherwise + */ + public boolean isHtmlContentAllowed() { + return htmlContentAllowed; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.terminal.gwt.client.ui.TabIndexState#getTabIndex() + */ + @Override + public int getTabIndex() { + return tabIndex; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.terminal.gwt.client.ui.TabIndexState#setTabIndex(int) + */ + @Override + public void setTabIndex(int tabIndex) { + this.tabIndex = tabIndex; + } + +} diff --git a/shared/src/com/vaadin/shared/ui/checkbox/CheckBoxServerRpc.java b/shared/src/com/vaadin/shared/ui/checkbox/CheckBoxServerRpc.java new file mode 100644 index 0000000000..fafd9bf2ff --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/checkbox/CheckBoxServerRpc.java @@ -0,0 +1,11 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ +package com.vaadin.shared.ui.checkbox; + +import com.vaadin.shared.MouseEventDetails; +import com.vaadin.shared.communication.ServerRpc; + +public interface CheckBoxServerRpc extends ServerRpc { + public void setChecked(boolean checked, MouseEventDetails mouseEventDetails); +}
\ No newline at end of file diff --git a/shared/src/com/vaadin/shared/ui/checkbox/CheckBoxState.java b/shared/src/com/vaadin/shared/ui/checkbox/CheckBoxState.java new file mode 100644 index 0000000000..d43959327c --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/checkbox/CheckBoxState.java @@ -0,0 +1,19 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ +package com.vaadin.shared.ui.checkbox; + +import com.vaadin.shared.AbstractFieldState; + +public class CheckBoxState extends AbstractFieldState { + private boolean checked = false; + + public boolean isChecked() { + return checked; + } + + public void setChecked(boolean checked) { + this.checked = checked; + } + +}
\ No newline at end of file diff --git a/shared/src/com/vaadin/shared/ui/csslayout/CssLayoutServerRpc.java b/shared/src/com/vaadin/shared/ui/csslayout/CssLayoutServerRpc.java new file mode 100644 index 0000000000..0672aa32ce --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/csslayout/CssLayoutServerRpc.java @@ -0,0 +1,11 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ +package com.vaadin.shared.ui.csslayout; + +import com.vaadin.shared.communication.ServerRpc; +import com.vaadin.shared.ui.LayoutClickRpc; + +public interface CssLayoutServerRpc extends LayoutClickRpc, ServerRpc { + +}
\ No newline at end of file diff --git a/shared/src/com/vaadin/shared/ui/csslayout/CssLayoutState.java b/shared/src/com/vaadin/shared/ui/csslayout/CssLayoutState.java new file mode 100644 index 0000000000..03b4a947f5 --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/csslayout/CssLayoutState.java @@ -0,0 +1,23 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ +package com.vaadin.shared.ui.csslayout; + +import java.util.HashMap; +import java.util.Map; + +import com.vaadin.shared.Connector; +import com.vaadin.shared.ui.AbstractLayoutState; + +public class CssLayoutState extends AbstractLayoutState { + private Map<Connector, String> childCss = new HashMap<Connector, String>(); + + public Map<Connector, String> getChildCss() { + return childCss; + } + + public void setChildCss(Map<Connector, String> childCss) { + this.childCss = childCss; + } + +}
\ No newline at end of file diff --git a/shared/src/com/vaadin/shared/ui/customlayout/CustomLayoutState.java b/shared/src/com/vaadin/shared/ui/customlayout/CustomLayoutState.java new file mode 100644 index 0000000000..4399e0ece1 --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/customlayout/CustomLayoutState.java @@ -0,0 +1,41 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ +package com.vaadin.shared.ui.customlayout; + +import java.util.HashMap; +import java.util.Map; + +import com.vaadin.shared.Connector; +import com.vaadin.shared.ui.AbstractLayoutState; + +public class CustomLayoutState extends AbstractLayoutState { + Map<Connector, String> childLocations = new HashMap<Connector, String>(); + private String templateContents; + private String templateName; + + public String getTemplateContents() { + return templateContents; + } + + public void setTemplateContents(String templateContents) { + this.templateContents = templateContents; + } + + public String getTemplateName() { + return templateName; + } + + public void setTemplateName(String templateName) { + this.templateName = templateName; + } + + public Map<Connector, String> getChildLocations() { + return childLocations; + } + + public void setChildLocations(Map<Connector, String> childLocations) { + this.childLocations = childLocations; + } + +}
\ No newline at end of file diff --git a/shared/src/com/vaadin/shared/ui/dd/AcceptCriterion.java b/shared/src/com/vaadin/shared/ui/dd/AcceptCriterion.java new file mode 100644 index 0000000000..4867e6b03f --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/dd/AcceptCriterion.java @@ -0,0 +1,33 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ + +package com.vaadin.shared.ui.dd; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * An annotation type used to point the server side counterpart for client side + * a {@link com.vaadin.terminal.gwt.client.ui.dd.VAcceptCriterion} class. + * <p> + * Annotations are used at GWT compilation phase, so remember to rebuild your + * widgetset if you do changes for {@link AcceptCriterion} mappings. + * + * Prior to Vaadin 7, the mapping was done with an annotation on server side + * classes. + * + * @since 7.0 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +public @interface AcceptCriterion { + /** + * @return the class of the server side counterpart for the annotated + * criterion + */ + Class<?> value(); + +} diff --git a/shared/src/com/vaadin/shared/ui/dd/DragEventType.java b/shared/src/com/vaadin/shared/ui/dd/DragEventType.java new file mode 100644 index 0000000000..e03b347ada --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/dd/DragEventType.java @@ -0,0 +1,9 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ + +package com.vaadin.shared.ui.dd; + +public enum DragEventType { + ENTER, LEAVE, OVER, DROP +}
\ No newline at end of file diff --git a/shared/src/com/vaadin/shared/ui/dd/HorizontalDropLocation.java b/shared/src/com/vaadin/shared/ui/dd/HorizontalDropLocation.java new file mode 100644 index 0000000000..065b880953 --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/dd/HorizontalDropLocation.java @@ -0,0 +1,8 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ +package com.vaadin.shared.ui.dd; + +public enum HorizontalDropLocation { + LEFT, RIGHT, CENTER +} diff --git a/shared/src/com/vaadin/shared/ui/dd/VerticalDropLocation.java b/shared/src/com/vaadin/shared/ui/dd/VerticalDropLocation.java new file mode 100644 index 0000000000..2658921124 --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/dd/VerticalDropLocation.java @@ -0,0 +1,8 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ +package com.vaadin.shared.ui.dd; + +public enum VerticalDropLocation { + TOP, BOTTOM, MIDDLE +} diff --git a/shared/src/com/vaadin/shared/ui/embedded/EmbeddedServerRpc.java b/shared/src/com/vaadin/shared/ui/embedded/EmbeddedServerRpc.java new file mode 100644 index 0000000000..27af1623b0 --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/embedded/EmbeddedServerRpc.java @@ -0,0 +1,10 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ +package com.vaadin.shared.ui.embedded; + +import com.vaadin.shared.communication.ServerRpc; +import com.vaadin.shared.ui.ClickRpc; + +public interface EmbeddedServerRpc extends ClickRpc, ServerRpc { +}
\ No newline at end of file diff --git a/shared/src/com/vaadin/shared/ui/form/FormState.java b/shared/src/com/vaadin/shared/ui/form/FormState.java new file mode 100644 index 0000000000..a3035491bf --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/form/FormState.java @@ -0,0 +1,29 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ +package com.vaadin.shared.ui.form; + +import com.vaadin.shared.AbstractFieldState; +import com.vaadin.shared.Connector; + +public class FormState extends AbstractFieldState { + private Connector layout; + private Connector footer; + + public Connector getLayout() { + return layout; + } + + public void setLayout(Connector layout) { + this.layout = layout; + } + + public Connector getFooter() { + return footer; + } + + public void setFooter(Connector footer) { + this.footer = footer; + } + +}
\ No newline at end of file diff --git a/shared/src/com/vaadin/shared/ui/gridlayout/GridLayoutServerRpc.java b/shared/src/com/vaadin/shared/ui/gridlayout/GridLayoutServerRpc.java new file mode 100644 index 0000000000..110b9c33f9 --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/gridlayout/GridLayoutServerRpc.java @@ -0,0 +1,11 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ +package com.vaadin.shared.ui.gridlayout; + +import com.vaadin.shared.communication.ServerRpc; +import com.vaadin.shared.ui.LayoutClickRpc; + +public interface GridLayoutServerRpc extends LayoutClickRpc, ServerRpc { + +}
\ No newline at end of file diff --git a/shared/src/com/vaadin/shared/ui/gridlayout/GridLayoutState.java b/shared/src/com/vaadin/shared/ui/gridlayout/GridLayoutState.java new file mode 100644 index 0000000000..9179a61d27 --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/gridlayout/GridLayoutState.java @@ -0,0 +1,37 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ +package com.vaadin.shared.ui.gridlayout; + +import com.vaadin.shared.ui.AbstractLayoutState; + +public class GridLayoutState extends AbstractLayoutState { + private boolean spacing = false; + private int rows = 0; + private int columns = 0; + + public boolean isSpacing() { + return spacing; + } + + public void setSpacing(boolean spacing) { + this.spacing = spacing; + } + + public int getRows() { + return rows; + } + + public void setRows(int rows) { + this.rows = rows; + } + + public int getColumns() { + return columns; + } + + public void setColumns(int cols) { + columns = cols; + } + +}
\ No newline at end of file diff --git a/shared/src/com/vaadin/shared/ui/label/ContentMode.java b/shared/src/com/vaadin/shared/ui/label/ContentMode.java new file mode 100644 index 0000000000..a58f2cdebb --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/label/ContentMode.java @@ -0,0 +1,46 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ +package com.vaadin.shared.ui.label; + +/** + * Content modes defining how the client should interpret a Label's value. + * + * @since 7.0.0 + */ +public enum ContentMode { + /** + * Content mode, where the label contains only plain text. + */ + TEXT, + + /** + * Content mode, where the label contains pre formatted text. In this mode + * newlines are preserved when rendered on the screen. + */ + PREFORMATTED, + + /** + * Content mode, where the label contains XHTML. Care should be taken to + * ensure + */ + XHTML, + + /** + * Content mode, where the label contains well-formed or well-balanced XML. + * This is handled in the same way as {@link #XHTML}. + * + * @deprecated Use {@link #XHTML} instead + */ + @Deprecated + XML, + + /** + * Legacy content mode, where the label contains RAW output. This is handled + * in exactly the same way as {@link #XHTML}. + * + * @deprecated Use {@link #XHTML} instead + */ + @Deprecated + RAW; +} diff --git a/shared/src/com/vaadin/shared/ui/label/LabelState.java b/shared/src/com/vaadin/shared/ui/label/LabelState.java new file mode 100644 index 0000000000..0298e40179 --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/label/LabelState.java @@ -0,0 +1,28 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ +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; + } + +} diff --git a/shared/src/com/vaadin/shared/ui/orderedlayout/AbstractOrderedLayoutServerRpc.java b/shared/src/com/vaadin/shared/ui/orderedlayout/AbstractOrderedLayoutServerRpc.java new file mode 100644 index 0000000000..3de8ec0220 --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/orderedlayout/AbstractOrderedLayoutServerRpc.java @@ -0,0 +1,12 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ +package com.vaadin.shared.ui.orderedlayout; + +import com.vaadin.shared.communication.ServerRpc; +import com.vaadin.shared.ui.LayoutClickRpc; + +public interface AbstractOrderedLayoutServerRpc extends LayoutClickRpc, + ServerRpc { + +}
\ No newline at end of file diff --git a/shared/src/com/vaadin/shared/ui/orderedlayout/AbstractOrderedLayoutState.java b/shared/src/com/vaadin/shared/ui/orderedlayout/AbstractOrderedLayoutState.java new file mode 100644 index 0000000000..c18a128912 --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/orderedlayout/AbstractOrderedLayoutState.java @@ -0,0 +1,56 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ +package com.vaadin.shared.ui.orderedlayout; + +import java.io.Serializable; +import java.util.HashMap; + +import com.vaadin.shared.Connector; +import com.vaadin.shared.ui.AbstractLayoutState; +import com.vaadin.shared.ui.AlignmentInfo; + +public class AbstractOrderedLayoutState extends AbstractLayoutState { + private boolean spacing = false; + + public HashMap<Connector, ChildComponentData> childData = new HashMap<Connector, ChildComponentData>(); + + public static class ChildComponentData implements Serializable { + private int alignmentBitmask = AlignmentInfo.TOP_LEFT.getBitMask(); + private float expandRatio = 0.0f; + + public int getAlignmentBitmask() { + return alignmentBitmask; + } + + public void setAlignmentBitmask(int alignmentBitmask) { + this.alignmentBitmask = alignmentBitmask; + } + + public float getExpandRatio() { + return expandRatio; + } + + public void setExpandRatio(float expandRatio) { + this.expandRatio = expandRatio; + } + + } + + public HashMap<Connector, ChildComponentData> getChildData() { + return childData; + } + + public void setChildData(HashMap<Connector, ChildComponentData> childData) { + this.childData = childData; + } + + public boolean isSpacing() { + return spacing; + } + + public void setSpacing(boolean spacing) { + this.spacing = spacing; + } + +}
\ No newline at end of file diff --git a/shared/src/com/vaadin/shared/ui/panel/PanelServerRpc.java b/shared/src/com/vaadin/shared/ui/panel/PanelServerRpc.java new file mode 100644 index 0000000000..6ed4652070 --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/panel/PanelServerRpc.java @@ -0,0 +1,11 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ +package com.vaadin.shared.ui.panel; + +import com.vaadin.shared.communication.ServerRpc; +import com.vaadin.shared.ui.ClickRpc; + +public interface PanelServerRpc extends ClickRpc, ServerRpc { + +}
\ No newline at end of file diff --git a/shared/src/com/vaadin/shared/ui/panel/PanelState.java b/shared/src/com/vaadin/shared/ui/panel/PanelState.java new file mode 100644 index 0000000000..ed31ed1ea3 --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/panel/PanelState.java @@ -0,0 +1,36 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ +package com.vaadin.shared.ui.panel; + +import com.vaadin.shared.ComponentState; + +public class PanelState extends ComponentState { + private int tabIndex; + private int scrollLeft, scrollTop; + + public int getTabIndex() { + return tabIndex; + } + + public void setTabIndex(int tabIndex) { + this.tabIndex = tabIndex; + } + + public int getScrollLeft() { + return scrollLeft; + } + + public void setScrollLeft(int scrollLeft) { + this.scrollLeft = scrollLeft; + } + + public int getScrollTop() { + return scrollTop; + } + + public void setScrollTop(int scrollTop) { + this.scrollTop = scrollTop; + } + +}
\ No newline at end of file diff --git a/shared/src/com/vaadin/shared/ui/root/PageClientRpc.java b/shared/src/com/vaadin/shared/ui/root/PageClientRpc.java new file mode 100644 index 0000000000..c7d587938d --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/root/PageClientRpc.java @@ -0,0 +1,13 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ + +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/RootServerRpc.java b/shared/src/com/vaadin/shared/ui/root/RootServerRpc.java new file mode 100644 index 0000000000..2e670553b8 --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/root/RootServerRpc.java @@ -0,0 +1,11 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ +package com.vaadin.shared.ui.root; + +import com.vaadin.shared.communication.ServerRpc; +import com.vaadin.shared.ui.ClickRpc; + +public interface RootServerRpc extends ClickRpc, ServerRpc { + +}
\ 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 new file mode 100644 index 0000000000..26844cba32 --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/root/RootState.java @@ -0,0 +1,20 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ +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/splitpanel/AbstractSplitPanelRpc.java b/shared/src/com/vaadin/shared/ui/splitpanel/AbstractSplitPanelRpc.java new file mode 100644 index 0000000000..e2ebcb0de3 --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/splitpanel/AbstractSplitPanelRpc.java @@ -0,0 +1,28 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ +package com.vaadin.shared.ui.splitpanel; + +import com.vaadin.shared.MouseEventDetails; +import com.vaadin.shared.communication.ServerRpc; + +public interface AbstractSplitPanelRpc extends ServerRpc { + + /** + * Called when the position has been updated by the user. + * + * @param position + * The new position in % if the current unit is %, in px + * otherwise + */ + public void setSplitterPosition(float position); + + /** + * Called when a click event has occurred on the splitter. + * + * @param mouseDetails + * Details about the mouse when the event took place + */ + public void splitterClick(MouseEventDetails mouseDetails); + +}
\ No newline at end of file diff --git a/shared/src/com/vaadin/shared/ui/splitpanel/AbstractSplitPanelState.java b/shared/src/com/vaadin/shared/ui/splitpanel/AbstractSplitPanelState.java new file mode 100644 index 0000000000..d94d5d8608 --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/splitpanel/AbstractSplitPanelState.java @@ -0,0 +1,124 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ +package com.vaadin.shared.ui.splitpanel; + +import java.io.Serializable; + +import com.vaadin.shared.ComponentState; +import com.vaadin.shared.Connector; + +public class AbstractSplitPanelState extends ComponentState { + + private Connector firstChild = null; + private Connector secondChild = null; + private SplitterState splitterState = new SplitterState(); + + public boolean hasFirstChild() { + return firstChild != null; + } + + public boolean hasSecondChild() { + return secondChild != null; + } + + public Connector getFirstChild() { + return firstChild; + } + + public void setFirstChild(Connector firstChild) { + this.firstChild = firstChild; + } + + public Connector getSecondChild() { + return secondChild; + } + + public void setSecondChild(Connector secondChild) { + this.secondChild = secondChild; + } + + public SplitterState getSplitterState() { + return splitterState; + } + + public void setSplitterState(SplitterState splitterState) { + this.splitterState = splitterState; + } + + public static class SplitterState implements Serializable { + private float position; + private String positionUnit; + private float minPosition; + private String minPositionUnit; + private float maxPosition; + private String maxPositionUnit; + private boolean positionReversed = false; + private boolean locked = false; + + public float getPosition() { + return position; + } + + public void setPosition(float position) { + this.position = position; + } + + public String getPositionUnit() { + return positionUnit; + } + + public void setPositionUnit(String positionUnit) { + this.positionUnit = positionUnit; + } + + public float getMinPosition() { + return minPosition; + } + + public void setMinPosition(float minPosition) { + this.minPosition = minPosition; + } + + public String getMinPositionUnit() { + return minPositionUnit; + } + + public void setMinPositionUnit(String minPositionUnit) { + this.minPositionUnit = minPositionUnit; + } + + public float getMaxPosition() { + return maxPosition; + } + + public void setMaxPosition(float maxPosition) { + this.maxPosition = maxPosition; + } + + public String getMaxPositionUnit() { + return maxPositionUnit; + } + + public void setMaxPositionUnit(String maxPositionUnit) { + this.maxPositionUnit = maxPositionUnit; + } + + public boolean isPositionReversed() { + return positionReversed; + } + + public void setPositionReversed(boolean positionReversed) { + this.positionReversed = positionReversed; + } + + public boolean isLocked() { + return locked; + } + + public void setLocked(boolean locked) { + this.locked = locked; + } + + } +}
\ No newline at end of file diff --git a/shared/src/com/vaadin/shared/ui/textarea/TextAreaState.java b/shared/src/com/vaadin/shared/ui/textarea/TextAreaState.java new file mode 100644 index 0000000000..3b3bd42f87 --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/textarea/TextAreaState.java @@ -0,0 +1,36 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ +package com.vaadin.shared.ui.textarea; + +import com.vaadin.shared.ui.textfield.AbstractTextFieldState; + +public class TextAreaState extends AbstractTextFieldState { + + /** + * Number of visible rows in the text area. The default is 5. + */ + private int rows = 5; + + /** + * Tells if word-wrapping should be used in the text area. + */ + private boolean wordwrap = true; + + public int getRows() { + return rows; + } + + public void setRows(int rows) { + this.rows = rows; + } + + public boolean isWordwrap() { + return wordwrap; + } + + public void setWordwrap(boolean wordwrap) { + this.wordwrap = wordwrap; + } + +} diff --git a/shared/src/com/vaadin/shared/ui/textfield/AbstractTextFieldState.java b/shared/src/com/vaadin/shared/ui/textfield/AbstractTextFieldState.java new file mode 100644 index 0000000000..d980eccae2 --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/textfield/AbstractTextFieldState.java @@ -0,0 +1,61 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ +package com.vaadin.shared.ui.textfield; + +import com.vaadin.shared.AbstractFieldState; + +public class AbstractTextFieldState extends AbstractFieldState { + /** + * Maximum character count in text field. + */ + private int maxLength = -1; + + /** + * Number of visible columns in the TextField. + */ + private int columns = 0; + + /** + * The prompt to display in an empty field. Null when disabled. + */ + private String inputPrompt = null; + + /** + * The text in the field + */ + private String text = null; + + public int getMaxLength() { + return maxLength; + } + + public void setMaxLength(int maxLength) { + this.maxLength = maxLength; + } + + public int getColumns() { + return columns; + } + + public void setColumns(int columns) { + this.columns = columns; + } + + public String getInputPrompt() { + return inputPrompt; + } + + public void setInputPrompt(String inputPrompt) { + this.inputPrompt = inputPrompt; + } + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + +} diff --git a/shared/src/com/vaadin/shared/ui/video/VideoState.java b/shared/src/com/vaadin/shared/ui/video/VideoState.java new file mode 100644 index 0000000000..1dc8d07b7c --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/video/VideoState.java @@ -0,0 +1,20 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ +package com.vaadin.shared.ui.video; + +import com.vaadin.shared.communication.URLReference; +import com.vaadin.shared.ui.AbstractMediaState; + +public class VideoState extends AbstractMediaState { + private URLReference poster; + + public URLReference getPoster() { + return poster; + } + + public void setPoster(URLReference poster) { + this.poster = poster; + } + +} diff --git a/shared/src/com/vaadin/shared/ui/window/WindowServerRpc.java b/shared/src/com/vaadin/shared/ui/window/WindowServerRpc.java new file mode 100644 index 0000000000..11abfae4be --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/window/WindowServerRpc.java @@ -0,0 +1,10 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ +package com.vaadin.shared.ui.window; + +import com.vaadin.shared.communication.ServerRpc; +import com.vaadin.shared.ui.ClickRpc; + +public interface WindowServerRpc extends ClickRpc, ServerRpc { +}
\ No newline at end of file diff --git a/shared/src/com/vaadin/shared/ui/window/WindowState.java b/shared/src/com/vaadin/shared/ui/window/WindowState.java new file mode 100644 index 0000000000..428bd75167 --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/window/WindowState.java @@ -0,0 +1,73 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ +package com.vaadin.shared.ui.window; + +import com.vaadin.shared.ui.panel.PanelState; + +public class WindowState extends PanelState { + private boolean modal = false; + private boolean resizable = true; + private boolean resizeLazy = false; + private boolean draggable = true; + private boolean centered = false;; + private int positionX = -1; + private int positionY = -1; + + public boolean isModal() { + return modal; + } + + public void setModal(boolean modal) { + this.modal = modal; + } + + public boolean isResizable() { + return resizable; + } + + public void setResizable(boolean resizable) { + this.resizable = resizable; + } + + public boolean isResizeLazy() { + return resizeLazy; + } + + public void setResizeLazy(boolean resizeLazy) { + this.resizeLazy = resizeLazy; + } + + public boolean isDraggable() { + return draggable; + } + + public void setDraggable(boolean draggable) { + this.draggable = draggable; + } + + public boolean isCentered() { + return centered; + } + + public void setCentered(boolean centered) { + this.centered = centered; + } + + public int getPositionX() { + return positionX; + } + + public void setPositionX(int positionX) { + this.positionX = positionX; + } + + public int getPositionY() { + return positionY; + } + + public void setPositionY(int positionY) { + this.positionY = positionY; + } + +}
\ No newline at end of file |