diff options
author | Jean Michel-Lemieux | 2004-06-03 15:56:43 +0000 |
---|---|---|
committer | Jean Michel-Lemieux | 2004-06-03 15:56:43 +0000 |
commit | 6452e00ae55e97b7d503f7f4dd094740a9c2bb0b (patch) | |
tree | 5635671aef8bb5a4419cfdce33bfc982aa802822 | |
parent | 4ebf231fafcc67210f43933843c42cf4120f2ead (diff) | |
download | eclipse.platform.team-branch_20040602_compare_editor_updating.tar.gz eclipse.platform.team-branch_20040602_compare_editor_updating.tar.xz eclipse.platform.team-branch_20040602_compare_editor_updating.zip |
Started working on: Bug 52196 synchronize view - reuse wrong viewbranch_20040602_compare_editor_updating
4 files changed, 70 insertions, 23 deletions
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/LocalResourceTypedElement.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/LocalResourceTypedElement.java index 114278588..ae96c6dc2 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/LocalResourceTypedElement.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/LocalResourceTypedElement.java @@ -48,6 +48,11 @@ public class LocalResourceTypedElement extends ResourceNode { super.setContent(contents); } + public void update(IResource resource) { + this.discardBuffer(); + fireContentChanged(); + } + /** * Commits buffered contents to resource. */ diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SyncInfoModelElement.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SyncInfoModelElement.java index f4b6833e2..d0cf0a081 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SyncInfoModelElement.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SyncInfoModelElement.java @@ -68,8 +68,18 @@ public class SyncInfoModelElement extends SynchronizeModelElement { public void update(SyncInfo info) { this.info = info; // update state - setKind(info.getKind()); + setKind(info.getKind()); + // never have to update the local, it's always the workspace resource + // Local + LocalResourceTypedElement localEl = (LocalResourceTypedElement)getLeft(); + IResource local = info.getLocal(); + if(local != null) { + setLeft(createLocalTypeElement(info)); + } else { + setLeft(null); + } + // Remote RemoteResourceTypedElement rightEl = (RemoteResourceTypedElement)getRight(); IResourceVariant remote = info.getRemote(); @@ -83,7 +93,7 @@ public class SyncInfoModelElement extends SynchronizeModelElement { } } // Base - RemoteResourceTypedElement ancestorEl = (RemoteResourceTypedElement)getRight(); + RemoteResourceTypedElement ancestorEl = (RemoteResourceTypedElement)getAncestor(); IResourceVariant base = info.getBase(); if(ancestorEl == null && base != null) { setAncestor(createBaseTypeElement(info)); 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 47a930da4..915616951 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 @@ -69,19 +69,20 @@ public class OpenInCompareAction extends Action { if(editor != null) { IEditorInput otherInput = editor.getEditorInput(); - if(otherInput instanceof SyncInfoCompareInput && otherInput.equals(input)) { + if(otherInput.equals(input)) { // simply provide focus to editor wpage.activate(editor); } else { // if editor is currently not open on that input either re-use existing - if(editor != null && editor instanceof IReusableEditor) { - CompareUI.reuseCompareEditor(input, (IReusableEditor)editor); - wpage.activate(editor); - } + input.dispose(); + CompareUI.reuseCompareEditor(input, (IReusableEditor)editor); + wpage.activate(editor); + input.init(editor); } } else { CompareUI.openCompareEditor(input); editor = wpage.getActiveEditor(); + input.init(editor); } if(keepFocus) { @@ -107,11 +108,10 @@ public class OpenInCompareAction extends Action { * has un-saved changes cannot be re-used. */ public static IEditorPart findReusableCompareEditor(IWorkbenchPage page) { - IEditorReference[] editorRefs = page.getEditorReferences(); - + IEditorReference[] editorRefs = page.getEditorReferences(); for (int i = 0; i < editorRefs.length; i++) { IEditorPart part = editorRefs[i].getEditor(true); - if(part != null && part.getEditorInput() instanceof SyncInfoCompareInput) { + if(part != null && part.getEditorInput() instanceof SyncInfoCompareInput && part instanceof IReusableEditor) { if(! part.isDirty()) { return part; } 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 aee6a0d37..c3318fe15 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 @@ -26,8 +26,7 @@ import org.eclipse.team.internal.core.Assert; import org.eclipse.team.internal.ui.*; import org.eclipse.team.internal.ui.synchronize.LocalResourceTypedElement; import org.eclipse.team.internal.ui.synchronize.SyncInfoModelElement; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IReusableEditor; +import org.eclipse.ui.*; import org.eclipse.ui.progress.UIJob; /** @@ -49,8 +48,24 @@ public final class SyncInfoCompareInput extends CompareEditorInput implements IR private MyDiffNode node; private String description; private IResource resource; - private IEditorPart editor; - private Image inputImage; + private IWorkbenchPart part; + + // Hook the compare input into it's containing workbench parts lifecycle. + private IPartListener partListener = new IPartListener() { + public void partActivated(IWorkbenchPart part) { + } + public void partBroughtToTop(IWorkbenchPart part) { + } + public void partClosed(IWorkbenchPart part) { + if(SyncInfoCompareInput.this.part == part) { + dispose(); + } + } + public void partDeactivated(IWorkbenchPart part) { + } + public void partOpened(IWorkbenchPart part) { + } + }; /* * This class exists so that we can force the text merge viewers to update by @@ -84,6 +99,13 @@ public final class SyncInfoCompareInput extends CompareEditorInput implements IR initializeContentChangeListeners(); } + public void init(IWorkbenchPart part) { + Assert.isNotNull(part); + this.part = part; + part.getSite().getPage().addPartListener(partListener); + ResourcesPlugin.getWorkspace().addResourceChangeListener(this); + } + private static CompareConfiguration getDefaultCompareConfiguration() { CompareConfiguration cc = new CompareConfiguration(); //cc.setProperty(CompareConfiguration.USE_OUTLINE_VIEW, true); @@ -113,20 +135,30 @@ public final class SyncInfoCompareInput extends CompareEditorInput implements IR if (delta != null) { IResourceDelta resourceDelta = delta.findMember(resource.getFullPath()); if (resourceDelta != null) { - if (editor != null && editor instanceof IReusableEditor) { - UIJob job = new UIJob("") { //$NON-NLS-1$ - public IStatus runInUIThread(IProgressMonitor monitor) { - node.update(node.getSyncInfo()); - return Status.OK_STATUS; - } - }; - job.setSystem(true); - job.schedule(); + if (part != null && part instanceof IReusableEditor) { + UIJob job = new UIJob("") { //$NON-NLS-1$ + public IStatus runInUIThread(IProgressMonitor monitor) { + if(! isSaveNeeded()) { + node.update(node.getSyncInfo()); + } + return Status.OK_STATUS; + } + }; + job.setSystem(true); + job.schedule(); } } } } + public void dispose() { + if(part != null) { + part.getSite().getPage().removePartListener(partListener); + ResourcesPlugin.getWorkspace().removeResourceChangeListener(this); + part = null; + } + } + /* * (non-Javadoc) * @see org.eclipse.compare.CompareEditorInput#getTitleImage() |