1 11 package org.eclipse.help.ui.internal.util; 12 import org.eclipse.jface.dialogs.*; 13 import org.eclipse.swt.*; 14 import org.eclipse.swt.layout.*; 15 import org.eclipse.swt.widgets.*; 16 21 public class RuntimeErrorDialog extends MessageDialog { 22 private static String errorStringToDisplay = null; 23 39 public RuntimeErrorDialog(Shell parentShell, String dialogTitle, 40 org.eclipse.swt.graphics.Image dialogTitleImage, 41 String dialogMessage, int dialogImageType, 42 java.lang.String [] dialogButtonLabels, int defaultIndex) { 43 super(parentShell, dialogTitle, dialogTitleImage, dialogMessage, 44 dialogImageType, dialogButtonLabels, defaultIndex); 45 } 46 protected Control createCustomArea(Composite parent) { 47 Composite composite = new Composite(parent, SWT.RESIZE); 48 GridLayout layout = new GridLayout(); 49 layout.numColumns = 2; 50 layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); 51 layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); 52 layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); 53 composite.setLayout(layout); 54 composite.setLayoutData(new GridData(GridData.FILL_BOTH)); 55 if (errorStringToDisplay != null) { 57 Text text = new Text(composite, SWT.BORDER | SWT.H_SCROLL 58 | SWT.V_SCROLL | SWT.READ_ONLY | SWT.MULTI); 59 text.setText(errorStringToDisplay); 60 GridData data = new GridData(GridData.GRAB_HORIZONTAL 61 | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL 62 | GridData.VERTICAL_ALIGN_CENTER); 63 data.widthHint = getMinimumMessageWidth(); 64 if (System.getProperty("os.name").startsWith("Linux")) data.heightHint = convertVerticalDLUsToPixels(100); 68 text.setLayoutData(data); 69 text.setFont(parent.getFont()); 70 text.setBackground(composite.getDisplay().getSystemColor( 71 SWT.COLOR_WHITE)); 72 } 73 return composite; 74 } 75 public static void open(Shell parentShell, String title, String message, 76 String errorString) { 77 errorStringToDisplay = errorString; 78 RuntimeErrorDialog dialog = new RuntimeErrorDialog(parentShell, title, 79 null, message, ERROR, new String []{IDialogConstants.OK_LABEL}, 0); 81 dialog.open(); 83 return; 84 } 85 } 86 | Popular Tags |