Changeset 3:296778dfdf6d for com.goldenhammers.merclipse/src/com/goldenhammers/merclipse/history/MercurialHistoryPage.java
Legend:
- Unmodified
- Added
- Removed
-
com.goldenhammers.merclipse/src/com/goldenhammers/merclipse/history/MercurialHistoryPage.java
r0 r3 14 14 15 15 import org.eclipse.core.resources.IFile; 16 import org.eclipse.core.resources.IProject; 16 17 import org.eclipse.core.resources.IResource; 18 import org.eclipse.core.runtime.IPath; 17 19 import org.eclipse.jface.action.Action; 18 20 import org.eclipse.jface.action.IAction; … … 81 83 @Override 82 84 public void run() { 83 IFile file = getCurrentFile();85 IFile file = (IFile) getCurrentResource(); 84 86 85 87 MercurialWorkingDir workingDir = MercurialUtils.getWorkingDirectory(file); … … 133 135 if (newInput != null) { 134 136 // TODO what if the files are commited? we need a new pull here. 135 mfh = new MercurialFileHistory(getCurrentFile()); 137 IResource currentResource = getCurrentResource(); 138 139 if (currentResource.getType() == IResource.FILE) { 140 mfh = new MercurialFileHistory((IFile) currentResource); 141 } else { 142 mfh = new MercurialFileHistory(MercurialUtils.getWorkingDirectory(currentResource)); 143 } 136 144 } else { 137 145 mfh = null; … … 162 170 163 171 private void fillTableMenu(IMenuManager menuMgr) { 172 if (getCurrentResource().getType() == IResource.PROJECT) { 173 return; 174 } 175 164 176 ISelection sel = tableViewer.getSelection(); 165 177 StructuredSelection structuredSel = (StructuredSelection) sel; … … 184 196 return container; 185 197 } 186 187 protected I File getCurrentFile() {188 return (I File) getInput();198 199 protected IResource getCurrentResource() { 200 return (IResource) getInput(); 189 201 } 190 202 … … 194 206 195 207 public String getDescription() { 208 IPath location = getCurrentResource().getLocation(); 209 210 if (location != null) { 211 return location.toString(); 212 } 213 196 214 return getName(); 197 215 } 198 216 199 217 public String getName() { 200 return getCurrent File().getName();218 return getCurrentResource().getName(); 201 219 } 202 220 … … 223 241 224 242 if (isValidInput(input)) { 225 currentRevision = new LocalFileRevision(getCurrentFile()); 226 tableViewer.setInput(getCurrentFile()); 243 if (getCurrentResource().getType() == IResource.FILE) { 244 currentRevision = new LocalFileRevision((IFile) getCurrentResource()); 245 } else { 246 currentRevision = null; 247 } 248 tableViewer.setInput(getCurrentResource()); 227 249 return true; 228 250 } … … 232 254 233 255 public boolean isValidInput(Object object) { 234 return object instanceof IFile ;256 return object instanceof IFile || object instanceof IProject; 235 257 } 236 258
