Source Code Cross Referenced for PathPanel.java in  » J2EE » enhydra-IDE-plugin » org » enhydra » kelp » common » importer » 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 » J2EE » enhydra IDE plugin » org.enhydra.kelp.common.importer 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Enhydra Java Application Server Project
003:         *
004:         * The contents of this file are subject to the Enhydra Public License
005:         * Version 1.1 (the "License"); you may not use this file except in
006:         * compliance with the License. You may obtain a copy of the License on
007:         * the Enhydra web site ( http://www.enhydra.org/ ).
008:         *
009:         * Software distributed under the License is distributed on an "AS IS"
010:         * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
011:         * the License for the specific terms governing rights and limitations
012:         * under the License.
013:         *
014:         * The Initial Developer of the Enhydra Application Server is Lutris
015:         * Technologies, Inc. The Enhydra Application Server and portions created
016:         * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
017:         * All Rights Reserved.
018:         *
019:         * Contributor(s):
020:         * Paul Mahar
021:         *
022:         */
023:        package org.enhydra.kelp.common.importer;
024:
025:        // ToolBox imports
026:        import org.enhydra.tool.common.PathHandle;
027:        import org.enhydra.tool.common.SwingUtil;
028:
029:        // Kelp imports
030:        import org.enhydra.kelp.common.PathUtil;
031:        import org.enhydra.kelp.common.ValidationException;
032:        import org.enhydra.kelp.common.ValidationUtil;
033:
034:        // Standard imports
035:        import javax.swing.*;
036:        import javax.swing.border.*;
037:        import java.awt.*;
038:        import java.awt.event.ActionEvent;
039:        import java.awt.event.ActionListener;
040:        import java.beans.*;
041:        import java.io.File;
042:        import java.util.ResourceBundle;
043:
044:        /**
045:         * Panel for entering the default options: project name, package
046:         * and destination.
047:         *
048:         * @author Paul Mahar
049:         */
050:        public class PathPanel extends ImporterPanel {
051:            static ResourceBundle res = ResourceBundle
052:                    .getBundle("org.enhydra.kelp.common.Res"); // nores
053:            transient private JPanel panelSource;
054:            transient private JTextField textSource;
055:            transient private JButton buttonSource;
056:            transient private JPanel panelResource;
057:            transient private JTextField textResource;
058:            transient private JButton buttonResource;
059:
060:            //
061:            transient private JPanel panelFiller;
062:            transient private GridBagLayout layoutMain;
063:            transient private GridBagLayout layoutSource;
064:            transient private GridBagLayout layoutResource;
065:            transient private LocalButtonListener buttonListener;
066:            transient private TitledBorder borderSource;
067:            transient private TitledBorder borderResource;
068:
069:            /**
070:             * Create default option panel 1 for entering the
071:             * following default options: project name, package and
072:             * destination.
073:             */
074:            public PathPanel() {
075:                try {
076:                    jbInit();
077:                    pmInit();
078:                } catch (Exception ex) {
079:                    ex.printStackTrace();
080:                }
081:            }
082:
083:            /**
084:             * Read project name, package and destination values from the
085:             * option set into the swing controls.
086:             *
087:             * @exception GeneratorException
088:             * Thrown if unable to update Swing controls with option set values.
089:             */
090:            public void readOptions() {
091:
092:                // wait till activated to to any real reading
093:            }
094:
095:            /**
096:             * Write project name, package and destination values from the
097:             * swing controls into the option set.
098:             *
099:             * @exception GeneratorException
100:             * Thrown if unable to update option set from Swing control values.
101:             */
102:            public void writeOptions() throws ValidationException {
103:                String value = new String();
104:
105:                if (getPaths() == null) {
106:                    throw new ValidationException(res
107:                            .getString("Import_paths_not_set"));
108:                }
109:
110:                // source
111:                value = textSource.getText().trim();
112:                getPaths().setSourcePath(value);
113:
114:                // resource
115:                value = textResource.getText().trim();
116:                getPaths().setResourcePath(value);
117:            }
118:
119:            /**
120:             * Validate project name, package and destination values
121:             * in the swing controls.
122:             *
123:             * @exception ValidationException
124:             * Thrown if swing control values are not valid for the
125:             * current option set.
126:             */
127:            public void validateOptions() throws ValidationException {
128:                String value = new String();
129:
130:                // package
131:                value = textSource.getText().trim();
132:                if (!ValidationUtil.isDirectory(value)) {
133:                    throw new ValidationException(res
134:                            .getString("SourcePathInvalid")
135:                            + res.getString("DirectoryNotFound"));
136:                }
137:
138:                // destination
139:                value = textResource.getText().trim();
140:                if (!ValidationUtil.isDirectory(value)) {
141:                    throw new ValidationException(res
142:                            .getString("ResourcePathInvalid")
143:                            + res.getString("DirectoryNotFound"));
144:                }
145:            }
146:
147:            /**
148:             * Get the title to use on the current page.
149:             *
150:             * @return
151:             * A string to place at the top of a CodeGen wizard panel.
152:             */
153:            public String getPageTitle() {
154:                return res.getString("Path_details");
155:            }
156:
157:            /**
158:             * Get the instructions for entering option values for the
159:             * current page.
160:             *
161:             * @return
162:             * A string to place below the page title.
163:             */
164:            public String getInstructions() {
165:                StringBuffer buf = new StringBuffer();
166:
167:                buf.append(res.getString("PathInstruct1"));
168:                buf.append(res.getString("PathInstruct2"));
169:                buf.append(res.getString("PathInstruct3"));
170:                buf.append(res.getString("PathInstruct4"));
171:                buf.append(res.getString("PathInstruct5"));
172:                buf.append(res.getString("PathInstruct6"));
173:                buf.append(res.getString("PathInstruct7"));
174:                buf.append(res.getString("PathInstruct8"));
175:                buf.append(res.getString("PathInstruct9"));
176:                return buf.toString();
177:            }
178:
179:            public void activated() {
180:                initPaths();
181:            }
182:
183:            private void initPaths() {
184:                String path = null;
185:
186:                // source path
187:                path = getPaths().getSourcePath();
188:                if (path == null) {
189:                    textSource.setText(getPaths().getDefaultSourcePath());
190:                } else {
191:                    textSource.setText(path);
192:                }
193:
194:                // resource path
195:                path = getPaths().getResourcePath();
196:                if (path == null) {
197:                    textResource.setText(getPaths().getDefaultResourcePath());
198:                } else {
199:                    textResource.setText(path);
200:                }
201:            }
202:
203:            // /
204:            // /
205:
206:            /**
207:             * Method declaration
208:             *
209:             *
210:             * @exception Exception
211:             *
212:             * @see
213:             */
214:            private void jbInit() throws Exception {
215:                textSource = (JTextField) Beans.instantiate(getClass()
216:                        .getClassLoader(), JTextField.class.getName());
217:                panelSource = (JPanel) Beans.instantiate(getClass()
218:                        .getClassLoader(), JPanel.class.getName());
219:                panelResource = (JPanel) Beans.instantiate(getClass()
220:                        .getClassLoader(), JPanel.class.getName());
221:                layoutSource = (GridBagLayout) Beans.instantiate(getClass()
222:                        .getClassLoader(), GridBagLayout.class.getName());
223:                layoutResource = (GridBagLayout) Beans.instantiate(getClass()
224:                        .getClassLoader(), GridBagLayout.class.getName());
225:                buttonSource = (JButton) Beans.instantiate(getClass()
226:                        .getClassLoader(), JButton.class.getName());
227:                buttonResource = (JButton) Beans.instantiate(getClass()
228:                        .getClassLoader(), JButton.class.getName());
229:                textResource = (JTextField) Beans.instantiate(getClass()
230:                        .getClassLoader(), JTextField.class.getName());
231:                layoutMain = (GridBagLayout) Beans.instantiate(getClass()
232:                        .getClassLoader(), GridBagLayout.class.getName());
233:                panelFiller = (JPanel) Beans.instantiate(getClass()
234:                        .getClassLoader(), JPanel.class.getName());
235:                buttonSource.setText("..."); // nores
236:                buttonResource.setText("..."); // nores
237:                panelSource.setLayout(layoutSource);
238:                panelSource.add(textSource, new GridBagConstraints(0, 0, 1, 1,
239:                        0.1, 0.1, GridBagConstraints.WEST,
240:                        GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5),
241:                        0, 0));
242:                panelSource
243:                        .add(buttonSource, new GridBagConstraints(1, 0, 1, 2,
244:                                0.0, 0.0, GridBagConstraints.CENTER,
245:                                GridBagConstraints.NONE,
246:                                new Insets(5, 5, 5, 20), 0, 0));
247:                panelResource.setLayout(layoutResource);
248:                panelResource.add(textResource, new GridBagConstraints(0, 0, 1,
249:                        1, 0.1, 0.1, GridBagConstraints.WEST,
250:                        GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5),
251:                        0, 0));
252:                panelResource
253:                        .add(buttonResource, new GridBagConstraints(1, 0, 1, 2,
254:                                0.0, 0.0, GridBagConstraints.CENTER,
255:                                GridBagConstraints.NONE,
256:                                new Insets(5, 5, 5, 20), 0, 0));
257:                this .setLayout(layoutMain);
258:                this .add(panelSource, new GridBagConstraints(0, 0, 1, 1, 0.1,
259:                        0.1, GridBagConstraints.CENTER,
260:                        GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));
261:                this .add(panelResource, new GridBagConstraints(0, 1, 1, 1, 0.1,
262:                        0.1, GridBagConstraints.CENTER,
263:                        GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));
264:            }
265:
266:            /**
267:             * Method declaration
268:             *
269:             *
270:             * @see
271:             */
272:            private void pmInit() {
273:                Border border = BorderFactory.createEtchedBorder();
274:
275:                borderSource = BorderFactory.createTitledBorder(border);
276:                borderSource.setTitle(res.getString("borderSource_Title"));
277:                borderResource = BorderFactory.createTitledBorder(border);
278:                borderResource.setTitle(res.getString("borderResource_Title"));
279:                panelSource.setBorder(borderSource);
280:                panelResource.setBorder(borderResource);
281:                buttonListener = new LocalButtonListener();
282:                buttonResource.addActionListener(buttonListener);
283:                buttonSource.addActionListener(buttonListener);
284:                textResource.setText(new String());
285:                textSource.setText(new String());
286:            }
287:
288:            /**
289:             * Method declaration
290:             *
291:             *
292:             * @see
293:             */
294:            private void browseForFile(JTextField field, String title) {
295:                File destDir = null;
296:
297:                destDir = SwingUtil.getDirectoryChoice(this , field.getText(),
298:                        title);
299:                if (destDir != null) {
300:                    field.setText(PathHandle.createPathString(destDir));
301:                }
302:            }
303:
304:            /**
305:             * Class declaration
306:             *
307:             *
308:             * @author Paul Mahar
309:             */
310:            private class LocalButtonListener implements  ActionListener {
311:
312:                public void actionPerformed(ActionEvent event) {
313:                    Object source = event.getSource();
314:
315:                    if (source == buttonSource) {
316:                        browseForFile(textSource, res
317:                                .getString("Select_source_path"));
318:                    } else {
319:                        browseForFile(textResource, res
320:                                .getString("Select_resource_path"));
321:                    }
322:                }
323:
324:            }
325:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.