Java Code Examples for org.eclipse.jdt.internal.ui.dialogs.StatusInfo#setError()

The following examples show how to use org.eclipse.jdt.internal.ui.dialogs.StatusInfo#setError() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TypeFilterInputDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void doValidation() {
	StatusInfo status= new StatusInfo();
	String newText= fNameDialogField.getText();
	if (newText.length() == 0) {
		status.setError(PreferencesMessages.TypeFilterInputDialog_error_enterName);
	} else {
		newText= newText.replace('*', 'X').replace('?', 'Y');
		IStatus val= JavaConventions.validatePackageName(newText, JavaCore.VERSION_1_3, JavaCore.VERSION_1_3);
		if (val.matches(IStatus.ERROR)) {
			status.setError(Messages.format(PreferencesMessages.TypeFilterInputDialog_error_invalidName, val.getMessage()));
		} else {
			if (fExistingEntries.contains(newText)) {
				status.setError(PreferencesMessages.TypeFilterInputDialog_error_entryExists);
			}
		}
	}
	updateStatus(status);
}
 
Example 2
Source File: NewEntryPointWizardPage.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
private IStatus moduleChanged() {
  StatusInfo status = new StatusInfo();
  module = null;

  moduleField.enableButton(getPackageFragmentRoot() != null
      && getPackageFragmentRoot().exists()
      && JavaProjectUtilities.isJavaProjectNonNullAndExists(getJavaProject())
      && GWTNature.isGWTProject(getJavaProject().getProject()));

  IStatus fieldStatus = moduleField.getStatus();
  if (!fieldStatus.isOK()) {
    status.setError(fieldStatus.getMessage());
    return status;
  }

  // TODO: verify that package is in client source path of module

  module = moduleField.getModule();
  return status;
}
 
Example 3
Source File: NewUiBinderWizardPage.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected IStatus typeNameChanged() {
  IStatus ownerClassNameStatus = super.typeNameChanged();
  if (ownerClassNameStatus.getSeverity() == IStatus.ERROR) {
    return ownerClassNameStatus;
  }

  StatusInfo uiXmlNameStatus = new StatusInfo();
  IPath uiXmlFilePath = getUiXmlFilePath();
  if (uiXmlFilePath != null) {
    // Make sure there's not already a ui.xml file with the same name
    if (ResourcesPlugin.getWorkspace().getRoot().exists(uiXmlFilePath)) {
      uiXmlNameStatus.setError(MessageFormat.format("{0} already exists.",
          uiXmlFilePath.lastSegment()));
    }
  } else {
    // Don't need to worry about this case since the ui.xml path should only
    // be null if the package fragment is invalid, in which case that error
    // will supersede ours.
  }

  return StatusUtil.getMostSevere(new IStatus[] {
      ownerClassNameStatus, uiXmlNameStatus});
}
 
Example 4
Source File: NewHostPageWizardPage.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
@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;
    }
  }
}
 
Example 5
Source File: SpellingConfigurationBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Validates that the file with the specified absolute path exists and can
 * be opened.
 *
 * @param path
 *                   The path of the file to validate
 * @return a status without error if the path is valid
 */
protected static IStatus validateAbsoluteFilePath(String path) {

	final StatusInfo status= new StatusInfo();
	IStringVariableManager variableManager= VariablesPlugin.getDefault().getStringVariableManager();
	try {
		path= variableManager.performStringSubstitution(path);
		if (path.length() > 0) {

			final File file= new File(path);
			if (!file.exists() && (!file.isAbsolute() || !file.getParentFile().canWrite()))
				status.setError(PreferencesMessages.SpellingPreferencePage_dictionary_error);
			else if (file.exists() && (!file.isFile() || !file.isAbsolute() || !file.canRead() || !file.canWrite()))
				status.setError(PreferencesMessages.SpellingPreferencePage_dictionary_error);
		}
	} catch (CoreException e) {
		status.setError(e.getLocalizedMessage());
	}
	return status;
}
 
Example 6
Source File: NewXtxtUMLFileWizardPage.java    From txtUML with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected IStatus typeNameChanged() {
	StatusInfo status = (StatusInfo) super.typeNameChanged();
	String message = status.getMessage();

	if (message != null && message.equals(NewWizardMessages.NewTypeWizardPage_error_EnterTypeName)) {
		status.setError("Filename is empty.");
	}

	if (getPackageFragment() != null && getTypeName() != null) {
		IFolder folder = (IFolder) getPackageFragment().getResource();
		IFile file = folder.getFile(getTypeName() + getSelectedExtension());
		if (file.exists()) {
			status.setError("File already exists.");
		}
	}

	return status;
}
 
