Java Code Examples for org.eclipse.jdt.internal.ui.dialogs.StatusInfo

The following examples show how to use org.eclipse.jdt.internal.ui.dialogs.StatusInfo. These examples are extracted from open source projects. 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
@Override
protected IStatus typeNameChanged() {
	IPackageFragment packageFragment = getPackageFragment();
	if (packageFragment != null) {
		IResource resource = packageFragment.getResource();
		if (resource instanceof IFolder) {
			IFolder folder = (IFolder) resource;
			if (folder.getFile(getTypeName() + ".xtend").exists()) { //$NON-NLS-1$
				String packageName = ""; //$NON-NLS-1$
				if (!packageFragment.isDefaultPackage()) {
					packageName = packageFragment.getElementName() + "."; //$NON-NLS-1$
				}
				return new StatusInfo(IStatus.ERROR, Messages.TYPE_EXISTS_0 + packageName + getTypeName()
						+ Messages.TYPE_EXISTS_1);
			}
		}
	}
	return super.typeNameChanged();
}
 
Example 2
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
@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
@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
@Override
protected IStatus typeNameChanged() {
	StatusInfo status = (StatusInfo) super.typeNameChanged();
	String message = status.getMessage();

	if (message != null) {
		if (message.startsWith(Messages.format(NewWizardMessages.NewTypeWizardPage_warning_TypeNameDiscouraged, ""))
				|| message.equals(NewWizardMessages.NewTypeWizardPage_error_TypeNameExists)) {
			status.setOK();
		} else if (message
				.startsWith(Messages.format(NewWizardMessages.NewTypeWizardPage_error_InvalidTypeName, ""))
				|| message.equals(NewWizardMessages.NewTypeWizardPage_error_QualifiedName)) {
			status.setError(message.replace("Type name", "Name").replace("Java type name", "name")
					.replace("type name", "name"));
			// errors about *type* names would be confusing here
		}
	}

	return status;
}
 
Example 6
Source Project: txtUML   Source File: NewXtxtUMLFileWizardPage.java    License: 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
/**
 * Validates that the specified number is positive.
 *
 * @param number the number to validate
 * @return The status of the validation
 */
protected static IStatus validatePositiveNumber(final String number) {
	final StatusInfo status= new StatusInfo();
	if (number.length() == 0) {
		status.setError(PreferencesMessages.SpellingPreferencePage_empty_threshold);
	} else {
		try {
			final int value= Integer.parseInt(number);
			if (value < 0) {
				status.setError(Messages.format(PreferencesMessages.SpellingPreferencePage_invalid_threshold, number));
			}
		} catch (NumberFormatException exception) {
			status.setError(Messages.format(PreferencesMessages.SpellingPreferencePage_invalid_threshold, number));
		}
	}
	return status;
}
 
Example 8
public IStatus validate(Object[] selection) {
	int selectedCount= 0;
	int duplicateCount= 0;
	if (selection != null && selection.length > 0) {

		HashSet<String> signatures= new HashSet<String>(selection.length);
		for (int index= 0; index < selection.length; index++) {
			if (selection[index] instanceof DelegateEntry) {
				DelegateEntry delegateEntry= (DelegateEntry) selection[index];
				if (!signatures.add(getSignature(delegateEntry.delegateMethod)))
					duplicateCount++;
				selectedCount++;
			}
		}
	}
	if (duplicateCount > 0) {
		return new StatusInfo(IStatus.ERROR, duplicateCount == 1
				? ActionMessages.AddDelegateMethodsAction_duplicate_methods_singular
				: Messages.format(ActionMessages.AddDelegateMethodsAction_duplicate_methods_plural, String.valueOf(duplicateCount)));
	}
	return new StatusInfo(IStatus.INFO, Messages.format(ActionMessages.AddDelegateMethodsAction_selectioninfo_more, new Object[] { String.valueOf(selectedCount), String.valueOf(fEntries) }));
}
 
