Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Michel-Lemieux2004-02-26 02:47:41 +0000
committerJean Michel-Lemieux2004-02-26 02:47:41 +0000
commitccdcc754946a929bfffe4f4cda83f56a373145ac (patch)
treedbf4ced3f4c3dbcb82c8230108c5e57b38cfcaed
parent02fc3a01930f97cb1ac9e454dae8b69d796f119a (diff)
downloadeclipse.platform.team-ccdcc754946a929bfffe4f4cda83f56a373145ac.tar.gz
eclipse.platform.team-ccdcc754946a929bfffe4f4cda83f56a373145ac.tar.xz
eclipse.platform.team-ccdcc754946a929bfffe4f4cda83f56a373145ac.zip
Adding updating of compare editors when local resource changes. Not finished though.
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties2
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeView.java3
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/OpenInCompareAction.java7
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/SyncInfoCompareInput.java110
4 files changed, 105 insertions, 17 deletions
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 d524745b0..b132fce74 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
@@ -97,7 +97,7 @@ SyncInfoCompareInput.baseLabel=Common Ancestor
SyncInfoCompareInput.remoteLabelExists=Remote File ({0})
SyncInfoCompareInput.baseLabelExists=Common Ancestor ({0})
SyncInfoCompareInput.title={0}
-SyncInfoCompareInput.tooltip=Comparing resources from {0}: {1}
+SyncInfoCompareInput.tooltip={0}: {1}
TeamAction.internal=Internal error occurred.
TeamFile.saveChanges=Unable to save changes to file: {0}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeView.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeView.java
index 0350ddd5d..58e036004 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeView.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeView.java
@@ -111,6 +111,7 @@ public class SynchronizeView extends PageBookView implements ISynchronizeView, I
} else {
setTitle(Policy.bind("SynchronizeView.2") + page.getName()); //$NON-NLS-1$
}
+ setTitle("This is a big bad boy...");
}
/* (non-Javadoc)
@@ -238,6 +239,7 @@ public class SynchronizeView extends PageBookView implements ISynchronizeView, I
super();
fParticipantToPart = new HashMap();
fPartToPage = new HashMap();
+ updateTitle();
}
/**
@@ -308,6 +310,7 @@ public class SynchronizeView extends PageBookView implements ISynchronizeView, I
halfBusyCursor = new JobBusyCursor(parent);
updateForExistingParticipants();
getViewSite().getActionBars().updateActionBars();
+ updateTitle();
}
/**
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 429f711ed..0a99a1f94 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
@@ -74,6 +74,11 @@ public class OpenInCompareAction extends Action {
}
} else {
CompareUI.openCompareEditor(input);
+ editor = page.getSite().getPage().getActiveEditor();
+ }
+
+ if(editor != null) {
+ input.setCompareEditor(editor);
}
if(keepFocus) {
@@ -89,7 +94,7 @@ public class OpenInCompareAction extends Action {
*/
private static SyncInfoCompareInput getCompareInput(ISynchronizeParticipant participant, SyncInfo info) {
if (info != null && info.getLocal() instanceof IFile) {
- return new SyncInfoCompareInput(info);
+ return new SyncInfoCompareInput(participant.getName(), info);
}
return null;
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/SyncInfoCompareInput.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/SyncInfoCompareInput.java
index 898aee5cc..f22d757d1 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/SyncInfoCompareInput.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/viewers/SyncInfoCompareInput.java
@@ -12,18 +12,39 @@ package org.eclipse.team.ui.synchronize.viewers;
import java.lang.reflect.InvocationTargetException;
-import org.eclipse.compare.*;
+import org.eclipse.compare.CompareConfiguration;
+import org.eclipse.compare.CompareEditorInput;
+import org.eclipse.compare.CompareUI;
+import org.eclipse.compare.IContentChangeListener;
+import org.eclipse.compare.IContentChangeNotifier;
+import org.eclipse.compare.ITypedElement;
import org.eclipse.compare.structuremergeviewer.DiffNode;
-import org.eclipse.core.runtime.*;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.IResourceChangeListener;
+import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.swt.graphics.Image;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.synchronize.SyncInfo;
import org.eclipse.team.internal.core.Assert;
-import org.eclipse.team.internal.ui.*;
+import org.eclipse.team.internal.ui.Policy;
+import org.eclipse.team.internal.ui.TeamUIPlugin;
+import org.eclipse.team.internal.ui.Utils;
import org.eclipse.team.internal.ui.synchronize.LocalResourceTypedElement;
import org.eclipse.team.ui.ISharedImages;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IPartListener;
+import org.eclipse.ui.IReusableEditor;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.progress.UIJob;
/**
* A {@link SyncInfo} editor input used as input to a two-way or three-way
@@ -41,17 +62,31 @@ import org.eclipse.team.ui.ISharedImages;
* @see SyncInfoModelElement
* @since 3.0
*/
-public class SyncInfoCompareInput extends CompareEditorInput {
+public final class SyncInfoCompareInput extends CompareEditorInput implements IResourceChangeListener {
private SyncInfoModelElement node;
+ private String description;
+ private IResource resource;
+ private IEditorPart editor;
- public SyncInfoCompareInput(SyncInfo sync) {
+ /**
+ * Creates a compare editor input based on an existing <code>SyncInfo</code>.
+ *
+ * @param description a description of the context of this sync info. This
+ * is displayed to the user.
+ * @param sync the <code>SyncInfo</code> used as the base for the compare input.
+ */
+ public SyncInfoCompareInput(String description, SyncInfo sync) {
super(new CompareConfiguration());
Assert.isNotNull(sync);
+ Assert.isNotNull(description);
+ this.description = description;
+ this.resource = sync.getLocal();
this.node = new SyncInfoModelElement(null, sync);
initializeContentChangeListeners();
+ initializeResourceChangeListeners();
}
-
+
private void initializeContentChangeListeners() {
ITypedElement te = node.getLeft();
if (te instanceof IContentChangeNotifier) {
@@ -65,10 +100,62 @@ public class SyncInfoCompareInput extends CompareEditorInput {
});
}
}
+
+ private void initializeResourceChangeListeners() {
+ ResourcesPlugin.getWorkspace().addResourceChangeListener(this);
+ }
+
+ public void resourceChanged(IResourceChangeEvent event) {
+ IResourceDelta delta = event.getDelta();
+ if (delta != null) {
+ IResourceDelta resourceDelta = delta.findMember(resource.getFullPath());
+ if (resourceDelta != null) {
+ if (resourceDelta.getKind() == IResourceDelta.CHANGED) {
+ if (editor != null && editor instanceof IReusableEditor) {
+ UIJob job = new UIJob("") {
+ public IStatus runInUIThread(IProgressMonitor monitor) {
+ CompareUI.reuseCompareEditor(SyncInfoCompareInput.this, (IReusableEditor) editor);
+ return Status.OK_STATUS;
+ }
+ };
+ job.setSystem(true);
+ job.schedule();
+ }
+ }
+ }
+ }
+ }
+ public void setCompareEditor(IEditorPart editor) {
+ Assert.isNotNull(editor);
+ this.editor = editor;
+ editor.getSite().getPage().addPartListener(new IPartListener() {
+ public void partActivated(IWorkbenchPart part) {
+ }
+ public void partBroughtToTop(IWorkbenchPart part) {
+ }
+ public void partClosed(IWorkbenchPart part) {
+ getCompareEditor().getSite().getPage().removePartListener(this);
+ dispose();
+ SyncInfoCompareInput.this.editor = null;
+ }
+ public void partDeactivated(IWorkbenchPart part) {
+ }
+ public void partOpened(IWorkbenchPart part) {
+ }
+ });
+ }
+
+ public IEditorPart getCompareEditor() {
+ return this.editor;
+ }
+
+ protected void dispose() {
+ ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
+ }
+
/*
* (non-Javadoc)
- *
* @see org.eclipse.compare.CompareEditorInput#getTitleImage()
*/
public Image getTitleImage() {
@@ -83,7 +170,6 @@ public class SyncInfoCompareInput extends CompareEditorInput {
/*
* (non-Javadoc)
- *
* @see org.eclipse.compare.CompareEditorInput#prepareInput(org.eclipse.core.runtime.IProgressMonitor)
*/
protected Object prepareInput(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
@@ -101,7 +187,6 @@ public class SyncInfoCompareInput extends CompareEditorInput {
/*
* (non-Javadoc)
- *
* @see org.eclipse.compare.CompareEditorInput#getTitle()
*/
public String getTitle() {
@@ -110,7 +195,6 @@ public class SyncInfoCompareInput extends CompareEditorInput {
/*
* (non-Javadoc)
- *
* @see org.eclipse.ui.IEditorInput#getImageDescriptor()
*/
public ImageDescriptor getImageDescriptor() {
@@ -119,17 +203,14 @@ public class SyncInfoCompareInput extends CompareEditorInput {
/*
* (non-Javadoc)
- *
* @see org.eclipse.ui.IEditorInput#getToolTipText()
*/
public String getToolTipText() {
- return "";
- //return Policy.bind("SyncInfoCompareInput.tooltip", participant.getName(), node.getName()); //$NON-NLS-1$
+ return Policy.bind("SyncInfoCompareInput.tooltip", description, node.getResource().getFullPath().toString()); //$NON-NLS-1$
}
/*
* (non-Javadoc)
- *
* @see java.lang.Object#equals(java.lang.Object)
*/
public boolean equals(Object other) {
@@ -143,7 +224,6 @@ public class SyncInfoCompareInput extends CompareEditorInput {
/*
* (non-Javadoc)
- *
* @see CompareEditorInput#saveChanges(org.eclipse.core.runtime.IProgressMonitor)
*/
public void saveChanges(IProgressMonitor pm) throws CoreException {

Back to the top