]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Navigate to substructure
authorAntti Villberg <antti.villberg@semantum.fi>
Fri, 10 Mar 2017 09:17:28 +0000 (11:17 +0200)
committerjsimomaa <jani.simomaa@gmail.com>
Fri, 28 Apr 2017 13:19:20 +0000 (16:19 +0300)
refs #7080

Change-Id: I2b183bf6b2d314577c664c16471c80658ce57450

bundles/org.simantics.modeling.ontology/graph/ModelingViewpoint.pgraph
bundles/org.simantics.modeling/scl/Simantics/All.scl
bundles/org.simantics.modeling/scl/Simantics/UserComponent.scl
bundles/org.simantics.modeling/scl/Simantics/Workbench.scl [new file with mode: 0644]

index fa0f29cba7b59f295e159eabcb093c9f4ad5ceea..c838c0a3648850a5fbb0793844e664577cd4fc07 100644 (file)
@@ -636,6 +636,9 @@ ACTIONS.CompilePGraphs : ACT.Action
 ACTIONS.RenameDiagramComponents : ACT.Action
 ACTIONS.Help : ACT.Action
 
+ACTIONS.NavigateToSubstructure
+  @MOD.sclAction "navigateToSubstructureAction"
+
 ACTIONS.NewProceduralComponentType : ACT.Action
 ACTIONS.NewComponentType : ACT.Action
 
index 0ea0459599439030a1b1915ecea72f37e5c4e330..02457e67f0811baac1465e760e143d32bdaac768 100644 (file)
@@ -25,6 +25,7 @@ include "Simantics/Query"
 include "Simantics/Datatypes"
 include "Spreadsheet/All"
 include "Simantics/WorkbenchSelection"
+include "Simantics/Workbench"
 include "Simantics/Structural"
 include "SWT/All"
 include "Simantics/UI"
index ecc84dcc61b889d51ca008ebd1b146c769e430c6..ad62e1d6a3effcae29504af0ddab77c399cef685 100644 (file)
@@ -1,6 +1,7 @@
 include "Simantics/Model"
 import "Simantics/Diagram"
 import "Simantics/Flag"
+import "Simantics/Workbench"
 include "Simantics/Ontologies"
 
 type UserComponent = Resource
@@ -132,3 +133,29 @@ addUserComponentScript userComponent scriptName scriptType scriptCode = do
     claimRelatedValue script L0.HasName scriptName
     claimRelatedValue script STR.ComponentTypeScript.type scriptType 
     claimRelatedValue script STR.ComponentTypeScript.code scriptCode 
+
+@private
+possibleSubstructure :: Resource -> <ReadGraph> Maybe Resource
+possibleSubstructure element = do
+     match possibleObject element MOD.ElementToComponent with
+       Nothing -> Nothing
+       Just component -> match possibleTypeOf component STR.Component with
+         Nothing -> Nothing
+         Just componentType -> match possibleObject componentType STR.IsDefinedBy with
+           Nothing -> Nothing
+           Just configuration -> Just configuration
+
+@private
+possibleSubstructureEditor :: Resource -> <ReadGraph,Proc> Maybe (Resource,EditorAdapter)
+possibleSubstructureEditor element = match possibleSubstructure element with
+  Nothing -> Nothing
+  Just configuration -> do
+    adapters = editorAdapters configuration
+    if(length adapters > 0) then Just (configuration, adapters!0) else Nothing
+
+navigateToSubstructureAction :: Resource -> <Proc> ()
+navigateToSubstructureAction element = do
+ match (syncRead (\x -> possibleSubstructureEditor element)) with
+   Nothing -> ()
+   Just (configuration,editor) -> openEditor editor configuration
+                
\ No newline at end of file
diff --git a/bundles/org.simantics.modeling/scl/Simantics/Workbench.scl b/bundles/org.simantics.modeling/scl/Simantics/Workbench.scl
new file mode 100644 (file)
index 0000000..2506124
--- /dev/null
@@ -0,0 +1,21 @@
+import "Simantics/DB"
+
+importJava "org.simantics.ui.workbench.editor.EditorAdapter" where
+    data EditorAdapter
+    openEditor :: EditorAdapter -> a -> <Proc> ()
+
+importJava "org.simantics.ui.workbench.editor.EditorRegistry" where
+
+    @private
+    @JavaName getInstance
+    getEditorRegistryInstance :: IEditorRegistry
+
+importJava "org.simantics.ui.workbench.editor.IEditorRegistry" where
+    data IEditorRegistry
+    
+    @private
+    @JavaName getAdaptersFor
+    editorAdapters_ :: IEditorRegistry -> a -> <ReadGraph> Vector EditorAdapter
+
+editorAdapters :: a -> <ReadGraph> [EditorAdapter]
+editorAdapters object = vectorToList $ editorAdapters_ getEditorRegistryInstance object