diff options
author | Leif Åstrand <leif@vaadin.com> | 2013-02-05 13:08:24 +0200 |
---|---|---|
committer | Leif Åstrand <leif@vaadin.com> | 2013-02-06 16:23:28 +0200 |
commit | 01ee88c00763e2bbe95e407a387170aa6b982540 (patch) | |
tree | 1c540588311aa5c6bb811b0eb0b928b4cf89495d /client | |
parent | 216e557e11dae53ba352dfed59b510b840db8d5b (diff) | |
download | vaadin-framework-01ee88c00763e2bbe95e407a387170aa6b982540.tar.gz vaadin-framework-01ee88c00763e2bbe95e407a387170aa6b982540.zip |
Use native collections in CssLayoutConnector (#10937)
Change-Id: Ie4f10c7b1de97476fe5aec2bfa2a0e1cd933121c
Diffstat (limited to 'client')
-rw-r--r-- | client/src/com/vaadin/client/ui/csslayout/CssLayoutConnector.java | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/client/src/com/vaadin/client/ui/csslayout/CssLayoutConnector.java b/client/src/com/vaadin/client/ui/csslayout/CssLayoutConnector.java index fc42a5bdbf..4c8d1a3ecc 100644 --- a/client/src/com/vaadin/client/ui/csslayout/CssLayoutConnector.java +++ b/client/src/com/vaadin/client/ui/csslayout/CssLayoutConnector.java @@ -15,15 +15,13 @@ */ package com.vaadin.client.ui.csslayout; -import java.util.HashMap; -import java.util.Map; - import com.google.gwt.dom.client.Style; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.ui.Widget; import com.vaadin.client.BrowserInfo; import com.vaadin.client.ComponentConnector; import com.vaadin.client.ConnectorHierarchyChangeEvent; +import com.vaadin.client.FastStringMap; import com.vaadin.client.Util; import com.vaadin.client.VCaption; import com.vaadin.client.communication.StateChangeEvent; @@ -58,7 +56,8 @@ public class CssLayoutConnector extends AbstractLayoutConnector { }; }; - private Map<ComponentConnector, VCaption> childToCaption = new HashMap<ComponentConnector, VCaption>(); + private final FastStringMap<VCaption> childIdToCaption = FastStringMap + .create(); /* * (non-Javadoc) @@ -123,7 +122,8 @@ public class CssLayoutConnector extends AbstractLayoutConnector { public void onConnectorHierarchyChange(ConnectorHierarchyChangeEvent event) { int index = 0; for (ComponentConnector child : getChildComponents()) { - VCaption childCaption = childToCaption.get(child); + VCaption childCaption = childIdToCaption + .get(child.getConnectorId()); if (childCaption != null) { getWidget().addOrMove(childCaption, index++); } @@ -137,8 +137,9 @@ public class CssLayoutConnector extends AbstractLayoutConnector { continue; } getWidget().remove(child.getWidget()); - VCaption vCaption = childToCaption.remove(child); + VCaption vCaption = childIdToCaption.get(child.getConnectorId()); if (vCaption != null) { + childIdToCaption.remove(child.getConnectorId()); getWidget().remove(vCaption); } } @@ -182,8 +183,7 @@ public class CssLayoutConnector extends AbstractLayoutConnector { /* * (non-Javadoc) * - * @see - * com.vaadin.client.HasComponentsConnector#updateCaption(com.vaadin + * @see com.vaadin.client.HasComponentsConnector#updateCaption(com.vaadin * .client.ComponentConnector) */ @Override @@ -191,11 +191,12 @@ public class CssLayoutConnector extends AbstractLayoutConnector { Widget childWidget = child.getWidget(); int widgetPosition = getWidget().getWidgetIndex(childWidget); - VCaption caption = childToCaption.get(child); + String childId = child.getConnectorId(); + VCaption caption = childIdToCaption.get(childId); if (VCaption.isNeeded(child.getState())) { if (caption == null) { caption = new VCaption(child, getConnection()); - childToCaption.put(child, caption); + childIdToCaption.put(childId, caption); } if (!caption.isAttached()) { // Insert caption at widget index == before widget @@ -203,7 +204,7 @@ public class CssLayoutConnector extends AbstractLayoutConnector { } caption.updateCaption(); } else if (caption != null) { - childToCaption.remove(child); + childIdToCaption.remove(childId); getWidget().remove(caption); } } |