Source Code Cross Referenced for MiddlePanel.java in  » Web-Services-AXIS2 » tools » org » apache » axis2 » tools » java2wsdl » 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 Services AXIS2 » tools » org.apache.axis2.tools.java2wsdl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one
003:         * or more contributor license agreements. See the NOTICE file
004:         * distributed with this work for additional information
005:         * regarding copyright ownership. The ASF licenses this file
006:         * to you under the Apache License, Version 2.0 (the
007:         * "License"); you may not use this file except in compliance
008:         * with the License. You may obtain a copy of the License at
009:         *
010:         * http://www.apache.org/licenses/LICENSE-2.0
011:         *
012:         * Unless required by applicable law or agreed to in writing,
013:         * software distributed under the License is distributed on an
014:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015:         * KIND, either express or implied. See the License for the
016:         * specific language governing permissions and limitations
017:         * under the License.
018:         */
019:        package org.apache.axis2.tools.java2wsdl;
020:
021:        import org.apache.axis2.tools.bean.ClassLoadingTestBean;
022:        import org.apache.axis2.tools.bean.WsdlgenBean;
023:        import org.apache.axis2.tools.bean.NamespaceFinder;
024:        import org.apache.axis2.tools.component.WizardPanel;
025:        import org.apache.axis2.tools.component.WizardComponents;
026:        import org.apache.axis2.tools.wizardframe.CodegenFrame;
027:
028:        import javax.swing.*;
029:        import javax.swing.border.EmptyBorder;
030:        import java.awt.*;
031:        import java.awt.event.ActionListener;
032:        import java.awt.event.ActionEvent;
033:        import java.io.File;
034:        import java.util.ArrayList;
035:        import java.util.Iterator;
036:
037:        /**
038:         * this is the first panel of java2wsdl wizard
039:         */
040:        public class MiddlePanel extends WizardPanel {
041:            /**
042:             * varibale
043:             */
044:            private JTextField txtClass;
045:            private JButton btnFolder;
046:            private JButton btnJar;
047:            private JButton btnRemove;
048:            private JButton btnTest;
049:            private JButton btnHint;
050:            private JTextArea txaHint;
051:            private boolean flag = false;
052:            private JList listPathDisply;
053:            private DefaultListModel listModel;
054:            private JLabel lblTest;
055:            private String hint = "Please give the fully qualified class name, example :com.foo.BarService"
056:                    + " Then add the folder or the jar file which contains that class file."
057:                    + " Finally check whether the class file can be loaded from the plugin."
058:                    + "  If the class that you are going to load contains any dependencies"
059:                    + "  on other axis2 libraries ( for example like axiom*.jar), please add those"
060:                    + " libraries as well and try to load the class.";
061:
062:            final JFileChooser FileChooser = new JFileChooser();
063:            final JFileChooser DirChooser = new JFileChooser();
064:            private WsdlgenBean wsdlgenBean;
065:
066:            /**
067:             * Constructor
068:             * @param wizardComponents
069:             * @param wsdlgenBean
070:             */
071:            public MiddlePanel(WizardComponents wizardComponents,
072:                    WsdlgenBean wsdlgenBean) {
073:                super (wizardComponents, "Axis2 Idea Plugin Java2WSDL Wizards");
074:                setPanelTopTitle("Java source / classpath selection");
075:                setPanelBottomTitle("Select the classes and the libraries");
076:                this .wsdlgenBean = wsdlgenBean;
077:                init();
078:            }
079:
080:            /**
081:             * initiate panel
082:             */
083:            private void init() {
084:
085:                txaHint = new JTextArea();
086:                txaHint.setBorder(null);
087:                txaHint.setFocusable(false);
088:                txaHint.setLineWrap(true);
089:                txaHint.setWrapStyleWord(true);
090:                txaHint.setOpaque(false);
091:
092:                btnHint = new JButton("Hint >>");
093:                btnHint.setBorder(new EmptyBorder(new Insets(0, 0, 0, 0)));
094:
095:                btnFolder = new JButton("Add Folder");
096:                btnJar = new JButton("Add Jar");
097:                btnRemove = new JButton("Remove");
098:                btnTest = new JButton("Test Class Loading");
099:
100:                txtClass = new JTextField();
101:                lblTest = new JLabel();
102:
103:                listModel = new DefaultListModel();
104:                listPathDisply = new JList(listModel);
105:                listPathDisply.setAutoscrolls(true);
106:                listPathDisply.setOpaque(false);
107:                listPathDisply.setBorder(BorderFactory.createBevelBorder(1));
108:                listPathDisply.setFocusable(false);
109:
110:                setBackButtonEnabled(true);
111:                setNextButtonEnabled(false);
112:                setFinishButtonEnabled(false);
113:                setPageComplete(false);
114:
115:                this .setLayout(new GridBagLayout());
116:
117:                this .add(new JLabel("Fully Qualified Class Name :"),
118:                        new GridBagConstraints(0, 0, 1, 1, 0.1, 0.0,
119:                                GridBagConstraints.WEST,
120:                                GridBagConstraints.NONE, new Insets(5, 10, 0,
121:                                        10), 0, 0));
122:
123:                this .add(txtClass, new GridBagConstraints(1, 0,
124:                        GridBagConstraints.REMAINDER, 1, 1.0, 0.0,
125:                        GridBagConstraints.CENTER,
126:                        GridBagConstraints.HORIZONTAL, new Insets(5, 1, 0, 10),
127:                        0, 0));
128:
129:                this 
130:                        .add(
131:                                new JLabel(
132:                                        "java class path Entries.select either folders or jar files "),
133:                                new GridBagConstraints(0, 1,
134:                                        GridBagConstraints.REMAINDER, 1, 0.0,
135:                                        0.0, GridBagConstraints.WEST,
136:                                        GridBagConstraints.HORIZONTAL,
137:                                        new Insets(5, 10, 0, 10), 0, 0));
138:
139:                this .add(btnFolder, new GridBagConstraints(0, 2, 1, 1, 0.1,
140:                        0.0, GridBagConstraints.CENTER,
141:                        GridBagConstraints.HORIZONTAL, new Insets(5, 10, 1, 1),
142:                        0, 0));
143:
144:                btnFolder.addActionListener(new ActionListener() {
145:                    public void actionPerformed(ActionEvent e) {
146:                        DirChooser
147:                                .setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
148:                        int returnVal = DirChooser.showOpenDialog(btnFolder);
149:                        if (returnVal == JFileChooser.APPROVE_OPTION) {
150:                            DirChooser
151:                                    .setFileSelectionMode(JFileChooser.FILES_ONLY);
152:                            File newfile = DirChooser.getSelectedFile();
153:                            listModel.addElement(newfile.getAbsolutePath());
154:                            setDefaultPathAndName(newfile);
155:                            updateStatusTextField(false, "");
156:                        }
157:                        update();
158:                    }
159:                });
160:
161:                this .add(btnJar, new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0,
162:                        GridBagConstraints.CENTER,
163:                        GridBagConstraints.HORIZONTAL, new Insets(5, 1, 1, 1),
164:                        0, 0));
165:                btnJar.addActionListener(new ActionListener() {
166:                    public void actionPerformed(ActionEvent e) {
167:
168:                        FileChooser.setFileFilter(new JarFileFilter());
169:                        int returnVal = FileChooser.showOpenDialog(btnJar);
170:                        if (returnVal == JFileChooser.APPROVE_OPTION) {
171:                            File file = FileChooser.getSelectedFile();
172:                            listModel.addElement(file.getAbsolutePath());
173:                            setDefaultPathAndName(file);
174:                            updateStatusTextField(false, "");
175:                        }
176:                        update();
177:                    }
178:                });
179:
180:                this .add(btnRemove, new GridBagConstraints(2, 2, 1, 1, 1.0,
181:                        0.0, GridBagConstraints.CENTER,
182:                        GridBagConstraints.HORIZONTAL, new Insets(5, 1, 1, 10),
183:                        0, 0));
184:                btnRemove.addActionListener(new ActionListener() {
185:                    public void actionPerformed(ActionEvent e) {
186:                        handleRemove();
187:                        update();
188:                    }
189:                });
190:
191:                this .add(new JScrollPane(listPathDisply),
192:                        new GridBagConstraints(0, 3,
193:                                GridBagConstraints.REMAINDER, 1, 0.1, 0.0,
194:                                GridBagConstraints.WEST,
195:                                GridBagConstraints.HORIZONTAL, new Insets(5,
196:                                        10, 1, 10), 0, 0));
197:
198:                this .add(btnTest, new GridBagConstraints(0, 4, 1, 1, 0.1, 0.0,
199:                        GridBagConstraints.CENTER,
200:                        GridBagConstraints.HORIZONTAL, new Insets(5, 10, 1, 1),
201:                        0, 0));
202:                btnTest.addActionListener(new ActionListener() {
203:                    public void actionPerformed(ActionEvent e) {
204:                        if (!testLoading()) {
205:                            setBackButtonEnabled(true);
206:                            setNextButtonEnabled(false);
207:                            setFinishButtonEnabled(false);
208:                        } else {
209:                            setBackButtonEnabled(true);
210:                            setNextButtonEnabled(true);
211:                            setFinishButtonEnabled(false);
212:                            wsdlgenBean.setClassPathList(getClassPathlist());
213:                            wsdlgenBean.setClassName(txtClass.getText().trim());
214:                            setPageComplete(true);
215:                        }
216:                        update();
217:                    }
218:                });
219:
220:                this .add(lblTest, new GridBagConstraints(1, 4,
221:                        GridBagConstraints.REMAINDER, 1, 1.0, 0.0,
222:                        GridBagConstraints.CENTER,
223:                        GridBagConstraints.HORIZONTAL, new Insets(5, 1, 1, 10),
224:                        0, 0));
225:
226:                this .add(new JSeparator(), new GridBagConstraints(0, 5,
227:                        GridBagConstraints.REMAINDER, 1, 0.0, 0.0,
228:                        GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
229:                        new Insets(5, 1, 1, 1), 0, 0));
230:
231:                this .add(btnHint, new GridBagConstraints(0, 6, 1, 1, 0.1, 0.0,
232:                        GridBagConstraints.WEST, GridBagConstraints.NONE,
233:                        new Insets(5, 10, 0, 10), 0, 0));
234:                btnHint.addActionListener(new ActionListener() {
235:                    public void actionPerformed(ActionEvent e) {
236:                        if (flag) {
237:                            btnHint.setText("Hint >>");
238:                            txaHint.setText("");
239:                            flag = false;
240:                        } else {
241:                            btnHint.setText("Hint <<");
242:                            txaHint.setText(hint);
243:                            flag = true;
244:                        }
245:                        update();
246:                    }
247:                });
248:
249:                this .add(txaHint, new GridBagConstraints(0, 7,
250:                        GridBagConstraints.REMAINDER, 1, 0.1, 1.0,
251:                        GridBagConstraints.CENTER, GridBagConstraints.BOTH,
252:                        new Insets(5, 10, 10, 10), 0, 0));
253:
254:            }
255:
256:            //next
257:            public void next() {
258:                if (txtClass.getText() != null && isPageComplete()) {
259:                    switchPanel(CodegenFrame.PANEL_OPTION_B);
260:                } else {
261:                    switchPanel(CodegenFrame.PANEL_FIRST_B);
262:                    setNextButtonEnabled(false);
263:                }
264:            }
265:
266:            //back
267:            public void back() {
268:                switchPanel(CodegenFrame.PANEL_CHOOSER);
269:            }
270:
271:            //update
272:            public void update() {
273:            }
274:
275:            //set default path and name
276:            private void setDefaultPathAndName(File file) {
277:                if (file.getParent() != null) {
278:                    wsdlgenBean.setOutputLocation(file.getParent());
279:                    wsdlgenBean.setOutputWSDLName("Services.wsdl");
280:                }
281:            }
282:
283:            // update next page
284:            public void updateStatusTextField(boolean success, String text) {
285:                if (success) {
286:                    wsdlgenBean.setServiceName(NamespaceFinder
287:                            .getServiceNameText(txtClass.getText()));
288:                    wsdlgenBean.setTargetNamespace(NamespaceFinder
289:                            .getTargetNamespaceFromClass(txtClass.getText()));
290:                    wsdlgenBean.setTargetNamespacePrefix(NamespaceFinder
291:                            .getDefaultNamespacePrefix());
292:                    wsdlgenBean.setSchemaTargetNamespace(NamespaceFinder
293:                            .getSchemaTargetNamespaceFromClass(txtClass
294:                                    .getText()));
295:                    wsdlgenBean.setSchemaTargetNamespacePrefix(NamespaceFinder
296:                            .getDefaultSchemaNamespacePrefix());
297:                }
298:                lblTest.setText(text);
299:            }
300:
301:            //  Pops up the file browse dialog box
302:
303:            private void handleRemove() {
304:                int[] selectionIndices = listPathDisply.getSelectedIndices();
305:                for (int i = 0; i < selectionIndices.length; i++) {
306:                    listModel.remove(selectionIndices[i]);
307:                }
308:                updateStatusTextField(false, "");
309:                update();
310:            }
311:
312:            //get class path list
313:            public String[] getClassPathlist() {
314:                Object[] listObject = listModel.toArray();
315:                String[] listString = new String[listObject.length];
316:                for (int i = 0; i < listObject.length; i++) {
317:                    listString[i] = listObject[i].toString();
318:                }
319:                return listString;
320:            }
321:
322:            // test loading
323:            public boolean testLoading() {
324:                java.util.List errorListener = new ArrayList();
325:                String[] listString = getClassPathlist();
326:                if (!ClassLoadingTestBean.tryLoadingClass(txtClass.getText(),
327:                        listString, errorListener)) {
328:                    Iterator it = errorListener.iterator();
329:                    while (it.hasNext()) {
330:                        Object nextObject = it.next();
331:                        String errorMessage = nextObject == null ? "Unknown error!"
332:                                : nextObject.toString();
333:                        lblTest.setText(errorMessage);
334:                        updateStatusTextField(false, errorMessage);
335:                        update();
336:                    }
337:                    return false;
338:                } else {
339:                    updateStatusTextField(true,
340:                            "Class file loaded successfully");
341:                    return true;
342:                }
343:
344:            }
345:
346:            //get page type
347:            public int getPageType() {
348:                return WizardPanel.JAVA_2_WSDL_TYPE;
349:            }
350:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.