KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > kelp > eclipse > enhydraWizard > NewEnhydraWizardSecondPage


1 package org.enhydra.kelp.eclipse.enhydraWizard;
2
3 import java.io.File JavaDoc;
4 import java.lang.reflect.InvocationTargetException JavaDoc;
5 import java.util.ArrayList JavaDoc;
6 import java.util.HashSet JavaDoc;
7 import java.util.Iterator JavaDoc;
8
9 import org.eclipse.core.resources.IFile;
10 import org.eclipse.core.resources.IProject;
11 import org.eclipse.core.resources.IResource;
12 import org.eclipse.core.resources.IResourceVisitor;
13 import org.eclipse.core.resources.ResourcesPlugin;
14 import org.eclipse.core.runtime.CoreException;
15 import org.eclipse.core.runtime.IPath;
16 import org.eclipse.core.runtime.IProgressMonitor;
17 import org.eclipse.core.runtime.NullProgressMonitor;
18 import org.eclipse.core.runtime.Path;
19 import org.eclipse.core.runtime.Platform;
20 import org.eclipse.core.runtime.SubProgressMonitor;
21 import org.eclipse.jdt.core.IClasspathEntry;
22 import org.eclipse.jdt.core.ICompilationUnit;
23 import org.eclipse.jdt.core.IJavaProject;
24 import org.eclipse.jdt.core.IPackageDeclaration;
25 import org.eclipse.jdt.core.IPackageFragmentRoot;
26 import org.eclipse.jdt.core.JavaConventions;
27 import org.eclipse.jdt.core.JavaCore;
28 import org.eclipse.jdt.core.JavaModelException;
29 import org.eclipse.jdt.internal.core.ClasspathEntry;
30 import org.eclipse.jdt.internal.ui.JavaPlugin;
31 import org.eclipse.jdt.internal.ui.preferences.NewJavaProjectPreferencePage;
32 import org.eclipse.jdt.internal.ui.util.ExceptionHandler;
33 import org.eclipse.jdt.internal.ui.wizards.buildpaths.BuildPathsBlock;
34 import org.eclipse.jdt.ui.wizards.JavaCapabilityConfigurationPage;
35 import org.eclipse.jface.dialogs.MessageDialog;
36 import org.eclipse.jface.operation.IRunnableWithProgress;
37 import org.eclipse.jface.wizard.IWizardPage;
38 import org.enhydra.tool.ToolBoxInfo;
39
40 /**
41  * @author Tweety
42  *
43  * To change this generated comment edit the template variable "typecomment":
44  * Window>Preferences>Java>Templates.
45  * To enable and disable the creation of type comments go to
46  * Window>Preferences>Java>Code Generation.
47  */

