use of javax.swing.event.DocumentEvent in project ACS by ACS-Community.
the class ScriptFilter method getFilterComponentTextField.
/**
* This method initializes filterComponentTextField
* @return javax.swing.JTextField
*/
private JTextField getFilterComponentTextField() {
if (filterComponentTextField == null) {
Dimension d = new Dimension(100, 19);
filterComponentTextField = new JTextField();
filterComponentTextField.setPreferredSize(d);
filterComponentTextField.setToolTipText("Write a word to find a particular component.");
//filterComponentTextField.setSize(d);
filterComponentTextField.setMinimumSize(d);
filterComponentTextField.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
filterComponentTextField.setHorizontalAlignment(JTextField.LEFT);
filterComponentTextField.getDocument().addDocumentListener(new DocumentListener() {
public void applyFilter() {
int total = compList.length;
String text = filterComponentTextField.getText();
if (!filterComponentTextField.getText().isEmpty()) {
ComponentComboBox.removeAllItems();
for (int i = 0; i < total; i++) {
if (compList[i].contains(text)) {
ComponentComboBox.addItem(compList[i]);
}
}
ComponentComboBox.hidePopup();
ComponentComboBox.showPopup();
} else {
ComponentComboBox.hidePopup();
ComponentComboBox.removeAllItems();
for (int j = 0; j < total; j++) {
ComponentComboBox.addItem(compList[j]);
}
}
if (ComponentComboBox.getItemCount() == 0) {
PropertyComboBox.removeAllItems();
}
}
public void changedUpdate(DocumentEvent e) {
}
public void insertUpdate(DocumentEvent e) {
applyFilter();
}
public void removeUpdate(DocumentEvent e) {
applyFilter();
}
});
}
return filterComponentTextField;
}
use of javax.swing.event.DocumentEvent in project ACS by ACS-Community.
the class ScriptFilter method getFilterPropertyTextField.
/**
* This method initializes filterPropertyTextField
* @return javax.swing.JTextField
*/
private JTextField getFilterPropertyTextField() {
if (filterPropertyTextField == null) {
Dimension d = new Dimension(100, 19);
filterPropertyTextField = new JTextField();
filterPropertyTextField.setPreferredSize(d);
filterPropertyTextField.setToolTipText("Write a word to find a particular property.");
//filterPropertyTextField.setSize(d);
filterPropertyTextField.setMinimumSize(d);
filterPropertyTextField.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
filterPropertyTextField.setHorizontalAlignment(JTextField.LEFT);
filterPropertyTextField.getDocument().addDocumentListener(new DocumentListener() {
public void applyFilter() {
String item = (String) ComponentComboBox.getSelectedItem();
int i = -1;
for (int j = 0; j < compList.length; j++) {
if (compList[j].compareTo(item) == 0) {
i = j;
break;
}
}
if (i == -1) {
PropertyComboBox.removeAll();
return;
}
int total = propList.get(i).size();
String text = filterPropertyTextField.getText();
PropertyComboBox.removeAllItems();
for (int j = 0; j < total; j++) {
PropertyComboBox.addItem(propList.get(i).get(j).toString());
}
PropertyComboBox.showPopup();
if (!filterPropertyTextField.getText().isEmpty()) {
PropertyComboBox.removeAllItems();
for (int j = 0; j < total; j++) {
if (propList.get(i).get(j).toString().contains(text)) {
PropertyComboBox.addItem(propList.get(i).get(j).toString());
}
}
} else {
PropertyComboBox.hidePopup();
}
}
public void changedUpdate(DocumentEvent e) {
}
public void insertUpdate(DocumentEvent e) {
applyFilter();
}
public void removeUpdate(DocumentEvent e) {
applyFilter();
}
});
}
return filterPropertyTextField;
}
use of javax.swing.event.DocumentEvent in project intellij-community by JetBrains.
the class EditLogPatternDialog method createCenterPanel.
@Override
protected JComponent createCenterPanel() {
myFilePattern.addBrowseFolderListener(UIBundle.message("file.chooser.default.title"), null, null, FileChooserDescriptorFactory.createSingleFileOrFolderDescriptor(), TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT);
myFilePattern.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {
@Override
protected void textChanged(DocumentEvent e) {
setOKActionEnabled(myFilePattern.getText() != null && myFilePattern.getText().length() > 0);
}
});
return myWholePanel;
}
use of javax.swing.event.DocumentEvent in project intellij-community by JetBrains.
the class GotoActionBase method showNavigationPopup.
protected <T> void showNavigationPopup(final GotoActionCallback<T> callback, @Nullable final String findUsagesTitle, final ChooseByNamePopup popup, final boolean allowMultipleSelection) {
final Class startedAction = myInAction;
LOG.assertTrue(startedAction != null);
popup.setCheckBoxShortcut(getShortcutSet());
popup.setFindUsagesTitle(findUsagesTitle);
final ChooseByNameFilter<T> filter = callback.createFilter(popup);
if (historyEnabled() && popup.getAdText() == null) {
popup.setAdText("Press " + KeymapUtil.getKeystrokeText(KeyStroke.getKeyStroke(KeyEvent.VK_UP, InputEvent.CTRL_MASK)) + " or " + KeymapUtil.getKeystrokeText(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, InputEvent.CTRL_MASK)) + " to navigate through the history");
}
popup.invoke(new ChooseByNamePopupComponent.Callback() {
@Override
public void onClose() {
//noinspection ConstantConditions
if (startedAction != null && startedAction.equals(myInAction)) {
String text = popup.getEnteredText();
ourLastStrings.put(myInAction, Pair.create(text, popup.getSelectedIndex()));
updateHistory(text);
myInAction = null;
}
if (filter != null) {
filter.close();
}
}
private void updateHistory(@Nullable String text) {
if (!StringUtil.isEmptyOrSpaces(text)) {
List<String> history = ourHistory.get(myInAction);
if (history == null)
history = ContainerUtil.newArrayList();
if (!text.equals(ContainerUtil.getFirstItem(history))) {
history.add(0, text);
}
ourHistory.put(myInAction, history);
}
}
@Override
public void elementChosen(Object element) {
callback.elementChosen(popup, element);
}
}, ModalityState.current(), allowMultipleSelection);
final JTextField editor = popup.getTextField();
final DocumentAdapter historyResetListener = new DocumentAdapter() {
@Override
protected void textChanged(DocumentEvent e) {
myHistoryIndex = 0;
}
};
abstract class HistoryAction extends DumbAwareAction {
@Override
public void update(@NotNull AnActionEvent e) {
e.getPresentation().setEnabled(historyEnabled());
}
void setText(@NotNull List<String> strings) {
javax.swing.text.Document document = editor.getDocument();
document.removeDocumentListener(historyResetListener);
editor.setText(strings.get(myHistoryIndex));
document.addDocumentListener(historyResetListener);
editor.selectAll();
}
}
editor.getDocument().addDocumentListener(historyResetListener);
new HistoryAction() {
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
List<String> strings = ourHistory.get(myInAction);
setText(strings);
myHistoryIndex = myHistoryIndex >= strings.size() - 1 ? 0 : myHistoryIndex + 1;
}
}.registerCustomShortcutSet(CustomShortcutSet.fromString("ctrl UP"), editor);
new HistoryAction() {
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
List<String> strings = ourHistory.get(myInAction);
setText(strings);
myHistoryIndex = myHistoryIndex <= 0 ? strings.size() - 1 : myHistoryIndex - 1;
}
}.registerCustomShortcutSet(CustomShortcutSet.fromString("ctrl DOWN"), editor);
}
use of javax.swing.event.DocumentEvent in project intellij-community by JetBrains.
the class ToolEditorDialog method addListeners.
private void addListeners() {
myOutputFiltersButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
OutputFiltersDialog dialog = new OutputFiltersDialog(myOutputFiltersButton, getData().getOutputFilters());
if (dialog.showAndGet()) {
myOutputFilters = dialog.getData();
}
}
});
myInsertCommandMacroButton.addActionListener(new InsertMacroActionListener(myTfCommand));
myInsertParametersMacroButton.addActionListener(new InsertMacroActionListener(myParametersField));
myInsertWorkingDirectoryMacroButton.addActionListener(new InsertMacroActionListener(myTfCommandWorkingDirectory));
myNameField.getDocument().addDocumentListener(new DocumentAdapter() {
@Override
public void textChanged(DocumentEvent event) {
handleOKButton();
}
});
myUseConsoleCheckbox.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
myShowConsoleOnStdOutCheckbox.setVisible(myUseConsoleCheckbox.isSelected());
myShowConsoleOnStdErrCheckbox.setVisible(myUseConsoleCheckbox.isSelected());
}
});
}
Aggregations