private void executeProjectionCommands(ProjectionCommandQueue commandQueue, boolean fireRedraw) throws BadLocationException { ProjectionCommand command; Iterator<ProjectionCommand> e= commandQueue.iterator(); while (e.hasNext()) { command= e.next(); switch (command.fType) { case ProjectionCommand.ADD: addMasterDocumentRange(command.fProjection, command.fOffset, command.fLength); break; case ProjectionCommand.REMOVE: removeMasterDocumentRange(command.fProjection, command.fOffset, command.fLength); break; case ProjectionCommand.INVALIDATE_PRESENTATION: if (fireRedraw) invalidateTextPresentation(command.fOffset, command.fLength); break; } } commandQueue.clear(); }
Annotation[] removedAnnotations= event.getRemovedAnnotations(); fCommandQueue= new ProjectionCommandQueue(); fCommandQueue= null; if (commandQueue.passedRedrawCostsThreshold()) { setRedraw(false); try { boolean fireRedraw= !commandQueue.passedInvalidationCostsThreshold(); executeProjectionCommands(commandQueue, fireRedraw); if (!fireRedraw)
Annotation[] removedAnnotations= event.getRemovedAnnotations(); fCommandQueue= new ProjectionCommandQueue(); fCommandQueue= null; if (commandQueue.passedRedrawCostsThreshold()) { setRedraw(false); try { boolean fireRedraw= !commandQueue.passedInvalidationCostsThreshold(); executeProjectionCommands(commandQueue, fireRedraw); if (!fireRedraw)
/** * Removes the given master range from the given projection document. While the * modification is processed, the viewer no longer handles projection * changes, as it is causing them. * * @param projection the projection document * @param offset the offset in the master document * @param length the length in the master document * @throws BadLocationException in case the specified range is invalid * * @see ProjectionDocument#removeMasterDocumentRange(int, int) */ private void removeMasterDocumentRange(ProjectionDocument projection, int offset, int length) throws BadLocationException { if (fCommandQueue != null) { fCommandQueue.add(new ProjectionCommand(projection, ProjectionCommand.REMOVE, offset, length)); } else { try { fHandleProjectionChanges= false; // https://bugs.eclipse.org/bugs/show_bug.cgi?id=108258 // make sure the document range is strictly line based int end= offset + length; offset= toLineStart(projection.getMasterDocument(), offset, false); length= toLineStart(projection.getMasterDocument(), end, true) - offset; projection.removeMasterDocumentRange(offset, length); } finally { fHandleProjectionChanges= true; } } }
/** * Removes the given master range from the given projection document. While the * modification is processed, the viewer no longer handles projection * changes, as it is causing them. * * @param projection the projection document * @param offset the offset in the master document * @param length the length in the master document * @throws BadLocationException in case the specified range is invalid * * @see ProjectionDocument#removeMasterDocumentRange(int, int) */ private void removeMasterDocumentRange(ProjectionDocument projection, int offset, int length) throws BadLocationException { if (fCommandQueue != null) { fCommandQueue.add(new ProjectionCommand(projection, ProjectionCommand.REMOVE, offset, length)); } else { try { fHandleProjectionChanges= false; // https://bugs.eclipse.org/bugs/show_bug.cgi?id=108258 // make sure the document range is strictly line based int end= offset + length; offset= toLineStart(projection.getMasterDocument(), offset, false); length= toLineStart(projection.getMasterDocument(), end, true) - offset; projection.removeMasterDocumentRange(offset, length); } finally { fHandleProjectionChanges= true; } } }
/** * Adds the given master range to the given projection document. While the * modification is processed, the viewer no longer handles projection * changes, as it is causing them. * * @param projection the projection document * @param offset the offset in the master document * @param length the length in the master document * @throws BadLocationException in case the specified range is invalid * * @see ProjectionDocument#addMasterDocumentRange(int, int) */ private void addMasterDocumentRange(ProjectionDocument projection, int offset, int length) throws BadLocationException { if (fCommandQueue != null) { fCommandQueue.add(new ProjectionCommand(projection, ProjectionCommand.ADD, offset, length)); } else { try { fHandleProjectionChanges= false; // https://bugs.eclipse.org/bugs/show_bug.cgi?id=108258 // make sure the document range is strictly line based int end= offset + length; offset= toLineStart(projection.getMasterDocument(), offset, false); length= toLineStart(projection.getMasterDocument(), end, true) - offset; projection.addMasterDocumentRange(offset, length); } finally { fHandleProjectionChanges= true; } } }
/** * Adds the given master range to the given projection document. While the * modification is processed, the viewer no longer handles projection * changes, as it is causing them. * * @param projection the projection document * @param offset the offset in the master document * @param length the length in the master document * @throws BadLocationException in case the specified range is invalid * * @see ProjectionDocument#addMasterDocumentRange(int, int) */ private void addMasterDocumentRange(ProjectionDocument projection, int offset, int length) throws BadLocationException { if (fCommandQueue != null) { fCommandQueue.add(new ProjectionCommand(projection, ProjectionCommand.ADD, offset, length)); } else { try { fHandleProjectionChanges= false; // https://bugs.eclipse.org/bugs/show_bug.cgi?id=108258 // make sure the document range is strictly line based int end= offset + length; offset= toLineStart(projection.getMasterDocument(), offset, false); length= toLineStart(projection.getMasterDocument(), end, true) - offset; projection.addMasterDocumentRange(offset, length); } finally { fHandleProjectionChanges= true; } } }
private void executeProjectionCommands(ProjectionCommandQueue commandQueue, boolean fireRedraw) throws BadLocationException { ProjectionCommand command; Iterator<ProjectionCommand> e= commandQueue.iterator(); while (e.hasNext()) { command= e.next(); switch (command.fType) { case ProjectionCommand.ADD: addMasterDocumentRange(command.fProjection, command.fOffset, command.fLength); break; case ProjectionCommand.REMOVE: removeMasterDocumentRange(command.fProjection, command.fOffset, command.fLength); break; case ProjectionCommand.INVALIDATE_PRESENTATION: if (fireRedraw) invalidateTextPresentation(command.fOffset, command.fLength); break; } } commandQueue.clear(); }
boolean passedInvalidationCostsThreshold() { if (fExpectedExecutionCosts == -1) computeExpectedExecutionCosts(); return fExpectedExecutionCosts > INVALIDATION_COSTS; }
boolean passedRedrawCostsThreshold() { if (fExpectedExecutionCosts == -1) computeExpectedExecutionCosts(); return fExpectedExecutionCosts > REDRAW_COSTS; }
boolean passedInvalidationCostsThreshold() { if (fExpectedExecutionCosts == -1) computeExpectedExecutionCosts(); return fExpectedExecutionCosts > INVALIDATION_COSTS; }
private void internalInvalidateTextPresentation(int offset, int length) { if (fCommandQueue != null) { fCommandQueue.add(new ProjectionCommand(offset, length)); } else { invalidateTextPresentation(offset, length); } }
boolean passedRedrawCostsThreshold() { if (fExpectedExecutionCosts == -1) computeExpectedExecutionCosts(); return fExpectedExecutionCosts > REDRAW_COSTS; }
private void internalInvalidateTextPresentation(int offset, int length) { if (fCommandQueue != null) { fCommandQueue.add(new ProjectionCommand(offset, length)); } else { invalidateTextPresentation(offset, length); } }