48 public class NewEnhydraWizardSecondPage
49     extends JavaCapabilityConfigurationPage {
50
51     private NewEnhydraWizardPage fMainPage;
52     private IPath fCurrProjectLocation;
53     private boolean fProjectCreated;
54     private boolean firstUpdate = true;
55     
56     /**
57      * Constructor for NewEnhydraWizardSecondPage.
58      */

59     public NewEnhydraWizardSecondPage() {
60         super();
61
62         fCurrProjectLocation= fMainPage.getLocationPath();
63         fProjectCreated= false;
64     }
65     
66     /**
67      * Constructor for ProjectWizardPage.
68      */

69     public NewEnhydraWizardSecondPage(NewEnhydraWizardPage mainPage) {
70         super();
71         
72         fMainPage= mainPage;
73         fCurrProjectLocation= fMainPage.getLocationPath();
74         fProjectCreated= false;
75     }
76     
77     private boolean canDetectExistingClassPath(IPath projLocation) {
78         return projLocation.toFile().exists() && !Platform.getLocation().equals(projLocation);
79     }
80     
81     private void update() {
82         IPath projLocation = fMainPage.getLocationPath();
83         if (!projLocation.equals(fCurrProjectLocation) && canDetectExistingClassPath(projLocation)) {
84             String JavaDoc title = NewEnhydraWizardMessages.getString("NewEnhydraWizardSecondPage.EarlyCreationDialog.title"); //$NON-NLS-1$
85
String JavaDoc description = NewEnhydraWizardMessages.getString("NewEnhydraWizardSecondPage.EarlyCreationDialog.description"); //$NON-NLS-1$
86
if (MessageDialog.openQuestion(getShell(), title, description)) {
87                 createAndDetect();
88             }
89         }
90                     
91         fCurrProjectLocation = projLocation;
92                 
93         IJavaProject prevProject = getJavaProject();
94         IProject currProject = fMainPage.getProjectHandle();
95         if ((prevProject == null) || !currProject.equals(prevProject.getProject())) {
96             init(JavaCore.create(currProject), null, null, false);
97         }
98 /**/
99         if (firstUpdate) {
100             IClasspathEntry[] sourceDirectories = createSourceDirectories();
101             IClasspathEntry[] myClasspaths = createMyClasspaths();
102             IClasspathEntry[] allEntries = joinEntries(sourceDirectories, myClasspaths);
103             
104             try {
105                 init(getJavaProject(), new Path(getOutputLocation() + "/classes"), allEntries, false);
106             } catch (NullPointerException JavaDoc e) {
107                 NewEnhydraWizardMessages.getString("NewEnhydraWizardSecondPage.CreatingEnhydraClasspathOperation.error");
108             }
109                 
110             firstUpdate = false;
111         }
112 /**/
113     }
114
115     private void createAndDetect() {
116         IRunnableWithProgress op= new IRunnableWithProgress() {
117             public void run(IProgressMonitor monitor) throws InvocationTargetException JavaDoc, InterruptedException JavaDoc {
118                 if (monitor == null)
119                     monitor= new NullProgressMonitor();
120         
121                 monitor.beginTask(NewEnhydraWizardMessages.getString("NewEnhydraWizardSecondPage.EarlyCreationOperation.desc"), 3); //$NON-NLS-1$
122
try {
123                     createProject(new SubProgressMonitor(monitor, 1));
124                     initFromExistingStructures(new SubProgressMonitor(monitor, 2));
125                 } catch (CoreException e) {
126                     throw new InvocationTargetException JavaDoc(e);
127                 }
128             }
129         };
130
131         try {
132             getContainer().run(false, true, op);
133         } catch (InvocationTargetException JavaDoc e) {
134             String JavaDoc title= NewEnhydraWizardMessages.getString("NewEnhydraWizardSecondPage.EarlyCreationOperation.error.title"); //$NON-NLS-1$
135
String JavaDoc message= NewEnhydraWizardMessages.getString("NewEnhydraWizardSecondPage.EarlyCreationOperation.error.desc"); //$NON-NLS-1$
136
ExceptionHandler.handle(e, getShell(), title, message);
137         } catch (InterruptedException JavaDoc e) {
138             // cancel pressed
139
}
140     }
141         
142     /* (non-Javadoc)
143      * @see IDialogPage#setVisible(boolean)
144      */

145     public void setVisible(boolean visible) {
146         if (visible) {
147             update();
148         }
149         super.setVisible(visible);
150     }
151     
152     /* (non-Javadoc)
153      * @see IWizardPage#getPreviousPage()
154      */

155     public IWizardPage getPreviousPage() {
156         if (fProjectCreated) {
157             return null;
158         }
159         return super.getPreviousPage();
160     }
161     
162     public IRunnableWithProgress getRunnable() {
163         return new IRunnableWithProgress() {
164             public void run(IProgressMonitor monitor) throws InvocationTargetException JavaDoc, InterruptedException JavaDoc {
165                 if (monitor == null)
166                     monitor= new NullProgressMonitor();
167                 
168                 monitor.beginTask(NewEnhydraWizardMessages.getString("NewEnhydraWizardSecondPage.NormalCreationOperation.desc"), 4); //$NON-NLS-1$
169
try {
170                     createProject(new SubProgressMonitor(monitor, 1));
171                     if (getJavaProject() == null) {
172                         initFromExistingStructures(new SubProgressMonitor(monitor, 1));
173                     } else {
174                         monitor.worked(1);
175                     }
176                     configureJavaProject(new SubProgressMonitor(monitor, 2));
177                 } catch (CoreException e) {
178                     throw new InvocationTargetException JavaDoc(e);
179                 } finally {
180                     monitor.done();
181                 }
182             }
183         };
184     }
185
186     private void createProject(IProgressMonitor monitor) throws CoreException {
187         IProject project= fMainPage.getProjectHandle();
188         IPath projectLocation= fMainPage.getLocationPath();
189         BuildPathsBlock.createProject(project, projectLocation, monitor);
190         fProjectCreated= true;
191     }
192     
193     private void initFromExistingStructures(IProgressMonitor monitor) throws CoreException {
194         if (monitor == null)
195             monitor= new NullProgressMonitor();
196         
197         monitor.beginTask(NewEnhydraWizardMessages.getString("NewEnhydraWizardSecondPage.DetectingClasspathOperation.desc"), 2); //$NON-NLS-1$
198
try {
199             IProject project= fMainPage.getProjectHandle();
200             
201             if (project.getFile(".classpath").exists()) { //$NON-NLS-1$
202
init(JavaCore.create(project), null, null, false);
203                 monitor.worked(2);
204             } else{
205                 final HashSet JavaDoc sourceFolders= new HashSet JavaDoc();
206                 IResourceVisitor visitor= new IResourceVisitor() {
207                     public boolean visit(IResource resource) throws CoreException {
208                         return doVisit(resource, sourceFolders);
209                     }
210                 };
211                 project.accept(visitor);
212                 monitor.worked(1);
213                                 
214                 IClasspathEntry[] entries= null;
215                 IPath outputLocation= null;
216                 
217                 if (!sourceFolders.isEmpty()) {
218                     int nSourceFolders= sourceFolders.size();
219                     IClasspathEntry[] jreEntries= NewJavaProjectPreferencePage.getDefaultJRELibrary();
220                     entries= new IClasspathEntry[nSourceFolders + jreEntries.length];
221                     Iterator JavaDoc iter = sourceFolders.iterator();
222                     for (int i = 0; i < nSourceFolders; i++) {
223                         entries[i]= JavaCore.newSourceEntry((IPath) iter.next());
224                     }
225                     System.arraycopy(jreEntries, 0, entries, nSourceFolders, jreEntries.length);
226                     
227                     IPath projPath= project.getFullPath();
228                     if (nSourceFolders == 1 && entries[0].getPath().equals(projPath)) {
229                         outputLocation= projPath;
230                     } else {
231                         outputLocation= projPath.append(NewJavaProjectPreferencePage.getOutputLocationName());
232                     }
233                     if (!JavaConventions.validateClasspath(JavaCore.create(project), entries, outputLocation).isOK()) {
234                         outputLocation= null;
235                         entries= null;
236                     }
237                 }
238                 init(JavaCore.create(project), outputLocation, entries, false);
239                 monitor.worked(1);
240             }
241         } finally {
242             monitor.done();
243         }
244         
245     }
246     
247     private boolean doVisit(IResource resource, HashSet JavaDoc sourceFolders) throws JavaModelException {
248         if (!sourceFolders.isEmpty()) {
249             IResource curr= resource;
250             while (curr.getType() != IResource.ROOT) {
251                 if (sourceFolders.contains(curr.getFullPath())) {
252                     return false;
253                 }
254                 curr= curr.getParent();
255             }
256         }
257         if (resource.getType() == IResource.FILE) {
258             if ("java".equals(resource.getFileExtension())) { //$NON-NLS-1$
259
ICompilationUnit cu= JavaCore.createCompilationUnitFrom((IFile) resource);
260                 if (cu != null) {
261                     IPath packPath= resource.getParent().getFullPath();
262                     IPackageDeclaration[] decls= cu.getPackageDeclarations();
263                     if (decls.length == 0) {
264                         sourceFolders.add(packPath);
265                     } else {
266                         IPath relpath= new Path(decls[0].getElementName().replace('.', '/'));
267                         int remainingSegments= packPath.segmentCount() - relpath.segmentCount();
268                         if (remainingSegments >= 0) {
269                             IPath prefix= packPath.uptoSegment(remainingSegments);
270                             IPath common= packPath.removeFirstSegments(remainingSegments);
271                             if (common.equals(relpath)) {
272                                 sourceFolders.add(prefix);
273                             }
274                         }
275                     }
276                 }
277             }
278         }
279         return true;
280     }
281
282     
283     /**
284      * Called from the wizard on cancel.
285      */

286     public void performCancel() {
287         if (fProjectCreated) {
288             try {
289                 fMainPage.getProjectHandle().delete(false, false, null);
290             } catch (CoreException e) {
291                 JavaPlugin.log(e);
292             }
293         }
294     }
295     
296     
297     /**
298      * Initializes the page with the project and default classpaths.
299      * <p>
300      * The default classpath entries must correspond the the given project.
301      * </p>
302      * <p>
303      * The caller of this method is responsible for creating the underlying project. The page will create the output,
304      * source and library folders if required.
305      * </p>
306      * <p>
307      * The project does not have to exist at the time of initialization, but must exist when executing the runnable
308      * obtained by <code>getRunnable()</code>.
309      * </p>
310      * @param project The Java project.
311      * @param entries The default classpath entries or <code>null</code> to let the page choose the default
312      * @param path The folder to be taken as the default output path or <code>null</code> to let the page choose the default
313      * @return overrideExistingClasspath If set to <code>true</code>, an existing '.classpath' file is ignored. If set to <code>false</code>
314      * the given default classpath and output location is only used if no '.classpath' exists.
315      */

316     public void init(IJavaProject jproject, IPath defaultOutputLocation, IClasspathEntry[] defaultEntries, boolean defaultsOverrideExistingClasspath) {
317         super.init(jproject, defaultOutputLocation, defaultEntries, defaultsOverrideExistingClasspath);
318     }
319     
320     public IClasspathEntry[] createMyClasspaths() {
321
322     final int jarFileElements = 29;
323         IClasspathEntry[] classpaths = getRawClassPath();
324         // Removed entry[0] - default source directory (Project root) make problems due project rebuild
325
// vl
326
// IClasspathEntry[] myClasspaths = new IClasspathEntry[classpaths.length + 21 - 1];
327
IClasspathEntry[] myClasspaths = new IClasspathEntry[classpaths.length + jarFileElements - 1]; // vl
328

329         for(int i = 1; i < classpaths.length; i++) {
330             myClasspaths[i-1] = classpaths[i];
331         }
332
333         
334         String JavaDoc enh_home = ToolBoxInfo.getEnhydraRoot();
335         String JavaDoc java_home = System.getProperty("java.home");
336
337         int i = classpaths.length - 1;
338         myClasspaths[i] = new ClasspathEntry(IPackageFragmentRoot.K_SOURCE,
339             ClasspathEntry.CPE_LIBRARY, new Path(enh_home + "/lib/log4j.jar"), null, null, false);
340         
341         i++;
342         myClasspaths[i] = new ClasspathEntry(IPackageFragmentRoot.K_SOURCE,
343             ClasspathEntry.CPE_LIBRARY, new Path(java_home+"/../lib/tools.jar"), null, null, false);
344
345         i++;
346         myClasspaths[i] = new ClasspathEntry(IPackageFragmentRoot.K_SOURCE,
347             ClasspathEntry.CPE_LIBRARY, new Path(enh_home + "/lib/admin.jar"), null, null, false);
348
349         i++;
350         myClasspaths[i] = new ClasspathEntry(IPackageFragmentRoot.K_SOURCE,
351             ClasspathEntry.CPE_LIBRARY, new Path(enh_home + "/lib/core.jar"), null, null, false);
352
353         i++;
354         myClasspaths[i] = new ClasspathEntry(IPackageFragmentRoot.K_SOURCE,
355             ClasspathEntry.CPE_LIBRARY, new Path(enh_home + "/lib/util.jar"), null, null, false);
356
357         i++;
358         myClasspaths[i] = new ClasspathEntry(IPackageFragmentRoot.K_SOURCE,
359             ClasspathEntry.CPE_LIBRARY, new Path(enh_home + "/dods/lib/dbmanager.jar"), null, null, false);
360         
361         i++;
362         myClasspaths[i] = new ClasspathEntry(IPackageFragmentRoot.K_SOURCE,
363             ClasspathEntry.CPE_LIBRARY, new Path(enh_home + "/dods/lib/dbmanager-api.jar"), null, null, false);
364         i++;
365         myClasspaths[i] = new ClasspathEntry(IPackageFragmentRoot.K_SOURCE,
366             ClasspathEntry.CPE_LIBRARY, new Path(enh_home + "/dods/lib/dsconnection.jar"), null, null, false);
367         i++;
368         myClasspaths[i] = new ClasspathEntry(IPackageFragmentRoot.K_SOURCE,
369             ClasspathEntry.CPE_LIBRARY, new Path(enh_home + "/dods/lib/stdcaches.jar"), null, null, false);
370         i++;
371         myClasspaths[i] = new ClasspathEntry(IPackageFragmentRoot.K_SOURCE,
372             ClasspathEntry.CPE_LIBRARY, new Path(enh_home + "/dods/lib/stdconnection.jar"), null, null, false);
373         i++;
374         myClasspaths[i] = new ClasspathEntry(IPackageFragmentRoot.K_SOURCE,
375             ClasspathEntry.CPE_LIBRARY, new Path(enh_home + "/dods/lib/stdtransaction.jar"), null, null, false);
376         i++;
377         myClasspaths[i] = new ClasspathEntry(IPackageFragmentRoot.K_SOURCE,
378             ClasspathEntry.CPE_LIBRARY, new Path(enh_home + "/lib/enhydra.jar"), null, null, false);
379
380         i++;
381         myClasspaths[i] = new ClasspathEntry(IPackageFragmentRoot.K_SOURCE,
382             ClasspathEntry.CPE_LIBRARY, new Path(enh_home + "/lib/gnu-regexp.jar"), null, null, false);
383
384         i++;
385         myClasspaths[i] = new ClasspathEntry(IPackageFragmentRoot.K_SOURCE,
386             ClasspathEntry.CPE_LIBRARY, new Path(enh_home + "/lib/jtidy.jar"), null, null, false);
387
388         i++;
389         myClasspaths[i] = new ClasspathEntry(IPackageFragmentRoot.K_SOURCE,
390             ClasspathEntry.CPE_LIBRARY, new Path(enh_home + "/lib/servlet.jar"), null, null, false);
391
392         i++;
393         myClasspaths[i] = new ClasspathEntry(IPackageFragmentRoot.K_SOURCE,
394             ClasspathEntry.CPE_LIBRARY, new Path(enh_home + "/lib/snoop.jar"), null, null, false);
395
396         i++;
397         myClasspaths[i] = new ClasspathEntry(IPackageFragmentRoot.K_SOURCE,
398             ClasspathEntry.CPE_LIBRARY, new Path(enh_home + "/lib/tomcat.jar"), null, null, false);
399 /* vl 19.07.03
400         i++;
401         myClasspaths[i] = new ClasspathEntry(IPackageFragmentRoot.K_SOURCE,
402             ClasspathEntry.CPE_LIBRARY, new Path(enh_home + "/lib/wireless.jar"), null, null, false);
403 */

404         i++;
405         myClasspaths[i] = new ClasspathEntry(IPackageFragmentRoot.K_SOURCE,
406             ClasspathEntry.CPE_LIBRARY, new Path(enh_home + "/lib/dom/xmlc-chtml.jar"), null, null, false);
407
408         i++;
409         myClasspaths[i] = new ClasspathEntry(IPackageFragmentRoot.K_SOURCE,
410             ClasspathEntry.CPE_LIBRARY, new Path(enh_home + "/lib/dom/xmlc-voicexml.jar"), null, null, false);
411
412         i++;
413         myClasspaths[i] = new ClasspathEntry(IPackageFragmentRoot.K_SOURCE,
414             ClasspathEntry.CPE_LIBRARY, new Path(enh_home + "/lib/dom/xmlc-wml.jar"), null, null, false);
415 // vl 19.07.03
416

417         i++;
418 // myClasspaths[i] = new ClasspathEntry(IPackageFragmentRoot.K_SOURCE,
419
// vl 20.07.03
420
// ClasspathEntry.CPE_LIBRARY, new Path(enh_home + "/lib/xerces.jar"), null, null, false);
421
myClasspaths[i] = new ClasspathEntry(IPackageFragmentRoot.K_SOURCE,
422         ClasspathEntry.CPE_LIBRARY, new Path(enh_home + "/lib/xercesImpl.jar"), null, null, false);
423
424         i++;
425         myClasspaths[i] = new ClasspathEntry(IPackageFragmentRoot.K_SOURCE,
426         ClasspathEntry.CPE_LIBRARY, new Path(enh_home + "/lib/xml-apis.jar"), null, null, false);
427         
428         i++;
429         myClasspaths[i] = new ClasspathEntry(IPackageFragmentRoot.K_SOURCE,
430         ClasspathEntry.CPE_LIBRARY, new Path(enh_home + "/lib/dom3-xml-apis.jar"), null, null, false);
431 // vl 20.07.03
432

433 /* vl 19.07.03
434         i++;
435         myClasspaths[i] = new ClasspathEntry(IPackageFragmentRoot.K_SOURCE,
436             ClasspathEntry.CPE_LIBRARY, new Path(enh_home + "/lib/xhtml.jar"), null, null, false);
437 */

438         i++;
439         myClasspaths[i] = new ClasspathEntry(IPackageFragmentRoot.K_SOURCE,
440             ClasspathEntry.CPE_LIBRARY, new Path(enh_home + "/lib/xhtml.jar"), null, null, false);
441 // vl 19.07.03
442

443         i++;
444         myClasspaths[i] = new ClasspathEntry(IPackageFragmentRoot.K_SOURCE,
445             ClasspathEntry.CPE_LIBRARY, new Path(enh_home + "/lib/xmlc.jar"), null, null, false);
446
447         i++;
448         myClasspaths[i] = new ClasspathEntry(IPackageFragmentRoot.K_SOURCE,
449             ClasspathEntry.CPE_LIBRARY, new Path(enh_home + "/lib/tools/SunClasses/xmlcSupport.jar"), null, null, false);
450
451         //SV i++;
452
//SV myClasspaths[i] = new ClasspathEntry(IPackageFragmentRoot.K_SOURCE,
453
//SVClasspathEntry.CPE_LIBRARY, new Path(enh_home + "/lib/tools/Xalan/xalan.jar"), null, null, false);
454

455         i++;
456         myClasspaths[i] = new ClasspathEntry(IPackageFragmentRoot.K_SOURCE,
457             ClasspathEntry.CPE_LIBRARY, new Path(enh_home + "/lib/build/toolbox.jar"), null, null, false);
458
459         i++;
460         myClasspaths[i] = new ClasspathEntry(IPackageFragmentRoot.K_SOURCE,
461             ClasspathEntry.CPE_LIBRARY, new Path(enh_home + "/dods/lib/dods.jar"), null, null, false);
462             
463         i++;
464         myClasspaths[i] = new ClasspathEntry(IPackageFragmentRoot.K_SOURCE,
465             ClasspathEntry.CPE_LIBRARY, new Path(enh_home + "/dods/lib/ejen.jar"), null, null, false);
466
467  
468         return myClasspaths;
469         
470     }
471     
472     
473     private IClasspathEntry[] createSourceDirectories() {
474         final HashSet JavaDoc sourceFolders = new HashSet JavaDoc();
475         IClasspathEntry[] entries = null;
476         IPath outputLocation = null;
477         IProject project = fMainPage.getProjectHandle();
478         IPath projPath = project.getFullPath();
479                 
480         if (!sourceFolders.isEmpty()) {
481             int nSourceFolders = sourceFolders.size();
482             IClasspathEntry[] jreEntries = NewJavaProjectPreferencePage.getDefaultJRELibrary();
483             entries = new IClasspathEntry[nSourceFolders + jreEntries.length];
484             Iterator JavaDoc iter = sourceFolders.iterator();
485             for (int i = 0; i < nSourceFolders; i++) {
486                 entries[i] = JavaCore.newSourceEntry((IPath) iter.next());
487             }
488             System.arraycopy(jreEntries, 0, entries, nSourceFolders, jreEntries.length);
489             
490             
491             if (nSourceFolders == 1 && entries[0].getPath().equals(projPath)) {
492                 outputLocation = projPath;
493             } else {
494                 outputLocation = projPath.append(NewJavaProjectPreferencePage.getOutputLocationName());
495             }
496             if (!JavaConventions.validateClasspath(JavaCore.create(project), entries, outputLocation).isOK()) {
497                 outputLocation= null;
498                 entries= null;
499             }
500             
501         } else {
502             entries = new IClasspathEntry[0];
503         }
504
505         String JavaDoc projDirName = projPath.segment(projPath.segmentCount() - 1);
506         IClasspathEntry[] myEntries = new IClasspathEntry[entries.length + 3];
507         myEntries[entries.length] = JavaCore.newSourceEntry((IPath) new Path("/" + projDirName + "/src"));
508         myEntries[entries.length + 1] = JavaCore.newSourceEntry((IPath) new Path("/" + projDirName + "/xmlc_generated_src"));
509         myEntries[entries.length + 2] = JavaCore.newSourceEntry((IPath) new Path("/" + projDirName + "/dods_generated_src"));
510
511         return myEntries;
512     }
513     
514     private IClasspathEntry[] joinEntries(IClasspathEntry[] a, IClasspathEntry[] b) {
515         
516         IClasspathEntry[] result;
517         try {
518             result = new IClasspathEntry[a.length + b.length];
519             for(int i = 0; i < a.length; i++) {
520                 result[i] = a[i];
521             }
522             for(int i = a.length; i < a.length + b.length; i++) {
523                 result[i] = b[i - a.length];
524             }
525         } catch (NullPointerException JavaDoc e) {
526             if(a == null) {
527                 if(b == null) return null;
528                 else return b;
529             } else {
530                 if(b == null) return null;
531                 else return a;
532             }
533         }
534
535         return result;
536     }
537     
538
539 }
540
Popular Tags