1 11 package org.eclipse.ui.internal.part.services; 12 13 import org.eclipse.core.runtime.IStatus; 14 import org.eclipse.core.runtime.Status; 15 import org.eclipse.jface.dialogs.ErrorDialog; 16 import org.eclipse.jface.dialogs.MessageDialog; 17 import org.eclipse.swt.widgets.Composite; 18 import org.eclipse.ui.internal.WorkbenchPlugin; 19 import org.eclipse.ui.internal.part.components.services.IUserMessages; 20 21 27 public class DefaultMessageDialogs implements IUserMessages { 28 29 private Composite control; 30 31 34 public DefaultMessageDialogs(Composite control) { 35 this.control = control; 36 } 37 38 41 public void show(IStatus message) { 42 if (message.getSeverity() == IStatus.ERROR) { 43 ErrorDialog.openError(control.getShell(), null, null, message); 44 } else { 45 show(message.getSeverity(), message.getMessage()); 46 } 47 } 48 49 52 public void showError(String message, Throwable cause) { 53 show(new Status(IStatus.ERROR, 54 WorkbenchPlugin.getDefault().getBundle().getSymbolicName(), 55 IStatus.OK, 56 message, 57 cause)); 58 } 59 60 63 public void show(int severity, String message) { 64 if (severity == IStatus.ERROR) { 65 MessageDialog.openError(control.getShell(), null, message); 66 } else if (severity == IStatus.WARNING) { 67 MessageDialog.openWarning(control.getShell(), null, message); 68 } else { 69 MessageDialog.openInformation(control.getShell(), null, message); 70 } 71 } 72 } 73 | Popular Tags |