Change-Id: I52d47de5eb16ce29720fdcf346356d5940dbf403
diagramResourceOf :: Diagram -> <ReadGraph> Resource
diagramResourceOf d = singleObject d MOD.CompositeToDiagram
diagramResourceOf :: Diagram -> <ReadGraph> Resource
diagramResourceOf d = singleObject d MOD.CompositeToDiagram
-import "Extras/HashMap" as Map
-
"""Constructs a transformation for a diagram element."""
mapDiagramElement :: (a -> <e> b) -> (a -> <e> b) -> (a -> <e> Maybe b) -> (a -> <e> b) -> DiagramElement a -> <e> DiagramElement b
mapDiagramElement mapComponentType mapTerminal mapAttribute mapFlagType diagramElement =
"""Constructs a transformation for a diagram element."""
mapDiagramElement :: (a -> <e> b) -> (a -> <e> b) -> (a -> <e> Maybe b) -> (a -> <e> b) -> DiagramElement a -> <e> DiagramElement b
mapDiagramElement mapComponentType mapTerminal mapAttribute mapFlagType diagramElement =
configuration = diagram'
diagram = compositeToDiagram' configuration
hasName = L0.HasName
configuration = diagram'
diagram = compositeToDiagram' configuration
hasName = L0.HasName
- componentMap = Map.fromList [ (c `relatedValue` hasName :: String, c)
- | c <- children configuration
- ]
+ componentMap = MMap.fromEntryList [ (c `relatedValue` hasName :: String, c)
+ | c <- children configuration
+ ]
denyByPredicate diagram L0.ConsistsOf
elements = setElements (DiagramInfo diagram configuration componentMap) joinMap elementSpecs
claimRelatedValue diagram DIA.HasModCount
denyByPredicate diagram L0.ConsistsOf
elements = setElements (DiagramInfo diagram configuration componentMap) joinMap elementSpecs
claimRelatedValue diagram DIA.HasModCount
createDiagramR (NewDiagram model path folderType compositeType) joinMap elementSpecs = (runProc do
configuration = createConfiguration ()
diagram = compositeToDiagram' configuration
createDiagramR (NewDiagram model path folderType compositeType) joinMap elementSpecs = (runProc do
configuration = createConfiguration ()
diagram = compositeToDiagram' configuration
- elements = setElements (DiagramInfo diagram configuration (Map.create ())) joinMap elementSpecs
+ elements = setElements (DiagramInfo diagram configuration (MMap.create ())) joinMap elementSpecs
claimRelatedValue diagram DIA.HasModCount
(fromInteger (length elements) :: Long)
(configuration, elements)
claimRelatedValue diagram DIA.HasModCount
(fromInteger (length elements) :: Long)
(configuration, elements)
/*
createJoin :: (Dynamic -> <WriteGraph> Resource) -> Dynamic -> <Proc,WriteGraph> Resource
/*
createJoin :: (Dynamic -> <WriteGraph> Resource) -> Dynamic -> <Proc,WriteGraph> Resource
-createJoin joinMap key = if Map.contains joinMap key
- then Map.unsafeGet joinMap key
+createJoin joinMap key = if MMap.containsKey joinMap key
+ then MMap.unsafeGet joinMap key
else do
j = newEntity [
hasType STR.ConnectionJoin
]
else do
j = newEntity [
hasType STR.ConnectionJoin
]
j
*/
data DiagramInfo = DiagramInfo
Resource // diagram
Resource // configuration
j
*/
data DiagramInfo = DiagramInfo
Resource // diagram
Resource // configuration
- (Map.T String Resource) // existing components
+ (MMap.T String Resource) // existing components
"""
Sets the elements of the diagram. Diagram is assumed to be empty,
"""
Sets the elements of the diagram. Diagram is assumed to be empty,
for (zip elementSpecs elements) setConnectionName
elements
) where
for (zip elementSpecs elements) setConnectionName
elements
) where
- elementMap = Map.create ()
+ elementMap = MMap.create ()
idRef = ref (0 :: Integer)
isConnectionResource r = isInstanceOf r DIA.Connection
idRef = ref (0 :: Integer)
isConnectionResource r = isInstanceOf r DIA.Connection
idRef := id + 1
show id
createElement (Component componentType name position properties) = do
idRef := id + 1
show id
createElement (Component componentType name position properties) = do
- component = if Map.contains componentMap name
- then Map.unsafeGet componentMap name
+ component = if MMap.containsKey componentMap name
+ then MMap.unsafeGet componentMap name
else newEntity [
hasName name,
hasParent configuration,
else newEntity [
hasName name,
hasParent configuration,
MOD.ElementToComponent
component
]
MOD.ElementToComponent
component
]
- Map.put elementMap name element
+ MMap.put elementMap name element
Just element
newOrMappedElement eName = do
Just element
newOrMappedElement eName = do
- element = match Map.get elementMap eName with
+ element = match MMap.get elementMap eName with
Just element -> element
Nothing -> newEntity []
Just element -> element
Nothing -> newEntity []
- Map.put elementMap eName element
+ MMap.put elementMap eName element
element
createElement (SimpleConnection aName ar bName br _) = do
connection = newEntity [
element
createElement (SimpleConnection aName ar bName br _) = do
connection = newEntity [
then do
claim flag DIA.ExternalFlag flag
else ()
then do
claim flag DIA.ExternalFlag flag
else ()
- Map.put elementMap name flag
+ MMap.put elementMap name flag
Just flag
createElement (Connection nodeSpecs edges _) = do
connection = newEntity [
Just flag
createElement (Connection nodeSpecs edges _) = do
connection = newEntity [
hasFont font
]
createElement (Monitor label (Just (MonitorReference componentName suffix)) (MonitorVisuals font strokeWidth hAlign vAlign) position) = do
hasFont font
]
createElement (Monitor label (Just (MonitorReference componentName suffix)) (MonitorVisuals font strokeWidth hAlign vAlign) position) = do
- match (Map.get elementMap componentName) with
+ match (MMap.get elementMap componentName) with
Nothing -> Nothing // Monitored component is not on the same diagram as the monitor. Not supported by this routine.
Just element -> do
component = singleObject element MOD.ElementToComponent
Nothing -> Nothing // Monitored component is not on the same diagram as the monitor. Not supported by this routine.
Just element -> do
component = singleObject element MOD.ElementToComponent
nodeResources = connectors + routeLines
nodeResourceWithIds = zip nodeResources [0..length nodeResources-1]
edges = runProc do
nodeResources = connectors + routeLines
nodeResourceWithIds = zip nodeResources [0..length nodeResources-1]
edges = runProc do
- rMap = Map.fromList nodeResourceWithIds
+ rMap = MMap.fromEntryList nodeResourceWithIds
edgesOf (node,i) =
[ Edge i j
| r <- node # DIA.AreConnected
edgesOf (node,i) =
[ Edge i j
| r <- node # DIA.AreConnected
- , j = Map.unsafeGet rMap r
+ , j = MMap.unsafeGet rMap r
, j > i ]
concatMap edgesOf nodeResourceWithIds
, j > i ]
concatMap edgesOf nodeResourceWithIds
-import "Extras/HashMap" as Map
import "Simantics/Entity"
import "Simantics/Model"
import "Simantics/Diagram"
import "Simantics/Entity"
import "Simantics/Model"
import "Simantics/Diagram"
import "http://www.simantics.org/Modeling-1.2" as MOD
import "http://www.simantics.org/ModelingTemplate2d-1.0" as TMPL
import "http://www.simantics.org/Modeling-1.2" as MOD
import "http://www.simantics.org/ModelingTemplate2d-1.0" as TMPL
-applyConnectionTypes :: Map.T (DiagramElement Resource) (Resource,Resource) -> <Proc,WriteGraph,ReadGraph> ()
+applyConnectionTypes :: MMap.T (DiagramElement Resource) (Resource,Resource) -> <Proc,WriteGraph,ReadGraph> ()
applyConnectionTypes elementMap =
let
isConnection ((Connection _ _ _),_) = True
isConnection _ = False
applyConnectionTypes elementMap =
let
isConnection ((Connection _ _ _),_) = True
isConnection _ = False
- in iter (\(a,(source,target)) -> applyConnectionType target) (filter isConnection (Map.entries elementMap))
+ in iter (\(a,(source,target)) -> applyConnectionType target) (filter isConnection (MMap.entries elementMap))
-doElementPostProcessing (elementMap :: Map.T (DiagramElement Resource) (Resource,Resource))
+doElementPostProcessing (elementMap :: MMap.T (DiagramElement Resource) (Resource,Resource))
(elementPostProcessing :: DiagramElement Resource -> Resource -> Resource -> <Proc,ReadGraph,WriteGraph> ()) = do
(elementPostProcessing :: DiagramElement Resource -> Resource -> Resource -> <Proc,ReadGraph,WriteGraph> ()) = do
- list = sortByCluster (Map.entries elementMap) (\(a,(source,target)) -> target)
+ list = sortByCluster (MMap.entries elementMap) (\(a,(source,target)) -> target)
iter (\(a,(source,target)) -> elementPostProcessing a source target) list
translateDiagrams (sourceModel :: Model)
iter (\(a,(source,target)) -> elementPostProcessing a source target) list
translateDiagrams (sourceModel :: Model)
(elementPostProcessing :: DiagramElement Resource -> Resource -> Resource -> <Proc,ReadGraph,WriteGraph> ())
(sourceDiagrams :: [Diagram]) = do
(elementPostProcessing :: DiagramElement Resource -> Resource -> Resource -> <Proc,ReadGraph,WriteGraph> ())
(sourceDiagrams :: [Diagram]) = do
- elementMap = Map.create() :: Map.T (DiagramElement Resource) (Resource,Resource)
+ elementMap = MMap.create () :: MMap.T (DiagramElement Resource) (Resource,Resource)
// Join map contains all joins of the model
joinMap = createJoinMap ()
// Join map contains all joins of the model
joinMap = createJoinMap ()
(compositeType :: Resource)
(f :: Diagram -> <ReadGraph> [(DiagramElement Resource,Resource)])
(joinMap :: Dynamic -> <WriteGraph> Resource)
(compositeType :: Resource)
(f :: Diagram -> <ReadGraph> [(DiagramElement Resource,Resource)])
(joinMap :: Dynamic -> <WriteGraph> Resource)
- (elementMap :: Map.T (DiagramElement Resource) (Resource,Resource))
+ (elementMap :: MMap.T (DiagramElement Resource) (Resource,Resource))
(diagramPostProcessing :: Diagram -> Diagram -> <Proc,ReadGraph,WriteGraph> ())
(sourceDiagram :: Diagram) = do
disableDependencies
(diagramPostProcessing :: Diagram -> Diagram -> <Proc,ReadGraph,WriteGraph> ())
(sourceDiagram :: Diagram) = do
disableDependencies
getTargetDiagram (targetModel :: Model) (sourceDiagram :: Diagram) =
(possibleDiagram targetModel $ pathOf sourceDiagram) :: Maybe Diagram
getTargetDiagram (targetModel :: Model) (sourceDiagram :: Diagram) =
(possibleDiagram targetModel $ pathOf sourceDiagram) :: Maybe Diagram
-store :: Map.T (DiagramElement Resource) (Resource,Resource) -> (DiagramElement Resource) -> Resource -> Resource -> <Proc,WriteGraph,ReadGraph> ()
+store :: MMap.T (DiagramElement Resource) (Resource,Resource) -> (DiagramElement Resource) -> Resource -> Resource -> <Proc,WriteGraph,ReadGraph> ()
store elementMap a b c = do
store elementMap a b c = do
- Map.put elementMap a (b,c)
+ MMap.put elementMap a (b,c)
()
getTargetComponent (targetDiagram :: Diagram) (sourceComponent :: Resource) =
()
getTargetComponent (targetDiagram :: Diagram) (sourceComponent :: Resource) =
(compositeType :: Resource)
(f :: Diagram -> <ReadGraph> [(DiagramElement Resource,Resource)])
(joinMap :: Dynamic -> <WriteGraph> Resource)
(compositeType :: Resource)
(f :: Diagram -> <ReadGraph> [(DiagramElement Resource,Resource)])
(joinMap :: Dynamic -> <WriteGraph> Resource)
- (elementMap :: Map.T (DiagramElement Resource) (Resource,Resource)) = do
+ (elementMap :: MMap.T (DiagramElement Resource) (Resource,Resource)) = do
spec = makeSpec targetModel sourceDiagram folderType compositeType
elementSpecs = f sourceDiagram
in1 = (filter (not . isReferring) elementSpecs + filter isReferring elementSpecs)
spec = makeSpec targetModel sourceDiagram folderType compositeType
elementSpecs = f sourceDiagram
in1 = (filter (not . isReferring) elementSpecs + filter isReferring elementSpecs)
-import "StandardLibrary" hiding (contains)
+module {
+ deprecated = "Use module MMap instead."
+}
-importJava "gnu.trove.map.hash.THashMap" where
- data T a b
-
- @JavaName "<init>"
- create :: () -> <Proc> T a b
- put :: T a b -> a -> b -> <Proc> Maybe b
- get :: T a b -> a -> <Proc> Maybe b
- @JavaName get
- unsafeGet :: T a b -> a -> <Proc> b
+import "MMap" as MMap
+
+type T a b = MMap.T a b
+
+create :: () -> <Proc> T a b
+create = MMap.create
+
+put :: T a b -> a -> b -> <Proc> Maybe b
+put = MMap.put
+
+get :: T a b -> a -> <Proc> Maybe b
+get = MMap.get
+
+unsafeGet :: T a b -> a -> <Proc> b
+unsafeGet = MMap.unsafeGet
- contains :: T a b -> a -> <Proc> Boolean
- size :: T a b -> <Proc> Integer
+contains :: T a b -> a -> <Proc> Boolean
+contains = MMap.containsKey
+
+size :: T a b -> <Proc> Integer
+size = MMap.size
-importJava "org.simantics.scl.osgi.map.HashMapUtils" where
- entries :: T a b -> <Proc> [(a,b)]
+entries :: T a b -> <Proc> [(a,b)]
+entries = MMap.entries
fromList :: [(a,b)] -> <Proc> T a b
fromList :: [(a,b)] -> <Proc> T a b
-fromList entries = do
- result = create ()
- for entries (\(k,v) -> do put result k v; ())
- result
\ No newline at end of file
+fromList = MMap.fromEntryList