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;
}
use of com.intellij.ui.DocumentAdapter 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();
}
});
}
use of com.intellij.ui.DocumentAdapter in project intellij-community by JetBrains.
the class ScopePanel method initComponent.
public void initComponent(@Nullable Module currentModule, final SearchScope scope) {
final ItemListener stateListener = new ItemListener() {
public void itemStateChanged(ItemEvent e) {
myModuleSelection.setEnabled(myModuleScope.isSelected());
myDirectory.setEnabled(myDirectoryScope.isSelected());
myRecursive.setEnabled(myDirectoryScope.isSelected());
myCustomScopeSelection.setEnabled(myCustomScope.isSelected());
if (e.getStateChange() == ItemEvent.SELECTED) {
firePropertyChange("scope", null, getSelectedScope());
}
}
};
final ItemListener scopeListener = new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
firePropertyChange("scope", null, getSelectedScope());
}
}
};
myWholeProjectScope.addItemListener(stateListener);
myWholeProjectScope.setSelected(scope.getScopeType() == SearchScope.ScopeType.PROJECT);
myModuleScope.addItemListener(stateListener);
myModuleScope.setSelected(scope.getScopeType() == SearchScope.ScopeType.MODULE);
myDirectoryScope.addItemListener(stateListener);
myDirectoryScope.setSelected(scope.getScopeType() == SearchScope.ScopeType.DIRECTORY);
myCustomScope.addItemListener(stateListener);
myCustomScope.setSelected(scope.getScopeType() == SearchScope.ScopeType.CUSTOM);
myModuleSelection.fillModules(myProject);
Module m;
if (scope.getModuleName() != null) {
if ((m = ModuleManager.getInstance(myProject).findModuleByName(scope.getModuleName())) == null) {
m = currentModule;
}
} else {
m = currentModule;
}
if (m != null) {
myModuleSelection.setSelectedModule(m);
}
myModuleSelection.addItemListener(scopeListener);
((ScopeChooserCombo) myCustomScopeSelection).init(myProject, true, true, scope.getScopeName());
myCustomScopeSelection.getComboBox().addItemListener(scopeListener);
myDirectory.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {
protected void textChanged(DocumentEvent e) {
firePropertyChange("scope", null, getSelectedScope());
}
});
myDirectory.setText(scope.getPath());
myDirectory.addBrowseFolderListener("Select Path", "Select Path", myProject, FileChooserDescriptorFactory.createSingleFolderDescriptor());
myRecursive.setSelected(scope.isRecursive());
}
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 GotoLineNumberDialog method createNorthPanel.
protected JComponent createNorthPanel() {
class MyTextField extends JTextField {
public MyTextField() {
super("");
}
public Dimension getPreferredSize() {
Dimension d = super.getPreferredSize();
return new Dimension(200, d.height);
}
}
JPanel panel = new JPanel(new GridBagLayout());
GridBagConstraints gbConstraints = new GridBagConstraints();
gbConstraints.insets = JBUI.insets(4, 0, 8, 8);
gbConstraints.fill = GridBagConstraints.VERTICAL;
gbConstraints.weightx = 0;
gbConstraints.weighty = 1;
gbConstraints.anchor = GridBagConstraints.EAST;
JLabel label = new JLabel("[Line] [:column]:");
panel.add(label, gbConstraints);
gbConstraints.fill = GridBagConstraints.BOTH;
gbConstraints.weightx = 1;
myField = new MyTextField();
panel.add(myField, gbConstraints);
myField.setText(String.format("%d:%d", getLine() + 1, getColumn() + 1));
if (isInternal()) {
gbConstraints.gridy = 1;
gbConstraints.weightx = 0;
gbConstraints.weighty = 1;
gbConstraints.anchor = GridBagConstraints.EAST;
final JLabel offsetLabel = new JLabel("Offset:");
panel.add(offsetLabel, gbConstraints);
gbConstraints.fill = GridBagConstraints.BOTH;
gbConstraints.weightx = 1;
myOffsetField = new MyTextField();
panel.add(myOffsetField, gbConstraints);
myOffsetField.setText(String.valueOf(getOffset()));
DocumentAdapter valueSync = new DocumentAdapter() {
boolean inSync;
@Override
protected void textChanged(DocumentEvent e) {
if (inSync)
return;
inSync = true;
String s = "<invalid>";
JTextField f = null;
try {
if (e.getDocument() == myField.getDocument()) {
f = myOffsetField;
Coordinates p = getCoordinates();
s = p == null ? s : String.valueOf(coordinatesToOffset(p));
} else {
f = myField;
int offset = StringUtil.parseInt(myOffsetField.getText(), -1);
Coordinates p = offset >= 0 ? offsetToCoordinates(Math.min(getMaxOffset() - 1, offset)) : null;
s = p == null ? s : String.format("%d:%d", p.row + 1, p.column + 1);
}
f.setText(s);
} catch (IndexOutOfBoundsException ignored) {
if (f != null)
f.setText(s);
} finally {
inSync = false;
}
}
};
myField.getDocument().addDocumentListener(valueSync);
myOffsetField.getDocument().addDocumentListener(valueSync);
}
return panel;
}
Aggregations