Lines 10-27
Link Here
|
10 |
*******************************************************************************/ |
10 |
*******************************************************************************/ |
11 |
package org.eclipse.team.internal.ui.synchronize.patch; |
11 |
package org.eclipse.team.internal.ui.synchronize.patch; |
12 |
|
12 |
|
13 |
import org.eclipse.compare.internal.patch.HunkDiffNode; |
13 |
import org.eclipse.compare.internal.patch.*; |
14 |
import org.eclipse.compare.internal.patch.PatchDiffNode; |
|
|
15 |
import org.eclipse.compare.structuremergeviewer.IDiffElement; |
14 |
import org.eclipse.compare.structuremergeviewer.IDiffElement; |
16 |
import org.eclipse.core.resources.IResource; |
15 |
import org.eclipse.core.resources.IResource; |
17 |
import org.eclipse.core.resources.mapping.*; |
16 |
import org.eclipse.core.resources.mapping.*; |
18 |
import org.eclipse.core.runtime.CoreException; |
17 |
import org.eclipse.core.runtime.CoreException; |
19 |
import org.eclipse.core.runtime.NullProgressMonitor; |
18 |
import org.eclipse.core.runtime.NullProgressMonitor; |
20 |
import org.eclipse.jface.util.PropertyChangeEvent; |
19 |
import org.eclipse.jface.util.PropertyChangeEvent; |
21 |
import org.eclipse.jface.viewers.ITreeContentProvider; |
20 |
import org.eclipse.jface.viewers.*; |
22 |
import org.eclipse.jface.viewers.Viewer; |
|
|
23 |
import org.eclipse.team.core.mapping.ISynchronizationContext; |
21 |
import org.eclipse.team.core.mapping.ISynchronizationContext; |
24 |
import org.eclipse.team.core.mapping.ISynchronizationScope; |
22 |
import org.eclipse.team.core.mapping.ISynchronizationScope; |
|
|
23 |
import org.eclipse.team.core.subscribers.Subscriber; |
25 |
import org.eclipse.team.internal.ui.TeamUIPlugin; |
24 |
import org.eclipse.team.internal.ui.TeamUIPlugin; |
26 |
import org.eclipse.team.internal.ui.mapping.SynchronizationResourceMappingContext; |
25 |
import org.eclipse.team.internal.ui.mapping.SynchronizationResourceMappingContext; |
27 |
import org.eclipse.team.ui.mapping.SynchronizationContentProvider; |
26 |
import org.eclipse.team.ui.mapping.SynchronizationContentProvider; |
Lines 54-67
Link Here
|
54 |
} |
53 |
} |
55 |
|
54 |
|
56 |
protected Object getModelRoot() { |
55 |
protected Object getModelRoot() { |
|
|
56 |
return PatchModelProvider.getPatchWorkspace(getSubscriber()); |
57 |
} |
58 |
|
59 |
private Subscriber getSubscriber() { |
57 |
if (getContext() instanceof ApplyPatchSubscriberMergeContext) { |
60 |
if (getContext() instanceof ApplyPatchSubscriberMergeContext) { |
58 |
ApplyPatchSubscriberMergeContext context = (ApplyPatchSubscriberMergeContext) getContext(); |
61 |
ApplyPatchSubscriberMergeContext context = (ApplyPatchSubscriberMergeContext) getContext(); |
59 |
return PatchModelProvider.getPatchWorkspace(context.getSubscriber()); |
62 |
return context.getSubscriber(); |
60 |
} |
63 |
} |
61 |
// TODO: assertion? |
|
|
62 |
return null; |
64 |
return null; |
63 |
} |
65 |
} |
64 |
|
66 |
|
65 |
/* |
67 |
/* |
66 |
* Copied from |
68 |
* Copied from |
67 |
* org.eclipse.team.examples.model.ui.mapping.ModelSyncContentProvider |
69 |
* org.eclipse.team.examples.model.ui.mapping.ModelSyncContentProvider |
Lines 94-100
Link Here
|
94 |
} |
96 |
} |
95 |
return false; |
97 |
return false; |
96 |
} |
98 |
} |
|
|
99 |
|
100 |
private class ExcludedPatchDiffNodesFilter extends ViewerFilter { |
97 |
|
101 |
|
|
|
102 |
public boolean select(Viewer viewer, Object parentElement, Object element) { |
103 |
if (element instanceof PatchDiffNode) { |
104 |
PatchDiffNode node = (PatchDiffNode) element; |
105 |
if (!node.isEnabled()) |
106 |
return false; |
107 |
if (node instanceof PatchFileDiffNode) { |
108 |
// when at least one hunk is manually merged, hide the node |
109 |
PatchFileDiffNode file = (PatchFileDiffNode) node; |
110 |
IDiffElement[] children = file.getChildren(); |
111 |
for (int i = 0; i < children.length; i++) { |
112 |
if (children[i] instanceof HunkDiffNode) { |
113 |
HunkDiffNode hunk = (HunkDiffNode) children[i]; |
114 |
WorkspacePatcher patcher = ((ApplyPatchSubscriber)PatchSyncContentProvider.this.getSubscriber()).getPatcher(); |
115 |
if (patcher.isManuallyMerged(hunk.getHunkResult().getHunk())) |
116 |
return false; |
117 |
} |
118 |
} |
119 |
} |
120 |
} |
121 |
return true; |
122 |
} |
123 |
} |
124 |
|
125 |
private ViewerFilter filter; |
126 |
|
127 |
public ViewerFilter getInstance() { |
128 |
if (filter == null) |
129 |
filter = new ExcludedPatchDiffNodesFilter(); |
130 |
return filter; |
131 |
} |
132 |
|
98 |
public void propertyChange(PropertyChangeEvent event) { |
133 |
public void propertyChange(PropertyChangeEvent event) { |
99 |
super.propertyChange(event); |
134 |
super.propertyChange(event); |
100 |
if (event.getProperty().equals(ModelSynchronizeParticipant.P_VISIBLE_MODEL_PROVIDER)) { |
135 |
if (event.getProperty().equals(ModelSynchronizeParticipant.P_VISIBLE_MODEL_PROVIDER)) { |
Lines 115-134
Link Here
|
115 |
} |
150 |
} |
116 |
} |
151 |
} |
117 |
|
152 |
|
118 |
private static void addFilter(Viewer v) { |
153 |
private void addFilter(Viewer v) { |
119 |
if (v != null && v instanceof CommonViewer) { |
154 |
if (v != null && v instanceof CommonViewer) { |
120 |
CommonViewer cv = (CommonViewer) v; |
155 |
CommonViewer cv = (CommonViewer) v; |
121 |
cv.addFilter(ExcludedPatchDiffNodesFilter.getInstance()); |
156 |
cv.addFilter(getInstance()); |
122 |
} |
157 |
} |
123 |
} |
158 |
} |
124 |
|
159 |
|
125 |
private static void removeFilter(Viewer v) { |
160 |
private void removeFilter(Viewer v) { |
126 |
if (v != null && v instanceof CommonViewer) { |
161 |
if (v != null && v instanceof CommonViewer) { |
127 |
CommonViewer cv = (CommonViewer) v; |
162 |
CommonViewer cv = (CommonViewer) v; |
128 |
cv.removeFilter(ExcludedPatchDiffNodesFilter.getInstance()); |
163 |
cv.removeFilter(getInstance()); |
129 |
} |
164 |
} |
130 |
} |
165 |
} |
131 |
|
166 |
|
132 |
public boolean hasChildren(final Object element) { |
167 |
public boolean hasChildren(final Object element) { |
133 |
if (element instanceof HunkDiffNode) |
168 |
if (element instanceof HunkDiffNode) |
134 |
return false; |
169 |
return false; |