Example 7
Source File: JavadocConfigurationBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private IStatus updateURLStatus() {
	StatusInfo status= new StatusInfo();
	fURLResult= null;
	try {
		String jdocLocation= fURLField.getText();
		if (jdocLocation.length() == 0) {
			return status;
		}
		URL url= new URL(jdocLocation);
		if ("file".equals(url.getProtocol())) { //$NON-NLS-1$
			if (url.getFile() == null) {
				status.setError(PreferencesMessages.JavadocConfigurationBlock_error_notafolder);
				return status;
			}
		}
		fURLResult= url;
	} catch (MalformedURLException e) {
		status.setError(PreferencesMessages.JavadocConfigurationBlock_MalformedURL_error);
		return status;
	}

	return status;
}
 
Example 8
Source File: NewTypeWizardPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Hook method that gets called when the list of super interface has changed. The method
 * validates the super interfaces and returns the status of the validation.
 * <p>
 * Subclasses may extend this method to perform their own validation.
 * </p>
 *
 * @return the status of the validation
 */
protected IStatus superInterfacesChanged() {
	StatusInfo status= new StatusInfo();

	IPackageFragmentRoot root= getPackageFragmentRoot();
	fSuperInterfacesDialogField.enableButton(0, root != null);

	if (root != null) {
		List<InterfaceWrapper> elements= fSuperInterfacesDialogField.getElements();
		int nElements= elements.size();
		for (int i= 0; i < nElements; i++) {
			String intfname= elements.get(i).interfaceName;
			Type type= TypeContextChecker.parseSuperInterface(intfname);
			if (type == null) {
				status.setError(Messages.format(NewWizardMessages.NewTypeWizardPage_error_InvalidSuperInterfaceName, BasicElementLabels.getJavaElementName(intfname)));
				return status;
			}
			if (type instanceof ParameterizedType && ! JavaModelUtil.is50OrHigher(root.getJavaProject())) {
				status.setError(Messages.format(NewWizardMessages.NewTypeWizardPage_error_SuperInterfaceNotParameterized, BasicElementLabels.getJavaElementName(intfname)));
				return status;
			}
		}
	}
	return status;
}
 
Example 9
Source File: CodeAssistFavoritesConfigurationBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void doValidation() {
	StatusInfo status= new StatusInfo();
	String newText= fNameDialogField.getText();
	if (newText.length() == 0) {
		status.setError(""); //$NON-NLS-1$
	} else {
		IStatus val= JavaConventions.validateJavaTypeName(newText, JavaCore.VERSION_1_3, JavaCore.VERSION_1_3);
		if (val.matches(IStatus.ERROR)) {
			if (fIsEditingMember)
				status.setError(PreferencesMessages.FavoriteStaticMemberInputDialog_error_invalidMemberName);
			else
				status.setError(PreferencesMessages.FavoriteStaticMemberInputDialog_error_invalidTypeName);
		} else {
			if (doesExist(newText)) {
				status.setError(PreferencesMessages.FavoriteStaticMemberInputDialog_error_entryExists);
			}
		}
	}
	updateStatus(status);
}
 
Example 10
Source File: LapseConfigurationDialog.java    From lapse-plus with GNU General Public License v3.0 5 votes vote down vote up
private void validateInput() {
    StatusInfo status = new StatusInfo();
    if (!isIntValid(fMaxCallDepth.getText())) {
        status.setError("Invalid input: expecting a number between 1 and 99");
    }
    if (!isIntValid(fMaxCallers.getText())) {
        status.setError("Invalid input: expecting a number between 1 and 99");
    }
    updateStatus(status);
}
 
Example 11
Source File: VariablePathDialogField.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public void selectionChanged(SelectionChangedEvent event) {
	List<CPVariableElement> elements= fVariableBlock.getSelectedElements();
	StatusInfo status= new StatusInfo();
	if (elements.size() != 1) {
		status.setError(""); //$NON-NLS-1$
	}
	updateStatus(status);
}
 
Example 12
Source File: NewElementWizardPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void setVisible(boolean visible) {
	super.setVisible(visible);
	fPageVisible= visible;
	// policy: wizards are not allowed to come up with an error message
	if (visible && fCurrStatus.matches(IStatus.ERROR)) {
		StatusInfo status= new StatusInfo();
		status.setError("");  //$NON-NLS-1$
		fCurrStatus= status;
	}
	updateStatus(fCurrStatus);
}
 
