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);
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 {
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;
}
captionText = null;
}
- if (owner.getState().description != null && captionText != null) {
+ if (ComponentStateUtil.hasDescription(owner.getState())
+ && captionText != null) {
addStyleDependentName("hasdescription");
} else {
removeStyleDependentName("hasdescription");
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
// 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);
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;
// 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 + " ";
}
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.
*/
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);
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;
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,
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;
/**
*/
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);
}
// 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);
}
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;
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;
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;
// 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();
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;
clickEventHandler.handleEventHandlerRegistration();
- if (getState().styles != null && !getState().styles.isEmpty()) {
+ if (ComponentStateUtil.hasStyles(getState())) {
getWidget().componentStyleNames = getState().styles;
} else {
getWidget().componentStyleNames = new LinkedList<String>();
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;
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();
@Override
public String getStyleName() {
String s = "";
- if (getState().styles != null) {
+ if (ComponentStateUtil.hasStyles(getState())) {
for (final Iterator<String> it = getState().styles.iterator(); it
.hasNext();) {
s += it.next();
@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) {
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.
*