blob: 3fba1048369d1aba30a6990894a3277786a7d218 (
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) 2009 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
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Adapted code from the class diagram
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.profile.custom.policies.itemsemantic;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.commands.UnexecutableCommand;
import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
import org.eclipse.papyrus.uml.diagram.profile.custom.commands.CustomAssociationReorientCommand;
import org.eclipse.papyrus.uml.diagram.profile.edit.parts.AssociationEditPart;
import org.eclipse.papyrus.uml.diagram.profile.edit.policies.DataTypeItemSemanticEditPolicy;
import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
/**
* this a specialization to manage creation of association and associationClass
*/
public class CustomClassItemSemanticEditPolicy extends DataTypeItemSemanticEditPolicy {
/**
*
* {@inheritDoc}
*/
@Override
protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
if(UMLElementTypes.Association_4001 == req.getElementType()) {
return getGEFWrapper(new org.eclipse.papyrus.uml.diagram.profile.custom.commands.CustomAssociationCreateCommand(req, req.getSource(), req.getTarget()));
}
return super.getCompleteCreateRelationshipCommand(req);
}
@Override
protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) {
switch(getVisualID(req)) {
case AssociationEditPart.VISUAL_ID:
return getGEFWrapper(new CustomAssociationReorientCommand(req));
}
return super.getReorientRelationshipCommand(req);
}
/**
*
* {@inheritDoc}
*/
@Override
protected Command getStartCreateRelationshipCommand(CreateRelationshipRequest req) {
if(UMLElementTypes.Association_4001 == req.getElementType()) {
return getGEFWrapper(new org.eclipse.papyrus.uml.diagram.profile.custom.commands.CustomAssociationCreateCommand(req, req.getSource(), req.getTarget()));
}
//forbid creation of association branch from it.
if(UMLElementTypes.Association_4019 == req.getElementType()) {
return UnexecutableCommand.INSTANCE;
}
return super.getStartCreateRelationshipCommand(req);
}
}
|