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