Xcos: fix the tree_show calls 27/17527/1
Clément DAVID [Mon, 30 Nov 2015 17:22:49 +0000 (18:22 +0100)]
This commit also re-introduce the tree_show(`scs_m`) browser view as the
MVC browser is not ready yet.

Change-Id: If351ce5c105f943a7da1b4e790fb0555dc8309d3

scilab/modules/xcos/src/java/org/scilab/modules/xcos/XcosTab.java
scilab/modules/xcos/src/java/org/scilab/modules/xcos/actions/ViewDiagramTreeShowAction.java [new file with mode: 0644]
scilab/modules/xcos/src/java/org/scilab/modules/xcos/block/actions/ViewDetailsAction.java
scilab/modules/xcos/src/java/org/scilab/modules/xcos/utils/XcosMessages.java

index 55d356d..8a6dfb6 100644 (file)
@@ -82,6 +82,7 @@ import org.scilab.modules.xcos.actions.ShowHideShadowAction;
 import org.scilab.modules.xcos.actions.StartAction;
 import org.scilab.modules.xcos.actions.StopAction;
 import org.scilab.modules.xcos.actions.ViewDiagramBrowserAction;
+import org.scilab.modules.xcos.actions.ViewDiagramTreeShowAction;
 import org.scilab.modules.xcos.actions.ViewGridAction;
 import org.scilab.modules.xcos.actions.ViewViewportAction;
 import org.scilab.modules.xcos.actions.XcosDemonstrationsAction;
@@ -428,6 +429,7 @@ public class XcosTab extends SwingScilabDockablePanel implements SimpleTab {
         view.add(NormalViewAction.createMenu(diagram));
         view.addSeparator();
         view.add(ViewPaletteBrowserAction.createCheckBoxMenu(diagram));
+        view.add(ViewDiagramTreeShowAction.createMenu(diagram));
         view.add(ViewDiagramBrowserAction.createMenu(diagram));
         final CheckBoxMenuItem menuItem = ViewViewportAction.createCheckBoxMenu(diagram);
         viewport = (JCheckBoxMenuItem) menuItem.getAsSimpleCheckBoxMenuItem();
diff --git a/scilab/modules/xcos/src/java/org/scilab/modules/xcos/actions/ViewDiagramTreeShowAction.java b/scilab/modules/xcos/src/java/org/scilab/modules/xcos/actions/ViewDiagramTreeShowAction.java
new file mode 100644 (file)
index 0000000..e310d91
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009 - DIGITEO - Vincent COUVERT
+ * Copyright (C) 2009 - DIGITEO - Bruno JOFRET
+ * Copyright (C) 2010 - DIGITEO - Clement DAVID
+ *
+ * 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.xcos.actions;
+
+import java.awt.event.ActionEvent;
+import org.scilab.modules.action_binding.highlevel.ScilabInterpreterManagement;
+
+import org.scilab.modules.graph.ScilabComponent;
+import org.scilab.modules.graph.ScilabGraph;
+import org.scilab.modules.graph.actions.base.DefaultAction;
+import org.scilab.modules.gui.menuitem.MenuItem;
+import org.scilab.modules.xcos.Xcos;
+import org.scilab.modules.xcos.explorer.BrowserTab;
+import org.scilab.modules.xcos.graph.XcosDiagram;
+import org.scilab.modules.xcos.utils.XcosMessages;
+
+/**
+ * View the diagram as a scilab tree
+ */
+@SuppressWarnings(value = { "serial" })
+public final class ViewDiagramTreeShowAction extends DefaultAction {
+    /** Name of the action */
+    public static final String NAME = XcosMessages.OLD_DIAGRAM_BROWSER;
+    /** Icon name of the action */
+    public static final String SMALL_ICON = "";
+    /** Mnemonic key of the action */
+    public static final int MNEMONIC_KEY = 0;
+    /** Accelerator key for the action */
+    public static final int ACCELERATOR_KEY = 0;
+
+    /**
+     * Constructor
+     *
+     * @param scilabGraph
+     *            graph
+     */
+    public ViewDiagramTreeShowAction(ScilabGraph scilabGraph) {
+        super(scilabGraph);
+    }
+
+    /**
+     * Create the menu
+     *
+     * @param scilabGraph
+     *            graph
+     * @return menu item
+     */
+    public static MenuItem createMenu(ScilabGraph scilabGraph) {
+        return createMenu(scilabGraph, ViewDiagramTreeShowAction.class);
+    }
+
+    /**
+     * @param e
+     *            parameter
+     * @see org.scilab.modules.graph.actions.base.DefaultAction#actionPerformed(java.awt.event.ActionEvent)
+     */
+    @Override
+    public void actionPerformed(ActionEvent e) {
+        final XcosDiagram graph = (XcosDiagram) getGraph(e);
+
+        // action disabled when the cell is edited
+        final ScilabComponent comp = ((ScilabComponent) graph.getAsComponent());
+        if (comp.isEditing()) {
+            return;
+        }
+
+        // build and execute the command
+        final String cmd = "tree_show(scicos_new(\"0x" + Long.toHexString(graph.getUID()) + "\"));";
+        ScilabInterpreterManagement.requestScilabExec(cmd);
+    }
+}
index 75f394d..cd3fde8 100644 (file)
@@ -99,7 +99,7 @@ public final class ViewDetailsAction extends VertexSelectionDependantAction {
         /*
          * Build and execute the command
          */
-        final String cmd = "tree_show(scicos_new(" + data.getUID() + "));";
+        final String cmd = "tree_show(scicos_new(\"0x" + Long.toHexString(data.getUID()) + "\"));";
         ScilabInterpreterManagement.requestScilabExec(cmd);
     }
 }
index 8143edd..17ed2dd 100644 (file)
@@ -78,6 +78,7 @@ public final class XcosMessages {
     public static final String FIT_DIAGRAM_TO_VIEW = Messages.gettext("Fit diagram or blocks to view");
     public static final String NORMAL_100 = Messages.gettext("Normal 100%");
     public static final String PALETTE_BROWSER = Messages.gettext("Palette browser");
+    public static final String OLD_DIAGRAM_BROWSER = Messages.gettext("tree_show(scs_m)");
     public static final String DIAGRAM_BROWSER = Messages.gettext("Diagram browser");
     public static final String VIEWPORT = Messages.gettext("Viewport");
     public static final String GET_INFOS = Messages.gettext("Get infos");