| /** |
| * Copyright (c) 2011, 2012 Montages A.G. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * Guillaume Hillairet (Montages A.G.) : initial implementation |
| */ |
| library Behaviours; |
| |
| modeltype GMFMAP uses mappings('http://www.eclipse.org/gmf/2006/mappings'); |
| modeltype GMFGEN uses gmfgen('http://www.eclipse.org/gmf/2009/GenModel'); |
| modeltype GMFGRAPH uses gmfgraph('http://www.eclipse.org/gmf/2006/GraphicalDefinition'); |
| modeltype ECORE uses ecore('http://www.eclipse.org/emf/2002/Ecore'); |
| |
| -- |
| -- Custom Behaviour |
| -- |
| |
| helper GMFMAP::CanvasMapping::handleRelatedDiagram(in mapElement : GMFMAP::MappingEntry) : GMFGEN::OpenDiagramBehaviour = |
| object GMFGEN::OpenDiagramBehaviour { |
| -- XXX alternative approach to tell whether related diagram is the same we are processing now, |
| -- originally self.eResource() != mapElement.eResource() |
| if self <> mapElement.container() then { |
| diagramKind := 'FIXME put GenEditorGenerator.modelID value here'; |
| editorID := 'FIXME put GenEditorView.id value here'; |
| } endif; |
| }; |
| |
| -- |
| -- VisualEffect |
| -- |
| |
| mapping GMFMAP::VisualEffectMapping::createVisualEffects(parent: GMFGEN::GenCommonBase, diagramElement: GMFGRAPH::DiagramElement): GMFGEN::GenVisualEffect { |
| name := self.diagramPin.name; |
| pinKind := self.diagramPin.oclAsType(EObject).eClass().name; |
| operationName := diagramElement.getOperationName(self.diagramPin); |
| operationType := self.diagramPin.getOperationType(); |
| oclExpression := self.oclExpression; |
| |
| editPolicyQualifiedClassName := parent.getEditPolicyQualifiedClassName(self.diagramPin); |
| key := result.editPolicyQualifiedClassName + '.KEY'; |
| } |
| |
| -- |
| -- Helpers |
| -- |
| |
| helper GMFGEN::GenCommonBase::getEditPolicyQualifiedClassName(pin: Pin): String = |
| self.getDiagram().editPoliciesPackageName + '.' + |
| pin.name.firstToUpper() + // FIXME Should be valid Java Class Name |
| self.visualID.toString() + 'Policy'; |
| |
| helper GMFGRAPH::DiagramElement::getOperationName(pin: GMFGRAPH::Pin): String = |
| if not self.figure.actualFigure.hasFigurePin(pin) then |
| let graphChildAccess = self.figure.accessors->any(figure.hasFigurePin(pin)) in |
| if graphChildAccess.oclIsUndefined() then |
| pin.getOperationName() |
| else |
| graphChildAccess.accessor + "()." + pin.getOperationName() |
| endif |
| else pin.getOperationName() endif; |
| |
| helper GMFGRAPH::Figure::hasFigurePin(pin: GMFGRAPH::Pin): Boolean = |
| let realFigure = |
| if self.oclIsTypeOf(FigureRef) then |
| self.oclAsType(FigureRef).figure |
| else self.oclAsType(RealFigure) endif |
| in |
| realFigure.pins->includes(pin); |