Search in sources :

Example 1 with FocusGainedListener

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;
}
Also used : SearchContext(org.fife.ui.rtextarea.SearchContext) LaraCli(org.lara.interpreter.cli.LaraCli) ItemListener(java.awt.event.ItemListener) SearchEngine(org.fife.ui.rtextarea.SearchEngine) EditorPanel(org.lara.interpreter.joptions.panels.editor.EditorPanel) DataStore(org.suikasoft.jOptions.Interfaces.DataStore) ImageIO(javax.imageio.ImageIO) ImageIcon(javax.swing.ImageIcon) BorderLayout(java.awt.BorderLayout) JComboBox(javax.swing.JComboBox) HeapBar(pt.up.fe.specs.util.utilities.heapwindow.HeapBar) AppKeys(org.suikasoft.jOptions.gui.panels.app.AppKeys) JComponent(javax.swing.JComponent) KeyStroke(javax.swing.KeyStroke) ItemEvent(java.awt.event.ItemEvent) JToolBar(javax.swing.JToolBar) JButton(javax.swing.JButton) SpecsIo(pt.up.fe.specs.util.SpecsIo) Image(java.awt.Image) RTextArea(org.fife.ui.rtextarea.RTextArea) TabsContainerPanel(org.lara.interpreter.joptions.panels.editor.tabbed.TabsContainerPanel) FocusGainedListener(org.lara.interpreter.joptions.panels.editor.listeners.FocusGainedListener) StrokesAndActions(org.lara.interpreter.joptions.panels.editor.listeners.StrokesAndActions) KeyEvent(java.awt.event.KeyEvent) JOptionPane(javax.swing.JOptionPane) ActionEvent(java.awt.event.ActionEvent) File(java.io.File) Consumer(java.util.function.Consumer) Dimension(java.awt.Dimension) JLabel(javax.swing.JLabel) JTextArea(javax.swing.JTextArea) SourceTextArea(org.lara.interpreter.joptions.panels.editor.tabbed.SourceTextArea) JPanel(javax.swing.JPanel) GenericActionListener(pt.up.fe.specs.util.swing.GenericActionListener) FocusGainedListener(org.lara.interpreter.joptions.panels.editor.listeners.FocusGainedListener) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) GenericActionListener(pt.up.fe.specs.util.swing.GenericActionListener)

Example 2 with FocusGainedListener

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;
}
Also used : SearchContext(org.fife.ui.rtextarea.SearchContext) LaraCli(org.lara.interpreter.cli.LaraCli) ItemListener(java.awt.event.ItemListener) SearchEngine(org.fife.ui.rtextarea.SearchEngine) EditorPanel(org.lara.interpreter.joptions.panels.editor.EditorPanel) DataStore(org.suikasoft.jOptions.Interfaces.DataStore) ImageIO(javax.imageio.ImageIO) ImageIcon(javax.swing.ImageIcon) BorderLayout(java.awt.BorderLayout) JComboBox(javax.swing.JComboBox) HeapBar(pt.up.fe.specs.util.utilities.heapwindow.HeapBar) AppKeys(org.suikasoft.jOptions.gui.panels.app.AppKeys) JComponent(javax.swing.JComponent) KeyStroke(javax.swing.KeyStroke) ItemEvent(java.awt.event.ItemEvent) JToolBar(javax.swing.JToolBar) JButton(javax.swing.JButton) SpecsIo(pt.up.fe.specs.util.SpecsIo) Image(java.awt.Image) RTextArea(org.fife.ui.rtextarea.RTextArea) TabsContainerPanel(org.lara.interpreter.joptions.panels.editor.tabbed.TabsContainerPanel) FocusGainedListener(org.lara.interpreter.joptions.panels.editor.listeners.FocusGainedListener) StrokesAndActions(org.lara.interpreter.joptions.panels.editor.listeners.StrokesAndActions) KeyEvent(java.awt.event.KeyEvent) JOptionPane(javax.swing.JOptionPane) ActionEvent(java.awt.event.ActionEvent) File(java.io.File) Consumer(java.util.function.Consumer) Dimension(java.awt.Dimension) JLabel(javax.swing.JLabel) JTextArea(javax.swing.JTextArea) SourceTextArea(org.lara.interpreter.joptions.panels.editor.tabbed.SourceTextArea) JPanel(javax.swing.JPanel) GenericActionListener(pt.up.fe.specs.util.swing.GenericActionListener) ImageIcon(javax.swing.ImageIcon) FocusGainedListener(org.lara.interpreter.joptions.panels.editor.listeners.FocusGainedListener) JButton(javax.swing.JButton) GenericActionListener(pt.up.fe.specs.util.swing.GenericActionListener) Image(java.awt.Image)

