本文整理汇总了Java中com.intellij.openapi.editor.event.DocumentListener类的典型用法代码示例。如果您正苦于以下问题:Java DocumentListener类的具体用法?Java DocumentListener怎么用?Java DocumentListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DocumentListener类属于com.intellij.openapi.editor.event包,在下文中一共展示了DocumentListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setupAutoStartDocumentListener
import com.intellij.openapi.editor.event.DocumentListener; //导入依赖的package包/类
private void setupAutoStartDocumentListener(boolean enabled) {
final EditorEventMulticaster editorEventMulticaster = EditorFactory.getInstance().getEventMulticaster();
if (autoStartDocumentListener != null) {
editorEventMulticaster.removeDocumentListener(autoStartDocumentListener);
autoStartDocumentListener = null;
}
if (enabled) {
editorEventMulticaster.addDocumentListener(autoStartDocumentListener = new DocumentListener() {
@Override
public void documentChanged(DocumentEvent e) {
if (running) return;
//getSelectedTextEditor() must be run from event dispatch thread
EventQueue.invokeLater(() -> {
final Editor selectedTextEditor = FileEditorManager.getInstance(project).getSelectedTextEditor();
if (selectedTextEditor == null) return;
if(e.getDocument().equals(selectedTextEditor.getDocument())) {
setRunning(true);
}
});
}
});
}
}
示例2: getTableCellEditorComponent
import com.intellij.openapi.editor.event.DocumentListener; //导入依赖的package包/类
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
final EditorTextField editorTextField = new EditorTextField((String) value, myProject, StdFileTypes.JAVA) {
@Override
protected boolean shouldHaveBorder() {
return false;
}
};
myDocument = editorTextField.getDocument();
if (myDocument != null) {
for (DocumentListener listener : myListeners) {
editorTextField.addDocumentListener(listener);
}
}
return editorTextField;
}
示例3: getTableCellEditorComponent
import com.intellij.openapi.editor.event.DocumentListener; //导入依赖的package包/类
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
myCodeFragment = (PsiCodeFragment)value;
myDocument = PsiDocumentManager.getInstance(myProject).getDocument(myCodeFragment);
myEditorTextField = createEditorField(myDocument);
if (myEditorTextField != null) {
for (DocumentListener listener : myListeners) {
myEditorTextField.addDocumentListener(listener);
}
myEditorTextField.setDocument(myDocument);
myEditorTextField.setBorder(new LineBorder(table.getSelectionBackground()));
}
return myEditorTextField;
}
示例4: getTableCellEditorComponent
import com.intellij.openapi.editor.event.DocumentListener; //导入依赖的package包/类
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
myCodeFragment = (PsiCodeFragment)((Pair)value).getFirst();
myDocument = PsiDocumentManager.getInstance(myProject).getDocument(myCodeFragment);
JPanel panel = new JPanel();
myEditorTextField = createEditorField(myDocument);
if (myEditorTextField != null) {
for (DocumentListener listener : myListeners) {
myEditorTextField.addDocumentListener(listener);
}
myEditorTextField.setDocument(myDocument);
myEditorTextField.setBorder(new LineBorder(table.getSelectionBackground()));
}
panel.add(myEditorTextField);
panel.add(new JCheckBox());
return panel;
}
示例5: editorReleased
import com.intellij.openapi.editor.event.DocumentListener; //导入依赖的package包/类
@Override
public void editorReleased(@NotNull EditorFactoryEvent event) {
Editor editor = event.getEditor();
final Document doc = editor.getDocument();
if (editor.getProject() != null && editor.getProject() != project) {
return;
}
STGroupFileEditorListener listener = editor.getUserData(EDITOR_DOCUMENT_LISTENER_KEY);
if (listener != null) {
doc.removeDocumentListener(listener);
doc.putUserData(EDITOR_DOCUMENT_LISTENER_KEY, null);
}
DocumentListener listener2 = editor.getUserData(EDITOR_STRUCTVIEW_LISTENER_KEY);
if (listener2 != null) {
doc.removeDocumentListener(listener2);
doc.putUserData(EDITOR_STRUCTVIEW_LISTENER_KEY, null);
}
}
示例6: changedUpdate
import com.intellij.openapi.editor.event.DocumentListener; //导入依赖的package包/类
private void changedUpdate(@NotNull DocumentEvent event, long newModificationStamp) {
try {
getLineSet().changedUpdate(event);
setModificationStamp(newModificationStamp);
if (!ShutDownTracker.isShutdownHookRunning()) {
DocumentListener[] listeners = getCachedListeners();
for (DocumentListener listener : listeners) {
try {
listener.documentChanged(event);
}
catch (Throwable e) {
log(e);
}
}
}
}
finally {
myEventsHandling = false;
}
}
示例7: changedUpdate
import com.intellij.openapi.editor.event.DocumentListener; //导入依赖的package包/类
private void changedUpdate(DocumentEvent event, long newModificationStamp) {
try {
if (LOG.isDebugEnabled()) LOG.debug(event.toString());
myLineSet.changedUpdate(event);
setModificationStamp(newModificationStamp);
if (!ShutDownTracker.isShutdownHookRunning()) {
DocumentListener[] listeners = getCachedListeners();
for (DocumentListener listener : listeners) {
try {
listener.documentChanged(event);
}
catch (Throwable e) {
LOG.error(e);
}
}
}
}
finally {
myEventsHandling = false;
}
}
示例8: getTableCellEditorComponent
import com.intellij.openapi.editor.event.DocumentListener; //导入依赖的package包/类
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
final EditorTextField editorTextField = new EditorTextField((String) value, myProject, InternalStdFileTypes.JAVA) {
@Override
protected boolean shouldHaveBorder() {
return false;
}
};
myDocument = editorTextField.getDocument();
if (myDocument != null) {
for (DocumentListener listener : myListeners) {
editorTextField.addDocumentListener(listener);
}
}
return editorTextField;
}
示例9: execute
import com.intellij.openapi.editor.event.DocumentListener; //导入依赖的package包/类
@Override
public void execute(@NotNull final Editor editor, char cha, @NotNull DataContext dataContext) {
if (!listenedDocuments.contains(editor.getDocument()) && isThisCorrectProject()) {
DocumentListener docl = new TextInputListener();
editor.getDocument().addDocumentListener(docl);
listenedDocuments.add(editor.getDocument());
logger.info("Added document listener to ", editor.getDocument().toString());
UsagesCollector.doPersistProjectUsages(new ObjectFinder().findCurrentProject());
}
handler.execute(editor, cha, dataContext);
}
示例10: fireMoveText
import com.intellij.openapi.editor.event.DocumentListener; //导入依赖的package包/类
private void fireMoveText(int start, int end, int newBase) {
for (DocumentListener listener : getCachedListeners()) {
if (listener instanceof PrioritizedInternalDocumentListener) {
((PrioritizedInternalDocumentListener)listener).moveTextHappened(start, end, newBase);
}
}
}
示例11: doBeforeChangedUpdate
import com.intellij.openapi.editor.event.DocumentListener; //导入依赖的package包/类
private void doBeforeChangedUpdate(DocumentEvent event) {
Application app = ApplicationManager.getApplication();
if (app != null) {
FileDocumentManager manager = FileDocumentManager.getInstance();
VirtualFile file = manager.getFile(this);
if (file != null && !file.isValid()) {
LOG.error("File of this document has been deleted.");
}
}
assertInsideCommand();
getLineSet(); // initialize line set to track changed lines
if (!ShutDownTracker.isShutdownHookRunning()) {
DocumentListener[] listeners = getCachedListeners();
for (int i = listeners.length - 1; i >= 0; i--) {
try {
listeners[i].beforeDocumentChange(event);
}
catch (Throwable e) {
LOG.error(e);
}
}
}
myEventsHandling = true;
}
示例12: changedUpdate
import com.intellij.openapi.editor.event.DocumentListener; //导入依赖的package包/类
private void changedUpdate(@NotNull DocumentEvent event, long newModificationStamp, ImmutableText prevText) {
try {
if (LOG.isDebugEnabled()) LOG.debug(event.toString());
myLineSet = getLineSet().update(prevText, event.getOffset(), event.getOffset() + event.getOldLength(), event.getNewFragment(), event.isWholeTextReplaced());
myFrozen = null;
if (myTabTrackingRequestors > 0) {
updateMightContainTabs(event.getNewFragment());
}
setModificationStamp(newModificationStamp);
if (!ShutDownTracker.isShutdownHookRunning()) {
DocumentListener[] listeners = getCachedListeners();
for (DocumentListener listener : listeners) {
try {
listener.documentChanged(event);
}
catch (Throwable e) {
LOG.error(e);
}
}
}
}
finally {
myEventsHandling = false;
}
}
示例13: addDocumentListener
import com.intellij.openapi.editor.event.DocumentListener; //导入依赖的package包/类
@Override
public void addDocumentListener(@NotNull DocumentListener listener) {
myCachedDocumentListeners.set(null);
if (myDocumentListeners.contains(listener)) {
LOG.error("Already registered: " + listener);
}
boolean added = myDocumentListeners.add(listener);
LOG.assertTrue(added, listener);
}
示例14: DocumentListenerDisposable
import com.intellij.openapi.editor.event.DocumentListener; //导入依赖的package包/类
private DocumentListenerDisposable(@NotNull DocumentListener listener,
@NotNull Ref<DocumentListener[]> cachedDocumentListenersRef,
@NotNull List<DocumentListener> documentListeners) {
myListener = listener;
myCachedDocumentListenersRef = cachedDocumentListenersRef;
myDocumentListeners = documentListeners;
}
示例15: doRemoveDocumentListener
import com.intellij.openapi.editor.event.DocumentListener; //导入依赖的package包/类
private static void doRemoveDocumentListener(@NotNull DocumentListener listener,
@NotNull Ref<DocumentListener[]> cachedDocumentListenersRef,
@NotNull List<DocumentListener> documentListeners) {
cachedDocumentListenersRef.set(null);
boolean success = documentListeners.remove(listener);
if (!success) {
LOG.error("Can't remove document listener (" + listener + "). Registered listeners: " + documentListeners);
}
}