fiore@0
|
1 /*
|
fiore@0
|
2 CCmI Editor - A Collaborative Cross-Modal Diagram Editing Tool
|
fiore@0
|
3
|
fiore@0
|
4 Copyright (C) 2011 Queen Mary University of London (http://ccmi.eecs.qmul.ac.uk/)
|
fiore@0
|
5
|
fiore@0
|
6 This program is free software: you can redistribute it and/or modify
|
fiore@0
|
7 it under the terms of the GNU General Public License as published by
|
fiore@0
|
8 the Free Software Foundation, either version 3 of the License, or
|
fiore@0
|
9 (at your option) any later version.
|
fiore@0
|
10
|
fiore@0
|
11 This program is distributed in the hope that it will be useful,
|
fiore@0
|
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
|
fiore@0
|
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
fiore@0
|
14 GNU General Public License for more details.
|
fiore@0
|
15
|
fiore@0
|
16 You should have received a copy of the GNU General Public License
|
fiore@0
|
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
|
fiore@0
|
18 */
|
fiore@0
|
19
|
fiore@0
|
20 package uk.ac.qmul.eecs.ccmi.gui;
|
fiore@0
|
21
|
fiore@0
|
22 import java.awt.Color;
|
fiore@0
|
23 import java.awt.Component;
|
fiore@0
|
24 import java.awt.Frame;
|
fiore@0
|
25 import java.awt.GridLayout;
|
fiore@0
|
26 import java.awt.event.InputEvent;
|
fiore@0
|
27 import java.awt.event.KeyEvent;
|
fiore@0
|
28 import java.awt.event.WindowAdapter;
|
fiore@0
|
29 import java.awt.event.WindowEvent;
|
fiore@0
|
30 import java.text.MessageFormat;
|
fiore@0
|
31 import java.util.LinkedHashSet;
|
fiore@0
|
32 import java.util.List;
|
fiore@0
|
33 import java.util.ResourceBundle;
|
fiore@0
|
34 import java.util.Set;
|
fiore@0
|
35
|
fiore@0
|
36 import javax.swing.JCheckBox;
|
fiore@0
|
37 import javax.swing.JComponent;
|
fiore@0
|
38 import javax.swing.JDialog;
|
fiore@0
|
39 import javax.swing.JFormattedTextField;
|
fiore@0
|
40 import javax.swing.JLabel;
|
fiore@0
|
41 import javax.swing.JOptionPane;
|
fiore@0
|
42 import javax.swing.JPanel;
|
fiore@0
|
43 import javax.swing.JProgressBar;
|
fiore@0
|
44 import javax.swing.JScrollPane;
|
fiore@0
|
45 import javax.swing.JSpinner;
|
fiore@0
|
46 import javax.swing.JTextArea;
|
fiore@0
|
47 import javax.swing.JTextField;
|
fiore@0
|
48 import javax.swing.KeyStroke;
|
fiore@0
|
49 import javax.swing.SwingWorker;
|
fiore@0
|
50 import javax.swing.event.ChangeEvent;
|
fiore@0
|
51 import javax.swing.event.ChangeListener;
|
fiore@0
|
52 import javax.swing.text.JTextComponent;
|
fiore@0
|
53
|
fiore@0
|
54 import uk.ac.qmul.eecs.ccmi.sound.SoundEvent;
|
fiore@0
|
55 import uk.ac.qmul.eecs.ccmi.sound.SoundFactory;
|
fiore@0
|
56 import uk.ac.qmul.eecs.ccmi.speech.NarratorFactory;
|
fiore@0
|
57 import uk.ac.qmul.eecs.ccmi.speech.SpeechUtilities;
|
fiore@0
|
58
|
fiore@0
|
59 /**
|
fiore@0
|
60 *
|
fiore@0
|
61 * TheSpeechOptionPane provides one-line calls to display accessible dialog boxes. Input by the user as well
|
fiore@0
|
62 * as focused components are spoken out through text to speech synthesis performed by the {@link Narrator} instance.
|
fiore@0
|
63 *
|
fiore@0
|
64 */
|
fiore@0
|
65 public abstract class SpeechOptionPane {
|
fiore@0
|
66
|
fiore@0
|
67 public static String showTextAreaDialog(Component parentComponent, String message, String initialSelectionValue){
|
fiore@0
|
68 JTextArea textArea = new JTextArea(NOTES_TEXT_AREA_ROW_SIZE,NOTES_TEXT_AREA_COL_SIZE);
|
fiore@0
|
69 textArea.setText(initialSelectionValue);
|
fiore@0
|
70 NarratorFactory.getInstance().speak(message);
|
fiore@0
|
71 return textComponentDialog(parentComponent, message, textArea);
|
fiore@0
|
72 }
|
fiore@0
|
73
|
fiore@0
|
74 public static String showInputDialog(Component parentComponent, String message, String initialSelectionValue){
|
fiore@0
|
75 final JTextField textField = new JTextField(initialSelectionValue);
|
fiore@0
|
76 textField.selectAll();
|
fiore@0
|
77 NarratorFactory.getInstance().speak(message);
|
fiore@0
|
78 return textComponentDialog(parentComponent, message, textField);
|
fiore@0
|
79 }
|
fiore@0
|
80
|
fiore@0
|
81 private static String textComponentDialog(Component parentComponent, String message, final JTextComponent textComponent){
|
fiore@0
|
82 Object componentToDisplay = textComponent;
|
fiore@0
|
83 if(textComponent instanceof JTextArea)
|
fiore@0
|
84 componentToDisplay = new JScrollPane(textComponent);
|
fiore@0
|
85
|
fiore@0
|
86 Object[] displayObjects = { new JLabel(message), componentToDisplay };
|
fiore@0
|
87 final JOptionPane optPane = new JOptionPane();
|
fiore@0
|
88 optPane.setMessage(displayObjects);
|
fiore@0
|
89 optPane.setMessageType(QUESTION_MESSAGE);
|
fiore@0
|
90 optPane.setOptionType(OK_CANCEL_OPTION);
|
fiore@0
|
91 /* ctrl key will hush the TTS */
|
fiore@0
|
92 optPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_CONTROL,InputEvent.CTRL_DOWN_MASK),"shut_up");
|
fiore@0
|
93 optPane.getActionMap().put("shut_up", SpeechUtilities.getShutUpAction());
|
fiore@0
|
94
|
fiore@0
|
95 final JDialog dialog = optPane.createDialog(parentComponent, resources.getString("dialog.speech_option_pane.input"));
|
fiore@0
|
96 if(textComponent instanceof JTextArea)
|
fiore@0
|
97 dialog.setResizable(true);
|
fiore@0
|
98 dialog.addWindowFocusListener(new WindowAdapter(){
|
fiore@0
|
99 @Override
|
fiore@0
|
100 public void windowGainedFocus(WindowEvent e) {
|
fiore@0
|
101 textComponent.requestFocusInWindow();
|
fiore@0
|
102 }
|
fiore@0
|
103 });
|
fiore@0
|
104
|
fiore@0
|
105 SpeechUtilities.changeTabListener(optPane,dialog);
|
fiore@0
|
106 textComponent.addKeyListener(SpeechUtilities.getSpeechKeyListener(true));
|
fiore@0
|
107 textComponent.setEditable(true);
|
fiore@0
|
108 // start the editing sound
|
fiore@0
|
109 SoundFactory.getInstance().startLoop(SoundEvent.EDITING);
|
fiore@0
|
110 dialog.setVisible(true);
|
fiore@0
|
111 SoundFactory.getInstance().stopLoop(SoundEvent.EDITING);
|
fiore@0
|
112
|
fiore@0
|
113 if(optPane.getValue() == null)//window closed
|
fiore@0
|
114 return null;
|
fiore@0
|
115 else if(((Integer)optPane.getValue()).intValue() == CANCEL_OPTION || ((Integer)optPane.getValue()).intValue() == CLOSED_OPTION)//pressed on cancel
|
fiore@0
|
116 return null;
|
fiore@0
|
117 else{ // pressed on OK
|
fiore@0
|
118 return textComponent.getText().trim();
|
fiore@0
|
119 }
|
fiore@0
|
120 }
|
fiore@0
|
121
|
fiore@0
|
122 public static String showInputDialog(Component parentComponent, String message){
|
fiore@0
|
123 return showInputDialog(parentComponent, message, "");
|
fiore@0
|
124 }
|
fiore@0
|
125
|
fiore@0
|
126 public static Object showSelectionDialog(Component parentComponent, String message, Object[] options, Object initialValue){
|
fiore@0
|
127 final LoopComboBox comboBox = new LoopComboBox(options);
|
fiore@0
|
128 comboBox.setSelectedItem(initialValue);
|
fiore@0
|
129 Object[] displayObjects = { new JLabel(message), comboBox };
|
fiore@0
|
130 JOptionPane optPane = new JOptionPane();
|
fiore@0
|
131 optPane.setMessage(displayObjects);
|
fiore@0
|
132 optPane.setMessageType(QUESTION_MESSAGE);
|
fiore@0
|
133 optPane.setOptionType(OK_CANCEL_OPTION);
|
fiore@0
|
134 /* ctrl key will hush the TTS */
|
fiore@0
|
135 optPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_CONTROL,InputEvent.CTRL_DOWN_MASK),"shut_up");
|
fiore@0
|
136 optPane.getActionMap().put("shut_up", SpeechUtilities.getShutUpAction());
|
fiore@0
|
137
|
fiore@0
|
138 NarratorFactory.getInstance().speak(message+", "+SpeechUtilities.getComponentSpeech(comboBox));
|
fiore@0
|
139 final JDialog dialog = optPane.createDialog(parentComponent, resources.getString("dialog.speech_option_pane.select"));
|
fiore@0
|
140 dialog.addWindowFocusListener(new WindowAdapter(){
|
fiore@0
|
141 @Override
|
fiore@0
|
142 public void windowGainedFocus(WindowEvent e) {
|
fiore@0
|
143 comboBox.requestFocusInWindow();
|
fiore@0
|
144 }
|
fiore@0
|
145 });
|
fiore@0
|
146
|
fiore@0
|
147 comboBox.addItemListener(SpeechUtilities.getSpeechComboBoxItemListener());
|
fiore@0
|
148
|
fiore@0
|
149 SpeechUtilities.changeTabListener(optPane,dialog);
|
fiore@0
|
150 // start the editing sound
|
fiore@0
|
151 SoundFactory.getInstance().startLoop(SoundEvent.EDITING);
|
fiore@0
|
152 dialog.setVisible(true);
|
fiore@0
|
153 SoundFactory.getInstance().stopLoop(SoundEvent.EDITING);
|
fiore@0
|
154 if(optPane.getValue() == null)//window closed
|
fiore@0
|
155 return null;
|
fiore@0
|
156 else if(((Integer)optPane.getValue()).intValue() == CANCEL_OPTION || ((Integer)optPane.getValue()).intValue() == CLOSED_OPTION)//pressed on cancel )//pressed on cancel
|
fiore@0
|
157 return null;
|
fiore@0
|
158 else{ // pressed on OK
|
fiore@0
|
159 return comboBox.getSelectedItem();
|
fiore@0
|
160 }
|
fiore@0
|
161 }
|
fiore@0
|
162
|
fiore@0
|
163 public static Integer showNarratorRateDialog(Component parentComponent, String message, int value, int min, int max){
|
fiore@0
|
164 NarratorFactory.getInstance().speak(message);
|
fiore@0
|
165 final JSpinner spinner = new JSpinner(new LoopSpinnerNumberModel(value,min,max));
|
fiore@0
|
166 JFormattedTextField tf = ((JSpinner.DefaultEditor)spinner.getEditor()).getTextField();
|
fiore@0
|
167 tf.setEditable(false);
|
fiore@0
|
168 tf.setFocusable(false);
|
fiore@0
|
169 tf.setBackground(Color.white);
|
fiore@0
|
170
|
fiore@0
|
171 Object[] displayObjects = { new JLabel(message), spinner};
|
fiore@0
|
172 final JOptionPane optPane = new JOptionPane();
|
fiore@0
|
173 optPane.setMessage(displayObjects);
|
fiore@0
|
174 optPane.setMessageType(QUESTION_MESSAGE);
|
fiore@0
|
175 optPane.setOptionType(OK_CANCEL_OPTION);
|
fiore@0
|
176 /* ctrl key will hush the TTS */
|
fiore@0
|
177 optPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_CONTROL,InputEvent.CTRL_DOWN_MASK),"shut_up");
|
fiore@0
|
178 optPane.getActionMap().put("shut_up", SpeechUtilities.getShutUpAction());
|
fiore@0
|
179
|
fiore@0
|
180 final JDialog dialog = optPane.createDialog(parentComponent, resources.getString("dialog.speech_option_pane.input"));
|
fiore@0
|
181 SpeechUtilities.changeTabListener(optPane,dialog);
|
fiore@0
|
182
|
fiore@0
|
183 dialog.addWindowFocusListener(new WindowAdapter(){
|
fiore@0
|
184 @Override
|
fiore@0
|
185 public void windowGainedFocus(WindowEvent e) {
|
fiore@0
|
186 spinner.requestFocusInWindow();
|
fiore@0
|
187 }
|
fiore@0
|
188 });
|
fiore@0
|
189 spinner.addChangeListener(new ChangeListener(){
|
fiore@0
|
190 @Override
|
fiore@0
|
191 public void stateChanged(ChangeEvent evt) {
|
fiore@0
|
192 JSpinner s = (JSpinner)(evt.getSource());
|
fiore@0
|
193 NarratorFactory.getInstance().setRate((Integer)s.getValue());
|
fiore@0
|
194 NarratorFactory.getInstance().speak(s.getValue().toString());
|
fiore@0
|
195 }
|
fiore@0
|
196 });
|
fiore@0
|
197 // start the editing sound
|
fiore@0
|
198 SoundFactory.getInstance().startLoop(SoundEvent.EDITING);
|
fiore@0
|
199 dialog.setVisible(true);
|
fiore@0
|
200 SoundFactory.getInstance().stopLoop(SoundEvent.EDITING);
|
fiore@0
|
201
|
fiore@0
|
202 /* set the speech rate back to the value passed as argument */
|
fiore@0
|
203 NarratorFactory.getInstance().setRate(value);
|
fiore@0
|
204 if(optPane.getValue() == null)//window closed
|
fiore@0
|
205 return null;
|
fiore@0
|
206 else if(((Integer)optPane.getValue()).intValue() == CANCEL_OPTION || ((Integer)optPane.getValue()).intValue() == CLOSED_OPTION)//pressed on cancel
|
fiore@0
|
207 return null;
|
fiore@0
|
208 else{ // pressed on OK
|
fiore@0
|
209 return (Integer)spinner.getValue();
|
fiore@0
|
210 }
|
fiore@0
|
211 }
|
fiore@0
|
212
|
fiore@0
|
213 public static int showConfirmDialog(Component parentComponent, String message, int optionType){
|
fiore@0
|
214 NarratorFactory.getInstance().speak(message);
|
fiore@0
|
215 JOptionPane optPane = new JOptionPane();
|
fiore@0
|
216 optPane.setMessage(message);
|
fiore@0
|
217 optPane.setMessageType(QUESTION_MESSAGE);
|
fiore@0
|
218 optPane.setOptionType(optionType);
|
fiore@0
|
219 /* ctrl key will hush the TTS */
|
fiore@0
|
220 optPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_CONTROL,InputEvent.CTRL_DOWN_MASK),"shut_up");
|
fiore@0
|
221 optPane.getActionMap().put("shut_up", SpeechUtilities.getShutUpAction());
|
fiore@0
|
222
|
fiore@0
|
223 JDialog dialog = optPane.createDialog(parentComponent, resources.getString("dialog.speech_option_pane.confirm"));
|
fiore@0
|
224 SpeechUtilities.changeTabListener(optPane,dialog);
|
fiore@0
|
225
|
fiore@0
|
226 SoundFactory.getInstance().startLoop(SoundEvent.EDITING);
|
fiore@0
|
227 dialog.setVisible(true);
|
fiore@0
|
228 SoundFactory.getInstance().stopLoop(SoundEvent.EDITING);
|
fiore@0
|
229
|
fiore@0
|
230 if(optPane.getValue() == null)//window closed
|
fiore@0
|
231 return CANCEL_OPTION;
|
fiore@0
|
232 else
|
fiore@0
|
233 return ((Integer)optPane.getValue()).intValue();
|
fiore@0
|
234 }
|
fiore@0
|
235
|
fiore@0
|
236 public static void showMessageDialog(Component parentComponent, String message, int messageType){
|
fiore@0
|
237 NarratorFactory.getInstance().speak(MessageFormat.format(resources.getString("dialog.speech_option_pane.message"), message));
|
fiore@0
|
238 JOptionPane optPane = new JOptionPane();
|
fiore@0
|
239 optPane.setMessage(message);
|
fiore@0
|
240 optPane.setMessageType(messageType);
|
fiore@0
|
241 /* ctrl key will hush the TTS */
|
fiore@0
|
242 optPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_CONTROL,InputEvent.CTRL_DOWN_MASK),"shut_up");
|
fiore@0
|
243 optPane.getActionMap().put("shut_up", SpeechUtilities.getShutUpAction());
|
fiore@0
|
244
|
fiore@0
|
245 JDialog dialog = optPane.createDialog(parentComponent, resources.getString("dialog.speech_option_pane.confirm"));
|
fiore@0
|
246 SpeechUtilities.changeTabListener(optPane,dialog);
|
fiore@0
|
247 SoundFactory.getInstance().startLoop(SoundEvent.EDITING);
|
fiore@0
|
248 dialog.setVisible(true);
|
fiore@0
|
249 SoundFactory.getInstance().stopLoop(SoundEvent.EDITING);
|
fiore@0
|
250 }
|
fiore@0
|
251
|
fiore@0
|
252 public static void showMessageDialog(Component parentComponent, String message){
|
fiore@0
|
253 showMessageDialog(parentComponent,message,ERROR_MESSAGE);
|
fiore@0
|
254 }
|
fiore@0
|
255
|
fiore@0
|
256 public static <T,V> int showProgressDialog(Component parentComponent, String message,final ProgressDialogWorker<T,V> worker, int millisToDecideToPopup){
|
fiore@0
|
257 JProgressBar progressBar = new JProgressBar();
|
fiore@0
|
258 progressBar.setIndeterminate(true);
|
fiore@0
|
259 Object displayObjects[] = {message, progressBar};
|
fiore@0
|
260 final JOptionPane optPane = new JOptionPane(displayObjects);
|
fiore@0
|
261 optPane.setOptionType(DEFAULT_OPTION);
|
fiore@0
|
262 optPane.setOptions(new Object[] {PROGRESS_DIALOG_CANCEL_OPTION});
|
fiore@0
|
263 /* ctrl key will hush the TTS */
|
fiore@0
|
264 optPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_CONTROL,InputEvent.CTRL_DOWN_MASK),"shut_up");
|
fiore@0
|
265 optPane.getActionMap().put("shut_up", SpeechUtilities.getShutUpAction());
|
fiore@0
|
266
|
fiore@0
|
267 final JDialog dialog = optPane.createDialog(parentComponent, resources.getString("dialog.speech_option_pane.download"));
|
fiore@0
|
268 SpeechUtilities.changeTabListener(optPane,dialog);
|
fiore@0
|
269
|
fiore@0
|
270 worker.setDialog(dialog);
|
fiore@0
|
271 worker.execute();
|
fiore@0
|
272 try {
|
fiore@0
|
273 Thread.sleep(millisToDecideToPopup);
|
fiore@0
|
274 } catch (InterruptedException ie) {
|
fiore@0
|
275 throw new RuntimeException(ie); //should never happen
|
fiore@0
|
276 }
|
fiore@0
|
277 if(worker.isDone())
|
fiore@0
|
278 return OK_OPTION;
|
fiore@0
|
279
|
fiore@0
|
280 NarratorFactory.getInstance().speak(message);
|
fiore@0
|
281 SoundFactory.getInstance().startLoop(SoundEvent.EDITING);
|
fiore@0
|
282 dialog.setVisible(true);
|
fiore@0
|
283 SoundFactory.getInstance().stopLoop(SoundEvent.EDITING);
|
fiore@0
|
284 if( optPane.getValue() == null ||
|
fiore@0
|
285 optPane.getValue() == PROGRESS_DIALOG_CANCEL_OPTION ||
|
fiore@0
|
286 Integer.valueOf(CLOSED_OPTION).equals(optPane.getValue())){
|
fiore@0
|
287 worker.cancel(true);
|
fiore@0
|
288 return CANCEL_OPTION;
|
fiore@0
|
289 }
|
fiore@0
|
290 return OK_OPTION;
|
fiore@0
|
291 }
|
fiore@0
|
292
|
fiore@0
|
293 public static Set<Integer> showModifiersDialog(Component parentComponent, String message, List<String> modifierTypes, Set<Integer> modifierIndexes){
|
fiore@0
|
294 JOptionPane optPane = new JOptionPane();
|
fiore@0
|
295
|
fiore@0
|
296 JPanel checkBoxPanel = new JPanel(new GridLayout(0, 1));
|
fiore@0
|
297 final JCheckBox[] checkBoxes = new JCheckBox[modifierTypes.size()];
|
fiore@0
|
298 for(int i=0;i<checkBoxes.length;i++){
|
fiore@0
|
299 checkBoxes[i] = new JCheckBox(modifierTypes.get(i));
|
fiore@0
|
300 if(modifierIndexes.contains(i))
|
fiore@0
|
301 checkBoxes[i].setSelected(true);
|
fiore@0
|
302 checkBoxPanel.add(checkBoxes[i]);
|
fiore@0
|
303 checkBoxes[i].addItemListener(SpeechUtilities.getCheckBoxSpeechItemListener());
|
fiore@0
|
304 }
|
fiore@0
|
305 NarratorFactory.getInstance().speak(message+" "+SpeechUtilities.getComponentSpeech(checkBoxes[0]));
|
fiore@0
|
306
|
fiore@0
|
307 Object[] displayObjects = {new JLabel(message),checkBoxPanel};
|
fiore@0
|
308 optPane.setMessage(displayObjects);
|
fiore@0
|
309 optPane.setMessageType(QUESTION_MESSAGE);
|
fiore@0
|
310 optPane.setOptionType(OK_CANCEL_OPTION);
|
fiore@0
|
311 /* ctrl key will hush the TTS */
|
fiore@0
|
312 optPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_CONTROL,InputEvent.CTRL_DOWN_MASK),"shut_up");
|
fiore@0
|
313 optPane.getActionMap().put("shut_up", SpeechUtilities.getShutUpAction());
|
fiore@0
|
314 JDialog dialog = optPane.createDialog(parentComponent, resources.getString("dialog.speech_option_pane.modifiers"));
|
fiore@0
|
315 SpeechUtilities.changeTabListener(optPane,dialog);
|
fiore@0
|
316
|
fiore@0
|
317 dialog.addWindowFocusListener(new WindowAdapter(){
|
fiore@0
|
318 @Override
|
fiore@0
|
319 public void windowGainedFocus(WindowEvent e) {
|
fiore@0
|
320 checkBoxes[0].requestFocusInWindow();
|
fiore@0
|
321 }
|
fiore@0
|
322 });
|
fiore@0
|
323
|
fiore@0
|
324 SoundFactory.getInstance().startLoop(SoundEvent.EDITING);
|
fiore@0
|
325 dialog.setVisible(true);
|
fiore@0
|
326 SoundFactory.getInstance().stopLoop(SoundEvent.EDITING);
|
fiore@0
|
327
|
fiore@0
|
328 if(optPane.getValue() == null)//window closed
|
fiore@0
|
329 return null;
|
fiore@0
|
330 else if(((Integer)optPane.getValue()).intValue() == CANCEL_OPTION || ((Integer)optPane.getValue()).intValue() == CLOSED_OPTION)//pressed on cancel
|
fiore@0
|
331 return null;
|
fiore@0
|
332 else{ // pressed on OK
|
fiore@0
|
333 Set<Integer> returnSet = new LinkedHashSet<Integer>();
|
fiore@0
|
334 for(int i=0;i<checkBoxes.length;i++)
|
fiore@0
|
335 if(checkBoxes[i].isSelected())
|
fiore@0
|
336 returnSet.add(i);
|
fiore@0
|
337 return returnSet;
|
fiore@0
|
338 }
|
fiore@0
|
339 }
|
fiore@0
|
340
|
fiore@0
|
341 public static Frame getFrameForComponent(Component parentComponent){
|
fiore@0
|
342 return JOptionPane.getFrameForComponent(parentComponent);
|
fiore@0
|
343 }
|
fiore@0
|
344
|
fiore@0
|
345 private static ResourceBundle resources = ResourceBundle.getBundle(EditorFrame.class.getName());
|
fiore@0
|
346 private static final int NOTES_TEXT_AREA_COL_SIZE = 10;
|
fiore@0
|
347 private static final int NOTES_TEXT_AREA_ROW_SIZE = 10;
|
fiore@0
|
348 private static final String PROGRESS_DIALOG_CANCEL_OPTION = resources.getString("dialog.speech_option_pane.cancel");
|
fiore@0
|
349
|
fiore@0
|
350
|
fiore@0
|
351 public static final int QUESTION_MESSAGE = JOptionPane.QUESTION_MESSAGE;
|
fiore@0
|
352 public static final int ERROR_MESSAGE = JOptionPane.ERROR_MESSAGE;
|
fiore@0
|
353 public static final int INFORMATION_MESSAGE = JOptionPane.INFORMATION_MESSAGE;
|
fiore@0
|
354 public static final int WARNING_MESSAGE = JOptionPane.WARNING_MESSAGE;
|
fiore@0
|
355 public static final int OK_CANCEL_OPTION = JOptionPane.OK_CANCEL_OPTION;
|
fiore@0
|
356 public static final int CANCEL_OPTION = JOptionPane.CANCEL_OPTION;
|
fiore@0
|
357 public static final int OK_OPTION = JOptionPane.OK_OPTION;
|
fiore@0
|
358 public static final int CLOSED_OPTION = JOptionPane.CLOSED_OPTION;
|
fiore@0
|
359 public static final int DEFAULT_OPTION = JOptionPane.DEFAULT_OPTION;
|
fiore@0
|
360 public static final int YES_NO_OPTION = JOptionPane.YES_NO_OPTION;
|
fiore@0
|
361 public static final int YES_OPTION = JOptionPane.YES_OPTION;
|
fiore@0
|
362 public static final int NO_OPTION = JOptionPane.NO_OPTION;
|
fiore@0
|
363
|
fiore@0
|
364
|
fiore@0
|
365 public static abstract class ProgressDialogWorker<T,V> extends SwingWorker<T,V> {
|
fiore@0
|
366 private void setDialog(JDialog dialog){
|
fiore@0
|
367 this.dialog = dialog;
|
fiore@0
|
368 }
|
fiore@0
|
369
|
fiore@0
|
370 @Override
|
fiore@0
|
371 protected void done() {
|
fiore@0
|
372 if(dialog != null)
|
fiore@0
|
373 dialog.dispose();
|
fiore@0
|
374 }
|
fiore@0
|
375
|
fiore@0
|
376 private JDialog dialog;
|
fiore@0
|
377 }
|
fiore@0
|
378
|
fiore@0
|
379
|
fiore@0
|
380 }
|