Java Code Examples for org.eclipse.core.runtime.IStatus#getSeverity()
The following examples show how to use
org.eclipse.core.runtime.IStatus#getSeverity() .
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: SpellingPreferenceBlock.java From xds-ide with Eclipse Public License 1.0 | 6 votes |
private void updateStatus() { if (statusMonitor != null) { IStatus status[] = new IStatus[] { fThresholdStatus, fFileStatus, fEncodingFieldEditorStatus }; IStatus max= null; for (int i= 0; i < status.length; i++) { IStatus curr= status[i]; if (curr.matches(IStatus.ERROR)) { max = curr; break; } if (max == null || curr.getSeverity() > max.getSeverity()) { max= curr; } } statusMonitor.statusChanged(max); } }
Example 2
Source File: NewNameQueries.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private static IInputValidator createCompilationUnitNameValidator(final ICompilationUnit cu) { IInputValidator validator= new IInputValidator(){ public String isValid(String newText) { if (newText == null || "".equals(newText)) //$NON-NLS-1$ return INVALID_NAME_NO_MESSAGE; String newCuName= JavaModelUtil.getRenamedCUName(cu, newText); IStatus status= JavaConventionsUtil.validateCompilationUnitName(newCuName, cu); if (status.getSeverity() == IStatus.ERROR) return status.getMessage(); RefactoringStatus refStatus; refStatus= Checks.checkCompilationUnitNewName(cu, newText); if (refStatus.hasFatalError()) return refStatus.getMessageMatchingSeverity(RefactoringStatus.FATAL); if (cu.getElementName().equalsIgnoreCase(newCuName)) return ReorgMessages.ReorgQueries_resourceExistsWithDifferentCaseMassage; return null; } }; return validator; }
Example 3
Source File: ExpressionViewer.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
protected void validateExternalDatabindingContextTargets(final DataBindingContext dbc) { if (dbc != null) { final IObservableList validationStatusProviders = dbc.getValidationStatusProviders(); final Iterator iterator = validationStatusProviders.iterator(); while (iterator.hasNext()) { final ValidationStatusProvider validationStatusProvider = (ValidationStatusProvider) iterator.next(); final IObservableValue validationStatus = validationStatusProvider.getValidationStatus(); if (!(validationStatus instanceof UnmodifiableObservableValue)) { final IStatus status = (IStatus) validationStatus.getValue(); if (status != null) { if (status.getSeverity() == IStatus.OK) { validationStatus.setValue(ValidationStatus.ok()); } else if (status.getSeverity() == IStatus.WARNING) { validationStatus.setValue(ValidationStatus.warning(status.getMessage())); } else if (status.getSeverity() == IStatus.INFO) { validationStatus.setValue(ValidationStatus.info(status.getMessage())); } else if (status.getSeverity() == IStatus.ERROR) { validationStatus.setValue(ValidationStatus.error(status.getMessage())); } else if (status.getSeverity() == IStatus.CANCEL) { validationStatus.setValue(ValidationStatus.cancel(status.getMessage())); } } } } } }
Example 4
Source File: ExternalLibrariesWizard.java From n4js with Eclipse Public License 1.0 | 5 votes |
@Override public boolean performFinish() { try { InstallOptions installOptions = new InstallOptions(); options.saveOptions(installOptions); RunnableInstallDependencies installDependnecies = installDependenciesRunnable.get(); installDependnecies.setInstallOptions(installOptions); getContainer().run(true, true, installDependnecies); IStatus resultStatus = installDependnecies.getResultStatus(); if (!resultStatus.isOK()) switch (resultStatus.getSeverity()) { case IStatus.ERROR: LOGGER.error(resultStatus.toString()); showErrorMessage(resultStatus); break; case IStatus.CANCEL: LOGGER.info(resultStatus.toString()); showWarnMessage(); break; case IStatus.WARNING: LOGGER.warn(resultStatus.toString()); break; case IStatus.INFO: LOGGER.info(resultStatus.toString()); break; case IStatus.OK: break; default: LOGGER.debug("Unhandled status " + resultStatus.getSeverity()); break; } } catch (Throwable throwable) { LOGGER.error("unhandled error while setting up dependencies", throwable); showErrorMessage(throwable); } return true; }
Example 5
Source File: TmDbManagerDialog.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
/** * 创建新库 ; */ private void createNewDatabase() { // 数据库连接参数输入合法性检查 IStatus status = validator(); if (status.getSeverity() != IStatus.OK) { MessageDialog.openInformation(getShell(), Messages.getString("dialog.TmDbManagerDialog.msgTitle"), status.getMessage()); return; } SystemDBOperator sysDbOp = getCurrSysDbOp(); if (sysDbOp == null) { return; } // 连接检查 if (!sysDbOp.checkDbConnection()) { MessageDialog.openInformation(getShell(), Messages.getString("dialog.TmDbManagerDialog.msgTitle"), Messages.getString("dialog.TmDbManagerDialog.msg1")); return; } DatabaseNameInputDialog inputDbNameialog = new DatabaseNameInputDialog(getShell(), Messages.getString("dialog.TmDbManagerDialog.inputDbNameialogTitle"), Messages.getString("dialog.TmDbManagerDialog.inputDbNameialogMsg"), "", new IInputValidator() { public String isValid(String newText) { String vRs = DbValidator.valiateDbName(newText); return vRs; } }); inputDbNameialog.setSystemDbOp(sysDbOp); if (inputDbNameialog.open() == Window.OK) { executeSearch(sysDbOp); // 刷新界面 } }
Example 6
Source File: DeployArtifactsHandler.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
private void openStatusDialog(Shell activeShell, IStatus status, RepositoryAccessor repositoryAccessor) { if (status instanceof MultiStatus) { if (status.getSeverity() == IStatus.ERROR || status.getSeverity() == IStatus.WARNING) { String[] buttonLabels = new String[] { IDialogConstants.CLOSE_LABEL }; List<ProcessValidationStatus> processValidationStatuses = new ArrayList<>(); findProcessValidationStaus(status, processValidationStatuses); if (!processValidationStatuses.isEmpty()) { buttonLabels = new String[] { org.bonitasoft.studio.ui.i18n.Messages.seeDetails, IDialogConstants.CLOSE_LABEL }; } MultiStatusDialog multiStatusDialog = new MultiStatusDialog(activeShell, Messages.deployStatus, errorMessageFromStatus(status), buttonLabels, (MultiStatus) status); multiStatusDialog.setLevel(IStatus.WARNING); if (multiStatusDialog.open() == MultiStatusDialog.SEE_DETAILS_ID) { openDiagrams(processValidationStatuses, repositoryAccessor); } } else { try { openSuccessDialog(activeShell, status); } catch (LoginException | BonitaHomeNotSetException | ServerAPIException | UnknownAPITypeException e) { BonitaStudioLog.error(e); new BonitaErrorDialog(activeShell, Messages.deployErrorTitle, e.getMessage(), e).open(); } } } else if (status.getSeverity() == IStatus.CANCEL) { MessageDialog.openInformation(activeShell, IDialogConstants.CANCEL_LABEL, status.getMessage()); } else { StatusManager.getManager().handle(status, StatusManager.SHOW); } }
Example 7
Source File: FlexWarStagingDelegateTest.java From google-cloud-eclipse with Apache License 2.0 | 5 votes |
private static String getStatusAsString(IStatus status) { String stringStatus = status.getSeverity() + ": " + status.getMessage(); if (status.getException() != null) { stringStatus += "\n==== start of IStatus exception stack trace ====\n"; StringWriter stringWriter = new StringWriter(); PrintWriter printWriter = new PrintWriter(stringWriter, true); status.getException().printStackTrace(printWriter); stringStatus += stringWriter.toString(); stringStatus += "==== end of IStatus exception stack trace ===="; } return stringStatus; }
Example 8
Source File: SARLEclipsePlugin.java From sarl with Apache License 2.0 | 5 votes |
private static IStatus findMax(Iterable<? extends IStatus> status) { IStatus max = null; for (final IStatus s : status) { if (max == null || max.getSeverity() > s.getSeverity()) { max = s; } } return max; }
Example 9
Source File: StatusUtil.java From editorconfig-eclipse with Apache License 2.0 | 5 votes |
/** * Compares two instances of <code>IStatus</code>. The more severe is returned: * An error is more severe than a warning, and a warning is more severe * than ok. If the two stati have the same severity, the second is returned. */ public static IStatus getMoreSevere(IStatus s1, IStatus s2) { if (s1.getSeverity() > s2.getSeverity()) { return s1; } else { return s2; } }
Example 10
Source File: AbstractProjectPropertyPage.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
/** * Returns the IStatus with the most critical severity. */ protected static IStatus getMostImportantStatus(IStatus[] status) { IStatus max = null; for (int i = 0; i < status.length; i++) { IStatus curr = status[i]; if (curr.matches(IStatus.ERROR)) { return curr; } if (max == null || curr.getSeverity() > max.getSeverity() || max.getMessage().length() == 0) { max = curr; } } return max; }
Example 11
Source File: TypeLabelProvider.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override public String getToolTipText(Object element) { IStatus status = validator.validate(element); if (status.getSeverity() == IStatus.ERROR) { return status.getMessage(); } return super.getToolTipText(element); }
Example 12
Source File: CustomXmlTraceInvalidTest.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
/** * Test all the invalid xml files */ @Test public void testInvalid() { IStatus invalid = getTrace().validate(null, getPath()); // Validation doesn't check for syntax errors. It returns a confidence // of 0 and status OK if it is a text file for invalid xml files. if ((IStatus.ERROR == invalid.getSeverity() || ((IStatus.OK == invalid.getSeverity() && (invalid instanceof TraceValidationStatus) && ((TraceValidationStatus) invalid).getConfidence() == 0)))) { return; } fail(getPath()); }
Example 13
Source File: ExpressionViewer.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
private Image getImageForMessageKind(final IStatus status) { switch (status.getSeverity()) { case IStatus.WARNING: return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_WARN_TSK); case IStatus.INFO: return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_INFO_TSK); case IStatus.ERROR: return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK); default: break; } return null; }
Example 14
Source File: StatusUtil.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
/** * Compares two instances of <code>IStatus</code>. The more severe is returned: An error is more severe than a * warning, and a warning is more severe than ok. If the two stati have the same severity, the second is returned. */ public static IStatus getMoreSevere(IStatus s1, IStatus s2) { if (s1.getSeverity() > s2.getSeverity()) { return s1; } else { return s2; } }
Example 15
Source File: PropertyHandleInputDialog.java From birt with Eclipse Public License 1.0 | 5 votes |
protected boolean validateSemantics( ) { IStatus status = validateSemantics( structureOrHandle ); if ( status == null ) return true; updateStatus( status ); return status.getSeverity( ) == IStatus.OK; }
Example 16
Source File: IntroduceParameterObjectWizard.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private boolean isErrorMessage(IStatus validationStatus) { if (!validationStatus.isOK()) { if (validationStatus.getSeverity() == IStatus.ERROR) { setErrorMessage(validationStatus.getMessage()); setPageComplete(false); return true; } else { if (validationStatus.getSeverity() == IStatus.INFO) setMessage(validationStatus.getMessage(), IMessageProvider.INFORMATION); else setMessage(validationStatus.getMessage(), IMessageProvider.WARNING); } } return false; }
Example 17
Source File: SVNUIPlugin.java From APICloud-Studio with GNU General Public License v3.0 | 4 votes |
/** * Convenience method for showing an error dialog * @param shell a valid shell or null * @param exception the exception to be report * @param title the title to be displayed * @param flags customizing attributes for the error handling * @return IStatus the status that was displayed to the user */ public static IStatus openError(Shell providedShell, String title, String message, Throwable exception, int flags) { // Unwrap InvocationTargetExceptions if (exception instanceof InvocationTargetException) { Throwable target = ((InvocationTargetException)exception).getTargetException(); // re-throw any runtime exceptions or errors so they can be handled by the workbench if (target instanceof RuntimeException) { throw (RuntimeException)target; } if (target instanceof Error) { throw (Error)target; } return openError(providedShell, title, message, target, flags); } // Determine the status to be displayed (and possibly logged) IStatus status = null; boolean log = false; if (exception instanceof CoreException) { status = ((CoreException)exception).getStatus(); log = ((flags & LOG_CORE_EXCEPTIONS) > 0); } else if (exception instanceof TeamException) { status = ((TeamException)exception).getStatus(); log = ((flags & LOG_TEAM_EXCEPTIONS) > 0); } else if (exception instanceof InterruptedException) { return new SVNStatus(IStatus.OK, Policy.bind("ok")); //$NON-NLS-1$ } else if (exception != null) { status = new SVNStatus(IStatus.ERROR, Policy.bind("internal"), exception); //$NON-NLS-1$ log = ((flags & LOG_OTHER_EXCEPTIONS) > 0); if (title == null) title = Policy.bind("SimpleInternal"); //$NON-NLS-1$ } // Check for a build error and report it differently if (status.getCode() == IResourceStatus.BUILD_FAILED) { message = Policy.bind("buildError"); //$NON-NLS-1$ log = true; } // Check for multi-status with only one child if (status.isMultiStatus() && status.getChildren().length == 1) { status = status.getChildren()[0]; } if (status.isOK()) return status; // Log if the user requested it if (log) SVNUIPlugin.log(status); // Create a runnable that will display the error status String svnInterface = SVNUIPlugin.getPlugin().getPreferenceStore().getString(ISVNUIConstants.PREF_SVNINTERFACE); boolean loadError = svnInterface.equals("javahl") && status != null && status.getMessage() != null && status.getMessage().equals(SVNClientManager.UNABLE_TO_LOAD_DEFAULT_CLIENT); if (!loadError || loadErrorHandled) { final String displayTitle = title; final String displayMessage = message; final IStatus displayStatus = status; final IOpenableInShell openable = new IOpenableInShell() { public void open(Shell shell) { if (displayStatus.getSeverity() == IStatus.INFO && !displayStatus.isMultiStatus()) { MessageDialog.openInformation(shell, Policy.bind("information"), displayStatus.getMessage()); //$NON-NLS-1$ } else { ErrorDialog.openError(shell, displayTitle, displayMessage, displayStatus); } } }; openDialog(providedShell, openable, flags); } if (loadError) loadErrorHandled = true; // return the status we display return status; }
Example 18
Source File: NLSAccessorConfigurationDialog.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
private void validatePropertyPackage() { IPackageFragmentRoot root= fResourceBundlePackage.getSelectedFragmentRoot(); if ((root == null) || !root.exists()) { setInvalid(IDX_BUNDLE_PACKAGE, NLSUIMessages.NLSAccessorConfigurationDialog_property_package_root_invalid); return; } IPackageFragment fragment= fResourceBundlePackage.getSelected(); if ((fragment == null) || !fragment.exists()) { setInvalid(IDX_BUNDLE_PACKAGE, NLSUIMessages.NLSAccessorConfigurationDialog_property_package_invalid); return; } String pkgName= fragment.getElementName(); IStatus status= JavaConventionsUtil.validatePackageName(pkgName, root); if ((pkgName.length() > 0) && (status.getSeverity() == IStatus.ERROR)) { setInvalid(IDX_BUNDLE_PACKAGE, status.getMessage()); return; } IPath pkgPath= new Path(pkgName.replace('.', IPath.SEPARATOR)).makeRelative(); IJavaProject project= fRefactoring.getCu().getJavaProject(); try { IJavaElement element= project.findElement(pkgPath); if (element == null || !element.exists()) { setInvalid(IDX_BUNDLE_PACKAGE, NLSUIMessages.NLSAccessorConfigurationDialog_must_exist); return; } IPackageFragment fPkgFragment= (IPackageFragment) element; if (!PackageBrowseAdapter.canAddPackage(fPkgFragment)) { setInvalid(IDX_BUNDLE_PACKAGE, NLSUIMessages.NLSAccessorConfigurationDialog_incorrect_package); return; } if (!PackageBrowseAdapter.canAddPackageRoot((IPackageFragmentRoot) fPkgFragment.getParent())) { setInvalid(IDX_BUNDLE_PACKAGE, NLSUIMessages.NLSAccessorConfigurationDialog_incorrect_package); return; } } catch (JavaModelException e) { setInvalid(IDX_BUNDLE_PACKAGE, e.getStatus().getMessage()); return; } setValid(IDX_BUNDLE_PACKAGE); }
Example 19
Source File: NewTypeWizardPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
/** * Hook method that gets called when the type name has changed. The method validates the * type name 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 typeNameChanged() { StatusInfo status= new StatusInfo(); fCurrType= null; String typeNameWithParameters= getTypeName(); // must not be empty if (typeNameWithParameters.length() == 0) { status.setError(NewWizardMessages.NewTypeWizardPage_error_EnterTypeName); return status; } String typeName= getTypeNameWithoutParameters(); if (typeName.indexOf('.') != -1) { status.setError(NewWizardMessages.NewTypeWizardPage_error_QualifiedName); return status; } IJavaProject project= getJavaProject(); IStatus val= validateJavaTypeName(typeName, project); if (val.getSeverity() == IStatus.ERROR) { status.setError(Messages.format(NewWizardMessages.NewTypeWizardPage_error_InvalidTypeName, val.getMessage())); return status; } else if (val.getSeverity() == IStatus.WARNING) { status.setWarning(Messages.format(NewWizardMessages.NewTypeWizardPage_warning_TypeNameDiscouraged, val.getMessage())); // continue checking } // must not exist if (!isEnclosingTypeSelected()) { IPackageFragment pack= getPackageFragment(); if (pack != null) { ICompilationUnit cu= pack.getCompilationUnit(getCompilationUnitName(typeName)); fCurrType= cu.getType(typeName); IResource resource= cu.getResource(); if (resource.exists()) { status.setError(NewWizardMessages.NewTypeWizardPage_error_TypeNameExists); return status; } if (!ResourcesPlugin.getWorkspace().validateFiltered(resource).isOK()) { status.setError(NewWizardMessages.NewTypeWizardPage_error_TypeNameFiltered); return status; } URI location= resource.getLocationURI(); if (location != null) { try { IFileStore store= EFS.getStore(location); if (store.fetchInfo().exists()) { status.setError(NewWizardMessages.NewTypeWizardPage_error_TypeNameExistsDifferentCase); return status; } } catch (CoreException e) { status.setError(Messages.format( NewWizardMessages.NewTypeWizardPage_error_uri_location_unkown, BasicElementLabels.getURLPart(Resources.getLocationString(resource)))); } } } } else { IType type= getEnclosingType(); if (type != null) { fCurrType= type.getType(typeName); if (fCurrType.exists()) { status.setError(NewWizardMessages.NewTypeWizardPage_error_TypeNameExists); return status; } } } if (!typeNameWithParameters.equals(typeName) && project != null) { if (!JavaModelUtil.is50OrHigher(project)) { status.setError(NewWizardMessages.NewTypeWizardPage_error_TypeParameters); return status; } String typeDeclaration= "class " + typeNameWithParameters + " {}"; //$NON-NLS-1$//$NON-NLS-2$ ASTParser parser= ASTParser.newParser(ASTProvider.SHARED_AST_LEVEL); parser.setSource(typeDeclaration.toCharArray()); parser.setProject(project); CompilationUnit compilationUnit= (CompilationUnit) parser.createAST(null); IProblem[] problems= compilationUnit.getProblems(); if (problems.length > 0) { status.setError(Messages.format(NewWizardMessages.NewTypeWizardPage_error_InvalidTypeName, problems[0].getMessage())); return status; } } return status; }
Example 20
Source File: StatusUtil.java From birt with Eclipse Public License 1.0 | 3 votes |
/** * Compares two instances of <code>IStatus</code>. The more severe is * returned: An error is more severe than a warning, and a warning is more * severe than ok. If the two stati have the same severity, the second is * returned. * * @param s1 * first status * @param s2 * second status * @return the more severe status */ public static IStatus getMoreSevere( IStatus s1, IStatus s2 ) { if ( s1.getSeverity( ) > s2.getSeverity( ) ) { return s1; } else { return s2; } }