]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@17335 ac1ea38d-2e2b...
authorlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Wed, 18 Aug 2010 12:47:33 +0000 (12:47 +0000)
committerlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Wed, 18 Aug 2010 12:47:33 +0000 (12:47 +0000)
13 files changed:
org.simantics.sysdyn.feature/feature.xml
org.simantics.sysdyn.ui/plugin.xml
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/LibraryViewpointContributor.java [deleted file]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Module.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/ExperimentNode.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/ModelNode.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/ModuleNode.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/ModuleTypeNode.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/SimulationResultNode.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/OpenDiagramFromConfigurationAdapter.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/ModuleFactory.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/UnlinkNodeHandler2.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/project/SysdynPerspectiveFactory.java

index 949cb85a1a44d16f6e160e4bff349d11098f3559..2dd54208b491e34258eef3b1e65e6c5e1a4b8295 100644 (file)
    </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
index 6988c69088d4d8dcd55c2bb5b94bbdf1a457a0ac..6910abb35bc75272b832d085e14cda5d352d85bb 100644 (file)
       </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
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/LibraryViewpointContributor.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/LibraryViewpointContributor.java
deleted file mode 100644 (file)
index 7eea121..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************\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
index 59945da359400cc6f5e2cc53256e9875b91ee345..cad29d6009c0c421a225c827d0194294e39ca755 100644 (file)
@@ -9,12 +9,13 @@ import org.simantics.db.ReadGraph;
 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
@@ -22,7 +23,14 @@ public class Module  extends ViewpointContributor<ModuleNode> {
         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
index a04e596860fbd7d0d42bebf2b0a3fd463aea05e6..b9e2ed194b40d9a3c0088f8c3b2f60219fcf3d1c 100644 (file)
  *******************************************************************************/\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
@@ -42,7 +52,7 @@ public class ExperimentNode extends AbstractNode implements IDoubleClickableNode
         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
@@ -56,4 +66,23 @@ public class ExperimentNode extends AbstractNode implements IDoubleClickableNode
         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
index b79582ccf288c975500eadfde02ad90582421631..c26a8df70838eb775d6ad4cac4a184bc5405f3a8 100644 (file)
@@ -1,13 +1,21 @@
 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
@@ -28,4 +36,25 @@ public class ModelNode extends AbstractNode implements IDeletable, IModifiableNo
         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
index 1689c075a2ce339d7d1eccc00cff6b7b52d25d4e..2241a7cafe5acc25e64534e733f424599ef24d96 100644 (file)
@@ -1,9 +1,8 @@
 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
index fdbad703cc53661f27b5d4174d553af6d7cd441c..68738690b0fe5c9b87c67d298d15a9dd628e6f6e 100644 (file)
@@ -1,11 +1,95 @@
 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
index ef28f83e77c8755d366283c09acba607dd7334c0..79dd7e69b984d7daba8fea7f3f0e2e599dede51b 100644 (file)
@@ -1,13 +1,23 @@
 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
@@ -26,4 +36,41 @@ public class SimulationResultNode  extends AbstractNode implements IDeletable, I
         };\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
index c2fcda8eb5bdad1a57c477984085d59db6a32544..2c4c6e0931462d4eb552416eb23541c0dad2eebe 100644 (file)
@@ -1,5 +1,15 @@
 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
@@ -14,4 +24,44 @@ public class OpenDiagramFromConfigurationAdapter extends org.simantics.modeling.
         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
index c542c1a26310ddc01957249e4f59d78c2bd83a23..1008a77c58173926b11858e984a72804bd9ac942 100644 (file)
@@ -50,7 +50,7 @@ public class ModuleFactory extends SysdynElementFactory {
                 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
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/UnlinkNodeHandler2.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/UnlinkNodeHandler2.java
new file mode 100644 (file)
index 0000000..8598b9b
--- /dev/null
@@ -0,0 +1,33 @@
+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
index 0d86050ec12cce74df4e8dbcf421f81f8c37dedc..29f047bafa76bebbd53429cdc0d8f94c354b07a4 100644 (file)
  *******************************************************************************/\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