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: *******************************************************************************/package org.eclipse.ui.part;
11:
12: import org.eclipse.swt.SWT;
13: import org.eclipse.swt.layout.FillLayout;
14: import org.eclipse.swt.widgets.Composite;
15: import org.eclipse.swt.widgets.Control;
16: import org.eclipse.swt.widgets.Label;
17:
18: /**
19: * A message page display a message in a pagebook view.
20: * <p>
21: * This class may be instantiated; it is not intended to be subclassed.
22: * </p>
23: *
24: * @see PageBookView
25: */
26: public class MessagePage extends Page {
27: private Composite pgComp;
28:
29: private Label msgLabel;
30:
31: private String message = "";//$NON-NLS-1$
32:
33: /**
34: * Creates a new page. The message is the empty string.
35: */
36: public MessagePage() {
37: // do nothing
38: }
39:
40: /* (non-Javadoc)
41: * Method declared on IPage.
42: */
43: public void createControl(Composite parent) {
44: // Message in default page of Outline should have margins
45: pgComp = new Composite(parent, SWT.NULL);
46: pgComp.setLayout(new FillLayout());
47:
48: msgLabel = new Label(pgComp, SWT.LEFT | SWT.TOP | SWT.WRAP);
49: msgLabel.setText(message);
50: }
51:
52: /* (non-Javadoc)
53: * Method declared on IPage.
54: */
55: public Control getControl() {
56: return pgComp;
57: }
58:
59: /**
60: * Sets focus to a part in the page.
61: */
62: public void setFocus() {
63: // important to give focus to the composite rather than the label
64: // as the composite will actually take focus (though hidden),
65: // but setFocus on a Label is a no-op
66: pgComp.setFocus();
67: }
68:
69: /**
70: * Sets the message to the given string.
71: *
72: * @param message the message text
73: */
74: public void setMessage(String message) {
75: this.message = message;
76: if (msgLabel != null) {
77: msgLabel.setText(message);
78: }
79: }
80: }
|