KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > omg > lifl > eclipse > plugin > project > OpenCCM > ProjectCreationWizardPage


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2003 USTL - LIFL - GOAL
5 Contact: openccm-team@objectweb.org
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA
21
22 Initial developer(s): offroy ________________________.
23 Contributor(s): ______________________________________.
24
25 ====================================================================*/

26 /*
27  * Created on 23 mai 2003 by jerome OFFROY (offroy@lifl.fr)
28  *
29  */

30
31 package org.omg.lifl.eclipse.plugin.project.OpenCCM;
32
33 import org.eclipse.core.resources.IResource;
34 import org.eclipse.core.resources.IWorkspace;
35 import org.eclipse.core.resources.ResourcesPlugin;
36 import org.eclipse.core.runtime.IConfigurationElement;
37 import org.eclipse.core.runtime.IStatus;
38 import org.eclipse.core.runtime.Status;
39 import org.eclipse.jface.dialogs.DialogPage;
40 import org.eclipse.jface.wizard.WizardPage;
41 import org.eclipse.swt.SWT;
42 import org.eclipse.swt.layout.RowLayout;
43 import org.eclipse.swt.widgets.Composite;
44 import org.eclipse.swt.widgets.DirectoryDialog;
45 import org.omg.lifl.eclipse.plugin.project.OpenCCM.utils.CVSsrcFSChooser;
46 import org.omg.lifl.eclipse.plugin.project.OpenCCM.utils.EclipseConfigChooser;
47 import org.omg.lifl.eclipse.plugin.project.OpenCCM.utils.OpenCCMConfigChooser;
48 import org.omg.lifl.eclipse.plugin.project.OpenCCM.utils.ProjectMessages;
49 import org.omg.lifl.eclipse.plugin.project.OpenCCM.utils.ValidatorProject;
50 import org.omg.lifl.eclipse.plugin.project.utils.AttributeManager;
51
52 /**
53  * @author LIFL
54  *
55  */

