Search in sources :

Example 6 with IDocumentListener

use of org.eclipse.jface.text.IDocumentListener in project mylyn.docs by eclipse.

the class MarkupEditor method updateDocument.

private void updateDocument() {
    if (getSourceViewer() != null) {
        IDocument previousDocument = document;
        document = getSourceViewer().getDocument();
        if (previousDocument == document) {
            return;
        }
        if (previousDocument != null && documentListener != null) {
            previousDocument.removeDocumentListener(documentListener);
        }
        if (previousDocument != null && documentPartitioningListener != null) {
            previousDocument.removeDocumentPartitioningListener(documentPartitioningListener);
        }
        if (document != null) {
            if (documentListener == null) {
                documentListener = new IDocumentListener() {

                    public void documentAboutToBeChanged(DocumentEvent event) {
                    }

                    public void documentChanged(DocumentEvent event) {
                        previewDirty = true;
                        outlineDirty = true;
                        synchronized (MarkupEditor.this) {
                            ++documentGeneration;
                        }
                        scheduleOutlineUpdate();
                        if (isShowingPreview()) {
                            updatePreview();
                        }
                    }
                };
            }
            document.addDocumentListener(documentListener);
            if (documentPartitioningListener == null) {
                documentPartitioningListener = new IDocumentPartitioningListener() {

                    public void documentPartitioningChanged(IDocument document) {
                        // async update
                        scheduleOutlineUpdate();
                    }
                };
            }
            document.addDocumentPartitioningListener(documentPartitioningListener);
        }
        previewDirty = true;
        outlineDirty = true;
        updateOutline();
    }
}
Also used : IDocumentListener(org.eclipse.jface.text.IDocumentListener) DocumentEvent(org.eclipse.jface.text.DocumentEvent) IDocumentPartitioningListener(org.eclipse.jface.text.IDocumentPartitioningListener) IDocument(org.eclipse.jface.text.IDocument)

Example 7 with IDocumentListener

use of org.eclipse.jface.text.IDocumentListener in project mylyn.docs by eclipse.

the class WikiTextSourceEditor method updateDocument.

private void updateDocument() {
    if (getSourceViewer() != null) {
        IDocument previousDocument = document;
        document = getSourceViewer().getDocument();
        if (previousDocument == document) {
            return;
        }
        if (previousDocument != null && documentListener != null) {
            previousDocument.removeDocumentListener(documentListener);
        }
        if (previousDocument != null && documentPartitioningListener != null) {
            previousDocument.removeDocumentPartitioningListener(documentPartitioningListener);
        }
        if (document != null) {
            if (documentListener == null) {
                documentListener = new IDocumentListener() {

                    public void documentAboutToBeChanged(DocumentEvent event) {
                    }

                    public void documentChanged(DocumentEvent event) {
                        outlineDirty = true;
                        synchronized (WikiTextSourceEditor.this) {
                            ++documentGeneration;
                        }
                        scheduleOutlineUpdate();
                    }
                };
            }
            document.addDocumentListener(documentListener);
            if (documentPartitioningListener == null) {
                documentPartitioningListener = new IDocumentPartitioningListener() {

                    public void documentPartitioningChanged(IDocument document) {
                        // async update
                        scheduleOutlineUpdate();
                    }
                };
            }
            document.addDocumentPartitioningListener(documentPartitioningListener);
        }
        synchronized (WikiTextSourceEditor.this) {
            outlineDirty = true;
        }
        updateOutline();
    }
}
Also used : IDocumentListener(org.eclipse.jface.text.IDocumentListener) DocumentEvent(org.eclipse.jface.text.DocumentEvent) IDocumentPartitioningListener(org.eclipse.jface.text.IDocumentPartitioningListener) IDocument(org.eclipse.jface.text.IDocument)

Example 8 with IDocumentListener

use of org.eclipse.jface.text.IDocumentListener in project egit by eclipse.

the class CommitMessageComponent method addListeners.

private void addListeners() {
    authorHandler = UIUtils.addPreviousValuesContentProposalToText(authorText, AUTHOR_VALUES_PREF);
    authorText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            if (!listenersEnabled || !authorText.isEnabled())
                return;
            listener.statusUpdated();
        }
    });
    committerText.addModifyListener(new ModifyListener() {

        String oldCommitter = committerText.getText();

        @Override
        public void modifyText(ModifyEvent e) {
            if (!listenersEnabled || !committerText.isEnabled())
                return;
            if (signedOff) {
                // the commit message is signed
                // the signature must be updated
                String newCommitter = committerText.getText();
                String oldSignOff = getSignedOff(oldCommitter);
                String newSignOff = getSignedOff(newCommitter);
                commitText.setText(replaceSignOff(commitText.getText(), oldSignOff, newSignOff));
                oldCommitter = newCommitter;
            }
            listener.statusUpdated();
        }
    });
    committerHandler = UIUtils.addPreviousValuesContentProposalToText(committerText, COMMITTER_VALUES_PREF);
    commitText.getDocument().addDocumentListener(new IDocumentListener() {

        @Override
        public void documentChanged(DocumentEvent event) {
            if (!listenersEnabled || !commitText.isEnabled())
                return;
            updateSignedOffButton();
            updateChangeIdButton();
            listener.statusUpdated();
        }

        @Override
        public void documentAboutToBeChanged(DocumentEvent event) {
        // nothing to do
        }
    });
}
Also used : ModifyEvent(org.eclipse.swt.events.ModifyEvent) ModifyListener(org.eclipse.swt.events.ModifyListener) IDocumentListener(org.eclipse.jface.text.IDocumentListener) DocumentEvent(org.eclipse.jface.text.DocumentEvent)

