blob: 25f812e22283687b3a25a4c90634addaaa6f2d10 (
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
/*****************************************************************************
* Copyright (c) 2009 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:
* Tristan FAURE (ATOS ORIGIN) tristan.faure@atosorigin.com - Initial API and implementation
*
*****************************************************************************/
package org.eclipse.papyrus.sysml.diagram.internalblock.edit.policies;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gef.Request;
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.papyrus.diagram.composite.edit.policies.PackageItemSemanticEditPolicy;
import org.eclipse.papyrus.diagram.composite.edit.policies.UMLBaseItemSemanticEditPolicy;
import org.eclipse.papyrus.sysml.diagram.internalblock.providers.SysmlElementTypes;
/**
* @generated
*/
public class ResourceItemSemanticEditPolicy extends UMLBaseItemSemanticEditPolicy {
PackageItemSemanticEditPolicy delegatePolicy = new PackageItemSemanticEditPolicy();
/**
* @generated
*/
public ResourceItemSemanticEditPolicy() {
super(SysmlElementTypes.Resource_1000);
}
/**
* @generated NOT
*/
protected Command getCreateCommand(CreateElementRequest req) {
Command result = super.getCreateCommand(req);
if (result == null) {
// if (SysmlElementTypes.FlowPort_2001 == req.getElementType()) {
// result = getGEFWrapper(new FlowPortCreateCommand(req));
// }
}
return result;
}
@Override
public Command getCommand(Request request) {
if(delegatePolicy.getHost() != null){
Command command = delegatePolicy.getCommand(request);
if (command != null) {
return command;
}
}
return super.getCommand(request);
}
@Override
public boolean understandsRequest(Request request) {
boolean understand = delegatePolicy.understandsRequest(request);
if (!understand) {
understand = super.understandsRequest(request);
}
return understand;
}
/**
* @generated
*/
protected Command getDuplicateCommand(DuplicateElementsRequest req) {
TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost()).getEditingDomain();
return getGEFWrapper(new DuplicateAnythingCommand(editingDomain, req));
}
/**
* @generated
*/
private static class DuplicateAnythingCommand extends DuplicateEObjectsCommand {
/**
* @generated
*/
public DuplicateAnythingCommand(TransactionalEditingDomain editingDomain, DuplicateElementsRequest req) {
super(editingDomain, req.getLabel(), req.getElementsToBeDuplicated(), req.getAllDuplicatedElementsMap());
}
}
}
|