Source Code Cross Referenced for NewEnhydraWizardSecondPage.java in  » J2EE » enhydra-IDE-plugin » org » enhydra » kelp » eclipse » enhydraWizard » 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 » J2EE » enhydra IDE plugin » org.enhydra.kelp.eclipse.enhydraWizard 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.enhydra.kelp.eclipse.enhydraWizard;
002:
003:        import java.io.File;
004:        import java.lang.reflect.InvocationTargetException;
005:        import java.lang.reflect.Method;
006:        import java.net.URI;
007:        import java.util.HashSet;
008:        import java.util.Iterator;
009:
010:        import org.eclipse.core.resources.IFile;
011:        import org.eclipse.core.resources.IProject;
012:        import org.eclipse.core.resources.IResource;
013:        import org.eclipse.core.resources.IResourceVisitor;
014:        import org.eclipse.core.runtime.CoreException;
015:        import org.eclipse.core.runtime.IPath;
016:        import org.eclipse.core.runtime.IProgressMonitor;
017:        import org.eclipse.core.runtime.NullProgressMonitor;
018:        import org.eclipse.core.runtime.Path;
019:        import org.eclipse.core.runtime.Platform;
020:        import org.eclipse.core.runtime.SubProgressMonitor;
021:        import org.eclipse.jdt.core.IClasspathEntry;
022:        import org.eclipse.jdt.core.ICompilationUnit;
023:        import org.eclipse.jdt.core.IJavaProject;
024:        import org.eclipse.jdt.core.IPackageDeclaration;
025:        import org.eclipse.jdt.core.JavaConventions;
026:        import org.eclipse.jdt.core.JavaCore;
027:        import org.eclipse.jdt.core.JavaModelException;
028:        import org.eclipse.jdt.internal.debug.ui.ExceptionHandler;
029:        import org.eclipse.jdt.internal.ui.JavaPlugin;
030:        import org.eclipse.jdt.internal.ui.preferences.NewJavaProjectPreferencePage;
031:        import org.eclipse.jdt.ui.wizards.JavaCapabilityConfigurationPage;
032:        import org.eclipse.jface.dialogs.MessageDialog;
033:        import org.eclipse.jface.operation.IRunnableWithProgress;
034:        import org.eclipse.jface.wizard.IWizardPage;
035:        import org.enhydra.tool.ToolBoxInfo;
036:
037:        /**
038:         * @author Tweety, Slobodan Vujasinovic
039:         *
040:         * To change this generated comment edit the template variable "typecomment":
041:         * Window>Preferences>Java>Templates.
042:         * To enable and disable the creation of type comments go to
043:         * Window>Preferences>Java>Code Generation.
044:         */
045:        public class NewEnhydraWizardSecondPage extends
046:                JavaCapabilityConfigurationPage {
047:
048:            private NewEnhydraWizardPage fMainPage;
049:            private IPath fCurrProjectLocation;
050:            private boolean fProjectCreated;
051:            private boolean firstUpdate = true;
052:
053:            String[] serverOptions = { "Tomcat", "JOnAS", "JBoss" };
054:            String serverOption = null;
055:
056:            /**
057:             * Constructor for NewEnhydraWizardSecondPage.
058:             */
059:            public NewEnhydraWizardSecondPage() {
060:                super ();
061:
062:                fCurrProjectLocation = fMainPage.getLocationPath();
063:                fProjectCreated = false;
064:            }
065:
066:            /**
067:             * Constructor for ProjectWizardPage.
068:             */
069:            public NewEnhydraWizardSecondPage(NewEnhydraWizardPage mainPage) {
070:                super ();
071:
072:                fMainPage = mainPage;
073:                fCurrProjectLocation = fMainPage.getLocationPath();
074:                fProjectCreated = false;
075:            }
076:
077:            private boolean canDetectExistingClassPath(IPath projLocation) {
078:                return projLocation.toFile().exists()
079:                        && !Platform.getLocation().equals(projLocation);
080:            }
081:
082:            private void update() {
083:                IPath projLocation = fMainPage.getLocationPath();
084:                if (!projLocation.equals(fCurrProjectLocation)
085:                        && canDetectExistingClassPath(projLocation)) {
086:                    String title = NewEnhydraWizardMessages
087:                            .getString("NewEnhydraWizardSecondPage.EarlyCreationDialog.title"); //$NON-NLS-1$
088:                    String description = NewEnhydraWizardMessages
089:                            .getString("NewEnhydraWizardSecondPage.EarlyCreationDialog.description"); //$NON-NLS-1$
090:                    if (MessageDialog.openQuestion(getShell(), title,
091:                            description)) {
092:                        createAndDetect();
093:                    }
094:                }
095:
096:                fCurrProjectLocation = projLocation;
097:
098:                IJavaProject prevProject = getJavaProject();
099:                IProject currProject = fMainPage.getProjectHandle();
100:                if ((prevProject == null)
101:                        || !currProject.equals(prevProject.getProject())) {
102:                    init(JavaCore.create(currProject), null, null, false);
103:                }
104:                /**/
105:                if (firstUpdate) {
106:                    IClasspathEntry[] sourceDirectories = createSourceDirectories();
107:                    IClasspathEntry[] myClasspaths = createMyClasspaths();
108:                    IClasspathEntry[] allEntries = joinEntries(
109:                            sourceDirectories, myClasspaths);
110:
111:                    try {
112:                        if (serverOption == null)
113:                            setServerOption();
114:
115:                        if (serverOptions[2].equals(serverOption)) {
116:                            init(
117:                                    getJavaProject(),
118:                                    new Path(
119:                                            getOutputLocation()
120:                                                    + "/application/output/server/default/deploy/"
121:                                                    + fMainPage
122:                                                            .getProjectName()
123:                                                    + ".war/WEB-INF/classes"),
124:                                    allEntries, false);
125:                        } else if (serverOptions[1].equals(serverOption)) {
126:                            init(
127:                                    getJavaProject(),
128:                                    new Path(
129:                                            getOutputLocation()
130:                                                    + "/application/bin/application/webapps/autoload/"
131:                                                    + fMainPage
132:                                                            .getProjectName()
133:                                                    + "/WEB-INF/classes"),
134:                                    allEntries, false);
135:                        } else {
136:                            init(getJavaProject(), new Path(getOutputLocation()
137:                                    + "/application/bin/application/webapps/"
138:                                    + fMainPage.getProjectName()
139:                                    + "/WEB-INF/classes"), allEntries, false);
140:                        }
141:                    } catch (NullPointerException e) {
142:                        NewEnhydraWizardMessages
143:                                .getString("NewEnhydraWizardSecondPage.CreatingEnhydraClasspathOperation.error");
144:                    }
145:
146:                    firstUpdate = false;
147:                }
148:                /**/
149:            }
150:
151:            private void createAndDetect() {
152:                IRunnableWithProgress op = new IRunnableWithProgress() {
153:                    public void run(IProgressMonitor monitor)
154:                            throws InvocationTargetException,
155:                            InterruptedException {
156:                        if (monitor == null)
157:                            monitor = new NullProgressMonitor();
158:
159:                        monitor
160:                                .beginTask(
161:                                        NewEnhydraWizardMessages
162:                                                .getString("NewEnhydraWizardSecondPage.EarlyCreationOperation.desc"), 3); //$NON-NLS-1$
163:                        try {
164:                            createProject(new SubProgressMonitor(monitor, 1));
165:                            initFromExistingStructures(new SubProgressMonitor(
166:                                    monitor, 2));
167:                        } catch (CoreException e) {
168:                            throw new InvocationTargetException(e);
169:                        }
170:                    }
171:                };
172:
173:                try {
174:                    getContainer().run(false, true, op);
175:                } catch (InvocationTargetException e) {
176:                    String title = NewEnhydraWizardMessages
177:                            .getString("NewEnhydraWizardSecondPage.EarlyCreationOperation.error.title"); //$NON-NLS-1$
178:                    String message = NewEnhydraWizardMessages
179:                            .getString("NewEnhydraWizardSecondPage.EarlyCreationOperation.error.desc"); //$NON-NLS-1$
180:
181:                    ExceptionHandler.handle(e, getShell(), title, message);
182:
183:                } catch (InterruptedException e) {
184:                    // cancel pressed
185:                }
186:            }
187:
188:            /* (non-Javadoc)
189:             * @see IDialogPage#setVisible(boolean)
190:             */
191:            public void setVisible(boolean visible) {
192:                if (visible) {
193:                    update();
194:                }
195:                super .setVisible(visible);
196:            }
197:
198:            /* (non-Javadoc)
199:             * @see IWizardPage#getPreviousPage()
200:             */
201:            public IWizardPage getPreviousPage() {
202:                if (fProjectCreated) {
203:                    return null;
204:                }
205:                return super .getPreviousPage();
206:            }
207:
208:            public IRunnableWithProgress getRunnable() {
209:                return new IRunnableWithProgress() {
210:                    public void run(IProgressMonitor monitor)
211:                            throws InvocationTargetException,
212:                            InterruptedException {
213:                        if (monitor == null)
214:                            monitor = new NullProgressMonitor();
215:
216:                        monitor
217:                                .beginTask(
218:                                        NewEnhydraWizardMessages
219:                                                .getString("NewEnhydraWizardSecondPage.NormalCreationOperation.desc"), 4); //$NON-NLS-1$
220:                        try {
221:                            createProject(new SubProgressMonitor(monitor, 1));
222:                            if (getJavaProject() == null) {
223:                                initFromExistingStructures(new SubProgressMonitor(
224:                                        monitor, 1));
225:                            } else {
226:                                monitor.worked(1);
227:                            }
228:                            configureJavaProject(new SubProgressMonitor(
229:                                    monitor, 2));
230:                        } catch (CoreException e) {
231:                            throw new InvocationTargetException(e);
232:                        } finally {
233:                            monitor.done();
234:                        }
235:                    }
236:                };
237:            }
238:
239:            private void createProject(IProgressMonitor monitor)
240:                    throws CoreException {
241:                fProjectCreated = false;
242:                IProject project = fMainPage.getProjectHandle();
243:                try {
244:                    // Eclipse 3.2
245:                    URI projectURI = project.getLocationURI();
246:                    //URI projectURI= fMainPage.getLocationURI();
247:                    //             BuildPathsBlock.createProject(project, projectURI, monitor);
248:                    //             fProjectCreated = true;
249:                    Method mth;
250:                    mth = Class
251:                            .forName(
252:                                    "org.eclipse.jdt.internal.ui.wizards.buildpaths.BuildPathsBlock")
253:                            .getMethod(
254:                                    "createProject",
255:                                    new Class[] { IProject.class, URI.class,
256:                                            IProgressMonitor.class });
257:                    mth.invoke(null, new Object[] { (IProject) project,
258:                            (URI) projectURI, (IProgressMonitor) monitor });
259:                    fProjectCreated = true;
260:                } catch (Exception ex) {
261:                    // Eclipse 3.1
262:                    IPath projectLocation = fMainPage.getLocationPath();
263:                    // BuildPathsBlock.createProject(project, projectLocation, monitor);
264:                    //  fProjectCreated = true;
265:                    try {
266:                        Method mth;
267:                        mth = Class
268:                                .forName(
269:                                        "org.eclipse.jdt.internal.ui.wizards.buildpaths.BuildPathsBlock")
270:                                .getMethod(
271:                                        "createProject",
272:                                        new Class[] { IProject.class,
273:                                                IPath.class,
274:                                                IProgressMonitor.class });
275:                        mth.invoke(null, new Object[] { (IProject) project,
276:                                (IPath) projectLocation,
277:                                (IProgressMonitor) monitor });
278:                        fProjectCreated = true;
279:                    } catch (NoSuchMethodException nsme) {
280:                        nsme.printStackTrace();
281:                    } catch (ClassNotFoundException cnfe) {
282:                        cnfe.printStackTrace();
283:                    } catch (IllegalArgumentException e) {
284:                        e.printStackTrace();
285:                    } catch (IllegalAccessException e) {
286:                        e.printStackTrace();
287:                    } catch (InvocationTargetException e) {
288:                        e.printStackTrace();
289:                    }
290:                }
291:            }
292:
293:            private void initFromExistingStructures(IProgressMonitor monitor)
294:                    throws CoreException {
295:                if (monitor == null)
296:                    monitor = new NullProgressMonitor();
297:
298:                monitor
299:                        .beginTask(
300:                                NewEnhydraWizardMessages
301:                                        .getString("NewEnhydraWizardSecondPage.DetectingClasspathOperation.desc"), 2); //$NON-NLS-1$
302:                try {
303:                    IProject project = fMainPage.getProjectHandle();
304:
305:                    if (project.getFile(".classpath").exists()) { //$NON-NLS-1$
306:                        init(JavaCore.create(project), null, null, false);
307:                        monitor.worked(2);
308:                    } else {
309:                        final HashSet sourceFolders = new HashSet();
310:                        IResourceVisitor visitor = new IResourceVisitor() {
311:                            public boolean visit(IResource resource)
312:                                    throws CoreException {
313:                                return doVisit(resource, sourceFolders);
314:                            }
315:                        };
316:                        project.accept(visitor);
317:                        monitor.worked(1);
318:
319:                        IClasspathEntry[] entries = null;
320:                        IPath outputLocation = null;
321:
322:                        if (!sourceFolders.isEmpty()) {
323:                            int nSourceFolders = sourceFolders.size();
324:                            IClasspathEntry[] jreEntries = NewJavaProjectPreferencePage
325:                                    .getDefaultJRELibrary();
326:                            entries = new IClasspathEntry[nSourceFolders
327:                                    + jreEntries.length];
328:                            Iterator iter = sourceFolders.iterator();
329:                            for (int i = 0; i < nSourceFolders; i++) {
330:                                entries[i] = JavaCore
331:                                        .newSourceEntry((IPath) iter.next());
332:                            }
333:                            System.arraycopy(jreEntries, 0, entries,
334:                                    nSourceFolders, jreEntries.length);
335:
336:                            IPath projPath = project.getFullPath();
337:                            if (nSourceFolders == 1
338:                                    && entries[0].getPath().equals(projPath)) {
339:                                outputLocation = projPath;
340:                            } else {
341:                                /* 
342:                                 * outputLocation= projPath.append(NewJavaProjectPreferencePage.getOutputLocationName());
343:                                 */
344:                                outputLocation = projPath
345:                                        .append(getJavaProject()
346:                                                .getOutputLocation());
347:                            }
348:                            if (!JavaConventions.validateClasspath(
349:                                    JavaCore.create(project), entries,
350:                                    outputLocation).isOK()) {
351:                                outputLocation = null;
352:                                entries = null;
353:                            }
354:                        }
355:                        init(JavaCore.create(project), outputLocation, entries,
356:                                false);
357:                        monitor.worked(1);
358:                    }
359:                } finally {
360:                    monitor.done();
361:                }
362:
363:            }
364:
365:            private boolean doVisit(IResource resource, HashSet sourceFolders)
366:                    throws JavaModelException {
367:                if (!sourceFolders.isEmpty()) {
368:                    IResource curr = resource;
369:                    while (curr.getType() != IResource.ROOT) {
370:                        if (sourceFolders.contains(curr.getFullPath())) {
371:                            return false;
372:                        }
373:                        curr = curr.getParent();
374:                    }
375:                }
376:                if (resource.getType() == IResource.FILE) {
377:                    if ("java".equals(resource.getFileExtension())) { //$NON-NLS-1$
378:                        ICompilationUnit cu = JavaCore
379:                                .createCompilationUnitFrom((IFile) resource);
380:                        if (cu != null) {
381:                            IPath packPath = resource.getParent().getFullPath();
382:                            IPackageDeclaration[] decls = cu
383:                                    .getPackageDeclarations();
384:                            if (decls.length == 0) {
385:                                sourceFolders.add(packPath);
386:                            } else {
387:                                IPath relpath = new Path(decls[0]
388:                                        .getElementName().replace('.', '/'));
389:                                int remainingSegments = packPath.segmentCount()
390:                                        - relpath.segmentCount();
391:                                if (remainingSegments >= 0) {
392:                                    IPath prefix = packPath
393:                                            .uptoSegment(remainingSegments);
394:                                    IPath common = packPath
395:                                            .removeFirstSegments(remainingSegments);
396:                                    if (common.equals(relpath)) {
397:                                        sourceFolders.add(prefix);
398:                                    }
399:                                }
400:                            }
401:                        }
402:                    }
403:                }
404:                return true;
405:            }
406:
407:            /**
408:             * Called from the wizard on cancel.
409:             */
410:            public void performCancel() {
411:                if (fProjectCreated) {
412:                    try {
413:                        fMainPage.getProjectHandle().delete(false, false, null);
414:                    } catch (CoreException e) {
415:                        JavaPlugin.log(e);
416:                    }
417:                }
418:            }
419:
420:            /**
421:             * Initializes the page with the project and default classpaths.
422:             * <p>
423:             * The default classpath entries must correspond the the given project.
424:             * </p>
425:             * <p>
426:             * The caller of this method is responsible for creating the underlying project. The page will create the output,
427:             * source and library folders if required.
428:             * </p>
429:             * <p>
430:             * The project does not have to exist at the time of initialization, but must exist when executing the runnable
431:             * obtained by <code>getRunnable()</code>.
432:             * </p>
433:             * @param project The Java project.
434:             * @param entries The default classpath entries or <code>null</code> to let the page choose the default
435:             * @param path The folder to be taken as the default output path or <code>null</code> to let the page choose the default
436:             * @return overrideExistingClasspath If set to <code>true</code>, an existing '.classpath' file is ignored. If set to <code>false</code>
437:             * the given default classpath and output location is only used if no '.classpath' exists.
438:             */
439:            public void init(IJavaProject jproject,
440:                    IPath defaultOutputLocation,
441:                    IClasspathEntry[] defaultEntries,
442:                    boolean defaultsOverrideExistingClasspath) {
443:                super .init(jproject, defaultOutputLocation, defaultEntries,
444:                        defaultsOverrideExistingClasspath);
445:            }
446:
447:            public IClasspathEntry[] createMyClasspaths() {
448:
449:                final int jarFileElements = 24; // vl
450:                IClasspathEntry[] classpaths = getRawClassPath();
451:                IClasspathEntry[] myClasspaths = new IClasspathEntry[classpaths.length
452:                        + jarFileElements - 1]; // vl
453:                for (int i = 1; i < classpaths.length; i++) {
454:                    myClasspaths[i - 1] = classpaths[i];
455:                }
456:
457:                String enh_home = ToolBoxInfo.getEnhydraRoot();
458:
459:                int i = classpaths.length - 1;
460:
461:                myClasspaths[i] = JavaCore.newLibraryEntry(new Path(enh_home
462:                        + "/lib/log4j.jar"), null, null, false);
463:
464:                i++;
465:                myClasspaths[i] = JavaCore.newLibraryEntry(new Path(enh_home
466:                        + "/lib/eaf_api.jar"), null, null, false);
467:
468:                i++;
469:                myClasspaths[i] = JavaCore.newLibraryEntry(new Path(enh_home
470:                        + "/lib/eaf.jar"), null, null, false);
471:
472:                i++;
473:                myClasspaths[i] = JavaCore.newLibraryEntry(new Path(enh_home
474:                        + "/lib/util.jar"), null, null, false);
475:
476:                i++;
477:                myClasspaths[i] = JavaCore.newLibraryEntry(new Path(enh_home
478:                        + "/dods/lib/dbmanager.jar"), null, null, false);
479:
480:                i++;
481:                myClasspaths[i] = JavaCore.newLibraryEntry(new Path(enh_home
482:                        + "/dods/lib/dsconnection.jar"), null, null, false);
483:
484:                i++;
485:                myClasspaths[i] = JavaCore.newLibraryEntry(new Path(enh_home
486:                        + "/dods/lib/stdcaches.jar"), null, null, false);
487:
488:                i++;
489:                myClasspaths[i] = JavaCore.newLibraryEntry(new Path(enh_home
490:                        + "/dods/lib/stdconnection.jar"), null, null, false);
491:
492:                i++;
493:                myClasspaths[i] = JavaCore
494:                        .newLibraryEntry(new Path(enh_home
495:                                + "/dods/lib-ext/jta-spec1_0_1.jar"), null,
496:                                null, false);
497:
498:                i++;
499:                myClasspaths[i] = JavaCore.newLibraryEntry(new Path(enh_home
500:                        + "/dods/lib/stdtransaction.jar"), null, null, false);
501:
502:                i++;
503:                myClasspaths[i] = JavaCore.newLibraryEntry(new Path(enh_home
504:                        + "/lib/gnu-regexp.jar"), null, null, false);
505:
506:                i++;
507:                myClasspaths[i] = JavaCore.newLibraryEntry(new Path(enh_home
508:                        + "/lib/nekohtml.jar"), null, null, false);
509:
510:                i++;
511:                myClasspaths[i] = JavaCore.newLibraryEntry(new Path(enh_home
512:                        + "/lib/resolver.jar"), null, null, false);
513:
514:                i++;
515:                if (serverOption == null)
516:                    setServerOption();
517:
518:                if (serverOptions[1].equals(serverOption)) {
519:                    myClasspaths[i] = JavaCore.newLibraryEntry(new Path(
520:                            enh_home + "/../lib/commons/j2ee/servlet-2_4.jar"),
521:                            null, null, false);
522:                } else if (serverOptions[2].equals(serverOption)) {
523:                    myClasspaths[i] = JavaCore.newLibraryEntry(new Path(
524:                            enh_home + "/../client/javax.servlet.jar"), null,
525:                            null, false);
526:                } else {
527:                    serverOption = serverOptions[0];
528:                    myClasspaths[i] = JavaCore.newLibraryEntry(new Path(
529:                            enh_home + "/../lib/servlet-api.jar"), null, null,
530:                            false);
531:                }
532:
533:                i++;
534:                myClasspaths[i] = JavaCore.newLibraryEntry(new Path(enh_home
535:                        + "/lib/dom/xmlc-chtml.jar"), null, null, false);
536:
537:                i++;
538:                myClasspaths[i] = JavaCore.newLibraryEntry(new Path(enh_home
539:                        + "/lib/dom/xmlc-voicexml.jar"), null, null, false);
540:
541:                i++;
542:                myClasspaths[i] = JavaCore.newLibraryEntry(new Path(enh_home
543:                        + "/lib/dom/xmlc-wml.jar"), null, null, false);
544:
545:                i++;
546:                myClasspaths[i] = JavaCore.newLibraryEntry(new Path(enh_home
547:                        + "/lib/xercesImpl.jar"), null, null, false);
548:
549:                i++;
550:                myClasspaths[i] = JavaCore.newLibraryEntry(new Path(enh_home
551:                        + "/lib/xml-apis.jar"), null, null, false);
552:
553:                i++;
554:                myClasspaths[i] = JavaCore.newLibraryEntry(new Path(enh_home
555:                        + "/lib/dom3-xml-apis.jar"), null, null, false);
556:
557:                i++;
558:                myClasspaths[i] = JavaCore.newLibraryEntry(new Path(enh_home
559:                        + "/lib/xhtml.jar"), null, null, false);
560:
561:                i++;
562:                myClasspaths[i] = JavaCore.newLibraryEntry(new Path(enh_home
563:                        + "/lib/xmlc.jar"), null, null, false);
564:
565:                i++;
566:                myClasspaths[i] = JavaCore.newLibraryEntry(new Path(enh_home
567:                        + "/dods/lib/dods.jar"), null, null, false);
568:
569:                i++;
570:                myClasspaths[i] = JavaCore.newLibraryEntry(new Path(enh_home
571:                        + "/dods/lib/ejen.jar"), null, null, false);
572:
573:                return myClasspaths;
574:            }
575:
576:            private IClasspathEntry[] createSourceDirectories() {
577:                final HashSet sourceFolders = new HashSet();
578:                IClasspathEntry[] entries = null;
579:                IPath outputLocation = null;
580:                IProject project = fMainPage.getProjectHandle();
581:                IPath projPath = project.getFullPath();
582:
583:                if (!sourceFolders.isEmpty()) {
584:                    int nSourceFolders = sourceFolders.size();
585:                    IClasspathEntry[] jreEntries = NewJavaProjectPreferencePage
586:                            .getDefaultJRELibrary();
587:                    entries = new IClasspathEntry[nSourceFolders
588:                            + jreEntries.length];
589:                    Iterator iter = sourceFolders.iterator();
590:                    for (int i = 0; i < nSourceFolders; i++) {
591:                        entries[i] = JavaCore.newSourceEntry((IPath) iter
592:                                .next());
593:                    }
594:                    System.arraycopy(jreEntries, 0, entries, nSourceFolders,
595:                            jreEntries.length);
596:
597:                    if (nSourceFolders == 1
598:                            && entries[0].getPath().equals(projPath)) {
599:                        outputLocation = projPath;
600:                    } else {
601:                        /* 
602:                         * outputLocation = projPath.append(NewJavaProjectPreferencePage.getOutputLocationName());
603:                         */
604:                        try {
605:                            outputLocation = projPath.append(getJavaProject()
606:                                    .getOutputLocation());
607:                        } catch (JavaModelException e) {
608:                            outputLocation = projPath;
609:                            //e.printStackTrace();
610:                        }
611:                    }
612:                    if (!JavaConventions.validateClasspath(
613:                            JavaCore.create(project), entries, outputLocation)
614:                            .isOK()) {
615:                        outputLocation = null;
616:                        entries = null;
617:                    }
618:
619:                } else {
620:                    entries = new IClasspathEntry[0];
621:                }
622:
623:                String projDirName = projPath
624:                        .segment(projPath.segmentCount() - 1);
625:                IClasspathEntry[] myEntries = new IClasspathEntry[entries.length + 6];
626:                myEntries[entries.length] = JavaCore
627:                        .newSourceEntry((IPath) new Path("/" + projDirName
628:                                + "/presentation/src"));
629:                myEntries[entries.length + 1] = JavaCore
630:                        .newSourceEntry((IPath) new Path("/" + projDirName
631:                                + "/presentation/src-generated"));
632:                myEntries[entries.length + 2] = JavaCore
633:                        .newSourceEntry((IPath) new Path("/" + projDirName
634:                                + "/business/src"));
635:                myEntries[entries.length + 3] = JavaCore
636:                        .newSourceEntry((IPath) new Path("/" + projDirName
637:                                + "/data/src"));
638:                myEntries[entries.length + 4] = JavaCore
639:                        .newSourceEntry((IPath) new Path("/" + projDirName
640:                                + "/data/src-generated"));
641:                myEntries[entries.length + 5] = JavaCore
642:                        .newSourceEntry((IPath) new Path("/" + projDirName
643:                                + "/specification/src"));
644:
645:                return myEntries;
646:            }
647:
648:            private IClasspathEntry[] joinEntries(IClasspathEntry[] a,
649:                    IClasspathEntry[] b) {
650:
651:                IClasspathEntry[] result;
652:                try {
653:                    result = new IClasspathEntry[a.length + b.length];
654:                    for (int i = 0; i < a.length; i++) {
655:                        result[i] = a[i];
656:                    }
657:                    for (int i = a.length; i < a.length + b.length; i++) {
658:                        result[i] = b[i - a.length];
659:                    }
660:                } catch (NullPointerException e) {
661:                    if (a == null) {
662:                        if (b == null)
663:                            return null;
664:                        else
665:                            return b;
666:                    } else {
667:                        if (b == null)
668:                            return null;
669:                        else
670:                            return a;
671:                    }
672:                }
673:
674:                return result;
675:            }
676:
677:            private void setServerOption() {
678:                File path = new File(ToolBoxInfo.getEnhydraRoot());
679:                path = path.getParentFile();
680:                String enhydraRoot = path.getAbsolutePath();
681:
682:                // JOnAS
683:                File pathJOnAS = new File(enhydraRoot + "/lib/client.jar");
684:                // JBoss
685:                File pathJBoss = new File(enhydraRoot + "/lib/jboss-common.jar");
686:
687:                if (pathJOnAS.exists()) {
688:                    serverOption = serverOptions[1];
689:                } else if (pathJBoss.exists()) {
690:                    serverOption = serverOptions[2];
691:                } else {
692:                    serverOption = serverOptions[0];
693:                }
694:            }
695:
696:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.