From: lempinen Date: Thu, 20 May 2010 06:41:38 +0000 (+0000) Subject: Gave models labels and modified editor to use the label as its partName X-Git-Tag: simantics-1.2.0~242 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=1cc13b3369496fff25322b3efc395489bb3ca391;p=simantics%2Fsysdyn.git Gave models labels and modified editor to use the label as its partName git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@15783 ac1ea38d-2e2b-0410-8846-a27921b304fc --- diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ModelLabeler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ModelLabeler.java index 64dc4856..bb53b594 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ModelLabeler.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ModelLabeler.java @@ -9,7 +9,7 @@ public class ModelLabeler extends LabelerContributor{ @Override public String getLabel(ReadGraph graph, ModelNode model) throws DatabaseException { - String name = graph.getPossibleRelatedValue(model.resource, graph.getBuiltins().HasName); - return name == null ? "Model (no name)" : name; + String label = graph.getPossibleRelatedValue(model.resource, graph.getBuiltins().HasLabel); + return label == null ? "Model (no name)" : label; } } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/SysdynDiagramEditor.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/SysdynDiagramEditor.java index 1da86b7c..1c795cfb 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/SysdynDiagramEditor.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/SysdynDiagramEditor.java @@ -23,6 +23,7 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorSite; import org.eclipse.ui.PartInitException; +import org.simantics.db.Builtins; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; import org.simantics.db.Session; @@ -175,12 +176,12 @@ public class SysdynDiagramEditor extends ResourceEditorPart { new TitleRequest(site.getId(), getResourceInput()) { @Override public String perform(ReadGraph graph) throws DatabaseException { + Builtins b = graph.getBuiltins(); Resource r = graph.getSingleObject( getResourceInput().getResource(), - graph.getBuiltins().IsConfigurationOf); - String n = null; - n = graph.adapt(r, String.class); - return n; + b.IsConfigurationOf); + String label = graph.getPossibleRelatedValue(r, b.HasLabel); + return label; } }, new TitleUpdater(site.getShell().getDisplay(), new Callback() { diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewModelHandler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewModelHandler.java index 232e673c..148bb34e 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewModelHandler.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewModelHandler.java @@ -24,6 +24,7 @@ public class NewModelHandler extends AbstractHandler { SysdynResource sr = SysdynResource.getInstance(graph); Resource model = graph.newResource(); graph.claimValue(model, b.HasName, "Model1"); + graph.claimValue(model, b.HasLabel, "Model1"); graph.claim(model, b.InstanceOf, sr.SysdynModel); graph.claim(model, b.PartOf, SimanticsUI.getProject().get()); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/project/SysdynProject.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/project/SysdynProject.java index 59fa382d..1020b1cd 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/project/SysdynProject.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/project/SysdynProject.java @@ -73,6 +73,7 @@ public class SysdynProject extends AbstractProjectFeature { SysdynResource sr = SysdynResource.getInstance(g); Resource model = g.newResource(); g.claimValue(model, b.HasName, "Model1"); + g.claimValue(model, b.HasLabel, "Model1"); g.claim(model, b.InstanceOf, sr.SysdynModel); g.claim(model, b.PartOf, library);