KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > wizards > buildpaths > BuildPathWizard


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.ui.wizards.buildpaths;
12
13 import java.util.ArrayList JavaDoc;
14 import java.util.Arrays JavaDoc;
15 import java.util.List JavaDoc;
16
17 import org.eclipse.core.runtime.CoreException;
18 import org.eclipse.core.runtime.IPath;
19 import org.eclipse.core.runtime.IProgressMonitor;
20
21 import org.eclipse.core.resources.IProject;
22 import org.eclipse.core.resources.IResource;
23
24 import org.eclipse.jface.resource.ImageDescriptor;
25
26 import org.eclipse.jdt.core.IJavaElement;
27 import org.eclipse.jdt.core.IJavaProject;
28 import org.eclipse.jdt.core.IPackageFragmentRoot;
29
30 import org.eclipse.jdt.internal.ui.JavaPlugin;
31 import org.eclipse.jdt.internal.ui.wizards.NewElementWizard;
32
33 public abstract class BuildPathWizard extends NewElementWizard {
34     
35     private boolean fDoFlushChange;
36     private final CPListElement fEntryToEdit;
37     private IPackageFragmentRoot fPackageFragmentRoot;
38     private IPath fOutputLocation;
39     private final ArrayList JavaDoc fExistingEntries;
40
41     public BuildPathWizard(CPListElement[] existingEntries, CPListElement newEntry, IPath outputLocation, String JavaDoc titel, ImageDescriptor image) {
42         fOutputLocation= outputLocation;
43         if (image != null)
44             setDefaultPageImageDescriptor(image);
45         
46         setDialogSettings(JavaPlugin.getDefault().getDialogSettings());
47         setWindowTitle(titel);
48
49         fEntryToEdit= newEntry;
50         fExistingEntries= new ArrayList JavaDoc(Arrays.asList(existingEntries));
51         fDoFlushChange= true;
52     }
53     
54     /**
55      * {@inheritDoc}
56      */

57     protected void finishPage(IProgressMonitor monitor) throws InterruptedException JavaDoc, CoreException {
58         if (fDoFlushChange) {
59             IJavaProject javaProject= getEntryToEdit().getJavaProject();
60             
61             BuildPathsBlock.flush(getExistingEntries(), getOutputLocation(), javaProject, monitor);
62             
63             IProject project= javaProject.getProject();
64             IPath path= getEntryToEdit().getPath();
65             
66             IResource folder= project.getWorkspace().getRoot().findMember(path);
67             fPackageFragmentRoot= javaProject.getPackageFragmentRoot(folder);
68         }
69     }
70
71     /**
72      * {@inheritDoc}
73      */

74     public IJavaElement getCreatedElement() {
75         return fPackageFragmentRoot;
76     }
77     
78     public void setDoFlushChange(boolean b) {
79         fDoFlushChange= b;
80     }
81     
82     public ArrayList JavaDoc getExistingEntries() {
83         return fExistingEntries;
84     }
85
86     public IPath getOutputLocation() {
87         return fOutputLocation;
88     }
89     
90     protected void setOutputLocation(IPath outputLocation) {
91         fOutputLocation= outputLocation;
92     }
93
94     protected CPListElement getEntryToEdit() {
95         return fEntryToEdit;
96     }
97
98     public List JavaDoc/*<CPListElement>*/ getInsertedElements() {
99         return new ArrayList JavaDoc();
100     }
101
102     public List JavaDoc/*<CPListElement>*/ getRemovedElements() {
103         return new ArrayList JavaDoc();
104     }
105
106     public List JavaDoc/*<CPListElement>*/ getModifiedElements() {
107         ArrayList JavaDoc result= new ArrayList JavaDoc(1);
108         result.add(fEntryToEdit);
109         return result;
110     }
111     
112     public abstract void cancel();
113
114 }
115
Popular Tags