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


001:        package com.bostechcorp.cbesb.ui.variant.wizards;
002:
003:        import java.io.FileOutputStream;
004:        import java.util.Vector;
005:
006:        import org.eclipse.core.runtime.CoreException;
007:        import org.eclipse.jface.viewers.IStructuredSelection;
008:        import org.eclipse.jface.wizard.Wizard;
009:        import org.eclipse.swt.SWT;
010:        import org.eclipse.swt.widgets.MessageBox;
011:        import org.eclipse.swt.widgets.TreeItem;
012:        import org.eclipse.ui.INewWizard;
013:        import org.eclipse.ui.IWorkbench;
014:        import org.eclipse.ui.IWorkbenchWizard;
015:        import org.eclipse.ui.PlatformUI;
016:
017:        import com.bostechcorp.cbesb.common.i18n.I18N;
018:        import com.bostechcorp.cbesb.common.i18n.Message;
019:        import com.bostechcorp.cbesb.common.i18n.Messages;
020:        import com.bostechcorp.cbesb.common.mdl.IMDLDocument;
021:        import com.bostechcorp.cbesb.common.mdl.IMessageDefinition;
022:        import com.bostechcorp.cbesb.common.mdl.util.FormatDefUtil;
023:        import com.bostechcorp.cbesb.ui.baseformat.editor.models.ModelFactory;
024:        import com.bostechcorp.cbesb.ui.util.MsgUtil;
025:        import com.bostechcorp.cbesb.ui.util.ProjectUtil;
026:        import com.bostechcorp.cbesb.ui.variant.editor.Activator;
027:        import com.bostechcorp.cbesb.ui.variant.editor.actions.Analyze;
028:        import com.bostechcorp.cbesb.ui.variant.editor.editors.X12Editor;
029:        import com.bostechcorp.cbesb.ui.variant.utils.FileChange;
030:
031:        public class VariantNewWizard extends Wizard implements  INewWizard {
032:
033:            private IStructuredSelection selection;
034:
035:            private IWorkbench workbench;
036:
037:            private VariantNewWizardMainPage mainPage;
038:
039:            private String wizardTitle = "";
040:
041:            private String pageTitle = "";
042:
043:            private String pageDescription = "";
044:
045:            protected X12Editor editor;
046:
047:            protected String var_type = "x12";
048:
049:            public TreeItem clipboard = null;
050:
051:            protected boolean message = true;
052:
053:            protected String path = "";
054:
055:            protected boolean copy = true;
056:
057:            public VariantNewWizard(X12Editor editor, String wizardTitle,
058:                    String pageTitle, String pageDescription, String var_type,
059:                    boolean message, boolean copy, String path) {
060:                super ();
061:                this .editor = editor;
062:                this .pageTitle = pageTitle;
063:                this .pageDescription = pageDescription;
064:                this .wizardTitle = wizardTitle;
065:                this .var_type = var_type;
066:                this .message = message;
067:                this .copy = copy;
068:                this .path = path;
069:            }
070:
071:            /**
072:             * Adding the page to the wizard.
073:             */
074:            public void addPages() {
075:                mainPage = new VariantNewWizardMainPage(workbench, selection,
076:                        pageTitle, pageDescription);
077:                addPage(mainPage);
078:            }
079:
080:            /**
081:             * We will accept the selection in the workbench to see if we can initialize
082:             * from it.
083:             * 
084:             * @see IWorkbenchWizard#init(IWorkbench, IStructuredSelection)
085:             */
086:            public void init(IWorkbench workbench,
087:                    IStructuredSelection selection) {
088:                this .workbench = workbench;
089:                this .selection = selection;
090:                setWindowTitle(wizardTitle);
091:                setDefaultPageImageDescriptor(Activator
092:                        .imageDescriptorFromPlugin(Activator.PLUGIN_ID,
093:                                "icons/full/wizban/openMessageFormatView.gif"));
094:            }
095:
096:            /**
097:             * (non-Javadoc) Method declared on IWizard
098:             */
099:            public boolean performFinish() {
100:                try {
101:                    doFinish();
102:                } catch (Exception ex) {
103:                    ex.printStackTrace();
104:                    MsgUtil.warningMsg(ex.toString());
105:
106:                }
107:                return true;//thiredPage.finish();
108:            }
109:
110:            private void doFinish() throws CoreException {
111:                String file_name = mainPage.getFilename();
112:
113:                if (message)
114:                    creatMDLFile(file_name);
115:                else
116:                    creatMDLFileSeg(file_name);
117:            }
118:
119:            private void creatMDLFile(String filename) {
120:                if (filename.equals(""))
121:                    filename = "Muntitled.mdl";
122:                if ((filename.endsWith(".mdl")) || (filename.endsWith(".MDL")))
123:                    filename = filename.substring(0, filename.indexOf("."));
124:                Analyze analyzeLeft = (Analyze) ((X12Editor) editor)
125:                        .getAnalyzeLeft();
126:                String mes_path = analyzeLeft.getMes_path();
127:                String filepath = mes_path + "\\" + filename + ".mdl";
128:
129:                // get the vector for the segments mdl files
130:                Vector vector_mes = analyzeLeft.getMes_mdl();
131:
132:                for (int i = 0; i < vector_mes.size(); i++) {
133:                    // If the new file already existed in the old vector
134:                    if (((TreeItem) vector_mes.get(i)).getText()
135:                            .equalsIgnoreCase(filename + ".mdl")) {
136:                        int open = MsgUtil.confirmMsg(I18N
137:                                .getString(Messages.OVERWRITE));
138:                        if (open == SWT.OK)
139:                            analyzeLeft.deleteFile(filepath);
140:                        else
141:                            return;
142:                    }
143:                }
144:
145:                analyzeLeft.addintoMes_mdl(filename);
146:                analyzeLeft.createFile(filepath);
147:                if (copy) {
148:                    IMDLDocument mdlDoc = FormatDefUtil
149:                            .getMdlDocFromFormatSpec("x12", path);
150:                    IMessageDefinition[] md = mdlDoc.getAllMessageDefinitions();
151:                    md[0].setName(filename);
152:                    //mdlDoc.setTargetNamespace(filename);
153:
154:                    try {
155:                        FileOutputStream fileOutputStream = new FileOutputStream(
156:                                filepath);
157:                        mdlDoc.serialize(fileOutputStream);
158:                    } catch (Exception ex) {
159:                        ex.printStackTrace();
160:                        MsgUtil.warningMsg(ex.toString());
161:                        return;
162:                    }
163:                } else {
164:                    analyzeLeft.writeMDLHeader(filepath, filename, true);
165:                }
166:                ((X12Editor) editor).varMDLFile = true;
167:                ((X12Editor) editor).executeOpenMDL(analyzeLeft.getNewItem());
168:                ((X12Editor) editor).getLeftPanel().layout();
169:                ((X12Editor) editor).currentMDLFile = ModelFactory.TYPE_VARIANT_MES;
170:                ((X12Editor) editor).setBasefilename(filename + ".mdl");
171:                Vector vec = ((X12Editor) editor).getAnalyze().getMes_mdl();
172:                int index = vec.size() - 1;
173:                ((X12Editor) editor).getLeftTree().setSelection(
174:                        (TreeItem) vec.get(index));
175:                ((X12Editor) editor).writeIntoTaggedList();
176:                ProjectUtil.refreshProject(((X12Editor) editor)
177:                        .getProjectName());
178:            }
179:
180:            public void creatMDLFileSeg(String filename) {
181:                if (filename.equals(""))
182:                    filename = "untitled.mdl";
183:                if ((filename.endsWith(".mdl")) || (filename.endsWith(".MDL")))
184:                    filename = filename.substring(0, filename.indexOf("."));
185:                //filename = filename.toUpperCase();
186:                Analyze analyzeLeft = (Analyze) ((X12Editor) editor)
187:                        .getAnalyzeLeft();
188:                String seg_path = analyzeLeft.getSeg_path();
189:                String filepath = seg_path + "\\" + filename + ".mdl";
190:
191:                // get the vector for the segments mdl files
192:                Vector vector_seg = analyzeLeft.getSeg_mdl();
193:
194:                for (int i = 0; i < vector_seg.size(); i++) {
195:                    // If the new file already existed in the old vector
196:                    if (((TreeItem) vector_seg.get(i)).getText()
197:                            .equalsIgnoreCase(filename + ".mdl")) {
198:                        MessageBox dlg = new MessageBox(PlatformUI
199:                                .getWorkbench().getActiveWorkbenchWindow()
200:                                .getShell(), SWT.ICON_QUESTION | SWT.YES
201:                                | SWT.NO);
202:                        dlg.setMessage(new Message(Messages.OVERWRITE)
203:                                .getMessage());
204:
205:                        int open = dlg.open();
206:                        switch (open) {
207:                        case SWT.YES:
208:                            analyzeLeft.deleteFile(filepath);
209:                            break;
210:                        case SWT.NO:
211:                            return;
212:
213:                        }
214:                        break;
215:                    }
216:                }
217:
218:                analyzeLeft.addintoSeg_mdl(filename);
219:                analyzeLeft.createFile(filepath);
220:
221:                if (copy) {
222:                    IMDLDocument mdlDoc = FormatDefUtil
223:                            .getMdlDocFromFormatSpec("x12", path);
224:
225:                    IMDLDocument new_mdlDoc = FileChange.copyChangeDoc(mdlDoc,
226:                            filename, "x12");
227:                    try {
228:                        FileOutputStream fileOutputStream = new FileOutputStream(
229:                                filepath);
230:                        new_mdlDoc.serialize(fileOutputStream);
231:                    } catch (Exception ex) {
232:                        ex.printStackTrace();
233:                    }
234:                } else {
235:                    analyzeLeft.writeMDLHeader(filepath, filename, false);
236:                }
237:
238:                ((X12Editor) editor).varMDLFile = true;
239:                ((X12Editor) editor).executeOpenMDL(analyzeLeft.getNewItem());
240:                ((X12Editor) editor).getLeftPanel().layout();
241:                ((X12Editor) editor).currentMDLFile = ModelFactory.TYPE_VARIANT_SEG;
242:                ((X12Editor) editor).setBasefilename(filename + ".mdl");
243:                Vector vec = ((X12Editor) editor).getAnalyze().getSeg_mdl();
244:                int index = vec.size() - 1;
245:                ((X12Editor) editor).getLeftTree().setSelection(
246:                        ((TreeItem) vec.get(index)));
247:
248:                ((X12Editor) editor).writeIntoTaggedList();
249:                ProjectUtil.refreshProject(((X12Editor) editor)
250:                        .getProjectName());
251:            }
252:
253:            public void setClipboard(TreeItem clipboard) {
254:                this .clipboard = clipboard;
255:            }
256:
257:            public TreeItem getClipboard() {
258:                return this.clipboard;
259:            }
260:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.