View | Details | Raw Unified | Return to bug 37648 | Differences between
and this patch

Collapse All | Expand All

(-)compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java (-9 / +52 lines)
Lines 60-65 Link Here
60
import org.eclipse.compare.internal.ICompareContextIds;
60
import org.eclipse.compare.internal.ICompareContextIds;
61
import org.eclipse.compare.internal.MergeSourceViewer;
61
import org.eclipse.compare.internal.MergeSourceViewer;
62
import org.eclipse.compare.internal.BufferedCanvas;
62
import org.eclipse.compare.internal.BufferedCanvas;
63
import org.eclipse.compare.internal.MergeViewerContentProvider;
63
import org.eclipse.compare.internal.Utilities;
64
import org.eclipse.compare.internal.Utilities;
64
import org.eclipse.compare.internal.TokenComparator;
65
import org.eclipse.compare.internal.TokenComparator;
65
import org.eclipse.compare.internal.DocLineComparator;
66
import org.eclipse.compare.internal.DocLineComparator;
Lines 257-262 Link Here
257
	private IPositionUpdater fPositionUpdater;
258
	private IPositionUpdater fPositionUpdater;
258
	private boolean fIsMotif;	
259
	private boolean fIsMotif;	
259
	private boolean fIsCarbon;	
260
	private boolean fIsCarbon;	
261
	
262
	private boolean fHasErrors;
260
		
263
		
261
264
262
	// SWT widgets
265
	// SWT widgets
Lines 1664-1679 Link Here
1664
	 	fChangeDiffs= null;
1667
	 	fChangeDiffs= null;
1665
		fAllDiffs= null;
1668
		fAllDiffs= null;
1666
		fEndOfDocReached= false;
1669
		fEndOfDocReached= false;
1670
		fHasErrors= false; // start with no errors
1667
		
1671
		
1668
		CompareConfiguration cc= getCompareConfiguration();
1672
		CompareConfiguration cc= getCompareConfiguration();
1669
		IMergeViewerContentProvider cp= getMergeContentProvider();
1673
		IMergeViewerContentProvider cp= getMergeContentProvider();
1670
		
1674
		
1671
		boolean rightEditable= cc.isRightEditable() && cp.isRightEditable(input);
1675
		if (cp instanceof MergeViewerContentProvider) {
1672
		boolean leftEditable= cc.isLeftEditable() && cp.isLeftEditable(input);
1676
			MergeViewerContentProvider mcp= (MergeViewerContentProvider) cp;
1677
			mcp.setAncestorError(null);
1678
			mcp.setLeftError(null);
1679
			mcp.setRightError(null);
1680
		}
1673
		
1681
		
1674
		fRight.setEditable(rightEditable);
1675
		fLeft.setEditable(leftEditable);
1676
																					
1677
		// set new documents
1682
		// set new documents
1678
		setDocument(fLeft, 'L', left);
1683
		setDocument(fLeft, 'L', left);
1679
		fLeftLineCount= fLeft.getLineCount();
1684
		fLeftLineCount= fLeft.getLineCount();
Lines 1685-1697 Link Here
1685
		
1690
		
1686
		setDocument(fAncestor, 'A', ancestor);
1691
		setDocument(fAncestor, 'A', ancestor);
1687
		
1692
		
1688
	    doDiff();
1693
		updateHeader();
1689
					
1694
		updateControls();
1695
		updateToolItems();
1696
		
1697
		if (!fHasErrors)
1698
			doDiff();
1699
1700
		fRight.setEditable(cc.isRightEditable() && cp.isRightEditable(input));
1701
		fLeft.setEditable(cc.isLeftEditable() && cp.isLeftEditable(input));
1702
		
1690
		invalidateLines();
1703
		invalidateLines();
1691
		updateVScrollBar();
1704
		updateVScrollBar();
1692
		refreshBirdsEyeView();
1705
		refreshBirdsEyeView();
1693
		
1706
		
1694
		if (!emptyInput && !fComposite.isDisposed()) {
1707
		if (!fHasErrors && !emptyInput && !fComposite.isDisposed()) {
1695
			Diff selectDiff= null;
1708
			Diff selectDiff= null;
1696
			if (FIX_47640) {
1709
			if (FIX_47640) {
1697
				if (leftRange != null)
1710
				if (leftRange != null)
Lines 1878-1883 Link Here
1878
		return 0;
1891
		return 0;
1879
	}
1892
	}
1880
	
1893
	
1894
	private void setError(char type, String message) {
1895
		IMergeViewerContentProvider cp= getMergeContentProvider();
1896
		if (cp instanceof MergeViewerContentProvider) {
1897
			MergeViewerContentProvider mcp= (MergeViewerContentProvider) cp;
1898
			switch (type) {
1899
			case 'A':
1900
				mcp.setAncestorError(message);
1901
				break;
1902
			case 'L':
1903
				mcp.setLeftError(message);
1904
				break;
1905
			case 'R':
1906
				mcp.setRightError(message);
1907
				break;
1908
			}
1909
		}
1910
		fHasErrors= true;
1911
	}
1912
	
1881
	/**
1913
	/**
1882
	 * Returns true if a new Document could be installed.
1914
	 * Returns true if a new Document could be installed.
1883
	 */
1915
	 */
Lines 1906-1912 Link Here
1906
				try {
1938
				try {
1907
					s= Utilities.readString(sca);
1939
					s= Utilities.readString(sca);
1908
				} catch (CoreException ex) {
1940
				} catch (CoreException ex) {
1909
					// NeedWork
1941
					setError(type, ex.getMessage());
1910
				}
1942
				}
1911
	
1943
	
1912
				newDoc= new Document(s != null ? s : ""); //$NON-NLS-1$
1944
				newDoc= new Document(s != null ? s : ""); //$NON-NLS-1$
Lines 3161-3166 Link Here
3161
					
3193
					
3162
		if (fIgnoreAncestorItem != null)
3194
		if (fIgnoreAncestorItem != null)
3163
			fIgnoreAncestorItem.setVisible(isThreeWay());
3195
			fIgnoreAncestorItem.setVisible(isThreeWay());
3196
		
3197
		if (fCopyDiffLeftToRightItem != null) {
3198
			IAction a= fCopyDiffLeftToRightItem.getAction();
3199
			if (a != null)
3200
				a.setEnabled(a.isEnabled() && !fHasErrors);
3201
		}
3202
		if (fCopyDiffRightToLeftItem != null) {
3203
			IAction a= fCopyDiffRightToLeftItem.getAction();
3204
			if (a != null)
3205
				a.setEnabled(a.isEnabled() && !fHasErrors);
3206
		}
3164
		
3207
		
3165
		super.updateToolItems();
3208
		super.updateToolItems();
3166
	}
3209
	}