Example 13
Source File: JavadocConfigurationBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private IStatus updateArchivePathStatus() {
	// no validation yet
	try {
		fArchiveURLResult= getArchiveURL();
	} catch (MalformedURLException e) {
		fArchiveURLResult= null;
		StatusInfo status= new StatusInfo();
		status.setError(e.getMessage());
		//status.setError(PreferencesMessages.getString("JavadocConfigurationBlock.MalformedURL.error"));  //$NON-NLS-1$
		return status;
	}
	return new StatusInfo();

}
 
Example 14
Source File: ComplianceConfigurationBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private IStatus validateCompliance() {
	StatusInfo status= new StatusInfo();
	String compliance= getValue(PREF_COMPLIANCE);
	String source= getValue(PREF_SOURCE_COMPATIBILITY);
	String target= getValue(PREF_CODEGEN_TARGET_PLATFORM);
	
	if (ComplianceConfigurationBlock.VERSION_JSR14.equals(target)) {
		target= source;
	}

	// compliance must not be smaller than source or target
	if (JavaModelUtil.isVersionLessThan(compliance, source)) {
		status.setError(PreferencesMessages.ComplianceConfigurationBlock_src_greater_compliance);
		return status;
	}

	if (JavaModelUtil.isVersionLessThan(compliance, target)) {
		status.setError(PreferencesMessages.ComplianceConfigurationBlock_classfile_greater_compliance);
		return status;
	}

	if (VERSION_CLDC_1_1.equals(target)) {
		if (!VERSION_1_3.equals(source) || !JavaModelUtil.isVersionLessThan(compliance, VERSION_1_5)) {
			status.setError(PreferencesMessages.ComplianceConfigurationBlock_cldc11_requires_source13_compliance_se14);
			return status;
		}
	}

	// target must not be smaller than source
	if (!VERSION_1_3.equals(source) && JavaModelUtil.isVersionLessThan(target, source)) {
		status.setError(PreferencesMessages.ComplianceConfigurationBlock_classfile_greater_source);
		return status;
	}

	return status;
}
 
Example 15
Source File: VariableCreationDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private StatusInfo pathUpdated() {
	StatusInfo status= new StatusInfo();

	String path= fPathField.getText();
	if (path.length() > 0) { // empty path is ok
		if (!Path.ROOT.isValidPath(path)) {
			status.setError(NewWizardMessages.VariableCreationDialog_error_invalidpath);
		} else if (!new File(path).exists()) {
			status.setWarning(NewWizardMessages.VariableCreationDialog_warning_pathnotexists);
		}
	}
	return status;
}
 
Example 16
Source File: ImportOrganizeConfigurationBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private boolean doThresholdChanged(String thresholdString) {
	StatusInfo status= new StatusInfo();
	try {
		int threshold= Integer.parseInt(thresholdString);
		if (threshold < 0) {
			status.setError(PreferencesMessages.ImportOrganizeConfigurationBlock_error_invalidthreshold);
		}
	} catch (NumberFormatException e) {
		status.setError(PreferencesMessages.ImportOrganizeConfigurationBlock_error_invalidthreshold);
	}
	updateStatus(status);
	return status.isOK();
}
 
Example 17
Source File: NewCheckCatalogWizardPage.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Validate grammar.
 * 
 * @return the status (ERROR or OK)
 */
private IStatus validateGrammarAccess() {
  StatusInfo status = new StatusInfo();
  if (getGrammar() == null || (getGrammar().getName().length() == 0)) {
    status.setError(Messages.CHOOSE_GRAMMAR_ID);
  }
  // update Check ProjectInfo
  if (status.isOK()) {
    projectInfo.setGrammar(getGrammar());
  }
  return status;
}
 
Example 18
Source File: NewTypeWizardPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * A hook method that gets called when the package field has changed. The method
 * validates the package name and returns the status of the validation. The validation
 * also updates the package fragment model.
 * <p>
 * Subclasses may extend this method to perform their own validation.
 * </p>
 *
 * @return the status of the validation
 */
