1
|
/*******************************************************************************
|
2
|
* Copyright (c) 2000, 2010 IBM Corporation and others.
|
3
|
* All rights reserved. This program and the accompanying materials
|
4
|
* are made available under the terms of the Eclipse Public License v1.0
|
5
|
* which accompanies this distribution, and is available at
|
6
|
* http://www.eclipse.org/legal/epl-v10.html
|
7
|
*
|
8
|
* Contributors:
|
9
|
* IBM Corporation - initial API and implementation
|
10
|
*******************************************************************************/
|
11
|
package org.eclipse.gef.handles;
|
12
|
|
13
|
import org.eclipse.draw2d.Locator;
|
14
|
import org.eclipse.draw2d.MidpointLocator;
|
15
|
import org.eclipse.draw2d.geometry.Dimension;
|
16
|
|
17
|
import org.eclipse.gef.ConnectionEditPart;
|
18
|
import org.eclipse.gef.DragTracker;
|
19
|
import org.eclipse.gef.RequestConstants;
|
20
|
import org.eclipse.gef.SharedCursors;
|
21
|
import org.eclipse.gef.tools.ConnectionBendpointTracker;
|
22
|
|
23
|
/**
|
24
|
* A BendpointHandle that is used to create a new bendpoint.
|
25
|
*/
|
26
|
public class BendpointCreationHandle extends BendpointHandle {
|
27
|
|
28
|
{
|
29
|
setCursor(SharedCursors.SIZEALL);
|
30
|
setPreferredSize(new Dimension(DEFAULT_HANDLE_SIZE - 2,
|
31
|
DEFAULT_HANDLE_SIZE - 2));
|
32
|
}
|
33
|
|
34
|
/**
|
35
|
* Creates a new BendpointCreationHandle.
|
36
|
*/
|
37
|
public BendpointCreationHandle() {
|
38
|
}
|
39
|
|
40
|
/**
|
41
|
* Creates a new BendpointCreationHandle, sets its owner to
|
42
|
* <code>owner</code> and its index to <code>index</code>, and sets its
|
43
|
* locator to a new {@link MidpointLocator}.
|
44
|
*
|
45
|
* @param owner
|
46
|
* the ConnectionEditPart owner
|
47
|
* @param index
|
48
|
* the index
|
49
|
*/
|
50
|
public BendpointCreationHandle(ConnectionEditPart owner, int index) {
|
51
|
setOwner(owner);
|
52
|
setIndex(index);
|
53
|
setLocator(new MidpointLocator(getConnection(), index));
|
54
|
}
|
55
|
|
56
|
/**
|
57
|
* Creates a new BendpointCreationHandle, sets its owner to
|
58
|
* <code>owner</code> and its index to <code>index</code>, and sets its
|
59
|
* locator to a new {@link MidpointLocator} with the given
|
60
|
* <code>locatorIndex</code>.
|
61
|
*
|
62
|
* @param owner
|
63
|
* the ConnectionEditPart owner
|
64
|
* @param index
|
65
|
* the index
|
66
|
* @param locatorIndex
|
67
|
* the locator index
|
68
|
*/
|
69
|
public BendpointCreationHandle(ConnectionEditPart owner, int index,
|
70
|
int locatorIndex) {
|
71
|
setOwner(owner);
|
72
|
setIndex(index);
|
73
|
setLocator(new MidpointLocator(getConnection(), locatorIndex));
|
74
|
}
|
75
|
|
76
|
/**
|
77
|
* Creates a new BendpointCreationHandle and sets its owner to
|
78
|
* <code>owner</code>, sets its index to <code>index</code>, and sets its
|
79
|
* locator to <code>locator</code>.
|
80
|
*
|
81
|
* @param owner
|
82
|
* the ConnectionEditPart owner
|
83
|
* @param index
|
84
|
* the index
|
85
|
* @param locator
|
86
|
* the Locator
|
87
|
*/
|
88
|
public BendpointCreationHandle(ConnectionEditPart owner, int index,
|
89
|
Locator locator) {
|
90
|
setOwner(owner);
|
91
|
setIndex(index);
|
92
|
setLocator(locator);
|
93
|
}
|
94
|
|
95
|
/**
|
96
|
* Creates and returns a new {@link ConnectionBendpointTracker}.
|
97
|
*
|
98
|
* @return the new ConnectionBendpointTracker
|
99
|
*/
|
100
|
protected DragTracker createDragTracker() {
|
101
|
ConnectionBendpointTracker tracker;
|
102
|
tracker = new ConnectionBendpointTracker(
|
103
|
(ConnectionEditPart) getOwner(), getIndex());
|
104
|
tracker.setType(RequestConstants.REQ_CREATE_BENDPOINT);
|
105
|
tracker.setDefaultCursor(getCursor());
|
106
|
return tracker;
|
107
|
}
|
108
|
|
109
|
}
|