use of javax.swing.AbstractAction in project jmeter by apache.
the class RowDetailDialog method createRootPane.
@Override
protected JRootPane createRootPane() {
JRootPane rootPane = new JRootPane();
// Hide Window on ESC
Action escapeAction = new AbstractAction("ESCAPE") {
private static final long serialVersionUID = -8699034338969407625L;
@Override
public void actionPerformed(ActionEvent actionEvent) {
setVisible(false);
}
};
// Do update on Enter
Action enterAction = new AbstractAction("ENTER") {
private static final long serialVersionUID = -1529005452976176873L;
@Override
public void actionPerformed(ActionEvent actionEvent) {
doUpdate(actionEvent);
setVisible(false);
}
};
ActionMap actionMap = rootPane.getActionMap();
actionMap.put(escapeAction.getValue(Action.NAME), escapeAction);
actionMap.put(enterAction.getValue(Action.NAME), enterAction);
InputMap inputMap = rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
inputMap.put(KeyStrokes.ESC, escapeAction.getValue(Action.NAME));
inputMap.put(KeyStrokes.ENTER, enterAction.getValue(Action.NAME));
return rootPane;
}
use of javax.swing.AbstractAction in project jmeter by apache.
the class MainFrame method addQuickComponentHotkeys.
private void addQuickComponentHotkeys(JTree treevar) {
Action quickComponent = new AbstractAction("Quick Component") {
private static final long serialVersionUID = 1L;
@Override
public void actionPerformed(ActionEvent actionEvent) {
String propname = "gui.quick_" + actionEvent.getActionCommand();
String comp = JMeterUtils.getProperty(propname);
log.debug("Event {}: {}", propname, comp);
if (comp == null) {
log.warn("No component set through property: {}", propname);
return;
}
GuiPackage guiPackage = GuiPackage.getInstance();
try {
guiPackage.updateCurrentNode();
TestElement testElement = guiPackage.createTestElement(SaveService.aliasToClass(comp));
JMeterTreeNode parentNode = guiPackage.getCurrentNode();
while (!MenuFactory.canAddTo(parentNode, testElement)) {
parentNode = (JMeterTreeNode) parentNode.getParent();
}
if (parentNode.getParent() == null) {
log.debug("Cannot add element on very top level");
} else {
JMeterTreeNode node = guiPackage.getTreeModel().addComponent(testElement, parentNode);
guiPackage.getMainFrame().getTree().setSelectionPath(new TreePath(node.getPath()));
}
} catch (Exception err) {
// $NON-NLS-1$
log.warn("Failed to perform quick component add: {}", comp, err);
}
}
};
InputMap inputMap = treevar.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
KeyStroke[] keyStrokes = new KeyStroke[] { KeyStrokes.CTRL_0, KeyStrokes.CTRL_1, KeyStrokes.CTRL_2, KeyStrokes.CTRL_3, KeyStrokes.CTRL_4, KeyStrokes.CTRL_5, KeyStrokes.CTRL_6, KeyStrokes.CTRL_7, KeyStrokes.CTRL_8, KeyStrokes.CTRL_9 };
for (int n = 0; n < keyStrokes.length; n++) {
treevar.getActionMap().put(ActionNames.QUICK_COMPONENT + String.valueOf(n), quickComponent);
inputMap.put(keyStrokes[n], ActionNames.QUICK_COMPONENT + String.valueOf(n));
}
}
use of javax.swing.AbstractAction in project jmeter by apache.
the class SavePropertyDialog method createRootPane.
@Override
protected JRootPane createRootPane() {
JRootPane rootPane = new JRootPane();
Action escapeAction = new AbstractAction("ESCAPE") {
/**
*
*/
private static final long serialVersionUID = 2208129319916921772L;
@Override
public void actionPerformed(ActionEvent e) {
setVisible(false);
}
};
InputMap inputMap = rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
inputMap.put(KeyStrokes.ESC, escapeAction.getValue(Action.NAME));
rootPane.getActionMap().put(escapeAction.getValue(Action.NAME), escapeAction);
return rootPane;
}
use of javax.swing.AbstractAction in project JMRI by JMRI.
the class PanelProPane method statusPanel.
@Override
protected JPanel statusPanel() {
JPanel j = new JPanel();
j.setLayout(new BoxLayout(j, BoxLayout.Y_AXIS));
j.add(super.statusPanel());
// Buttons
Action quit = new AbstractAction(Bundle.getMessage("MenuItemQuit")) {
@Override
public void actionPerformed(ActionEvent e) {
Apps.handleQuit();
}
};
JPanel p3 = new JPanel();
p3.setLayout(new java.awt.FlowLayout());
JButton h1 = new JButton(Bundle.getMessage("ButtonHelp"));
jmri.util.HelpUtil.addHelpToComponent(h1, "html.apps.PanelPro.PanelPro");
h1.setAlignmentX(JLabel.CENTER_ALIGNMENT);
p3.add(h1);
JButton q1 = new JButton(Bundle.getMessage("ButtonQuit"));
q1.addActionListener(quit);
q1.setAlignmentX(JLabel.CENTER_ALIGNMENT);
p3.add(q1);
j.add(p3);
return j;
}
use of javax.swing.AbstractAction in project JMRI by JMRI.
the class PanelPro method statusPanel.
@Override
protected JPanel statusPanel() {
JPanel j = new JPanel();
j.setLayout(new BoxLayout(j, BoxLayout.Y_AXIS));
j.add(super.statusPanel());
// Buttons
Action quit = new AbstractAction(Bundle.getMessage("MenuItemQuit")) {
@Override
public void actionPerformed(ActionEvent e) {
Apps.handleQuit();
}
};
JPanel p3 = new JPanel();
p3.setLayout(new java.awt.FlowLayout());
JButton h1 = new JButton(Bundle.getMessage("ButtonHelp"));
jmri.util.HelpUtil.addHelpToComponent(h1, "html.apps.PanelPro.PanelPro");
h1.setAlignmentX(JLabel.CENTER_ALIGNMENT);
p3.add(h1);
JButton q1 = new JButton(Bundle.getMessage("ButtonQuit"));
q1.addActionListener(quit);
q1.setAlignmentX(JLabel.CENTER_ALIGNMENT);
p3.add(q1);
j.add(p3);
return j;
}
Aggregations