blob: c01a4122f97c76ce5836adf91d6fc0d7b675df50 (
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
|
/*****************************************************************************
* Copyright (c) 2017 CEA LIST and others.
*
* 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.uml.diagram.sequence.edit.parts;
import java.util.List;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.Request;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.commands.UnexecutableCommand;
import org.eclipse.gef.requests.ChangeBoundsRequest;
import org.eclipse.gef.requests.ReconnectRequest;
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest;
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest.ViewAndElementDescriptor;
import org.eclipse.gmf.runtime.emf.type.core.IElementType;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.uml.service.types.element.UMLDIElementTypes;
import org.eclipse.papyrus.uml.service.types.utils.ElementUtil;
/**
* @author Celine JANSSENS
*
*/
public class CInteractionInteractionCompartmentEditPart extends InteractionInteractionCompartmentEditPart {
/**
* Constructor.
*
* @param view
*/
public CInteractionInteractionCompartmentEditPart(View view) {
super(view);
}
/**
* @see org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart#getCommand(org.eclipse.gef.Request)
*
* @param _request
* @return
*/
@Override
public Command getCommand(Request request) {
if (request instanceof CreateViewAndElementRequest && request.getType().equals(REQ_CREATE)) {
CreateViewAndElementRequest createrequest = (CreateViewAndElementRequest) request;
ViewAndElementDescriptor descriptor = createrequest.getViewAndElementDescriptor();
IElementType elementType = descriptor.getElementAdapter().getAdapter(IElementType.class);
if (ElementUtil.isTypeOf(elementType, UMLDIElementTypes.DURATION_CONSTRAINT_SHAPE)) {
return null;
}
}
// ExecutionSpecification can't be drop into Interaction
if (request instanceof ChangeBoundsRequest) {
List<?> editParts = ((ChangeBoundsRequest) request).getEditParts();
if(null != editParts && !editParts.isEmpty()) {
for (Object part : editParts) {
if (part instanceof AbstractExecutionSpecificationEditPart) {
return UnexecutableCommand.INSTANCE;
}
}
}
}
return super.getCommand(request);
}
/**
* @see org.eclipse.papyrus.uml.diagram.sequence.edit.parts.InteractionInteractionCompartmentEditPart#getTargetEditPart(org.eclipse.gef.Request)
*
* @param request
* @return
*/
@Override
public EditPart getTargetEditPart(Request request) {
if (request instanceof ReconnectRequest) {
return this.getParent();
}
return super.getTargetEditPart(request);
}
}
|