From cd3c2c7a63a5cbe4b733d7e7ef3d94af1c7d5670 Mon Sep 17 00:00:00 2001 From: villberg Date: Wed, 27 Nov 2013 05:17:32 +0000 Subject: [PATCH] ResourceEditorInput2 RVI is now from RVI.toString refs #4564 git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@28391 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../ui/browser/actions/OpenSheetAction.java | 8 ++-- .../sysdyn/ui/browser/nodes/SheetNode.java | 7 ++-- .../OpenDiagramFromComponentAdapter.java | 37 +++++++++++-------- .../OpenDiagramFromConfigurationAdapter.java | 2 + 4 files changed, 33 insertions(+), 21 deletions(-) diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/actions/OpenSheetAction.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/actions/OpenSheetAction.java index 3c31b88f..91e560ef 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/actions/OpenSheetAction.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/actions/OpenSheetAction.java @@ -16,6 +16,7 @@ import org.eclipse.ui.PlatformUI; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; import org.simantics.db.exception.DatabaseException; +import org.simantics.db.layer0.variable.RVI; import org.simantics.db.layer0.variable.Variable; import org.simantics.db.layer0.variable.Variables; import org.simantics.spreadsheet.resource.SpreadsheetResource; @@ -44,10 +45,11 @@ public class OpenSheetAction implements IDoubleClickAction { final Resource sheet = result; if(graph.isInstanceOf(sheet, SHEET.Spreadsheet)) { + Variable variable = graph.adapt(sheet, Variable.class); final Resource model = Variables.getModel(graph, variable); - final String RVI = Variables.getRVI(graph, variable); - + final RVI rvi = variable.getRVI(graph); + PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { private static final String EDITOR_ID = "org.simantics.spreadsheet.ui.editor2"; @@ -55,7 +57,7 @@ public class OpenSheetAction implements IDoubleClickAction { @Override public void run() { try { - WorkbenchUtils.openEditor(EDITOR_ID, new ResourceEditorInput2(EDITOR_ID, sheet, model, RVI)); + WorkbenchUtils.openEditor(EDITOR_ID, new ResourceEditorInput2(EDITOR_ID, sheet, model, rvi)); } catch (PartInitException e) { e.printStackTrace(); } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/SheetNode.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/SheetNode.java index e6213e1d..39fdb224 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/SheetNode.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/SheetNode.java @@ -12,6 +12,7 @@ import org.simantics.db.Resource; import org.simantics.db.Session; import org.simantics.db.common.request.ReadRequest; import org.simantics.db.exception.DatabaseException; +import org.simantics.db.layer0.variable.RVI; import org.simantics.db.layer0.variable.Variable; import org.simantics.db.layer0.variable.Variables; import org.simantics.layer0.Layer0; @@ -53,7 +54,7 @@ public class SheetNode extends AbstractNode implements IModifiableNode Variable variable = graph.adapt(data, Variable.class); final Resource model = Variables.getModel(graph, variable); - final String RVI = Variables.getRVI(graph, variable); + final RVI rvi = variable.getRVI(graph); PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { @@ -62,8 +63,8 @@ public class SheetNode extends AbstractNode implements IModifiableNode @Override public void run() { try { - System.out.println("Activating sheet: model=" + model + " rvi=" + RVI); - WorkbenchUtils.openEditor(EDITOR_ID, new ResourceEditorInput2(EDITOR_ID, data, model, RVI)); + System.out.println("Activating sheet: model=" + model + " rvi=" + rvi); + WorkbenchUtils.openEditor(EDITOR_ID, new ResourceEditorInput2(EDITOR_ID, data, model, rvi)); } catch (PartInitException e) { e.printStackTrace(); } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/OpenDiagramFromComponentAdapter.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/OpenDiagramFromComponentAdapter.java index 3875c71f..fb89ccc3 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/OpenDiagramFromComponentAdapter.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/OpenDiagramFromComponentAdapter.java @@ -8,9 +8,10 @@ import org.eclipse.swt.widgets.Display; import org.eclipse.ui.IEditorPart; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; -import org.simantics.db.common.ResourceArray; import org.simantics.db.common.request.ReadRequest; import org.simantics.db.exception.DatabaseException; +import org.simantics.db.layer0.request.PossibleModel; +import org.simantics.db.layer0.variable.RVI; import org.simantics.db.layer0.variable.Variable; import org.simantics.db.layer0.variable.Variables; import org.simantics.diagram.content.ConnectionUtil; @@ -23,7 +24,6 @@ import org.simantics.modeling.ComponentUtils; import org.simantics.modeling.ModelingResources; import org.simantics.modeling.actions.NavigateToTarget; import org.simantics.modeling.ui.Activator; -import org.simantics.structural2.StructuralVariables; import org.simantics.sysdyn.SysdynResource; import org.simantics.ui.SimanticsUI; import org.simantics.ui.utils.ResourceAdaptionUtils; @@ -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)) { Collection result = new ArrayList(1); + Variable moduleVariable = Variables.getVariable(g, module); + RVI rvi = moduleVariable.getRVI(g); + Resource composite = g.getSingleObject(module, l0.PartOf); + Resource model = g.syncRequest(new PossibleModel(composite)); final Resource diagram = ComponentUtils.getCompositeDiagram(g, composite); - final ResourceArray compositePath = StructuralVariables.getCompositeArray(g, composite); - final ResourceArray variablePath = compositePath.removeFromBeginning(1); - - Resource model = StructuralVariables.getModel(g, compositePath.head()); - if (model == null) - return Collections.emptyList(); - - String rvi = StructuralVariables.getRVI(g, variablePath); - if (rvi == null) - return Collections.emptyList(); + +// final ResourceArray compositePath = StructuralVariables.getCompositeArray(g, composite); +// final ResourceArray variablePath = compositePath.removeFromBeginning(1); +// +// Resource model = StructuralVariables.getModel(g, compositePath.head()); +// if (model == null) +// return Collections.emptyList(); +// +// String rvi = StructuralVariables.getRVI(g, variablePath); +// if (rvi == null) +// return Collections.emptyList(); if (variable != null) { // Get proper RVI from variable if it exists. @@ -140,9 +145,11 @@ public class OpenDiagramFromComponentAdapter extends AbstractResourceEditorAdapt // We want the composite's RVI, not the component in it. Variable parent = variable.getParent(g); if (parent != null) { - String contextURI = context.getURI(g); - String parentURI = parent.getURI(g); - rvi = parentURI.replace(contextURI, ""); + rvi = parent.getRVI(g); +// String contextURI = context.getURI(g); +// String parentURI = parent.getURI(g); +// rvi = parentURI.replace(contextURI, ""); + model = Variables.getModel(g, context); } } } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/OpenDiagramFromConfigurationAdapter.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/OpenDiagramFromConfigurationAdapter.java index d752f358..8fe5d1dd 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/OpenDiagramFromConfigurationAdapter.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/OpenDiagramFromConfigurationAdapter.java @@ -94,6 +94,8 @@ public class OpenDiagramFromConfigurationAdapter extends AbstractResourceEditorA final Resource model = StructuralVariables.getModel(g, compositePath.head()); if(model == null) return; + + final String rvi = StructuralVariables.getRVI(g, variablePath); if(rvi == null) return; -- 2.47.1