1 11 package org.eclipse.ui.internal.ide; 12 13 import java.net.URI ; 14 15 import org.eclipse.core.filesystem.IFileInfo; 16 import org.eclipse.core.resources.IResource; 17 import org.eclipse.jface.resource.ImageDescriptor; 18 import org.eclipse.jface.viewers.IDecoration; 19 import org.eclipse.jface.viewers.ILabelProviderListener; 20 import org.eclipse.jface.viewers.ILightweightLabelDecorator; 21 import org.eclipse.ui.internal.ide.dialogs.IDEResourceInfoUtils; 22 import org.eclipse.ui.plugin.AbstractUIPlugin; 23 24 30 public class LinkedResourceDecorator implements ILightweightLabelDecorator { 31 private static final ImageDescriptor LINK; 32 33 private static final ImageDescriptor LINK_WARNING; 34 35 static { 36 LINK = AbstractUIPlugin.imageDescriptorFromPlugin( 37 IDEWorkbenchPlugin.IDE_WORKBENCH, 38 "$nl$/icons/full/ovr16/link_ovr.gif"); LINK_WARNING = AbstractUIPlugin.imageDescriptorFromPlugin( 40 IDEWorkbenchPlugin.IDE_WORKBENCH, 41 "$nl$/icons/full/ovr16/linkwarn_ovr.gif"); } 43 44 47 public LinkedResourceDecorator() { 48 } 49 50 53 public void addListener(ILabelProviderListener listener) { 54 } 55 56 59 public void dispose() { 60 } 62 63 66 public boolean isLabelProperty(Object element, String property) { 67 return false; 68 } 69 70 73 public void removeListener(ILabelProviderListener listener) { 74 } 75 76 84 public void decorate(Object element, IDecoration decoration) { 85 86 if (element instanceof IResource == false) { 87 return; 88 } 89 IResource resource = (IResource) element; 90 if (resource.isLinked()) { 91 IFileInfo fileInfo = null; 92 URI location = resource.getLocationURI(); 93 if (location != null) { 94 fileInfo = IDEResourceInfoUtils.getFileInfo(location); 95 } 96 if (fileInfo != null && fileInfo.exists()) { 97 decoration.addOverlay(LINK); 98 } else { 99 decoration.addOverlay(LINK_WARNING); 100 } 101 } 102 103 } 104 105 } 106 | Popular Tags |