Source Code Cross Referenced for VariantCreationWizardPage.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:        package com.bostechcorp.cbesb.ui.ide.wizards;
002:
003:        import java.io.File;
004:        import java.io.InputStream;
005:        import java.util.ArrayList;
006:        import java.util.EventListener;
007:        import java.util.List;
008:
009:        import org.eclipse.core.resources.IFile;
010:        import org.eclipse.core.resources.ResourcesPlugin;
011:        import org.eclipse.core.runtime.IPath;
012:        import org.eclipse.core.runtime.IStatus;
013:        import org.eclipse.jface.viewers.IStructuredSelection;
014:        import org.eclipse.swt.SWT;
015:        import org.eclipse.swt.layout.GridData;
016:        import org.eclipse.swt.widgets.Button;
017:        import org.eclipse.swt.widgets.Combo;
018:        import org.eclipse.swt.widgets.Composite;
019:        import org.eclipse.swt.widgets.Event;
020:        import org.eclipse.swt.widgets.Label;
021:        import org.eclipse.ui.IWorkbench;
022:        import org.eclipse.ui.IWorkbenchPage;
023:        import org.eclipse.ui.IWorkbenchWindow;
024:        import org.eclipse.ui.PartInitException;
025:        import org.eclipse.ui.ide.IDE;
026:
027:        import com.bostechcorp.cbesb.common.i18n.I18N;
028:        import com.bostechcorp.cbesb.common.i18n.Messages;
029:        import com.bostechcorp.cbesb.common.util.project.ProjectUtil;
030:
031:        public class VariantCreationWizardPage extends
032:                WizardNewFileCreationPage {
033:
034:            protected IWorkbench workbench;
035:
036:            protected String current_project_name = null;
037:
038:            protected String zipsource = "src/formats/hl7";
039:
040:            // widgets
041:            private Button openFileCheckbox;
042:
043:            public static Combo versionChoice;
044:
045:            private Label label;
046:
047:            private IPath projectPath;
048:
049:            protected IPath rootLoc;
050:
051:            protected String projectName = null;
052:
053:            protected String variant_name = "x12";
054:
055:            static String ext = ".zip";
056:
057:            static String start = "v";
058:
059:            static String end_letter = "v";
060:
061:            static String defaultName = "x12Var";
062:
063:            static String extension = "vcx";
064:
065:            static String pathOfFolder;
066:
067:            static String MESSAGE = "messages";
068:
069:            static String SEGMENT = "segments";
070:
071:            static String DATATYPE = "datatypes.mdl";
072:
073:            static String newVarName = "";
074:
075:            static String version = "";
076:
077:            // the root path for the zip files
078:            public static String base_version_zip_path = null;
079:
080:            private static int nameCounter = 1;
081:
082:            /**
083:             * Creates the page for the readme creation wizard.
084:             * 
085:             * @param workbench
086:             *            the workbench on which the page should be created
087:             * @param selection
088:             *            the current selection
089:             */
090:            public VariantCreationWizardPage(String name, IWorkbench workbench,
091:                    IStructuredSelection selection) {
092:
093:                super (name, selection);
094:                this .workbench = workbench;
095:            }
096:
097:            /**
098:             * The <code>MessageFormatCreationWizardPage</code> implementation of this
099:             * <code>WizardNewFileCreationPage</code> method generates sample headings
100:             * for sections and subsections in the newly-created Readme file according
101:             * to the selections of self's checkbox widgets
102:             */
103:            protected InputStream getInitialContents() {
104:                return null;
105:            }
106:
107:            /**
108:             * (non-Javadoc) Method declared on WizardNewFileCreationPage.
109:             */
110:            protected String getNewFileLabel() {
111:
112:                return "";
113:            }
114:
115:            public void handleEvent(Event event) {
116:                rootLoc = ResourcesPlugin.getWorkspace().getRoot()
117:                        .getLocation();
118:                pathOfFolder = null;
119:                List fileList = null;
120:                try {
121:                    projectPath = this .getContainerFullPath();
122:                    String path1 = projectPath.toString().substring(1,
123:                            projectPath.toString().length());
124:                    if (path1.contains("/"))
125:                        projectName = path1.substring(0, path1.indexOf("/"));
126:                    else
127:                        projectName = path1;
128:                    pathOfFolder = rootLoc.toString()
129:                            + "/"
130:                            + projectPath.toString().substring(1,
131:                                    projectPath.toOSString().length());
132:
133:                    // Clear the Combo
134:                    versionChoice.removeAll();
135:
136:                    String dir = pathOfFolder;
137:                    // set the project name
138:
139:                    fileList = listBaseVesionFiles(base_version_zip_path, ext,
140:                            start);
141:                    if (!fileList.isEmpty()) {
142:                        Object[] objectList = fileList.toArray();
143:                        for (int i = 0; i < objectList.length; i++)
144:                            versionChoice.add(objectList[i].toString()
145:                                    .substring(
146:                                            0,
147:                                            objectList[i].toString().indexOf(
148:                                                    ".zip")), i);
149:                    }
150:                    versionChoice.setText(versionChoice.getItem(0));
151:                    version = versionChoice.getText();
152:                    newVarName = getFileName();
153:                } catch (Exception e) {//TODO
154:                    setPageComplete(false);
155:                    return;
156:                }
157:
158:                setPageComplete(validatePage(this .getContainerFullPath()
159:                        .toString(), zipsource));
160:                if ((fileList == null) || (fileList.isEmpty())) {
161:                    setPageComplete(false);
162:                }
163:            }
164:
165:            // List all the available version within a certain project
166:            public List listBaseVesionFiles(String dire, String end,
167:                    String start) {
168:                File dir = new File(dire);
169:                String[] list = dir.list();
170:                List finalList = new ArrayList();
171:                if (list.length == 0)
172:                    return finalList;
173:
174:                for (int i = 0; i < list.length; i++) {
175:                    String fileName = list[i].toString();
176:                    if (fileName.endsWith(end) && fileName.startsWith(start)) {
177:
178:                        finalList.add(list[i]);
179:                    }
180:                }
181:                return finalList;
182:            }
183:
184:            /**
185:             * (non-Javadoc) Method declared on IDialogPage.
186:             */
187:            public void createControl(Composite parent) {
188:                // inherit default container and name specification widgets
189:                super .createControl(parent);
190:                Composite composite = (Composite) getControl();
191:                this .setFileName(defaultName, extension);
192:                // open file for editing checkbox
193:                openFileCheckbox = new Button(composite, SWT.CHECK);
194:                openFileCheckbox.setSelection(true);
195:
196:                label = new Label(composite, SWT.NONE);
197:                final GridData gridData = new GridData();
198:                gridData.horizontalSpan = 5;
199:                label.setLayoutData(gridData);
200:                openFileCheckbox.setText(I18N
201:                        .getString(Messages.IDE_OPEN_FILE_EDITOR));
202:                label.setText(I18N.getString(Messages.IDE_VER_CHOOSE));
203:                // Combo for MDL version choice
204:                versionChoice = new Combo(composite, SWT.READ_ONLY);
205:                versionChoice.setLayoutData(new GridData(
206:                        GridData.HORIZONTAL_ALIGN_FILL));
207:
208:                // Add listener to Combo
209:
210:                rootLoc = ResourcesPlugin.getWorkspace().getRoot()
211:                        .getLocation();
212:                pathOfFolder = null;
213:                List fileList = null;
214:                try {
215:                    projectPath = this .getContainerFullPath();
216:                    String path1 = projectPath.toString().substring(1,
217:                            projectPath.toString().length());
218:                    if (path1.contains("/"))
219:                        projectName = path1.substring(0, path1.indexOf("/"));
220:                    else
221:                        projectName = path1;
222:                    pathOfFolder = rootLoc.toString()
223:                            + "/"
224:                            + projectPath.toString().substring(1,
225:                                    projectPath.toOSString().length());
226:
227:                    // Clear the Combo
228:                    versionChoice.removeAll();
229:                    String dir = pathOfFolder;
230:
231:                    String split = projectPath.toString().substring(
232:                            projectPath.toString().indexOf("/") + 1,
233:                            projectPath.toString().length());
234:                    if (split.contains("/"))
235:                        current_project_name = split.substring(0, split
236:                                .indexOf("/"));
237:                    else
238:                        current_project_name = split;
239:                    base_version_zip_path = ProjectUtil.getZipPathForUI(rootLoc
240:                            .toString()
241:                            + "/" + current_project_name, variant_name);
242:                    fileList = listBaseVesionFiles(base_version_zip_path, ext,
243:                            start);
244:                    if (!fileList.isEmpty()) {
245:                        Object[] objectList = fileList.toArray();
246:                        for (int i = 0; i < objectList.length; i++)
247:                            versionChoice.add(objectList[i].toString()
248:                                    .substring(
249:                                            0,
250:                                            objectList[i].toString().indexOf(
251:                                                    ".zip")), i);
252:                    }
253:                    versionChoice.setText(versionChoice.getItem(0));
254:                    version = versionChoice.getText();
255:                    newVarName = getFileName();
256:                } catch (Exception ev) {
257:                    //TODO
258:                }
259:                setPageComplete(validatePage(this .getContainerFullPath()
260:                        .toString(), zipsource));
261:                if (fileList.isEmpty()) {
262:                    setPageComplete(false);
263:                }
264:            }
265:
266:            /**
267:             * Creates a new file resource as requested by the user. If everything is OK
268:             * then answer true. If not, false will cause the dialog to stay open.
269:             * 
270:             * @return whether creation was successful
271:             * @see MessageFormatCreationWizard#performFinish()
272:             */
273:            public boolean finish() {
274:                // create the new file resource
275:                if (versionChoice.getText().equals("")) {
276:                    return false;
277:
278:                }
279:
280:                IFile newFile = createNewFile(extension);
281:                if (newFile == null)
282:                    return false; // ie.- creation was unsuccessful
283:
284:                // Since the file resource was created fine, open it for editing
285:                // if requested by the user
286:                try {
287:                    if (openFileCheckbox.getSelection()) {
288:                        IWorkbenchWindow dwindow = workbench
289:                                .getActiveWorkbenchWindow();
290:                        IWorkbenchPage page = dwindow.getActivePage();
291:                        if (page != null) {
292:                            IDE.openEditor(page, newFile, true);
293:                        }
294:                    }
295:                } catch (PartInitException e) {
296:                    e.printStackTrace();
297:                    return false;
298:                }
299:                nameCounter++;
300:                return true;
301:            }
302:
303:            // After creating a .vcx file, we need to create some other folders.
304:            public void dispose() {
305:
306:            }
307:
308:            public static String getDefaultName() {
309:                return defaultName;
310:            }
311:
312:            public static void setDefaultName(String defaultName) {
313:                VariantCreationWizardPage.defaultName = defaultName;
314:            }
315:
316:            public static String getExtension() {
317:                return extension;
318:            }
319:
320:            public static void setExtension(String extension) {
321:                VariantCreationWizardPage.extension = extension;
322:            }
323:
324:            protected boolean validatePage(String path, String key) {
325:                this .path = path;
326:                this .key = key;
327:                boolean valid = true;
328:
329:                if (!resourceGroup.areAllValuesValid()) {
330:                    // if blank name then fail silently
331:                    if (resourceGroup.getProblemType() == ResourceAndContainerGroup.PROBLEM_RESOURCE_EMPTY
332:                            || resourceGroup.getProblemType() == ResourceAndContainerGroup.PROBLEM_CONTAINER_EMPTY) {
333:                        setMessage(resourceGroup.getProblemMessage());
334:                        setErrorMessage(null);
335:                    } else {
336:                        setErrorMessage(resourceGroup.getProblemMessage());
337:                    }
338:                    valid = false;
339:                }
340:
341:                IStatus linkedResourceStatus = null;
342:                if (valid) {
343:                    linkedResourceStatus = validateLinkedResource();
344:                    if (linkedResourceStatus.getSeverity() == IStatus.ERROR) {
345:                        valid = false;
346:                    }
347:                }
348:                // validateLinkedResource sets messages itself
349:                if (valid
350:                        && (linkedResourceStatus == null || linkedResourceStatus
351:                                .isOK())) {
352:                    setMessage(null);
353:                    setErrorMessage(null);
354:                }
355:                return valid;
356:            }
357:
358:            public String getVariant_name() {
359:                return variant_name;
360:            }
361:
362:            public void setVariant_name(String variant_name) {
363:                this .variant_name = variant_name;
364:            }
365:
366:            public String getZipsource() {
367:                return zipsource;
368:            }
369:
370:            public void setZipsource(String zipsource) {
371:                this .zipsource = zipsource;
372:            }
373:
374:            public static String getBase_version_zip_path() {
375:                return base_version_zip_path;
376:            }
377:
378:            public static void setBase_version_zip_path(
379:                    String base_version_zip_path) {
380:                VariantCreationWizardPage.base_version_zip_path = base_version_zip_path;
381:            }
382:
383:            public static String getDATATYPE() {
384:                return DATATYPE;
385:            }
386:
387:            public static void setDATATYPE(String datatype) {
388:                DATATYPE = datatype;
389:            }
390:
391:            public static String getEnd_letter() {
392:                return end_letter;
393:            }
394:
395:            public static void setEnd_letter(String end_letter) {
396:                VariantCreationWizardPage.end_letter = end_letter;
397:            }
398:
399:            public static String getExt() {
400:                return ext;
401:            }
402:
403:            public static void setExt(String ext) {
404:                VariantCreationWizardPage.ext = ext;
405:            }
406:
407:            public static String getMESSAGE() {
408:                return MESSAGE;
409:            }
410:
411:            public static void setMESSAGE(String message) {
412:                MESSAGE = message;
413:            }
414:
415:            public static int getNameCounter() {
416:                return nameCounter;
417:            }
418:
419:            public static void setNameCounter(int nameCounter) {
420:                VariantCreationWizardPage.nameCounter = nameCounter;
421:            }
422:
423:            public static String getNewX12Name() {
424:                return newVarName;
425:            }
426:
427:            public static void setNewX12Name(String newVarName1) {
428:                newVarName = newVarName1;
429:            }
430:
431:            public static String getPathOfX12Folder() {
432:                return pathOfFolder;
433:            }
434:
435:            public static void setPathOfX12Folder(String pathOfX12Folder) {
436:                pathOfFolder = pathOfX12Folder;
437:            }
438:
439:            public static String getSEGMENT() {
440:                return SEGMENT;
441:            }
442:
443:            public static void setSEGMENT(String segment) {
444:                SEGMENT = segment;
445:            }
446:
447:            public static String getStart() {
448:                return start;
449:            }
450:
451:            public static void setStart(String start) {
452:                VariantCreationWizardPage.start = start;
453:            }
454:
455:            public static String getVersion() {
456:                return version;
457:            }
458:
459:            public static void setVersion(String version) {
460:                VariantCreationWizardPage.version = version;
461:            }
462:
463:            public static Combo getVersionChoice() {
464:                return versionChoice;
465:            }
466:
467:            public static void setVersionChoice(Combo versionChoice) {
468:                VariantCreationWizardPage.versionChoice = versionChoice;
469:            }
470:
471:            public String getCurrent_project_name() {
472:                return current_project_name;
473:            }
474:
475:            public void setCurrent_project_name(String current_project_name) {
476:                this .current_project_name = current_project_name;
477:            }
478:
479:            public Label getLabel() {
480:                return label;
481:            }
482:
483:            public void setLabel(Label label) {
484:                this .label = label;
485:            }
486:
487:            public Button getOpenFileCheckbox() {
488:                return openFileCheckbox;
489:            }
490:
491:            public void setOpenFileCheckbox(Button openFileCheckbox) {
492:                this .openFileCheckbox = openFileCheckbox;
493:            }
494:
495:            public IPath getProjectPath() {
496:                return projectPath;
497:            }
498:
499:            public void setProjectPath(IPath projectPath) {
500:                this .projectPath = projectPath;
501:            }
502:
503:            public IPath getRootLoc() {
504:                return rootLoc;
505:            }
506:
507:            public void setRootLoc(IPath rootLoc) {
508:                this .rootLoc = rootLoc;
509:            }
510:
511:            public IWorkbench getWorkbench() {
512:                return workbench;
513:            }
514:
515:            public void setWorkbench(IWorkbench workbench) {
516:                this .workbench = workbench;
517:            }
518:
519:            public String getProjectName() {
520:                return projectName;
521:            }
522:
523:            public void setProjectName(String projectName) {
524:                this.projectName = projectName;
525:            }
526:
527:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.