Source Code Cross Referenced for ApplicationFrame.java in  » Web-Framework » JAT » com » jat » core » installer » gui » 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 » Web Framework » JAT » com.jat.core.installer.gui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.jat.core.installer.gui;
002:
003:        import java.io.File;
004:
005:        import java.awt.AWTEvent;
006:        import java.awt.BorderLayout;
007:        import java.awt.Cursor;
008:        import java.awt.Dimension;
009:        import java.awt.Rectangle;
010:        import java.awt.event.ActionEvent;
011:        import java.awt.event.MouseAdapter;
012:        import java.awt.event.WindowEvent;
013:        import javax.swing.JButton;
014:        import javax.swing.JFileChooser;
015:        import javax.swing.JFrame;
016:        import javax.swing.JLabel;
017:        import javax.swing.JPanel;
018:        import javax.swing.JTextField;
019:        import javax.swing.SwingConstants;
020:
021:        import com.jat.core.installer.Installer;
022:
023:        /**
024:         * <p>Title: JAT</p>
025:         * <p>Description:</p>
026:         * <p>Copyright: Copyright (c) 2004 -2005 Stefano Fratini (stefano.fratini@gmail.com)</p>
027:         * <p>Distributed under the terms of the GNU Lesser General Public License, v2.1 or later</p>
028:         * @author stf
029:         * @version 1.1
030:         * @since 1.2
031:         */
032:
033:        public class ApplicationFrame extends JFrame {
034:            JPanel contentPane;
035:            BorderLayout borderLayout1 = new BorderLayout();
036:            JPanel corePanel = new JPanel();
037:            JPanel actionPanel = new JPanel();
038:            JLabel jLabel1 = new JLabel();
039:            JTextField projectNameTextField = new JTextField();
040:            JLabel jLabel2 = new JLabel();
041:            JTextField projectPathTextField = new JTextField();
042:            JLabel jLabel3 = new JLabel();
043:            JTextField webAppPathTextField = new JTextField();
044:            JButton projectPathButton = new JButton();
045:            JButton wabAppPathButton = new JButton();
046:            JButton installButton = new JButton();
047:
048:            //Construct the frame
049:            private String projectName;
050:            private String projectPath;
051:            private String webAppPath;
052:            private Installer gc;
053:            JPanel messagePanel = new JPanel();
054:            BorderLayout borderLayout2 = new BorderLayout();
055:            JPanel buttonsPanel = new JPanel();
056:            JLabel messageLabel = new JLabel();
057:
058:            public ApplicationFrame(Installer gc, String projectName,
059:                    String projectPath, String webAppPath) {
060:                this .gc = gc;
061:                this .projectName = projectName;
062:                this .projectPath = projectPath;
063:                this .webAppPath = webAppPath;
064:                enableEvents(AWTEvent.WINDOW_EVENT_MASK);
065:                try {
066:                    jbInit();
067:                } catch (Exception e) {
068:                    e.printStackTrace();
069:                }
070:            }
071:
072:            //Component initialization
073:            private void jbInit() throws Exception {
074:                projectPathButton.setActionCommand("select...");
075:                projectPathButton.setText("select...");
076:                projectPathButton
077:                        .addActionListener(new ApplicationFrame_projectPathButton_actionAdapter(
078:                                this ));
079:                wabAppPathButton.setText("select...");
080:                wabAppPathButton
081:                        .addActionListener(new ApplicationFrame_wabAppPathButton_actionAdapter(
082:                                this ));
083:                installButton.setText("install");
084:                installButton
085:                        .addActionListener(new ApplicationFrame_installButton_actionAdapter(
086:                                this ));
087:                this .setResizable(false);
088:                this 
089:                        .addWindowFocusListener(new ApplicationFrame_this_windowFocusAdapter(
090:                                this ));
091:                this .addMouseListener(new ApplicationFrame_this_mouseAdapter(
092:                        this ));
093:                actionPanel.setLayout(borderLayout2);
094:                corePanel.setLayout(null);
095:                jLabel1.setHorizontalAlignment(SwingConstants.RIGHT);
096:                jLabel1.setBounds(new Rectangle(10, 65, 110, 15));
097:                projectNameTextField.setBounds(new Rectangle(125, 62, 124, 21));
098:
099:                jLabel2.setHorizontalAlignment(SwingConstants.RIGHT);
100:                jLabel2.setBounds(new Rectangle(11, 90, 110, 15));
101:                projectPathTextField.setBounds(new Rectangle(125, 88, 167, 21));
102:                projectPathButton.setBounds(new Rectangle(300, 86, 79, 25));
103:                projectPathButton.setAlignmentX((float) 0.0);
104:
105:                jLabel3.setHorizontalAlignment(SwingConstants.RIGHT);
106:                jLabel3.setBounds(new Rectangle(11, 117, 110, 15));
107:                webAppPathTextField.setBounds(new Rectangle(125, 114, 167, 21));
108:                wabAppPathButton.setBounds(new Rectangle(300, 113, 79, 25));
109:
110:                jLabel4.setHorizontalAlignment(SwingConstants.RIGHT);
111:                jLabel4.setText("Web Application");
112:                jLabel4.setBounds(new Rectangle(14, 144, 105, 15));
113:                warTextField.setText(gc.getWarFilename());
114:                warTextField.setBounds(new Rectangle(125, 140, 166, 21));
115:                warButton.setBounds(new Rectangle(300, 140, 79, 25));
116:                warButton.setText("select...");
117:                warButton
118:                        .addActionListener(new ApplicationFrame_warButton_actionAdapter(
119:                                this ));
120:                jLabel5.setHorizontalAlignment(SwingConstants.RIGHT);
121:                jLabel5.setText("Main config file");
122:                jLabel5.setBounds(new Rectangle(15, 169, 108, 15));
123:                configTextField.setText(gc.getConfigFilename());
124:                configTextField.setBounds(new Rectangle(124, 165, 167, 21));
125:                configButton.setBounds(new Rectangle(300, 166, 79, 25));
126:                configButton.setText("select...");
127:                configButton
128:                        .addActionListener(new ApplicationFrame_configButton_actionAdapter(
129:                                this ));
130:                contentPane = (JPanel) this .getContentPane();
131:                contentPane.setLayout(borderLayout1);
132:                this .setSize(new Dimension(400, 300));
133:                this .setTitle("JAT Installer");
134:                jLabel1.setText("Project name");
135:                projectNameTextField.setText(projectName);
136:                jLabel2.setText("Project path");
137:                projectPathTextField.setText(projectPath);
138:                jLabel3.setText("Appl.Server path");
139:                webAppPathTextField.setText(webAppPath);
140:                contentPane.add(actionPanel, BorderLayout.SOUTH);
141:                actionPanel.add(messagePanel, BorderLayout.NORTH);
142:                messagePanel.add(messageLabel, null);
143:                buttonsPanel.add(installButton, BorderLayout.SOUTH);
144:                contentPane.add(corePanel, BorderLayout.CENTER);
145:                actionPanel.add(buttonsPanel, BorderLayout.CENTER);
146:                corePanel.add(projectNameTextField);
147:                corePanel.add(jLabel1);
148:                corePanel.add(jLabel2);
149:                corePanel.add(projectPathTextField);
150:                corePanel.add(projectPathButton);
151:                corePanel.add(wabAppPathButton);
152:                corePanel.add(webAppPathTextField);
153:                corePanel.add(jLabel3);
154:                corePanel.add(warButton, null);
155:                corePanel.add(warTextField, null);
156:                corePanel.add(jLabel4, null);
157:                corePanel.add(configTextField, null);
158:                corePanel.add(configButton, null);
159:                corePanel.add(jLabel5, null);
160:            }
161:
162:            private String selectFile(String current, String fileType,
163:                    String fileDescr) {
164:                JFileChooser chooser = new JFileChooser();
165:                chooser.setMultiSelectionEnabled(false);
166:                chooser.setDialogTitle("Please, select the file");
167:                chooser.setDialogType(JFileChooser.OPEN_DIALOG);
168:                chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
169:                File f = new File(current);
170:                try {
171:                    chooser.setCurrentDirectory(new File(f.getCanonicalPath()));
172:                } catch (Exception ex) {
173:                    System.out.println(ex);
174:                }
175:                FileFilter filter = new FileFilter(fileType, fileDescr);
176:                chooser.setFileFilter(filter);
177:                chooser.setAcceptAllFileFilterUsed(false);
178:                int returnVal = chooser.showOpenDialog(this );
179:                if (returnVal == JFileChooser.APPROVE_OPTION) {
180:                    return chooser.getSelectedFile().getAbsolutePath();
181:                } else {
182:                    return null;
183:                }
184:            }
185:
186:            private String selectPath(String current) {
187:                JFileChooser chooser = new JFileChooser();
188:                chooser.setMultiSelectionEnabled(false);
189:                chooser.setDialogTitle("Please, select a folder");
190:                chooser.setDialogType(JFileChooser.OPEN_DIALOG);
191:                chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
192:                try {
193:                    chooser.setCurrentDirectory(new File(current));
194:                } catch (Exception ex) {
195:
196:                }
197:                int returnVal = chooser.showOpenDialog(this );
198:                if (returnVal == JFileChooser.APPROVE_OPTION) {
199:                    return chooser.getSelectedFile().getAbsolutePath();
200:                } else {
201:                    return null;
202:                }
203:            }
204:
205:            //Overridden so we can exit when window is closed
206:            protected void processWindowEvent(WindowEvent e) {
207:                super .processWindowEvent(e);
208:                if (installing)
209:                    return;
210:                if (e.getID() == WindowEvent.WINDOW_CLOSING) {
211:                    System.exit(0);
212:                }
213:            }
214:
215:            void projectPathButton_actionPerformed(ActionEvent e) {
216:                String path = this .selectPath(this .projectPathTextField
217:                        .getText());
218:                if (path != null) {
219:                    this .projectPathTextField.setText(path);
220:                }
221:            }
222:
223:            void wabAppPathButton_actionPerformed(ActionEvent e) {
224:                String path = this .selectPath(this .webAppPathTextField
225:                        .getText());
226:                if (path != null) {
227:                    this .webAppPathTextField.setText(path);
228:                }
229:            }
230:
231:            void installButton_actionPerformed(ActionEvent e) {
232:                try {
233:                    this .messageLabel.setText("Installation '"
234:                            + this .projectNameTextField.getText() + "'...");
235:                    this .setAllEnabled(false);
236:                    gc.setProjectName(this .projectNameTextField.getText());
237:                    gc.setProjectDir(this .projectPathTextField.getText());
238:                    gc.setWebAppDir(this .webAppPathTextField.getText());
239:                    gc.setConfigFilename(this .configTextField.getText());
240:                    gc.setWarFilename(this .warTextField.getText());
241:                    gc.runBatch();
242:                    this .messageLabel.setText("Project '"
243:                            + this .projectNameTextField.getText()
244:                            + "' installed successfully");
245:                    ;
246:                } catch (Exception ex) {
247:                    String msg = ex.getMessage();
248:                    if (msg == null || msg.trim().equals(""))
249:                        msg = ex.toString();
250:                    ErrorDialog ed = new ErrorDialog(this , msg);
251:                    ed.show();
252:                    this .messageLabel.setText("");
253:                } finally {
254:                    this .setAllEnabled(true);
255:                }
256:            }
257:
258:            boolean installing = false;
259:            JLabel jLabel4 = new JLabel();
260:            JTextField warTextField = new JTextField();
261:            JButton warButton = new JButton();
262:            JLabel jLabel5 = new JLabel();
263:            JTextField configTextField = new JTextField();
264:            JButton configButton = new JButton();
265:
266:            private void setAllEnabled(boolean enable) {
267:                installing = !enable;
268:                if (enable)
269:                    this .setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
270:                else
271:                    this .setCursor(new Cursor(Cursor.WAIT_CURSOR));
272:                this .installButton.setEnabled(enable);
273:                this .projectPathButton.setEnabled(enable);
274:                this .wabAppPathButton.setEnabled(enable);
275:                this .projectNameTextField.setEditable(enable);
276:                this .projectPathTextField.setEditable(enable);
277:                this .webAppPathTextField.setEditable(enable);
278:
279:            }
280:
281:            void this _windowGainedFocus(WindowEvent e) {
282:                if (!installing)
283:                    this .setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
284:                else
285:                    this .setCursor(new Cursor(Cursor.WAIT_CURSOR));
286:            }
287:
288:            void configButton_actionPerformed(ActionEvent e) {
289:                String file = this .selectFile(this .configTextField.getText(),
290:                        ".config", "CONFIG File");
291:                if (file != null) {
292:                    this .configTextField.setText(file);
293:                }
294:            }
295:
296:            void warButton_actionPerformed(ActionEvent e) {
297:                String file = this .selectFile(this .warTextField.getText(),
298:                        ".war", "WAR File");
299:                if (file != null) {
300:                    this .warTextField.setText(file);
301:                }
302:            }
303:        }
304:
305:        class ApplicationFrame_projectPathButton_actionAdapter implements 
306:                java.awt.event.ActionListener {
307:            ApplicationFrame adaptee;
308:
309:            ApplicationFrame_projectPathButton_actionAdapter(
310:                    ApplicationFrame adaptee) {
311:                this .adaptee = adaptee;
312:            }
313:
314:            public void actionPerformed(ActionEvent e) {
315:                adaptee.projectPathButton_actionPerformed(e);
316:            }
317:        }
318:
319:        class ApplicationFrame_wabAppPathButton_actionAdapter implements 
320:                java.awt.event.ActionListener {
321:            ApplicationFrame adaptee;
322:
323:            ApplicationFrame_wabAppPathButton_actionAdapter(
324:                    ApplicationFrame adaptee) {
325:                this .adaptee = adaptee;
326:            }
327:
328:            public void actionPerformed(ActionEvent e) {
329:                adaptee.wabAppPathButton_actionPerformed(e);
330:            }
331:        }
332:
333:        class ApplicationFrame_installButton_actionAdapter implements 
334:                java.awt.event.ActionListener {
335:            ApplicationFrame adaptee;
336:
337:            ApplicationFrame_installButton_actionAdapter(
338:                    ApplicationFrame adaptee) {
339:                this .adaptee = adaptee;
340:            }
341:
342:            public void actionPerformed(ActionEvent e) {
343:                adaptee.installButton_actionPerformed(e);
344:            }
345:        }
346:
347:        class ApplicationFrame_this _mouseAdapter extends
348:                java.awt.event.MouseAdapter {
349:            ApplicationFrame adaptee;
350:
351:            ApplicationFrame_this _mouseAdapter(ApplicationFrame adaptee) {
352:                this .adaptee = adaptee;
353:            }
354:        }
355:
356:        class ApplicationFrame_this _windowFocusAdapter implements 
357:                java.awt.event.WindowFocusListener {
358:            ApplicationFrame adaptee;
359:
360:            ApplicationFrame_this _windowFocusAdapter(ApplicationFrame adaptee) {
361:                this .adaptee = adaptee;
362:            }
363:
364:            public void windowGainedFocus(WindowEvent e) {
365:                adaptee.this _windowGainedFocus(e);
366:            }
367:
368:            public void windowLostFocus(WindowEvent e) {
369:            }
370:        }
371:
372:        class ApplicationFrame_configButton_actionAdapter implements 
373:                java.awt.event.ActionListener {
374:            ApplicationFrame adaptee;
375:
376:            ApplicationFrame_configButton_actionAdapter(ApplicationFrame adaptee) {
377:                this .adaptee = adaptee;
378:            }
379:
380:            public void actionPerformed(ActionEvent e) {
381:                adaptee.configButton_actionPerformed(e);
382:            }
383:        }
384:
385:        class ApplicationFrame_warButton_actionAdapter implements 
386:                java.awt.event.ActionListener {
387:            ApplicationFrame adaptee;
388:
389:            ApplicationFrame_warButton_actionAdapter(ApplicationFrame adaptee) {
390:                this .adaptee = adaptee;
391:            }
392:
393:            public void actionPerformed(ActionEvent e) {
394:                adaptee.warButton_actionPerformed(e);
395:            }
396:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.