Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 300347 | Differences between
and this patch

Collapse All | Expand All

(-)plugin.xml (+8 lines)
Lines 632-637 Link Here
632
            <actionProvider
632
            <actionProvider
633
                  class="org.eclipse.team.internal.ui.synchronize.patch.ApplyPatchSynchronizationActionProvider">
633
                  class="org.eclipse.team.internal.ui.synchronize.patch.ApplyPatchSynchronizationActionProvider">
634
            </actionProvider>
634
            </actionProvider>
635
            <commonSorter
636
                  class="org.eclipse.team.ui.HunkDiffNodeSorter">
637
               <parentExpression>
638
                  <instanceof
639
                        value="org.eclipse.compare.internal.patch.PatchFileDiffNode">
640
                  </instanceof>
641
               </parentExpression>
642
            </commonSorter>
635
         </navigatorContent>
643
         </navigatorContent>
636
      </extension>
644
      </extension>
637
      <extension
645
      <extension
(-)src/org/eclipse/team/ui/HunkDiffNodeSorter.java (+60 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 * IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.team.ui;
12
13
import java.text.Collator;
14
import java.util.regex.Pattern;
15
16
import org.eclipse.jface.viewers.*;
17
18
public class HunkDiffNodeSorter extends ViewerSorter {
19
20
	public HunkDiffNodeSorter() {
21
	}
22
23
	public HunkDiffNodeSorter(Collator collator) {
24
		super(collator);
25
	}
26
27
	public int compare(Viewer viewer, Object e1, Object e2) {
28
		String label1;
29
		String label2;
30
31
		if (viewer == null || !(viewer instanceof ContentViewer)) {
32
			label1 = e1.toString();
33
			label2 = e2.toString();
34
		} else {
35
			IBaseLabelProvider prov = ((ContentViewer) viewer)
36
					.getLabelProvider();
37
			if (prov instanceof ILabelProvider) {
38
				ILabelProvider lprov = (ILabelProvider) prov;
39
				label1 = lprov.getText(e1);
40
				label2 = lprov.getText(e2);
41
			} else {
42
				label1 = e1.toString();
43
				label2 = e2.toString();
44
			}
45
		}
46
47
		// see org.eclipse.compare.internal.patch.Hunk.getDescription()
48
		String pattern = "\\d+,\\d+ -> \\d+,\\d+"; //$NON-NLS-1$
49
50
		if (Pattern.matches(pattern, label1)
51
				&& Pattern.matches(pattern, label2)) {
52
			int oldStart0 = Integer.parseInt(label1.split(",")[0]); //$NON-NLS-1$
53
			int oldStart1 = Integer.parseInt(label2.split(",")[0]); //$NON-NLS-1$
54
55
			return oldStart0 - oldStart1;
56
		}
57
		return super.compare(viewer, e1, e2);
58
	}
59
60
}

Return to bug 300347