Skip to main content
aboutsummaryrefslogblamecommitdiffstats
blob: a0595abc8b23b916911d099ba9d529403c097b70 (plain) (tree)






















                                                                                                                                                                                                                                                                       
                                                                            









































































































































                                                                                                                                                                      
/*
 * Copyright (c) 2006, 2009 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:
 *    Dmitry Stadnik (Borland) - initial API and implementation
 *    Alexander Shatalin (Borland) - initial API and implementation
 *    Remi Schnekenburger (CEA LIST) - modification for Papyrus MDT
 */

«IMPORT 'http://www.eclipse.org/gmf/2009/GenModel'»
«IMPORT 'http://www.eclipse.org/papyrus/2009/papyrusgmfgenextension'»

«REM»BEGIN: PapyrusGenCode«ENDREM»
«REM»computes super type of the link edit part in case the edit part manages a representation of a UML element«ENDREM»
«DEFINE extendsListContents FOR gmfgen::GenLink-»

«IF papyrusgmfgenextension::ExtendedGenView.allInstances()->select(v:papyrusgmfgenextension::ExtendedGenView|v.genView->includes(self) and v.superOwnedEditPart<>null)->size()<>0»
	«FOREACH papyrusgmfgenextension::ExtendedGenView.allInstances()->select(v:papyrusgmfgenextension::ExtendedGenView|v.genView->includes(self) and v.superOwnedEditPart<>null) AS extendedObject»«EXPAND specifyInheritance FOR extendedObject»«ENDFOREACH-»
«ELSE»org.eclipse.papyrus.infra.gmfdiag.common.editpart.ConnectionEditPart
«ENDIF»
«ENDDEFINE»
«REM»END: BEGIN: PapyrusGenCode«ENDREM»

«REM»BEGIN: PapyrusGenCode«ENDREM»
«REM»definition of the inheritance «ENDREM»
«DEFINE specifyInheritance FOR papyrusgmfgenextension::ExtendedGenView-»«superOwnedEditPart»«ENDDEFINE»
«REM»END: BEGIN: PapyrusGenCode«ENDREM»

«DEFINE _constructor FOR gmfgen::GenLink-»
	«EXPAND xpt::Common::generatedMemberComment»
	public «editPartClassName»(org.eclipse.gmf.runtime.notation.View view) {
		super(view);
	}
«ENDDEFINE»

«DEFINE createDefaultEditPoliciesBody FOR gmfgen::GenLink-»
	super.createDefaultEditPolicies();
	«IF null = modelFacet-»
		installEditPolicy(org.eclipse.gef.EditPolicy.COMPONENT_ROLE, new org.eclipse.gmf.runtime.diagram.ui.editpolicies.ViewComponentEditPolicy());
	«ENDIF-»
	«EXPAND xpt::diagram::editparts::Common::installSemanticEditPolicy-»
	«EXPAND xpt::diagram::editparts::Common::behaviour FOR self-»
«ENDDEFINE»

«DEFINE addFixedChild FOR gmfgen::GenLink-»
	«IF labels->size() > 0-»
		«EXPAND xpt::Common::generatedMemberComment»
		protected boolean addFixedChild(org.eclipse.gef.EditPart childEditPart) {
			«FOREACH labels->asSequence() AS label-»
				«EXPAND addLabel(label) FOR label.viewmap-»
			«ENDFOREACH-»
			return false;
		}
	«ENDIF»
«ENDDEFINE»

«DEFINE addLabel(label : gmfgen::GenLinkLabel) FOR gmfgen::Viewmap-»
«ENDDEFINE»

«DEFINE addLabel(label : gmfgen::GenLinkLabel) FOR gmfgen::ParentAssignedViewmap-»
	if (childEditPart instanceof «label.getEditPartQualifiedClassName()») {
		((«label.getEditPartQualifiedClassName()») childEditPart).«EXPAND impl::diagram::editparts::TextAware::labelSetterName»(
				getPrimaryShape().«getterName»());
		return true;
	}
«ENDDEFINE»

«DEFINE removeFixedChild FOR gmfgen::GenLink-»
	«IF labels->size() > 0-»
		«EXPAND xpt::Common::generatedMemberComment»
		protected boolean removeFixedChild(org.eclipse.gef.EditPart childEditPart) {
			«FOREACH labels->asSequence() AS label-»
				«EXPAND removeLabel(label) FOR label.viewmap-»
			«ENDFOREACH-»
			return false;
		}
	«ENDIF»
«ENDDEFINE»

«DEFINE removeLabel(label : gmfgen::GenLinkLabel) FOR gmfgen::Viewmap-»
«ENDDEFINE»

«DEFINE removeLabel(label : gmfgen::GenLinkLabel) FOR gmfgen::ParentAssignedViewmap-»
	if (childEditPart instanceof «label.getEditPartQualifiedClassName()») {
		return true;
	}
«ENDDEFINE»

«DEFINE addChildVisual FOR gmfgen::GenLink-»
	«IF labels->size() > 0-»
		«EXPAND xpt::Common::generatedMemberComment»
		protected void addChildVisual(org.eclipse.gef.EditPart childEditPart, int index) {
			if (addFixedChild(childEditPart)) {
				return;
			}
			super.addChildVisual(childEditPart, -1);
		}
	«ENDIF»
«ENDDEFINE»

«DEFINE removeChildVisual FOR gmfgen::GenLink-»
	«IF labels->size() > 0-»
		«EXPAND xpt::Common::generatedMemberComment»
		protected void removeChildVisual(org.eclipse.gef.EditPart childEditPart) {
			if (removeFixedChild(childEditPart)) {
				return;
			}
			super.removeChildVisual(childEditPart);
		}
	«ENDIF»
«ENDDEFINE»

«DEFINE createLinkFigure FOR gmfgen::GenLink-»
	«EXPAND xpt::Common::generatedMemberComment(
		'Creates figure for this edit part.\n' + 
		'\n' + 
		'Body of this method does not depend on settings in generation model\n' + 
		'so you may safely remove <i>generated</i> tag and modify it.\n'
	)»
	«EXPAND createLinkFigure(self) FOR viewmap-»
«ENDDEFINE»

«DEFINE createLinkFigure(link : gmfgen::GenLink) FOR gmfgen::Viewmap-»
	«ERROR 'Unknown viewmap: ' + self.repr()-»
«ENDDEFINE»

«DEFINE createLinkFigure(link : gmfgen::GenLink) FOR gmfgen::FigureViewmap-»
	«LET (if figureQualifiedClassName = null then 'org.eclipse.gmf.runtime.draw2d.ui.figures.PolylineConnectionEx' else figureQualifiedClassName endif) AS fqn-»
		protected org.eclipse.draw2d.Connection createConnectionFigure() {
			return new «fqn»();
		}

		«EXPAND xpt::Common::generatedMemberComment»
		public «fqn» getPrimaryShape() {
			return («fqn») getFigure();
		}
	«ENDLET-»
«ENDDEFINE»

«DEFINE createLinkFigure(link : gmfgen::GenLink) FOR gmfgen::SnippetViewmap»
	protected org.eclipse.draw2d.Connection createConnectionFigure() {
		return «body»;
	}
«ENDDEFINE»

«DEFINE createLinkFigure(link : gmfgen::GenLink) FOR gmfgen::InnerClassViewmap»
	protected org.eclipse.draw2d.Connection createConnectionFigure() {
		return new «className»();
	}

	«EXPAND xpt::Common::generatedMemberComment»
	public «className» getPrimaryShape() {
		return («className») getFigure();
	}

	«classBody»
«ENDDEFINE»

Back to the top