From: jplaine Date: Tue, 24 Aug 2010 12:11:23 +0000 (+0000) Subject: Variable browser (copied from Apros, doesn't seem to work yet, though) X-Git-Tag: simantics-1.2.0~82 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=1d74edbb8e774a1c39f3636f8b7465eed1e16f18;p=simantics%2Fsysdyn.git Variable browser (copied from Apros, doesn't seem to work yet, though) git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@17510 ac1ea38d-2e2b-0410-8846-a27921b304fc --- diff --git a/org.simantics.sysdyn.ui/plugin.xml b/org.simantics.sysdyn.ui/plugin.xml index 544b4155..dbcacb59 100644 --- a/org.simantics.sysdyn.ui/plugin.xml +++ b/org.simantics.sysdyn.ui/plugin.xml @@ -77,6 +77,17 @@ name="Dependencies" restorable="true"> + + + Operation view browser for Sysdyn. + + @@ -481,6 +492,11 @@ preference="2.0"> + + + + + @@ -506,10 +522,6 @@ class="org.simantics.sysdyn.ui.browser.contributions.ModulesLabeler" preference="2.0"> - @@ -531,6 +543,10 @@ preference="2.0"> + + + + @@ -545,6 +561,10 @@ preference="2.0"> + + + + diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/SysdynOperationBrowser.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/SysdynOperationBrowser.java new file mode 100644 index 00000000..45f98c0b --- /dev/null +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/SysdynOperationBrowser.java @@ -0,0 +1,17 @@ +package org.simantics.sysdyn.ui.browser; + +import java.util.Collections; +import java.util.Set; + +import org.simantics.browsing.ui.swt.GraphExplorerView; + +public class SysdynOperationBrowser extends GraphExplorerView { + + final private Set browseContexts = Collections.singleton("http://www.simantics.org/Sysdyn-1.0/SysdynOperationBrowser"); + + @Override + protected Set getBrowseContexts() { + return browseContexts; + } + +} diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/property/OperationModelContributor.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/property/OperationModelContributor.java new file mode 100644 index 00000000..d1fd23f0 --- /dev/null +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/property/OperationModelContributor.java @@ -0,0 +1,29 @@ +package org.simantics.sysdyn.ui.property; + +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.exception.DatabaseException; +import org.simantics.db.layer0.variable.Variable; + +public class OperationModelContributor extends ViewpointContributor { + + @Override + public Collection getContribution(ReadGraph graph, OperationModelNode model) throws DatabaseException { + + Variable modelVariable = model.data; + Variable config = modelVariable.getChild(graph, "BaseRealization"); + ArrayList result = new ArrayList(); + result.addAll(config.browseChildren(graph)); + return result; + + } + + @Override + public String getViewpointId() { + return "Standard"; + } + +} \ No newline at end of file diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/property/OperationModelLabels.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/property/OperationModelLabels.java new file mode 100644 index 00000000..55fef5e5 --- /dev/null +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/property/OperationModelLabels.java @@ -0,0 +1,23 @@ +package org.simantics.sysdyn.ui.property; + +import java.util.Map; + +import org.simantics.browsing.ui.common.ColumnKeys; +import org.simantics.browsing.ui.graph.contributor.labeler.ColumnLabelerContributor; +import org.simantics.databoard.binding.java.StringBindingDefault; +import org.simantics.db.ReadGraph; +import org.simantics.db.exception.DatabaseException; +import org.simantics.utils.datastructures.ArrayMap; + +public class OperationModelLabels extends ColumnLabelerContributor { + + @Override + public Map getLabel(ReadGraph graph, OperationModelNode model) throws DatabaseException { + + String label = model.data.getPropertyValue(graph, "Name", StringBindingDefault.INSTANCE); + + return new ArrayMap(new String[] { ColumnKeys.SINGLE } , new String[] { label }); + + } + +} diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/property/OperationModelNode.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/property/OperationModelNode.java new file mode 100644 index 00000000..f6e249ae --- /dev/null +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/property/OperationModelNode.java @@ -0,0 +1,21 @@ +package org.simantics.sysdyn.ui.property; + +import org.simantics.browsing.ui.common.ColumnKeys; +import org.simantics.browsing.ui.common.imagers.ImageURLs; +import org.simantics.browsing.ui.common.imagers.SingleImageURLs; +import org.simantics.browsing.ui.common.node.AbstractNode; +import org.simantics.db.layer0.variable.Variable; +import org.simantics.sysdyn.ui.Activator; + +public class OperationModelNode extends AbstractNode { + + public OperationModelNode(Variable data) { + super(data); + } + + @Override + protected ImageURLs getImageURLs() { + return new SingleImageURLs(ColumnKeys.SINGLE, Activator.getDefaultResource("icons/chart_organisation.png")); + } + +} diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/property/OperationProjectContributor.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/property/OperationProjectContributor.java new file mode 100644 index 00000000..af6e5e6f --- /dev/null +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/property/OperationProjectContributor.java @@ -0,0 +1,42 @@ +package org.simantics.sysdyn.ui.property; + +import java.util.ArrayList; +import java.util.Collection; + +import org.simantics.browsing.ui.Tester; +import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributor; +import org.simantics.browsing.ui.graph.tester.GraphTesters; +import org.simantics.db.Builtins; +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.db.layer0.variable.Variable; +import org.simantics.project.ontology.ProjectResource; +import org.simantics.simulation.ontology.SimulationResource; + +public class OperationProjectContributor extends ViewpointContributor { + + @Override + public Collection getContribution(ReadGraph graph, Resource project) throws DatabaseException { + + ArrayList result = new ArrayList(); + for(Resource model : graph.syncRequest(new ObjectsWithType(project, b.ConsistsOf, SimulationResource.getInstance(graph).Model))) { + result.add(new OperationModelNode(graph.adapt(model, Variable.class))); + } + return result; + + } + + @Override + public Tester getNodeContextTester() { + + return GraphTesters.type(ProjectResource.URIs.Project); + } + + @Override + public String getViewpointId() { + return "Standard"; + } + +} \ No newline at end of file diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/property/OperationVariableContributor.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/property/OperationVariableContributor.java new file mode 100644 index 00000000..a87a467e --- /dev/null +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/property/OperationVariableContributor.java @@ -0,0 +1,26 @@ +package org.simantics.sysdyn.ui.property; + +import java.util.ArrayList; +import java.util.Collection; + +import org.simantics.browsing.ui.graph.impl.contributor.viewpoint.ViewpointContributorImpl; +import org.simantics.db.ReadGraph; +import org.simantics.db.exception.DatabaseException; +import org.simantics.db.layer0.variable.Variable; + +public class OperationVariableContributor extends ViewpointContributorImpl { + + @Override + public Collection getContribution(ReadGraph graph, Variable input) throws DatabaseException { + ArrayList result = new ArrayList(); + result.addAll(input.browseProperties(graph)); + result.addAll(input.browseChildren(graph)); + return result; + } + + @Override + public String getViewpointId() { + return "Properties"; + } + +} diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/property/OperationVariableImager.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/property/OperationVariableImager.java new file mode 100644 index 00000000..dbad90eb --- /dev/null +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/property/OperationVariableImager.java @@ -0,0 +1,28 @@ +/******************************************************************************* + * Copyright (c) 2007, 2010 Association for Decentralized Information Management + * in Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.sysdyn.ui.property; + +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.db.layer0.variable.Variable; +import org.simantics.modeling.ui.Activator; + +public class OperationVariableImager extends ImagerContributor { + + @Override + public ImageDescriptor getDescriptor(ReadGraph graph, Variable var) throws DatabaseException { + return Activator.BULLET_ICON; + } + +} diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/property/OperationVariableLabels.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/property/OperationVariableLabels.java new file mode 100644 index 00000000..52162ba1 --- /dev/null +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/property/OperationVariableLabels.java @@ -0,0 +1,24 @@ +package org.simantics.sysdyn.ui.property; + +import java.util.Map; + +import org.simantics.browsing.ui.common.ColumnKeys; +import org.simantics.browsing.ui.graph.contributor.labeler.ColumnLabelerContributor; +import org.simantics.databoard.binding.java.StringBindingDefault; +import org.simantics.db.ReadGraph; +import org.simantics.db.exception.DatabaseException; +import org.simantics.db.layer0.variable.Variable; +import org.simantics.utils.datastructures.ArrayMap; + +public class OperationVariableLabels extends ColumnLabelerContributor { + + @Override + public Map getLabel(ReadGraph graph, Variable variable) throws DatabaseException { + + String label = variable.getPropertyValue(graph, "Name", StringBindingDefault.INSTANCE); + + return new ArrayMap(new String[] { ColumnKeys.SINGLE } , new String[] { label }); + + } + +}