Example 3 with FocusGainedListener

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;
}
Also used : SearchContext(org.fife.ui.rtextarea.SearchContext) LaraCli(org.lara.interpreter.cli.LaraCli) ItemListener(java.awt.event.ItemListener) SearchEngine(org.fife.ui.rtextarea.SearchEngine) EditorPanel(org.lara.interpreter.joptions.panels.editor.EditorPanel) DataStore(org.suikasoft.jOptions.Interfaces.DataStore) ImageIO(javax.imageio.ImageIO) ImageIcon(javax.swing.ImageIcon) BorderLayout(java.awt.BorderLayout) JComboBox(javax.swing.JComboBox) HeapBar(pt.up.fe.specs.util.utilities.heapwindow.HeapBar) AppKeys(org.suikasoft.jOptions.gui.panels.app.AppKeys) JComponent(javax.swing.JComponent) KeyStroke(javax.swing.KeyStroke) ItemEvent(java.awt.event.ItemEvent) JToolBar(javax.swing.JToolBar) JButton(javax.swing.JButton) SpecsIo(pt.up.fe.specs.util.SpecsIo) Image(java.awt.Image) RTextArea(org.fife.ui.rtextarea.RTextArea) TabsContainerPanel(org.lara.interpreter.joptions.panels.editor.tabbed.TabsContainerPanel) FocusGainedListener(org.lara.interpreter.joptions.panels.editor.listeners.FocusGainedListener) StrokesAndActions(org.lara.interpreter.joptions.panels.editor.listeners.StrokesAndActions) KeyEvent(java.awt.event.KeyEvent) JOptionPane(javax.swing.JOptionPane) ActionEvent(java.awt.event.ActionEvent) File(java.io.File) Consumer(java.util.function.Consumer) Dimension(java.awt.Dimension) JLabel(javax.swing.JLabel) JTextArea(javax.swing.JTextArea) SourceTextArea(org.lara.interpreter.joptions.panels.editor.tabbed.SourceTextArea) JPanel(javax.swing.JPanel) GenericActionListener(pt.up.fe.specs.util.swing.GenericActionListener) FocusGainedListener(org.lara.interpreter.joptions.panels.editor.listeners.FocusGainedListener) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) GenericActionListener(pt.up.fe.specs.util.swing.GenericActionListener)

Example 4 with FocusGainedListener

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;
}
Also used : SearchContext(org.fife.ui.rtextarea.SearchContext) LaraCli(org.lara.interpreter.cli.LaraCli) ItemListener(java.awt.event.ItemListener) SearchEngine(org.fife.ui.rtextarea.SearchEngine) EditorPanel(org.lara.interpreter.joptions.panels.editor.EditorPanel) DataStore(org.suikasoft.jOptions.Interfaces.DataStore) ImageIO(javax.imageio.ImageIO) ImageIcon(javax.swing.ImageIcon) BorderLayout(java.awt.BorderLayout) JComboBox(javax.swing.JComboBox) HeapBar(pt.up.fe.specs.util.utilities.heapwindow.HeapBar) AppKeys(org.suikasoft.jOptions.gui.panels.app.AppKeys) JComponent(javax.swing.JComponent) KeyStroke(javax.swing.KeyStroke) ItemEvent(java.awt.event.ItemEvent) JToolBar(javax.swing.JToolBar) JButton(javax.swing.JButton) SpecsIo(pt.up.fe.specs.util.SpecsIo) Image(java.awt.Image) RTextArea(org.fife.ui.rtextarea.RTextArea) TabsContainerPanel(org.lara.interpreter.joptions.panels.editor.tabbed.TabsContainerPanel) FocusGainedListener(org.lara.interpreter.joptions.panels.editor.listeners.FocusGainedListener) StrokesAndActions(org.lara.interpreter.joptions.panels.editor.listeners.StrokesAndActions) KeyEvent(java.awt.event.KeyEvent) JOptionPane(javax.swing.JOptionPane) ActionEvent(java.awt.event.ActionEvent) File(java.io.File) Consumer(java.util.function.Consumer) Dimension(java.awt.Dimension) JLabel(javax.swing.JLabel) JTextArea(javax.swing.JTextArea) SourceTextArea(org.lara.interpreter.joptions.panels.editor.tabbed.SourceTextArea) JPanel(javax.swing.JPanel) GenericActionListener(pt.up.fe.specs.util.swing.GenericActionListener) FocusGainedListener(org.lara.interpreter.joptions.panels.editor.listeners.FocusGainedListener) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) GenericActionListener(pt.up.fe.specs.util.swing.GenericActionListener)

Aggregations

BorderLayout (java.awt.BorderLayout)4 Dimension (java.awt.Dimension)4 Image (java.awt.Image)4 ActionEvent (java.awt.event.ActionEvent)4 ItemEvent (java.awt.event.ItemEvent)4 ItemListener (java.awt.event.ItemListener)4 KeyEvent (java.awt.event.KeyEvent)4 File (java.io.File)4 Consumer (java.util.function.Consumer)4 ImageIO (javax.imageio.ImageIO)4 ImageIcon (javax.swing.ImageIcon)4 JButton (javax.swing.JButton)4 JComboBox (javax.swing.JComboBox)4 JComponent (javax.swing.JComponent)4 JLabel (javax.swing.JLabel)4 JOptionPane (javax.swing.JOptionPane)4 JPanel (javax.swing.JPanel)4 JTextArea (javax.swing.JTextArea)4 JToolBar (javax.swing.JToolBar)4 KeyStroke (javax.swing.KeyStroke)4