</license>\r
\r
<includes\r
- id="org.simantics.sdk"\r
+ id="org.eclipse.equinox.executable"\r
+ version="0.0.0"/>\r
+\r
+ <includes\r
+ id="org.eclipse.rcp"\r
+ version="0.0.0"/>\r
+\r
+ <includes\r
+ id="org.simantics.browsing.ui"\r
+ version="0.0.0"/>\r
+\r
+ <includes\r
+ id="org.simantics.charts"\r
+ version="0.0.0"/>\r
+\r
+ <includes\r
+ id="org.simantics.data"\r
+ version="0.0.0"/>\r
+\r
+ <includes\r
+ id="org.simantics.db.client"\r
+ version="0.0.0"/>\r
+\r
+ <includes\r
+ id="org.simantics.db.services"\r
+ version="0.0.0"/>\r
+\r
+ <includes\r
+ id="org.simantics.eclipsec.launcher"\r
+ version="0.0.0"\r
+ optional="true"\r
+ os="win32"\r
+ ws="win32,wpf"\r
+ arch="x86,x86_64"/>\r
+\r
+ <includes\r
+ id="org.simantics.externals"\r
+ version="0.0.0"/>\r
+\r
+ <includes\r
+ id="org.simantics.g2d"\r
+ version="0.0.0"/>\r
+\r
+ <includes\r
+ id="org.simantics.help"\r
+ version="0.0.0"/>\r
+\r
+ <includes\r
+ id="org.simantics.issues"\r
+ version="0.0.0"/>\r
+\r
+ <includes\r
+ id="org.simantics.layer0"\r
+ version="0.0.0"/>\r
+\r
+ <includes\r
+ id="org.simantics.modeling"\r
+ version="0.0.0"/>\r
+\r
+ <includes\r
+ id="org.simantics.platform"\r
+ version="0.0.0"/>\r
+\r
+ <includes\r
+ id="org.simantics.platform.ui"\r
+ version="0.0.0"/>\r
+\r
+ <includes\r
+ id="org.simantics.rcp"\r
+ version="0.0.0"/>\r
+\r
+ <includes\r
+ id="org.simantics.search"\r
+ version="0.0.0"/>\r
+\r
+ <includes\r
+ id="org.simantics.simulation"\r
+ version="0.0.0"/>\r
+\r
+ <includes\r
+ id="org.simantics.structural"\r
+ version="0.0.0"/>\r
+\r
+ <includes\r
+ id="org.simantics.team"\r
+ version="0.0.0"/>\r
+\r
+ <includes\r
+ id="org.simantics.ui.workbench"\r
+ version="0.0.0"/>\r
+\r
+ <includes\r
+ id="org.simantics.utils"\r
+ version="0.0.0"/>\r
+\r
+ <includes\r
+ id="org.simantics.workbench"\r
version="0.0.0"/>\r
\r
<plugin\r
</menuContribution>\r
<menuContribution\r
locationURI="popup:#SysdynBrowserPopup?after=wbStart">\r
- <command\r
- commandId="org.simantics.sysdyn.ui.activateResult"\r
- id="org.simantics.sysdyn.ui.browser.activateResult"\r
- label="Show in charts"\r
- style="push">\r
- <visibleWhen\r
- checkEnabled="true">\r
- <with\r
- variable="selection">\r
- <test\r
- args="org.simantics.sysdyn.ui.browser.nodes.SimulationResultNode"\r
- property="org.simantics.sysdyn.ui.nodeClass">\r
- </test>\r
- </with>\r
- </visibleWhen>\r
- </command>\r
- <dynamic\r
- class="org.simantics.ui.contribution.OpenWithMenuContribution"\r
- id="org.simantics.sysdyn.ui.browser.openWithMenu">\r
- </dynamic>\r
- <command\r
- commandId="org.simantics.sysdyn.ui.renameNode"\r
- icon="icons/textfield_rename.png"\r
- id="org.simantics.sysdyn.ui.browser.rename"\r
- label="Rename"\r
- style="push">\r
- <visibleWhen checkEnabled="true">\r
- </visibleWhen>\r
- </command>\r
- <command\r
- commandId="org.simantics.sysdyn.ui.removeNode"\r
- icon="icons/cross.png"\r
- id="org.simantics.sysdyn.ui.browser.remove"\r
- label="Remove"\r
- style="push">\r
- <visibleWhen checkEnabled="true">\r
- </visibleWhen>\r
- </command>\r
<menu\r
label="New">\r
<command\r
</visibleWhen>\r
</command>\r
</menu>\r
- </menuContribution>\r
- <menuContribution\r
- locationURI="popup:#SysdynDiagramPopup?after=wbStart">\r
- <menu\r
- label="New...">\r
- <command\r
- commandId="org.simantics.sysdyn.ui.createAuxiliary"\r
- label="Auxiliary"\r
- style="push">\r
- </command>\r
- <command\r
- commandId="org.simantics.sysdyn.ui.createStock"\r
- label="Stock"\r
- style="push">\r
- </command>\r
- <command\r
- commandId="org.simantics.sysdyn.ui.createValve"\r
- label="Valve"\r
- style="push">\r
- </command>\r
- <command\r
- commandId="org.simantics.sysdyn.ui.createCloud"\r
- label="Cloud"\r
- style="push">\r
- </command>\r
- </menu>\r
+ <dynamic\r
+ class="org.simantics.ui.contribution.OpenWithMenuContribution"\r
+ id="org.simantics.sysdyn.ui.browser.openWithMenu">\r
+ </dynamic>\r
<command\r
- commandId="org.simantics.sysdyn.ui.showModule"\r
- icon="icons/palette.png"\r
- label="Show Module"\r
+ commandId="org.simantics.sysdyn.ui.activateResult"\r
+ id="org.simantics.sysdyn.ui.browser.activateResult"\r
+ label="Show in charts"\r
style="push">\r
- <visibleWhen>\r
- <and>\r
- <with\r
- variable="selection">\r
- <and>\r
- <test\r
- args="http://www.simantics.org/Sysdyn-1.0/ModuleSymbol"\r
- property="org.simantics.graph.resourceType">\r
- </test>\r
- </and>\r
- </with>\r
- </and>\r
+ <visibleWhen\r
+ checkEnabled="true">\r
+ <with\r
+ variable="selection">\r
+ <test\r
+ args="org.simantics.sysdyn.ui.browser.nodes.SimulationResultNode"\r
+ property="org.simantics.sysdyn.ui.nodeClass">\r
+ </test>\r
+ </with>\r
</visibleWhen>\r
</command>\r
<command\r
- commandId="org.simantics.sysdyn.ui.rename"\r
+ commandId="org.simantics.sysdyn.ui.renameNode"\r
icon="icons/textfield_rename.png"\r
+ id="org.simantics.sysdyn.ui.browser.rename"\r
label="Rename"\r
style="push">\r
- <visibleWhen\r
- checkEnabled="false">\r
+ <visibleWhen checkEnabled="true">\r
</visibleWhen>\r
</command>\r
<command\r
- commandId="org.simantics.sysdyn.ui.remove"\r
+ commandId="org.simantics.sysdyn.ui.removeNode"\r
icon="icons/cross.png"\r
+ id="org.simantics.sysdyn.ui.browser.remove"\r
label="Remove"\r
style="push">\r
- <visibleWhen\r
- checkEnabled="false">\r
+ <visibleWhen checkEnabled="true">\r
+ </visibleWhen>\r
+ </command>\r
+ </menuContribution>\r
+ <menuContribution\r
+ locationURI="popup:#SysdynDiagramPopup?after=wbStart">\r
+ <command\r
+ commandId="org.simantics.sysdyn.ui.showModule"\r
+ icon="icons/palette.png"\r
+ label="Show Module"\r
+ style="push">\r
+ <visibleWhen>\r
+ <with\r
+ variable="selection">\r
+ <test\r
+ args="http://www.simantics.org/Sysdyn-1.0/ModuleSymbol"\r
+ property="org.simantics.graph.resourceType">\r
+ </test>\r
+ </with>\r
</visibleWhen>\r
</command>\r
</menuContribution>\r
</activeWhen>\r
</handler>\r
<handler\r
- class="org.simantics.sysdyn.ui.handlers.UnlinkNodeHandler"\r
+ class="org.simantics.sysdyn.ui.handlers.UnlinkNodeHandler2"\r
commandId="org.simantics.sysdyn.ui.removeNode">\r
<activeWhen>\r
- <or>\r
- <with\r
- variable="selection">\r
+ <with\r
+ variable="selection">\r
+ <or>\r
<test\r
- args="org.simantics.sysdyn.ui.browser.nodes.ExperimentNode"\r
+ args="org.simantics.sysdyn.ui.browser.nodes.ModelNode"\r
property="org.simantics.sysdyn.ui.nodeClass">\r
</test>\r
- </with>\r
- <with\r
- variable="selection">\r
<test\r
- args="org.simantics.sysdyn.ui.browser.nodes.ModelNode"\r
+ args="org.simantics.sysdyn.ui.browser.nodes.ExperimentNode"\r
property="org.simantics.sysdyn.ui.nodeClass">\r
</test>\r
- </with>\r
- <with\r
- variable="selection">\r
<test\r
args="org.simantics.sysdyn.ui.browser.nodes.SimulationResultNode"\r
property="org.simantics.sysdyn.ui.nodeClass">\r
</test>\r
- </with>\r
- </or>\r
+ <test\r
+ args="org.simantics.sysdyn.ui.browser.nodes.ModuleTypeNode"\r
+ property="org.simantics.sysdyn.ui.nodeClass">\r
+ </test>\r
+ </or>\r
+ </with>\r
</activeWhen>\r
</handler>\r
<handler\r
args="org.simantics.sysdyn.ui.browser.nodes.SimulationResultNode"\r
property="org.simantics.sysdyn.ui.nodeClass">\r
</test>\r
+ <test\r
+ args="org.simantics.sysdyn.ui.browser.nodes.ModuleTypeNode"\r
+ property="org.simantics.sysdyn.ui.nodeClass">\r
+ </test>\r
</or>\r
</with>\r
</activeWhen>\r
class="org.simantics.sysdyn.ui.properties.ResourceSelectionProcessor">\r
</implementation>\r
</binding>\r
+ </extension>\r
+ <extension\r
+ point="org.eclipse.ui.perspectiveExtensions">\r
+ <perspectiveExtension\r
+ targetID="org.simantics.sysdyn.ui.perspective">\r
+ <view\r
+ id="org.simantics.browsing.ui.graph.propertyView"\r
+ ratio="0.75f"\r
+ relationship="bottom"\r
+ relative="org.eclipse.ui.editorss">\r
+ </view>\r
+ <view\r
+ id="org.eclipse.ui.console.ConsoleView"\r
+ minimized="false"\r
+ relationship="stack"\r
+ relative="org.simantics.browsing.ui.graph.propertyView">\r
+ </view>\r
+ <view\r
+ id="org.simantics.sysdyn.ui.trend.view"\r
+ relationship="left"\r
+ relative="org.simantics.browsing.ui.graph.propertyView">\r
+ </view>\r
+ <view\r
+ id="org.simantics.sysdyn.ui.dependencies.view"\r
+ minimized="false"\r
+ relationship="stack"\r
+ relative="org.simantics.sysdyn.ui.trend.view">\r
+ </view>\r
+ <view\r
+ id="org.simantics.sysdyn.ui.browser"\r
+ ratio="0.25f"\r
+ relationship="left"\r
+ relative="org.eclipse.ui.editorss">\r
+ </view>\r
+ <view\r
+ id="org.simantics.diagram.symbollibrary"\r
+ minimized="false"\r
+ relationship="stack"\r
+ relative="org.simantics.sysdyn.ui.browser">\r
+ </view>\r
+ </perspectiveExtension>\r
</extension>
</plugin>\r
+++ /dev/null
-/*******************************************************************************\r
- * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
- * in Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- * VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.sysdyn.ui.browser.contributions;\r
-\r
-import java.util.ArrayList;\r
-import java.util.Collection;\r
-\r
-import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributor;\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.request.Read;\r
-import org.simantics.sysdyn.SysdynResource;\r
-import org.simantics.sysdyn.ui.browser.nodes.AbstractNode;\r
-\r
-/**\r
- * @author Tuukka Lehtonen\r
- *\r
- * @param <T> input library node type\r
- */\r
-public abstract class LibraryViewpointContributor<T extends AbstractNode> extends ViewpointContributor<T> {\r
-\r
- protected abstract Read<Collection<Resource>> getChildRequest(ReadGraph graph, T lib) throws DatabaseException;\r
-\r
- @Override\r
- public final Collection<?> getContribution(ReadGraph graph, T lib) throws DatabaseException {\r
- ArrayList<AbstractNode> result = new ArrayList<AbstractNode>();\r
- for (Resource r : graph.syncRequest(getChildRequest(graph, lib))) {\r
- try {\r
- AbstractNode n = graph.adapt(r, AbstractNode.class);\r
- result.add(n);\r
- } catch (DatabaseException e) {\r
- e.printStackTrace();\r
- }\r
- }\r
- return result;\r
- }\r
-\r
- @Override\r
- public String getViewpointId() {\r
- return "Standard";\r
- }\r
-\r
-}\r
import org.simantics.db.Resource;\r
import org.simantics.db.common.request.ObjectsWithType;\r
import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.modeling.ModelingResources;\r
import org.simantics.structural.stubs.StructuralResource2;\r
import org.simantics.sysdyn.SysdynResource;\r
import org.simantics.sysdyn.ui.browser.nodes.AbstractNode;\r
import org.simantics.sysdyn.ui.browser.nodes.ModuleNode;\r
\r
-public class Module extends ViewpointContributor<ModuleNode> {\r
+public class Module extends ViewpointContributor<ModuleNode> {\r
\r
@Override\r
public Collection<?> getContribution(ReadGraph graph, ModuleNode module) throws DatabaseException {\r
Builtins b = graph.getBuiltins();\r
SysdynResource sr = SysdynResource.getInstance(graph);\r
StructuralResource2 str = StructuralResource2.getInstance(graph);\r
+\r
+ // ModuleTypeNode extends ModuleNode, so we get the instance in two different ways\r
Resource instance = graph.getPossibleObject(module.resource, b.InstanceOf);\r
+ if(graph.isInheritedFrom(module.resource, sr.ModuleSymbol)) {\r
+ ModelingResources mr = ModelingResources.getInstance(graph);\r
+ instance = graph.getPossibleObject(module.resource, mr.SymbolToComponentType);\r
+ }\r
+\r
if(instance == null) return result;\r
Resource conf = graph.getSingleObject(instance, str.IsDefinedBy);\r
for(Resource r : graph.syncRequest(new ObjectsWithType(conf, b.ConsistsOf, sr.IndependentVariable))) {\r
*******************************************************************************/\r
package org.simantics.sysdyn.ui.browser.nodes;\r
\r
-import org.simantics.browsing.ui.common.node.IDeletable;\r
+import java.util.Collection;\r
+\r
+import org.simantics.browsing.ui.common.node.DeleteException;\r
+import org.simantics.browsing.ui.common.node.IDeletableNode;\r
import org.simantics.browsing.ui.common.node.IDoubleClickableNode;\r
import org.simantics.browsing.ui.common.node.IModifiableNode;\r
import org.simantics.browsing.ui.content.Labeler.Modifier;\r
import org.simantics.browsing.ui.graph.impl.LabelModifier;\r
+import org.simantics.db.Builtins;\r
import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.exception.CancelTransactionException;\r
+import org.simantics.db.exception.DatabaseException;\r
import org.simantics.project.IProject;\r
import org.simantics.simulation.project.IExperimentManager;\r
+import org.simantics.sysdyn.SysdynResource;\r
import org.simantics.sysdyn.ui.handlers.SysdynExperimentActivator;\r
import org.simantics.ui.SimanticsUI;\r
import org.simantics.utils.ui.ErrorLogger;\r
+import org.simantics.utils.ui.ExceptionUtils;\r
\r
-public class ExperimentNode extends AbstractNode implements IDoubleClickableNode, IDeletable, IModifiableNode{\r
+public class ExperimentNode extends AbstractNode implements IDoubleClickableNode, IDeletableNode, IModifiableNode{\r
\r
public ExperimentNode(Resource resource) {\r
super(resource);\r
SysdynExperimentActivator.scheduleActivation(SimanticsUI.getSession(), project, experimentManager, resource);\r
return true;\r
}\r
- \r
+\r
@Override\r
public Modifier getModifier(String columnId) {\r
LabelModifier modifier = new LabelModifier(SimanticsUI.getSession(), resource) {\r
return modifier;\r
}\r
\r
+ @Override\r
+ public void delete() throws DeleteException {\r
+ try {\r
+ SimanticsUI.getSession().syncRequest(new WriteRequest() {\r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException, CancelTransactionException {\r
+ Builtins b = graph.getBuiltins();\r
+ Collection<Resource> results = graph.getObjects(resource, SysdynResource.getInstance(graph).HasResult);\r
+ if(results != null)\r
+ for(Resource result : results) \r
+ SimulationResultNode.unlinkResult(graph, result);\r
+ graph.deny(resource, b.PartOf); \r
+ }\r
+ });\r
+ } catch (DatabaseException e) {\r
+ ExceptionUtils.logAndShowError(e);\r
+ } \r
+ }\r
+\r
}\r
package org.simantics.sysdyn.ui.browser.nodes;\r
\r
-import org.simantics.browsing.ui.common.node.IDeletable;\r
+import org.simantics.browsing.ui.common.node.DeleteException;\r
+import org.simantics.browsing.ui.common.node.IDeletableNode;\r
import org.simantics.browsing.ui.common.node.IModifiableNode;\r
import org.simantics.browsing.ui.content.Labeler.Modifier;\r
import org.simantics.browsing.ui.graph.impl.LabelModifier;\r
+import org.simantics.db.Builtins;\r
import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.exception.CancelTransactionException;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.SysdynResource;\r
import org.simantics.ui.SimanticsUI;\r
+import org.simantics.utils.ui.ExceptionUtils;\r
\r
-public class ModelNode extends AbstractNode implements IDeletable, IModifiableNode {\r
+public class ModelNode extends AbstractNode implements IDeletableNode, IModifiableNode {\r
\r
public ModelNode(Resource resource) {\r
super(resource);\r
return modifier;\r
}\r
\r
+ @Override\r
+ public void delete() throws DeleteException {\r
+ try {\r
+ SimanticsUI.getSession().syncRequest(new WriteRequest() {\r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException, CancelTransactionException {\r
+ Builtins b = graph.getBuiltins();\r
+\r
+ for(Resource r : graph.getObjects(resource, b.ConsistsOf))\r
+ if(graph.isInstanceOf(r, SysdynResource.getInstance(graph).Result))\r
+ SimulationResultNode.deleteResultFiles(graph, r);\r
+\r
+ graph.deny(resource, b.PartOf);\r
+ }\r
+ });\r
+ } catch (DatabaseException e) {\r
+ ExceptionUtils.logAndShowError(e);\r
+ }\r
+ \r
+ }\r
+\r
}\r
package org.simantics.sysdyn.ui.browser.nodes;\r
\r
-import org.simantics.browsing.ui.common.node.IDeletable;\r
import org.simantics.db.Resource;\r
\r
-public class ModuleNode extends AbstractNode implements IDeletable {\r
+public class ModuleNode extends AbstractNode {\r
\r
public ModuleNode(Resource resource) {\r
super(resource);\r
package org.simantics.sysdyn.ui.browser.nodes;\r
\r
-import org.simantics.browsing.ui.common.node.IDeletable;\r
+import java.util.Collection;\r
+\r
+import org.simantics.browsing.ui.common.node.DeleteException;\r
+import org.simantics.browsing.ui.common.node.IDeletableNode;\r
+import org.simantics.browsing.ui.common.node.IModifiableNode;\r
+import org.simantics.browsing.ui.content.Labeler.Modifier;\r
+import org.simantics.browsing.ui.graph.impl.LabelModifier;\r
+import org.simantics.db.Builtins;\r
+import org.simantics.db.ReadGraph;\r
import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.ObjectsWithType;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.exception.ManyObjectsForFunctionalRelationException;\r
+import org.simantics.db.exception.ServiceException;\r
+import org.simantics.db.request.Read;\r
+import org.simantics.modeling.ModelingResources;\r
+import org.simantics.structural.stubs.StructuralResource2;\r
+import org.simantics.ui.SimanticsUI;\r
\r
-public class ModuleTypeNode extends AbstractNode implements IDeletable {\r
+public class ModuleTypeNode extends ModuleNode implements IDeletableNode, IModifiableNode {\r
\r
public ModuleTypeNode(Resource resource) {\r
super(resource);\r
}\r
+\r
+ @Override\r
+ public Modifier getModifier(String columnId) {\r
+ Modifier modifier = null;\r
+ try {\r
+ modifier = SimanticsUI.getSession().syncRequest(new Read<Modifier>() {\r
+\r
+ @Override\r
+ public Modifier perform(ReadGraph graph) throws ManyObjectsForFunctionalRelationException, ServiceException {\r
+ ModelingResources mr = ModelingResources.getInstance(graph);\r
+ Builtins b = graph.getBuiltins();\r
+ Resource type = graph.getPossibleObject(resource, mr.SymbolToComponentType);\r
+\r
+ LabelModifier modifier = new LabelModifier(SimanticsUI.getSession(), type, b.HasName) {\r
+ @Override\r
+ public String isValid(String label) {\r
+ if (label.isEmpty())\r
+ return "Empty name not allowed";\r
+ return null;\r
+ }\r
+ };\r
+\r
+\r
+ return modifier;\r
+ }\r
+ });\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ } \r
+\r
+ return modifier;\r
+ }\r
+\r
+ @Override\r
+ public void delete() throws DeleteException {\r
+ try {\r
+ SimanticsUI.getSession().syncRequest(new WriteRequest() {\r
+\r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException {\r
+ Builtins b = graph.getBuiltins();\r
+ StructuralResource2 st = StructuralResource2.getInstance(graph);\r
+ ModelingResources mr = ModelingResources.getInstance(graph);\r
+\r
+ Resource type = graph.getPossibleObject(resource, mr.SymbolToComponentType);\r
+ Resource model = graph.getSingleObject(type, b.PartOf);\r
+ Resource modelConfiguration = graph.getSingleObject(model, b.HasConfiguration);\r
+ if (!graph.syncRequest(new ObjectsWithType(modelConfiguration, b.ConsistsOf, type)).isEmpty()) {\r
+ System.out.println("The module is used at the model configuration");\r
+ return;\r
+ }\r
+ Collection<Resource> moduleTypes = graph.syncRequest(new ObjectsWithType(model, b.ConsistsOf, st.ComponentType));\r
+ for(Resource r : moduleTypes) {\r
+ Resource configuration = graph.getSingleObject(r, st.IsDefinedBy);\r
+ if(!graph.syncRequest(new ObjectsWithType(configuration, b.ConsistsOf, type)).isEmpty()) {\r
+ System.out.println("The module is used at another module: " + graph.getRelatedValue(r, b.HasName));\r
+ return;\r
+ }\r
+ }\r
+ graph.deny(model, b.ConsistsOf, type);\r
+ }\r
+ });\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
}\r
package org.simantics.sysdyn.ui.browser.nodes;\r
\r
-import org.simantics.browsing.ui.common.node.IDeletable;\r
+import java.io.File;\r
+\r
+import org.simantics.browsing.ui.common.node.DeleteException;\r
+import org.simantics.browsing.ui.common.node.IDeletableNode;\r
import org.simantics.browsing.ui.common.node.IModifiableNode;\r
import org.simantics.browsing.ui.content.Labeler.Modifier;\r
import org.simantics.browsing.ui.graph.impl.LabelModifier;\r
+import org.simantics.db.Builtins;\r
import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.exception.CancelTransactionException;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.SysdynResource;\r
import org.simantics.ui.SimanticsUI;\r
+import org.simantics.utils.ui.ExceptionUtils;\r
\r
-public class SimulationResultNode extends AbstractNode implements IDeletable, IModifiableNode {\r
+public class SimulationResultNode extends AbstractNode implements IDeletableNode, IModifiableNode {\r
\r
public SimulationResultNode(Resource resource) {\r
super(resource);\r
};\r
return modifier;\r
}\r
+\r
+\r
+ @Override\r
+ public void delete() throws DeleteException {\r
+ try {\r
+ SimanticsUI.getSession().syncRequest(new WriteRequest() {\r
+ @Override\r
+ public void perform(WriteGraph graph) throws DatabaseException, CancelTransactionException {\r
+ unlinkResult(graph, resource);\r
+ }\r
+ });\r
+ } catch (DatabaseException e) {\r
+ ExceptionUtils.logAndShowError(e);\r
+ }\r
+ \r
+ }\r
+ \r
+ \r
+ public static void unlinkResult(WriteGraph graph, Resource result) throws DatabaseException {\r
+ Builtins b = graph.getBuiltins();\r
+ deleteResultFiles(graph, result);\r
+ graph.deny(result, b.PartOf);\r
+ graph.deny(result, graph.getInverse(SysdynResource.getInstance(graph).HasResult));\r
+\r
+ }\r
+ \r
+ public static void deleteResultFiles(WriteGraph graph, Resource result) throws DatabaseException {\r
+ String path;\r
+ path = graph.getPossibleRelatedValue(result, SysdynResource.getInstance(graph).HasResultFile);\r
+ if(path != null) {\r
+ File file = new File(path);\r
+ file.delete();\r
+ File parent = file.getParentFile();\r
+ if(parent.listFiles().length == 0)\r
+ parent.delete();\r
+ }\r
+ }\r
}\r
package org.simantics.sysdyn.ui.editor;\r
\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.request.Read;\r
+import org.simantics.modeling.ComponentUtils;\r
+import org.simantics.modeling.ModelingResources;\r
+import org.simantics.structural.stubs.StructuralResource2;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.ui.SimanticsUI;\r
+\r
\r
public class OpenDiagramFromConfigurationAdapter extends org.simantics.modeling.ui.diagramEditor.OpenDiagramFromConfigurationAdapter {\r
\r
return EDITOR_ID;\r
}\r
\r
+ @Override\r
+ public boolean canHandle(ReadGraph g, Resource r) throws DatabaseException {\r
+ if(g.isInheritedFrom(r, SysdynResource.getInstance(g).ModuleSymbol)) {\r
+ ModelingResources mr = ModelingResources.getInstance(g);\r
+ StructuralResource2 sr2 = StructuralResource2.getInstance(g);\r
+ Resource componentType = g.getSingleObject(r, mr.SymbolToComponentType);\r
+ r = g.getSingleObject(componentType, sr2.IsDefinedBy);\r
+ }\r
+ return ComponentUtils.compositeHasDiagram(g, r) /*|| ComponentUtils.componentHasDiagram(g, r)*/;\r
+ }\r
+\r
+ @Override\r
+ public void openEditor(final Resource r) throws Exception {\r
+ Resource configuration = null;\r
+ try {\r
+ configuration = SimanticsUI.getSession().syncRequest(new Read<Resource>() {\r
+\r
+ @Override\r
+ public Resource perform(ReadGraph graph) throws DatabaseException {\r
+ if(graph.isInheritedFrom(r, SysdynResource.getInstance(graph).ModuleSymbol)) {\r
+ ModelingResources mr = ModelingResources.getInstance(graph);\r
+ StructuralResource2 sr2 = StructuralResource2.getInstance(graph);\r
+ Resource componentType = graph.getSingleObject(r, mr.SymbolToComponentType);\r
+ Resource configuration = graph.getSingleObject(componentType, sr2.IsDefinedBy);\r
+ return configuration;\r
+ }\r
+ else {\r
+ return null;\r
+ }\r
+ }\r
+ });\r
+ } catch (DatabaseException e1) {\r
+ e1.printStackTrace();\r
+ }\r
+ if (configuration != null)\r
+ super.openEditor(configuration);\r
+ else\r
+ super.openEditor(r);\r
+ }\r
+\r
}\r
new StaticObjectAdapter(elementType),\r
new StaticSymbolImpl(DEFAULT_IMAGE),\r
StaticSymbolImageInitializer.INSTANCE,\r
- new HoverTextElementHandler(0, 0, Alignment.LEADING, 1f , 7, 7, false),\r
+ new HoverTextElementHandler(0, 0, Alignment.LEADING, 1f , 7, 7, true),\r
BoundsOutline.INSTANCE,\r
new WholeElementTerminals(terminals)\r
).setId(ModuleFactory.class.getSimpleName());\r
--- /dev/null
+package org.simantics.sysdyn.ui.handlers;\r
+\r
+import org.eclipse.core.commands.ExecutionEvent;\r
+import org.eclipse.core.commands.ExecutionException;\r
+import org.eclipse.jface.dialogs.MessageDialog;\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.swt.widgets.Shell;\r
+import org.eclipse.ui.handlers.HandlerUtil;\r
+import org.simantics.db.Resource;\r
+import org.simantics.modeling.ui.modelBrowser.handlers.DeleteNodeHandler;\r
+import org.simantics.ui.utils.ResourceAdaptionUtils;\r
+\r
+public class UnlinkNodeHandler2 extends DeleteNodeHandler {\r
+\r
+ @Override\r
+ public Object execute(ExecutionEvent event) throws ExecutionException {\r
+ Shell shell = HandlerUtil.getActiveShellChecked(event);\r
+ ISelection sel = HandlerUtil.getCurrentSelection(event);\r
+ Resource[] resources = ResourceAdaptionUtils.toResources(sel);\r
+ if (resources.length == 0)\r
+ return null;\r
+\r
+ MessageDialog dialog = new MessageDialog(shell, "Remove Item", null, "Are you sure?", 0,\r
+ new String[] { "OK", "Cancel" }, 0);\r
+ dialog.create();\r
+ if (dialog.open() == 0) {\r
+ //TODO: deletenodehandler for all resources\r
+ super.execute(event);\r
+ }\r
+ return null;\r
+ }\r
+ \r
+}\r
*******************************************************************************/\r
package org.simantics.sysdyn.ui.project;\r
\r
-import org.eclipse.ui.IFolderLayout;\r
import org.eclipse.ui.IPageLayout;\r
import org.eclipse.ui.IPerspectiveFactory;\r
-import org.eclipse.ui.console.IConsoleConstants;\r
\r
public class SysdynPerspectiveFactory implements IPerspectiveFactory {\r
\r
@Override\r
public void createInitialLayout(IPageLayout layout) {\r
layout.setEditorAreaVisible(true);\r
- String editorArea = layout.getEditorArea();\r
-\r
- IFolderLayout bottom1 = layout.createFolder("bottom1", IPageLayout.BOTTOM, 0.75f, editorArea);\r
- IFolderLayout bottom2 = layout.createFolder("bottom2", IPageLayout.LEFT, 0.4f, "bottom1");\r
- bottom1.addView("org.simantics.browsing.ui.graph.propertyView");\r
- bottom1.addView(IConsoleConstants.ID_CONSOLE_VIEW);\r
- bottom2.addView("org.simantics.sysdyn.ui.trend.view");\r
- bottom2.addView("org.simantics.sysdyn.ui.dependencies.view");\r
-\r
- IFolderLayout left = layout.createFolder("left", IPageLayout.LEFT, 0.25f, editorArea);\r
- left.addView("org.simantics.sysdyn.ui.browser");\r
- \r
- IFolderLayout right = layout.createFolder("right", IPageLayout.RIGHT, 0.7f, editorArea);\r
- right.addView("org.simantics.diagram.symbollibrary");\r
}\r
\r
}\r