1 11 package org.eclipse.pde.internal.ui.view; 12 13 import com.ibm.icu.text.DateFormat; 14 import java.util.Date ; 15 16 import org.eclipse.pde.internal.core.FileAdapter; 17 import org.eclipse.ui.views.properties.IPropertyDescriptor; 18 import org.eclipse.ui.views.properties.IPropertySource; 19 import org.eclipse.ui.views.properties.PropertyDescriptor; 20 21 public class FileAdapterPropertySource implements IPropertySource { 22 private IPropertyDescriptor [] descriptors; 23 private FileAdapter adapter; 24 25 28 public FileAdapterPropertySource() { 29 super(); 30 } 31 32 public void setAdapter(FileAdapter adapter) { 33 this.adapter = adapter; 34 } 35 36 39 public Object getEditableValue() { 40 return null; 41 } 42 43 46 public IPropertyDescriptor[] getPropertyDescriptors() { 47 if (descriptors==null) { 48 descriptors = new IPropertyDescriptor[5]; 49 descriptors[0] = new PropertyDescriptor("editable", "editable"); descriptors[1] = new PropertyDescriptor("last", "last modified"); descriptors[2] = new PropertyDescriptor("name", "name"); descriptors[3] = new PropertyDescriptor("path", "path"); descriptors[4] = new PropertyDescriptor("size", "size"); } 55 return descriptors; 56 } 57 58 61 public Object getPropertyValue(Object id) { 62 String key = id.toString(); 63 if (key.equals("editable")) return "false"; if (key.equals("last")) { Date date = new Date (adapter.getFile().lastModified()); 67 return DateFormat.getInstance().format(date); 68 } 69 if (key.equals("name")) return adapter.getFile().getName(); 71 if (key.equals("path")) return adapter.getFile().getAbsolutePath(); 73 if (key.equals("size")) return ""+adapter.getFile().length(); return null; 76 } 77 78 81 public boolean isPropertySet(Object id) { 82 return false; 83 } 84 85 88 public void resetPropertyValue(Object id) { 89 } 90 91 94 public void setPropertyValue(Object id, Object value) { 95 } 96 97 } 98 | Popular Tags |