Example 9 with IDocumentListener

use of org.eclipse.jface.text.IDocumentListener in project titan.EclipsePlug-ins by eclipse.

the class DocumentSetupParticipant method setup.

@Override
public void setup(final IDocument document) {
    IDocumentPartitioner partitioner = new FastPartitioner(new PartitionScanner(), PartitionScanner.PARTITION_TYPES);
    if (document instanceof IDocumentExtension3) {
        IDocumentExtension3 extension3 = (IDocumentExtension3) document;
        extension3.setDocumentPartitioner(PartitionScanner.CONFIG_PARTITIONING, partitioner);
    } else {
        document.setDocumentPartitioner(partitioner);
    }
    partitioner.connect(document);
    document.addDocumentListener(new IDocumentListener() {

        @Override
        public void documentAboutToBeChanged(final DocumentEvent event) {
            GlobalIntervalHandler.putInterval(event.getDocument(), null);
        }

        @Override
        public void documentChanged(final DocumentEvent event) {
        // Do nothing
        }
    });
}
Also used : IDocumentExtension3(org.eclipse.jface.text.IDocumentExtension3) IDocumentPartitioner(org.eclipse.jface.text.IDocumentPartitioner) FastPartitioner(org.eclipse.jface.text.rules.FastPartitioner) IDocumentListener(org.eclipse.jface.text.IDocumentListener) DocumentEvent(org.eclipse.jface.text.DocumentEvent)

Example 10 with IDocumentListener

use of org.eclipse.jface.text.IDocumentListener in project titan.EclipsePlug-ins by eclipse.

the class DocumentSetupParticipant method setup.

/*
	 * (non-Javadoc)
	 *
	 * @see
	 * org.eclipse.core.filebuffers.IDocumentSetupParticipant#setup(org.
	 * eclipse.jface.text.IDocument)
	 */
@Override
public void setup(final IDocument document) {
    EditorTracker.remove(editor);
    EditorTracker.put((IFile) editor.getEditorInput().getAdapter(IFile.class), editor);
    DocumentTracker.put((IFile) editor.getEditorInput().getAdapter(IFile.class), document);
    IDocumentPartitioner partitioner = new FastPartitioner(new PartitionScanner(), PartitionScanner.PARTITION_TYPES);
    if (document instanceof IDocumentExtension3) {
        IDocumentExtension3 extension3 = (IDocumentExtension3) document;
        extension3.setDocumentPartitioner(PartitionScanner.ASN1_PARTITIONING, partitioner);
    } else {
        document.setDocumentPartitioner(partitioner);
    }
    partitioner.connect(document);
    document.addDocumentListener(new IDocumentListener() {

        @Override
        public void documentAboutToBeChanged(final DocumentEvent event) {
            GlobalIntervalHandler.putInterval(event.getDocument(), null);
        }

        @Override
        public void documentChanged(final DocumentEvent event) {
            IPreferencesService prefs = Platform.getPreferencesService();
            if (prefs.getBoolean(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.USEONTHEFLYPARSING, true, null)) {
                analyze(document, false);
            }
        }
    });
    analyze(document, true);
}
Also used : IDocumentExtension3(org.eclipse.jface.text.IDocumentExtension3) IDocumentPartitioner(org.eclipse.jface.text.IDocumentPartitioner) FastPartitioner(org.eclipse.jface.text.rules.FastPartitioner) IDocumentListener(org.eclipse.jface.text.IDocumentListener) DocumentEvent(org.eclipse.jface.text.DocumentEvent) IPreferencesService(org.eclipse.core.runtime.preferences.IPreferencesService)

Aggregations

IDocumentListener (org.eclipse.jface.text.IDocumentListener)28 DocumentEvent (org.eclipse.jface.text.DocumentEvent)27 IDocument (org.eclipse.jface.text.IDocument)11 ArrayList (java.util.ArrayList)6 Document (org.eclipse.jface.text.Document)5 IDocumentExtension3 (org.eclipse.jface.text.IDocumentExtension3)4 IDocumentPartitioner (org.eclipse.jface.text.IDocumentPartitioner)4 FastPartitioner (org.eclipse.jface.text.rules.FastPartitioner)4 Composite (org.eclipse.swt.widgets.Composite)4 List (java.util.List)3 SourceViewer (org.eclipse.jface.text.source.SourceViewer)3 PropertyChangeEvent (org.eclipse.jface.util.PropertyChangeEvent)3 StyledText (org.eclipse.swt.custom.StyledText)3 RGB (org.eclipse.swt.graphics.RGB)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 IFile (org.eclipse.core.resources.IFile)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 IStatus (org.eclipse.core.runtime.IStatus)2 BadLocationException (org.eclipse.jface.text.BadLocationException)2