Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKai Maetzel2004-04-13 09:34:35 +0000
committerKai Maetzel2004-04-13 09:34:35 +0000
commit06351f1532bb6a959864bebf15af83be87a0e796 (patch)
tree39fdc2c0ea591e36e7d11f469d0d08866d3484a1
parent93b49c3a659e52fb0f6fac2fd1d7da0717d21ca9 (diff)
downloadeclipse.platform.text-06351f1532bb6a959864bebf15af83be87a0e796.tar.gz
eclipse.platform.text-06351f1532bb6a959864bebf15af83be87a0e796.tar.xz
eclipse.platform.text-06351f1532bb6a959864bebf15af83be87a0e796.zip
bug fixing
-rw-r--r--org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionViewer.java53
1 files changed, 45 insertions, 8 deletions
diff --git a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionViewer.java b/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionViewer.java
index d4a142d39..be9bd5e51 100644
--- a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionViewer.java
+++ b/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionViewer.java
@@ -94,6 +94,8 @@ public class ProjectionViewer extends SourceViewer implements ITextViewerExtensi
private ProjectionSummary fProjectionSummary;
/** Indication that an annotation world change has not yet been processed. */
private boolean fPendingAnnotationWorldChange= false;
+ /** Indication whether projection changes in the visible document should be considered. */
+ private boolean fHandleProjectionChanges= true;
/**
* Creates a new projection source viewer.
@@ -188,7 +190,12 @@ public class ProjectionViewer extends SourceViewer implements ITextViewerExtensi
protected boolean updateSlaveDocument(IDocument slaveDocument, int modelRangeOffset, int modelRangeLength) throws BadLocationException {
if (slaveDocument instanceof ProjectionDocument) {
ProjectionDocument document= (ProjectionDocument) slaveDocument;
- document.replaceMasterDocumentRanges(modelRangeOffset, modelRangeLength);
+ try {
+ fHandleProjectionChanges= false;
+ document.replaceMasterDocumentRanges(modelRangeOffset, modelRangeLength);
+ } finally {
+ fHandleProjectionChanges= true;
+ }
return true;
}
return false;
@@ -221,6 +228,36 @@ public class ProjectionViewer extends SourceViewer implements ITextViewerExtensi
if (!isProjectionMode())
addProjectionAnnotationModel(getVisualAnnotationModel());
}
+
+ /**
+ * Remembers whether to listen to projection changes of the visible
+ * document.
+ *
+ * @see ProjectionDocument#addMasterDocumentRange(int, int)
+ */
+ private void addMasterDocumentRange(ProjectionDocument projection, int offset, int length) throws BadLocationException {
+ try {
+ fHandleProjectionChanges= false;
+ projection.addMasterDocumentRange(offset, length);
+ } finally {
+ fHandleProjectionChanges= true;
+ }
+ }
+
+ /**
+ * Remembers whether to listen to projection changes of the visible
+ * document.
+ *
+ * @see ProjectionDocument#removeMasterDocumentRange(int, int)
+ */
+ private void removeMasterDocumentRange(ProjectionDocument projection, int offset, int length) throws BadLocationException {
+ try {
+ fHandleProjectionChanges= false;
+ projection.removeMasterDocumentRange(offset, length);
+ } finally {
+ fHandleProjectionChanges= true;
+ }
+ }
/*
* @see org.eclipse.jface.text.TextViewer#setVisibleRegion(int, int)
@@ -297,13 +334,13 @@ public class ProjectionViewer extends SourceViewer implements ITextViewerExtensi
IDocument slave= createSlaveDocument(getDocument());
if (slave instanceof ProjectionDocument) {
projection= (ProjectionDocument) slave;
- projection.addMasterDocumentRange(0, master.getLength());
+ addMasterDocumentRange(projection, 0, master.getLength());
replaceVisibleDocument(projection);
}
}
if (projection != null) {
- projection.removeMasterDocumentRange(offset, length);
+ removeMasterDocumentRange(projection, offset, length);
if (fireRedraw) {
// repaint line above
IDocument document= getDocument();
@@ -339,13 +376,13 @@ public class ProjectionViewer extends SourceViewer implements ITextViewerExtensi
textWidget.setRedraw(false);
// expand
- projection.addMasterDocumentRange(expanded.getOffset(), expanded.getLength());
+ addMasterDocumentRange(projection, expanded.getOffset(), expanded.getLength());
// collapse contained regions
if (collapsed != null) {
for (int i= 0; i < collapsed.length; i++) {
IRegion p= computeCollapsedRegion(collapsed[i]);
- projection.removeMasterDocumentRange(p.getOffset(), p.getLength());
+ removeMasterDocumentRange(projection, p.getOffset(), p.getLength());
}
}
@@ -544,7 +581,7 @@ public class ProjectionViewer extends SourceViewer implements ITextViewerExtensi
IDocument slave= manager.createSlaveDocument(master);
if (slave instanceof ProjectionDocument) {
projection= (ProjectionDocument) slave;
- projection.addMasterDocumentRange(0, master.getLength());
+ addMasterDocumentRange(projection, 0, master.getLength());
}
}
}
@@ -557,7 +594,7 @@ public class ProjectionViewer extends SourceViewer implements ITextViewerExtensi
Position position= fProjectionAnnotationModel.getPosition(annotation);
IRegion region= computeCollapsedRegion(position);
if (region != null)
- projection.removeMasterDocumentRange(region.getOffset(), region.getLength());
+ removeMasterDocumentRange(projection, region.getOffset(), region.getLength());
}
}
@@ -613,7 +650,7 @@ public class ProjectionViewer extends SourceViewer implements ITextViewerExtensi
* @see org.eclipse.jface.text.TextViewer#handleVisibleDocumentAboutToBeChanged(org.eclipse.jface.text.DocumentEvent)
*/
protected void handleVisibleDocumentChanged(DocumentEvent event) {
- if (isProjectionMode() && event instanceof ProjectionDocumentEvent) {
+ if (fHandleProjectionChanges && event instanceof ProjectionDocumentEvent && isProjectionMode()) {
ProjectionDocumentEvent e= (ProjectionDocumentEvent) event;
if (ProjectionDocumentEvent.PROJECTION_CHANGE == e.getChangeType() && e.getLength() == 0 && e.getText().length() != 0)
fProjectionAnnotationModel.expandAll(e.getMasterOffset(), e.getMasterLength());

Back to the top