]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
ResourceEditorInput2 RVI is now from RVI.toString
authorvillberg <villberg@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Wed, 27 Nov 2013 05:17:32 +0000 (05:17 +0000)
committervillberg <villberg@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Wed, 27 Nov 2013 05:17:32 +0000 (05:17 +0000)
refs #4564

git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@28391 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/actions/OpenSheetAction.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/SheetNode.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/OpenDiagramFromComponentAdapter.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/OpenDiagramFromConfigurationAdapter.java

index 3c31b88f31784b2cf36a01d053c96c99cb31c963..91e560ef85e28fb5764c2a9ae224ddac59ce5dc2 100644 (file)
@@ -16,6 +16,7 @@ import org.eclipse.ui.PlatformUI;
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
 import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.variable.RVI;\r
 import org.simantics.db.layer0.variable.Variable;\r
 import org.simantics.db.layer0.variable.Variables;\r
 import org.simantics.spreadsheet.resource.SpreadsheetResource;\r
@@ -44,10 +45,11 @@ public class OpenSheetAction implements IDoubleClickAction {
         final Resource sheet = result;\r
 \r
         if(graph.isInstanceOf(sheet, SHEET.Spreadsheet)) {\r
+               \r
             Variable variable = graph.adapt(sheet, Variable.class);\r
             final Resource model = Variables.getModel(graph, variable);\r
-            final String RVI = Variables.getRVI(graph, variable);\r
-\r
+            final RVI rvi = variable.getRVI(graph);\r
+            \r
             PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {\r
 \r
                 private static final String EDITOR_ID = "org.simantics.spreadsheet.ui.editor2";\r
@@ -55,7 +57,7 @@ public class OpenSheetAction implements IDoubleClickAction {
                 @Override\r
                 public void run() {\r
                     try {\r
-                        WorkbenchUtils.openEditor(EDITOR_ID, new ResourceEditorInput2(EDITOR_ID, sheet, model, RVI));\r
+                        WorkbenchUtils.openEditor(EDITOR_ID, new ResourceEditorInput2(EDITOR_ID, sheet, model, rvi));\r
                     } catch (PartInitException e) {\r
                         e.printStackTrace();\r
                     }\r
index e6213e1df545df2f742e66a81026970017d3180d..39fdb2241041810f497880f973877f4da1dc992f 100644 (file)
@@ -12,6 +12,7 @@ import org.simantics.db.Resource;
 import org.simantics.db.Session;\r
 import org.simantics.db.common.request.ReadRequest;\r
 import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.variable.RVI;\r
 import org.simantics.db.layer0.variable.Variable;\r
 import org.simantics.db.layer0.variable.Variables;\r
 import org.simantics.layer0.Layer0;\r
@@ -53,7 +54,7 @@ public class SheetNode extends AbstractNode<Resource> implements IModifiableNode
 \r
                     Variable variable = graph.adapt(data, Variable.class);\r
                     final Resource model = Variables.getModel(graph, variable);\r
-                    final String RVI = Variables.getRVI(graph, variable);\r
+                    final RVI rvi = variable.getRVI(graph);\r
 \r
                     PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {\r
                         \r
@@ -62,8 +63,8 @@ public class SheetNode extends AbstractNode<Resource> implements IModifiableNode
                         @Override\r
                         public void run() {\r
                             try {\r
-                                System.out.println("Activating sheet: model=" + model + " rvi=" + RVI);\r
-                                WorkbenchUtils.openEditor(EDITOR_ID, new ResourceEditorInput2(EDITOR_ID, data, model, RVI));\r
+                                System.out.println("Activating sheet: model=" + model + " rvi=" + rvi);\r
+                                WorkbenchUtils.openEditor(EDITOR_ID, new ResourceEditorInput2(EDITOR_ID, data, model, rvi));\r
                             } catch (PartInitException e) {\r
                                 e.printStackTrace();\r
                             }\r
index 3875c71f35066d48128085801c8579218ddcbea6..fb89ccc3c531824a406ff7ca4503c98a9fc770c5 100644 (file)
@@ -8,9 +8,10 @@ import org.eclipse.swt.widgets.Display;
 import org.eclipse.ui.IEditorPart;\r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
-import org.simantics.db.common.ResourceArray;\r
 import org.simantics.db.common.request.ReadRequest;\r
 import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.request.PossibleModel;\r
+import org.simantics.db.layer0.variable.RVI;\r
 import org.simantics.db.layer0.variable.Variable;\r
 import org.simantics.db.layer0.variable.Variables;\r
 import org.simantics.diagram.content.ConnectionUtil;\r
@@ -23,7 +24,6 @@ import org.simantics.modeling.ComponentUtils;
 import org.simantics.modeling.ModelingResources;\r
 import org.simantics.modeling.actions.NavigateToTarget;\r
 import org.simantics.modeling.ui.Activator;\r
-import org.simantics.structural2.StructuralVariables;\r
 import org.simantics.sysdyn.SysdynResource;\r
 import org.simantics.ui.SimanticsUI;\r
 import org.simantics.ui.utils.ResourceAdaptionUtils;\r
@@ -119,19 +119,24 @@ public class OpenDiagramFromComponentAdapter extends AbstractResourceEditorAdapt
         if (g.isInstanceOf(module, SYSDYN.IndependentVariable) || g.isInstanceOf(module, SYSDYN.Input) || g.isInstanceOf(module, SYSDYN.Module)) {\r
             Collection<Runnable> result = new ArrayList<Runnable>(1);\r
 \r
+            Variable moduleVariable = Variables.getVariable(g, module);\r
+            RVI rvi = moduleVariable.getRVI(g);\r
+            \r
             Resource composite = g.getSingleObject(module, l0.PartOf);\r
+            Resource model = g.syncRequest(new PossibleModel(composite));\r
 \r
             final Resource diagram = ComponentUtils.getCompositeDiagram(g, composite);\r
-            final ResourceArray compositePath = StructuralVariables.getCompositeArray(g, composite);\r
-            final ResourceArray variablePath = compositePath.removeFromBeginning(1);\r
-\r
-            Resource model = StructuralVariables.getModel(g, compositePath.head());\r
-            if (model == null)\r
-                return Collections.emptyList();\r
-\r
-            String rvi = StructuralVariables.getRVI(g, variablePath);\r
-            if (rvi == null)\r
-                return Collections.emptyList();\r
+            \r
+//            final ResourceArray compositePath = StructuralVariables.getCompositeArray(g, composite);\r
+//            final ResourceArray variablePath = compositePath.removeFromBeginning(1);\r
+//\r
+//            Resource model = StructuralVariables.getModel(g, compositePath.head());\r
+//            if (model == null)\r
+//                return Collections.emptyList();\r
+//\r
+//            String rvi = StructuralVariables.getRVI(g, variablePath);\r
+//            if (rvi == null)\r
+//                return Collections.emptyList();\r
 \r
             if (variable != null) {\r
                 // Get proper RVI from variable if it exists.\r
@@ -140,9 +145,11 @@ public class OpenDiagramFromComponentAdapter extends AbstractResourceEditorAdapt
                     // We want the composite's RVI, not the component in it.\r
                     Variable parent = variable.getParent(g);\r
                     if (parent != null) {\r
-                        String contextURI = context.getURI(g);\r
-                        String parentURI = parent.getURI(g);\r
-                        rvi = parentURI.replace(contextURI, "");\r
+                       rvi = parent.getRVI(g);\r
+//                        String contextURI = context.getURI(g);\r
+//                        String parentURI = parent.getURI(g);\r
+//                        rvi = parentURI.replace(contextURI, "");\r
+                       model = Variables.getModel(g, context);\r
                     }\r
                 }\r
             }\r
index d752f3585ec90b20aa1927578c25155e70b9c234..8fe5d1dd2f8255e9b8d6f302536b31fa4c722756 100644 (file)
@@ -94,6 +94,8 @@ public class OpenDiagramFromConfigurationAdapter extends AbstractResourceEditorA
                 final Resource model = StructuralVariables.getModel(g, compositePath.head());\r
                 if(model == null) return;\r
 \r
+                \r
+                \r
                 final String rvi = StructuralVariables.getRVI(g, variablePath);\r
                 if(rvi == null) return;\r
 \r