KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > navigator > resources > workbench > TabbedPropertySheetTitleProvider


1 /*******************************************************************************
2  * Copyright (c) 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
12 package org.eclipse.ui.internal.navigator.resources.workbench;
13
14 import org.eclipse.jface.viewers.ILabelProvider;
15 import org.eclipse.jface.viewers.LabelProvider;
16 import org.eclipse.swt.graphics.Image;
17 import org.eclipse.ui.IWorkbenchPart;
18 import org.eclipse.ui.PlatformUI;
19 import org.eclipse.ui.internal.navigator.resources.plugin.WorkbenchNavigatorPlugin;
20 import org.eclipse.ui.navigator.IDescriptionProvider;
21 import org.eclipse.ui.navigator.INavigatorContentService;
22
23 /**
24  * Defines a label provider for the title bar in the tabbed properties view.
25  *
26  * @since 3.2
27  */

28 public class TabbedPropertySheetTitleProvider extends LabelProvider {
29
30     private ILabelProvider labelProvider;
31
32     private IDescriptionProvider descriptionProvider;
33
34     /**
35      * Constructor for CommonNavigatorTitleProvider.
36      */

37     public TabbedPropertySheetTitleProvider() {
38         super();
39         IWorkbenchPart part = PlatformUI.getWorkbench()
40                 .getActiveWorkbenchWindow().getActivePage().getActivePart();
41
42         INavigatorContentService contentService = (INavigatorContentService) part
43                 .getAdapter(INavigatorContentService.class);
44
45         if (contentService != null) {
46             labelProvider = contentService.createCommonLabelProvider();
47             descriptionProvider = contentService
48                     .createCommonDescriptionProvider();
49         } else {
50             WorkbenchNavigatorPlugin.log(
51                     "Could not acquire INavigatorContentService from part (\"" //$NON-NLS-1$
52
+ part.getTitle() + "\").", null); //$NON-NLS-1$
53
}
54     }
55
56     /**
57      * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
58      */

59     public Image getImage(Object JavaDoc object) {
60         return labelProvider != null ? labelProvider.getImage(object) : null;
61     }
62
63     /**
64      * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
65      */

66     public String JavaDoc getText(Object JavaDoc object) {
67         return descriptionProvider != null ? descriptionProvider
68                 .getDescription(object) : null;
69     }
70 }
71
Popular Tags