Cleanup of Generic history view
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/filehistory/IFileHistoryProvider.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/filehistory/IFileHistoryProvider.java
index 1814e7b..fa7cce7 100644
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/filehistory/IFileHistoryProvider.java
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/filehistory/IFileHistoryProvider.java
@@ -35,5 +35,15 @@
 	 * @return the history of the file
 	 */
 	public abstract IFileHistory getFileHistoryFor(IResource resource, IProgressMonitor monitor);
+	
+
+	/**
+	 * Returns the file revision of the passed in resourrce or null if that file revision cannot be
+	 * determined
+	 * 
+	 * @param resource
+	 * @return the file revision belonging to the passed in resource or null
+	 */
+	public abstract IFileRevision getWorkspaceFileRevision(IResource resource);
 
 }
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/FileHistory.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/FileHistory.java
index 28b8b7f..e4f4f80 100644
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/FileHistory.java
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/FileHistory.java
@@ -11,17 +11,8 @@
 
 package org.eclipse.team.internal.core;
 
-import org.eclipse.team.core.TeamException;
 import org.eclipse.team.core.filehistory.IFileHistory;
-import org.eclipse.team.core.filehistory.IFileRevision;
 
 public abstract class FileHistory implements IFileHistory {
 
-	public abstract IFileRevision[] getFileRevisions() throws TeamException;
-
-	public abstract IFileRevision getFileRevision(String id) throws TeamException;
-
-	public abstract IFileRevision getPredecessor(IFileRevision revision) throws TeamException;
-
-	public abstract IFileRevision[] getDirectDescendents(IFileRevision revision) throws TeamException;
 }
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/FileHistoryProvider.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/FileHistoryProvider.java
new file mode 100644
index 0000000..98b240f
--- /dev/null
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/FileHistoryProvider.java
@@ -0,0 +1,7 @@
+package org.eclipse.team.internal.core;
+
+import org.eclipse.team.core.filehistory.IFileHistoryProvider;
+
+public abstract class FileHistoryProvider implements IFileHistoryProvider {
+
+}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/filehistory/CVSFileHistoryProvider.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/filehistory/CVSFileHistoryProvider.java
index 090ed4a..2cda305 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/filehistory/CVSFileHistoryProvider.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/filehistory/CVSFileHistoryProvider.java
@@ -14,13 +14,18 @@
 import org.eclipse.core.resources.IResource;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.team.core.filehistory.IFileHistory;
-import org.eclipse.team.core.filehistory.IFileHistoryProvider;
+import org.eclipse.team.core.filehistory.IFileRevision;
 import org.eclipse.team.internal.ccvs.core.CVSException;
+import org.eclipse.team.internal.ccvs.core.CVSTag;
 import org.eclipse.team.internal.ccvs.core.ICVSFile;
 import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource;
+import org.eclipse.team.internal.ccvs.core.client.listeners.LogEntry;
 import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
+import org.eclipse.team.internal.ccvs.core.resources.RemoteFile;
+import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
+import org.eclipse.team.internal.core.FileHistoryProvider;
 
