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


001:        /*
002:         * ChainBuilder ESB
003:         *          Visual Enterprise Integration
004:         * 
005:         * Copyright (C) 2006 Bostech Corporation
006:         * 
007:         * This program is free software; you can redistribute it and/or modify it 
008:         * under the terms of the GNU General Public License as published by the 
009:         * Free Software Foundation; either version 2 of the License, or (at your option) 
010:         * any later version.
011:         *
012:         * This program is distributed in the hope that it will be useful, 
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
014:         * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
015:         * for more details.
016:         * 
017:         * You should have received a copy of the GNU General Public License along with 
018:         * this program; if not, write to the Free Software Foundation, Inc., 
019:         * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020:         *
021:         *
022:         * $Id$
023:         */
024:        package com.bostechcorp.cbesb.ui.ide.wizards;
025:
026:        import java.io.BufferedInputStream;
027:        import java.io.DataInputStream;
028:        import java.io.File;
029:        import java.io.FileInputStream;
030:        import java.io.FileWriter;
031:        import java.io.StringWriter;
032:
033:        import javax.xml.parsers.DocumentBuilder;
034:        import javax.xml.parsers.DocumentBuilderFactory;
035:        import javax.xml.transform.OutputKeys;
036:        import javax.xml.transform.Transformer;
037:        import javax.xml.transform.TransformerFactory;
038:        import javax.xml.transform.dom.DOMSource;
039:        import javax.xml.transform.stream.StreamResult;
040:
041:        import org.eclipse.jface.viewers.IStructuredSelection;
042:        import org.eclipse.jface.wizard.Wizard;
043:        import org.eclipse.ui.INewWizard;
044:        import org.eclipse.ui.IWorkbench;
045:        import org.w3c.dom.Document;
046:        import org.w3c.dom.Element;
047:
048:        import com.bostechcorp.cbesb.common.i18n.I18N;
049:        import com.bostechcorp.cbesb.common.i18n.Messages;
050:        import com.bostechcorp.cbesb.ui.ide.Activator;
051:        import com.bostechcorp.cbesb.ui.util.ProjectUtil;
052:        import com.bostechcorp.cbesb.ui.util.variant.VariantCreation;
053:
054:        /*
055:         */
056:        public class X12VariantCreationWizard extends Wizard implements 
057:                INewWizard {
058:            private IStructuredSelection selection;
059:
060:            private IWorkbench workbench;
061:
062:            String xmlString = null;
063:
064:            String x12VarFile = null;
065:
066:            String header = null;
067:
068:            String projectName = null;
069:
070:            int index = 0;
071:
072:            private X12VariantCreationWizardPage mainPage;
073:
074:            /**
075:             * (non-Javadoc) Method declared on Wizard.
076:             */
077:            public void addPages() {
078:                mainPage = new X12VariantCreationWizardPage(
079:                        "NewX12VariantWizard", workbench, selection);
080:                addPage(mainPage);
081:            }
082:
083:            /**
084:             * (non-Javadoc) Method declared on IWorkbenchWizard
085:             */
086:            public void init(IWorkbench workbench,
087:                    IStructuredSelection selection) {
088:                this .workbench = workbench;
089:                this .selection = selection;
090:                setWindowTitle(I18N.getString(Messages.IDE_X12_TITLE));// "New X12
091:                // variant");
092:                // //$NON-NLS-1$
093:                setDefaultPageImageDescriptor(Activator
094:                        .imageDescriptorFromPlugin(Activator.PLUGIN_ID,
095:                                "icons/full/wizban/openX12VariantView.gif"));
096:            }
097:
098:            /**
099:             * (non-Javadoc) Method declared on IWizard
100:             */
101:            public boolean performFinish() {
102:
103:                projectName = mainPage.getProjectName();
104:
105:                VariantCreation.version_name = X12VariantCreationWizardPage.versionChoice
106:                        .getText();
107:                VariantCreation.var_name = X12VariantCreationWizardPage.newVarName;
108:                // Create a folder for this x12 variant
109:                String newVariantPath = X12VariantCreationWizardPage.pathOfFolder
110:                        + "/"
111:                        + X12VariantCreationWizardPage.versionChoice.getText();
112:                boolean success = (new File(newVariantPath).mkdir());
113:                String varName = newVariantPath + "/"
114:                        + X12VariantCreationWizardPage.newVarName;
115:                success = (new File(varName).mkdir());
116:                String mess = varName + "/"
117:                        + X12VariantCreationWizardPage.MESSAGE;
118:                success = (new File(mess).mkdir());
119:                String seg = varName + "/"
120:                        + X12VariantCreationWizardPage.SEGMENT;
121:                success = (new File(seg).mkdir());
122:
123:                ProjectUtil.refreshProject(projectName);
124:                return mainPage.finish();
125:            }
126:
127:            public void dispose() {
128:
129:                boolean exist = true;
130:                x12VarFile = X12VariantCreationWizardPage.pathOfFolder + "/"
131:                        + X12VariantCreationWizardPage.newVarName + "."
132:                        + X12VariantCreationWizardPage.extension;
133:
134:                try {
135:                    FileInputStream fis = new FileInputStream(x12VarFile);
136:                    BufferedInputStream bis = new BufferedInputStream(fis);
137:                    DataInputStream dis = new DataInputStream(bis);
138:                } catch (Exception e) {
139:                    //TODO
140:                    exist = false;
141:
142:                    return;
143:                }
144:
145:                if (exist) {
146:
147:                    header = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
148:
149:                    try {
150:                        // ///////////////////////////
151:                        // Creating an empty XML Document
152:
153:                        // We need a Document
154:                        DocumentBuilderFactory dbfac = DocumentBuilderFactory
155:                                .newInstance();
156:                        DocumentBuilder docBuilder = dbfac.newDocumentBuilder();
157:                        Document doc = docBuilder.newDocument();
158:
159:                        // create the root element and add it to the document
160:
161:                        // Comment comment = doc.createComment(header);
162:                        // doc.appendChild(comment);
163:
164:                        Element variantcontrol = doc
165:                                .createElement("vcf:variantcontrol");
166:                        variantcontrol.setAttribute("xmlns:vcf",
167:                                "http://cbesb.bostechcorp.com/vcf/1.0");
168:                        variantcontrol.setAttribute("xmlns",
169:                                "http://www.bostechcorp.com/x12/demo");
170:                        variantcontrol.setAttribute("targetNamespace",
171:                                "http://cbesb.bostechcorp.com/vcf/1.0");
172:
173:                        Element variant = doc.createElement("vcf:variant");
174:                        variant.setAttribute("name",
175:                                X12VariantCreationWizardPage.newVarName);
176:                        variant.setAttribute("type", "X12");
177:                        variant.setAttribute("version",
178:                                X12VariantCreationWizardPage.versionChoice
179:                                        .getText());
180:                        variantcontrol.appendChild(variant);
181:
182:                        doc.appendChild(variantcontrol);
183:
184:                        // ///////////////
185:                        // Output the XML
186:
187:                        // set up a transformer
188:                        TransformerFactory transfac = TransformerFactory
189:                                .newInstance();
190:                        Transformer trans = transfac.newTransformer();
191:                        trans.setOutputProperty(
192:                                OutputKeys.OMIT_XML_DECLARATION, "yes");
193:                        trans.setOutputProperty(OutputKeys.INDENT, "yes");
194:
195:                        // create string from xml tree
196:                        StringWriter sw = new StringWriter();
197:
198:                        StreamResult result = new StreamResult(sw);
199:                        DOMSource source = new DOMSource(doc);
200:                        trans.transform(source, result);
201:                        xmlString = sw.toString();
202:
203:                    } catch (Exception e) {
204:                        //TODO handle Exception
205:                        System.out.println(e);
206:                    }
207:
208:                    try {
209:
210:                        // x12VarFile =
211:                        // X12VariantCreationWizardPage.pathOfX12Folder+"/"+X12VariantCreationWizardPage.newX12Name+".txt";
212:
213:                        FileWriter out = new FileWriter(x12VarFile, true);
214:
215:                        out.write(header + "\n" + xmlString);
216:                        // Close the output stream
217:                        out.close();
218:
219:                    } catch (Exception e) {
220:                        //TODO handle Exception
221:                        System.out.println(e);
222:                    }
223:
224:                }
225:                //TODO remove sysout
226:                System.out.println("projectName is " + projectName);
227:                ProjectUtil.refreshProject(projectName);
228:            }
229:
230:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.