Mercurial > projects > dwt-addons
annotate dwtx/jface/action/StatusLine.d @ 43:ea8ff534f622
Fix override and super aliases
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Fri, 11 Apr 2008 01:24:25 +0200 |
parents | da5ad8eedf5d |
children | 46a6e0e6ccd4 |
rev | line source |
---|---|
26 | 1 /******************************************************************************* |
2 * Copyright (c) 2000, 2006 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 * Port to the D programming language: | |
11 * Frank Benoit <benoit@tionex.de> | |
12 *******************************************************************************/ | |
13 | |
14 module dwtx.jface.action.StatusLine; | |
15 | |
16 import dwtx.jface.action.StatusLineLayoutData; | |
17 | |
18 import dwt.DWT; | |
19 import dwt.custom.CLabel; | |
20 import dwt.events.DisposeEvent; | |
21 import dwt.events.DisposeListener; | |
22 import dwt.events.SelectionAdapter; | |
23 import dwt.events.SelectionEvent; | |
24 import dwt.graphics.Cursor; | |
25 import dwt.graphics.Font; | |
26 import dwt.graphics.Image; | |
27 import dwt.graphics.Point; | |
28 import dwt.graphics.Rectangle; | |
29 import dwt.layout.GridData; | |
30 import dwt.layout.GridLayout; | |
31 import dwt.widgets.Composite; | |
32 import dwt.widgets.Control; | |
33 import dwt.widgets.Display; | |
34 import dwt.widgets.Layout; | |
35 import dwt.widgets.ToolBar; | |
36 import dwt.widgets.ToolItem; | |
37 import dwtx.core.runtime.IProgressMonitor; | |
38 import dwtx.jface.dialogs.ProgressIndicator; | |
39 import dwtx.jface.resource.ImageDescriptor; | |
40 import dwtx.jface.resource.JFaceColors; | |
41 import dwtx.jface.resource.JFaceResources; | |
42 | |
43 import dwt.dwthelper.utils; | |
44 import dwt.dwthelper.Runnable; | |
45 | |
46 /** | |
47 * A StatusLine control is a DWT Composite with a horizontal layout which hosts | |
48 * a number of status indication controls. | |
49 * Typically it is situated below the content area of the window. | |
50 * <p> | |
51 * By default a StatusLine has two predefined status controls: a MessageLine and a | |
52 * ProgressIndicator and it provides API for easy access. | |
53 * </p> | |
54 * <p> | |
55 * This is an internal class, not intended to be used outside the JFace framework. | |
56 * </p> | |
57 */ | |
58 /* package */class StatusLine : Composite, IProgressMonitor { | |
59 | |
60 /** Horizontal gaps between items. */ | |
61 public static const int GAP = 3; | |
62 | |
63 /** Progress bar creation is delayed by this ms */ | |
64 public static const int DELAY_PROGRESS = 500; | |
65 | |
66 /** visibility state of the progressbar */ | |
67 protected bool fProgressIsVisible = false; | |
68 | |
69 /** visibility state of the cancle button */ | |
70 protected bool fCancelButtonIsVisible = false; | |
71 | |
72 /** enablement state of the cancle button */ | |
73 protected bool fCancelEnabled = false; | |
74 | |
75 /** name of the task */ | |
76 protected String fTaskName; | |
77 | |
78 /** is the task is cancled */ | |
79 protected bool fIsCanceled; | |
80 | |
81 /** the start time of the task */ | |
82 protected long fStartTime; | |
83 | |
84 private Cursor fStopButtonCursor; | |
85 | |
86 /** the message text */ | |
87 protected String fMessageText; | |
88 | |
89 /** the message image */ | |
90 protected Image fMessageImage; | |
91 | |
92 /** the error text */ | |
93 protected String fErrorText; | |
94 | |
95 /** the error image */ | |
96 protected Image fErrorImage; | |
97 | |
98 /** the message label */ | |
99 protected CLabel fMessageLabel; | |
100 | |
101 /** the composite parent of the progress bar */ | |
102 protected Composite fProgressBarComposite; | |
103 | |
104 /** the progress bar */ | |
105 protected ProgressIndicator fProgressBar; | |
106 | |
107 /** the toolbar */ | |
108 protected ToolBar fToolBar; | |
109 | |
110 /** the cancle button */ | |
111 protected ToolItem fCancelButton; | |
112 | |
113 /** stop image descriptor */ | |
114 protected static ImageDescriptor fgStopImage; | |
115 | |
116 static this() { | |
38
c884a1ab6db3
resource loading, fix type in image names
Frank Benoit <benoit@tionex.de>
parents:
26
diff
changeset
|
117 fgStopImage = ImageDescriptor.createFromFile( |
40
da5ad8eedf5d
debug prints, dwt.dwthelper restructure, ...
Frank Benoit <benoit@tionex.de>
parents:
39
diff
changeset
|
118 getImportData!("dwtx.jface.action.images.stop.gif"));//$NON-NLS-1$ |
da5ad8eedf5d
debug prints, dwt.dwthelper restructure, ...
Frank Benoit <benoit@tionex.de>
parents:
39
diff
changeset
|
119 //getImportData!("file.png"));//$NON-NLS-1$ |
39 | 120 //DWT Note: Not used in jface, but needs Display instance, which is not yet available. |
121 // JFaceResources.getImageRegistry().put( | |
122 // "dwtx.jface.parts.StatusLine.stopImage", fgStopImage);//$NON-NLS-1$ | |
26 | 123 } |
124 | |
125 /** | |
126 * Layout the contribution item controls on the status line. | |
127 */ | |
128 public class StatusLineLayout : Layout { | |
129 private const StatusLineLayoutData DEFAULT_DATA; | |
130 | |
131 this(){ | |
132 DEFAULT_DATA = new StatusLineLayoutData(); | |
133 } | |
134 | |
43
ea8ff534f622
Fix override and super aliases
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
135 public override Point computeSize(Composite composite, int wHint, int hHint, |
26 | 136 bool changed) { |
137 | |
138 if (wHint !is DWT.DEFAULT && hHint !is DWT.DEFAULT) { | |
139 return new Point(wHint, hHint); | |
140 } | |
141 | |
142 Control[] children = composite.getChildren(); | |
143 int totalWidth = 0; | |
144 int maxHeight = 0; | |
145 int totalCnt = 0; | |
146 for (int i = 0; i < children.length; i++) { | |
147 bool useWidth = true; | |
148 Control w = children[i]; | |
149 if (w is fProgressBarComposite && !fProgressIsVisible) { | |
150 useWidth = false; | |
151 } else if (w is fToolBar && !fCancelButtonIsVisible) { | |
152 useWidth = false; | |
153 } | |
154 StatusLineLayoutData data = cast(StatusLineLayoutData) w | |
155 .getLayoutData(); | |
156 if (data is null) { | |
157 data = DEFAULT_DATA; | |
158 } | |
159 Point e = w.computeSize(data.widthHint, data.heightHint, | |
160 changed); | |
161 if (useWidth) { | |
162 totalWidth += e.x; | |
163 totalCnt++; | |
164 } | |
165 maxHeight = Math.max(maxHeight, e.y); | |
166 } | |
167 if (totalCnt > 0) { | |
168 totalWidth += (totalCnt - 1) * GAP; | |
169 } | |
170 if (totalWidth <= 0) { | |
171 totalWidth = maxHeight * 4; | |
172 } | |
173 return new Point(totalWidth, maxHeight); | |
174 } | |
175 | |
43
ea8ff534f622
Fix override and super aliases
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
176 public override void layout(Composite composite, bool flushCache) { |
26 | 177 |
178 if (composite is null) { | |
179 return; | |
180 } | |
181 | |
182 // StatusLineManager skips over the standard status line widgets | |
183 // in its update method. There is thus a dependency | |
184 // between the layout of the standard widgets and the update method. | |
185 | |
186 // Make sure cancel button and progress bar are before contributions. | |
187 fMessageLabel.moveAbove(null); | |
188 fToolBar.moveBelow(fMessageLabel); | |
189 fProgressBarComposite.moveBelow(fToolBar); | |
190 | |
191 Rectangle rect = composite.getClientArea(); | |
192 Control[] children = composite.getChildren(); | |
193 int count = children.length; | |
194 | |
195 int ws[] = new int[count]; | |
196 | |
197 int h = rect.height; | |
198 int totalWidth = -GAP; | |
199 for (int i = 0; i < count; i++) { | |
200 Control w = children[i]; | |
201 if (w is fProgressBarComposite && !fProgressIsVisible) { | |
202 continue; | |
203 } | |
204 if (w is fToolBar && !fCancelButtonIsVisible) { | |
205 continue; | |
206 } | |
207 StatusLineLayoutData data = cast(StatusLineLayoutData) w | |
208 .getLayoutData(); | |
209 if (data is null) { | |
210 data = DEFAULT_DATA; | |
211 } | |
212 int width = w.computeSize(data.widthHint, h, flushCache).x; | |
213 ws[i] = width; | |
214 totalWidth += width + GAP; | |
215 } | |
216 | |
217 int diff = rect.width - totalWidth; | |
218 ws[0] += diff; // make the first StatusLabel wider | |
219 | |
220 // Check against minimum recommended width | |
221 final int msgMinWidth = rect.width / 3; | |
222 if (ws[0] < msgMinWidth) { | |
223 diff = ws[0] - msgMinWidth; | |
224 ws[0] = msgMinWidth; | |
225 } else { | |
226 diff = 0; | |
227 } | |
228 | |
229 // Take space away from the contributions first. | |
230 for (int i = count - 1; i >= 0 && diff < 0; --i) { | |
231 int min = Math.min(ws[i], -diff); | |
232 ws[i] -= min; | |
233 diff += min + GAP; | |
234 } | |
235 | |
236 int x = rect.x; | |
237 int y = rect.y; | |
238 for (int i = 0; i < count; i++) { | |
239 Control w = children[i]; | |
240 /* | |
241 * Workaround for Linux Motif: | |
242 * Even if the progress bar and cancel button are | |
243 * not set to be visible ad of width 0, they still | |
244 * draw over the first pixel of the editor | |
245 * contributions. | |
246 * | |
247 * The fix here is to draw the progress bar and | |
248 * cancel button off screen if they are not visible. | |
249 */ | |
250 if (w is fProgressBarComposite && !fProgressIsVisible | |
251 || w is fToolBar && !fCancelButtonIsVisible) { | |
252 w.setBounds(x + rect.width, y, ws[i], h); | |
253 continue; | |
254 } | |
255 w.setBounds(x, y, ws[i], h); | |
256 if (ws[i] > 0) { | |
257 x += ws[i] + GAP; | |
258 } | |
259 } | |
260 } | |
261 } | |
262 | |
263 /** | |
264 * Create a new StatusLine as a child of the given parent. | |
265 * | |
266 * @param parent the parent for this Composite | |
267 * @param style the style used to create this widget | |
268 */ | |
269 public this(Composite parent, int style) { | |
270 super(parent, style); | |
271 | |
272 addDisposeListener(new class DisposeListener { | |
273 public void widgetDisposed(DisposeEvent e) { | |
274 handleDispose(); | |
275 } | |
276 }); | |
277 | |
278 // StatusLineManager skips over the standard status line widgets | |
279 // in its update method. There is thus a dependency | |
280 // between this code defining the creation and layout of the standard | |
281 // widgets and the update method. | |
282 | |
283 setLayout(new StatusLineLayout()); | |
284 | |
285 fMessageLabel = new CLabel(this, DWT.NONE);//DWT.SHADOW_IN); | |
286 // Color[] colors = new Color[2]; | |
287 // colors[0] = parent.getDisplay().getSystemColor(DWT.COLOR_WIDGET_LIGHT_SHADOW); | |
288 // colors[1] = fMessageLabel.getBackground(); | |
289 // int[] gradient = new int[] {JFaceColors.STATUS_PERCENT}; | |
290 // fMessageLabel.setBackground(colors, gradient); | |
291 | |
292 fProgressIsVisible = false; | |
293 fCancelEnabled = false; | |
294 | |
295 fToolBar = new ToolBar(this, DWT.FLAT); | |
296 fCancelButton = new ToolItem(fToolBar, DWT.PUSH); | |
297 fCancelButton.setImage(fgStopImage.createImage()); | |
298 fCancelButton.setToolTipText(JFaceResources | |
299 .getString("Cancel_Current_Operation")); //$NON-NLS-1$ | |
300 fCancelButton.addSelectionListener(new class SelectionAdapter { | |
301 public void widgetSelected(SelectionEvent e) { | |
302 setCanceled(true); | |
303 } | |
304 }); | |
305 fCancelButton.addDisposeListener(new class DisposeListener { | |
306 public void widgetDisposed(DisposeEvent e) { | |
307 Image i = fCancelButton.getImage(); | |
308 if ((i !is null) && (!i.isDisposed())) { | |
309 i.dispose(); | |
310 } | |
311 } | |
312 }); | |
313 | |
314 // We create a composite to create the progress bar in | |
315 // so that it can be centered. See bug #32331 | |
316 fProgressBarComposite = new Composite(this, DWT.NONE); | |
317 GridLayout layout = new GridLayout(); | |
318 layout.horizontalSpacing = 0; | |
319 layout.verticalSpacing = 0; | |
320 layout.marginHeight = 0; | |
321 layout.marginWidth = 0; | |
322 fProgressBarComposite.setLayout(layout); | |
323 fProgressBar = new ProgressIndicator(fProgressBarComposite); | |
324 fProgressBar.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | |
325 | GridData.GRAB_VERTICAL)); | |
326 | |
327 fStopButtonCursor = new Cursor(getDisplay(), DWT.CURSOR_ARROW); | |
328 } | |
329 | |
330 /** | |
331 * Notifies that the main task is beginning. | |
332 * | |
333 * @param name the name (or description) of the main task | |
334 * @param totalWork the total number of work units into which | |
335 * the main task is been subdivided. If the value is 0 or UNKNOWN the | |
336 * implemenation is free to indicate progress in a way which doesn't | |
337 * require the total number of work units in advance. In general users | |
338 * should use the UNKNOWN value if they don't know the total amount of | |
339 * work units. | |
340 */ | |
341 public void beginTask(String name, int totalWork) { | |
342 long timestamp = System.currentTimeMillis(); | |
343 fStartTime = timestamp; | |
344 bool animated = (totalWork is UNKNOWN || totalWork is 0); | |
345 // make sure the progress bar is made visible while | |
346 // the task is running. Fixes bug 32198 for the non-animated case. | |
39 | 347 Runnable timer = new class(animated,timestamp) Runnable { |
26 | 348 bool animated_; |
349 long timestamp_; | |
39 | 350 this(bool a,long b){ |
351 animated_=a; | |
352 timestamp_=b; | |
26 | 353 } |
354 public void run() { | |
355 this.outer.startTask(timestamp_, animated_); | |
356 } | |
357 }; | |
358 if (fProgressBar is null) { | |
359 return; | |
360 } | |
361 | |
362 fProgressBar.getDisplay().timerExec(DELAY_PROGRESS, timer); | |
363 if (!animated) { | |
364 fProgressBar.beginTask(totalWork); | |
365 } | |
366 if (name is null) { | |
367 fTaskName = "";//$NON-NLS-1$ | |
368 } else { | |
369 fTaskName = name; | |
370 } | |
371 setMessage(fTaskName); | |
372 } | |
373 | |
374 /** | |
375 * Notifies that the work is done; that is, either the main task is completed or the | |
376 * user cancelled it. | |
377 * Done() can be called more than once; an implementation should be prepared to handle | |
378 * this case. | |
379 */ | |
380 public void done() { | |
381 | |
382 fStartTime = 0; | |
383 | |
384 if (fProgressBar !is null) { | |
385 fProgressBar.sendRemainingWork(); | |
386 fProgressBar.done(); | |
387 } | |
388 setMessage(null); | |
389 | |
390 hideProgress(); | |
391 } | |
392 | |
393 /** | |
394 * Returns the status line's progress monitor | |
395 * @return {@link IProgressMonitor} the progress monitor | |
396 */ | |
397 public IProgressMonitor getProgressMonitor() { | |
398 return this; | |
399 } | |
400 | |
401 /** | |
402 * @private | |
403 */ | |
404 protected void handleDispose() { | |
405 if (fStopButtonCursor !is null) { | |
406 fStopButtonCursor.dispose(); | |
407 fStopButtonCursor = null; | |
408 } | |
409 if (fProgressBar !is null) { | |
410 fProgressBar.dispose(); | |
411 fProgressBar = null; | |
412 } | |
413 } | |
414 | |
415 /** | |
416 * Hides the Cancel button and ProgressIndicator. | |
417 * @private | |
418 */ | |
419 protected void hideProgress() { | |
420 | |
421 if (fProgressIsVisible && !isDisposed()) { | |
422 fProgressIsVisible = false; | |
423 fCancelEnabled = false; | |
424 fCancelButtonIsVisible = false; | |
425 if (fToolBar !is null && !fToolBar.isDisposed()) { | |
426 fToolBar.setVisible(false); | |
427 } | |
428 if (fProgressBarComposite !is null | |
429 && !fProgressBarComposite.isDisposed()) { | |
430 fProgressBarComposite.setVisible(false); | |
431 } | |
432 layout(); | |
433 } | |
434 } | |
435 | |
436 /** | |
437 * @see IProgressMonitor#internalWorked(double) | |
438 */ | |
439 public void internalWorked(double work) { | |
440 if (!fProgressIsVisible) { | |
441 if (System.currentTimeMillis() - fStartTime > DELAY_PROGRESS) { | |
442 showProgress(); | |
443 } | |
444 } | |
445 | |
446 if (fProgressBar !is null) { | |
447 fProgressBar.worked(work); | |
448 } | |
449 } | |
450 | |
451 /** | |
452 * Returns true if the user does some UI action to cancel this operation. | |
453 * (like hitting the Cancel button on the progress dialog). | |
454 * The long running operation typically polls isCanceled(). | |
455 */ | |
456 public bool isCanceled() { | |
457 return fIsCanceled; | |
458 } | |
459 | |
460 /** | |
461 * Returns <code>true</true> if the ProgressIndication provides UI for canceling | |
462 * a long running operation. | |
463 * @return <code>true</true> if the ProgressIndication provides UI for canceling | |
464 */ | |
465 public bool isCancelEnabled() { | |
466 return fCancelEnabled; | |
467 } | |
468 | |
469 /** | |
470 * Sets the cancel status. This method is usually called with the | |
471 * argument false if a client wants to abort a cancel action. | |
472 */ | |
473 public void setCanceled(bool b) { | |
474 fIsCanceled = b; | |
475 if (fCancelButton !is null) { | |
476 fCancelButton.setEnabled(!b); | |
477 } | |
478 } | |
479 | |
480 /** | |
481 * Controls whether the ProgressIndication provides UI for canceling | |
482 * a long running operation. | |
483 * If the ProgressIndication is currently visible calling this method may have | |
484 * a direct effect on the layout because it will make a cancel button visible. | |
485 * | |
486 * @param enabled <code>true</true> if cancel should be enabled | |
487 */ | |
488 public void setCancelEnabled(bool enabled) { | |
489 fCancelEnabled = enabled; | |
490 if (fProgressIsVisible && !fCancelButtonIsVisible && enabled) { | |
491 showButton(); | |
492 layout(); | |
493 } | |
494 if (fCancelButton !is null && !fCancelButton.isDisposed()) { | |
495 fCancelButton.setEnabled(enabled); | |
496 } | |
497 } | |
498 | |
499 /** | |
500 * Sets the error message text to be displayed on the status line. | |
501 * The image on the status line is cleared. | |
502 * | |
503 * @param message the error message, or <code>null</code> for no error message | |
504 */ | |
505 public void setErrorMessage(String message) { | |
506 setErrorMessage(null, message); | |
507 } | |
508 | |
509 /** | |
510 * Sets an image and error message text to be displayed on the status line. | |
511 * | |
512 * @param image the image to use, or <code>null</code> for no image | |
513 * @param message the error message, or <code>null</code> for no error message | |
514 */ | |
515 public void setErrorMessage(Image image, String message) { | |
516 fErrorText = trim(message); | |
517 fErrorImage = image; | |
518 updateMessageLabel(); | |
519 } | |
520 | |
521 /** | |
522 * Applies the given font to this status line. | |
523 */ | |
43
ea8ff534f622
Fix override and super aliases
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
524 public override void setFont(Font font) { |
26 | 525 super.setFont(font); |
526 Control[] children = getChildren(); | |
527 for (int i = 0; i < children.length; i++) { | |
528 children[i].setFont(font); | |
529 } | |
530 } | |
531 | |
532 /** | |
533 * Sets the message text to be displayed on the status line. | |
534 * The image on the status line is cleared. | |
535 * | |
536 * @param message the error message, or <code>null</code> for no error message | |
537 */ | |
538 public void setMessage(String message) { | |
539 setMessage(null, message); | |
540 } | |
541 | |
542 /** | |
543 * Sets an image and a message text to be displayed on the status line. | |
544 * | |
545 * @param image the image to use, or <code>null</code> for no image | |
546 * @param message the message, or <code>null</code> for no message | |
547 */ | |
548 public void setMessage(Image image, String message) { | |
549 fMessageText = trim(message); | |
550 fMessageImage = image; | |
551 updateMessageLabel(); | |
552 } | |
553 | |
554 /** | |
555 * @see IProgressMonitor#setTaskName(java.lang.String) | |
556 */ | |
557 public void setTaskName(String name) { | |
558 fTaskName = name; | |
559 } | |
560 | |
561 /** | |
562 * Makes the Cancel button visible. | |
563 * @private | |
564 */ | |
565 protected void showButton() { | |
566 if (fToolBar !is null && !fToolBar.isDisposed()) { | |
567 fToolBar.setVisible(true); | |
568 fToolBar.setEnabled(true); | |
569 fToolBar.setCursor(fStopButtonCursor); | |
570 fCancelButtonIsVisible = true; | |
571 } | |
572 } | |
573 | |
574 /** | |
575 * Shows the Cancel button and ProgressIndicator. | |
576 * @private | |
577 */ | |
578 protected void showProgress() { | |
579 if (!fProgressIsVisible && !isDisposed()) { | |
580 fProgressIsVisible = true; | |
581 if (fCancelEnabled) { | |
582 showButton(); | |
583 } | |
584 if (fProgressBarComposite !is null | |
585 && !fProgressBarComposite.isDisposed()) { | |
586 fProgressBarComposite.setVisible(true); | |
587 } | |
588 layout(); | |
589 } | |
590 } | |
591 | |
592 /** | |
593 * @private | |
594 */ | |
595 void startTask(long timestamp, bool animated) { | |
596 if (!fProgressIsVisible && fStartTime is timestamp) { | |
597 showProgress(); | |
598 if (animated) { | |
599 if (fProgressBar !is null && !fProgressBar.isDisposed()) { | |
600 fProgressBar.beginAnimatedTask(); | |
601 } | |
602 } | |
603 } | |
604 } | |
605 | |
606 /** | |
607 * Notifies that a subtask of the main task is beginning. | |
608 * Subtasks are optional; the main task might not have subtasks. | |
609 * @param name the name (or description) of the subtask | |
610 * @see IProgressMonitor#subTask(String) | |
611 */ | |
612 public void subTask(String name) { | |
613 String text; | |
614 if (fTaskName.length is 0) { | |
615 text = name; | |
616 } else { | |
617 text = JFaceResources.format( | |
618 "Set_SubTask", [ fTaskName, name ]);//$NON-NLS-1$ | |
619 } | |
620 setMessage(text); | |
621 } | |
622 | |
623 /** | |
624 * Trims the message to be displayable in the status line. | |
625 * This just pulls out the first line of the message. | |
626 * Allows null. | |
627 */ | |
628 String trim(String message) { | |
629 if (message is null) { | |
630 return null; | |
631 } | |
632 int cr = message.indexOf('\r'); | |
633 int lf = message.indexOf('\n'); | |
634 if (cr is -1 && lf is -1) { | |
635 return message; | |
636 } | |
637 int len; | |
638 if (cr is -1) { | |
639 len = lf; | |
640 } else if (lf is -1) { | |
641 len = cr; | |
642 } else { | |
643 len = Math.min(cr, lf); | |
644 } | |
645 return message.substring(0, len); | |
646 } | |
647 | |
648 /** | |
649 * Updates the message label widget. | |
650 */ | |
651 protected void updateMessageLabel() { | |
652 if (fMessageLabel !is null && !fMessageLabel.isDisposed()) { | |
653 Display display = fMessageLabel.getDisplay(); | |
654 if ((fErrorText !is null && fErrorText.length > 0) | |
655 || fErrorImage !is null) { | |
656 fMessageLabel.setForeground(JFaceColors.getErrorText(display)); | |
657 fMessageLabel.setText(fErrorText); | |
658 fMessageLabel.setImage(fErrorImage); | |
659 } else { | |
660 fMessageLabel.setForeground(display | |
661 .getSystemColor(DWT.COLOR_WIDGET_FOREGROUND)); | |
662 fMessageLabel.setText(fMessageText is null ? "" : fMessageText); //$NON-NLS-1$ | |
663 fMessageLabel.setImage(fMessageImage); | |
664 } | |
665 } | |
666 } | |
667 | |
668 /** | |
669 * @see IProgressMonitor#worked(int) | |
670 */ | |
671 public void worked(int work) { | |
672 internalWorked(work); | |
673 } | |
674 } |