blob: 55c60cf63ca800cd79c45a043eec42a4d85ed116 (
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
|
/*****************************************************************************
* 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
*
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.clazz.custom.policies;
import org.eclipse.gef.DragTracker;
import org.eclipse.gef.Request;
import org.eclipse.gef.RequestConstants;
import org.eclipse.gef.requests.SelectionRequest;
import org.eclipse.gef.tools.DeselectAllTracker;
import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeCompartmentEditPart;
import org.eclipse.gmf.runtime.diagram.ui.internal.tools.RubberbandDragTracker;
import org.eclipse.gmf.runtime.notation.View;
/**
* this is an abstract editpart used to allow double click on XY layout compartment
*
*/
@SuppressWarnings("restriction")
public abstract class AbstractPackageableElementCompartmentEditPart extends ShapeCompartmentEditPart {
public AbstractPackageableElementCompartmentEditPart(View view) {
super(view);
}
/**
*
* @see org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeCompartmentEditPart#getDragTracker(org.eclipse.gef.Request)
*
*/
@Override
public DragTracker getDragTracker(Request req) {
if(!supportsDragSelection()) {
return super.getDragTracker(req);
}
if(req instanceof SelectionRequest && ((SelectionRequest)req).getLastButtonPressed() == 3) {
return new DeselectAllTracker(this) {
@Override
protected boolean handleButtonDown(int button) {
getCurrentViewer().select(AbstractPackageableElementCompartmentEditPart.this);
return true;
}
};
}
return new RubberbandDragTracker() {
/*
* this method has been respecified in order to allow double click
* on the compartment.
* hence it allows the navigation by double click
*/
@Override
protected boolean handleDoubleClick(int button) {
SelectionRequest request = new SelectionRequest();
request.setLocation(getLocation());
request.setType(RequestConstants.REQ_OPEN);
AbstractPackageableElementCompartmentEditPart.this.performRequest(request);
return true;
}
@Override
protected void handleFinished() {
if(getViewer().getSelectedEditParts().isEmpty()) {
getViewer().select(AbstractPackageableElementCompartmentEditPart.this);
}
}
};
}
@Override
public boolean isSelectable() {
return false;
}
}
|