use of org.lara.interpreter.joptions.panels.editor.listeners.FocusGainedListener 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 org.lara.interpreter.joptions.panels.editor.listeners.FocusGainedListener 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 org.lara.interpreter.joptions.panels.editor.listeners.FocusGainedListener in project lara-framework by specs-feup.
the class EditorToolBar method addTestButton.
private JButton addTestButton() {
testButton = new JButton();
setIcon(testButton, "test", EditorToolBar.RUN_LARA_TEXT);
running = false;
Consumer<ActionEvent> listener = e -> {
if (!running) {
editor.test();
;
} else {
editor.cancelExecution();
}
};
testButton.addActionListener(new GenericActionListener(listener));
// String replace = StrokesAndActions.prettyString(StrokesAndActions.F11);
// testButton.setToolTipText(EditorToolBar.TEST_LARA_TEXT + " (" + replace + ")");
testButton.setToolTipText(EditorToolBar.TEST_LARA_TEXT);
// testButton.registerKeyboardAction(new GenericActionListener(listener), StrokesAndActions.F11,
// JComponent.WHEN_IN_FOCUSED_WINDOW);
testButton.addFocusListener(new FocusGainedListener(e -> getCurrentTab().requestFocus()));
toolBar.add(testButton);
return testButton;
}
use of org.lara.interpreter.joptions.panels.editor.listeners.FocusGainedListener in project lara-framework by specs-feup.
the class EditorToolBar method addDebugButton.
private JButton addDebugButton() {
debugButton = new JButton();
setIcon(debugButton, "debug", EditorToolBar.DEBUG_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.runDebug();
// setIcon(newItem, "run", "Run LARA");
} else {
// setIcon(newItem, "cancel", "Cancel");
editor.cancelExecution();
}
};
debugButton.addActionListener(new GenericActionListener(listener));
String replace = StrokesAndActions.prettyString(StrokesAndActions.CTRL_F11);
debugButton.setToolTipText(EditorToolBar.RUN_LARA_IN_DEBUG_MODE_TEXT + " (" + replace + ")");
debugButton.registerKeyboardAction(new GenericActionListener(listener), StrokesAndActions.CTRL_F11, JComponent.WHEN_IN_FOCUSED_WINDOW);
// ListenerUtils.mapAction(newItem, stroke, actionName,
// listener);
debugButton.addFocusListener(new FocusGainedListener(e -> getCurrentTab().requestFocus()));
toolBar.add(debugButton);
return debugButton;
}
Aggregations