1 11 package org.eclipse.team.internal.ui.mapping; 12 13 import org.eclipse.core.resources.mapping.ModelProvider; 14 import org.eclipse.core.resources.mapping.ResourceMapping; 15 import org.eclipse.jface.viewers.LabelProvider; 16 import org.eclipse.swt.graphics.Image; 17 import org.eclipse.ui.model.WorkbenchLabelProvider; 18 19 public class ResourceMappingLabelProvider extends LabelProvider { 20 WorkbenchLabelProvider provider = new WorkbenchLabelProvider(); 21 public String getText(Object element) { 22 if (element instanceof ResourceMapping) { 23 ResourceMapping mapping = (ResourceMapping) element; 24 String text = provider.getText(mapping.getModelObject()); 25 if (text != null && text.length() > 0) 26 return text; 27 return super.getText(mapping.getModelObject()); 28 } 29 if (element instanceof ModelProvider) { 30 ModelProvider provider = (ModelProvider) element; 31 return provider.getDescriptor().getLabel(); 32 } 33 String text = provider.getText(element); 34 if (text != null && text.length() > 0) 35 return text; 36 return super.getText(element); 37 } 38 public Image getImage(Object element) { 39 Image image = provider.getImage(element); 40 if (image != null) 41 return image; 42 if (element instanceof ResourceMapping) { 43 ResourceMapping mapping = (ResourceMapping) element; 44 image = provider.getImage(mapping.getModelObject()); 45 if (image != null) 46 return image; 47 } 48 return super.getImage(element); 49 } 50 public void dispose() { 51 provider.dispose(); 52 super.dispose(); 53 } 54 } | Popular Tags |