01: /*******************************************************************************
02: * Copyright (c) 2000, 2005 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.jdt.internal.ui.util;
11:
12: import org.eclipse.swt.SWT;
13: import org.eclipse.swt.custom.CLabel;
14: import org.eclipse.swt.custom.ViewForm;
15: import org.eclipse.swt.graphics.Image;
16: import org.eclipse.swt.widgets.Composite;
17: import org.eclipse.swt.widgets.ToolBar;
18:
19: import org.eclipse.jface.action.ToolBarManager;
20:
21: /**
22: * A <code>ViewerPane</code> is a convenience class which installs a
23: * <code>CLabel</code> and a <code>Toolbar</code> in a <code>ViewForm</code>.
24: * <P>
25: */
26: public class ViewerPane extends ViewForm {
27:
28: private ToolBarManager fToolBarManager;
29:
30: public ViewerPane(Composite parent, int style) {
31: super (parent, style);
32:
33: marginWidth = 0;
34: marginHeight = 0;
35:
36: CLabel label = new CLabel(this , SWT.NONE);
37: setTopLeft(label);
38:
39: ToolBar tb = new ToolBar(this , SWT.FLAT);
40: setTopCenter(tb);
41: fToolBarManager = new ToolBarManager(tb);
42: }
43:
44: /**
45: * Sets the receiver's title text.
46: */
47: public void setText(String label) {
48: CLabel cl = (CLabel) getTopLeft();
49: cl.setText(label);
50: }
51:
52: public String getText() {
53: CLabel cl = (CLabel) getTopLeft();
54: return cl.getText();
55: }
56:
57: /**
58: * Sets the receiver's title image.
59: */
60: public void setImage(Image image) {
61: CLabel cl = (CLabel) getTopLeft();
62: cl.setImage(image);
63: }
64:
65: public Image getImage() {
66: CLabel cl = (CLabel) getTopLeft();
67: return cl.getImage();
68: }
69:
70: public ToolBarManager getToolBarManager() {
71: return fToolBarManager;
72: }
73: }
|