public ProjectionViewerInformation(ProjectionViewer viewer) { fDocument = viewer.getDocument(); fProjectionAnnotationModel = viewer.getProjectionAnnotationModel(); }
/** * Tests whether the visible document's master document * is identical to this viewer's document. * * @return <code>true</code> if the visible document's master is * identical to this viewer's document * @since 3.1 */ private boolean isVisibleMasterDocumentSameAsDocument() { IDocument visibleDocument= getVisibleDocument(); return (visibleDocument instanceof ProjectionDocument) && ((ProjectionDocument)visibleDocument).getMasterDocument() == getDocument(); }
/** * Tests whether the visible document's master document * is identical to this viewer's document. * * @return <code>true</code> if the visible document's master is * identical to this viewer's document * @since 3.1 */ private boolean isVisibleMasterDocumentSameAsDocument() { IDocument visibleDocument= getVisibleDocument(); return (visibleDocument instanceof ProjectionDocument) && ((ProjectionDocument)visibleDocument).getMasterDocument() == getDocument(); }
private boolean isSegmented() { IDocument document= getDocument(); int length= document == null ? 0 : document.getLength(); IRegion visible= getModelCoverage(); boolean isSegmented= visible != null && !visible.equals(new Region(0, length)); return isSegmented; }
private boolean isSegmented() { IDocument document= getDocument(); int length= document == null ? 0 : document.getLength(); IRegion visible= getModelCoverage(); boolean isSegmented= visible != null && !visible.equals(new Region(0, length)); return isSegmented; }
@Override protected FindReplaceDocumentAdapter getFindReplaceDocumentAdapter() { if (fFindReplaceDocumentAdapter == null) { IDocument document= isProjectionMode() ? getDocument() : getVisibleDocument(); fFindReplaceDocumentAdapter= new FindReplaceDocumentAdapter(document); } return fFindReplaceDocumentAdapter; }
private void expandAll() { int offset= 0; IDocument doc= getDocument(); int length= doc == null ? 0 : doc.getLength(); if (isProjectionMode()) { fProjectionAnnotationModel.expandAll(offset, length); } }
private void collapseAll() { int offset= 0; IDocument doc= getDocument(); int length= doc == null ? 0 : doc.getLength(); if (isProjectionMode()) { fProjectionAnnotationModel.collapseAll(offset, length); } }
private void expandAll() { int offset= 0; IDocument doc= getDocument(); int length= doc == null ? 0 : doc.getLength(); if (isProjectionMode()) { fProjectionAnnotationModel.expandAll(offset, length); } }
private void collapseAll() { int offset= 0; IDocument doc= getDocument(); int length= doc == null ? 0 : doc.getLength(); if (isProjectionMode()) { fProjectionAnnotationModel.collapseAll(offset, length); } }
@Override protected FindReplaceDocumentAdapter getFindReplaceDocumentAdapter() { if (fFindReplaceDocumentAdapter == null) { IDocument document= isProjectionMode() ? getDocument() : getVisibleDocument(); fFindReplaceDocumentAdapter= new FindReplaceDocumentAdapter(document); } return fFindReplaceDocumentAdapter; }
@Override protected void copyMarkedRegion(boolean delete) { IRegion markedRegion= getMarkedRegion(); if (markedRegion != null) copyToClipboard(new TextSelection(getDocument(), markedRegion.getOffset(), markedRegion.getLength()), delete, getTextWidget()); }
@Override protected void copyMarkedRegion(boolean delete) { IRegion markedRegion= getMarkedRegion(); if (markedRegion != null) copyToClipboard(new TextSelection(getDocument(), markedRegion.getOffset(), markedRegion.getLength()), delete, getTextWidget()); }
/** * Computes the region that must be collapsed when the given position is the * position of an expanded projection annotation. * * @param position the position * @return the range that must be collapsed */ public IRegion computeCollapsedRegion(Position position) { try { IDocument document= getDocument(); if (document == null) return null; int line= document.getLineOfOffset(position.getOffset()); int offset= document.getLineOffset(line + 1); int length= position.getLength() - (offset - position.getOffset()); if (length > 0) return new Region(offset, length); } catch (BadLocationException x) { } return null; }
/** * Computes the collapsed region anchor for the given position. Assuming * that the position is the position of an expanded projection annotation, * the anchor is the region that is still visible after the projection * annotation has been collapsed. * * @param position the position * @return the collapsed region anchor */ public Position computeCollapsedRegionAnchor(Position position) { try { IDocument document= getDocument(); if (document == null) return null; int captionOffset= position.getOffset(); if (position instanceof IProjectionPosition) captionOffset+= ((IProjectionPosition) position).computeCaptionOffset(document); IRegion lineInfo= document.getLineInformationOfOffset(captionOffset); return new Position(lineInfo.getOffset() + lineInfo.getLength(), 0); } catch (BadLocationException x) { } return null; }
/** * Computes the region that must be collapsed when the given position is the * position of an expanded projection annotation. * * @param position the position * @return the range that must be collapsed */ public IRegion computeCollapsedRegion(Position position) { try { IDocument document= getDocument(); if (document == null) return null; int line= document.getLineOfOffset(position.getOffset()); int offset= document.getLineOffset(line + 1); int length= position.getLength() - (offset - position.getOffset()); if (length > 0) return new Region(offset, length); } catch (BadLocationException x) { } return null; }
/** * Computes the collapsed region anchor for the given position. Assuming * that the position is the position of an expanded projection annotation, * the anchor is the region that is still visible after the projection * annotation has been collapsed. * * @param position the position * @return the collapsed region anchor */ public Position computeCollapsedRegionAnchor(Position position) { try { IDocument document= getDocument(); if (document == null) return null; int captionOffset= position.getOffset(); if (position instanceof IProjectionPosition) captionOffset+= ((IProjectionPosition) position).computeCaptionOffset(document); IRegion lineInfo= document.getLineInformationOfOffset(captionOffset); return new Position(lineInfo.getOffset() + lineInfo.getLength(), 0); } catch (BadLocationException x) { } return null; }
/** * Initialize this provider with the correct document. Assumes projection * is enabled. (otherwise, only install would have been called) */ public void initialize() { if (!isInstalled()) { return; } // clear out old info projectionDisabled(); fDocument = fViewer.getDocument(); // set projection viewer on new document's adapter factory if (fViewer.getProjectionAnnotationModel() != null) { ProjectionModelNodeAdapterFactoryXML factory = getAdapterFactory(true); if (factory != null) { factory.addProjectionViewer(fViewer); } addAllAdapters(); } fProjectionNeedsToBeEnabled = false; }
/** * Computes the regions that must be collapsed when the given position is * the position of an expanded projection annotation. * * @param position the position * @return the ranges that must be collapsed, or <code>null</code> if * there are none * @since 3.1 */ IRegion[] computeCollapsedRegions(Position position) { try { IDocument document= getDocument(); if (document == null) return null; if (position instanceof IProjectionPosition) { IProjectionPosition projPosition= (IProjectionPosition) position; return projPosition.computeProjectionRegions(document); } int line= document.getLineOfOffset(position.getOffset()); int offset= document.getLineOffset(line + 1); int length= position.getLength() - (offset - position.getOffset()); if (length > 0) return new IRegion[] {new Region(offset, length)}; return null; } catch (BadLocationException x) { return null; } }
@Override protected void handleVerifyEvent(VerifyEvent e) { if (getTextWidget().getBlockSelection()) { ITextSelection selection= (ITextSelection) getSelection(); if (exposeModelRange(new Region(selection.getOffset(), selection.getLength()))) setSelection(selection); super.handleVerifyEvent(e); return; } Point selection= getSelectedRange(); IRegion modelRange= event2ModelRange(e); if (exposeModelRange(modelRange)) { e.doit= false; try { if (selection.y == 0 && e.text.length() <= 1 && modelRange.getLength() == 1) { selection.y= 1; if (selection.x - 1 == modelRange.getOffset()) selection.x--; } getDocument().replace(selection.x, selection.y, e.text); setSelectedRange(selection.x + e.text.length(), 0); } catch (BadLocationException e1) { // ignore as nothing bad happens (no log at this level) } } else super.handleVerifyEvent(e); }