01: /*******************************************************************************
02: * Copyright (c) 2004, 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.ui.examples.components.views.comparisons;
11:
12: import org.eclipse.jface.resource.ImageDescriptor;
13: import org.eclipse.swt.SWT;
14: import org.eclipse.swt.graphics.Image;
15: import org.eclipse.swt.widgets.Composite;
16: import org.eclipse.swt.widgets.Label;
17: import org.eclipse.ui.examples.components.ComponentExamplesPlugin;
18: import org.eclipse.ui.part.ViewPart;
19: import org.eclipse.ui.plugin.AbstractUIPlugin;
20:
21: /**
22: * Sample view that sets its name, tooltip, image, and content description. The view
23: * uses a custom image supplied by its plugin.
24: *
25: * @since 3.1
26: */
27: public class NameViewOld extends ViewPart {
28:
29: private Image image = null;
30: private Composite mainControl;
31:
32: /* (non-Javadoc)
33: * @see org.eclipse.ui.IWorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
34: */
35: public void createPartControl(Composite parent) {
36: // Remember main control (for setFocus)
37: mainControl = parent;
38:
39: // Set name, content description, and tooltip
40: setPartName("Name View (Old)");
41: setContentDescription("content description");
42: setTitleToolTip("This is a tooltip");
43:
44: // Load custom image and put it in the view's title
45: String symbolicName = ComponentExamplesPlugin.getDefault()
46: .getBundle().getSymbolicName();
47: ImageDescriptor imageDescriptor = AbstractUIPlugin
48: .imageDescriptorFromPlugin(symbolicName,
49: "icons/sample.gif");
50:
51: this .image = imageDescriptor.createImage();
52: if (image != null) {
53: setTitleImage(image);
54: }
55:
56: // Create some bogus view contents
57: Label content = new Label(parent, SWT.NONE);
58: content.setText("View contents go here");
59: }
60:
61: /* (non-Javadoc)
62: * @see org.eclipse.ui.IWorkbenchPart#setFocus()
63: */
64: public void setFocus() {
65: mainControl.setFocus();
66: }
67:
68: /* (non-Javadoc)
69: * @see org.eclipse.ui.part.WorkbenchPart#dispose()
70: */
71: public void dispose() {
72: super .dispose();
73:
74: // If we allocated an image for the title image of this view, deallocate it here.
75: if (image != null) {
76: image.dispose();
77: }
78: }
79: }
|