下面列出了org.eclipse.ui.ide.IDEEncoding#org.eclipse.jdt.internal.ui.dialogs.StatusInfo 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@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();
}
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;
}
@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});
}
@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;
}
}
}
@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;
}
@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;
}
/**
* 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;
}
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) }));
}
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;
}
/**
* 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();
}
@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;
}
/** 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));
}
}
}
/**
* 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;
}
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));
}
}
}
@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);
}
}
}
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();
}
/** 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);
}
}
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);
}
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;
}
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();
}
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;
}
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);
}
@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());
}
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;
}
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;
}
@Override
protected void validateSettings(Key changedKey, String oldValue, String newValue) {
if (!areSettingsEnabled()) {
return;
}
fContext.statusChanged(new StatusInfo());
}
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);
}
/**
* 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();
}
/**
* 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();
}
public ModuleSelectionDialogButtonField(WizardPage page,
IDialogFieldListener changeListener) {
super();
this.page = page;
this.browseButtonEnabled = true;
setDialogFieldListener(changeListener);
setContentAssistProcessor(new ModuleCompletionProcessor());
status = new StatusInfo();
}