1 package org.simantics.sysdyn.ui.properties.widgets.arrays;
\r
3 import org.simantics.browsing.ui.common.node.AbstractNode;
\r
4 import org.simantics.browsing.ui.common.node.IModifiableNode;
\r
5 import org.simantics.browsing.ui.content.Labeler.Modifier;
\r
6 import org.simantics.db.ReadGraph;
\r
7 import org.simantics.db.Resource;
\r
8 import org.simantics.db.WriteGraph;
\r
9 import org.simantics.db.common.request.WriteRequest;
\r
10 import org.simantics.db.exception.DatabaseException;
\r
11 import org.simantics.db.request.Read;
\r
12 import org.simantics.layer0.Layer0;
\r
13 import org.simantics.sysdyn.ui.utils.VariableNameUtils;
\r
14 import org.simantics.ui.SimanticsUI;
\r
16 public class EnumerationIndexNode extends AbstractNode<Resource> implements IModifiableNode {
\r
18 public EnumerationIndexNode(Resource resource) {
\r
23 public Modifier getModifier(String columnId) {
\r
24 Modifier modifier = new Modifier() {
\r
27 public String getValue() {
\r
28 Read<String> request =
\r
29 new Read<String>() {
\r
32 public String perform(ReadGraph graph) throws DatabaseException {
\r
33 String name = graph.getPossibleRelatedValue(data, Layer0.getInstance(graph).HasName);
\r
34 return name != null ? name : "";
\r
39 return SimanticsUI.getSession().syncRequest(request);
\r
40 } catch (DatabaseException e) {
\r
41 e.printStackTrace();
\r
47 public String isValid(String label) {
\r
48 if(!VariableNameUtils.isValid(label))
\r
54 public void modify(final String label) {
\r
55 SimanticsUI.getSession().asyncRequest(new WriteRequest() {
\r
57 public void perform(WriteGraph graph) throws DatabaseException {
\r
58 graph.claimLiteral(data, Layer0.getInstance(graph).HasName, label);
\r