Example 9
private StatusInfo nameUpdated() {
	StatusInfo status= new StatusInfo();
	String name= fNameField.getText();
	if (name.length() == 0) {
		status.setError(NewWizardMessages.VariableCreationDialog_error_entername);
		return status;
	}
	if (name.trim().length() != name.length()) {
		status.setError(NewWizardMessages.VariableCreationDialog_error_whitespace);
	} else if (!Path.ROOT.isValidSegment(name)) {
		status.setError(NewWizardMessages.VariableCreationDialog_error_invalidname);
	} else if (nameConflict(name)) {
		status.setError(NewWizardMessages.VariableCreationDialog_error_nameexists);
	}
	return status;
}
 
Example 10
/**
 * Creates a new <code>NewPackageWizardPage</code>
 */
public NewPackageWizardPage() {
	super(PAGE_NAME);

	setTitle(NewWizardMessages.NewPackageWizardPage_title);
	setDescription(NewWizardMessages.NewPackageWizardPage_description);

	fCreatedPackageFragment= null;

	PackageFieldAdapter adapter= new PackageFieldAdapter();

	fPackageDialogField= new StringDialogField();
	fPackageDialogField.setDialogFieldListener(adapter);
	fPackageDialogField.setLabelText(NewWizardMessages.NewPackageWizardPage_package_label);

	fCreatePackageInfoJavaDialogField= new SelectionButtonDialogField(SWT.CHECK);
	fCreatePackageInfoJavaDialogField.setDialogFieldListener(adapter);
	fCreatePackageInfoJavaDialogField.setLabelText(NewWizardMessages.NewPackageWizardPage_package_CreatePackageInfoJava);

	fPackageStatus= new StatusInfo();
}
 
Example 11
@Override
protected IStatus containerChanged() {
	IStatus status= super.containerChanged();
    IPackageFragmentRoot root= getPackageFragmentRoot();
	if ((fTypeKind == ANNOTATION_TYPE || fTypeKind == ENUM_TYPE) && !status.matches(IStatus.ERROR)) {
    	if (root != null && !JavaModelUtil.is50OrHigher(root.getJavaProject())) {
    		// error as createType will fail otherwise (bug 96928)
			return new StatusInfo(IStatus.ERROR, Messages.format(NewWizardMessages.NewTypeWizardPage_warning_NotJDKCompliant, BasicElementLabels.getJavaElementName(root.getJavaProject().getElementName())));
    	}
    	if (fTypeKind == ENUM_TYPE) {
	    	try {
	    	    // if findType(...) == null then Enum is unavailable
	    	    if (findType(root.getJavaProject(), "java.lang.Enum") == null) //$NON-NLS-1$
	    	        return new StatusInfo(IStatus.WARNING, NewWizardMessages.NewTypeWizardPage_warning_EnumClassNotFound);
	    	} catch (JavaModelException e) {
	    	    JavaPlugin.log(e);
	    	}
    	}
    }

	fCurrPackageCompletionProcessor.setPackageFragmentRoot(root);
	if (root != null) {
		fEnclosingTypeCompletionProcessor.setPackageFragment(root.getPackageFragment("")); //$NON-NLS-1$
	}
	return status;
}
 
Example 12
Source Project: sarl   Source File: AbstractSuperTypeSelectionDialog.java    License: Apache License 2.0 6 votes vote down vote up
/** Adds selected interfaces to the list.
 */
