01: package com.salmonllc.ideTools.eclipse;
02:
03: import org.eclipse.core.resources.IProject;
04: import org.eclipse.core.resources.IWorkspaceRoot;
05: import org.eclipse.core.resources.ResourcesPlugin;
06: import org.eclipse.ui.dialogs.WizardNewProjectCreationPage;
07:
08: public class SalmonWizardNewProjectCreationPage extends
09: WizardNewProjectCreationPage {
10:
11: String _descriptionMessage;
12:
13: public SalmonWizardNewProjectCreationPage(String pageName,
14: String projectName, String descriptionMessage) {
15: super (pageName);
16: _descriptionMessage = descriptionMessage;
17: setDescription(_descriptionMessage);
18: setInitialProjectName(projectName);
19:
20: if (projectExists(projectName)) {
21: setDescription("Project already exists in the workspace, Please choose another name.");
22: setPageComplete(false);
23: } else
24: setPageComplete(true);
25: }
26:
27: public void setPageComplete(boolean complete) {
28: super .setPageComplete(complete);
29: if (complete)
30: setDescription(_descriptionMessage);
31: }
32:
33: protected boolean projectExists(String projectName) {
34: IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
35: IProject[] p = root.getProjects();
36: try {
37: for (int i = 0; i < p.length; i++) {
38: if (p[i].getName().equals(projectName))
39: return true;
40: }
41: } catch (Exception e) {
42: }
43: return false;
44: }
45:
46: }
|