Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 157236 Details for
Bug 298923
[Sync View][Apply patch] Merge changes from dev branch back to HEAD
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
All changes v01
298923_all_changes.txt (text/plain), 98.30 KB, created by
Tomasz Zarna
on 2010-01-26 06:29:34 EST
(
hide
)
Description:
All changes v01
Filename:
MIME Type:
Creator:
Tomasz Zarna
Created:
2010-01-26 06:29:34 EST
Size:
98.30 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.compare >Index: compare/org/eclipse/compare/internal/patch/HunkDiffNode.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/HunkDiffNode.java,v >retrieving revision 1.9 >diff -u -r1.9 HunkDiffNode.java >--- compare/org/eclipse/compare/internal/patch/HunkDiffNode.java 15 Jul 2008 14:45:28 -0000 1.9 >+++ compare/org/eclipse/compare/internal/patch/HunkDiffNode.java 26 Jan 2010 11:28:12 -0000 >@@ -14,6 +14,7 @@ > 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 @@ > return false; > } > >+ public IResource getResource() { >+ return ((PatchFileDiffNode)getParent()).getResource(); >+ } > } >Index: compare/org/eclipse/compare/internal/patch/InputPatchPage.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/InputPatchPage.java,v >retrieving revision 1.46 >diff -u -r1.46 InputPatchPage.java >--- compare/org/eclipse/compare/internal/patch/InputPatchPage.java 23 Dec 2009 13:13:12 -0000 1.46 >+++ compare/org/eclipse/compare/internal/patch/InputPatchPage.java 26 Jan 2010 11:28:12 -0000 >@@ -80,7 +80,7 @@ > > 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 @@ > } > } > >- InputPatchPage(PatchWizard pw) { >+ public InputPatchPage(PatchWizard pw) { > super(INPUTPATCHPAGE_NAME, PatchMessages.InputPatchPage_title, null); > fPatchWizard= pw; > setMessage(PatchMessages.InputPatchPage_message); >@@ -221,7 +221,10 @@ > // 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(); >Index: compare/org/eclipse/compare/internal/patch/PatchDiffNode.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchDiffNode.java,v >retrieving revision 1.4 >diff -u -r1.4 PatchDiffNode.java >--- compare/org/eclipse/compare/internal/patch/PatchDiffNode.java 16 Mar 2007 19:53:10 -0000 1.4 >+++ compare/org/eclipse/compare/internal/patch/PatchDiffNode.java 26 Jan 2010 11:28:12 -0000 >@@ -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 @@ > return getPatchElement().hashCode(); > } > >+ public IResource getResource() { >+ return null; >+ } > } >Index: compare/org/eclipse/compare/internal/patch/PatchFileDiffNode.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchFileDiffNode.java,v >retrieving revision 1.6 >diff -u -r1.6 PatchFileDiffNode.java >--- compare/org/eclipse/compare/internal/patch/PatchFileDiffNode.java 4 Mar 2009 15:45:39 -0000 1.6 >+++ compare/org/eclipse/compare/internal/patch/PatchFileDiffNode.java 26 Jan 2010 11:28:12 -0000 >@@ -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 boolean fileExists() { >- IFile file = ((WorkspaceFileDiffResult)getDiffResult()).getTargetFile(); >+ IResource file = getResource(); > return file != null && file.isAccessible(); > } > >+ public IResource getResource() { >+ return ((WorkspaceFileDiffResult)getDiffResult()).getTargetFile(); >+ } > } >Index: compare/org/eclipse/compare/internal/patch/PatchProjectDiffNode.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchProjectDiffNode.java,v >retrieving revision 1.6 >diff -u -r1.6 PatchProjectDiffNode.java >--- compare/org/eclipse/compare/internal/patch/PatchProjectDiffNode.java 16 Feb 2009 11:46:21 -0000 1.6 >+++ compare/org/eclipse/compare/internal/patch/PatchProjectDiffNode.java 26 Jan 2010 11:28:12 -0000 >@@ -14,7 +14,11 @@ > 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 @@ > return project; > } > >+ public IResource getResource() { >+ return ResourcesPlugin.getWorkspace().getRoot().getProject(getDiffProject().getName()); >+ } >+ > } >Index: compare/org/eclipse/compare/internal/patch/PatchTargetPage.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchTargetPage.java,v >retrieving revision 1.7 >diff -u -r1.7 PatchTargetPage.java >--- compare/org/eclipse/compare/internal/patch/PatchTargetPage.java 8 Dec 2006 17:10:19 -0000 1.7 >+++ compare/org/eclipse/compare/internal/patch/PatchTargetPage.java 26 Jan 2010 11:28:12 -0000 >@@ -12,18 +12,31 @@ > > 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 @@ > > 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; >Index: compare/org/eclipse/compare/internal/patch/PatchWizard.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchWizard.java,v >retrieving revision 1.50 >diff -u -r1.50 PatchWizard.java >--- compare/org/eclipse/compare/internal/patch/PatchWizard.java 26 Aug 2009 09:12:59 -0000 1.50 >+++ compare/org/eclipse/compare/internal/patch/PatchWizard.java 26 Jan 2010 11:28:12 -0000 >@@ -40,9 +40,9 @@ > > 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 @@ > } > } > >- WorkspacePatcher getPatcher() { >+ protected WorkspacePatcher getPatcher() { > return fPatcher; > } >- >+ >+ protected IStorage getPatch() { >+ return patch; >+ } >+ > IResource getTarget() { > return fPatcher.getTarget(); > } > >- > /* (non-Javadoc) > * Method declared on IWizard. > */ >Index: compare/org/eclipse/compare/internal/patch/Patcher.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/Patcher.java,v >retrieving revision 1.69 >diff -u -r1.69 Patcher.java >--- compare/org/eclipse/compare/internal/patch/Patcher.java 4 Mar 2009 15:45:39 -0000 1.69 >+++ compare/org/eclipse/compare/internal/patch/Patcher.java 26 Jan 2010 11:28:12 -0000 >@@ -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 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 @@ > 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); >#P org.eclipse.team.ui >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.team.ui/META-INF/MANIFEST.MF,v >retrieving revision 1.28 >diff -u -r1.28 MANIFEST.MF >--- META-INF/MANIFEST.MF 10 Jul 2009 13:25:27 -0000 1.28 >+++ META-INF/MANIFEST.MF 26 Jan 2010 11:28:14 -0000 >@@ -15,6 +15,7 @@ > 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, >Index: plugin.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.team.ui/plugin.properties,v >retrieving revision 1.77 >diff -u -r1.77 plugin.properties >--- plugin.properties 22 Dec 2009 11:45:26 -0000 1.77 >+++ plugin.properties 26 Jan 2010 11:28:14 -0000 >@@ -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.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. >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.team.ui/plugin.xml,v >retrieving revision 1.203 >diff -u -r1.203 plugin.xml >--- plugin.xml 22 Dec 2009 11:45:26 -0000 1.203 >+++ plugin.xml 26 Jan 2010 11:28:14 -0000 >@@ -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> >Index: src/org/eclipse/team/internal/ui/TeamUIMessages.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamUIMessages.java,v >retrieving revision 1.84 >diff -u -r1.84 TeamUIMessages.java >--- src/org/eclipse/team/internal/ui/TeamUIMessages.java 16 Oct 2009 10:29:25 -0000 1.84 >+++ src/org/eclipse/team/internal/ui/TeamUIMessages.java 26 Jan 2010 11:28:14 -0000 >@@ -714,6 +714,11 @@ > 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; > > } >Index: src/org/eclipse/team/internal/ui/messages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties,v >retrieving revision 1.255 >diff -u -r1.255 messages.properties >--- src/org/eclipse/team/internal/ui/messages.properties 8 Dec 2009 16:17:59 -0000 1.255 >+++ src/org/eclipse/team/internal/ui/messages.properties 26 Jan 2010 11:28:15 -0000 >@@ -570,3 +570,10 @@ > 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 >Index: src/org/eclipse/team/internal/ui/mapping/ModelCompareEditorInput.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ModelCompareEditorInput.java,v >retrieving revision 1.41 >diff -u -r1.41 ModelCompareEditorInput.java >--- src/org/eclipse/team/internal/ui/mapping/ModelCompareEditorInput.java 24 Feb 2009 10:31:13 -0000 1.41 >+++ src/org/eclipse/team/internal/ui/mapping/ModelCompareEditorInput.java 26 Jan 2010 11:28:15 -0000 >@@ -189,7 +189,7 @@ > } > > 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) { >Index: src/org/eclipse/team/internal/ui/synchronize/actions/OpenInCompareAction.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/OpenInCompareAction.java,v >retrieving revision 1.47 >diff -u -r1.47 OpenInCompareAction.java >--- src/org/eclipse/team/internal/ui/synchronize/actions/OpenInCompareAction.java 29 Apr 2009 13:17:11 -0000 1.47 >+++ src/org/eclipse/team/internal/ui/synchronize/actions/OpenInCompareAction.java 26 Jan 2010 11:28:15 -0000 >@@ -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.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 @@ > 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; >Index: src/org/eclipse/team/internal/ui/synchronize/patch/AdapterFactory.java >=================================================================== >RCS file: src/org/eclipse/team/internal/ui/synchronize/patch/AdapterFactory.java >diff -N src/org/eclipse/team/internal/ui/synchronize/patch/AdapterFactory.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/team/internal/ui/synchronize/patch/AdapterFactory.java 1 Jan 1970 00:00:00 -0000 >@@ -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 }; >+ } >+} >Index: src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchMergeActionHandler.java >=================================================================== >RCS file: src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchMergeActionHandler.java >diff -N src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchMergeActionHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchMergeActionHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -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; >+ } >+ } >+ } >+ >+} >Index: src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchModelCompareEditorInput.java >=================================================================== >RCS file: src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchModelCompareEditorInput.java >diff -N src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchModelCompareEditorInput.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchModelCompareEditorInput.java 1 Jan 1970 00:00:00 -0000 >@@ -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$ >+ */ >+ } >+} >Index: src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchModelSynchronizeParticipant.java >=================================================================== >RCS file: src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchModelSynchronizeParticipant.java >diff -N src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchModelSynchronizeParticipant.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchModelSynchronizeParticipant.java 1 Jan 1970 00:00:00 -0000 >@@ -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; >+ } >+} >Index: src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchSubscriber.java >=================================================================== >RCS file: src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchSubscriber.java >diff -N src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchSubscriber.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchSubscriber.java 1 Jan 1970 00:00:00 -0000 >@@ -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; >+ } >+} >Index: src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchSubscriberMergeContext.java >=================================================================== >RCS file: src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchSubscriberMergeContext.java >diff -N src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchSubscriberMergeContext.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchSubscriberMergeContext.java 1 Jan 1970 00:00:00 -0000 >@@ -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); >+ } >+ } >+} >Index: src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchSynchronizationActionProvider.java >=================================================================== >RCS file: src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchSynchronizationActionProvider.java >diff -N src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchSynchronizationActionProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchSynchronizationActionProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -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) >+ } >+} >Index: src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchSynchronizationWizard.java >=================================================================== >RCS file: src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchSynchronizationWizard.java >diff -N src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchSynchronizationWizard.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/team/internal/ui/synchronize/patch/ApplyPatchSynchronizationWizard.java 1 Jan 1970 00:00:00 -0000 >@@ -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(); >+ } >+} >Index: src/org/eclipse/team/internal/ui/synchronize/patch/DiffProjectResourceMapping.java >=================================================================== >RCS file: src/org/eclipse/team/internal/ui/synchronize/patch/DiffProjectResourceMapping.java >diff -N src/org/eclipse/team/internal/ui/synchronize/patch/DiffProjectResourceMapping.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/team/internal/ui/synchronize/patch/DiffProjectResourceMapping.java 1 Jan 1970 00:00:00 -0000 >@@ -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); >+ } >+ >+} >Index: src/org/eclipse/team/internal/ui/synchronize/patch/ExcludedPatchDiffNodesFilter.java >=================================================================== >RCS file: src/org/eclipse/team/internal/ui/synchronize/patch/ExcludedPatchDiffNodesFilter.java >diff -N src/org/eclipse/team/internal/ui/synchronize/patch/ExcludedPatchDiffNodesFilter.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/team/internal/ui/synchronize/patch/ExcludedPatchDiffNodesFilter.java 1 Jan 1970 00:00:00 -0000 >@@ -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; >+ } >+} >Index: src/org/eclipse/team/internal/ui/synchronize/patch/FilePatchResourceMapping.java >=================================================================== >RCS file: src/org/eclipse/team/internal/ui/synchronize/patch/FilePatchResourceMapping.java >diff -N src/org/eclipse/team/internal/ui/synchronize/patch/FilePatchResourceMapping.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/team/internal/ui/synchronize/patch/FilePatchResourceMapping.java 1 Jan 1970 00:00:00 -0000 >@@ -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(); >+ } >+} >Index: src/org/eclipse/team/internal/ui/synchronize/patch/HunkResourceMapping.java >=================================================================== >RCS file: src/org/eclipse/team/internal/ui/synchronize/patch/HunkResourceMapping.java >diff -N src/org/eclipse/team/internal/ui/synchronize/patch/HunkResourceMapping.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/team/internal/ui/synchronize/patch/HunkResourceMapping.java 1 Jan 1970 00:00:00 -0000 >@@ -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) }; >+ } >+} >Index: src/org/eclipse/team/internal/ui/synchronize/patch/PatchCompareAdapter.java >=================================================================== >RCS file: src/org/eclipse/team/internal/ui/synchronize/patch/PatchCompareAdapter.java >diff -N src/org/eclipse/team/internal/ui/synchronize/patch/PatchCompareAdapter.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/team/internal/ui/synchronize/patch/PatchCompareAdapter.java 1 Jan 1970 00:00:00 -0000 >@@ -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); >+ } >+} >Index: src/org/eclipse/team/internal/ui/synchronize/patch/PatchModelProvider.java >=================================================================== >RCS file: src/org/eclipse/team/internal/ui/synchronize/patch/PatchModelProvider.java >diff -N src/org/eclipse/team/internal/ui/synchronize/patch/PatchModelProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/team/internal/ui/synchronize/patch/PatchModelProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -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; >+ } >+} >Index: src/org/eclipse/team/internal/ui/synchronize/patch/PatchPreviewModePage.java >=================================================================== >RCS file: src/org/eclipse/team/internal/ui/synchronize/patch/PatchPreviewModePage.java >diff -N src/org/eclipse/team/internal/ui/synchronize/patch/PatchPreviewModePage.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/team/internal/ui/synchronize/patch/PatchPreviewModePage.java 1 Jan 1970 00:00:00 -0000 >@@ -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(); >+ } >+ >+} >Index: src/org/eclipse/team/internal/ui/synchronize/patch/PatchSyncContentProvider.java >=================================================================== >RCS file: src/org/eclipse/team/internal/ui/synchronize/patch/PatchSyncContentProvider.java >diff -N src/org/eclipse/team/internal/ui/synchronize/patch/PatchSyncContentProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/team/internal/ui/synchronize/patch/PatchSyncContentProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -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()); >+ } >+ } >+} >Index: src/org/eclipse/team/internal/ui/synchronize/patch/PatchSyncLabelProvider.java >=================================================================== >RCS file: src/org/eclipse/team/internal/ui/synchronize/patch/PatchSyncLabelProvider.java >diff -N src/org/eclipse/team/internal/ui/synchronize/patch/PatchSyncLabelProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/team/internal/ui/synchronize/patch/PatchSyncLabelProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -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); >+ } >+ >+} >Index: src/org/eclipse/team/internal/ui/synchronize/patch/PatchWorkbenchAdapter.java >=================================================================== >RCS file: src/org/eclipse/team/internal/ui/synchronize/patch/PatchWorkbenchAdapter.java >diff -N src/org/eclipse/team/internal/ui/synchronize/patch/PatchWorkbenchAdapter.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/team/internal/ui/synchronize/patch/PatchWorkbenchAdapter.java 1 Jan 1970 00:00:00 -0000 >@@ -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; >+ } >+} >Index: src/org/eclipse/team/internal/ui/synchronize/patch/PatchWorkbenchLabelProvider.java >=================================================================== >RCS file: src/org/eclipse/team/internal/ui/synchronize/patch/PatchWorkbenchLabelProvider.java >diff -N src/org/eclipse/team/internal/ui/synchronize/patch/PatchWorkbenchLabelProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/team/internal/ui/synchronize/patch/PatchWorkbenchLabelProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -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; >+ } >+ >+} >Index: src/org/eclipse/team/internal/ui/synchronize/patch/PatchWorkspace.java >=================================================================== >RCS file: src/org/eclipse/team/internal/ui/synchronize/patch/PatchWorkspace.java >diff -N src/org/eclipse/team/internal/ui/synchronize/patch/PatchWorkspace.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/team/internal/ui/synchronize/patch/PatchWorkspace.java 1 Jan 1970 00:00:00 -0000 >@@ -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); >+ } >+} >Index: src/org/eclipse/team/internal/ui/synchronize/patch/PatchedFileVariant.java >=================================================================== >RCS file: src/org/eclipse/team/internal/ui/synchronize/patch/PatchedFileVariant.java >diff -N src/org/eclipse/team/internal/ui/synchronize/patch/PatchedFileVariant.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/team/internal/ui/synchronize/patch/PatchedFileVariant.java 1 Jan 1970 00:00:00 -0000 >@@ -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; >+ } >+} >Index: src/org/eclipse/team/internal/ui/synchronize/patch/PatchedFileVariantComparator.java >=================================================================== >RCS file: src/org/eclipse/team/internal/ui/synchronize/patch/PatchedFileVariantComparator.java >diff -N src/org/eclipse/team/internal/ui/synchronize/patch/PatchedFileVariantComparator.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/team/internal/ui/synchronize/patch/PatchedFileVariantComparator.java 1 Jan 1970 00:00:00 -0000 >@@ -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 >Index: src/org/eclipse/team/ui/synchronize/AbstractSynchronizeLabelProvider.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/AbstractSynchronizeLabelProvider.java,v >retrieving revision 1.17 >diff -u -r1.17 AbstractSynchronizeLabelProvider.java >--- src/org/eclipse/team/ui/synchronize/AbstractSynchronizeLabelProvider.java 3 Jun 2008 13:35:37 -0000 1.17 >+++ src/org/eclipse/team/ui/synchronize/AbstractSynchronizeLabelProvider.java 26 Jan 2010 11:28:17 -0000 >@@ -119,7 +119,13 @@ > 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); > } > >Index: src/org/eclipse/team/ui/synchronize/ModelSynchronizeParticipantActionGroup.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ModelSynchronizeParticipantActionGroup.java,v >retrieving revision 1.11 >diff -u -r1.11 ModelSynchronizeParticipantActionGroup.java >--- src/org/eclipse/team/ui/synchronize/ModelSynchronizeParticipantActionGroup.java 22 May 2007 20:19:54 -0000 1.11 >+++ src/org/eclipse/team/ui/synchronize/ModelSynchronizeParticipantActionGroup.java 26 Jan 2010 11:28:17 -0000 >@@ -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 @@ > > /** > * 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$ >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 298923
:
155863
|
155865
|
155866
|
156075
|
156083
|
156229
|
156372
|
156490
|
156493
|
156536
| 157236