Java Code Examples for org.eclipse.core.runtime.IStatus#WARNING
The following examples show how to use
org.eclipse.core.runtime.IStatus#WARNING .
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: NewFileWizardPrimaryPage.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Override public void setStatus(IStatus status) { if (status == null || status.getSeverity() == IStatus.OK) { setErrorMessage(null); setMessage(null); setPageComplete(true); } else if (status.getSeverity() == IStatus.ERROR) { setErrorMessage(status.getMessage()); setPageComplete(false); } else if (status.getSeverity() == IStatus.WARNING) { setErrorMessage(null); setMessage(status.getMessage(), IMessageProvider.WARNING); setPageComplete(true); } else { setErrorMessage(null); setMessage(status.getMessage(), IMessageProvider.INFORMATION); setPageComplete(true); } }
Example 2
Source File: NavigatorResourceDropAssistant.java From gama with GNU General Public License v3.0 | 6 votes |
/** * Opens an error dialog if necessary. Takes care of complex rules necessary for making the error dialog look nice. */ private void openError(final IStatus status) { if (status == null) { return; } final String genericTitle = WorkbenchNavigatorMessages.DropAdapter_title; final int codes = IStatus.ERROR | IStatus.WARNING; // simple case: one error, not a multistatus if (!status.isMultiStatus()) { ErrorDialog.openError(getShell(), genericTitle, null, status, codes); return; } // one error, single child of multistatus final IStatus[] children = status.getChildren(); if (children.length == 1) { ErrorDialog.openError(getShell(), status.getMessage(), null, children[0], codes); return; } // several problems ErrorDialog.openError(getShell(), genericTitle, null, status, codes); }
Example 3
Source File: EclipseLogAppender.java From n4js with Eclipse Public License 1.0 | 6 votes |
private int mapLevel(Level level) { switch (level.toInt()) { case Priority.DEBUG_INT: case Priority.INFO_INT: return IStatus.INFO; case Priority.WARN_INT: return IStatus.WARNING; case Priority.ERROR_INT: case Priority.FATAL_INT: return IStatus.ERROR; default: return IStatus.INFO; } }
Example 4
Source File: NamespaceXMLFileValidator.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override public IStatus validate(Object value) { try { File file = new File((String) value); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); Document document = dbf.newDocumentBuilder().parse(file); Element documentElement = document.getDocumentElement(); if (!isValid(documentElement)) { switch (severity) { case IStatus.ERROR: return ValidationStatus.error(message); case IStatus.WARNING: return ValidationStatus.warning(message); default: return ValidationStatus.info(message); } } } catch (SAXException | IOException | ParserConfigurationException e) { throw new RuntimeException(e); } return ValidationStatus.ok(); }
Example 5
Source File: AbstractSREInstallPage.java From sarl with Apache License 2.0 | 6 votes |
/** * Updates the status message on the page, based on the status of the SRE and other * status provided by the page. */ protected void updatePageStatus() { if (this.status.isOK()) { setMessage(null, IMessageProvider.NONE); } else { switch (this.status.getSeverity()) { case IStatus.ERROR: setMessage(this.status.getMessage(), IMessageProvider.ERROR); break; case IStatus.INFO: setMessage(this.status.getMessage(), IMessageProvider.INFORMATION); break; case IStatus.WARNING: setMessage(this.status.getMessage(), IMessageProvider.WARNING); break; default: break; } } setPageComplete(this.status.isOK() || this.status.getSeverity() == IStatus.INFO); }
Example 6
Source File: OpenStickerPreferencePage.java From elexis-3-core with Eclipse Public License 1.0 | 6 votes |
@Override public Object execute(ExecutionEvent event) throws ExecutionException{ ICommandService commandService = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class); Command cmd = commandService.getCommand("org.eclipse.ui.window.preferences"); try { HashMap<String, String> hm = new HashMap<String, String>(); hm.put("preferencePageId", "ch.elexis.prefs.sticker"); ExecutionEvent ev = new ExecutionEvent(cmd, hm, null, null); cmd.executeWithChecks(ev); } catch (Exception exception) { Status status = new Status(IStatus.WARNING, Activator.PLUGIN_ID, "Error opening sticker preference page"); StatusManager.getManager().handle(status, StatusManager.SHOW); } return null; }
Example 7
Source File: StatusUtil.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * Applies the status to the status line of a dialog page. * @param page the dialog page * @param status the status to apply */ public static void applyToStatusLine(DialogPage page, IStatus status) { String message= status.getMessage(); if (message != null && message.length() == 0) { message= null; } switch (status.getSeverity()) { case IStatus.OK: page.setMessage(message, IMessageProvider.NONE); page.setErrorMessage(null); break; case IStatus.WARNING: page.setMessage(message, IMessageProvider.WARNING); page.setErrorMessage(null); break; case IStatus.INFO: page.setMessage(message, IMessageProvider.INFORMATION); page.setErrorMessage(null); break; default: page.setMessage(null); page.setErrorMessage(message); break; } }
Example 8
Source File: SelectLanguageConfigurationWizardPage.java From tm4e with Eclipse Public License 1.0 | 5 votes |
protected IStatus validatePage(Event event) { infoWidget.refresh(null); String path = fileText.getText(); if (path.length() == 0) { return new Status(IStatus.ERROR, LanguageConfigurationPlugin.PLUGIN_ID, LanguageConfigurationMessages.SelectLanguageConfigurationWizardPage_fileError_noSelection); } IPath p = new Path(path); if (!p.isAbsolute()) { p = ResourcesPlugin.getWorkspace().getRoot().getFile(p).getLocation(); } try { ILanguageConfiguration configuration = LanguageConfiguration.load(new FileReader(p.toFile())); if (configuration == null) { return new Status(IStatus.ERROR, LanguageConfigurationPlugin.PLUGIN_ID, LanguageConfigurationMessages.SelectLanguageConfigurationWizardPage_fileError_invalid); } infoWidget.refresh(configuration); } catch (Exception e) { return new Status(IStatus.ERROR, LanguageConfigurationPlugin.PLUGIN_ID, LanguageConfigurationMessages.SelectLanguageConfigurationWizardPage_fileError_error + e.getLocalizedMessage()); } if (contentTypeText.getText().isEmpty()) { return new Status(IStatus.ERROR, LanguageConfigurationPlugin.PLUGIN_ID, LanguageConfigurationMessages.SelectLanguageConfigurationWizardPage_contentTypeError_noSelection); } IContentType contentType = ContentTypeHelper.getContentTypeById(contentTypeText.getText()); if (contentType == null) { return new Status(IStatus.ERROR, LanguageConfigurationPlugin.PLUGIN_ID, LanguageConfigurationMessages.SelectLanguageConfigurationWizardPage_contentTypeError_invalid); } if (registryManager.getLanguageConfigurationFor(new IContentType[] { contentType }) != null) { return new Status(IStatus.WARNING, LanguageConfigurationPlugin.PLUGIN_ID, LanguageConfigurationMessages.SelectLanguageConfigurationWizardPage_contentTypeWarning_duplicate); } return null; }
Example 9
Source File: ExportBarWizard.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
private boolean statusContainsError(IStatus validationStatus) { if(validationStatus != null){ if(validationStatus.getChildren().length > 0){ for(IStatus s : validationStatus.getChildren()){ if(s.getSeverity() == IStatus.WARNING || s.getSeverity() == IStatus.ERROR){ return true; } } }else{ return validationStatus.getSeverity() == IStatus.WARNING || validationStatus.getSeverity() == IStatus.ERROR; } } return false; }
Example 10
Source File: TypeScriptUIImageResource.java From typescript.java with MIT License | 5 votes |
public static Image getDecoratedImage(Image baseImage, int severity) { initializeIfNeeded(); String baseImageId = baseImage.toString(); // Construct a new image identifier String decoratedImageId = baseImageId.concat(String.valueOf(severity)); ImageDescriptor overlay = null; switch (severity) { case IStatus.ERROR: overlay = PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_DEC_FIELD_ERROR); break; case IStatus.WARNING: overlay = PlatformUI.getWorkbench().getSharedImages() .getImageDescriptor(ISharedImages.IMG_DEC_FIELD_WARNING); break; default: return baseImage; } // Return the stored image if we have one Image image = imageRegistry.get(decoratedImageId); if (image != null) { return image; } // Otherwise create a new image and store it DecorationOverlayIcon decoratedImage = new DecorationOverlayIcon(baseImage, new ImageDescriptor[] { null, null, null, overlay, null }, size) { }; imageRegistry.put(decoratedImageId, decoratedImage); return imageRegistry.get(decoratedImageId); }
Example 11
Source File: WellTest.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Test public void should_update_label_text() throws Exception { final Well well = new Well(realm.createComposite(), "", new FormToolkit(realm.getShell().getDisplay()), IStatus.WARNING); well.setText("hello"); assertThat(well.getText()).isEqualTo("hello"); }
Example 12
Source File: SGenJavaValidator.java From statecharts with Eclipse Public License 1.0 | 5 votes |
private void createMarker(IStatus status) { switch (status.getSeverity()) { case IStatus.ERROR: { if (status instanceof ErrorCodeStatus) { super.error(status.getMessage(), SGenPackage.Literals.FEATURE_PARAMETER_VALUE__EXPRESSION, ((ErrorCodeStatus) status).getErrorCode()); }else { super.error(status.getMessage(), SGenPackage.Literals.FEATURE_PARAMETER_VALUE__EXPRESSION); } break; } case IStatus.WARNING: super.warning(status.getMessage(), SGenPackage.Literals.FEATURE_PARAMETER_VALUE__EXPRESSION); } }
Example 13
Source File: Well.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
private Color backgroundColor(final FormToolkit toolkit, final int style) { switch (style) { case IStatus.WARNING: return warningBackground; case IStatus.ERROR: return errorBackground; case IStatus.INFO: default: return infoBackground; } }
Example 14
Source File: FormatterManager.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
/** * Load profiles from a XML stream and add them to a map or <code>null</code> if the source is not a profile store. * @param inputSource The input stream * @return returns a list of <code>CustomProfile</code> or <code>null</code> * @throws CoreException */ public static Map<String, String> readSettingsFromStream(InputSource inputSource, String profileName) throws CoreException { final ProfileDefaultHandler handler = new ProfileDefaultHandler(profileName); try { final SAXParserFactory factory = SAXParserFactory.newInstance(); final SAXParser parser = factory.newSAXParser(); parser.parse(inputSource, handler); } catch (Exception e) { throw new CoreException(new Status(IStatus.WARNING, IConstants.PLUGIN_ID, e.getMessage(), e)); } return handler.getSettings(); }
Example 15
Source File: StatusInfo.java From typescript.java with MIT License | 4 votes |
/** * Returns if the status' severity is WARNING. */ public boolean isWarning() { return fSeverity == IStatus.WARNING; }
Example 16
Source File: CompilationUnitEditor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
/** * Opens a warning dialog informing about a failure during handling of save listeners. * * @param title the dialog title * @param message the message to display * @param exception the exception to handle * @since 3.4 */ private void openSaveListenerWarningDialog(String title, String message, CoreException exception) { final String linkText; final IJavaProject javaProject= getInputJavaElement().getJavaProject(); IProject project= javaProject != null ? javaProject.getProject() : null; final boolean hasProjectSettings= project != null && CleanUpPreferenceUtil.hasSettingsInScope(new ProjectScope(project)); if (exception.getStatus().getCode() == IJavaStatusConstants.EDITOR_POST_SAVE_NOTIFICATION) { message= JavaEditorMessages.CompilationUnitEditor_error_saving_participant_message; if (hasProjectSettings) linkText= JavaEditorMessages.CompilationUnitEditor_error_saving_participant_property_link; else linkText= JavaEditorMessages.CompilationUnitEditor_error_saving_participant_link; } else { message= JavaEditorMessages.CompilationUnitEditor_error_saving_editedLines_calculation_message; if (hasProjectSettings) linkText= JavaEditorMessages.CompilationUnitEditor_error_saving_editedLines_calculation_property_link; else linkText= JavaEditorMessages.CompilationUnitEditor_error_saving_editedLines_calculation_link; } IStatus status= exception.getStatus(); int mask= IStatus.WARNING | IStatus.ERROR; ErrorDialog dialog= new ErrorDialog(getSite().getShell(), title, message, status, mask) { @Override protected Control createMessageArea(Composite parent) { Control result= super.createMessageArea(parent); // Panic code: use 'parent' instead of 'result' in case super implementation changes in the future new Label(parent, SWT.NONE); // filler as parent has 2 columns (icon and label) Link link= new Link(parent, SWT.NONE); link.setText(linkText); link.setFont(parent.getFont()); link.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (hasProjectSettings) PreferencesUtil.createPropertyDialogOn(getShell(), javaProject, SaveParticipantPreferencePage.PROPERTY_PAGE_ID, null, null).open(); else PreferencesUtil.createPreferenceDialogOn(getShell(), SaveParticipantPreferencePage.PREFERENCE_PAGE_ID, null, null).open(); } }); GridData gridData= new GridData(SWT.FILL, SWT.BEGINNING, true, false); link.setLayoutData(gridData); return result; } @Override protected Image getImage() { return getWarningImage(); } }; dialog.open(); }
Example 17
Source File: EmptyInputValidator.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
public Builder warningLevel() { this.severity = IStatus.WARNING; return this; }
Example 18
Source File: CompletionProposalComputerDescriptor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
private IStatus createExceptionStatus(RuntimeException x) { // misbehaving extension - log String blame= createBlameMessage(); String reason= JavaTextMessages.CompletionProposalComputerDescriptor_reason_runtime_ex; return new Status(IStatus.WARNING, JavaPlugin.getPluginId(), IStatus.OK, blame + " " + reason, x); //$NON-NLS-1$ }
Example 19
Source File: M2DocPlugin.java From M2Doc with Eclipse Public License 1.0 | 3 votes |
/** * Logs the given exception as error or warning. * * @param exception * The exception to log. * @param blocker * <code>true</code> if the message must be logged as error, <code>false</code> to log it as a * warning. */ public static void log(Exception exception, boolean blocker) { int severity = IStatus.WARNING; if (blocker) { severity = IStatus.ERROR; } M2DocPlugin.INSTANCE.log(new Status(severity, PLUGIN_ID, exception.getMessage(), exception)); }
Example 20
Source File: GenconfPlugin.java From M2Doc with Eclipse Public License 1.0 | 3 votes |
/** * Logs the given exception as error or warning. * * @param exception * The exception to log. * @param blocker * <code>true</code> if the message must be logged as error, <code>false</code> to log it as a * warning. */ public static void log(Exception exception, boolean blocker) { int severity = IStatus.WARNING; if (blocker) { severity = IStatus.ERROR; } GenconfPlugin.INSTANCE.log(new Status(severity, PLUGIN_ID, exception.getMessage(), exception)); }