From: lempinen Date: Fri, 30 Jul 2010 13:14:58 +0000 (+0000) Subject: Model browser cleanup X-Git-Tag: simantics-1.2.0~145 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=68a295253073844faeeff1e4a8dbc81b15420820;p=simantics%2Fsysdyn.git Model browser cleanup git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@16883 ac1ea38d-2e2b-0410-8846-a27921b304fc --- diff --git a/org.simantics.sysdyn.ui/icons/palette.png b/org.simantics.sysdyn.ui/icons/palette.png new file mode 100644 index 00000000..73c5b3f2 Binary files /dev/null and b/org.simantics.sysdyn.ui/icons/palette.png differ diff --git a/org.simantics.sysdyn.ui/plugin.xml b/org.simantics.sysdyn.ui/plugin.xml index 4ae354c9..6988c690 100644 --- a/org.simantics.sysdyn.ui/plugin.xml +++ b/org.simantics.sysdyn.ui/plugin.xml @@ -74,6 +74,7 @@ restorable="true"> @@ -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