-public class CVSFileHistoryProvider implements IFileHistoryProvider {
+public class CVSFileHistoryProvider extends FileHistoryProvider {
 
 	/**
 	 * see <code>org.eclipse.team.core.IFileHistoryProvider</code>
@@ -44,4 +49,21 @@
 		return null;
 	}
 
+	public IFileRevision getWorkspaceFileRevision(IResource resource) {
+		
+		ICVSRemoteResource remoteResource;
+		try {
+			remoteResource = CVSWorkspaceRoot.getRemoteResourceFor(resource);
+			if (remoteResource != null && 
+				remoteResource instanceof RemoteFile){
+				ResourceSyncInfo syncInfo = remoteResource.getSyncInfo();
+				LogEntry cvsEntry = new LogEntry((RemoteFile) remoteResource, syncInfo.getRevision(), "", null,"","", new CVSTag[0]);  //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+				return new CVSFileRevision(cvsEntry);
+			}
+		} catch (CVSException e) {
+		}
+		
+		return null;
+	}
+
 }
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamUIMessages.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamUIMessages.java
index f0a8065..5e1e720 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamUIMessages.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamUIMessages.java
@@ -334,6 +334,7 @@
 	public static String GenericHistoryTableProvider_Comment;
 	public static String OpenRevisionAction_DeletedRevisionTitle;
 	public static String OpenRevisionAction_DeletedRevisionMessage;
+	public static String GenericHistoryView_ErrorFetchingEntries;
 	
 	static {
 		// load message values from bundle file
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/filehistory/GenericHistoryDropAdapter.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/filehistory/GenericHistoryDropAdapter.java
index 2a791e9..84c7ef4 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/filehistory/GenericHistoryDropAdapter.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/filehistory/GenericHistoryDropAdapter.java
@@ -55,19 +55,15 @@
     		if (sources.length == 0) return false;
     		IResource resource = sources[0];
     		if (!(resource instanceof IFile)) return false;
-    		view.showHistory(resource, true /* fetch */);
+    			view.showHistory(resource, true /* fetch */);
     		return true;
-        } /*else if( data instanceof ICVSRemoteFile) {
-            view.showHistory((ICVSRemoteFile) data, true  fetch );
-            return true;
-        }*/
+        }
         return false;
 	}
 	
 	public boolean validateDrop(Object target, int operation, TransferData transferType) {
         if (transferType != null && 
-            ResourceTransfer.getInstance().isSupportedType(transferType) /*||
-             CVSResourceTransfer.getInstance().isSupportedType(transferType))*/) {
+            ResourceTransfer.getInstance().isSupportedType(transferType)) {
 			return true;
 		}
 		return false;
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/filehistory/GenericHistoryTableProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/filehistory/GenericHistoryTableProvider.java
index 5fd99fb..df3ae6a 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/filehistory/GenericHistoryTableProvider.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/filehistory/GenericHistoryTableProvider.java
@@ -14,7 +14,9 @@
 import java.text.DateFormat;
 import java.util.Date;
 
+import org.eclipse.core.resources.IFile;
 import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.resource.JFaceResources;
 import org.eclipse.jface.viewers.ColumnWeightData;
 import org.eclipse.jface.viewers.IColorProvider;
 import org.eclipse.jface.viewers.IFontProvider;
@@ -32,18 +34,22 @@
 import org.eclipse.swt.events.SelectionListener;
 import org.eclipse.swt.graphics.Color;
 import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
 import org.eclipse.swt.graphics.Image;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Table;
 import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.team.core.RepositoryProvider;
 import org.eclipse.team.core.filehistory.IFileHistory;
 import org.eclipse.team.core.filehistory.IFileRevision;
 import org.eclipse.team.internal.ui.TeamUIMessages;
 
 public class GenericHistoryTableProvider {
 
-	private IFileHistory currentFile;
+	private IFileHistory currentFileHistory;
+	private IFile currentFile;
 	private String currentRevision;
 	private TableViewer viewer;
 	private Font currentRevisionFont;
@@ -84,12 +90,11 @@
 		 * @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object)
 		 */
 		public Color getForeground(Object element) {
-		/*	ILogEntry entry = adaptToLogEntry(element);
+			IFileRevision entry = adaptToFileRevision(element);
 			if (entry.isDeletion())  {
 				return Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW);
-			} else  {
-				return null;
-			}*/
+			} 
+			
 			return null;
 		}
 		/* (non-Javadoc)
@@ -103,12 +108,12 @@
 		 * @see org.eclipse.jface.viewers.IFontProvider#getFont(java.lang.Object)
 		 */
 		public Font getFont(Object element) {
-	/*		ILogEntry entry = adaptToLogEntry(element);
+			IFileRevision entry = adaptToFileRevision(element);
 			if (entry == null)
 				return null;
-			String revision = entry.getRevision();
-			String currentRevision = getCurrentRevision();
-			if (currentRevision != null && currentRevision.equals(revision)) {
+			String revision = entry.getContentIndentifier();
+			String tempCurrentRevision = getCurrentRevision();
+			if (tempCurrentRevision != null && tempCurrentRevision.equals(revision)) {
 				if (currentRevisionFont == null) {
 					Font defaultFont = JFaceResources.getDefaultFont();
 					FontData[] data = defaultFont.getFontData();
@@ -118,7 +123,7 @@
 					currentRevisionFont = new Font(viewer.getTable().getDisplay(), data);
 				}
 				return currentRevisionFont;
-			}*/
+			}
 			return null;
 		}
 	}
@@ -245,15 +250,15 @@
 		viewer.setLabelProvider(new HistoryLabelProvider());
 		
 		// By default, reverse sort by revision.
-		HistorySorter sorter = new HistorySorter(COL_AUTHOR);
+		HistorySorter sorter = new HistorySorter(COL_REVISIONID);
 		sorter.setReversed(true);
 		viewer.setSorter(sorter);
 		
 		table.addDisposeListener(new DisposeListener() {
 			public void widgetDisposed(DisposeEvent e) {
-				/*if(currentRevisionFont != null) {
+				if(currentRevisionFont != null) {
 					currentRevisionFont.dispose();
-				}*/
+				}
 			}
 		});
 		
@@ -331,12 +336,28 @@
 		};
 	}
 	
-	public void setFile(IFileHistory file)  {
-		this.currentFile = file;
-		//this.currentRevision = getRevision(this.currentFile);
+	public void setFile(IFileHistory fileHistory, IFile file)  {
+		this.currentFileHistory = fileHistory;
+		this.currentFile= file;
+		this.currentRevision = findCurrentRevision();
+	}
+	
+	private String findCurrentRevision() {
+		
+		RepositoryProvider teamProvider = RepositoryProvider.getProvider(currentFile.getProject());
+		IFileRevision fileRevision = teamProvider.getFileHistoryProvider().getWorkspaceFileRevision(currentFile);
+		
+		if (fileRevision != null )
+			return fileRevision.getContentIndentifier();
+		
+		return null;
 	}
 
 	public IFileHistory getIFileHistory() {
-		return this.currentFile;
+		return this.currentFileHistory;
+	}
+	
+	public String getCurrentRevision() {
+		return currentRevision;
 	}
 }
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/filehistory/GenericHistoryView.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/filehistory/GenericHistoryView.java
index 60b7a21..0dcc201 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/filehistory/GenericHistoryView.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/filehistory/GenericHistoryView.java
@@ -40,6 +40,7 @@
 import org.eclipse.jface.viewers.TableViewer;
 import org.eclipse.jface.viewers.Viewer;
 import org.eclipse.jface.viewers.ViewerSorter;
