root / trunk / build / distribution / IzPack / src / lib / com / izforge / izpack / panels / CompilePanel.java @ 21757
History | View | Annotate | Download (22.9 KB)
1 |
/*
|
---|---|
2 |
* $Id: CompilePanel.java 5819 2006-06-14 07:29:09Z cesar $
|
3 |
* IzPack
|
4 |
* Copyright (C) 2001-2003 Julien Ponge, Tino Schwarze
|
5 |
*
|
6 |
* File : CompilePanel.java
|
7 |
* Description : A panel to compile files after installation
|
8 |
* Author's email : julien@izforge.com
|
9 |
* Author's Website : http://www.izforge.com
|
10 |
*
|
11 |
* This program is free software; you can redistribute it and/or
|
12 |
* modify it under the terms of the GNU General Public License
|
13 |
* as published by the Free Software Foundation; either version 2
|
14 |
* of the License, or any later version.
|
15 |
*
|
16 |
* This program is distributed in the hope that it will be useful,
|
17 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
19 |
* GNU General Public License for more details.
|
20 |
*
|
21 |
* You should have received a copy of the GNU General Public License
|
22 |
* along with this program; if not, write to the Free Software
|
23 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
24 |
*/
|
25 |
package com.izforge.izpack.panels; |
26 |
|
27 |
import java.awt.Dimension; |
28 |
import java.awt.Font; |
29 |
import java.awt.GridBagConstraints; |
30 |
import java.awt.GridBagLayout; |
31 |
import java.awt.Insets; |
32 |
import java.awt.event.ActionEvent; |
33 |
import java.awt.event.ActionListener; |
34 |
import java.io.File; |
35 |
import java.io.IOException; |
36 |
import java.util.Iterator; |
37 |
|
38 |
import javax.swing.BoxLayout; |
39 |
import javax.swing.JButton; |
40 |
import javax.swing.JComboBox; |
41 |
import javax.swing.JDialog; |
42 |
import javax.swing.JFileChooser; |
43 |
import javax.swing.JLabel; |
44 |
import javax.swing.JPanel; |
45 |
import javax.swing.JProgressBar; |
46 |
import javax.swing.JScrollPane; |
47 |
import javax.swing.JTabbedPane; |
48 |
import javax.swing.JTextArea; |
49 |
import javax.swing.SwingConstants; |
50 |
|
51 |
import net.n3.nanoxml.XMLElement; |
52 |
|
53 |
import com.izforge.izpack.gui.ButtonFactory; |
54 |
import com.izforge.izpack.gui.LabelFactory; |
55 |
import com.izforge.izpack.installer.CompileHandler; |
56 |
import com.izforge.izpack.installer.CompileResult; |
57 |
import com.izforge.izpack.installer.CompileWorker; |
58 |
import com.izforge.izpack.installer.InstallData; |
59 |
import com.izforge.izpack.installer.InstallerFrame; |
60 |
import com.izforge.izpack.installer.IzPanel; |
61 |
|
62 |
/**
|
63 |
* The compile panel class.
|
64 |
*
|
65 |
* This class allows .java files to be compiled after installation.
|
66 |
*
|
67 |
* Parts of the code have been taken from InstallPanel.java and
|
68 |
* modified a lot.
|
69 |
*
|
70 |
* @author Tino Schwarze
|
71 |
* @author Julien Ponge
|
72 |
*/
|
73 |
public class CompilePanel extends IzPanel implements ActionListener, CompileHandler |
74 |
{ |
75 |
/** The combobox for compiler selection. */
|
76 |
protected JComboBox compilerComboBox; |
77 |
|
78 |
/** The combobox for compiler argument selection. */
|
79 |
protected JComboBox argumentsComboBox; |
80 |
|
81 |
/** The start button. */
|
82 |
protected JButton startButton; |
83 |
|
84 |
/** The browse button. */
|
85 |
protected JButton browseButton; |
86 |
|
87 |
/** The tip label. */
|
88 |
protected JLabel tipLabel; |
89 |
|
90 |
/** The operation label . */
|
91 |
protected JLabel opLabel; |
92 |
|
93 |
/** The pack progress bar. */
|
94 |
protected JProgressBar packProgressBar; |
95 |
|
96 |
/** The operation label . */
|
97 |
protected JLabel overallLabel; |
98 |
|
99 |
/** The overall progress bar. */
|
100 |
protected JProgressBar overallProgressBar; |
101 |
|
102 |
/** True if the compilation has been done. */
|
103 |
private boolean validated = false; |
104 |
|
105 |
/** The compilation worker. Does all the work. */
|
106 |
private CompileWorker worker;
|
107 |
|
108 |
/** Number of jobs to compile. Used for progress indication. */
|
109 |
private int noOfJobs; |
110 |
|
111 |
/**
|
112 |
* The constructor.
|
113 |
*
|
114 |
* @param parent The parent window.
|
115 |
* @param idata The installation data.
|
116 |
*/
|
117 |
public CompilePanel(InstallerFrame parent, InstallData idata)
|
118 |
throws IOException |
119 |
{ |
120 |
super(parent, idata);
|
121 |
|
122 |
this.worker = new CompileWorker (idata, this); |
123 |
|
124 |
GridBagConstraints gridBagConstraints;
|
125 |
|
126 |
JLabel heading = new JLabel(); |
127 |
// put everything but the heading into it's own panel
|
128 |
// (to center it vertically)
|
129 |
JPanel subpanel = new JPanel (); |
130 |
JLabel compilerLabel = new JLabel(); |
131 |
compilerComboBox = new JComboBox(); |
132 |
this.browseButton = ButtonFactory.createButton (parent.langpack.getString ("CompilePanel.browse"), idata.buttonsHColor); |
133 |
JLabel argumentsLabel = new JLabel(); |
134 |
this.argumentsComboBox = new JComboBox(); |
135 |
this.startButton = ButtonFactory.createButton (parent.langpack.getString ("CompilePanel.start"), idata.buttonsHColor); |
136 |
this.tipLabel = LabelFactory.create(parent.langpack.getString ("CompilePanel.tip"), |
137 |
parent.icons.getImageIcon ("tip"), SwingConstants.TRAILING); |
138 |
this.opLabel = new JLabel(); |
139 |
packProgressBar = new JProgressBar(); |
140 |
this.overallLabel = new JLabel(); |
141 |
this.overallProgressBar = new JProgressBar(); |
142 |
|
143 |
setLayout(new GridBagLayout()); |
144 |
|
145 |
Font font = heading.getFont ();
|
146 |
font = font.deriveFont (Font.BOLD, font.getSize() * 2.0f); |
147 |
heading.setFont(font); |
148 |
heading.setHorizontalAlignment(SwingConstants.CENTER);
|
149 |
heading.setText(parent.langpack.getString ("CompilePanel.heading"));
|
150 |
heading.setVerticalAlignment(SwingConstants.TOP);
|
151 |
gridBagConstraints = new GridBagConstraints(); |
152 |
gridBagConstraints.gridy = 0;
|
153 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
|
154 |
gridBagConstraints.anchor = GridBagConstraints.NORTH;
|
155 |
gridBagConstraints.weightx = 1.0;
|
156 |
gridBagConstraints.weighty = 0.1;
|
157 |
add(heading, gridBagConstraints); |
158 |
|
159 |
gridBagConstraints = new GridBagConstraints(); |
160 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
|
161 |
gridBagConstraints.anchor = GridBagConstraints.CENTER;
|
162 |
gridBagConstraints.gridy = 1;
|
163 |
gridBagConstraints.weightx = 1.0;
|
164 |
gridBagConstraints.weighty = 0.9;
|
165 |
add (subpanel, gridBagConstraints); |
166 |
|
167 |
subpanel.setLayout(new GridBagLayout()); |
168 |
|
169 |
int row = 0; |
170 |
|
171 |
compilerLabel.setHorizontalAlignment(SwingConstants.LEFT);
|
172 |
compilerLabel.setLabelFor(compilerComboBox); |
173 |
compilerLabel.setText(parent.langpack.getString ("CompilePanel.choose_compiler"));
|
174 |
gridBagConstraints = new GridBagConstraints(); |
175 |
gridBagConstraints.gridy = row; |
176 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
|
177 |
//gridBagConstraints.weighty = 0.1;
|
178 |
subpanel.add(compilerLabel, gridBagConstraints); |
179 |
|
180 |
compilerComboBox.setEditable(true);
|
181 |
gridBagConstraints = new GridBagConstraints(); |
182 |
gridBagConstraints.gridy = row++; |
183 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
|
184 |
//gridBagConstraints.weighty = 0.1;
|
185 |
|
186 |
Iterator it = this.worker.getAvailableCompilers().iterator(); |
187 |
|
188 |
while (it.hasNext())
|
189 |
compilerComboBox.addItem ((String)it.next());
|
190 |
|
191 |
subpanel.add(compilerComboBox, gridBagConstraints); |
192 |
|
193 |
gridBagConstraints = new GridBagConstraints(); |
194 |
gridBagConstraints.gridy = row++; |
195 |
gridBagConstraints.gridx = 1;
|
196 |
gridBagConstraints.anchor = GridBagConstraints.EAST;
|
197 |
browseButton.addActionListener (this);
|
198 |
subpanel.add(browseButton, gridBagConstraints); |
199 |
|
200 |
argumentsLabel.setHorizontalAlignment(SwingConstants.LEFT);
|
201 |
argumentsLabel.setLabelFor(argumentsComboBox); |
202 |
argumentsLabel.setText(parent.langpack.getString ("CompilePanel.additional_arguments"));
|
203 |
//argumentsLabel.setToolTipText("");
|
204 |
gridBagConstraints = new GridBagConstraints(); |
205 |
gridBagConstraints.gridy = row; |
206 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
|
207 |
gridBagConstraints.weightx = 0.5;
|
208 |
//gridBagConstraints.weighty = 0.1;
|
209 |
subpanel.add(argumentsLabel, gridBagConstraints); |
210 |
|
211 |
argumentsComboBox.setEditable(true);
|
212 |
gridBagConstraints = new GridBagConstraints(); |
213 |
gridBagConstraints.gridy = row++; |
214 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
|
215 |
gridBagConstraints.weightx = 0.5;
|
216 |
//gridBagConstraints.weighty = 0.1;
|
217 |
|
218 |
it = this.worker.getAvailableArguments ().iterator();
|
219 |
|
220 |
while (it.hasNext())
|
221 |
argumentsComboBox.addItem ((String)it.next());
|
222 |
|
223 |
subpanel.add(argumentsComboBox, gridBagConstraints); |
224 |
|
225 |
// leave some space above the label
|
226 |
gridBagConstraints.insets = new Insets (10, 0, 0, 0); |
227 |
gridBagConstraints = new GridBagConstraints(); |
228 |
gridBagConstraints.gridy = row++; |
229 |
gridBagConstraints.gridwidth = 2;
|
230 |
gridBagConstraints.fill = GridBagConstraints.NONE;
|
231 |
gridBagConstraints.anchor = GridBagConstraints.NORTHWEST;
|
232 |
subpanel.add(tipLabel, gridBagConstraints); |
233 |
|
234 |
opLabel.setText(" ");
|
235 |
gridBagConstraints = new GridBagConstraints(); |
236 |
gridBagConstraints.gridy = row++; |
237 |
gridBagConstraints.gridwidth = 2;
|
238 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
|
239 |
subpanel.add(opLabel, gridBagConstraints); |
240 |
|
241 |
packProgressBar.setValue(0);
|
242 |
packProgressBar.setString(parent.langpack.getString ("CompilePanel.progress.initial"));
|
243 |
packProgressBar.setStringPainted(true);
|
244 |
gridBagConstraints = new GridBagConstraints(); |
245 |
gridBagConstraints.gridy = row++; |
246 |
gridBagConstraints.gridwidth = 2;
|
247 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
|
248 |
gridBagConstraints.anchor = GridBagConstraints.SOUTH;
|
249 |
subpanel.add(packProgressBar, gridBagConstraints); |
250 |
|
251 |
overallLabel.setText (parent.langpack.getString ("CompilePanel.progress.overall"));
|
252 |
gridBagConstraints = new GridBagConstraints(); |
253 |
gridBagConstraints.gridy = row++; |
254 |
gridBagConstraints.gridwidth = 2;
|
255 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
|
256 |
subpanel.add(overallLabel, gridBagConstraints); |
257 |
|
258 |
overallProgressBar.setValue(0);
|
259 |
overallProgressBar.setString("");
|
260 |
overallProgressBar.setStringPainted(true);
|
261 |
gridBagConstraints = new GridBagConstraints(); |
262 |
gridBagConstraints.gridy = row++; |
263 |
gridBagConstraints.gridwidth = 2;
|
264 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
|
265 |
gridBagConstraints.anchor = GridBagConstraints.SOUTH;
|
266 |
subpanel.add(overallProgressBar, gridBagConstraints); |
267 |
|
268 |
startButton.setText(parent.langpack.getString ("CompilePanel.start"));
|
269 |
startButton.addActionListener (this);
|
270 |
gridBagConstraints = new GridBagConstraints(); |
271 |
gridBagConstraints.gridx = 0;
|
272 |
gridBagConstraints.gridwidth = 2;
|
273 |
gridBagConstraints.gridy = row++; |
274 |
gridBagConstraints.fill = GridBagConstraints.NONE;
|
275 |
// leave some space above the button
|
276 |
gridBagConstraints.insets = new Insets (5, 0, 0, 0); |
277 |
subpanel.add(startButton, gridBagConstraints); |
278 |
} |
279 |
|
280 |
|
281 |
/**
|
282 |
* Indicates wether the panel has been validated or not.
|
283 |
*
|
284 |
* @return The validation state.
|
285 |
*/
|
286 |
public boolean isValidated() |
287 |
{ |
288 |
return validated;
|
289 |
} |
290 |
|
291 |
/**
|
292 |
* Action function, called when the start button is pressed.
|
293 |
*/
|
294 |
public void actionPerformed (ActionEvent e) |
295 |
{ |
296 |
if (e.getSource() == this.startButton) |
297 |
{ |
298 |
this.worker.setCompiler ((String)this.compilerComboBox.getSelectedItem ()); |
299 |
|
300 |
this.worker.setCompilerArguments ((String)this.argumentsComboBox.getSelectedItem ()); |
301 |
|
302 |
this.blockGUI ();
|
303 |
this.worker.startThread ();
|
304 |
} |
305 |
else if (e.getSource () == this.browseButton) |
306 |
{ |
307 |
this.parent.blockGUI ();
|
308 |
JFileChooser chooser = new JFileChooser (); |
309 |
chooser.setCurrentDirectory (new File ((String)this.compilerComboBox.getSelectedItem()).getParentFile ()); |
310 |
int result = chooser.showDialog (this.parent, this.parent.langpack.getString ("CompilePanel.browse.approve")); |
311 |
if (result == JFileChooser.APPROVE_OPTION) |
312 |
{ |
313 |
File file_chosen = chooser.getSelectedFile();
|
314 |
|
315 |
if (file_chosen.isFile ())
|
316 |
{ |
317 |
this.compilerComboBox.setSelectedItem (file_chosen.getAbsolutePath());
|
318 |
} |
319 |
|
320 |
} |
321 |
|
322 |
this.parent.releaseGUI();
|
323 |
} |
324 |
|
325 |
} |
326 |
|
327 |
/**
|
328 |
* Block the GUI - disalow input.
|
329 |
*/
|
330 |
protected void blockGUI () |
331 |
{ |
332 |
// disable all controls
|
333 |
this.startButton.setEnabled (false); |
334 |
this.browseButton.setEnabled (false); |
335 |
this.compilerComboBox.setEnabled (false); |
336 |
this.argumentsComboBox.setEnabled (false); |
337 |
|
338 |
this.parent.blockGUI();
|
339 |
} |
340 |
|
341 |
/**
|
342 |
* Release the GUI - allow input.
|
343 |
*
|
344 |
* @param allowconfig allow the user to enter new configuration
|
345 |
*/
|
346 |
protected void releaseGUI (boolean allowconfig) |
347 |
{ |
348 |
// disable all controls
|
349 |
if (allowconfig)
|
350 |
{ |
351 |
this.startButton.setEnabled (true); |
352 |
this.browseButton.setEnabled (true); |
353 |
this.compilerComboBox.setEnabled (true); |
354 |
this.argumentsComboBox.setEnabled (true); |
355 |
} |
356 |
|
357 |
this.parent.releaseGUI();
|
358 |
} |
359 |
|
360 |
/**
|
361 |
* An error was encountered.
|
362 |
*
|
363 |
* @param error The error information.
|
364 |
* @see com.izforge.izpack.installer.CompileHandler
|
365 |
*/
|
366 |
public void handleCompileError (CompileResult error) |
367 |
{ |
368 |
String message = error.getMessage ();
|
369 |
opLabel.setText(message); |
370 |
CompilerErrorDialog dialog = new CompilerErrorDialog (parent, message, idata.buttonsHColor);
|
371 |
dialog.show (error); |
372 |
|
373 |
if (dialog.getResult() == CompilerErrorDialog.RESULT_IGNORE)
|
374 |
{ |
375 |
error.setAction (CompileResult.ACTION_CONTINUE); |
376 |
} |
377 |
else if (dialog.getResult() == CompilerErrorDialog.RESULT_RECONFIGURE) |
378 |
{ |
379 |
error.setAction (CompileResult.ACTION_RECONFIGURE); |
380 |
} |
381 |
else // default case: abort |
382 |
{ |
383 |
error.setAction (CompileResult.ACTION_ABORT); |
384 |
} |
385 |
|
386 |
} |
387 |
|
388 |
|
389 |
/** The compiler starts. */
|
390 |
public void startAction (String name, int noOfJobs) |
391 |
{ |
392 |
this.noOfJobs = noOfJobs;
|
393 |
overallProgressBar.setMaximum (noOfJobs); |
394 |
parent.lockPrevButton(); |
395 |
} |
396 |
|
397 |
|
398 |
/** The compiler stops. */
|
399 |
public void stopAction () |
400 |
{ |
401 |
CompileResult result = this.worker.getResult ();
|
402 |
|
403 |
this.releaseGUI(result.isReconfigure());
|
404 |
|
405 |
if (result.isContinue())
|
406 |
{ |
407 |
parent.lockPrevButton(); |
408 |
|
409 |
packProgressBar.setString(parent.langpack.getString("CompilePanel.progress.finished"));
|
410 |
packProgressBar.setEnabled(false);
|
411 |
packProgressBar.setValue (packProgressBar.getMaximum()); |
412 |
|
413 |
overallProgressBar.setValue (this.noOfJobs);
|
414 |
String no_of_jobs = Integer.toString (this.noOfJobs); |
415 |
overallProgressBar.setString (no_of_jobs + " / " + no_of_jobs);
|
416 |
overallProgressBar.setEnabled (false);
|
417 |
|
418 |
opLabel.setText(" ");
|
419 |
opLabel.setEnabled(false);
|
420 |
|
421 |
validated = true;
|
422 |
idata.installSuccess = true;
|
423 |
if (idata.panels.indexOf(this) != (idata.panels.size() - 1)) |
424 |
parent.unlockNextButton(); |
425 |
} |
426 |
else
|
427 |
{ |
428 |
idata.installSuccess = false;
|
429 |
} |
430 |
|
431 |
} |
432 |
|
433 |
|
434 |
/**
|
435 |
* Normal progress indicator.
|
436 |
*
|
437 |
* @param val The progression value.
|
438 |
* @param msg The progression message.
|
439 |
*/
|
440 |
public void progress (int val, String msg) |
441 |
{ |
442 |
//Debug.trace ("progress: " + val + " " + msg);
|
443 |
packProgressBar.setValue(val + 1);
|
444 |
opLabel.setText(msg); |
445 |
} |
446 |
|
447 |
|
448 |
/**
|
449 |
* Job changing.
|
450 |
*
|
451 |
* @param jobName The job name.
|
452 |
* @param max The new maximum progress.
|
453 |
* @param jobNo The job number.
|
454 |
*/
|
455 |
public void nextStep (String jobName, int max, int jobNo) |
456 |
{ |
457 |
packProgressBar.setValue(0);
|
458 |
packProgressBar.setMaximum(max); |
459 |
packProgressBar.setString(jobName); |
460 |
|
461 |
opLabel.setText ("");
|
462 |
|
463 |
overallProgressBar.setValue (jobNo); |
464 |
overallProgressBar.setString (Integer.toString (jobNo) + " / " + Integer.toString (this.noOfJobs)); |
465 |
} |
466 |
|
467 |
|
468 |
/** Called when the panel becomes active. */
|
469 |
public void panelActivate() |
470 |
{ |
471 |
// get compilers again (because they might contain variables from former panels)
|
472 |
Iterator it = this.worker.getAvailableCompilers().iterator(); |
473 |
|
474 |
compilerComboBox.removeAllItems(); |
475 |
|
476 |
while (it.hasNext())
|
477 |
compilerComboBox.addItem ((String)it.next());
|
478 |
|
479 |
// We clip the panel
|
480 |
Dimension dim = parent.getPanelsContainerSize();
|
481 |
dim.width = dim.width - (dim.width / 4);
|
482 |
dim.height = 150;
|
483 |
setMinimumSize(dim); |
484 |
setMaximumSize(dim); |
485 |
setPreferredSize(dim); |
486 |
|
487 |
parent.lockNextButton(); |
488 |
} |
489 |
|
490 |
/** Create XML data for automated installation. */
|
491 |
public void makeXMLData (XMLElement panelRoot) |
492 |
{ |
493 |
// just save the compiler chosen and the arguments
|
494 |
XMLElement compiler = new XMLElement ("compiler"); |
495 |
compiler.setContent (this.worker.getCompiler());
|
496 |
panelRoot.addChild (compiler); |
497 |
|
498 |
XMLElement args = new XMLElement ("arguments"); |
499 |
args.setContent (this.worker.getCompilerArguments());
|
500 |
panelRoot.addChild (args); |
501 |
} |
502 |
|
503 |
/**
|
504 |
* Show a special dialog for compiler errors.
|
505 |
*
|
506 |
* This dialog is neccessary because we have lots of information if
|
507 |
* compilation failed. We'd also like the user to chose whether
|
508 |
* to ignore the error or not.
|
509 |
*/
|
510 |
protected class CompilerErrorDialog extends JDialog implements ActionListener |
511 |
{ |
512 |
/** user closed the dialog without pressing "Ignore" or "Abort" */
|
513 |
public static final int RESULT_NONE = 0; |
514 |
/** user pressed "Ignore" button */
|
515 |
public static final int RESULT_IGNORE = 23; |
516 |
/** user pressed "Abort" button */
|
517 |
public static final int RESULT_ABORT = 42; |
518 |
/** user pressed "Reconfigure" button */
|
519 |
public static final int RESULT_RECONFIGURE = 47; |
520 |
|
521 |
/** visual goodie: button hightlight color */
|
522 |
private java.awt.Color buttonHColor = null; |
523 |
|
524 |
/** Creates new form compilerErrorDialog */
|
525 |
public CompilerErrorDialog(java.awt.Frame parent, String title, java.awt.Color buttonHColor) |
526 |
{ |
527 |
super(parent, title, true); |
528 |
this.buttonHColor = buttonHColor;
|
529 |
initComponents(); |
530 |
} |
531 |
|
532 |
/** This method is called from within the constructor to
|
533 |
* initialize the form.
|
534 |
*
|
535 |
* Generated with help from NetBeans IDE.
|
536 |
*/
|
537 |
private void initComponents() |
538 |
{ |
539 |
JPanel errorMessagePane = new JPanel(); |
540 |
errorMessageText = new JTextArea(); |
541 |
JTextArea seeBelowText = new JTextArea (); |
542 |
JTabbedPane errorDisplayPane = new JTabbedPane(); |
543 |
JScrollPane commandScrollPane = new JScrollPane(); |
544 |
commandText = new JTextArea(); |
545 |
JScrollPane stdOutScrollPane = new JScrollPane(); |
546 |
stdOutText = new JTextArea(); |
547 |
JScrollPane stdErrScrollPane = new JScrollPane(); |
548 |
stdErrText = new JTextArea(); |
549 |
JPanel buttonsPanel = new JPanel(); |
550 |
reconfigButton = ButtonFactory.createButton (parent.langpack.getString ("CompilePanel.error.reconfigure"), this.buttonHColor); |
551 |
ignoreButton = ButtonFactory.createButton (parent.langpack.getString ("CompilePanel.error.ignore"), this.buttonHColor); |
552 |
abortButton = ButtonFactory.createButton (parent.langpack.getString ("CompilePanel.error.abort"), this.buttonHColor); |
553 |
|
554 |
addWindowListener(new java.awt.event.WindowAdapter() {
|
555 |
public void windowClosing(java.awt.event.WindowEvent evt) { |
556 |
closeDialog(evt); |
557 |
} |
558 |
}); |
559 |
|
560 |
errorMessagePane.setLayout (new BoxLayout (errorMessagePane, BoxLayout.Y_AXIS)); |
561 |
errorMessageText.setBackground(super.getBackground());
|
562 |
errorMessageText.setEditable(false);
|
563 |
errorMessageText.setLineWrap(true);
|
564 |
//errorMessageText.setText("The compiler does not seem to work. See below for the command we tried to execute and the results.");
|
565 |
//errorMessageText.setToolTipText("null");
|
566 |
errorMessageText.setWrapStyleWord(true);
|
567 |
errorMessagePane.add(errorMessageText); |
568 |
|
569 |
seeBelowText.setBackground(super.getBackground());
|
570 |
seeBelowText.setEditable(false);
|
571 |
seeBelowText.setLineWrap(true);
|
572 |
seeBelowText.setWrapStyleWord(true);
|
573 |
seeBelowText.setText (parent.langpack.getString ("CompilePanel.error.seebelow"));
|
574 |
errorMessagePane.add (seeBelowText); |
575 |
|
576 |
getContentPane().add(errorMessagePane, java.awt.BorderLayout.NORTH); |
577 |
|
578 |
// use 12pt monospace font for compiler output etc.
|
579 |
Font output_font = new Font ("Monospaced", Font.PLAIN, 12); |
580 |
|
581 |
//errorDisplayPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
|
582 |
//errorDisplayPane.setName("null");
|
583 |
commandText.setFont (output_font); |
584 |
commandText.setEditable(false);
|
585 |
commandText.setRows(10);
|
586 |
commandText.setColumns(82);
|
587 |
commandText.setWrapStyleWord(true);
|
588 |
commandText.setLineWrap(true);
|
589 |
//commandText.setText("akjfkajfeafjakefjakfkaejfja");
|
590 |
commandScrollPane.setViewportView(commandText); |
591 |
|
592 |
errorDisplayPane.addTab("Command", commandScrollPane);
|
593 |
|
594 |
stdOutText.setFont (output_font); |
595 |
stdOutText.setEditable(false);
|
596 |
stdOutText.setWrapStyleWord(true);
|
597 |
stdOutText.setLineWrap(true);
|
598 |
stdOutScrollPane.setViewportView(stdOutText); |
599 |
|
600 |
errorDisplayPane.addTab("Standard Output", null, stdOutScrollPane); |
601 |
|
602 |
stdErrText.setFont (output_font); |
603 |
stdErrText.setEditable(false);
|
604 |
stdErrText.setWrapStyleWord(true);
|
605 |
stdErrText.setLineWrap(true);
|
606 |
stdErrScrollPane.setViewportView(stdErrText); |
607 |
|
608 |
errorDisplayPane.addTab("Standard Error", null, stdErrScrollPane); |
609 |
|
610 |
getContentPane().add(errorDisplayPane, java.awt.BorderLayout.CENTER); |
611 |
|
612 |
buttonsPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT));
|
613 |
|
614 |
reconfigButton.addActionListener (this);
|
615 |
buttonsPanel.add(reconfigButton); |
616 |
|
617 |
ignoreButton.addActionListener (this);
|
618 |
buttonsPanel.add(ignoreButton); |
619 |
|
620 |
abortButton.addActionListener (this);
|
621 |
buttonsPanel.add(abortButton); |
622 |
|
623 |
getContentPane().add(buttonsPanel, java.awt.BorderLayout.SOUTH); |
624 |
|
625 |
pack(); |
626 |
} |
627 |
|
628 |
/** Closes the dialog */
|
629 |
protected void closeDialog(java.awt.event.WindowEvent evt) |
630 |
{ |
631 |
setVisible(false);
|
632 |
dispose(); |
633 |
} |
634 |
|
635 |
|
636 |
public void show (CompileResult error) |
637 |
{ |
638 |
this.errorMessageText.setText (error.getMessage ());
|
639 |
this.commandText.setText (error.getCmdline ());
|
640 |
this.stdOutText.setText (error.getStdout ());
|
641 |
this.stdErrText.setText (error.getStderr ());
|
642 |
super.show();
|
643 |
} |
644 |
|
645 |
public int getResult () |
646 |
{ |
647 |
return this.result; |
648 |
} |
649 |
|
650 |
|
651 |
public void actionPerformed (ActionEvent e) |
652 |
{ |
653 |
boolean closenow = false; |
654 |
|
655 |
if (e.getSource () == this.ignoreButton) |
656 |
{ |
657 |
this.result = RESULT_IGNORE;
|
658 |
closenow = true;
|
659 |
} |
660 |
else if (e.getSource () == this.abortButton) |
661 |
{ |
662 |
this.result = RESULT_ABORT;
|
663 |
closenow = true;
|
664 |
} |
665 |
else if (e.getSource () == this.reconfigButton) |
666 |
{ |
667 |
this.result = RESULT_RECONFIGURE;
|
668 |
closenow = true;
|
669 |
} |
670 |
|
671 |
if (closenow)
|
672 |
{ |
673 |
this.setVisible (false); |
674 |
this.dispose ();
|
675 |
} |
676 |
|
677 |
} |
678 |
|
679 |
// Variables declaration - do not modify//GEN-BEGIN:variables
|
680 |
private JTextArea commandText; |
681 |
//private JScrollPane stdOutScrollPane;
|
682 |
private JTextArea stdErrText; |
683 |
//private JPanel buttonsPanel;
|
684 |
//private JScrollPane commandScrollPane;
|
685 |
private JTextArea errorMessageText; |
686 |
//private JScrollPane stdErrScrollPane;
|
687 |
private JButton ignoreButton; |
688 |
private JTextArea stdOutText; |
689 |
private JButton abortButton; |
690 |
private JButton reconfigButton; |
691 |
//private JTabbedPane errorDisplayPane;
|
692 |
// End of variables declaration//GEN-END:variables
|
693 |
|
694 |
private int result = RESULT_NONE; |
695 |
} |
696 |
} |
697 |
|