Source Code Cross Referenced for SchemaImportPage.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.File;
004:        import java.util.ArrayList;
005:        import java.util.Map.Entry;
006:
007:        import org.eclipse.jface.wizard.WizardPage;
008:        import org.eclipse.swt.SWT;
009:        import org.eclipse.swt.events.SelectionAdapter;
010:        import org.eclipse.swt.events.SelectionEvent;
011:        import org.eclipse.swt.graphics.Image;
012:        import org.eclipse.swt.layout.GridData;
013:        import org.eclipse.swt.layout.GridLayout;
014:        import org.eclipse.swt.widgets.Button;
015:        import org.eclipse.swt.widgets.Composite;
016:        import org.eclipse.swt.widgets.List;
017:        import org.eclipse.swt.widgets.Shell;
018:
019:        import com.bostechcorp.cbesb.common.i18n.I18N;
020:        import com.bostechcorp.cbesb.common.i18n.Messages;
021:        import com.bostechcorp.cbesb.common.util.FileUtil;
022:        import com.bostechcorp.cbesb.common.util.xfm.XmlFormatModelFactory;
023:        import com.bostechcorp.cbesb.common.util.xfm.impl.XmlFormatModelXSDImpl;
024:        import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.diagram.part.ComponentFlowEditorDiagramEditorPlugin;
025:        import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.diagram.wizards.httpExtra.io.WsdlPorting;
026:        import com.bostechcorp.cbesb.ui.util.browser.SystemFileBrowse;
027:        import com.bostechcorp.cbesb.ui.util.resource.ESBResourceManager;
028:
029:        public class SchemaImportPage extends WizardPage {
030:            public static java.util.List<String> xsdDataTypes;
031:
032:            static {
033:                xsdDataTypes = new ArrayList<String>();
034:                /*
035:                 * 3.2 Primitive datatypes
036:                3.2.1 string
037:                3.2.2 boolean
038:                3.2.3 decimal
039:                3.2.4 float
040:                3.2.5 double
041:                3.2.6 duration
042:                3.2.7 dateTime
043:                3.2.8 time
044:                3.2.9 date
045:                3.2.10 gYearMonth
046:                3.2.11 gYear
047:                3.2.12 gMonthDay
048:                3.2.13 gDay
049:                3.2.14 gMonth
050:                3.2.15 hexBinary
051:                3.2.16 base64Binary
052:                3.2.17 anyURI
053:                3.2.18 QName
054:                3.2.19 NOTATION
055:                 */
056:
057:                xsdDataTypes.add("string");
058:                xsdDataTypes.add("boolean");
059:                xsdDataTypes.add("decimal");
060:                xsdDataTypes.add("float");
061:                xsdDataTypes.add("double");
062:                xsdDataTypes.add("duration");
063:                xsdDataTypes.add("dateTime");
064:                xsdDataTypes.add("time");
065:                xsdDataTypes.add("date");
066:                xsdDataTypes.add("gYearMonth");
067:                xsdDataTypes.add("gYear");
068:                xsdDataTypes.add("gMonthDay");
069:                xsdDataTypes.add("gDay");
070:                xsdDataTypes.add("gMonth");
071:                xsdDataTypes.add("hexBinary");
072:                xsdDataTypes.add("base64Binary");
073:                xsdDataTypes.add("anyURI");
074:                xsdDataTypes.add("QName");
075:                xsdDataTypes.add("NOTATION");
076:
077:                /*
078:                3.3 Derived datatypes
079:                3.3.1 normalizedString
080:                3.3.2 token
081:                3.3.3 language
082:                3.3.4 NMTOKEN
083:                3.3.5 NMTOKENS
084:                3.3.6 Name
085:                3.3.7 NCName
086:                3.3.8 ID
087:                3.3.9 IDREF
088:                3.3.10 IDREFS
089:                3.3.11 ENTITY
090:                3.3.12 ENTITIES
091:                3.3.13 integer
092:                3.3.14 nonPositiveInteger
093:                3.3.15 negativeInteger
094:                3.3.16 long
095:                3.3.17 int
096:                3.3.18 short
097:                3.3.19 byte
098:                3.3.20 nonNegativeInteger
099:                3.3.21 unsignedLong
100:                3.3.22 unsignedInt
101:                3.3.23 unsignedShort
102:                3.3.24 unsignedByte
103:                3.3.25 positiveInteger
104:                 */
105:                xsdDataTypes.add("normalizedString");
106:                xsdDataTypes.add("token");
107:                xsdDataTypes.add("language");
108:                xsdDataTypes.add("NMTOKEN");
109:                xsdDataTypes.add("NMTOKENS");
110:                xsdDataTypes.add("Name");
111:                xsdDataTypes.add("NCName");
112:                xsdDataTypes.add("ID");
113:                xsdDataTypes.add("IDREF");
114:                xsdDataTypes.add("IDREFS");
115:                xsdDataTypes.add("ENTITY");
116:                xsdDataTypes.add("ENTITIES");
117:                xsdDataTypes.add("integer");
118:                xsdDataTypes.add("nonPositiveInteger");
119:                xsdDataTypes.add("negativeInteger");
120:                xsdDataTypes.add("long");
121:                xsdDataTypes.add("int");
122:                xsdDataTypes.add("short");
123:                xsdDataTypes.add("byte");
124:                xsdDataTypes.add("nonNegativeInteger");
125:                xsdDataTypes.add("unsignedLong");
126:                xsdDataTypes.add("unsignedInt");
127:                xsdDataTypes.add("unsignedShort");
128:                xsdDataTypes.add("unsignedByte");
129:                xsdDataTypes.add("positiveInteger");
130:            }
131:
132:            public static Image simpleTypeImage;
133:            public static Image complexTypeImage;
134:            public static Image elementTypeImage;
135:            public static Image xsdTypeImage;
136:            static {
137:                initImages();
138:            } //initialiazing those images
139:
140:            private Button removeButton;
141:            private List list;
142:            Shell shell;
143:
144:            /**
145:             * Create the wizard
146:             */
147:            public SchemaImportPage() {
148:                super ("wizardPage");
149:                this .setTitle(I18N.getString(Messages.SCHEMA_IMPORT_PAGE));
150:                this .setDescription(I18N.getString(Messages.XSD_FILE_LIST));
151:            }
152:
153:            /**
154:             * @param pageName
155:             */
156:            public SchemaImportPage(String pageName) {
157:                super (pageName);
158:                this .setTitle(I18N.getString(Messages.SCHEMA_IMPORT_PAGE));
159:                this .setDescription(I18N.getString(Messages.XSD_FILE_LIST));
160:            }
161:
162:            /**
163:             * Create contents of the wizard
164:             * @param parent
165:             */
166:            public void createControl(Composite parent) {
167:                Composite container = new Composite(parent, SWT.NULL);
168:                shell = this .getShell();
169:                final GridLayout gridLayout = new GridLayout();
170:                gridLayout.numColumns = 2;
171:                container.setLayout(gridLayout);
172:                //
173:                setControl(container);
174:
175:                list = new List(container, SWT.BORDER | SWT.SINGLE);
176:                list.addSelectionListener(new SelectionAdapter() {
177:                    public void widgetSelected(final SelectionEvent e) {
178:                        if (list.getSelection().length > 0) {
179:                            getRemoveButton().setEnabled(true);
180:                        } else {
181:                            getRemoveButton().setEnabled(true);
182:                        }
183:                    }
184:                });
185:                list.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true,
186:                        1, 2));
187:
188:                init(); //Initialize the list values
189:                initImages();
190:
191:                final Button addButton = new Button(container, SWT.NONE);
192:                addButton.addSelectionListener(new SelectionAdapter() {
193:                    public void widgetSelected(final SelectionEvent e) {
194:                        SystemFileBrowse sfb = new SystemFileBrowse(
195:                                pathToDir(), new String[] { "All Files",
196:                                        "XSD Files" }, new String[] { "*.*",
197:                                        "*.xsd" });
198:                        String fileitem = sfb.systemFilebrowseToString(shell
199:                                .getShell());
200:                        //if (fileitem.startsWith(" ")) fileitem.replaceAll(" ","");
201:                        File f = new File(fileitem);
202:                        int check = checkFile(f);
203:                        if (check == 0) {
204:                            //Copy file to the right location
205:                            //FileUtil.copyFile(f,pathToDir()); //simple copy
206:                            try {
207:                                WsdlPorting.doCopyXsd(f.getAbsolutePath(),
208:                                        pathToDir());
209:                            } catch (Exception e1) {
210:                                e1.printStackTrace();
211:                            } //recursive copy
212:                            //add to the model as well.
213:                            String namespacePrefix = generateNS();
214:                            getWizard().getModel().putFileName(namespacePrefix,
215:                                    new File(fileitem).getName());
216:                            //add to list
217:                            list.add(new File(fileitem).getName() + "\t\t("
218:                                    + namespacePrefix + ")");
219:                            //populate comboBoxes
220:                            populateCombos();
221:                        } else {
222:                            if (check == 1)
223:                                messageWarning(I18N
224:                                        .getString(Messages.FILE_DOES_NOT_EXIST));
225:                            if (check == 2)
226:                                messageWarning(I18N
227:                                        .getString(Messages.FILE_SHOULD_IN_DESFOLDER));
228:                            if (check == 3)
229:                                messageWarning(I18N
230:                                        .getString(Messages.FILE_ALREADY_IN));
231:                        }
232:                    }
233:                });
234:                addButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false,
235:                        false));
236:                addButton.setText("Add");
237:
238:                removeButton = new Button(container, SWT.NONE);
239:                removeButton.addSelectionListener(new SelectionAdapter() {
240:                    public void widgetSelected(final SelectionEvent e) {
241:                        if (list.getSelectionCount() > 0
242:                                && ckeckSchemaUseinOperations()) {
243:                            new File(pathToDir() + list.getSelection()[0])
244:                                    .delete();
245:                            //remove from model
246:                            String selectedItem = list.getItem(list
247:                                    .getSelectionIndex());
248:                            String namespacePrefix = selectedItem.substring(
249:                                    selectedItem.indexOf("(") + 1, selectedItem
250:                                            .indexOf(")"));
251:                            getWizard().getModel().removeFile(namespacePrefix);
252:                            //remove from fresh imports
253:                            getWizard().getFreshImports().remove(
254:                                    selectedItem.substring(0, selectedItem
255:                                            .indexOf("(")));
256:                            //remove from list
257:                            list.remove(list.getSelectionIndex());
258:                            //populate comboboxes
259:                            populateCombos();
260:                        }
261:                    }
262:                });
263:                removeButton.setLayoutData(new GridData(SWT.LEFT, SWT.TOP,
264:                        false, false));
265:                removeButton.setText(I18N.getString(Messages.REMOVE));
266:            }
267:
268:            private static void initImages() {
269:                simpleTypeImage = ESBResourceManager.getPluginImage(
270:                        ComponentFlowEditorDiagramEditorPlugin.getInstance(),
271:                        "icons/Map16.ico");
272:                complexTypeImage = ESBResourceManager.getPluginImage(
273:                        ComponentFlowEditorDiagramEditorPlugin.getInstance(),
274:                        "icons/Comment16.ico");
275:                elementTypeImage = ESBResourceManager.getPluginImage(
276:                        ComponentFlowEditorDiagramEditorPlugin.getInstance(),
277:                        "icons/Script16.ico");
278:                xsdTypeImage = ESBResourceManager.getPluginImage(
279:                        ComponentFlowEditorDiagramEditorPlugin.getInstance(),
280:                        "icons/Parser16.ico");
281:
282:            }
283:
284:            /**
285:             * Parse operations, and is any operation use types
286:             * from this file then popup a dialog waring the 
287:             * user that those operations will be deleted from the model.
288:             * if user agrees the the operations will be deleted as well.
289:             * 
290:             * @return
291:             */
292:            protected boolean ckeckSchemaUseinOperations() {
293:                //TODO: implrement this method
294:                return false;
295:            }
296:
297:            protected void messageWarning(String string) {
298:                this .setMessage(string, WARNING);
299:            }
300:
301:            protected void messageError(String string) {
302:                this .setErrorMessage(string);
303:            }
304:
305:            protected int checkFile(File f) {
306:                if (!f.exists())
307:                    return 1; // file should exist
308:                if (f.getPath().contains(pathToDir()))
309:                    return 2; // file should not be from the destination dir
310:                for (String fileName : getWizard().getModel().getXsdFileNames()
311:                        .values()) {
312:                    if (fileName.equals(f.getName())) // file should not be already existing in the list
313:                        return 3;
314:                }
315:                return 0;
316:            }
317:
318:            public void populateCombos() {
319:                try {
320:                    getWizard().getEditorPage().getCombo_2().removeAll();
321:                    getWizard().getEditorPage().getCombo_1().removeAll();
322:                    populateTypeCombo(getWizard().getEditorPage().getCombo_2());
323:                    populateTypeCombo(getWizard().getEditorPage().getCombo_1());
324:
325:                } catch (Exception e1) {
326:                    e1.printStackTrace();
327:                }
328:            }
329:
330:            private String pathToDir() {
331:                String path = ((NewWSDLWizard) getWizard()).getPathToProject();
332:                if (!path.endsWith(File.separator))
333:                    path += File.separator + "src" + File.separator + "wsdl"
334:                            + File.separator
335:                            + ((NewWSDLWizard) getWizard()).getSuNAme()
336:                            + File.separator;
337:                else
338:                    path += "src" + File.separator + "wsdl" + File.separator
339:                            + ((NewWSDLWizard) getWizard()).getSuNAme()
340:                            + File.separator;
341:                return path;
342:            }
343:
344:            /**
345:             * @return the list
346:             */
347:            public List getList() {
348:                return list;
349:            }
350:
351:            /*
352:             * Axis does not like the type at all. We only are going to support the element.
353:             */
354:            private void populateTypeCombo(ImageCombo combo) throws Exception {
355:                combo.removeAll();
356:                for (Entry<String, String> i : getWizard().getModel()
357:                        .getXsdFileNames().entrySet()) {
358:                    XmlFormatModelXSDImpl file = (XmlFormatModelXSDImpl) XmlFormatModelFactory
359:                            .newXsdReader(pathToDir() + i.getValue());
360:                    //			for (String completType : file.getComplexTypeList()) {
361:                    //				combo.add(replaceNS(completType, i.getKey(), file
362:                    //						.getTargetNamespace()), complexTypeImage);
363:                    //			}
364:                    //			for (String simpleType : file.getSimpleTypeList()) {
365:                    //				combo.add(replaceNS(simpleType, i.getKey(), file
366:                    //						.getTargetNamespace()), simpleTypeImage);
367:                    //			}
368:
369:                    for (String elementType : file.getRootElementList()) {
370:                        combo.add(replaceNS(elementType, i.getKey(), file
371:                                .getTargetNamespace()), elementTypeImage);
372:                    }
373:                }
374:                // adding XSD types
375:                //		for (String xsdType : xsdDataTypes) {
376:                //			combo.add("xsd:" + xsdType, xsdTypeImage);
377:                //		}
378:            }
379:
380:            private String replaceNS(String completType,
381:                    String newNamespacePrefix, String currentNsPrefix) {
382:                //return completType.replaceAll(currentNsPrefix, newNamespacePrefix);
383:                return newNamespacePrefix + ":" + completType;
384:            }
385:
386:            private String generateNS() {
387:                int i = 0;
388:                String constant = "ns";
389:                for (String ns : getWizard().getModel().getXsdFileNames()
390:                        .keySet()) {
391:                    int j = Integer.valueOf(ns.replace(constant, ""));
392:                    if (j >= i) {
393:                        i = j + 1;
394:                    }
395:                }
396:                return constant + i;
397:            }
398:
399:            @Override
400:            public NewWSDLWizard getWizard() {
401:                return ((NewWSDLWizard) super .getWizard());
402:            }
403:
404:            public void init() {
405:                for (Entry<String, String> i : getWizard().getModel()
406:                        .getXsdFileNames().entrySet()) {
407:                    list.add(i.getValue() + "\t\t(" + i.getKey() + ")");
408:                }
409:            }
410:
411:            protected Button getRemoveButton() {
412:                return removeButton;
413:            }
414:        }
w_w__w.___j_ava_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.