1 11 package org.eclipse.team.internal.ccvs.ui.model; 12 13 14 import java.lang.reflect.InvocationTargetException ; 15 16 import org.eclipse.core.runtime.IProgressMonitor; 17 import org.eclipse.jface.operation.IRunnableWithProgress; 18 import org.eclipse.team.core.TeamException; 19 import org.eclipse.team.internal.ccvs.core.ICVSRemoteFile; 20 import org.eclipse.team.internal.ccvs.core.ILogEntry; 21 import org.eclipse.team.internal.ccvs.ui.*; 22 import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; 23 import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants; 24 import org.eclipse.ui.views.properties.IPropertyDescriptor; 25 import org.eclipse.ui.views.properties.IPropertySource; 26 import org.eclipse.ui.views.properties.PropertyDescriptor; 27 28 public class CVSRemoteFilePropertySource implements IPropertySource { 29 ICVSRemoteFile file; 30 ILogEntry entry; 31 boolean initialized; 32 33 static protected IPropertyDescriptor[] propertyDescriptors = new IPropertyDescriptor[5]; 35 { 36 PropertyDescriptor descriptor; 37 String category = CVSUIMessages.cvs; 38 39 descriptor = new PropertyDescriptor(ICVSUIConstants.PROP_NAME, CVSUIMessages.CVSRemoteFilePropertySource_name); 41 descriptor.setAlwaysIncompatible(true); 42 descriptor.setCategory(category); 43 propertyDescriptors[0] = descriptor; 44 descriptor = new PropertyDescriptor(ICVSUIConstants.PROP_REVISION, CVSUIMessages.CVSRemoteFilePropertySource_revision); 46 descriptor.setAlwaysIncompatible(true); 47 descriptor.setCategory(category); 48 propertyDescriptors[1] = descriptor; 49 descriptor = new PropertyDescriptor(ICVSUIConstants.PROP_DATE, CVSUIMessages.CVSRemoteFilePropertySource_date); 51 descriptor.setAlwaysIncompatible(true); 52 descriptor.setCategory(category); 53 propertyDescriptors[2] = descriptor; 54 descriptor = new PropertyDescriptor(ICVSUIConstants.PROP_AUTHOR, CVSUIMessages.CVSRemoteFilePropertySource_author); 56 descriptor.setAlwaysIncompatible(true); 57 descriptor.setCategory(category); 58 propertyDescriptors[3] = descriptor; 59 descriptor = new PropertyDescriptor(ICVSUIConstants.PROP_COMMENT, CVSUIMessages.CVSRemoteFilePropertySource_comment); 61 descriptor.setAlwaysIncompatible(true); 62 descriptor.setCategory(category); 63 propertyDescriptors[4] = descriptor; 64 } 65 66 69 public CVSRemoteFilePropertySource(ICVSRemoteFile file) { 70 this.file = file; 71 } 72 73 76 public Object getEditableValue() { 77 return this; 78 } 79 80 83 public IPropertyDescriptor[] getPropertyDescriptors() { 84 return propertyDescriptors; 85 } 86 87 90 public Object getPropertyValue(Object id) { 91 if (!initialized) { 92 initialize(); 93 initialized = true; 94 } 95 if (id.equals(ICVSUIConstants.PROP_NAME)) { 96 return file.getName(); 97 } 98 if (entry != null) { 99 if (id.equals(ICVSUIConstants.PROP_REVISION)) { 100 return entry.getRevision(); 101 } 102 if (id.equals(ICVSUIConstants.PROP_DATE)) { 103 return entry.getDate(); 104 } 105 if (id.equals(ICVSUIConstants.PROP_AUTHOR)) { 106 return entry.getAuthor(); 107 } 108 if (id.equals(ICVSUIConstants.PROP_COMMENT)) { 109 return entry.getComment(); 110 } 111 } 112 return ""; } 114 115 119 public boolean isPropertySet(Object property) { 120 return false; 121 } 122 128 public void resetPropertyValue(Object property) { 129 } 130 133 public void setPropertyValue(Object name, Object value) { 134 } 135 136 private void initialize() { 137 try { 138 CVSUIPlugin.runWithProgress(null, true , new IRunnableWithProgress() { 139 public void run(IProgressMonitor monitor) throws InvocationTargetException , InterruptedException { 140 try { 141 ILogEntry[] entries = file.getLogEntries(monitor); 142 String revision = file.getRevision(); 143 for (int i = 0; i < entries.length; i++) { 144 if (entries[i].getRevision().equals(revision)) { 145 entry = entries[i]; 146 return; 147 } 148 } 149 } catch (TeamException e) { 150 throw new InvocationTargetException (e); 151 } 152 } 153 }); 154 } catch (InterruptedException e) { } catch (InvocationTargetException e) { 156 CVSUIPlugin.openError(null, null, null, e); 157 } 158 } 159 } 160 | Popular Tags |