use of pt.up.fe.specs.util.swing.GenericActionListener in project lara-framework by specs-feup.
the class EditorToolBar method addExecButton.
private JButton addExecButton() {
execButton = new JButton();
setIcon(execButton, "run", EditorToolBar.RUN_LARA_TEXT);
// try {
// Image img = ImageIO.read(IoUtils.resourceToStream("larai/resources/img/cancel.gif"));
// execButton.setSelectedIcon(new ImageIcon(img));
// } catch (Exception ex) {
// }
running = false;
// execButton.setSelected(false);
// execButton.setMnemonic(StrokesAndActions.F11);
Consumer<ActionEvent> listener = e -> {
if (!running) {
// if (execButton.isSelected()) {
editor.execute();
// setIcon(newItem, "run", "Run LARA");
} else {
// setIcon(newItem, "cancel", "Cancel");
editor.cancelExecution();
}
};
execButton.addActionListener(new GenericActionListener(listener));
String replace = StrokesAndActions.prettyString(StrokesAndActions.F11);
execButton.setToolTipText(EditorToolBar.RUN_LARA_TEXT + " (" + replace + ")");
execButton.registerKeyboardAction(new GenericActionListener(listener), StrokesAndActions.F11, JComponent.WHEN_IN_FOCUSED_WINDOW);
// ListenerUtils.mapAction(newItem, stroke, actionName,
// listener);
execButton.addFocusListener(new FocusGainedListener(e -> getCurrentTab().requestFocus()));
toolBar.add(execButton);
return execButton;
}
use of pt.up.fe.specs.util.swing.GenericActionListener in project lara-framework by specs-feup.
the class EditorToolBar method addNewItem.
private JButton addNewItem(String toolTip, String icon, int keyEvent, KeyStroke stroke, Consumer<ActionEvent> listener) {
JButton newItem = new JButton();
try {
Image img = ImageIO.read(SpecsIo.resourceToStream("larai/resources/img/" + icon + ".gif"));
newItem.setIcon(new ImageIcon(img));
} catch (Exception ex) {
newItem.setText(toolTip);
}
// newItem.setMnemonic(keyEvent);
newItem.addActionListener(new GenericActionListener(listener));
newItem.setToolTipText(toolTip);
if (stroke != null) {
String replace = StrokesAndActions.prettyString(stroke);
newItem.setToolTipText(toolTip + " (" + replace + ")");
newItem.registerKeyboardAction(new GenericActionListener(listener), stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);
// ListenerUtils.mapAction(newItem, stroke, actionName,
// listener);
}
newItem.addFocusListener(new FocusGainedListener(e -> getCurrentTab().requestFocus()));
toolBar.add(newItem);
return newItem;
}
use of pt.up.fe.specs.util.swing.GenericActionListener in project lara-framework by specs-feup.
the class ExplorerPopup method newItem.
private JMenuItem newItem(String name, Consumer<ActionEvent> listener) {
JMenuItem newItem = new JMenuItem(name);
// newItem.setMnemonic(keyEvent);
newItem.addActionListener(new GenericActionListener(listener));
return add(newItem);
}
use of pt.up.fe.specs.util.swing.GenericActionListener in project lara-framework by specs-feup.
the class LanguageSpecificationSideBar method initJoinPoints.
private void initJoinPoints() {
joinPoints.addItem(langSpec.getGlobal());
for (JoinPointClass joinPoint : langSpec.getJoinPoints().values()) {
joinPoints.addItem(joinPoint);
}
joinPoints.addActionListener(new GenericActionListener(e -> updateJPInfo((JoinPointClass) joinPoints.getSelectedItem())));
}
use of pt.up.fe.specs.util.swing.GenericActionListener in project lara-framework by specs-feup.
the class LanguageSpecificationSideBar method initExtends.
private void initExtends() {
JLabel jLabel = new JLabel("Extends: ");
extendsButton = new JButton("N/A");
extendsButton.setContentAreaFilled(false);
extendsButton.setBorder(BorderFactory.createEtchedBorder());
extendsButton.addActionListener(new GenericActionListener(e -> {
if (currentExtend != null) {
joinPoints.setSelectedItem(currentExtend);
}
}));
extendsPanel.add(jLabel);
extendsPanel.add(extendsButton);
joinPointPanel.add(extendsPanel, BorderLayout.EAST);
// rootPanel.setPreferredSize(new Dimension(50, 50));
}
Aggregations