/** Start listening to changes again. */ protected synchronized void stopDisconnected() { disconnectionLevel -= 1; if (disconnectionLevel == 0) { doc.addDocumentListener(this); } }
/* * @see * org.eclipse.jface.text.ITextInputListener#inputDocumentChanged(org * .eclipse.jface.text.IDocument, org.eclipse.jface.text.IDocument) */ @Override public void inputDocumentChanged(final IDocument oldInput, final IDocument newInput) { if (newInput == null) { return; } newInput.addDocumentListener(this); }
/** * Provide the initialization of the listeners additions. The Window, Part, and Document Listener * are added. Note that sensor shell should be instantiated before this method is called because * <code>processActivity()</code> method uses sensor shell instance. */ private void registerListeners() { IWorkbench workbench = EclipseSensorPlugin.getInstance().getWorkbench(); // :RESOLVED: JULY 1, 2003 // Supports the multiple window for sensor collection. IWorkbenchWindow[] activeWindows = workbench.getWorkbenchWindows(); // Check if window listener is not added yet. Otherwise multi instances are notified. if (this.windowListener == null) { this.windowListener = new WindowListenerAdapter(); workbench.addWindowListener(new WindowListenerAdapter()); } for (int i = 0; i < activeWindows.length; i++) { IWorkbenchPage activePage = activeWindows[i].getActivePage(); activePage.addPartListener(new PartListenerAdapter()); IEditorPart activeEditorPart = activePage.getActiveEditor(); // Adds this EclipseSensorPlugin instance to IDocumentListener // only when activeEditorPart is the instance of ITextEditor // so that null case is also ignored. if (activeEditorPart instanceof ITextEditor) { // Sets activeTextEditor. Otherwise a first activated file would not be recorded. this.activeTextEditor = (ITextEditor) activeEditorPart; // Gets opened file since the initial opened file is not notified from IPartListener. URI fileResource = EclipseSensor.this.getFileResource(this.activeTextEditor); Map<String, String> keyValueMap = new HashMap<String, String>(); keyValueMap.put(EclipseSensorConstants.SUBTYPE, "Open"); keyValueMap.put(EclipseSensorConstants.UNIT_TYPE, EclipseSensorConstants.FILE); keyValueMap.put( EclipseSensorConstants.UNIT_NAME, EclipseSensor.this.extractFileName(fileResource)); this.addDevEvent( EclipseSensorConstants.DEVEVENT_EDIT, fileResource, keyValueMap, "Opened " + fileResource.toString()); IDocumentProvider provider = this.activeTextEditor.getDocumentProvider(); IDocument document = provider.getDocument(activeEditorPart.getEditorInput()); // Initially sets active buffer and threshold buffer. // Otherwise a first activated buffer would not be recorded. this.activeBufferSize = document.getLength(); this.thresholdBufferSize = document.getLength(); document.addDocumentListener(new DocumentListenerAdapter()); } } // Handles breakpoint set/unset event. IBreakpointManager bpManager = DebugPlugin.getDefault().getBreakpointManager(); bpManager.addBreakpointListener(new BreakPointerSensor(this)); // Listens to debug event. DebugPlugin.getDefault().addDebugEventListener(new DebugSensor(this)); // Creates instance to handle build error. this.buildErrorSensor = new BuildErrorSensor(this); }
public RemoveCoverageMarkersListener(IDocument document, PyEdit edit, IFile file) { this.doc = document; this.edit = edit; this.file = file; document.addDocumentListener(this); edit.addPyeditListener(this); }
public void inputDocumentChanged(IDocument oldInput, IDocument newInput) { if (oldInput != null) { oldInput.removeDocumentListener(this); } if (newInput != null) { newInput.addDocumentListener(this); } inspect(); }
/** * 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; }
@Override public void connect(IDocument document) { super.connect(document); if (document instanceof DisassemblyDocument) { final IBreakpointManager bpMgr = DebugPlugin.getDefault().getBreakpointManager(); addBreakpoints(bpMgr.getBreakpoints()); bpMgr.addBreakpointListener(this); document.addDocumentListener(this); } }
public void install() { ISourceViewer sourceViewer = editor.getISourceViewer(); if (sourceViewer == null) return; StyledText text = sourceViewer.getTextWidget(); if (text == null || text.isDisposed()) return; sourceViewer.addTextInputListener(this); IDocument document = sourceViewer.getDocument(); if (document != null) document.addDocumentListener(this); }
@Override public void connect(IDocument document) { if (this.document != document) throw new RuntimeException(CANT_CONNECT_TO_DIFFERENT_DOCUMENT_); for (final ColorAnnotation ca : annotations) { try { document.addPosition(ca.getPosition()); } catch (BadLocationException ex) { } } if (openConnections++ == 0) { document.addDocumentListener(documentListener); } }
@Override public void setDocument(final IDocument document) { final IDocument oldDocument = getDocument(); if (oldDocument != null) { oldDocument.removeDocumentListener(getDocumentListener()); } super.setDocument(document); if (document != null) { document.addDocumentListener(getDocumentListener()); } }
@Override public void connect(IDocument document) { if (this.document != document) throw new RuntimeException("Can't connect to different document."); for (final ColorAnnotation ca : annotations) { try { document.addPosition(ca.getPosition()); } catch (BadLocationException ex) { } } if (openConnections++ == 0) { document.addDocumentListener(documentListener); } }
/** * Provides manipulation of browser open status due to implement <code>IWindowListener</code>. * This method must not be called by client because it is called by platform. Do nothing for * Eclipse sensor so far. * * @param window An IWorkbenchWindow instance to be triggered when a window is activated. */ public void windowActivated(IWorkbenchWindow window) { IEditorPart activeEditorPart = window.getActivePage().getActiveEditor(); if (activeEditorPart instanceof ITextEditor) { EclipseSensor.this.activeTextEditor = (ITextEditor) activeEditorPart; ITextEditor editor = EclipseSensor.this.activeTextEditor; IDocumentProvider provider = editor.getDocumentProvider(); IDocument document = provider.getDocument(editor.getEditorInput()); document.addDocumentListener(new DocumentListenerAdapter()); int activeBufferSize = provider.getDocument(editor.getEditorInput()).getLength(); // BuffTrans: Copy the new active file size to the threshold buffer size . EclipseSensor.this.thresholdBufferSize = activeBufferSize; EclipseSensor.this.activeBufferSize = activeBufferSize; } }
public void connect(IDocument document) { if (this.document != document) { throw new IllegalArgumentException("Can't connect to different document."); // $NON-NLS-1$ } for (final CoverageAnnotation ca : annotations) { try { document.addPosition(ca.getPosition()); } catch (BadLocationException ex) { EclEmmaUIPlugin.log(ex); } } if (openConnections++ == 0) { CoverageTools.addJavaCoverageListener(coverageListener); document.addDocumentListener(documentListener); } }
/** * Provides manipulation of browser part activation status due to implement <code>IPartListener * </code>. This method must not be called by client because it is called by platform. Do * nothing for Eclipse sensor so far. * * @param part An IWorkbenchPart instance to be triggered when a part is activated. */ public void partActivated(IWorkbenchPart part) { if (part instanceof ITextEditor) { // System.out.println("Sensor : " + part); EclipseSensor.this.isActivatedWindow = true; EclipseSensor.this.activeTextEditor = (ITextEditor) part; ITextEditor editor = EclipseSensor.this.activeTextEditor; IDocumentProvider provider = editor.getDocumentProvider(); IDocument document = provider.getDocument(editor.getEditorInput()); document.addDocumentListener(new DocumentListenerAdapter()); int activeBufferSize = provider.getDocument(editor.getEditorInput()).getLength(); // BuffTrans: Copy the new active file size to the threshold buffer size . EclipseSensor.this.thresholdBufferSize = activeBufferSize; EclipseSensor.this.activeBufferSize = activeBufferSize; } }
public void install() { final ISourceViewer sourceViewer = erlangEditor.getViewer(); if (sourceViewer == null) { return; } final StyledText text = sourceViewer.getTextWidget(); if (text == null || text.isDisposed()) { return; } sourceViewer.addTextInputListener(this); final IDocument document = sourceViewer.getDocument(); if (document != null) { document.addDocumentListener(this); } }
public void verifyText(VerifyEvent e) { IDocument document = getDocumentProvider().getDocument(getEditorInput()); final boolean[] documentChanged = new boolean[1]; IDocumentListener listener = new IDocumentListener() { public void documentAboutToBeChanged(DocumentEvent event) {} public void documentChanged(DocumentEvent event) { documentChanged[0] = true; } }; try { if (document != null) document.addDocumentListener(listener); if (!validateEditorInputState() || documentChanged[0]) e.doit = false; } finally { if (document != null) document.removeDocumentListener(listener); } }
protected void doSetInput(IEditorInput editorInput) throws CoreException { super.doSetInput(editorInput); initializeResourceObject(editorInput); IDocument document = getDocumentProvider().getDocument(getEditorInput()); document.addDocumentListener(new DocumentListener()); }
/* * (non-Javadoc) * @see org.eclipse.jface.text.ITextInputListener#inputDocumentChanged(org.eclipse.jface.text.IDocument, * org.eclipse.jface.text.IDocument) */ public void inputDocumentChanged(IDocument oldInput, IDocument newInput) { if (newInput == null) return; newInput.addDocumentListener(this); }
public void registerListener() { IDocument doc = console.getDocument(); doc.addDocumentListener(this); }