use of javax.swing.event.DocumentEvent in project intellij-community by JetBrains.
the class EditableSchemesCombo method createNameEditorField.
private JTextField createNameEditorField() {
JTextField nameEditorField = new JTextField();
nameEditorField.registerKeyboardAction(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
revertSchemeName();
cancelEdit();
}
}, ESC_KEY_STROKE, JComponent.WHEN_FOCUSED);
nameEditorField.registerKeyboardAction(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
stopEdit();
}
}, ENTER_KEY_STROKE, JComponent.WHEN_FOCUSED);
nameEditorField.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent e) {
stopEdit();
}
});
nameEditorField.getDocument().addDocumentListener(new DocumentAdapter() {
@Override
protected void textChanged(DocumentEvent e) {
validateOnTyping();
}
});
return nameEditorField;
}
use of javax.swing.event.DocumentEvent in project intellij-community by JetBrains.
the class AddFieldBreakpointDialog method createCenterPanel.
protected JComponent createCenterPanel() {
myClassChooser.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {
public void textChanged(DocumentEvent event) {
updateUI();
}
});
myClassChooser.addActionListener(new ActionListener() {
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() {
public void actionPerformed(ActionEvent e) {
PsiClass selectedClass = getSelectedClass();
if (selectedClass != null) {
PsiField[] fields = selectedClass.getFields();
MemberChooser<PsiFieldMember> chooser = new MemberChooser<>(ContainerUtil.map2Array(fields, PsiFieldMember.class, PsiFieldMember::new), false, false, myProject);
chooser.setTitle(DebuggerBundle.message("add.field.breakpoint.dialog.field.chooser.title", fields.length));
chooser.setCopyJavadocVisible(false);
TransactionGuard.getInstance().submitTransactionAndWait(() -> chooser.show());
List<PsiFieldMember> selectedElements = chooser.getSelectedElements();
if (selectedElements != null && selectedElements.size() == 1) {
PsiField field = selectedElements.get(0).getElement();
myFieldChooser.setText(field.getName());
}
}
}
});
myFieldChooser.setEnabled(false);
return myPanel;
}
use of javax.swing.event.DocumentEvent in project intellij-community by JetBrains.
the class ClassHasNoToStringMethodInspection method createOptionsPanel.
/**
* Creates the options panel in the settings for user changeable options.
*
* @return the options panel
*/
@Override
public JComponent createOptionsPanel() {
JPanel panel = new JPanel(new GridBagLayout());
GridBagConstraints constraints = new GridBagConstraints();
constraints.gridx = 0;
constraints.gridy = 0;
constraints.weightx = 0.0;
constraints.anchor = GridBagConstraints.WEST;
constraints.fill = GridBagConstraints.NONE;
panel.add(new JLabel("Exclude classes (reg exp):"), constraints);
final JFormattedTextField excludeClassNamesField = new JFormattedTextField(new RegExFormatter());
excludeClassNamesField.setValue(excludeClassNamesPattern);
excludeClassNamesField.setColumns(25);
excludeClassNamesField.setInputVerifier(new RegExInputVerifier());
excludeClassNamesField.setFocusLostBehavior(JFormattedTextField.COMMIT);
excludeClassNamesField.setMinimumSize(excludeClassNamesField.getPreferredSize());
UIUtil.fixFormattedField(excludeClassNamesField);
Document document = excludeClassNamesField.getDocument();
document.addDocumentListener(new DocumentAdapter() {
@Override
protected void textChanged(DocumentEvent e) {
try {
excludeClassNamesField.commitEdit();
excludeClassNamesPattern = (Pattern) excludeClassNamesField.getValue();
excludeClassNames = excludeClassNamesPattern.pattern();
} catch (final Exception ignore) {
}
}
});
constraints.gridx = 1;
constraints.gridy = 0;
constraints.weightx = 1.0;
constraints.anchor = GridBagConstraints.NORTHWEST;
constraints.fill = GridBagConstraints.NONE;
panel.add(excludeClassNamesField, constraints);
final CheckBox excludeExceptionCheckBox = new CheckBox("Ignore exception classes", this, "excludeException");
constraints.gridx = 0;
constraints.gridy = 1;
constraints.gridwidth = 2;
constraints.fill = GridBagConstraints.HORIZONTAL;
panel.add(excludeExceptionCheckBox, constraints);
final CheckBox excludeDeprecatedCheckBox = new CheckBox("Ignore deprecated classes", this, "excludeDeprecated");
constraints.gridy = 2;
panel.add(excludeDeprecatedCheckBox, constraints);
final CheckBox excludeEnumCheckBox = new CheckBox("Ignore enum classes", this, "excludeEnum");
constraints.gridy = 3;
panel.add(excludeEnumCheckBox, constraints);
final CheckBox excludeAbstractCheckBox = new CheckBox("Ignore abstract classes", this, "excludeAbstract");
constraints.gridy = 4;
panel.add(excludeAbstractCheckBox, constraints);
final CheckBox excludeInTestCodeCheckBox = new CheckBox("Ignore test classes", this, "excludeTestCode");
constraints.gridy = 5;
panel.add(excludeInTestCodeCheckBox, constraints);
final CheckBox excludeInnerClasses = new CheckBox("Ignore inner classes", this, "excludeInnerClasses");
constraints.gridy = 6;
constraints.weighty = 1.0;
panel.add(excludeInnerClasses, constraints);
return panel;
}
use of javax.swing.event.DocumentEvent in project intellij-community by JetBrains.
the class DuplicateStringLiteralInspection method createOptionsPanel.
@Override
public JComponent createOptionsPanel() {
final OptionsPanel optionsPanel = new OptionsPanel();
optionsPanel.myIgnorePropertyKeyExpressions.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
IGNORE_PROPERTY_KEYS = optionsPanel.myIgnorePropertyKeyExpressions.isSelected();
}
});
optionsPanel.myMinStringLengthField.getDocument().addDocumentListener(new DocumentAdapter() {
@Override
protected void textChanged(final DocumentEvent e) {
try {
MIN_STRING_LENGTH = Integer.parseInt(optionsPanel.myMinStringLengthField.getText());
} catch (NumberFormatException ignored) {
}
}
});
optionsPanel.myIgnorePropertyKeyExpressions.setSelected(IGNORE_PROPERTY_KEYS);
optionsPanel.myMinStringLengthField.setText(Integer.toString(MIN_STRING_LENGTH));
return optionsPanel.myPanel;
}
use of javax.swing.event.DocumentEvent in project intellij-community by JetBrains.
the class GitRebaseDialog method setupBranches.
/**
* Setup branch drop down.
*/
private void setupBranches() {
GitUIUtil.getTextField(myOntoComboBox).getDocument().addDocumentListener(new DocumentAdapter() {
protected void textChanged(final DocumentEvent e) {
validateFields();
}
});
final ActionListener rootListener = new ActionListener() {
public void actionPerformed(final ActionEvent e) {
loadRefs();
updateBranches();
}
};
final ActionListener showListener = new ActionListener() {
public void actionPerformed(final ActionEvent e) {
updateOntoFrom();
}
};
myShowRemoteBranchesCheckBox.addActionListener(showListener);
myShowTagsCheckBox.addActionListener(showListener);
rootListener.actionPerformed(null);
myGitRootComboBox.addActionListener(rootListener);
myBranchComboBox.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
updateTrackedBranch();
}
});
}
Aggregations