private boolean isProjectNameAlreadyUsed(String newProjectName) { IProxyRepositoryFactory repositoryFactory = ProxyRepositoryFactory.getInstance(); if (projects == null) { try { projects = repositoryFactory.readProject(); } catch (Exception e) { return true; } } for (Project project : projects) { if (Project.createTechnicalName(newProjectName).compareTo(project.getTechnicalLabel()) == 0) { return true; } } return false; }
/** DOC ocarbone Comment method "checkField". */ protected void checkFieldsValue() { // Field Name if (nameText.getText().length() == 0) { nameStatus = new Status( IStatus.ERROR, RepositoryPlugin.PLUGIN_ID, IStatus.OK, Messages.getString("NewProjectWizardPage.nameEmpty"), null); //$NON-NLS-1$ } else { // for bug 11214 if (!nameText.getText().endsWith(" ")) { // $NON-NLS-1$ technicalNameText.setText(Project.createTechnicalName(nameText.getText())); } if (ProjectUtils.isNotValidProjectName(nameText.getText())) { // $NON-NLS-1$ nameStatus = new Status( IStatus.ERROR, RepositoryPlugin.PLUGIN_ID, IStatus.OK, Messages.getString("NewProjectWizardPage.illegalCharacter"), null); //$NON-NLS-1$ } else { if (isProjectNameAlreadyUsed(nameText.getText())) { nameStatus = new Status( IStatus.ERROR, RepositoryPlugin.PLUGIN_ID, IStatus.OK, Messages.getString("NewProjectWizardPage.projectNameAlredyExists"), null); //$NON-NLS-1$ } else { nameStatus = createOkStatus(); // Field description descriptionStatus = createOkStatus(); // Combo language if (!languageJavaRadio.getSelection() && !languagePerlRadio.getSelection()) { languageStatus = new Status( IStatus.ERROR, RepositoryPlugin.PLUGIN_ID, IStatus.OK, Messages.getString("NewProjectWizardPage.languageEmpty"), // $NON-NLS-1$ null); } else if (!languageEnable(getLanguage())) { languageStatus = new Status( IStatus.ERROR, RepositoryPlugin.PLUGIN_ID, IStatus.WARNING, Messages.getString( "NewProjectWizard.error.languageNotSupported", getLanguage()), //$NON-NLS-1$ null); } else { languageStatus = createOkStatus(); } } } } updatePageStatus(); }