blob: f3503a405abf2588ff47f52ef18b59ba831985c8 (
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
73
74
75
76
77
|
/*****************************************************************************
* Copyright (c) 2010 Atos Origin.
*
*
* 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:
* Atos Origin - Initial API and implementation
*
*****************************************************************************/
package org.eclipse.papyrus.sysml.diagram.blockdiagram.edit.policies;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gef.commands.Command;
import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
import org.eclipse.gmf.runtime.emf.commands.core.commands.DuplicateEObjectsCommand;
import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.DuplicateElementsRequest;
import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.papyrus.diagram.clazz.edit.policies.ModelItemSemanticEditPolicy;
import org.eclipse.papyrus.sysml.diagram.blockdiagram.edit.commands.BlockCreateCommand;
import org.eclipse.papyrus.sysml.diagram.blockdiagram.providers.SysmlElementTypes;
/**
* @generated
*/
public class ResourceItemSemanticEditPolicy extends ModelItemSemanticEditPolicy {
/**
* @generated
*/
public ResourceItemSemanticEditPolicy() {
super();
}
/**
* @generated
*/
protected Command getCreateCommand(CreateElementRequest req) {
if(SysmlElementTypes.Block_2001 == req.getElementType()) {
return getGEFWrapper(new BlockCreateCommand(req));
}
return super.getCreateCommand(req);
}
/**
* @generated
*/
protected Command getDuplicateCommand(DuplicateElementsRequest req) {
TransactionalEditingDomain editingDomain = ((IGraphicalEditPart)getHost()).getEditingDomain();
Diagram currentDiagram = null;
if(getHost() instanceof IGraphicalEditPart) {
currentDiagram = ((IGraphicalEditPart)getHost()).getNotationView().getDiagram();
}
return getGEFWrapper(new DuplicateAnythingCommand(editingDomain, req, currentDiagram));
}
/**
* @generated
*/
private static class DuplicateAnythingCommand extends DuplicateEObjectsCommand {
private Diagram diagram;
/**
* @generated
*/
public DuplicateAnythingCommand(TransactionalEditingDomain editingDomain, DuplicateElementsRequest req, Diagram currentDiagram) {
super(editingDomain, req.getLabel(), req.getElementsToBeDuplicated(), req.getAllDuplicatedElementsMap());
this.diagram = currentDiagram;
}
}
}
|