Improve export of code in colormap.xml 06/8506/2
Calixte DENIZET [Fri, 3 Aug 2012 08:40:53 +0000 (10:40 +0200)]
Change-Id: I51e7f5c813ed233e32130d4c3f39f43c7db46deb

scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/utils/MenuBarBuilder.java

index 7a78c27..18a46b1 100644 (file)
@@ -102,8 +102,18 @@ public final class MenuBarBuilder {
      * @param figureId the figure
      */
     public static void buildFigureMenuBar(String figureId) {
-        MenuBarBuilder.isParentValid = false;
-        buildMenuBar(GRAPHICSMENUBARXMLFILE, figureId);
+       boolean isheadless = false;
+       
+       try {
+           Class clazz = ClassLoader.getSystemClassLoader().loadClass("org.scilab.modules.gui.SwingView");
+           Method meth = clazz.getMethod("isHeadless");
+           isheadless = (Boolean) meth.invoke(null);
+       } catch (Exception e) { System.err.println(e);}
+
+        if (!isheadless) {
+            MenuBarBuilder.isParentValid = false;
+            buildMenuBar(GRAPHICSMENUBARXMLFILE, figureId);
+        }
     }
 
     /**