From ae2a42dd038b03c5b3dc69c4574bc887bfc8abc2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Leif=20=C3=85strand?= Date: Fri, 15 Jun 2012 13:56:10 +0300 Subject: [PATCH] Add API for getting the parent connector's id (#8888) --- .../gwt/client/JavaScriptConnectorHelper.java | 30 +++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/com/vaadin/terminal/gwt/client/JavaScriptConnectorHelper.java b/src/com/vaadin/terminal/gwt/client/JavaScriptConnectorHelper.java index 006105fed6..bd62a759cb 100644 --- a/src/com/vaadin/terminal/gwt/client/JavaScriptConnectorHelper.java +++ b/src/com/vaadin/terminal/gwt/client/JavaScriptConnectorHelper.java @@ -173,6 +173,9 @@ public class JavaScriptConnectorHelper { 'getConnectorId': function() { return connectorId; }, + 'getParentId': $entry(function(connectorId) { + return h.@com.vaadin.terminal.gwt.client.JavaScriptConnectorHelper::getParentId(Ljava/lang/String;)(connectorId); + }), 'getState': function() { return nativeState; }, @@ -208,13 +211,21 @@ public class JavaScriptConnectorHelper { }); }-*/; - private Element getWidgetElement(String connectorId) { - if (connectorId == null) { - connectorId = connector.getConnectorId(); + private String getParentId(String connectorId) { + ServerConnector target = getConnector(connectorId); + if (target == null) { + return null; } + ServerConnector parent = target.getParent(); + if (parent == null) { + return null; + } else { + return parent.getConnectorId(); + } + } - ServerConnector target = ConnectorMap.get(connector.getConnection()) - .getConnector(connectorId); + private Element getWidgetElement(String connectorId) { + ServerConnector target = getConnector(connectorId); if (target instanceof ComponentConnector) { return ((ComponentConnector) target).getWidget().getElement(); } else { @@ -222,6 +233,15 @@ public class JavaScriptConnectorHelper { } } + private ServerConnector getConnector(String connectorId) { + if (connectorId == null || connectorId.length() == 0) { + return connector; + } + + return ConnectorMap.get(connector.getConnection()) + .getConnector(connectorId); + } + private void fireRpc(String iface, String method, JsArray arguments) { if (iface == null) { -- 2.39.5