01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * 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: *******************************************************************************/package org.eclipse.ui.texteditor;
12:
13: import org.eclipse.swt.SWT;
14: import org.eclipse.swt.layout.GridData;
15: import org.eclipse.swt.layout.GridLayout;
16: import org.eclipse.swt.widgets.Composite;
17:
18: import org.eclipse.jface.dialogs.Dialog;
19: import org.eclipse.jface.dialogs.DialogPage;
20: import org.eclipse.jface.dialogs.IMessageProvider;
21:
22: /**
23: * Dialog page used to show text or error message.
24: *
25: * @since 3.1
26: */
27: class MessageDialogPage extends DialogPage {
28:
29: MessageRegion fMessageRegion;
30:
31: public MessageDialogPage(Composite parent) {
32: createControl(parent);
33: }
34:
35: public void createControl(Composite parent) {
36: Composite composite1 = new Composite(parent, SWT.NONE);
37: composite1
38: .setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
39: GridLayout layout = new GridLayout();
40: layout.marginWidth = 0;
41: layout.marginHeight = 0;
42: composite1.setLayout(layout);
43: fMessageRegion = new MessageRegion();
44: fMessageRegion.createContents(composite1);
45: GridData messageData = new GridData(GridData.FILL_HORIZONTAL
46: | GridData.GRAB_HORIZONTAL);
47: fMessageRegion.setMessageLayoutData(messageData);
48: setControl(composite1);
49: Dialog.applyDialogFont(composite1);
50: }
51:
52: public void setMessage(String newMessage, int newType) {
53: super .setMessage(newMessage, newType);
54: fMessageRegion.updateText(newMessage, newType);
55: }
56:
57: public void setErrorMessage(String newMessage) {
58: super.setErrorMessage(newMessage);
59: fMessageRegion.updateText(newMessage, IMessageProvider.ERROR);
60: }
61: }
|