/** * Does the actual toggling of projection. */ private void toggleFolding() { ISourceViewer sourceViewer= getSourceViewer(); if (sourceViewer instanceof ProjectionViewer) { ProjectionViewer pv= (ProjectionViewer) sourceViewer; if (pv.isProjectionMode() != isFoldingEnabled()) { if (pv.canDoOperation(ProjectionViewer.TOGGLE)) pv.doOperation(ProjectionViewer.TOGGLE); } } }
/** * Registers the listener with the viewer. * * @param viewer the viewer to register a listener with */ public ProjectionListener(ProjectionViewer viewer) { Assert.isLegal(viewer != null); fViewer= viewer; fViewer.addProjectionListener(this); }
/** * Disposes of this listener and removes the projection listener from the viewer. */ public void dispose() { if (fViewer != null) { fViewer.removeProjectionListener(this); fViewer= null; } }
/** * Enables the projection mode. */ public final void enableProjection() { if (!isProjectionMode()) { addProjectionAnnotationModel(getVisualAnnotationModel()); fFindReplaceDocumentAdapter= null; fireProjectionEnabled(); } }
public ProjectionViewerInformation(ProjectionViewer viewer) { fDocument = viewer.getDocument(); fProjectionAnnotationModel = viewer.getProjectionAnnotationModel(); }
/** * Disables the projection mode. */ public final void disableProjection() { if (isProjectionMode()) { removeProjectionAnnotationModel(getVisualAnnotationModel()); fProjectionAnnotationModel.removeAllAnnotations(); fFindReplaceDocumentAdapter= null; fireProjectionDisabled(); } }
switch (operation) { case TOGGLE: if (canDoOperation(TOGGLE)) { if (!isProjectionMode()) { enableProjection(); } else { expandAll(); disableProjection(); if (!isProjectionMode()) { super.doOperation(operation); return; StyledText textWidget= getTextWidget(); if (textWidget == null) return; if (redraws()) { selection= (ITextSelection) getSelection(); if (exposeModelRange(new Region(selection.getOffset(), selection.getLength()))) setSelection(selection); copyMarkedRegion(true); else copyToClipboard(selection, true, textWidget); fireSelectionChanged(range.x, range.y); if (redraws()) {
@Override protected void performRevert() { ProjectionViewer projectionViewer= (ProjectionViewer) getSourceViewer(); projectionViewer.setRedraw(false); try { boolean projectionMode= projectionViewer.isProjectionMode(); if (projectionMode) { projectionViewer.disableProjection(); if (fProjectionModelUpdater != null) fProjectionModelUpdater.uninstall(); } super.performRevert(); if (projectionMode) { if (fProjectionModelUpdater != null) fProjectionModelUpdater.install(this, projectionViewer); projectionViewer.enableProjection(); } } finally { projectionViewer.setRedraw(true); } }
@Override public void doOperation(int operation) { if (operation == QUICK_OUTLINE && outlinePresenter != null) { outlinePresenter.showInformation(); return; } super.doOperation(operation); }
if (event == null || !isVisibleMasterDocumentSameAsDocument()) { reinitializeProjection(); reinitializeProjection(); } else fPendingAnnotationWorldChange= true; if (event.isValid()) { fPendingAnnotationWorldChange= false; reinitializeProjection(); boolean isRedrawing= redraws(); int topIndex= isRedrawing ? getTopIndex() : -1; processDeletions(event, removedAnnotations, true); List<Position> coverage= new ArrayList<>(); processChanges(addedAnnotations, true, coverage); processChanges(changedAnnotation, true, coverage); setRedraw(false); try { executeProjectionCommands(commandQueue, false); } catch (IllegalArgumentException x) { reinitializeProjection(); } finally { setRedraw(true, topIndex); executeProjectionCommands(commandQueue, fireRedraw);
/** * Returns whether this viewer is in projection mode. * * @return <code>true</code> if this viewer is in projection mode, * <code>false</code> otherwise */ public final boolean isProjectionMode() { return getProjectionAnnotationModel() != null; }
private void syncProjectionModeWithPreferences() { ProjectionViewer viewer = (ProjectionViewer) getSourceViewer(); if (viewer.isProjectionMode() != WikiTextUiPlugin.getDefault().getPreferences().isEditorFolding()) { viewer.doOperation(ProjectionViewer.TOGGLE); } }
@Override public void createPartControl(Composite parent) { super.createPartControl(parent); ProjectionViewer viewer = getProjectionViewer(); projectionSupport = new ProjectionSupport(viewer, getAnnotationAccess(), getSharedColors()); projectionSupport.install(); // turn projection mode on viewer.doOperation(ProjectionViewer.TOGGLE); annotationModel = viewer.getProjectionAnnotationModel(); getPreferenceStore().addPropertyChangeListener(preferenceChangeListener); }
@Override public boolean canDoOperation(int operation) { if (operation == SHOW_OUTLINE) return fOutlinePresenter != null; if (operation == OPEN_STRUCTURE) return fStructurePresenter != null; if (operation == SHOW_HIERARCHY) return fHierarchyPresenter != null; return super.canDoOperation(operation); }
@Override public void setVisibleRegion(int start, int length) { fWasProjectionEnabled= isProjectionMode(); disableProjection(); super.setVisibleRegion(start, length); }
@Override protected FindReplaceDocumentAdapter getFindReplaceDocumentAdapter() { if (fFindReplaceDocumentAdapter == null) { IDocument document= isProjectionMode() ? getDocument() : getVisibleDocument(); fFindReplaceDocumentAdapter= new FindReplaceDocumentAdapter(document); } return fFindReplaceDocumentAdapter; }
/** * Installs this projection support on its viewer. */ public void install() { fViewer.setProjectionSummary(createProjectionSummary()); fProjectionListener= new ProjectionListener(); fViewer.addProjectionListener(fProjectionListener); }
@Override public boolean exposeModelRange(IRegion modelRange) { if (isProjectionMode()) return fProjectionAnnotationModel.expandAll(modelRange.getOffset(), modelRange.getLength()); if (!overlapsWithVisibleRegion(modelRange.getOffset(), modelRange.getLength())) { resetVisibleRegion(); return true; } return false; }
private void collapseAll() { int offset= 0; IDocument doc= getDocument(); int length= doc == null ? 0 : doc.getLength(); if (isProjectionMode()) { fProjectionAnnotationModel.collapseAll(offset, length); } }
@Override public void configure(SourceViewerConfiguration configuration) { super.configure(configuration); if (configuration instanceof MarkupSourceViewerConfiguration) { outlinePresenter = ((MarkupSourceViewerConfiguration) configuration).getOutlineInformationPresenter(this); outlinePresenter.install(this); } } }