+import org.eclipse.osgi.util.NLS;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.custom.BusyIndicator;
 import org.eclipse.swt.custom.SashForm;
@@ -93,8 +94,6 @@
 	private IAction toggleListAction;
 	private Action refreshAction;
 	private Action linkWithEditorAction;
-	private Action getPredecessor;
-	private Action getDirectDescendents;
 	
 	private SashForm sashForm;
 	private SashForm innerSashForm;
@@ -265,29 +264,7 @@
 			 }
 		 };
 		 linkWithEditorAction.setChecked(isLinkingEnabled());
-		 
-		getDirectDescendents = new Action(TeamUIMessages.GenericHistoryView_GetDirectDescendents, null) {
-			public void run() {
-				IFileHistory currentHistory = historyTableProvider.getIFileHistory();
-				try {
-					entries=currentHistory.getDirectDescendents(currentSelection);
-				} catch (TeamException e) {}
-				
-				tableViewer.refresh();
-			}
-		};
-	
-		getPredecessor = new Action(TeamUIMessages.GenericHistoryView_GetPredecessor, null) {
-			public void run() {
-				IFileHistory currentHistory = historyTableProvider.getIFileHistory();
-				try {
-					entries=new IFileRevision[] {currentHistory.getPredecessor(currentSelection)};
-				} catch (TeamException e) {}
-				
-				tableViewer.refresh();
-			}
-		};
-		
+		 		
 		// Toggle text visible action
 		final IPreferenceStore store = TeamUIPlugin.getPlugin().getPreferenceStore();
 		toggleTextAction = new Action(TeamUIMessages.GenericHistoryView_ShowCommentViewer) { 
@@ -350,8 +327,6 @@
 
 	private void fillTableMenu(IMenuManager manager) {
 		// file actions go first (view file)
-		manager.add(getPredecessor);
-		manager.add(getDirectDescendents);
 		manager.add(new Separator("additions")); //$NON-NLS-1$
 		manager.add(refreshAction);
 		manager.add(new Separator("additions-end")); //$NON-NLS-1$
@@ -398,6 +373,7 @@
 						try {
 							fetchLogEntriesJob.join();
 						} catch (InterruptedException e) {
+							TeamUIPlugin.log(new TeamException(NLS.bind(TeamUIMessages.GenericHistoryView_ErrorFetchingEntries, new String[] { "" }), e));   //$NON-NLS-1$
 						}
 					}
 					fetchLogEntriesJob.setRemoteFile(remoteFile);
@@ -488,7 +464,7 @@
 			} catch (TeamException e) {
 
 			}
-			historyTableProvider.setFile(fileHistory);
+			historyTableProvider.setFile(fileHistory, file);
 			tableViewer.setInput(fileHistory);
 			setContentDescription(newfile.getName());
 		} else {
@@ -576,6 +552,23 @@
 		return linkingEnabled;
 	}
 
+	public void dispose() {
+		shutdown = true;
+
+		if(fetchLogEntriesJob != null) {
+			if(fetchLogEntriesJob.getState() != Job.NONE) {
+				fetchLogEntriesJob.cancel();
+				try {
+					fetchLogEntriesJob.join();
+				} catch (InterruptedException e) {
+					TeamUIPlugin.log(new TeamException(NLS.bind(TeamUIMessages.GenericHistoryView_ErrorFetchingEntries, new String[] { "" }), e));   //$NON-NLS-1$
+				}
+			}
+		}
+		getSite().getPage().removePartListener(partListener);
+		getSite().getPage().removePartListener(partListener2);
+	}	
+	
 	private class FetchLogEntriesJob extends Job {
 		public IFileHistory fileHistory;
 
@@ -611,7 +604,7 @@
 		public IFileHistory getRemoteFile() {
 			return this.fileHistory;
 		}
-	};
+	}
     
 	/**
 	 * A default content provider to prevent subclasses from
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties
index 1fd8622..f10c8c6 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties
@@ -338,6 +338,7 @@
 GenericHistoryTableProvider_Author=Author
 GenericHistoryView_ShowTagViewer=Show Tag Viewer
 GenericHistoryView_GetDirectDescendents=Get Direct Descendents
+GenericHistoryView_ErrorFetchingEntries=Error fetching entries for {0}
 GenericHistoryTableProvider_RevisionTime=Revision Time
 GenericHistoryView_WrapComments=Wrap Comments
 OpenRevisionAction_DeletedRevisionTitle=Deleted Revision