X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.modeling%2Fscl%2FSimantics%2FUserComponent.scl;h=d79db922229d5c9c2bfa114d0f27c41e9f471d3f;hb=b000e272429e157638c0384878b07b8dcd758472;hp=ecc84dcc61b889d51ca008ebd1b146c769e430c6;hpb=a42562ce5347643cf8303eb4c6acef4d65c9e210;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.modeling/scl/Simantics/UserComponent.scl b/bundles/org.simantics.modeling/scl/Simantics/UserComponent.scl index ecc84dcc6..d79db9222 100644 --- a/bundles/org.simantics.modeling/scl/Simantics/UserComponent.scl +++ b/bundles/org.simantics.modeling/scl/Simantics/UserComponent.scl @@ -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,32 @@ 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 -> 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 -> 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 -> () +navigateToSubstructureAction element = do + match (syncRead (\x -> possibleSubstructureEditor element)) with + Nothing -> () + Just (configuration,editor) -> openEditor editor configuration + +importJava "org.simantics.modeling.MigrateModel" where + "changeAllComponentTypes model oldComponentType newComponentType" + changeAllComponentTypes :: Resource -> Resource -> Resource -> ()