2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2009 - DIGITEO - Bruno JOFRET
5 * This file must be used under the terms of the CeCILL.
6 * This source file is licensed as described in the file COPYING, which
7 * you should have received as part of this distribution. The terms
8 * are also available at
9 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
13 package org.scilab.modules.scinotes.actions;
15 import javax.swing.KeyStroke;
17 import org.scilab.modules.gui.console.ScilabConsole;
18 import org.scilab.modules.gui.menuitem.MenuItem;
19 import org.scilab.modules.scinotes.SciNotes;
20 import org.scilab.modules.scinotes.utils.SciNotesMessages;
21 import org.scilab.modules.scinotes.ScilabEditorPane;
24 * EvaluateSelectionAction class
25 * @author Bruno JOFRET
28 public final class EvaluateSelectionAction extends DefaultAction {
33 private static final long serialVersionUID = 320938663765236236L;
37 * @param editor SciNotes
39 private EvaluateSelectionAction(SciNotes editor) {
40 super(SciNotesMessages.EVALUATE_SELECTION, editor);
46 public void doAction() {
47 /* Will do the job as if it was copy / paste in scilab Console */
48 ScilabEditorPane sep = (ScilabEditorPane) getEditor().getTextPane();
49 String selection = sep.getCodeToExecute();
50 if (selection.compareTo("") != 0) {
51 ScilabConsole.getConsole().getAsSimpleConsole().sendCommandsToScilab(selection, true, false);
57 * @param editor scinotes
58 * @param key KeyStroke
61 public static MenuItem createMenu(SciNotes editor, KeyStroke key) {
62 return createMenu(SciNotesMessages.EVALUATE_SELECTION, null, new EvaluateSelectionAction(editor), key);