Add an item in Scinotes menubar/toolbar to launch preferences/help 18/9118/2
Vincent COUVERT [Mon, 24 Sep 2012 11:02:58 +0000 (13:02 +0200)]
Change-Id: Ib1cb1c5f9a5444f73f223609b0624272a7e3fbab

scilab/modules/console/etc/Actions-Configuration.xml
scilab/modules/scinotes/etc/scinotesGUIConfiguration.xml
scilab/modules/scinotes/src/java/org/scilab/modules/scinotes/actions/GeneralSettingsAction.java [new file with mode: 0644]
scilab/modules/scinotes/src/java/org/scilab/modules/scinotes/actions/HelpAction.java

index 7f678ec..60fcf50 100644 (file)
 <?xml version="1.0" encoding="UTF-8"?>
 <!-- Map between action names and Java or Scilab action -->
 <map>
-  <scinotes>
-    <entry type="java" action="ActivateHelpOnTypingForOpenersAction" name="scinotes-autocomplete-openers"/>
-    <entry type="java" action="ActivateHelpOnTypingForKeywordsAction" name="scinotes-autocomplete-keyword"/>
-    <entry type="java" action="GenerateHelpFromFunctionAction" name="scinotes-help-prototype"/>
-    <entry type="java" action="TabifyAction" name="scinotes-tabify"/>
-    <entry type="java" action="UnTabifyAction" name="scinotes-untabify"/>
-    <entry type="java" action="IndentAction" name="scinotes-indent"/>
-    <entry type="java" action="CommentAction" name="scinotes-comment"/>
-    <entry type="java" action="UnCommentAction" name="scinotes-uncomment"/>
-    <entry type="java" action="RemoveTrailingWhiteAction" name="scinotes-remove-whites"/>
-    <entry type="java" action="SelectAllAction" name="scinotes-select-all"/>
-    <entry type="java" action="SelectBlockAction" name="scinotes-select-block"/>
-    <entry type="java" action="OpenTabInNewWindowAction" name="scinotes-clone-current"/>
-    <entry type="java" action="CCloseTabInNewWindowAction" name="scinotes-export-current"/>
-    <entry type="java" action="CopyAsHTMLAction" name="scinotes-copy"/>
-    <entry type="java" action="CutAction" name="scinotes-cut"/>
-    <entry type="java" action="PasteAction" name="scinotes-paste"/>
-    <entry type="java" action="PasteColumnAction" name="scinotes-paste-column"/>
-    <entry type="java" action="RepeatSelectionOnColumnAction" name="scinotes-repeat-column"/>
-    <entry type="java" action="UndoAction" name="scinotes-undo"/>
-    <entry type="java" action="RedoAction" name="scinotes-redo"/>
-    <entry type="java" action="CopyAsHTMLWithLineNumberAction" name="scinotes-copy-with-lines"/>
-    <entry type="java" action="NewAction" name="scinotes-new"/>
-    <entry type="java" action="OpenAction" name="scinotes-open"/>
-    <entry type="java" action="OpenURLAction" name="scinotes-open-url"/>
-    <entry type="java" action="OpenSourceFileOnKeywordAction" name="scinotes-open-source"/>
-    <entry type="java" action="SaveAction" name="scinotes-save"/>
-    <entry type="java" action="SaveAsAction" name="scinotes-save-as"/>
-    <entry type="java" action="ReloadAction" name="scinotes-reload"/>
-    <entry type="java" action="PrintPreviewAction" name="scinotes-print-preview"/>
-    <entry type="java" action="PrintAction" name="scinotes-print"/>
-    <entry type="java" action="CloseAction" name="scinotes-close"/>
-    <entry type="java" action="ExitAction" name="scinotes-exit"/>
-    <entry type="java" action="ToLowerCaseAction" name="scinotes-tolowercase"/>
-    <entry type="java" action="ToUpperCaseAction" name="scinotes-touppercase"/>
-    <entry type="java" action="CapitalizeAction" name="scinotes-capitalize"/>
-    <entry type="java" action="HelpOnKeywordAction" name="scinotes-help-keyword"/>
-    <entry type="java" action="LoadIntoScilabAction" name="scinotes-load-scilab"/>
-    <entry type="java" action="ExecuteFileIntoScilabAction" name="scinotes-execute-scilab"/>
-    <entry type="java" action="EvaluateSelectionAction" name="scinotes-evaluate-selection"/>
-    <entry type="java" action="SaveAndExecuteFileAction" name="scinotes-save-execute"/>
-    <entry type="java" action="SaveAndExecuteAllFilesAction" name="scinotes-save-execute-all"/>
-    <entry type="java" action="FindAction" name="scinotes-find"/>
-    <entry type="java" action="FindNextAction" name="scinotes-find-next"/>
-    <entry type="java" action="FindPreviousAction" name="scinotes-find-previous"/>
-    <entry type="java" action="IncrementalSearchAction" name="scinotes-incremental-search"/>
-    <entry type="java" action="SetAnchorAction" name="scinotes-set-anchor"/>
-    <entry type="java" action="RemoveAnchorAction" name="scinotes-remove-anchor"/>
-    <entry type="java" action="GotoNextAnchorAction" name="scinotes-next-anchor"/>
-    <entry type="java" action="GotoPreviousAnchorAction" name="scinotes-previous-anchor"/>
-    <entry type="java" action="CodeNavigatorAction" name="scinotes-code-navigator"/>
-    <entry type="java" action="SearchWordInFilesAction" name="scinotes-word-file"/>
-    <entry type="java" action="SearchFilesAction" name="scinotes-search-files"/>
-    <entry type="java" action="SciNotesCompletionAction" name="scinotes-completion"/>
-    <entry type="java" action="HelpAction" name="scinotes-help"/>
-    <entry type="java" action="AboutAction" name="scinotes-about"/>
-    <entry type="java" action="NextTabAction" name="scinotes-next-tab"/>
-    <entry type="java" action="PreviousTabAction" name="scinotes-previous-tab"/>
-    <entry type="java" action="DeleteAction" name="scinotes-delete"/>
-    <entry type="java" action="NextParagraphAction" name="scinotes-next-paragraph"/>
-    <entry type="java" action="PreviousParagraphAction" name="scinotes-previous-paragraph"/>
-    <entry type="java" action="SaveAllAction" name="scinotes-save-all"/>
-    <entry type="java" action="OverwriteAction" name="scinotes-overwrite"/>
-    <entry type="java" action="PageSetupAction" name="scinotes-page-setup"/>
-    <entry type="java" action="CloseAllAction" name="scinotes-close-all"/>
-    <entry type="java" action="CloseAllButThisAction" name="scinotes-close-all-but"/>
-    <entry type="java" action="DoubleQuoteStringAction" name="scinotes-double-quote"/>
-    <entry type="java" action="LineNumbersAction" name="scinotes-line-numbering"/>
-    <entry type="java" action="RecentFileAction" name="scinotes-recent"/>
-    <entry type="java" action="RegisterFavoriteDirsAction" name="scinotes-register-favorite-dir"/>
-    <entry type="java" action="OpenFileInAction" name="scinotes-open-file-in"/>
-    <entry type="java" action="SaveFileInAction" name="scinotes-save-file-in"/>
-    <entry type="java" action="RestoreOpenedFilesAction" name="scinotes-restore-startup"/>
-    <entry type="java" action="ExportAction" name="scinotes-export"/>
-    <entry type="java" action="EncodingAction" name="scinotes-encoding"/>
-    <entry type="java" action="EndOfLineAction" name="scinotes-eof"/>
-    <entry type="java" action="CopySelectionInNewTabAction" name="scinotes-selection-new-tab"/>
-    <entry type="java" action="SplitAction" name="scinotes-split"/>
-    <entry type="java" action="HelpOnKeywordInPopupAction" name="scinotes-help-keyword-popup"/>
-    <entry type="java" action="SetFontAction" name="scinotes-set-font"/>
-    <entry type="java" action="SetColorsAction" name="scinotes-set-colors"/>
-  </scinotes>
-  <console>
-    <entry type="java" action="org.scilab.modules.console.SelectAllAction" name="console-select-all"/>
-    <entry type="java" action="org.scilab.modules.console.ClearConsoleAction" name="console-clear"/>
-    <entry type="java" action="org.scilab.modules.console.ConsoleboxAction" name="console-box"/>
-    <entry type="java" action="org.scilab.modules.console.HelpAction" name="console-help-browser"/>
-    <entry type="java" action="org.scilab.modules.console.ValidationAction" name="console-enter"/>
-    <entry type="java" action="org.scilab.modules.console.CompletionAction" name="console-completion"/>
-    <entry type="java" action="org.scilab.modules.console.LineBeginningAction" name="console-line-begin"/>
-    <entry type="java" action="org.scilab.modules.console.GetPreviousAction" name="console-prev-history"/>
-    <entry type="java" action="org.scilab.modules.console.GetNextAction" name="console-next-history"/>
-    <entry type="java" action="org.scilab.modules.console.LineEndAction" name="console-line-end"/>
-    <entry type="java" action="org.scilab.modules.console.PreviousCharAction" name="console-prev-char"/>
-    <entry type="java" action="org.scilab.modules.console.NextCharAction" name="console-next-char"/>
-    <entry type="java" action="org.scilab.modules.console.DelPreviousCharAction" name="console-del-prev-char"/>
-    <entry type="java" action="org.scilab.modules.console.DelNextCharAction" name="console-del-next-char"/>
-    <entry type="java" action="org.scilab.modules.console.DelLastWordAction" name="console-del-last-word"/>
-    <entry type="java" action="org.scilab.modules.console.DelEndOfLineAction" name="console-del-end-line"/>
-    <entry type="java" action="org.scilab.modules.console.DelWholeLineAction" name="console-del-whole-line"/>
-    <entry type="java" action="org.scilab.modules.console.InterruptScilabWorkOrCut" name="console-cut-or-interrupt"/>
-    <entry type="java" action="org.scilab.modules.console.InterruptScilabWorkOrCopy" name="console-copy-or-interrupt"/>
-    <entry type="java" action="org.scilab.modules.console.PageUpAction" name="console-prev-page"/>
-    <entry type="java" action="org.scilab.modules.console.PageDownAction" name="console-next-page"/>
-  </console>
+    <scinotes>
+        <entry type="java" action="ActivateHelpOnTypingForOpenersAction" name="scinotes-autocomplete-openers"/>
+        <entry type="java" action="ActivateHelpOnTypingForKeywordsAction" name="scinotes-autocomplete-keyword"/>
+        <entry type="java" action="GenerateHelpFromFunctionAction" name="scinotes-help-prototype"/>
+        <entry type="java" action="TabifyAction" name="scinotes-tabify"/>
+        <entry type="java" action="UnTabifyAction" name="scinotes-untabify"/>
+        <entry type="java" action="IndentAction" name="scinotes-indent"/>
+        <entry type="java" action="CommentAction" name="scinotes-comment"/>
+        <entry type="java" action="UnCommentAction" name="scinotes-uncomment"/>
+        <entry type="java" action="RemoveTrailingWhiteAction" name="scinotes-remove-whites"/>
+        <entry type="java" action="SelectAllAction" name="scinotes-select-all"/>
+        <entry type="java" action="SelectBlockAction" name="scinotes-select-block"/>
+        <entry type="java" action="OpenTabInNewWindowAction" name="scinotes-clone-current"/>
+        <entry type="java" action="CCloseTabInNewWindowAction" name="scinotes-export-current"/>
+        <entry type="java" action="CopyAsHTMLAction" name="scinotes-copy"/>
+        <entry type="java" action="CutAction" name="scinotes-cut"/>
+        <entry type="java" action="PasteAction" name="scinotes-paste"/>
+        <entry type="java" action="PasteColumnAction" name="scinotes-paste-column"/>
+        <entry type="java" action="RepeatSelectionOnColumnAction" name="scinotes-repeat-column"/>
+        <entry type="java" action="UndoAction" name="scinotes-undo"/>
+        <entry type="java" action="RedoAction" name="scinotes-redo"/>
+        <entry type="java" action="CopyAsHTMLWithLineNumberAction" name="scinotes-copy-with-lines"/>
+        <entry type="java" action="NewAction" name="scinotes-new"/>
+        <entry type="java" action="OpenAction" name="scinotes-open"/>
+        <entry type="java" action="OpenURLAction" name="scinotes-open-url"/>
+        <entry type="java" action="OpenSourceFileOnKeywordAction" name="scinotes-open-source"/>
+        <entry type="java" action="SaveAction" name="scinotes-save"/>
+        <entry type="java" action="SaveAsAction" name="scinotes-save-as"/>
+        <entry type="java" action="ReloadAction" name="scinotes-reload"/>
+        <entry type="java" action="PrintPreviewAction" name="scinotes-print-preview"/>
+        <entry type="java" action="PrintAction" name="scinotes-print"/>
+        <entry type="java" action="CloseAction" name="scinotes-close"/>
+        <entry type="java" action="ExitAction" name="scinotes-exit"/>
+        <entry type="java" action="ToLowerCaseAction" name="scinotes-tolowercase"/>
+        <entry type="java" action="ToUpperCaseAction" name="scinotes-touppercase"/>
+        <entry type="java" action="CapitalizeAction" name="scinotes-capitalize"/>
+        <entry type="java" action="HelpOnKeywordAction" name="scinotes-help-keyword"/>
+        <entry type="java" action="LoadIntoScilabAction" name="scinotes-load-scilab"/>
+        <entry type="java" action="ExecuteFileIntoScilabAction" name="scinotes-execute-scilab"/>
+        <entry type="java" action="EvaluateSelectionAction" name="scinotes-evaluate-selection"/>
+        <entry type="java" action="SaveAndExecuteFileAction" name="scinotes-save-execute"/>
+        <entry type="java" action="SaveAndExecuteAllFilesAction" name="scinotes-save-execute-all"/>
+        <entry type="java" action="FindAction" name="scinotes-find"/>
+        <entry type="java" action="FindNextAction" name="scinotes-find-next"/>
+        <entry type="java" action="FindPreviousAction" name="scinotes-find-previous"/>
+        <entry type="java" action="IncrementalSearchAction" name="scinotes-incremental-search"/>
+        <entry type="java" action="SetAnchorAction" name="scinotes-set-anchor"/>
+        <entry type="java" action="RemoveAnchorAction" name="scinotes-remove-anchor"/>
+        <entry type="java" action="GotoNextAnchorAction" name="scinotes-next-anchor"/>
+        <entry type="java" action="GotoPreviousAnchorAction" name="scinotes-previous-anchor"/>
+        <entry type="java" action="CodeNavigatorAction" name="scinotes-code-navigator"/>
+        <entry type="java" action="SearchWordInFilesAction" name="scinotes-word-file"/>
+        <entry type="java" action="SearchFilesAction" name="scinotes-search-files"/>
+        <entry type="java" action="SciNotesCompletionAction" name="scinotes-completion"/>
+        <entry type="java" action="HelpAction" name="scinotes-help"/>
+        <entry type="java" action="AboutAction" name="scinotes-about"/>
+        <entry type="java" action="NextTabAction" name="scinotes-next-tab"/>
+        <entry type="java" action="PreviousTabAction" name="scinotes-previous-tab"/>
+        <entry type="java" action="DeleteAction" name="scinotes-delete"/>
+        <entry type="java" action="NextParagraphAction" name="scinotes-next-paragraph"/>
+        <entry type="java" action="PreviousParagraphAction" name="scinotes-previous-paragraph"/>
+        <entry type="java" action="SaveAllAction" name="scinotes-save-all"/>
+        <entry type="java" action="OverwriteAction" name="scinotes-overwrite"/>
+        <entry type="java" action="PageSetupAction" name="scinotes-page-setup"/>
+        <entry type="java" action="CloseAllAction" name="scinotes-close-all"/>
+        <entry type="java" action="CloseAllButThisAction" name="scinotes-close-all-but"/>
+        <entry type="java" action="DoubleQuoteStringAction" name="scinotes-double-quote"/>
+        <entry type="java" action="LineNumbersAction" name="scinotes-line-numbering"/>
+        <entry type="java" action="RecentFileAction" name="scinotes-recent"/>
+        <entry type="java" action="RegisterFavoriteDirsAction" name="scinotes-register-favorite-dir"/>
+        <entry type="java" action="OpenFileInAction" name="scinotes-open-file-in"/>
+        <entry type="java" action="SaveFileInAction" name="scinotes-save-file-in"/>
+        <entry type="java" action="RestoreOpenedFilesAction" name="scinotes-restore-startup"/>
+        <entry type="java" action="ExportAction" name="scinotes-export"/>
+        <entry type="java" action="EncodingAction" name="scinotes-encoding"/>
+        <entry type="java" action="EndOfLineAction" name="scinotes-eof"/>
+        <entry type="java" action="CopySelectionInNewTabAction" name="scinotes-selection-new-tab"/>
+        <entry type="java" action="SplitAction" name="scinotes-split"/>
+        <entry type="java" action="HelpOnKeywordInPopupAction" name="scinotes-help-keyword-popup"/>
+        <entry type="java" action="SetFontAction" name="scinotes-set-font"/>
+        <entry type="java" action="SetColorsAction" name="scinotes-set-colors"/>
+        <entry type="java" action="GeneralSettingsAction" name="scinotes-general-settings"/>
+    </scinotes>
+    <console>
+        <entry type="java" action="org.scilab.modules.console.SelectAllAction" name="console-select-all"/>
+        <entry type="java" action="org.scilab.modules.console.ClearConsoleAction" name="console-clear"/>
+        <entry type="java" action="org.scilab.modules.console.ConsoleboxAction" name="console-box"/>
+        <entry type="java" action="org.scilab.modules.console.HelpAction" name="console-help-browser"/>
+        <entry type="java" action="org.scilab.modules.console.ValidationAction" name="console-enter"/>
+        <entry type="java" action="org.scilab.modules.console.CompletionAction" name="console-completion"/>
+        <entry type="java" action="org.scilab.modules.console.LineBeginningAction" name="console-line-begin"/>
+        <entry type="java" action="org.scilab.modules.console.GetPreviousAction" name="console-prev-history"/>
+        <entry type="java" action="org.scilab.modules.console.GetNextAction" name="console-next-history"/>
+        <entry type="java" action="org.scilab.modules.console.LineEndAction" name="console-line-end"/>
+        <entry type="java" action="org.scilab.modules.console.PreviousCharAction" name="console-prev-char"/>
+        <entry type="java" action="org.scilab.modules.console.NextCharAction" name="console-next-char"/>
+        <entry type="java" action="org.scilab.modules.console.DelPreviousCharAction" name="console-del-prev-char"/>
+        <entry type="java" action="org.scilab.modules.console.DelNextCharAction" name="console-del-next-char"/>
+        <entry type="java" action="org.scilab.modules.console.DelLastWordAction" name="console-del-last-word"/>
+        <entry type="java" action="org.scilab.modules.console.DelEndOfLineAction" name="console-del-end-line"/>
+        <entry type="java" action="org.scilab.modules.console.DelWholeLineAction" name="console-del-whole-line"/>
+        <entry type="java" action="org.scilab.modules.console.InterruptScilabWorkOrCut" name="console-cut-or-interrupt"/>
+        <entry type="java" action="org.scilab.modules.console.InterruptScilabWorkOrCopy" name="console-copy-or-interrupt"/>
+        <entry type="java" action="org.scilab.modules.console.PageUpAction" name="console-prev-page"/>
+        <entry type="java" action="org.scilab.modules.console.PageDownAction" name="console-next-page"/>
+    </console>
 </map>
