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