/** * Creates the textfield for the project name. * * @param parent The parent composite. */ private void createProjectNameField(Composite parent) { Composite leftComposite = createComposite(parent, NUM_COLUMNS_1, GridData.BEGINNING, false); Composite rightComposite = createComposite(parent, NUM_COLUMNS_1, GridData.FILL, true); createLabel(leftComposite, Messages.ProjectPropertyPageProjectName); m_projectNameTextField = new CheckedProjectNameText(rightComposite, SWT.BORDER); m_projectNameTextField.setText(getProject().getName()); GridData textGridData = new GridData(); textGridData.grabExcessHorizontalSpace = true; textGridData.horizontalAlignment = GridData.FILL; LayoutUtil.addToolTipAndMaxWidth(textGridData, m_projectNameTextField); m_projectNameTextField.setLayoutData(textGridData); LayoutUtil.setMaxChar(m_projectNameTextField); }
/** * The action of the project name field. * * @param isProjectNameVerified True, if the project name was verified. * @return false, if the project name field contents an error: the project name starts or end with * a blank, or the field is empty */ boolean modifyProjectNameFieldAction(boolean isProjectNameVerified) { boolean isCorrect = true; String projectName = m_projectNameTextField.getText(); int projectNameLength = projectName.length(); super.getShell().setText(Messages.ProjectPropertyPageShellTitle + projectName); if ((projectNameLength == 0) || (projectName.startsWith(StringConstants.SPACE)) || (projectName.charAt(projectNameLength - 1) == ' ')) { isCorrect = false; } if (isCorrect) { setErrorMessage(null); setMessage(Messages.PropertiesActionPage1, NONE); setValid(true); if (isProjectNameVerified) { m_newProjectName = projectName; } if (ProjectPM.doesProjectNameExist(projectName) && !m_oldProjectName.equals(projectName)) { setErrorMessage(Messages.ProjectSettingWizardPageDoubleProjectName); isCorrect = false; setValid(false); } } else { if (projectNameLength == 0) { setErrorMessage(Messages.ProjectWizardEmptyProject); setValid(false); } else { setErrorMessage(Messages.ProjectWizardNotValidProject); setValid(false); } } return isCorrect; }
/** Adds necessary listeners. */ private void addListener() { m_projectNameTextField.addModifyListener(m_modifyListener); m_projectToolkitCombo.addSelectionListener(m_toolkitComboListener); }