KickJava   Java API By Example, From Geeks To Geeks.

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


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.List JavaDoc;
14
15 import org.eclipse.core.runtime.IPath;
16
17 import org.eclipse.core.resources.IContainer;
18
19 import org.eclipse.jdt.internal.ui.JavaPluginImages;
20 import org.eclipse.jdt.internal.ui.wizards.NewWizardMessages;
21
22 public class AddSourceFolderWizard extends BuildPathWizard {
23     
24     private AddSourceFolderWizardPage fAddFolderPage;
25     private SetFilterWizardPage fFilterPage;
26     private final boolean fLinkedMode;
27     private boolean fAllowConflict;
28     private final boolean fAllowRemoveProjectFolder;
29     private final boolean fAllowAddExclusionPatterns;
30     private final boolean fCanCommitConflict;
31     private final IContainer fParent;
32     
33     public AddSourceFolderWizard(CPListElement[] existingEntries, CPListElement newEntry, IPath outputLocation,
34             boolean linkedMode, boolean canCommitConflict,
35             boolean allowConflict, boolean allowRemoveProjectFolder, boolean allowAddExclusionPatterns) {
36         this(existingEntries, newEntry, outputLocation, linkedMode, canCommitConflict, allowConflict, allowRemoveProjectFolder, allowAddExclusionPatterns, newEntry.getJavaProject().getProject());
37     }
38     
39     public AddSourceFolderWizard(CPListElement[] existingEntries, CPListElement newEntry, IPath outputLocation,
40             boolean linkedMode, boolean canCommitConflict,
41             boolean allowConflict, boolean allowRemoveProjectFolder, boolean allowAddExclusionPatterns, IContainer parent) {
42         super(existingEntries, newEntry, outputLocation, getTitel(newEntry, linkedMode), JavaPluginImages.DESC_WIZBAN_NEWSRCFOLDR);
43         fLinkedMode= linkedMode;
44         fCanCommitConflict= canCommitConflict;
45         fAllowConflict= allowConflict;
46         fAllowRemoveProjectFolder= allowRemoveProjectFolder;
47         fAllowAddExclusionPatterns= allowAddExclusionPatterns;
48         fParent= parent;
49     }
50
51     private static String JavaDoc getTitel(CPListElement newEntry, boolean linkedMode) {
52         if (newEntry.getPath() == null) {
53             if (linkedMode) {
54                 return NewWizardMessages.NewSourceFolderCreationWizard_link_title;
55             } else {
56                 return NewWizardMessages.NewSourceFolderCreationWizard_title;
57             }
58         } else {
59             return NewWizardMessages.NewSourceFolderCreationWizard_edit_title;
60         }
61     }
62
63     /**
64      * {@inheritDoc}
65      */

66     public void addPages() {
67         super.addPages();
68     
69         fAddFolderPage= new AddSourceFolderWizardPage(getEntryToEdit(), getExistingEntries(), getOutputLocation(),
70                 fLinkedMode, fCanCommitConflict,
71                 fAllowConflict, fAllowRemoveProjectFolder, fAllowAddExclusionPatterns, fParent);
72         addPage(fAddFolderPage);
73         
74         fFilterPage= new SetFilterWizardPage(getEntryToEdit(), getExistingEntries(), getOutputLocation());
75         addPage(fFilterPage);
76     }
77     
78     /**
79      * {@inheritDoc}
80      */

81     public List JavaDoc getInsertedElements() {
82         List JavaDoc result= super.getInsertedElements();
83         if (getEntryToEdit().getOrginalPath() == null)
84             result.add(getEntryToEdit());
85         
86         return result;
87     }
88
89     /**
90      * {@inheritDoc}
91      */

92     public List JavaDoc getRemovedElements() {
93         return fAddFolderPage.getRemovedElements();
94     }
95     
96     /**
97      * {@inheritDoc}
98      */

99     public List JavaDoc getModifiedElements() {
100         return fAddFolderPage.getModifiedElements();
101     }
102     
103     /**
104      * {@inheritDoc}
105      */

106     public boolean performFinish() {
107         getEntryToEdit().setAttribute(CPListElement.INCLUSION, fFilterPage.getInclusionPattern());
108         getEntryToEdit().setAttribute(CPListElement.EXCLUSION, fFilterPage.getExclusionPattern());
109         setOutputLocation(fAddFolderPage.getOutputLocation());
110         
111         boolean res= super.performFinish();
112         if (res) {
113             selectAndReveal(fAddFolderPage.getCorrespondingResource());
114         }
115         return res;
116     }
117     
118     public void cancel() {
119         fAddFolderPage.restore();
120     }
121 }
122
Popular Tags