Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/HunkDiffNode.java4
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/InputPatchPage.java9
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchDiffNode.java10
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchFileDiffNode.java18
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchProjectDiffNode.java10
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchTargetPage.java21
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchWizard.java15
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java6
-rw-r--r--bundles/org.eclipse.team.ui/META-INF/MANIFEST.MF1
-rw-r--r--bundles/org.eclipse.team.ui/icons/full/obj/hunk_obj.gifbin0 -> 598 bytes
-rw-r--r--bundles/org.eclipse.team.ui/plugin.properties7
-rw-r--r--bundles/org.eclipse.team.ui/plugin.xml110
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamUIMessages.java5
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ModelCompareEditorInput.java2
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties7
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/OpenInCompareAction.java9
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/AdapterFactory.java57
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchMergeActionHandler.java37
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchModelCompareEditorInput.java52
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchModelSynchronizeParticipant.java89
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchSubscriber.java150
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchSubscriberMergeContext.java86
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchSynchronizationActionProvider.java33
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchSynchronizationWizard.java96
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/DiffProjectResourceMapping.java73
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/ExcludedPatchDiffNodesFilter.java38
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/FilePatchResourceMapping.java54
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/HunkResourceMapping.java54
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/PatchCompareAdapter.java43
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/PatchModelProvider.java125
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/PatchPreviewModePage.java84
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/PatchSyncContentProvider.java130
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/PatchSyncLabelProvider.java71
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/PatchWorkbenchAdapter.java48
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/PatchWorkbenchLabelProvider.java63
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/PatchWorkspace.java111
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/PatchedFileVariant.java79
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/PatchedFileVariantComparator.java34
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/AbstractSynchronizeLabelProvider.java8
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ModelSynchronizeParticipantActionGroup.java4
40 files changed, 1822 insertions, 31 deletions
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/HunkDiffNode.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/HunkDiffNode.java
index 5515a7ee1..c0cb6610d 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/HunkDiffNode.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/HunkDiffNode.java
@@ -14,6 +14,7 @@ import org.eclipse.compare.ITypedElement;
import org.eclipse.compare.internal.core.patch.HunkResult;
import org.eclipse.compare.patch.PatchConfiguration;
import org.eclipse.compare.structuremergeviewer.Differencer;
+import org.eclipse.core.resources.IResource;
public class HunkDiffNode extends PatchDiffNode {
@@ -101,4 +102,7 @@ public class HunkDiffNode extends PatchDiffNode {
return false;
}
+ public IResource getResource() {
+ return ((PatchFileDiffNode)getParent()).getResource();
+ }
}
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/InputPatchPage.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/InputPatchPage.java
index 94c16351b..78b199cb5 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/InputPatchPage.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/InputPatchPage.java
@@ -80,7 +80,7 @@ import org.eclipse.ui.views.navigator.ResourceComparator;
import com.ibm.icu.text.MessageFormat;
-/* package */ class InputPatchPage extends WizardPage {
+public class InputPatchPage extends WizardPage {
// constants
protected static final int SIZING_TEXT_FIELD_WIDTH= 250;
@@ -139,7 +139,7 @@ import com.ibm.icu.text.MessageFormat;
}
}
- InputPatchPage(PatchWizard pw) {
+ public InputPatchPage(PatchWizard pw) {
super(INPUTPATCHPAGE_NAME, PatchMessages.InputPatchPage_title, null);
fPatchWizard= pw;
setMessage(PatchMessages.InputPatchPage_message);
@@ -221,7 +221,10 @@ import com.ibm.icu.text.MessageFormat;
// all of the projects that make up the patch and continue on to final preview page
// else go on to target selection page
if (patcher.isWorkspacePatch()) {
- return fPatchWizard.getPage(PreviewPatchPage2.PREVIEWPATCHPAGE_NAME);
+ // skip 'Patch Target' page
+ IWizardPage page = super.getNextPage();
+ if (page.getName().equals(PatchTargetPage.PATCHTARGETPAGE_NAME))
+ return page.getNextPage();
}
return super.getNextPage();
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchDiffNode.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchDiffNode.java
index 89e9f1f81..ea4ba2de8 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchDiffNode.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchDiffNode.java
@@ -10,11 +10,14 @@
*******************************************************************************/
package org.eclipse.compare.internal.patch;
+import org.eclipse.compare.IResourceProvider;
import org.eclipse.compare.ITypedElement;
import org.eclipse.compare.patch.PatchConfiguration;
-import org.eclipse.compare.structuremergeviewer.*;
+import org.eclipse.compare.structuremergeviewer.DiffNode;
+import org.eclipse.compare.structuremergeviewer.IDiffContainer;
+import org.eclipse.core.resources.IResource;
-public abstract class PatchDiffNode extends DiffNode {
+public abstract class PatchDiffNode extends DiffNode implements IResourceProvider {
private Object fElement;
@@ -59,4 +62,7 @@ public abstract class PatchDiffNode extends DiffNode {
return getPatchElement().hashCode();
}
+ public IResource getResource() {
+ return null;
+ }
}
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchFileDiffNode.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchFileDiffNode.java
index 8149140ea..922ce5d7a 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchFileDiffNode.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchFileDiffNode.java
@@ -10,12 +10,17 @@
*******************************************************************************/
package org.eclipse.compare.internal.patch;
-import org.eclipse.compare.*;
-import org.eclipse.compare.internal.core.patch.FilePatch2;
+import org.eclipse.compare.IContentChangeListener;
+import org.eclipse.compare.IContentChangeNotifier;
+import org.eclipse.compare.ITypedElement;
import org.eclipse.compare.internal.core.patch.FileDiffResult;
+import org.eclipse.compare.internal.core.patch.FilePatch2;
import org.eclipse.compare.patch.PatchConfiguration;
-import org.eclipse.compare.structuremergeviewer.*;
-import org.eclipse.core.resources.IFile;
+import org.eclipse.compare.structuremergeviewer.DiffNode;
+import org.eclipse.compare.structuremergeviewer.Differencer;
+import org.eclipse.compare.structuremergeviewer.IDiffContainer;
+import org.eclipse.compare.structuremergeviewer.IDiffElement;
+import org.eclipse.core.resources.IResource;
public class PatchFileDiffNode extends PatchDiffNode implements IContentChangeListener {
@@ -110,8 +115,11 @@ public class PatchFileDiffNode extends PatchDiffNode implements IContentChangeLi
}
public boolean fileExists() {
- IFile file = ((WorkspaceFileDiffResult)getDiffResult()).getTargetFile();
+ IResource file = getResource();
return file != null && file.isAccessible();
}
+ public IResource getResource() {
+ return ((WorkspaceFileDiffResult)getDiffResult()).getTargetFile();
+ }
}
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchProjectDiffNode.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchProjectDiffNode.java
index 2f8f58a69..dd2285df2 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchProjectDiffNode.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchProjectDiffNode.java
@@ -14,7 +14,11 @@ import org.eclipse.compare.CompareUI;
import org.eclipse.compare.ITypedElement;
import org.eclipse.compare.internal.core.patch.DiffProject;
import org.eclipse.compare.patch.PatchConfiguration;
-import org.eclipse.compare.structuremergeviewer.*;
+import org.eclipse.compare.structuremergeviewer.Differencer;
+import org.eclipse.compare.structuremergeviewer.IDiffContainer;
+import org.eclipse.compare.structuremergeviewer.IDiffElement;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.jface.resource.LocalResourceManager;
import org.eclipse.swt.graphics.Image;
@@ -76,4 +80,8 @@ public class PatchProjectDiffNode extends PatchDiffNode {
return project;
}
+ public IResource getResource() {
+ return ResourcesPlugin.getWorkspace().getRoot().getProject(getDiffProject().getName());
+ }
+
}
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchTargetPage.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchTargetPage.java
index ccca2d32e..8fd95d738 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchTargetPage.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchTargetPage.java
@@ -12,18 +12,31 @@ package org.eclipse.compare.internal.patch;
import org.eclipse.compare.internal.ICompareContextIds;
import org.eclipse.compare.internal.Utilities;
-import org.eclipse.core.resources.*;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.*;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.Tree;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.model.WorkbenchContentProvider;
import org.eclipse.ui.model.WorkbenchLabelProvider;
@@ -48,7 +61,7 @@ public class PatchTargetPage extends WizardPage {
protected final static String PATCHTARGETPAGE_NAME = "PatchTargetPage"; //$NON-NLS-1$
- PatchTargetPage(WorkspacePatcher patcher) {
+ public PatchTargetPage(WorkspacePatcher patcher) {
super(PATCHTARGETPAGE_NAME, PatchMessages.PatchTargetPage_title, null);
setMessage(PatchMessages.PatchTargetPage_message);
fPatcher = patcher;
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchWizard.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchWizard.java
index fa19443a7..9b9773583 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchWizard.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchWizard.java
@@ -40,9 +40,9 @@ public class PatchWizard extends Wizard {
private boolean fHasNewDialogSettings;
- private InputPatchPage fPatchWizardPage;
- private PatchTargetPage fPatchTargetPage;
- private PreviewPatchPage2 fPreviewPage2;
+ protected InputPatchPage fPatchWizardPage;
+ protected PatchTargetPage fPatchTargetPage;
+ protected PreviewPatchPage2 fPreviewPage2;
private final WorkspacePatcher fPatcher;
@@ -86,15 +86,18 @@ public class PatchWizard extends Wizard {
}
}
- WorkspacePatcher getPatcher() {
+ protected WorkspacePatcher getPatcher() {
return fPatcher;
}
-
+
+ protected IStorage getPatch() {
+ return patch;
+ }
+
IResource getTarget() {
return fPatcher.getTarget();
}
-
/* (non-Javadoc)
* Method declared on IWizard.
*/
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java
index 0217db414..a059819db 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -28,8 +28,8 @@ import java.util.Set;
import org.eclipse.compare.internal.core.Messages;
import org.eclipse.compare.internal.core.patch.DiffProject;
-import org.eclipse.compare.internal.core.patch.FilePatch2;
import org.eclipse.compare.internal.core.patch.FileDiffResult;
+import org.eclipse.compare.internal.core.patch.FilePatch2;
import org.eclipse.compare.internal.core.patch.Hunk;
import org.eclipse.compare.internal.core.patch.PatchReader;
import org.eclipse.compare.patch.IHunk;
@@ -601,7 +601,7 @@ public class Patcher implements IHunkFilter {
refresh(getDiffs());
}
- protected void refresh(FilePatch2[] diffs) {
+ public void refresh(FilePatch2[] diffs) {
for (int i = 0; i < diffs.length; i++) {
FilePatch2 diff = diffs[i];
FileDiffResult result = getDiffResult(diff);
diff --git a/bundles/org.eclipse.team.ui/META-INF/MANIFEST.MF b/bundles/org.eclipse.team.ui/META-INF/MANIFEST.MF
index a838368a7..45d93b6e9 100644
--- a/bundles/org.eclipse.team.ui/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.team.ui/META-INF/MANIFEST.MF
@@ -15,6 +15,7 @@ Export-Package: org.eclipse.team.internal.ui;x-friends:="org.eclipse.team.cvs.ss
org.eclipse.team.internal.ui.registry;x-friends:="org.eclipse.team.cvs.ssh,org.eclipse.team.cvs.ssh2,org.eclipse.team.cvs.ui",
org.eclipse.team.internal.ui.synchronize;x-friends:="org.eclipse.team.cvs.ssh,org.eclipse.team.cvs.ssh2,org.eclipse.team.cvs.ui",
org.eclipse.team.internal.ui.synchronize.actions;x-friends:="org.eclipse.team.cvs.ssh,org.eclipse.team.cvs.ssh2,org.eclipse.team.cvs.ui",
+ org.eclipse.team.internal.ui.synchronize.patch;x-internal:=true,
org.eclipse.team.internal.ui.wizards;x-friends:="org.eclipse.team.cvs.ssh,org.eclipse.team.cvs.ssh2,org.eclipse.team.cvs.ui",
org.eclipse.team.ui,
org.eclipse.team.ui.history,
diff --git a/bundles/org.eclipse.team.ui/icons/full/obj/hunk_obj.gif b/bundles/org.eclipse.team.ui/icons/full/obj/hunk_obj.gif
new file mode 100644
index 000000000..353b6f38c
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/icons/full/obj/hunk_obj.gif
Binary files differ
diff --git a/bundles/org.eclipse.team.ui/plugin.properties b/bundles/org.eclipse.team.ui/plugin.properties
index 28d7d884e..a174d7645 100644
--- a/bundles/org.eclipse.team.ui/plugin.properties
+++ b/bundles/org.eclipse.team.ui/plugin.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2000, 2009 IBM Corporation and others.
+# Copyright (c) 2000, 2010 IBM Corporation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
@@ -79,3 +79,8 @@ CompareWithEachOtherAction.label= &Each Other
CompareWithEachOtherAction.tooltip= Compare the Selected Resources
ignoresTransferName= Team Ignored Resources Transfer
+PatchModelProvider=Patch Contents
+PatchNavigatorContent=Patch
+PatchSyncParticipant=Patch
+PatchSyncWizard=Synchronize with Patch
+PatchSyncWizard_description=Synchronize resources with patch contents.
diff --git a/bundles/org.eclipse.team.ui/plugin.xml b/bundles/org.eclipse.team.ui/plugin.xml
index 7acfd8b89..5ebf00ab2 100644
--- a/bundles/org.eclipse.team.ui/plugin.xml
+++ b/bundles/org.eclipse.team.ui/plugin.xml
@@ -577,4 +577,114 @@
</mapping>
</transfer>
</extension>
+
+ <!-- ******* Apply Patch in Sync View ******** -->
+ <extension
+ point="org.eclipse.team.ui.synchronizeWizards">
+ <wizard
+ class="org.eclipse.team.internal.ui.synchronize.patch.ApplyPatchSynchronizationWizard"
+ description="%PatchSyncWizard_description"
+ icon="icons/full/obj/hunk_obj.gif"
+ id="org.eclipse.team.ui.applyPatchWizard"
+ name="%PatchSyncWizard">
+ </wizard>
+ </extension>
+ <extension
+ point="org.eclipse.team.ui.synchronizeParticipants">
+ <participant
+ class="org.eclipse.team.internal.ui.synchronize.patch.ApplyPatchModelSynchronizeParticipant"
+ icon="icons/full/obj/hunk_obj.gif"
+ id="org.eclipse.team.ui.applyPatchModelParticipant"
+ name="%PatchSyncParticipant"
+ persistent="false">
+ </participant>
+ </extension>
+ <extension
+ id="patchModelProvider"
+ name="%PatchModelProvider"
+ point="org.eclipse.core.resources.modelProviders">
+ <modelProvider
+ class="org.eclipse.team.internal.ui.synchronize.patch.PatchModelProvider"/>
+ <extends-model id="org.eclipse.core.resources.modelProvider"/>
+ </extension>
+ <extension
+ point="org.eclipse.ui.navigator.navigatorContent">
+ <navigatorContent
+ contentProvider="org.eclipse.team.internal.ui.synchronize.patch.PatchSyncContentProvider"
+ icon="icons/full/obj/hunk_obj.gif"
+ id="org.eclipse.team.ui.patchSyncNavigatorContent"
+ labelProvider="org.eclipse.team.internal.ui.synchronize.patch.PatchSyncLabelProvider"
+ name="%PatchNavigatorContent"
+ priority="normal">
+ <enablement>
+ <or>
+ <instanceof
+ value="org.eclipse.team.internal.ui.synchronize.patch.PatchWorkspace">
+ </instanceof>
+ <instanceof
+ value="org.eclipse.compare.internal.patch.PatchDiffNode">
+ </instanceof>
+ <instanceof
+ value="org.eclipse.team.internal.ui.synchronize.patch.PatchModelProvider">
+ </instanceof>
+ </or>
+ </enablement>
+ <actionProvider
+ class="org.eclipse.team.internal.ui.synchronize.patch.ApplyPatchSynchronizationActionProvider">
+ </actionProvider>
+ </navigatorContent>
+ </extension>
+ <extension
+ point="org.eclipse.core.runtime.adapters">
+ <factory
+ adaptableType="org.eclipse.compare.internal.patch.PatchProjectDiffNode"
+ class="org.eclipse.team.internal.ui.synchronize.patch.AdapterFactory">
+ <adapter
+ type="org.eclipse.core.resources.mapping.ResourceMapping">
+ </adapter>
+ <adapter
+ type="org.eclipse.ui.model.IWorkbenchAdapter">
+ </adapter>
+ </factory>
+ <factory
+ adaptableType="org.eclipse.compare.internal.patch.PatchFileDiffNode"
+ class="org.eclipse.team.internal.ui.synchronize.patch.AdapterFactory">
+ <adapter
+ type="org.eclipse.core.resources.mapping.ResourceMapping">
+ </adapter>
+ <adapter
+ type="org.eclipse.ui.model.IWorkbenchAdapter">
+ </adapter>
+ </factory>
+ <factory
+ adaptableType="org.eclipse.compare.internal.patch.HunkDiffNode"
+ class="org.eclipse.team.internal.ui.synchronize.patch.AdapterFactory">
+ <adapter
+ type="org.eclipse.core.resources.mapping.ResourceMapping">
+ </adapter>
+ <adapter
+ type="org.eclipse.ui.model.IWorkbenchAdapter">
+ </adapter>
+ </factory>
+ <factory
+ adaptableType="org.eclipse.team.internal.ui.synchronize.patch.PatchWorkspace"
+ class="org.eclipse.team.internal.ui.synchronize.patch.AdapterFactory">
+ <adapter
+ type="org.eclipse.ui.model.IWorkbenchAdapter">
+ </adapter>
+ </factory>
+ <factory
+ adaptableType="org.eclipse.team.internal.ui.synchronize.patch.PatchModelProvider"
+ class="org.eclipse.team.internal.ui.synchronize.patch.AdapterFactory">
+ <adapter type="org.eclipse.team.ui.mapping.ISynchronizationCompareAdapter"/>
+ </factory>
+ </extension>
+ <extension
+ point="org.eclipse.team.ui.teamContentProviders">
+ <teamContentProvider
+ contentExtensionId="org.eclipse.team.ui.patchSyncNavigatorContent"
+ icon="icons/full/obj/hunk_obj.gif"
+ modelProviderId="org.eclipse.team.ui.patchModelProvider">
+ </teamContentProvider>
+ </extension>
</plugin>
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 e2545dc60..d2fb871f4 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
@@ -714,6 +714,11 @@ public class TeamUIMessages extends NLS {
public static String SelectAncestorDialog_message;
public static String SelectAncestorDialog_option;
+ public static String PatchPreviewModePage_title;
+ public static String PatchPreviewModePage_description;
+ public static String PatchPreviewModePage_previewInPatchWizard;
+ public static String PatchPreviewModePage_previewInSynchronizeView;
+
public static String NotFound;
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ModelCompareEditorInput.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ModelCompareEditorInput.java
index 534d8c016..54ea848a6 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ModelCompareEditorInput.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ModelCompareEditorInput.java
@@ -189,7 +189,7 @@ public class ModelCompareEditorInput extends SaveableCompareEditorInput implemen
}
protected void handleMenuAboutToShow(IMenuManager manager) {
- StructuredSelection selection = new StructuredSelection(((ResourceDiffCompareInput)getCompareInput()).getResource());
+ StructuredSelection selection = new StructuredSelection(((IResourceProvider)getCompareInput()).getResource());
final ResourceMarkAsMergedHandler markAsMergedHandler = new ResourceMarkAsMergedHandler(getSynchronizeConfiguration());
markAsMergedHandler.updateEnablement(selection);
Action markAsMergedAction = new Action(TeamUIMessages.ModelCompareEditorInput_0) {
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 e0353a660..fc7cad943 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
@@ -570,3 +570,10 @@ SaveablesCompareEditorInput_threeWayTooltip=Three-way compare of ''{1}'' and ''{
SelectAncestorDialog_title=Select Common Ancestor
SelectAncestorDialog_message=Which resource would you like to use as the common ancestor in the three-way compare?
SelectAncestorDialog_option=''{0}''
+#
+# PatchPreviewModePage
+#
+PatchPreviewModePage_title=Patch Preview Mode
+PatchPreviewModePage_description=Choose the way to preview the patch.
+PatchPreviewModePage_previewInPatchWizard=Preview in the &Patch Wizard
+PatchPreviewModePage_previewInSynchronizeView=Preview in the &synchronize view \ No newline at end of file
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 75e49af6c..411b1f0a9 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -27,6 +27,8 @@ import org.eclipse.team.core.synchronize.SyncInfo;
import org.eclipse.team.internal.ui.*;
import org.eclipse.team.internal.ui.mapping.ModelCompareEditorInput;
import org.eclipse.team.internal.ui.synchronize.SyncInfoModelElement;
+import org.eclipse.team.internal.ui.synchronize.patch.ApplyPatchModelCompareEditorInput;
+import org.eclipse.team.internal.ui.synchronize.patch.PatchModelProvider;
import org.eclipse.team.ui.mapping.ISynchronizationCompareInput;
import org.eclipse.team.ui.synchronize.*;
import org.eclipse.ui.*;
@@ -110,7 +112,10 @@ public class OpenInCompareAction extends Action {
ICompareInput input = msp.asCompareInput(object);
IWorkbenchPage workbenchPage = getWorkbenchPage(site);
if (input != null && workbenchPage != null && isOkToOpen(site, participant, input)) {
- return openCompareEditor(workbenchPage, new ModelCompareEditorInput(msp, input, workbenchPage, configuration), keepFocus, site, reuseEditorIfPossible);
+ if (configuration.getProperty(ModelSynchronizeParticipant.P_VISIBLE_MODEL_PROVIDER).equals(PatchModelProvider.ID))
+ return openCompareEditor(workbenchPage, new ApplyPatchModelCompareEditorInput(msp, input, workbenchPage, configuration), keepFocus, site, reuseEditorIfPossible);
+ else
+ return openCompareEditor(workbenchPage, new ModelCompareEditorInput(msp, input, workbenchPage, configuration), keepFocus, site, reuseEditorIfPossible);
}
}
return null;
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/AdapterFactory.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/AdapterFactory.java
new file mode 100644
index 000000000..419530c82
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/AdapterFactory.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.internal.ui.synchronize.patch;
+
+import org.eclipse.compare.internal.patch.*;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.mapping.ResourceMapping;
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.team.ui.mapping.ISynchronizationCompareAdapter;
+import org.eclipse.ui.model.IWorkbenchAdapter;
+
+public class AdapterFactory implements IAdapterFactory {
+
+ private IWorkbenchAdapter modelAdapter = new PatchWorkbenchAdapter();
+ private ISynchronizationCompareAdapter compareAdapter;
+
+ public Object getAdapter(Object adaptableObject, Class adapterType) {
+ if (adapterType == ResourceMapping.class) {
+ if (adaptableObject instanceof PatchProjectDiffNode) {
+ return new DiffProjectResourceMapping(
+ ((PatchProjectDiffNode) adaptableObject)
+ .getDiffProject());
+ }
+ if (adaptableObject instanceof PatchFileDiffNode) {
+ return new FilePatchResourceMapping(
+ ((PatchFileDiffNode) adaptableObject).getDiffResult());
+ }
+ if (adaptableObject instanceof HunkDiffNode) {
+ return new HunkResourceMapping(((HunkDiffNode) adaptableObject)
+ .getHunkResult());
+ }
+ }
+ if (adapterType == IWorkbenchAdapter.class)
+ return modelAdapter;
+ if (adapterType == ISynchronizationCompareAdapter.class
+ && adaptableObject instanceof PatchModelProvider) {
+ if (compareAdapter == null) {
+ compareAdapter = new PatchCompareAdapter();
+ }
+ return compareAdapter;
+ }
+ return null;
+ }
+
+ public Class[] getAdapterList() {
+ return new Class[] { ResourceMapping.class, IWorkbenchAdapter.class,
+ IResource.class };
+ }
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchMergeActionHandler.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchMergeActionHandler.java
new file mode 100644
index 000000000..3ba6d0044
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchMergeActionHandler.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.internal.ui.synchronize.patch;
+
+import org.eclipse.compare.internal.patch.HunkDiffNode;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.team.internal.ui.mapping.ResourceMergeHandler;
+import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
+
+public class ApplyPatchMergeActionHandler extends ResourceMergeHandler {
+
+ public ApplyPatchMergeActionHandler(
+ ISynchronizePageConfiguration configuration, boolean overwrite) {
+ super(configuration, overwrite);
+ }
+
+ public void updateEnablement(IStructuredSelection selection) {
+ super.updateEnablement(selection);
+ // disable merge for hunks
+ Object[] elements = getOperation().getElements();
+ for (int i = 0; i < elements.length; i++) {
+ if (elements[i] instanceof HunkDiffNode) {
+ setEnabled(false);
+ return;
+ }
+ }
+ }
+
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchModelCompareEditorInput.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchModelCompareEditorInput.java
new file mode 100644
index 000000000..019741bb6
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchModelCompareEditorInput.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.internal.ui.synchronize.patch;
+
+import org.eclipse.compare.structuremergeviewer.ICompareInput;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.team.internal.ui.mapping.ModelCompareEditorInput;
+import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
+import org.eclipse.team.ui.synchronize.ModelSynchronizeParticipant;
+import org.eclipse.ui.IWorkbenchPage;
+
+public class ApplyPatchModelCompareEditorInput extends ModelCompareEditorInput {
+
+ public ApplyPatchModelCompareEditorInput(
+ ModelSynchronizeParticipant participant, ICompareInput input,
+ IWorkbenchPage page,
+ ISynchronizePageConfiguration synchronizeConfiguration) {
+ super(participant, input, page, synchronizeConfiguration);
+ }
+
+ protected void handleMenuAboutToShow(IMenuManager manager) {
+ // add nothing for now, but when bug 300221 is fixed add 'Merge' only
+ /*
+ StructuredSelection selection = new StructuredSelection(((IResourceProvider)getCompareInput()).getResource());
+
+ final ResourceMergeHandler mergeHandler = new ResourceMergeHandler(getSynchronizeConfiguration(), false);
+ mergeHandler.updateEnablement(selection);
+ Action mergeAction = new Action(TeamUIMessages.ModelCompareEditorInput_1) {
+ public void run() {
+ try {
+ mergeHandler.execute(new ExecutionEvent());
+ } catch (ExecutionException e) {
+ TeamUIPlugin.log(IStatus.ERROR, e.getMessage(), e);
+ }
+ }
+ };
+ Utils.initAction(mergeAction, "action.merge."); //$NON-NLS-1$
+ mergeAction.setEnabled(mergeAction.isEnabled());
+
+ manager.insertAfter(IWorkbenchActionConstants.MB_ADDITIONS, new Separator("merge")); //$NON-NLS-1$
+ manager.insertAfter("merge", mergeAction); //$NON-NLS-1$
+ */
+ }
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchModelSynchronizeParticipant.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchModelSynchronizeParticipant.java
new file mode 100644
index 000000000..fb1f100ba
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchModelSynchronizeParticipant.java
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.internal.ui.synchronize.patch;
+
+import org.eclipse.core.resources.mapping.ModelProvider;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.team.core.mapping.provider.SynchronizationContext;
+import org.eclipse.team.ui.TeamUI;
+import org.eclipse.team.ui.mapping.SynchronizationActionProvider;
+import org.eclipse.team.ui.synchronize.*;
+
+public class ApplyPatchModelSynchronizeParticipant extends
+ ModelSynchronizeParticipant {
+
+ public static final String ID = "org.eclipse.team.ui.applyPatchModelParticipant"; //$NON-NLS-1$
+
+ public ApplyPatchModelSynchronizeParticipant(SynchronizationContext context) {
+ super(context);
+ init();
+ }
+
+ private void init() {
+ try {
+ ISynchronizeParticipantDescriptor descriptor = TeamUI
+ .getSynchronizeManager().getParticipantDescriptor(ID);
+ setInitializationData(descriptor);
+ setSecondaryId(Long.toString(System.currentTimeMillis()));
+ } catch (CoreException e) {
+ // ignore
+ }
+ }
+
+ protected void initializeConfiguration(
+ final ISynchronizePageConfiguration configuration) {
+ super.initializeConfiguration(configuration);
+ configuration
+ .setSupportedModes(ISynchronizePageConfiguration.INCOMING_MODE
+ | ISynchronizePageConfiguration.CONFLICTING_MODE);
+ configuration.setMode(ISynchronizePageConfiguration.INCOMING_MODE);
+ }
+
+ protected ModelSynchronizeParticipantActionGroup createMergeActionGroup() {
+ return new ApplyPatchModelSynchronizeParticipantActionGroup();
+ }
+
+ public class ApplyPatchModelSynchronizeParticipantActionGroup extends
+ ModelSynchronizeParticipantActionGroup {
+ protected void addToContextMenu(String mergeActionId, Action action,
+ IMenuManager manager) {
+ if (mergeActionId == SynchronizationActionProvider.OVERWRITE_ACTION_ID) {
+ // omit this action
+ return;
+ } else if (mergeActionId == SynchronizationActionProvider.MARK_AS_MERGE_ACTION_ID) {
+ // omit this action
+ return;
+ }
+ super.addToContextMenu(mergeActionId, action, manager);
+ }
+ }
+
+ public ModelProvider[] getEnabledModelProviders() {
+ ModelProvider[] enabledProviders = super.getEnabledModelProviders();
+ // add Patch model provider if it's not there
+ for (int i = 0; i < enabledProviders.length; i++) {
+ ModelProvider provider = enabledProviders[i];
+ if (provider.getId().equals(PatchModelProvider.ID))
+ return enabledProviders;
+ }
+ ModelProvider[] extended = new ModelProvider[enabledProviders.length + 1];
+ for (int i = 0; i < enabledProviders.length; i++) {
+ extended[i] = enabledProviders[i];
+ }
+ PatchModelProvider provider = PatchModelProvider.getProvider();
+ if (provider == null)
+ return enabledProviders;
+ extended[extended.length - 1] = provider;
+ return extended;
+ }
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchSubscriber.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchSubscriber.java
new file mode 100644
index 000000000..16b9ecb33
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchSubscriber.java
@@ -0,0 +1,150 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.internal.ui.synchronize.patch;
+
+import java.util.*;
+
+import org.eclipse.compare.internal.core.patch.DiffProject;
+import org.eclipse.compare.internal.core.patch.FilePatch2;
+import org.eclipse.compare.internal.patch.PatchProjectDiffNode;
+import org.eclipse.compare.internal.patch.WorkspacePatcher;
+import org.eclipse.compare.structuremergeviewer.IDiffElement;
+import org.eclipse.core.resources.*;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.team.core.TeamException;
+import org.eclipse.team.core.subscribers.Subscriber;
+import org.eclipse.team.core.synchronize.SyncInfo;
+import org.eclipse.team.core.variants.IResourceVariant;
+import org.eclipse.team.core.variants.IResourceVariantComparator;
+import org.eclipse.team.internal.core.mapping.LocalResourceVariant;
+
+public class ApplyPatchSubscriber extends Subscriber {
+
+ private class ApplyPatchSyncInfo extends SyncInfo {
+ private ApplyPatchSyncInfo(IResource local, IResourceVariant base,
+ IResourceVariant remote, IResourceVariantComparator comparator) {
+ super(local, base, remote, comparator);
+ }
+
+ protected int calculateKind() throws TeamException {
+ // TODO: this works only for files, what about excluding individual hunks?
+ if (!getPatcher().isEnabled(PatchModelProvider.getPatchObject(getLocal(), patcher)))
+ return IN_SYNC;
+ // mark diffs with problems as conflicts
+ if (getRemote() != null
+ && getPatcher().getDiffResult(((PatchedFileVariant)getRemote()).getDiff()).containsProblems())
+ return CONFLICTING;
+ return super.calculateKind();
+ }
+ }
+
+ private WorkspacePatcher patcher;
+ private IResourceVariantComparator comparator;
+
+ public ApplyPatchSubscriber(WorkspacePatcher patcher) {
+ this.patcher = patcher;
+ this.comparator = new PatchedFileVariantComparator();
+ getPatcher().refresh();
+ }
+
+ public String getName() {
+ return "Apply Patch Subscriber"; //$NON-NLS-1$
+ }
+
+ public IResourceVariantComparator getResourceComparator() {
+ return comparator;
+ }
+
+ public SyncInfo getSyncInfo(IResource resource) throws TeamException {
+ if (!isSupervised(resource)) return null;
+ // XXX: doing this here is highly inefficient!
+ // getPatcher().refresh();
+ // a little bit better but still called gazzilon times
+ refresh(new IResource[] { resource }, IResource.DEPTH_ZERO, null);
+ try {
+ FilePatch2 diff = (FilePatch2) PatchModelProvider.getPatchObject(resource, getPatcher());
+ // use null as remote variant for deletions
+ IResourceVariant variant = null;
+ if (diff.getDiffType(patcher.isReversed()) != FilePatch2.DELETION)
+ variant = new PatchedFileVariant(getPatcher(), diff);
+ IResourceVariant base = resource.exists() ? new LocalResourceVariant(resource) : null;
+ SyncInfo info = new ApplyPatchSyncInfo(resource, base, variant, getResourceComparator());
+ info.init();
+ return info;
+ } catch (CoreException e) {
+ throw TeamException.asTeamException(e);
+ }
+ }
+
+ public boolean isSupervised(IResource resource) throws TeamException {
+ return resource.getType() == IResource.FILE
+ && PatchModelProvider.getPatchObject(resource, getPatcher()) != null;
+ }
+
+ public IResource[] members(IResource resource) throws TeamException {
+ try {
+ if(resource.getType() == IResource.FILE)
+ // file has no IResource members
+ return new IResource[0];
+ IContainer container = (IContainer) resource;
+
+ // workspace container members
+ List existingChildren = new ArrayList(Arrays.asList(container.members()));
+
+ // patch members, subscriber location
+ FilePatch2[] diffs = getPatcher().getDiffs();
+ for (int i = 0; i < diffs.length; i++) {
+ IResource file = PatchModelProvider.getFile(diffs[i], getPatcher());
+ if (!container.exists(file.getProjectRelativePath())) {
+ existingChildren.add(file);
+ }
+ }
+ return (IResource[]) existingChildren.toArray(new IResource[existingChildren.size()]);
+ } catch (CoreException e) {
+ throw TeamException.asTeamException(e);
+ }
+ }
+
+ public void refresh(IResource[] resources, int depth,
+ IProgressMonitor monitor) throws TeamException {
+ Set /* <FilePatch> */diffs = new HashSet();
+ for (int i = 0; i < resources.length; i++) {
+ Object object = PatchModelProvider.getPatchObject(resources[i],
+ getPatcher());
+ if (object instanceof FilePatch2) {
+ FilePatch2 filePatch = (FilePatch2) object;
+ diffs.add(filePatch);
+ }
+ }
+ getPatcher().refresh((FilePatch2[]) diffs.toArray(new FilePatch2[0]));
+ }
+
+ public IResource[] roots() {
+ Set roots = new HashSet();
+ if (getPatcher().isWorkspacePatch()) {
+ IDiffElement[] children = PatchModelProvider.getPatchWorkspace(this).getChildren();
+ for (int i = 0; i < children.length; i++) {
+ // return array of projects from the patch
+ DiffProject diffProject = ((PatchProjectDiffNode)children[i]).getDiffProject();
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(diffProject.getName());
+ roots.add(project);
+ }
+ } else {
+ roots.add(getPatcher().getTarget());
+ }
+ return (IResource[]) roots.toArray(new IResource[0]);
+ }
+
+ WorkspacePatcher getPatcher() {
+ return patcher;
+ }
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchSubscriberMergeContext.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchSubscriberMergeContext.java
new file mode 100644
index 000000000..8442b1688
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchSubscriberMergeContext.java
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.internal.ui.synchronize.patch;
+
+import org.eclipse.compare.internal.core.patch.*;
+import org.eclipse.compare.internal.patch.WorkspacePatcher;
+import org.eclipse.core.resources.*;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
+import org.eclipse.team.core.diff.IDiff;
+import org.eclipse.team.core.mapping.ISynchronizationScopeManager;
+import org.eclipse.team.core.subscribers.Subscriber;
+import org.eclipse.team.core.subscribers.SubscriberMergeContext;
+
+class ApplyPatchSubscriberMergeContext extends SubscriberMergeContext {
+
+ protected ApplyPatchSubscriberMergeContext(Subscriber subscriber,
+ ISynchronizationScopeManager manager) {
+ super(subscriber, manager);
+ }
+
+ public static ApplyPatchSubscriberMergeContext createContext(
+ Subscriber subscriber, ISynchronizationScopeManager manager) {
+ ApplyPatchSubscriberMergeContext mergeContext = new ApplyPatchSubscriberMergeContext(
+ subscriber, manager);
+ // Initialize using the ApplyPatchSubscriber to populate the diff tree.
+ mergeContext.initialize();
+ return mergeContext;
+ }
+
+ protected void makeInSync(IDiff diff, IProgressMonitor monitor)
+ throws CoreException {
+ markAsMerged(diff, true, monitor);
+ }
+
+ public void markAsMerged(IDiff node, boolean inSyncHint,
+ IProgressMonitor monitor) throws CoreException {
+ IResource resource = getDiffTree().getResource(node);
+ WorkspacePatcher patcher = ((ApplyPatchSubscriber) getSubscriber())
+ .getPatcher();
+ Object object = PatchModelProvider.getPatchObject(resource, patcher);
+ if (object instanceof FilePatch2) {
+ FilePatch2 filePatch = (FilePatch2) object;
+ FileDiffResult fileDiffResult = patcher.getDiffResult(filePatch);
+ HunkResult[] hunkResults = fileDiffResult.getHunkResults();
+ for (int i = 0; i < hunkResults.length; i++) {
+ // disable hunks that were merged
+ if (hunkResults[i].isOK())
+ patcher.setEnabled(hunkResults[i].getHunk(), false);
+ }
+ } else {
+ patcher.setEnabled(object, false);
+ }
+ }
+
+ public void reject(IDiff diff, IProgressMonitor monitor)
+ throws CoreException {
+ // do nothing
+ }
+
+ public ISchedulingRule getMergeRule(IDiff diff) {
+ IResource resource = getDiffTree().getResource(diff);
+ IResourceRuleFactory ruleFactory = ResourcesPlugin.getWorkspace()
+ .getRuleFactory();
+ if (!resource.exists()) {
+ // for additions return rule for all parents that need to be created
+ IContainer parent = resource.getParent();
+ while (!parent.exists()) {
+ resource = parent;
+ parent = parent.getParent();
+ }
+ return ruleFactory.createRule(resource);
+ } else {
+ return super.getMergeRule(diff);
+ }
+ }
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchSynchronizationActionProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchSynchronizationActionProvider.java
new file mode 100644
index 000000000..2ca4072d6
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchSynchronizationActionProvider.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.internal.ui.synchronize.patch;
+
+import org.eclipse.team.ui.mapping.SynchronizationActionProvider;
+import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
+
+public class ApplyPatchSynchronizationActionProvider extends
+ SynchronizationActionProvider {
+
+ public ApplyPatchSynchronizationActionProvider() {
+ super();
+ }
+
+ protected void initialize() {
+ super.initialize();
+ final ISynchronizePageConfiguration configuration = getSynchronizePageConfiguration();
+ // We provide custom handler that is disabled for hunks.
+ registerHandler(MERGE_ACTION_ID, new ApplyPatchMergeActionHandler(
+ configuration, false));
+ // 'Overwrite' and 'Mark as merged' actions are not shown, see
+ // ApplyPatchModelSynchronizeParticipant.ApplyPatchModelSynchronizeParticipantActionGroup.addToContextMenu(String,
+ // Action, IMenuManager)
+ }
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchSynchronizationWizard.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchSynchronizationWizard.java
new file mode 100644
index 000000000..4d1a99346
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchSynchronizationWizard.java
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * Copyright (c) 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.internal.ui.synchronize.patch;
+
+import org.eclipse.compare.CompareConfiguration;
+import org.eclipse.compare.internal.patch.*;
+import org.eclipse.core.resources.*;
+import org.eclipse.core.resources.mapping.ResourceMapping;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.team.core.subscribers.SubscriberMergeContext;
+import org.eclipse.team.core.subscribers.SubscriberScopeManager;
+import org.eclipse.team.internal.ui.Utils;
+import org.eclipse.team.ui.IConfigurationWizard;
+import org.eclipse.team.ui.TeamUI;
+import org.eclipse.team.ui.synchronize.ISynchronizeParticipant;
+import org.eclipse.team.ui.synchronize.ModelSynchronizeParticipant;
+import org.eclipse.ui.IWorkbench;
+
+public class ApplyPatchSynchronizationWizard extends PatchWizard implements
+ IConfigurationWizard {
+
+ public ApplyPatchSynchronizationWizard() {
+ // TODO: get selection, available when launched from toolbar or main menu
+ super((IStorage) null, (IResource) null, new CompareConfiguration());
+ }
+
+ private boolean isPreviewInSyncViewSelected() {
+ return ((PatchPreviewModePage)getPage(PatchPreviewModePage.PATCH_PREVIEW_MODE_PAGE_NAME)).isPreviewInSyncViewSelected();
+ }
+
+ public boolean performFinish() {
+ if (isPreviewInSyncViewSelected()) {
+ ApplyPatchSubscriber subscriber = new ApplyPatchSubscriber(getPatcher());
+
+ // Get ResourceMappings for root resources from the patch.
+ ResourceMapping[] inputMappings = Utils.getResourceMappings(subscriber.roots());
+
+ // Take the given mappings, consult logical models and construct the complete set of resources to be operated on.
+ // Use SubscriberResourceMappingContext which uses subscriber to access to the remote state of local resources.
+ SubscriberScopeManager scopeManager = new SubscriberScopeManager(subscriber.getName(), inputMappings, subscriber, true);
+
+ // Initialize the diff tree.
+ // TODO: are we going to perform head-less auto-merges? do we need to subclass MergeContext?
+ SubscriberMergeContext mergeContext = ApplyPatchSubscriberMergeContext.createContext(subscriber, scopeManager);
+
+ // Create the participant and show it.
+ ModelSynchronizeParticipant participant = new ApplyPatchModelSynchronizeParticipant(mergeContext);
+ TeamUI.getSynchronizeManager().addSynchronizeParticipants(new ISynchronizeParticipant[]{participant});
+ // We don't know in which site to show progress because a participant could actually be shown in multiple sites.
+ participant.run(null /* no site */);
+ return true;
+ } else {
+ // apply the patch
+ return super.performFinish();
+ // TODO: Next, synchronize the affected files, but only when the wizard has been opened from the sync view.
+ }
+ }
+
+ public void init(IWorkbench workbench, IProject project) {
+ // nothing to do here
+ }
+
+ public void addPages() {
+ if (getPatch() == null)
+ addPage(fPatchWizardPage = new InputPatchPage(this));
+ if (getPatch() == null || !getPatcher().isWorkspacePatch())
+ addPage(fPatchTargetPage = new PatchTargetPage(getPatcher()));
+ addPage(new PatchPreviewModePage());
+ fPreviewPage2 = new PreviewPatchPage2(getPatcher(),
+ getCompareConfiguration());
+ addPage(fPreviewPage2);
+ }
+
+ public boolean canFinish() {
+ IWizardPage currentPage = getContainer().getCurrentPage();
+ if (currentPage.getName().equals(
+ PatchPreviewModePage.PATCH_PREVIEW_MODE_PAGE_NAME)
+ && isPreviewInSyncViewSelected()) {
+ return true;
+ }
+ return super.canFinish();
+ }
+
+ public WorkspacePatcher getPatcher() {
+ // make the patcher available to other classes in the package
+ return super.getPatcher();
+ }
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/DiffProjectResourceMapping.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/DiffProjectResourceMapping.java
new file mode 100644
index 000000000..376e9b815
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/DiffProjectResourceMapping.java
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.internal.ui.synchronize.patch;
+
+import org.eclipse.compare.internal.core.patch.*;
+import org.eclipse.core.resources.*;
+import org.eclipse.core.resources.mapping.*;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+public class DiffProjectResourceMapping extends ResourceMapping {
+
+ private final DiffProject object;
+
+ public DiffProjectResourceMapping(DiffProject adaptableObject) {
+ object = adaptableObject;
+ }
+
+ public Object getModelObject() {
+ return object;
+ }
+
+ public String getModelProviderId() {
+ return PatchModelProvider.ID;
+ }
+
+ public IProject[] getProjects() {
+ IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject(
+ object.getName());
+ return new IProject[] { p };
+ }
+
+ public ResourceTraversal[] getTraversals(ResourceMappingContext context,
+ IProgressMonitor monitor) throws CoreException {
+ return new ResourceTraversal[] { new ResourceTraversal(
+ new IResource[] { getResource() }, IResource.DEPTH_INFINITE,
+ IResource.NONE) };
+ }
+
+ private IResource getResource() {
+ return getProjects()[0];
+ }
+
+ public boolean contains(ResourceMapping mapping) {
+ if (mapping instanceof DiffProjectResourceMapping) {
+ DiffProject diffProject = (DiffProject) mapping.getModelObject();
+ return diffProject.getName().equals(object.getName());
+ } else if (mapping instanceof FilePatchResourceMapping) {
+ FileDiffResult filePatch = (FileDiffResult) mapping
+ .getModelObject();
+ FilePatch2[] filePatches = object.getFileDiffs();
+ for (int i = 0; i < filePatches.length; i++) {
+ if (filePatches[i].getPath(false).equals(
+ filePatch.getTargetPath()))
+ return true;
+ }
+ } else if (mapping instanceof HunkResourceMapping) {
+ HunkResult hunk = (HunkResult) mapping.getModelObject();
+ DiffProject diffProject = hunk.getHunk().getParent().getProject();
+ return diffProject.getName().equals(object.getName());
+ }
+ return super.contains(mapping);
+ }
+
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/ExcludedPatchDiffNodesFilter.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/ExcludedPatchDiffNodesFilter.java
new file mode 100644
index 000000000..a49ba4a64
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/ExcludedPatchDiffNodesFilter.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.internal.ui.synchronize.patch;
+
+import org.eclipse.compare.internal.patch.PatchDiffNode;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+
+public class ExcludedPatchDiffNodesFilter extends ViewerFilter {
+
+ private static ViewerFilter filter;
+
+ public static ViewerFilter getInstance() {
+ if (filter == null)
+ filter = new ExcludedPatchDiffNodesFilter();
+ return filter;
+ }
+
+ public ExcludedPatchDiffNodesFilter() {
+ super();
+ }
+
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
+ if (element instanceof PatchDiffNode) {
+ PatchDiffNode node = (PatchDiffNode) element;
+ return node.isEnabled();
+ }
+ return true;
+ }
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/FilePatchResourceMapping.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/FilePatchResourceMapping.java
new file mode 100644
index 000000000..2795d5fa5
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/FilePatchResourceMapping.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.internal.ui.synchronize.patch;
+
+import org.eclipse.compare.internal.core.patch.DiffProject;
+import org.eclipse.compare.internal.core.patch.FileDiffResult;
+import org.eclipse.compare.internal.patch.WorkspaceFileDiffResult;
+import org.eclipse.core.resources.*;
+import org.eclipse.core.resources.mapping.*;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+public class FilePatchResourceMapping extends ResourceMapping {
+
+ private final FileDiffResult object;
+
+ public FilePatchResourceMapping(FileDiffResult fileDiffResult) {
+ object = fileDiffResult;
+ }
+
+ public Object getModelObject() {
+ return object;
+ }
+
+ public String getModelProviderId() {
+ return PatchModelProvider.ID;
+ }
+
+ public IProject[] getProjects() {
+ DiffProject dp = (DiffProject) object.getDiff().getProject();
+ IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject(
+ dp.getName());
+ return new IProject[] { p };
+ }
+
+ public ResourceTraversal[] getTraversals(ResourceMappingContext context,
+ IProgressMonitor monitor) throws CoreException {
+ return new ResourceTraversal[] { new ResourceTraversal(
+ new IResource[] { getResource() }, IResource.DEPTH_INFINITE,
+ IResource.NONE) };
+ }
+
+ private IResource getResource() {
+ return ((WorkspaceFileDiffResult) object).getTargetFile();
+ }
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/HunkResourceMapping.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/HunkResourceMapping.java
new file mode 100644
index 000000000..9bd50fcc7
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/HunkResourceMapping.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.internal.ui.synchronize.patch;
+
+import org.eclipse.compare.internal.core.patch.DiffProject;
+import org.eclipse.compare.internal.core.patch.HunkResult;
+import org.eclipse.core.resources.*;
+import org.eclipse.core.resources.mapping.*;
+import org.eclipse.core.runtime.*;
+
+public class HunkResourceMapping extends ResourceMapping {
+
+ private final HunkResult object;
+
+ public HunkResourceMapping(HunkResult hunkResult) {
+ this.object = hunkResult;
+ }
+
+ public Object getModelObject() {
+ return object;
+ }
+
+ public String getModelProviderId() {
+ return PatchModelProvider.ID;
+ }
+
+ public IProject[] getProjects() {
+ DiffProject dp = (DiffProject) object.getHunk().getParent()
+ .getProject();
+ IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject(
+ dp.getName());
+ return new IProject[] { p };
+ }
+
+ private IResource getResource() {
+ IPath path = object.getHunk().getParent().getPath(false);
+ return getProjects()[0].getFile(path);
+ }
+
+ public ResourceTraversal[] getTraversals(ResourceMappingContext context,
+ IProgressMonitor monitor) throws CoreException {
+ return new ResourceTraversal[] { new ResourceTraversal(
+ new IResource[] { getResource() }, IResource.DEPTH_ZERO,
+ IResource.NONE) };
+ }
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/PatchCompareAdapter.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/PatchCompareAdapter.java
new file mode 100644
index 000000000..f4f2802c0
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/PatchCompareAdapter.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.internal.ui.synchronize.patch;
+
+import org.eclipse.compare.structuremergeviewer.ICompareInput;
+import org.eclipse.core.resources.mapping.*;
+import org.eclipse.team.core.mapping.ISynchronizationContext;
+import org.eclipse.team.core.mapping.ISynchronizationScope;
+import org.eclipse.team.internal.ui.mapping.DiffTreeChangesSection.ITraversalFactory;
+import org.eclipse.team.ui.mapping.SynchronizationCompareAdapter;
+import org.eclipse.ui.IMemento;
+
+public class PatchCompareAdapter extends SynchronizationCompareAdapter
+ implements ITraversalFactory {
+
+ public ICompareInput asCompareInput(ISynchronizationContext context,
+ Object o) {
+ if (o instanceof ICompareInput)
+ return (ICompareInput) o;
+ return super.asCompareInput(context, o);
+ }
+
+ public void save(ResourceMapping[] mappings, IMemento memento) {
+ // Don't save
+ }
+
+ public ResourceMapping[] restore(IMemento memento) {
+ // Don't restore
+ return null;
+ }
+
+ public ResourceTraversal[] getTraversals(ISynchronizationScope scope) {
+ return scope.getTraversals(ModelProvider.RESOURCE_MODEL_PROVIDER_ID);
+ }
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/PatchModelProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/PatchModelProvider.java
new file mode 100644
index 000000000..3f3b0256b
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/PatchModelProvider.java
@@ -0,0 +1,125 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.internal.ui.synchronize.patch;
+
+import org.eclipse.compare.internal.core.patch.DiffProject;
+import org.eclipse.compare.internal.core.patch.FilePatch2;
+import org.eclipse.compare.internal.patch.*;
+import org.eclipse.compare.structuremergeviewer.IDiffElement;
+import org.eclipse.core.resources.*;
+import org.eclipse.core.resources.mapping.ModelProvider;
+import org.eclipse.core.resources.mapping.ResourceMapping;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.team.core.subscribers.Subscriber;
+import org.eclipse.team.internal.core.TeamPlugin;
+
+public class PatchModelProvider extends ModelProvider {
+
+ public static final String ID = "org.eclipse.team.ui.patchModelProvider"; //$NON-NLS-1$
+ private static PatchModelProvider provider;
+
+ public static PatchModelProvider getProvider() {
+ if (provider == null) {
+ try {
+ provider = (PatchModelProvider) ModelProvider
+ .getModelProviderDescriptor(PatchModelProvider.ID)
+ .getModelProvider();
+ } catch (CoreException e) {
+ TeamPlugin.log(e);
+ }
+ }
+ return provider;
+ }
+
+ static ResourceMapping getResourceMapping(IDiffElement object) {
+ if (object instanceof PatchProjectDiffNode) {
+ return new DiffProjectResourceMapping(
+ ((PatchProjectDiffNode) object).getDiffProject());
+ } else if (object instanceof PatchFileDiffNode) {
+ return new FilePatchResourceMapping(((PatchFileDiffNode) object)
+ .getDiffResult());
+ } else if (object instanceof HunkDiffNode) {
+ return new HunkResourceMapping(((HunkDiffNode) object)
+ .getHunkResult());
+ }
+ return null;
+ }
+
+ /**
+ * Returns the resource associated with the corresponding model element.
+ *
+ * @param element
+ * the model element
+ * @return the associated resource, or <code>null</code>
+ */
+ static IResource getResource(PatchDiffNode element) {
+ IResource resource= null;
+ if (element instanceof PatchProjectDiffNode) {
+ return ((PatchProjectDiffNode) element).getResource();
+ } else if (element instanceof PatchFileDiffNode) {
+ return ((PatchFileDiffNode) element).getResource();
+ } else if (element instanceof HunkDiffNode) {
+ return ((HunkDiffNode) element).getResource();
+ }
+ return resource;
+ }
+
+ static Object/*DiffProject or FilePatch2*/ getPatchObject(IResource resource, WorkspacePatcher patcher) {
+ switch (resource.getType()) {
+ case IResource.PROJECT: {
+ if (patcher.isWorkspacePatch()) {
+ DiffProject[] diffProjects = patcher.getDiffProjects();
+ for (int i = 0; i < diffProjects.length; i++) {
+ if (diffProjects[i].getName().equals(resource.getName()))
+ return diffProjects[i];
+ }
+ } else {
+ // TODO:
+ }
+ }
+ case IResource.FILE: {
+ FilePatch2[] diffs = patcher.getDiffs();
+ for (int i = 0; i < diffs.length; i++) {
+ if (resource.equals(getFile(diffs[i], patcher))) {
+ return diffs[i];
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ static IFile getFile(FilePatch2 diff, WorkspacePatcher patcher) {
+ IProject project = null;
+ if (patcher.isWorkspacePatch()) {
+ DiffProject diffProject = (diff).getProject();
+ project = ResourcesPlugin.getWorkspace().getRoot().getProject(diffProject.getName());
+ if (project.getName().equals(diffProject.getName())) {
+ return project.getFile(diff.getPath(patcher.isReversed()));
+ }
+ } else {
+ project = patcher.getTarget().getProject();
+ if (project.getName().equals(patcher.getTarget().getProject().getName())) {
+ return project.getFile(diff.getPath(patcher.isReversed()));
+ }
+ }
+ return project.getFile(diff.getPath(patcher.isReversed()));
+ }
+
+ public static PatchWorkspace getPatchWorkspace(Subscriber subscriber) {
+ if (subscriber instanceof ApplyPatchSubscriber) {
+ ApplyPatchSubscriber aps = (ApplyPatchSubscriber) subscriber;
+ return new PatchWorkspace(aps.getPatcher());
+ }
+ // TODO: assertion?
+ return null;
+ }
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/PatchPreviewModePage.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/PatchPreviewModePage.java
new file mode 100644
index 000000000..7af836caf
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/PatchPreviewModePage.java
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * Copyright (c) 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.internal.ui.synchronize.patch;
+
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.team.internal.ui.TeamUIMessages;
+
+public class PatchPreviewModePage extends WizardPage {
+
+ public final static String PATCH_PREVIEW_MODE_PAGE_NAME = "PatchPreviewModePage"; //$NON-NLS-1$
+ private Button previewInDialogButton;
+ private Button previewInSyncViewButton;
+
+ public PatchPreviewModePage() {
+ super(PATCH_PREVIEW_MODE_PAGE_NAME,
+ TeamUIMessages.PatchPreviewModePage_title, null);
+ setDescription(TeamUIMessages.PatchPreviewModePage_description);
+ }
+
+ public void createControl(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NULL);
+ composite.setLayout(new GridLayout());
+ composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL
+ | GridData.HORIZONTAL_ALIGN_FILL));
+ setControl(composite);
+
+ initializeDialogUnits(parent);
+ createPreviewOptionArea(composite);
+ }
+
+ private void createPreviewOptionArea(Composite parent) {
+
+ SelectionAdapter selectionAdapter = new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ setPageComplete(true); // update wizard buttons
+ }
+ };
+
+ GridData gd = new GridData();
+
+ // 1st row
+ previewInDialogButton = new Button(parent, SWT.RADIO);
+ previewInDialogButton
+ .setText(TeamUIMessages.PatchPreviewModePage_previewInPatchWizard);
+ previewInDialogButton.setLayoutData(gd);
+ previewInDialogButton.addSelectionListener(selectionAdapter);
+ // TODO: enable 'Next' and 'Finish'
+
+ // 2nd row
+ previewInSyncViewButton = new Button(parent, SWT.RADIO);
+ previewInSyncViewButton
+ .setText(TeamUIMessages.PatchPreviewModePage_previewInSynchronizeView);
+ previewInSyncViewButton.setLayoutData(gd);
+ previewInSyncViewButton.addSelectionListener(selectionAdapter);
+ previewInSyncViewButton.setSelection(true);
+ }
+
+ public IWizardPage getNextPage() {
+ if (previewInSyncViewButton.getSelection())
+ return null;
+ return super.getNextPage();
+ }
+
+ public boolean isPreviewInSyncViewSelected() {
+ return previewInSyncViewButton.getSelection();
+ }
+
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/PatchSyncContentProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/PatchSyncContentProvider.java
new file mode 100644
index 000000000..ae0316eb6
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/PatchSyncContentProvider.java
@@ -0,0 +1,130 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.internal.ui.synchronize.patch;
+
+import org.eclipse.compare.internal.patch.PatchDiffNode;
+import org.eclipse.compare.structuremergeviewer.IDiffElement;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.mapping.*;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.team.core.mapping.ISynchronizationContext;
+import org.eclipse.team.core.mapping.ISynchronizationScope;
+import org.eclipse.team.internal.ui.TeamUIPlugin;
+import org.eclipse.team.internal.ui.mapping.SynchronizationResourceMappingContext;
+import org.eclipse.team.ui.mapping.SynchronizationContentProvider;
+import org.eclipse.team.ui.synchronize.ModelSynchronizeParticipant;
+import org.eclipse.ui.model.BaseWorkbenchContentProvider;
+import org.eclipse.ui.navigator.CommonViewer;
+import org.eclipse.ui.navigator.ICommonContentExtensionSite;
+
+public class PatchSyncContentProvider extends SynchronizationContentProvider {
+
+ private BaseWorkbenchContentProvider delegate;
+
+ public void init(ICommonContentExtensionSite site) {
+ super.init(site);
+ delegate = new BaseWorkbenchContentProvider();
+ }
+
+ public void dispose() {
+ super.dispose();
+ if (delegate != null)
+ delegate.dispose();
+ }
+
+ protected ITreeContentProvider getDelegateContentProvider() {
+ return delegate;
+ }
+
+ protected String getModelProviderId() {
+ return PatchModelProvider.ID;
+ }
+
+ protected Object getModelRoot() {
+ if (getContext() instanceof ApplyPatchSubscriberMergeContext) {
+ ApplyPatchSubscriberMergeContext context = (ApplyPatchSubscriberMergeContext) getContext();
+ return PatchModelProvider.getPatchWorkspace(context.getSubscriber());
+ }
+ // TODO: assertion?
+ return null;
+ }
+
+ /*
+ * Copied from
+ * org.eclipse.team.examples.model.ui.mapping.ModelSyncContentProvider
+ * .getTraversals(ISynchronizationContext, Object)
+ */
+ protected ResourceTraversal[] getTraversals(
+ ISynchronizationContext context, Object object) {
+ if (object instanceof IDiffElement) {
+ ResourceMapping mapping = PatchModelProvider.getResourceMapping((IDiffElement) object);
+ ResourceMappingContext rmc = new SynchronizationResourceMappingContext(
+ context);
+ try {
+ return mapping.getTraversals(rmc, new NullProgressMonitor());
+ } catch (CoreException e) {
+ TeamUIPlugin.log(e);
+ }
+ }
+ return new ResourceTraversal[0];
+ }
+
+ protected boolean isInScope(ISynchronizationScope scope, Object parent,
+ Object element) {
+ if (element instanceof PatchDiffNode) {
+ final IResource resource = PatchModelProvider
+ .getResource((PatchDiffNode) element);
+ if (resource == null)
+ return false;
+ if (scope.contains(resource))
+ return true;
+ }
+ return false;
+ }
+
+ public void propertyChange(PropertyChangeEvent event) {
+ super.propertyChange(event);
+ if (event.getProperty().equals(ModelSynchronizeParticipant.P_VISIBLE_MODEL_PROVIDER)) {
+ if (event.getNewValue().equals(PatchModelProvider.ID)) {
+ addFilter(getViewer());
+ } else if (event.getOldValue().equals(PatchModelProvider.ID)){
+ removeFilter(getViewer());
+ }
+ }
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ super.inputChanged(viewer, oldInput, newInput);
+ if (PatchModelProvider.getProvider().equals(newInput)) {
+ addFilter(viewer);
+ } else if (PatchModelProvider.getProvider().equals(oldInput)) {
+ // removeFilter(viewer);
+ }
+ }
+
+ private static void addFilter(Viewer v) {
+ if (v != null && v instanceof CommonViewer) {
+ CommonViewer cv = (CommonViewer) v;
+ cv.addFilter(ExcludedPatchDiffNodesFilter.getInstance());
+ }
+ }
+
+ private static void removeFilter(Viewer v) {
+ if (v != null && v instanceof CommonViewer) {
+ CommonViewer cv = (CommonViewer) v;
+ cv.removeFilter(ExcludedPatchDiffNodesFilter.getInstance());
+ }
+ }
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/PatchSyncLabelProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/PatchSyncLabelProvider.java
new file mode 100644
index 000000000..f48d6121f
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/PatchSyncLabelProvider.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.internal.ui.synchronize.patch;
+
+import org.eclipse.compare.internal.patch.PatchDiffNode;
+import org.eclipse.compare.structuremergeviewer.Differencer;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.team.core.diff.IDiff;
+import org.eclipse.team.ui.mapping.SynchronizationLabelProvider;
+import org.eclipse.ui.navigator.ICommonContentExtensionSite;
+
+public class PatchSyncLabelProvider extends SynchronizationLabelProvider {
+
+ private PatchWorkbenchLabelProvider delegate;
+
+ public PatchSyncLabelProvider() {
+ super();
+ }
+
+ public void init(ICommonContentExtensionSite site) {
+ super.init(site);
+ delegate = new PatchWorkbenchLabelProvider();
+ }
+
+ public void dispose() {
+ super.dispose();
+ if (delegate != null)
+ delegate.dispose();
+ }
+
+ protected ILabelProvider getDelegateLabelProvider() {
+ return delegate;
+ }
+
+ protected IDiff getDiff(Object element) {
+ if (element instanceof PatchDiffNode) {
+ IResource resource = PatchModelProvider
+ .getResource((PatchDiffNode) element);
+ return getContext().getDiffTree().getDiff(resource);
+ }
+ return super.getDiff(element);
+ }
+
+ protected Image getCompareImage(Image base, int kind) {
+ /*
+ * Need to swap left and right for PatchDiffNodes as done in Apply Patch
+ * wizard. See org.eclipse.compare.structuremergeviewer.DiffTreeViewer.
+ * DiffViewerLabelProvider.getImage(Object).
+ */
+ switch (kind & Differencer.DIRECTION_MASK) {
+ case Differencer.LEFT:
+ kind = (kind & ~Differencer.LEFT) | Differencer.RIGHT;
+ break;
+ case Differencer.RIGHT:
+ kind = (kind & ~Differencer.RIGHT) | Differencer.LEFT;
+ break;
+ }
+ return super.getCompareImage(base, kind);
+ }
+
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/PatchWorkbenchAdapter.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/PatchWorkbenchAdapter.java
new file mode 100644
index 000000000..d8cc10410
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/PatchWorkbenchAdapter.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.internal.ui.synchronize.patch;
+
+import org.eclipse.compare.structuremergeviewer.DiffNode;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.model.IWorkbenchAdapter;
+
+public class PatchWorkbenchAdapter implements IWorkbenchAdapter {
+
+ public Object[] getChildren(Object o) {
+ if (o instanceof DiffNode) {
+ return ((DiffNode) o).getChildren();
+ }
+ return null;
+ }
+
+ public ImageDescriptor getImageDescriptor(Object object) {
+ if (object instanceof DiffNode) {
+ Image image = ((DiffNode) object).getImage();
+ return ImageDescriptor.createFromImage(image);
+ }
+ return null;
+ }
+
+ public String getLabel(Object o) {
+ if (o instanceof DiffNode) {
+ return ((DiffNode) o).getName();
+ }
+ return null;
+ }
+
+ public Object getParent(Object o) {
+ if (o instanceof DiffNode) {
+ return ((DiffNode) o).getParent();
+ }
+ return null;
+ }
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/PatchWorkbenchLabelProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/PatchWorkbenchLabelProvider.java
new file mode 100644
index 000000000..38f903ee9
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/PatchWorkbenchLabelProvider.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.internal.ui.synchronize.patch;
+
+import org.eclipse.compare.structuremergeviewer.DiffNode;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
+import org.eclipse.ui.navigator.ICommonContentExtensionSite;
+import org.eclipse.ui.navigator.ICommonLabelProvider;
+
+public class PatchWorkbenchLabelProvider extends WorkbenchLabelProvider
+ implements ICommonLabelProvider {
+
+ private ICommonContentExtensionSite extensionSite;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.navigator.ICommonLabelProvider#init(org.eclipse.ui.navigator.ICommonContentExtensionSite)
+ */
+ public void init(ICommonContentExtensionSite aConfig) {
+ extensionSite = aConfig;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.navigator.IMementoAware#restoreState(org.eclipse.ui.IMemento)
+ */
+ public void restoreState(IMemento aMemento) {
+ // Nothing to do
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.navigator.IMementoAware#saveState(org.eclipse.ui.IMemento)
+ */
+ public void saveState(IMemento aMemento) {
+ // Nothing to do
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.navigator.IDescriptionProvider#getDescription(java.lang.Object)
+ */
+ public String getDescription(Object anElement) {
+ if (anElement instanceof DiffNode) {
+ return ((DiffNode) anElement).getName();
+ }
+ return null;
+ }
+
+ /**
+ * Return the extension site for this label provider.
+ * @return the extension site for this label provider
+ */
+ public ICommonContentExtensionSite getExtensionSite() {
+ return extensionSite;
+ }
+
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/PatchWorkspace.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/PatchWorkspace.java
new file mode 100644
index 000000000..0a726277d
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/PatchWorkspace.java
@@ -0,0 +1,111 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.internal.ui.synchronize.patch;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.compare.internal.core.patch.*;
+import org.eclipse.compare.internal.patch.*;
+import org.eclipse.compare.structuremergeviewer.*;
+import org.eclipse.core.internal.runtime.AdapterManager;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IAdaptable;
+
+// TODO: extend PatchDiffNode, update navigatorContent triggerPoints when done
+public class PatchWorkspace extends DiffNode implements IAdaptable {
+
+ private WorkspacePatcher patcher;
+
+ public PatchWorkspace(WorkspacePatcher patcher) {
+ super(null, Differencer.NO_CHANGE);
+ this.patcher = patcher;
+ }
+
+ public WorkspacePatcher getPatcher() {
+ return patcher;
+ }
+
+ public IResource getResource() {
+ return ResourcesPlugin.getWorkspace().getRoot();
+ }
+
+ public String getName() {
+ return "Patch Root Workspace"; //$NON-NLS-1$
+ }
+
+ public IDiffContainer getParent() {
+ return null;
+ }
+
+ public IDiffElement[] getChildren() {
+ /*
+ * Create a complete tree of patch model objects - elements of the
+ * patch, but return only top-level ones: PatchProjectDiffNode(s) for a
+ * workspace patch or FileDiffResult(s) otherwise. See
+ * org.eclipse.compare.internal
+ * .patch.PatchCompareEditorInput.buildTree()
+ */
+ IDiffElement[] children;
+ if (getPatcher().isWorkspacePatch()) {
+ children = processProjects(getPatcher().getDiffProjects());
+ } else {
+ children = processDiffs(getPatcher().getDiffs());
+ }
+ return children;
+ }
+
+ // see org.eclipse.compare.internal.patch.PatchCompareEditorInput.processDiffs(FilePatch2[])
+ private IDiffElement[] processDiffs(FilePatch2[] diffs) {
+ List result = new ArrayList();
+ for (int i = 0; i < diffs.length; i++) {
+ result.addAll(processDiff(diffs[i], this));
+ }
+ return (IDiffElement[]) result.toArray(new IDiffElement[result.size()]);
+ }
+
+ // see org.eclipse.compare.internal.patch.PatchCompareEditorInput.processProjects(DiffProject[])
+ private IDiffElement[] processProjects(DiffProject[] diffProjects) {
+ List result = new ArrayList();
+ for (int i = 0; i < diffProjects.length; i++) {
+ PatchProjectDiffNode projectNode = new PatchProjectDiffNode(this, diffProjects[i], getPatcher().getConfiguration());
+ result.add(projectNode);
+ FilePatch2[] diffs = diffProjects[i].getFileDiffs();
+ for (int j = 0; j < diffs.length; j++) {
+ FilePatch2 fileDiff = diffs[j];
+ processDiff(fileDiff, projectNode);
+ }
+ }
+ return (IDiffElement[]) result.toArray(new IDiffElement[result.size()]);
+ }
+
+ // see org.eclipse.compare.internal.patch.PatchCompareEditorInput.processDiff(FilePatch2, DiffNode)
+ private List/*<IDiffElement>*/ processDiff(FilePatch2 diff, DiffNode parent) {
+ List result = new ArrayList();
+ FileDiffResult diffResult = getPatcher().getDiffResult(diff);
+ PatchFileDiffNode node = PatchFileDiffNode.createDiffNode(parent, diffResult);
+ result.add(node);
+ HunkResult[] hunkResults = diffResult.getHunkResults();
+ for (int i = 0; i < hunkResults.length; i++) {
+ HunkResult hunkResult = hunkResults[i];
+ /*HunkDiffNode hunkDiffNode =*/ HunkDiffNode.createDiffNode(node, hunkResult, false, true, false);
+ // result.add(hunkDiffNode);
+ }
+ return result;
+ }
+
+ // cannot extend PlatformObject (already extends DiffNode) so implement
+ // IAdaptable
+ public Object getAdapter(Class adapter) {
+ return AdapterManager.getDefault().getAdapter(this, adapter);
+ }
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/PatchedFileVariant.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/PatchedFileVariant.java
new file mode 100644
index 000000000..1283f5a7b
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/PatchedFileVariant.java
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.internal.ui.synchronize.patch;
+
+import java.io.InputStream;
+
+import org.eclipse.compare.internal.core.patch.FileDiffResult;
+import org.eclipse.compare.internal.core.patch.FilePatch2;
+import org.eclipse.compare.internal.patch.WorkspacePatcher;
+import org.eclipse.core.resources.IStorage;
+import org.eclipse.core.runtime.*;
+import org.eclipse.team.core.TeamException;
+import org.eclipse.team.core.variants.IResourceVariant;
+
+public class PatchedFileVariant implements IResourceVariant {
+
+ private FilePatch2 diff;
+ private WorkspacePatcher patcher;
+
+ public PatchedFileVariant(WorkspacePatcher patcher, FilePatch2 diff) {
+ this.diff = diff;
+ this.patcher = patcher;
+ }
+
+ public byte[] asBytes() {
+ // We don't persist the variant between sessions.
+ return null;
+ }
+
+ public String getContentIdentifier() {
+ return "(After Patch)"; //$NON-NLS-1$
+ }
+
+ public String getName() {
+ return diff.getPath(patcher.isReversed()).lastSegment();
+ }
+
+ public IStorage getStorage(IProgressMonitor monitor) throws TeamException {
+ return new IStorage() {
+
+ public Object getAdapter(Class adapter) {
+ return null;
+ }
+
+ public boolean isReadOnly() {
+ return true;
+ }
+
+ public String getName() {
+ return PatchedFileVariant.this.getName();
+ }
+
+ public IPath getFullPath() {
+ return null;
+ }
+
+ public InputStream getContents() throws CoreException {
+ FileDiffResult diffResult = patcher.getDiffResult(diff);
+ return diffResult.getPatchedContents();
+ }
+ };
+ }
+
+ public boolean isContainer() {
+ return false;
+ }
+
+ FilePatch2 getDiff() {
+ return diff;
+ }
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/PatchedFileVariantComparator.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/PatchedFileVariantComparator.java
new file mode 100644
index 000000000..af968befe
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/patch/PatchedFileVariantComparator.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.internal.ui.synchronize.patch;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.team.core.variants.IResourceVariant;
+import org.eclipse.team.core.variants.IResourceVariantComparator;
+import org.eclipse.team.internal.core.mapping.LocalResourceVariant;
+
+public class PatchedFileVariantComparator implements IResourceVariantComparator {
+
+ public boolean compare(IResource local, IResourceVariant remote) {
+ if (remote instanceof LocalResourceVariant)
+ // return true when matching with base
+ return true;
+ return false;
+ }
+
+ public boolean compare(IResourceVariant base, IResourceVariant remote) {
+ return false;
+ }
+
+ public boolean isThreeWay() {
+ return true;
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/AbstractSynchronizeLabelProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/AbstractSynchronizeLabelProvider.java
index 7d668d17d..680325800 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/AbstractSynchronizeLabelProvider.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/AbstractSynchronizeLabelProvider.java
@@ -119,7 +119,13 @@ public abstract class AbstractSynchronizeLabelProvider implements ILabelProvider
return getCompareImage(base, compareKind);
}
- private Image getCompareImage(Image base, int compareKind) {
+ /**
+ * Returns an image showing the specified change kind applied to a given base image.
+ *
+ * @nooverride This method is not intended to be re-implemented or extended by clients.
+ * @noreference This method is not intended to be referenced by clients.
+ */
+ protected Image getCompareImage(Image base, int compareKind) {
return getImageManager().getImage(base, compareKind);
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ModelSynchronizeParticipantActionGroup.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ModelSynchronizeParticipantActionGroup.java
index f0a4821b7..4b3969183 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ModelSynchronizeParticipantActionGroup.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ModelSynchronizeParticipantActionGroup.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
+ * Copyright (c) 2005, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -49,7 +49,7 @@ public class ModelSynchronizeParticipantActionGroup extends SynchronizePageActio
/**
* The id of the action group that determines where the other
- * actions (e.g. mark-as-mered) appear in the context menu.
+ * actions (e.g. mark-as-merged) appear in the context menu.
*/
public static final String OTHER_ACTION_GROUP = "other"; //$NON-NLS-1$

Back to the top