1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.commons.jelly.tags.swt;
17
18 import java.util.Map;
19
20 import org.apache.commons.jelly.JellyTagException;
21 import org.apache.commons.jelly.XMLOutput;
22 import org.eclipse.swt.widgets.Dialog;
23 import org.eclipse.swt.widgets.Shell;
24 import org.eclipse.swt.widgets.Widget;
25
26 /***
27 * This tag creates an SWT dialog.
28 *
29 * @author <a href="mailto:ckl@dacelo.nl">Christiaan ten Klooster</a>
30 *
31 */
32 public class DialogTag extends WidgetTag {
33
34 /***
35 * @param widgetClass
36 * @param style
37 */
38 public DialogTag(Class widgetClass, int style) {
39 super(widgetClass, style);
40 }
41
42 /***
43 * @param widgetClass
44 */
45 public DialogTag(Class widgetClass) {
46 super(widgetClass);
47 }
48
49
50
51
52 /***
53 * Factory method to create a new dialog
54 */
55 protected Object newInstance(Class theClass, Map attributes, XMLOutput output)
56 throws JellyTagException {
57 int style = getStyle(attributes);
58
59
60 Widget parent = getParentWidget();
61
62 boolean isParentShell = parent instanceof Shell;
63 if (parent == null || !isParentShell) {
64 throw new JellyTagException("This tag must be nested within a Shell");
65 }
66
67 Dialog dialog = (Dialog) createWidget(theClass, parent, style);
68
69 return dialog;
70 }
71
72 }