1 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 28 public class TabbedPropertySheetTitleProvider extends LabelProvider { 29 30 private ILabelProvider labelProvider; 31 32 private IDescriptionProvider descriptionProvider; 33 34 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 (\"" + part.getTitle() + "\").", null); } 54 } 55 56 59 public Image getImage(Object object) { 60 return labelProvider != null ? labelProvider.getImage(object) : null; 61 } 62 63 66 public String getText(Object object) { 67 return descriptionProvider != null ? descriptionProvider 68 .getDescription(object) : null; 69 } 70 } 71 | Popular Tags |