import java.util.Map;\r
\r
import org.simantics.browsing.ui.BuiltinKeys;\r
-import org.simantics.browsing.ui.ColumnKeys;\r
-import org.simantics.browsing.ui.ContextMenuInitializer;\r
-import org.simantics.browsing.ui.IContextMenuInitializer;\r
-import org.simantics.browsing.ui.INodeContext;\r
-import org.simantics.browsing.ui.Labeler;\r
-import org.simantics.browsing.ui.LabelerFactory;\r
+import org.simantics.browsing.ui.NodeContext;\r
import org.simantics.browsing.ui.PrimitiveQueryUpdater;\r
import org.simantics.browsing.ui.BuiltinKeys.LabelerKey;\r
+import org.simantics.browsing.ui.common.ColumnKeys;\r
+import org.simantics.browsing.ui.common.ContextMenuInitializer;\r
import org.simantics.browsing.ui.common.EvaluatorData;\r
-import org.simantics.browsing.ui.common.IEvaluatorData.Evaluator;\r
-import org.simantics.browsing.ui.common.labelers.LazyGraphLabeler;\r
-import org.simantics.browsing.ui.common.labelers.StringRepresentationLabelerFactory;\r
-import org.simantics.browsing.ui.common.viewpoints.GraphViewpointFactory;\r
-import org.simantics.browsing.ui.common.views.GraphExplorerViewBase2;\r
+import org.simantics.browsing.ui.common.EvaluatorDataImpl;\r
+import org.simantics.browsing.ui.common.EvaluatorImpl;\r
+import org.simantics.browsing.ui.common.IContextMenuInitializer;\r
+import org.simantics.browsing.ui.common.EvaluatorData.Evaluator;\r
+import org.simantics.browsing.ui.content.Labeler;\r
+import org.simantics.browsing.ui.content.LabelerFactory;\r
+import org.simantics.browsing.ui.graph.GraphExplorerViewBase2;\r
+import org.simantics.browsing.ui.graph.GraphViewpointFactory;\r
+import org.simantics.browsing.ui.graph.LazyGraphLabeler;\r
import org.simantics.db.Builtins;\r
import org.simantics.db.ReadGraph;\r
import org.simantics.db.Resource;\r
import org.simantics.db.Session;\r
import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.modeling.ui.modelBrowser.model.util.LabelModifier;\r
import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.ui.SimanticsUI;\r
import org.simantics.utils.datastructures.hints.HintContext;\r
\r
\r
//if (sessionContext != null)\r
//factoryHints.setHint(IGraphExplorerHints.KEY_SESSION_CONTEXT, sessionContext);\r
\r
- EvaluatorData data = new EvaluatorData();\r
+ EvaluatorData data = new EvaluatorDataImpl();\r
data.addEvaluator(Resource.class, createResourceEvaluator(session, factoryHints));\r
return data;\r
}\r
\r
private Evaluator createResourceEvaluator(Session session, HintContext factoryHints) {\r
- Evaluator evaluator = new Evaluator();\r
+ Evaluator evaluator = new EvaluatorImpl();\r
evaluator.addViewpoint(new GraphViewpointFactory() { \r
@Override\r
protected Collection<?> getChildren(ReadGraph g, Resource r)\r
}, 1.0);\r
evaluator.addLabeler(new LabelerFactory() { \r
@Override\r
- public Labeler create(PrimitiveQueryUpdater updater, final INodeContext context,\r
- LabelerKey key) {\r
+ public Labeler create(PrimitiveQueryUpdater updater, final NodeContext context, LabelerKey key) {\r
return new LazyGraphLabeler(updater, context, key) {\r
+ \r
+ Resource nameResource;\r
+ \r
@Override\r
public Map<String, String> labels(ReadGraph g)\r
throws DatabaseException {\r
Builtins b = g.getBuiltins();\r
- SysdynResource sr = SysdynResource.getInstance(g);\r
+ nameResource = b.HasName;\r
Resource el = (Resource) context.getConstant(BuiltinKeys.INPUT);\r
StringBuilder sb = new StringBuilder();\r
for(Resource r : g.getObjects(el, b.HasName))\r
\r
@Override\r
public Modifier getModifier(String key) {\r
- System.out.println("getModifier(" + key + ")");\r
- return null;\r
+ LabelModifier modifier = new LabelModifier(SimanticsUI.getSession(), (Resource) context.getConstant(BuiltinKeys.INPUT), nameResource) {\r
+ @Override\r
+ public String isValid(String label) {\r
+ if (label.isEmpty())\r
+ return "Empty label not allowed";\r
+ if (label.contains(" "))\r
+ return "Spaces are not allowed";\r
+ return null;\r
+ }\r
+ };\r
+ return modifier;\r
}\r
}; \r
} \r