From dc65c9c5dc1f8a1c9e72d99a5aa889c894c06bde Mon Sep 17 00:00:00 2001 From: lempinen Date: Wed, 24 Feb 2010 17:08:02 +0000 Subject: [PATCH] Renaming in sysdyn model browser git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@14387 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../sysdyn/ui/browser/SysdynBrowser.java | 50 ++++++++++++------- 1 file changed, 32 insertions(+), 18 deletions(-) diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/SysdynBrowser.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/SysdynBrowser.java index 4cf4c6f3..2cf9ae61 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/SysdynBrowser.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/SysdynBrowser.java @@ -6,26 +6,29 @@ import java.util.Collections; import java.util.Map; import org.simantics.browsing.ui.BuiltinKeys; -import org.simantics.browsing.ui.ColumnKeys; -import org.simantics.browsing.ui.ContextMenuInitializer; -import org.simantics.browsing.ui.IContextMenuInitializer; -import org.simantics.browsing.ui.INodeContext; -import org.simantics.browsing.ui.Labeler; -import org.simantics.browsing.ui.LabelerFactory; +import org.simantics.browsing.ui.NodeContext; import org.simantics.browsing.ui.PrimitiveQueryUpdater; import org.simantics.browsing.ui.BuiltinKeys.LabelerKey; +import org.simantics.browsing.ui.common.ColumnKeys; +import org.simantics.browsing.ui.common.ContextMenuInitializer; import org.simantics.browsing.ui.common.EvaluatorData; -import org.simantics.browsing.ui.common.IEvaluatorData.Evaluator; -import org.simantics.browsing.ui.common.labelers.LazyGraphLabeler; -import org.simantics.browsing.ui.common.labelers.StringRepresentationLabelerFactory; -import org.simantics.browsing.ui.common.viewpoints.GraphViewpointFactory; -import org.simantics.browsing.ui.common.views.GraphExplorerViewBase2; +import org.simantics.browsing.ui.common.EvaluatorDataImpl; +import org.simantics.browsing.ui.common.EvaluatorImpl; +import org.simantics.browsing.ui.common.IContextMenuInitializer; +import org.simantics.browsing.ui.common.EvaluatorData.Evaluator; +import org.simantics.browsing.ui.content.Labeler; +import org.simantics.browsing.ui.content.LabelerFactory; +import org.simantics.browsing.ui.graph.GraphExplorerViewBase2; +import org.simantics.browsing.ui.graph.GraphViewpointFactory; +import org.simantics.browsing.ui.graph.LazyGraphLabeler; import org.simantics.db.Builtins; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; import org.simantics.db.Session; import org.simantics.db.exception.DatabaseException; +import org.simantics.modeling.ui.modelBrowser.model.util.LabelModifier; import org.simantics.sysdyn.SysdynResource; +import org.simantics.ui.SimanticsUI; import org.simantics.utils.datastructures.hints.HintContext; @@ -42,13 +45,13 @@ public class SysdynBrowser extends GraphExplorerViewBase2 { //if (sessionContext != null) //factoryHints.setHint(IGraphExplorerHints.KEY_SESSION_CONTEXT, sessionContext); - EvaluatorData data = new EvaluatorData(); + EvaluatorData data = new EvaluatorDataImpl(); data.addEvaluator(Resource.class, createResourceEvaluator(session, factoryHints)); return data; } private Evaluator createResourceEvaluator(Session session, HintContext factoryHints) { - Evaluator evaluator = new Evaluator(); + Evaluator evaluator = new EvaluatorImpl(); evaluator.addViewpoint(new GraphViewpointFactory() { @Override protected Collection getChildren(ReadGraph g, Resource r) @@ -69,14 +72,16 @@ public class SysdynBrowser extends GraphExplorerViewBase2 { }, 1.0); evaluator.addLabeler(new LabelerFactory() { @Override - public Labeler create(PrimitiveQueryUpdater updater, final INodeContext context, - LabelerKey key) { + public Labeler create(PrimitiveQueryUpdater updater, final NodeContext context, LabelerKey key) { return new LazyGraphLabeler(updater, context, key) { + + Resource nameResource; + @Override public Map labels(ReadGraph g) throws DatabaseException { Builtins b = g.getBuiltins(); - SysdynResource sr = SysdynResource.getInstance(g); + nameResource = b.HasName; Resource el = (Resource) context.getConstant(BuiltinKeys.INPUT); StringBuilder sb = new StringBuilder(); for(Resource r : g.getObjects(el, b.HasName)) @@ -90,8 +95,17 @@ public class SysdynBrowser extends GraphExplorerViewBase2 { @Override public Modifier getModifier(String key) { - System.out.println("getModifier(" + key + ")"); - return null; + LabelModifier modifier = new LabelModifier(SimanticsUI.getSession(), (Resource) context.getConstant(BuiltinKeys.INPUT), nameResource) { + @Override + public String isValid(String label) { + if (label.isEmpty()) + return "Empty label not allowed"; + if (label.contains(" ")) + return "Spaces are not allowed"; + return null; + } + }; + return modifier; } }; } -- 2.47.1