use of org.eclipse.jface.text.ITextViewerExtension in project webtools.sourceediting by eclipse.
the class StructuredTextEditor method dispose.
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.IWorkbenchPart#dispose()
*/
public void dispose() {
// $NON-NLS-1$ //$NON-NLS-2$
Logger.trace("Source Editor", "StructuredTextEditor::dispose entry");
if (org.eclipse.wst.sse.core.internal.util.Debug.perfTestAdapterClassLoading) {
// $NON-NLS-1$
System.out.println("Total calls to getAdapter: " + adapterRequests);
// $NON-NLS-1$
System.out.println("Total time in getAdapter: " + adapterTime);
// $NON-NLS-1$
System.out.println("Average time per call: " + (adapterTime / adapterRequests));
}
ISourceViewer viewer = getSourceViewer();
if (viewer instanceof ITextViewerExtension)
((ITextViewerExtension) viewer).removeVerifyKeyListener(fPairInserter);
// dispose of information presenter
if (fInformationPresenter != null) {
fInformationPresenter.dispose();
fInformationPresenter = null;
}
if (fOutlineHandler != null) {
fOutlineHandler.dispose();
fOutlineHandler = null;
}
// dispose of selection history
if (fSelectionHistory != null) {
fSelectionHistory.dispose();
fSelectionHistory = null;
}
if (fProjectionSupport != null) {
fProjectionSupport.dispose();
fProjectionSupport = null;
}
if (fFoldingGroup != null) {
fFoldingGroup.dispose();
fFoldingGroup = null;
}
// dispose of menus that were being tracked
if (fTextContextMenu != null) {
fTextContextMenu.dispose();
fTextContextMenu = null;
}
if (fRulerContextMenu != null) {
fRulerContextMenu.dispose();
fRulerContextMenu = null;
}
if (fTextContextMenuManager != null) {
fTextContextMenuManager.removeMenuListener(getContextMenuListener());
fTextContextMenuManager.removeAll();
fTextContextMenuManager.dispose();
}
if (fRulerContextMenuManager != null) {
fRulerContextMenuManager.removeMenuListener(getContextMenuListener());
fRulerContextMenuManager.removeAll();
fRulerContextMenuManager.dispose();
}
// less severe.
if (fStructuredModel != null) {
fStructuredModel.removeModelStateListener(getInternalModelStateListener());
// fStructuredModel.setStructuredDocument(null);
/* BUG398460 - Editor is still marked dirty when relaunching editor after closing without saving changes */
// fStructuredModel = null;
}
// to document, so nothing to remove
if (getDocumentProvider() != null) {
IDocument doc = getDocumentProvider().getDocument(getEditorInput());
if (doc != null) {
if (doc instanceof IExecutionDelegatable) {
((IExecutionDelegatable) doc).setExecutionDelegate(null);
}
}
}
// up after themselves
if (fOutlinePage != null) {
if (fOutlinePage instanceof ConfigurableContentOutlinePage && fOutlinePageListener != null) {
((ConfigurableContentOutlinePage) fOutlinePage).removeDoubleClickListener(fOutlinePageListener);
}
if (fOutlinePageListener != null) {
fOutlinePage.removeSelectionChangedListener(fOutlinePageListener);
fOutlinePageListener = null;
}
fOutlinePage = null;
}
fEditorDisposed = true;
disposeModelDependentFields();
if (fDropTarget != null)
fDropTarget.dispose();
if (fPartListener != null) {
getSite().getWorkbenchWindow().getPartService().removePartListener(fPartListener);
fPartListener = null;
}
uninstallSemanticHighlighting();
if (fPairInserter != null) {
fPairInserter.dispose();
fPairInserter = null;
}
setPreferenceStore(null);
/*
* Strictly speaking, but following null outs should not be needed,
* but in the event of a memory leak, they make the memory leak less
* severe
*/
fDropAdapter = null;
fDropTarget = null;
if (fStructuredSelectionProvider != null) {
fStructuredSelectionProvider.dispose();
fStructuredSelectionProvider = null;
}
if (fStatusLineLabelProvider != null) {
fStatusLineLabelProvider.dispose();
fStatusLineLabelProvider = null;
}
setStatusLineMessage(null);
super.dispose();
// $NON-NLS-1$ //$NON-NLS-2$
Logger.trace("Source Editor", "StructuredTextEditor::dispose exit");
}
use of org.eclipse.jface.text.ITextViewerExtension in project n4js by eclipse.
the class FQNImporter method applyWithImport.
/**
* Applies the proposal and imports the given qualifiedName with the given alias (may be null). Prevents flickering
* by temporarily disabling redraw on the text viewer widget.
*/
private void applyWithImport(QualifiedName qualifiedName, String alias, IDocument document, ConfigurableCompletionProposal proposal) throws BadLocationException {
// Import does not introduce ambiguities - add import and insert short name
int topPixel = -1;
// store the pixel coordinates to prevent the ui from flickering
StyledText widget = viewer.getTextWidget();
if (widget != null)
topPixel = widget.getTopPixel();
ITextViewerExtension viewerExtension = null;
if (viewer instanceof ITextViewerExtension) {
viewerExtension = (ITextViewerExtension) viewer;
viewerExtension.setRedraw(false);
}
DocumentRewriteSession rewriteSession = null;
try {
if (document instanceof IDocumentExtension4) {
rewriteSession = ((IDocumentExtension4) document).startRewriteSession(DocumentRewriteSessionType.UNRESTRICTED_SMALL);
}
int initialCursorLine = document.getLineOfOffset(proposal.getReplacementOffset());
// apply short proposal and obtain the new cursor position
int newCursorPositionInDocument = doApply(qualifiedName, alias, document, proposal);
// set the pixel coordinates of the viewer widget, e.g. move it up one line if necessary
int newCursorLine = document.getLineOfOffset(newCursorPositionInDocument);
if (widget != null) {
int additionalTopPixel = (newCursorLine - initialCursorLine) * widget.getLineHeight();
widget.setTopPixel(topPixel + additionalTopPixel);
}
} finally {
if (rewriteSession != null) {
((IDocumentExtension4) document).stopRewriteSession(rewriteSession);
}
if (viewerExtension != null)
viewerExtension.setRedraw(true);
}
}
use of org.eclipse.jface.text.ITextViewerExtension in project xtext-eclipse by eclipse.
the class TextViewerMoveLinesAction method beginCompoundEdit.
/**
* Ends the compound change.
*/
private void beginCompoundEdit() {
ITextViewer viewer = getTextViewer();
if (fEditInProgress || viewer == null || !(viewer instanceof ITextViewerExtension))
return;
fEditInProgress = true;
fStrategy.arm(viewer);
IRewriteTarget target = ((ITextViewerExtension) viewer).getRewriteTarget();
if (target != null) {
target.beginCompoundChange();
}
}
use of org.eclipse.jface.text.ITextViewerExtension in project xtext-eclipse by eclipse.
the class TextViewerMoveLinesAction method endCompoundEdit.
/**
* Ends the compound change.
*/
private void endCompoundEdit() {
ITextViewer viewer = getTextViewer();
if (!fEditInProgress || viewer == null || !(viewer instanceof ITextViewerExtension))
return;
IRewriteTarget target = ((ITextViewerExtension) viewer).getRewriteTarget();
if (target != null) {
target.endCompoundChange();
}
fEditInProgress = false;
}
use of org.eclipse.jface.text.ITextViewerExtension in project xtext-eclipse by eclipse.
the class MarkRegionTargetWithoutStatusline method setMarkAtCursor.
@Override
public void setMarkAtCursor(boolean set) {
if (!(fViewer instanceof ITextViewerExtension))
return;
ITextViewerExtension viewerExtension = ((ITextViewerExtension) fViewer);
if (set) {
Point selection = fViewer.getSelectedRange();
viewerExtension.setMark(selection.x);
} else {
viewerExtension.setMark(-1);
}
}
Aggregations