当前位置: 首页>>代码示例>>Java>>正文


Java DocumentListener类代码示例

本文整理汇总了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);
                    }
                });
            }
        });
    }
}
 
开发者ID:Darkyenus,项目名称:DarkyenusTimeTracker,代码行数:24,代码来源:TimeTrackerWidget.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:StringTableCellEditor.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:CodeFragmentTableCellEditorBase.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:PyParameterTableModel.java

示例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);
	}
}
 
开发者ID:antlr,项目名称:jetbrains-plugin-st4,代码行数:19,代码来源:STGroupPluginController.java

示例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;
  }
}
 
开发者ID:eddysystems,项目名称:eddy,代码行数:22,代码来源:LightDocument.java

示例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;
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:24,代码来源:DocumentImpl.java

示例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;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:17,代码来源:StringTableCellEditor.java

示例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);
}
 
开发者ID:testmycode,项目名称:tmc-intellij,代码行数:12,代码来源:ActivateSpywareAction.java

示例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);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:DocumentImpl.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:DocumentImpl.java

示例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;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:DocumentImpl.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:DocumentImpl.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:DocumentImpl.java

示例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);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:DocumentImpl.java


注:本文中的com.intellij.openapi.editor.event.DocumentListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。