blob: 2353d6ae800cc1cf736b107010f62f3ed94cb5b9 (
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
|
/*****************************************************************************
* Copyright (c) 2010 CEA LIST.
*
*
* 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:
* Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
*
*****************************************************************************/
package org.eclipse.papyrus.diagram.clazz.custom.command;
import java.util.Iterator;
import org.eclipse.emf.ecore.EAnnotation;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.transaction.RecordingCommand;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
import org.eclipse.gmf.runtime.notation.Node;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.diagram.clazz.providers.UMLViewProvider;
/**
* this is the specific command in charge to transform an element editpart into a shape_namedElement Editpart
*
*/
public class ElementToStereotypedShape extends RecordingCommand {
protected GraphicalEditPart elementEditPart;
/**
*
* Constructor of this command
*
* @param domain
* the transactional editing domain to execute transaction
* @param classView
* the editpart that will be transformed
*/
public ElementToStereotypedShape(TransactionalEditingDomain domain, GraphicalEditPart classView) {
super(domain);
this.elementEditPart = classView;
}
@Override
protected void doExecute() {
//creation of the node
UMLViewProvider umlViewProvider = new UMLViewProvider();
Node packageview = umlViewProvider.createNamedElement_2098(elementEditPart.resolveSemanticElement(), (View)elementEditPart.getNotationView().eContainer(), -1, true, elementEditPart.getDiagramPreferencesHint());
packageview.setLayoutConstraint(((Node)elementEditPart.getNotationView()).getLayoutConstraint());
//copy of all eannotations
Iterator<EAnnotation> iter = elementEditPart.getNotationView().getEAnnotations().iterator();
while(iter.hasNext()) {
EAnnotation annotation = EcoreUtil.copy(iter.next());
packageview.getEAnnotations().add(annotation);
}
}
}
|