From 68a295253073844faeeff1e4a8dbc81b15420820 Mon Sep 17 00:00:00 2001 From: lempinen Date: Fri, 30 Jul 2010 13:14:58 +0000 Subject: [PATCH] Model browser cleanup git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@16883 ac1ea38d-2e2b-0410-8846-a27921b304fc --- org.simantics.sysdyn.ui/icons/palette.png | Bin 0 -> 856 bytes org.simantics.sysdyn.ui/plugin.xml | 39 +----------------- .../contributions/AbstractNodeImager.java | 24 ++++++++++- .../contributions/ConfigurationImager.java | 16 ------- .../contributions/ExperimentImager.java | 23 ----------- .../contributions/ExperimentsImager.java | 16 ------- .../ui/browser/contributions/InputImager.java | 17 -------- .../ui/browser/contributions/ModelImager.java | 16 ------- .../browser/contributions/ModuleImager.java | 16 ------- .../ui/browser/contributions/ModuleType.java | 30 -------------- .../contributions/ModuleTypeLabeler.java | 6 ++- .../ui/browser/contributions/Modules.java | 4 +- .../browser/contributions/VariableImager.java | 16 ------- .../ui/handlers/NewModuleNodeHandler.java | 1 - .../ResourceSelectionProcessor.java | 7 +++- 15 files changed, 37 insertions(+), 194 deletions(-) create mode 100644 org.simantics.sysdyn.ui/icons/palette.png delete mode 100644 org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ConfigurationImager.java delete mode 100644 org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ExperimentImager.java delete mode 100644 org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ExperimentsImager.java delete mode 100644 org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/InputImager.java delete mode 100644 org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ModelImager.java delete mode 100644 org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ModuleImager.java delete mode 100644 org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ModuleType.java delete mode 100644 org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/VariableImager.java diff --git a/org.simantics.sysdyn.ui/icons/palette.png b/org.simantics.sysdyn.ui/icons/palette.png new file mode 100644 index 0000000000000000000000000000000000000000..73c5b3f243d98d089dd9e025edc81b939c1a9320 GIT binary patch literal 856 zcmV-e1E>6nP)PbXFR5;6x zQ`<|^Q5@e>|3Fq06ckj13SKAzrBX7=2LmNa=VjAGbC_kBmo!b(h0(lh&dtlb&FNfD zmuquN(K1t)x?D|-M01+g{cLIqvEiq)K|Q2K51*IA`CQKDe7`gRw4E?o66yPi8&Nn? z6l%~H1nUQ%T@&i^1O5KKw~aW)k2+%HG368DWXx)cVb)1u?vucz;=oXT3q3jhU%Im| z1?(s=#*a)g@)(;l>H@5fX<;>n14d_9M|`nnP-6AN3z#%q4DzF(Nk5nWM_|14<{lEc zYPuy4KilYl*ag-mA8dVe2Tbuq#03kAEX>O@@Lksg>YW6tl(V+B2dCW}0wgkfx|Qv4 z-D>azy5k)pmaZ6BhrO`cMMsS?2x;x!C{kX=N`E6pB`Ii0bgLj_hNq!8%(hX_#U?!j zKiGk=Hh5$0c^KwfGl^?D=47dOtiAw2KNAm$$b9o7%%}<>OK>*QNXr%9w1k|LfQ{U2 zSbTi2+))I}Pzx-B&9LZXSZvF~o2CeGlzvc4uVc3ME*4%1(7-xD(S|uUCaD1_sK#7S ztY9n_un1WWgXlK28Rs!v7K;_~=D2b`P734*5Qt!^h`~~a5OuM~Hfisl25mar^a_}} zg_v*2Bt^;WEyLcAGWiUsw{`FkNI_Ti5|L(1@j^*TA*!PfgVy)tDpxOv#%F0dOfNa0 zdc|1jYs3&aBQ0Zq#{l)Z8sgGaTq&(WaY+Uil^l#q(oh+BaNO|=WH5X?GktSNWOaL* z*ZNp}GN_(f2a)O)VOE@kDJ~t8MZuVBOvi$ni}tLGC}Zpk**1wJva900hs{igrph=+ z+^OPVd@W&MNyEpqoQ;kge+VO-3U?f3JDTsf%0@_u%bjJIsY%3=wv>=dpyM%#>wcRc z+$m+(U9dwMf67h5I&QPOO-M5_z-8e1J$HL#g&=&d>pz$2H|k=JCX$xdMNx @@ -587,10 +588,6 @@ class="org.simantics.sysdyn.ui.browser.contributions.Module" preference="1.0"> - - - - - - - - - - - - - - - - - - diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/AbstractNodeImager.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/AbstractNodeImager.java index 977d54e8..21ae321a 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/AbstractNodeImager.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/AbstractNodeImager.java @@ -17,20 +17,40 @@ import org.simantics.db.ReadGraph; import org.simantics.db.exception.DatabaseException; import org.simantics.sysdyn.ui.Activator; import org.simantics.sysdyn.ui.browser.nodes.AbstractNode; +import org.simantics.sysdyn.ui.browser.nodes.ConfigurationNode; +import org.simantics.sysdyn.ui.browser.nodes.ExperimentNode; import org.simantics.sysdyn.ui.browser.nodes.ExperimentsFolder; +import org.simantics.sysdyn.ui.browser.nodes.InputNode; +import org.simantics.sysdyn.ui.browser.nodes.ModelNode; +import org.simantics.sysdyn.ui.browser.nodes.ModuleNode; +import org.simantics.sysdyn.ui.browser.nodes.ModuleTypeNode; import org.simantics.sysdyn.ui.browser.nodes.ModulesNode; import org.simantics.sysdyn.ui.browser.nodes.OperatingInterfacesFolder; +import org.simantics.sysdyn.ui.browser.nodes.VariableNode; public class AbstractNodeImager extends ImagerContributor { @Override public ImageDescriptor getDescriptor(ReadGraph graph, AbstractNode node) throws DatabaseException { + String image = null; if (node instanceof ExperimentsFolder || node instanceof OperatingInterfacesFolder || node instanceof ModulesNode) - return ImageDescriptor.createFromURL(Activator.getDefault().getBundle().getResource("icons/folder.png")); - + image = "icons/folder.png"; + else if (node instanceof ModuleTypeNode || node instanceof ModuleNode || node instanceof ConfigurationNode) + image = "icons/bricks.png"; + else if (node instanceof ExperimentNode) + image = "icons/time.png"; + else if (node instanceof InputNode) + image = "icons/brick_link.png"; + else if (node instanceof ModelNode) + image = "icons/chart_organisation.png"; + else if (node instanceof VariableNode) + image = "icons/brick.png"; + + if (image != null) + return ImageDescriptor.createFromURL(Activator.getDefault().getBundle().getResource(image)); return null; } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ConfigurationImager.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ConfigurationImager.java deleted file mode 100644 index e8f1f917..00000000 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ConfigurationImager.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.simantics.sysdyn.ui.browser.contributions; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.simantics.browsing.ui.swt.ImagerContributor; -import org.simantics.db.ReadGraph; -import org.simantics.db.exception.DatabaseException; -import org.simantics.sysdyn.ui.Activator; -import org.simantics.sysdyn.ui.browser.nodes.ConfigurationNode; - -public class ConfigurationImager extends ImagerContributor { - - @Override - public ImageDescriptor getDescriptor(ReadGraph graph, ConfigurationNode node) throws DatabaseException { - return ImageDescriptor.createFromURL(Activator.getDefault().getBundle().getResource("icons/bricks.png")); - } -} diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ExperimentImager.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ExperimentImager.java deleted file mode 100644 index 0f607d5d..00000000 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ExperimentImager.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.simantics.sysdyn.ui.browser.contributions; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.simantics.browsing.ui.swt.ImagerContributor; -import org.simantics.db.ReadGraph; -import org.simantics.db.exception.DatabaseException; -import org.simantics.project.IProject; -import org.simantics.simulation.project.IExperimentManager; -import org.simantics.sysdyn.ui.Activator; -import org.simantics.sysdyn.ui.browser.nodes.ExperimentNode; -import org.simantics.ui.SimanticsUI; - -public class ExperimentImager extends ImagerContributor { - - @Override - public ImageDescriptor getDescriptor(ReadGraph graph, ExperimentNode experiment) throws DatabaseException { - IProject project = SimanticsUI.getProject(); - IExperimentManager experimentManager = project.getHint(IExperimentManager.KEY_EXPERIMENT_MANAGER); - System.out.println(experimentManager.getActiveExperiment()); - return ImageDescriptor.createFromURL(Activator.getDefault().getBundle().getResource("icons/time.png")); - } - -} diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ExperimentsImager.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ExperimentsImager.java deleted file mode 100644 index beb1e804..00000000 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ExperimentsImager.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.simantics.sysdyn.ui.browser.contributions; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.simantics.browsing.ui.swt.ImagerContributor; -import org.simantics.db.ReadGraph; -import org.simantics.db.exception.DatabaseException; -import org.simantics.sysdyn.ui.Activator; -import org.simantics.sysdyn.ui.browser.nodes.ExperimentsFolder; - -public class ExperimentsImager extends ImagerContributor { - - @Override - public ImageDescriptor getDescriptor(ReadGraph graph, ExperimentsFolder node) throws DatabaseException { - return ImageDescriptor.createFromURL(Activator.getDefault().getBundle().getResource("icons/folder.png")); - } -} diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/InputImager.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/InputImager.java deleted file mode 100644 index c70b3665..00000000 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/InputImager.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.simantics.sysdyn.ui.browser.contributions; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.simantics.browsing.ui.swt.ImagerContributor; -import org.simantics.db.ReadGraph; -import org.simantics.db.exception.DatabaseException; -import org.simantics.sysdyn.ui.Activator; -import org.simantics.sysdyn.ui.browser.nodes.InputNode; - -public class InputImager extends ImagerContributor { - - @Override - public ImageDescriptor getDescriptor(ReadGraph graph, InputNode node) throws DatabaseException { - return ImageDescriptor.createFromURL(Activator.getDefault().getBundle().getResource("icons/brick_link.png")); - } - -} diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ModelImager.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ModelImager.java deleted file mode 100644 index 00e386b5..00000000 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ModelImager.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.simantics.sysdyn.ui.browser.contributions; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.simantics.browsing.ui.swt.ImagerContributor; -import org.simantics.db.ReadGraph; -import org.simantics.db.exception.DatabaseException; -import org.simantics.sysdyn.ui.Activator; -import org.simantics.sysdyn.ui.browser.nodes.ModelNode; - -public class ModelImager extends ImagerContributor { - - @Override - public ImageDescriptor getDescriptor(ReadGraph graph, ModelNode node) throws DatabaseException { - return ImageDescriptor.createFromURL(Activator.getDefault().getBundle().getResource("icons/chart_organisation.png")); - } -} diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ModuleImager.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ModuleImager.java deleted file mode 100644 index b6ecea38..00000000 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ModuleImager.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.simantics.sysdyn.ui.browser.contributions; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.simantics.browsing.ui.swt.ImagerContributor; -import org.simantics.db.ReadGraph; -import org.simantics.db.exception.DatabaseException; -import org.simantics.sysdyn.ui.Activator; -import org.simantics.sysdyn.ui.browser.nodes.ModuleNode; - -public class ModuleImager extends ImagerContributor { - - @Override - public ImageDescriptor getDescriptor(ReadGraph graph, ModuleNode node) throws DatabaseException { - return ImageDescriptor.createFromURL(Activator.getDefault().getBundle().getResource("icons/bricks.png")); - } -} diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ModuleType.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ModuleType.java deleted file mode 100644 index 5e79acd9..00000000 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ModuleType.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.simantics.sysdyn.ui.browser.contributions; - -import java.util.ArrayList; -import java.util.Collection; - -import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributor; -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.exception.DatabaseException; -import org.simantics.modeling.ModelingResources; -import org.simantics.sysdyn.ui.browser.nodes.AbstractNode; -import org.simantics.sysdyn.ui.browser.nodes.ModuleTypeNode; - -public class ModuleType extends ViewpointContributor { - - @Override - public Collection getContribution(ReadGraph graph, ModuleTypeNode module) throws DatabaseException { - ArrayList result = new ArrayList(); - ModelingResources mr = ModelingResources.getInstance(graph); - Resource symbol = graph.getPossibleObject(module.resource, mr.ComponentTypeToSymbol); - result.add(graph.adapt(symbol, AbstractNode.class)); - return result; - } - - @Override - public String getViewpointId() { - return "Standard"; - } - -} diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ModuleTypeLabeler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ModuleTypeLabeler.java index 4390dcdf..74adf591 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ModuleTypeLabeler.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ModuleTypeLabeler.java @@ -2,14 +2,18 @@ package org.simantics.sysdyn.ui.browser.contributions; import org.simantics.browsing.ui.graph.contributor.labeler.LabelerContributor; import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; import org.simantics.db.exception.DatabaseException; +import org.simantics.modeling.ModelingResources; import org.simantics.sysdyn.ui.browser.nodes.ModuleTypeNode; public class ModuleTypeLabeler extends LabelerContributor{ @Override public String getLabel(ReadGraph graph, ModuleTypeNode moduleType) throws DatabaseException { - String label = graph.getPossibleRelatedValue(moduleType.resource, graph.getBuiltins().HasLabel); + ModelingResources mr = ModelingResources.getInstance(graph); + Resource typeResource = graph.getPossibleObject(moduleType.resource, mr.SymbolToComponentType); + String label = graph.getPossibleRelatedValue(typeResource, graph.getBuiltins().HasName); return label == null ? "ModuleType (no name)" : label; } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Modules.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Modules.java index 5281330f..4399de9b 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Modules.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Modules.java @@ -9,6 +9,7 @@ import org.simantics.db.ReadGraph; import org.simantics.db.Resource; import org.simantics.db.common.request.ObjectsWithType; import org.simantics.db.exception.DatabaseException; +import org.simantics.modeling.ModelingResources; import org.simantics.structural.stubs.StructuralResource2; import org.simantics.sysdyn.ui.browser.nodes.AbstractNode; import org.simantics.sysdyn.ui.browser.nodes.ModuleTypeNode; @@ -24,7 +25,8 @@ public class Modules extends ViewpointContributor { Builtins b = graph.getBuiltins(); StructuralResource2 st = StructuralResource2.getInstance(graph); for(Resource r : graph.syncRequest(new ObjectsWithType(model.resource, b.ConsistsOf, st.ComponentType))) { - result.add(new ModuleTypeNode(r)); + Resource symbol = graph.getPossibleObject(r,ModelingResources.getInstance(graph).ComponentTypeToSymbol); + result.add(new ModuleTypeNode(symbol)); } return result; diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/VariableImager.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/VariableImager.java deleted file mode 100644 index 3dc6c4cd..00000000 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/VariableImager.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.simantics.sysdyn.ui.browser.contributions; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.simantics.browsing.ui.swt.ImagerContributor; -import org.simantics.db.ReadGraph; -import org.simantics.db.exception.DatabaseException; -import org.simantics.sysdyn.ui.Activator; -import org.simantics.sysdyn.ui.browser.nodes.VariableNode; - -public class VariableImager extends ImagerContributor { - - @Override - public ImageDescriptor getDescriptor(ReadGraph graph, VariableNode node) throws DatabaseException { - return ImageDescriptor.createFromURL(Activator.getDefault().getBundle().getResource("icons/brick.png")); - } -} diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewModuleNodeHandler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewModuleNodeHandler.java index 1e9fdc0f..cd1484ed 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewModuleNodeHandler.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewModuleNodeHandler.java @@ -41,7 +41,6 @@ public class NewModuleNodeHandler extends AbstractHandler { Resource moduleType = g.newResource(); g.claimValue(moduleType, mu.b.HasName, "New Module Type"); - g.claimValue(moduleType, mu.b.HasLabel, "New Module Type"); g.claim(moduleType, mu.b.Inherits, sr.Module); g.claim(moduleType, mu.b.PartOf, model); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ResourceSelectionProcessor.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ResourceSelectionProcessor.java index cf6fd216..8dcc4316 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ResourceSelectionProcessor.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ResourceSelectionProcessor.java @@ -128,13 +128,16 @@ public class ResourceSelectionProcessor implements SelectionProcessor