From dac974af9bc73491d8818581821a2c99458f71a2 Mon Sep 17 00:00:00 2001 From: John Ahlroos Date: Fri, 31 Aug 2012 12:27:45 +0300 Subject: Removed getters/setters from states and made instance variabled public --- .../src/com/vaadin/shared/AbstractFieldState.java | 129 +------- shared/src/com/vaadin/shared/ComponentState.java | 356 +-------------------- .../vaadin/shared/communication/SharedState.java | 26 +- .../vaadin/shared/ui/AbstractEmbeddedState.java | 11 +- .../com/vaadin/shared/ui/ComponentStateUtil.java | 52 +++ shared/src/com/vaadin/shared/ui/TabIndexState.java | 18 +- .../ui/absolutelayout/AbsoluteLayoutState.java | 19 +- .../com/vaadin/shared/ui/button/ButtonState.java | 105 +----- .../vaadin/shared/ui/checkbox/CheckBoxState.java | 12 +- .../vaadin/shared/ui/csslayout/CssLayoutState.java | 13 +- .../shared/ui/customlayout/CustomLayoutState.java | 33 +- .../src/com/vaadin/shared/ui/flash/FlashState.java | 60 +--- .../src/com/vaadin/shared/ui/form/FormState.java | 23 +- .../shared/ui/gridlayout/GridLayoutState.java | 43 +-- .../orderedlayout/AbstractOrderedLayoutState.java | 52 +-- .../src/com/vaadin/shared/ui/panel/PanelState.java | 31 +- .../com/vaadin/shared/ui/slider/SliderState.java | 50 +-- .../ui/splitpanel/AbstractSplitPanelState.java | 121 +------ .../vaadin/shared/ui/textarea/TextAreaState.java | 22 +- .../ui/textfield/AbstractTextFieldState.java | 41 +-- shared/src/com/vaadin/shared/ui/ui/UIState.java | 13 +- .../com/vaadin/shared/ui/window/WindowState.java | 73 +---- 22 files changed, 150 insertions(+), 1153 deletions(-) create mode 100644 shared/src/com/vaadin/shared/ui/ComponentStateUtil.java (limited to 'shared') diff --git a/shared/src/com/vaadin/shared/AbstractFieldState.java b/shared/src/com/vaadin/shared/AbstractFieldState.java index 02cbd16a6f..37f8599bbf 100644 --- a/shared/src/com/vaadin/shared/AbstractFieldState.java +++ b/shared/src/com/vaadin/shared/AbstractFieldState.java @@ -24,128 +24,9 @@ import com.vaadin.shared.ui.TabIndexState; * @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 true if the field is required, otherwise - * false. - */ - 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.client.ComponentState#getTabIndex() - */ - @Override - public int getTabIndex() { - return tabIndex; - } - - /* - * (non-Javadoc) - * - * @see com.vaadin.client.ui.TabIndexState#setTabIndex(int) - */ - @Override - public void setTabIndex(int tabIndex) { - this.tabIndex = tabIndex; - } - +public class AbstractFieldState extends TabIndexState { + public boolean propertyReadOnly = false; + public boolean hideErrors = false; + public boolean required = false; + public boolean modified = false; } diff --git a/shared/src/com/vaadin/shared/ComponentState.java b/shared/src/com/vaadin/shared/ComponentState.java index 898114e1db..55a26a8e0f 100644 --- a/shared/src/com/vaadin/shared/ComponentState.java +++ b/shared/src/com/vaadin/shared/ComponentState.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2011 Vaadin Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not @@ -16,7 +16,6 @@ package com.vaadin.shared; -import java.util.HashSet; import java.util.List; import java.util.Set; @@ -30,354 +29,25 @@ import com.vaadin.shared.communication.SharedState; * @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 = ""; + public String height = ""; + public String width = ""; + public boolean readOnly = false; + public boolean immediate = false; + public 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 List styles = null; - private String id = null; + public String caption = null; + public boolean visible = true; + public List styles = null; + public String id = null; /** * A set of event identifiers with registered listeners. */ - private Set registeredEventListeners = null; + public Set 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; + public 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.server.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.server.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; - } - - /** - * Gets the style names for the component. - * - * @return A List of style names or null if no styles have been set. - */ - public List getStyles() { - return styles; - } - - /** - * Sets the style names for the component. - * - * @param styles - * A list containing style names - */ - public void setStyles(List styles) { - this.styles = styles; - } - - /** - * Gets the id for the component. The id is added as DOM id for the - * component. - * - * @return The id for the component or null if not set - */ - public String getId() { - return id; - } - - /** - * Sets the id for the component. The id is added as DOM id for the - * component. - * - * @param id - * The new id for the component or null for no id - * - */ - public void setId(String id) { - this.id = id; - } - - /** - * 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 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 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(); - } - 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; - } - -} +} \ No newline at end of file diff --git a/shared/src/com/vaadin/shared/communication/SharedState.java b/shared/src/com/vaadin/shared/communication/SharedState.java index 09147ac97d..4473eba7a0 100644 --- a/shared/src/com/vaadin/shared/communication/SharedState.java +++ b/shared/src/com/vaadin/shared/communication/SharedState.java @@ -59,29 +59,5 @@ public class SharedState implements Serializable { */ public Map resources = new HashMap(); - 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; - } - + public boolean enabled = true; } diff --git a/shared/src/com/vaadin/shared/ui/AbstractEmbeddedState.java b/shared/src/com/vaadin/shared/ui/AbstractEmbeddedState.java index 6422b643ad..608152cc54 100644 --- a/shared/src/com/vaadin/shared/ui/AbstractEmbeddedState.java +++ b/shared/src/com/vaadin/shared/ui/AbstractEmbeddedState.java @@ -6,14 +6,5 @@ public class AbstractEmbeddedState extends ComponentState { public static final String SOURCE_RESOURCE = "source"; - private String alternateText; - - public String getAlternateText() { - return alternateText; - } - - public void setAlternateText(String alternateText) { - this.alternateText = alternateText; - } - + public String alternateText; } diff --git a/shared/src/com/vaadin/shared/ui/ComponentStateUtil.java b/shared/src/com/vaadin/shared/ui/ComponentStateUtil.java new file mode 100644 index 0000000000..556c46518f --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/ComponentStateUtil.java @@ -0,0 +1,52 @@ +package com.vaadin.shared.ui; + +import java.util.HashSet; + +import com.vaadin.shared.ComponentState; + +public final class ComponentStateUtil { + + private ComponentStateUtil() { + // Util class is not instantiable + } + + public static final boolean isUndefinedWidth(ComponentState state) { + return state.width == null || "".equals(state.width); + } + + public static final boolean isUndefinedHeight(ComponentState state) { + return state.height == null || "".equals(state.height); + } + + /** + * Removes an event listener id. + * + * @param eventListenerId + * The event identifier to remove + */ + public static final void removeRegisteredEventListener( + ComponentState state, + String eventIdentifier) { + if (state.registeredEventListeners == null) { + return; + } + state.registeredEventListeners.remove(eventIdentifier); + if (state.registeredEventListeners.size() == 0) { + state.registeredEventListeners = null; + } + } + + /** + * Adds an event listener id. + * + * @param eventListenerId + * The event identifier to add + */ + public static final void addRegisteredEventListener(ComponentState state, + String eventListenerId) { + if (state.registeredEventListeners == null) { + state.registeredEventListeners = new HashSet(); + } + state.registeredEventListeners.add(eventListenerId); + } +} diff --git a/shared/src/com/vaadin/shared/ui/TabIndexState.java b/shared/src/com/vaadin/shared/ui/TabIndexState.java index 5f17b9b016..a9cb56e5ed 100644 --- a/shared/src/com/vaadin/shared/ui/TabIndexState.java +++ b/shared/src/com/vaadin/shared/ui/TabIndexState.java @@ -15,6 +15,8 @@ */ package com.vaadin.shared.ui; +import com.vaadin.shared.ComponentState; + /** * Interface implemented by state classes that support tab indexes. * @@ -22,19 +24,11 @@ package com.vaadin.shared.ui; * @since 7.0.0 * */ -public interface TabIndexState { - /** - * Gets the tabulator index of the field. - * - * @return the tab index for the Field - */ - public int getTabIndex(); +public class TabIndexState extends ComponentState { /** - * Sets the tabulator index of the field. - * - * @param tabIndex - * the tab index to set + * The tabulator index of the field. */ - public void setTabIndex(int tabIndex); + public int tabIndex = 0; + } diff --git a/shared/src/com/vaadin/shared/ui/absolutelayout/AbsoluteLayoutState.java b/shared/src/com/vaadin/shared/ui/absolutelayout/AbsoluteLayoutState.java index a0e0f4d3c7..283e827e6e 100644 --- a/shared/src/com/vaadin/shared/ui/absolutelayout/AbsoluteLayoutState.java +++ b/shared/src/com/vaadin/shared/ui/absolutelayout/AbsoluteLayoutState.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2011 Vaadin Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not @@ -18,24 +18,9 @@ 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 connectorToCssPosition = new HashMap(); - - public String getConnectorPosition(Connector connector) { - return connectorToCssPosition.get(connector.getConnectorId()); - } - - public Map getConnectorToCssPosition() { - return connectorToCssPosition; - } - - public void setConnectorToCssPosition( - Map componentToCssPosition) { - connectorToCssPosition = componentToCssPosition; - } - + public Map connectorToCssPosition = new HashMap(); } \ 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 index 2383b038bd..c144a8124f 100644 --- a/shared/src/com/vaadin/shared/ui/button/ButtonState.java +++ b/shared/src/com/vaadin/shared/ui/button/ButtonState.java @@ -27,108 +27,11 @@ import com.vaadin.shared.ui.TabIndexState; * * @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; +public class ButtonState extends TabIndexState { + public boolean disableOnClick = false; + public int clickShortcutKeyCode = 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 - * true if caption is rendered as HTML, - * false otherwise - */ - public void setHtmlContentAllowed(boolean htmlContentAllowed) { - this.htmlContentAllowed = htmlContentAllowed; - } - - /** - * Return HTML rendering setting. - * - * @return true if the caption text is to be rendered as HTML, - * false otherwise - */ - public boolean isHtmlContentAllowed() { - return htmlContentAllowed; - } - - /* - * (non-Javadoc) - * - * @see com.vaadin.client.ui.TabIndexState#getTabIndex() - */ - @Override - public int getTabIndex() { - return tabIndex; - } - - /* - * (non-Javadoc) - * - * @see com.vaadin.client.ui.TabIndexState#setTabIndex(int) - */ - @Override - public void setTabIndex(int tabIndex) { - this.tabIndex = tabIndex; - } - + public boolean htmlContentAllowed = false; } diff --git a/shared/src/com/vaadin/shared/ui/checkbox/CheckBoxState.java b/shared/src/com/vaadin/shared/ui/checkbox/CheckBoxState.java index 1f48b8fe9e..b89270bee2 100644 --- a/shared/src/com/vaadin/shared/ui/checkbox/CheckBoxState.java +++ b/shared/src/com/vaadin/shared/ui/checkbox/CheckBoxState.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2011 Vaadin Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not @@ -18,14 +18,6 @@ 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; - } + public boolean checked = false; } \ 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 index fc230a8e2f..2fbc42ca0f 100644 --- a/shared/src/com/vaadin/shared/ui/csslayout/CssLayoutState.java +++ b/shared/src/com/vaadin/shared/ui/csslayout/CssLayoutState.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2011 Vaadin Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not @@ -22,14 +22,5 @@ import com.vaadin.shared.Connector; import com.vaadin.shared.ui.AbstractLayoutState; public class CssLayoutState extends AbstractLayoutState { - private Map childCss = new HashMap(); - - public Map getChildCss() { - return childCss; - } - - public void setChildCss(Map childCss) { - this.childCss = childCss; - } - + public Map childCss = new HashMap(); } \ 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 index 0c1aa24161..e77ea5c068 100644 --- a/shared/src/com/vaadin/shared/ui/customlayout/CustomLayoutState.java +++ b/shared/src/com/vaadin/shared/ui/customlayout/CustomLayoutState.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2011 Vaadin Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not @@ -22,32 +22,7 @@ import com.vaadin.shared.Connector; import com.vaadin.shared.ui.AbstractLayoutState; public class CustomLayoutState extends AbstractLayoutState { - Map childLocations = new HashMap(); - 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 getChildLocations() { - return childLocations; - } - - public void setChildLocations(Map childLocations) { - this.childLocations = childLocations; - } - + public Map childLocations = new HashMap(); + public String templateContents; + public String templateName; } \ No newline at end of file diff --git a/shared/src/com/vaadin/shared/ui/flash/FlashState.java b/shared/src/com/vaadin/shared/ui/flash/FlashState.java index 2d33d1a711..50f0d63733 100644 --- a/shared/src/com/vaadin/shared/ui/flash/FlashState.java +++ b/shared/src/com/vaadin/shared/ui/flash/FlashState.java @@ -6,63 +6,15 @@ import com.vaadin.shared.ui.AbstractEmbeddedState; public class FlashState extends AbstractEmbeddedState { - protected String classId; + public String classId; - protected String codebase; + public String codebase; - protected String codetype; + public String codetype; - protected String archive; + public String archive; - protected String standby; + public String standby; - protected Map embedParams; - - public String getClassId() { - return classId; - } - - public void setClassId(String classId) { - this.classId = classId; - } - - public String getCodebase() { - return codebase; - } - - public void setCodebase(String codeBase) { - codebase = codebase; - } - - public String getCodetype() { - return codetype; - } - - public void setCodetype(String codetype) { - this.codetype = codetype; - } - - public String getArchive() { - return archive; - } - - public void setArchive(String archive) { - this.archive = archive; - } - - public String getStandby() { - return standby; - } - - public void setStandby(String standby) { - this.standby = standby; - } - - public Map getEmbedParams() { - return embedParams; - } - - public void setEmbedParams(Map embedParams) { - this.embedParams = embedParams; - } + public Map embedParams; } diff --git a/shared/src/com/vaadin/shared/ui/form/FormState.java b/shared/src/com/vaadin/shared/ui/form/FormState.java index 7e8b36707a..f0e79ad38f 100644 --- a/shared/src/com/vaadin/shared/ui/form/FormState.java +++ b/shared/src/com/vaadin/shared/ui/form/FormState.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2011 Vaadin Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not @@ -19,23 +19,6 @@ 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; - } - + public Connector layout; + public Connector footer; } \ 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 index 381a6a7f85..ae54dc3765 100644 --- a/shared/src/com/vaadin/shared/ui/gridlayout/GridLayoutState.java +++ b/shared/src/com/vaadin/shared/ui/gridlayout/GridLayoutState.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2011 Vaadin Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not @@ -18,41 +18,8 @@ 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; - private int marginsBitmask = 0; - - public boolean isSpacing() { - return spacing; - } - - public void setSpacing(boolean spacing) { - this.spacing = spacing; - } - - public int getMarginsBitmask() { - return marginsBitmask; - } - - public void setMarginsBitmask(int marginsBitmask) { - this.marginsBitmask = marginsBitmask; - } - - 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; - } - + public boolean spacing = false; + public int rows = 0; + public int columns = 0; + public int marginsBitmask = 0; } \ 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 index 35456ab9ac..27ab6ac8e0 100644 --- a/shared/src/com/vaadin/shared/ui/orderedlayout/AbstractOrderedLayoutState.java +++ b/shared/src/com/vaadin/shared/ui/orderedlayout/AbstractOrderedLayoutState.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2011 Vaadin Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not @@ -23,56 +23,16 @@ import com.vaadin.shared.ui.AbstractLayoutState; import com.vaadin.shared.ui.AlignmentInfo; public class AbstractOrderedLayoutState extends AbstractLayoutState { - private boolean spacing = false; + public boolean spacing = false; - private HashMap childData = new HashMap(); + public HashMap childData = new HashMap(); - private int marginsBitmask = 0; + public int marginsBitmask = 0; public static class ChildComponentData implements Serializable { - private int alignmentBitmask = AlignmentInfo.TOP_LEFT.getBitMask(); - private float expandRatio = 0.0f; - public int getAlignmentBitmask() { - return alignmentBitmask; - } + public int alignmentBitmask = AlignmentInfo.TOP_LEFT.getBitMask(); - public void setAlignmentBitmask(int alignmentBitmask) { - this.alignmentBitmask = alignmentBitmask; - } - - public float getExpandRatio() { - return expandRatio; - } - - public void setExpandRatio(float expandRatio) { - this.expandRatio = expandRatio; - } - - } - - public HashMap getChildData() { - return childData; - } - - public void setChildData(HashMap childData) { - this.childData = childData; - } - - public boolean isSpacing() { - return spacing; - } - - public void setSpacing(boolean spacing) { - this.spacing = spacing; - } - - public int getMarginsBitmask() { - return marginsBitmask; - } - - public void setMarginsBitmask(int marginsBitmask) { - this.marginsBitmask = marginsBitmask; + public float expandRatio = 0.0f; } - } \ 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 index d432de97ad..878b921d55 100644 --- a/shared/src/com/vaadin/shared/ui/panel/PanelState.java +++ b/shared/src/com/vaadin/shared/ui/panel/PanelState.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2011 Vaadin Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not @@ -18,31 +18,6 @@ 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; - } - + public int tabIndex; + public int scrollLeft, scrollTop; } \ No newline at end of file diff --git a/shared/src/com/vaadin/shared/ui/slider/SliderState.java b/shared/src/com/vaadin/shared/ui/slider/SliderState.java index 98168b80af..7236672b31 100644 --- a/shared/src/com/vaadin/shared/ui/slider/SliderState.java +++ b/shared/src/com/vaadin/shared/ui/slider/SliderState.java @@ -4,57 +4,17 @@ import com.vaadin.shared.AbstractFieldState; public class SliderState extends AbstractFieldState { - protected double value; + public double value; - protected double maxValue; - protected double minValue; + public double maxValue; + public double minValue; /** * The number of fractional digits that are considered significant. Must be * non-negative. */ - protected int resolution; + public int resolution; - protected SliderOrientation orientation; - - public double getValue() { - return value; - } - - public void setValue(double value) { - this.value = value; - } - - public double getMaxValue() { - return maxValue; - } - - public void setMaxValue(double maxValue) { - this.maxValue = maxValue; - } - - public double getMinValue() { - return minValue; - } - - public void setMinValue(double minValue) { - this.minValue = minValue; - } - - public int getResolution() { - return resolution; - } - - public void setResolution(int resolution) { - this.resolution = resolution; - } - - public SliderOrientation getOrientation() { - return orientation; - } - - public void setOrientation(SliderOrientation orientation) { - this.orientation = orientation; - } + public SliderOrientation orientation; } diff --git a/shared/src/com/vaadin/shared/ui/splitpanel/AbstractSplitPanelState.java b/shared/src/com/vaadin/shared/ui/splitpanel/AbstractSplitPanelState.java index 71f789b70d..41c51f998a 100644 --- a/shared/src/com/vaadin/shared/ui/splitpanel/AbstractSplitPanelState.java +++ b/shared/src/com/vaadin/shared/ui/splitpanel/AbstractSplitPanelState.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2011 Vaadin Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not @@ -23,117 +23,22 @@ import com.vaadin.shared.annotations.DelegateToWidget; 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 Connector firstChild = null; + public Connector secondChild = null; + public SplitterState splitterState = new 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 float position; + public String positionUnit; + public float minPosition; + public String minPositionUnit; + public float maxPosition; + public String maxPositionUnit; + @DelegateToWidget - public void setPositionReversed(boolean positionReversed) { - this.positionReversed = positionReversed; - } - - public boolean isLocked() { - return locked; - } + public boolean positionReversed = false; @DelegateToWidget - public void setLocked(boolean locked) { - this.locked = locked; - } - + public boolean locked = false; } } \ 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 index 50dc1393a3..a562c607b0 100644 --- a/shared/src/com/vaadin/shared/ui/textarea/TextAreaState.java +++ b/shared/src/com/vaadin/shared/ui/textarea/TextAreaState.java @@ -23,29 +23,13 @@ public class TextAreaState extends AbstractTextFieldState { /** * Number of visible rows in the text area. The default is 5. */ - private int rows = 5; + @DelegateToWidget + public int rows = 5; /** * Tells if word-wrapping should be used in the text area. */ - private boolean wordwrap = true; - - public int getRows() { - return rows; - } - - @DelegateToWidget - public void setRows(int rows) { - this.rows = rows; - } - - public boolean isWordwrap() { - return wordwrap; - } - @DelegateToWidget - public void setWordwrap(boolean wordwrap) { - this.wordwrap = wordwrap; - } + public boolean wordwrap = true; } diff --git a/shared/src/com/vaadin/shared/ui/textfield/AbstractTextFieldState.java b/shared/src/com/vaadin/shared/ui/textfield/AbstractTextFieldState.java index cd3562606d..39265c516f 100644 --- a/shared/src/com/vaadin/shared/ui/textfield/AbstractTextFieldState.java +++ b/shared/src/com/vaadin/shared/ui/textfield/AbstractTextFieldState.java @@ -21,53 +21,20 @@ public class AbstractTextFieldState extends AbstractFieldState { /** * Maximum character count in text field. */ - private int maxLength = -1; + public int maxLength = -1; /** * Number of visible columns in the TextField. */ - private int columns = 0; + public int columns = 0; /** * The prompt to display in an empty field. Null when disabled. */ - private String inputPrompt = null; + public 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; - } - + public String text = null; } diff --git a/shared/src/com/vaadin/shared/ui/ui/UIState.java b/shared/src/com/vaadin/shared/ui/ui/UIState.java index 01426bd8f3..6bbfeb18e1 100644 --- a/shared/src/com/vaadin/shared/ui/ui/UIState.java +++ b/shared/src/com/vaadin/shared/ui/ui/UIState.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2011 Vaadin Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not @@ -19,14 +19,5 @@ import com.vaadin.shared.ComponentState; import com.vaadin.shared.Connector; public class UIState extends ComponentState { - private Connector content; - - public Connector getContent() { - return content; - } - - public void setContent(Connector content) { - this.content = content; - } - + public Connector content; } \ 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 index 526c5dacb0..c86b6cb187 100644 --- a/shared/src/com/vaadin/shared/ui/window/WindowState.java +++ b/shared/src/com/vaadin/shared/ui/window/WindowState.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2011 Vaadin Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not @@ -18,68 +18,11 @@ 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; - } - + public boolean modal = false; + public boolean resizable = true; + public boolean resizeLazy = false; + public boolean draggable = true; + public boolean centered = false;; + public int positionX = -1; + public int positionY = -1; } \ No newline at end of file -- cgit v1.2.3 From dc8bc6119c1bd019600559db552ec26b4db2ec54 Mon Sep 17 00:00:00 2001 From: John Ahlroos Date: Fri, 31 Aug 2012 14:22:26 +0300 Subject: More state getter removal --- .../JavaScriptManagerConnector.java | 4 +- .../com/vaadin/client/ui/MediaBaseConnector.java | 10 +- .../com/vaadin/client/ui/audio/AudioConnector.java | 2 +- .../src/com/vaadin/server/AbstractUIProvider.java | 70 +++++++------- .../src/com/vaadin/server/DefaultUIProvider.java | 102 ++++++++++---------- server/src/com/vaadin/server/UIProvider.java | 58 ++++++------ server/src/com/vaadin/ui/AbstractMedia.java | 32 +++---- server/src/com/vaadin/ui/JavaScript.java | 6 +- .../vaadin/shared/JavaScriptExtensionState.java | 2 +- .../javascriptmanager/JavaScriptManagerState.java | 12 +-- .../com/vaadin/shared/ui/AbstractMediaState.java | 74 ++------------- .../loginform/LoginFormUIInLoginHandler.java | 104 ++++++++++----------- 12 files changed, 204 insertions(+), 272 deletions(-) (limited to 'shared') diff --git a/client/src/com/vaadin/client/extensions/javascriptmanager/JavaScriptManagerConnector.java b/client/src/com/vaadin/client/extensions/javascriptmanager/JavaScriptManagerConnector.java index 7cab90a90d..f6d643d1ba 100644 --- a/client/src/com/vaadin/client/extensions/javascriptmanager/JavaScriptManagerConnector.java +++ b/client/src/com/vaadin/client/extensions/javascriptmanager/JavaScriptManagerConnector.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2011 Vaadin Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not @@ -48,7 +48,7 @@ public class JavaScriptManagerConnector extends AbstractExtensionConnector { public void onStateChanged(StateChangeEvent stateChangeEvent) { super.onStateChanged(stateChangeEvent); - Set newNames = getState().getNames(); + Set newNames = getState().names; // Current names now only contains orphan callbacks currentNames.removeAll(newNames); diff --git a/client/src/com/vaadin/client/ui/MediaBaseConnector.java b/client/src/com/vaadin/client/ui/MediaBaseConnector.java index 8a17e052ba..961ba4821e 100644 --- a/client/src/com/vaadin/client/ui/MediaBaseConnector.java +++ b/client/src/com/vaadin/client/ui/MediaBaseConnector.java @@ -49,12 +49,12 @@ public abstract class MediaBaseConnector extends AbstractComponentConnector { public void onStateChanged(StateChangeEvent stateChangeEvent) { super.onStateChanged(stateChangeEvent); - for (int i = 0; i < getState().getSources().size(); i++) { - URLReference source = getState().getSources().get(i); - String sourceType = getState().getSourceTypes().get(i); + for (int i = 0; i < getState().sources.size(); i++) { + URLReference source = getState().sources.get(i); + String sourceType = getState().sourceTypes.get(i); getWidget().addSource(source.getURL(), sourceType); } - setAltText(getState().getAltText()); + setAltText(getState().altText); } @Override @@ -66,7 +66,7 @@ public abstract class MediaBaseConnector extends AbstractComponentConnector { if (altText == null || "".equals(altText)) { altText = getDefaultAltHtml(); - } else if (!getState().isHtmlContentAllowed()) { + } else if (!getState().htmlContentAllowed) { altText = Util.escapeHTML(altText); } getWidget().setAltText(altText); diff --git a/client/src/com/vaadin/client/ui/audio/AudioConnector.java b/client/src/com/vaadin/client/ui/audio/AudioConnector.java index 8c2fa179c8..bfa282ca09 100644 --- a/client/src/com/vaadin/client/ui/audio/AudioConnector.java +++ b/client/src/com/vaadin/client/ui/audio/AudioConnector.java @@ -35,7 +35,7 @@ public class AudioConnector extends MediaBaseConnector { Style style = getWidget().getElement().getStyle(); // Make sure that the controls are not clipped if visible. - if (getState().isShowControls() + if (getState().showControls && (style.getHeight() == null || "".equals(style.getHeight()))) { if (BrowserInfo.get().isChrome()) { style.setHeight(32, Unit.PX); diff --git a/server/src/com/vaadin/server/AbstractUIProvider.java b/server/src/com/vaadin/server/AbstractUIProvider.java index 07b95fc713..f383368d91 100644 --- a/server/src/com/vaadin/server/AbstractUIProvider.java +++ b/server/src/com/vaadin/server/AbstractUIProvider.java @@ -1,35 +1,35 @@ -/* - * Copyright 2011 Vaadin Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ - -package com.vaadin.server; - -import com.vaadin.Application; -import com.vaadin.ui.UI; - -public abstract class AbstractUIProvider implements UIProvider { - - @Override - public UI instantiateUI(Application application, Class type, - WrappedRequest request) { - try { - return type.newInstance(); - } catch (InstantiationException e) { - throw new RuntimeException("Could not instantiate root class", e); - } catch (IllegalAccessException e) { - throw new RuntimeException("Could not access root class", e); - } - } -} +/* + * Copyright 2011 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package com.vaadin.server; + +import com.vaadin.Application; +import com.vaadin.ui.UI; + +public abstract class AbstractUIProvider implements UIProvider { + + @Override + public UI instantiateUI(Application application, Class type, + WrappedRequest request) { + try { + return type.newInstance(); + } catch (InstantiationException e) { + throw new RuntimeException("Could not instantiate root class", e); + } catch (IllegalAccessException e) { + throw new RuntimeException("Could not access root class", e); + } + } +} diff --git a/server/src/com/vaadin/server/DefaultUIProvider.java b/server/src/com/vaadin/server/DefaultUIProvider.java index 913402c89f..d4490b1642 100644 --- a/server/src/com/vaadin/server/DefaultUIProvider.java +++ b/server/src/com/vaadin/server/DefaultUIProvider.java @@ -1,51 +1,51 @@ -/* - * Copyright 2011 Vaadin Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ - -package com.vaadin.server; - -import com.vaadin.Application; -import com.vaadin.UIRequiresMoreInformationException; -import com.vaadin.ui.UI; - -public class DefaultUIProvider extends AbstractUIProvider { - - @Override - public Class getUIClass(Application application, - WrappedRequest request) throws UIRequiresMoreInformationException { - Object uiClassNameObj = application - .getProperty(Application.UI_PARAMETER); - - if (uiClassNameObj instanceof String) { - String uiClassName = uiClassNameObj.toString(); - - ClassLoader classLoader = request.getDeploymentConfiguration() - .getClassLoader(); - if (classLoader == null) { - classLoader = getClass().getClassLoader(); - } - try { - Class uiClass = Class.forName(uiClassName, true, - classLoader).asSubclass(UI.class); - - return uiClass; - } catch (ClassNotFoundException e) { - throw new RuntimeException("Could not find UI class", e); - } - } - - return null; - } -} +/* + * Copyright 2011 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package com.vaadin.server; + +import com.vaadin.Application; +import com.vaadin.UIRequiresMoreInformationException; +import com.vaadin.ui.UI; + +public class DefaultUIProvider extends AbstractUIProvider { + + @Override + public Class getUIClass(Application application, + WrappedRequest request) throws UIRequiresMoreInformationException { + Object uiClassNameObj = application + .getProperty(Application.UI_PARAMETER); + + if (uiClassNameObj instanceof String) { + String uiClassName = uiClassNameObj.toString(); + + ClassLoader classLoader = request.getDeploymentConfiguration() + .getClassLoader(); + if (classLoader == null) { + classLoader = getClass().getClassLoader(); + } + try { + Class uiClass = Class.forName(uiClassName, true, + classLoader).asSubclass(UI.class); + + return uiClass; + } catch (ClassNotFoundException e) { + throw new RuntimeException("Could not find UI class", e); + } + } + + return null; + } +} diff --git a/server/src/com/vaadin/server/UIProvider.java b/server/src/com/vaadin/server/UIProvider.java index f262a3e225..890809fdd5 100644 --- a/server/src/com/vaadin/server/UIProvider.java +++ b/server/src/com/vaadin/server/UIProvider.java @@ -1,29 +1,29 @@ -/* - * Copyright 2011 Vaadin Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ - -package com.vaadin.server; - -import com.vaadin.Application; -import com.vaadin.UIRequiresMoreInformationException; -import com.vaadin.ui.UI; - -public interface UIProvider { - public Class getUIClass(Application application, - WrappedRequest request) throws UIRequiresMoreInformationException; - - public UI instantiateUI(Application application, Class type, - WrappedRequest request); -} +/* + * Copyright 2011 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package com.vaadin.server; + +import com.vaadin.Application; +import com.vaadin.UIRequiresMoreInformationException; +import com.vaadin.ui.UI; + +public interface UIProvider { + public Class getUIClass(Application application, + WrappedRequest request) throws UIRequiresMoreInformationException; + + public UI instantiateUI(Application application, Class type, + WrappedRequest request); +} diff --git a/server/src/com/vaadin/ui/AbstractMedia.java b/server/src/com/vaadin/ui/AbstractMedia.java index 3f59b070b7..219413974b 100644 --- a/server/src/com/vaadin/ui/AbstractMedia.java +++ b/server/src/com/vaadin/ui/AbstractMedia.java @@ -56,8 +56,8 @@ public abstract class AbstractMedia extends AbstractComponent { } private void clearSources() { - getState().getSources().clear(); - getState().getSourceTypes().clear(); + getState().sources.clear(); + getState().sourceTypes.clear(); } /** @@ -71,10 +71,10 @@ public abstract class AbstractMedia extends AbstractComponent { */ public void addSource(Resource source) { if (source != null) { - List sources = getState().getSources(); + List sources = getState().sources; sources.add(new ResourceReference(source, this, Integer .toString(sources.size()))); - getState().getSourceTypes().add(source.getMIMEType()); + getState().sourceTypes.add(source.getMIMEType()); } } @@ -83,7 +83,7 @@ public abstract class AbstractMedia extends AbstractComponent { WrappedResponse response, String path) throws IOException { Matcher matcher = Pattern.compile("(\\d+)(/.*)?").matcher(path); if (matcher.matches()) { - List sources = getState().getSources(); + List sources = getState().sources; int sourceIndex = Integer.parseInt(matcher.group(1)); @@ -128,7 +128,7 @@ public abstract class AbstractMedia extends AbstractComponent { */ public List getSources() { ArrayList sources = new ArrayList(); - for (URLReference ref : getState().getSources()) { + for (URLReference ref : getState().sources) { sources.add(((ResourceReference) ref).getResource()); } return sources; @@ -140,14 +140,14 @@ public abstract class AbstractMedia extends AbstractComponent { * @param showControls */ public void setShowControls(boolean showControls) { - getState().setShowControls(showControls); + getState().showControls = showControls; } /** * @return true if the browser is to show native media controls. */ public boolean isShowControls() { - return getState().isShowControls(); + return getState().showControls; } /** @@ -162,7 +162,7 @@ public abstract class AbstractMedia extends AbstractComponent { * @param altText */ public void setAltText(String altText) { - getState().setAltText(altText); + getState().altText = altText; } /** @@ -170,7 +170,7 @@ public abstract class AbstractMedia extends AbstractComponent { * HTML5. */ public String getAltText() { - return getState().getAltText(); + return getState().altText; } /** @@ -180,7 +180,7 @@ public abstract class AbstractMedia extends AbstractComponent { * @param htmlContentAllowed */ public void setHtmlContentAllowed(boolean htmlContentAllowed) { - getState().setHtmlContentAllowed(htmlContentAllowed); + getState().htmlContentAllowed = htmlContentAllowed; } /** @@ -188,7 +188,7 @@ public abstract class AbstractMedia extends AbstractComponent { * be rendered as HTML. */ public boolean isHtmlContentAllowed() { - return getState().isHtmlContentAllowed(); + return getState().htmlContentAllowed; } /** @@ -198,14 +198,14 @@ public abstract class AbstractMedia extends AbstractComponent { * @param autoplay */ public void setAutoplay(boolean autoplay) { - getState().setAutoplay(autoplay); + getState().autoplay = autoplay; } /** * @return true if the media is set to automatically start playback. */ public boolean isAutoplay() { - return getState().isAutoplay(); + return getState().autoplay; } /** @@ -214,14 +214,14 @@ public abstract class AbstractMedia extends AbstractComponent { * @param muted */ public void setMuted(boolean muted) { - getState().setMuted(muted); + getState().muted = muted; } /** * @return true if the audio is muted. */ public boolean isMuted() { - return getState().isMuted(); + return getState().muted; } /** diff --git a/server/src/com/vaadin/ui/JavaScript.java b/server/src/com/vaadin/ui/JavaScript.java index f3e8564fab..f9324ba321 100644 --- a/server/src/com/vaadin/ui/JavaScript.java +++ b/server/src/com/vaadin/ui/JavaScript.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2011 Vaadin Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not @@ -93,7 +93,7 @@ public class JavaScript extends AbstractExtension { */ public void addFunction(String name, JavaScriptFunction function) { functions.put(name, function); - getState().getNames().add(name); + getState().names.add(name); } /** @@ -109,7 +109,7 @@ public class JavaScript extends AbstractExtension { */ public void removeFunction(String name) { functions.remove(name); - getState().getNames().remove(name); + getState().names.remove(name); } /** diff --git a/shared/src/com/vaadin/shared/JavaScriptExtensionState.java b/shared/src/com/vaadin/shared/JavaScriptExtensionState.java index 3e97294f7d..fb864c6ee1 100644 --- a/shared/src/com/vaadin/shared/JavaScriptExtensionState.java +++ b/shared/src/com/vaadin/shared/JavaScriptExtensionState.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2011 Vaadin Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not diff --git a/shared/src/com/vaadin/shared/extension/javascriptmanager/JavaScriptManagerState.java b/shared/src/com/vaadin/shared/extension/javascriptmanager/JavaScriptManagerState.java index 7d1938d735..71af5e9598 100644 --- a/shared/src/com/vaadin/shared/extension/javascriptmanager/JavaScriptManagerState.java +++ b/shared/src/com/vaadin/shared/extension/javascriptmanager/JavaScriptManagerState.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2011 Vaadin Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not @@ -22,13 +22,5 @@ import java.util.Set; import com.vaadin.shared.communication.SharedState; public class JavaScriptManagerState extends SharedState { - private Set names = new HashSet(); - - public Set getNames() { - return names; - } - - public void setNames(Set names) { - this.names = names; - } + public Set names = new HashSet(); } diff --git a/shared/src/com/vaadin/shared/ui/AbstractMediaState.java b/shared/src/com/vaadin/shared/ui/AbstractMediaState.java index 80d41dd797..76d4e1b000 100644 --- a/shared/src/com/vaadin/shared/ui/AbstractMediaState.java +++ b/shared/src/com/vaadin/shared/ui/AbstractMediaState.java @@ -19,80 +19,20 @@ import java.util.ArrayList; import java.util.List; import com.vaadin.shared.ComponentState; -import com.vaadin.shared.annotations.DelegateToWidget; import com.vaadin.shared.communication.URLReference; public class AbstractMediaState extends ComponentState { - private boolean showControls; + public boolean showControls; - private String altText; + public String altText; - private boolean htmlContentAllowed; + public boolean htmlContentAllowed; - private boolean autoplay; + public boolean autoplay; - private boolean muted; + public boolean muted; - private List sources = new ArrayList(); - private List sourceTypes = new ArrayList(); - - public boolean isShowControls() { - return showControls; - } - - @DelegateToWidget("setControls") - 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; - } - - @DelegateToWidget - public void setAutoplay(boolean autoplay) { - this.autoplay = autoplay; - } - - public boolean isMuted() { - return muted; - } - - @DelegateToWidget - public void setMuted(boolean muted) { - this.muted = muted; - } - - public List getSources() { - return sources; - } - - public void setSources(List sources) { - this.sources = sources; - } - - public List getSourceTypes() { - return sourceTypes; - } - - public void setSourceTypes(List sourceTypes) { - this.sourceTypes = sourceTypes; - } + public List sources = new ArrayList(); + public List sourceTypes = new ArrayList(); } diff --git a/uitest/src/com/vaadin/tests/components/loginform/LoginFormUIInLoginHandler.java b/uitest/src/com/vaadin/tests/components/loginform/LoginFormUIInLoginHandler.java index b3ebb02751..58656cb7bf 100755 --- a/uitest/src/com/vaadin/tests/components/loginform/LoginFormUIInLoginHandler.java +++ b/uitest/src/com/vaadin/tests/components/loginform/LoginFormUIInLoginHandler.java @@ -1,52 +1,52 @@ -package com.vaadin.tests.components.loginform; - -import com.vaadin.tests.components.TestBase; -import com.vaadin.ui.Label; -import com.vaadin.ui.LoginForm; -import com.vaadin.ui.LoginForm.LoginEvent; -import com.vaadin.ui.LoginForm.LoginListener; -import com.vaadin.ui.UI; - -public class LoginFormUIInLoginHandler extends TestBase { - - @Override - protected void setup() { - LoginForm lf = new LoginForm(); - lf.addListener(new LoginListener() { - - @Override - public void onLogin(LoginEvent event) { - UI r1 = UI.getCurrent(); - if (r1 != null) { - addComponent(new Label("UI.getCurrent().data: " - + r1.getData())); - } else { - addComponent(new Label("UI.getCurrent() is null")); - } - UI r2 = ((LoginForm) event.getSource()).getUI(); - if (r2 != null) { - addComponent(new Label("event.getSource().data: " - + r2.getData())); - } else { - addComponent(new Label( - "event.getSource().getRoot() is null")); - } - } - }); - addComponent(lf); - getLayout().getUI().setData("This UI"); - } - - @Override - protected String getDescription() { - // TODO Auto-generated method stub - return null; - } - - @Override - protected Integer getTicketNumber() { - // TODO Auto-generated method stub - return null; - } - -} +package com.vaadin.tests.components.loginform; + +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.Label; +import com.vaadin.ui.LoginForm; +import com.vaadin.ui.LoginForm.LoginEvent; +import com.vaadin.ui.LoginForm.LoginListener; +import com.vaadin.ui.UI; + +public class LoginFormUIInLoginHandler extends TestBase { + + @Override + protected void setup() { + LoginForm lf = new LoginForm(); + lf.addListener(new LoginListener() { + + @Override + public void onLogin(LoginEvent event) { + UI r1 = UI.getCurrent(); + if (r1 != null) { + addComponent(new Label("UI.getCurrent().data: " + + r1.getData())); + } else { + addComponent(new Label("UI.getCurrent() is null")); + } + UI r2 = ((LoginForm) event.getSource()).getUI(); + if (r2 != null) { + addComponent(new Label("event.getSource().data: " + + r2.getData())); + } else { + addComponent(new Label( + "event.getSource().getRoot() is null")); + } + } + }); + addComponent(lf); + getLayout().getUI().setData("This UI"); + } + + @Override + protected String getDescription() { + // TODO Auto-generated method stub + return null; + } + + @Override + protected Integer getTicketNumber() { + // TODO Auto-generated method stub + return null; + } + +} -- cgit v1.2.3 From 5abe444f28b89cc6c06cc178912a8fa3e03107c9 Mon Sep 17 00:00:00 2001 From: John Ahlroos Date: Fri, 31 Aug 2012 16:13:40 +0300 Subject: Add helper methods for checking state --- client/src/com/vaadin/client/LayoutManager.java | 3 ++- client/src/com/vaadin/client/VCaption.java | 7 ++++--- client/src/com/vaadin/client/ui/AbstractComponentConnector.java | 3 ++- client/src/com/vaadin/client/ui/UI/UIConnector.java | 3 ++- client/src/com/vaadin/client/ui/combobox/VFilterSelect.java | 4 ++-- client/src/com/vaadin/client/ui/form/FormConnector.java | 3 ++- client/src/com/vaadin/client/ui/formlayout/VFormLayout.java | 3 ++- client/src/com/vaadin/client/ui/menubar/MenuBarConnector.java | 2 +- client/src/com/vaadin/client/ui/panel/PanelConnector.java | 3 ++- client/src/com/vaadin/client/ui/popupview/PopupViewConnector.java | 3 ++- .../vaadin/client/ui/splitpanel/AbstractSplitPanelConnector.java | 3 ++- client/src/com/vaadin/client/ui/tabsheet/VTabsheet.java | 3 ++- server/src/com/vaadin/ui/AbstractComponent.java | 4 ++-- shared/src/com/vaadin/shared/ui/ComponentStateUtil.java | 8 ++++++++ 14 files changed, 35 insertions(+), 17 deletions(-) (limited to 'shared') diff --git a/client/src/com/vaadin/client/LayoutManager.java b/client/src/com/vaadin/client/LayoutManager.java index a0d8761581..7b6fe19a37 100644 --- a/client/src/com/vaadin/client/LayoutManager.java +++ b/client/src/com/vaadin/client/LayoutManager.java @@ -1077,7 +1077,8 @@ public class LayoutManager { int assignedHeight) { assert component.isRelativeHeight(); - float percentSize = parsePercent(component.getState().height); + float percentSize = parsePercent(component.getState().height == null ? "" + : component.getState().height); int effectiveHeight = Math.round(assignedHeight * (percentSize / 100)); reportOuterHeight(component, effectiveHeight); diff --git a/client/src/com/vaadin/client/VCaption.java b/client/src/com/vaadin/client/VCaption.java index a3d3a7034e..aadc7b88ad 100644 --- a/client/src/com/vaadin/client/VCaption.java +++ b/client/src/com/vaadin/client/VCaption.java @@ -25,6 +25,7 @@ import com.vaadin.client.ui.Icon; import com.vaadin.shared.AbstractFieldState; import com.vaadin.shared.ComponentConstants; import com.vaadin.shared.ComponentState; +import com.vaadin.shared.ui.ComponentStateUtil; public class VCaption extends HTML { @@ -110,8 +111,7 @@ public class VCaption extends HTML { placedAfterComponent = true; String style = CLASSNAME; - if (owner.getState().styles != null - && !owner.getState().styles.isEmpty()) { + if (ComponentStateUtil.hasStyles(owner.getState())) { for (String customStyle : owner.getState().styles) { style += " " + CLASSNAME + "-" + customStyle; } @@ -192,7 +192,8 @@ public class VCaption extends HTML { captionText = null; } - if (owner.getState().description != null && captionText != null) { + if (ComponentStateUtil.hasDescription(owner.getState()) + && captionText != null) { addStyleDependentName("hasdescription"); } else { removeStyleDependentName("hasdescription"); diff --git a/client/src/com/vaadin/client/ui/AbstractComponentConnector.java b/client/src/com/vaadin/client/ui/AbstractComponentConnector.java index 8ac113e72e..d5e8dc0ba0 100644 --- a/client/src/com/vaadin/client/ui/AbstractComponentConnector.java +++ b/client/src/com/vaadin/client/ui/AbstractComponentConnector.java @@ -42,6 +42,7 @@ import com.vaadin.client.ui.datefield.PopupDateFieldConnector; import com.vaadin.shared.ComponentConstants; import com.vaadin.shared.ComponentState; import com.vaadin.shared.Connector; +import com.vaadin.shared.ui.ComponentStateUtil; import com.vaadin.shared.ui.TabIndexState; public abstract class AbstractComponentConnector extends AbstractConnector @@ -282,7 +283,7 @@ public abstract class AbstractComponentConnector extends AbstractConnector // add additional user defined style names as class names, prefixed with // component default class name. remove nonexistent style names. - if (state.styles != null && !state.styles.isEmpty()) { + if (ComponentStateUtil.hasStyles(state)) { // add new style names List newStyles = new ArrayList(); newStyles.addAll(state.styles); diff --git a/client/src/com/vaadin/client/ui/UI/UIConnector.java b/client/src/com/vaadin/client/ui/UI/UIConnector.java index b22e9af09b..cb8b0ece9e 100644 --- a/client/src/com/vaadin/client/ui/UI/UIConnector.java +++ b/client/src/com/vaadin/client/ui/UI/UIConnector.java @@ -52,6 +52,7 @@ import com.vaadin.client.ui.layout.MayScrollChildren; import com.vaadin.client.ui.notification.VNotification; import com.vaadin.client.ui.window.WindowConnector; import com.vaadin.shared.MouseEventDetails; +import com.vaadin.shared.ui.ComponentStateUtil; import com.vaadin.shared.ui.Connect; import com.vaadin.shared.ui.Connect.LoadStyle; import com.vaadin.shared.ui.ui.PageClientRpc; @@ -119,7 +120,7 @@ public class UIConnector extends AbstractComponentContainerConnector implements // this also implicitly removes old styles String styles = ""; styles += getWidget().getStylePrimaryName() + " "; - if (getState().styles != null && !getState().styles.isEmpty()) { + if (ComponentStateUtil.hasStyles(getState())) { for (String style : getState().styles) { styles += style + " "; } diff --git a/client/src/com/vaadin/client/ui/combobox/VFilterSelect.java b/client/src/com/vaadin/client/ui/combobox/VFilterSelect.java index efca4ca083..8692622892 100644 --- a/client/src/com/vaadin/client/ui/combobox/VFilterSelect.java +++ b/client/src/com/vaadin/client/ui/combobox/VFilterSelect.java @@ -72,6 +72,7 @@ import com.vaadin.client.ui.menubar.MenuBar; import com.vaadin.client.ui.menubar.MenuItem; import com.vaadin.shared.ComponentState; import com.vaadin.shared.EventId; +import com.vaadin.shared.ui.ComponentStateUtil; /** * Client side implementation of the Select component. @@ -580,8 +581,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, */ public void updateStyleNames(UIDL uidl, ComponentState componentState) { setStyleName(CLASSNAME + "-suggestpopup"); - if (componentState.styles == null - || componentState.styles.isEmpty()) { + if (ComponentStateUtil.hasStyles(componentState)) { for (String style : componentState.styles) { if (!"".equals(style)) { addStyleDependentName(style); diff --git a/client/src/com/vaadin/client/ui/form/FormConnector.java b/client/src/com/vaadin/client/ui/form/FormConnector.java index 1be137dcaa..25b4a76a09 100644 --- a/client/src/com/vaadin/client/ui/form/FormConnector.java +++ b/client/src/com/vaadin/client/ui/form/FormConnector.java @@ -29,6 +29,7 @@ import com.vaadin.client.ui.ShortcutActionHandler; import com.vaadin.client.ui.layout.ElementResizeEvent; import com.vaadin.client.ui.layout.ElementResizeListener; import com.vaadin.client.ui.layout.MayScrollChildren; +import com.vaadin.shared.ui.ComponentStateUtil; import com.vaadin.shared.ui.Connect; import com.vaadin.shared.ui.form.FormState; import com.vaadin.ui.Form; @@ -112,7 +113,7 @@ public class FormConnector extends AbstractComponentContainerConnector getWidget().errorMessage.setVisible(false); } - if (getState().description != null) { + if (ComponentStateUtil.hasDescription(getState())) { getWidget().desc.setInnerHTML(getState().description); if (getWidget().desc.getParentElement() == null) { getWidget().fieldSet.insertAfter(getWidget().desc, diff --git a/client/src/com/vaadin/client/ui/formlayout/VFormLayout.java b/client/src/com/vaadin/client/ui/formlayout/VFormLayout.java index c39b945220..f2f6e0bc72 100644 --- a/client/src/com/vaadin/client/ui/formlayout/VFormLayout.java +++ b/client/src/com/vaadin/client/ui/formlayout/VFormLayout.java @@ -38,6 +38,7 @@ import com.vaadin.client.ui.AbstractFieldConnector; import com.vaadin.client.ui.Icon; import com.vaadin.shared.ComponentConstants; import com.vaadin.shared.ComponentState; +import com.vaadin.shared.ui.ComponentStateUtil; import com.vaadin.shared.ui.MarginInfo; /** @@ -66,7 +67,7 @@ public class VFormLayout extends SimplePanel { */ private String[] getStylesFromState(ComponentState state, boolean enabled) { List styles = new ArrayList(); - if (state.styles != null && !state.styles.isEmpty()) { + if (ComponentStateUtil.hasStyles(state)) { for (String name : state.styles) { styles.add(name); } diff --git a/client/src/com/vaadin/client/ui/menubar/MenuBarConnector.java b/client/src/com/vaadin/client/ui/menubar/MenuBarConnector.java index 7dcbbadcd3..fcd1a3bdac 100644 --- a/client/src/com/vaadin/client/ui/menubar/MenuBarConnector.java +++ b/client/src/com/vaadin/client/ui/menubar/MenuBarConnector.java @@ -143,7 +143,7 @@ public class MenuBarConnector extends AbstractComponentConnector implements // this is the top-level style that also propagates to items - // any item specific styles are set above in // currentItem.updateFromUIDL(item, client) - if (getState().styles != null && !getState().styles.isEmpty()) { + if (ComponentStateUtil.hasStyles(getState())) { for (String style : getState().styles) { currentMenu.addStyleDependentName(style); } diff --git a/client/src/com/vaadin/client/ui/panel/PanelConnector.java b/client/src/com/vaadin/client/ui/panel/PanelConnector.java index 35adf95066..35a2681590 100644 --- a/client/src/com/vaadin/client/ui/panel/PanelConnector.java +++ b/client/src/com/vaadin/client/ui/panel/PanelConnector.java @@ -33,6 +33,7 @@ import com.vaadin.client.ui.ShortcutActionHandler; import com.vaadin.client.ui.SimpleManagedLayout; import com.vaadin.client.ui.layout.MayScrollChildren; import com.vaadin.shared.MouseEventDetails; +import com.vaadin.shared.ui.ComponentStateUtil; import com.vaadin.shared.ui.Connect; import com.vaadin.shared.ui.panel.PanelServerRpc; import com.vaadin.shared.ui.panel.PanelState; @@ -116,7 +117,7 @@ public class PanelConnector extends AbstractComponentContainerConnector String captionClass = captionBaseClass; String contentClass = contentBaseClass; String decoClass = decoBaseClass; - if (getState().styles != null && !getState().styles.isEmpty()) { + if (ComponentStateUtil.hasStyles(getState())) { for (String style : getState().styles) { captionClass += " " + captionBaseClass + "-" + style; contentClass += " " + contentBaseClass + "-" + style; diff --git a/client/src/com/vaadin/client/ui/popupview/PopupViewConnector.java b/client/src/com/vaadin/client/ui/popupview/PopupViewConnector.java index efc6c8c4d7..8def4d244d 100644 --- a/client/src/com/vaadin/client/ui/popupview/PopupViewConnector.java +++ b/client/src/com/vaadin/client/ui/popupview/PopupViewConnector.java @@ -23,6 +23,7 @@ import com.vaadin.client.VCaption; import com.vaadin.client.VCaptionWrapper; import com.vaadin.client.ui.AbstractComponentContainerConnector; import com.vaadin.client.ui.PostLayoutListener; +import com.vaadin.shared.ui.ComponentStateUtil; import com.vaadin.shared.ui.Connect; import com.vaadin.ui.PopupView; @@ -69,7 +70,7 @@ public class PopupViewConnector extends AbstractComponentContainerConnector // showPopupOnTop(popup, hostReference); getWidget().preparePopup(getWidget().popup); getWidget().popup.updateFromUIDL(popupUIDL, client); - if (getState().styles != null && !getState().styles.isEmpty()) { + if (ComponentStateUtil.hasStyles(getState())) { final StringBuffer styleBuf = new StringBuffer(); final String primaryName = getWidget().popup .getStylePrimaryName(); diff --git a/client/src/com/vaadin/client/ui/splitpanel/AbstractSplitPanelConnector.java b/client/src/com/vaadin/client/ui/splitpanel/AbstractSplitPanelConnector.java index a0bfc36298..229d3894cf 100644 --- a/client/src/com/vaadin/client/ui/splitpanel/AbstractSplitPanelConnector.java +++ b/client/src/com/vaadin/client/ui/splitpanel/AbstractSplitPanelConnector.java @@ -37,6 +37,7 @@ import com.vaadin.client.ui.SimpleManagedLayout; import com.vaadin.client.ui.splitpanel.VAbstractSplitPanel.SplitterMoveHandler; import com.vaadin.client.ui.splitpanel.VAbstractSplitPanel.SplitterMoveHandler.SplitterMoveEvent; import com.vaadin.shared.MouseEventDetails; +import com.vaadin.shared.ui.ComponentStateUtil; import com.vaadin.shared.ui.splitpanel.AbstractSplitPanelRpc; import com.vaadin.shared.ui.splitpanel.AbstractSplitPanelState; import com.vaadin.shared.ui.splitpanel.AbstractSplitPanelState.SplitterState; @@ -129,7 +130,7 @@ public abstract class AbstractSplitPanelConnector extends clickEventHandler.handleEventHandlerRegistration(); - if (getState().styles != null && !getState().styles.isEmpty()) { + if (ComponentStateUtil.hasStyles(getState())) { getWidget().componentStyleNames = getState().styles; } else { getWidget().componentStyleNames = new LinkedList(); diff --git a/client/src/com/vaadin/client/ui/tabsheet/VTabsheet.java b/client/src/com/vaadin/client/ui/tabsheet/VTabsheet.java index bd77c0d7d9..b2ad68e79b 100644 --- a/client/src/com/vaadin/client/ui/tabsheet/VTabsheet.java +++ b/client/src/com/vaadin/client/ui/tabsheet/VTabsheet.java @@ -58,6 +58,7 @@ import com.vaadin.client.VCaption; import com.vaadin.client.ui.label.VLabel; import com.vaadin.shared.ComponentState; import com.vaadin.shared.EventId; +import com.vaadin.shared.ui.ComponentStateUtil; import com.vaadin.shared.ui.tabsheet.TabsheetBaseConstants; import com.vaadin.shared.ui.tabsheet.TabsheetConstants; @@ -739,7 +740,7 @@ public class VTabsheet extends VTabsheetBase implements Focusable, void handleStyleNames(UIDL uidl, ComponentState state) { // Add proper stylenames for all elements (easier to prevent unwanted // style inheritance) - if (state.styles != null && !state.styles.isEmpty()) { + if (ComponentStateUtil.hasStyles(state)) { final List styles = state.styles; if (!currentStyle.equals(styles.toString())) { currentStyle = styles.toString(); diff --git a/server/src/com/vaadin/ui/AbstractComponent.java b/server/src/com/vaadin/ui/AbstractComponent.java index e367d39b07..97883b780f 100644 --- a/server/src/com/vaadin/ui/AbstractComponent.java +++ b/server/src/com/vaadin/ui/AbstractComponent.java @@ -155,7 +155,7 @@ public abstract class AbstractComponent extends AbstractClientConnector @Override public String getStyleName() { String s = ""; - if (getState().styles != null) { + if (ComponentStateUtil.hasStyles(getState())) { for (final Iterator it = getState().styles.iterator(); it .hasNext();) { s += it.next(); @@ -214,7 +214,7 @@ public abstract class AbstractComponent extends AbstractClientConnector @Override public void removeStyleName(String style) { - if (getState().styles != null) { + if (ComponentStateUtil.hasStyles(getState())) { String[] styleParts = style.split(" +"); for (String part : styleParts) { if (part.length() > 0) { diff --git a/shared/src/com/vaadin/shared/ui/ComponentStateUtil.java b/shared/src/com/vaadin/shared/ui/ComponentStateUtil.java index 556c46518f..dd2611f04b 100644 --- a/shared/src/com/vaadin/shared/ui/ComponentStateUtil.java +++ b/shared/src/com/vaadin/shared/ui/ComponentStateUtil.java @@ -18,6 +18,14 @@ public final class ComponentStateUtil { return state.height == null || "".equals(state.height); } + public static final boolean hasDescription(ComponentState state) { + return state.description != null && !"".equals(state.description); + } + + public static final boolean hasStyles(ComponentState state) { + return state.styles != null && !state.styles.isEmpty(); + } + /** * Removes an event listener id. * -- cgit v1.2.3