use of javax.swing.KeyStroke in project processdash by dtuma.
the class ClipboardBridge method setupAction.
private void setupAction(int keyChar, String token, Action action) {
KeyStroke keyStroke = KeyStroke.getKeyStroke(keyChar, KEY_MODIFIER, false);
table.getInputMap().put(keyStroke, token);
table.getActionMap().put(token, action);
}
use of javax.swing.KeyStroke in project cayenne by apache.
the class CayenneDialog method initCloseOnEscape.
/**
* Makes dialog closeable when ESC button is clicked.
*/
protected void initCloseOnEscape() {
// make dialog closable on escape
// TODO: Note that if a dialog contains subcomponents
// that use ESC for their own purposes (like editable JTable or JComboBox),
// this code will still close the dialog (e.g. not just an expanded
// ComboBox). To fix it see this advise (Swing is Fun!!):
//
// http://www.eos.dk/pipermail/swing/2001-June/000789.html
KeyStroke escReleased = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, true);
ActionListener closeAction = new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (CayenneDialog.this.isVisible()) {
// dispatch window closing event
WindowEvent windowClosing = new WindowEvent(CayenneDialog.this, WindowEvent.WINDOW_CLOSING);
CayenneDialog.super.processWindowEvent(windowClosing);
}
}
};
getRootPane().registerKeyboardAction(closeAction, escReleased, JComponent.WHEN_IN_FOCUSED_WINDOW);
}
use of javax.swing.KeyStroke in project sulky by huxi.
the class KeyStrokes method appendInputMap.
private static void appendInputMap(StringBuilder buffer, String mapName, InputMap inputMap) {
buffer.append("\tmapName: ").append(mapName).append('\n');
KeyStroke[] keys = inputMap.allKeys();
if (keys != null) {
for (KeyStroke ks : keys) {
buffer.append("\t\tKey : ").append(ks).append("\n\t\tValue: ").append(inputMap.get(ks)).append("\n\t\t----------\n");
}
}
}
use of javax.swing.KeyStroke in project knime-core by knime.
the class TableView method registerAction.
/**
* Registers the argument action in the components action map.
*
* @param action The action to register (does nothing if it hasn't a key stroke assigned)
*/
private void registerAction(final TableAction action) {
KeyStroke stroke = action.getKeyStroke();
Object name = action.getValue(Action.NAME);
if (stroke != null) {
getInputMap(WHEN_IN_FOCUSED_WINDOW).put(stroke, name);
getActionMap().put(name, action);
}
}
use of javax.swing.KeyStroke in project knime-core by knime.
the class TableView method registerFindAction.
/**
* Creates and registers the "Find ..." action on this component. Multiple invocation of this method have no effect
* (lazy initialization).
*
* @return The non-null action representing the find task.
* @see #registerNavigationActions()
*/
public TableAction registerFindAction() {
if (m_findAction == null) {
String name = "Find...";
KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_F, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
TableAction action = new TableAction(stroke, name) {
@Override
public void actionPerformed(final ActionEvent e) {
if (!hasData()) {
return;
}
if (m_searchPosition == null) {
initNewSearchPostion(new SearchOptions(true, false, true));
}
m_searchPosition.reset();
SearchOptions searchOptions = m_searchPosition.getSearchOptions();
boolean isSearchRowID = searchOptions.isSearchRowID();
boolean isSearchColumnName = searchOptions.isSearchColumnName();
boolean isSearchData = searchOptions.isSearchData();
JCheckBox rowKeyBox = new JCheckBox("Search RowID Column", isSearchRowID);
JCheckBox colNameBox = new JCheckBox("Search Column Names", isSearchColumnName);
JCheckBox dataBox = new JCheckBox("Search Data", isSearchData);
JCheckBox[] asArray = new JCheckBox[] { rowKeyBox, colNameBox, dataBox };
rowKeyBox.addItemListener(new AtLeastOnButtonSelectedItemListener(dataBox, asArray));
colNameBox.addItemListener(new AtLeastOnButtonSelectedItemListener(rowKeyBox, asArray));
dataBox.addItemListener(new AtLeastOnButtonSelectedItemListener(rowKeyBox, asArray));
JCheckBox ignoreCaseBox = new JCheckBox("Case insensitive", m_searchString.map(i -> i.isIgnoreCase()).orElse(false));
JCheckBox regexBox = new JCheckBox("Regular Expression", m_searchString.map(i -> i.isRegex()).orElse(false));
JPanel panel = new JPanel(new BorderLayout());
panel.add(new JLabel("Options: "), BorderLayout.NORTH);
JPanel centerPanel = new JPanel(new GridLayout(0, 1));
centerPanel.add(rowKeyBox);
centerPanel.add(colNameBox);
centerPanel.add(dataBox);
centerPanel.add(new JLabel());
centerPanel.add(ignoreCaseBox);
centerPanel.add(regexBox);
centerPanel.add(new JLabel());
panel.add(centerPanel, BorderLayout.CENTER);
panel.add(new JLabel(" "), BorderLayout.WEST);
panel.add(new JLabel("Find String: "), BorderLayout.SOUTH);
SearchString newSearchString;
while (true) {
String in = (String) JOptionPane.showInputDialog(TableView.this, panel, "Search", JOptionPane.QUESTION_MESSAGE, null, null, m_searchString.map(s -> s.getSearchString()).orElse(""));
if (StringUtils.isEmpty(in)) {
// canceled
return;
}
try {
newSearchString = new SearchString(in, ignoreCaseBox.isSelected(), regexBox.isSelected());
break;
} catch (PatternSyntaxException pse) {
JOptionPane.showMessageDialog(TableView.this, pse.getMessage(), "Invalid regular expression", JOptionPane.ERROR_MESSAGE);
}
}
searchOptions = new SearchOptions(rowKeyBox.isSelected(), colNameBox.isSelected(), dataBox.isSelected());
find(newSearchString, searchOptions);
}
};
registerAction(action);
m_findAction = action;
}
return m_findAction;
}
Aggregations