|
Lines 28-37
Link Here
|
| 28 |
public class StatusLineManager extends ContributionManager implements IStatusLineWithProgressManager { |
28 |
public class StatusLineManager extends ContributionManager implements IStatusLineWithProgressManager { |
| 29 |
|
29 |
|
| 30 |
/** |
30 |
/** |
|
|
31 |
* Global group marker used to control positioning of contributions |
| 32 |
*/ |
| 33 |
public static final String BEGIN_GROUP = "BEGIN_GROUP"; |
| 34 |
|
| 35 |
/** |
| 36 |
* Global group marker used to control positioning of contributions |
| 37 |
*/ |
| 38 |
public static final String MIDDLE_GROUP = "MIDDLE_GROUP"; |
| 39 |
|
| 40 |
/** |
| 41 |
* Global group marker used to control positioning of contributions |
| 42 |
*/ |
| 43 |
public static final String END_GROUP = "END_GROUP"; |
| 44 |
|
| 45 |
/** |
| 31 |
* The status line control; <code>null</code> before |
46 |
* The status line control; <code>null</code> before |
| 32 |
* creation and after disposal. |
47 |
* creation and after disposal. |
| 33 |
*/ |
48 |
*/ |
| 34 |
private StatusLine statusLine = null; |
49 |
private Composite statusLine = null; |
| 35 |
|
50 |
|
| 36 |
private String lastMessage; |
51 |
private String lastMessage; |
| 37 |
private Image lastImage; |
52 |
private Image lastImage; |
|
Lines 50-58
Link Here
|
| 50 |
* @param parent the parent control |
65 |
* @param parent the parent control |
| 51 |
* @return the status line control |
66 |
* @return the status line control |
| 52 |
*/ |
67 |
*/ |
| 53 |
public StatusLine createControl(Composite parent) { |
68 |
public Control createControl(Composite parent) { |
| 54 |
if (!statusLineExist() && parent != null) { |
69 |
if (!statusLineExist() && parent != null) { |
| 55 |
statusLine= new StatusLine(parent); |
70 |
statusLine= new StatusLine(parent); |
|
|
71 |
add(new GroupMarker(BEGIN_GROUP)); |
| 72 |
add(new GroupMarker (MIDDLE_GROUP)); |
| 73 |
add(new GroupMarker(END_GROUP)); |
| 56 |
update(false); |
74 |
update(false); |
| 57 |
} |
75 |
} |
| 58 |
return statusLine; |
76 |
return statusLine; |
|
Lines 74-87
Link Here
|
| 74 |
} |
92 |
} |
| 75 |
} |
93 |
} |
| 76 |
/** |
94 |
/** |
| 77 |
* Internal -- returns the StatusLine control. |
95 |
* Returns the Control used by this StatusLineManager. |
| 78 |
* <p> |
96 |
* |
| 79 |
* This method is not intended to be used outside of the JFace framework. |
97 |
* @return the control used by this manager |
| 80 |
* </p> |
|
|
| 81 |
*/ |
98 |
*/ |
| 82 |
public Control getControl() { |
99 |
public Control getControl() { |
| 83 |
return statusLine; |
100 |
return statusLine; |
| 84 |
} |
101 |
} |
|
|
102 |
/** |
| 103 |
* Returns the progress monitor delegate. Override this method |
| 104 |
* to provide your own object used to handle progress. |
| 105 |
* |
| 106 |
* @return the IProgressMonitor delegate |
| 107 |
*/ |
| 108 |
protected IProgressMonitor getProgressMonitorDelegate() { |
| 109 |
return (IProgressMonitor)getControl(); |
| 110 |
} |
| 85 |
/* |
111 |
/* |
| 86 |
* (non-Javadoc) |
112 |
* (non-Javadoc) |
| 87 |
* Method declared on IStatusLineManager |
113 |
* Method declared on IStatusLineManager |
|
Lines 89-106
Link Here
|
| 89 |
public IProgressMonitor getProgressMonitor() { |
115 |
public IProgressMonitor getProgressMonitor() { |
| 90 |
|
116 |
|
| 91 |
return new IProgressMonitor(){ |
117 |
return new IProgressMonitor(){ |
|
|
118 |
|
| 119 |
IProgressMonitor progressDelegate = getProgressMonitorDelegate(); |
| 120 |
|
| 92 |
/* (non-Javadoc) |
121 |
/* (non-Javadoc) |
| 93 |
* @see org.eclipse.core.runtime.IProgressMonitor#beginTask(java.lang.String, int) |
122 |
* @see org.eclipse.core.runtime.IProgressMonitor#beginTask(java.lang.String, int) |
| 94 |
*/ |
123 |
*/ |
| 95 |
public void beginTask(String name, int totalWork) { |
124 |
public void beginTask(String name, int totalWork) { |
| 96 |
statusLine.beginTask(name,totalWork); |
125 |
progressDelegate.beginTask(name,totalWork); |
| 97 |
|
126 |
|
| 98 |
} |
127 |
} |
| 99 |
/* (non-Javadoc) |
128 |
/* (non-Javadoc) |
| 100 |
* @see org.eclipse.core.runtime.IProgressMonitor#done() |
129 |
* @see org.eclipse.core.runtime.IProgressMonitor#done() |
| 101 |
*/ |
130 |
*/ |
| 102 |
public void done() { |
131 |
public void done() { |
| 103 |
statusLine.done(); |
132 |
progressDelegate.done(); |
| 104 |
clearProgress(); |
133 |
clearProgress(); |
| 105 |
} |
134 |
} |
| 106 |
|
135 |
|
|
Lines 108-114
Link Here
|
| 108 |
* @see org.eclipse.core.runtime.IProgressMonitor#internalWorked(double) |
137 |
* @see org.eclipse.core.runtime.IProgressMonitor#internalWorked(double) |
| 109 |
*/ |
138 |
*/ |
| 110 |
public void internalWorked(double work) { |
139 |
public void internalWorked(double work) { |
| 111 |
statusLine.internalWorked(work); |
140 |
progressDelegate.internalWorked(work); |
| 112 |
|
141 |
|
| 113 |
} |
142 |
} |
| 114 |
|
143 |
|
|
Lines 116-122
Link Here
|
| 116 |
* @see org.eclipse.core.runtime.IProgressMonitor#isCanceled() |
145 |
* @see org.eclipse.core.runtime.IProgressMonitor#isCanceled() |
| 117 |
*/ |
146 |
*/ |
| 118 |
public boolean isCanceled() { |
147 |
public boolean isCanceled() { |
| 119 |
return statusLine.isCanceled(); |
148 |
return progressDelegate.isCanceled(); |
| 120 |
} |
149 |
} |
| 121 |
|
150 |
|
| 122 |
/* (non-Javadoc) |
151 |
/* (non-Javadoc) |
|
Lines 126-132
Link Here
|
| 126 |
//Don't bother updating for disposed status |
155 |
//Don't bother updating for disposed status |
| 127 |
if(statusLine.isDisposed()) |
156 |
if(statusLine.isDisposed()) |
| 128 |
return; |
157 |
return; |
| 129 |
statusLine.setCanceled(value); |
158 |
progressDelegate.setCanceled(value); |
| 130 |
|
159 |
|
| 131 |
} |
160 |
} |
| 132 |
|
161 |
|
|
Lines 134-140
Link Here
|
| 134 |
* @see org.eclipse.core.runtime.IProgressMonitor#setTaskName(java.lang.String) |
163 |
* @see org.eclipse.core.runtime.IProgressMonitor#setTaskName(java.lang.String) |
| 135 |
*/ |
164 |
*/ |
| 136 |
public void setTaskName(String name) { |
165 |
public void setTaskName(String name) { |
| 137 |
statusLine.setTaskName(name); |
166 |
progressDelegate.setTaskName(name); |
| 138 |
|
167 |
|
| 139 |
} |
168 |
} |
| 140 |
|
169 |
|
|
Lines 142-148
Link Here
|
| 142 |
* @see org.eclipse.core.runtime.IProgressMonitor#subTask(java.lang.String) |
171 |
* @see org.eclipse.core.runtime.IProgressMonitor#subTask(java.lang.String) |
| 143 |
*/ |
172 |
*/ |
| 144 |
public void subTask(String name) { |
173 |
public void subTask(String name) { |
| 145 |
statusLine.subTask(name); |
174 |
progressDelegate.subTask(name); |
| 146 |
|
175 |
|
| 147 |
} |
176 |
} |
| 148 |
|
177 |
|
|
Lines 150-156
Link Here
|
| 150 |
* @see org.eclipse.core.runtime.IProgressMonitor#worked(int) |
179 |
* @see org.eclipse.core.runtime.IProgressMonitor#worked(int) |
| 151 |
*/ |
180 |
*/ |
| 152 |
public void worked(int work) { |
181 |
public void worked(int work) { |
| 153 |
statusLine.worked(work); |
182 |
progressDelegate.worked(work); |
| 154 |
} |
183 |
} |
| 155 |
}; |
184 |
}; |
| 156 |
} |
185 |
} |
|
Lines 158-192
Link Here
|
| 158 |
* Method declared on IStatueLineManager |
187 |
* Method declared on IStatueLineManager |
| 159 |
*/ |
188 |
*/ |
| 160 |
public boolean isCancelEnabled() { |
189 |
public boolean isCancelEnabled() { |
| 161 |
return statusLineExist() && statusLine.isCancelEnabled(); |
190 |
return statusLineExist() && ((StatusLine)statusLine).isCancelEnabled(); |
| 162 |
} |
191 |
} |
| 163 |
/* (non-Javadoc) |
192 |
/* (non-Javadoc) |
| 164 |
* Method declared on IStatueLineManager |
193 |
* Method declared on IStatueLineManager |
| 165 |
*/ |
194 |
*/ |
| 166 |
public void setCancelEnabled(boolean enabled) { |
195 |
public void setCancelEnabled(boolean enabled) { |
| 167 |
if (statusLineExist()) |
196 |
if (statusLineExist()) |
| 168 |
statusLine.setCancelEnabled(enabled); |
197 |
((StatusLine)statusLine).setCancelEnabled(enabled); |
| 169 |
} |
198 |
} |
| 170 |
/* (non-Javadoc) |
199 |
/* (non-Javadoc) |
| 171 |
* Method declared on IStatusLineManager. |
200 |
* Method declared on IStatusLineManager. |
| 172 |
*/ |
201 |
*/ |
| 173 |
public void setErrorMessage(String message) { |
202 |
public void setErrorMessage(String message) { |
| 174 |
if (statusLineExist()) |
203 |
if (statusLineExist()) |
| 175 |
statusLine.setErrorMessage(message); |
204 |
((StatusLine)statusLine).setErrorMessage(message); |
| 176 |
} |
205 |
} |
| 177 |
/* (non-Javadoc) |
206 |
/* (non-Javadoc) |
| 178 |
* Method declared on IStatusLineManager. |
207 |
* Method declared on IStatusLineManager. |
| 179 |
*/ |
208 |
*/ |
| 180 |
public void setErrorMessage(Image image, String message) { |
209 |
public void setErrorMessage(Image image, String message) { |
| 181 |
if (statusLineExist()) |
210 |
if (statusLineExist()) |
| 182 |
statusLine.setErrorMessage(image, message); |
211 |
((StatusLine)statusLine).setErrorMessage(image, message); |
| 183 |
} |
212 |
} |
| 184 |
/* (non-Javadoc) |
213 |
/* (non-Javadoc) |
| 185 |
* Method declared on IStatusLineManager. |
214 |
* Method declared on IStatusLineManager. |
| 186 |
*/ |
215 |
*/ |
| 187 |
public void setMessage(String message) { |
216 |
public void setMessage(String message) { |
| 188 |
if (statusLineExist()) |
217 |
if (statusLineExist()) |
| 189 |
statusLine.setMessage(message); |
218 |
((StatusLine)statusLine).setMessage(message); |
| 190 |
lastMessage = message; |
219 |
lastMessage = message; |
| 191 |
} |
220 |
} |
| 192 |
/* (non-Javadoc) |
221 |
/* (non-Javadoc) |
|
Lines 194-200
Link Here
|
| 194 |
*/ |
223 |
*/ |
| 195 |
public void setMessage(Image image, String message) { |
224 |
public void setMessage(Image image, String message) { |
| 196 |
if (statusLineExist()) |
225 |
if (statusLineExist()) |
| 197 |
statusLine.setMessage(image, message); |
226 |
((StatusLine)statusLine).setMessage(image, message); |
| 198 |
lastMessage = message; |
227 |
lastMessage = message; |
| 199 |
lastImage = image; |
228 |
lastImage = image; |
| 200 |
} |
229 |
} |
|
Lines 337-343
Link Here
|
| 337 |
* @see org.eclipse.jface.action.IStatusLineWithProgressManager#clearProgress() |
366 |
* @see org.eclipse.jface.action.IStatusLineWithProgressManager#clearProgress() |
| 338 |
*/ |
367 |
*/ |
| 339 |
public void clearProgress() { |
368 |
public void clearProgress() { |
| 340 |
statusLine.setMessage(lastImage,lastMessage); |
369 |
((StatusLine)statusLine).setMessage(lastImage,lastMessage); |
| 341 |
|
370 |
|
| 342 |
} |
371 |
} |
| 343 |
|
372 |
|
|
Lines 346-352
Link Here
|
| 346 |
*/ |
375 |
*/ |
| 347 |
public void setProgressMessage(String message) { |
376 |
public void setProgressMessage(String message) { |
| 348 |
if (statusLineExist()) |
377 |
if (statusLineExist()) |
| 349 |
statusLine.setMessage(message); |
378 |
((StatusLine)statusLine).setMessage(message); |
| 350 |
} |
379 |
} |
| 351 |
|
380 |
|
| 352 |
} |
381 |
} |