Revision 301 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 | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import java.awt.BorderLayout; |
4 | 4 |
import java.awt.Dimension; |
5 |
import java.awt.Font; |
|
5 | 6 |
import java.awt.event.ActionEvent; |
6 | 7 |
import java.awt.event.ActionListener; |
7 | 8 |
import java.io.File; |
8 | 9 |
import java.io.OutputStream; |
10 |
import java.io.PrintStream; |
|
9 | 11 |
import java.util.ArrayList; |
10 | 12 |
import java.util.Iterator; |
11 | 13 |
import java.util.List; |
12 | 14 |
|
13 |
import javax.script.ScriptException; |
|
14 | 15 |
import javax.swing.JButton; |
15 | 16 |
import javax.swing.JEditorPane; |
16 | 17 |
import javax.swing.JLabel; |
... | ... | |
27 | 28 |
import javax.swing.JToolBar; |
28 | 29 |
import javax.swing.ListSelectionModel; |
29 | 30 |
import javax.swing.SwingConstants; |
31 |
import javax.swing.SwingUtilities; |
|
30 | 32 |
import javax.swing.event.ChangeEvent; |
31 | 33 |
import javax.swing.event.ChangeListener; |
32 | 34 |
import javax.swing.event.ListSelectionEvent; |
33 | 35 |
import javax.swing.event.ListSelectionListener; |
34 | 36 |
import javax.swing.table.DefaultTableModel; |
35 | 37 |
|
38 |
import org.gvsig.scripting.CompileErrorException; |
|
39 |
import org.gvsig.scripting.ExecuteErrorException; |
|
36 | 40 |
import org.gvsig.scripting.ScriptingBaseScript; |
37 | 41 |
import org.gvsig.scripting.ScriptingDialog; |
38 | 42 |
import org.gvsig.scripting.ScriptingFolder; |
... | ... | |
52 | 56 |
import org.gvsig.scripting.swing.impl.composer.DefaultJCodeEditor.EditorActionEvent; |
53 | 57 |
import org.gvsig.tools.observer.Observable; |
54 | 58 |
import org.gvsig.tools.observer.Observer; |
59 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
60 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
|
61 |
import org.gvsig.tools.task.AbstractMonitorableTask; |
|
62 |
import org.gvsig.tools.task.SimpleTaskStatus; |
|
55 | 63 |
|
56 | 64 |
|
57 | 65 |
public class DefaultJScriptingComposer extends JScriptingComposer implements Observer, ActionListener{ |
... | ... | |
86 | 94 |
JTextArea console; |
87 | 95 |
DefaultJScriptingLauncher launcher; |
88 | 96 |
JToolBar launcherButtons; |
89 |
|
|
97 |
PrintStream consolePrintStream = null; |
|
98 |
WindowManager windowsManager = null; |
|
99 |
|
|
90 | 100 |
/* JFrame para la creación de nuevos ScriptingBaseScripts o modificación de atributos */ |
91 | 101 |
//JFrame NewUnitFrame; |
92 | 102 |
|
... | ... | |
104 | 114 |
loader = this.getClass().getClassLoader(); |
105 | 115 |
this.uimanager = uimanager; |
106 | 116 |
this.manager = uimanager.getManager(); |
117 |
this.setWindowManager( ToolsSwingLocator.getWindowManager()); |
|
107 | 118 |
|
108 | 119 |
unitsEditor = new ArrayList<JEditor>(); |
109 | 120 |
|
110 |
// Barra de menú |
|
121 |
initUI(); |
|
122 |
|
|
123 |
System.setOut(this.getConsolePrintStream()); |
|
124 |
System.setErr(this.getConsolePrintStream()); |
|
125 |
|
|
126 |
} |
|
127 |
|
|
128 |
public WindowManager getWindowManager() { |
|
129 |
return this.windowsManager; |
|
130 |
} |
|
131 |
|
|
132 |
public void setWindowManager(WindowManager windowsManager) { |
|
133 |
this.windowsManager = windowsManager; |
|
134 |
} |
|
135 |
|
|
136 |
private void initUI() { |
|
137 |
// Barra de menu |
|
111 | 138 |
menuBar = new JMenuBar(); |
112 | 139 |
|
113 |
// Construimos los componentes del menú
|
|
140 |
// Construimos los componentes del menu
|
|
114 | 141 |
JMenu menu_file = new JMenu("File"); |
115 | 142 |
JMenuItem menuItem_new = new JMenuItem("New",uimanager.getIcon("document-new")); |
116 | 143 |
menuItem_new.addActionListener(new ActionListener(){ |
... | ... | |
204 | 231 |
JMenuItem menuItem_launcher = new JMenuItem("Launcher"); |
205 | 232 |
menuItem_launcher.addActionListener(new ActionListener(){ |
206 | 233 |
public void actionPerformed(ActionEvent e) { |
207 |
uimanager.showTool(uimanager.createLauncher(), "Scripting Launcher");
|
|
234 |
getWindowManager().showWindow(uimanager.createLauncher(), "Scripting Launcher", WindowManager.MODE.TOOL);
|
|
208 | 235 |
} |
209 | 236 |
}); |
210 | 237 |
menu_tools.add(menuItem_launcher); |
... | ... | |
214 | 241 |
JMenuItem menuItem_import = new JMenuItem("Import JavaDoc",uimanager.getIcon("list-add")); |
215 | 242 |
menuItem_import.addActionListener(new ActionListener(){ |
216 | 243 |
public void actionPerformed(ActionEvent e) { |
217 |
getImportHelpDialog();
|
|
244 |
getWindowManager().showWindow(getImportHelpDialog(), "JavaDoc", WindowManager.MODE.WINDOW);
|
|
218 | 245 |
} |
219 | 246 |
}); |
220 | 247 |
menu_help.add(menuItem_import); |
... | ... | |
233 | 260 |
JMenuItem menuItem_show = new JMenuItem("Show JavaDoc",uimanager.getIcon("help-browser")); |
234 | 261 |
menuItem_show.addActionListener(new ActionListener(){ |
235 | 262 |
public void actionPerformed(ActionEvent e) { |
236 |
uimanager.showWindow(uimanager.getAPIHelp(),"JavaDoc");
|
|
263 |
getWindowManager().showWindow(uimanager.getAPIHelp(), "JavaDoc", WindowManager.MODE.WINDOW);
|
|
237 | 264 |
} |
238 | 265 |
}); |
239 | 266 |
menu_help.add(menuItem_show); |
... | ... | |
241 | 268 |
JMenuItem menuItem_about = new JMenuItem("About us",uimanager.getIcon("system-users")); |
242 | 269 |
menuItem_about.addActionListener(new ActionListener(){ |
243 | 270 |
public void actionPerformed(ActionEvent e) { |
244 |
getAboutUsDialog(); |
|
271 |
getWindowManager().showWindow(getAboutUsDialog(), "About", WindowManager.MODE.WINDOW); |
|
272 |
|
|
245 | 273 |
} |
246 | 274 |
}); |
247 | 275 |
menu_help.add(menuItem_about); |
248 | 276 |
JMenuItem menuItem_help = new JMenuItem("Get help",uimanager.getIcon("help-browser")); |
249 | 277 |
menuItem_help.addActionListener(new ActionListener(){ |
250 | 278 |
public void actionPerformed(ActionEvent e) { |
251 |
uimanager.showWindow(uimanager.getUserHelp(),"Scripting Framework Help");
|
|
279 |
getWindowManager().showWindow(uimanager.getUserHelp(), "Scripting Framework Help", WindowManager.MODE.WINDOW);
|
|
252 | 280 |
} |
253 | 281 |
}); |
254 | 282 |
menu_help.add(menuItem_help); |
... | ... | |
317 | 345 |
scrollProblems.setAutoscrolls(true); |
318 | 346 |
|
319 | 347 |
console = new JTextArea(); |
320 |
/* Descomentarizar cuando se quiera redirigir la salida estándar |
|
321 |
* a la consola de la aplicación*/ |
|
348 |
console.setFont(new Font("monospaced",Font.PLAIN,13)); |
|
322 | 349 |
|
323 |
/*JTextAreaOutputStream outputConsole = new JTextAreaOutputStream(console); |
|
324 |
outputConsole.ta.setFont(new Font("Serif",Font.PLAIN,13)); |
|
325 |
System.setOut(new PrintStream(outputConsole)); |
|
326 |
System.setErr(new PrintStream(outputConsole));*/ |
|
327 |
|
|
328 | 350 |
JScrollPane scrollConsole = new JScrollPane(console); |
329 | 351 |
problemsPane.add("Problems", scrollProblems); |
330 | 352 |
problemsPane.add("Console", scrollConsole); |
... | ... | |
370 | 392 |
this.setPreferredSize(new Dimension(800,600)); |
371 | 393 |
} |
372 | 394 |
|
395 |
private PrintStream getConsolePrintStream() { |
|
396 |
if( this.consolePrintStream == null ) { |
|
397 |
JTextAreaOutputStream outputConsole = new JTextAreaOutputStream(console); |
|
398 |
this.consolePrintStream = new PrintStream(outputConsole); |
|
399 |
} |
|
400 |
return this.consolePrintStream; |
|
401 |
} |
|
402 |
|
|
373 | 403 |
private class AbstractTableModel extends DefaultTableModel { |
374 | 404 |
|
375 | 405 |
/** |
... | ... | |
390 | 420 |
return; |
391 | 421 |
} |
392 | 422 |
if(!table.getSelectionModel().isSelectionEmpty()){ |
393 |
String[] line = ((String)table.getValueAt(table.getSelectionModel().getLeadSelectionIndex(), 2)).split(":"); |
|
394 |
int row = 0; |
|
395 |
if(line.length>2) |
|
396 |
row = Integer.parseInt(line[1].trim()); |
|
397 |
setEditorSelection(((String)table.getValueAt(table.getSelectionModel().getLeadSelectionIndex(), 1)), row); |
|
423 |
int index = table.getSelectionModel().getLeadSelectionIndex(); |
|
424 |
String[] lineAndColumn = ((String)table.getValueAt(index, 2)).split(":"); |
|
425 |
int line = -1; |
|
426 |
if(lineAndColumn.length>0) { |
|
427 |
try { |
|
428 |
line = Integer.parseInt(lineAndColumn[0].trim()); |
|
429 |
} catch (Exception e) { |
|
430 |
// Do nothing |
|
431 |
} |
|
432 |
} |
|
433 |
if( line >= 0 ) { |
|
434 |
setEditorSelection(((String)table.getValueAt(index, 1)), line); |
|
435 |
} |
|
398 | 436 |
} |
399 | 437 |
} |
400 | 438 |
} |
... | ... | |
480 | 518 |
help.removeAll(); |
481 | 519 |
JButton newb = new JButton(uimanager.getIcon("document-new")); |
482 | 520 |
newb.setToolTipText("New"); |
521 |
newb.setBorderPainted(false); |
|
483 | 522 |
newb.addActionListener(new ActionListener(){ |
484 | 523 |
public void actionPerformed(ActionEvent e) { |
485 | 524 |
try { |
... | ... | |
495 | 534 |
|
496 | 535 |
help.removeAll(); |
497 | 536 |
JButton helpb = new JButton(uimanager.getIcon("help-browser")); |
537 |
helpb.setBorderPainted(false); |
|
498 | 538 |
helpb.setToolTipText("Help"); |
499 | 539 |
helpb.addActionListener(new ActionListener(){ |
500 | 540 |
public void actionPerformed(ActionEvent e) { |
... | ... | |
517 | 557 |
script.setVisible(true); |
518 | 558 |
setEditButtons(); |
519 | 559 |
JButton close = new JButton(uimanager.getIcon("emblem-unreadable")); |
560 |
close.setBorderPainted(false); |
|
520 | 561 |
close.setToolTipText("Close current tab"); |
521 | 562 |
close.addActionListener(new ActionListener(){ |
522 | 563 |
public void actionPerformed(ActionEvent e) { |
... | ... | |
525 | 566 |
}); |
526 | 567 |
file.add(close); |
527 | 568 |
JButton save = new JButton(uimanager.getIcon("media-floppy")); |
569 |
save.setBorderPainted(false); |
|
528 | 570 |
save.setToolTipText("Save"); |
529 | 571 |
save.addActionListener(new ActionListener(){ |
530 | 572 |
public void actionPerformed(ActionEvent e) { |
... | ... | |
535 | 577 |
file.repaint(); |
536 | 578 |
|
537 | 579 |
JButton run = new JButton(uimanager.getIcon("applications-system")); |
580 |
run.setBorderPainted(false); |
|
538 | 581 |
run.setToolTipText("Run"); |
539 | 582 |
run.addActionListener(new ActionListener(){ |
540 | 583 |
public void actionPerformed(ActionEvent e) { |
... | ... | |
550 | 593 |
setScriptButtons(); |
551 | 594 |
script.addSeparator(); |
552 | 595 |
JButton help = new JButton(uimanager.getIcon("help-browser")); |
596 |
help.setBorderPainted(false); |
|
553 | 597 |
help.setToolTipText("Help"); |
554 | 598 |
script.add(help); |
555 | 599 |
script.repaint(); |
... | ... | |
557 | 601 |
|
558 | 602 |
private void setEditButtons(){ |
559 | 603 |
JButton cut = new JButton(uimanager.getIcon("edit-cut")); |
604 |
cut.setBorderPainted(false); |
|
560 | 605 |
cut.setToolTipText("Cut"); |
561 | 606 |
cut.addActionListener(new ActionListener(){ |
562 | 607 |
public void actionPerformed(ActionEvent e) { |
... | ... | |
565 | 610 |
}); |
566 | 611 |
edit.add(cut); |
567 | 612 |
JButton copy = new JButton(uimanager.getIcon("edit-copy")); |
613 |
copy.setBorderPainted(false); |
|
568 | 614 |
copy.setToolTipText("Copy"); |
569 | 615 |
copy.addActionListener(new ActionListener(){ |
570 | 616 |
public void actionPerformed(ActionEvent e) { |
... | ... | |
573 | 619 |
}); |
574 | 620 |
edit.add(copy); |
575 | 621 |
JButton paste = new JButton(uimanager.getIcon("edit-paste")); |
622 |
paste.setBorderPainted(false); |
|
576 | 623 |
paste.setToolTipText("Paste"); |
577 | 624 |
paste.addActionListener(new ActionListener(){ |
578 | 625 |
public void actionPerformed(ActionEvent e) { |
... | ... | |
590 | 637 |
private void setLauncherPaneButtons(){ |
591 | 638 |
|
592 | 639 |
JButton newb = new JButton(uimanager.getIcon("document-new")); |
640 |
newb.setBorderPainted(false); |
|
593 | 641 |
newb.setToolTipText("New"); |
594 | 642 |
newb.addActionListener(new ActionListener(){ |
595 | 643 |
public void actionPerformed(ActionEvent e) { |
... | ... | |
603 | 651 |
}); |
604 | 652 |
launcherButtons.add(newb); |
605 | 653 |
JButton edit = new JButton(uimanager.getIcon("applications-accessories")); |
654 |
edit.setBorderPainted(false); |
|
606 | 655 |
edit.setToolTipText("Open edition mode"); |
607 | 656 |
edit.addActionListener(new ActionListener(){ |
608 | 657 |
public void actionPerformed(ActionEvent e) { |
... | ... | |
611 | 660 |
}); |
612 | 661 |
launcherButtons.add(edit); |
613 | 662 |
JButton run = new JButton(uimanager.getIcon("applications-system")); |
663 |
run.setBorderPainted(false); |
|
614 | 664 |
run.setToolTipText("Run selected script"); |
615 | 665 |
run.addActionListener(new ActionListener(){ |
616 | 666 |
public void actionPerformed(ActionEvent e) { |
... | ... | |
620 | 670 |
launcherButtons.add(run); |
621 | 671 |
launcherButtons.addSeparator(); |
622 | 672 |
JButton refresh = new JButton(uimanager.getIcon("view-refresh")); |
673 |
refresh.setBorderPainted(false); |
|
623 | 674 |
refresh.setToolTipText("Refresh directories"); |
624 | 675 |
refresh.addActionListener(new ActionListener(){ |
625 | 676 |
public void actionPerformed(ActionEvent e) { |
... | ... | |
629 | 680 |
launcherButtons.add(refresh); |
630 | 681 |
launcherButtons.addSeparator(); |
631 | 682 |
JButton rename = new JButton(uimanager.getIcon("preferences-system")); |
683 |
rename.setBorderPainted(false); |
|
632 | 684 |
rename.setToolTipText("Set file properties"); |
633 | 685 |
rename.addActionListener(new ActionListener(){ |
634 | 686 |
public void actionPerformed(ActionEvent e) { |
... | ... | |
642 | 694 |
}); |
643 | 695 |
launcherButtons.add(rename); |
644 | 696 |
JButton move = new JButton(uimanager.getIcon("format-indent-more")); |
697 |
move.setBorderPainted(false); |
|
645 | 698 |
move.setToolTipText("Move files"); |
646 | 699 |
move.addActionListener(new ActionListener(){ |
647 | 700 |
public void actionPerformed(ActionEvent e){ |
... | ... | |
656 | 709 |
launcherButtons.add(move); |
657 | 710 |
launcherButtons.addSeparator(); |
658 | 711 |
JButton delete = new JButton(uimanager.getIcon("user-trash")); |
712 |
delete.setBorderPainted(false); |
|
659 | 713 |
delete.setToolTipText("Delete selected script"); |
660 | 714 |
delete.addActionListener(new ActionListener(){ |
661 | 715 |
public void actionPerformed(ActionEvent e) { |
... | ... | |
739 | 793 |
this.launcherRefresh(); |
740 | 794 |
} |
741 | 795 |
|
742 |
public void getImportHelpDialog(){
|
|
743 |
new JDialogContent(uimanager, "list-add","Import JavaDoc","Insert JavaDocs from system directories to the ScriptingFramework JavaDoc",new JImportHelp(uimanager,this)); |
|
796 |
public JPanel getImportHelpDialog(){
|
|
797 |
return new JDialogContent(uimanager, "list-add","Import JavaDoc","Insert JavaDocs from system directories to the ScriptingFramework JavaDoc",new JImportHelp(uimanager,this));
|
|
744 | 798 |
} |
745 | 799 |
|
746 | 800 |
public void getRemoveHelpDialog() throws Exception{ |
... | ... | |
836 | 890 |
} |
837 | 891 |
|
838 | 892 |
@Override |
839 |
public void getAboutUsDialog(){
|
|
840 |
new JDialogContent(uimanager, "system-users","About us","Information about the contributors to gvSIG project",new JDefaultDialog(uimanager,this,uimanager.getAboutManager().getAboutPanel())); |
|
893 |
public JPanel getAboutUsDialog(){
|
|
894 |
return new JDialogContent(uimanager, "system-users","About us","Information about the contributors to gvSIG project",new JDefaultDialog(uimanager,this,uimanager.getAboutManager().getAboutPanel()));
|
|
841 | 895 |
} |
842 | 896 |
|
843 | 897 |
|
... | ... | |
947 | 1001 |
if (!unitsEditor.isEmpty()){ |
948 | 1002 |
int pestanaIndex = scriptEditors.getSelectedIndex(); |
949 | 1003 |
JEditor pestanaEditor = (JEditor) scriptEditors.getComponentAt(pestanaIndex); |
950 |
tableModel.setRowCount(0);
|
|
951 |
console.setText("Running '"+ pestanaEditor.getScript().getName() +"'...\n");
|
|
1004 |
consoleClear();
|
|
1005 |
errorsClear();
|
|
952 | 1006 |
pestanaEditor.getScript().addObserver(this); |
953 |
pestanaEditor.getScript().run(); |
|
1007 |
try { |
|
1008 |
ScriptingScript script = pestanaEditor.getScript(); |
|
1009 |
script.compile(); |
|
1010 |
if( script instanceof ScriptingDialog ) { |
|
1011 |
script.run(); |
|
1012 |
} else { |
|
1013 |
ScriptTask task = new ScriptTask(this, script); |
|
1014 |
task.start(); |
|
1015 |
} |
|
1016 |
} catch (Throwable e) { |
|
1017 |
// Ignore it, compile and run handle errors correctlty |
|
1018 |
} |
|
954 | 1019 |
} |
955 | 1020 |
} |
956 | 1021 |
|
1022 |
class ScriptTask extends AbstractMonitorableTask { |
|
1023 |
|
|
1024 |
ScriptingScript script; |
|
1025 |
DefaultJScriptingComposer composer; |
|
1026 |
|
|
1027 |
protected ScriptTask(DefaultJScriptingComposer composer, ScriptingScript script) { |
|
1028 |
super(script.getName()); |
|
1029 |
this.composer = composer; |
|
1030 |
this.script = script; |
|
1031 |
this.script.put("task",this); |
|
1032 |
this.script.put("taskStatus",this.getTaskStatus()); |
|
1033 |
} |
|
1034 |
|
|
1035 |
public void run() { |
|
1036 |
try { |
|
1037 |
composer.consolePrintln("Running '"+ script.getName() +"'..."); |
|
1038 |
script.run(); |
|
1039 |
composer.consolePrintln("Quit '"+ script.getName() +"'"); |
|
1040 |
} catch (Throwable e) { |
|
1041 |
((SimpleTaskStatus)this.getTaskStatus()).abort(); |
|
1042 |
composer.consolePrintln("Aborted '"+ script.getName() +"'"); |
|
1043 |
} |
|
1044 |
} |
|
1045 |
} |
|
1046 |
|
|
1047 |
|
|
957 | 1048 |
/** |
958 | 1049 |
* Funciones de 'cortar', 'copiar', 'pegar' y 'seleccionar todo' para los JEditors |
959 | 1050 |
* |
... | ... | |
1114 | 1205 |
} |
1115 | 1206 |
} |
1116 | 1207 |
|
1117 |
public void update(Observable observable, Object notification) { |
|
1208 |
public void update(final Observable observable, final Object notification) { |
|
1209 |
if( !SwingUtilities.isEventDispatchThread() ) { |
|
1210 |
SwingUtilities.invokeLater(new Runnable() { |
|
1211 |
public void run() { |
|
1212 |
update(observable,notification); |
|
1213 |
} |
|
1214 |
}); |
|
1215 |
return; |
|
1216 |
} |
|
1118 | 1217 |
if(notification instanceof ScriptingNotification){ |
1119 | 1218 |
ScriptingNotification e= (ScriptingNotification) notification; |
1120 | 1219 |
|
1121 |
if(e.getException() instanceof ScriptException){ |
|
1122 |
ScriptException se = (ScriptException) e.getException(); |
|
1123 |
Object[] row = null; |
|
1124 |
if(se.getLineNumber() == -1 && se.getColumnNumber() == -1){ |
|
1125 |
Object[] rowData = {se.getMessage(),se.getFileName(),"Line: "+"no available"}; |
|
1126 |
row = rowData; |
|
1127 |
} else if(se.getColumnNumber() == -1){ |
|
1128 |
Object[] rowData = {se.getMessage(),se.getFileName(),"Line: "+se.getLineNumber()}; |
|
1129 |
row = rowData; |
|
1130 |
} |
|
1131 |
else{ |
|
1132 |
Object[] rowData = {se.getMessage(),se.getFileName(),"Line: "+se.getLineNumber()+":"+se.getColumnNumber()}; |
|
1133 |
row = rowData; |
|
1134 |
} |
|
1135 |
tableModel.addRow(row); |
|
1136 |
}else if(e.getException() instanceof NoSuchMethodException){ |
|
1137 |
Object[] rowData = {"No Main function",e.getId(),"No line"}; |
|
1138 |
tableModel.addRow(rowData); |
|
1139 |
} else{ |
|
1140 |
System.out.println("JComposer"+e.getException().getCause().toString()); |
|
1141 |
System.out.println("JComposer"+e.getException().toString()); |
|
1220 |
if(e.getException() instanceof CompileErrorException){ |
|
1221 |
CompileErrorException ce = (CompileErrorException) e.getException(); |
|
1222 |
errorsAdd(ce.getMessage(), ce.getScriptName(), ce.getLineNumber(), ce.getColumnNumber()) ; |
|
1223 |
|
|
1224 |
} else if(e.getException() instanceof ExecuteErrorException){ |
|
1225 |
ExecuteErrorException ee = (ExecuteErrorException) e.getException(); |
|
1226 |
errorsAdd(ee.getMessage(), ee.getScriptName(), ee.getLineNumber(), ee.getColumnNumber()) ; |
|
1227 |
consolePrintln(ee.getMessage()); |
|
1228 |
ee.printStackTrace(this.getConsolePrintStream()); |
|
1229 |
|
|
1230 |
} else { |
|
1231 |
Throwable ex = e.getException(); |
|
1232 |
errorsAdd(ex.getMessage()) ; |
|
1233 |
consolePrintln(ex.getMessage()); |
|
1234 |
ex.printStackTrace(this.getConsolePrintStream()); |
|
1142 | 1235 |
} |
1143 | 1236 |
} |
1144 | 1237 |
} |
1238 |
|
|
1239 |
public void errorsAdd(final String description, final String resource, final int line, final int column) { |
|
1240 |
if( !SwingUtilities.isEventDispatchThread() ) { |
|
1241 |
SwingUtilities.invokeLater(new Runnable() { |
|
1242 |
public void run() { |
|
1243 |
errorsAdd(description, resource, line, column); |
|
1244 |
} |
|
1245 |
}); |
|
1246 |
return; |
|
1247 |
} |
|
1248 |
String location1; |
|
1249 |
if( line < 0 ) { |
|
1250 |
location1 = "(no line)"; |
|
1251 |
} else if( column < 0) { |
|
1252 |
location1 = String.valueOf(line); |
|
1253 |
} else { |
|
1254 |
location1 = String.valueOf(line)+":"+String.valueOf(column); |
|
1255 |
} |
|
1256 |
Object[] rowData = {description, resource,location1}; |
|
1257 |
tableModel.addRow(rowData); |
|
1258 |
problemsPane.setSelectedIndex(0); |
|
1259 |
} |
|
1260 |
|
|
1261 |
public void errorsAdd(String description, String resource) { |
|
1262 |
errorsAdd(description, resource, -1, -1); |
|
1263 |
} |
|
1264 |
|
|
1265 |
public void errorsAdd(String description) { |
|
1266 |
errorsAdd(description, null, -1, -1); |
|
1267 |
} |
|
1268 |
|
|
1269 |
public void errorsClear() { |
|
1270 |
if( !SwingUtilities.isEventDispatchThread() ) { |
|
1271 |
SwingUtilities.invokeLater(new Runnable() { |
|
1272 |
public void run() { |
|
1273 |
errorsClear(); |
|
1274 |
} |
|
1275 |
}); |
|
1276 |
return; |
|
1277 |
} |
|
1278 |
while( tableModel.getRowCount()>0) { |
|
1279 |
tableModel.removeRow(0); |
|
1280 |
} |
|
1281 |
} |
|
1282 |
|
|
1283 |
public void consoleClear() { |
|
1284 |
if( !SwingUtilities.isEventDispatchThread() ) { |
|
1285 |
SwingUtilities.invokeLater(new Runnable() { |
|
1286 |
public void run() { |
|
1287 |
consoleClear(); |
|
1288 |
} |
|
1289 |
}); |
|
1290 |
return; |
|
1291 |
} |
|
1292 |
console.setText(""); |
|
1293 |
problemsPane.setSelectedIndex(1); |
|
1294 |
} |
|
1295 |
|
|
1296 |
public void consolePrintln(final String str) { |
|
1297 |
if( !SwingUtilities.isEventDispatchThread() ) { |
|
1298 |
SwingUtilities.invokeLater(new Runnable() { |
|
1299 |
public void run() { |
|
1300 |
consolePrintln(str); |
|
1301 |
} |
|
1302 |
}); |
|
1303 |
return; |
|
1304 |
} |
|
1305 |
console.append(str); |
|
1306 |
console.append("\n"); |
|
1307 |
problemsPane.setSelectedIndex(1); |
|
1308 |
} |
|
1309 |
|
|
1310 |
public void consolePrint(final String str) { |
|
1311 |
if( !SwingUtilities.isEventDispatchThread() ) { |
|
1312 |
SwingUtilities.invokeLater(new Runnable() { |
|
1313 |
public void run() { |
|
1314 |
consolePrint(str); |
|
1315 |
} |
|
1316 |
}); |
|
1317 |
return; |
|
1318 |
} |
|
1319 |
console.append(str); |
|
1320 |
problemsPane.setSelectedIndex(1); |
|
1321 |
} |
|
1322 |
|
|
1145 | 1323 |
} |
Also available in: Unified diff