private void fillWizardPageWithSelectedTypes() {
	final StructuredSelection selection = getSelectedItems();
	if (selection == null) {
		return;
	}
	for (final Iterator<?> iter = selection.iterator(); iter.hasNext();) {
		final Object obj = iter.next();
		if (obj instanceof TypeNameMatch) {
			accessedHistoryItem(obj);
			final TypeNameMatch type = (TypeNameMatch) obj;
			final String qualifiedName = Utilities.getNameWithTypeParameters(type.getType());
			final String message;

			if (addTypeToWizardPage(this.typeWizardPage, qualifiedName)) {
				message = MessageFormat.format(Messages.AbstractSuperTypeSelectionDialog_2,
						TextProcessor.process(qualifiedName, JAVA_ELEMENT_DELIMITERS));
			} else {
				message = MessageFormat.format(Messages.AbstractSuperTypeSelectionDialog_3,
						TextProcessor.process(qualifiedName, JAVA_ELEMENT_DELIMITERS));
			}
			updateStatus(new StatusInfo(IStatus.INFO, message));
		}
	}
}
 
Example 13
/**
 * Validates that the specified number is positive.
 *
 * @param number
 *                   The number to validate
 * @return The status of the validation
 */
protected static IStatus validatePositiveNumber(final String number) {

	final StatusInfo status= new StatusInfo();
	if (number.length() == 0) {
		status.setError(PreferencesMessages.SpellingPreferencePage_empty_threshold);
	} else {
		try {
			final int value= Integer.parseInt(number);
			if (value < 0) {
				status.setError(Messages.format(PreferencesMessages.SpellingPreferencePage_invalid_threshold, number));
			}
		} catch (NumberFormatException exception) {
			status.setError(Messages.format(PreferencesMessages.SpellingPreferencePage_invalid_threshold, number));
		}
	}
	return status;
}
 
Example 14
private void addSelectedInterfaces() {
	StructuredSelection selection= getSelectedItems();
	if (selection == null)
		return;
	for (Iterator<?> iter= selection.iterator(); iter.hasNext();) {
		Object obj= iter.next();
		if (obj instanceof TypeNameMatch) {
			accessedHistoryItem(obj);
			TypeNameMatch type= (TypeNameMatch) obj;
			String qualifiedName= getNameWithTypeParameters(type.getType());
			String message;

			if (fTypeWizardPage.addSuperInterface(qualifiedName)) {
				message= Messages.format(NewWizardMessages.SuperInterfaceSelectionDialog_interfaceadded_info, BasicElementLabels.getJavaElementName(qualifiedName));
			} else {
				message= Messages.format(NewWizardMessages.SuperInterfaceSelectionDialog_interfacealreadyadded_info, BasicElementLabels.getJavaElementName(qualifiedName));
			}
			updateStatus(new StatusInfo(IStatus.INFO, message));
		}
	}
}
 
Example 15
@Override
public void updateStatus(IStatus status) {
	int count= 0;
	for (int i= 0; i < fPages.length; i++) {
		count+= fPages[i].getSelectedCleanUpCount();
	}
	if (count == 0) {
		super.updateStatus(new Status(IStatus.ERROR, JavaUI.ID_PLUGIN, getEmptySelectionMessage()));
	} else {
		if (status == null) {
			super.updateStatus(StatusInfo.OK_STATUS);
		} else {
			super.updateStatus(status);
		}
	}
}
 
Example 16
public IStatus validate(Object[] selection) {
	int nSelected= selection.length;
	if (nSelected == 0 || (nSelected > 1 && !fMultiSelect)) {
		return new StatusInfo(IStatus.ERROR, "");  //$NON-NLS-1$
	}
	for (int i= 0; i < selection.length; i++) {
		Object curr= selection[i];
		if (curr instanceof File) {
			File file= (File) curr;
			if (!fAcceptFolders && !file.isFile()) {
				return new StatusInfo(IStatus.ERROR, "");  //$NON-NLS-1$
			}
		}
	}
	return new StatusInfo();
}
 
Example 17
Source Project: sarl   Source File: BuildSettingWizardPage.java    License: Apache License 2.0 6 votes vote down vote up
/** Update the status of this page according to the given exception.
 *
 * @param event the exception.
 */
