Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Michel-Lemieux2004-06-14 22:03:16 -0400
committerJean Michel-Lemieux2004-06-14 22:03:16 -0400
commitcf4de3196a2c690a369c8035fb84db025511cdc5 (patch)
treeec15a49ec4b4655d5e41ddd76a5202d570ed5ed6
parentd94f6f5bc5f2771af2ce5646576dd4a0080e19df (diff)
downloadeclipse.platform.team-branch_20040614_52196_reuse_wrong_view.tar.gz
eclipse.platform.team-branch_20040614_52196_reuse_wrong_view.tar.xz
eclipse.platform.team-branch_20040614_52196_reuse_wrong_view.zip
patch for 52196. Basically if the timestamp of a local file is different than that shown in the active compare editor, the compare editor is not re-used.branch_20040614_52196_reuse_wrong_view
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/SyncAction.java6
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshUserNotificationPolicy.java8
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshUserNotificationPolicyInModalDialog.java13
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/NavigateAction.java6
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/OpenInCompareAction.java57
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoCompareInput.java6
6 files changed, 40 insertions, 56 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/SyncAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/SyncAction.java
index 41219d0b2..315f9504f 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/SyncAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/SyncAction.java
@@ -11,8 +11,6 @@
package org.eclipse.team.internal.ccvs.ui.actions;
import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.compare.CompareUI;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.action.IAction;
@@ -26,6 +24,7 @@ import org.eclipse.team.internal.ccvs.core.*;
import org.eclipse.team.internal.ccvs.ui.Policy;
import org.eclipse.team.internal.ccvs.ui.subscriber.WorkspaceSynchronizeParticipant;
import org.eclipse.team.internal.ui.Utils;
+import org.eclipse.team.internal.ui.synchronize.actions.OpenInCompareAction;
import org.eclipse.team.ui.TeamUI;
import org.eclipse.team.ui.synchronize.*;
import org.eclipse.ui.PlatformUI;
@@ -76,8 +75,7 @@ public class SyncAction extends WorkspaceAction {
if (info.getKind() == SyncInfo.IN_SYNC) {
MessageDialog.openInformation(shell, Policy.bind("SyncAction.noChangesTitle"), Policy.bind("SyncAction.noChangesMessage")); //$NON-NLS-1$ //$NON-NLS-2$
} else {
- SyncInfoCompareInput input = new SyncInfoCompareInput(subscriber.getName(), info);
- CompareUI.openCompareEditor(input);
+ OpenInCompareAction.openCompareEditor(subscriber.getName(), info, false, null);
}
}
});
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshUserNotificationPolicy.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshUserNotificationPolicy.java
index 4a3a2604a..cb0f88eea 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshUserNotificationPolicy.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshUserNotificationPolicy.java
@@ -1,14 +1,15 @@
package org.eclipse.team.internal.ui.synchronize;
import java.util.*;
-import org.eclipse.compare.CompareUI;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.team.core.synchronize.SyncInfo;
import org.eclipse.team.internal.ui.*;
+import org.eclipse.team.internal.ui.synchronize.actions.OpenInCompareAction;
import org.eclipse.team.ui.TeamUI;
-import org.eclipse.team.ui.synchronize.*;
+import org.eclipse.team.ui.synchronize.ISynchronizeView;
+import org.eclipse.team.ui.synchronize.SubscriberParticipant;
import org.eclipse.ui.actions.ActionFactory;
/**
@@ -67,8 +68,7 @@ public class RefreshUserNotificationPolicy implements IRefreshSubscriberListener
IResource file = resources[0];
SyncInfo info = participant.getSubscriberSyncInfoCollector().getSyncInfoSet().getSyncInfo(file);
if(info != null) {
- SyncInfoCompareInput input = new SyncInfoCompareInput(participant.getName(), info);
- CompareUI.openCompareEditor(input);
+ OpenInCompareAction.openCompareEditor(participant.getName(), info, false, null);
prompt = false;
}
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshUserNotificationPolicyInModalDialog.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshUserNotificationPolicyInModalDialog.java
index e8fc36fc4..466f03af3 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshUserNotificationPolicyInModalDialog.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshUserNotificationPolicyInModalDialog.java
@@ -11,12 +11,10 @@
package org.eclipse.team.internal.ui.synchronize;
import org.eclipse.compare.CompareConfiguration;
-import org.eclipse.compare.CompareUI;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.widgets.Shell;
-import org.eclipse.team.core.synchronize.SyncInfo;
import org.eclipse.team.internal.ui.Policy;
import org.eclipse.team.internal.ui.Utils;
import org.eclipse.team.ui.TeamUI;
@@ -71,17 +69,6 @@ public class RefreshUserNotificationPolicyInModalDialog implements IRefreshSubsc
return resources.length == 1 && resources[0].getType() == IResource.FILE;
}
- protected void compareAndOpenEditors(IRefreshEvent event, SubscriberParticipant participant) {
- IResource[] resources = event.getResources();
- for (int i = 0; i < resources.length; i++) {
- SyncInfo info = participant.getSyncInfoSet().getSyncInfo(resources[i]);
- if (info != null) {
- SyncInfoCompareInput input = new SyncInfoCompareInput(event.getSubscriber().getName(), info);
- CompareUI.openCompareEditor(input);
- }
- }
- }
-
protected void compareAndOpenDialog(final IRefreshEvent event, final SubscriberParticipant participant) {
CompareConfiguration cc = new CompareConfiguration();
ParticipantPageSaveablePart input = new ParticipantPageSaveablePart(Utils.getShell(null), cc, configuration, participant) {
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/NavigateAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/NavigateAction.java
index fd1c983e3..341307d59 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/NavigateAction.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/NavigateAction.java
@@ -83,7 +83,7 @@ public class NavigateAction extends Action {
if(info.getLocal().getType() != IResource.FILE) {
if(! nav.gotoDifference(next)) {
info = getSyncInfoFromSelection();
- OpenInCompareAction.openCompareEditor(site, getTitle(), info, true /* keep focus */);
+ OpenInCompareAction.openCompareEditor(getTitle(), info, true /* keep focus */, site);
}
return;
}
@@ -102,14 +102,14 @@ public class NavigateAction extends Action {
if(navigator.selectChange(next)) {
if(! nav.gotoDifference(next)) {
info = getSyncInfoFromSelection();
- OpenInCompareAction.openCompareEditor(site, getTitle(), info, true /* keep focus */);
+ OpenInCompareAction.openCompareEditor(getTitle(), info, true /* keep focus */, site);
}
}
}
} else {
// otherwise, select the next change and open a compare editor which will automatically
// show the first change.
- OpenInCompareAction.openCompareEditor(site, getTitle(), info, true /* keep focus */);
+ OpenInCompareAction.openCompareEditor(getTitle(), info, true /* keep focus */, site);
}
}
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/OpenInCompareAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/OpenInCompareAction.java
index dad4c3c91..7b018ad30 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/OpenInCompareAction.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/OpenInCompareAction.java
@@ -11,23 +11,17 @@
package org.eclipse.team.internal.ui.synchronize.actions;
import org.eclipse.compare.CompareUI;
-import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.team.core.synchronize.SyncInfo;
+import org.eclipse.team.internal.core.Assert;
import org.eclipse.team.internal.ui.Utils;
import org.eclipse.team.internal.ui.synchronize.SyncInfoModelElement;
import org.eclipse.team.ui.synchronize.ISynchronizePageSite;
import org.eclipse.team.ui.synchronize.SyncInfoCompareInput;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IEditorReference;
-import org.eclipse.ui.IReusableEditor;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPartSite;
-import org.eclipse.ui.IWorkbenchSite;
+import org.eclipse.ui.*;
/**
* Action to open a compare editor from a SyncInfo object.
@@ -53,52 +47,53 @@ public class OpenInCompareAction extends Action {
if (obj instanceof SyncInfoModelElement) {
SyncInfo info = ((SyncInfoModelElement) obj).getSyncInfo();
if (info != null) {
- openCompareEditor(site, name, info, false /* don't keep focus */);
+ openCompareEditor(name, info, false /* don't keep focus */, site);
}
}
}
}
- public static SyncInfoCompareInput openCompareEditor(ISynchronizePageSite site, String name, SyncInfo info, boolean keepFocus) {
- SyncInfoCompareInput input = getCompareInput(name, info);
- if(input != null) {
- IWorkbenchSite ws = site.getWorkbenchSite();
- if (ws == null) return null;
- IWorkbenchPage wpage = ws.getPage();
- IEditorPart editor = findReusableCompareEditor(wpage);
+ public static SyncInfoCompareInput openCompareEditor(String name, SyncInfo info, boolean keepFocus, ISynchronizePageSite site) {
+ Assert.isNotNull(info);
+ Assert.isNotNull(name);
+
+ SyncInfoCompareInput input = new SyncInfoCompareInput(name, info);
+
+ IWorkbenchPage page = null;
+ if(site == null) {
+ IWorkbenchWindow window= PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ if (window != null)
+ page = window.getActivePage();
+ } else {
+ page = site.getWorkbenchSite().getPage();
+ }
+
+ if(page != null) {
+
+ IEditorPart editor = findReusableCompareEditor(page);
if(editor != null) {
IEditorInput otherInput = editor.getEditorInput();
if(otherInput.equals(input)) {
// simply provide focus to editor
- wpage.activate(editor);
+ page.activate(editor);
} else {
// if editor is currently not open on that input either re-use existing
CompareUI.reuseCompareEditor(input, (IReusableEditor)editor);
- wpage.activate(editor);
+ page.activate(editor);
}
} else {
CompareUI.openCompareEditor(input);
- editor = wpage.getActiveEditor();
+ editor = page.getActiveEditor();
}
- if(keepFocus) {
+ if(site != null && keepFocus) {
site.setFocus();
}
return input;
}
return null;
- }
-
- /**
- * Returns a SyncInfoCompareInput instance for the current selection.
- */
- private static SyncInfoCompareInput getCompareInput(String name, SyncInfo info) {
- if (info != null && info.getLocal() instanceof IFile) {
- return new SyncInfoCompareInput(name, info);
- }
- return null;
- }
+ }
/**
* Returns an editor that can be re-used. An open compare editor that
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoCompareInput.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoCompareInput.java
index de0592c09..b9583c65c 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoCompareInput.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SyncInfoCompareInput.java
@@ -85,6 +85,7 @@ public final class SyncInfoCompareInput extends CompareEditorInput implements IR
Assert.isNotNull(description);
this.description = description;
this.resource = sync.getLocal();
+ timestamp = resource.getLocalTimeStamp();
this.node = new MyDiffNode(null, sync);
initializeContentChangeListeners();
}
@@ -229,7 +230,10 @@ public final class SyncInfoCompareInput extends CompareEditorInput implements IR
if (other == this)
return true;
if (other instanceof SyncInfoCompareInput) {
- return getSyncInfo().equals(((SyncInfoCompareInput) other).getSyncInfo());
+ SyncInfo otherSyncInfo = ((SyncInfoCompareInput) other).getSyncInfo();
+ SyncInfo thisSyncInfo = getSyncInfo();
+ IResource otherResource = otherSyncInfo.getLocal();
+ return thisSyncInfo.equals(otherSyncInfo) && timestamp == otherResource.getLocalTimeStamp();
}
return false;
}

Back to the top