Bug 13036 fixed: Bad help page associated to history browser 73/13073/1
Calixte DENIZET [Mon, 4 Nov 2013 14:32:33 +0000 (15:32 +0100)]
Change-Id: Ic68a8bc761d660a9fbc2282a3e2b5f98cd06a302

scilab/CHANGES_5.5.X
scilab/modules/history_browser/src/java/org/scilab/modules/history_browser/CommandHistory.java
scilab/modules/history_browser/src/java/org/scilab/modules/history_browser/CommandHistoryMessages.java
scilab/modules/history_browser/src/java/org/scilab/modules/history_browser/actions/HelpAction.java
scilab/modules/history_browser/src/java/org/scilab/modules/history_browser/actions/PrefsAction.java [new file with mode: 0644]

index d2b2b49..77aebaf 100644 (file)
@@ -101,6 +101,8 @@ Scilab Bug Fixes
 
 * Bug #13032 fixed - Fixed CMATVIEW help example and created one for CMAT3D.
 
+* Bug #13036 fixed - Bad help page associated to history browser.
+
 
 Xcos Bug Fixes
 ==============
index c08228a..8192933 100644 (file)
@@ -62,6 +62,7 @@ import org.scilab.modules.history_browser.actions.DeleteAction;
 import org.scilab.modules.history_browser.actions.EditInScinotesAction;
 import org.scilab.modules.history_browser.actions.EvaluateAction;
 import org.scilab.modules.history_browser.actions.HelpAction;
+import org.scilab.modules.history_browser.actions.PrefsAction;
 import org.scilab.modules.history_manager.HistoryManagement;
 import org.scilab.modules.localization.Messages;
 
@@ -111,7 +112,7 @@ public final class CommandHistory extends SwingScilabTab implements SimpleTab {
      */
     private CommandHistory() {
         super(CommandHistoryMessages.TITLE, COMMANDHISTORYUUID);
-        setAssociatedXMLIDForHelp("historybrowser");
+        setAssociatedXMLIDForHelp("browsehistory");
         initialize();
         addMenuBar(createMenuBar());
         addToolBar(createToolBar());
@@ -480,6 +481,8 @@ public final class CommandHistory extends SwingScilabTab implements SimpleTab {
         toolBar.add(DeleteAction.createPushButton());
 
         toolBar.addSeparator();
+        toolBar.add(PrefsAction.createPushButton());
+        toolBar.addSeparator();
 
         toolBar.add(HelpAction.createPushButton());
 
index 541e8e5..4b71f2d 100644 (file)
@@ -40,6 +40,8 @@ public final class CommandHistoryMessages {
     public static final String ERROR = Messages.gettext("Error");
     public static final String CANNOT_DELETE_CURRENT_SESSION_NODE = Messages.gettext("Cannot delete current session beginning line.");
 
+    public static final String SCILAB_PREFS = Messages.gettext("History preferences");
+
     /**
      * This class is a static singleton
      * Thus it must not be instantiated
index 5e39353..4475cea 100644 (file)
@@ -16,7 +16,7 @@ import java.lang.reflect.InvocationTargetException;
 
 import javax.swing.ImageIcon;
 
-import org.scilab.modules.action_binding.InterpreterManagement;
+import org.scilab.modules.gui.bridge.CallScilabBridge;
 import org.scilab.modules.gui.bridge.menuitem.SwingScilabMenuItem;
 import org.scilab.modules.gui.events.callback.CommonCallBack;
 import org.scilab.modules.gui.menuitem.MenuItem;
@@ -100,6 +100,6 @@ public final class HelpAction extends CommonCallBack {
      */
     @Override
     public void callBack() {
-        InterpreterManagement.putCommandInScilabQueue("help();");
+        CallScilabBridge.openHelp("browsehistory");
     }
 }
diff --git a/scilab/modules/history_browser/src/java/org/scilab/modules/history_browser/actions/PrefsAction.java b/scilab/modules/history_browser/src/java/org/scilab/modules/history_browser/actions/PrefsAction.java
new file mode 100644 (file)
index 0000000..d84160e
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2010 - DIGITEO - Vincent COUVERT
+ *
+ * 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.1-en.txt
+ *
+ */
+
+package org.scilab.modules.history_browser.actions;
+
+import java.lang.reflect.InvocationTargetException;
+
+import javax.swing.ImageIcon;
+
+import org.scilab.modules.commons.ScilabGeneralPrefs;
+import org.scilab.modules.gui.bridge.menuitem.SwingScilabMenuItem;
+import org.scilab.modules.gui.events.callback.CommonCallBack;
+import org.scilab.modules.gui.menuitem.MenuItem;
+import org.scilab.modules.gui.menuitem.ScilabMenuItem;
+import org.scilab.modules.gui.pushbutton.PushButton;
+import org.scilab.modules.gui.pushbutton.ScilabPushButton;
+import org.scilab.modules.gui.utils.ScilabSwingUtilities;
+import org.scilab.modules.history_browser.CommandHistoryMessages;
+
+/**
+ * Manage Help Actions
+ * @author Vincent COUVERT
+ */
+public final class PrefsAction extends CommonCallBack {
+
+    private static final long serialVersionUID = 1L;
+
+    private static final String LABEL = CommandHistoryMessages.SCILAB_PREFS;
+    private static final String ICON = ScilabSwingUtilities.findIcon("preferences-system");
+    private static final char MNEMONIC = 'P';
+
+    /**
+     * Constructor
+     */
+    public PrefsAction() {
+        super("");
+    }
+
+    /**
+     * Create the associated menu
+     * @return the menu
+     */
+    public static MenuItem createMenuItem() {
+        MenuItem menuItem = ScilabMenuItem.createMenuItem();
+        menuItem.setText(LABEL);
+        menuItem.setMnemonic(MNEMONIC);
+        menuItem.setCallback(getCallBack());
+        ((SwingScilabMenuItem) menuItem.getAsSimpleMenuItem()).setIcon(new ImageIcon(ICON));
+        return menuItem;
+    }
+
+    /**
+     * Create the associated button
+     * @return the button
+     */
+    public static PushButton createPushButton() {
+        PushButton pushButton = ScilabPushButton.createPushButton();
+        pushButton.setIcon(ICON);
+        pushButton.setToolTipText(LABEL);
+        pushButton.setCallback(getCallBack());
+        return pushButton;
+    }
+
+    /**
+     * Create a new class instance
+     * @return the instance
+     */
+    private static CommonCallBack getCallBack() {
+        CommonCallBack callback = null;
+        try {
+            callback = PrefsAction.class.getConstructor().newInstance();
+        } catch (IllegalArgumentException e) {
+            e.printStackTrace();
+        } catch (SecurityException e) {
+            e.printStackTrace();
+        } catch (InstantiationException e) {
+            e.printStackTrace();
+        } catch (IllegalAccessException e) {
+            e.printStackTrace();
+        } catch (InvocationTargetException e) {
+            e.printStackTrace();
+        } catch (NoSuchMethodException e) {
+            e.printStackTrace();
+        }
+        return callback;
+    }
+
+    /**
+     * Action!
+     * @see org.scilab.modules.gui.events.callback.CallBack#callBack()
+     */
+    @Override
+    public void callBack() {
+        ScilabGeneralPrefs.openPreferences("command-history/");
+    }
+}