KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > help > ui > internal > util > RuntimeErrorDialog


1 /*******************************************************************************
2  * Copyright (c) 2000, 2004 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

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 /**
17  * This is the Dialog box that displays all the errors the occur during the
18  * initial load of the Help System. It's data (model) is taken from the
19  * RuntimeHelpStatus object.
20  */

21 public class RuntimeErrorDialog extends MessageDialog {
22     private static String JavaDoc errorStringToDisplay = null;
23     /**
24      * RuntimeErrorDialog constructor comment.
25      *
26      * @param dialogTitle
27      * java.lang.String
28      * @param dialogTitleImage
29      * org.eclipse.swt.graphics.Image
30      * @param dialogMessage
31      * java.lang.String
32      * @param dialogImageType
33      * int
34      * @param dialogButtonLabels
35      * java.lang.String[]
36      * @param defaultIndex
37      * int
38      */

39     public RuntimeErrorDialog(Shell parentShell, String JavaDoc dialogTitle,
40             org.eclipse.swt.graphics.Image dialogTitleImage,
41             String JavaDoc dialogMessage, int dialogImageType,
42             java.lang.String JavaDoc[] 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         // set error message
56
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             // set the default height on linux.
65
// Note: on Windows, the default height is fine.
66
if (System.getProperty("os.name").startsWith("Linux")) //$NON-NLS-1$ //$NON-NLS-2$
67
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 JavaDoc title, String JavaDoc message,
76             String JavaDoc errorString) {
77         errorStringToDisplay = errorString;
78         RuntimeErrorDialog dialog = new RuntimeErrorDialog(parentShell, title,
79                 null, // accept the default window icon
80
message, ERROR, new String JavaDoc[]{IDialogConstants.OK_LABEL}, 0);
81         // ok is the default
82
dialog.open();
83         return;
84     }
85 }
86
Popular Tags