use of com.intellij.openapi.editor.event.DocumentEvent in project intellij-community by JetBrains.
the class XmlSyncTagCommunityTest method testDoNotFireDocumentChangeEventIfTagWasNotChanged.
public void testDoNotFireDocumentChangeEventIfTagWasNotChanged() {
myFixture.configureByText(XmlFileType.INSTANCE, "<di<caret>></di>");
type("v");
Ref<Boolean> eventSent = Ref.create(false);
myFixture.getEditor().getDocument().addDocumentListener(new DocumentAdapter() {
@Override
public void documentChanged(DocumentEvent e) {
eventSent.set(true);
}
}, myFixture.getTestRootDisposable());
myFixture.testAction(new MoveCaretLeftAction());
assertFalse(eventSent.get());
}
use of com.intellij.openapi.editor.event.DocumentEvent in project intellij-community by JetBrains.
the class MvcRunTargetDialog method createUIComponents.
private void createUIComponents() {
myTargetField = new ComboBox(MvcRunTargetHistoryService.getInstance().getHistory());
myTargetField.setLightWeightPopupEnabled(false);
EditorComboBoxEditor editor = new StringComboboxEditor(myModule.getProject(), PlainTextFileType.INSTANCE, myTargetField);
myTargetField.setRenderer(new EditorComboBoxRenderer(editor));
myTargetField.setEditable(true);
myTargetField.setEditor(editor);
EditorTextField editorTextField = editor.getEditorComponent();
myFakePanel = new JPanel(new BorderLayout());
myFakePanel.add(myTargetField, BorderLayout.CENTER);
TextFieldCompletionProvider vmOptionCompletionProvider = new TextFieldCompletionProviderDumbAware() {
@NotNull
@Override
protected String getPrefix(@NotNull String currentTextPrefix) {
return MvcRunTargetDialog.getPrefix(currentTextPrefix);
}
@Override
protected void addCompletionVariants(@NotNull String text, int offset, @NotNull String prefix, @NotNull CompletionResultSet result) {
if (prefix.endsWith("-D")) {
result.addAllElements(MvcTargetDialogCompletionUtils.getSystemPropertiesVariants());
}
}
};
myVmOptionsField = vmOptionCompletionProvider.createEditor(myModule.getProject());
new TextFieldCompletionProviderDumbAware() {
@NotNull
@Override
protected String getPrefix(@NotNull String currentTextPrefix) {
return MvcRunTargetDialog.getPrefix(currentTextPrefix);
}
@Override
protected void addCompletionVariants(@NotNull String text, int offset, @NotNull String prefix, @NotNull CompletionResultSet result) {
for (LookupElement variant : MvcTargetDialogCompletionUtils.collectVariants(myModule, text, offset, prefix)) {
result.addElement(variant);
}
}
}.apply(editorTextField);
editorTextField.getDocument().addDocumentListener(new DocumentAdapter() {
@Override
public void documentChanged(DocumentEvent e) {
setOKActionEnabled(!StringUtil.isEmptyOrSpaces(e.getDocument().getText()));
}
});
setOKActionEnabled(false);
}
use of com.intellij.openapi.editor.event.DocumentEvent in project intellij-community by JetBrains.
the class GroovyCreateClassDialog method createCenterPanel.
@Override
@Nullable
protected JComponent createCenterPanel() {
myPackageTextField.getDocument().addDocumentListener(new DocumentAdapter() {
@Override
public void documentChanged(DocumentEvent e) {
PsiNameHelper nameHelper = PsiNameHelper.getInstance(myProject);
String packageName = getPackageName();
getOKAction().setEnabled(nameHelper.isQualifiedName(packageName) || packageName != null && packageName.isEmpty());
}
});
new AnAction() {
@Override
public void actionPerformed(AnActionEvent e) {
myPackageChooseButton.doClick();
}
}.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.SHIFT_DOWN_MASK)), myPackageTextField);
return myContentPane;
}
use of com.intellij.openapi.editor.event.DocumentEvent in project intellij-community by JetBrains.
the class PyIntroduceDialog method setUpNameComboBox.
private void setUpNameComboBox(Collection<String> possibleNames) {
final EditorComboBoxEditor comboEditor = new StringComboboxEditor(myProject, PythonFileType.INSTANCE, myNameComboBox);
myNameComboBox.setEditor(comboEditor);
myNameComboBox.setRenderer(new EditorComboBoxRenderer(comboEditor));
myNameComboBox.setEditable(true);
myNameComboBox.setMaximumRowCount(8);
myNameComboBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
updateControls();
}
});
((EditorTextField) myNameComboBox.getEditor().getEditorComponent()).addDocumentListener(new DocumentListener() {
public void beforeDocumentChange(DocumentEvent event) {
}
public void documentChanged(DocumentEvent event) {
updateControls();
}
});
myContentPane.registerKeyboardAction(new ActionListener() {
public void actionPerformed(ActionEvent e) {
IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> {
IdeFocusManager.getGlobalInstance().requestFocus(myNameComboBox, true);
});
}
}, KeyStroke.getKeyStroke(KeyEvent.VK_N, KeyEvent.ALT_MASK), JComponent.WHEN_IN_FOCUSED_WINDOW);
for (String possibleName : possibleNames) {
myNameComboBox.addItem(possibleName);
}
}
use of com.intellij.openapi.editor.event.DocumentEvent in project intellij-community by JetBrains.
the class GrIntroduceConstantDialog method initializeTargetClassEditor.
private void initializeTargetClassEditor() {
myTargetClassEditor = new ReferenceEditorComboWithBrowseButton(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
TreeClassChooser chooser = TreeClassChooserFactory.getInstance(myContext.getProject()).createWithInnerClassesScopeChooser(RefactoringBundle.message("choose.destination.class"), GlobalSearchScope.projectScope(myContext.getProject()), new ClassFilter() {
@Override
public boolean isAccepted(PsiClass aClass) {
return aClass.getParent() instanceof GroovyFile || aClass.hasModifierProperty(PsiModifier.STATIC);
}
}, null);
if (myTargetClass != null) {
chooser.selectDirectory(myTargetClass.getContainingFile().getContainingDirectory());
}
chooser.showDialog();
PsiClass aClass = chooser.getSelected();
if (aClass != null) {
myTargetClassEditor.setText(aClass.getQualifiedName());
}
}
}, "", myContext.getProject(), true, RECENTS_KEY);
myTargetClassPanel.setLayout(new BorderLayout());
myTargetClassPanel.add(myTargetClassLabel, BorderLayout.NORTH);
myTargetClassPanel.add(myTargetClassEditor, BorderLayout.CENTER);
Set<String> possibleClassNames = new LinkedHashSet<>();
for (final PsiElement occurrence : myContext.getOccurrences()) {
final PsiClass parentClass = getParentClass(occurrence);
if (parentClass != null && parentClass.getQualifiedName() != null) {
possibleClassNames.add(parentClass.getQualifiedName());
}
}
for (String possibleClassName : possibleClassNames) {
myTargetClassEditor.prependItem(possibleClassName);
}
if (myDefaultTargetClass != null) {
myTargetClassEditor.prependItem(myDefaultTargetClass.getQualifiedName());
}
myTargetClassEditor.getChildComponent().addDocumentListener(new DocumentAdapter() {
@Override
public void documentChanged(DocumentEvent e) {
targetClassChanged();
updateOkStatus();
// enableEnumDependant(introduceEnumConstant());
}
});
}
Aggregations