Revision 478 org.gvsig.scripting/trunk/org.gvsig.scripting/org.gvsig.scripting.swing/org.gvsig.scripting.swing.impl/src/main/java/org/gvsig/scripting/swing/impl/composer/DefaultJScriptingComposer.java
DefaultJScriptingComposer.java | ||
---|---|---|
1 | 1 |
package org.gvsig.scripting.swing.impl.composer; |
2 | 2 |
|
3 | 3 |
import java.awt.BorderLayout; |
4 |
import java.awt.Color; |
|
4 | 5 |
import java.awt.Dialog; |
5 | 6 |
import java.awt.Dimension; |
6 |
import java.awt.Font; |
|
7 | 7 |
import java.awt.event.ActionEvent; |
8 | 8 |
import java.awt.event.ActionListener; |
9 | 9 |
import java.awt.event.KeyEvent; |
... | ... | |
15 | 15 |
import java.util.List; |
16 | 16 |
import java.util.Map; |
17 | 17 |
import javax.swing.AbstractAction; |
18 |
|
|
18 |
import javax.swing.Action; |
|
19 |
import static javax.swing.Action.ACCELERATOR_KEY; |
|
19 | 20 |
import javax.swing.JButton; |
20 | 21 |
import javax.swing.JLabel; |
21 | 22 |
import javax.swing.JMenu; |
... | ... | |
53 | 54 |
import org.gvsig.installer.swing.api.SwingInstallerLocator; |
54 | 55 |
import org.gvsig.installer.swing.api.SwingInstallerManager; |
55 | 56 |
import org.gvsig.installer.swing.api.packagebuilder.PackageBuildder; |
56 |
|
|
57 | 57 |
import org.gvsig.scripting.CompileErrorException; |
58 | 58 |
import org.gvsig.scripting.ExecuteErrorException; |
59 | 59 |
import org.gvsig.scripting.ScriptingBaseScript; |
... | ... | |
67 | 67 |
import org.gvsig.scripting.swing.api.JEditor; |
68 | 68 |
import org.gvsig.scripting.swing.api.JScriptingBrowser; |
69 | 69 |
import org.gvsig.scripting.swing.api.JScriptingComposer; |
70 |
import org.gvsig.scripting.swing.api.JScriptingConsole; |
|
70 | 71 |
import org.gvsig.scripting.swing.api.ScriptingUIManager; |
71 | 72 |
import org.gvsig.scripting.swing.api.SyntaxtHighlightTextComponent.UpdateCaretPositionActionEvent; |
72 | 73 |
import org.gvsig.scripting.swing.impl.DefaultJScriptingBrowser; |
74 |
import org.gvsig.scripting.swing.impl.DefaultJScriptingConsole; |
|
73 | 75 |
import org.gvsig.scripting.swing.impl.DefaultJScriptingLauncher; |
74 | 76 |
import org.gvsig.scripting.swing.impl.DefaultJScriptingLauncher.LauncherActionEvent; |
75 | 77 |
import org.gvsig.scripting.swing.impl.DefaultScriptingUIManager; |
... | ... | |
87 | 89 |
|
88 | 90 |
public class DefaultJScriptingComposer extends JScriptingComposer implements Observer, ActionListener, SearchListener { |
89 | 91 |
|
92 |
|
|
93 |
private class GoToLineAction extends AbstractAction { |
|
94 |
|
|
95 |
public GoToLineAction() { |
|
96 |
super("Go To Line..."); |
|
97 |
int c = getToolkit().getMenuShortcutKeyMask(); |
|
98 |
putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_L, c)); |
|
99 |
} |
|
100 |
|
|
101 |
public void actionPerformed(ActionEvent e) { |
|
102 |
|
|
103 |
RSyntaxTextArea textArea = getCurrentRSyntaxTextArea(); |
|
104 |
if (textArea == null) { |
|
105 |
return; |
|
106 |
} |
|
107 |
|
|
108 |
if (findDialog.isVisible()) { |
|
109 |
findDialog.setVisible(false); |
|
110 |
} |
|
111 |
if (replaceDialog.isVisible()) { |
|
112 |
replaceDialog.setVisible(false); |
|
113 |
} |
|
114 |
gotoDialog.setMaxLineNumberAllowed(textArea.getLineCount()); |
|
115 |
gotoDialog.setVisible(true); |
|
116 |
int line = gotoDialog.getLineNumber(); |
|
117 |
if (line > 0) { |
|
118 |
try { |
|
119 |
textArea.setCaretPosition(textArea.getLineStartOffset(line - 1)); |
|
120 |
} catch (BadLocationException ble) { // Never happens |
|
121 |
UIManager.getLookAndFeel().provideErrorFeedback(textArea); |
|
122 |
ble.printStackTrace(); |
|
123 |
} |
|
124 |
} |
|
125 |
} |
|
126 |
} |
|
127 |
|
|
128 |
private class ShowFindDialogAction extends AbstractAction { |
|
129 |
|
|
130 |
public ShowFindDialogAction() { |
|
131 |
super("Find..."); |
|
132 |
int c = getToolkit().getMenuShortcutKeyMask(); |
|
133 |
putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_F, c)); |
|
134 |
} |
|
135 |
|
|
136 |
public void actionPerformed(ActionEvent e) { |
|
137 |
if (replaceDialog.isVisible()) { |
|
138 |
replaceDialog.setVisible(false); |
|
139 |
} |
|
140 |
findDialog.setVisible(true); |
|
141 |
} |
|
142 |
} |
|
143 |
|
|
144 |
private class ShowReplaceDialogAction extends AbstractAction { |
|
145 |
|
|
146 |
public ShowReplaceDialogAction() { |
|
147 |
super("Replace..."); |
|
148 |
int c = getToolkit().getMenuShortcutKeyMask(); |
|
149 |
putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_H, c)); |
|
150 |
} |
|
151 |
|
|
152 |
public void actionPerformed(ActionEvent e) { |
|
153 |
if (findDialog.isVisible()) { |
|
154 |
findDialog.setVisible(false); |
|
155 |
} |
|
156 |
replaceDialog.setVisible(true); |
|
157 |
} |
|
158 |
} |
|
159 |
|
|
160 |
private class LauncherAction extends AbstractAction { |
|
161 |
|
|
162 |
public LauncherAction() { |
|
163 |
super(uimanager.getTranslation("Launcher")); |
|
164 |
} |
|
165 |
|
|
166 |
@Override |
|
167 |
public void actionPerformed(ActionEvent e) { |
|
168 |
getWindowManager().showWindow( |
|
169 |
uimanager.createLauncher(), |
|
170 |
uimanager.getTranslation("Scripting_Launcher"), |
|
171 |
WindowManager.MODE.TOOL |
|
172 |
); |
|
173 |
} |
|
174 |
|
|
175 |
} |
|
176 |
|
|
177 |
private class SelectAllAction extends AbstractAction { |
|
178 |
|
|
179 |
public SelectAllAction() { |
|
180 |
super(uimanager.getTranslation("Select_all")); |
|
181 |
putValue(Action.SMALL_ICON, uimanager.getIcon("edit-select-all")); |
|
182 |
putValue(Action.SHORT_DESCRIPTION, uimanager.getTranslation("Select_all")); |
|
183 |
} |
|
184 |
|
|
185 |
@Override |
|
186 |
public void actionPerformed(ActionEvent e) { |
|
187 |
currentScriptSelectAll(); |
|
188 |
} |
|
189 |
|
|
190 |
} |
|
191 |
|
|
192 |
private class PackageScriptAction extends AbstractAction { |
|
193 |
|
|
194 |
public PackageScriptAction() { |
|
195 |
super(uimanager.getTranslation("_Package_script")); |
|
196 |
} |
|
197 |
|
|
198 |
@Override |
|
199 |
public void actionPerformed(ActionEvent e) { |
|
200 |
createScriptPackage(); |
|
201 |
} |
|
202 |
|
|
203 |
} |
|
204 |
|
|
205 |
private class ImportJavadocAction extends AbstractAction { |
|
206 |
|
|
207 |
public ImportJavadocAction() { |
|
208 |
super(uimanager.getTranslation("Import_JavaDoc")); |
|
209 |
putValue(Action.SMALL_ICON, uimanager.getIcon("list-add")); |
|
210 |
putValue(Action.SHORT_DESCRIPTION, uimanager.getTranslation("Import_JavaDoc")); |
|
211 |
} |
|
212 |
|
|
213 |
@Override |
|
214 |
public void actionPerformed(ActionEvent e) { |
|
215 |
getWindowManager().showWindow( |
|
216 |
getImportHelpDialog(), |
|
217 |
uimanager.getTranslation("JavaDoc"), |
|
218 |
WindowManager.MODE.WINDOW |
|
219 |
); |
|
220 |
} |
|
221 |
|
|
222 |
} |
|
223 |
|
|
224 |
private class RemoveHelpAction extends AbstractAction { |
|
225 |
|
|
226 |
public RemoveHelpAction() { |
|
227 |
super(uimanager.getTranslation("Remove_help")); |
|
228 |
putValue(Action.SMALL_ICON, uimanager.getIcon("list-remove")); |
|
229 |
putValue(Action.SHORT_DESCRIPTION, uimanager.getTranslation("Remove_JavaDoc")); |
|
230 |
} |
|
231 |
|
|
232 |
@Override |
|
233 |
public void actionPerformed(ActionEvent e) { |
|
234 |
try { |
|
235 |
//getRemoveHelpDialog(); |
|
236 |
JOptionPane.showMessageDialog( |
|
237 |
DefaultJScriptingComposer.this, |
|
238 |
"Falta por implementar", |
|
239 |
"Warning", |
|
240 |
JOptionPane.INFORMATION_MESSAGE |
|
241 |
); |
|
242 |
} catch (Exception e1) { |
|
243 |
logger.warn("Can't remove help",e1); |
|
244 |
} |
|
245 |
} |
|
246 |
|
|
247 |
} |
|
248 |
|
|
249 |
private class HelpAction extends AbstractAction { |
|
250 |
|
|
251 |
public HelpAction() { |
|
252 |
super(uimanager.getTranslation("Help_contents")); |
|
253 |
int c = getToolkit().getMenuShortcutKeyMask(); |
|
254 |
putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_F1, c)); |
|
255 |
putValue(Action.SMALL_ICON, uimanager.getIcon("help-browser")); |
|
256 |
putValue(Action.SHORT_DESCRIPTION, uimanager.getTranslation("Help_contents")); |
|
257 |
|
|
258 |
} |
|
259 |
|
|
260 |
@Override |
|
261 |
public void actionPerformed(ActionEvent e) { |
|
262 |
try { |
|
263 |
uimanager.showWindow( |
|
264 |
uimanager.getHelp(), |
|
265 |
uimanager.getTranslation("Help_contents") |
|
266 |
); |
|
267 |
} catch(Exception ex) { |
|
268 |
logger.warn("Can't show help dialog.",ex); |
|
269 |
JOptionPane.showMessageDialog( |
|
270 |
DefaultJScriptingComposer.this, |
|
271 |
uimanager.getTranslation("_Cant_show_help_dialog") |
|
272 |
+ "\n\n" |
|
273 |
+ uimanager.getTranslation("_See_the_error_log_for_more_information"), |
|
274 |
"_Warning", |
|
275 |
JOptionPane.WARNING_MESSAGE |
|
276 |
); |
|
277 |
} |
|
278 |
} |
|
279 |
|
|
280 |
} |
|
281 |
|
|
282 |
private class AboutAction extends AbstractAction { |
|
283 |
|
|
284 |
public AboutAction() { |
|
285 |
super(uimanager.getTranslation("About_scripts_editor")); |
|
286 |
putValue(Action.SMALL_ICON, uimanager.getIcon("system-users")); |
|
287 |
putValue(Action.SHORT_DESCRIPTION, uimanager.getTranslation("About_scripts_editor")); |
|
288 |
} |
|
289 |
|
|
290 |
@Override |
|
291 |
public void actionPerformed(ActionEvent e) { |
|
292 |
getWindowManager().showWindow( |
|
293 |
getAboutUsDialog(), |
|
294 |
uimanager.getTranslation("About_scripts_editor"), |
|
295 |
WindowManager.MODE.WINDOW |
|
296 |
); |
|
297 |
} |
|
298 |
|
|
299 |
} |
|
300 |
|
|
301 |
private class CutAction extends AbstractAction { |
|
302 |
|
|
303 |
public CutAction() { |
|
304 |
super(uimanager.getTranslation("Cut")); |
|
305 |
putValue(Action.SMALL_ICON, uimanager.getIcon("edit-cut")); |
|
306 |
putValue(Action.SHORT_DESCRIPTION, uimanager.getTranslation("Cut")); |
|
307 |
} |
|
308 |
|
|
309 |
@Override |
|
310 |
public void actionPerformed(ActionEvent e) { |
|
311 |
currentScriptCut(); |
|
312 |
} |
|
313 |
|
|
314 |
} |
|
315 |
|
|
316 |
private class CopyAction extends AbstractAction { |
|
317 |
|
|
318 |
public CopyAction() { |
|
319 |
super(uimanager.getTranslation("Copy")); |
|
320 |
putValue(Action.SMALL_ICON, uimanager.getIcon("edit-copy")); |
|
321 |
putValue(Action.SHORT_DESCRIPTION, uimanager.getTranslation("Copy")); |
|
322 |
} |
|
323 |
|
|
324 |
@Override |
|
325 |
public void actionPerformed(ActionEvent e) { |
|
326 |
currentScriptCopy(); |
|
327 |
} |
|
328 |
|
|
329 |
} |
|
330 |
|
|
331 |
private class PasteAction extends AbstractAction { |
|
332 |
|
|
333 |
public PasteAction() { |
|
334 |
super(uimanager.getTranslation("Paste")); |
|
335 |
putValue(Action.SMALL_ICON, uimanager.getIcon("edit-paste")); |
|
336 |
putValue(Action.SHORT_DESCRIPTION, uimanager.getTranslation("Paste")); |
|
337 |
} |
|
338 |
|
|
339 |
@Override |
|
340 |
public void actionPerformed(ActionEvent e) { |
|
341 |
currentScriptPaste(); |
|
342 |
} |
|
343 |
|
|
344 |
} |
|
345 |
|
|
346 |
private class ExitAction extends AbstractAction { |
|
347 |
|
|
348 |
public ExitAction() { |
|
349 |
super(uimanager.getTranslation("Close")); |
|
350 |
putValue(Action.SMALL_ICON, uimanager.getIcon("system-log-out")); |
|
351 |
putValue(Action.SHORT_DESCRIPTION, uimanager.getTranslation("Close")); |
|
352 |
} |
|
353 |
|
|
354 |
@Override |
|
355 |
public void actionPerformed(ActionEvent e) { |
|
356 |
closeAllScripts(); |
|
357 |
closeWindow(); |
|
358 |
if (defaultActionlistener != null) { |
|
359 |
ActionEvent event = new ActionEvent(this, CLOSE_ACTION, "close"); |
|
360 |
defaultActionlistener.actionPerformed(event); |
|
361 |
} |
|
362 |
} |
|
363 |
|
|
364 |
} |
|
365 |
|
|
366 |
private class SaveAction extends AbstractAction { |
|
367 |
|
|
368 |
public SaveAction() { |
|
369 |
super(uimanager.getTranslation("Save")); |
|
370 |
int c = getToolkit().getMenuShortcutKeyMask(); |
|
371 |
putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_S, c)); |
|
372 |
putValue(Action.SMALL_ICON, uimanager.getIcon("media-floppy")); |
|
373 |
putValue(Action.SHORT_DESCRIPTION, uimanager.getTranslation("Save")); |
|
374 |
} |
|
375 |
|
|
376 |
@Override |
|
377 |
public void actionPerformed(ActionEvent e) { |
|
378 |
currentScriptSave(); |
|
379 |
} |
|
380 |
} |
|
381 |
|
|
382 |
private class RunAction extends AbstractAction { |
|
383 |
|
|
384 |
public RunAction() { |
|
385 |
super(uimanager.getTranslation("Run")); |
|
386 |
int c = getToolkit().getMenuShortcutKeyMask(); |
|
387 |
putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_F5, c)); |
|
388 |
putValue(Action.SMALL_ICON, uimanager.getIcon("applications-system")); |
|
389 |
putValue(Action.SHORT_DESCRIPTION, uimanager.getTranslation("Run")); |
|
390 |
} |
|
391 |
|
|
392 |
@Override |
|
393 |
public void actionPerformed(ActionEvent e) { |
|
394 |
currentScriptExecute(); |
|
395 |
} |
|
396 |
|
|
397 |
} |
|
398 |
|
|
399 |
private class CloseAllAction extends AbstractAction { |
|
400 |
|
|
401 |
public CloseAllAction() { |
|
402 |
super(uimanager.getTranslation("Close_all_documents")); |
|
403 |
putValue(Action.SMALL_ICON, uimanager.getIcon("emblem-unreadable")); |
|
404 |
putValue(Action.SHORT_DESCRIPTION, uimanager.getTranslation("Close_all_documents")); |
|
405 |
} |
|
406 |
|
|
407 |
@Override |
|
408 |
public void actionPerformed(ActionEvent e) { |
|
409 |
closeAllScripts(); |
|
410 |
} |
|
411 |
|
|
412 |
} |
|
413 |
|
|
414 |
private class CloseDocumentAction extends AbstractAction { |
|
415 |
|
|
416 |
public CloseDocumentAction() { |
|
417 |
super(uimanager.getTranslation("Close_document")); |
|
418 |
putValue(Action.SMALL_ICON, uimanager.getIcon("emblem-unreadable")); |
|
419 |
putValue(Action.SHORT_DESCRIPTION, uimanager.getTranslation("Close_current_tab")); |
|
420 |
} |
|
421 |
|
|
422 |
@Override |
|
423 |
public void actionPerformed(ActionEvent e) { |
|
424 |
currentScriptClose(); |
|
425 |
} |
|
426 |
|
|
427 |
} |
|
428 |
|
|
429 |
private class NewDocumentAction extends AbstractAction { |
|
430 |
|
|
431 |
public NewDocumentAction() { |
|
432 |
super(uimanager.getTranslation("New")); |
|
433 |
putValue(Action.SMALL_ICON, uimanager.getIcon("document-new")); |
|
434 |
putValue(Action.SHORT_DESCRIPTION, uimanager.getTranslation("New")); |
|
435 |
} |
|
436 |
|
|
437 |
@Override |
|
438 |
public void actionPerformed(ActionEvent e) { |
|
439 |
try { |
|
440 |
scriptNew(); |
|
441 |
} catch (Exception e1) { |
|
442 |
logger.warn("Can't create a new document",e1); |
|
443 |
} |
|
444 |
} |
|
445 |
|
|
446 |
} |
|
447 |
|
|
448 |
private class EditAction extends AbstractAction { |
|
449 |
|
|
450 |
public EditAction() { |
|
451 |
super(uimanager.getTranslation("Edit")); |
|
452 |
putValue(Action.SMALL_ICON, uimanager.getIcon("applications-accessories")); |
|
453 |
putValue(Action.SHORT_DESCRIPTION, uimanager.getTranslation("Open_edition_mode")); |
|
454 |
} |
|
455 |
|
|
456 |
@Override |
|
457 |
public void actionPerformed(ActionEvent e) { |
|
458 |
try { |
|
459 |
scriptEdit((ScriptingBaseScript)getLauncherSelectedScript()); |
|
460 |
} catch (Exception e1) { |
|
461 |
logger.warn("Can't edit document",e1); |
|
462 |
} |
|
463 |
} |
|
464 |
} |
|
465 |
|
|
466 |
private class RefreshTreeAction extends AbstractAction { |
|
467 |
|
|
468 |
public RefreshTreeAction() { |
|
469 |
super(uimanager.getTranslation("Refresh")); |
|
470 |
putValue(Action.SMALL_ICON, uimanager.getIcon("view-refresh")); |
|
471 |
putValue(Action.SHORT_DESCRIPTION, uimanager.getTranslation("Refresh_directories")); |
|
472 |
} |
|
473 |
|
|
474 |
@Override |
|
475 |
public void actionPerformed(ActionEvent e) { |
|
476 |
launcherRefresh(); |
|
477 |
} |
|
478 |
|
|
479 |
} |
|
480 |
|
|
481 |
private class RenameAction extends AbstractAction { |
|
482 |
|
|
483 |
public RenameAction() { |
|
484 |
super(uimanager.getTranslation("Rename")); |
|
485 |
putValue(Action.SMALL_ICON, uimanager.getIcon("preferences-system")); |
|
486 |
putValue(Action.SHORT_DESCRIPTION, uimanager.getTranslation("Set_file_properties")); |
|
487 |
} |
|
488 |
|
|
489 |
@Override |
|
490 |
public void actionPerformed(ActionEvent e) { |
|
491 |
try { |
|
492 |
scriptRename(getLauncherSelectedScript()); |
|
493 |
} catch (Exception e1) { |
|
494 |
logger.warn("Can't rename document",e1); |
|
495 |
} |
|
496 |
} |
|
497 |
} |
|
498 |
|
|
499 |
private class MoveAction extends AbstractAction { |
|
500 |
|
|
501 |
public MoveAction() { |
|
502 |
super(uimanager.getTranslation("Move")); |
|
503 |
putValue(Action.SMALL_ICON, uimanager.getIcon("format-indent-more")); |
|
504 |
putValue(Action.SHORT_DESCRIPTION, uimanager.getTranslation("Move_files")); |
|
505 |
} |
|
506 |
|
|
507 |
@Override |
|
508 |
public void actionPerformed(ActionEvent e) { |
|
509 |
try { |
|
510 |
scriptMove(getLauncherSelectedScript()); |
|
511 |
} catch (Exception e1) { |
|
512 |
logger.warn("Can't move document",e1); |
|
513 |
} |
|
514 |
} |
|
515 |
} |
|
516 |
|
|
517 |
private class DeleteAction extends AbstractAction { |
|
518 |
|
|
519 |
public DeleteAction() { |
|
520 |
super(uimanager.getTranslation("Delete")); |
|
521 |
putValue(Action.SMALL_ICON, uimanager.getIcon("user-trash")); |
|
522 |
putValue(Action.SHORT_DESCRIPTION, uimanager.getTranslation("Delete_selected_script")); |
|
523 |
} |
|
524 |
|
|
525 |
@Override |
|
526 |
public void actionPerformed(ActionEvent e) { |
|
527 |
try { |
|
528 |
scriptDelete(getLauncherSelectedScript(), false); |
|
529 |
} catch (Exception e1) { |
|
530 |
logger.warn("Can't delete document",e1); |
|
531 |
} |
|
532 |
} |
|
533 |
} |
|
534 |
|
|
535 |
private class IndexHelpAction extends AbstractAction { |
|
536 |
|
|
537 |
public IndexHelpAction() { |
|
538 |
super(uimanager.getTranslation("Index_help")); |
|
539 |
} |
|
540 |
|
|
541 |
@Override |
|
542 |
public void actionPerformed(ActionEvent e) { |
|
543 |
JOptionPane.showMessageDialog( |
|
544 |
DefaultJScriptingComposer.this, |
|
545 |
"Falta por implementar", |
|
546 |
"Warning", |
|
547 |
JOptionPane.INFORMATION_MESSAGE |
|
548 |
); |
|
549 |
} |
|
550 |
} |
|
551 |
|
|
552 |
private class PackageHelpAction extends AbstractAction { |
|
553 |
|
|
554 |
public PackageHelpAction() { |
|
555 |
super(uimanager.getTranslation("_Package_help")); |
|
556 |
} |
|
557 |
|
|
558 |
@Override |
|
559 |
public void actionPerformed(ActionEvent e) { |
|
560 |
createHelpPackage(); |
|
561 |
} |
|
562 |
} |
|
563 |
|
|
90 | 564 |
/** |
91 | 565 |
* |
92 | 566 |
*/ |
... | ... | |
116 | 590 |
JLabel currentLine; |
117 | 591 |
JLabel statusBarMessage; |
118 | 592 |
JTextArea problems; |
119 |
JTextArea console;
|
|
593 |
JScriptingConsole console;
|
|
120 | 594 |
DefaultJScriptingLauncher launcher; |
121 | 595 |
JToolBar launcherButtons; |
122 | 596 |
PrintStream consolePrintStream = null; |
... | ... | |
132 | 606 |
/** |
133 | 607 |
* Instanciacion de un JComposer con todos sus elementos y acciones |
134 | 608 |
* |
135 |
* @param manager |
|
609 |
* @param uimanager
|
|
136 | 610 |
*/ |
137 | 611 |
public DefaultJScriptingComposer(final ScriptingUIManager uimanager) { |
138 | 612 |
loader = this.getClass().getClassLoader(); |
... | ... | |
142 | 616 |
unitsEditor = new LinkedHashMap<String, JEditor>(); |
143 | 617 |
|
144 | 618 |
initComponents(); |
145 |
|
|
146 |
System.setOut(this.getConsolePrintStream()); |
|
147 |
System.setErr(this.getConsolePrintStream()); |
|
148 |
|
|
149 | 619 |
} |
150 | 620 |
|
151 | 621 |
@Override |
... | ... | |
172 | 642 |
|
173 | 643 |
// Construimos los componentes del menu |
174 | 644 |
JMenu menu_file = new JMenu(this.uimanager.getTranslation("File")); |
175 |
JMenuItem menuItem_new = new JMenuItem(this.uimanager.getTranslation("New"), uimanager.getIcon("document-new")); |
|
176 |
menuItem_new.addActionListener(new ActionListener() { |
|
177 |
public void actionPerformed(ActionEvent e) { |
|
178 |
try { |
|
179 |
scriptNew(); |
|
180 |
} catch (Exception e1) { |
|
181 |
// TODO Auto-generated catch block |
|
182 |
e1.printStackTrace(); |
|
183 |
} |
|
184 |
} |
|
185 |
}); |
|
186 |
menu_file.add(menuItem_new); |
|
645 |
menu_file.add(new JMenuItem(new NewDocumentAction())); |
|
187 | 646 |
menu_file.addSeparator(); |
188 |
JMenuItem menuItem_close = new JMenuItem(this.uimanager.getTranslation("Close_document"), uimanager.getIcon("emblem-unreadable")); |
|
189 |
menuItem_close.addActionListener(new ActionListener() { |
|
190 |
public void actionPerformed(ActionEvent e) { |
|
191 |
currentScriptClose(); |
|
192 |
} |
|
193 |
}); |
|
194 |
menu_file.add(menuItem_close); |
|
195 |
JMenuItem menuItem_closeAll = new JMenuItem(this.uimanager.getTranslation("Close_all_documents"), uimanager.getIcon("emblem-unreadable")); |
|
196 |
menuItem_closeAll.addActionListener(new ActionListener() { |
|
197 |
public void actionPerformed(ActionEvent e) { |
|
198 |
closeAllScripts(); |
|
199 |
} |
|
200 |
}); |
|
201 |
menu_file.add(menuItem_closeAll); |
|
647 |
menu_file.add(new JMenuItem(new CloseDocumentAction())); |
|
648 |
menu_file.add(new JMenuItem(new CloseAllAction())); |
|
202 | 649 |
menu_file.addSeparator(); |
203 |
JMenuItem menuItem_run = new JMenuItem(this.uimanager.getTranslation("Run"), uimanager.getIcon("applications-system")); |
|
204 |
menuItem_run.addActionListener(new ActionListener() { |
|
205 |
public void actionPerformed(ActionEvent e) { |
|
206 |
currentScriptExecute(); |
|
207 |
} |
|
208 |
}); |
|
209 |
menu_file.add(menuItem_run); |
|
650 |
menu_file.add(new JMenuItem(new RunAction())); |
|
210 | 651 |
menu_file.addSeparator(); |
211 |
JMenuItem menuItem_save = new JMenuItem(this.uimanager.getTranslation("Save"), uimanager.getIcon("media-floppy")); |
|
212 |
menuItem_save.addActionListener(new ActionListener() { |
|
213 |
public void actionPerformed(ActionEvent e) { |
|
214 |
currentScriptSave(); |
|
215 |
} |
|
216 |
}); |
|
217 |
menu_file.add(menuItem_save); |
|
652 |
menu_file.add(new JMenuItem(new SaveAction())); |
|
218 | 653 |
menu_file.addSeparator(); |
219 |
JMenuItem menuItem_exit = new JMenuItem(this.uimanager.getTranslation("Close"), uimanager.getIcon("system-log-out")); |
|
220 |
menuItem_exit.addActionListener(new ActionListener() { |
|
221 |
public void actionPerformed(ActionEvent e) { |
|
222 |
closeAllScripts(); |
|
223 |
closeWindow(); |
|
224 |
if (defaultActionlistener != null) { |
|
225 |
ActionEvent event = new ActionEvent(this, CLOSE_ACTION, "close"); |
|
226 |
defaultActionlistener.actionPerformed(event); |
|
227 |
} |
|
654 |
menu_file.add(new JMenuItem(new ExitAction())); |
|
228 | 655 |
|
229 |
} |
|
230 |
}); |
|
231 |
menu_file.add(menuItem_exit); |
|
232 |
|
|
233 | 656 |
JMenu menu_edit = new JMenu(this.uimanager.getTranslation("Edit")); |
234 |
JMenuItem menuItem_cut = new JMenuItem(this.uimanager.getTranslation("Cut"), uimanager.getIcon("edit-cut")); |
|
235 |
menuItem_cut.addActionListener(new ActionListener() { |
|
236 |
@Override |
|
237 |
public void actionPerformed(ActionEvent e) { |
|
238 |
currentScriptCut(); |
|
239 |
} |
|
240 |
}); |
|
241 |
menu_edit.add(menuItem_cut); |
|
242 |
JMenuItem menuItem_copy = new JMenuItem(this.uimanager.getTranslation("Copy"), uimanager.getIcon("edit-copy")); |
|
243 |
menuItem_copy.addActionListener(new ActionListener() { |
|
244 |
@Override |
|
245 |
public void actionPerformed(ActionEvent e) { |
|
246 |
currentScriptCopy(); |
|
247 |
} |
|
248 |
}); |
|
249 |
menu_edit.add(menuItem_copy); |
|
250 |
JMenuItem menuItem_paste = new JMenuItem(this.uimanager.getTranslation("Paste"), uimanager.getIcon("edit-paste")); |
|
251 |
menuItem_paste.addActionListener(new ActionListener() { |
|
252 |
@Override |
|
253 |
public void actionPerformed(ActionEvent e) { |
|
254 |
currentScriptPaste(); |
|
255 |
} |
|
256 |
}); |
|
257 |
menu_edit.add(menuItem_paste); |
|
657 |
menu_edit.add(new JMenuItem(new CutAction())); |
|
658 |
menu_edit.add(new JMenuItem(new CopyAction())); |
|
659 |
menu_edit.add(new JMenuItem(new PasteAction())); |
|
258 | 660 |
menu_edit.addSeparator(); |
259 |
|
|
260 |
JMenuItem menuItem_selectAll = new JMenuItem(this.uimanager.getTranslation("Select_all"), uimanager.getIcon("edit-select-all")); |
|
261 |
menuItem_selectAll.addActionListener(new ActionListener() { |
|
262 |
@Override |
|
263 |
public void actionPerformed(ActionEvent e) { |
|
264 |
currentScriptSelectAll(); |
|
265 |
} |
|
266 |
}); |
|
267 |
menu_edit.add(menuItem_selectAll); |
|
661 |
menu_edit.add(new JMenuItem(new SelectAllAction())); |
|
268 | 662 |
menu_edit.addSeparator(); |
269 |
|
|
270 |
menu_edit.add(new JMenuItem(new ShowFindDialogAction())); |
|
663 |
menu_edit.add(new JMenuItem(new ShowFindDialogAction())); |
|
271 | 664 |
menu_edit.add(new JMenuItem(new ShowReplaceDialogAction())); |
272 | 665 |
menu_edit.add(new JMenuItem(new GoToLineAction())); |
273 | 666 |
|
274 | 667 |
JMenu menu_tools = new JMenu(this.uimanager.getTranslation("Tools")); |
275 |
JMenuItem menuItem_launcher = new JMenuItem(this.uimanager.getTranslation("Launcher")); |
|
276 |
menuItem_launcher.addActionListener(new ActionListener() { |
|
277 |
@Override |
|
278 |
public void actionPerformed(ActionEvent e) { |
|
279 |
getWindowManager().showWindow(uimanager.createLauncher(), uimanager.getTranslation("Scripting_Launcher"), WindowManager.MODE.TOOL); |
|
280 |
} |
|
281 |
}); |
|
282 |
menu_tools.add(menuItem_launcher); |
|
668 |
menu_tools.add(new JMenuItem(new LauncherAction())); |
|
669 |
menu_tools.addSeparator(); |
|
670 |
menu_tools.add(new JMenuItem(new PackageScriptAction())); |
|
671 |
menu_tools.add(new JMenuItem(new PackageHelpAction())); |
|
672 |
menu_tools.addSeparator(); |
|
673 |
|
|
674 |
JMenu menu_tools_javadoc = new JMenu(this.uimanager.getTranslation("Help")); |
|
675 |
menu_tools_javadoc.add(new JMenuItem(new RemoveHelpAction())); |
|
676 |
menu_tools_javadoc.add(new JMenuItem(new IndexHelpAction())); |
|
677 |
menu_tools_javadoc.addSeparator(); |
|
678 |
menu_tools_javadoc.add(new JMenuItem(new ImportJavadocAction())); |
|
679 |
menu_tools.add(menu_tools_javadoc); |
|
680 |
|
|
283 | 681 |
|
284 |
JMenuItem menuItem_packager = new JMenuItem(this.uimanager.getTranslation("_Scripting_packager")); |
|
285 |
menuItem_packager.addActionListener(new ActionListener() { |
|
286 |
|
|
287 |
@Override |
|
288 |
public void actionPerformed(ActionEvent ae) { |
|
289 |
createPackage(); |
|
290 |
} |
|
291 |
}); |
|
292 |
menu_tools.add(menuItem_packager); |
|
293 |
|
|
294 | 682 |
JMenu menu_help = new JMenu("Help"); |
295 |
JMenuItem menuItem_import = new JMenuItem(this.uimanager.getTranslation("Import_JavaDoc"), uimanager.getIcon("list-add")); |
|
296 |
menuItem_import.addActionListener(new ActionListener() { |
|
297 |
@Override |
|
298 |
public void actionPerformed(ActionEvent e) { |
|
299 |
getWindowManager().showWindow(getImportHelpDialog(), uimanager.getTranslation("JavaDoc"), WindowManager.MODE.WINDOW); |
|
300 |
} |
|
301 |
}); |
|
302 |
menu_help.add(menuItem_import); |
|
303 |
JMenuItem menuItem_remove = new JMenuItem(this.uimanager.getTranslation("Remove_JavaDoc"), uimanager.getIcon("list-remove")); |
|
304 |
menuItem_remove.addActionListener(new ActionListener() { |
|
305 |
@Override |
|
306 |
public void actionPerformed(ActionEvent e) { |
|
307 |
try { |
|
308 |
getRemoveHelpDialog(); |
|
309 |
} catch (Exception e1) { |
|
310 |
// TODO Auto-generated catch block |
|
311 |
e1.printStackTrace(); |
|
312 |
} |
|
313 |
} |
|
314 |
}); |
|
315 |
menu_help.add(menuItem_remove); |
|
316 |
JMenuItem menuItem_show = new JMenuItem(this.uimanager.getTranslation("Show_JavaDoc"), uimanager.getIcon("help-browser")); |
|
317 |
menuItem_show.addActionListener(new ActionListener() { |
|
318 |
@Override |
|
319 |
public void actionPerformed(ActionEvent e) { |
|
320 |
getWindowManager().showWindow(uimanager.getAPIHelp(), uimanager.getTranslation("JavaDoc"), WindowManager.MODE.WINDOW); |
|
321 |
} |
|
322 |
}); |
|
323 |
menu_help.add(menuItem_show); |
|
683 |
menu_help.add(new JMenuItem(new HelpAction())); |
|
324 | 684 |
menu_help.addSeparator(); |
325 |
JMenuItem menuItem_about = new JMenuItem(this.uimanager.getTranslation("About_us"), uimanager.getIcon("system-users")); |
|
326 |
menuItem_about.addActionListener(new ActionListener() { |
|
327 |
@Override |
|
328 |
public void actionPerformed(ActionEvent e) { |
|
329 |
getWindowManager().showWindow(getAboutUsDialog(), uimanager.getTranslation("About_us"), WindowManager.MODE.WINDOW); |
|
685 |
menu_help.add(new JMenuItem(new AboutAction())); |
|
330 | 686 |
|
331 |
} |
|
332 |
}); |
|
333 |
menu_help.add(menuItem_about); |
|
334 |
JMenuItem menuItem_help = new JMenuItem(this.uimanager.getTranslation("Get_help"), uimanager.getIcon("help-browser")); |
|
335 |
menuItem_help.addActionListener(new ActionListener() { |
|
336 |
@Override |
|
337 |
public void actionPerformed(ActionEvent e) { |
|
338 |
getWindowManager().showWindow(uimanager.getUserHelp(), uimanager.getTranslation("Get_help"), WindowManager.MODE.WINDOW); |
|
339 |
} |
|
340 |
}); |
|
341 |
menu_help.add(menuItem_help); |
|
342 |
|
|
343 | 687 |
menuBar.add(menu_file); |
344 | 688 |
menuBar.add(menu_edit); |
345 | 689 |
menuBar.add(menu_tools); |
346 | 690 |
menuBar.add(menu_help); |
347 | 691 |
|
348 |
// Botones de acción
|
|
692 |
// Botones |
|
349 | 693 |
file = new JToolBar(); |
350 | 694 |
help = new JToolBar(); |
351 | 695 |
edit = new JToolBar(); |
... | ... | |
370 | 714 |
launcherPane.add(launcher, BorderLayout.CENTER); |
371 | 715 |
launcherPane.add(launcherButtons, BorderLayout.WEST); |
372 | 716 |
|
373 |
// Panel de Edición
|
|
717 |
// Panel de Edicion
|
|
374 | 718 |
scriptEditors = new JTabbedPane(); |
375 | 719 |
scriptEditors.addChangeListener(new ChangeListener() { |
376 | 720 |
public void stateChanged(ChangeEvent arg0) { |
... | ... | |
393 | 737 |
tableModel.addColumn(this.uimanager.getTranslation("Location")); |
394 | 738 |
table = new JTable(tableModel); |
395 | 739 |
table.getColumnModel().getColumn(0).setPreferredWidth(300); |
396 |
//table.setFont(new Font("Serif",Font.PLAIN,13)); |
|
397 | 740 |
|
398 | 741 |
table.getSelectionModel().addListSelectionListener(new RowListener()); |
399 | 742 |
table.setRowSelectionAllowed(true); |
... | ... | |
402 | 745 |
JScrollPane scrollProblems = new JScrollPane(table); |
403 | 746 |
scrollProblems.setAutoscrolls(true); |
404 | 747 |
|
405 |
console = new JTextArea(); |
|
406 |
console.setFont(new Font("monospaced", Font.PLAIN, 13)); |
|
748 |
console = new DefaultJScriptingConsole(); |
|
407 | 749 |
|
408 |
JScrollPane scrollConsole = new JScrollPane(console); |
|
409 | 750 |
problemsPane.add(this.uimanager.getTranslation("Problems"), scrollProblems); |
410 |
problemsPane.add(this.uimanager.getTranslation("Console"), scrollConsole);
|
|
751 |
problemsPane.add(this.uimanager.getTranslation("Console"), console.asJComponent());
|
|
411 | 752 |
problemsPane.setPreferredSize(new Dimension(450, 100)); |
412 | 753 |
problemsPane.setSelectedIndex(1); |
413 | 754 |
|
... | ... | |
450 | 791 |
this.setPreferredSize(new Dimension(800, 600)); |
451 | 792 |
} |
452 | 793 |
|
453 |
private void createPackage() { |
|
794 |
private void createScriptPackage() {
|
|
454 | 795 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
455 | 796 |
SwingInstallerManager installerManager = SwingInstallerLocator.getSwingInstallerManager(); |
456 | 797 |
PackageBuildder packager = installerManager.createPackagerPanel( |
... | ... | |
474 | 815 |
); |
475 | 816 |
} |
476 | 817 |
|
477 |
private PrintStream getConsolePrintStream() { |
|
478 |
if (this.consolePrintStream == null) { |
|
479 |
JTextAreaOutputStream outputConsole = new JTextAreaOutputStream(console); |
|
480 |
this.consolePrintStream = new PrintStream(outputConsole); |
|
481 |
} |
|
482 |
return this.consolePrintStream; |
|
818 |
private void createHelpPackage() { |
|
819 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
820 |
SwingInstallerManager installerManager = SwingInstallerLocator.getSwingInstallerManager(); |
|
821 |
|
|
822 |
PackageBuildder packager = installerManager.createPackagerPanel( |
|
823 |
ScriptingManager.HELP_INSTALLER_PROVIDER_NAME, |
|
824 |
manager.getHelpManager().getHelpRoots().get(0), |
|
825 |
manager.getPackagesFolder() |
|
826 |
); |
|
827 |
PackageInfo packageInfo = packager.getPackageInfo(); |
|
828 |
packageInfo.setArchitecture(PackageManager.ARCH.ALL); |
|
829 |
packageInfo.setJavaVM(PackageManager.JVM.J1_7); |
|
830 |
packageInfo.setOperatingSystem(PackageManager.OS.ALL); |
|
831 |
packageInfo.setOfficial(false); |
|
832 |
packageInfo.setState(PackageManager.STATE.TESTING); |
|
833 |
packageInfo.setType(ScriptingManager.INSTALLER_PROVIDER_NAME); |
|
834 |
Version version = ToolsLocator.getPackageManager().createVersion(); |
|
835 |
version.parse("1.0.0"); |
|
836 |
packageInfo.setVersion(version); |
|
837 |
this.uimanager.showWindow( |
|
838 |
(JPanel) packager.asJComponent(), |
|
839 |
i18nManager.getTranslation("_Help_scripting_packager") |
|
840 |
); |
|
483 | 841 |
} |
484 | 842 |
|
485 | 843 |
private class AbstractTableModel extends DefaultTableModel { |
... | ... | |
576 | 934 |
} |
577 | 935 |
} |
578 | 936 |
|
937 |
private JButton createButton(Action action) { |
|
938 |
JButton btn = new JButton(action); |
|
939 |
btn.setBorderPainted(false); |
|
940 |
btn.setText(""); |
|
941 |
return btn; |
|
942 |
} |
|
579 | 943 |
/** |
580 | 944 |
* Funciones para obtener las botoneras en función del tipo de |
581 | 945 |
* ScriptingBaseScript que se esté mostrando en ese momento. Está la |
... | ... | |
591 | 955 |
edit.removeAll(); |
592 | 956 |
script.removeAll(); |
593 | 957 |
help.removeAll(); |
594 |
JButton newb = new JButton(uimanager.getIcon("document-new")); |
|
595 |
newb.setToolTipText(this.uimanager.getTranslation("New")); |
|
596 |
newb.setBorderPainted(false); |
|
597 |
newb.addActionListener(new ActionListener() { |
|
598 |
public void actionPerformed(ActionEvent e) { |
|
599 |
try { |
|
600 |
scriptNew(); |
|
601 |
} catch (Exception e1) { |
|
602 |
// TODO Auto-generated catch block |
|
603 |
e1.printStackTrace(); |
|
604 |
} |
|
605 |
} |
|
606 |
}); |
|
607 |
file.add(newb); |
|
958 |
|
|
959 |
file.add(createButton(new NewDocumentAction())); |
|
608 | 960 |
file.repaint(); |
609 | 961 |
|
610 |
help.removeAll(); |
|
611 |
JButton helpb = new JButton(uimanager.getIcon("help-browser")); |
|
612 |
helpb.setBorderPainted(false); |
|
613 |
helpb.setToolTipText(this.uimanager.getTranslation("Help")); |
|
614 |
helpb.addActionListener(new ActionListener() { |
|
615 |
public void actionPerformed(ActionEvent e) { |
|
616 |
uimanager.showWindow(uimanager.getAPIHelp(), uimanager.getTranslation("JavaDoc")); |
|
617 |
} |
|
618 |
}); |
|
619 |
help.add(helpb); |
|
962 |
help.add(createButton(new HelpAction())); |
|
620 | 963 |
help.repaint(); |
964 |
|
|
621 | 965 |
edit.setVisible(false); |
622 | 966 |
script.setVisible(false); |
623 | 967 |
} |
624 | 968 |
|
625 | 969 |
private void setButtonsScript() { |
626 |
file.removeAll(); |
|
627 |
edit.removeAll(); |
|
628 |
script.removeAll(); |
|
629 | 970 |
setButtonsDefault(); |
630 | 971 |
|
631 | 972 |
edit.setVisible(true); |
632 | 973 |
script.setVisible(true); |
974 |
|
|
633 | 975 |
setButtonsEdit(); |
634 |
JButton close = new JButton(uimanager.getIcon("emblem-unreadable")); |
|
635 |
close.setBorderPainted(false); |
|
636 |
close.setToolTipText(this.uimanager.getTranslation("Close_current_tab")); |
|
637 |
close.addActionListener(new ActionListener() { |
|
638 |
public void actionPerformed(ActionEvent e) { |
|
639 |
currentScriptClose(); |
|
640 |
} |
|
641 |
}); |
|
642 |
file.add(close); |
|
643 |
JButton save = new JButton(uimanager.getIcon("media-floppy")); |
|
644 |
save.setBorderPainted(false); |
|
645 |
save.setToolTipText(this.uimanager.getTranslation("Save")); |
|
646 |
save.addActionListener(new ActionListener() { |
|
647 |
public void actionPerformed(ActionEvent e) { |
|
648 |
currentScriptSave(); |
|
649 |
} |
|
650 |
}); |
|
651 |
file.add(save); |
|
976 |
|
|
977 |
file.add(createButton(new CloseDocumentAction())); |
|
978 |
file.add(createButton(new SaveAction())); |
|
652 | 979 |
file.repaint(); |
653 | 980 |
|
654 |
JButton run = new JButton(uimanager.getIcon("applications-system")); |
|
655 |
run.setBorderPainted(false); |
|
656 |
run.setToolTipText(this.uimanager.getTranslation("Run")); |
|
657 |
run.addActionListener(new ActionListener() { |
|
658 |
public void actionPerformed(ActionEvent e) { |
|
659 |
currentScriptExecute(); |
|
660 |
} |
|
661 |
}); |
|
662 |
script.add(run); |
|
981 |
script.add(createButton(new RunAction())); |
|
663 | 982 |
script.repaint(); |
664 | 983 |
} |
665 | 984 |
|
666 | 985 |
private void setButtonsDialog() { |
667 |
script.removeAll(); |
|
668 | 986 |
setButtonsScript(); |
987 |
|
|
669 | 988 |
script.addSeparator(); |
670 |
JButton help = new JButton(uimanager.getIcon("help-browser")); |
|
671 |
help.setBorderPainted(false); |
|
672 |
help.setToolTipText(this.uimanager.getTranslation("Help")); |
|
673 |
script.add(help); |
|
989 |
script.add(createButton(new HelpAction())); |
|
674 | 990 |
script.repaint(); |
675 | 991 |
} |
676 | 992 |
|
677 | 993 |
private void setButtonsEdit() { |
678 |
JButton cut = new JButton(uimanager.getIcon("edit-cut")); |
|
679 |
cut.setBorderPainted(false); |
|
680 |
cut.setToolTipText(this.uimanager.getTranslation("Cut")); |
|
681 |
cut.addActionListener(new ActionListener() { |
|
682 |
public void actionPerformed(ActionEvent e) { |
|
683 |
currentScriptCut(); |
|
684 |
} |
|
685 |
}); |
|
686 |
edit.add(cut); |
|
687 |
JButton copy = new JButton(uimanager.getIcon("edit-copy")); |
|
688 |
copy.setBorderPainted(false); |
|
689 |
copy.setToolTipText(this.uimanager.getTranslation("Copy")); |
|
690 |
copy.addActionListener(new ActionListener() { |
|
691 |
public void actionPerformed(ActionEvent e) { |
|
692 |
currentScriptCopy(); |
|
693 |
} |
|
694 |
}); |
|
695 |
edit.add(copy); |
|
696 |
JButton paste = new JButton(uimanager.getIcon("edit-paste")); |
|
697 |
paste.setBorderPainted(false); |
|
698 |
paste.setToolTipText(this.uimanager.getTranslation("Paste")); |
|
699 |
paste.addActionListener(new ActionListener() { |
|
700 |
public void actionPerformed(ActionEvent e) { |
|
701 |
currentScriptPaste(); |
|
702 |
} |
|
703 |
}); |
|
704 |
edit.add(paste); |
|
994 |
edit.add(createButton(new CutAction())); |
|
995 |
edit.add(createButton(new CopyAction())); |
|
996 |
edit.add(createButton(new PasteAction())); |
|
705 | 997 |
edit.repaint(); |
706 | 998 |
} |
707 | 999 |
|
... | ... | |
710 | 1002 |
* |
711 | 1003 |
*/ |
712 | 1004 |
private void setButtonsLauncherPanel() { |
713 |
|
|
714 |
JButton newb = new JButton(uimanager.getIcon("document-new")); |
|
715 |
newb.setBorderPainted(false); |
|
716 |
newb.setToolTipText(this.uimanager.getTranslation("New")); |
|
717 |
newb.addActionListener(new ActionListener() { |
|
718 |
public void actionPerformed(ActionEvent e) { |
|
719 |
try { |
|
720 |
scriptNew(); |
|
721 |
} catch (Exception e1) { |
|
722 |
// TODO Auto-generated catch block |
|
723 |
e1.printStackTrace(); |
|
724 |
} |
|
725 |
} |
|
726 |
}); |
|
727 |
launcherButtons.add(newb); |
|
728 |
JButton edit = new JButton(uimanager.getIcon("applications-accessories")); |
|
729 |
edit.setBorderPainted(false); |
|
730 |
edit.setToolTipText(this.uimanager.getTranslation("Open_edition_mode")); |
|
731 |
edit.addActionListener(new ActionListener() { |
|
732 |
public void actionPerformed(ActionEvent e) { |
|
733 |
scriptEdit((ScriptingBaseScript)getLauncherSelectedScript()); |
|
734 |
} |
|
735 |
}); |
|
736 |
launcherButtons.add(edit); |
|
737 |
JButton run = new JButton(uimanager.getIcon("applications-system")); |
|
738 |
run.setBorderPainted(false); |
|
739 |
run.setToolTipText(this.uimanager.getTranslation("Run_selected_script")); |
|
740 |
run.addActionListener(new ActionListener() { |
|
741 |
public void actionPerformed(ActionEvent e) { |
|
742 |
scriptExecute(getLauncherSelectedScript()); |
|
743 |
} |
|
744 |
}); |
|
745 |
launcherButtons.add(run); |
|
1005 |
launcherButtons.add(createButton(new NewDocumentAction())); |
|
1006 |
launcherButtons.add(createButton(new EditAction())); |
|
1007 |
launcherButtons.add(createButton(new RunAction())); |
|
746 | 1008 |
launcherButtons.addSeparator(); |
747 |
JButton refresh = new JButton(uimanager.getIcon("view-refresh")); |
|
748 |
refresh.setBorderPainted(false); |
|
749 |
refresh.setToolTipText(this.uimanager.getTranslation("Refresh_directories")); |
|
750 |
refresh.addActionListener(new ActionListener() { |
|
751 |
public void actionPerformed(ActionEvent e) { |
|
752 |
launcherRefresh(); |
|
753 |
} |
|
754 |
}); |
|
755 |
launcherButtons.add(refresh); |
|
1009 |
launcherButtons.add(createButton(new RefreshTreeAction())); |
|
756 | 1010 |
launcherButtons.addSeparator(); |
757 |
JButton rename = new JButton(uimanager.getIcon("preferences-system")); |
|
758 |
rename.setBorderPainted(false); |
|
759 |
rename.setToolTipText(this.uimanager.getTranslation("Set_file_properties")); |
|
760 |
rename.addActionListener(new ActionListener() { |
|
761 |
public void actionPerformed(ActionEvent e) { |
|
762 |
try { |
|
763 |
scriptRename(getLauncherSelectedScript()); |
|
764 |
} catch (Exception e1) { |
|
765 |
// TODO Auto-generated catch block |
|
766 |
e1.printStackTrace(); |
|
767 |
} |
|
768 |
} |
|
769 |
}); |
|
770 |
launcherButtons.add(rename); |
|
771 |
JButton move = new JButton(uimanager.getIcon("format-indent-more")); |
|
772 |
move.setBorderPainted(false); |
|
773 |
move.setToolTipText(this.uimanager.getTranslation("Move_files")); |
|
774 |
move.addActionListener(new ActionListener() { |
|
775 |
public void actionPerformed(ActionEvent e) { |
|
776 |
try { |
|
777 |
scriptMove(getLauncherSelectedScript()); |
|
778 |
} catch (Exception e1) { |
|
779 |
// TODO Auto-generated catch block |
|
780 |
e1.printStackTrace(); |
|
781 |
} |
|
782 |
} |
|
783 |
}); |
|
784 |
launcherButtons.add(move); |
|
1011 |
launcherButtons.add(createButton(new RenameAction())); |
|
1012 |
launcherButtons.add(createButton(new MoveAction())); |
|
785 | 1013 |
launcherButtons.addSeparator(); |
786 |
JButton delete = new JButton(uimanager.getIcon("user-trash")); |
|
787 |
delete.setBorderPainted(false); |
|
788 |
delete.setToolTipText(this.uimanager.getTranslation("Delete_selected_script")); |
|
789 |
delete.addActionListener(new ActionListener() { |
|
790 |
public void actionPerformed(ActionEvent e) { |
|
791 |
scriptDelete(getLauncherSelectedScript(), false); |
|
792 |
} |
|
793 |
}); |
|
794 |
launcherButtons.add(delete); |
|
1014 |
launcherButtons.add(createButton(new DeleteAction())); |
|
795 | 1015 |
} |
796 | 1016 |
|
797 | 1017 |
/** |
... | ... | |
907 | 1127 |
this.uimanager.getTranslation("Deleting_JavaDocs_successfully"), |
908 | 1128 |
this.uimanager.getTranslation("Deleting_JavaDocs_successfully_title"), |
909 | 1129 |
JOptionPane.INFORMATION_MESSAGE); |
910 |
uimanager.showWindow(uimanager.getAPIHelp(), this.uimanager.getTranslation("JavaDoc"));
|
|
1130 |
uimanager.showWindow(uimanager.getHelp(), this.uimanager.getTranslation("JavaDoc")); |
|
911 | 1131 |
} |
912 | 1132 |
|
913 | 1133 |
public void scriptMove(final ScriptingUnit theUnit) throws Exception { |
... | ... | |
1251 | 1471 |
|
1252 | 1472 |
/** |
1253 | 1473 |
* |
1474 |
* @param e |
|
1254 | 1475 |
*/ |
1255 | 1476 |
public void actionPerformed(ActionEvent e) { |
1256 | 1477 |
|
... | ... | |
1320 | 1541 |
} else if (e.getException() instanceof ExecuteErrorException) { |
1321 | 1542 |
ExecuteErrorException ee = (ExecuteErrorException) e.getException(); |
1322 | 1543 |
errorsAdd(ee.getMessage(), ee.getScriptName(), ee.getLineNumber(), ee.getColumnNumber()); |
1323 |
consolePrintln(ee.getMessage()); |
|
1324 |
ee.printStackTrace(this.getConsolePrintStream());
|
|
1544 |
consolePrintln(ee.getMessage(), Color.RED.darker());
|
|
1545 |
ee.printStackTrace(this.console.getStderr());
|
|
1325 | 1546 |
|
1326 | 1547 |
} else { |
1327 | 1548 |
Throwable ex = e.getException(); |
1328 | 1549 |
errorsAdd(ex.getMessage()); |
1329 |
consolePrintln(ex.getMessage()); |
|
1330 |
ex.printStackTrace(this.getConsolePrintStream());
|
|
1550 |
consolePrintln(ex.getMessage(), Color.RED.darker());
|
|
1551 |
ex.printStackTrace(this.console.getStderr());
|
|
1331 | 1552 |
} |
1332 | 1553 |
} |
1333 | 1554 |
} |
... | ... | |
1385 | 1606 |
}); |
1386 | 1607 |
return; |
1387 | 1608 |
} |
1388 |
console.setText("");
|
|
1609 |
console.clear();
|
|
1389 | 1610 |
problemsPane.setSelectedIndex(1); |
1390 | 1611 |
} |
1391 | 1612 |
|
1392 |
public void consolePrintln(final String str) { |
|
1613 |
public void consolePrintln(final String str, final Color color) {
|
|
1393 | 1614 |
if (!SwingUtilities.isEventDispatchThread()) { |
1394 | 1615 |
SwingUtilities.invokeLater(new Runnable() { |
1395 | 1616 |
public void run() { |
1396 |
consolePrintln(str); |
|
1617 |
consolePrintln(str, color);
|
|
1397 | 1618 |
} |
1398 | 1619 |
}); |
1399 | 1620 |
return; |
1400 | 1621 |
} |
1401 |
console.append(str); |
|
1622 |
console.append(str, color);
|
|
1402 | 1623 |
console.append("\n"); |
1403 | 1624 |
problemsPane.setSelectedIndex(1); |
1404 | 1625 |
} |
... | ... | |
1430 | 1651 |
} |
1431 | 1652 |
return (RSyntaxTextArea)textComponent; |
1432 | 1653 |
} |
1433 |
|
|
1434 |
private class GoToLineAction extends AbstractAction { |
|
1435 |
|
|
1436 |
public GoToLineAction() { |
|
1437 |
super("Go To Line..."); |
|
1438 |
int c = getToolkit().getMenuShortcutKeyMask(); |
|
1439 |
putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_L, c)); |
|
1440 |
} |
|
1441 |
|
|
1442 |
public void actionPerformed(ActionEvent e) { |
|
1443 |
|
|
1444 |
RSyntaxTextArea textArea = getCurrentRSyntaxTextArea(); |
|
1445 |
if (textArea == null) { |
|
1446 |
return; |
|
1447 |
} |
|
1448 |
|
|
1449 |
if (findDialog.isVisible()) { |
|
1450 |
findDialog.setVisible(false); |
|
1451 |
} |
|
1452 |
if (replaceDialog.isVisible()) { |
|
1453 |
replaceDialog.setVisible(false); |
|
1454 |
} |
|
1455 |
gotoDialog.setMaxLineNumberAllowed(textArea.getLineCount()); |
|
1456 |
gotoDialog.setVisible(true); |
|
1457 |
int line = gotoDialog.getLineNumber(); |
|
1458 |
if (line > 0) { |
|
1459 |
try { |
|
1460 |
textArea.setCaretPosition(textArea.getLineStartOffset(line - 1)); |
|
1461 |
} catch (BadLocationException ble) { // Never happens |
|
1462 |
UIManager.getLookAndFeel().provideErrorFeedback(textArea); |
|
1463 |
ble.printStackTrace(); |
|
1464 |
} |
|
1465 |
} |
|
1466 |
} |
|
1467 |
} |
|
1468 |
|
|
1469 |
private class ShowFindDialogAction extends AbstractAction { |
|
1470 |
|
|
1471 |
public ShowFindDialogAction() { |
|
1472 |
super("Find..."); |
|
1473 |
int c = getToolkit().getMenuShortcutKeyMask(); |
|
1474 |
putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_F, c)); |
|
1475 |
} |
|
1476 |
|
|
1477 |
public void actionPerformed(ActionEvent e) { |
|
1478 |
if (replaceDialog.isVisible()) { |
|
1479 |
replaceDialog.setVisible(false); |
|
1480 |
} |
|
1481 |
findDialog.setVisible(true); |
|
1482 |
} |
|
1483 |
} |
|
1484 | 1654 |
|
1485 |
private class ShowReplaceDialogAction extends AbstractAction { |
|
1486 |
|
|
1487 |
public ShowReplaceDialogAction() { |
|
1488 |
super("Replace..."); |
|
1489 |
int c = getToolkit().getMenuShortcutKeyMask(); |
|
1490 |
putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_H, c)); |
|
1491 |
} |
|
1492 |
|
|
1493 |
public void actionPerformed(ActionEvent e) { |
|
1494 |
if (findDialog.isVisible()) { |
|
1495 |
findDialog.setVisible(false); |
|
1496 |
} |
|
1497 |
replaceDialog.setVisible(true); |
|
1498 |
} |
|
1499 |
} |
|
1500 |
|
|
1501 | 1655 |
@Override |
1502 | 1656 |
public void searchEvent(SearchEvent e) { |
1503 | 1657 |
|
Also available in: Unified diff