1 11 package org.eclipse.ui.internal.dialogs; 12 13 14 import org.eclipse.core.runtime.IStatus; 15 import org.eclipse.jface.dialogs.ErrorDialog; 16 import org.eclipse.jface.dialogs.IDialogConstants; 17 import org.eclipse.swt.graphics.Image; 18 import org.eclipse.swt.layout.GridLayout; 19 import org.eclipse.swt.widgets.Button; 20 import org.eclipse.swt.widgets.Composite; 21 import org.eclipse.swt.widgets.Shell; 22 23 26 public class PreferenceErrorDialog extends ErrorDialog { 27 30 public PreferenceErrorDialog( 31 Shell parentShell, 32 String dialogTitle, 33 String message, 34 IStatus status, 35 int displayMask) { 36 37 super(parentShell, dialogTitle, message, status, displayMask); 38 } 39 42 public static int openError(Shell parentShell, String title, String message, IStatus status) { 43 int displayMask = IStatus.OK | IStatus.INFO | IStatus.WARNING | IStatus.ERROR; 44 ErrorDialog dialog = new PreferenceErrorDialog(parentShell, title, message, status, displayMask); 45 return dialog.open(); 46 } 47 50 protected void buttonPressed(int buttonId) { 51 if (IDialogConstants.YES_ID == buttonId) 52 okPressed(); 53 else if (IDialogConstants.NO_ID == buttonId) 54 cancelPressed(); 55 else 56 super.buttonPressed(buttonId); 57 } 58 61 protected void createButtonsForButtonBar(Composite parent) { 62 createButton(parent, IDialogConstants.YES_ID, IDialogConstants.YES_LABEL, true); 64 createButton(parent, IDialogConstants.NO_ID, IDialogConstants.NO_LABEL, false); 65 super.createButtonsForButtonBar(parent); 66 Button okButton = getButton(IDialogConstants.OK_ID); 68 if (okButton != null && !okButton.isDisposed()) { 69 okButton.dispose(); 70 ((GridLayout)parent.getLayout()).numColumns--; 71 } 72 } 73 76 protected Image getImage() { 77 return getWarningImage(); 78 } 79 } 80 81 | Popular Tags |