KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > texteditor > MessageDialogPage


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  * Hiroyuki Inaba <hiroyuki.inaba@jp.fujitsu.com> - https://bugs.eclipse.org/bugs/show_bug.cgi?id=140121
11  *******************************************************************************/

12
13 package org.eclipse.ui.texteditor;
14
15 import org.eclipse.swt.SWT;
16 import org.eclipse.swt.layout.GridData;
17 import org.eclipse.swt.layout.GridLayout;
18 import org.eclipse.swt.widgets.Composite;
19
20 import org.eclipse.jface.dialogs.Dialog;
21 import org.eclipse.jface.dialogs.DialogPage;
22 import org.eclipse.jface.dialogs.IMessageProvider;
23
24 /**
25  * Dialog page used to show text or error message.
26  *
27  * @since 3.1
28  */

29 class MessageDialogPage extends DialogPage {
30
31     MessageRegion fMessageRegion;
32
33
34     public MessageDialogPage(Composite parent) {
35         createControl(parent);
36     }
37
38     public void createControl(Composite parent) {
39         Composite composite1= new Composite(parent, SWT.NONE);
40         composite1.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
41         GridLayout layout = new GridLayout();
42         layout.marginWidth = 0;
43         layout.marginHeight = 0;
44         composite1.setLayout(layout);
45         fMessageRegion= new MessageRegion();
46         fMessageRegion.createContents(composite1);
47         GridData messageData= new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
48         fMessageRegion.setMessageLayoutData(messageData);
49         setControl(composite1);
50         Dialog.applyDialogFont(composite1);
51     }
52
53     public void setMessage(String JavaDoc newMessage,int newType) {
54         super.setMessage(newMessage, newType);
55         fMessageRegion.updateText(newMessage, newType);
56     }
57
58     public void setErrorMessage(String JavaDoc newMessage) {
59         super.setErrorMessage(newMessage);
60         fMessageRegion.updateText(newMessage, IMessageProvider.ERROR);
61     }
62 }
63
Popular Tags