Java Code Examples for org.eclipse.jface.text.IDocument#removeDocumentListener()
The following examples show how to use
org.eclipse.jface.text.IDocument#removeDocumentListener() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseDocumentCommand.java From Pydev with Eclipse Public License 1.0 | 6 votes |
/** * Executes the document command on the specified document. * * @param document the document on which to execute the command. * @throws BadLocationException in case this commands cannot be executed */ public void execute(IDocument document) throws BadLocationException { if (fLength == 0 && fText == null) { return; } if (fOwner != null) { document.removeDocumentListener(fOwner); } document.replace(fOffset, fLength, fText); if (fOwner != null) { document.addDocumentListener(fOwner); } }
Example 2
Source File: ConsoleCmdHandler.java From e4macs with Eclipse Public License 1.0 | 6 votes |
/** * @see com.mulgasoft.emacsplus.commands.IConsoleDispatch#consoleDispatch(org.eclipse.ui.console.TextConsoleViewer, IConsoleView, ExecutionEvent) */ public Object consoleDispatch(TextConsoleViewer viewer, IConsoleView activePart, ExecutionEvent event) { IDocument doc = viewer.getDocument(); int action = -1; try { StyledText st = viewer.getTextWidget(); action = getDispatchId(getId(event, viewer)); if (action > -1) { // set up for kill ring doc.addDocumentListener(KillRing.getInstance()); // setUpUndo(viewer); st.invokeAction(action); } } finally { // remove kill ring behavior if (action > -1) { doc.removeDocumentListener(KillRing.getInstance()); } KillRing.getInstance().setKill(null, false); } return null; }
Example 3
Source File: DocumentManager.java From ContentAssist with MIT License | 6 votes |
/** * Unregisters a document manager with an editor. * @param doc the document to be managed * @param st the styled text of the editor * @param dm the document manager */ public static void unregister(IDocument doc, StyledText st, DocumentManager dm) { if (doc != null) { doc.removeDocumentListener(dm); IDocumentUndoManager undoManager = DocumentUndoManagerRegistry.getDocumentUndoManager(doc); DocumentUndoManagerRegistry.disconnect(doc); if (undoManager != null) { undoManager.removeDocumentUndoListener(dm); } } if (st != null) { st.removeListener(SWT.KeyDown, dm); st.removeListener(SWT.MouseDown, dm); st.removeListener(SWT.MouseDoubleClick, dm); } }
Example 4
Source File: JavaEditor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public void uninstall() { ISourceViewer sourceViewer= getSourceViewer(); if (sourceViewer != null) sourceViewer.removeTextInputListener(this); IDocumentProvider documentProvider= getDocumentProvider(); if (documentProvider != null) { IDocument document= documentProvider.getDocument(getEditorInput()); if (document != null) document.removeDocumentListener(this); } }
Example 5
Source File: IOConsoleViewer.java From goclipse with Eclipse Public License 1.0 | 5 votes |
@Override public void setDocument(IDocument document) { IDocument oldDocument= getDocument(); super.setDocument(document); if (oldDocument != null) { oldDocument.removeDocumentListener(getDocumentListener()); } if (document != null) { document.addDocumentListener(getDocumentListener()); } }
Example 6
Source File: ScriptConsoleDocumentListener.java From Pydev with Eclipse Public License 1.0 | 5 votes |
/** * Stops listening changes in one document and starts listening another one. * * @param oldDoc may be null (if not null, this class will stop listening changes in it). * @param newDoc the document that should be listened from now on. */ protected synchronized void reconnect(IDocument oldDoc, IDocument newDoc) { Assert.isTrue(disconnectionLevel == 0); if (oldDoc != null) { oldDoc.removeDocumentListener(this); } newDoc.addDocumentListener(this); this.doc = newDoc; }
Example 7
Source File: ConsoleCopyCutHandler.java From e4macs with Eclipse Public License 1.0 | 5 votes |
/** * @see com.mulgasoft.emacsplus.commands.ConsoleCmdHandler#consoleDispatch(TextConsoleViewer, IConsoleView, ExecutionEvent) */ @Override public Object consoleDispatch(TextConsoleViewer viewer, IConsoleView activePart, ExecutionEvent event) { Object result = null; IDocument doc = viewer.getDocument(); try { IWorkbenchPartSite site = activePart.getSite(); if (site != null) { IHandlerService service = (IHandlerService) site.getService(IHandlerService.class); if (doc != null && service != null) { doc.addDocumentListener(KillRing.getInstance()); String cmdId = getId(event, viewer); if (cmdId != null) { result = service.executeCommand(cmdId, null); } } } } catch (CommandException e) { // Shouldn't happen as the Command id will be null or valid e.printStackTrace(); } finally { if (doc != null) { doc.removeDocumentListener(KillRing.getInstance()); } // clear kill command flag KillRing.getInstance().setKill(null, false); } MarkUtils.clearConsoleMark(viewer); return result; }
Example 8
Source File: MarkUtils.java From e4macs with Eclipse Public License 1.0 | 5 votes |
private static void removeDocumentListeners(ITextEditor editor) { if (docListener != null) { IDocumentProvider idp = editor.getDocumentProvider(); IDocument document; // add null check for document, due to an unreproducible NPE reported by a clojure user if (idp != null && (document = idp.getDocument(editor.getEditorInput())) != null) { document.removeDocumentListener(docListener); } } docListener = null; }
Example 9
Source File: SemanticHighlightingPresenter.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Stop managing the given document. * * @param document The document */ private void releaseDocument(IDocument document) { if (document != null) { document.removeDocumentListener(this); document.removePositionUpdater(fPositionUpdater); try { document.removePositionCategory(getPositionCategory()); } catch (BadPositionCategoryException e) { // Should not happen JavaPlugin.log(e); } } }
Example 10
Source File: CommonOccurrencesUpdater.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
/** * uninstall */ public void uninstall() { ISourceViewer sourceViewer = getSourceViewer(); IDocument document = getDocument(); if (sourceViewer != null) { sourceViewer.removeTextInputListener(this); } if (document != null) { document.removeDocumentListener(this); } }
Example 11
Source File: CommonQuickOutlinePage.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
/** * @see org.eclipse.ui.part.Page#dispose() */ public void dispose() { if (this._documentListener != null) { IDocument document = getDocument(); if (document != null) { document.removeDocumentListener(this._documentListener); } this._documentListener = null; } if (this._delayedRefreshJob != null) { this._delayedRefreshJob.cancel(); this._delayedRefreshJob = null; } if (this._filterRefreshJob != null) { this._filterRefreshJob.cancel(); this._filterRefreshJob = null; } if (this._toolbarManager != null) { this._toolbarManager.dispose(); this._toolbarManager = null; } super.dispose(); }
Example 12
Source File: CompletionProposalPopup.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
/** * Unregister this completion proposal popup. * * @since 3.0 */ private void unregister() { if (fDocumentListener != null) { IDocument document = fContentAssistSubjectControlAdapter.getDocument(); if (document != null) { document.removeDocumentListener(fDocumentListener); } fDocumentListener = null; } fDocumentEvents.clear(); if (fKeyListener != null && Helper.okToUse(fContentAssistSubjectControlAdapter.getControl())) { fContentAssistSubjectControlAdapter.removeKeyListener(fKeyListener); fKeyListener = null; } if (fLastProposal != null) { if (fLastProposal instanceof ICompletionProposalExtension2 && fViewer != null) { ICompletionProposalExtension2 extension = (ICompletionProposalExtension2) fLastProposal; extension.unselected(fViewer); } fLastProposal = null; } fFilteredProposals = null; fComputedProposals = null; fContentAssistant.possibleCompletionsClosed(); }
Example 13
Source File: TypeScriptEditor.java From typescript.java with MIT License | 5 votes |
public void uninstall() { ISourceViewer sourceViewer = getSourceViewer(); if (sourceViewer != null) sourceViewer.removeTextInputListener(this); IDocumentProvider documentProvider = getDocumentProvider(); if (documentProvider != null) { IDocument document = documentProvider.getDocument(getEditorInput()); if (document != null) document.removeDocumentListener(this); } }
Example 14
Source File: XdsConsoleViewer.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
public void setDocument(IDocument document) { IDocument oldDocument= getDocument(); super.setDocument(document); if (oldDocument != null) { oldDocument.removeDocumentListener(getDocumentListener()); } if (document != null) { document.addDocumentListener(getDocumentListener()); } }
Example 15
Source File: SourceCodeTextEditor.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
@Override public void inputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) { if (oldInput != null) { oldInput.removeDocumentListener(documentListener); } if (newInput != null) { newInput.addDocumentListener(documentListener); } modificationStamp = ModificationStamp.OLDEST; }
Example 16
Source File: HighlightingPresenter.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
/** * Stop managing the given document. * * @param document * The document */ private void releaseDocument(IDocument document) { if (document != null) { document.removeDocumentListener(this); document.removePositionUpdater(fPositionUpdater); try { document.removePositionCategory(getPositionCategory()); } catch (BadPositionCategoryException e) { // Should not happen log.debug(e.getMessage(), e); } } }
Example 17
Source File: CommonOccurrencesUpdater.java From APICloud-Studio with GNU General Public License v3.0 | 4 votes |
public void inputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) { if (oldInput != null) { oldInput.removeDocumentListener(this); } }
Example 18
Source File: JavaEditor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public void inputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) { if (oldInput == null) return; oldInput.removeDocumentListener(this); }
Example 19
Source File: TypeScriptEditor.java From typescript.java with MIT License | 4 votes |
public void inputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) { if (oldInput == null) return; oldInput.removeDocumentListener(this); }
Example 20
Source File: EditorPool.java From saros with GNU General Public License v2.0 | 3 votes |
/** * Removes an {@link IEditorPart} from the pool and makes the editor editable again. * * <p>This Method also disconnects the editorPart from its data source (identified by associated * {@link IFile}) and removes registered listeners: * * <ul> * <li>{@link IElementStateListener} from {@link IDocumentProvider} * <li>{@link IDocumentListener} from {@link IDocument} * <li>{@link EditorListener} from {@link IEditorPart} * </ul> * * @param editorPart editorPart to be removed */ public void remove(final IEditorPart editorPart) { log.trace("removing editor part " + editorPart + " [" + editorPart.getTitle() + "]"); if (!isManaged(editorPart)) { log.error("editor part is not managed: " + editorPart); return; } final EditorPartInputReferences inputRefs = editorInputMap.remove(editorPart); final IEditorInput input = inputRefs.input; final IFile file = inputRefs.file; // Unregister and unhook setEditable(editorPart, true); editorListeners.remove(editorPart).unbind(); final IDocumentProvider documentProvider = EditorAPI.getDocumentProvider(input); dirtyStateListener.unregister(documentProvider, input); final IDocument document = documentProvider.getDocument(input); if (document == null) { log.warn("could not disconnect from document: " + file); } else { document.removeDocumentListener(documentListener); } editorManager.disconnect(file); final saros.filesystem.IFile wrappedFile = ResourceAdapterFactory.create(file); editorParts.get(wrappedFile).remove(editorPart); }