} else if (part.equals("")) {
w = client.getView().getWidget();
} else if (w == null) {
- // Must be static pid (PID_S*)
- w = ((ComponentConnector) ConnectorMap.get(client)
- .getConnector(part)).getWidget();
+ String id = part;
+ // Must be old static pid (PID_S*)
+ ComponentConnector connector = (ComponentConnector) ConnectorMap
+ .get(client).getConnector(id);
+ if (connector == null) {
+ // Lookup by debugId
+ // TODO Optimize this
+ connector = findConnectorById(client.getView(),
+ id.substring(5));
+ }
+
+ if (connector != null) {
+ w = connector.getWidget();
+ } else {
+ // Not found
+ return null;
+ }
} else if (part.startsWith("domChild[")) {
// The target widget has been found and the rest identifies the
// element
return w;
}
+ private ComponentConnector findConnectorById(ComponentConnector root,
+ String id) {
+ if (root instanceof ComponentConnector
+ && id.equals(root.getState().getDebugId())) {
+ return root;
+ }
+ if (root instanceof ComponentContainerConnector) {
+ ComponentContainerConnector ccc = (ComponentContainerConnector) root;
+ for (ComponentConnector child : ccc.getChildren()) {
+ ComponentConnector found = findConnectorById(child, id);
+ if (found != null) {
+ return found;
+ }
+ }
+ }
+
+ return null;
+ }
+
/**
* Checks if the given pid is a static pid.
*
private boolean visible = true;
private URLReference icon = null;
private List<String> styles = null;
+ private String debugId = null;
/**
* Returns the component height as set by the server.
this.styles = styles;
}
+ /**
+ * Gets the debug id for the component. The debugId is added as DOM id for
+ * the component.
+ *
+ * @return The debug id for the component or null if not set
+ */
+ public String getDebugId() {
+ return debugId;
+ }
+
+ /**
+ * Sets the debug id for the component. The debugId is added as DOM id for
+ * the component.
+ *
+ * @param debugId
+ * The new debugId for the component or null for no debug id
+ *
+ */
+ public void setDebugId(String debugId) {
+ this.debugId = debugId;
+ }
+
}
package com.vaadin.terminal.gwt.client.ui;
import com.google.gwt.core.client.GWT;
-import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.FocusWidget;
import com.google.gwt.user.client.ui.Focusable;
import com.google.gwt.user.client.ui.Widget;
// Visibility
setVisible(!uidl.getBooleanAttribute("invisible"), uidl);
- if (uidl.getId().startsWith("PID_S")) {
- DOM.setElementProperty(getWidget().getElement(), "id", uidl.getId()
- .substring(5));
+ if (getState().getDebugId() != null) {
+ getWidget().getElement().setId(getState().getDebugId());
+ } else {
+ getWidget().getElement().setId(null);
+
}
if (!isVisible()) {
*/
private LinkedList<RepaintRequestListener> repaintRequestListeners = null;
- private String testingId;
-
/* Sizeable fields */
private float width = SIZE_UNDEFINED;
/* Get/Set component properties */
public void setDebugId(String id) {
- testingId = id;
+ getState().setDebugId(id);
}
public String getDebugId() {
- return testingId;
+ return getState().getDebugId();
}
/**