KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > izforge > izpack > panels > CompilePanel


1 /*
2  * IzPack - Copyright 2001-2007 Julien Ponge, All Rights Reserved.
3  *
4  * http://www.izforge.com/izpack/
5  * http://developer.berlios.de/projects/izpack/
6  *
7  * Copyright 2003 Tino Schwarze
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  */

21 package com.izforge.izpack.panels;
22
23 import java.awt.Dimension JavaDoc;
24 import java.awt.Font JavaDoc;
25 import java.awt.GridBagConstraints JavaDoc;
26 import java.awt.GridBagLayout JavaDoc;
27 import java.awt.Insets JavaDoc;
28 import java.awt.event.ActionEvent JavaDoc;
29 import java.awt.event.ActionListener JavaDoc;
30 import java.io.File JavaDoc;
31 import java.io.IOException JavaDoc;
32 import java.util.Iterator JavaDoc;
33
34 import javax.swing.BoxLayout JavaDoc;
35 import javax.swing.JButton JavaDoc;
36 import javax.swing.JComboBox JavaDoc;
37 import javax.swing.JDialog JavaDoc;
38 import javax.swing.JFileChooser JavaDoc;
39 import javax.swing.JLabel JavaDoc;
40 import javax.swing.JPanel JavaDoc;
41 import javax.swing.JProgressBar JavaDoc;
42 import javax.swing.JScrollPane JavaDoc;
43 import javax.swing.JTabbedPane JavaDoc;
44 import javax.swing.JTextArea JavaDoc;
45 import javax.swing.SwingConstants JavaDoc;
46
47 import net.n3.nanoxml.XMLElement;
48
49 import com.izforge.izpack.gui.ButtonFactory;
50 import com.izforge.izpack.gui.LabelFactory;
51 import com.izforge.izpack.installer.CompileHandler;
52 import com.izforge.izpack.installer.CompileResult;
53 import com.izforge.izpack.installer.CompileWorker;
54 import com.izforge.izpack.installer.InstallData;
55 import com.izforge.izpack.installer.InstallerFrame;
56 import com.izforge.izpack.installer.IzPanel;
57
58 /**
59  * The compile panel class.
60  *
61  * This class allows .java files to be compiled after installation.
62  *
63  * Parts of the code have been taken from InstallPanel.java and modified a lot.
64  *
65  * @author Tino Schwarze
66  * @author Julien Ponge
67  */

