75
|
1 /*******************************************************************************
|
|
2 * Copyright (c) 2007 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.ui.internal.forms.MessageManager;
|
|
15
|
|
16 import dwtx.ui.internal.forms.Messages;
|
|
17
|
|
18 import dwt.DWT;
|
|
19 import dwt.custom.CLabel;
|
|
20 import dwt.widgets.Composite;
|
|
21 import dwt.widgets.Control;
|
|
22 import dwt.widgets.Label;
|
|
23 import dwtx.jface.dialogs.IMessageProvider;
|
|
24 import dwtx.jface.fieldassist.ControlDecoration;
|
|
25 import dwtx.jface.fieldassist.FieldDecoration;
|
|
26 import dwtx.jface.fieldassist.FieldDecorationRegistry;
|
|
27 import dwtx.ui.forms.IMessage;
|
|
28 import dwtx.ui.forms.IMessageManager;
|
|
29 import dwtx.ui.forms.IMessagePrefixProvider;
|
|
30 import dwtx.ui.forms.widgets.Hyperlink;
|
|
31 import dwtx.ui.forms.widgets.ScrolledForm;
|
|
32
|
|
33 import dwt.dwthelper.utils;
|
|
34
|
|
35 import tango.util.collection.ArraySeq;
|
|
36 import tango.util.collection.HashMap;
|
|
37 import tango.util.Convert;
|
76
|
38 import tango.text.Text;
|
90
|
39 import tango.io.model.IFile;
|
75
|
40 /**
|
|
41 * @see IMessageManager
|
|
42 */
|
|
43
|
|
44 public class MessageManager : IMessageManager {
|
|
45
|
76
|
46 private static DefaultPrefixProvider DEFAULT_PREFIX_PROVIDER_;
|
|
47 private static DefaultPrefixProvider DEFAULT_PREFIX_PROVIDER(){
|
75
|
48 if( DEFAULT_PREFIX_PROVIDER_ is null ){
|
|
49 synchronized(MessageManager.classinfo){
|
|
50 if( DEFAULT_PREFIX_PROVIDER_ is null ){
|
|
51 DEFAULT_PREFIX_PROVIDER_ = new DefaultPrefixProvider();
|
|
52 }
|
|
53 }
|
|
54 }
|
|
55 return DEFAULT_PREFIX_PROVIDER_;
|
|
56 }
|
|
57 private ArraySeq!(Object) messages;
|
|
58 private HashMap!(Object,Object) decorators;
|
|
59 private bool autoUpdate = true;
|
|
60 private ScrolledForm scrolledForm;
|
|
61 private IMessagePrefixProvider prefixProvider;
|
|
62 private int decorationPosition = DWT.LEFT | DWT.BOTTOM;
|
|
63
|
|
64 private static FieldDecoration standardError_;
|
|
65 private static FieldDecoration standardError(){
|
|
66 if( standardError_ is null ){
|
|
67 synchronized(MessageManager.classinfo){
|
|
68 if( standardError_ is null ){
|
|
69 standardError_ = FieldDecorationRegistry
|
|
70 .getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_ERROR);
|
|
71 }
|
|
72 }
|
|
73 }
|
|
74 return standardError_;
|
|
75 }
|
|
76
|
|
77 private static FieldDecoration standardWarning_;
|
|
78 private static FieldDecoration standardWarning(){
|
|
79 if( standardWarning_ is null ){
|
|
80 synchronized(MessageManager.classinfo){
|
|
81 if( standardWarning_ is null ){
|
|
82 standardWarning_ = FieldDecorationRegistry
|
|
83 .getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_WARNING);
|
|
84 }
|
|
85 }
|
|
86 }
|
|
87 return standardWarning_;
|
|
88 }
|
|
89
|
|
90 private static FieldDecoration standardInformation_;
|
|
91 private static FieldDecoration standardInformation(){
|
|
92 if( standardInformation_ is null ){
|
|
93 synchronized(MessageManager.classinfo){
|
|
94 if( standardInformation_ is null ){
|
|
95 standardInformation_ = FieldDecorationRegistry
|
|
96 .getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION);
|
|
97 }
|
|
98 }
|
|
99 }
|
|
100 return standardInformation_;
|
|
101 }
|
|
102
|
78
|
103 private static String[] SINGLE_MESSAGE_SUMMARY_KEYS_;
|
|
104 private static String[] SINGLE_MESSAGE_SUMMARY_KEYS(){
|
|
105 if( SINGLE_MESSAGE_SUMMARY_KEYS_ is null ){
|
|
106 synchronized(MessageManager.classinfo){
|
|
107 if( SINGLE_MESSAGE_SUMMARY_KEYS_ is null ){
|
|
108 SINGLE_MESSAGE_SUMMARY_KEYS_ = [
|
|
109 Messages.MessageManager_sMessageSummary,
|
|
110 Messages.MessageManager_sMessageSummary,
|
|
111 Messages.MessageManager_sWarningSummary,
|
|
112 Messages.MessageManager_sErrorSummary ];
|
|
113 }
|
|
114 }
|
|
115 }
|
|
116 return SINGLE_MESSAGE_SUMMARY_KEYS_;
|
|
117 }
|
76
|
118
|
78
|
119 private static String[] MULTIPLE_MESSAGE_SUMMARY_KEYS_;
|
|
120 private static String[] MULTIPLE_MESSAGE_SUMMARY_KEYS(){
|
|
121 if( MULTIPLE_MESSAGE_SUMMARY_KEYS_ is null ){
|
|
122 synchronized(MessageManager.classinfo){
|
|
123 if( MULTIPLE_MESSAGE_SUMMARY_KEYS_ is null ){
|
|
124 MULTIPLE_MESSAGE_SUMMARY_KEYS_ = [
|
|
125 Messages.MessageManager_pMessageSummary,
|
|
126 Messages.MessageManager_pMessageSummary,
|
|
127 Messages.MessageManager_pWarningSummary,
|
|
128 Messages.MessageManager_pErrorSummary ];
|
|
129 }
|
|
130 }
|
|
131 }
|
|
132 return MULTIPLE_MESSAGE_SUMMARY_KEYS_;
|
76
|
133 }
|
75
|
134
|
|
135 static class Message : IMessage {
|
|
136 Control control;
|
|
137 Object data;
|
|
138 Object key;
|
|
139 String message;
|
|
140 int type;
|
|
141 String prefix;
|
|
142
|
|
143 this(Object key, String message, int type, Object data) {
|
|
144 this.key = key;
|
|
145 this.message = message;
|
|
146 this.type = type;
|
|
147 this.data = data;
|
|
148 }
|
|
149
|
|
150 /*
|
|
151 * (non-Javadoc)
|
|
152 *
|
|
153 * @see dwtx.jface.dialogs.IMessage#getKey()
|
|
154 */
|
|
155 public Object getKey() {
|
|
156 return key;
|
|
157 }
|
|
158
|
|
159 /*
|
|
160 * (non-Javadoc)
|
|
161 *
|
|
162 * @see dwtx.jface.dialogs.IMessageProvider#getMessage()
|
|
163 */
|
|
164 public String getMessage() {
|
|
165 return message;
|
|
166 }
|
|
167
|
|
168 /*
|
|
169 * (non-Javadoc)
|
|
170 *
|
|
171 * @see dwtx.jface.dialogs.IMessageProvider#getMessageType()
|
|
172 */
|
|
173 public int getMessageType() {
|
|
174 return type;
|
|
175 }
|
|
176
|
|
177 /*
|
|
178 * (non-Javadoc)
|
|
179 *
|
|
180 * @see dwtx.ui.forms.messages.IMessage#getControl()
|
|
181 */
|
|
182 public Control getControl() {
|
|
183 return control;
|
|
184 }
|
|
185
|
|
186 /*
|
|
187 * (non-Javadoc)
|
|
188 *
|
|
189 * @see dwtx.ui.forms.messages.IMessage#getData()
|
|
190 */
|
|
191 public Object getData() {
|
|
192 return data;
|
|
193 }
|
|
194
|
|
195 /*
|
|
196 * (non-Javadoc)
|
|
197 *
|
|
198 * @see dwtx.ui.forms.messages.IMessage#getPrefix()
|
|
199 */
|
|
200 public String getPrefix() {
|
|
201 return prefix;
|
|
202 }
|
|
203 }
|
|
204
|
|
205 static class DefaultPrefixProvider : IMessagePrefixProvider {
|
|
206
|
|
207 public String getPrefix(Control c) {
|
|
208 Composite parent = c.getParent();
|
|
209 Control[] siblings = parent.getChildren();
|
|
210 for (int i = 0; i < siblings.length; i++) {
|
|
211 if (siblings[i] is c) {
|
|
212 // this is us - go backward until you hit
|
|
213 // a label-like widget
|
|
214 for (int j = i - 1; j >= 0; j--) {
|
|
215 Control label = siblings[j];
|
|
216 String ltext = null;
|
|
217 if ( auto l = cast(Label)label ) {
|
|
218 ltext = l.getText();
|
|
219 } else if ( auto hl = cast(Hyperlink)label ) {
|
|
220 ltext = hl.getText();
|
|
221 } else if ( auto cl = cast(CLabel)label ) {
|
|
222 ltext = cl.getText();
|
|
223 }
|
|
224 if (ltext !is null) {
|
|
225 if (!ltext.endsWith(":")) //$NON-NLS-1$
|
|
226 return ltext ~ ": "; //$NON-NLS-1$
|
|
227 return ltext ~ " "; //$NON-NLS-1$
|
|
228 }
|
|
229 }
|
|
230 break;
|
|
231 }
|
|
232 }
|
|
233 return null;
|
|
234 }
|
|
235 }
|
|
236
|
|
237 class ControlDecorator {
|
|
238 private ControlDecoration decoration;
|
76
|
239 private ArraySeq!(Object) controlMessages;
|
75
|
240 private String prefix;
|
|
241
|
|
242 this(Control control) {
|
76
|
243 controlMessages = new ArraySeq!(Object);
|
75
|
244 this.decoration = new ControlDecoration(control, decorationPosition, scrolledForm.getBody());
|
|
245 }
|
|
246
|
|
247 public bool isDisposed() {
|
|
248 return decoration.getControl() is null;
|
|
249 }
|
|
250
|
|
251 void updatePrefix() {
|
|
252 prefix = null;
|
|
253 }
|
|
254
|
|
255 void updatePosition() {
|
|
256 Control control = decoration.getControl();
|
|
257 decoration.dispose();
|
|
258 this.decoration = new ControlDecoration(control, decorationPosition, scrolledForm.getBody());
|
|
259 update();
|
|
260 }
|
|
261
|
|
262 String getPrefix() {
|
|
263 if (prefix is null)
|
|
264 createPrefix();
|
|
265 return prefix;
|
|
266 }
|
|
267
|
|
268 private void createPrefix() {
|
|
269 if (prefixProvider is null) {
|
|
270 prefix = ""; //$NON-NLS-1$
|
|
271 return;
|
|
272 }
|
|
273 prefix = prefixProvider.getPrefix(decoration.getControl());
|
|
274 if (prefix is null)
|
|
275 // make a prefix anyway
|
|
276 prefix = ""; //$NON-NLS-1$
|
|
277 }
|
|
278
|
|
279 void addAll(ArraySeq!(Object) target) {
|
76
|
280 foreach( o; controlMessages ){
|
|
281 target.append(o);
|
|
282 }
|
75
|
283 }
|
|
284
|
|
285 void addMessage(Object key, String text, Object data, int type) {
|
|
286 Message message = this.outer.addMessage(getPrefix(), key,
|
|
287 text, data, type, controlMessages);
|
|
288 message.control = decoration.getControl();
|
|
289 if (isAutoUpdate())
|
|
290 update();
|
|
291 }
|
|
292
|
|
293 bool removeMessage(Object key) {
|
|
294 Message message = findMessage(key, controlMessages);
|
|
295 if (message !is null) {
|
|
296 controlMessages.remove(message);
|
|
297 if (isAutoUpdate())
|
|
298 update();
|
|
299 }
|
|
300 return message !is null;
|
|
301 }
|
|
302
|
|
303 bool removeMessages() {
|
76
|
304 if (controlMessages.drained())
|
75
|
305 return false;
|
|
306 controlMessages.clear();
|
|
307 if (isAutoUpdate())
|
|
308 update();
|
|
309 return true;
|
|
310 }
|
|
311
|
|
312 public void update() {
|
76
|
313 if (controlMessages.drained()) {
|
75
|
314 decoration.setDescriptionText(null);
|
|
315 decoration.hide();
|
|
316 } else {
|
|
317 auto peers = createPeers(controlMessages);
|
|
318 int type = (cast(IMessage) peers.get(0)).getMessageType();
|
|
319 String description = createDetails(createPeers(peers), true);
|
|
320 if (type is IMessageProvider.ERROR)
|
|
321 decoration.setImage(standardError.getImage());
|
|
322 else if (type is IMessageProvider.WARNING)
|
|
323 decoration.setImage(standardWarning.getImage());
|
|
324 else if (type is IMessageProvider.INFORMATION)
|
|
325 decoration.setImage(standardInformation.getImage());
|
|
326 decoration.setDescriptionText(description);
|
|
327 decoration.show();
|
|
328 }
|
|
329 }
|
|
330 }
|
|
331
|
|
332 /**
|
|
333 * Creates a new instance of the message manager that will work with the
|
|
334 * provided form.
|
|
335 *
|
|
336 * @param scrolledForm
|
|
337 * the form to control
|
|
338 */
|
|
339 public this(ScrolledForm scrolledForm) {
|
|
340 prefixProvider = DEFAULT_PREFIX_PROVIDER;
|
|
341 messages = new ArraySeq!(Object);
|
|
342 decorators = new HashMap!(Object,Object);
|
|
343 this.scrolledForm = scrolledForm;
|
|
344 }
|
|
345
|
|
346 /*
|
|
347 * (non-Javadoc)
|
|
348 *
|
|
349 * @see dwtx.ui.forms.IMessageManager#addMessage(java.lang.Object,
|
|
350 * java.lang.String, int)
|
|
351 */
|
|
352 public void addMessage(Object key, String messageText, Object data, int type) {
|
|
353 addMessage(null, key, messageText, data, type, messages);
|
|
354 if (isAutoUpdate())
|
|
355 updateForm();
|
|
356 }
|
|
357
|
|
358 /*
|
|
359 * (non-Javadoc)
|
|
360 *
|
|
361 * @see dwtx.ui.forms.IMessageManager#addMessage(java.lang.Object,
|
|
362 * java.lang.String, int, dwt.widgets.Control)
|
|
363 */
|
|
364 public void addMessage(Object key, String messageText, Object data,
|
|
365 int type, Control control) {
|
|
366 ControlDecorator dec = cast(ControlDecorator) decorators.get(control);
|
|
367
|
|
368 if (dec is null) {
|
|
369 dec = new ControlDecorator(control);
|
76
|
370 decorators.add(control, dec);
|
75
|
371 }
|
|
372 dec.addMessage(key, messageText, data, type);
|
|
373 if (isAutoUpdate())
|
|
374 updateForm();
|
|
375 }
|
|
376
|
|
377 /*
|
|
378 * (non-Javadoc)
|
|
379 *
|
|
380 * @see dwtx.ui.forms.IMessageManager#removeMessage(java.lang.Object)
|
|
381 */
|
|
382 public void removeMessage(Object key) {
|
|
383 Message message = findMessage(key, messages);
|
|
384 if (message !is null) {
|
|
385 messages.remove(message);
|
|
386 if (isAutoUpdate())
|
|
387 updateForm();
|
|
388 }
|
|
389 }
|
|
390
|
|
391 /*
|
|
392 * (non-Javadoc)
|
|
393 *
|
|
394 * @see dwtx.ui.forms.IMessageManager#removeMessages()
|
|
395 */
|
|
396 public void removeMessages() {
|
76
|
397 if (!messages.drained()) {
|
75
|
398 messages.clear();
|
|
399 if (isAutoUpdate())
|
|
400 updateForm();
|
|
401 }
|
|
402 }
|
|
403
|
|
404 /*
|
|
405 * (non-Javadoc)
|
|
406 *
|
|
407 * @see dwtx.ui.forms.IMessageManager#removeMessage(java.lang.Object,
|
|
408 * dwt.widgets.Control)
|
|
409 */
|
|
410 public void removeMessage(Object key, Control control) {
|
|
411 ControlDecorator dec = cast(ControlDecorator) decorators.get(control);
|
|
412 if (dec is null)
|
|
413 return;
|
|
414 if (dec.removeMessage(key))
|
|
415 if (isAutoUpdate())
|
|
416 updateForm();
|
|
417 }
|
|
418
|
|
419 /*
|
|
420 * (non-Javadoc)
|
|
421 *
|
|
422 * @see dwtx.ui.forms.IMessageManager#removeMessages(dwt.widgets.Control)
|
|
423 */
|
|
424 public void removeMessages(Control control) {
|
|
425 ControlDecorator dec = cast(ControlDecorator) decorators.get(control);
|
|
426 if (dec !is null) {
|
|
427 if (dec.removeMessages()) {
|
|
428 if (isAutoUpdate())
|
|
429 updateForm();
|
|
430 }
|
|
431 }
|
|
432 }
|
|
433
|
|
434 /*
|
|
435 * (non-Javadoc)
|
|
436 *
|
|
437 * @see dwtx.ui.forms.IMessageManager#removeAllMessages()
|
|
438 */
|
|
439 public void removeAllMessages() {
|
|
440 bool needsUpdate = false;
|
76
|
441 foreach( v; decorators ){
|
|
442 ControlDecorator control = cast(ControlDecorator) v;
|
75
|
443 if (control.removeMessages())
|
|
444 needsUpdate = true;
|
|
445 }
|
76
|
446 if (!messages.drained()) {
|
75
|
447 messages.clear();
|
|
448 needsUpdate = true;
|
|
449 }
|
|
450 if (needsUpdate && isAutoUpdate())
|
|
451 updateForm();
|
|
452 }
|
|
453
|
|
454 /*
|
|
455 * Adds the message if it does not already exist in the provided list.
|
|
456 */
|
|
457
|
|
458 private Message addMessage(String prefix, Object key, String messageText,
|
|
459 Object data, int type, ArraySeq!(Object) list) {
|
|
460 Message message = findMessage(key, list);
|
|
461 if (message is null) {
|
|
462 message = new Message(key, messageText, type, data);
|
|
463 message.prefix = prefix;
|
76
|
464 list.append(message);
|
75
|
465 } else {
|
|
466 message.message = messageText;
|
|
467 message.type = type;
|
|
468 message.data = data;
|
|
469 }
|
|
470 return message;
|
|
471 }
|
|
472
|
|
473 /*
|
|
474 * Finds the message with the provided key in the provided list.
|
|
475 */
|
|
476
|
|
477 private Message findMessage(Object key, ArraySeq!(Object) list) {
|
|
478 for (int i = 0; i < list.size(); i++) {
|
|
479 Message message = cast(Message) list.get(i);
|
76
|
480 if (message.getKey().opEquals(key))
|
75
|
481 return message;
|
|
482 }
|
|
483 return null;
|
|
484 }
|
|
485
|
|
486 /*
|
|
487 * (non-Javadoc)
|
|
488 *
|
|
489 * @see dwtx.ui.forms.IMessageManager#update()
|
|
490 */
|
|
491 public void update() {
|
|
492 // Update decorations
|
76
|
493 foreach( v; decorators ){
|
|
494 ControlDecorator dec = cast(ControlDecorator) v;
|
75
|
495 dec.update();
|
|
496 }
|
|
497 // Update the form
|
|
498 updateForm();
|
|
499 }
|
|
500
|
|
501 /*
|
|
502 * Updates the container by rolling the messages up from the controls.
|
|
503 */
|
|
504
|
|
505 private void updateForm() {
|
76
|
506 ArraySeq!(Object) mergedList = new ArraySeq!(Object);
|
|
507 foreach( o; messages ){
|
|
508 mergedList.append(o);
|
|
509 }
|
|
510 foreach( v; decorators ){
|
|
511 ControlDecorator dec = cast(ControlDecorator) v;
|
75
|
512 dec.addAll(mergedList);
|
|
513 }
|
|
514 update(mergedList);
|
|
515 }
|
|
516
|
|
517 private void update(ArraySeq!(Object) mergedList) {
|
|
518 pruneControlDecorators();
|
76
|
519 if (scrolledForm.getForm().getHead().getBounds().height is 0 || mergedList.drained() || mergedList is null) {
|
75
|
520 scrolledForm.setMessage(null, IMessageProvider.NONE);
|
|
521 return;
|
|
522 }
|
|
523 auto peers = createPeers(mergedList);
|
|
524 int maxType = (cast(IMessage) peers.get(0)).getMessageType();
|
|
525 String messageText;
|
|
526 IMessage[] array = arraycast!(IMessage)( peers
|
|
527 .toArray());
|
|
528 if (peers.size() is 1 && (cast(Message) peers.get(0)).prefix is null) {
|
|
529 // a single message
|
|
530 IMessage message = cast(IMessage) peers.get(0);
|
|
531 messageText = message.getMessage();
|
|
532 scrolledForm.setMessage(messageText, maxType, array);
|
|
533 } else {
|
|
534 // show a summary message for the message
|
|
535 // and list of errors for the details
|
|
536 if (peers.size() > 1)
|
|
537 messageText = Messages.bind(
|
|
538 MULTIPLE_MESSAGE_SUMMARY_KEYS[maxType],
|
|
539 [ to!(String)(peers.size()) ]); //$NON-NLS-1$
|
|
540 else
|
|
541 messageText = SINGLE_MESSAGE_SUMMARY_KEYS[maxType];
|
|
542 scrolledForm.setMessage(messageText, maxType, array);
|
|
543 }
|
|
544 }
|
|
545
|
|
546 private static String getFullMessage(IMessage message) {
|
|
547 if (message.getPrefix() is null)
|
|
548 return message.getMessage();
|
76
|
549 return message.getPrefix() ~ message.getMessage();
|
75
|
550 }
|
|
551
|
76
|
552 private ArraySeq!(Object) createPeers(ArraySeq!(Object) messages) {
|
|
553 auto peers = new ArraySeq!(Object);
|
75
|
554 int maxType = 0;
|
76
|
555 foreach( o; messages ){
|
|
556 auto message = cast(Message)o;
|
75
|
557 if (message.type > maxType) {
|
|
558 peers.clear();
|
|
559 maxType = message.type;
|
|
560 }
|
|
561 if (message.type is maxType)
|
|
562 peers.append(message);
|
|
563 }
|
|
564 return peers;
|
|
565 }
|
|
566
|
|
567 private String createDetails(ArraySeq!(Object) messages, bool excludePrefix) {
|
76
|
568 auto txt = new tango.text.Text.Text!(char);
|
75
|
569
|
|
570 for (int i = 0; i < messages.size(); i++) {
|
|
571 if (i > 0)
|
76
|
572 txt.append( FileConst.NewlineString );
|
75
|
573 IMessage m = cast(IMessage) messages.get(i);
|
76
|
574 txt.append(excludePrefix ? m.getMessage() : getFullMessage(m));
|
75
|
575 }
|
76
|
576 return txt.toString();
|
75
|
577 }
|
|
578
|
|
579 public static String createDetails(IMessage[] messages) {
|
|
580 if (messages is null || messages.length is 0)
|
|
581 return null;
|
76
|
582 auto txt = new tango.text.Text.Text!(char);
|
75
|
583
|
|
584 for (int i = 0; i < messages.length; i++) {
|
|
585 if (i > 0)
|
76
|
586 txt.append( FileConst.NewlineString );
|
|
587 txt.append(getFullMessage(messages[i]));
|
75
|
588 }
|
76
|
589 return txt.toString();
|
75
|
590 }
|
|
591
|
|
592 /*
|
|
593 * (non-Javadoc)
|
|
594 *
|
|
595 * @see dwtx.ui.forms.IMessageManager#createSummary(dwtx.ui.forms.IMessage[])
|
|
596 */
|
|
597 public String createSummary(IMessage[] messages) {
|
|
598 return createDetails(messages);
|
|
599 }
|
|
600
|
|
601 private void pruneControlDecorators() {
|
76
|
602 foreach( o; decorators.dup ){
|
|
603 ControlDecorator dec = cast(ControlDecorator) o;
|
75
|
604 if (dec.isDisposed())
|
76
|
605 decorators.remove(o);
|
75
|
606 }
|
|
607 }
|
|
608
|
|
609 /*
|
|
610 * (non-Javadoc)
|
|
611 *
|
|
612 * @see dwtx.ui.forms.IMessageManager#getMessagePrefixProvider()
|
|
613 */
|
|
614 public IMessagePrefixProvider getMessagePrefixProvider() {
|
|
615 return prefixProvider;
|
|
616 }
|
|
617
|
|
618 /*
|
|
619 * (non-Javadoc)
|
|
620 *
|
|
621 * @see dwtx.ui.forms.IMessageManager#setMessagePrefixProvider(dwtx.ui.forms.IMessagePrefixProvider)
|
|
622 */
|
|
623 public void setMessagePrefixProvider(IMessagePrefixProvider provider) {
|
|
624 this.prefixProvider = provider;
|
76
|
625 foreach( o; decorators ){
|
|
626 ControlDecorator dec = cast(ControlDecorator) o;
|
75
|
627 dec.updatePrefix();
|
|
628 }
|
|
629 }
|
|
630
|
|
631 /*
|
|
632 * (non-Javadoc)
|
|
633 *
|
|
634 * @see dwtx.ui.forms.IMessageManager#getDecorationPosition()
|
|
635 */
|
|
636 public int getDecorationPosition() {
|
|
637 return decorationPosition;
|
|
638 }
|
|
639
|
|
640 /*
|
|
641 * (non-Javadoc)
|
|
642 *
|
|
643 * @see dwtx.ui.forms.IMessageManager#setDecorationPosition(int)
|
|
644 */
|
|
645 public void setDecorationPosition(int position) {
|
|
646 this.decorationPosition = position;
|
76
|
647 foreach( o; decorators ){
|
|
648 ControlDecorator dec = cast(ControlDecorator) o;
|
75
|
649 dec.updatePosition();
|
|
650 }
|
|
651 }
|
|
652
|
|
653 /*
|
|
654 * (non-Javadoc)
|
|
655 *
|
|
656 * @see dwtx.ui.forms.IMessageManager#isAutoUpdate()
|
|
657 */
|
|
658 public bool isAutoUpdate() {
|
|
659 return autoUpdate;
|
|
660 }
|
|
661
|
|
662 /*
|
|
663 * (non-Javadoc)
|
|
664 *
|
|
665 * @see dwtx.ui.forms.IMessageManager#setAutoUpdate(bool)
|
|
666 */
|
|
667 public void setAutoUpdate(bool autoUpdate) {
|
|
668 bool needsUpdate = !this.autoUpdate && autoUpdate;
|
|
669 this.autoUpdate = autoUpdate;
|
|
670 if (needsUpdate)
|
|
671 update();
|
|
672 }
|
|
673 }
|