use of com.intellij.ui.DocumentAdapter in project intellij-community by JetBrains.
the class I18nInspection method createOptionsPanel.
@Override
public JComponent createOptionsPanel() {
final GridBagLayout layout = new GridBagLayout();
final JPanel panel = new JPanel(layout);
final JCheckBox assertStatementsCheckbox = new JCheckBox(CodeInsightBundle.message("inspection.i18n.option.ignore.assert"), ignoreForAssertStatements);
assertStatementsCheckbox.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(@NotNull ChangeEvent e) {
ignoreForAssertStatements = assertStatementsCheckbox.isSelected();
}
});
final JCheckBox exceptionConstructorCheck = new JCheckBox(CodeInsightBundle.message("inspection.i18n.option.ignore.for.exception.constructor.arguments"), ignoreForExceptionConstructors);
exceptionConstructorCheck.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(@NotNull ChangeEvent e) {
ignoreForExceptionConstructors = exceptionConstructorCheck.isSelected();
}
});
final JTextField specifiedExceptions = new JTextField(ignoreForSpecifiedExceptionConstructors);
specifiedExceptions.getDocument().addDocumentListener(new DocumentAdapter() {
@Override
protected void textChanged(DocumentEvent e) {
ignoreForSpecifiedExceptionConstructors = specifiedExceptions.getText();
}
});
final JCheckBox junitAssertCheckbox = new JCheckBox(CodeInsightBundle.message("inspection.i18n.option.ignore.for.junit.assert.arguments"), ignoreForJUnitAsserts);
junitAssertCheckbox.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(@NotNull ChangeEvent e) {
ignoreForJUnitAsserts = junitAssertCheckbox.isSelected();
}
});
final JCheckBox classRef = new JCheckBox(CodeInsightBundle.message("inspection.i18n.option.ignore.qualified.class.names"), ignoreForClassReferences);
classRef.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(@NotNull ChangeEvent e) {
ignoreForClassReferences = classRef.isSelected();
}
});
final JCheckBox propertyRef = new JCheckBox(CodeInsightBundle.message("inspection.i18n.option.ignore.property.keys"), ignoreForPropertyKeyReferences);
propertyRef.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(@NotNull ChangeEvent e) {
ignoreForPropertyKeyReferences = propertyRef.isSelected();
}
});
final JCheckBox nonAlpha = new JCheckBox(CodeInsightBundle.message("inspection.i18n.option.ignore.nonalphanumerics"), ignoreForNonAlpha);
nonAlpha.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(@NotNull ChangeEvent e) {
ignoreForNonAlpha = nonAlpha.isSelected();
}
});
final JCheckBox assignedToConstants = new JCheckBox(CodeInsightBundle.message("inspection.i18n.option.ignore.assigned.to.constants"), ignoreAssignedToConstants);
assignedToConstants.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(@NotNull ChangeEvent e) {
ignoreAssignedToConstants = assignedToConstants.isSelected();
}
});
final JCheckBox chkToString = new JCheckBox(CodeInsightBundle.message("inspection.i18n.option.ignore.tostring"), ignoreToString);
chkToString.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(@NotNull ChangeEvent e) {
ignoreToString = chkToString.isSelected();
}
});
final JCheckBox ignoreEnumConstants = new JCheckBox("Ignore enum constants", ignoreForEnumConstants);
ignoreEnumConstants.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(@NotNull ChangeEvent e) {
ignoreForEnumConstants = ignoreEnumConstants.isSelected();
}
});
final GridBagConstraints gc = new GridBagConstraints();
gc.fill = GridBagConstraints.HORIZONTAL;
gc.insets.bottom = 2;
gc.gridx = GridBagConstraints.REMAINDER;
gc.gridy = 0;
gc.weightx = 1;
gc.weighty = 0;
panel.add(assertStatementsCheckbox, gc);
gc.gridy++;
panel.add(junitAssertCheckbox, gc);
gc.gridy++;
panel.add(exceptionConstructorCheck, gc);
gc.gridy++;
final Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
panel.add(new FieldPanel(specifiedExceptions, null, CodeInsightBundle.message("inspection.i18n.option.ignore.for.specified.exception.constructor.arguments"), openProjects.length == 0 ? null : new ActionListener() {
@Override
public void actionPerformed(@NotNull ActionEvent e) {
createIgnoreExceptionsConfigurationDialog(openProjects[0], specifiedExceptions).show();
}
}, null), gc);
gc.gridy++;
panel.add(classRef, gc);
gc.gridy++;
panel.add(propertyRef, gc);
gc.gridy++;
panel.add(assignedToConstants, gc);
gc.gridy++;
panel.add(chkToString, gc);
gc.gridy++;
panel.add(nonAlpha, gc);
gc.gridy++;
panel.add(ignoreEnumConstants, gc);
gc.gridy++;
gc.anchor = GridBagConstraints.NORTHWEST;
gc.weighty = 1;
final JTextField text = new JTextField(nonNlsCommentPattern);
final FieldPanel nonNlsCommentPatternComponent = new FieldPanel(text, CodeInsightBundle.message("inspection.i18n.option.ignore.comment.pattern"), CodeInsightBundle.message("inspection.i18n.option.ignore.comment.title"), null, () -> {
nonNlsCommentPattern = text.getText();
cacheNonNlsCommentPattern();
});
panel.add(nonNlsCommentPatternComponent, gc);
final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(panel);
scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
scrollPane.setBorder(null);
scrollPane.setPreferredSize(new Dimension(panel.getPreferredSize().width + scrollPane.getVerticalScrollBar().getPreferredSize().width, panel.getPreferredSize().height + scrollPane.getHorizontalScrollBar().getPreferredSize().height));
return scrollPane;
}
use of com.intellij.ui.DocumentAdapter in project intellij-community by JetBrains.
the class SetPropertyDialog method init.
protected void init() {
super.init();
if (myPropertyName != null) {
updatePropertyValue(myPropertyName);
} else {
myPropertyNameBox.getEditor().setItem("");
}
myPropertyNameBox.addItemListener(e -> {
if (e.getStateChange() == ItemEvent.SELECTED) {
String name = getPropertyName();
updatePropertyValue(name);
getOKAction().setEnabled(name != null && !"".equals(name.trim()));
}
});
Component editor = myPropertyNameBox.getEditor().getEditorComponent();
if (editor instanceof JTextField) {
JTextField jTextField = (JTextField) editor;
jTextField.getDocument().addDocumentListener(new DocumentAdapter() {
protected void textChanged(DocumentEvent e) {
String name = getPropertyName();
updatePropertyValue(name);
getOKAction().setEnabled(name != null && !"".equals(name.trim()));
}
});
}
getOKAction().setEnabled(myPropertyName != null && !"".equals(myPropertyName.trim()));
}
use of com.intellij.ui.DocumentAdapter in project intellij-community by JetBrains.
the class SshSettingsPanel method init.
private void init() {
register(myPasswordChoice, SvnConfiguration.SshConnectionType.PASSWORD);
register(myPrivateKeyChoice, SvnConfiguration.SshConnectionType.PRIVATE_KEY);
register(mySubversionConfigChoice, SvnConfiguration.SshConnectionType.SUBVERSION_CONFIG);
ItemListener connectionTypeChangedListener = e -> {
if (e.getStateChange() == ItemEvent.SELECTED) {
enableOptions(e.getSource());
}
};
myPasswordChoice.addItemListener(connectionTypeChangedListener);
myPrivateKeyChoice.addItemListener(connectionTypeChangedListener);
mySubversionConfigChoice.addItemListener(connectionTypeChangedListener);
enableOptions(mySubversionConfigChoice);
registerBrowseDialog(myExecutablePathField, SvnBundle.message("ssh.settings.browse.executable.dialog.title"));
registerBrowseDialog(myPrivateKeyPathField, SvnBundle.message("ssh.settings.browse.private.key.dialog.title"));
mySshTunnelField.getEmptyText().setText(SshTunnelRuntimeModule.DEFAULT_SSH_TUNNEL_VALUE);
mySshTunnelField.getDocument().addDocumentListener(new DocumentAdapter() {
@Override
protected void textChanged(DocumentEvent e) {
updateSshTunnelDependentValues(mySshTunnelField.getText());
}
});
myUpdateTunnelButton.addActionListener(e -> {
String tunnel = mySshTunnelField.getText();
mySvnConfiguration.setSshTunnelSetting(StringUtil.nullize(tunnel));
setSshTunnelSetting(mySvnConfiguration.getSshTunnelSetting());
});
}
use of com.intellij.ui.DocumentAdapter in project intellij-community by JetBrains.
the class DependsOnGroupsInspection method createOptionsPanel.
@Override
@Nullable
public JComponent createOptionsPanel() {
final LabeledComponent<JTextField> definedGroups = new LabeledComponent<>();
definedGroups.setText("&Defined Groups");
final JTextField textField = new JTextField(StringUtil.join(ArrayUtil.toStringArray(groups), ","));
textField.getDocument().addDocumentListener(new DocumentAdapter() {
@Override
protected void textChanged(final DocumentEvent e) {
groups.clear();
String text = textField.getText();
if (!StringUtil.isEmptyOrSpaces(text)) {
ContainerUtil.addAll(groups, text.split("[, ]"));
}
}
});
definedGroups.setComponent(textField);
final JPanel optionsPanel = new JPanel(new BorderLayout());
optionsPanel.add(definedGroups, BorderLayout.NORTH);
return optionsPanel;
}
use of com.intellij.ui.DocumentAdapter 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;
}
Aggregations