index ae62757..35039ee 100644 (file)
@@ -99,6 +99,7 @@
             <menu label="Preferences">
                 <menuitem action="scinotes-set-font" label="Set font"/>
                 <menuitem action="scinotes-set-colors" label="Set colors"/>
+                <menuitem action="scinotes-general-settings" label="Scinotes General settings"/>
             </menu>
             <separator/>
             <menu label="Auto-completion on">
         <button action="scinotes-execute-scilab" tooltip="Execute" icon="media-playback-start"/>
         <button action="scinotes-save-execute" tooltip="Save and execute" icon="save-and-execute"/>
         <button action="scinotes-save-execute-all" tooltip="Save and execute all" icon="execute-all"/>
+        <separator/>
+        <button action="scinotes-general-settings" tooltip="Scinotes General settings" icon="preferences-system"/>
+        <separator/>
+        <button action="scinotes-help" tooltip="Scinotes help" icon="help-browser"/>
     </ToolBar>
     
 </Configuration>
diff --git a/scilab/modules/scinotes/src/java/org/scilab/modules/scinotes/actions/GeneralSettingsAction.java b/scilab/modules/scinotes/src/java/org/scilab/modules/scinotes/actions/GeneralSettingsAction.java
new file mode 100644 (file)
index 0000000..46fd892
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+package org.scilab.modules.scinotes.actions;
+
+import javax.swing.KeyStroke;
+
+import org.scilab.modules.commons.ScilabGeneralPrefs;
+import org.scilab.modules.gui.menuitem.MenuItem;
+import org.scilab.modules.gui.pushbutton.PushButton;
+import org.scilab.modules.scinotes.SciNotes;
+
+/**
+ * SetFontAction Class
+ * @author Calixte DENIZET
+ */
+public class GeneralSettingsAction extends DefaultAction {
+
+    /**
+     * Constructor
+     * @param name the name of the action
+     * @param editor SciNotes
+     */
+    public GeneralSettingsAction(String name, SciNotes editor) {
+        super(name, editor);
+    }
+
+    /**
+     * doAction
+     */
+    @Override
+    public void doAction() {
+        ScilabGeneralPrefs.openPreferences("scinotes/");
+    }
+
+    /**
+     * createMenu
+     * @param label label of the menu
+     * @param editor SciNotes
+     * @param key Keystroke
+     * @return MenuItem
+     */
+    public static MenuItem createMenu(String label, final SciNotes editor, KeyStroke key) {
+        return createMenu(label, null, new GeneralSettingsAction(label, editor), key);
+    }
+
+    /**
+     * createButton
+     * @param tooltip the tooltip
+     * @param icon an icon name searched in SCI/modules/gui/images/icons/
+     * @param editor SciNotes
+     * @return PushButton
+     */
+    public static PushButton createButton(String tooltip, String icon, SciNotes editor) {
+        return createButton(tooltip, icon, new GeneralSettingsAction(tooltip, editor));
+    }
+}
index 0bb89f4..2841388 100644 (file)
@@ -16,6 +16,7 @@ import javax.swing.KeyStroke;
 
 import org.scilab.modules.action_binding.InterpreterManagement;
 import org.scilab.modules.gui.menuitem.MenuItem;
+import org.scilab.modules.gui.pushbutton.PushButton;
 import org.scilab.modules.scinotes.SciNotes;
 
 /**
@@ -61,4 +62,15 @@ public final class HelpAction extends DefaultAction {
     public static MenuItem createMenu(String label, SciNotes editor, KeyStroke key) {
         return createMenu(label, null, new HelpAction(label, editor), key);
     }
+
+    /**
+     * createButton
+     * @param tooltip the tooltip
+     * @param icon an icon name searched in SCI/modules/gui/images/icons/
+     * @param editor SciNotes
+     * @return PushButton
+     */
+    public static PushButton createButton(String tooltip, String icon, SciNotes editor) {
+        return createButton(tooltip, icon, new HelpAction(tooltip, editor));
+    }
 }