Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndre Weinand2004-06-17 11:58:01 -0400
committerAndre Weinand2004-06-17 11:58:01 -0400
commit339248e6139f0aba611bc2480a1249aa7d98cf7c (patch)
tree7c48bc1853fbf44dceabe16f32ed0a73618ce507 /bundles/org.eclipse.compare/compare
parentb9cc42261be95cf678107a5354bb97137980e1c0 (diff)
downloadeclipse.platform.team-339248e6139f0aba611bc2480a1249aa7d98cf7c.tar.gz
eclipse.platform.team-339248e6139f0aba611bc2480a1249aa7d98cf7c.tar.xz
eclipse.platform.team-339248e6139f0aba611bc2480a1249aa7d98cf7c.zip
fix for #37648: Exceptions after one of the compare viewer inputs got deleted
Diffstat (limited to 'bundles/org.eclipse.compare/compare')
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java61
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeViewerContentProvider.java35
2 files changed, 87 insertions, 9 deletions
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java
index 496dddaf8..3ec22c11a 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java
@@ -60,6 +60,7 @@ import org.eclipse.compare.*;
import org.eclipse.compare.internal.ICompareContextIds;
import org.eclipse.compare.internal.MergeSourceViewer;
import org.eclipse.compare.internal.BufferedCanvas;
+import org.eclipse.compare.internal.MergeViewerContentProvider;
import org.eclipse.compare.internal.Utilities;
import org.eclipse.compare.internal.TokenComparator;
import org.eclipse.compare.internal.DocLineComparator;
@@ -257,6 +258,8 @@ public class TextMergeViewer extends ContentMergeViewer {
private IPositionUpdater fPositionUpdater;
private boolean fIsMotif;
private boolean fIsCarbon;
+
+ private boolean fHasErrors;
// SWT widgets
@@ -1664,16 +1667,18 @@ public class TextMergeViewer extends ContentMergeViewer {
fChangeDiffs= null;
fAllDiffs= null;
fEndOfDocReached= false;
+ fHasErrors= false; // start with no errors
CompareConfiguration cc= getCompareConfiguration();
IMergeViewerContentProvider cp= getMergeContentProvider();
- boolean rightEditable= cc.isRightEditable() && cp.isRightEditable(input);
- boolean leftEditable= cc.isLeftEditable() && cp.isLeftEditable(input);
+ if (cp instanceof MergeViewerContentProvider) {
+ MergeViewerContentProvider mcp= (MergeViewerContentProvider) cp;
+ mcp.setAncestorError(null);
+ mcp.setLeftError(null);
+ mcp.setRightError(null);
+ }
- fRight.setEditable(rightEditable);
- fLeft.setEditable(leftEditable);
-
// set new documents
setDocument(fLeft, 'L', left);
fLeftLineCount= fLeft.getLineCount();
@@ -1685,13 +1690,21 @@ public class TextMergeViewer extends ContentMergeViewer {
setDocument(fAncestor, 'A', ancestor);
- doDiff();
-
+ updateHeader();
+ updateControls();
+ updateToolItems();
+
+ if (!fHasErrors)
+ doDiff();
+
+ fRight.setEditable(cc.isRightEditable() && cp.isRightEditable(input));
+ fLeft.setEditable(cc.isLeftEditable() && cp.isLeftEditable(input));
+
invalidateLines();
updateVScrollBar();
refreshBirdsEyeView();
- if (!emptyInput && !fComposite.isDisposed()) {
+ if (!fHasErrors && !emptyInput && !fComposite.isDisposed()) {
Diff selectDiff= null;
if (FIX_47640) {
if (leftRange != null)
@@ -1878,6 +1891,25 @@ public class TextMergeViewer extends ContentMergeViewer {
return 0;
}
+ private void setError(char type, String message) {
+ IMergeViewerContentProvider cp= getMergeContentProvider();
+ if (cp instanceof MergeViewerContentProvider) {
+ MergeViewerContentProvider mcp= (MergeViewerContentProvider) cp;
+ switch (type) {
+ case 'A':
+ mcp.setAncestorError(message);
+ break;
+ case 'L':
+ mcp.setLeftError(message);
+ break;
+ case 'R':
+ mcp.setRightError(message);
+ break;
+ }
+ }
+ fHasErrors= true;
+ }
+
/**
* Returns true if a new Document could be installed.
*/
@@ -1906,7 +1938,7 @@ public class TextMergeViewer extends ContentMergeViewer {
try {
s= Utilities.readString(sca);
} catch (CoreException ex) {
- // NeedWork
+ setError(type, ex.getMessage());
}
newDoc= new Document(s != null ? s : ""); //$NON-NLS-1$
@@ -3162,6 +3194,17 @@ public class TextMergeViewer extends ContentMergeViewer {
if (fIgnoreAncestorItem != null)
fIgnoreAncestorItem.setVisible(isThreeWay());
+ if (fCopyDiffLeftToRightItem != null) {
+ IAction a= fCopyDiffLeftToRightItem.getAction();
+ if (a != null)
+ a.setEnabled(a.isEnabled() && !fHasErrors);
+ }
+ if (fCopyDiffRightToLeftItem != null) {
+ IAction a= fCopyDiffRightToLeftItem.getAction();
+ if (a != null)
+ a.setEnabled(a.isEnabled() && !fHasErrors);
+ }
+
super.updateToolItems();
}
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeViewerContentProvider.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeViewerContentProvider.java
index a21e6a4cd..0156e7df1 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeViewerContentProvider.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeViewerContentProvider.java
@@ -25,11 +25,18 @@ import org.eclipse.compare.contentmergeviewer.IMergeViewerContentProvider;
public class MergeViewerContentProvider implements IMergeViewerContentProvider {
private CompareConfiguration fCompareConfiguration;
+ private String fAncestorError;
+ private String fLeftError;
+ private String fRightError;
public MergeViewerContentProvider(CompareConfiguration cc) {
fCompareConfiguration= cc;
}
+ private boolean hasError() {
+ return fAncestorError != null || fLeftError != null || fRightError != null;
+ }
+
public void dispose() {
}
@@ -39,11 +46,19 @@ public class MergeViewerContentProvider implements IMergeViewerContentProvider {
//---- ancestor
+ public void setAncestorError(String errorMessage) {
+ fAncestorError= errorMessage;
+ }
+
public String getAncestorLabel(Object element) {
+ if (fAncestorError != null)
+ return fAncestorError;
return fCompareConfiguration.getAncestorLabel(element);
}
public Image getAncestorImage(Object element) {
+ if (fAncestorError != null)
+ return null;
return fCompareConfiguration.getAncestorImage(element);
}
@@ -62,11 +77,19 @@ public class MergeViewerContentProvider implements IMergeViewerContentProvider {
//---- left
+ public void setLeftError(String errorMessage) {
+ fLeftError= errorMessage;
+ }
+
public String getLeftLabel(Object element) {
+ if (fLeftError != null)
+ return fLeftError;
return fCompareConfiguration.getLeftLabel(element);
}
public Image getLeftImage(Object element) {
+ if (fLeftError != null)
+ return null;
return fCompareConfiguration.getLeftImage(element);
}
@@ -77,6 +100,8 @@ public class MergeViewerContentProvider implements IMergeViewerContentProvider {
}
public boolean isLeftEditable(Object element) {
+ if (hasError())
+ return false;
if (element instanceof ICompareInput) {
Object left= ((ICompareInput) element).getLeft();
if (left == null) {
@@ -112,11 +137,19 @@ public class MergeViewerContentProvider implements IMergeViewerContentProvider {
//---- right
+ public void setRightError(String errorMessage) {
+ fRightError= errorMessage;
+ }
+
public String getRightLabel(Object element) {
+ if (fRightError != null)
+ return fRightError;
return fCompareConfiguration.getRightLabel(element);
}
public Image getRightImage(Object element) {
+ if (fRightError != null)
+ return null;
return fCompareConfiguration.getRightImage(element);
}
@@ -127,6 +160,8 @@ public class MergeViewerContentProvider implements IMergeViewerContentProvider {
}
public boolean isRightEditable(Object element) {
+ if (hasError())
+ return false;
if (element instanceof ICompareInput) {
Object right= ((ICompareInput) element).getRight();
if (right == null) {

Back to the top