KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > part > MessagePage


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  *******************************************************************************/

11 package org.eclipse.ui.part;
12
13 import org.eclipse.swt.SWT;
14 import org.eclipse.swt.layout.FillLayout;
15 import org.eclipse.swt.widgets.Composite;
16 import org.eclipse.swt.widgets.Control;
17 import org.eclipse.swt.widgets.Label;
18
19 /**
20  * A message page display a message in a pagebook view.
21  * <p>
22  * This class may be instantiated; it is not intended to be subclassed.
23  * </p>
24  *
25  * @see PageBookView
26  */

27 public class MessagePage extends Page {
28     private Composite pgComp;
29
30     private Label msgLabel;
31
32     private String JavaDoc message = "";//$NON-NLS-1$
33

34     /**
35      * Creates a new page. The message is the empty string.
36      */

37     public MessagePage() {
38         // do nothing
39
}
40
41     /* (non-Javadoc)
42      * Method declared on IPage.
43      */

44     public void createControl(Composite parent) {
45         // Message in default page of Outline should have margins
46
pgComp = new Composite(parent, SWT.NULL);
47         pgComp.setLayout(new FillLayout());
48
49         msgLabel = new Label(pgComp, SWT.LEFT | SWT.TOP | SWT.WRAP);
50         msgLabel.setText(message);
51     }
52
53     /* (non-Javadoc)
54      * Method declared on IPage.
55      */

56     public Control getControl() {
57         return pgComp;
58     }
59
60     /**
61      * Sets focus to a part in the page.
62      */

63     public void setFocus() {
64         // important to give focus to the composite rather than the label
65
// as the composite will actually take focus (though hidden),
66
// but setFocus on a Label is a no-op
67
pgComp.setFocus();
68     }
69
70     /**
71      * Sets the message to the given string.
72      *
73      * @param message the message text
74      */

75     public void setMessage(String JavaDoc message) {
76         this.message = message;
77         if (msgLabel != null) {
78             msgLabel.setText(message);
79         }
80     }
81 }
82
Popular Tags