diff options
author | John Ahlroos <john@vaadin.com> | 2012-09-03 11:41:06 +0300 |
---|---|---|
committer | John Ahlroos <john@vaadin.com> | 2012-09-03 11:41:06 +0300 |
commit | 971b0684482dd3b7eb4efac09b9c24e1ea2b305d (patch) | |
tree | 6d6a4be640837500cfaa2f805a8602a9f4803871 /server/src/com/vaadin/ui | |
parent | 340cd7899812b444941584d383d930fe8155159b (diff) | |
parent | f85c152a48686a8a0dca38ca12b4f3509cac056f (diff) | |
download | vaadin-framework-971b0684482dd3b7eb4efac09b9c24e1ea2b305d.tar.gz vaadin-framework-971b0684482dd3b7eb4efac09b9c24e1ea2b305d.zip |
Merge branch 'master' into layoutgraph
Conflicts:
shared/src/com/vaadin/shared/ComponentState.java
Diffstat (limited to 'server/src/com/vaadin/ui')
25 files changed, 490 insertions, 428 deletions
diff --git a/server/src/com/vaadin/ui/AbsoluteLayout.java b/server/src/com/vaadin/ui/AbsoluteLayout.java index 794de49671..e3eecaac12 100644 --- a/server/src/com/vaadin/ui/AbsoluteLayout.java +++ b/server/src/com/vaadin/ui/AbsoluteLayout.java @@ -182,7 +182,7 @@ public class AbsoluteLayout extends AbstractLayout implements connectorToPosition.put(c.getConnectorId(), getPosition(c) .getCSSString()); } - getState().setConnectorToCssPosition(connectorToPosition); + getState().connectorToCssPosition = connectorToPosition; } @@ -639,6 +639,7 @@ public class AbsoluteLayout extends AbstractLayout implements * @deprecated Since 7.0, replaced by * {@link #addLayoutClickListener(LayoutClickListener)} **/ + @Override @Deprecated public void addListener(LayoutClickListener listener) { addLayoutClickListener(listener); @@ -654,6 +655,7 @@ public class AbsoluteLayout extends AbstractLayout implements * @deprecated Since 7.0, replaced by * {@link #removeLayoutClickListener(LayoutClickListener)} **/ + @Override @Deprecated public void removeListener(LayoutClickListener listener) { removeLayoutClickListener(listener); diff --git a/server/src/com/vaadin/ui/AbstractComponent.java b/server/src/com/vaadin/ui/AbstractComponent.java index 045173036e..97883b780f 100644 --- a/server/src/com/vaadin/ui/AbstractComponent.java +++ b/server/src/com/vaadin/ui/AbstractComponent.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2011 Vaadin Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not @@ -40,6 +40,7 @@ import com.vaadin.server.Resource; import com.vaadin.server.Terminal; import com.vaadin.shared.ComponentConstants; import com.vaadin.shared.ComponentState; +import com.vaadin.shared.ui.ComponentStateUtil; import com.vaadin.tools.ReflectTools; /** @@ -118,7 +119,7 @@ public abstract class AbstractComponent extends AbstractClientConnector */ @Override public void setId(String id) { - getState().setId(id); + getState().id = id; } /* @@ -128,7 +129,7 @@ public abstract class AbstractComponent extends AbstractClientConnector */ @Override public String getId() { - return getState().getId(); + return getState().id; } /** @@ -154,8 +155,8 @@ public abstract class AbstractComponent extends AbstractClientConnector @Override public String getStyleName() { String s = ""; - if (getState().getStyles() != null) { - for (final Iterator<String> it = getState().getStyles().iterator(); it + if (ComponentStateUtil.hasStyles(getState())) { + for (final Iterator<String> it = getState().styles.iterator(); it .hasNext();) { s += it.next(); if (it.hasNext()) { @@ -173,13 +174,13 @@ public abstract class AbstractComponent extends AbstractClientConnector @Override public void setStyleName(String style) { if (style == null || "".equals(style)) { - getState().setStyles(null); + getState().styles = null; return; } - if (getState().getStyles() == null) { - getState().setStyles(new ArrayList<String>()); + if (getState().styles == null) { + getState().styles = new ArrayList<String>(); } - List<String> styles = getState().getStyles(); + List<String> styles = getState().styles; styles.clear(); String[] styleParts = style.split(" +"); for (String part : styleParts) { @@ -202,10 +203,10 @@ public abstract class AbstractComponent extends AbstractClientConnector return; } - if (getState().getStyles() == null) { - getState().setStyles(new ArrayList<String>()); + if (getState().styles == null) { + getState().styles = new ArrayList<String>(); } - List<String> styles = getState().getStyles(); + List<String> styles = getState().styles; if (!styles.contains(style)) { styles.add(style); } @@ -213,11 +214,11 @@ public abstract class AbstractComponent extends AbstractClientConnector @Override public void removeStyleName(String style) { - if (getState().getStyles() != null) { + if (ComponentStateUtil.hasStyles(getState())) { String[] styleParts = style.split(" +"); for (String part : styleParts) { if (part.length() > 0) { - getState().getStyles().remove(part); + getState().styles.remove(part); } } } @@ -229,7 +230,7 @@ public abstract class AbstractComponent extends AbstractClientConnector */ @Override public String getCaption() { - return getState().getCaption(); + return getState().caption; } /** @@ -242,7 +243,7 @@ public abstract class AbstractComponent extends AbstractClientConnector */ @Override public void setCaption(String caption) { - getState().setCaption(caption); + getState().caption = caption; } /* @@ -319,7 +320,7 @@ public abstract class AbstractComponent extends AbstractClientConnector */ @Override public boolean isEnabled() { - return getState().isEnabled(); + return getState().enabled; } /* @@ -329,7 +330,7 @@ public abstract class AbstractComponent extends AbstractClientConnector */ @Override public void setEnabled(boolean enabled) { - getState().setEnabled(enabled); + getState().enabled = enabled; } /* @@ -358,7 +359,7 @@ public abstract class AbstractComponent extends AbstractClientConnector * interface. */ public boolean isImmediate() { - return getState().isImmediate(); + return getState().immediate; } /** @@ -371,7 +372,7 @@ public abstract class AbstractComponent extends AbstractClientConnector * @see Component#isImmediate() */ public void setImmediate(boolean immediate) { - getState().setImmediate(immediate); + getState().immediate = immediate; } /* @@ -381,7 +382,7 @@ public abstract class AbstractComponent extends AbstractClientConnector */ @Override public boolean isVisible() { - return getState().isVisible(); + return getState().visible; } /* @@ -391,11 +392,11 @@ public abstract class AbstractComponent extends AbstractClientConnector */ @Override public void setVisible(boolean visible) { - if (getState().isVisible() == visible) { + if (getState().visible == visible) { return; } - getState().setVisible(visible); + getState().visible = visible; if (getParent() != null) { // Must always repaint the parent (at least the hierarchy) when // visibility of a child component changes. @@ -461,7 +462,7 @@ public abstract class AbstractComponent extends AbstractClientConnector * @return component's description <code>String</code> */ public String getDescription() { - return getState().getDescription(); + return getState().description; } /** @@ -477,7 +478,7 @@ public abstract class AbstractComponent extends AbstractClientConnector * the new description string for the component. */ public void setDescription(String description) { - getState().setDescription(description); + getState().description = description; } /* @@ -570,7 +571,7 @@ public abstract class AbstractComponent extends AbstractClientConnector */ @Override public boolean isReadOnly() { - return getState().isReadOnly(); + return getState().readOnly; } /* @@ -579,7 +580,7 @@ public abstract class AbstractComponent extends AbstractClientConnector */ @Override public void setReadOnly(boolean readOnly) { - getState().setReadOnly(readOnly); + getState().readOnly = readOnly; } /* @@ -700,24 +701,24 @@ public abstract class AbstractComponent extends AbstractClientConnector if (getHeight() >= 0 && (getHeightUnits() != Unit.PERCENTAGE || ComponentSizeValidator .parentCanDefineHeight(this))) { - getState().setHeight("" + getCSSHeight()); + getState().height = "" + getCSSHeight(); } else { - getState().setHeight(""); + getState().height = ""; } if (getWidth() >= 0 && (getWidthUnits() != Unit.PERCENTAGE || ComponentSizeValidator .parentCanDefineWidth(this))) { - getState().setWidth("" + getCSSWidth()); + getState().width = "" + getCSSWidth(); } else { - getState().setWidth(""); + getState().width = ""; } ErrorMessage error = getErrorMessage(); if (null != error) { - getState().setErrorMessage(error.getFormattedHtmlMessage()); + getState().errorMessage = error.getFormattedHtmlMessage(); } else { - getState().setErrorMessage(null); + getState().errorMessage = null; } } @@ -766,7 +767,8 @@ public abstract class AbstractComponent extends AbstractClientConnector eventRouter.addListener(eventType, target, method); if (needRepaint) { - getState().addRegisteredEventListener(eventIdentifier); + ComponentStateUtil.addRegisteredEventListener(getState(), + eventIdentifier); } } @@ -814,7 +816,8 @@ public abstract class AbstractComponent extends AbstractClientConnector if (eventRouter != null) { eventRouter.removeListener(eventType, target); if (!eventRouter.hasListeners(eventType)) { - getState().removeRegisteredEventListener(eventIdentifier); + ComponentStateUtil.removeRegisteredEventListener(getState(), + eventIdentifier); } } } diff --git a/server/src/com/vaadin/ui/AbstractComponentContainer.java b/server/src/com/vaadin/ui/AbstractComponentContainer.java index cf3bf1d2b9..31529ca0d6 100644 --- a/server/src/com/vaadin/ui/AbstractComponentContainer.java +++ b/server/src/com/vaadin/ui/AbstractComponentContainer.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2011 Vaadin Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not @@ -115,6 +115,7 @@ public abstract class AbstractComponentContainer extends AbstractComponent * @deprecated Since 7.0, replaced by * {@link #addComponentAttachListener(com.vaadin.ui.ComponentContainer.ComponentAttachListener)} **/ + @Override @Deprecated public void addListener(ComponentAttachListener listener) { addComponentAttachListener(listener); @@ -131,6 +132,7 @@ public abstract class AbstractComponentContainer extends AbstractComponent * @deprecated Since 7.0, replaced by * {@link #addComponentDetachListener(com.vaadin.ui.ComponentContainer.ComponentDetachListener)} **/ + @Override @Deprecated public void addListener(ComponentDetachListener listener) { addComponentDetachListener(listener); @@ -147,6 +149,7 @@ public abstract class AbstractComponentContainer extends AbstractComponent * @deprecated Since 7.0, replaced by * {@link #removeComponentAttachListener(com.vaadin.ui.ComponentContainer.ComponentAttachListener)} **/ + @Override @Deprecated public void removeListener(ComponentAttachListener listener) { removeComponentAttachListener(listener); @@ -163,6 +166,7 @@ public abstract class AbstractComponentContainer extends AbstractComponent * @deprecated Since 7.0, replaced by * {@link #removeComponentDetachListener(com.vaadin.ui.ComponentContainer.ComponentDetachListener)} **/ + @Override @Deprecated public void removeListener(ComponentDetachListener listener) { removeComponentDetachListener(listener); @@ -240,7 +244,7 @@ public abstract class AbstractComponentContainer extends AbstractComponent @Override public void setVisible(boolean visible) { - if (getState().isVisible() == visible) { + if (getState().visible == visible) { return; } diff --git a/server/src/com/vaadin/ui/AbstractEmbedded.java b/server/src/com/vaadin/ui/AbstractEmbedded.java index d94f62120f..5c72141ef9 100644 --- a/server/src/com/vaadin/ui/AbstractEmbedded.java +++ b/server/src/com/vaadin/ui/AbstractEmbedded.java @@ -52,10 +52,10 @@ public abstract class AbstractEmbedded extends AbstractComponent { * content. */ public void setAlternateText(String altText) { - if (altText != getState().getAlternateText() - || (altText != null && !altText.equals(getState() - .getAlternateText()))) { - getState().setAlternateText(altText); + if (altText != getState().alternateText + || (altText != null && !altText + .equals(getState().alternateText))) { + getState().alternateText = altText; requestRepaint(); } } @@ -67,7 +67,7 @@ public abstract class AbstractEmbedded extends AbstractComponent { * @returns Alternate text */ public String getAlternateText() { - return getState().getAlternateText(); + return getState().alternateText; } } diff --git a/server/src/com/vaadin/ui/AbstractField.java b/server/src/com/vaadin/ui/AbstractField.java index b1d45ae590..548cb06c8f 100644 --- a/server/src/com/vaadin/ui/AbstractField.java +++ b/server/src/com/vaadin/ui/AbstractField.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2011 Vaadin Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not @@ -355,11 +355,11 @@ public abstract class AbstractField<T> extends AbstractComponent implements */ @Override public boolean isModified() { - return getState().isModified(); + return getState().modified; } private void setModified(boolean modified) { - getState().setModified(modified); + getState().modified = modified; } /** @@ -632,8 +632,8 @@ public abstract class AbstractField<T> extends AbstractComponent implements // Sets the new data source dataSource = newDataSource; - getState().setPropertyReadOnly( - dataSource == null ? false : dataSource.isReadOnly()); + getState().propertyReadOnly = dataSource == null ? false : dataSource + .isReadOnly(); // Check if the current converter is compatible. if (newDataSource != null @@ -1056,6 +1056,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements * @deprecated Since 7.0, replaced by * {@link #addValueChangeListener(com.vaadin.data.Property.ValueChangeListener)} **/ + @Override @Deprecated public void addListener(Property.ValueChangeListener listener) { addValueChangeListener(listener); @@ -1076,6 +1077,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements * @deprecated Since 7.0, replaced by * {@link #removeValueChangeListener(com.vaadin.data.Property.ValueChangeListener)} **/ + @Override @Deprecated public void removeListener(Property.ValueChangeListener listener) { removeValueChangeListener(listener); @@ -1117,7 +1119,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements */ @Override public void readOnlyStatusChange(Property.ReadOnlyStatusChangeEvent event) { - getState().setPropertyReadOnly(event.getProperty().isReadOnly()); + getState().propertyReadOnly = event.getProperty().isReadOnly(); } /** @@ -1167,6 +1169,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements * @deprecated Since 7.0, replaced by * {@link #addReadOnlyStatusChangeListener(com.vaadin.data.Property.ReadOnlyStatusChangeListener)} **/ + @Override @Deprecated public void addListener(Property.ReadOnlyStatusChangeListener listener) { addReadOnlyStatusChangeListener(listener); @@ -1188,6 +1191,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements * @deprecated Since 7.0, replaced by * {@link #removeReadOnlyStatusChangeListener(com.vaadin.data.Property.ReadOnlyStatusChangeListener)} **/ + @Override @Deprecated public void removeListener(Property.ReadOnlyStatusChangeListener listener) { removeReadOnlyStatusChangeListener(listener); @@ -1258,7 +1262,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements */ @Override public int getTabIndex() { - return getState().getTabIndex(); + return getState().tabIndex; } /* @@ -1268,7 +1272,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements */ @Override public void setTabIndex(int tabIndex) { - getState().setTabIndex(tabIndex); + getState().tabIndex = tabIndex; } /** @@ -1350,7 +1354,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements */ @Override public boolean isRequired() { - return getState().isRequired(); + return getState().required; } /** @@ -1370,7 +1374,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements */ @Override public void setRequired(boolean required) { - getState().setRequired(required); + getState().required = required; } /** @@ -1569,7 +1573,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements super.beforeClientResponse(initial); // Hide the error indicator if needed - getState().setHideErrors(shouldHideErrors()); + getState().hideErrors = shouldHideErrors(); } /** 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<URLReference> sources = getState().getSources(); + List<URLReference> 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<URLReference> sources = getState().getSources(); + List<URLReference> sources = getState().sources; int sourceIndex = Integer.parseInt(matcher.group(1)); @@ -128,7 +128,7 @@ public abstract class AbstractMedia extends AbstractComponent { */ public List<Resource> getSources() { ArrayList<Resource> sources = new ArrayList<Resource>(); - 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/AbstractOrderedLayout.java b/server/src/com/vaadin/ui/AbstractOrderedLayout.java index 184f7c40f4..4e27dbb158 100644 --- a/server/src/com/vaadin/ui/AbstractOrderedLayout.java +++ b/server/src/com/vaadin/ui/AbstractOrderedLayout.java @@ -143,11 +143,11 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements } private void componentRemoved(Component c) { - getState().getChildData().remove(c); + getState().childData.remove(c); } private void componentAdded(Component c) { - getState().getChildData().put(c, new ChildComponentData()); + getState().childData.put(c, new ChildComponentData()); } /** @@ -232,11 +232,11 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements @Override public void setComponentAlignment(Component childComponent, Alignment alignment) { - ChildComponentData childData = getState().getChildData().get( + ChildComponentData childData = getState().childData.get( childComponent); if (childData != null) { // Alignments are bit masks - childData.setAlignmentBitmask(alignment.getBitMask()); + childData.alignmentBitmask = alignment.getBitMask(); } else { throw new IllegalArgumentException( "Component must be added to layout before using setComponentAlignment()"); @@ -252,14 +252,14 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements */ @Override public Alignment getComponentAlignment(Component childComponent) { - ChildComponentData childData = getState().getChildData().get( + ChildComponentData childData = getState().childData.get( childComponent); if (childData == null) { throw new IllegalArgumentException( "The given component is not a child of this layout"); } - return new Alignment(childData.getAlignmentBitmask()); + return new Alignment(childData.alignmentBitmask); } /* @@ -269,7 +269,7 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements */ @Override public void setSpacing(boolean spacing) { - getState().setSpacing(spacing); + getState().spacing = spacing; } /* @@ -279,7 +279,7 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements */ @Override public boolean isSpacing() { - return getState().isSpacing(); + return getState().spacing; } /** @@ -312,13 +312,13 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements * @param ratio */ public void setExpandRatio(Component component, float ratio) { - ChildComponentData childData = getState().getChildData().get(component); + ChildComponentData childData = getState().childData.get(component); if (childData == null) { throw new IllegalArgumentException( "The given component is not a child of this layout"); } - childData.setExpandRatio(ratio); + childData.expandRatio = ratio; } /** @@ -329,13 +329,13 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements * @return expand ratio of given component, 0.0f by default. */ public float getExpandRatio(Component component) { - ChildComponentData childData = getState().getChildData().get(component); + ChildComponentData childData = getState().childData.get(component); if (childData == null) { throw new IllegalArgumentException( "The given component is not a child of this layout"); } - return childData.getExpandRatio(); + return childData.expandRatio; } @Override @@ -349,6 +349,7 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements * @deprecated Since 7.0, replaced by * {@link #addLayoutClickListener(LayoutClickListener)} **/ + @Override @Deprecated public void addListener(LayoutClickListener listener) { addLayoutClickListener(listener); @@ -364,6 +365,7 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements * @deprecated Since 7.0, replaced by * {@link #removeLayoutClickListener(LayoutClickListener)} **/ + @Override @Deprecated public void removeListener(LayoutClickListener listener) { removeLayoutClickListener(listener); @@ -405,7 +407,7 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements */ @Override public MarginInfo getMargin() { - return new MarginInfo(getState().getMarginsBitmask()); + return new MarginInfo(getState().marginsBitmask); } /* @@ -415,6 +417,6 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements */ @Override public void setMargin(MarginInfo marginInfo) { - getState().setMarginsBitmask(marginInfo.getBitMask()); + getState().marginsBitmask = marginInfo.getBitMask(); } } diff --git a/server/src/com/vaadin/ui/AbstractSelect.java b/server/src/com/vaadin/ui/AbstractSelect.java index 3dba5088df..2fc3bf4080 100644 --- a/server/src/com/vaadin/ui/AbstractSelect.java +++ b/server/src/com/vaadin/ui/AbstractSelect.java @@ -40,12 +40,11 @@ import com.vaadin.event.dd.acceptcriteria.ClientSideCriterion; import com.vaadin.event.dd.acceptcriteria.ContainsDataFlavor; import com.vaadin.event.dd.acceptcriteria.TargetDetailIs; import com.vaadin.server.KeyMapper; +import com.vaadin.server.LegacyComponent; import com.vaadin.server.PaintException; import com.vaadin.server.PaintTarget; import com.vaadin.server.Resource; -import com.vaadin.server.LegacyComponent; import com.vaadin.shared.ui.dd.VerticalDropLocation; -import com.vaadin.ui.AbstractSelect.ItemCaptionMode; /** * <p> @@ -109,43 +108,44 @@ public abstract class AbstractSelect extends AbstractField<Object> implements } /** - * @deprecated from 7.0, use {@link ItemCaptionMode.ID} instead + * @deprecated from 7.0, use {@link ItemCaptionMode#ID} instead */ @Deprecated public static final ItemCaptionMode ITEM_CAPTION_MODE_ID = ItemCaptionMode.ID; /** - * @deprecated from 7.0, use {@link ItemCaptionMode.ID} instead + * @deprecated from 7.0, use {@link ItemCaptionMode#ITEM} instead */ @Deprecated public static final ItemCaptionMode ITEM_CAPTION_MODE_ITEM = ItemCaptionMode.ITEM; /** - * @deprecated from 7.0, use {@link ItemCaptionMode.ID} instead + * @deprecated from 7.0, use {@link ItemCaptionMode#INDEX} instead */ @Deprecated public static final ItemCaptionMode ITEM_CAPTION_MODE_INDEX = ItemCaptionMode.INDEX; /** - * @deprecated from 7.0, use {@link ItemCaptionMode.ID} instead + * @deprecated from 7.0, use {@link ItemCaptionMode#EXPLICIT_DEFAULTS_ID} + * instead */ @Deprecated public static final ItemCaptionMode ITEM_CAPTION_MODE_EXPLICIT_DEFAULTS_ID = ItemCaptionMode.EXPLICIT_DEFAULTS_ID; /** - * @deprecated from 7.0, use {@link ItemCaptionMode.ID} instead + * @deprecated from 7.0, use {@link ItemCaptionMode#EXPLICIT} instead */ @Deprecated public static final ItemCaptionMode ITEM_CAPTION_MODE_EXPLICIT = ItemCaptionMode.EXPLICIT; /** - * @deprecated from 7.0, use {@link ItemCaptionMode.ID} instead + * @deprecated from 7.0, use {@link ItemCaptionMode#ICON_ONLY} instead */ @Deprecated public static final ItemCaptionMode ITEM_CAPTION_MODE_ICON_ONLY = ItemCaptionMode.ICON_ONLY; /** - * @deprecated from 7.0, use {@link ItemCaptionMode.ID} instead + * @deprecated from 7.0, use {@link ItemCaptionMode#PROPERTY} instead */ @Deprecated public static final ItemCaptionMode ITEM_CAPTION_MODE_PROPERTY = ItemCaptionMode.PROPERTY; diff --git a/server/src/com/vaadin/ui/AbstractSplitPanel.java b/server/src/com/vaadin/ui/AbstractSplitPanel.java index f1452caacf..c5df57b36f 100644 --- a/server/src/com/vaadin/ui/AbstractSplitPanel.java +++ b/server/src/com/vaadin/ui/AbstractSplitPanel.java @@ -56,7 +56,7 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer { @Override public void setSplitterPosition(float position) { - getSplitterState().setPosition(position); + getSplitterState().position = position; } }; @@ -150,7 +150,7 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer { // detach old removeComponent(getFirstComponent()); } - getState().setFirstChild(c); + getState().firstChild = c; if (c != null) { super.addComponent(c); } @@ -173,7 +173,7 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer { // detach old removeComponent(getSecondComponent()); } - getState().setSecondChild(c); + getState().secondChild = c; if (c != null) { super.addComponent(c); } @@ -186,7 +186,7 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer { * @return the first component of this split panel */ public Component getFirstComponent() { - return (Component) getState().getFirstChild(); + return (Component) getState().firstChild; } /** @@ -196,7 +196,7 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer { * @return the second component of this split panel */ public Component getSecondComponent() { - return (Component) getState().getSecondChild(); + return (Component) getState().secondChild; } /** @@ -210,9 +210,9 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer { public void removeComponent(Component c) { super.removeComponent(c); if (c == getFirstComponent()) { - getState().setFirstChild(null); + getState().firstChild = null; } else if (c == getSecondComponent()) { - getState().setSecondChild(null); + getState().secondChild = null; } markAsDirty(); } @@ -322,9 +322,9 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer { pos = Math.round(pos); } SplitterState splitterState = getSplitterState(); - splitterState.setPosition(pos); - splitterState.setPositionUnit(unit.getSymbol()); - splitterState.setPositionReversed(reverse); + splitterState.position = pos; + splitterState.positionUnit = unit.getSymbol(); + splitterState.positionReversed = reverse; posUnit = unit; } @@ -335,7 +335,7 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer { * @return position of the splitter */ public float getSplitPosition() { - return getSplitterState().getPosition(); + return getSplitterState().position; } /** @@ -358,7 +358,7 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer { * Allowed units are UNITS_PERCENTAGE and UNITS_PIXELS */ public void setMinSplitPosition(int pos, Unit unit) { - setSplitPositionLimits(pos, unit, getSplitterState().getMaxPosition(), + setSplitPositionLimits(pos, unit, getSplitterState().maxPosition, posMaxUnit); } @@ -369,7 +369,7 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer { * @return the minimum position of the splitter */ public float getMinSplitPosition() { - return getSplitterState().getMinPosition(); + return getSplitterState().minPosition; } /** @@ -392,7 +392,7 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer { * Allowed units are UNITS_PERCENTAGE and UNITS_PIXELS */ public void setMaxSplitPosition(float pos, Unit unit) { - setSplitPositionLimits(getSplitterState().getMinPosition(), posMinUnit, + setSplitPositionLimits(getSplitterState().minPosition, posMinUnit, pos, unit); } @@ -403,7 +403,7 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer { * @return the maximum position of the splitter */ public float getMaxSplitPosition() { - return getSplitterState().getMaxPosition(); + return getSplitterState().maxPosition; } /** @@ -440,12 +440,12 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer { SplitterState state = getSplitterState(); - state.setMinPosition(minPos); - state.setMinPositionUnit(minPosUnit.getSymbol()); + state.minPosition = minPos; + state.minPositionUnit = minPosUnit.getSymbol(); posMinUnit = minPosUnit; - state.setMaxPosition(maxPos); - state.setMaxPositionUnit(maxPosUnit.getSymbol()); + state.maxPosition = maxPos; + state.maxPositionUnit = maxPosUnit.getSymbol(); posMaxUnit = maxPosUnit; } @@ -457,7 +457,7 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer { * Set <code>true</code> if locked, <code>false</code> otherwise. */ public void setLocked(boolean locked) { - getSplitterState().setLocked(locked); + getSplitterState().locked = locked; } /** @@ -467,7 +467,7 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer { * @return <code>true</code> if locked, <code>false</code> otherwise. */ public boolean isLocked() { - return getSplitterState().isLocked(); + return getSplitterState().locked; } /** @@ -535,6 +535,6 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer { } private SplitterState getSplitterState() { - return getState().getSplitterState(); + return getState().splitterState; } } diff --git a/server/src/com/vaadin/ui/AbstractTextField.java b/server/src/com/vaadin/ui/AbstractTextField.java index c187d9e198..0cb74dae6d 100644 --- a/server/src/com/vaadin/ui/AbstractTextField.java +++ b/server/src/com/vaadin/ui/AbstractTextField.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2011 Vaadin Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not @@ -27,9 +27,9 @@ import com.vaadin.event.FieldEvents.FocusNotifier; import com.vaadin.event.FieldEvents.TextChangeEvent; import com.vaadin.event.FieldEvents.TextChangeListener; import com.vaadin.event.FieldEvents.TextChangeNotifier; +import com.vaadin.server.LegacyComponent; import com.vaadin.server.PaintException; import com.vaadin.server.PaintTarget; -import com.vaadin.server.LegacyComponent; import com.vaadin.shared.ui.textfield.AbstractTextFieldState; import com.vaadin.shared.ui.textfield.TextFieldConstants; @@ -104,7 +104,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements if (value == null) { value = getNullRepresentation(); } - getState().setText(value); + getState().text = value; } @Override @@ -312,7 +312,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements * @return the maxLength */ public int getMaxLength() { - return getState().getMaxLength(); + return getState().maxLength; } /** @@ -323,7 +323,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements * the maxLength to set */ public void setMaxLength(int maxLength) { - getState().setMaxLength(maxLength); + getState().maxLength = maxLength; } /** @@ -334,7 +334,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements * @return the number of columns in the editor. */ public int getColumns() { - return getState().getColumns(); + return getState().columns; } /** @@ -349,7 +349,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements if (columns < 0) { columns = 0; } - getState().setColumns(columns); + getState().columns = columns; } /** @@ -359,7 +359,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements * @return the current input prompt, or null if not enabled */ public String getInputPrompt() { - return getState().getInputPrompt(); + return getState().inputPrompt; } /** @@ -369,7 +369,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements * @param inputPrompt */ public void setInputPrompt(String inputPrompt) { - getState().setInputPrompt(inputPrompt); + getState().inputPrompt = inputPrompt; } /* ** Text Change Events ** */ @@ -521,6 +521,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements * @deprecated Since 7.0, replaced by * {@link #addTextChangeListener(TextChangeListener)} **/ + @Override @Deprecated public void addListener(TextChangeListener listener) { addTextChangeListener(listener); @@ -536,6 +537,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements * @deprecated Since 7.0, replaced by * {@link #removeTextChangeListener(TextChangeListener)} **/ + @Override @Deprecated public void removeListener(TextChangeListener listener) { removeTextChangeListener(listener); @@ -688,6 +690,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements * @deprecated Since 7.0, replaced by * {@link #addFocusListener(FocusListener)} **/ + @Override @Deprecated public void addListener(FocusListener listener) { addFocusListener(listener); @@ -702,6 +705,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements * @deprecated Since 7.0, replaced by * {@link #removeFocusListener(FocusListener)} **/ + @Override @Deprecated public void removeListener(FocusListener listener) { removeFocusListener(listener); @@ -716,6 +720,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements /** * @deprecated Since 7.0, replaced by {@link #addBlurListener(BlurListener)} **/ + @Override @Deprecated public void addListener(BlurListener listener) { addBlurListener(listener); @@ -730,6 +735,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements * @deprecated Since 7.0, replaced by * {@link #removeBlurListener(BlurListener)} **/ + @Override @Deprecated public void removeListener(BlurListener listener) { removeBlurListener(listener); diff --git a/server/src/com/vaadin/ui/Button.java b/server/src/com/vaadin/ui/Button.java index 2e026ebc52..bbed7d540f 100644 --- a/server/src/com/vaadin/ui/Button.java +++ b/server/src/com/vaadin/ui/Button.java @@ -367,6 +367,7 @@ public class Button extends AbstractComponent implements /** * @deprecated Since 7.0, replaced by {@link #addBlurListener(BlurListener)} **/ + @Override @Deprecated public void addListener(BlurListener listener) { addBlurListener(listener); @@ -381,6 +382,7 @@ public class Button extends AbstractComponent implements * @deprecated Since 7.0, replaced by * {@link #removeBlurListener(BlurListener)} **/ + @Override @Deprecated public void removeListener(BlurListener listener) { removeBlurListener(listener); @@ -396,6 +398,7 @@ public class Button extends AbstractComponent implements * @deprecated Since 7.0, replaced by * {@link #addFocusListener(FocusListener)} **/ + @Override @Deprecated public void addListener(FocusListener listener) { addFocusListener(listener); @@ -410,6 +413,7 @@ public class Button extends AbstractComponent implements * @deprecated Since 7.0, replaced by * {@link #removeFocusListener(FocusListener)} **/ + @Override @Deprecated public void removeListener(FocusListener listener) { removeFocusListener(listener); @@ -438,7 +442,7 @@ public class Button extends AbstractComponent implements } clickShortcut = new ClickShortcut(this, keyCode, modifiers); addShortcutListener(clickShortcut); - getState().setClickShortcutKeyCode(clickShortcut.getKeyCode()); + getState().clickShortcutKeyCode = clickShortcut.getKeyCode(); } /** @@ -449,7 +453,7 @@ public class Button extends AbstractComponent implements if (clickShortcut != null) { removeShortcutListener(clickShortcut); clickShortcut = null; - getState().setClickShortcutKeyCode(0); + getState().clickShortcutKeyCode = 0; } } @@ -517,7 +521,7 @@ public class Button extends AbstractComponent implements * @return true if the button is disabled when clicked, false otherwise */ public boolean isDisableOnClick() { - return getState().isDisableOnClick(); + return getState().disableOnClick; } /** @@ -533,7 +537,7 @@ public class Button extends AbstractComponent implements * true to disable button when it is clicked, false otherwise */ public void setDisableOnClick(boolean disableOnClick) { - getState().setDisableOnClick(disableOnClick); + getState().disableOnClick = disableOnClick; } /* @@ -543,7 +547,7 @@ public class Button extends AbstractComponent implements */ @Override public int getTabIndex() { - return getState().getTabIndex(); + return getState().tabIndex; } /* @@ -553,7 +557,7 @@ public class Button extends AbstractComponent implements */ @Override public void setTabIndex(int tabIndex) { - getState().setTabIndex(tabIndex); + getState().tabIndex = tabIndex; } @Override @@ -580,7 +584,7 @@ public class Button extends AbstractComponent implements * <code>false</code> otherwise */ public void setHtmlContentAllowed(boolean htmlContentAllowed) { - getState().setHtmlContentAllowed(htmlContentAllowed); + getState().htmlContentAllowed = htmlContentAllowed; } /** @@ -590,7 +594,7 @@ public class Button extends AbstractComponent implements * <code>false</code> otherwise */ public boolean isHtmlContentAllowed() { - return getState().isHtmlContentAllowed(); + return getState().htmlContentAllowed; } } diff --git a/server/src/com/vaadin/ui/CheckBox.java b/server/src/com/vaadin/ui/CheckBox.java index 149d4779d8..8a42182598 100644 --- a/server/src/com/vaadin/ui/CheckBox.java +++ b/server/src/com/vaadin/ui/CheckBox.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2011 Vaadin Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not @@ -116,7 +116,7 @@ public class CheckBox extends AbstractField<Boolean> { if (newValue == null) { newValue = false; } - getState().setChecked(newValue); + getState().checked = newValue; } public void addBlurListener(BlurListener listener) { diff --git a/server/src/com/vaadin/ui/ComboBox.java b/server/src/com/vaadin/ui/ComboBox.java index da3d2fd91d..2555aac339 100644 --- a/server/src/com/vaadin/ui/ComboBox.java +++ b/server/src/com/vaadin/ui/ComboBox.java @@ -358,39 +358,45 @@ public class ComboBox extends AbstractSelect implements filterable.addContainerFilter(filter); } - Indexed indexed = (Indexed) container; + // try-finally to ensure that the filter is removed from container even + // if a exception is thrown... + try { + Indexed indexed = (Indexed) container; - int indexToEnsureInView = -1; + int indexToEnsureInView = -1; - // if not an option request (item list when user changes page), go - // to page with the selected item after filtering if accepted by - // filter - Object selection = getValue(); - if (isScrollToSelectedItem() && !optionRequest && selection != null) { - // ensure proper page - indexToEnsureInView = indexed.indexOfId(selection); - } + // if not an option request (item list when user changes page), go + // to page with the selected item after filtering if accepted by + // filter + Object selection = getValue(); + if (isScrollToSelectedItem() && !optionRequest && selection != null) { + // ensure proper page + indexToEnsureInView = indexed.indexOfId(selection); + } - filteredSize = container.size(); - currentPage = adjustCurrentPage(currentPage, needNullSelectOption, - indexToEnsureInView, filteredSize); - int first = getFirstItemIndexOnCurrentPage(needNullSelectOption, - filteredSize); - int last = getLastItemIndexOnCurrentPage(needNullSelectOption, - filteredSize, first); - - List<Object> options = new ArrayList<Object>(); - for (int i = first; i <= last && i < filteredSize; ++i) { - options.add(indexed.getIdByIndex(i)); - } + filteredSize = container.size(); + currentPage = adjustCurrentPage(currentPage, needNullSelectOption, + indexToEnsureInView, filteredSize); + int first = getFirstItemIndexOnCurrentPage(needNullSelectOption, + filteredSize); + int last = getLastItemIndexOnCurrentPage(needNullSelectOption, + filteredSize, first); - // to the outside, filtering should not be visible - if (filter != null) { - filterable.removeContainerFilter(filter); - filteringContainer = false; - } + // Compute the number of items to fetch from the indexes given or + // based on the filtered size of the container + int lastItemToFetch = Math.min(last, filteredSize - 1); + int nrOfItemsToFetch = (lastItemToFetch + 1) - first; + + List<?> options = indexed.getItemIds(first, nrOfItemsToFetch); - return options; + return options; + } finally { + // to the outside, filtering should not be visible + if (filter != null) { + filterable.removeContainerFilter(filter); + filteringContainer = false; + } + } } /** diff --git a/server/src/com/vaadin/ui/CssLayout.java b/server/src/com/vaadin/ui/CssLayout.java index b63c8573ba..9ac29c4deb 100644 --- a/server/src/com/vaadin/ui/CssLayout.java +++ b/server/src/com/vaadin/ui/CssLayout.java @@ -199,12 +199,12 @@ public class CssLayout extends AbstractLayout implements LayoutClickNotifier { @Override public void beforeClientResponse(boolean initial) { super.beforeClientResponse(initial); - getState().getChildCss().clear(); + getState().childCss.clear(); for (Iterator<Component> ci = getComponentIterator(); ci.hasNext();) { Component child = ci.next(); String componentCssString = getCss(child); if (componentCssString != null) { - getState().getChildCss().put(child, componentCssString); + getState().childCss.put(child, componentCssString); } } @@ -291,6 +291,7 @@ public class CssLayout extends AbstractLayout implements LayoutClickNotifier { * @deprecated Since 7.0, replaced by * {@link #addLayoutClickListener(LayoutClickListener)} **/ + @Override @Deprecated public void addListener(LayoutClickListener listener) { addLayoutClickListener(listener); @@ -306,6 +307,7 @@ public class CssLayout extends AbstractLayout implements LayoutClickNotifier { * @deprecated Since 7.0, replaced by * {@link #removeLayoutClickListener(LayoutClickListener)} **/ + @Override @Deprecated public void removeListener(LayoutClickListener listener) { removeLayoutClickListener(listener); diff --git a/server/src/com/vaadin/ui/CustomLayout.java b/server/src/com/vaadin/ui/CustomLayout.java index f747b6ff3b..828a1b91ad 100644 --- a/server/src/com/vaadin/ui/CustomLayout.java +++ b/server/src/com/vaadin/ui/CustomLayout.java @@ -25,9 +25,9 @@ import java.util.Map; import java.util.Set; import com.vaadin.server.JsonPaintTarget; +import com.vaadin.server.LegacyComponent; import com.vaadin.server.PaintException; import com.vaadin.server.PaintTarget; -import com.vaadin.server.LegacyComponent; import com.vaadin.shared.ui.customlayout.CustomLayoutState; /** @@ -142,7 +142,7 @@ public class CustomLayout extends AbstractLayout implements LegacyComponent { removeComponent(old); } slots.put(location, c); - getState().getChildLocations().put(c, location); + getState().childLocations.put(c, location); c.setParent(this); fireComponentAttachEvent(c); } @@ -173,7 +173,7 @@ public class CustomLayout extends AbstractLayout implements LegacyComponent { return; } slots.values().remove(c); - getState().getChildLocations().remove(c); + getState().childLocations.remove(c); super.removeComponent(c); } @@ -247,19 +247,19 @@ public class CustomLayout extends AbstractLayout implements LegacyComponent { } else { slots.put(newLocation, oldComponent); slots.put(oldLocation, newComponent); - getState().getChildLocations().put(newComponent, oldLocation); - getState().getChildLocations().put(oldComponent, newLocation); + getState().childLocations.put(newComponent, oldLocation); + getState().childLocations.put(oldComponent, newLocation); } } /** Get the name of the template */ public String getTemplateName() { - return getState().getTemplateName(); + return getState().templateName; } /** Get the contents of the template */ public String getTemplateContents() { - return getState().getTemplateContents(); + return getState().templateContents; } /** @@ -272,8 +272,8 @@ public class CustomLayout extends AbstractLayout implements LegacyComponent { * @param templateName */ public void setTemplateName(String templateName) { - getState().setTemplateName(templateName); - getState().setTemplateContents(null); + getState().templateName = templateName; + getState().templateContents = null; } /** @@ -282,8 +282,8 @@ public class CustomLayout extends AbstractLayout implements LegacyComponent { * @param templateContents */ public void setTemplateContents(String templateContents) { - getState().setTemplateContents(templateContents); - getState().setTemplateName(null); + getState().templateContents = templateContents; + getState().templateName = null; } @Override @@ -295,7 +295,7 @@ public class CustomLayout extends AbstractLayout implements LegacyComponent { public void paintContent(PaintTarget target) throws PaintException { // Workaround to make the CommunicationManager read the template file // and send it to the client - String templateName = getState().getTemplateName(); + String templateName = getState().templateName; if (templateName != null && templateName.length() != 0) { Set<Object> usedResources = ((JsonPaintTarget) target) .getUsedResources(); diff --git a/server/src/com/vaadin/ui/Flash.java b/server/src/com/vaadin/ui/Flash.java index 0e6cf63a91..d39f34634e 100644 --- a/server/src/com/vaadin/ui/Flash.java +++ b/server/src/com/vaadin/ui/Flash.java @@ -33,10 +33,10 @@ public class Flash extends AbstractEmbedded { * The base path */ public void setCodebase(String codebase) { - if (codebase != getState().getCodebase() + if (codebase != getState().codebase || (codebase != null && !codebase.equals(getState() - .getCodebase()))) { - getState().setCodebase(codebase); +.codebase))) { + getState().codebase = codebase; requestRepaint(); } } @@ -52,10 +52,10 @@ public class Flash extends AbstractEmbedded { * the codetype to set. */ public void setCodetype(String codetype) { - if (codetype != getState().getCodetype() + if (codetype != getState().codetype || (codetype != null && !codetype.equals(getState() - .getCodetype()))) { - getState().setCodetype(codetype); +.codetype))) { + getState().codetype = codetype; requestRepaint(); } } @@ -73,17 +73,17 @@ public class Flash extends AbstractEmbedded { * object */ public void setArchive(String archive) { - if (archive != getState().getArchive() - || (archive != null && !archive.equals(getState().getArchive()))) { - getState().setArchive(archive); + if (archive != getState().archive + || (archive != null && !archive.equals(getState().archive))) { + getState().archive = archive; requestRepaint(); } } public void setStandby(String standby) { - if (standby != getState().getStandby() - || (standby != null && !standby.equals(getState().getStandby()))) { - getState().setStandby(standby); + if (standby != getState().standby + || (standby != null && !standby.equals(getState().standby))) { + getState().standby = standby; requestRepaint(); } } @@ -100,10 +100,10 @@ public class Flash extends AbstractEmbedded { * the value of the parameter. */ public void setParameter(String name, String value) { - if (getState().getEmbedParams() == null) { - getState().setEmbedParams(new HashMap<String, String>()); + if (getState().embedParams == null) { + getState().embedParams = new HashMap<String, String>(); } - getState().getEmbedParams().put(name, value); + getState().embedParams.put(name, value); requestRepaint(); } @@ -115,8 +115,8 @@ public class Flash extends AbstractEmbedded { * @return the Value of parameter or null if not found. */ public String getParameter(String name) { - return getState().getEmbedParams() != null ? getState() - .getEmbedParams().get(name) : null; + return getState().embedParams != null ? getState().embedParams + .get(name) : null; } /** @@ -126,10 +126,10 @@ public class Flash extends AbstractEmbedded { * the name of the parameter to remove. */ public void removeParameter(String name) { - if (getState().getEmbedParams() == null) { + if (getState().embedParams == null) { return; } - getState().getEmbedParams().remove(name); + getState().embedParams.remove(name); requestRepaint(); } diff --git a/server/src/com/vaadin/ui/Form.java b/server/src/com/vaadin/ui/Form.java index 7e77117acb..dd804ef67a 100644 --- a/server/src/com/vaadin/ui/Form.java +++ b/server/src/com/vaadin/ui/Form.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2011 Vaadin Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not @@ -39,10 +39,10 @@ import com.vaadin.event.ActionManager; import com.vaadin.server.AbstractErrorMessage; import com.vaadin.server.CompositeErrorMessage; import com.vaadin.server.ErrorMessage; +import com.vaadin.server.LegacyComponent; import com.vaadin.server.PaintException; import com.vaadin.server.PaintTarget; import com.vaadin.server.UserError; -import com.vaadin.server.LegacyComponent; import com.vaadin.shared.ui.form.FormState; /** @@ -776,7 +776,7 @@ public class Form extends AbstractField<Object> implements Item.Editor, * @return the Layout of the form. */ public Layout getLayout() { - return (Layout) getState().getLayout(); + return (Layout) getState().layout; } /** @@ -819,7 +819,7 @@ public class Form extends AbstractField<Object> implements Item.Editor, // Replace the previous layout layout.setParent(this); - getState().setLayout(layout); + getState().layout = layout; } /** @@ -1214,7 +1214,7 @@ public class Form extends AbstractField<Object> implements Item.Editor, * @return layout rendered below normal form contents. */ public Layout getFooter() { - return (Layout) getState().getFooter(); + return (Layout) getState().footer; } /** @@ -1233,7 +1233,7 @@ public class Form extends AbstractField<Object> implements Item.Editor, footer = new HorizontalLayout(); } - getState().setFooter(footer); + getState().footer = footer; footer.setParent(this); } diff --git a/server/src/com/vaadin/ui/GridLayout.java b/server/src/com/vaadin/ui/GridLayout.java index 21602c6802..de167962e7 100644 --- a/server/src/com/vaadin/ui/GridLayout.java +++ b/server/src/com/vaadin/ui/GridLayout.java @@ -27,10 +27,10 @@ import java.util.Map.Entry; import com.vaadin.event.LayoutEvents.LayoutClickEvent; import com.vaadin.event.LayoutEvents.LayoutClickListener; import com.vaadin.event.LayoutEvents.LayoutClickNotifier; +import com.vaadin.server.LegacyComponent; import com.vaadin.server.LegacyPaint; import com.vaadin.server.PaintException; import com.vaadin.server.PaintTarget; -import com.vaadin.server.LegacyComponent; import com.vaadin.shared.Connector; import com.vaadin.shared.EventId; import com.vaadin.shared.MouseEventDetails; @@ -961,7 +961,7 @@ public class GridLayout extends AbstractLayout implements } } - getState().setColumns(columns); + getState().columns = columns; } /** @@ -970,7 +970,7 @@ public class GridLayout extends AbstractLayout implements * @return the number of columns in the grid. */ public int getColumns() { - return getState().getColumns(); + return getState().columns; } /** @@ -1003,7 +1003,7 @@ public class GridLayout extends AbstractLayout implements } } - getState().setRows(rows); + getState().rows = rows; } /** @@ -1012,7 +1012,7 @@ public class GridLayout extends AbstractLayout implements * @return the number of rows in the grid. */ public int getRows() { - return getState().getRows(); + return getState().rows; } /** @@ -1127,7 +1127,7 @@ public class GridLayout extends AbstractLayout implements */ @Override public void setSpacing(boolean spacing) { - getState().setSpacing(spacing); + getState().spacing = spacing; } /* @@ -1137,7 +1137,7 @@ public class GridLayout extends AbstractLayout implements */ @Override public boolean isSpacing() { - return getState().isSpacing(); + return getState().spacing; } /** @@ -1405,7 +1405,7 @@ public class GridLayout extends AbstractLayout implements */ @Override public void setMargin(MarginInfo marginInfo) { - getState().setMarginsBitmask(marginInfo.getBitMask()); + getState().marginsBitmask = marginInfo.getBitMask(); } /* @@ -1415,7 +1415,7 @@ public class GridLayout extends AbstractLayout implements */ @Override public MarginInfo getMargin() { - return new MarginInfo(getState().getMarginsBitmask()); + return new MarginInfo(getState().marginsBitmask); } } 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/server/src/com/vaadin/ui/Panel.java b/server/src/com/vaadin/ui/Panel.java index 6f399bcc19..de34c0be2c 100644 --- a/server/src/com/vaadin/ui/Panel.java +++ b/server/src/com/vaadin/ui/Panel.java @@ -25,10 +25,10 @@ import com.vaadin.event.Action.Handler; import com.vaadin.event.ActionManager; import com.vaadin.event.MouseEvents.ClickEvent; import com.vaadin.event.MouseEvents.ClickListener; +import com.vaadin.server.LegacyComponent; import com.vaadin.server.PaintException; import com.vaadin.server.PaintTarget; import com.vaadin.server.Scrollable; -import com.vaadin.server.LegacyComponent; import com.vaadin.shared.EventId; import com.vaadin.shared.MouseEventDetails; import com.vaadin.shared.ui.panel.PanelServerRpc; @@ -83,7 +83,7 @@ public class Panel extends AbstractComponentContainer implements Scrollable, registerRpc(rpc); setContent(content); setWidth(100, Unit.PERCENTAGE); - getState().setTabIndex(-1); + getState().tabIndex = -1; } /** @@ -269,11 +269,11 @@ public class Panel extends AbstractComponentContainer implements Scrollable, final Integer newScrollY = (Integer) variables.get("scrollTop"); if (newScrollX != null && newScrollX.intValue() != getScrollLeft()) { // set internally, not to fire request repaint - getState().setScrollLeft(newScrollX.intValue()); + getState().scrollLeft = newScrollX.intValue(); } if (newScrollY != null && newScrollY.intValue() != getScrollTop()) { // set internally, not to fire request repaint - getState().setScrollTop(newScrollY.intValue()); + getState().scrollTop = newScrollY.intValue(); } // Actions @@ -292,7 +292,7 @@ public class Panel extends AbstractComponentContainer implements Scrollable, */ @Override public int getScrollLeft() { - return getState().getScrollLeft(); + return getState().scrollLeft; } /* @@ -302,7 +302,7 @@ public class Panel extends AbstractComponentContainer implements Scrollable, */ @Override public int getScrollTop() { - return getState().getScrollTop(); + return getState().scrollTop; } /* @@ -316,7 +316,7 @@ public class Panel extends AbstractComponentContainer implements Scrollable, throw new IllegalArgumentException( "Scroll offset must be at least 0"); } - getState().setScrollLeft(scrollLeft); + getState().scrollLeft = scrollLeft; } /* @@ -330,7 +330,7 @@ public class Panel extends AbstractComponentContainer implements Scrollable, throw new IllegalArgumentException( "Scroll offset must be at least 0"); } - getState().setScrollTop(scrollTop); + getState().scrollTop = scrollTop; } /* Documented in superclass */ @@ -471,7 +471,7 @@ public class Panel extends AbstractComponentContainer implements Scrollable, */ @Override public int getTabIndex() { - return getState().getTabIndex(); + return getState().tabIndex; } /** @@ -479,7 +479,7 @@ public class Panel extends AbstractComponentContainer implements Scrollable, */ @Override public void setTabIndex(int tabIndex) { - getState().setTabIndex(tabIndex); + getState().tabIndex = tabIndex; } /** diff --git a/server/src/com/vaadin/ui/Slider.java b/server/src/com/vaadin/ui/Slider.java index 660bf739ae..fe913f6b2c 100644 --- a/server/src/com/vaadin/ui/Slider.java +++ b/server/src/com/vaadin/ui/Slider.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2011 Vaadin Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not @@ -25,10 +25,10 @@ import com.vaadin.shared.ui.slider.SliderState; * * Example code: <code> * class MyPlayer extends CustomComponent implements ValueChangeListener { - * + * * Label volumeIndicator = new Label(); * Slider slider; - * + * * public MyPlayer() { * VerticalLayout vl = new VerticalLayout(); * setCompositionRoot(vl); @@ -68,11 +68,11 @@ public class Slider extends AbstractField<Double> { } catch (final ValueOutOfBoundsException e) { // Convert to nearest bound double out = e.getValue().doubleValue(); - if (out < getState().getMinValue()) { - out = getState().getMinValue(); + if (out < getState().minValue) { + out = getState().minValue; } - if (out > getState().getMaxValue()) { - out = getState().getMaxValue(); + if (out > getState().maxValue) { + out = getState().maxValue; } Slider.super.setValue(new Double(out), false); } @@ -88,7 +88,7 @@ public class Slider extends AbstractField<Double> { public Slider() { super(); registerRpc(rpc); - super.setValue(new Double(getState().getMinValue())); + super.setValue(new Double(getState().minValue)); } /** @@ -164,7 +164,7 @@ public class Slider extends AbstractField<Double> { * @return the largest value the slider can have */ public double getMax() { - return getState().getMaxValue(); + return getState().maxValue; } /** @@ -175,7 +175,7 @@ public class Slider extends AbstractField<Double> { * The new maximum slider value */ public void setMax(double max) { - getState().setMaxValue(max); + getState().maxValue = max; if (getValue() > max) { setValue(max); } @@ -187,7 +187,7 @@ public class Slider extends AbstractField<Double> { * @return the smallest value the slider can have */ public double getMin() { - return getState().getMinValue(); + return getState().minValue; } /** @@ -198,7 +198,7 @@ public class Slider extends AbstractField<Double> { * The new minimum slider value */ public void setMin(double min) { - getState().setMinValue(min); + getState().minValue = min; if (getValue() < min) { setValue(min); } @@ -211,7 +211,7 @@ public class Slider extends AbstractField<Double> { * {@link SliderOrientation#VERTICAL} */ public SliderOrientation getOrientation() { - return getState().getOrientation(); + return getState().orientation; } /** @@ -223,7 +223,7 @@ public class Slider extends AbstractField<Double> { * {@link SliderOrientation#VERTICAL} */ public void setOrientation(SliderOrientation orientation) { - getState().setOrientation(orientation); + getState().orientation = orientation; } /** @@ -233,7 +233,7 @@ public class Slider extends AbstractField<Double> { * @return resolution */ public int getResolution() { - return getState().getResolution(); + return getState().resolution; } /** @@ -250,7 +250,7 @@ public class Slider extends AbstractField<Double> { throw new IllegalArgumentException( "Cannot set a negative resolution to Slider"); } - getState().setResolution(resolution); + getState().resolution = resolution; } /** @@ -284,7 +284,7 @@ public class Slider extends AbstractField<Double> { } } - getState().setValue(newValue); + getState().value = newValue; super.setValue(newValue, repaintIsNotNeeded); } @@ -296,7 +296,7 @@ public class Slider extends AbstractField<Double> { } super.setValue(newFieldValue); // The cast is safe if the above call returned without throwing - getState().setValue((Double) newFieldValue); + getState().value = (Double) newFieldValue; } /** diff --git a/server/src/com/vaadin/ui/Table.java b/server/src/com/vaadin/ui/Table.java index d1bdcdd708..5eb18ee61f 100644 --- a/server/src/com/vaadin/ui/Table.java +++ b/server/src/com/vaadin/ui/Table.java @@ -27,6 +27,7 @@ import java.util.Iterator; import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.LinkedList; +import java.util.List; import java.util.Map; import java.util.Set; import java.util.StringTokenizer; @@ -1066,6 +1067,23 @@ public class Table extends AbstractSelect implements Action.Container, return currentPageFirstItemId; } + /** + * Returns the item ID for the item represented by the index given. Assumes + * that the current container implements {@link Container.Indexed}. + * + * See {@link Container.Indexed#getIdByIndex(int)} for more information + * about the exceptions that can be thrown. + * + * @param index + * the index for which the item ID should be fetched + * @return the item ID for the given index + * + * @throws ClassCastException + * if container does not implement {@link Container.Indexed} + * @throws IndexOutOfBoundsException + * thrown by {@link Container.Indexed#getIdByIndex(int)} if the + * index is invalid + */ protected Object getIdByIndex(int index) { return ((Container.Indexed) items).getIdByIndex(index); } @@ -1929,17 +1947,6 @@ public class Table extends AbstractSelect implements Action.Container, return cells; } - // Gets the first item id - Object id; - if (items instanceof Container.Indexed) { - id = getIdByIndex(firstIndex); - } else { - id = firstItemId(); - for (int i = 0; i < firstIndex; i++) { - id = nextItemId(id); - } - } - final RowHeaderMode headmode = getRowHeaderMode(); final boolean[] iscomponent = new boolean[cols]; for (int i = 0; i < cols; i++) { @@ -1956,120 +1963,41 @@ public class Table extends AbstractSelect implements Action.Container, // Creates the page contents int filledRows = 0; - for (int i = 0; i < rows && id != null; i++) { - cells[CELL_ITEMID][i] = id; - cells[CELL_KEY][i] = itemIdMapper.key(id); - if (headmode != ROW_HEADER_MODE_HIDDEN) { - switch (headmode) { - case INDEX: - cells[CELL_HEADER][i] = String.valueOf(i + firstIndex + 1); - break; - default: - cells[CELL_HEADER][i] = getItemCaption(id); - } - cells[CELL_ICON][i] = getItemIcon(id); + if (items instanceof Container.Indexed) { + // more efficient implementation for containers supporting access by + // index + + Container.Indexed indexed = ((Container.Indexed) items); + List<?> itemIds = indexed.getItemIds(firstIndex, rows); + for (int i = 0; i < rows && i < itemIds.size(); i++) { + Object id = itemIds.get(i); + // Start by parsing the values, id should already be set + parseItemIdToCells(cells, id, i, firstIndex, headmode, cols, + colids, firstIndexNotInCache, iscomponent, + oldListenedProperties); + + filledRows++; } + } else { + // slow back-up implementation for cases where the container does + // not support access by index - GeneratedRow generatedRow = rowGenerator != null ? rowGenerator - .generateRow(this, id) : null; - cells[CELL_GENERATED_ROW][i] = generatedRow; - - for (int j = 0; j < cols; j++) { - if (isColumnCollapsed(colids[j])) { - continue; - } - Property<?> p = null; - Object value = ""; - boolean isGeneratedRow = generatedRow != null; - boolean isGeneratedColumn = columnGenerators - .containsKey(colids[j]); - boolean isGenerated = isGeneratedRow || isGeneratedColumn; - - if (!isGenerated) { - p = getContainerProperty(id, colids[j]); - } - - if (isGeneratedRow) { - if (generatedRow.isSpanColumns() && j > 0) { - value = null; - } else if (generatedRow.isSpanColumns() && j == 0 - && generatedRow.getValue() instanceof Component) { - value = generatedRow.getValue(); - } else if (generatedRow.getText().length > j) { - value = generatedRow.getText()[j]; - } - } else { - // check in current pageBuffer already has row - int index = firstIndex + i; - if (p != null || isGenerated) { - int indexInOldBuffer = index - pageBufferFirstIndex; - if (index < firstIndexNotInCache - && index >= pageBufferFirstIndex - && pageBuffer[CELL_GENERATED_ROW][indexInOldBuffer] == null - && id.equals(pageBuffer[CELL_ITEMID][indexInOldBuffer])) { - // we already have data in our cache, - // recycle it instead of fetching it via - // getValue/getPropertyValue - value = pageBuffer[CELL_FIRSTCOL + j][indexInOldBuffer]; - if (!isGeneratedColumn && iscomponent[j] - || !(value instanceof Component)) { - listenProperty(p, oldListenedProperties); - } - } else { - if (isGeneratedColumn) { - ColumnGenerator cg = columnGenerators - .get(colids[j]); - value = cg.generateCell(this, id, colids[j]); - if (value != null - && !(value instanceof Component) - && !(value instanceof String)) { - // Avoid errors if a generator returns - // something - // other than a Component or a String - value = value.toString(); - } - } else if (iscomponent[j]) { - value = p.getValue(); - listenProperty(p, oldListenedProperties); - } else if (p != null) { - value = getPropertyValue(id, colids[j], p); - /* - * If returned value is Component (via - * fieldfactory or overridden getPropertyValue) - * we excpect it to listen property value - * changes. Otherwise if property emits value - * change events, table will start to listen - * them and refresh content when needed. - */ - if (!(value instanceof Component)) { - listenProperty(p, oldListenedProperties); - } - } else { - value = getPropertyValue(id, colids[j], null); - } - } - } - } - - if (value instanceof Component) { - registerComponent((Component) value); - } - cells[CELL_FIRSTCOL + j][i] = value; + // Gets the first item id + Object id = firstItemId(); + for (int i = 0; i < firstIndex; i++) { + id = nextItemId(id); } + for (int i = 0; i < rows && id != null; i++) { + // Start by parsing the values, id should already be set + parseItemIdToCells(cells, id, i, firstIndex, headmode, cols, + colids, firstIndexNotInCache, iscomponent, + oldListenedProperties); - // Gets the next item id - if (items instanceof Container.Indexed) { - int index = firstIndex + i + 1; - if (index < size()) { - id = getIdByIndex(index); - } else { - id = null; - } - } else { + // Gets the next item id for non indexed container id = nextItemId(id); - } - filledRows++; + filledRows++; + } } // Assures that all the rows of the cell-buffer are valid @@ -2089,6 +2017,117 @@ public class Table extends AbstractSelect implements Action.Container, return cells; } + /** + * Update a cache array for a row, register any relevant listeners etc. + * + * This is an internal method extracted from + * {@link #getVisibleCellsNoCache(int, int, boolean)} and should be removed + * when the Table is rewritten. + */ + private void parseItemIdToCells(Object[][] cells, Object id, int i, + int firstIndex, RowHeaderMode headmode, int cols, Object[] colids, + int firstIndexNotInCache, boolean[] iscomponent, + HashSet<Property<?>> oldListenedProperties) { + + cells[CELL_ITEMID][i] = id; + cells[CELL_KEY][i] = itemIdMapper.key(id); + if (headmode != ROW_HEADER_MODE_HIDDEN) { + switch (headmode) { + case INDEX: + cells[CELL_HEADER][i] = String.valueOf(i + firstIndex + 1); + break; + default: + cells[CELL_HEADER][i] = getItemCaption(id); + } + cells[CELL_ICON][i] = getItemIcon(id); + } + + GeneratedRow generatedRow = rowGenerator != null ? rowGenerator + .generateRow(this, id) : null; + cells[CELL_GENERATED_ROW][i] = generatedRow; + + for (int j = 0; j < cols; j++) { + if (isColumnCollapsed(colids[j])) { + continue; + } + Property<?> p = null; + Object value = ""; + boolean isGeneratedRow = generatedRow != null; + boolean isGeneratedColumn = columnGenerators.containsKey(colids[j]); + boolean isGenerated = isGeneratedRow || isGeneratedColumn; + + if (!isGenerated) { + p = getContainerProperty(id, colids[j]); + } + + if (isGeneratedRow) { + if (generatedRow.isSpanColumns() && j > 0) { + value = null; + } else if (generatedRow.isSpanColumns() && j == 0 + && generatedRow.getValue() instanceof Component) { + value = generatedRow.getValue(); + } else if (generatedRow.getText().length > j) { + value = generatedRow.getText()[j]; + } + } else { + // check in current pageBuffer already has row + int index = firstIndex + i; + if (p != null || isGenerated) { + int indexInOldBuffer = index - pageBufferFirstIndex; + if (index < firstIndexNotInCache + && index >= pageBufferFirstIndex + && pageBuffer[CELL_GENERATED_ROW][indexInOldBuffer] == null + && id.equals(pageBuffer[CELL_ITEMID][indexInOldBuffer])) { + // we already have data in our cache, + // recycle it instead of fetching it via + // getValue/getPropertyValue + value = pageBuffer[CELL_FIRSTCOL + j][indexInOldBuffer]; + if (!isGeneratedColumn && iscomponent[j] + || !(value instanceof Component)) { + listenProperty(p, oldListenedProperties); + } + } else { + if (isGeneratedColumn) { + ColumnGenerator cg = columnGenerators + .get(colids[j]); + value = cg.generateCell(this, id, colids[j]); + if (value != null && !(value instanceof Component) + && !(value instanceof String)) { + // Avoid errors if a generator returns + // something + // other than a Component or a String + value = value.toString(); + } + } else if (iscomponent[j]) { + value = p.getValue(); + listenProperty(p, oldListenedProperties); + } else if (p != null) { + value = getPropertyValue(id, colids[j], p); + /* + * If returned value is Component (via fieldfactory + * or overridden getPropertyValue) we expect it to + * listen property value changes. Otherwise if + * property emits value change events, table will + * start to listen them and refresh content when + * needed. + */ + if (!(value instanceof Component)) { + listenProperty(p, oldListenedProperties); + } + } else { + value = getPropertyValue(id, colids[j], null); + } + } + } + } + + if (value instanceof Component) { + registerComponent((Component) value); + } + cells[CELL_FIRSTCOL + j][i] = value; + } + } + protected void registerComponent(Component component) { getLogger().finest( "Registered " + component.getClass().getSimpleName() + ": " diff --git a/server/src/com/vaadin/ui/TextArea.java b/server/src/com/vaadin/ui/TextArea.java index 0dc9722eb3..cc8e947e24 100644 --- a/server/src/com/vaadin/ui/TextArea.java +++ b/server/src/com/vaadin/ui/TextArea.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2011 Vaadin Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not @@ -95,7 +95,7 @@ public class TextArea extends AbstractTextField { if (rows < 0) { rows = 0; } - getState().setRows(rows); + getState().rows = rows; } /** @@ -104,7 +104,7 @@ public class TextArea extends AbstractTextField { * @return number of explicitly set rows. */ public int getRows() { - return getState().getRows(); + return getState().rows; } /** @@ -115,7 +115,7 @@ public class TextArea extends AbstractTextField { * word-wrap mode. */ public void setWordwrap(boolean wordwrap) { - getState().setWordwrap(wordwrap); + getState().wordwrap = wordwrap; } /** @@ -125,7 +125,7 @@ public class TextArea extends AbstractTextField { * <code>false</code> if not. */ public boolean isWordwrap() { - return getState().isWordwrap(); + return getState().wordwrap; } } diff --git a/server/src/com/vaadin/ui/UI.java b/server/src/com/vaadin/ui/UI.java index a59b96d27a..d1ccaacde3 100644 --- a/server/src/com/vaadin/ui/UI.java +++ b/server/src/com/vaadin/ui/UI.java @@ -28,21 +28,20 @@ import java.util.LinkedHashSet; import java.util.Map; import com.vaadin.Application; -import com.vaadin.annotations.EagerInit; import com.vaadin.event.Action; import com.vaadin.event.Action.Handler; import com.vaadin.event.ActionManager; import com.vaadin.event.MouseEvents.ClickEvent; import com.vaadin.event.MouseEvents.ClickListener; import com.vaadin.server.AbstractApplicationServlet; +import com.vaadin.server.LegacyComponent; import com.vaadin.server.Page; +import com.vaadin.server.Page.BrowserWindowResizeEvent; +import com.vaadin.server.Page.BrowserWindowResizeListener; import com.vaadin.server.PaintException; import com.vaadin.server.PaintTarget; import com.vaadin.server.Resource; -import com.vaadin.server.LegacyComponent; import com.vaadin.server.WrappedRequest; -import com.vaadin.server.Page.BrowserWindowResizeEvent; -import com.vaadin.server.Page.BrowserWindowResizeListener; import com.vaadin.server.WrappedRequest.BrowserDetails; import com.vaadin.shared.EventId; import com.vaadin.shared.MouseEventDetails; @@ -77,15 +76,9 @@ import com.vaadin.tools.ReflectTools; * passing a {@link ComponentContainer} with the main layout of the view to * {@link #setContent(ComponentContainer)}. * </p> - * <p> - * If a {@link EagerInit} annotation is present on a class extending - * <code>UI</code>, the framework will use a faster initialization method which - * will not ensure that {@link BrowserDetails} are present in the - * {@link WrappedRequest} passed to the init method. - * </p> * * @see #init(WrappedRequest) - * @see Application#getUI(WrappedRequest) + * @see Application#createUI(WrappedRequest) * * @since 7.0 */ @@ -98,7 +91,6 @@ public abstract class UI extends AbstractComponentContainer implements * window in Vaadin 6 with {@link com.vaadin.Application.LegacyApplication} */ @Deprecated - @EagerInit public static class LegacyWindow extends UI { private String name; @@ -385,7 +377,7 @@ public abstract class UI extends AbstractComponentContainer implements @Override public void setCaption(String caption) { // Override to provide backwards compatibility - getState().setCaption(caption); + getState().caption = caption; getPage().setTitle(caption); } @@ -710,28 +702,6 @@ public abstract class UI extends AbstractComponentContainer implements } /** - * Sets the id of this UI within its application. The UI id is used to route - * requests to the right UI. - * <p> - * This method is mainly intended for internal use by the framework. - * </p> - * - * @param uiId - * the id of this UI - * - * @throws IllegalStateException - * if the UI id has already been set - * - * @see #getUIId() - */ - public void setUIId(int uiId) { - if (this.uiId != -1) { - throw new IllegalStateException("UI id has already been defined"); - } - this.uiId = uiId; - } - - /** * Gets the id of the UI, used to identify this UI within its application * when processing requests. The UI id should be present in every request to * the server that originates from this UI. @@ -748,8 +718,8 @@ public abstract class UI extends AbstractComponentContainer implements * Adds a window as a subwindow inside this UI. To open a new browser window * or tab, you should instead use {@link open(Resource)} with an url * pointing to this application and ensure - * {@link Application#getUI(WrappedRequest)} returns an appropriate UI for - * the request. + * {@link Application#createUI(WrappedRequest)} returns an appropriate UI + * for the request. * * @param window * @throws IllegalArgumentException @@ -831,6 +801,8 @@ public abstract class UI extends AbstractComponentContainer implements private boolean resizeLazy = false; + private String theme; + /** * This method is used by Component.Focusable objects to request focus to * themselves. Focus renders must be handled at window level (instead of @@ -879,7 +851,7 @@ public abstract class UI extends AbstractComponentContainer implements * @see #createDefaultLayout() */ public ComponentContainer getContent() { - return (ComponentContainer) getState().getContent(); + return (ComponentContainer) getState().content; } /** @@ -911,10 +883,10 @@ public abstract class UI extends AbstractComponentContainer implements content = createDefaultLayout(); } - if (getState().getContent() != null) { - super.removeComponent((Component) getState().getContent()); + if (getState().content != null) { + super.removeComponent((Component) getState().content); } - getState().setContent(content); + getState().content = content; if (content != null) { super.addComponent(content); } @@ -959,8 +931,16 @@ public abstract class UI extends AbstractComponentContainer implements * * @param request * the initialization request + * @param uiId + * the id of the new ui */ - public void doInit(WrappedRequest request) { + public void doInit(WrappedRequest request, int uiId) { + if (this.uiId != -1) { + throw new IllegalStateException("UI id has already been defined"); + } + this.uiId = uiId; + theme = getApplication().getThemeForUI(request, getClass()); + getPage().init(request); // Call the init overridden by the application developer @@ -974,11 +954,8 @@ public abstract class UI extends AbstractComponentContainer implements * state of the UI is not properly set up when the constructor is invoked. * <p> * The {@link WrappedRequest} can be used to get information about the - * request that caused this UI to be created. By default, the - * {@link BrowserDetails} will be available in the request. If the browser - * details are not required, loading the application in the browser can take - * some shortcuts giving a faster initial rendering. This can be indicated - * by adding the {@link EagerInit} annotation to the UI class. + * request that caused this UI to be created. {@link BrowserDetails} will be + * available in the request. * </p> * * @param request @@ -1352,4 +1329,13 @@ public abstract class UI extends AbstractComponentContainer implements public void setLastUidlRequestTime(long lastUidlRequest) { this.lastUidlRequest = lastUidlRequest; } + + /** + * Gets the theme that was used when the UI was initialized. + * + * @return the theme name + */ + public String getTheme() { + return theme; + } } diff --git a/server/src/com/vaadin/ui/Window.java b/server/src/com/vaadin/ui/Window.java index aaf0fbc492..5c94a4c929 100644 --- a/server/src/com/vaadin/ui/Window.java +++ b/server/src/com/vaadin/ui/Window.java @@ -31,9 +31,9 @@ import com.vaadin.event.ShortcutAction; import com.vaadin.event.ShortcutAction.KeyCode; import com.vaadin.event.ShortcutAction.ModifierKey; import com.vaadin.event.ShortcutListener; +import com.vaadin.server.LegacyComponent; import com.vaadin.server.PaintException; import com.vaadin.server.PaintTarget; -import com.vaadin.server.LegacyComponent; import com.vaadin.shared.MouseEventDetails; import com.vaadin.shared.ui.window.WindowServerRpc; import com.vaadin.shared.ui.window.WindowState; @@ -242,7 +242,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, * @since 4.0.0 */ public int getPositionX() { - return getState().getPositionX(); + return getState().positionX; } /** @@ -255,8 +255,8 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, * @since 4.0.0 */ public void setPositionX(int positionX) { - getState().setPositionX(positionX); - getState().setCentered(false); + getState().positionX = positionX; + getState().centered = false; } /** @@ -269,7 +269,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, * @since 4.0.0 */ public int getPositionY() { - return getState().getPositionY(); + return getState().positionY; } /** @@ -283,8 +283,8 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, * @since 4.0.0 */ public void setPositionY(int positionY) { - getState().setPositionY(positionY); - getState().setCentered(false); + getState().positionY = positionY; + getState().centered = false; } private static final Method WINDOW_CLOSE_METHOD; @@ -540,7 +540,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, * true if modality is to be turned on */ public void setModal(boolean modal) { - getState().setModal(modal); + getState().modal = modal; center(); } @@ -548,7 +548,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, * @return true if this window is modal. */ public boolean isModal() { - return getState().isModal(); + return getState().modal; } /** @@ -558,7 +558,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, * true if resizability is to be turned on */ public void setResizable(boolean resizable) { - getState().setResizable(resizable); + getState().resizable = resizable; } /** @@ -566,7 +566,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, * @return true if window is resizable by the end-user, otherwise false. */ public boolean isResizable() { - return getState().isResizable(); + return getState().resizable; } /** @@ -575,7 +575,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, * sizes are recalculated immediately. */ public boolean isResizeLazy() { - return getState().isResizeLazy(); + return getState().resizeLazy; } /** @@ -591,7 +591,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, * calculate immediately. */ public void setResizeLazy(boolean resizeLazy) { - getState().setResizeLazy(resizeLazy); + getState().resizeLazy = resizeLazy; } /** @@ -604,7 +604,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, * Please refer to http://dev.vaadin.com/ticket/8971 for details. */ public void center() { - getState().setCentered(true); + getState().centered = true; } /** @@ -655,7 +655,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, * true if the sub window can be dragged by the user */ public boolean isDraggable() { - return getState().isDraggable(); + return getState().draggable; } /** @@ -668,7 +668,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, * true if the sub window can be dragged by the user */ public void setDraggable(boolean draggable) { - getState().setDraggable(draggable); + getState().draggable = draggable; } /* @@ -793,6 +793,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, * @deprecated Since 7.0, replaced by * {@link #addFocusListener(FocusListener)} **/ + @Override @Deprecated public void addListener(FocusListener listener) { addFocusListener(listener); @@ -807,6 +808,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, * @deprecated Since 7.0, replaced by * {@link #removeFocusListener(FocusListener)} **/ + @Override @Deprecated public void removeListener(FocusListener listener) { removeFocusListener(listener); @@ -829,6 +831,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, /** * @deprecated Since 7.0, replaced by {@link #addBlurListener(BlurListener)} **/ + @Override @Deprecated public void addListener(BlurListener listener) { addBlurListener(listener); @@ -843,6 +846,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, * @deprecated Since 7.0, replaced by * {@link #removeBlurListener(BlurListener)} **/ + @Override @Deprecated public void removeListener(BlurListener listener) { removeBlurListener(listener); |