use of com.intellij.ui.DocumentAdapter in project kotlin by JetBrains.
the class AddFieldBreakpointDialog method createCenterPanel.
@Override
protected JComponent createCenterPanel() {
myClassChooser.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {
@Override
public void textChanged(DocumentEvent event) {
updateUI();
}
});
myClassChooser.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
PsiClass currentClass = getSelectedClass();
TreeClassChooser chooser = TreeClassChooserFactory.getInstance(myProject).createAllProjectScopeChooser(DebuggerBundle.message("add.field.breakpoint.dialog.classchooser.title"));
if (currentClass != null) {
PsiFile containingFile = currentClass.getContainingFile();
if (containingFile != null) {
PsiDirectory containingDirectory = containingFile.getContainingDirectory();
if (containingDirectory != null) {
chooser.selectDirectory(containingDirectory);
}
}
}
chooser.showDialog();
PsiClass selectedClass = chooser.getSelected();
if (selectedClass != null) {
myClassChooser.setText(selectedClass.getQualifiedName());
}
}
});
myFieldChooser.addActionListener(new ActionListener() {
@Override
public void actionPerformed(@NotNull ActionEvent e) {
PsiClass selectedClass = getSelectedClass();
DescriptorMemberChooserObject[] properties = FieldBreakpointDialogUtilKt.collectProperties(selectedClass);
MemberChooser<DescriptorMemberChooserObject> chooser = new MemberChooser<DescriptorMemberChooserObject>(properties, false, false, myProject);
chooser.setTitle(DebuggerBundle.message("add.field.breakpoint.dialog.field.chooser.title", properties.length));
chooser.setCopyJavadocVisible(false);
chooser.show();
List<DescriptorMemberChooserObject> selectedElements = chooser.getSelectedElements();
if (selectedElements != null && selectedElements.size() == 1) {
KtProperty field = (KtProperty) selectedElements.get(0).getElement();
myFieldChooser.setText(field.getName());
}
}
});
myFieldChooser.setEnabled(false);
return myPanel;
}
use of com.intellij.ui.DocumentAdapter in project intellij-community by JetBrains.
the class ProjectSpecificSettingsStep method registerValidators.
@Override
protected void registerValidators() {
super.registerValidators();
if (myProjectGenerator instanceof PythonProjectGenerator && !((PythonProjectGenerator) myProjectGenerator).hideInterpreter()) {
myLocationField.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {
@Override
protected void textChanged(DocumentEvent e) {
final String path = myLocationField.getText().trim();
((PythonProjectGenerator) myProjectGenerator).locationChanged(PathUtil.getFileName(path));
}
});
mySdkCombo.getComboBox().addItemListener(e -> {
if (e.getStateChange() == ItemEvent.SELECTED) {
final Runnable checkValidOnSwing = () -> ApplicationManager.getApplication().invokeLater(this::checkValid);
ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> {
try {
final Sdk sdk = getSdk();
if (sdk == null) {
return;
}
final boolean noPackages = PyPackageManager.getInstance(sdk).refreshAndGetPackages(true).isEmpty();
if (noPackages) {
LOGGER.warn(String.format("No packages on %s", sdk.getHomePath()));
}
checkValidOnSwing.run();
} catch (final ExecutionException exception) {
LOGGER.warn(exception);
checkValidOnSwing.run();
}
}, "Refreshing List of Packages, Please Wait", false, null);
}
});
UiNotifyConnector.doWhenFirstShown(mySdkCombo, this::checkValid);
}
}
use of com.intellij.ui.DocumentAdapter in project intellij-community by JetBrains.
the class AbstractCreateVirtualEnvDialog method registerValidators.
protected void registerValidators(final FacetValidatorsManager validatorsManager) {
myDestination.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {
@Override
protected void textChanged(DocumentEvent e) {
validatorsManager.validate();
}
});
myDestination.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
validatorsManager.validate();
}
});
myName.addCaretListener(new CaretListener() {
@Override
public void caretUpdate(CaretEvent event) {
validatorsManager.validate();
}
});
myDestination.getTextField().addCaretListener(new CaretListener() {
@Override
public void caretUpdate(CaretEvent event) {
validatorsManager.validate();
}
});
}
use of com.intellij.ui.DocumentAdapter in project intellij-community by JetBrains.
the class HtmlUnknownTagInspection method createOptionsPanel.
@NotNull
protected static JComponent createOptionsPanel(@NotNull final HtmlUnknownElementInspection inspection) {
final JPanel result = new JPanel(new BorderLayout());
final JPanel internalPanel = new JPanel(new BorderLayout());
result.add(internalPanel, BorderLayout.NORTH);
final Ref<FieldPanel> panelRef = new Ref<>();
final FieldPanel additionalAttributesPanel = new FieldPanel(null, null, new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
Messages.showTextAreaDialog(panelRef.get().getTextField(), StringUtil.wordsToBeginFromUpperCase(inspection.getPanelTitle()), inspection.getClass().getSimpleName(), s -> reparseProperties(s), strings -> StringUtil.join(strings, ","));
}
}, null);
((JButton) additionalAttributesPanel.getComponent(1)).setIcon(PlatformIcons.OPEN_EDIT_DIALOG_ICON);
panelRef.set(additionalAttributesPanel);
additionalAttributesPanel.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {
@Override
protected void textChanged(DocumentEvent e) {
final Document document = e.getDocument();
try {
final String text = document.getText(0, document.getLength());
if (text != null) {
inspection.updateAdditionalEntries(text.trim());
}
} catch (BadLocationException e1) {
inspection.getLogger().error(e1);
}
}
});
final JCheckBox checkBox = new JCheckBox(inspection.getCheckboxTitle());
checkBox.setSelected(inspection.isCustomValuesEnabled());
checkBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final boolean b = checkBox.isSelected();
if (b != inspection.isCustomValuesEnabled()) {
inspection.enableCustomValues(b);
additionalAttributesPanel.setEnabled(inspection.isCustomValuesEnabled());
}
}
});
internalPanel.add(checkBox, BorderLayout.NORTH);
internalPanel.add(additionalAttributesPanel, BorderLayout.CENTER);
additionalAttributesPanel.setPreferredSize(new Dimension(150, additionalAttributesPanel.getPreferredSize().height));
additionalAttributesPanel.setEnabled(inspection.isCustomValuesEnabled());
additionalAttributesPanel.setText(inspection.getAdditionalEntries());
return result;
}
use of com.intellij.ui.DocumentAdapter in project flutter-intellij by flutter.
the class FlutterSettingsConfigurable method init.
private void init() {
mySdkCombo.getComboBox().setEditable(true);
final JTextComponent sdkEditor = (JTextComponent) mySdkCombo.getComboBox().getEditor().getEditorComponent();
sdkEditor.getDocument().addDocumentListener(new DocumentAdapter() {
protected void textChanged(final DocumentEvent e) {
updateVersionText();
}
});
mySdkCombo.addBrowseFolderListener("Select Flutter SDK Path", null, null, FileChooserDescriptorFactory.createSingleFolderDescriptor(), TextComponentAccessor.STRING_COMBOBOX_WHOLE_TEXT);
myPrivacyPolicy.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
try {
BrowserLauncher.getInstance().browse(new URI(FlutterBundle.message("flutter.analytics.privacyUrl")));
} catch (URISyntaxException ignore) {
}
}
});
// noinspection Convert2Lambda
myFormatCodeOnSaveCheckBox.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
myOrganizeImportsOnSaveCheckBox.setEnabled(myFormatCodeOnSaveCheckBox.isSelected());
}
});
}
Aggregations