From 697baba1cb63c3b263cd58be0d10025398be4f40 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Mon, 12 Mar 2012 16:33:32 +0200 Subject: [PATCH] Connector interface. Renamed getId() -> getConnectorId() to avoid mixups --- .../vaadin/terminal/gwt/client/Connector.java | 29 +++++++++++++++++++ .../terminal/gwt/client/ConnectorMap.java | 8 ++--- .../terminal/gwt/client/LayoutManager.java | 12 ++++---- .../terminal/gwt/client/ServerConnector.java | 17 +---------- .../client/ui/AbstractComponentConnector.java | 6 ++-- .../gwt/client/ui/AbstractConnector.java | 2 +- .../ui/AbstractOrderedLayoutConnector.java | 2 +- .../terminal/gwt/client/ui/FormConnector.java | 2 +- .../gwt/client/ui/PanelConnector.java | 2 +- .../terminal/gwt/client/ui/RootConnector.java | 4 +-- .../gwt/client/ui/WindowConnector.java | 6 ++-- 11 files changed, 52 insertions(+), 38 deletions(-) create mode 100644 src/com/vaadin/terminal/gwt/client/Connector.java diff --git a/src/com/vaadin/terminal/gwt/client/Connector.java b/src/com/vaadin/terminal/gwt/client/Connector.java new file mode 100644 index 0000000000..d6e2b617ff --- /dev/null +++ b/src/com/vaadin/terminal/gwt/client/Connector.java @@ -0,0 +1,29 @@ +package com.vaadin.terminal.gwt.client; + +import com.vaadin.terminal.gwt.client.communication.SharedState; + +/** + * TODO Add javadoc + * + * @author Vaadin Ltd + * @version @VERSION@ + * @since 7.0.0 + * + */ +public interface Connector { + /** + * Gets the current shared state of the connector. + * + * @return state + */ + public SharedState getState(); + + /** + * Returns the id for this connector. This must always be what has been set + * in {@link #doInit(String, ApplicationConnection)} and must never change. + * + * @return The id for the connector. + */ + public String getConnectorId(); + +} diff --git a/src/com/vaadin/terminal/gwt/client/ConnectorMap.java b/src/com/vaadin/terminal/gwt/client/ConnectorMap.java index 286b8396cd..1ec3b84eeb 100644 --- a/src/com/vaadin/terminal/gwt/client/ConnectorMap.java +++ b/src/com/vaadin/terminal/gwt/client/ConnectorMap.java @@ -117,14 +117,14 @@ public class ConnectorMap { * the connector whose id is needed * @return the id for the given connector or null if the connector could not * be found - * @deprecated use {@link ServerConnector#getId()} instead + * @deprecated use {@link ServerConnector#getConnectorId()} instead */ @Deprecated public String getConnectorId(ServerConnector connector) { if (connector == null) { return null; } - return connector.getId(); + return connector.getConnectorId(); } @Deprecated @@ -181,7 +181,7 @@ public class ConnectorMap { VConsole.error("WARN: Trying to unregister null connector"); return; } - String id = connector.getId(); + String id = connector.getConnectorId(); Widget widget = null; if (connector instanceof ComponentConnector) { widget = ((ComponentConnector) connector).getWidget(); @@ -206,7 +206,7 @@ public class ConnectorMap { for (ServerConnector connector : getConnectors()) { if (connector instanceof ComponentConnector) { ComponentConnector componentConnector = (ComponentConnector) connector; - if (!unregistryBag.contains(connector.getId())) { + if (!unregistryBag.contains(connector.getConnectorId())) { result.add(componentConnector); } } diff --git a/src/com/vaadin/terminal/gwt/client/LayoutManager.java b/src/com/vaadin/terminal/gwt/client/LayoutManager.java index bc1a0c8bba..8bd7a3dac7 100644 --- a/src/com/vaadin/terminal/gwt/client/LayoutManager.java +++ b/src/com/vaadin/terminal/gwt/client/LayoutManager.java @@ -37,7 +37,7 @@ public class LayoutManager { if (measuredSize.isWidthNeedsUpdate()) { ownerSize.setWidthNeedsUpdate(); } - measuredSize.addDependent(owner.getId()); + measuredSize.addDependent(owner.getConnectorId()); } private MeasuredSize ensureMeasured(Element element) { @@ -95,7 +95,7 @@ public class LayoutManager { if (measuredSize == null) { return; } - measuredSize.removeDependent(owner.getId()); + measuredSize.removeDependent(owner.getConnectorId()); if (!needsMeasure(element)) { nonPaintableElements.remove(element); setMeasuredSize(element, null); @@ -139,18 +139,18 @@ public class LayoutManager { if (measuredSize.isHeightNeedsUpdate()) { if (managed) { - needsHeightUpdate.add(paintable.getId()); + needsHeightUpdate.add(paintable.getConnectorId()); } if (!paintable.isRelativeHeight() && managedParent) { - needsHeightUpdate.add(parent.getId()); + needsHeightUpdate.add(parent.getConnectorId()); } } if (measuredSize.isWidthNeedsUpdate()) { if (managed) { - needsWidthUpdate.add(paintable.getId()); + needsWidthUpdate.add(paintable.getConnectorId()); } if (!paintable.isRelativeWidth() && managedParent) { - needsWidthUpdate.add(parent.getId()); + needsWidthUpdate.add(parent.getConnectorId()); } } measuredSize.clearDirtyState(); diff --git a/src/com/vaadin/terminal/gwt/client/ServerConnector.java b/src/com/vaadin/terminal/gwt/client/ServerConnector.java index ef10cc2566..4cccb6cf8a 100644 --- a/src/com/vaadin/terminal/gwt/client/ServerConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ServerConnector.java @@ -17,7 +17,7 @@ import com.vaadin.terminal.gwt.client.communication.SharedState; * @version @VERSION@ * @since 7.0.0 */ -public interface ServerConnector { +public interface ServerConnector extends Connector { /** * TODO * @@ -26,13 +26,6 @@ public interface ServerConnector { */ public void updateFromUIDL(UIDL uidl, ApplicationConnection client); - /** - * Gets the current shared state of the connector. - * - * @return state - */ - public SharedState getState(); - /** * Sets a new state for the connector. * @@ -44,14 +37,6 @@ public interface ServerConnector { @Deprecated public void setState(SharedState state); - /** - * Returns the id for this connector. This must always be what has been set - * in {@link #doInit(String, ApplicationConnection)} and must never change. - * - * @return The id for the connector. - */ - public String getId(); - /** * Gets ApplicationConnection instance that created this connector. * diff --git a/src/com/vaadin/terminal/gwt/client/ui/AbstractComponentConnector.java b/src/com/vaadin/terminal/gwt/client/ui/AbstractComponentConnector.java index 5f0b22261a..582fc3078c 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/AbstractComponentConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/AbstractComponentConnector.java @@ -127,7 +127,7 @@ public abstract class AbstractComponentConnector extends AbstractConnector ConnectorMap paintableMap = ConnectorMap.get(getConnection()); // register the listened events by the server-side to the event-handler // of the component - paintableMap.registerEventListenersFromUIDL(getId(), uidl); + paintableMap.registerEventListenersFromUIDL(getConnectorId(), uidl); // Visibility setVisible(!uidl.getBooleanAttribute("invisible"), uidl); @@ -210,7 +210,7 @@ public abstract class AbstractComponentConnector extends AbstractConnector w = componentState.getWidth(); } else { // TODO move logging to VUIDLBrowser and VDebugConsole - VConsole.log("No state for paintable " + getId() + VConsole.log("No state for paintable " + getConnectorId() + " in VAbstractPaintableWidget.updateComponentSize()"); } @@ -425,7 +425,7 @@ public abstract class AbstractComponentConnector extends AbstractConnector * GWT.create(). */ protected T initRPC(T clientToServerRpc) { - ((InitializableClientToServerRpc) clientToServerRpc).initRpc(getId(), + ((InitializableClientToServerRpc) clientToServerRpc).initRpc(getConnectorId(), getConnection()); return clientToServerRpc; } diff --git a/src/com/vaadin/terminal/gwt/client/ui/AbstractConnector.java b/src/com/vaadin/terminal/gwt/client/ui/AbstractConnector.java index f83944271e..8ba2bb4d31 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/AbstractConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/AbstractConnector.java @@ -42,7 +42,7 @@ public abstract class AbstractConnector implements ServerConnector { * * @see com.vaadin.terminal.gwt.client.Connector#getId() */ - public String getId() { + public String getConnectorId() { return id; } diff --git a/src/com/vaadin/terminal/gwt/client/ui/AbstractOrderedLayoutConnector.java b/src/com/vaadin/terminal/gwt/client/ui/AbstractOrderedLayoutConnector.java index c49b55eef7..619eb8d980 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/AbstractOrderedLayoutConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/AbstractOrderedLayoutConnector.java @@ -85,7 +85,7 @@ public abstract class AbstractOrderedLayoutConnector extends } layout.addOrMove(slot, currentIndex++); - String pid = child.getId(); + String pid = child.getConnectorId(); AlignmentInfo alignment; if (alignments.containsKey(pid)) { diff --git a/src/com/vaadin/terminal/gwt/client/ui/FormConnector.java b/src/com/vaadin/terminal/gwt/client/ui/FormConnector.java index 3107780d59..05db22e6ae 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/FormConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/FormConnector.java @@ -140,7 +140,7 @@ public class FormConnector extends AbstractComponentContainerConnector if (childUidl != null) { if (getWidget().shortcutHandler == null) { getWidget().shortcutHandler = new ShortcutActionHandler( - getId(), client); + getConnectorId(), client); getWidget().keyDownRegistration = getWidget() .addDomHandler(getWidget(), KeyDownEvent.getType()); } diff --git a/src/com/vaadin/terminal/gwt/client/ui/PanelConnector.java b/src/com/vaadin/terminal/gwt/client/ui/PanelConnector.java index b48b0e8232..f990fc590d 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/PanelConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/PanelConnector.java @@ -164,7 +164,7 @@ public class PanelConnector extends AbstractComponentContainerConnector if (childUidl.getTag().equals("actions")) { if (getWidget().shortcutHandler == null) { getWidget().shortcutHandler = new ShortcutActionHandler( - getId(), client); + getConnectorId(), client); } getWidget().shortcutHandler.updateActionMap(childUidl); } diff --git a/src/com/vaadin/terminal/gwt/client/ui/RootConnector.java b/src/com/vaadin/terminal/gwt/client/ui/RootConnector.java index 37afeafce7..ffe9f7f16b 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/RootConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/RootConnector.java @@ -39,10 +39,10 @@ public class RootConnector extends AbstractComponentContainerConnector ConnectorMap paintableMap = ConnectorMap.get(getConnection()); // register the listened events by the server-side to the event-handler // of the component - paintableMap.registerEventListenersFromUIDL(getId(), uidl); + paintableMap.registerEventListenersFromUIDL(getConnectorId(), uidl); getWidget().rendering = true; - getWidget().id = getId(); + getWidget().id = getConnectorId(); boolean firstPaint = getWidget().connection == null; getWidget().connection = client; diff --git a/src/com/vaadin/terminal/gwt/client/ui/WindowConnector.java b/src/com/vaadin/terminal/gwt/client/ui/WindowConnector.java index 7775766689..7e9f7c9580 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/WindowConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/WindowConnector.java @@ -55,12 +55,12 @@ public class WindowConnector extends AbstractComponentContainerConnector @Override public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { - getWidget().id = getId(); + getWidget().id = getConnectorId(); getWidget().client = client; // Workaround needed for Testing Tools (GWT generates window DOM // slightly different in different browsers). - DOM.setElementProperty(getWidget().closeBox, "id", getId() + DOM.setElementProperty(getWidget().closeBox, "id", getConnectorId() + "_window_close"); if (uidl.hasAttribute("invisible")) { @@ -169,7 +169,7 @@ public class WindowConnector extends AbstractComponentContainerConnector if (childUidl.getTag().equals("actions")) { if (getWidget().shortcutHandler == null) { getWidget().shortcutHandler = new ShortcutActionHandler( - getId(), client); + getConnectorId(), client); } getWidget().shortcutHandler.updateActionMap(childUidl); } -- 2.39.5