reduce depth search to find figure during closing
[scilab.git] / scilab / modules / gui / src / java / org / scilab / modules / gui / bridge / tab / SwingScilabCommonPanel.java
index 2c20ca6..77b8287 100644 (file)
@@ -11,7 +11,6 @@
  * and continues to be available under such terms.
  * For more information, see the COPYING file which you should have received
  * along with this program.
- * === LICENSE_END ===
  *
  */
 package org.scilab.modules.gui.bridge.tab;
@@ -131,9 +130,15 @@ public class SwingScilabCommonPanel {
                 }
 
                 /* Update callback */
-                String closingCommand = "if (get_figure_handle(" + figureId + ") <> []) then" + "  if (get(get_figure_handle(" + figureId + "), 'event_handler_enable') == 'on') then"
-                                        + "    execstr(get(get_figure_handle(" + figureId + "), 'event_handler')+'(" + figureId + ", -1, -1, -1000)', 'errcatch', 'm');" + "  end;" + "  delete(get_figure_handle("
-                                        + figureId + "));" + "end;";
+                String closingCommand =   "%closing_fig = findobj('figure_id', " + figureId + ", '-flat');"
+                                        + "if (%closing_fig <> []) then"
+                                        + "    if (get(%closing_fig, 'event_handler_enable') == 'on') then"
+                                        + "        execstr(get(%closing_fig, 'event_handler')+'(" + figureId + ", -1, -1, -1000)', 'errcatch', 'm');"
+                                        + "    end;"
+                                        + "    delete(%closing_fig);"
+                                        + "end;"
+                                        + "clear('%closing_fig');";
+
                 component.setCallback(null);
                 component.setCallback(ScilabCloseCallBack.create(component.getId(), closingCommand));
                 /* Update menus callback */
@@ -191,6 +196,14 @@ public class SwingScilabCommonPanel {
                 if (component.getParentWindow().getNbDockedObjects() == 1) {
                     component.getParentWindow().setVisible((Boolean) value);
                 }
+
+                //de-iconify windows
+                if((Boolean)value == true) {
+                    int state = component.getParentWindow().getExtendedState();
+                    if((state & SwingScilabWindow.ICONIFIED) == SwingScilabWindow.ICONIFIED) {
+                        component.getParentWindow().setExtendedState(state - SwingScilabWindow.ICONIFIED);
+                    }
+                }
                 break;
             case __GO_INFOBAR_VISIBLE__: {
                 component.disableResizeEvent();