(-)compare/org/eclipse/compare/internal/MergeViewerContentProvider.java (+35 lines)
Lines 25-35 Link Here
25
public class MergeViewerContentProvider implements IMergeViewerContentProvider {
25
public class MergeViewerContentProvider implements IMergeViewerContentProvider {
26
	
26
	
27
	private CompareConfiguration fCompareConfiguration;
27
	private CompareConfiguration fCompareConfiguration;
28
	private String fAncestorError;
29
	private String fLeftError;
30
	private String fRightError;
28
		
31
		
29
	public MergeViewerContentProvider(CompareConfiguration cc) {
32
	public MergeViewerContentProvider(CompareConfiguration cc) {
30
		fCompareConfiguration= cc;
33
		fCompareConfiguration= cc;
31
	}
34
	}
32
	
35
	
36
	private boolean hasError() {
37
		return fAncestorError != null || fLeftError != null || fRightError != null;
38
	}
39
	
33
	public void dispose() {
40
	public void dispose() {
34
	}
41
	}
35
	
42
	
Lines 39-49 Link Here
39
	
46
	
40
	//---- ancestor
47
	//---- ancestor
41
			
48
			
49
	public void setAncestorError(String errorMessage) {
50
		fAncestorError= errorMessage;
51
	}
52
	
42
	public String getAncestorLabel(Object element) {
53
	public String getAncestorLabel(Object element) {
54
		if (fAncestorError != null)
55
			return fAncestorError;
43
		return fCompareConfiguration.getAncestorLabel(element);
56
		return fCompareConfiguration.getAncestorLabel(element);
44
	}
57
	}
45
	
58
	
46
	public Image getAncestorImage(Object element) {
59
	public Image getAncestorImage(Object element) {
60
		if (fAncestorError != null)
61
			return null;
47
		return fCompareConfiguration.getAncestorImage(element);
62
		return fCompareConfiguration.getAncestorImage(element);
48
	}
63
	}
49
	
64
	
Lines 62-72 Link Here
62
77
63
	//---- left
78
	//---- left
64
					
79
					
80
	public void setLeftError(String errorMessage) {
81
		fLeftError= errorMessage;
82
	}
83
	
65
	public String getLeftLabel(Object element) {
84
	public String getLeftLabel(Object element) {
85
		if (fLeftError != null)
86
			return fLeftError;
66
		return fCompareConfiguration.getLeftLabel(element);
87
		return fCompareConfiguration.getLeftLabel(element);
67
	}
88
	}
68
	
89
	
69
	public Image getLeftImage(Object element) {
90
	public Image getLeftImage(Object element) {
91
		if (fLeftError != null)
92
			return null;
70
		return fCompareConfiguration.getLeftImage(element);
93
		return fCompareConfiguration.getLeftImage(element);
71
	}
94
	}
72
	
95
	
Lines 77-82 Link Here
77
	}
100
	}
78
		
101
		
79
	public boolean isLeftEditable(Object element) {
102
	public boolean isLeftEditable(Object element) {
103
		if (hasError())
104
			return false;
80
		if (element instanceof ICompareInput) {
105
		if (element instanceof ICompareInput) {
81
			Object left= ((ICompareInput) element).getLeft();
106
			Object left= ((ICompareInput) element).getLeft();
82
			if (left == null) {
107
			if (left == null) {
Lines 112-122 Link Here
112
	
137
	
113
	//---- right
138
	//---- right
114
	
139
	
140
	public void setRightError(String errorMessage) {
141
		fRightError= errorMessage;
142
	}
143
	
115
	public String getRightLabel(Object element) {
144
	public String getRightLabel(Object element) {
145
		if (fRightError != null)
146
			return fRightError;
116
		return fCompareConfiguration.getRightLabel(element);
147
		return fCompareConfiguration.getRightLabel(element);
117
	}
148
	}
118
	
149
	
119
	public Image getRightImage(Object element) {
150
	public Image getRightImage(Object element) {
151
		if (fRightError != null)
152
			return null;
120
		return fCompareConfiguration.getRightImage(element);
153
		return fCompareConfiguration.getRightImage(element);
121
	}
154
	}
122
	
155
	
Lines 127-132 Link Here
127
	}
160
	}
128
	
161
	
129
	public boolean isRightEditable(Object element) {
162
	public boolean isRightEditable(Object element) {
163
		if (hasError())
164
			return false;
130
		if (element instanceof ICompareInput) {
165
		if (element instanceof ICompareInput) {
131
			Object right= ((ICompareInput) element).getRight();
166
			Object right= ((ICompareInput) element).getRight();
132
			if (right == null) {
167
			if (right == null) {

Return to bug 37648