1 | /* |
2 | * Copyright 2007, IPD, SDQ, University of Karlsruhe |
3 | */ |
4 | package de.uka.ipd.sdq.pcm.gmf.repository.edit.parts; |
5 | |
6 | import java.util.ArrayList; |
7 | import java.util.Iterator; |
8 | import java.util.List; |
9 | |
10 | import org.eclipse.emf.ecore.EObject; |
11 | import org.eclipse.gef.commands.Command; |
12 | import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy; |
13 | import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart; |
14 | import org.eclipse.gmf.runtime.diagram.ui.editpolicies.DiagramDragDropEditPolicy; |
15 | import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; |
16 | import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest; |
17 | import org.eclipse.gmf.runtime.diagram.ui.requests.DropObjectsRequest; |
18 | import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter; |
19 | import org.eclipse.gmf.runtime.notation.Node; |
20 | import org.eclipse.gmf.runtime.notation.View; |
21 | |
22 | import de.uka.ipd.sdq.pcm.gmf.repository.edit.commands.PalladioComponentModelCreateShortcutDecorationsCommand; |
23 | import de.uka.ipd.sdq.pcm.gmf.repository.edit.policies.RepositoryCanonicalEditPolicy; |
24 | import de.uka.ipd.sdq.pcm.gmf.repository.edit.policies.RepositoryItemSemanticEditPolicy; |
25 | |
26 | /** |
27 | * @generated |
28 | */ |
29 | public class RepositoryEditPart extends DiagramEditPart { |
30 | |
31 | /** |
32 | * @generated |
33 | */ |
34 | public final static String MODEL_ID = "PCM Repository Model"; //$NON-NLS-1$ |
35 | |
36 | /** |
37 | * @generated |
38 | */ |
39 | public static final int VISUAL_ID = 1000; |
40 | |
41 | /** |
42 | * @generated |
43 | */ |
44 | public RepositoryEditPart(View view) { |
45 | super(view); |
46 | } |
47 | |
48 | /** |
49 | * @generated not |
50 | */ |
51 | protected void createDefaultEditPolicies() { |
52 | super.createDefaultEditPolicies(); |
53 | installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, |
54 | new RepositoryItemSemanticEditPolicy()); |
55 | // Make diagram unsynched |
56 | installEditPolicy(EditPolicyRoles.CANONICAL_ROLE, |
57 | new RepositoryCanonicalEditPolicy()); |
58 | // Install an edit policy which also create links to the new created view |
59 | // according to the semantic model |
60 | // installEditPolicy(EditPolicyRoles.CREATION_ROLE, |
61 | // new RepositoryCreationEditPolicy()); |
62 | installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, // Fix a bug in GMF. Workaround |
63 | new DiagramDragDropEditPolicy() { |
64 | |
65 | @Override |
66 | protected Command createViewsAndArrangeCommand( |
67 | DropObjectsRequest dropRequest, List viewDescriptors) { |
68 | ArrayList newDesc = new ArrayList(); |
69 | for (CreateViewRequest.ViewDescriptor d : (List<CreateViewRequest.ViewDescriptor>) viewDescriptors) { |
70 | newDesc.add(new CreateViewRequest.ViewDescriptor(d |
71 | .getElementAdapter(), d.getViewKind(), |
72 | null, d.getPreferencesHint())); |
73 | } |
74 | return super.createViewsAndArrangeCommand(dropRequest, |
75 | newDesc); |
76 | } |
77 | |
78 | }); |
79 | } |
80 | } |