Last active
October 9, 2017 15:15
-
-
Save agarciadom/5636a8040101549c546b8dcf9f7ffcc4 to your computer and use it in GitHub Desktop.
Eugenia polishing tx for an OCL-driven external label for a node
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Shows an external label on A with the name of the B it's pointing to | |
var canvas = GmfGraph!Canvas.all.first; | |
var gallery = canvas.figures; | |
-- Create figure descriptor for external label | |
var fd = new GmfGraph!FigureDescriptor; | |
fd.name = 'AFigureBName'; | |
gallery.descriptors.add(fd); | |
var fdLabel = new GmfGraph!Label; | |
fdLabel.name = 'AFigureBNameLabel'; | |
fd.actualFigure = fdLabel; | |
var fdChildAccessor = new GmfGraph!ChildAccess; | |
fdChildAccessor.accessor = 'getFigureBNameLabel'; | |
fdChildAccessor.figure = fdLabel; | |
fd.accessors.add(fdChildAccessor); | |
-- Create diagram label for that figure descriptor | |
var diagLabel = new GmfGraph!DiagramLabel; | |
canvas.labels.add(diagLabel); | |
diagLabel.figure = fd; | |
diagLabel.name = 'ABNameLabel'; | |
diagLabel.elementIcon = false; | |
-- Add the label to the node mapping | |
var nodeMapping = GmfMap!NodeMapping.all.selectOne(nm|nm.domainMetaElement.name='A'); | |
var exprLabel = new GmfMap!ExpressionLabelMapping; | |
nodeMapping.labelMappings.add(exprLabel); | |
var valueExpression = new GmfMap!ValueExpression; | |
exprLabel.viewExpression = valueExpression; | |
exprLabel.diagramLabel = diagLabel; | |
-- OCL expression for computing the text of the label | |
valueExpression.body = 'self.b.name'; | |
valueExpression.language = GmfMap!Language#ocl; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@namespace(uri="oclex", prefix="oclex") | |
@gmf | |
package example; | |
@gmf.diagram | |
class Model { | |
val A[*] as; | |
val B[*] bs; | |
} | |
@gmf.node(label="name") | |
class A { | |
attr String name; | |
@gmf.link | |
ref B b; | |
} | |
@gmf.node(label="name") | |
class B { | |
attr String name; | |
attr int value; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment