本文整理汇总了Java中com.intellij.openapi.editor.event.DocumentAdapter类的典型用法代码示例。如果您正苦于以下问题:Java DocumentAdapter类的具体用法?Java DocumentAdapter怎么用?Java DocumentAdapter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DocumentAdapter类属于com.intellij.openapi.editor.event包,在下文中一共展示了DocumentAdapter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: GCMStructureViewModel
import com.intellij.openapi.editor.event.DocumentAdapter; //导入依赖的package包/类
public GCMStructureViewModel(@NotNull PsiFile psiFile, @NotNull final GCMStructureViewRootElement root, Editor editor) {
super(psiFile, root);
withSorters(typeSorter, Sorter.ALPHA_SORTER);
editor.getDocument().addDocumentListener(new DocumentAdapter() {
@Override
public void documentChanged(DocumentEvent event) {
synchronized (needRefresh) {
needRefresh = true;
}
}
});
executor.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
GCMStructureViewModel.this.refreshView();
}
}, 15, 5, TimeUnit.SECONDS);
}
示例2: createEditor
import com.intellij.openapi.editor.event.DocumentAdapter; //导入依赖的package包/类
private Editor createEditor() {
PsiFile myFile = null;
EditorFactory editorFactory = EditorFactory.getInstance();
Document doc = myFile == null
? editorFactory.createDocument("")
: PsiDocumentManager.getInstance(mProject).getDocument(myFile);
Editor editor = editorFactory.createEditor(doc, mProject);
EditorSettings editorSettings = editor.getSettings();
editorSettings.setVirtualSpace(false);
editorSettings.setLineMarkerAreaShown(false);
editorSettings.setIndentGuidesShown(false);
editorSettings.setFoldingOutlineShown(true);
editorSettings.setAdditionalColumnsCount(3);
editorSettings.setAdditionalLinesCount(3);
editorSettings.setLineNumbersShown(true);
editorSettings.setCaretRowShown(true);
editor.getDocument().addDocumentListener(new DocumentAdapter() {
@Override
public void documentChanged(DocumentEvent e) {
}
});
((EditorEx) editor).setHighlighter(createHighlighter(FileTypes.PLAIN_TEXT));
return editor;
}
示例3: setupPathComponent
import com.intellij.openapi.editor.event.DocumentAdapter; //导入依赖的package包/类
private void setupPathComponent(final JPanel northPanel) {
northPanel.add(new TextFieldAction() {
@Override
public void linkSelected(LinkLabel aSource, Object aLinkData) {
toggleShowPathComponent(northPanel, this);
}
}, BorderLayout.EAST);
myPathEditor = new EditorTextField(JavaReferenceEditorUtil.createDocument("", myProject, false), myProject, StdFileTypes.JAVA);
myPathEditor.addDocumentListener(new DocumentAdapter() {
@Override
public void documentChanged(DocumentEvent e) {
myAlarm.cancelAllRequests();
myAlarm.addRequest(new Runnable() {
@Override
public void run() {
updateTreeFromPath();
}
}, 300);
}
});
myPathEditor.setBorder(BorderFactory.createEmptyBorder(0, 0, 2, 0));
northPanel.add(myPathEditor, BorderLayout.SOUTH);
}
示例4: testDocSynchronizerPrefersLineBoundaryChanges
import com.intellij.openapi.editor.event.DocumentAdapter; //导入依赖的package包/类
public void testDocSynchronizerPrefersLineBoundaryChanges() throws Exception {
String text = "import java.awt.List;\n" +
"[import java.util.ArrayList;\n]" +
"import java.util.HashMap;\n" +
"import java.util.Map;";
RangeMarker marker = createMarker(text);
synchronizer.startTransaction(getProject(), document, psiFile);
String newText = StringUtil.replaceSubstring(document.getText(), TextRange.create(marker), "");
synchronizer.replaceString(document, 0, document.getTextLength(), newText);
final List<DocumentEvent> events = new ArrayList<DocumentEvent>();
document.addDocumentListener(new DocumentAdapter() {
@Override
public void documentChanged(DocumentEvent e) {
events.add(e);
}
});
synchronizer.commitTransaction(document);
assertEquals(newText, document.getText());
DocumentEvent event = assertOneElement(events);
assertEquals("DocumentEventImpl[myOffset=22, myOldLength=28, myNewLength=0, myOldString='import java.util.ArrayList;\n', myNewString=''].", event.toString());
}
示例5: SearchSupport
import com.intellij.openapi.editor.event.DocumentAdapter; //导入依赖的package包/类
public SearchSupport(EditorTextField textField) {
myTextField = textField;
myTextField.getDocument().addDocumentListener(new DocumentAdapter() {
@Override
public void documentChanged(DocumentEvent event) {
onTextChanged();
}
});
//noinspection SSBasedInspection
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
myTextField.addKeyListener(new KeyAdapter() {
public void keyPressed(final KeyEvent e) {
processListSelection(e);
}
});
}
});
myList.setVisibleRowCount(10);
myListModel = new SortedListModel<T>(null);
myList.setModel(myListModel);
}
示例6: createEditorInPanel
import com.intellij.openapi.editor.event.DocumentAdapter; //导入依赖的package包/类
private Editor createEditorInPanel(String string) {
EditorFactory editorFactory = EditorFactory.getInstance();
Editor editor = editorFactory.createEditor(editorFactory.createDocument(string));
EditorSettings editorSettings = editor.getSettings();
editorSettings.setVirtualSpace(false);
editorSettings.setLineMarkerAreaShown(false);
editorSettings.setIndentGuidesShown(false);
editorSettings.setLineNumbersShown(false);
editorSettings.setFoldingOutlineShown(false);
editorSettings.setAdditionalColumnsCount(3);
editorSettings.setAdditionalLinesCount(3);
editor.getDocument().addDocumentListener(new DocumentAdapter() {
@Override
public void documentChanged(DocumentEvent e) {
onTextChanged();
}
});
((EditorEx) editor).setHighlighter(getEditorHighlighter());
addEditorToPanel(editor);
return editor;
}
示例7: LazyRangeMarkerFactory
import com.intellij.openapi.editor.event.DocumentAdapter; //导入依赖的package包/类
public LazyRangeMarkerFactory(@NotNull Project project, @NotNull final FileDocumentManager fileDocumentManager) {
super(project);
EditorFactory.getInstance().getEventMulticaster().addDocumentListener(new DocumentAdapter() {
@Override
public void beforeDocumentChange(DocumentEvent e) {
VirtualFile docFile = fileDocumentManager.getFile(e.getDocument());
if (docFile == null) return;
WeakList<LazyMarker> lazyMarkers = myMarkers.get(docFile);
if (lazyMarkers == null) return;
List<LazyMarker> markers = lazyMarkers.toStrongList();
List<LazyMarker> markersToRemove = new ArrayList<LazyMarker>();
for (final LazyMarker marker : markers) {
if (Comparing.equal(marker.getFile(), docFile)) {
marker.getOrCreateDelegate();
markersToRemove.add(marker);
}
}
lazyMarkers.removeAll(markersToRemove);
}
}, project);
}
示例8: testDocSynchronizerPrefersLineBoundaryChanges
import com.intellij.openapi.editor.event.DocumentAdapter; //导入依赖的package包/类
public void testDocSynchronizerPrefersLineBoundaryChanges() throws Exception {
RangeMarker marker = createMarker("import java.awt.List;\n" +
"[import java.util.ArrayList;\n]" +
"import java.util.HashMap;\n" +
"import java.util.Map;");
PsiToDocumentSynchronizer synchronizer = ((PsiDocumentManagerImpl)PsiDocumentManager.getInstance(getProject())).getSynchronizer();
Document document = marker.getDocument();
synchronizer.startTransaction(getProject(), document, null);
String newText = StringUtil.replaceSubstring(document.getText(), TextRange.create(marker), "");
synchronizer.replaceString(document, 0, document.getTextLength(), newText);
final List<DocumentEvent> events = new ArrayList<DocumentEvent>();
document.addDocumentListener(new DocumentAdapter() {
@Override
public void documentChanged(DocumentEvent e) {
events.add(e);
}
});
synchronizer.doCommitTransaction(document);
assertEquals(newText, document.getText());
DocumentEvent event = assertOneElement(events);
assertEquals("DocumentEventImpl[myOffset=22, myOldLength=28, myNewLength=0, myOldString='import java.util.ArrayList;\n', myNewString=''].", event.toString());
}
示例9: init
import com.intellij.openapi.editor.event.DocumentAdapter; //导入依赖的package包/类
private void init() {
this.field = new EditorTextField("", project, com.jetbrains.php.lang.PhpFileType.INSTANCE);
PhpCompletionUtil.installClassCompletion(this.field, null, getDisposable());
this.field.getDocument().addDocumentListener(new DocumentAdapter() {
@Override
public void documentChanged(DocumentEvent e) {
String text = field.getText();
if (StringUtil.isEmpty(text) || StringUtil.endsWith(text, "\\")) {
return;
}
addUpdateRequest(250, () -> consumer.consume(field.getText()));
}
});
GridBagConstraints gbConstraints = new GridBagConstraints();
gbConstraints.fill = 1;
gbConstraints.weightx = 1.0D;
gbConstraints.gridx = 1;
gbConstraints.gridy = 1;
panel.add(field, gbConstraints);
}
示例10: createManualInputPreviewEditor
import com.intellij.openapi.editor.event.DocumentAdapter; //导入依赖的package包/类
public void createManualInputPreviewEditor(final PreviewState previewState) {
final EditorFactory factory = EditorFactory.getInstance();
Document doc = factory.createDocument(previewState.manualInputText);
doc.addDocumentListener(
new DocumentAdapter() {
@Override
public void documentChanged(DocumentEvent e) {
previewState.manualInputText = e.getDocument().getCharsSequence();
}
}
);
Editor editor = createPreviewEditor(previewState.grammarFile, doc);
setEditorComponent(editor.getComponent()); // do before setting state
previewState.setInputEditor(editor);
}
示例11: testDocSynchronizerPrefersLineBoundaryChanges
import com.intellij.openapi.editor.event.DocumentAdapter; //导入依赖的package包/类
public void testDocSynchronizerPrefersLineBoundaryChanges() throws Exception {
String text = "import java.awt.List;\n" +
"[import java.util.ArrayList;\n]" +
"import java.util.HashMap;\n" +
"import java.util.Map;";
RangeMarker marker = createMarker(text);
synchronizer.startTransaction(getProject(), document, psiFile);
String newText = StringUtil.replaceSubstring(document.getText(), TextRange.create(marker), "");
synchronizer.replaceString(document, 0, document.getTextLength(), newText);
final List<DocumentEvent> events = new ArrayList<DocumentEvent>();
document.addDocumentListener(new DocumentAdapter() {
@Override
public void documentChanged(DocumentEvent e) {
events.add(e);
}
});
synchronizer.commitTransaction(document);
assertEquals(newText, document.getText());
DocumentEvent event = assertOneElement(events);
assertEquals("DocumentEventImpl[myOffset=22, myOldLength=28, myNewLength=0, myOldString='import java.util.ArrayList;\n', myNewString=''].", event.toString());
}
示例12: EncodingManagerImpl
import com.intellij.openapi.editor.event.DocumentAdapter; //导入依赖的package包/类
public EncodingManagerImpl(@Nonnull EditorFactory editorFactory) {
editorFactory.getEventMulticaster().addDocumentListener(new DocumentAdapter() {
@Override
public void documentChanged(DocumentEvent e) {
Document document = e.getDocument();
if (isEditorOpenedFor(document)) {
queueUpdateEncodingFromContent(document);
}
}
}, this);
editorFactory.addEditorFactoryListener(new EditorFactoryAdapter() {
@Override
public void editorCreated(@Nonnull EditorFactoryEvent event) {
queueUpdateEncodingFromContent(event.getEditor().getDocument());
}
}, this);
}
示例13: createUIComponents
import com.intellij.openapi.editor.event.DocumentAdapter; //导入依赖的package包/类
private void createUIComponents() {
List<Language> languages = getBaseLanguagesWithProviders();
Language selected = myInitiallySelectedLanguage;
if (selected == null) {
selected = languages.get(0);
}
String text = getLanguageBlackList(selected);
myEditorTextField = createEditor(text, myNewPreselectedItem);
myEditorTextField.addDocumentListener(new DocumentAdapter() {
@Override
public void documentChanged(DocumentEvent e) {
updateOkEnabled();
}
});
myDoNotShowIfParameterNameContainedInMethodName = new JBCheckBox();
myShowWhenMultipleParamsWithSameType = new JBCheckBox();
ParameterNameHintsSettings settings = ParameterNameHintsSettings.getInstance();
myDoNotShowIfParameterNameContainedInMethodName.setSelected(settings.isDoNotShowIfMethodNameContainsParameterName());
myShowWhenMultipleParamsWithSameType.setSelected(settings.isShowForParamsWithSameType());
initLanguageCombo(languages, selected);
}
示例14: ActionTracker
import com.intellij.openapi.editor.event.DocumentAdapter; //导入依赖的package包/类
ActionTracker(Editor editor, Disposable parentDisposable) {
myEditor = editor;
myProject = editor.getProject();
ActionManager.getInstance().addAnActionListener(new AnActionListener.Adapter() {
@Override
public void beforeActionPerformed(AnAction action, DataContext dataContext, AnActionEvent event) {
myActionsHappened = true;
}
}, parentDisposable);
myEditor.getDocument().addDocumentListener(new DocumentAdapter() {
@Override
public void documentChanged(DocumentEvent e) {
if (!myIgnoreDocumentChanges) {
myActionsHappened = true;
}
}
}, parentDisposable);
}
示例15: createDocumentListener
import com.intellij.openapi.editor.event.DocumentAdapter; //导入依赖的package包/类
@NotNull
private static DocumentAdapter createDocumentListener(final ItemInfo itemInfo, final JBDebuggerFormTable table) {
return new DocumentAdapter() {
@Override
public void documentChanged(DocumentEvent documentEvent) {
if (table.getRowCount() == table.getEditingRow() + 1) {
itemInfo.enabled = true;
itemInfo.checked = true;
table.getListTableModel().addRow(new ItemInfo());
}
}
};
}