56 public class ProjectCreationWizardPage
57     extends WizardPage
58     implements ValidatorProject {
59
60     private DirectoryDialog fd1;
61     private IStatus fCurrStatus;
62     private boolean fPageVisible;
63     private AttributeManager attributeManager;
64     
65     private ProjectChooser projectChooser;
66     private CVSsrcFSChooser cvsFSchooser;
67     private OpenCCMConfigChooser openccmConfigChooser;
68     private EclipseConfigChooser eclipseConfigChooser;
69     
70     /**
71      * @param pageNumber
72      * @param elem
73      */

74     public ProjectCreationWizardPage(
75         int pageNumber,
76         IConfigurationElement elem) {
77         super("page" + pageNumber);
78         fCurrStatus = createStatus(IStatus.OK, "");
79         attributeManager = new AttributeManager(elem);
80
81         setTitle(attributeManager.getAttribute("pagetitle"));
82         setDescription(attributeManager.getAttribute("pagedescription"));
83
84         projectChooser = new ProjectChooser(elem);
85         cvsFSchooser = new CVSsrcFSChooser(elem);
86         openccmConfigChooser = new OpenCCMConfigChooser(elem);
87         eclipseConfigChooser = new EclipseConfigChooser(elem);
88
89     }
90
91     /**
92      * @param severity
93      * @param message
94      */

95     private static IStatus createStatus(int severity, String JavaDoc message) {
96         return new Status(
97             severity,
98             MainPlugin.getPluginId(),
99             severity,
100             message,
101             null);
102
103     }
104
105     /* (non-Javadoc)
106      * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
107      */

108     public void createControl(Composite parent) {
109         Composite composite = new Composite(parent, SWT.NONE);
110         RowLayout gd2 = new RowLayout(SWT.VERTICAL);
111         composite.setLayout(gd2);
112         
113         // Group to choose the name of the new project
114
projectChooser.viewToSetOpenCCMProjectName(composite,this);
115         
116         // Group to choose the directory to import in the new project
117
cvsFSchooser.viewToSetCVSsrcFS(composite);
118         
119         // Group to choose the directory of installed ORB
120
openccmConfigChooser.viewToSetCCMConfig(composite);
121         
122         // Group to choose Eclipse WorkBench specific Options
123
eclipseConfigChooser.viewToSetEclipseConfig(composite);
124         
125         setControl(composite);
126     }
127
128     /**
129      * @param string
130      */

131     public void validateTextProjectName(String JavaDoc text) {
132         IWorkspace workspace = ResourcesPlugin.getWorkspace();
133         IStatus status = workspace.validateName(text, IResource.PROJECT);
134         if (status.isOK()) {
135             if (workspace.getRoot().getProject(text).exists()) {
136                 status =
137                     createStatus(
138                         IStatus.ERROR,
139                         ProjectMessages.getString(
140                             "ProjectCreationWizardPage.error.alreadyexists"));
141             }
142         }
143         updateStatus(status);
144
145         projectChooser.set_ProjectName(text);
146         
147     }
148
149     /**
150      * Updates the status line and the ok button depending on the status
151      * @param status
152      */

153     private void updateStatus(IStatus status) {
154         fCurrStatus = status;
155         setPageComplete(!status.matches(IStatus.ERROR));
156         if (fPageVisible) {
157             applyToStatusLine(this, status);
158         }
159     }
160
161     /**
162      * Applies the status to a dialog page
163      * @param page
164      * @param status
165      */

166     private static void applyToStatusLine(DialogPage page, IStatus status) {
167         String JavaDoc errorMessage = null;
168         String JavaDoc warningMessage = null;
169         String JavaDoc statusMessage = status.getMessage();
170         if (statusMessage.length() > 0) {
171             if (status.matches(IStatus.ERROR)) {
172                 errorMessage = statusMessage;
173             } else if (!status.isOK()) {
174                 warningMessage = statusMessage;
175             }
176         }
177         page.setErrorMessage(errorMessage);
178         page.setMessage(warningMessage);
179     }
180
181     /*
182      * @see WizardPage#becomesVisible
183      */

184     public void setVisible(boolean visible) {
185         super.setVisible(visible);
186         fPageVisible = visible;
187         // policy: wizards are not allowed to come up with an error message
188
if (visible && fCurrStatus.matches(IStatus.ERROR)) {
189             // keep the error state, but remove the message
190
fCurrStatus = createStatus(IStatus.ERROR, "");
191         }
192         updateStatus(fCurrStatus);
193     }
194
195     /**
196      * Returns the name entered by the user
197      */

198     public String JavaDoc getName() {
199         return projectChooser.get_ProjectName();
200     }
201
202     /**
203      * @return
204      */

205     public CVSsrcFSChooser getCvsFSchooser() {
206         return cvsFSchooser;
207     }
208
209     /**
210      * @param chooser
211      */

212     public void setCvsFSchooser(CVSsrcFSChooser chooser) {
213         cvsFSchooser = chooser;
214     }
215
216     /**
217      * @return
218      */

219     public OpenCCMConfigChooser getOpenccmConfigChooser() {
220         return openccmConfigChooser;
221     }
222
223     /**
224      * @param chooser
225      */

226     public void setOpenccmConfigChooser(OpenCCMConfigChooser chooser) {
227         openccmConfigChooser = chooser;
228     }
229
230     /**
231      * @return
232      */

233     public AttributeManager getAttributeManager() {
234         return attributeManager;
235     }
236
237     /**
238      * @param manager
239      */

240     public void setAttributeManager(AttributeManager manager) {
241         attributeManager = manager;
242     }
243
244     /**
245      * @return
246      */

247     public ProjectChooser getProjectChooser() {
248         return projectChooser;
249     }
250
251     /**
252      * @param chooser
253      */

254     public void setProjectChooser(ProjectChooser chooser) {
255         projectChooser = chooser;
256     }
257
258     /**
259      * @return
260      */

261     public EclipseConfigChooser getEclipseConfigChooser() {
262         return eclipseConfigChooser;
263     }
264
265     /**
266      * @param chooser
267      */

268     public void setEclipseConfigChooser(EclipseConfigChooser chooser) {
269         eclipseConfigChooser = chooser;
270     }
271
272 }
273
Popular Tags