Source Code Cross Referenced for ServiceXMLGenerationPage.java in  » Web-Services-AXIS2 » tools » org » apache » axis2 » tool » service » eclipse » ui » 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.tool.service.eclipse.ui 
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.tool.service.eclipse.ui;
020:
021:        import org.apache.axis2.tool.service.bean.Page2Bean;
022:        import org.apache.axis2.tool.service.bean.WSDLAutoGenerateOptionBean;
023:        import org.apache.axis2.tool.service.eclipse.plugin.ServiceArchiver;
024:        import org.eclipse.swt.SWT;
025:        import org.eclipse.swt.events.ModifyEvent;
026:        import org.eclipse.swt.events.ModifyListener;
027:        import org.eclipse.swt.events.SelectionEvent;
028:        import org.eclipse.swt.events.SelectionListener;
029:        import org.eclipse.swt.layout.GridData;
030:        import org.eclipse.swt.layout.GridLayout;
031:        import org.eclipse.swt.widgets.Button;
032:        import org.eclipse.swt.widgets.Composite;
033:        import org.eclipse.swt.widgets.Label;
034:        import org.eclipse.swt.widgets.Table;
035:        import org.eclipse.swt.widgets.TableColumn;
036:        import org.eclipse.swt.widgets.TableItem;
037:        import org.eclipse.swt.widgets.Text;
038:
039:        import java.io.File;
040:        import java.lang.reflect.Method;
041:        import java.net.MalformedURLException;
042:        import java.net.URL;
043:        import java.net.URLClassLoader;
044:        import java.util.ArrayList;
045:
046:        public class ServiceXMLGenerationPage extends AbstractServiceWizardPage {
047:
048:            private Text classNameTextBox;
049:            private Text serviceNameTextBox;
050:            private Button searchDeclaredMethodsCheckBox;
051:            Button loadButton;
052:            private Table table;
053:
054:            private boolean dirty = false;
055:
056:            public ServiceXMLGenerationPage() {
057:                super ("page3");
058:            }
059:
060:            /* (non-Javadoc)
061:             * @see org.apache.axis2.tool.service.eclipse.ui.AbstractServiceWizardPage#initializeDefaultSettings()
062:             */
063:            protected void initializeDefaultSettings() {
064:                settings.put(PREF_SERVICE_GEN_SERVICE_NAME, "MyService");
065:                settings.put(PREF_SERVICE_GEN_CLASSNAME, "");
066:                settings.put(PREF_SERVICE_GEN_LOAD_ALL, false);
067:            }
068:
069:            /* (non-Javadoc)
070:             * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
071:             */
072:            public void createControl(Composite parent) {
073:                Composite container = new Composite(parent, SWT.NULL);
074:                GridLayout layout = new GridLayout();
075:                layout.numColumns = 3;
076:                container.setLayout(layout);
077:
078:                Label label = new Label(container, SWT.NULL);
079:                label.setText(ServiceArchiver
080:                        .getResourceString("page3.servicename.lable"));
081:
082:                GridData gd = new GridData(GridData.FILL_HORIZONTAL);
083:                gd.horizontalSpan = 2;
084:                serviceNameTextBox = new Text(container, SWT.BORDER);
085:                serviceNameTextBox.setLayoutData(gd);
086:                serviceNameTextBox.setToolTipText(ServiceArchiver
087:                        .getResourceString("page3.servicename.tooltip"));
088:                serviceNameTextBox.setText(settings
089:                        .get(PREF_SERVICE_GEN_SERVICE_NAME));
090:                serviceNameTextBox.addModifyListener(new ModifyListener() {
091:                    public void modifyText(ModifyEvent e) {
092:                        updateDirtyStatus(true);
093:                        settings.put(PREF_SERVICE_GEN_SERVICE_NAME,
094:                                serviceNameTextBox.getText());
095:                        //validate
096:                    }
097:                });
098:
099:                label = new Label(container, SWT.NULL);
100:                label.setText(ServiceArchiver
101:                        .getResourceString("page3.classname.lable"));
102:
103:                gd = new GridData(GridData.FILL_HORIZONTAL);
104:                classNameTextBox = new Text(container, SWT.BORDER);
105:                classNameTextBox.setLayoutData(gd);
106:                classNameTextBox.setToolTipText(ServiceArchiver
107:                        .getResourceString("page3.classname.tooltip"));
108:                classNameTextBox.setText(settings
109:                        .get(PREF_SERVICE_GEN_CLASSNAME));
110:                classNameTextBox.addModifyListener(new ModifyListener() {
111:                    public void modifyText(ModifyEvent e) {
112:                        updateDirtyStatus(true);
113:                        settings.put(PREF_SERVICE_GEN_CLASSNAME,
114:                                classNameTextBox.getText());
115:                    }
116:                });
117:
118:                gd = new GridData(GridData.FILL_HORIZONTAL);
119:                loadButton = new Button(container, SWT.PUSH);
120:                loadButton.setText(ServiceArchiver
121:                        .getResourceString("page3.loadbutton.lable"));
122:                loadButton.setLayoutData(gd);
123:                loadButton.addSelectionListener(new SelectionListener() {
124:                    public void widgetSelected(SelectionEvent e) {
125:                        updateTable();
126:                    }
127:
128:                    public void widgetDefaultSelected(SelectionEvent e) {
129:                    }
130:                });
131:
132:                gd = new GridData(GridData.FILL_HORIZONTAL);
133:                gd.horizontalSpan = 3;
134:
135:                searchDeclaredMethodsCheckBox = new Button(container, SWT.CHECK);
136:                searchDeclaredMethodsCheckBox.setLayoutData(gd);
137:                searchDeclaredMethodsCheckBox.setText(ServiceArchiver
138:                        .getResourceString("page3.declared.lable"));
139:                searchDeclaredMethodsCheckBox
140:                        .addSelectionListener(new SelectionListener() {
141:                            public void widgetSelected(SelectionEvent e) {
142:                                updateDirtyStatus(true);//dirty
143:                                settings.put(PREF_SERVICE_GEN_LOAD_ALL,
144:                                        searchDeclaredMethodsCheckBox
145:                                                .getSelection());
146:                                if (table.isVisible()) {
147:                                    updateTable();
148:                                }
149:
150:                            }
151:
152:                            public void widgetDefaultSelected(SelectionEvent e) {
153:                            }
154:                        });
155:                searchDeclaredMethodsCheckBox.setSelection(settings
156:                        .getBoolean(PREF_SERVICE_GEN_LOAD_ALL));
157:
158:                gd = new GridData(GridData.FILL_BOTH);
159:                gd.horizontalSpan = 2;
160:                gd.verticalSpan = 5;
161:
162:                table = new Table(container, SWT.SINGLE | SWT.FULL_SELECTION
163:                        | SWT.CHECK);
164:                table.setLinesVisible(true);
165:                table.setHeaderVisible(true);
166:                table.setLayoutData(gd);
167:                declareColumn(table, 20, "");
168:                declareColumn(table, 100, ServiceArchiver
169:                        .getResourceString("page3.table.col1"));
170:                declareColumn(table, 100, ServiceArchiver
171:                        .getResourceString("page3.table.col2"));
172:                declareColumn(table, 100, ServiceArchiver
173:                        .getResourceString("page3.table.col3"));
174:
175:                table.setVisible(false);
176:
177:                if (restoredFromPreviousSettings) {
178:                    //try running the update
179:                    updateTable();
180:                } else {
181:                    setPageComplete(false);
182:                }
183:
184:                setControl(container);
185:
186:            }
187:
188:            /**
189:             * if the user has already filled the data, this page needs to be 
190:             * unchangeable
191:             *
192:             */
193:            public void fillDatafromPrevious(WSDLAutoGenerateOptionBean bean) {
194:                //set class name
195:                String automaticClassName = bean.getClassFileName();
196:                this .classNameTextBox.setText(automaticClassName);
197:                this .classNameTextBox.setEnabled(false);
198:                //set service name
199:                String[] classnameParts = automaticClassName.split("\\.");
200:                if (classnameParts.length == 0) {
201:                    this .serviceNameTextBox.setText(automaticClassName);
202:                } else {
203:                    this .serviceNameTextBox
204:                            .setText(classnameParts[classnameParts.length - 1]);
205:                }
206:                //load the classes
207:                updateTable();
208:                //check the correct ones
209:
210:                //disbale the table
211:                table.setEnabled(false);
212:                loadButton.setEnabled(false);
213:            }
214:
215:            public void clearPreviousData() {
216:                this .classNameTextBox.setText("");
217:                this .classNameTextBox.setEnabled(true);
218:                //set service name
219:                this .serviceNameTextBox.setText("");
220:                if (table.isVisible()) {
221:                    table.setVisible(false);
222:                }
223:                loadButton.setEnabled(true);
224:            }
225:
226:            private void updateDirtyStatus(boolean status) {
227:                dirty = status;
228:                if (table.isVisible()) {
229:                    table.setEnabled(!status);
230:                }
231:                setPageComplete(!status);
232:            }
233:
234:            private void declareColumn(Table table, int width, String colName) {
235:                TableColumn column = new TableColumn(table, SWT.NONE);
236:                column.setWidth(width);
237:                column.setText(colName);
238:            }
239:
240:            private void updateTable() {
241:                //get a URL from the class file location
242:                try {
243:                    String classFileLocation = getClassFileLocation();
244:                    URL classFileURL = new File(classFileLocation).toURL();
245:
246:                    ArrayList listofURLs = new ArrayList();
247:                    listofURLs.add(classFileURL);
248:
249:                    //get the libraries from the lib page and load it 
250:                    String[] libFileList = ((ServiceArchiveWizard) this 
251:                            .getWizard()).getLibFileList();
252:                    if (libFileList != null) {
253:                        int count = libFileList.length;
254:                        for (int i = 0; i < count; i++) {
255:                            listofURLs.add(new File(libFileList[i]).toURL());
256:                        }
257:                    }
258:
259:                    ClassLoader loader = new URLClassLoader((URL[]) listofURLs
260:                            .toArray(new URL[listofURLs.size()]));
261:                    Class clazz = Class.forName(classNameTextBox.getText(),
262:                            true, loader);
263:                    Method[] methods = null;
264:
265:                    if (searchDeclaredMethodsCheckBox.getSelection()) {
266:                        methods = clazz.getDeclaredMethods();
267:                    } else {
268:                        methods = clazz.getMethods();
269:                    }
270:
271:                    int methodCount = methods.length;
272:                    if (methodCount > 0) {
273:                        table.removeAll();
274:                        TableItem[] items = new TableItem[methodCount]; // An item for each field
275:                        for (int i = 0; i < methodCount; i++) {
276:                            items[i] = new TableItem(table, SWT.NONE);
277:                            items[i].setText(1, methods[i].getName());
278:                            items[i].setText(2, methods[i].getReturnType()
279:                                    .getName());
280:                            items[i].setText(3,
281:                                    methods[i].getParameterTypes().length + "");
282:                            items[i].setChecked(true);//check them all by default
283:                        }
284:                        table.setVisible(true);
285:
286:                        //update the dirty variable
287:                        updateDirtyStatus(false);
288:                        updateStatus(null);
289:                    }
290:
291:                } catch (MalformedURLException e) {
292:                    updateStatus(ServiceArchiver
293:                            .getResourceString("page3.error.url")
294:                            + e.getMessage());
295:                } catch (ClassNotFoundException e) {
296:                    updateStatus(ServiceArchiver
297:                            .getResourceString("page3.error.class")
298:                            + e.getMessage());
299:                } catch (Exception e) {
300:                    e.printStackTrace();
301:                    updateStatus(ServiceArchiver
302:                            .getResourceString("page3.error.unknown")
303:                            + e.getMessage());
304:                }
305:            }
306:
307:            public boolean isDirty() {
308:                return dirty;
309:            }
310:
311:            private String getClassFileLocation() {
312:                ServiceArchiveWizard wizard = (ServiceArchiveWizard) getWizard();
313:                return wizard.getClassFileLocation();
314:            }
315:
316:            public Page2Bean getBean(Page2Bean previousBean) {
317:                if (!previousBean.isManual()) {
318:                    previousBean.setAutomatic(true);
319:                    previousBean.setAutomaticClassName(classNameTextBox
320:                            .getText());
321:                    ArrayList list = new ArrayList();
322:                    TableItem[] items = table.getItems();
323:                    int itemLength = items.length;
324:                    for (int i = 0; i < itemLength; i++) {
325:                        if (items[i].getChecked()) {
326:                            list.add(items[i].getText(1));//get the selected method name only
327:                        }
328:                    }
329:                    previousBean.setSelectedMethodNames(list);
330:                    previousBean.setServiceName(this .serviceNameTextBox
331:                            .getText());
332:                }
333:                return previousBean;
334:            }
335:
336:            protected boolean getWizardComplete() {
337:                return false;
338:            }
339:        }
www.__jav__a_2s.___c__o___m_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.