Refactor: Introduce JTextComponent.onTextChange() function
This commit is contained in:
+9
-7
@@ -25,9 +25,10 @@ import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.ui.DocumentAdapter;
|
||||
import kotlin.Unit;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.idea.core.util.DescriptorMemberChooserObject;
|
||||
import org.jetbrains.kotlin.idea.util.UiUtilKt;
|
||||
import org.jetbrains.kotlin.psi.KtProperty;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -51,12 +52,13 @@ public abstract class AddFieldBreakpointDialog extends DialogWrapper {
|
||||
|
||||
@Override
|
||||
protected JComponent createCenterPanel() {
|
||||
myClassChooser.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {
|
||||
@Override
|
||||
public void textChanged(DocumentEvent event) {
|
||||
updateUI();
|
||||
}
|
||||
});
|
||||
UiUtilKt.onTextChange(
|
||||
myClassChooser.getTextField(),
|
||||
(DocumentEvent e) -> {
|
||||
updateUI();
|
||||
return Unit.INSTANCE;
|
||||
}
|
||||
);
|
||||
|
||||
myClassChooser.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
|
||||
@@ -19,11 +19,12 @@ package org.jetbrains.kotlin.idea.framework.ui;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
|
||||
import com.intellij.ui.DocumentAdapter;
|
||||
import com.intellij.ui.JBColor;
|
||||
import com.intellij.util.EventDispatcher;
|
||||
import kotlin.Unit;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.idea.util.UiUtilKt;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
@@ -46,12 +47,13 @@ public class CopyIntoPanel {
|
||||
copyIntoField.addBrowseFolderListener(
|
||||
"Copy Into...", "Choose folder where files will be copied", project,
|
||||
FileChooserDescriptorFactory.createSingleFolderDescriptor());
|
||||
copyIntoField.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {
|
||||
@Override
|
||||
protected void textChanged(DocumentEvent e) {
|
||||
updateComponents();
|
||||
}
|
||||
});
|
||||
UiUtilKt.onTextChange(
|
||||
copyIntoField.getTextField(),
|
||||
(DocumentEvent e) -> {
|
||||
updateComponents();
|
||||
return Unit.INSTANCE;
|
||||
}
|
||||
);
|
||||
|
||||
if (labelText != null) {
|
||||
String text = labelText.replace("&", "");
|
||||
|
||||
Reference in New Issue
Block a user