]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Renaming in sysdyn model browser
authorlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Wed, 24 Feb 2010 17:08:02 +0000 (17:08 +0000)
committerlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Wed, 24 Feb 2010 17:08:02 +0000 (17:08 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@14387 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/SysdynBrowser.java

index 4cf4c6f31bb96ea62b3241a32a9227c0c55ea28b..2cf9ae61f9325ae0901f645cb1c966ffc2c68b6a 100644 (file)
@@ -6,26 +6,29 @@ import java.util.Collections;
 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
@@ -42,13 +45,13 @@ public class SysdynBrowser extends GraphExplorerViewBase2 {
         //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
@@ -69,14 +72,16 @@ public class SysdynBrowser extends GraphExplorerViewBase2 {
         }, 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
@@ -90,8 +95,17 @@ public class SysdynBrowser extends GraphExplorerViewBase2 {
                     \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