private void updateStatus(Throwable event) {
	Throwable cause = event;
	while (cause != null
			&& (!(cause instanceof CoreException))
			&& cause.getCause() != null
			&& cause.getCause() != cause) {
		cause = cause.getCause();
	}
	if (cause instanceof CoreException) {
		updateStatus(((CoreException) cause).getStatus());
	} else {
		final String message;
		if (cause != null) {
			message = cause.getLocalizedMessage();
		} else {
			message = event.getLocalizedMessage();
		}
		final IStatus status = new StatusInfo(IStatus.ERROR, message);
		updateStatus(status);
	}
}
 
Example 18
private void validatePath() {
	StatusInfo status= new StatusInfo();
	String str= fEntryField.getText();
	if (str.length() == 0) {
		status.setError(NewWizardMessages.ClasspathContainerDefaultPage_path_error_enterpath);
	} else if (!Path.ROOT.isValidPath(str)) {
		status.setError(NewWizardMessages.ClasspathContainerDefaultPage_path_error_invalidpath);
	} else {
		IPath path= new Path(str);
		if (path.segmentCount() == 0) {
			status.setError(NewWizardMessages.ClasspathContainerDefaultPage_path_error_needssegment);
		} else if (fUsedPaths.contains(path)) {
			status.setError(NewWizardMessages.ClasspathContainerDefaultPage_path_error_alreadyexists);
		}
	}
	updateStatus(status);
}
 
Example 19
private IStatus updateShownLibraries(IStatus status) {
	if (!status.isOK()) {
		fExportImportList.removeAllElements();
		fExportImportList.setEnabled(false);
		fLastFile= null;
	} else {
		File file= new File(fLocationField.getText());
		if (!file.equals(fLastFile)) {
			fLastFile= file;
			try {
				List<CPUserLibraryElement> elements= loadLibraries(file);
				fExportImportList.setElements(elements);
				fExportImportList.checkAll(true);
				fExportImportList.setEnabled(true);
				if (elements.isEmpty()) {
					return new StatusInfo(IStatus.ERROR, PreferencesMessages.UserLibraryPreferencePage_LoadSaveDialog_error_empty);
				}
			} catch (IOException e) {
				fExportImportList.removeAllElements();
				fExportImportList.setEnabled(false);
				return new StatusInfo(IStatus.ERROR, PreferencesMessages.UserLibraryPreferencePage_LoadSaveDialog_error_invalidfile);
			}
		}
	}
	return status;
}
 
Example 20
private IStatus validateIdentifiers(String[] values, boolean prefix) {
	for (int i= 0; i < values.length; i++) {
		String val= values[i];
		if (val.length() == 0) {
			if (prefix) {
				return new StatusInfo(IStatus.ERROR, PreferencesMessages.NameConventionConfigurationBlock_error_emptyprefix);
			} else {
				return new StatusInfo(IStatus.ERROR, PreferencesMessages.NameConventionConfigurationBlock_error_emptysuffix);
			}
		}
		String name= prefix ? val + "x" : "x" + val; //$NON-NLS-2$ //$NON-NLS-1$
		IStatus status= JavaConventions.validateIdentifier(name, JavaCore.VERSION_1_3, JavaCore.VERSION_1_3);
		if (status.matches(IStatus.ERROR)) {
			if (prefix) {
				return new StatusInfo(IStatus.ERROR, Messages.format(PreferencesMessages.NameConventionConfigurationBlock_error_invalidprefix, val));
			} else {
				return new StatusInfo(IStatus.ERROR, Messages.format(PreferencesMessages.NameConventionConfigurationBlock_error_invalidsuffix, val));
			}
		}
	}
	return new StatusInfo();
}
 
