use of javax.swing.ActionMap in project jabref by JabRef.
the class ProtectedTermsDialog method init.
private void init() {
setupPopupMenu();
loadButton.addActionListener(actionEvent -> {
AddFileDialog addDialog = new AddFileDialog();
addDialog.setVisible(true);
addDialog.getFileName().ifPresent(fileName -> loader.addProtectedTermsListFromFile(fileName, true));
tableModel.fireTableDataChanged();
});
loadButton.setToolTipText(Localization.lang("Add protected terms file"));
removeButton.addActionListener(removeAction);
removeButton.setToolTipText(Localization.lang("Remove protected terms file"));
newButton.addActionListener(actionEvent -> {
NewProtectedTermsFileDialog newDialog = new NewProtectedTermsFileDialog(diag, loader);
newDialog.setVisible(true);
tableModel.fireTableDataChanged();
});
newButton.setToolTipText(Localization.lang("New protected terms file"));
setupTable();
// Build dialog
diag = new JDialog(frame, Localization.lang("Manage protected terms files"), true);
FormBuilder builder = FormBuilder.create();
builder.layout(new FormLayout("fill:pref:grow, 4dlu, left:pref, 4dlu, left:pref, 4dlu, left:pref", "100dlu:grow, 4dlu, pref"));
builder.add(new JScrollPane(table)).xyw(1, 1, 7);
builder.add(newButton).xy(3, 3);
builder.add(loadButton).xy(5, 3);
builder.add(removeButton).xy(7, 3);
builder.padding("5dlu, 5dlu, 5dlu, 5dlu");
diag.add(builder.getPanel(), BorderLayout.CENTER);
AbstractAction okListener = new AbstractAction() {
@Override
public void actionPerformed(ActionEvent event) {
// Write changes to preferences
storePreferences();
diag.dispose();
}
};
ok.addActionListener(okListener);
Action cancelListener = new AbstractAction() {
@Override
public void actionPerformed(ActionEvent event) {
// Restore from preferences
loader.update(Globals.prefs.getProtectedTermsPreferences());
diag.dispose();
}
};
cancel.addActionListener(cancelListener);
ButtonBarBuilder bb = new ButtonBarBuilder();
bb.addGlue();
bb.addButton(ok);
bb.addButton(cancel);
bb.addGlue();
bb.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
diag.add(bb.getPanel(), BorderLayout.SOUTH);
ActionMap am = bb.getPanel().getActionMap();
InputMap im = bb.getPanel().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
im.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_DIALOG), "close");
am.put("close", cancelListener);
im.put(KeyStroke.getKeyStroke("ENTER"), "enterOk");
am.put("enterOk", okListener);
diag.pack();
WindowLocation pw = new WindowLocation(diag, JabRefPreferences.TERMS_POS_X, JabRefPreferences.TERMS_POS_Y, JabRefPreferences.TERMS_SIZE_X, JabRefPreferences.TERMS_SIZE_Y);
pw.displayWindowAtStoredLocation();
}
use of javax.swing.ActionMap in project jabref by JabRef.
the class PushToApplicationButton method showSettingsDialog.
public static void showSettingsDialog(JFrame parent, PushToApplication toApp, JPanel options) {
final BooleanHolder okPressed = new BooleanHolder(false);
final JDialog diag = new JDialog(parent, Localization.lang("Settings"), true);
options.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
diag.getContentPane().add(options, BorderLayout.CENTER);
ButtonBarBuilder bb = new ButtonBarBuilder();
JButton ok = new JButton(Localization.lang("OK"));
JButton cancel = new JButton(Localization.lang("Cancel"));
bb.addGlue();
bb.addButton(ok);
bb.addButton(cancel);
bb.addGlue();
bb.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
diag.getContentPane().add(bb.getPanel(), BorderLayout.SOUTH);
ok.addActionListener(e -> {
okPressed.value = true;
diag.dispose();
});
cancel.addActionListener(e -> diag.dispose());
// Key bindings:
ActionMap am = bb.getPanel().getActionMap();
InputMap im = bb.getPanel().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
im.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_DIALOG), "close");
am.put("close", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
diag.dispose();
}
});
diag.pack();
diag.setLocationRelativeTo(parent);
// Show the dialog:
diag.setVisible(true);
// to store its settings:
if (okPressed.value) {
toApp.storeSettings();
}
}
use of javax.swing.ActionMap in project processdash by dtuma.
the class WBSTabPanel method installKeyboardShortcuts.
/**
* Configure a number of keyboard shortcuts for navigating within the
* contents of the WBS tab panel
*/
private void installKeyboardShortcuts() {
InputMap inputMap = dataTable.getInputMap();
ActionMap actionMap = dataTable.getActionMap();
inputMap.put(KeyStroke.getKeyStroke("HOME"), "focusTree");
inputMap.put(KeyStroke.getKeyStroke("shift SPACE"), "focusTree");
actionMap.put("focusTree", new TransferFocusToWbsNode());
new MoveLeftFromDataCell().install(dataTable);
inputMap = wbsTable.getInputMap();
actionMap = wbsTable.getActionMap();
inputMap.put(KeyStroke.getKeyStroke("END"), "lastDataCol");
actionMap.put("lastDataCol", new TransferFocusToDataTable(true));
inputMap.put(KeyStroke.getKeyStroke("RIGHT"), "firstDataCol");
actionMap.put("firstDataCol", new TransferFocusToDataTable(false));
inputMap.put(KeyStroke.getKeyStroke("LEFT"), "startEditing");
inputMap = this.getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
inputMap.put(//
KeyStroke.getKeyStroke(//
KeyEvent.VK_T, MacGUIUtils.getCtrlModifier()), "focusTabs");
this.getActionMap().put("focusTabs", new TransferFocusToTabs());
}
use of javax.swing.ActionMap in project vcell by virtualcell.
the class PDEPlotControlPanel method sliderUpDownBusyActions.
private void sliderUpDownBusyActions() {
// map KeyStroke to actionID (for WHEN_FOCUS condition)
InputMap im_focus = ivjJSliderTime.getInputMap();
// map actionID to Action
ActionMap am = ivjJSliderTime.getActionMap();
// Get actionID for DOWN-ARROW keystroke
Object downArrowActionID = im_focus.get(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0));
// Get actionID for UP-ARROW keystroke
Object upArrowActionID = im_focus.get(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0));
// remove any currently defined actions for up and down actionIDs
am.remove(downArrowActionID);
am.remove(upArrowActionID);
// redefine Actions of up and down arrows on JSlider
// If getPdeDataContext isBusy then ignore up and down arrow actions to avoid
// having the "wait" popup appear when using the up and down arrows on the JSlider
am.put(downArrowActionID, new AbstractAction() {
public void actionPerformed(ActionEvent e) {
if (ClientTaskDispatcher.isBusy(null, null)) {
return;
}
if (ivjJSliderTime.getValue() == ivjJSliderTime.getMaximum()) {
return;
}
if (arrowTimer == null) {
arrowTimer = new Timer(100, new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
synchronized (arrowTimer) {
PDEPlotControlPanel.this.arrowTimer.stop();
PDEPlotControlPanel.this.arrowTimer = null;
}
ivjJSliderTime.setValue(ivjJSliderTime.getValue() + 1);
}
});
arrowTimer.setRepeats(false);
arrowTimer.start();
} else {
return;
}
}
});
am.put(upArrowActionID, new AbstractAction() {
public void actionPerformed(ActionEvent e) {
if (ClientTaskDispatcher.isBusy(null, null)) {
return;
}
if (ivjJSliderTime.getValue() == ivjJSliderTime.getMinimum()) {
return;
}
if (arrowTimer == null) {
arrowTimer = new Timer(100, new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
synchronized (arrowTimer) {
PDEPlotControlPanel.this.arrowTimer.stop();
PDEPlotControlPanel.this.arrowTimer = null;
}
ivjJSliderTime.setValue(ivjJSliderTime.getValue() - 1);
}
});
arrowTimer.setRepeats(false);
arrowTimer.start();
} else {
return;
}
}
});
}
use of javax.swing.ActionMap in project vcell by virtualcell.
the class MultiPurposeTextPanel method getSearchTextField.
private JTextField getSearchTextField() {
if (searchTextField == null) {
try {
searchTextField = new JTextField();
searchTextField.setColumns(15);
searchTextFieldBackground = searchTextField.getBackground();
searchTextField.getDocument().addDocumentListener(eventHandler);
InputMap im = searchTextField.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
im.put(KeyStroke.getKeyStroke("ESCAPE"), CANCEL_ACTION);
ActionMap am = searchTextField.getActionMap();
am.put(CANCEL_ACTION, new CancelSearchAction());
} catch (java.lang.Throwable ivjExc) {
ivjExc.printStackTrace();
}
}
return searchTextField;
}
Aggregations