| /* |
| * Copyright (c) 2007, 2008 Borland Software Corporation |
| * |
| * 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: |
| * Anna Karjakina (Borland) - initial API and implementation |
| * Alexander Shatalin (Borland) - initial API and implementation |
| */ |
| |
| «IMPORT "http://www.eclipse.org/gmf/2008/GenModel"» |
| «IMPORT "http://www.eclipse.org/emf/2002/GenModel"» |
| «IMPORT "http://www.eclipse.org/emf/2002/Ecore"» |
| «IMPORT "http://www.eclipse.org/gmf/2008/Context"» |
| «IMPORT "http://www.eclipse.org/gmf/2008/GmfGraph/wysiwyg"» |
| |
| «EXTENSION aspects::impl::diagram::editparts::Utils» |
| «EXTENSION xpt::GenModelUtils» |
| |
| «AROUND extendsList FOR gmfgen::GenNode»«IF hasSynchronizers(this)»extends «getDiagram().editPartsPackageName».«EXPAND superclassName»«ELSE»«targetDef.proceed()»«ENDIF»«ENDAROUND» |
| |
| «DEFINE superclassName FOR gmfgen::GenNode»«IF isPolylinePoint(this)»AbstractPointEditPart«ELSE»AbstractFigureEditPart«ENDIF»«ENDDEFINE» |
| |
| «AROUND handleNotificationEvent FOR gmfgen::GenNode-» |
| «IF hasSynchronizers(this)-» |
| «EXPAND xpt::Common::generatedMemberComment» |
| protected void handleNotificationEvent(org.eclipse.emf.common.notify.Notification notification) { |
| Object feature = notification.getFeature(); |
| «IF hasLayoutDataSynchronizers(this)»if (org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getSize_Width().equals(feature) |
| || org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getSize_Height().equals(feature) |
| || org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getLocation_X().equals(feature) |
| || org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) { |
| return; |
| } else «ENDIF»if (org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getFillStyle_FillColor().equals(feature)) { |
| return; |
| } else if (org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getLineStyle_LineColor().equals(feature)) { |
| return; |
| } |
| super.handleNotificationEvent(notification); |
| } |
| «ENDIF-» |
| «targetDef.proceed()-» |
| «ENDAROUND» |
| |
| «AROUND additions FOR gmfgen::GenNode-» |
| «IF hasSynchronizers(this)-» |
| |
| «EXPAND myDomainElementAdapters-» |
| |
| «EXPAND getGmfgraphElement-» |
| |
| «EXPAND removeSemanticListeners-» |
| |
| «EXPAND setFigure-» |
| |
| «EXPAND activate-» |
| «IF hasLayoutDataSynchronizers(this)-» |
| |
| «EXPAND refreshBounds-» |
| «ENDIF-» |
| «IF isPolyline(this)-» |
| «IF hasLayoutDataSynchronizers(this)-» |
| |
| «EXPAND refreshMainFigureBounds-» |
| «ENDIF-» |
| |
| «EXPAND DefaultSizeNodeFigureExt-» |
| «ENDIF-» |
| «ENDIF-» |
| «targetDef.proceed()» |
| «ENDAROUND» |
| |
| «DEFINE myDomainElementAdapters FOR gmfgen::GenNode-» |
| «EXPAND xpt::Common::generatedMemberComment» |
| private java.util.Collection<org.eclipse.emf.common.notify.Adapter> myDomainElementAdapters = new java.util.ArrayList<org.eclipse.emf.common.notify.Adapter>(); |
| «ENDDEFINE» |
| |
| «DEFINE activate FOR gmfgen::GenNode-» |
| «EXPAND xpt::Common::generatedMemberComment» |
| public void activate() { |
| if (isActive()){ |
| return; |
| } |
| final «EXPAND MetaModel::QualifiedClassName FOR metaclass()» modelElement = getGmfgraphElement(); |
| if (modelElement == null) { |
| super.activate(); |
| return; |
| } |
| «EXPAND addDomainElementAdapters FOREACH getSynchronizers(this)-» |
| modelElement.eAdapters().addAll(myDomainElementAdapters); |
| super.activate(); |
| } |
| «ENDDEFINE» |
| |
| «DEFINE getGmfgraphElement FOR gmfgen::GenNode-» |
| «EXPAND xpt::Common::generatedMemberComment» |
| private «EXPAND MetaModel::QualifiedClassName FOR metaclass()» getGmfgraphElement() { |
| org.eclipse.gmf.runtime.notation.View view = getNotationView(); |
| if (view == null) { |
| return null; |
| } |
| org.eclipse.emf.ecore.EObject element = view.getElement(); |
| if («EXPAND MetaModel::IsInstance("element") FOR metaclass()») { |
| «EXPAND MetaModel::DeclareAndAssign("modelFigureElement", "element") FOR metaclass()» |
| return modelFigureElement; |
| } |
| return null; |
| } |
| «ENDDEFINE» |
| |
| «DEFINE removeSemanticListeners FOR gmfgen::GenNode-» |
| «EXPAND xpt::Common::generatedMemberComment» |
| protected void removeSemanticListeners() { |
| «EXPAND MetaModel::QualifiedClassName FOR metaclass()» modelElement = getGmfgraphElement(); |
| if (modelElement != null) { |
| modelElement.eAdapters().removeAll(myDomainElementAdapters); |
| myDomainElementAdapters.clear(); |
| } |
| super.removeSemanticListeners(); |
| } |
| «ENDDEFINE» |
| |
| «DEFINE setFigure FOR gmfgen::GenNode-» |
| «EXPAND xpt::Common::generatedMemberComment» |
| protected void setFigure(org.eclipse.draw2d.IFigure figure) { |
| super.setFigure(figure); |
| «EXPAND processChanges-» |
| } |
| «ENDDEFINE» |
| |
| «DEFINE processChanges FOR gmfgen::GenNode-» |
| «EXPAND MetaModel::QualifiedClassName FOR metaclass()» modelElement = getGmfgraphElement(); |
| if (modelElement != null) { |
| «EXPAND processChanges FOREACH getSynchronizers(this)-» |
| } |
| «ENDDEFINE» |
| |
| «DEFINE processChanges FOR wysiwyg::DomainPropertiesSynchronizer-» |
| «EXPAND processChanges(contexts) FOREACH actions-» |
| «ENDDEFINE» |
| |
| «DEFINE processChanges(List[context::Context] contexts) FOR wysiwyg::AbstractAction-» |
| «ERROR "Should never be called"» |
| «ENDDEFINE» |
| |
| «DEFINE processChanges(List[context::Context] contexts) FOR wysiwyg::MethodCallAction-» |
| «methodName»(); |
| «ENDDEFINE» |
| |
| «DEFINE processChanges(List[context::Context] contexts) FOR wysiwyg::FigurePropertySynchAction-» |
| getPrimaryShape().«EXPAND setterName»(«IF domainValueTransformerName != null»«domainValueTransformerName»(«ENDIF»«EXPAND getModelElementProperty FOREACH contexts SEPARATOR ", "»«IF domainValueTransformerName != null»)«ENDIF»); |
| «ENDDEFINE» |
| |
| «DEFINE getModelElementProperty FOR context::Context-» |
| «ERROR "Should never be called"» |
| «ENDDEFINE» |
| |
| «DEFINE getModelElementProperty FOR context::FeatureContext»modelElement.«EXPAND getterName FOR selector»()«ENDDEFINE» |
| |
| «DEFINE refreshBounds FOR gmfgen::GenNode-» |
| «EXPAND xpt::Common::generatedMemberComment» |
| protected void refreshBounds() { |
| «EXPAND MetaModel::QualifiedClassName FOR metaclass()» modelElement = getGmfgraphElement(); |
| if (modelElement == null) { |
| return; |
| } |
| if (modelElement.getPreferredSize() != null) { |
| getFigure().setPreferredSize(getDraw2dDimension(modelElement.getPreferredSize())); |
| } |
| if (modelElement.getLocation() != null) { |
| getFigure().setLocation(getDraw2DPoint(modelElement.getLocation())); |
| } |
| } |
| «ENDDEFINE» |
| |
| «DEFINE addDomainElementAdapters FOR wysiwyg::DomainPropertiesSynchronizer-» |
| |
| org.eclipse.gmf.graphdef.editor.sheet.ChangeTracker «EXPAND changeTrackerVarName» = new org.eclipse.gmf.graphdef.editor.sheet.ChangeTracker() { |
| public void modelChanged(org.eclipse.emf.common.notify.Notification msg) { |
| «EXPAND processChanges-» |
| } |
| }; |
| myDomainElementAdapters.add(«EXPAND attachContextListener(this) FOREACH contexts SEPARATOR "); \nmyDomainElementAdapters.add("»); |
| «ENDDEFINE» |
| |
| «DEFINE changeTrackerVarName FOR wysiwyg::DomainPropertiesSynchronizer»«EXPAND changeTrackerVarName FOR (wysiwyg::AbstractAction) actions.first()»«ENDDEFINE» |
| |
| «DEFINE changeTrackerVarName FOR wysiwyg::AbstractAction» |
| «ERROR "Should never be called"» |
| «ENDDEFINE» |
| |
| «DEFINE changeTrackerVarName FOR wysiwyg::MethodCallAction»«methodName»Tracker«ENDDEFINE» |
| |
| «DEFINE changeTrackerVarName FOR wysiwyg::FigurePropertySynchAction»«figureAttribute.toFirstLower()»Tracker«ENDDEFINE» |
| |
| «DEFINE attachContextListener(wysiwyg::DomainPropertiesSynchronizer synchronizer) FOR context::Context-» |
| «ERROR "Should never be called"» |
| «ENDDEFINE» |
| |
| «DEFINE attachContextListener(wysiwyg::DomainPropertiesSynchronizer synchronizer) FOR context::FeatureContext-» |
| «IF children.size() == 0-» |
| new org.eclipse.gmf.graphdef.editor.sheet.FeatureTracker(«EXPAND changeTrackerVarName FOR synchronizer», «EXPAND accessor FOR selector») |
| «ELSE-» |
| new org.eclipse.gmf.graphdef.editor.sheet.AttachAdapter(«EXPAND accessor FOR selector», «EXPAND changeTrackerVarName FOR synchronizer», «EXPAND attachContextListener(synchronizer) FOREACH children SEPARATOR ", "») |
| «ENDIF-» |
| «ENDDEFINE» |
| |
| «DEFINE refreshMainFigureBounds FOR gmfgen::GenNode-» |
| «EXPAND xpt::Common::generatedMemberComment» |
| public void refreshMainFigureBounds() { |
| DefaultSizeNodeFigureExt nodeFigure = (DefaultSizeNodeFigureExt) getFigure(); |
| nodeFigure.fireFigureMoved(); |
| nodeFigure.revalidate(); |
| } |
| «ENDDEFINE» |
| |
| «DEFINE DefaultSizeNodeFigureExt FOR gmfgen::GenNode-» |
| «EXPAND xpt::Common::generatedClassComment» |
| class DefaultSizeNodeFigureExt extends org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure { |
| |
| «EXPAND xpt::Common::generatedMemberComment» |
| DefaultSizeNodeFigureExt(int width, int height) { |
| super(width, height); |
| } |
| |
| «IF hasLayoutDataSynchronizers(this)-» |
| «EXPAND xpt::Common::generatedMemberComment» |
| public void setBounds(org.eclipse.draw2d.geometry.Rectangle rect) { |
| getPrimaryShape().setBounds(rect); |
| } |
| |
| «EXPAND xpt::Common::generatedMemberComment» |
| public org.eclipse.draw2d.geometry.Rectangle getBounds() { |
| org.eclipse.draw2d.geometry.Rectangle polylineBounds = getPrimaryShape().getBounds().getCopy(); |
| polylineBounds.width += 8; |
| polylineBounds.height += 8; |
| return polylineBounds; |
| } |
| |
| «EXPAND xpt::Common::generatedMemberComment» |
| public void fireFigureMoved() { |
| super.fireFigureMoved(); |
| } |
| «ELSE-» |
| «EXPAND xpt::Common::generatedMemberComment» |
| protected boolean useLocalCoordinates() { |
| return true; |
| } |
| |
| «EXPAND xpt::Common::generatedMemberComment» |
| protected void paintFigure(org.eclipse.draw2d.Graphics graphics) { |
| graphics.pushState(); |
| graphics.setLineWidth(1); |
| graphics.setLineStyle(org.eclipse.swt.SWT.LINE_DOT); |
| org.eclipse.draw2d.geometry.Rectangle fb = getBounds(); |
| graphics.drawRectangle(fb.x, fb.y, fb.width - 1, fb.height - 1); |
| graphics.popState(); |
| super.paintFigure(graphics); |
| } |
| «ENDIF-» |
| |
| } |
| «ENDDEFINE» |
| |
| «REM»Temporary solution. Use MetaModel.xpt from formtk here.«ENDREM» |
| «DEFINE accessor FOR ecore::EStructuralFeature»org.eclipse.gmf.gmfgraph.GMFGraphPackage.eINSTANCE.get«eContainingClass.name.toFirstUpper()»_«name.toFirstUpper()»()«ENDDEFINE» |
| |
| «DEFINE setterName FOR wysiwyg::FigurePropertySynchAction»set«figureAttribute»«ENDDEFINE» |
| |
| «DEFINE getterName FOR ecore::EStructuralFeature»«IF eType.name == "EBoolean"»is«ELSE»get«ENDIF»«name.toFirstUpper()»«ENDDEFINE» |