1 11 package org.eclipse.jdt.internal.ui.dialogs; 12 13 import org.eclipse.core.runtime.IStatus; 14 15 import org.eclipse.swt.SWT; 16 import org.eclipse.swt.graphics.Image; 17 import org.eclipse.swt.widgets.Composite; 18 import org.eclipse.swt.widgets.Control; 19 import org.eclipse.swt.widgets.Display; 20 import org.eclipse.swt.widgets.Label; 21 import org.eclipse.swt.widgets.Shell; 22 23 import org.eclipse.jface.dialogs.ErrorDialog; 24 25 35 public class ProblemDialog extends ErrorDialog { 36 37 private Image fImage; 38 39 54 protected ProblemDialog(Shell parent, String title, String message, 55 Image image, IStatus status, int displayMask) 56 { 57 super(parent, title, message, status, displayMask); 58 fImage= image; 59 } 60 61 64 protected Control createDialogArea(Composite parent) { 65 Composite composite= (Composite)super.createDialogArea(parent); 66 if (fImage == null) 67 return composite; 68 69 Control[] kids= composite.getChildren(); 71 int childCount= kids.length; 72 Label label= null; 73 int i= 0; 74 while (i < childCount) { 75 if (kids[i] instanceof Label) { 76 label= (Label)kids[i]; 77 if (label.getImage() != null) 78 break; 79 } 80 i++; 81 } 82 if (i < childCount && label != null) 83 label.setImage(fImage); 84 applyDialogFont(composite); 85 return composite; 86 } 87 88 105 public static int open(Shell parent, String title, String message, IStatus status) { 106 return open(parent, title, message, status, IStatus.OK | IStatus.INFO | IStatus.WARNING | IStatus.ERROR); 107 } 108 109 131 public static int open(Shell parent, String title, String message, 132 IStatus status, int displayMask) 133 { 134 Image image; 135 Display display= parent.getDisplay(); 136 if (status == null || status.matches(IStatus.ERROR)) 137 image= display.getSystemImage(SWT.ICON_ERROR); 138 else if (status.matches(IStatus.WARNING)) 139 image= display.getSystemImage(SWT.ICON_WARNING); 140 else 141 image= display.getSystemImage(SWT.ICON_INFORMATION); 142 143 ErrorDialog dialog= new ProblemDialog(parent, title, message, image, status, displayMask); 144 return dialog.open(); 145 } 146 147 } 148 | Popular Tags |