ToolBar/MenuBar creation update 52/13652/2
Bruno JOFRET [Tue, 4 Feb 2014 14:53:56 +0000 (15:53 +0100)]
Change-Id: I666bf0370fbda56a2abbe832108c4932adf492f3

scilab/modules/gui/src/java/org/scilab/modules/gui/SwingView.java
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/tab/SwingScilabCommonPanel.java
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/tab/SwingScilabDockablePanel.java
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/toolbar/SwingScilabToolBar.java
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/window/SwingScilabDockingWindow.java

index bc7ed72..d187269 100644 (file)
@@ -124,6 +124,7 @@ import org.scilab.modules.gui.bridge.waitbar.SwingScilabWaitBar;
 import org.scilab.modules.gui.bridge.window.SwingScilabWindow;
 import org.scilab.modules.gui.console.ScilabConsole;
 import org.scilab.modules.gui.ged.Inspector;
+import org.scilab.modules.gui.menubar.MenuBar;
 import org.scilab.modules.gui.menubar.ScilabMenuBar;
 import org.scilab.modules.gui.textbox.ScilabTextBox;
 import org.scilab.modules.gui.textbox.TextBox;
@@ -382,8 +383,6 @@ public final class SwingView implements GraphicView {
                 SwingScilabPanel tab;
                 if (figure.getDockable()) {
                     tab = new SwingScilabDockablePanel(figureTitle, figureId, figure);
-                    DockingManager.dock((SwingScilabDockablePanel) tab, window.getDockingPort());
-                    ActiveDockableTracker.requestDockableActivation((SwingScilabDockablePanel) tab);
                 } else {
                     tab = new SwingScilabStaticPanel(figureTitle, figureId, figure);
                     window.addTab(tab);
@@ -391,20 +390,27 @@ public final class SwingView implements GraphicView {
                 tab.setId(id);
 
                 /* MENUBAR */
-                tab.setMenuBar(ScilabMenuBar.createMenuBar());
+                MenuBar menuBar = ScilabMenuBar.createMenuBar();
+                menuBar.setVisible(figure.getMenubarVisible());
+                tab.setMenuBar(menuBar);
+                window.addMenuBar(menuBar);
+                
                 /* TOOLBAR */
-                if (figure.getToolbarAsEnum() == Figure.BarType.FIGURE) {
-                    ToolBar toolBar = ToolBarBuilder.buildToolBar(SwingScilabCommonPanel.GRAPHICS_TOOLBAR_DESCRIPTOR, figureId);
-                    tab.setToolBar(toolBar);
-                } else {
-                    tab.setToolBar(ScilabToolBar.createToolBar());
-                }
+                ToolBar toolbar = ScilabToolBar.createToolBar();
+                toolbar.setVisible(figure.getToolbarVisible());
+                tab.setToolBar(toolbar);
+                window.addToolBar(toolbar);
+                
                 /* INFOBAR */
                 TextBox infoBar = ScilabTextBox.createTextBox();
-                tab.setInfoBar(ScilabTextBox.createTextBox());
-                window.addMenuBar(tab.getMenuBar());
-                window.addToolBar(tab.getToolBar());
-                window.addInfoBar(tab.getInfoBar());
+                infoBar.setVisible(figure.getInfobarVisible());
+                tab.setInfoBar(infoBar);
+                window.addInfoBar(infoBar);
+                
+                if (figure.getDockable()) {
+                    DockingManager.dock((SwingScilabDockablePanel) tab, window.getDockingPort());
+                    ActiveDockableTracker.requestDockableActivation((SwingScilabDockablePanel) tab);
+                }
 
                 tab.setWindowIcon("graphic-window");
 
index 715c551..5d911f9 100644 (file)
@@ -46,6 +46,8 @@ import java.awt.GridLayout;
 
 import javax.swing.JLayeredPane;
 
+import org.scilab.modules.graphic_objects.figure.Figure;
+import org.scilab.modules.graphic_objects.figure.Figure.BarType;
 import org.scilab.modules.graphic_objects.graphicController.GraphicController;
 import org.scilab.modules.graphic_objects.graphicModel.GraphicModel;
 import org.scilab.modules.graphic_objects.uicontrol.Uicontrol;
@@ -55,6 +57,7 @@ import org.scilab.modules.gui.SwingViewObject;
 import org.scilab.modules.gui.bridge.frame.SwingScilabFrame;
 import org.scilab.modules.gui.bridge.window.SwingScilabWindow;
 import org.scilab.modules.gui.events.callback.ScilabCloseCallBack;
+import org.scilab.modules.gui.toolbar.ToolBar;
 import org.scilab.modules.gui.utils.Position;
 import org.scilab.modules.gui.utils.Size;
 import org.scilab.modules.gui.utils.ToolBarBuilder;
@@ -81,12 +84,18 @@ public class SwingScilabCommonPanel {
             case __GO_ID__ :
                 /* Update title */
                 figureId = ((Integer) value);
-                name = (String) GraphicController.getController().getProperty(component.getId(), __GO_NAME__);
+                Figure localFigure = (Figure) GraphicController.getController().getObjectFromId(component.getId());
+                name = localFigure.getName();
                 updateTitle(component, name, figureId);
 
                 /** Update tool bar */
-                component.setToolBar(ToolBarBuilder.buildToolBar(GRAPHICS_TOOLBAR_DESCRIPTOR, figureId));
-                SwingScilabWindow parentWindow = SwingScilabWindow.allScilabWindows.get(component.getParentWindowId());
+                if (localFigure.getToolbarAsEnum() == BarType.FIGURE) {
+                    SwingScilabWindow parentWindow = SwingScilabWindow.allScilabWindows.get(component.getParentWindowId());
+                    ToolBar toolbar = ToolBarBuilder.buildToolBar(GRAPHICS_TOOLBAR_DESCRIPTOR, figureId);
+                    toolbar.setVisible(localFigure.getToolbarVisible());
+                    component.setToolBar(toolbar);
+                    parentWindow.addToolBar(toolbar);
+                }
 
                 /* Update callback */
                 String closingCommand =
index 1be92f2..79b88d4 100644 (file)
@@ -1214,12 +1214,7 @@ public class SwingScilabDockablePanel extends View implements SimpleTab, FocusLi
      */
     @Override
     public void setToolBar(ToolBar newToolBar) {
-        if (this.toolBar != newToolBar) {
-            if (this.toolBar != null) {
-                ((SwingScilabToolBar) this.toolBar.getAsSimpleToolBar()).close();
-            }
-            this.toolBar = newToolBar;
-        }
+        this.toolBar = newToolBar;
     }
 
     /**
index bf34fe0..f4759a2 100644 (file)
@@ -70,9 +70,4 @@ public class SwingScilabToolBar extends JToolBar implements SimpleToolBar {
         this.elementId = id;
     }
 
-    public void close() {
-        removeAll();
-        UIElementMapper.removeMapping(elementId);
-    }
-
 }
index 3950595..5a629f9 100644 (file)
@@ -100,10 +100,10 @@ public class SwingScilabDockingWindow extends SwingScilabWindow {
         if (getDockingPort() == null || getDockingPort().getDockables().isEmpty()) {
             // remove xxxBars
             if (toolBar != null) {
-                ((SwingScilabToolBar) toolBar).close();
+                ((SwingScilabToolBar) toolBar).removeAll();
             }
             if (menuBar != null) {
-                ((SwingScilabMenuBar) menuBar).close();
+                ((SwingScilabMenuBar) menuBar).removeAll();
             }
 
             // clean all