Source Code Cross Referenced for ImportWsdlDialog.java in  » ESB » cbesb-1.2 » com » bostechcorp » cbesb » ui » componentflow » componentFlowEditor » diagram » wizards » httpExtra » 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 » ESB » cbesb 1.2 » com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.diagram.wizards.httpExtra 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.diagram.wizards.httpExtra;
002:
003:        import java.io.BufferedReader;
004:        import java.io.DataInputStream;
005:        import java.io.File;
006:        import java.io.FileInputStream;
007:        import java.io.FileNotFoundException;
008:        import java.io.IOException;
009:        import java.io.InputStreamReader;
010:        import java.net.MalformedURLException;
011:
012:        import javax.wsdl.WSDLException;
013:
014:        import org.eclipse.core.resources.IResource;
015:        import org.eclipse.core.runtime.CoreException;
016:        import org.eclipse.swt.SWT;
017:        import org.eclipse.swt.events.ModifyEvent;
018:        import org.eclipse.swt.events.ModifyListener;
019:        import org.eclipse.swt.events.SelectionAdapter;
020:        import org.eclipse.swt.events.SelectionEvent;
021:        import org.eclipse.swt.layout.GridData;
022:        import org.eclipse.swt.layout.GridLayout;
023:        import org.eclipse.swt.widgets.Button;
024:        import org.eclipse.swt.widgets.Dialog;
025:        import org.eclipse.swt.widgets.Display;
026:        import org.eclipse.swt.widgets.Label;
027:        import org.eclipse.swt.widgets.Shell;
028:        import org.eclipse.swt.widgets.Text;
029:
030:        import com.bostechcorp.cbesb.common.i18n.I18N;
031:        import com.bostechcorp.cbesb.common.i18n.Messages;
032:        import com.bostechcorp.cbesb.common.util.FileUtil;
033:        import com.bostechcorp.cbesb.common.util.project.ProjectUtil;
034:        import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.diagram.wizards.httpExtra.io.WsdlPorting;
035:        import com.bostechcorp.cbesb.ui.util.DownloadUtil;
036:        import com.bostechcorp.cbesb.ui.util.DownloadUtil.HttpRequestMode;
037:        import com.bostechcorp.cbesb.ui.util.browser.SystemFileBrowse;
038:
039:        public class ImportWsdlDialog extends Dialog {
040:            private Button downloadButton;
041:
042:            private final static String SUFFIX = "_Server.wsdl";
043:
044:            private Text text_2;
045:
046:            private Button browseButton;
047:
048:            private Button httpResourceButton;
049:
050:            private Button fileResourceButton;
051:
052:            private Text text_1;
053:
054:            private Text text;
055:
056:            protected String result;
057:
058:            protected Shell shell;
059:
060:            private String suName = "";
061:
062:            private String path = "";
063:
064:            private String soapAddress = "";
065:
066:            /**
067:             * Create the dialog
068:             * 
069:             * @param parent
070:             * @param style
071:             */
072:            public ImportWsdlDialog(Shell parent, int style, String suName,
073:                    String path) {
074:                super (parent, style);
075:                this .suName = suName;
076:                this .path = path;
077:            }
078:
079:            /**
080:             * Open the dialog
081:             * 
082:             * @return the result
083:             */
084:            public String open() {
085:                createContents();
086:                shell.open();
087:                shell.layout();
088:                Display display = getParent().getDisplay();
089:                while (!shell.isDisposed()) {
090:                    if (!display.readAndDispatch())
091:                        display.sleep();
092:                }
093:                return result;
094:            }
095:
096:            /**
097:             * Create contents of the dialog
098:             */
099:            protected void createContents() {
100:                shell = new Shell(getParent(), SWT.DIALOG_TRIM
101:                        | SWT.APPLICATION_MODAL);
102:                final GridLayout gridLayout = new GridLayout();
103:                gridLayout.numColumns = 3;
104:                shell.setLayout(gridLayout);
105:                shell.setSize(423, 241);
106:                shell.setText(I18N.getString(Messages.IMPORT_WSDL_DIALOG));
107:
108:                fileResourceButton = new Button(shell, SWT.RADIO);
109:                fileResourceButton.setSelection(true);
110:                fileResourceButton.addSelectionListener(new SelectionAdapter() {
111:                    public void widgetSelected(final SelectionEvent e) {
112:                        if (fileResourceButton.getSelection())
113:                            enableControls();
114:                    }
115:                });
116:                fileResourceButton.setLayoutData(new GridData(SWT.FILL,
117:                        SWT.CENTER, false, false));
118:                fileResourceButton.setText(I18N
119:                        .getString(Messages.FILE_RESOURCE));
120:
121:                text_1 = new Text(shell, SWT.READ_ONLY | SWT.BORDER);
122:                text_1.addModifyListener(new ModifyListener() {
123:                    public void modifyText(final ModifyEvent e) {
124:                        if (text_1.getText().length() != 0)
125:                            try {
126:                                FileInputStream is = new FileInputStream(
127:                                        new File(text_1.getText()));
128:                                DataInputStream dis = new DataInputStream(is);
129:                                BufferedReader br = new BufferedReader(
130:                                        new InputStreamReader(dis));
131:                                StringBuffer text = new StringBuffer();
132:                                String strLine;
133:                                text_2.setText("");
134:                                while ((strLine = br.readLine()) != null) {
135:                                    text.append(strLine);
136:                                    // text_2.setText(text_2.getText()+strLine);
137:                                    // System.out.println(strLine);
138:                                }
139:                                text_2.setText(text.toString());
140:                            } catch (FileNotFoundException e1) {
141:                                e1.printStackTrace();
142:                            } catch (IOException e1) {
143:                                e1.printStackTrace();
144:                            }
145:                    }
146:                });
147:                text_1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
148:                        false));
149:
150:                browseButton = new Button(shell, SWT.NONE);
151:                browseButton.setEnabled(true);
152:                browseButton.addSelectionListener(new SelectionAdapter() {
153:                    public void widgetSelected(final SelectionEvent e) {
154:                        SystemFileBrowse sfb = new SystemFileBrowse(path,
155:                                new String[] { "All Files", "WSDL Files" },
156:                                new String[] { "*.*", "*.wsdl" });
157:                        sfb.systemFileBrowseToTextBox(text_1);
158:                    }
159:                });
160:                final GridData gridData_1 = new GridData(SWT.FILL, SWT.CENTER,
161:                        false, false);
162:                gridData_1.widthHint = 50;
163:                browseButton.setLayoutData(gridData_1);
164:                browseButton.setText(I18N.getString(Messages.BROWSE_BUTTON));
165:
166:                httpResourceButton = new Button(shell, SWT.RADIO);
167:
168:                httpResourceButton.addSelectionListener(new SelectionAdapter() {
169:                    public void widgetSelected(final SelectionEvent e) {
170:                        if (httpResourceButton.getSelection())
171:                            enableControls();
172:                    }
173:                });
174:                httpResourceButton.setLayoutData(new GridData(SWT.FILL,
175:                        SWT.CENTER, false, false));
176:                httpResourceButton.setText(I18N
177:                        .getString(Messages.HTTP_RESOURCE));
178:
179:                text = new Text(shell, SWT.BORDER);
180:                text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
181:                        false));
182:                text.setEnabled(false);
183:                downloadButton = new Button(shell, SWT.NONE);
184:                downloadButton.addSelectionListener(new SelectionAdapter() {
185:                    public void widgetSelected(final SelectionEvent e) {
186:                        text_2.setText("");
187:                        try {
188:                            text_2.setText(new DownloadUtil().httpSimpleFetch(
189:                                    text.getText(), HttpRequestMode.GET,
190:                                    hadleDownloadedFileName()));
191:                        } catch (MalformedURLException e1) {
192:                            e1.printStackTrace();
193:                        } catch (IOException e1) {
194:                            e1.printStackTrace();
195:                        }
196:                    }
197:
198:                    private File hadleDownloadedFileName() {
199:                        String filename = "";
200:                        if (!path.endsWith(File.separator))
201:                            filename += path + File.separator + "src"
202:                                    + File.separator + "wsdl" + File.separator
203:                                    + suName + File.separator;
204:                        else
205:                            filename += path + "src" + File.separator + "wsdl"
206:                                    + File.separator + suName + File.separator;
207:                        //making sure the path exist
208:                        FileUtil.buildDirectory(new File(filename));
209:                        //adding file name to the path
210:                        filename += suName + SUFFIX;
211:                        return new File(filename);
212:                    }
213:                });
214:                downloadButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER,
215:                        false, false));
216:                downloadButton.setText(I18N.getString(Messages.DOWNLOAD));
217:                downloadButton.setEnabled(false);
218:
219:                text_2 = new Text(shell, SWT.WRAP | SWT.V_SCROLL
220:                        | SWT.READ_ONLY | SWT.MULTI | SWT.H_SCROLL | SWT.BORDER);
221:                text_2.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
222:                        true, 3, 1));
223:                new Label(shell, SWT.NONE);
224:
225:                final Button okButton = new Button(shell, SWT.NONE);
226:                okButton.addSelectionListener(new SelectionAdapter() {
227:                    public void widgetSelected(final SelectionEvent e) {
228:                        result = "";
229:                        String origFilePath = text_1.getText();
230:                        String origFileName = new File(origFilePath).getName();
231:                        String parent = (new File(origFilePath)).getParent();
232:                        if (httpResourceButton.getSelection()) {
233:                            result = suName + SUFFIX;
234:                        } else if (fileResourceButton.getSelection()) {
235:                            result = origFileName;
236:
237:                            String destination = path + File.separator + "src"
238:                                    + File.separator + "wsdl" + File.separator
239:                                    + suName + File.separator;
240:                            if (!parent.equals(new File(destination).getPath())) {
241:                                try {
242:                                    WsdlPorting.doCopyWsdl(origFilePath,
243:                                            destination);
244:                                } catch (WSDLException e1) {
245:                                    e1.printStackTrace();
246:                                } catch (IOException ee) {
247:                                    ee.printStackTrace();
248:                                } catch (Exception ex) {
249:                                    ex.printStackTrace();
250:                                }
251:
252:                                // If don't need to rename the wsdl file, just comment
253:                                // out the following four line.
254:
255:                                String origin = destination + origFileName;
256:                                String target = destination + suName
257:                                        + "_Server.wsdl";
258:                                File file = new File(origin);
259:                                File desFile = new File(target);
260:                                if (desFile.exists()
261:                                        && !origFileName.equals(suName
262:                                                + "_Server.wsdl"))
263:                                    desFile.delete();
264:                                file.renameTo(new File(destination + suName
265:                                        + "_Server.wsdl"));
266:                            }
267:
268:                        }
269:                        shell.close();
270:                        try {
271:                            ProjectUtil.getCurProject().refreshLocal(
272:                                    IResource.DEPTH_INFINITE, null);
273:                        } catch (CoreException e1) {
274:                            e1.printStackTrace();
275:                        }
276:
277:                    }
278:                });
279:                final GridData gridData_2 = new GridData(SWT.RIGHT, SWT.CENTER,
280:                        false, false);
281:                gridData_2.widthHint = 64;
282:                okButton.setLayoutData(gridData_2);
283:                okButton.setText(I18N.getString(Messages.OK));
284:
285:                final Button cancelButton = new Button(shell, SWT.NONE);
286:                cancelButton.addSelectionListener(new SelectionAdapter() {
287:                    public void widgetSelected(final SelectionEvent e) {
288:                        result = "";
289:                        shell.close();
290:                    }
291:                });
292:                final GridData gridData = new GridData(SWT.FILL, SWT.CENTER,
293:                        false, false);
294:                gridData.widthHint = 50;
295:                cancelButton.setLayoutData(gridData);
296:                cancelButton.setText(I18N.getString(Messages.CANCEL));
297:                //
298:            }
299:
300:            /**
301:             * just check what controls shoul be enabled and witch one should not
302:             */
303:            private void enableControls() {
304:                text.setEnabled(getHttpResourceButton().getSelection());
305:                text_1.setEnabled(getFileResourceButton().getSelection());
306:                getBrowseButton().setEnabled(
307:                        getFileResourceButton().getSelection());
308:                getDownloadButton().setEnabled(
309:                        getHttpResourceButton().getSelection());
310:
311:            }
312:
313:            protected Button getFileResourceButton() {
314:                return fileResourceButton;
315:            }
316:
317:            protected Button getHttpResourceButton() {
318:                return httpResourceButton;
319:            }
320:
321:            protected Button getBrowseButton() {
322:                return browseButton;
323:            }
324:
325:            protected Button getDownloadButton() {
326:                return downloadButton;
327:            }
328:
329:            /**
330:             * @return the soapAddress
331:             */
332:            public String getSoapAddress() {
333:                return soapAddress;
334:            }
335:
336:            //	 public static void main(String[] args) {
337:            //	 try {
338:            ////	 HashMap m = WsdlInfo.extractFilesForCopy( new File("c:\\asd\\src\\wsdl\\HTTP\\HTTP_Server.wsdl").toURI().getPath(),new File("c:\\qqq\\").toURL().getPath());
339:            ////	 WsdlInfo.extractFilesForCopy("c:\\asd\\src\\wsdl\\HTTP\\HTTP_Server.wsdl","c:\\qqq\\qwe1\\qwe2\\qwe3\\");
340:            ////	 //C:\asd\src\wsdl\HTTP\HTTP_Server.wsdl
341:            ////	 //D:\ChainbuilderESB\ideworkspace\jmsScenario2\src\wsdl\HTTP\
342:            ////	 System.out.println(m);
343:            ////	 FileUtil.copyFiles(m);
344:            //		 doCopyWsdl("c:\\asd\\staff\\HTTP_Server.wsdl","c:\\qqq\\qwe1\\qwe2\\qwe3\\");
345:            //	 } catch (Exception e) {
346:            //		e.printStackTrace();
347:            //	}
348:            //	 }
349:
350:        }
ww___w___.__java___2_s.c___o__m__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.