public void validatePage() { StatusInfo si = new StatusInfo(StatusInfo.OK, ""); if (patternText != null) { String patternName = patternText.getText(); if (patternName == null || patternName.length() == 0) { if (parameterSet) { si.setError(PATTERN_NAME_MUST_BE_SPECIFIED); } else { si.setWarning(PATTERN_NAME_SHOULD_BE_SPECIFIED); } } } if (si.getSeverity() == IStatus.OK) { si.setInfo(""); } updateStatus(si); if (si.isError()) { setErrorMessage(si.getMessage()); } }
protected void checkIfPatternValid() { String pattern = fExclusionPatternDialog.getText().trim(); if (pattern.length() == 0) { fExclusionPatternStatus.setError(NewWizardMessages.ExclusionInclusionEntryDialog_error_empty); return; } IPath path = new Path(pattern); if (path.isAbsolute() || path.getDevice() != null) { fExclusionPatternStatus.setError( NewWizardMessages.ExclusionInclusionEntryDialog_error_notrelative); return; } if (fExistingPatterns.contains(pattern)) { fExclusionPatternStatus.setError( NewWizardMessages.ExclusionInclusionEntryDialog_error_exists); return; } fExclusionPattern = pattern; fExclusionPatternStatus.setOK(); }
@Override public void setVisible(boolean visible) { super.setVisible(visible); pageVisible = visible; // Wizards are not allowed to start up with an error message if (visible) { setFocus(); if (pageStatus.matches(IStatus.ERROR)) { StatusInfo status = new StatusInfo(); status.setError(""); pageStatus = status; } } }
/** * This method is a hook which gets called after the source folder's text input field has changed. * This default implementation updates the model and returns an error status. The underlying model * is only valid if the returned status is OK. * * @return the model's error status */ protected IStatus containerChanged() { StatusInfo status = new StatusInfo(); fCurrRoot = null; String str = getPackageFragmentRootText(); if (str.length() == 0) { status.setError(NewWizardMessages.NewContainerWizardPage_error_EnterContainerName); return status; } IPath path = new Path(str); IResource res = fWorkspaceRoot.findMember(path); if (res != null) { int resType = res.getType(); if (resType == IResource.PROJECT || resType == IResource.FOLDER) { IProject proj = res.getProject(); if (!proj.isOpen()) { status.setError( Messages.format( NewWizardMessages.NewContainerWizardPage_error_ProjectClosed, BasicElementLabels.getPathLabel(proj.getFullPath(), false))); return status; } IJavaProject jproject = JavaCore.create(proj); fCurrRoot = jproject.getPackageFragmentRoot(res); if (res.exists()) { if (res.isVirtual()) { status.setError(NewWizardMessages.NewContainerWizardPage_error_FolderIsVirtual); return status; } try { if (!proj.hasNature(JavaCore.NATURE_ID)) { if (resType == IResource.PROJECT) { status.setError(NewWizardMessages.NewContainerWizardPage_warning_NotAJavaProject); } else { status.setWarning( NewWizardMessages.NewContainerWizardPage_warning_NotInAJavaProject); } return status; } if (fCurrRoot.isArchive()) { status.setError( Messages.format( NewWizardMessages.NewContainerWizardPage_error_ContainerIsBinary, BasicElementLabels.getPathLabel(path, false))); return status; } if (fCurrRoot.getKind() == IPackageFragmentRoot.K_BINARY) { status.setWarning( Messages.format( NewWizardMessages.NewContainerWizardPage_warning_inside_classfolder, BasicElementLabels.getPathLabel(path, false))); } else if (!jproject.isOnClasspath(fCurrRoot)) { status.setWarning( Messages.format( NewWizardMessages.NewContainerWizardPage_warning_NotOnClassPath, BasicElementLabels.getPathLabel(path, false))); } } catch (JavaModelException e) { status.setWarning(NewWizardMessages.NewContainerWizardPage_warning_NotOnClassPath); } catch (CoreException e) { status.setWarning(NewWizardMessages.NewContainerWizardPage_warning_NotAJavaProject); } } return status; } else { status.setError( Messages.format( NewWizardMessages.NewContainerWizardPage_error_NotAFolder, BasicElementLabels.getPathLabel(path, false))); return status; } } else { status.setError( Messages.format( NewWizardMessages.NewContainerWizardPage_error_ContainerDoesNotExist, BasicElementLabels.getPathLabel(path, false))); return status; } }