Source Code Cross Referenced for CompilePanel.java in  » Installer » IzPack » com » izforge » izpack » panels » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Installer » IzPack » com.izforge.izpack.panels 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * IzPack - Copyright 2001-2008 Julien Ponge, All Rights Reserved.
003:         * 
004:         * http://izpack.org/
005:         * http://izpack.codehaus.org/
006:         * 
007:         * Copyright 2003 Tino Schwarze
008:         * 
009:         * Licensed under the Apache License, Version 2.0 (the "License");
010:         * you may not use this file except in compliance with the License.
011:         * You may obtain a copy of the License at
012:         * 
013:         *     http://www.apache.org/licenses/LICENSE-2.0
014:         *     
015:         * Unless required by applicable law or agreed to in writing, software
016:         * distributed under the License is distributed on an "AS IS" BASIS,
017:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018:         * See the License for the specific language governing permissions and
019:         * limitations under the License.
020:         */
021:        package com.izforge.izpack.panels;
022:
023:        import java.awt.Dimension;
024:        import java.awt.Font;
025:        import java.awt.GridBagConstraints;
026:        import java.awt.GridBagLayout;
027:        import java.awt.Insets;
028:        import java.awt.event.ActionEvent;
029:        import java.awt.event.ActionListener;
030:        import java.io.File;
031:        import java.io.IOException;
032:        import java.util.Iterator;
033:
034:        import javax.swing.BoxLayout;
035:        import javax.swing.JButton;
036:        import javax.swing.JComboBox;
037:        import javax.swing.JDialog;
038:        import javax.swing.JFileChooser;
039:        import javax.swing.JLabel;
040:        import javax.swing.JPanel;
041:        import javax.swing.JProgressBar;
042:        import javax.swing.JScrollPane;
043:        import javax.swing.JTabbedPane;
044:        import javax.swing.JTextArea;
045:        import javax.swing.SwingConstants;
046:
047:        import net.n3.nanoxml.XMLElement;
048:
049:        import com.izforge.izpack.gui.ButtonFactory;
050:        import com.izforge.izpack.gui.LabelFactory;
051:        import com.izforge.izpack.installer.CompileHandler;
052:        import com.izforge.izpack.installer.CompileResult;
053:        import com.izforge.izpack.installer.CompileWorker;
054:        import com.izforge.izpack.installer.InstallData;
055:        import com.izforge.izpack.installer.InstallerFrame;
056:        import com.izforge.izpack.installer.IzPanel;
057:
058:        /**
059:         * The compile panel class.
060:         * 
061:         * This class allows .java files to be compiled after installation.
062:         * 
063:         * Parts of the code have been taken from InstallPanel.java and modified a lot.
064:         * 
065:         * @author Tino Schwarze
066:         * @author Julien Ponge
067:         */
068:        public class CompilePanel extends IzPanel implements  ActionListener,
069:                CompileHandler {
070:
071:            /**
072:             * 
073:             */
074:            private static final long serialVersionUID = 3258408430669674552L;
075:
076:            /** The combobox for compiler selection. */
077:            protected JComboBox compilerComboBox;
078:
079:            /** The combobox for compiler argument selection. */
080:            protected JComboBox argumentsComboBox;
081:
082:            /** The start button. */
083:            protected JButton startButton;
084:
085:            /** The browse button. */
086:            protected JButton browseButton;
087:
088:            /** The tip label. */
089:            protected JLabel tipLabel;
090:
091:            /** The operation label . */
092:            protected JLabel opLabel;
093:
094:            /** The pack progress bar. */
095:            protected JProgressBar packProgressBar;
096:
097:            /** The operation label . */
098:            protected JLabel overallLabel;
099:
100:            /** The overall progress bar. */
101:            protected JProgressBar 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)
120:                    throws IOException {
121:                super (parent, idata);
122:
123:                this .worker = new CompileWorker(idata, this );
124:
125:                GridBagConstraints gridBagConstraints;
126:
127:                JLabel heading = new JLabel();
128:                // put everything but the heading into it's own panel
129:                // (to center it vertically)
130:                JPanel subpanel = new JPanel();
131:                JLabel compilerLabel = new JLabel();
132:                compilerComboBox = new JComboBox();
133:                this .browseButton = ButtonFactory.createButton(parent.langpack
134:                        .getString("CompilePanel.browse"), idata.buttonsHColor);
135:                JLabel argumentsLabel = new JLabel();
136:                this .argumentsComboBox = new JComboBox();
137:                this .startButton = ButtonFactory.createButton(parent.langpack
138:                        .getString("CompilePanel.start"), idata.buttonsHColor);
139:                this .tipLabel = LabelFactory.create(parent.langpack
140:                        .getString("CompilePanel.tip"), parent.icons
141:                        .getImageIcon("tip"), SwingConstants.TRAILING);
142:                this .opLabel = new JLabel();
143:                packProgressBar = new JProgressBar();
144:                this .overallLabel = new JLabel();
145:                this .overallProgressBar = new JProgressBar();
146:
147:                setLayout(new GridBagLayout());
148:
149:                Font font = heading.getFont();
150:                font = font.deriveFont(Font.BOLD, font.getSize() * 2.0f);
151:                heading.setFont(font);
152:                heading.setHorizontalAlignment(SwingConstants.CENTER);
153:                heading.setText(parent.langpack
154:                        .getString("CompilePanel.heading"));
155:                heading.setVerticalAlignment(SwingConstants.TOP);
156:                gridBagConstraints = new GridBagConstraints();
157:                gridBagConstraints.gridy = 0;
158:                gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
159:                gridBagConstraints.anchor = GridBagConstraints.NORTH;
160:                gridBagConstraints.weightx = 1.0;
161:                gridBagConstraints.weighty = 0.1;
162:                add(heading, gridBagConstraints);
163:
164:                gridBagConstraints = new GridBagConstraints();
165:                gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
166:                gridBagConstraints.anchor = GridBagConstraints.CENTER;
167:                gridBagConstraints.gridy = 1;
168:                gridBagConstraints.weightx = 1.0;
169:                gridBagConstraints.weighty = 0.9;
170:                add(subpanel, gridBagConstraints);
171:
172:                subpanel.setLayout(new GridBagLayout());
173:
174:                int row = 0;
175:
176:                compilerLabel.setHorizontalAlignment(SwingConstants.LEFT);
177:                compilerLabel.setLabelFor(compilerComboBox);
178:                compilerLabel.setText(parent.langpack
179:                        .getString("CompilePanel.choose_compiler"));
180:                gridBagConstraints = new GridBagConstraints();
181:                gridBagConstraints.gridy = row;
182:                gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
183:                // gridBagConstraints.weighty = 0.1;
184:                subpanel.add(compilerLabel, gridBagConstraints);
185:
186:                compilerComboBox.setEditable(true);
187:                gridBagConstraints = new GridBagConstraints();
188:                gridBagConstraints.gridy = row++;
189:                gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
190:                // gridBagConstraints.weighty = 0.1;
191:
192:                Iterator<String> it = this .worker.getAvailableCompilers()
193:                        .iterator();
194:
195:                while (it.hasNext())
196:                    compilerComboBox.addItem(it.next());
197:
198:                subpanel.add(compilerComboBox, gridBagConstraints);
199:
200:                gridBagConstraints = new GridBagConstraints();
201:                gridBagConstraints.gridy = row++;
202:                gridBagConstraints.gridx = 1;
203:                gridBagConstraints.anchor = GridBagConstraints.EAST;
204:                browseButton.addActionListener(this );
205:                subpanel.add(browseButton, gridBagConstraints);
206:
207:                argumentsLabel.setHorizontalAlignment(SwingConstants.LEFT);
208:                argumentsLabel.setLabelFor(argumentsComboBox);
209:                argumentsLabel.setText(parent.langpack
210:                        .getString("CompilePanel.additional_arguments"));
211:                // argumentsLabel.setToolTipText("");
212:                gridBagConstraints = new GridBagConstraints();
213:                gridBagConstraints.gridy = row;
214:                gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
215:                gridBagConstraints.weightx = 0.5;
216:                // gridBagConstraints.weighty = 0.1;
217:                subpanel.add(argumentsLabel, gridBagConstraints);
218:
219:                argumentsComboBox.setEditable(true);
220:                gridBagConstraints = new GridBagConstraints();
221:                gridBagConstraints.gridy = row++;
222:                gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
223:                gridBagConstraints.weightx = 0.5;
224:                // gridBagConstraints.weighty = 0.1;
225:
226:                it = this .worker.getAvailableArguments().iterator();
227:
228:                while (it.hasNext())
229:                    argumentsComboBox.addItem(it.next());
230:
231:                subpanel.add(argumentsComboBox, gridBagConstraints);
232:
233:                // leave some space above the label
234:                gridBagConstraints.insets = new Insets(10, 0, 0, 0);
235:                gridBagConstraints = new GridBagConstraints();
236:                gridBagConstraints.gridy = row++;
237:                gridBagConstraints.gridwidth = 2;
238:                gridBagConstraints.fill = GridBagConstraints.NONE;
239:                gridBagConstraints.anchor = GridBagConstraints.NORTHWEST;
240:                subpanel.add(tipLabel, gridBagConstraints);
241:
242:                opLabel.setText(" ");
243:                gridBagConstraints = new GridBagConstraints();
244:                gridBagConstraints.gridy = row++;
245:                gridBagConstraints.gridwidth = 2;
246:                gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
247:                subpanel.add(opLabel, gridBagConstraints);
248:
249:                packProgressBar.setValue(0);
250:                packProgressBar.setString(parent.langpack
251:                        .getString("CompilePanel.progress.initial"));
252:                packProgressBar.setStringPainted(true);
253:                gridBagConstraints = new GridBagConstraints();
254:                gridBagConstraints.gridy = row++;
255:                gridBagConstraints.gridwidth = 2;
256:                gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
257:                gridBagConstraints.anchor = GridBagConstraints.SOUTH;
258:                subpanel.add(packProgressBar, gridBagConstraints);
259:
260:                overallLabel.setText(parent.langpack
261:                        .getString("CompilePanel.progress.overall"));
262:                gridBagConstraints = new GridBagConstraints();
263:                gridBagConstraints.gridy = row++;
264:                gridBagConstraints.gridwidth = 2;
265:                gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
266:                subpanel.add(overallLabel, gridBagConstraints);
267:
268:                overallProgressBar.setValue(0);
269:                overallProgressBar.setString("");
270:                overallProgressBar.setStringPainted(true);
271:                gridBagConstraints = new GridBagConstraints();
272:                gridBagConstraints.gridy = row++;
273:                gridBagConstraints.gridwidth = 2;
274:                gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
275:                gridBagConstraints.anchor = GridBagConstraints.SOUTH;
276:                subpanel.add(overallProgressBar, gridBagConstraints);
277:
278:                startButton.setText(parent.langpack
279:                        .getString("CompilePanel.start"));
280:                startButton.addActionListener(this );
281:                gridBagConstraints = new GridBagConstraints();
282:                gridBagConstraints.gridx = 0;
283:                gridBagConstraints.gridwidth = 2;
284:                gridBagConstraints.gridy = row++;
285:                gridBagConstraints.fill = GridBagConstraints.NONE;
286:                // leave some space above the button
287:                gridBagConstraints.insets = new Insets(5, 0, 0, 0);
288:                subpanel.add(startButton, gridBagConstraints);
289:            }
290:
291:            /**
292:             * Indicates wether the panel has been validated or not.
293:             * 
294:             * @return The validation state.
295:             */
296:            public boolean isValidated() {
297:                return validated;
298:            }
299:
300:            /**
301:             * Action function, called when the start button is pressed.
302:             */
303:            public void actionPerformed(ActionEvent e) {
304:                if (e.getSource() == this .startButton) {
305:                    this .worker.setCompiler((String) this .compilerComboBox
306:                            .getSelectedItem());
307:
308:                    this .worker
309:                            .setCompilerArguments((String) this .argumentsComboBox
310:                                    .getSelectedItem());
311:
312:                    this .blockGUI();
313:                    this .worker.startThread();
314:                } else if (e.getSource() == this .browseButton) {
315:                    this .parent.blockGUI();
316:                    JFileChooser chooser = new JFileChooser();
317:                    chooser.setCurrentDirectory(new File(
318:                            (String) this .compilerComboBox.getSelectedItem())
319:                            .getParentFile());
320:                    int result = chooser.showDialog(this .parent,
321:                            this .parent.langpack
322:                                    .getString("CompilePanel.browse.approve"));
323:                    if (result == JFileChooser.APPROVE_OPTION) {
324:                        File file_chosen = chooser.getSelectedFile();
325:
326:                        if (file_chosen.isFile()) {
327:                            this .compilerComboBox.setSelectedItem(file_chosen
328:                                    .getAbsolutePath());
329:                        }
330:
331:                    }
332:
333:                    this .parent.releaseGUI();
334:                }
335:
336:            }
337:
338:            /**
339:             * Block the GUI - disalow input.
340:             */
341:            protected void blockGUI() {
342:                // disable all controls
343:                this .startButton.setEnabled(false);
344:                this .browseButton.setEnabled(false);
345:                this .compilerComboBox.setEnabled(false);
346:                this .argumentsComboBox.setEnabled(false);
347:
348:                this .parent.blockGUI();
349:            }
350:
351:            /**
352:             * Release the GUI - allow input.
353:             * 
354:             * @param allowconfig allow the user to enter new configuration
355:             */
356:            protected void releaseGUI(boolean allowconfig) {
357:                // disable all controls
358:                if (allowconfig) {
359:                    this .startButton.setEnabled(true);
360:                    this .browseButton.setEnabled(true);
361:                    this .compilerComboBox.setEnabled(true);
362:                    this .argumentsComboBox.setEnabled(true);
363:                }
364:
365:                this .parent.releaseGUI();
366:            }
367:
368:            /**
369:             * An error was encountered.
370:             * 
371:             * @param error The error information.
372:             * @see com.izforge.izpack.installer.CompileHandler
373:             */
374:            public void handleCompileError(CompileResult error) {
375:                String message = error.getMessage();
376:                opLabel.setText(message);
377:                CompilerErrorDialog dialog = new CompilerErrorDialog(parent,
378:                        message, idata.buttonsHColor);
379:                dialog.show(error);
380:
381:                if (dialog.getResult() == CompilerErrorDialog.RESULT_IGNORE) {
382:                    error.setAction(CompileResult.ACTION_CONTINUE);
383:                } else if (dialog.getResult() == CompilerErrorDialog.RESULT_RECONFIGURE) {
384:                    error.setAction(CompileResult.ACTION_RECONFIGURE);
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 name, int noOfJobs1) {
397:                this .noOfJobs = noOfJobs1;
398:                overallProgressBar.setMaximum(noOfJobs1);
399:                parent.lockPrevButton();
400:            }
401:
402:            /** The compiler stops. */
403:            public void stopAction() {
404:                CompileResult result = this .worker.getResult();
405:
406:                this .releaseGUI(result.isReconfigure());
407:
408:                if (result.isContinue()) {
409:                    parent.lockPrevButton();
410:
411:                    packProgressBar.setString(parent.langpack
412:                            .getString("CompilePanel.progress.finished"));
413:                    packProgressBar.setEnabled(false);
414:                    packProgressBar.setValue(packProgressBar.getMaximum());
415:
416:                    overallProgressBar.setValue(this .noOfJobs);
417:                    String no_of_jobs = Integer.toString(this .noOfJobs);
418:                    overallProgressBar.setString(no_of_jobs + " / "
419:                            + no_of_jobs);
420:                    overallProgressBar.setEnabled(false);
421:
422:                    opLabel.setText(" ");
423:                    opLabel.setEnabled(false);
424:
425:                    validated = true;
426:                    idata.installSuccess = true;
427:                    if (idata.panels.indexOf(this ) != (idata.panels.size() - 1))
428:                        parent.unlockNextButton();
429:                } else {
430:                    idata.installSuccess = false;
431:                }
432:
433:            }
434:
435:            /**
436:             * Normal progress indicator.
437:             * 
438:             * @param val The progression value.
439:             * @param msg The progression message.
440:             */
441:            public void progress(int val, String msg) {
442:                // Debug.trace ("progress: " + val + " " + msg);
443:                packProgressBar.setValue(val + 1);
444:                opLabel.setText(msg);
445:            }
446:
447:            /**
448:             * Job changing.
449:             * 
450:             * @param jobName The job name.
451:             * @param max The new maximum progress.
452:             * @param jobNo The job number.
453:             */
454:            public void nextStep(String jobName, int max, int jobNo) {
455:                packProgressBar.setValue(0);
456:                packProgressBar.setMaximum(max);
457:                packProgressBar.setString(jobName);
458:
459:                opLabel.setText("");
460:
461:                overallProgressBar.setValue(jobNo);
462:                overallProgressBar.setString(Integer.toString(jobNo) + " / "
463:                        + Integer.toString(this .noOfJobs));
464:            }
465:
466:            /**
467:             * {@inheritDoc}
468:             */
469:            public void setSubStepNo(int max) {
470:                packProgressBar.setMaximum(max);
471:            }
472:
473:            /** Called when the panel becomes active. */
474:            public void panelActivate() {
475:                // get compilers again (because they might contain variables from former
476:                // panels)
477:                Iterator<String> it = this .worker.getAvailableCompilers()
478:                        .iterator();
479:
480:                compilerComboBox.removeAllItems();
481:
482:                while (it.hasNext())
483:                    compilerComboBox.addItem(it.next());
484:
485:                // We clip the panel
486:                Dimension dim = parent.getPanelsContainerSize();
487:                dim.width -= (dim.width / 4);
488:                dim.height = 150;
489:                setMinimumSize(dim);
490:                setMaximumSize(dim);
491:                setPreferredSize(dim);
492:
493:                parent.lockNextButton();
494:            }
495:
496:            /** Create XML data for automated installation. */
497:            public void makeXMLData(XMLElement panelRoot) {
498:                // just save the compiler chosen and the arguments
499:                XMLElement compiler = new XMLElement("compiler");
500:                compiler.setContent(this .worker.getCompiler());
501:                panelRoot.addChild(compiler);
502:
503:                XMLElement args = new XMLElement("arguments");
504:                args.setContent(this .worker.getCompilerArguments());
505:                panelRoot.addChild(args);
506:            }
507:
508:            /**
509:             * Show a special dialog for compiler errors.
510:             * 
511:             * This dialog is neccessary because we have lots of information if compilation failed. We'd
512:             * also like the user to chose whether to ignore the error or not.
513:             */
514:            protected class CompilerErrorDialog extends JDialog implements 
515:                    ActionListener {
516:
517:                private static final long serialVersionUID = 3762537797721995317L;
518:
519:                /** user closed the dialog without pressing "Ignore" or "Abort" */
520:                public static final int RESULT_NONE = 0;
521:
522:                /** user pressed "Ignore" button */
523:                public static final int RESULT_IGNORE = 23;
524:
525:                /** user pressed "Abort" button */
526:                public static final int RESULT_ABORT = 42;
527:
528:                /** user pressed "Reconfigure" button */
529:                public static final int RESULT_RECONFIGURE = 47;
530:
531:                /** visual goodie: button hightlight color */
532:                private java.awt.Color buttonHColor = null;
533:
534:                /** Creates new form compilerErrorDialog 
535:                 * @param parent parent to be used
536:                 * @param title String to be used as title
537:                 * @param buttonHColor highlight color to be used*/
538:                public CompilerErrorDialog(java.awt.Frame parent, String title,
539:                        java.awt.Color buttonHColor) {
540:                    super (parent, title, true);
541:                    this .buttonHColor = buttonHColor;
542:                    initComponents();
543:                }
544:
545:                /**
546:                 * This method is called from within the constructor to initialize the form.
547:                 * 
548:                 * Generated with help from NetBeans IDE.
549:                 */
550:                private void initComponents() {
551:                    JPanel errorMessagePane = new JPanel();
552:                    errorMessageText = new JTextArea();
553:                    JTextArea seeBelowText = new JTextArea();
554:                    JTabbedPane errorDisplayPane = new JTabbedPane();
555:                    JScrollPane commandScrollPane = new JScrollPane();
556:                    commandText = new JTextArea();
557:                    JScrollPane stdOutScrollPane = new JScrollPane();
558:                    stdOutText = new JTextArea();
559:                    JScrollPane stdErrScrollPane = new JScrollPane();
560:                    stdErrText = new JTextArea();
561:                    JPanel buttonsPanel = new JPanel();
562:                    reconfigButton = ButtonFactory.createButton(parent.langpack
563:                            .getString("CompilePanel.error.reconfigure"),
564:                            this .buttonHColor);
565:                    ignoreButton = ButtonFactory.createButton(parent.langpack
566:                            .getString("CompilePanel.error.ignore"),
567:                            this .buttonHColor);
568:                    abortButton = ButtonFactory.createButton(parent.langpack
569:                            .getString("CompilePanel.error.abort"),
570:                            this .buttonHColor);
571:
572:                    addWindowListener(new java.awt.event.WindowAdapter() {
573:
574:                        public void windowClosing(java.awt.event.WindowEvent evt) {
575:                            closeDialog();
576:                        }
577:                    });
578:
579:                    errorMessagePane.setLayout(new BoxLayout(errorMessagePane,
580:                            BoxLayout.Y_AXIS));
581:                    errorMessageText.setBackground(super .getBackground());
582:                    errorMessageText.setEditable(false);
583:                    errorMessageText.setLineWrap(true);
584:                    // errorMessageText.setText("The compiler does not seem to work. See
585:                    // below for the command we tried to execute and the results.");
586:                    // errorMessageText.setToolTipText("null");
587:                    errorMessageText.setWrapStyleWord(true);
588:                    errorMessagePane.add(errorMessageText);
589:
590:                    seeBelowText.setBackground(super .getBackground());
591:                    seeBelowText.setEditable(false);
592:                    seeBelowText.setLineWrap(true);
593:                    seeBelowText.setWrapStyleWord(true);
594:                    seeBelowText.setText(parent.langpack
595:                            .getString("CompilePanel.error.seebelow"));
596:                    errorMessagePane.add(seeBelowText);
597:
598:                    getContentPane().add(errorMessagePane,
599:                            java.awt.BorderLayout.NORTH);
600:
601:                    // use 12pt monospace font for compiler output etc.
602:                    Font output_font = new Font("Monospaced", Font.PLAIN, 12);
603:
604:                    // errorDisplayPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
605:                    // errorDisplayPane.setName("null");
606:                    commandText.setFont(output_font);
607:                    commandText.setEditable(false);
608:                    commandText.setRows(10);
609:                    commandText.setColumns(82);
610:                    commandText.setWrapStyleWord(true);
611:                    commandText.setLineWrap(true);
612:                    // commandText.setText("akjfkajfeafjakefjakfkaejfja");
613:                    commandScrollPane.setViewportView(commandText);
614:
615:                    errorDisplayPane.addTab("Command", commandScrollPane);
616:
617:                    stdOutText.setFont(output_font);
618:                    stdOutText.setEditable(false);
619:                    stdOutText.setWrapStyleWord(true);
620:                    stdOutText.setLineWrap(true);
621:                    stdOutScrollPane.setViewportView(stdOutText);
622:
623:                    errorDisplayPane.addTab("Standard Output", null,
624:                            stdOutScrollPane);
625:
626:                    stdErrText.setFont(output_font);
627:                    stdErrText.setEditable(false);
628:                    stdErrText.setWrapStyleWord(true);
629:                    stdErrText.setLineWrap(true);
630:                    stdErrScrollPane.setViewportView(stdErrText);
631:
632:                    errorDisplayPane.addTab("Standard Error", null,
633:                            stdErrScrollPane);
634:
635:                    getContentPane().add(errorDisplayPane,
636:                            java.awt.BorderLayout.CENTER);
637:
638:                    buttonsPanel.setLayout(new java.awt.FlowLayout(
639:                            java.awt.FlowLayout.RIGHT));
640:
641:                    reconfigButton.addActionListener(this );
642:                    buttonsPanel.add(reconfigButton);
643:
644:                    ignoreButton.addActionListener(this );
645:                    buttonsPanel.add(ignoreButton);
646:
647:                    abortButton.addActionListener(this );
648:                    buttonsPanel.add(abortButton);
649:
650:                    getContentPane().add(buttonsPanel,
651:                            java.awt.BorderLayout.SOUTH);
652:
653:                    pack();
654:                }
655:
656:                /** 
657:                 * Close the panel.
658:                 */
659:                protected void closeDialog() {
660:                    setVisible(false);
661:                    dispose();
662:                }
663:
664:                /**
665:                 * Shows the given errors
666:                 * @param error error messages to be shown
667:                 */
668:                public void show(CompileResult error) {
669:                    this .errorMessageText.setText(error.getMessage());
670:                    this .commandText.setText(error.getCmdline());
671:                    this .stdOutText.setText(error.getStdout());
672:                    this .stdErrText.setText(error.getStderr());
673:                    super .setVisible(true);
674:                }
675:
676:                /**
677:                 * Returns the result of this dialog.
678:                 * @return the result of this dialog
679:                 */
680:                public int getResult() {
681:                    return this .result;
682:                }
683:
684:                public void actionPerformed(ActionEvent e) {
685:                    boolean closenow = false;
686:
687:                    if (e.getSource() == this .ignoreButton) {
688:                        this .result = RESULT_IGNORE;
689:                        closenow = true;
690:                    } else if (e.getSource() == this .abortButton) {
691:                        this .result = RESULT_ABORT;
692:                        closenow = true;
693:                    } else if (e.getSource() == this .reconfigButton) {
694:                        this .result = RESULT_RECONFIGURE;
695:                        closenow = true;
696:                    }
697:
698:                    if (closenow) {
699:                        this .setVisible(false);
700:                        this .dispose();
701:                    }
702:
703:                }
704:
705:                // Variables declaration - do not modify//GEN-BEGIN:variables
706:                private JTextArea commandText;
707:
708:                // private JScrollPane stdOutScrollPane;
709:                private JTextArea stdErrText;
710:
711:                // private JPanel buttonsPanel;
712:                // private JScrollPane commandScrollPane;
713:                private JTextArea errorMessageText;
714:
715:                // private JScrollPane stdErrScrollPane;
716:                private JButton ignoreButton;
717:
718:                private JTextArea stdOutText;
719:
720:                private JButton abortButton;
721:
722:                private JButton reconfigButton;
723:
724:                // private JTabbedPane errorDisplayPane;
725:                // End of variables declaration//GEN-END:variables
726:
727:                private int result = RESULT_NONE;
728:            }
729:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.