protected IStatus packageChanged() {
	StatusInfo status= new StatusInfo();
	IPackageFragmentRoot root= getPackageFragmentRoot();
	fPackageDialogField.enableButton(root != null);

	IJavaProject project= root != null ? root.getJavaProject() : null;

	String packName= getPackageText();
	if (packName.length() > 0) {
		IStatus val= validatePackageName(packName, project);
		if (val.getSeverity() == IStatus.ERROR) {
			status.setError(Messages.format(NewWizardMessages.NewTypeWizardPage_error_InvalidPackageName, val.getMessage()));
			return status;
		} else if (val.getSeverity() == IStatus.WARNING) {
			status.setWarning(Messages.format(NewWizardMessages.NewTypeWizardPage_warning_DiscouragedPackageName, val.getMessage()));
			// continue
		}
	} else {
		status.setWarning(NewWizardMessages.NewTypeWizardPage_warning_DefaultPackageDiscouraged);
	}

	if (project != null) {
		if (project.exists() && packName.length() > 0) {
			try {
				IPath rootPath= root.getPath();
				IPath outputPath= project.getOutputLocation();
				if (rootPath.isPrefixOf(outputPath) && !rootPath.equals(outputPath)) {
					// if the bin folder is inside of our root, don't allow to name a package
					// like the bin folder
					IPath packagePath= rootPath.append(packName.replace('.', '/'));
					if (outputPath.isPrefixOf(packagePath)) {
						status.setError(NewWizardMessages.NewTypeWizardPage_error_ClashOutputLocation);
						return status;
					}
				}
			} catch (JavaModelException e) {
				JavaPlugin.log(e);
				// let pass
			}
		}

		fCurrPackage= root.getPackageFragment(packName);
		IResource resource= fCurrPackage.getResource();
		if (resource != null){
			if (resource.isVirtual()){
				status.setError(NewWizardMessages.NewTypeWizardPage_error_PackageIsVirtual);
				return status;
			}
			if (!ResourcesPlugin.getWorkspace().validateFiltered(resource).isOK()) {
				status.setError(NewWizardMessages.NewTypeWizardPage_error_PackageNameFiltered);
				return status;
			}
		}
	} else {
		status.setError(""); //$NON-NLS-1$
	}
	return status;
}
 
Example 19
Source File: AddSourceFolderWizardPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
private static StatusInfo validatePathName(String str, IContainer parent) {
	StatusInfo result= new StatusInfo();
	result.setOK();

	IPath parentPath= parent.getFullPath();

	if (str.length() == 0) {
		result.setError(Messages.format(NewWizardMessages.NewSourceFolderWizardPage_error_EnterRootName, BasicElementLabels.getPathLabel(parentPath, false)));
		return result;
	}

	IPath path= parentPath.append(str);

	IWorkspaceRoot workspaceRoot= ResourcesPlugin.getWorkspace().getRoot();
	IStatus validate= workspaceRoot.getWorkspace().validatePath(path.toString(), IResource.FOLDER);
	if (validate.matches(IStatus.ERROR)) {
		result.setError(Messages.format(NewWizardMessages.NewSourceFolderWizardPage_error_InvalidRootName, validate.getMessage()));
		return result;
	}

	IResource res= workspaceRoot.findMember(path);
	if (res != null) {
		if (res.getType() != IResource.FOLDER) {
			result.setError(NewWizardMessages.NewSourceFolderWizardPage_error_NotAFolder);
			return result;
		}
	} else {

		URI parentLocation= parent.getLocationURI();
		if (parentLocation != null) {
			try {
				IFileStore store= EFS.getStore(parentLocation).getChild(str);
				if (store.fetchInfo().exists()) {
					result.setError(NewWizardMessages.NewSourceFolderWizardPage_error_AlreadyExistingDifferentCase);
					return result;
				}
			} catch (CoreException e) {
				// we couldn't create the file store. Ignore the exception
				// since we can't check if the file exist. Pretend that it
				// doesn't.
			}
		}
	}

	return result;
}
 
Example 20
Source File: NewTypeWizardPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 3 votes vote down vote up
/**
 * Hook method that gets called when the modifiers have changed. The method validates
 * the modifiers and returns the status of the validation.
 * <p>
 * Subclasses may extend this method to perform their own validation.
 * </p>
 *
 * @return the status of the validation
 */
protected IStatus modifiersChanged() {
	StatusInfo status= new StatusInfo();
	int modifiers= getModifiers();
	if (Flags.isFinal(modifiers) && Flags.isAbstract(modifiers)) {
		status.setError(NewWizardMessages.NewTypeWizardPage_error_ModifiersFinalAndAbstract);
	}
	return status;
}