blob: 1177affb2a16a4e0bc65af734f5d5763b18958d9 (
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
|
/*****************************************************************************
* Copyright (c) 2011 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:
*
* CEA LIST - Initial API and implementation
*
*****************************************************************************/
package org.eclipse.papyrus.sysml.diagram.common.edit.policy;
import java.util.List;
import java.util.Set;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.commands.UnexecutableCommand;
import org.eclipse.gmf.runtime.diagram.ui.requests.DuplicateRequest;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.sysml.diagram.common.utils.SysMLGraphicalTypes;
import org.eclipse.papyrus.uml.diagram.common.editpolicies.DuplicatePasteEditPolicy;
import org.eclipse.papyrus.uml.diagram.common.utils.UMLGraphicalTypes;
/**
* Specific edit policy for compartment, to forbid the duplication of ports as affixed children.
*
* @see bug 375041
*/
public class CustomDuplicatePasteEditPolicy extends DuplicatePasteEditPolicy {
/**
* {@inheritDoc}
*/
@Override
protected Command constructDuplicationCommand(List notationViewsToDuplicate, Set elementsToDuplicate, DuplicateRequest request, TransactionalEditingDomain editingDomain) {
if (notationViewsToDuplicate != null && !notationViewsToDuplicate.isEmpty()) {
for (Object o : notationViewsToDuplicate) {
if (o instanceof View) {
String type = ((View) o).getType();
if (SysMLGraphicalTypes.SHAPE_SYSML_FLOWPORT_AS_AFFIXED_ID.equals(type) || UMLGraphicalTypes.SHAPE_UML_PORT_AS_AFFIXED_ID.equals(type)) {
return UnexecutableCommand.INSTANCE;
}
}
}
}
return super.constructDuplicationCommand(notationViewsToDuplicate, elementsToDuplicate, request, editingDomain);
}
}
|