List of usage examples for org.eclipse.jface.dialogs IMessageProvider ERROR
int ERROR
To view the source code for org.eclipse.jface.dialogs IMessageProvider ERROR.
Click Source Link
From source file:org.eclipse.m2e.core.ui.internal.dialogs.MavenMessageDialog.java
License:Open Source License
/** * @param parent/*from w w w. j a v a2 s. c o m*/ * @param title * @param label * @param message * @param severity constants from MessageDialog */ public static void openWithSeverity(Shell parent, String title, String label, String message, int severity) { Image icon = severity == IMessageProvider.ERROR ? Display.getDefault().getSystemImage(SWT.ICON_ERROR) : Display.getDefault().getSystemImage(SWT.ICON_INFORMATION); MavenMessageDialog dialog = new MavenMessageDialog(parent, title, icon, // accept label, severity, new String[] { IDialogConstants.OK_LABEL }, 0); // ok dialog.create(); dialog.getMessageArea().setText(message); dialog.getDialogArea().pack(true); dialog.open(); return; }
From source file:org.eclipse.m2e.core.ui.internal.preferences.MavenSettingsPreferencePage.java
License:Open Source License
protected void updateLocalRepository() { final String userSettings = getUserSettings(); String globalSettings = runtimeManager.getGlobalSettingsFile(); try {/*from w w w. j av a2 s . co m*/ Settings settings = maven.buildSettings(globalSettings, userSettings); String localRepository = settings.getLocalRepository(); if (localRepository == null) { localRepository = RepositorySystem.defaultUserLocalRepository.getAbsolutePath(); } if (!localRepositoryText.isDisposed()) { localRepositoryText.setText(localRepository == null ? "" : localRepository); //$NON-NLS-1$ } } catch (CoreException e) { setMessage(e.getMessage(), IMessageProvider.ERROR); } }
From source file:org.eclipse.m2e.editor.pom.DependencyTreePage.java
License:Open Source License
void loadData(final boolean force) { // form.setMessage() forces the panel layout, which messes up the viewers // (e.g. long entries in the tree cause it to expand horizontally so much // doesn't fit into the editor anymore). Clearing the input in the viewers // helps to ensure they won't change the size when the message is set. if (treeViewer.getTree().isDisposed()) { return;/*w ww . j av a 2 s . c om*/ } treeViewer.setInput(null); if (listViewer.getTable().isDisposed()) { return; } listViewer.setInput(null); FormUtils.setMessage(getManagedForm().getForm(), Messages.DependencyTreePage_message_resolving, IMessageProvider.WARNING); dataLoadingJob = new Job(Messages.DependencyTreePage_job_loading) { protected IStatus run(IProgressMonitor monitor) { try { mavenProject = pomEditor.readMavenProject(force, monitor); if (mavenProject == null) { log.error("Unable to read maven project. Dependencies not updated."); //$NON-NLS-1$ return Status.CANCEL_STATUS; } final DependencyNode dependencyNode = pomEditor.readDependencyTree(force, currentClasspath, monitor); if (dependencyNode == null) { return Status.CANCEL_STATUS; } dependencyNode.accept(new DependencyVisitor() { public boolean visitEnter(DependencyNode node) { if (node.getDependency() != null) { dependencyNodes.add(node); } return true; } public boolean visitLeave(DependencyNode dependencynode) { return true; } }); getPartControl().getDisplay().syncExec(new Runnable() { public void run() { FormUtils.setMessage(getManagedForm().getForm(), null, IMessageProvider.NONE); if (treeViewer.getTree().isDisposed()) { return; } treeViewer.setInput(dependencyNode); treeViewer.expandAll(); if (listViewer.getTable().isDisposed()) { return; } listViewer.setInput(mavenProject); } }); } catch (final CoreException ex) { log.error(ex.getMessage(), ex); getPartControl().getDisplay().asyncExec(new Runnable() { public void run() { FormUtils.setMessage(getManagedForm().getForm(), ex.getMessage(), IMessageProvider.ERROR); } }); } return Status.OK_STATUS; } }; dataLoadingJob.schedule(); }
From source file:org.eclipse.m2e.editor.pom.FormUtils.java
License:Open Source License
private static FormHoverProvider.Execute createDefaultPerformer(final ScrolledForm form, final String message, final String ttip, final int severity) { if (ttip != null && ttip.length() > 0 && message != null) { return new FormHoverProvider.Execute() { public void run(Point point) { int dialogSev = IMessageProvider.ERROR == severity ? MessageDialog.ERROR : MessageDialog.WARNING; MavenMessageDialog.openWithSeverity(form.getShell(), Messages.FormUtils_error_info, Messages.FormUtils_pom_error, ttip, dialogSev); }/*from w w w .j a v a2s . c o m*/ }; } return null; }
From source file:org.eclipse.m2e.editor.pom.MavenPomEditor.java
License:Open Source License
/** * Closes all project files on project close. */// ww w .j a va2 s. c o m public void resourceChanged(final IResourceChangeEvent event) { if (pomFile == null) { return; } //handle project delete if (event.getType() == IResourceChangeEvent.PRE_CLOSE || event.getType() == IResourceChangeEvent.PRE_DELETE) { if (pomFile.getProject().equals(event.getResource())) { Display.getDefault().asyncExec(new Runnable() { public void run() { close(false); } }); } return; } //handle pom delete class RemovedResourceDeltaVisitor implements IResourceDeltaVisitor { boolean removed = false; public boolean visit(IResourceDelta delta) throws CoreException { if (delta.getResource() == pomFile // && (delta.getKind() & (IResourceDelta.REMOVED)) != 0) { removed = true; return false; } return true; } } ; try { RemovedResourceDeltaVisitor visitor = new RemovedResourceDeltaVisitor(); event.getDelta().accept(visitor); if (visitor.removed) { Display.getDefault().asyncExec(new Runnable() { public void run() { close(true); } }); } } catch (CoreException ex) { log.error(ex.getMessage(), ex); } // Reload model if pom file was changed externally. // TODO implement generic merge scenario (when file is externally changed and is dirty) // suppress a prompt to reload the pom if modifications were caused by workspace actions //XXX: mkleint: why is this called outside of the ChangedResourceDeltaVisitor? if (sourcePage != null) { sourcePage.updateModificationStamp(); } class ChangedResourceDeltaVisitor implements IResourceDeltaVisitor { public boolean visit(IResourceDelta delta) throws CoreException { if (delta.getResource().equals(pomFile) && (delta.getKind() & IResourceDelta.CHANGED) != 0 && delta.getResource().exists()) { int flags = delta.getFlags(); if ((flags & IResourceDelta.CONTENT) != 0 || (flags & IResourceDelta.REPLACED) != 0) { handleContentChanged(); return false; } if ((flags & IResourceDelta.MARKERS) != 0) { handleMarkersChanged(); return false; } } return true; } /** * this method never got called with the current editor changes/saves the file. the doSave() method removed/added * the resource listener when saving it did get called however when external editor (txt/xml) saved the file.. * I've changed that behaviour to only avoid the reload() call when current editor saves the file. we still want * to attempt to reload the mavenproject instance.. please read <code>mavenProjectChanged</code> javadoc for * details on when this works and when not. */ private void handleContentChanged() { reloadMavenProjectCache(); if (!resourceChangeEventSkip) { Display.getDefault().asyncExec(new Runnable() { public void run() { /* MNGECLIPSE-1789: commented this out since forced model reload caused the XML editor to go crazy; the model is already updated at this point so reloading from file is unnecessary; externally originated file updates are checked in handleActivation() */ // try { // structuredModel.reload(pomFile.getContents()); reload(); // } catch(CoreException e) { // log.error(e.getMessage(), e); // } catch(Exception e) { // log.error("Error loading pom editor model.", e); // } } }); } } private void handleMarkersChanged() { try { IMarker[] markers = pomFile.findMarkers(IMavenConstants.MARKER_ID, true, IResource.DEPTH_ZERO); final String msg = markers != null && markers.length > 0 // ? markers[0].getAttribute(IMarker.MESSAGE, "Unknown error") : null; final int severity = markers != null && markers.length > 0 ? (markers[0].getAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR) == IMarker.SEVERITY_WARNING ? IMessageProvider.WARNING : IMessageProvider.ERROR) : IMessageProvider.NONE; Display.getDefault().asyncExec(new Runnable() { public void run() { for (MavenPomEditorPage page : getMavenPomEditorPages()) { page.setErrorMessage(msg, msg == null ? IMessageProvider.NONE : severity); } } }); } catch (CoreException ex) { log.error("Error updating pom file markers.", ex); //$NON-NLS-1$ } } } ; try { ChangedResourceDeltaVisitor visitor = new ChangedResourceDeltaVisitor(); event.getDelta().accept(visitor); } catch (CoreException ex) { log.error(ex.getMessage(), ex); } }
From source file:org.eclipse.m2e.editor.pom.MavenPomEditorPage.java
License:Open Source License
private void doLoadData(boolean active) { try {/*from w w w .j a v a 2s .c o m*/ if (active && !dataLoaded) { dataLoaded = true; if (getPartControl() != null) { getPartControl().getDisplay().asyncExec(new Runnable() { public void run() { try { loadData(); updateParentAction(); } catch (Throwable e) { LOG.error("Error loading data", e); //$NON-NLS-1$ } } }); } } //error markers have to be always updated.. IFile pomFile = pomEditor.getPomFile(); if (pomFile != null) { String text = ""; //$NON-NLS-1$ IMarker[] markers = pomFile.findMarkers(IMavenConstants.MARKER_ID, true, IResource.DEPTH_ZERO); IMarker max = null; int maxSev = -1; if (markers != null) { for (IMarker mark : markers) { IMarker toAdd = max; int sev = mark.getAttribute(IMarker.SEVERITY, -1); if (sev > maxSev) { max = mark; maxSev = sev; } else { toAdd = mark; } if (toAdd != null) { //errors get prepended while warnings get appended. if (toAdd.getAttribute(IMarker.SEVERITY, -1) == IMarker.SEVERITY_ERROR) { text = NLS.bind(Messages.MavenPomEditorPage_error_add, toAdd.getAttribute(IMarker.MESSAGE, "")) + text; //$NON-NLS-2$ } else { text = text + NLS.bind(Messages.MavenPomEditorPage_warning_add, toAdd.getAttribute(IMarker.MESSAGE, "")); //$NON-NLS-2$ } } } } if (max != null) { String head; String maxText = max.getAttribute(IMarker.MESSAGE, Messages.MavenPomEditorPage_error_unknown); if (text.length() > 0) { //if we have multiple errors text = NLS.bind(Messages.MavenPomEditorPage_add_desc, maxText, text); if (markers != null) { String number = new Integer(markers.length - 1).toString(); head = NLS.bind(Messages.FormUtils_click_for_details2, maxText.length() > FormUtils.MAX_MSG_LENGTH ? maxText.substring(0, FormUtils.MAX_MSG_LENGTH) : maxText, number); } else { head = maxText; if (head.length() > FormUtils.MAX_MSG_LENGTH) { head = NLS.bind(Messages.FormUtils_click_for_details, head.substring(0, FormUtils.MAX_MSG_LENGTH)); } } } else { //only this one text = maxText; head = maxText; if (head.length() > FormUtils.MAX_MSG_LENGTH) { head = NLS.bind(Messages.FormUtils_click_for_details, head.substring(0, FormUtils.MAX_MSG_LENGTH)); } } int severity; switch (max.getAttribute(IMarker.SEVERITY, -1)) { case IMarker.SEVERITY_ERROR: { severity = IMessageProvider.ERROR; break; } case IMarker.SEVERITY_WARNING: { severity = IMessageProvider.WARNING; break; } case IMarker.SEVERITY_INFO: { severity = IMessageProvider.INFORMATION; break; } default: { severity = IMessageProvider.NONE; } } setErrorMessageForMarkers(head, text, severity, markers); } else { setErrorMessageForMarkers(null, null, IMessageProvider.NONE, new IMarker[0]); } } } catch (final CoreException ex) { LOG.error(ex.getMessage(), ex); final String msg = ex.getMessage(); setErrorMessageForMarkers(msg, msg, IMessageProvider.ERROR, new IMarker[0]); } }
From source file:org.eclipse.m2e.internal.discovery.wizards.MavenCatalogViewer.java
License:Open Source License
private void handleStatus(final IStatus status) { if (status.isOK()) { return;/* w w w . ja va 2s . c o m*/ } if (shellProvider instanceof WizardPage) { shellProvider.getShell().getDisplay().asyncExec(new Runnable() { public void run() { // Display the error in the wizard header int messageType = IMessageProvider.INFORMATION; if (status.matches(IStatus.ERROR)) { messageType = IMessageProvider.ERROR; } else if (status.matches(IStatus.WARNING)) { messageType = IMessageProvider.WARNING; } ((WizardPage) shellProvider).setMessage(status.getMessage(), messageType); StatusManager.getManager().handle(status); } }); } else { StatusManager.getManager().handle(status, StatusManager.SHOW | StatusManager.BLOCK | StatusManager.LOG); } }
From source file:org.eclipse.m2e.internal.discovery.wizards.MavenDiscoveryWizard.java
License:Open Source License
@Override public boolean performFinish() { try {// w w w . ja va 2s .com return MavenDiscoveryUi.install(getCatalogPage().getInstallableConnectors(), null, getContainer()); } catch (CoreException e) { IWizardPage page = getContainer().getCurrentPage(); if (page instanceof WizardPage) { ((WizardPage) page).setMessage(e.getMessage(), IMessageProvider.ERROR); } else { // This should never happen, but just in case. StatusManager.getManager().handle(e.getStatus(), StatusManager.SHOW | StatusManager.LOG); } return false; } }
From source file:org.eclipse.m2m.internal.qvt.oml.ui.wizards.NewQvtModuleCreationPage.java
License:Open Source License
final protected void updateStatus(IStatus[] result) { // select most sever status fStatus = Status.OK_STATUS;// w w w . jav a 2 s. c o m for (IStatus status : result) { if (status.getSeverity() > fStatus.getSeverity()) { fStatus = status; } } if (!fStatus.isOK()) { int type = IMessageProvider.NONE; switch (fStatus.getSeverity()) { case IStatus.ERROR: type = IMessageProvider.ERROR; break; case IStatus.WARNING: type = IMessageProvider.WARNING; break; case IStatus.INFO: type = IMessageProvider.INFORMATION; break; } setMessage(fStatus.getMessage(), type); setPageComplete(isValid()); setPageComplete(true); } else { setErrorMessage(null); setMessage(null); setPageComplete(true); } }
From source file:org.eclipse.m2m.internal.qvt.oml.ui.wizards.project.NewQVTProjectCreationPage.java
License:Open Source License
protected boolean validateQvtSourceContainer() { IStatus status = SourceContainerUpdater.validate(getQVTSourceContainerValue()); if (!status.isOK()) { int type = IMessageProvider.NONE; switch (status.getSeverity()) { case IStatus.INFO: type = IMessageProvider.INFORMATION; break; case IStatus.WARNING: type = IMessageProvider.WARNING; break; case IStatus.ERROR: type = IMessageProvider.ERROR; break; }//from w w w . j a v a 2s . c o m setMessage(status.getMessage(), type); return status.getSeverity() <= IStatus.INFO; } return true; }