summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorJohn Ahlroos <john.ahlroos@jasoft.fi>2015-04-12 09:59:07 +0300
committerJohn Ahlroos <john@vaadin.com>2015-04-13 14:57:23 +0300
commit72d2fabc95384e1f7fdb6fbd9a9f5757437087ed (patch)
treef692871b48ecfc2ee6af5ae9ab2621f0033f9a38 /server
parent68c7963f085fc299ac9ebded9394b638c7392bb1 (diff)
downloadvaadin-framework-72d2fabc95384e1f7fdb6fbd9a9f5757437087ed.tar.gz
vaadin-framework-72d2fabc95384e1f7fdb6fbd9a9f5757437087ed.zip
Add getter for local id #17444
Change-Id: I0007bdf111bf516cb9e2f244b63fde42213f5c98
Diffstat (limited to 'server')
-rw-r--r--server/src/com/vaadin/ui/declarative/DesignContext.java13
-rw-r--r--server/tests/src/com/vaadin/tests/design/DesignContextLocalIdTest.java10
2 files changed, 23 insertions, 0 deletions
diff --git a/server/src/com/vaadin/ui/declarative/DesignContext.java b/server/src/com/vaadin/ui/declarative/DesignContext.java
index fe3abcfb77..657e15896c 100644
--- a/server/src/com/vaadin/ui/declarative/DesignContext.java
+++ b/server/src/com/vaadin/ui/declarative/DesignContext.java
@@ -170,6 +170,7 @@ public class DesignContext implements Serializable {
* component, the mapping from c to the string is removed. Similarly, if
* component was mapped to some string s different from localId, the mapping
* from s to component is removed.
+ *
* @param component
* The component whose local id is to be set.
* @param localId
@@ -185,6 +186,18 @@ public class DesignContext implements Serializable {
}
/**
+ * Returns the local id for a component
+ *
+ * @param component
+ * The component whose local id to get.
+ * @return the local id of the component, or null if the component has no
+ * local id assigned
+ */
+ public String getComponentLocalId(Component component) {
+ return componentToLocalId.get(component);
+ }
+
+ /**
* Creates a mapping between the given caption and the component. Returns
* true if caption was already mapped to some component.
*
diff --git a/server/tests/src/com/vaadin/tests/design/DesignContextLocalIdTest.java b/server/tests/src/com/vaadin/tests/design/DesignContextLocalIdTest.java
index dffeb2e412..6cedb17409 100644
--- a/server/tests/src/com/vaadin/tests/design/DesignContextLocalIdTest.java
+++ b/server/tests/src/com/vaadin/tests/design/DesignContextLocalIdTest.java
@@ -32,6 +32,7 @@ import com.vaadin.ui.CustomLayout;
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.HorizontalSplitPanel;
+import com.vaadin.ui.Label;
import com.vaadin.ui.Panel;
import com.vaadin.ui.SingleComponentContainer;
import com.vaadin.ui.TabSheet;
@@ -113,4 +114,13 @@ public class DesignContextLocalIdTest {
.getElementsByTag("v-button").first().attr("_id"));
}
}
+
+ @Test
+ public void testGetLocalId() {
+ DesignContext ctx = new DesignContext();
+ Label label = new Label();
+ ctx.setComponentLocalId(label, "my-local-id");
+ ctx.setRootComponent(label);
+ assertEquals("my-local-id", ctx.getComponentLocalId(label));
+ }
}