include "Simantics/Model"
import "Simantics/Diagram"
import "Simantics/Flag"
+import "Simantics/Workbench"
include "Simantics/Ontologies"
type UserComponent = Resource
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
--- /dev/null
+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