} else {
id = "PID_S" + id;
}
+ Paintable old = idPaintableMap.put(id, paintable);
+ if (old != null && old != paintable) {
+ /*
+ * Two paintables have the same id. We still make sure the old
+ * one is a component which is still attached to the
+ * application. This is just a precaution and should not be
+ * absolutely necessary.
+ */
+
+ if (old instanceof Component
+ && ((Component) old).getApplication() != null) {
+ throw new IllegalStateException("Two paintables ("
+ + paintable.getClass().getSimpleName() + ","
+ + old.getClass().getSimpleName()
+ + ") have been assigned the same id: "
+ + paintable.getDebugId());
+ }
+ }
paintableIdMap.put(paintable, id);
- idPaintableMap.put(id, paintable);
}
return id;
--- /dev/null
+package com.itmill.toolkit.tests.components;
+
+import com.itmill.toolkit.ui.Button;
+import com.itmill.toolkit.ui.TextField;
+
+public class MultipleDebugIds extends TestBase {
+
+ @Override
+ protected String getDescription() {
+ return "An exception should be thrown if the same debugId is assigned to several components";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 2796;
+ }
+
+ @Override
+ protected void setup() {
+ TextField textField = new TextField();
+ TextField textField2 = new TextField();
+ Button button = new Button();
+ Button button2 = new Button();
+ textField.setDebugId("textfield");
+ button.setDebugId("button");
+ textField2.setDebugId("textfield2");
+ button2.setDebugId("textfield");
+
+ addComponent(textField);
+ addComponent(textField2);
+ addComponent(button);
+ addComponent(button2);
+ }
+
+}