1 11 package org.eclipse.ui.views.properties; 12 13 import org.eclipse.core.resources.IFile; 14 import org.eclipse.jface.viewers.IBasicPropertyConstants; 15 import org.eclipse.osgi.util.TextProcessor; 16 import org.eclipse.ui.internal.ide.dialogs.IDEResourceInfoUtils; 17 18 21 public class FilePropertySource extends ResourcePropertySource { 22 23 private static PropertyDescriptor fileDescriptor; 24 static { 25 fileDescriptor = new PropertyDescriptor( 26 IResourcePropertyConstants.P_SIZE_RES, 27 IResourcePropertyConstants.P_DISPLAY_SIZE); 28 fileDescriptor.setAlwaysIncompatible(true); 29 fileDescriptor 30 .setCategory(IResourcePropertyConstants.P_FILE_SYSTEM_CATEGORY); 31 } 32 33 37 public FilePropertySource(IFile file) { 38 super(file); 39 } 40 41 45 private static PropertyDescriptor getInitialPropertyDescriptor() { 46 return fileDescriptor; 47 } 48 49 52 public IPropertyDescriptor[] getPropertyDescriptors() { 53 IPropertyDescriptor[] superDescriptors = super.getPropertyDescriptors(); 54 int superLength = superDescriptors.length; 55 IPropertyDescriptor[] fileDescriptors = new IPropertyDescriptor[superLength + 1]; 56 System.arraycopy(superDescriptors, 0, fileDescriptors, 0, superLength); 57 fileDescriptors[superLength] = getInitialPropertyDescriptor(); 58 59 return fileDescriptors; 60 } 61 62 65 public Object getPropertyValue(Object key) { 66 Object returnValue = (key.equals(IBasicPropertyConstants.P_TEXT)) ? TextProcessor 67 .process(element.getName()) 68 : super.getPropertyValue(key); 69 70 if (returnValue != null) { 71 return returnValue; 72 } 73 74 if (key.equals(IResourcePropertyConstants.P_SIZE_RES)) { 75 return IDEResourceInfoUtils.getSizeString((IFile) element); 76 } 77 return null; 78 } 79 } 80 | Popular Tags |