Source Code Cross Referenced for ServiceXMLGenerationPage.java in  » Web-Services-AXIS2 » tools » org » apache » ideaplugin » frames » 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.ideaplugin.frames 
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.ideaplugin.frames;
020:
021:        import org.apache.axis2.tools.component.WizardPanel;
022:        import org.apache.axis2.tools.component.WizardComponents;
023:        import org.apache.axis2.tools.wizardframe.CodegenFrame;
024:        import org.apache.ideaplugin.bean.ArchiveBean;
025:        import org.apache.ideaplugin.bean.OperationObj;
026:        import org.apache.ideaplugin.bean.ServiceObj;
027:        import org.apache.ideaplugin.bean.ClassFileFilter;
028:        import org.apache.ideaplugin.frames.table.ArchiveTableModel;
029:
030:        import javax.swing.*;
031:        import javax.swing.border.EmptyBorder;
032:        import javax.swing.table.TableModel;
033:        import java.util.HashMap;
034:        import java.util.ArrayList;
035:        import java.util.Iterator;
036:        import java.awt.*;
037:        import java.awt.event.ActionListener;
038:        import java.awt.event.ActionEvent;
039:        import java.lang.reflect.Method;
040:        import java.net.URL;
041:        import java.net.URLClassLoader;
042:        import java.net.MalformedURLException;
043:        import java.io.File;
044:
045:        public class ServiceXMLGenerationPage extends WizardPanel {
046:
047:            private JTextField txtServiceName;
048:            private JTextField txtClassName;
049:            private JCheckBox chkBoxSearchMethod;
050:            private JButton btnLoad;
051:            private JButton btnBrowse;
052:            private JTable table;
053:            private JLabel lblTable;
054:            private JScrollPane scrollPane;
055:            private HashMap operations;
056:            private String fileName;
057:            private int count = 1;
058:            private ArrayList servicelsit;
059:            private String sgXMl;
060:            private final JFileChooser fileChooser = new JFileChooser();
061:            private ArchiveBean archiveBean;
062:
063:            /**
064:             * Constructor
065:             * @param wizardComponents
066:             */
067:            public ServiceXMLGenerationPage(WizardComponents wizardComponents,
068:                    ArchiveBean archiveBean) {
069:                super (wizardComponents,
070:                        "Axis2 Idea Plugin Service Archiver Creator Wizards");
071:                setPanelTopTitle("Service Archiver");
072:                setPanelBottomTitle("Service XML Generation");
073:                this .archiveBean = archiveBean;
074:                init();
075:            }
076:
077:            private void init() {
078:
079:                txtServiceName = new JTextField();
080:                txtClassName = new JTextField();
081:
082:                btnBrowse = new JButton("Browse");
083:                btnLoad = new JButton("Load");
084:
085:                chkBoxSearchMethod = new JCheckBox(
086:                        "Search declared method only", true);
087:
088:                lblTable = new JLabel(
089:                        "Mark operation you do not want to publish ");
090:                operations = new HashMap();
091:                ArchiveTableModel myModel = new ArchiveTableModel(operations);
092:                table = new JTable(myModel);
093:                table.setOpaque(true);
094:                table.setBackground(getBackground());
095:                table.setShowGrid(true);
096:                table.setSize(getPreferredSize());
097:
098:                scrollPane = new JScrollPane(table);
099:                scrollPane.setBorder(new EmptyBorder(0, 0, 0, 0));
100:                scrollPane.setSize(table.getSize());
101:                scrollPane.setOpaque(true);
102:                scrollPane.setBackground(getBackground());
103:                scrollPane.getViewport().setBackground(getBackground());
104:                scrollPane.setViewportBorder(new EmptyBorder(0, 0, 0, 0));
105:
106:                setBackButtonEnabled(true);
107:                setNextButtonEnabled(false);
108:                setFinishButtonEnabled(false);
109:                setPageComplete(false);
110:                this .setLayout(new GridBagLayout());
111:
112:                this 
113:                        .add(new JLabel("Class Name"), new GridBagConstraints(
114:                                0, 0, 1, 1, 0.1, 0.0,
115:                                GridBagConstraints.NORTHWEST,
116:                                GridBagConstraints.NONE,
117:                                new Insets(5, 10, 0, 0), 0, 0));
118:
119:                this .add(txtClassName, new GridBagConstraints(1, 0, 1, 1, 1.0,
120:                        0.0, GridBagConstraints.NORTHWEST,
121:                        GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 0),
122:                        0, 0));
123:                this .add(btnBrowse, new GridBagConstraints(2, 0, 1, 1, 0.1,
124:                        0.0, GridBagConstraints.NORTH, GridBagConstraints.NONE,
125:                        new Insets(5, 1, 1, 1), 0, 0));
126:                btnBrowse.addActionListener(new ActionListener() {
127:                    public void actionPerformed(ActionEvent e) {
128:                        browseClassFile();
129:                        update();
130:                    }
131:                });
132:                this .add(btnLoad, new GridBagConstraints(3, 0, 1, 1, 0.1, 0.0,
133:                        GridBagConstraints.NORTH, GridBagConstraints.NONE,
134:                        new Insets(5, 1, 1, 10), 0, 0));
135:
136:                btnLoad.addActionListener(new ActionListener() {
137:                    public void actionPerformed(ActionEvent e) {
138:                        updateTable();
139:                        update();
140:                    }
141:                });
142:                this 
143:                        .add(new JLabel("Service Name"),
144:                                new GridBagConstraints(0, 1, 1, 1, 0.1, 0.0,
145:                                        GridBagConstraints.NORTHWEST,
146:                                        GridBagConstraints.NONE, new Insets(5,
147:                                                10, 0, 0), 0, 0));
148:                this .add(txtServiceName, new GridBagConstraints(1, 1, 1, 1,
149:                        1.0, 0.0, GridBagConstraints.NORTHWEST,
150:                        GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 0),
151:                        0, 0));
152:
153:                this .add(chkBoxSearchMethod, new GridBagConstraints(0, 2,
154:                        GridBagConstraints.RELATIVE, 1, 0.0, 0.0,
155:                        GridBagConstraints.NORTHWEST,
156:                        GridBagConstraints.HORIZONTAL,
157:                        new Insets(5, 10, 0, 10), 0, 0));
158:                chkBoxSearchMethod.addActionListener(new ActionListener() {
159:                    public void actionPerformed(ActionEvent e) {
160:                        updateTable();
161:                        update();
162:                    }
163:                });
164:                this .add(lblTable, new GridBagConstraints(0, 3,
165:                        GridBagConstraints.RELATIVE, 1, 0.0, 0.0,
166:                        GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
167:                        new Insets(5, 10, 0, 10), 0, 0));
168:
169:                this .add(scrollPane, new GridBagConstraints(0, 4,
170:                        GridBagConstraints.REMAINDER, 1, 1.0, 1.0,
171:                        GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH,
172:                        new Insets(5, 10, 10, 10), 0, 0));
173:
174:                setPageComplete(true);
175:            }
176:
177:            public void back() {
178:                switchPanel(CodegenFrame.PANEL_FOURTH_C);
179:            }
180:
181:            public void next() {
182:                setNextButtonEnabled(false);
183:                checkautoGeneration();
184:                switchPanel(CodegenFrame.PANEL_OPTION_C);
185:                ((ServiceXMLEditPage) getWizardComponents().getWizardPanel(
186:                        CodegenFrame.PANEL_OPTION_C))
187:                        .setDescription(archiveBean.getServiceXML());
188:                ((ServiceXMLEditPage) getWizardComponents().getWizardPanel(
189:                        CodegenFrame.PANEL_OPTION_C)).setDefaultEnabled();
190:            }
191:
192:            public void update() {
193:
194:            }
195:
196:            public int getPageType() {
197:                return WizardPanel.SERVICE_ARCHIVE_TYPE;
198:            }
199:
200:            private void updateTable() {
201:                //get a URL from the class file location
202:                try {
203:                    String classFileLocation = archiveBean.getClassLoc()
204:                            .getPath();
205:                    URL classFileURL = new File(classFileLocation).toURL();
206:
207:                    ArrayList listofURLs = new ArrayList();
208:                    listofURLs.add(classFileURL);
209:
210:                    //get the libraries from the lib page and load it
211:                    ArrayList libList = archiveBean.getLibs();
212:                    String[] libFileList = new String[libList.size()];
213:                    for (int i = 0; i < libList.size(); i++) {
214:                        libFileList[i] = (String) libList.get(i);
215:                    }
216:
217:                    if (libFileList != null) {
218:                        int count = libFileList.length;
219:                        for (int i = 0; i < count; i++) {
220:                            listofURLs.add(new File(libFileList[i]).toURL());
221:                        }
222:                    }
223:                    txtServiceName.setText("MyService" + count);
224:                    ClassLoader loader = new URLClassLoader((URL[]) listofURLs
225:                            .toArray(new URL[listofURLs.size()]));
226:                    Class clazz = Class.forName(fileName, true, loader);
227:                    Method[] methods = null;
228:                    if (chkBoxSearchMethod.isSelected()) {
229:                        methods = clazz.getDeclaredMethods();
230:                    } else {
231:                        methods = clazz.getMethods();
232:                    }
233:
234:                    int methodCount = methods.length;
235:                    if (methodCount > 0) {
236:                        try {
237:                            table.removeAll();
238:                            table.setVisible(true);
239:                            operations.clear();
240:                        } catch (Exception e1) {
241:                        }
242:                        for (int i = 0; i < methodCount; i++) {
243:                            Method method = methods[i];
244:                            OperationObj operationobj = new OperationObj(method
245:                                    .getName(), method.getReturnType()
246:                                    .toString(), new Integer(method
247:                                    .getParameterTypes().length), new Boolean(
248:                                    true));
249:                            operations.put(method.getName(), operationobj);
250:                        }
251:
252:                        ArchiveTableModel myModel = new ArchiveTableModel(
253:                                operations);
254:                        table.setModel(myModel);
255:                        scrollPane.repaint();
256:                        this .repaint();
257:                        setNextButtonEnabled(true);
258:                    }
259:
260:                } catch (MalformedURLException e) {
261:                    setNextButtonEnabled(false);
262:                    JOptionPane.showMessageDialog(btnLoad,
263:                            "The specified file is not a valid java class",
264:                            "Error!", JOptionPane.ERROR_MESSAGE);
265:                } catch (ClassNotFoundException e) {
266:                    setNextButtonEnabled(false);
267:                    JOptionPane.showMessageDialog(btnLoad,
268:                            "The specified file is not a valid java class",
269:                            "Error!", JOptionPane.ERROR_MESSAGE);
270:                }
271:            }
272:
273:            private void browseClassFile() {
274:                fileChooser.setFileFilter(new ClassFileFilter());
275:                fileChooser.setCurrentDirectory(archiveBean.getClassLoc());
276:                int returnVal = fileChooser.showOpenDialog(this );
277:                if (returnVal == JFileChooser.APPROVE_OPTION) {
278:                    File tempfile = fileChooser.getSelectedFile();
279:                    String newFile = tempfile.getPath();
280:                    int index = newFile.indexOf(archiveBean.getClassLoc()
281:                            .getAbsolutePath().trim());
282:                    if (index >= 0) {
283:                        int lastindex = archiveBean.getClassLoc()
284:                                .getAbsolutePath().trim().length();
285:                        newFile = newFile.substring(lastindex + 1);
286:                        char ch = File.separatorChar;
287:                        char newch = '.';
288:                        int cindex = newFile.indexOf(ch);
289:                        while (cindex >= 0) {
290:                            newFile = newFile.replace(ch, newch);
291:                            cindex = newFile.indexOf(ch);
292:                        }
293:                        fileName = newFile;
294:                        int classIndex = fileName.lastIndexOf(".");
295:                        fileName = fileName.substring(0, classIndex);
296:                        txtClassName.setText(fileName);
297:                    }
298:                }
299:            }
300:
301:            private void serviceGroupProcess() {
302:
303:                ArrayList ops = new ArrayList();
304:                Iterator opitr = operations.values().iterator();
305:                while (opitr.hasNext()) {
306:                    OperationObj operationObj = (OperationObj) opitr.next();
307:                    if (operationObj.getSelect().booleanValue()) {
308:                        ops.add(operationObj.getOpName());
309:                    }
310:                }
311:
312:                ServiceObj service = new ServiceObj(txtServiceName.getText(),
313:                        fileName, ops);
314:                archiveBean.addToServicelsit(service);
315:                if (!archiveBean.isSingleService()) {
316:                    int valu = JOptionPane.showConfirmDialog(this ,
317:                            "Do you want to add an another service to group",
318:                            "Service Archive", JOptionPane.YES_NO_OPTION);
319:                    if (valu == 0) {
320:                        fileName = "";
321:                        txtClassName.setText("");
322:                        txtServiceName.setText("");
323:                        operations.clear();
324:                        setNextButtonEnabled(false);
325:                        switchPanel(CodegenFrame.PANEL_FIRST_C);
326:                        count++;
327:                        this .repaint();
328:                    } else {
329:                        servicelsit = archiveBean.getServicelsit();
330:                        System.out.println(servicelsit.size());
331:                        sgXMl = "<serviceGroup>\n";
332:                        for (int i = 0; i < servicelsit.size(); i++) {
333:                            ServiceObj serviceObj = (ServiceObj) servicelsit
334:                                    .get(i);
335:                            sgXMl = sgXMl + serviceObj.toString();
336:                        }
337:                        sgXMl = sgXMl + "</serviceGroup>";
338:                        archiveBean.setServiceXML(sgXMl);
339:                        sgXMl = "";
340:                        switchPanel(CodegenFrame.PANEL_OPTION_C);
341:                    }
342:                } else {
343:                    servicelsit = archiveBean.getServicelsit();
344:                    sgXMl = "<serviceGroup>\n";
345:                    for (int i = 0; i < servicelsit.size(); i++) {
346:                        ServiceObj serviceObj = (ServiceObj) servicelsit.get(i);
347:                        sgXMl = sgXMl + serviceObj.toString();
348:                    }
349:                    sgXMl = sgXMl + "</serviceGroup>";
350:                    archiveBean.setServiceXML(sgXMl);
351:                    sgXMl = "";
352:                    switchPanel(CodegenFrame.PANEL_OPTION_C);
353:                }
354:            }
355:
356:            private void checkautoGeneration() {
357:                ArrayList ops = new ArrayList();
358:                Iterator opitr = operations.values().iterator();
359:                while (opitr.hasNext()) {
360:                    OperationObj operationObj = (OperationObj) opitr.next();
361:                    if (operationObj.getSelect().booleanValue()) {
362:                        ops.add(operationObj.getOpName());
363:                    }
364:                }
365:                txtServiceName.setText(txtServiceName.getText());
366:                ServiceObj service = new ServiceObj(txtServiceName.getText(),
367:                        fileName, ops);
368:                archiveBean.addToServicelsit(service);
369:                servicelsit = archiveBean.getServicelsit();
370:                sgXMl = "<serviceGroup>";
371:                for (int i = 0; i < servicelsit.size(); i++) {
372:                    ServiceObj serviceObj = (ServiceObj) servicelsit.get(i);
373:                    sgXMl = sgXMl + serviceObj.toString();
374:                }
375:                sgXMl = sgXMl + "</serviceGroup>";
376:                archiveBean.setServiceXML(sgXMl);
377:                sgXMl = "";
378:            }
379:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.