75
|
1 /*******************************************************************************
|
|
2 * Copyright (c) 2000, 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 module dwtx.ui.forms.widgets.Form;
|
|
14
|
|
15 import dwtx.ui.forms.widgets.SizeCache;
|
|
16 import dwtx.ui.forms.widgets.FormText;
|
|
17 import dwtx.ui.forms.widgets.ILayoutExtension;
|
|
18 import dwtx.ui.forms.widgets.LayoutComposite;
|
|
19
|
|
20 import dwt.DWT;
|
|
21 import dwt.dnd.DragSourceListener;
|
|
22 import dwt.dnd.DropTargetListener;
|
|
23 import dwt.dnd.Transfer;
|
|
24 import dwt.graphics.Color;
|
|
25 import dwt.graphics.Font;
|
|
26 import dwt.graphics.Image;
|
|
27 import dwt.graphics.Point;
|
|
28 import dwt.graphics.Rectangle;
|
|
29 import dwt.widgets.Composite;
|
|
30 import dwt.widgets.Control;
|
|
31 import dwt.widgets.Layout;
|
|
32 import dwt.widgets.Menu;
|
|
33 import dwtx.jface.action.IMenuManager;
|
|
34 import dwtx.jface.action.IToolBarManager;
|
|
35 import dwtx.ui.forms.IFormColors;
|
|
36 import dwtx.ui.forms.IMessage;
|
|
37 import dwtx.ui.forms.events.IHyperlinkListener;
|
|
38 import dwtx.ui.internal.forms.widgets.FormHeading;
|
|
39 import dwtx.ui.internal.forms.widgets.FormUtil;
|
|
40
|
|
41 import dwt.dwthelper.utils;
|
|
42
|
|
43 /**
|
|
44 * Form is a custom control that renders a title and an optional background
|
|
45 * image above the body composite. It can be used alone when part of parents
|
|
46 * that are scrolled. If scrolling is required, use <code>ScrolledForm</code>
|
|
47 * instead because it has an instance of <code>Form</code> and adds scrolling
|
|
48 * capability.
|
|
49 * <p>
|
|
50 * Form can have a title if set. If not set, title area will not be left empty -
|
|
51 * form body will be resized to fill the entire form. In addition, an optional
|
|
52 * title image can be set and is rendered to the left of the title (since 3.2).
|
|
53 * <p>
|
|
54 * Form can have a title drop down menu if the menu bar manager is not empty
|
|
55 * (since 3.3).
|
|
56 * <p>
|
|
57 * Form title can support drag and drop if drag and drop support methods are
|
|
58 * invoked. When used, additional decoration is rendered behind the title to
|
|
59 * reinforce the drag and drop ability (since 3.3).
|
|
60 * <p>
|
|
61 * The form supports status messages. These messages can have various severity
|
|
62 * (error, warning, info or none). If status hyperlink handler is specified, the
|
|
63 * messages with the specified severity other than none will be rendered as
|
|
64 * hyperlinks.
|
|
65 * <p>
|
|
66 * Form can have a background image behind the title text. The image is tiled as
|
|
67 * many times as needed to fill the title area. Alternatively, gradient
|
|
68 * background can be painted vertically or horizontally.
|
|
69 * <p>
|
|
70 * Form can be put in a 'busy' state. While in this state, title image is
|
|
71 * replaced with an animation that lasts as long as the 'busy' state is active.
|
|
72 * <p>
|
|
73 * It is possible to create an optional head client control. When created, this
|
|
74 * control is placed in the form heading as a second row.
|
|
75 * <p>
|
|
76 * Form has a custom layout manager that is wrap-enabled. If a form is placed in
|
|
77 * a composite whose layout manager implements ILayoutExtension, the body of the
|
|
78 * form will participate in wrapping as long as its layout manager implements
|
|
79 * ILayoutExtension as well.
|
|
80 * <p>
|
|
81 * Children of the form should typically be created using FormToolkit to match
|
|
82 * the appearance and behaviour. When creating children, use the form body as a
|
|
83 * parent by calling 'getBody()' on the form instance. Example:
|
|
84 *
|
|
85 * <pre>
|
|
86 * FormToolkit toolkit = new FormToolkit(parent.getDisplay());
|
|
87 * Form form = toolkit.createForm(parent);
|
|
88 * form.setText("Sample form");
|
|
89 * form.getBody().setLayout(new GridLayout());
|
|
90 * toolkit.createButton(form.getBody(), "Checkbox", DWT.CHECK);
|
|
91 * </pre>
|
|
92 *
|
|
93 * <p>
|
|
94 * No layout manager has been set on the body. Clients are required to set the
|
|
95 * desired layout manager explicitly.
|
|
96 * <p>
|
|
97 * Although the class is not final, it should not be subclassed.
|
|
98 *
|
|
99 * @since 3.0
|
90
|
100 * @noextend This class is not intended to be subclassed by clients.
|
75
|
101 */
|
|
102 public class Form : Composite {
|
|
103 private FormHeading head;
|
|
104
|
|
105 private Composite body_;
|
|
106
|
|
107 private SizeCache body_Cache;
|
|
108
|
|
109 private SizeCache headCache;
|
|
110
|
|
111 private FormText selectionText;
|
|
112
|
|
113 private class FormLayout : Layout, ILayoutExtension {
|
|
114 public int computeMinimumWidth(Composite composite, bool flushCache) {
|
|
115 return computeSize(composite, 5, DWT.DEFAULT, flushCache).x;
|
|
116 }
|
|
117
|
|
118 public int computeMaximumWidth(Composite composite, bool flushCache) {
|
|
119 return computeSize(composite, DWT.DEFAULT, DWT.DEFAULT, flushCache).x;
|
|
120 }
|
|
121
|
|
122 public Point computeSize(Composite composite, int wHint, int hHint,
|
|
123 bool flushCache) {
|
|
124 if (flushCache) {
|
|
125 body_Cache.flush();
|
|
126 headCache.flush();
|
|
127 }
|
|
128 body_Cache.setControl(body_);
|
|
129 headCache.setControl(head);
|
|
130
|
|
131 int width = 0;
|
|
132 int height = 0;
|
|
133
|
|
134 Point hsize = headCache.computeSize(FormUtil.getWidthHint(wHint,
|
|
135 head), DWT.DEFAULT);
|
|
136 width = Math.max(hsize.x, width);
|
|
137 height = hsize.y;
|
|
138
|
|
139 bool ignoreBody=getData(FormUtil.IGNORE_BODY) !is null;
|
|
140
|
|
141 Point bsize;
|
|
142 if (ignoreBody)
|
|
143 bsize = new Point(0,0);
|
|
144 else
|
|
145 bsize = body_Cache.computeSize(FormUtil.getWidthHint(wHint,
|
|
146 body_), DWT.DEFAULT);
|
|
147 width = Math.max(bsize.x, width);
|
|
148 height += bsize.y;
|
|
149 return new Point(width, height);
|
|
150 }
|
|
151
|
|
152 protected void layout(Composite composite, bool flushCache) {
|
|
153 if (flushCache) {
|
|
154 body_Cache.flush();
|
|
155 headCache.flush();
|
|
156 }
|
|
157 body_Cache.setControl(body_);
|
|
158 headCache.setControl(head);
|
|
159 Rectangle carea = composite.getClientArea();
|
|
160
|
|
161 Point hsize = headCache.computeSize(carea.width, DWT.DEFAULT);
|
|
162 headCache.setBounds(0, 0, carea.width, hsize.y);
|
|
163 body_Cache
|
|
164 .setBounds(0, hsize.y, carea.width, carea.height - hsize.y);
|
|
165 }
|
|
166 }
|
|
167
|
|
168 /**
|
|
169 * Creates the form content control as a child of the provided parent.
|
|
170 *
|
|
171 * @param parent
|
|
172 * the parent widget
|
|
173 */
|
|
174 public this(Composite parent, int style) {
|
|
175
|
|
176 body_Cache = new SizeCache();
|
|
177 headCache = new SizeCache();
|
|
178
|
|
179 super(parent, DWT.NO_BACKGROUND | style);
|
|
180 super.setLayout(new FormLayout());
|
|
181 head = new FormHeading(this, DWT.NULL);
|
|
182 head.setMenu(parent.getMenu());
|
|
183 body_ = new LayoutComposite(this, DWT.NULL);
|
|
184 body_.setMenu(parent.getMenu());
|
|
185 }
|
|
186
|
|
187 /**
|
|
188 * Passes the menu to the form body.
|
|
189 *
|
|
190 * @param menu
|
|
191 * the parent menu
|
|
192 */
|
|
193 public void setMenu(Menu menu) {
|
|
194 super.setMenu(menu);
|
|
195 head.setMenu(menu);
|
|
196 body_.setMenu(menu);
|
|
197 }
|
|
198
|
|
199 /**
|
|
200 * Fully delegates the size computation to the internal layout manager.
|
|
201 */
|
|
202 public final Point computeSize(int wHint, int hHint, bool changed) {
|
|
203 return (cast(FormLayout) getLayout()).computeSize(this, wHint, hHint,
|
|
204 changed);
|
|
205 }
|
|
206
|
|
207 /**
|
|
208 * Prevents from changing the custom control layout.
|
|
209 */
|
|
210 public final void setLayout(Layout layout) {
|
|
211 }
|
|
212
|
|
213 /**
|
|
214 * Returns the title text that will be rendered at the top of the form.
|
|
215 *
|
|
216 * @return the title text
|
|
217 */
|
|
218 public String getText() {
|
|
219 return head.getText();
|
|
220 }
|
|
221
|
|
222 /**
|
|
223 * Returns the title image that will be rendered to the left of the title.
|
|
224 *
|
|
225 * @return the title image or <code>null</code> if not set.
|
|
226 * @since 3.2
|
|
227 */
|
|
228 public Image getImage() {
|
|
229 return head.getImage();
|
|
230 }
|
|
231
|
|
232 /**
|
|
233 * Sets the foreground color of the form. This color will also be used for
|
|
234 * the body.
|
|
235 *
|
|
236 * @param fg
|
|
237 * the foreground color
|
|
238 */
|
|
239 public void setForeground(Color fg) {
|
|
240 super.setForeground(fg);
|
|
241 head.setForeground(fg);
|
|
242 body_.setForeground(fg);
|
|
243 }
|
|
244
|
|
245 /**
|
|
246 * Sets the background color of the form. This color will also be used for
|
|
247 * the body.
|
|
248 *
|
|
249 * @param bg
|
|
250 * the background color
|
|
251 */
|
|
252 public void setBackground(Color bg) {
|
|
253 super.setBackground(bg);
|
|
254 head.setBackground(bg);
|
|
255 body_.setBackground(bg);
|
|
256 }
|
|
257
|
|
258 /**
|
|
259 * Sets the font of the header text.
|
|
260 *
|
|
261 * @param font
|
|
262 * the new font
|
|
263 */
|
|
264 public void setFont(Font font) {
|
|
265 super.setFont(font);
|
|
266 head.setFont(font);
|
|
267 }
|
|
268
|
|
269 /**
|
|
270 * Sets the text to be rendered at the top of the form above the body as a
|
|
271 * title.
|
|
272 * <p>
|
|
273 * <strong>Note:</strong> Mnemonics are indicated by an '&' that causes
|
|
274 * the next character to be the mnemonic. Mnemonics are not applicable in
|
|
275 * the case of the form title but need to be taken into acount due to the
|
|
276 * usage of the underlying widget that renders mnemonics in the title area.
|
|
277 * The mnemonic indicator character '&' can be escaped by doubling it in
|
|
278 * the string, causing a single '&' to be displayed.
|
|
279 * </p>
|
|
280 *
|
|
281 * @param text
|
|
282 * the title text
|
|
283 */
|
|
284 public void setText(String text) {
|
|
285 head.setText(text);
|
|
286 layout();
|
|
287 redraw();
|
|
288 }
|
|
289
|
|
290 /**
|
|
291 * Sets the image to be rendered to the left of the title. This image will
|
|
292 * be temporarily hidden in two cases:
|
|
293 *
|
|
294 * <ol>
|
|
295 * <li>When the form is busy - replaced with a busy animation</li>
|
|
296 * <li>When the form has message set - replaced with the image indicating
|
|
297 * message severity</li>
|
|
298 * </ol>
|
|
299 *
|
|
300 * @param image
|
|
301 * the title image or <code>null</code> to show no image.
|
|
302 * @since 3.2
|
|
303 */
|
|
304 public void setImage(Image image) {
|
|
305 head.setImage(image);
|
|
306 layout();
|
|
307 redraw();
|
|
308 }
|
|
309
|
|
310 /**
|
|
311 * Sets the background colors to be painted behind the title text in a
|
|
312 * gradient. Note that this method will reset color previously set by
|
|
313 * {@link #setBackground(Color)}. This is necessary for the simulated
|
|
314 * transparency of the heading in all of its children control.
|
|
315 *
|
|
316 * @param gradientColors
|
|
317 * the array of colors that form the gradient
|
|
318 * @param percents
|
|
319 * the partition of the overall space between the gradient colors
|
|
320 * @param vertical
|
|
321 * of <code>true</code>, the gradient will be rendered
|
|
322 * vertically, if <code>false</code> the orientation will be
|
|
323 * horizontal.
|
|
324 */
|
|
325
|
|
326 public void setTextBackground(Color[] gradientColors, int[] percents,
|
|
327 bool vertical) {
|
|
328 head.setTextBackground(gradientColors, percents, vertical);
|
|
329 }
|
|
330
|
|
331 /**
|
|
332 * Returns the optional background image of the form head.
|
|
333 *
|
|
334 * @return the background image or <code>null</code> if not specified.
|
|
335 */
|
|
336 public Image getBackgroundImage() {
|
|
337 return head.getHeadingBackgroundImage();
|
|
338 }
|
|
339
|
|
340 /**
|
|
341 * Sets the optional background image to be rendered behind the title
|
|
342 * starting at the position 0,0. If the image is smaller than the container
|
|
343 * in any dimension, it will be tiled.
|
|
344 *
|
|
345 * @since 3.2
|
|
346 *
|
|
347 * @param backgroundImage
|
|
348 * the head background image.
|
|
349 *
|
|
350 */
|
|
351 public void setBackgroundImage(Image backgroundImage) {
|
|
352 head.setHeadingBackgroundImage(backgroundImage);
|
|
353 }
|
|
354
|
|
355 /**
|
|
356 * Returns the tool bar manager that is used to manage tool items in the
|
|
357 * form's title area.
|
|
358 *
|
|
359 * @return form tool bar manager
|
|
360 */
|
|
361 public IToolBarManager getToolBarManager() {
|
|
362 return head.getToolBarManager();
|
|
363 }
|
|
364
|
|
365 /**
|
|
366 * Sets the tool bar vertical alignment relative to the header. Can be
|
|
367 * useful when there is more free space at the second row (with the head
|
|
368 * client).
|
|
369 *
|
|
370 * @param alignment
|
|
371 * DWT.TOP or DWT.BOTTOM
|
|
372 * @since 3.3
|
|
373 */
|
|
374
|
|
375 public void setToolBarVerticalAlignment(int alignment) {
|
|
376 head.setToolBarAlignment(alignment);
|
|
377 }
|
|
378
|
|
379 /**
|
|
380 * Returns the current tool bar alignment (if used).
|
|
381 *
|
|
382 * @return DWT.TOP or DWT.BOTTOM
|
|
383 * @since 3.3
|
|
384 */
|
|
385
|
|
386 public int getToolBarVerticalAlignment() {
|
|
387 return head.getToolBarAlignment();
|
|
388 }
|
|
389
|
|
390 /**
|
|
391 * Returns the menu manager that is used to manage title area drop-down menu
|
|
392 * items.
|
|
393 *
|
|
394 * @return title area drop-down menu manager
|
|
395 * @since 3.3
|
|
396 */
|
|
397 public IMenuManager getMenuManager() {
|
|
398 return head.getMenuManager();
|
|
399 }
|
|
400
|
|
401 /**
|
|
402 * Updates the local tool bar manager if used. Does nothing if local tool
|
|
403 * bar manager has not been created yet.
|
|
404 */
|
|
405 public void updateToolBar() {
|
|
406 head.updateToolBar();
|
|
407 }
|
|
408
|
|
409 /**
|
|
410 * Returns the container that occupies the head of the form (the form area
|
|
411 * above the body). Use this container as a parent for the head client.
|
|
412 *
|
|
413 * @return the head of the form.
|
|
414 * @since 3.2
|
|
415 */
|
|
416 public Composite getHead() {
|
|
417 return head;
|
|
418 }
|
|
419
|
|
420 /**
|
|
421 * Returns the optional head client if set.
|
|
422 *
|
|
423 * @return the head client or <code>null</code> if not set.
|
|
424 * @see #setHeadClient(Control)
|
|
425 * @since 3.2
|
|
426 */
|
|
427 public Control getHeadClient() {
|
|
428 return head.getHeadClient();
|
|
429 }
|
|
430
|
|
431 /**
|
|
432 * Sets the optional head client. Head client is placed after the form
|
|
433 * title. This option causes the tool bar to be placed in the second raw of
|
|
434 * the header (below the head client).
|
|
435 * <p>
|
|
436 * The head client must be a child of the composite returned by
|
|
437 * <code>getHead()</code> method.
|
|
438 *
|
|
439 * @param headClient
|
|
440 * the optional child of the head
|
|
441 * @since 3.2
|
|
442 */
|
|
443 public void setHeadClient(Control headClient) {
|
|
444 head.setHeadClient(headClient);
|
|
445 layout();
|
|
446 }
|
|
447
|
|
448 /**
|
|
449 * Returns the container that occupies the body of the form (the form area
|
|
450 * below the title). Use this container as a parent for the controls that
|
|
451 * should be in the form. No layout manager has been set on the form body.
|
|
452 *
|
|
453 * @return Returns the body of the form.
|
|
454 */
|
|
455 public Composite getBody() {
|
|
456 return body_;
|
|
457 }
|
|
458
|
|
459 /**
|
|
460 * Tests if the background image is tiled to cover the entire area of the
|
|
461 * form heading.
|
|
462 *
|
|
463 * @return <code>true</code> if heading background image is tiled,
|
|
464 * <code>false</code> otherwise.
|
|
465 */
|
|
466 public bool isBackgroundImageTiled() {
|
|
467 return head.isBackgroundImageTiled();
|
|
468 }
|
|
469
|
|
470 /**
|
|
471 * Sets whether the header background image is repeated to cover the entire
|
|
472 * heading area or not.
|
|
473 *
|
|
474 * @param backgroundImageTiled
|
|
475 * set <code>true</code> to tile the image, or
|
|
476 * <code>false</code> to paint the background image only once
|
|
477 * at 0,0
|
|
478 */
|
|
479 public void setBackgroundImageTiled(bool backgroundImageTiled) {
|
|
480 head.setBackgroundImageTiled(backgroundImageTiled);
|
|
481 }
|
|
482
|
|
483 /**
|
|
484 * Returns the background image alignment.
|
|
485 *
|
|
486 * @deprecated due to the underlying widget limitations, background image is
|
|
487 * either painted at 0,0 and/or tiled.
|
|
488 * @return DWT.LEFT
|
|
489 */
|
|
490 public int getBackgroundImageAlignment() {
|
|
491 return DWT.LEFT;
|
|
492 }
|
|
493
|
|
494 /**
|
|
495 * Sets the background image alignment.
|
|
496 *
|
|
497 * @deprecated due to the underlying widget limitations, background image is
|
|
498 * always tiled and alignment cannot be controlled.
|
|
499 * @param backgroundImageAlignment
|
|
500 * The backgroundImageAlignment to set.
|
|
501 * @since 3.1
|
|
502 */
|
|
503 public void setBackgroundImageAlignment(int backgroundImageAlignment) {
|
|
504 }
|
|
505
|
|
506 /**
|
|
507 * Tests if background image is clipped.
|
|
508 *
|
|
509 * @deprecated due to the underlying widget limitations, background image is
|
|
510 * always clipped.
|
|
511 * @return true
|
|
512 * @since 3.1
|
|
513 */
|
|
514 public bool isBackgroundImageClipped() {
|
|
515 return true;
|
|
516 }
|
|
517
|
|
518 /**
|
|
519 * Sets whether the background image is clipped.
|
|
520 *
|
|
521 * @deprecated due to the underlying widget limitations, background image is
|
|
522 * always clipped.
|
|
523 * @param backgroundImageClipped
|
|
524 * the value to set
|
|
525 * @since 3.1
|
|
526 */
|
|
527 public void setBackgroundImageClipped(bool backgroundImageClipped) {
|
|
528 }
|
|
529
|
|
530 /**
|
|
531 * Tests if the form head separator is visible.
|
|
532 *
|
|
533 * @return <code>true</code> if the head/body separator is visible,
|
|
534 * <code>false</code> otherwise
|
|
535 * @since 3.2
|
|
536 */
|
|
537 public bool isSeparatorVisible() {
|
|
538 return head.isSeparatorVisible();
|
|
539 }
|
|
540
|
|
541 /**
|
|
542 * If set, adds a separator between the head and body. Since 3.3, the colors
|
|
543 * that are used to render it are {@link IFormColors#H_BOTTOM_KEYLINE1} and
|
|
544 * {@link IFormColors#H_BOTTOM_KEYLINE2}.
|
|
545 *
|
|
546 * @param addSeparator
|
|
547 * <code>true</code> to make the separator visible,
|
|
548 * <code>false</code> otherwise.
|
|
549 * @since 3.2
|
|
550 */
|
|
551 public void setSeparatorVisible(bool addSeparator) {
|
|
552 head.setSeparatorVisible(addSeparator);
|
|
553 }
|
|
554
|
|
555 /**
|
|
556 * Returns the color used to render the optional head separator. If gradient
|
|
557 * text background is used additional colors from the gradient will be used
|
|
558 * to render the separator.
|
|
559 *
|
|
560 * @return separator color or <code>null</code> if not set.
|
|
561 * @since 3.2
|
|
562 * @deprecated use <code>getHeadColor(IFormColors.H_BOTTOM_KEYLINE2)</code>
|
|
563 */
|
|
564
|
|
565 public Color getSeparatorColor() {
|
|
566 return head.getColor(IFormColors.H_BOTTOM_KEYLINE2);
|
|
567 }
|
|
568
|
|
569 /**
|
|
570 * Sets the color to be used to render the optional head separator.
|
|
571 *
|
|
572 * @param separatorColor
|
|
573 * the color to render the head separator or <code>null</code>
|
|
574 * to use the default color.
|
|
575 * @since 3.2
|
|
576 * @deprecated use
|
|
577 * <code>setHeadColor(IFormColors.H_BOTTOM_KEYLINE2, separatorColor)</code>
|
|
578 */
|
|
579 public void setSeparatorColor(Color separatorColor) {
|
|
580 head.putColor(IFormColors.H_BOTTOM_KEYLINE2, separatorColor);
|
|
581 }
|
|
582
|
|
583 /**
|
|
584 * Sets the color used to paint an aspect of the form heading.
|
|
585 *
|
|
586 * @param key
|
|
587 * a valid form heading color key as defined in
|
|
588 * {@link IFormColors}. Relevant keys all start with an H_
|
|
589 * prefix.
|
|
590 * @param color
|
|
591 * the color to use for the provided key
|
|
592 * @since 3.3
|
|
593 */
|
|
594
|
|
595 public void setHeadColor(String key, Color color) {
|
|
596 head.putColor(key, color);
|
|
597 }
|
|
598
|
|
599 /**
|
|
600 * Returns the color that is currently use to paint an aspect of the form
|
|
601 * heading, or <code>null</code> if not defined.
|
|
602 *
|
|
603 * @param key
|
|
604 * the color key
|
|
605 * @return the color object or <code>null</code> if not set.
|
|
606 * @since 3.3
|
|
607 */
|
|
608
|
|
609 public Color getHeadColor(String key) {
|
|
610 return head.getColor(key);
|
|
611 }
|
|
612
|
|
613 /**
|
|
614 * Sets the message for this form. Message text is rendered in the form head
|
|
615 * when shown.
|
|
616 *
|
|
617 * @param message
|
|
618 * the message, or <code>null</code> to clear the message
|
|
619 * @see #setMessage(String, int)
|
|
620 * @since 3.2
|
|
621 */
|
|
622 public void setMessage(String message) {
|
|
623 this.setMessage(message, 0, null);
|
|
624 }
|
|
625
|
|
626 /**
|
|
627 * Sets the message for this form with an indication of what type of message
|
|
628 * it is.
|
|
629 * <p>
|
|
630 * The valid message types are one of <code>NONE</code>,
|
|
631 * <code>INFORMATION</code>,<code>WARNING</code>, or
|
|
632 * <code>ERROR</code> defined in IMessageProvider interface.
|
|
633 * </p>
|
|
634 *
|
|
635 * @param newMessage
|
|
636 * the message, or <code>null</code> to clear the message
|
|
637 * @param newType
|
|
638 * the message type
|
|
639 * @see dwtx.jface.dialogs.IMessageProvider
|
|
640 * @since 3.2
|
|
641 */
|
|
642
|
|
643 public void setMessage(String newMessage, int newType) {
|
|
644 this.setMessage(newMessage, newType, null);
|
|
645 }
|
|
646
|
|
647 /**
|
|
648 * Sets the message for this form with an indication of what type of message
|
|
649 * it is.
|
|
650 * <p>
|
|
651 * The valid message types are one of <code>NONE</code>,
|
|
652 * <code>INFORMATION</code>,<code>WARNING</code>, or
|
|
653 * <code>ERROR</code> defined in IMessageProvider interface.
|
|
654 * </p>
|
|
655 * <p>
|
|
656 * In addition to the summary message, this method also sets an array of
|
|
657 * individual messages.
|
|
658 *
|
|
659 *
|
|
660 * @param newMessage
|
|
661 * the message, or <code>null</code> to clear the message
|
|
662 * @param newType
|
|
663 * the message type
|
|
664 * @param children
|
|
665 * the individual messages that contributed to the overall
|
|
666 * message
|
|
667 * @see dwtx.jface.dialogs.IMessageProvider
|
|
668 * @since 3.3
|
|
669 */
|
|
670
|
|
671 public void setMessage(String newMessage, int newType, IMessage[] children) {
|
|
672 head.showMessage(newMessage, newType, children);
|
|
673 layout();
|
|
674 }
|
|
675
|
|
676 /**
|
|
677 * Adds a message hyperlink listener. If at least one listener is present,
|
|
678 * messages will be rendered as hyperlinks.
|
|
679 *
|
|
680 * @param listener
|
|
681 * @see #removeMessageHyperlinkListener(IHyperlinkListener)
|
|
682 * @since 3.3
|
|
683 */
|
|
684 public void addMessageHyperlinkListener(IHyperlinkListener listener) {
|
|
685 head.addMessageHyperlinkListener(listener);
|
|
686 }
|
|
687
|
|
688 /**
|
|
689 * Remove the message hyperlink listener.
|
|
690 *
|
|
691 * @param listener
|
|
692 * @see #addMessageHyperlinkListener(IHyperlinkListener)
|
|
693 * @since 3.3
|
|
694 */
|
|
695 public void removeMessageHyperlinkListener(IHyperlinkListener listener) {
|
|
696 head.removeMessageHyperlinkListener(listener);
|
|
697 }
|
|
698
|
|
699 /**
|
|
700 * Tests if the form is in the 'busy' state. Busy form displays 'busy'
|
|
701 * animation in the area of the title image.
|
|
702 *
|
|
703 * @return <code>true</code> if busy, <code>false</code> otherwise.
|
|
704 * @since 3.2
|
|
705 */
|
|
706
|
|
707 public bool isBusy() {
|
|
708 return head.isBusy();
|
|
709 }
|
|
710
|
|
711 /**
|
|
712 * Sets the form's busy state. Busy form will display 'busy' animation in
|
|
713 * the area of the title image.
|
|
714 *
|
|
715 * @param busy
|
|
716 * the form's busy state
|
|
717 * @since 3.2
|
|
718 */
|
|
719
|
|
720 public void setBusy(bool busy) {
|
|
721 head.setBusy(busy);
|
|
722 }
|
|
723
|
|
724 /**
|
|
725 * Adds support for dragging items out of the form title area via a user
|
|
726 * drag-and-drop operation.
|
|
727 *
|
|
728 * @param operations
|
|
729 * a bitwise OR of the supported drag and drop operation types (
|
|
730 * <code>DROP_COPY</code>,<code>DROP_LINK</code>, and
|
|
731 * <code>DROP_MOVE</code>)
|
|
732 * @param transferTypes
|
|
733 * the transfer types that are supported by the drag operation
|
|
734 * @param listener
|
|
735 * the callback that will be invoked to set the drag data and to
|
|
736 * cleanup after the drag and drop operation finishes
|
|
737 * @see dwt.dnd.DND
|
|
738 * @since 3.3
|
|
739 */
|
|
740 public void addTitleDragSupport(int operations, Transfer[] transferTypes,
|
|
741 DragSourceListener listener) {
|
|
742 head.addDragSupport(operations, transferTypes, listener);
|
|
743 }
|
|
744
|
|
745 /**
|
|
746 * Adds support for dropping items into the form title area via a user
|
|
747 * drag-and-drop operation.
|
|
748 *
|
|
749 * @param operations
|
|
750 * a bitwise OR of the supported drag and drop operation types (
|
|
751 * <code>DROP_COPY</code>,<code>DROP_LINK</code>, and
|
|
752 * <code>DROP_MOVE</code>)
|
|
753 * @param transferTypes
|
|
754 * the transfer types that are supported by the drop operation
|
|
755 * @param listener
|
|
756 * the callback that will be invoked after the drag and drop
|
|
757 * operation finishes
|
|
758 * @see dwt.dnd.DND
|
|
759 * @since 3.3
|
|
760 */
|
|
761 public void addTitleDropSupport(int operations, Transfer[] transferTypes,
|
|
762 DropTargetListener listener) {
|
|
763 head.addDropSupport(operations, transferTypes, listener);
|
|
764 }
|
|
765
|
|
766 /*
|
|
767 * (non-Javadoc)
|
|
768 *
|
|
769 * @see dwtx.jface.dialogs.IMessageProvider#getMessage()
|
|
770 */
|
|
771 public String getMessage() {
|
|
772 return head.getMessage();
|
|
773 }
|
|
774
|
|
775 /*
|
|
776 * (non-Javadoc)
|
|
777 *
|
|
778 * @see dwtx.jface.dialogs.IMessageProvider#getMessageType()
|
|
779 */
|
|
780 public int getMessageType() {
|
|
781 return head.getMessageType();
|
|
782 }
|
|
783
|
|
784 /**
|
|
785 * Returns the children messages that the cause of the summary message
|
|
786 * currently set on the form.
|
|
787 *
|
|
788 * @return an array of children messages or <code>null</code> if not set.
|
|
789 * @see #setMessage(String, int, IMessage[])
|
|
790 * @since 3.3
|
|
791 */
|
|
792 public IMessage[] getChildrenMessages() {
|
|
793 return head.getChildrenMessages();
|
|
794 }
|
|
795
|
|
796 void setSelectionText(FormText text) {
|
|
797 if (selectionText !is null && selectionText !is text) {
|
|
798 selectionText.clearSelection();
|
|
799 }
|
|
800 this.selectionText = text;
|
|
801 }
|
|
802 }
|