68 public class CompilePanel extends IzPanel implements ActionListener JavaDoc, CompileHandler
69 {
70
71     /**
72      *
73      */

74     private static final long serialVersionUID = 3258408430669674552L;
75
76     /** The combobox for compiler selection. */
77     protected JComboBox JavaDoc compilerComboBox;
78
79     /** The combobox for compiler argument selection. */
80     protected JComboBox JavaDoc argumentsComboBox;
81
82     /** The start button. */
83     protected JButton JavaDoc startButton;
84
85     /** The browse button. */
86     protected JButton JavaDoc browseButton;
87
88     /** The tip label. */
89     protected JLabel JavaDoc tipLabel;
90
91     /** The operation label . */
92     protected JLabel JavaDoc opLabel;
93
94     /** The pack progress bar. */
95     protected JProgressBar JavaDoc packProgressBar;
96
97     /** The operation label . */
98     protected JLabel JavaDoc overallLabel;
99
100     /** The overall progress bar. */
101     protected JProgressBar JavaDoc overallProgressBar;
102
103     /** True if the compilation has been done. */
104     private boolean validated = false;
105
106     /** The compilation worker. Does all the work. */
107     private CompileWorker worker;
108
109     /** Number of jobs to compile. Used for progress indication. */
110     private int noOfJobs;
111
112     /**
113      * The constructor.
114      *
115      * @param parent The parent window.
116      * @param idata The installation data.
117      * @throws IOException
118      */

119     public CompilePanel(InstallerFrame parent, InstallData idata) throws IOException JavaDoc
120     {
121         super(parent, idata);
122
123         this.worker = new CompileWorker(idata, this);
124
125         GridBagConstraints JavaDoc gridBagConstraints;
126
127         JLabel JavaDoc heading = new JLabel JavaDoc();
128         // put everything but the heading into it's own panel
129
// (to center it vertically)
130
JPanel JavaDoc subpanel = new JPanel JavaDoc();
131         JLabel JavaDoc compilerLabel = new JLabel JavaDoc();
132         compilerComboBox = new JComboBox JavaDoc();
133         this.browseButton = ButtonFactory.createButton(parent.langpack
134                 .getString("CompilePanel.browse"), idata.buttonsHColor);
135         JLabel JavaDoc argumentsLabel = new JLabel JavaDoc();
136         this.argumentsComboBox = new JComboBox JavaDoc();
137         this.startButton = ButtonFactory.createButton(parent.langpack
138                 .getString("CompilePanel.start"), idata.buttonsHColor);
139         this.tipLabel = LabelFactory.create(parent.langpack.getString("CompilePanel.tip"),
140                 parent.icons.getImageIcon("tip"), SwingConstants.TRAILING);
141         this.opLabel = new JLabel JavaDoc();
142         packProgressBar = new JProgressBar JavaDoc();
143         this.overallLabel = new JLabel JavaDoc();
144         this.overallProgressBar = new JProgressBar JavaDoc();
145
146         setLayout(new GridBagLayout JavaDoc());
147
148         Font JavaDoc font = heading.getFont();
149         font = font.deriveFont(Font.BOLD, font.getSize() * 2.0f);
150         heading.setFont(font);
151         heading.setHorizontalAlignment(SwingConstants.CENTER);
152         heading.setText(parent.langpack.getString("CompilePanel.heading"));
153         heading.setVerticalAlignment(SwingConstants.TOP);
154         gridBagConstraints = new GridBagConstraints JavaDoc();
155         gridBagConstraints.gridy = 0;
156         gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
157         gridBagConstraints.anchor = GridBagConstraints.NORTH;
158         gridBagConstraints.weightx = 1.0;
159         gridBagConstraints.weighty = 0.1;
160         add(heading, gridBagConstraints);
161
162         gridBagConstraints = new GridBagConstraints JavaDoc();
163         gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
164         gridBagConstraints.anchor = GridBagConstraints.CENTER;
165         gridBagConstraints.gridy = 1;
166         gridBagConstraints.weightx = 1.0;
167         gridBagConstraints.weighty = 0.9;
168         add(subpanel, gridBagConstraints);
169
170         subpanel.setLayout(new GridBagLayout JavaDoc());
171
172         int row = 0;
173
174         compilerLabel.setHorizontalAlignment(SwingConstants.LEFT);
175         compilerLabel.setLabelFor(compilerComboBox);
176         compilerLabel.setText(parent.langpack.getString("CompilePanel.choose_compiler"));
177         gridBagConstraints = new GridBagConstraints JavaDoc();
178         gridBagConstraints.gridy = row;
179         gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
180         // gridBagConstraints.weighty = 0.1;
181
subpanel.add(compilerLabel, gridBagConstraints);
182
183         compilerComboBox.setEditable(true);
184         gridBagConstraints = new GridBagConstraints JavaDoc();
185         gridBagConstraints.gridy = row++;
186         gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
187         // gridBagConstraints.weighty = 0.1;
188

189         Iterator JavaDoc it = this.worker.getAvailableCompilers().iterator();
190
191         while (it.hasNext())
192             compilerComboBox.addItem(it.next());
193
194         subpanel.add(compilerComboBox, gridBagConstraints);
195
196         gridBagConstraints = new GridBagConstraints JavaDoc();
197         gridBagConstraints.gridy = row++;
198         gridBagConstraints.gridx = 1;
199         gridBagConstraints.anchor = GridBagConstraints.EAST;
200         browseButton.addActionListener(this);
201         subpanel.add(browseButton, gridBagConstraints);
202
203         argumentsLabel.setHorizontalAlignment(SwingConstants.LEFT);
204         argumentsLabel.setLabelFor(argumentsComboBox);
205         argumentsLabel.setText(parent.langpack.getString("CompilePanel.additional_arguments"));
206         // argumentsLabel.setToolTipText("");
207
gridBagConstraints = new GridBagConstraints JavaDoc();
208         gridBagConstraints.gridy = row;
209         gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
210         gridBagConstraints.weightx = 0.5;
211         // gridBagConstraints.weighty = 0.1;
212
subpanel.add(argumentsLabel, gridBagConstraints);
213
214         argumentsComboBox.setEditable(true);
215         gridBagConstraints = new GridBagConstraints JavaDoc();
216         gridBagConstraints.gridy = row++;
217         gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
218         gridBagConstraints.weightx = 0.5;
219         // gridBagConstraints.weighty = 0.1;
220

221         it = this.worker.getAvailableArguments().iterator();
222
223         while (it.hasNext())
224             argumentsComboBox.addItem(it.next());
225
226         subpanel.add(argumentsComboBox, gridBagConstraints);
227
228         // leave some space above the label
229
gridBagConstraints.insets = new Insets JavaDoc(10, 0, 0, 0);
230         gridBagConstraints = new GridBagConstraints JavaDoc();
231         gridBagConstraints.gridy = row++;
232         gridBagConstraints.gridwidth = 2;
233         gridBagConstraints.fill = GridBagConstraints.NONE;
234         gridBagConstraints.anchor = GridBagConstraints.NORTHWEST;
235         subpanel.add(tipLabel, gridBagConstraints);
236
237         opLabel.setText(" ");
238         gridBagConstraints = new GridBagConstraints JavaDoc();
239         gridBagConstraints.gridy = row++;
240         gridBagConstraints.gridwidth = 2;
241         gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
242         subpanel.add(opLabel, gridBagConstraints);
243
244         packProgressBar.setValue(0);
245         packProgressBar.setString(parent.langpack.getString("CompilePanel.progress.initial"));
246         packProgressBar.setStringPainted(true);
247         gridBagConstraints = new GridBagConstraints JavaDoc();
248         gridBagConstraints.gridy = row++;
249         gridBagConstraints.gridwidth = 2;
250         gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
251         gridBagConstraints.anchor = GridBagConstraints.SOUTH;
252         subpanel.add(packProgressBar, gridBagConstraints);
253
254         overallLabel.setText(parent.langpack.getString("CompilePanel.progress.overall"));
255         gridBagConstraints = new GridBagConstraints JavaDoc();
256         gridBagConstraints.gridy = row++;
257         gridBagConstraints.gridwidth = 2;
258         gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
259         subpanel.add(overallLabel, gridBagConstraints);
260
261         overallProgressBar.setValue(0);
262         overallProgressBar.setString("");
263         overallProgressBar.setStringPainted(true);
264         gridBagConstraints = new GridBagConstraints JavaDoc();
265         gridBagConstraints.gridy = row++;
266         gridBagConstraints.gridwidth = 2;
267         gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
268         gridBagConstraints.anchor = GridBagConstraints.SOUTH;
269         subpanel.add(overallProgressBar, gridBagConstraints);
270
271         startButton.setText(parent.langpack.getString("CompilePanel.start"));
272         startButton.addActionListener(this);
273         gridBagConstraints = new GridBagConstraints JavaDoc();
274         gridBagConstraints.gridx = 0;
275         gridBagConstraints.gridwidth = 2;
276         gridBagConstraints.gridy = row++;
277         gridBagConstraints.fill = GridBagConstraints.NONE;
278         // leave some space above the button
279
gridBagConstraints.insets = new Insets JavaDoc(5, 0, 0, 0);
280         subpanel.add(startButton, gridBagConstraints);
281     }
282
283     /**
284      * Indicates wether the panel has been validated or not.
285      *
286      * @return The validation state.
287      */

288     public boolean isValidated()
289     {
290         return validated;
291     }
292
293     /**
294      * Action function, called when the start button is pressed.
295      */

296     public void actionPerformed(ActionEvent JavaDoc e)
297     {
298         if (e.getSource() == this.startButton)
299         {
300             this.worker.setCompiler((String JavaDoc) this.compilerComboBox.getSelectedItem());
301
302             this.worker.setCompilerArguments((String JavaDoc) this.argumentsComboBox.getSelectedItem());
303
304             this.blockGUI();
305             this.worker.startThread();
306         }
307         else if (e.getSource() == this.browseButton)
308         {
309             this.parent.blockGUI();
310             JFileChooser JavaDoc chooser = new JFileChooser JavaDoc();
311             chooser.setCurrentDirectory(new File JavaDoc((String JavaDoc) this.compilerComboBox.getSelectedItem())
312                     .getParentFile());
313             int result = chooser.showDialog(this.parent, this.parent.langpack
314                     .getString("CompilePanel.browse.approve"));
315             if (result == JFileChooser.APPROVE_OPTION)
316             {
317                 File JavaDoc file_chosen = chooser.getSelectedFile();
318
319                 if (file_chosen.isFile())
320                 {
321                     this.compilerComboBox.setSelectedItem(file_chosen.getAbsolutePath());
322                 }
323
324             }
325
326             this.parent.releaseGUI();
327         }
328
329     }
330
331     /**
332      * Block the GUI - disalow input.
333      */

334     protected void blockGUI()
335     {
336         // disable all controls
337
this.startButton.setEnabled(false);
338         this.browseButton.setEnabled(false);
339         this.compilerComboBox.setEnabled(false);
340         this.argumentsComboBox.setEnabled(false);
341
342         this.parent.blockGUI();
343     }
344
345     /**
346      * Release the GUI - allow input.
347      *
348      * @param allowconfig allow the user to enter new configuration
349      */

350     protected void releaseGUI(boolean allowconfig)
351     {
352         // disable all controls
353
if (allowconfig)
354         {
355             this.startButton.setEnabled(true);
356             this.browseButton.setEnabled(true);
357             this.compilerComboBox.setEnabled(true);
358             this.argumentsComboBox.setEnabled(true);
359         }
360
361         this.parent.releaseGUI();
362     }
363
364     /**
365      * An error was encountered.
366      *
367      * @param error The error information.
368      * @see com.izforge.izpack.installer.CompileHandler
369      */

370     public void handleCompileError(CompileResult error)
371     {
372         String JavaDoc message = error.getMessage();
373         opLabel.setText(message);
374         CompilerErrorDialog dialog = new CompilerErrorDialog(parent, message, idata.buttonsHColor);
375         dialog.show(error);
376
377         if (dialog.getResult() == CompilerErrorDialog.RESULT_IGNORE)
378         {
379             error.setAction(CompileResult.ACTION_CONTINUE);
380         }
381         else if (dialog.getResult() == CompilerErrorDialog.RESULT_RECONFIGURE)
382         {
383             error.setAction(CompileResult.ACTION_RECONFIGURE);
384         }
385         else
386         // default case: abort
387
{
388             error.setAction(CompileResult.ACTION_ABORT);
389         }
390
391     }
392
393     /* (non-Javadoc)
394      * @see com.izforge.izpack.util.AbstractUIProgressHandler#startAction(java.lang.String, int)
395      */

396     public void startAction(String JavaDoc name, int noOfJobs1)
397     {
398         this.noOfJobs = noOfJobs1;
399         overallProgressBar.setMaximum(noOfJobs1);
400         parent.lockPrevButton();
401     }
402
403     /** The compiler stops. */
404     public void stopAction()
405     {
406         CompileResult result = this.worker.getResult();
407
408         this.releaseGUI(result.isReconfigure());
409
410         if (result.isContinue())
411         {
412             parent.lockPrevButton();
413
414             packProgressBar.setString(parent.langpack.getString("CompilePanel.progress.finished"));
415             packProgressBar.setEnabled(false);
416             packProgressBar.setValue(packProgressBar.getMaximum());
417
418             overallProgressBar.setValue(this.noOfJobs);
419             String JavaDoc no_of_jobs = Integer.toString(this.noOfJobs);
420             overallProgressBar.setString(no_of_jobs + " / " + no_of_jobs);
421             overallProgressBar.setEnabled(false);
422
423             opLabel.setText(" ");
424             opLabel.setEnabled(false);
425
426             validated = true;
427             idata.installSuccess = true;
428             if (idata.panels.indexOf(this) != (idata.panels.size() - 1)) parent.unlockNextButton();
429         }
430         else
431         {
432             idata.installSuccess = false;
433         }
434
435     }
436
437     /**
438      * Normal progress indicator.
439      *
440      * @param val The progression value.
441      * @param msg The progression message.
442      */

443     public void progress(int val, String JavaDoc msg)
444     {
445         // Debug.trace ("progress: " + val + " " + msg);
446
packProgressBar.setValue(val + 1);
447         opLabel.setText(msg);
448     }
449
450     /**
451      * Job changing.
452      *
453      * @param jobName The job name.
454      * @param max The new maximum progress.
455      * @param jobNo The job number.
456      */

457     public void nextStep(String JavaDoc jobName, int max, int jobNo)
458     {
459         packProgressBar.setValue(0);
460         packProgressBar.setMaximum(max);
461         packProgressBar.setString(jobName);
462
463         opLabel.setText("");
464
465         overallProgressBar.setValue(jobNo);
466         overallProgressBar.setString(Integer.toString(jobNo) + " / "
467                 + Integer.toString(this.noOfJobs));
468     }
469
470     /** Called when the panel becomes active. */
471     public void panelActivate()
472     {
473         // get compilers again (because they might contain variables from former
474
// panels)
475
Iterator JavaDoc it = this.worker.getAvailableCompilers().iterator();
476
477         compilerComboBox.removeAllItems();
478
479         while (it.hasNext())
480             compilerComboBox.addItem(it.next());
481
482         // We clip the panel
483
Dimension JavaDoc dim = parent.getPanelsContainerSize();
484         dim.width -= (dim.width / 4);
485         dim.height = 150;
486         setMinimumSize(dim);
487         setMaximumSize(dim);
488         setPreferredSize(dim);
489
490         parent.lockNextButton();
491     }
492
493     /** Create XML data for automated installation. */
494     public void makeXMLData(XMLElement panelRoot)
495     {
496         // just save the compiler chosen and the arguments
497
XMLElement compiler = new XMLElement("compiler");
498         compiler.setContent(this.worker.getCompiler());
499         panelRoot.addChild(compiler);
500
501         XMLElement args = new XMLElement("arguments");
502         args.setContent(this.worker.getCompilerArguments());
503         panelRoot.addChild(args);
504     }
505
506     /**
507      * Show a special dialog for compiler errors.
508      *
509      * This dialog is neccessary because we have lots of information if compilation failed. We'd
510      * also like the user to chose whether to ignore the error or not.
511      */

512     protected class CompilerErrorDialog extends JDialog JavaDoc implements ActionListener JavaDoc
513     {
514
515         private static final long serialVersionUID = 3762537797721995317L;
516
517         /** user closed the dialog without pressing "Ignore" or "Abort" */
518         public static final int RESULT_NONE = 0;
519
520         /** user pressed "Ignore" button */
521         public static final int RESULT_IGNORE = 23;
522
523         /** user pressed "Abort" button */
524         public static final int RESULT_ABORT = 42;
525
526         /** user pressed "Reconfigure" button */
527         public static final int RESULT_RECONFIGURE = 47;
528
529         /** visual goodie: button hightlight color */
530         private java.awt.Color JavaDoc buttonHColor = null;
531
532         /** Creates new form compilerErrorDialog
533          * @param parent parent to be used
534          * @param title String to be used as title
535          * @param buttonHColor highlight color to be used*/

536         public CompilerErrorDialog(java.awt.Frame JavaDoc parent, String JavaDoc title, java.awt.Color JavaDoc buttonHColor)
537         {
538             super(parent, title, true);
539             this.buttonHColor = buttonHColor;
540             initComponents();
541         }
542
543         /**
544          * This method is called from within the constructor to initialize the form.
545          *
546          * Generated with help from NetBeans IDE.
547          */

548         private void initComponents()
549         {
550             JPanel JavaDoc errorMessagePane = new JPanel JavaDoc();
551             errorMessageText = new JTextArea JavaDoc();
552             JTextArea JavaDoc seeBelowText = new JTextArea JavaDoc();
553             JTabbedPane JavaDoc errorDisplayPane = new JTabbedPane JavaDoc();
554             JScrollPane JavaDoc commandScrollPane = new JScrollPane JavaDoc();
555             commandText = new JTextArea JavaDoc();
556             JScrollPane JavaDoc stdOutScrollPane = new JScrollPane JavaDoc();
557             stdOutText = new JTextArea JavaDoc();
558             JScrollPane JavaDoc stdErrScrollPane = new JScrollPane JavaDoc();
559             stdErrText = new JTextArea JavaDoc();
560             JPanel JavaDoc buttonsPanel = new JPanel JavaDoc();
561             reconfigButton = ButtonFactory.createButton(parent.langpack
562                     .getString("CompilePanel.error.reconfigure"), this.buttonHColor);
563             ignoreButton = ButtonFactory.createButton(parent.langpack
564                     .getString("CompilePanel.error.ignore"), this.buttonHColor);
565             abortButton = ButtonFactory.createButton(parent.langpack
566                     .getString("CompilePanel.error.abort"), this.buttonHColor);
567
568             addWindowListener(new java.awt.event.WindowAdapter JavaDoc() {
569
570                 public void windowClosing(java.awt.event.WindowEvent JavaDoc evt)
571                 {
572                     closeDialog();
573                 }
574             });
575
576             errorMessagePane.setLayout(new BoxLayout JavaDoc(errorMessagePane, BoxLayout.Y_AXIS));
577             errorMessageText.setBackground(super.getBackground());
578             errorMessageText.setEditable(false);
579             errorMessageText.setLineWrap(true);
580             // errorMessageText.setText("The compiler does not seem to work. See
581
// below for the command we tried to execute and the results.");
582
// errorMessageText.setToolTipText("null");
583
errorMessageText.setWrapStyleWord(true);
584             errorMessagePane.add(errorMessageText);
585
586             seeBelowText.setBackground(super.getBackground());
587             seeBelowText.setEditable(false);
588             seeBelowText.setLineWrap(true);
589             seeBelowText.setWrapStyleWord(true);
590             seeBelowText.setText(parent.langpack.getString("CompilePanel.error.seebelow"));
591             errorMessagePane.add(seeBelowText);
592
593             getContentPane().add(errorMessagePane, java.awt.BorderLayout.NORTH);
594
595             // use 12pt monospace font for compiler output etc.
596
Font JavaDoc output_font = new Font JavaDoc("Monospaced", Font.PLAIN, 12);
597
598             // errorDisplayPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
599
// errorDisplayPane.setName("null");
600
commandText.setFont(output_font);
601             commandText.setEditable(false);
602             commandText.setRows(10);
603             commandText.setColumns(82);
604             commandText.setWrapStyleWord(true);
605             commandText.setLineWrap(true);
606             // commandText.setText("akjfkajfeafjakefjakfkaejfja");
607
commandScrollPane.setViewportView(commandText);
608
609             errorDisplayPane.addTab("Command", commandScrollPane);
610
611             stdOutText.setFont(output_font);
612             stdOutText.setEditable(false);
613             stdOutText.setWrapStyleWord(true);
614             stdOutText.setLineWrap(true);
615             stdOutScrollPane.setViewportView(stdOutText);
616
617             errorDisplayPane.addTab("Standard Output", null, stdOutScrollPane);
618
619             stdErrText.setFont(output_font);
620             stdErrText.setEditable(false);
621             stdErrText.setWrapStyleWord(true);
622             stdErrText.setLineWrap(true);
623             stdErrScrollPane.setViewportView(stdErrText);
624
625             errorDisplayPane.addTab("Standard Error", null, stdErrScrollPane);
626
627             getContentPane().add(errorDisplayPane, java.awt.BorderLayout.CENTER);
628
629             buttonsPanel.setLayout(new java.awt.FlowLayout JavaDoc(java.awt.FlowLayout.RIGHT));
630
631             reconfigButton.addActionListener(this);
632             buttonsPanel.add(reconfigButton);
633
634             ignoreButton.addActionListener(this);
635             buttonsPanel.add(ignoreButton);
636
637             abortButton.addActionListener(this);
638             buttonsPanel.add(abortButton);
639
640             getContentPane().add(buttonsPanel, java.awt.BorderLayout.SOUTH);
641
642             pack();
643         }
644
645         /**
646          * Close the panel.
647          */

648         protected void closeDialog()
649         {
650             setVisible(false);
651             dispose();
652         }
653
654         /**
655          * Shows the given errors
656          * @param error error messages to be shown
657          */

658         public void show(CompileResult error)
659         {
660             this.errorMessageText.setText(error.getMessage());
661             this.commandText.setText(error.getCmdline());
662             this.stdOutText.setText(error.getStdout());
663             this.stdErrText.setText(error.getStderr());
664             super.setVisible(true);
665         }
666
667         /**
668          * Returns the result of this dialog.
669          * @return the result of this dialog
670          */

671         public int getResult()
672         {
673             return this.result;
674         }
675
676         public void actionPerformed(ActionEvent JavaDoc e)
677         {
678             boolean closenow = false;
679
680             if (e.getSource() == this.ignoreButton)
681             {
682                 this.result = RESULT_IGNORE;
683                 closenow = true;
684             }
685             else if (e.getSource() == this.abortButton)
686             {
687                 this.result = RESULT_ABORT;
688                 closenow = true;
689             }
690             else if (e.getSource() == this.reconfigButton)
691             {
692                 this.result = RESULT_RECONFIGURE;
693                 closenow = true;
694             }
695
696             if (closenow)
697             {
698                 this.setVisible(false);
699                 this.dispose();
700             }
701
702         }
703
704         // Variables declaration - do not modify//GEN-BEGIN:variables
705
private JTextArea JavaDoc commandText;
706
707         // private JScrollPane stdOutScrollPane;
708
private JTextArea JavaDoc stdErrText;
709
710         // private JPanel buttonsPanel;
711
// private JScrollPane commandScrollPane;
712
private JTextArea JavaDoc errorMessageText;
713
714         // private JScrollPane stdErrScrollPane;
715
private JButton JavaDoc ignoreButton;
716
717         private JTextArea JavaDoc stdOutText;
718
719         private JButton JavaDoc abortButton;
720
721         private JButton JavaDoc reconfigButton;
722
723         // private JTabbedPane errorDisplayPane;
724
// End of variables declaration//GEN-END:variables
725

726         private int result = RESULT_NONE;
727     }
728 }
729
Popular Tags