Source Code Cross Referenced for PathSelectionPanel.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 2004 Klaus Bartz
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:
022:        package com.izforge.izpack.panels;
023:
024:        import java.awt.Dimension;
025:        import java.awt.event.ActionEvent;
026:        import java.awt.event.ActionListener;
027:        import java.io.File;
028:
029:        import javax.swing.JButton;
030:        import javax.swing.JFileChooser;
031:        import javax.swing.JPanel;
032:        import javax.swing.JTextField;
033:
034:        import com.izforge.izpack.gui.ButtonFactory;
035:        import com.izforge.izpack.gui.IzPanelConstraints;
036:        import com.izforge.izpack.gui.IzPanelLayout;
037:        import com.izforge.izpack.gui.LayoutConstants;
038:        import com.izforge.izpack.installer.InstallData;
039:        import com.izforge.izpack.installer.IzPanel;
040:        import com.izforge.izpack.installer.LayoutHelper;
041:
042:        /**
043:         * This is a sub panel which contains a text field and a browse button for path selection. This is
044:         * NOT an IzPanel, else it is made to use in an IzPanel for any path selection. If the IzPanel
045:         * parent implements ActionListener, the ActionPerformed method will be called, if
046:         * PathSelectionPanel.ActionPerformed was called with a source other than the browse button. This
047:         * can be used to perform parentFrame.navigateNext in the IzPanel parent. An example implementation
048:         * is done in com.izforge.izpack.panels.PathInputPanel.
049:         * 
050:         * @author Klaus Bartz
051:         * 
052:         */
053:        public class PathSelectionPanel extends JPanel implements 
054:                ActionListener, LayoutConstants {
055:
056:            /**
057:             * 
058:             */
059:            private static final long serialVersionUID = 3618700794577105718L;
060:
061:            /** The text field for the path. */
062:            private JTextField textField;
063:
064:            /** The 'browse' button. */
065:            private JButton browseButton;
066:
067:            /** IzPanel parent (not the InstallerFrame). */
068:            private IzPanel parent;
069:
070:            /**
071:             * The installer internal data.
072:             */
073:            private InstallData idata;
074:
075:            /**
076:             * The constructor. Be aware, parent is the parent IzPanel, not the installer frame.
077:             * 
078:             * @param parent The parent IzPanel.
079:             * @param idata The installer internal data.
080:             */
081:            public PathSelectionPanel(IzPanel parent, InstallData idata) {
082:                super ();
083:                this .parent = parent;
084:                this .idata = idata;
085:                createLayout();
086:            }
087:
088:            /**
089:             * Creates the layout for this sub panel.
090:             */
091:            protected void createLayout() {
092:                // We would use the IzPanelLayout also in this "sub" panel.
093:                // In an IzPanel there is support for this layout manager in
094:                // more than one place, but not in this panel so we have
095:                // to make all things needed.
096:                // First create a layout helper.
097:                LayoutHelper layoutHelper = new LayoutHelper(this );
098:                // Start the layout.
099:                layoutHelper.startLayout(new IzPanelLayout());
100:                // One of the rare points we need explicit a constraints.
101:                IzPanelConstraints ipc = IzPanelLayout
102:                        .getDefaultConstraint(TEXT_CONSTRAINT);
103:                // The text field should be stretched.
104:                ipc.setXStretch(1.0);
105:                textField = new JTextField(idata.getInstallPath(), 10);
106:                textField.addActionListener(this );
107:                parent.setInitialFocus(textField);
108:                add(textField, ipc);
109:                // We would have place between text field and button.
110:                add(IzPanelLayout.createHorizontalFiller(3));
111:                // No explicit constraints for the button (else implicit) because
112:                // defaults are OK.
113:                browseButton = ButtonFactory.createButton(parent
114:                        .getInstallerFrame().langpack
115:                        .getString("TargetPanel.browse"), parent
116:                        .getInstallerFrame().icons.getImageIcon("open"),
117:                        idata.buttonsHColor);
118:                browseButton.addActionListener(this );
119:                add(browseButton);
120:            }
121:
122:            // There are problems with the size if no other component needs the
123:            // full size. Sometimes directly, somtimes only after a back step.
124:
125:            public Dimension getMinimumSize() {
126:                Dimension ss = super .getPreferredSize();
127:                Dimension retval = parent.getSize();
128:                retval.height = ss.height;
129:                return (retval);
130:            }
131:
132:            /**
133:             * Actions-handling method.
134:             * 
135:             * @param e The event.
136:             */
137:            public void actionPerformed(ActionEvent e) {
138:                Object source = e.getSource();
139:
140:                if (source == browseButton) {
141:                    // The user wants to browse its filesystem
142:
143:                    // Prepares the file chooser
144:                    JFileChooser fc = new JFileChooser();
145:                    fc.setCurrentDirectory(new File(textField.getText()));
146:                    fc.setMultiSelectionEnabled(false);
147:                    fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
148:                    fc.addChoosableFileFilter(fc.getAcceptAllFileFilter());
149:
150:                    // Shows it
151:                    if (fc.showOpenDialog(this ) == JFileChooser.APPROVE_OPTION) {
152:                        String path = fc.getSelectedFile().getAbsolutePath();
153:                        textField.setText(path);
154:                    }
155:
156:                } else {
157:                    if (parent instanceof  ActionListener)
158:                        ((ActionListener) parent).actionPerformed(e);
159:                }
160:            }
161:
162:            /**
163:             * Returns the chosen path.
164:             * 
165:             * @return the chosen path
166:             */
167:            public String getPath() {
168:                return (textField.getText());
169:            }
170:
171:            /**
172:             * Sets the contents of the text field to the given path.
173:             * 
174:             * @param path the path to be set
175:             */
176:            public void setPath(String path) {
177:                textField.setText(path);
178:            }
179:
180:            /**
181:             * Returns the text input field for the path. This methode can be used to differ in a
182:             * ActionPerformed method of the parent between the browse button and the text field.
183:             * 
184:             * @return the text input field for the path
185:             */
186:            public JTextField getPathInputField() {
187:                return textField;
188:            }
189:
190:            /**
191:             * Returns the browse button object for modification or for use with a different ActionListener.
192:             * 
193:             * @return the browse button to open the JFileChooser
194:             */
195:            public JButton getBrowseButton() {
196:                return browseButton;
197:            }
198:
199:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.