1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.seasar.uruma.ui.dialogs;
17
18 import org.eclipse.jface.dialogs.InputDialog;
19 import org.eclipse.jface.dialogs.MessageDialog;
20 import org.eclipse.jface.window.Window;
21 import org.seasar.uruma.core.UrumaConstants;
22 import org.seasar.uruma.util.MessageUtil;
23 import org.seasar.uruma.util.ShellUtil;
24
25
26
27
28
29
30
31
32
33 public class UrumaMessageDialog {
34 private static final String TITLE_SUFFIX = "_TITLE";
35
36 private static final String MESSAGE_SUFFIX = "_MSG";
37
38 private UrumaMessageDialog() {
39
40 }
41
42
43
44
45
46
47
48
49
50 public static final void openInformation(final String title,
51 final String msg) {
52 MessageDialog.openInformation(ShellUtil.getShell(), title, msg);
53 }
54
55
56
57
58
59
60
61 public static final void openInformation(final String key) {
62 openInformation(getTitle(key), getMessage(key));
63 }
64
65
66
67
68
69
70
71
72
73 public static final void openError(final String title, final String msg) {
74 MessageDialog.openError(ShellUtil.getShell(), title, msg);
75 }
76
77
78
79
80
81
82
83 public static final void openError(final String key) {
84 openError(getTitle(key), getMessage(key));
85 }
86
87
88
89
90
91
92
93
94
95
96 public static final boolean openConfirm(final String title, final String msg) {
97 return MessageDialog.openConfirm(ShellUtil.getShell(), title, msg);
98 }
99
100
101
102
103
104
105
106
107 public static final boolean openConfirm(final String key) {
108 return openConfirm(getTitle(key), getMessage(key));
109 }
110
111
112
113
114
115
116
117
118
119
120
121
122 public static String openInput(final String title, final String msg,
123 final String initialText) {
124 InputDialog dialog = new InputDialog(ShellUtil.getShell(), title, msg,
125 initialText, null);
126 if (dialog.open() == Window.OK) {
127 return dialog.getValue();
128 } else {
129 return null;
130 }
131 }
132
133
134
135
136
137
138
139
140
141
142 public static String openInput(final String key, final String initialText) {
143 return openInput(getTitle(key), getMessage(key), initialText);
144 }
145
146
147
148
149
150
151
152
153 public static String openInput(final String key) {
154 return openInput(getTitle(key), getMessage(key),
155 UrumaConstants.NULL_STRING);
156 }
157
158 protected static String getTitle(final String bundleKey) {
159 return MessageUtil.getMessage(bundleKey + TITLE_SUFFIX);
160 }
161
162 protected static String getMessage(final String bundleKey) {
163 return MessageUtil.getMessage(bundleKey + MESSAGE_SUFFIX);
164 }
165 }