blob: 9051c52c823f76b3130b68dd56b2140d8bceab66 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
/*****************************************************************************
* 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 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Dmitry Stadnik (Borland) - initial API and implementation
* Alexander Shatalin (Borland) - initial API and implementation
* Michael Golubev (Montages) - #386838 - migrate to Xtend2
*
*****************************************************************************/
package aspects.impl.diagram.editparts
import com.google.inject.Inject
import com.google.inject.Singleton
import org.eclipse.gmf.codegen.gmfgen.GenCompartment
import xpt.diagram.editparts.Common
import org.eclipse.papyrus.papyrusgmfgenextension.ExtendedGenView
//DOCUMENTATION: PapyrusGenCode
//Overload only the creation of editPolicies in order to add the paste edit policy
@Singleton class CompartmentEditPart extends impl.diagram.editparts.CompartmentEditPart {
@Inject extension xpt.Common;
@Inject Common xptEditpartsCommon;
override createDefaultEditPoliciesBody(GenCompartment it) '''
super.createDefaultEditPolicies();
«IF canCollapse»
installEditPolicy(org.eclipse.gef.EditPolicy.PRIMARY_DRAG_ROLE, new org.eclipse.gmf.runtime.diagram.ui.editpolicies.ResizableCompartmentEditPolicy());
«ENDIF»
«xptEditpartsCommon.installSemanticEditPolicy(it)»
«IF ! childNodes.empty»
installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CREATION_ROLE, new org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultCreationEditPolicy());
installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.DRAG_DROP_ROLE, new org.eclipse.gmf.runtime.diagram.ui.editpolicies.DragDropEditPolicy());
installEditPolicy(org.eclipse.papyrus.uml.diagram.common.editpolicies.PasteEditPolicy.PASTE_ROLE, new org.eclipse.papyrus.uml.diagram.common.editpolicies.PasteEditPolicy());
«ENDIF»
«xptEditpartsCommon.installCanonicalEditPolicy(it)»
«xptEditpartsCommon.behaviour(it)»
'''
override getTargetEditPartMethod(GenCompartment it) '''
«generatedMemberComment»
public org.eclipse.gef.EditPart getTargetEditPart(org.eclipse.gef.Request request) {
return super.getTargetEditPart(request);
}
'''
override createFigure(GenCompartment it) {
if (hasExternalSuperClass(it,'org.eclipse.papyrus.uml.diagram.activity.edit.part.ShapeCompartmentWithoutScrollbarsEditPart')) {
'''
@Override
public org.eclipse.draw2d.IFigure createFigure() {
return super.createFigure();
}
'''
} else {
super.createFigure(it);
}
}
def boolean hasExternalSuperClass(GenCompartment it, String className) {
return it.eResource.allContents.filter(typeof(ExtendedGenView)).filter [v | (v.genView.contains(it) && v.superOwnedEditPart.equals(className))].size > 0;
}
}
|