Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2006-01-24 03:04:55 +0000
committerMichael Valenta2006-01-24 03:04:55 +0000
commit8ef304dfa48a1c14200d9ea869efbcb0f02abc00 (patch)
tree043a0d34a8179375436e087f3bea035ff105b2fa
parentd14b98e242bb5e1d31ecebf605692f413dffd453 (diff)
downloadeclipse.platform.team-8ef304dfa48a1c14200d9ea869efbcb0f02abc00.tar.gz
eclipse.platform.team-8ef304dfa48a1c14200d9ea869efbcb0f02abc00.tar.xz
eclipse.platform.team-8ef304dfa48a1c14200d9ea869efbcb0f02abc00.zip
The latest history view fixes
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSAdapterFactory.java2
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/GenericHistoryDropAdapter.java14
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/GenericHistoryView.java23
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/LocalHistoryTableProvider.java2
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/TeamUI.java44
5 files changed, 60 insertions, 25 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSAdapterFactory.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSAdapterFactory.java
index c8a17c77f..d52071da9 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSAdapterFactory.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSAdapterFactory.java
@@ -75,7 +75,7 @@ public class CVSAdapterFactory implements IAdapterFactory {
* Method declared on IAdapterFactory.
*/
public Class[] getAdapterList() {
- return new Class[] {IWorkbenchAdapter.class, IPropertySource.class, IDeferredWorkbenchAdapter.class};
+ return new Class[] {IWorkbenchAdapter.class, IPropertySource.class, IDeferredWorkbenchAdapter.class, IHistoryPageSource.class};
}
/**
* Returns the property source for the given object. Caches
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/GenericHistoryDropAdapter.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/GenericHistoryDropAdapter.java
index 5c87fc533..1c6b84628 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/GenericHistoryDropAdapter.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/GenericHistoryDropAdapter.java
@@ -13,13 +13,11 @@ package org.eclipse.team.internal.ui.history;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
-import org.eclipse.jface.viewers.ViewerDropAdapter;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.DropTargetEvent;
-import org.eclipse.swt.dnd.TransferData;
+import org.eclipse.swt.dnd.*;
+import org.eclipse.ui.part.PluginDropAdapter;
import org.eclipse.ui.part.ResourceTransfer;
-public class GenericHistoryDropAdapter extends ViewerDropAdapter {
+public class GenericHistoryDropAdapter extends PluginDropAdapter {
private GenericHistoryView view;
@@ -72,7 +70,11 @@ public class GenericHistoryDropAdapter extends ViewerDropAdapter {
if (transferType != null && ResourceTransfer.getInstance().isSupportedType(transferType)) {
return true;
}
- return false;
+
+ return super.validateDrop(target, operation, transferType);
}
+ protected Object getCurrentTarget() {
+ return view;
+ }
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/GenericHistoryView.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/GenericHistoryView.java
index 68aa341da..8ba9c7de9 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/GenericHistoryView.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/GenericHistoryView.java
@@ -13,8 +13,7 @@ package org.eclipse.team.internal.ui.history;
import java.util.*;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.*;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.action.*;
@@ -82,6 +81,13 @@ public class GenericHistoryView extends ViewPart implements IHistoryView {
* The current page container
*/
PageContainer currentPageContainer;
+
+ /**
+ * The drop target + drop target listener
+ */
+ DropTarget dropTarget;
+ GenericHistoryDropAdapter dropAdapter;
+
private IPartListener partListener = new IPartListener() {
public void partActivated(IWorkbenchPart part) {
@@ -291,13 +297,14 @@ public class GenericHistoryView extends ViewPart implements IHistoryView {
*/
void initDragAndDrop() {
int ops = DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK;
- Transfer[] transfers = new Transfer[] {ResourceTransfer.getInstance(), ResourceTransfer.getInstance()};
+ Transfer[] transfers = new Transfer[] {ResourceTransfer.getInstance(), PluginTransfer.getInstance()};
- DropTarget dropTarget = new DropTarget(book, ops);
+ dropTarget = new DropTarget(book, ops);
dropTarget.setTransfer(transfers);
- dropTarget.addDropListener(new GenericHistoryDropAdapter(this));
+ dropAdapter = new GenericHistoryDropAdapter(this);
+ dropTarget.addDropListener(dropAdapter);
}
-
+
public void setFocus() {
// TODO Auto-generated method stub
@@ -519,7 +526,7 @@ public class GenericHistoryView extends ViewPart implements IHistoryView {
if (input instanceof FileRevisionEditorInput) {
IFile file;
try {
- file = ResourceUtil.getFile(((FileRevisionEditorInput) input).getStorage().getFullPath());
+ file = ResourcesPlugin.getWorkspace().getRoot().getFile(((FileRevisionEditorInput) input).getStorage().getFullPath());
if (file != null) {
itemDropped(file);
}
@@ -540,6 +547,8 @@ public class GenericHistoryView extends ViewPart implements IHistoryView {
public void dispose() {
super.dispose();
+ //Remove the drop listener
+ dropTarget.removeDropListener(dropAdapter);
//Call dispose on current and default pages
currentPageContainer.getPage().dispose();
defaultPageContainer.getPage().dispose();
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/LocalHistoryTableProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/LocalHistoryTableProvider.java
index 4b981f9dc..b37afa704 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/LocalHistoryTableProvider.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/LocalHistoryTableProvider.java
@@ -39,7 +39,7 @@ public class LocalHistoryTableProvider {
return ""; //$NON-NLS-1$
switch (columnIndex) {
case COL_DATE :
- String revision = DateFormat.getInstance().format(new Date(entry.getModificationTime()));
+ String revision = DateFormat.getDateTimeInstance().format(new Date(entry.getModificationTime()));
return revision;
case COL_AUTHOR:
return ""; //$NON-NLS-1$
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/TeamUI.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/TeamUI.java
index 911008dc0..a59a70f8c 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/TeamUI.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/TeamUI.java
@@ -16,6 +16,8 @@ import org.eclipse.team.internal.ui.history.GenericHistoryView;
import org.eclipse.team.internal.ui.synchronize.SynchronizeManager;
import org.eclipse.team.ui.history.IHistoryView;
import org.eclipse.team.ui.synchronize.ISynchronizeManager;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
/**
* TeamUI contains public API for generic UI-based Team functionality.
@@ -27,9 +29,6 @@ public class TeamUI {
// manages synchronize participants
private static ISynchronizeManager synchronizeManager;
- //returns the history view
- private static IHistoryView historyView;
-
/**
* Property constant indicating the global ignores list has changed.
*/
@@ -73,14 +72,39 @@ public class TeamUI {
}
/**
- * TODO: This won't work!!! We need to find the view in
- * the current perspective and, if we can't, open it
+ * Shows the history view and returns a handle to it. Note that in the case of many
+ * history views, the main history view is the one returned here. Users should use
+ * {@link #getHistoryView(IWorkbenchPage, Object)} if they want a particular instance
+ * of the history view.
+ *
+ * @return an IHistoryView which is the main history view if it is found or null if it can't be found
+ */
+ public static IHistoryView getHistoryView() {
+ try {
+ TeamUIPlugin.getActivePage().showView(GenericHistoryView.viewId);
+ return (IHistoryView) TeamUIPlugin.getActivePage().findView(GenericHistoryView.viewId);
+ } catch (PartInitException e) {
+ }
+
+ return null;
+ }
+
+ /**
+ * TODO: Enable this method by adding an id field to the IHistoryPageSource
+ * which can be used to uniquely identify each view.
+ *
+ * Returns the history view for the given object. The object needs to
+ * adapt to an IHistoryPageSource.
+ * @param object
* @return
*/
- public static IHistoryView getHistoryView(){
- if (historyView == null)
- historyView = new GenericHistoryView();
-
- return historyView;
+ public static IHistoryView getHistoryView(IWorkbenchPage page, Object object) {
+ try {
+ page.showView(GenericHistoryView.viewId);
+ return (IHistoryView) page.findView(GenericHistoryView.viewId);
+ } catch (PartInitException e) {
+ }
+
+ return null;
}
}

Back to the top