Example 21
private IStatus validateSettings() {
	String name= fNameField.getText();
	if (name.length() == 0) {
		return new StatusInfo(IStatus.ERROR, PreferencesMessages.UserLibraryPreferencePage_LibraryNameDialog_name_error_entername);
	}
	for (int i= 0; i < fExistingLibraries.size(); i++) {
		CPUserLibraryElement curr= fExistingLibraries.get(i);
		if (curr != fElementToEdit && name.equals(curr.getName())) {
			return new StatusInfo(IStatus.ERROR, Messages.format(PreferencesMessages.UserLibraryPreferencePage_LibraryNameDialog_name_error_exists, name));
		}
	}
	IStatus status= ResourcesPlugin.getWorkspace().validateName(name, IResource.FILE);
	if (status.matches(IStatus.ERROR)) {
		return new StatusInfo(IStatus.ERROR, "Name contains invalid characters."); //$NON-NLS-1$
	}
	return StatusInfo.OK_STATUS;
}
 
Example 22
private void doValidate() {
  	String name= fProfileNameField.getText().trim();
if (name.equals(fProfile.getName()) && fProfile.hasEqualSettings(fWorkingValues, fWorkingValues.keySet())) {
	updateStatus(StatusInfo.OK_STATUS);
	return;
}

  	IStatus status= validateProfileName();
  	if (status.matches(IStatus.ERROR)) {
  		updateStatus(status);
  		return;
  	}

if (!name.equals(fProfile.getName()) && fProfileManager.containsName(name)) {
	updateStatus(new Status(IStatus.ERROR, JavaUI.ID_PLUGIN, FormatterMessages.ModifyDialog_Duplicate_Status));
	return;
}

if (fProfile.isBuiltInProfile() || fProfile.isSharedProfile()) {
	updateStatus(new Status(IStatus.INFO, JavaUI.ID_PLUGIN, FormatterMessages.ModifyDialog_NewCreated_Status));
	return;
}

   updateStatus(StatusInfo.OK_STATUS);
  }
 
Example 23
@Override
protected void validateSettings(Key changedKey, String oldValue, String newValue) {
	if (!areSettingsEnabled()) {
		return;
	}

	if (changedKey != null) {
		if (PREF_PB_INVALID_JAVADOC.equals(changedKey) ||
				PREF_PB_MISSING_JAVADOC_TAGS.equals(changedKey) ||
				PREF_PB_MISSING_JAVADOC_COMMENTS.equals(changedKey) ||
				PREF_JAVADOC_SUPPORT.equals(changedKey) ||
				PREF_PB_INVALID_JAVADOC_TAGS.equals(changedKey)) {
			updateEnableStates();
		} else {
			return;
		}
	} else {
		updateEnableStates();
	}
	fContext.statusChanged(new StatusInfo());
}
 
Example 24
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 25
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 26
@Override
protected void validateSettings(Key changedKey, String oldValue, String newValue) {
	if (!areSettingsEnabled()) {
		return;
	}
	fContext.statusChanged(new StatusInfo());
}
 
Example 27
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 28
/**
 * Constructor for NewCheckProjectWizardPage.
 * 
 * @param selection
 */
@Inject
public NewCheckProjectWizardPage() {
  super(NewTypeWizardPage.CLASS_TYPE, "NewCheckProjectWizardPage");
  setTitle(Messages.PROJECT_WIZARD_TITLE);
  setDescription(Messages.PROJECT_WIZARD_DESCRIPTION);
  projectName = new StringDialogField();
  projectNameStatus = new StatusInfo();
}
 
Example 29
/**
 * Instantiates a new new check catalog wizard page.
 */
@Inject
public NewCheckCatalogWizardPage() {
  super(NewTypeWizardPage.CLASS_TYPE, "NewCheckCatalogWizardPage");
  setTitle(Messages.CATALOG_WIZARD_TITLE);
  setDescription(Messages.CATALOG_WIZARD_DESCRIPTION);
  projectInfo = new CheckProjectInfo();
  grammarStatus = new StatusInfo();
}
 
Example 30
public ModuleSelectionDialogButtonField(WizardPage page,
    IDialogFieldListener changeListener) {
  super();
  this.page = page;
  this.browseButtonEnabled = true;
  setDialogFieldListener(changeListener);
  setContentAssistProcessor(new ModuleCompletionProcessor());

  status = new StatusInfo();
}