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.editpolicies;
|
12
|
|
13
|
import org.eclipse.gef.EditPart;
|
14
|
import org.eclipse.gef.EditPolicy;
|
15
|
import org.eclipse.gef.Request;
|
16
|
import org.eclipse.gef.RequestConstants;
|
17
|
import org.eclipse.gef.commands.Command;
|
18
|
|
19
|
/**
|
20
|
* The default implementation of {@link EditPolicy}.
|
21
|
* <P>
|
22
|
* Since this is the default implementation of an interface, this document deals
|
23
|
* with proper sub-classing. This class is not the API. For documentation on
|
24
|
* proper usage of the public API, see the documentation for the interface
|
25
|
* itself: {@link EditPolicy}.
|
26
|
*/
|
27
|
public abstract class AbstractEditPolicy implements EditPolicy,
|
28
|
RequestConstants {
|
29
|
|
30
|
private EditPart host;
|
31
|
|
32
|
/**
|
33
|
* Does nothing by default.
|
34
|
*
|
35
|
* @see org.eclipse.gef.EditPolicy#activate()
|
36
|
*/
|
37
|
public void activate() {
|
38
|
}
|
39
|
|
40
|
/**
|
41
|
* Does nothing by default.
|
42
|
*
|
43
|
* @see org.eclipse.gef.EditPolicy#deactivate()
|
44
|
*/
|
45
|
public void deactivate() {
|
46
|
}
|
47
|
|
48
|
/**
|
49
|
* This method will log the message to GEF's trace/debug system if the
|
50
|
* corrseponding flag for FEEDBACK is set to true.
|
51
|
*
|
52
|
* @param message
|
53
|
* the String to log
|
54
|
* @deprecated in 3.1 This method will be removed in future releases.
|
55
|
*/
|
56
|
protected final void debugFeedback(String message) {
|
57
|
}
|
58
|
|
59
|
/**
|
60
|
* Does nothing by default.
|
61
|
*
|
62
|
* @see org.eclipse.gef.EditPolicy#eraseSourceFeedback(Request)
|
63
|
*/
|
64
|
public void eraseSourceFeedback(Request request) {
|
65
|
}
|
66
|
|
67
|
/**
|
68
|
* Does nothing by default.
|
69
|
*
|
70
|
* @see org.eclipse.gef.EditPolicy#eraseTargetFeedback(Request)
|
71
|
*/
|
72
|
public void eraseTargetFeedback(Request request) {
|
73
|
}
|
74
|
|
75
|
/**
|
76
|
* Returns <code>null</code> by default. <code>null</code> is used to
|
77
|
* indicate that the EditPolicy does not contribute to the specified
|
78
|
* <code>Request</code>.
|
79
|
*
|
80
|
* @see org.eclipse.gef.EditPolicy#getCommand(Request)
|
81
|
*/
|
82
|
public Command getCommand(Request request) {
|
83
|
return null;
|
84
|
}
|
85
|
|
86
|
/**
|
87
|
* @see org.eclipse.gef.EditPolicy#getHost()
|
88
|
*/
|
89
|
public EditPart getHost() {
|
90
|
return host;
|
91
|
}
|
92
|
|
93
|
/**
|
94
|
* Returns <code>null</code> by default. <code>null</code> indicates that
|
95
|
* this policy is unable to determine the target for the specified
|
96
|
* <code>Request</code>.
|
97
|
*
|
98
|
* @see org.eclipse.gef.EditPolicy#getTargetEditPart(Request)
|
99
|
*/
|
100
|
public EditPart getTargetEditPart(Request request) {
|
101
|
return null;
|
102
|
}
|
103
|
|
104
|
/**
|
105
|
* @see org.eclipse.gef.EditPolicy#setHost(EditPart)
|
106
|
*/
|
107
|
public void setHost(EditPart host) {
|
108
|
this.host = host;
|
109
|
}
|
110
|
|
111
|
/**
|
112
|
* Does nothing by default.
|
113
|
*
|
114
|
* @see org.eclipse.gef.EditPolicy#showSourceFeedback(Request)
|
115
|
*/
|
116
|
public void showSourceFeedback(Request request) {
|
117
|
}
|
118
|
|
119
|
/**
|
120
|
* Does nothing by default.
|
121
|
*
|
122
|
* @see org.eclipse.gef.EditPolicy#showTargetFeedback(Request)
|
123
|
*/
|
124
|
public void showTargetFeedback(Request request) {
|
125
|
}
|
126
|
|
127
|
/**
|
128
|
* @see java.lang.Object#toString()
|
129
|
*/
|
130
|
public String toString() {
|
131
|
String c = getClass().getName();
|
132
|
c = c.substring(c.lastIndexOf('.') + 1);
|
133
|
if (getHost() != null) {
|
134
|
return getHost().toString() + "." + c; //$NON-NLS-1$
|
135
|
} else {
|
136
|
return c + " (no host for EditPolicy set yet)"; //$NON-NLS-1$
|
137
|
}
|
138
|
}
|
139
|
|
140
|
/**
|
141
|
* Returns <code>false</code> by default.
|
142
|
*
|
143
|
* @see org.eclipse.gef.EditPolicy#understandsRequest(Request)
|
144
|
*/
|
145
|
public boolean understandsRequest(Request req) {
|
146
|
return false;
|
147
|
}
|
148
|
|
149
|
}
|