summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorJohn Ahlroos <john@vaadin.com>2012-08-31 16:13:40 +0300
committerJohn Ahlroos <john@vaadin.com>2012-08-31 16:13:40 +0300
commit5abe444f28b89cc6c06cc178912a8fa3e03107c9 (patch)
tree15c67af25779901648e8440302dd75b1f76a2ebd /client
parent4e7104a68bafa96455518f006ad1ee310e185cd8 (diff)
downloadvaadin-framework-5abe444f28b89cc6c06cc178912a8fa3e03107c9.tar.gz
vaadin-framework-5abe444f28b89cc6c06cc178912a8fa3e03107c9.zip
Add helper methods for checking state
Diffstat (limited to 'client')
-rw-r--r--client/src/com/vaadin/client/LayoutManager.java3
-rw-r--r--client/src/com/vaadin/client/VCaption.java7
-rw-r--r--client/src/com/vaadin/client/ui/AbstractComponentConnector.java3
-rw-r--r--client/src/com/vaadin/client/ui/UI/UIConnector.java3
-rw-r--r--client/src/com/vaadin/client/ui/combobox/VFilterSelect.java4
-rw-r--r--client/src/com/vaadin/client/ui/form/FormConnector.java3
-rw-r--r--client/src/com/vaadin/client/ui/formlayout/VFormLayout.java3
-rw-r--r--client/src/com/vaadin/client/ui/menubar/MenuBarConnector.java2
-rw-r--r--client/src/com/vaadin/client/ui/panel/PanelConnector.java3
-rw-r--r--client/src/com/vaadin/client/ui/popupview/PopupViewConnector.java3
-rw-r--r--client/src/com/vaadin/client/ui/splitpanel/AbstractSplitPanelConnector.java3
-rw-r--r--client/src/com/vaadin/client/ui/tabsheet/VTabsheet.java3
12 files changed, 25 insertions, 15 deletions
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<String> newStyles = new ArrayList<String>();
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<String> styles = new ArrayList<String>();
- 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<String>();
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<String> styles = state.styles;
if (!currentStyle.equals(styles.toString())) {
currentStyle = styles.toString();