KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > util > ViewerPane


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 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.jdt.internal.ui.util;
12
13 import org.eclipse.swt.SWT;
14 import org.eclipse.swt.custom.CLabel;
15 import org.eclipse.swt.custom.ViewForm;
16 import org.eclipse.swt.graphics.Image;
17 import org.eclipse.swt.widgets.Composite;
18 import org.eclipse.swt.widgets.ToolBar;
19
20 import org.eclipse.jface.action.ToolBarManager;
21
22 /**
23  * A <code>ViewerPane</code> is a convenience class which installs a
24  * <code>CLabel</code> and a <code>Toolbar</code> in a <code>ViewForm</code>.
25  * <P>
26  */

27 public class ViewerPane extends ViewForm {
28     
29     private ToolBarManager fToolBarManager;
30
31     public ViewerPane(Composite parent, int style) {
32         super(parent, style);
33         
34         marginWidth= 0;
35         marginHeight= 0;
36         
37         CLabel label= new CLabel(this, SWT.NONE);
38         setTopLeft(label);
39         
40         ToolBar tb= new ToolBar(this, SWT.FLAT);
41         setTopCenter(tb);
42         fToolBarManager= new ToolBarManager(tb);
43     }
44     
45     /**
46      * Sets the receiver's title text.
47      */

48     public void setText(String JavaDoc label) {
49         CLabel cl= (CLabel) getTopLeft();
50         cl.setText(label);
51     }
52     
53     public String JavaDoc getText() {
54         CLabel cl= (CLabel) getTopLeft();
55         return cl.getText();
56     }
57     
58     /**
59      * Sets the receiver's title image.
60      */

61     public void setImage(Image image) {
62         CLabel cl= (CLabel) getTopLeft();
63         cl.setImage(image);
64     }
65     
66     public Image getImage() {
67         CLabel cl= (CLabel) getTopLeft();
68         return cl.getImage();
69     }
70     
71     public ToolBarManager getToolBarManager() {
72         return fToolBarManager;
73     }
74 }
75
Popular Tags