* Bug #11489 fixed - 'SliderStep' property was ignored for uicontrols. 49/9049/4
Vincent COUVERT [Tue, 18 Sep 2012 13:12:14 +0000 (15:12 +0200)]
Change-Id: Ie3aff3471d9bfdb4bbf9de02e9a98f0981e8b1c2

scilab/CHANGES_5.4.X
scilab/modules/gui/sci_gateway/c/sci_uicontrol.c
scilab/modules/gui/src/cpp/SetUicontrolSliderStep.cpp
scilab/modules/gui/src/cpp/SetUicontrolSliderStep.hxx
scilab/modules/gui/src/java/org/scilab/modules/gui/SwingView.java
scilab/modules/gui/src/java/org/scilab/modules/gui/SwingViewWidget.java
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/slider/SwingScilabSlider.java
scilab/modules/gui/tests/nonreg_tests/bug_11489.tst [new file with mode: 0644]

index e6dc998..bb4937e 100644 (file)
@@ -64,6 +64,8 @@ Bug Fixes
 
 * Bug #11293 fixed - Line style was not taken into account.
 
+* Bug #11489 fixed - 'SliderStep' property was ignored for uicontrols.
+
 * Bug #11558 fixed - Typo in helptools module fixed.
 
 * Bug #11657 fixed - Setting the callback_type property of an uicontrol was not
index 11c04a6..4bb5ec3 100644 (file)
@@ -428,6 +428,24 @@ int sci_uicontrol(char *fname, unsigned long fname_len)
         setGraphicObjectProperty(pUicontrol, __GO_VISIBLE__, &b, jni_bool, 1);
     }
 
+    if (propertiesValuesIndices[14] == NOT_FOUND)    /* SliderStep property not set */
+    {
+        /* Set SliderStep property to [1/100*(Max-Min) 1/10*(Max-Min)] */
+        double maxValue = 0;
+        double* pdblMaxValue = &maxValue;
+        double minValue = 0;
+        double* pdblMinValue = &minValue;
+        double pdblStep[2];
+
+        getGraphicObjectProperty(pUicontrol, __GO_UI_MIN__, jni_double, (void**) &pdblMinValue);
+        getGraphicObjectProperty(pUicontrol, __GO_UI_MAX__, jni_double, (void**) &pdblMaxValue);
+
+        pdblStep[0] = 0.01 * (maxValue - minValue);
+        pdblStep[1] = 0.1 * (maxValue - minValue);
+
+        setGraphicObjectProperty(pUicontrol, __GO_UI_SLIDERSTEP__, pdblStep, jni_double_vector, 2);
+    }
+
     FREE(propertiesValuesIndices);
 
     /* Create return variable */
index ec53c0c..d348a3e 100644 (file)
@@ -30,9 +30,16 @@ int SetUicontrolSliderStep(void* _pvCtx, char* sciObjUID, size_t stackPointer, i
     {
         double pdblStep[2];
         double* pdblStackVal = stk(stackPointer);
+        double maxValue = 0;
+        double* pdblMaxValue = &maxValue;
+        double minValue = 0;
+        double* pdblMinValue = &minValue;
+
+        getGraphicObjectProperty(sciObjUID, __GO_UI_MIN__, jni_double, (void**) &pdblMinValue);
+        getGraphicObjectProperty(sciObjUID, __GO_UI_MAX__, jni_double, (void**) &pdblMaxValue);
 
         pdblStep[0] = pdblStackVal[0];
-        pdblStep[1] = 0.1;// default big value : 10%
+        pdblStep[1] = 0.1 * (maxValue - minValue);// default big value : 10% of the scale
 
         status = setGraphicObjectProperty(sciObjUID, __GO_UI_SLIDERSTEP__, pdblStep, jni_double_vector, 2);
     }
index 0c4eb3c..bb5813c 100644 (file)
@@ -1,11 +1,11 @@
 /*
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
  * Copyright (C) 2007 - INRIA - 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    
+ * are also available at
  * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
  *
  */
@@ -23,6 +23,7 @@ extern "C"
 #include "Scierror.h"
 #include "graphicObjectProperties.h"
 #include "setGraphicObjectProperty.h"
+#include "getGraphicObjectProperty.h"
 }
 
 #endif /* __SET_UICONTROL_SLIDERSTEP_HXX__ */
index 350dece..bce37ce 100644 (file)
@@ -165,26 +165,26 @@ public final class SwingView implements GraphicView {
 
     private enum UielementType {
         Console,
-            CheckBox,
-            Edit,
-            Frame,
-            Figure,
-            Image,
-            ListBox,
-            PopupMenu,
-            Progressbar,
-            PushButton,
-            RadioButton,
-            Slider,
-            Table,
-            Text,
-            Uimenu,
-            UiParentMenu,
-            UiChildMenu,
-            UiCheckedMenu,
-            UiContextMenu,
-            Waitbar
-            }
+        CheckBox,
+        Edit,
+        Frame,
+        Figure,
+        Image,
+        ListBox,
+        PopupMenu,
+        Progressbar,
+        PushButton,
+        RadioButton,
+        Slider,
+        Table,
+        Text,
+        Uimenu,
+        UiParentMenu,
+        UiChildMenu,
+        UiCheckedMenu,
+        UiContextMenu,
+        Waitbar
+    }
 
     private class TypedObject {
         private UielementType   _type;
@@ -221,21 +221,21 @@ public final class SwingView implements GraphicView {
             return _children.contains(childUID);
         }
     };
-    
+
     private static final Set<Integer> managedTypes = new HashSet<Integer>(Arrays.asList(
-            GraphicObjectProperties.__GO_FIGURE__,
-            GraphicObjectProperties.__GO_UICONTEXTMENU__,
-            GraphicObjectProperties.__GO_UIMENU__,
-            GraphicObjectProperties.__GO_CONSOLE__,
-            GraphicObjectProperties.__GO_PROGRESSIONBAR__,
-            GraphicObjectProperties.__GO_WAITBAR__,
-            GraphicObjectProperties.__GO_UICONTROL__
+                GraphicObjectProperties.__GO_FIGURE__,
+                GraphicObjectProperties.__GO_UICONTEXTMENU__,
+                GraphicObjectProperties.__GO_UIMENU__,
+                GraphicObjectProperties.__GO_CONSOLE__,
+                GraphicObjectProperties.__GO_PROGRESSIONBAR__,
+                GraphicObjectProperties.__GO_WAITBAR__,
+                GraphicObjectProperties.__GO_UICONTROL__
             ));
     @Override
     public void createObject(String id) {
-        
+
         int objectType = (Integer) GraphicController.getController().getProperty(id, __GO_TYPE__);
-        
+
         if (managedTypes.contains(objectType) == false) {
             return;
         }
@@ -272,46 +272,46 @@ public final class SwingView implements GraphicView {
     private UielementType StyleToEnum(int style) {
         DEBUG("SwingView", "StyleToEnum(" + style + ")");
         switch (style) {
-        case __GO_FIGURE__ :
-            return UielementType.Figure;
-        case __GO_CONSOLE__ :
-            return UielementType.Console;
-        case __GO_UI_CHECKBOX__ :
-            return UielementType.CheckBox;
-        case __GO_UI_EDIT__ :
-            return UielementType.Edit;
-        case __GO_UI_FRAME__ :
-            return UielementType.Frame;
-        case __GO_UI_IMAGE__ :
-            return UielementType.Image;
-        case __GO_UI_LISTBOX__ :
-            return UielementType.ListBox;
-        case __GO_UI_POPUPMENU__ :
-            return UielementType.PopupMenu;
-        case __GO_UI_PUSHBUTTON__ :
-            return UielementType.PushButton;
-        case __GO_UI_RADIOBUTTON__ :
-            return UielementType.RadioButton;
-        case __GO_UI_SLIDER__ :
-            return UielementType.Slider;
-        case __GO_UI_TABLE__ :
-            return UielementType.Table;
-        case __GO_UI_TEXT__ :
-            return UielementType.Text;
-        case __GO_UIMENU__ :
-            return UielementType.UiChildMenu;
-        case __GO_UIPARENTMENU__ :
-            return UielementType.UiParentMenu;
-        case __GO_UICHILDMENU__ :
-            return UielementType.UiChildMenu;
-        case __GO_UICHECKEDMENU__ :
-            return UielementType.UiCheckedMenu;
-        case __GO_PROGRESSIONBAR__ :
-            return UielementType.Progressbar;
-        case __GO_WAITBAR__ :
-            return UielementType.Waitbar;
-        case __GO_UICONTEXTMENU__ :
-            return UielementType.UiContextMenu;
+            case __GO_FIGURE__ :
+                return UielementType.Figure;
+            case __GO_CONSOLE__ :
+                return UielementType.Console;
+            case __GO_UI_CHECKBOX__ :
+                return UielementType.CheckBox;
+            case __GO_UI_EDIT__ :
+                return UielementType.Edit;
+            case __GO_UI_FRAME__ :
+                return UielementType.Frame;
+            case __GO_UI_IMAGE__ :
+                return UielementType.Image;
+            case __GO_UI_LISTBOX__ :
+                return UielementType.ListBox;
+            case __GO_UI_POPUPMENU__ :
+                return UielementType.PopupMenu;
+            case __GO_UI_PUSHBUTTON__ :
+                return UielementType.PushButton;
+            case __GO_UI_RADIOBUTTON__ :
+                return UielementType.RadioButton;
+            case __GO_UI_SLIDER__ :
+                return UielementType.Slider;
+            case __GO_UI_TABLE__ :
+                return UielementType.Table;
+            case __GO_UI_TEXT__ :
+                return UielementType.Text;
+            case __GO_UIMENU__ :
+                return UielementType.UiChildMenu;
+            case __GO_UIPARENTMENU__ :
+                return UielementType.UiParentMenu;
+            case __GO_UICHILDMENU__ :
+                return UielementType.UiChildMenu;
+            case __GO_UICHECKEDMENU__ :
+                return UielementType.UiCheckedMenu;
+            case __GO_PROGRESSIONBAR__ :
+                return UielementType.Progressbar;
+            case __GO_WAITBAR__ :
+                return UielementType.Waitbar;
+            case __GO_UICONTEXTMENU__ :
+                return UielementType.UiContextMenu;
         }
         return null;
     }
@@ -323,152 +323,155 @@ public final class SwingView implements GraphicView {
 
     private SwingViewObject CreateObjectFromType(UielementType type, String id) {
         switch (type) {
-        case CheckBox:
-            SwingScilabCheckBox checkBox = new SwingScilabCheckBox();
-            checkBox.setId(id);
-            setDefaultProperties(checkBox, id);
-            return checkBox;
-        case Console:
-            Console console = (Console) GraphicController.getController().getObjectFromId(id);
-            if (console.getScilabMode() == Console.ScilabMode.STD) {
-                WindowsConfigurationManager.restoreUUID(NULLUUID);
-                SwingScilabConsole sciConsole = ((SwingScilabConsole) ScilabConsole.getConsole().getAsSimpleConsole());
-                SwingScilabTab consoleTab = (SwingScilabTab) sciConsole.getParent();
-                consoleTab.setId(id);
-                return consoleTab;
-            } else {
-                return null;
-            }
-        case Edit:
-            SwingScilabEditBox edit = new SwingScilabEditBox();
-            edit.setId(id);
-            setDefaultProperties(edit, id);
-            return edit;
-        case Figure:
-            Figure figure = (Figure) GraphicController.getController().getObjectFromId(id);
-            String figureTitle = figure.getName();
-            Integer figureId = figure.getId();
-            if ((figureTitle != null) && (figureId != null)) {
-                figureTitle = figureTitle.replaceFirst("%d", figureId.toString());
-            }
+            case CheckBox:
+                SwingScilabCheckBox checkBox = new SwingScilabCheckBox();
+                checkBox.setId(id);
+                setDefaultProperties(checkBox, id);
+                return checkBox;
+            case Console:
+                Console console = (Console) GraphicController.getController().getObjectFromId(id);
+                if (console.getScilabMode() == Console.ScilabMode.STD) {
+                    WindowsConfigurationManager.restoreUUID(NULLUUID);
+                    SwingScilabConsole sciConsole = ((SwingScilabConsole) ScilabConsole.getConsole().getAsSimpleConsole());
+                    SwingScilabTab consoleTab = (SwingScilabTab) sciConsole.getParent();
+                    consoleTab.setId(id);
+                    return consoleTab;
+                } else {
+                    return null;
+                }
+            case Edit:
+                SwingScilabEditBox edit = new SwingScilabEditBox();
+                edit.setId(id);
+                setDefaultProperties(edit, id);
+                return edit;
+            case Figure:
+                Figure figure = (Figure) GraphicController.getController().getObjectFromId(id);
+                String figureTitle = figure.getName();
+                Integer figureId = figure.getId();
+                if ((figureTitle != null) && (figureId != null)) {
+                    figureTitle = figureTitle.replaceFirst("%d", figureId.toString());
+                }
 
-            SwingScilabWindow window = new SwingScilabWindow();
+                SwingScilabWindow window = new SwingScilabWindow();
 
-            window.setTitle(figureTitle);
-            /* TOOLBAR */
-            ToolBar toolBar = ToolBarBuilder.buildToolBar(SwingScilabTab.GRAPHICS_TOOLBAR_DESCRIPTOR, figureId);
-            /* INFOBAR */
-            TextBox infoBar = ScilabTextBox.createTextBox();
+                window.setTitle(figureTitle);
+                /* TOOLBAR */
+                ToolBar toolBar = ToolBarBuilder.buildToolBar(SwingScilabTab.GRAPHICS_TOOLBAR_DESCRIPTOR, figureId);
+                /* INFOBAR */
+                TextBox infoBar = ScilabTextBox.createTextBox();
 
-            SwingScilabTab tab = new SwingScilabTab(figureTitle, figureId, figure);
-            tab.setId(id);
+                SwingScilabTab tab = new SwingScilabTab(figureTitle, figureId, figure);
+                tab.setId(id);
 
-            tab.setMenuBar(ScilabMenuBar.createMenuBar());
-            tab.setToolBar(toolBar);
-            tab.setInfoBar(ScilabTextBox.createTextBox());
-            window.addMenuBar(tab.getMenuBar());
-            window.addToolBar(tab.getToolBar());
-            window.addInfoBar(tab.getInfoBar());
+                tab.setMenuBar(ScilabMenuBar.createMenuBar());
+                tab.setToolBar(toolBar);
+                tab.setInfoBar(ScilabTextBox.createTextBox());
+                window.addMenuBar(tab.getMenuBar());
+                window.addToolBar(tab.getToolBar());
+                window.addInfoBar(tab.getInfoBar());
 
-            tab.setWindowIcon("graphic-window");
+                tab.setWindowIcon("graphic-window");
 
-            tab.setParentWindowId(window.getId());
+                tab.setParentWindowId(window.getId());
 
-            tab.setEventHandler(figure.getEventHandlerString());
-            tab.setEventHandlerEnabled(figure.getEventHandlerEnable());
+                tab.setEventHandler(figure.getEventHandlerString());
+                tab.setEventHandlerEnabled(figure.getEventHandlerEnable());
 
-            DockingManager.dock(tab, window.getDockingPort());
-            ActiveDockableTracker.requestDockableActivation(tab);
+                DockingManager.dock(tab, window.getDockingPort());
+                ActiveDockableTracker.requestDockableActivation(tab);
 
-            window.setVisible(true);
-            tab.setVisible(true);
-            tab.setName(figureTitle);
+                window.setVisible(true);
+                tab.setVisible(true);
+                tab.setName(figureTitle);
 
-            String infoMessage = figure.getInfoMessage();
-            if ((infoMessage == null) || (infoMessage.length() == 0)) {
-                infoBar.setText("");
-            } else {
-                infoBar.setText(infoMessage);
-            }
-            tab.update(__GO_SIZE__, (Integer[]) GraphicController.getController().getProperty(id, __GO_SIZE__));
-            tab.update(__GO_POSITION__, (Integer[]) GraphicController.getController().getProperty(id, __GO_POSITION__));
-            // TODO set other default properties
-            return tab;
-        case Frame:
-            SwingScilabFrame frame = new SwingScilabFrame();
-            frame.setId(id);
-            setDefaultProperties(frame, id);
-            return frame;
-        case Image:
-            SwingScilabUiImage image = new SwingScilabUiImage();
-            image.setId(id);
-            return image;
-        case ListBox:
-            SwingScilabListBox listBox = new SwingScilabListBox();
-            listBox.setId(id);
-            return listBox;
-        case PopupMenu:
-            SwingScilabPopupMenu popupMenu = new SwingScilabPopupMenu();
-            popupMenu.setId(id);
-            setDefaultProperties(popupMenu, id);
-            return popupMenu;
-        case Progressbar:
-            SwingScilabWaitBar progressbar = new SwingScilabWaitBar();
-            progressbar.setIndeterminateMode(true);
-            progressbar.setId(id);
-            return progressbar;
-        case PushButton:
-            SwingScilabPushButton pushButton = new SwingScilabPushButton();
-            pushButton.setId(id);
-            setDefaultProperties(pushButton, id);
-            return pushButton;
-        case RadioButton:
-            SwingScilabRadioButton radioButton = new SwingScilabRadioButton();
-            radioButton.setId(id);
-            setDefaultProperties(radioButton, id);
-            return radioButton;
-        case Slider:
-            SwingScilabSlider slider = new SwingScilabSlider();
-            slider.setId(id);
-            setDefaultProperties(slider, id);
-            return slider;
-        case Table:
-            SwingScilabUiTable table = new SwingScilabUiTable();
-            table.setId(id);
-            return table;
-        case Text:
-            SwingScilabLabel text = new SwingScilabLabel();
-            text.setId(id);
-            setDefaultProperties(text, id);
-            return text;
-        case Uimenu:
-            throw new UnsupportedOperationException();
-        case UiParentMenu: /* SwingView internal type */
-            SwingScilabMenu parentMenu = new SwingScilabMenu();
-            parentMenu.setId(id);
-            setMenuDefaultProperties(parentMenu, id);
-            return parentMenu;
-        case UiChildMenu: /* SwingView internal type */
-            SwingScilabMenuItem childMenu = new SwingScilabMenuItem();
-            childMenu.setId(id);
-            setMenuDefaultProperties(childMenu, id);
-            return childMenu;
-        case UiCheckedMenu: /* SwingView internal type */
-            SwingScilabCheckBoxMenuItem checkedMenu = new SwingScilabCheckBoxMenuItem(false);
-            checkedMenu.setId(id);
-            setMenuDefaultProperties(checkedMenu, id);
-            return checkedMenu;
-        case UiContextMenu:
-            SwingScilabContextMenu contextMenu = new SwingScilabContextMenu();
-            contextMenu.setId(id);
-            return contextMenu;
-        case Waitbar:
-            SwingScilabWaitBar waitbar = new SwingScilabWaitBar();
-            waitbar.setIndeterminateMode(false);
-            waitbar.setId(id);
-            return waitbar;
-        default:
-            return null;
+                String infoMessage = figure.getInfoMessage();
+                if ((infoMessage == null) || (infoMessage.length() == 0)) {
+                    infoBar.setText("");
+                } else {
+                    infoBar.setText(infoMessage);
+                }
+                tab.update(__GO_SIZE__, (Integer[]) GraphicController.getController().getProperty(id, __GO_SIZE__));
+                tab.update(__GO_POSITION__, (Integer[]) GraphicController.getController().getProperty(id, __GO_POSITION__));
+                // TODO set other default properties
+                return tab;
+            case Frame:
+                SwingScilabFrame frame = new SwingScilabFrame();
+                frame.setId(id);
+                setDefaultProperties(frame, id);
+                return frame;
+            case Image:
+                SwingScilabUiImage image = new SwingScilabUiImage();
+                image.setId(id);
+                setDefaultProperties(image, id);
+                return image;
+            case ListBox:
+                SwingScilabListBox listBox = new SwingScilabListBox();
+                listBox.setId(id);
+                setDefaultProperties(listBox, id);
+                return listBox;
+            case PopupMenu:
+                SwingScilabPopupMenu popupMenu = new SwingScilabPopupMenu();
+                popupMenu.setId(id);
+                setDefaultProperties(popupMenu, id);
+                return popupMenu;
+            case Progressbar:
+                SwingScilabWaitBar progressbar = new SwingScilabWaitBar();
+                progressbar.setIndeterminateMode(true);
+                progressbar.setId(id);
+                return progressbar;
+            case PushButton:
+                SwingScilabPushButton pushButton = new SwingScilabPushButton();
+                pushButton.setId(id);
+                setDefaultProperties(pushButton, id);
+                return pushButton;
+            case RadioButton:
+                SwingScilabRadioButton radioButton = new SwingScilabRadioButton();
+                radioButton.setId(id);
+                setDefaultProperties(radioButton, id);
+                return radioButton;
+            case Slider:
+                SwingScilabSlider slider = new SwingScilabSlider();
+                slider.setId(id);
+                setDefaultProperties(slider, id);
+                return slider;
+            case Table:
+                SwingScilabUiTable table = new SwingScilabUiTable();
+                table.setId(id);
+                setDefaultProperties(table, id);
+                return table;
+            case Text:
+                SwingScilabLabel text = new SwingScilabLabel();
+                text.setId(id);
+                setDefaultProperties(text, id);
+                return text;
+            case Uimenu:
+                throw new UnsupportedOperationException();
+            case UiParentMenu: /* SwingView internal type */
+                SwingScilabMenu parentMenu = new SwingScilabMenu();
+                parentMenu.setId(id);
+                setMenuDefaultProperties(parentMenu, id);
+                return parentMenu;
+            case UiChildMenu: /* SwingView internal type */
+                SwingScilabMenuItem childMenu = new SwingScilabMenuItem();
+                childMenu.setId(id);
+                setMenuDefaultProperties(childMenu, id);
+                return childMenu;
+            case UiCheckedMenu: /* SwingView internal type */
+                SwingScilabCheckBoxMenuItem checkedMenu = new SwingScilabCheckBoxMenuItem(false);
+                checkedMenu.setId(id);
+                setMenuDefaultProperties(checkedMenu, id);
+                return checkedMenu;
+            case UiContextMenu:
+                SwingScilabContextMenu contextMenu = new SwingScilabContextMenu();
+                contextMenu.setId(id);
+                return contextMenu;
+            case Waitbar:
+                SwingScilabWaitBar waitbar = new SwingScilabWaitBar();
+                waitbar.setIndeterminateMode(false);
+                waitbar.setId(id);
+                return waitbar;
+            default:
+                return null;
         }
     }
 
@@ -540,10 +543,10 @@ public final class SwingView implements GraphicView {
         final TypedObject requestedObject = allObjects.get(id);
         if (requestedObject != null) {
             switch (requestedObject.getType()) {
-            case Figure:
-                final SwingScilabTab tab = (SwingScilabTab) requestedObject.getValue();
-                tab.disablePaint();
-                SwingUtilities.invokeLater(new Runnable() {
+                case Figure:
+                    final SwingScilabTab tab = (SwingScilabTab) requestedObject.getValue();
+                    tab.disablePaint();
+                    SwingUtilities.invokeLater(new Runnable() {
                         public void run() {
                             DockingManager.close(tab);
                             DockingManager.unregisterDockable((Dockable) tab);
@@ -553,16 +556,16 @@ public final class SwingView implements GraphicView {
                             tab.close();
                         }
                     });
-                break;
-            case Progressbar:
-            case Waitbar:
-                SwingScilabWaitBar bar = (SwingScilabWaitBar) requestedObject.getValue();
-                bar.close();
-                break;
-            default:
-                // Nothing to do
-                // uicontrol case: the object is destroyed when its parent updates its children
-                break;
+                    break;
+                case Progressbar:
+                case Waitbar:
+                    SwingScilabWaitBar bar = (SwingScilabWaitBar) requestedObject.getValue();
+                    bar.close();
+                    break;
+                default:
+                    // Nothing to do
+                    // uicontrol case: the object is destroyed when its parent updates its children
+                    break;
             }
             allObjects.remove(id);
         }
@@ -592,41 +595,40 @@ public final class SwingView implements GraphicView {
         if (registeredObject != null && property == __GO_CHILDREN__) {
             String[] newChildren = (String[]) GraphicController.getController().getProperty(id, __GO_CHILDREN__);
 
-            switch(type)
-            {
-            /*
-             * FIGURE CHILDREN UPDATE
-             */
-            case __GO_FIGURE__ :
-                updateFigureChildren(id, newChildren);
-                break;
-            /*
-             * CONSOLE CHILDREN UPDATE
-             */
-            case __GO_CONSOLE__ :
-                updateConsoleChildren(id, newChildren);
-                break;
-            /*
-             * MENU CHILDREN UPDATE
-             */
-            case __GO_UIMENU__ :
-                updateMenuChildren(id, newChildren);
-                break;
-            /*
-             * CONTEXTMENU CHILDREN UPDATE
-             */
-            case __GO_UICONTEXTMENU__ :
-                updateContextMenuChildren(id, newChildren);
-                break;
-            /*
-             * UICONTROL "FRAME" CHILDREN UPDATE
-             */
-            case __GO_UICONTROL__ :
-                int style = (Integer) GraphicController.getController().getProperty(id, __GO_STYLE__);
-                if (style == __GO_UI_FRAME__) {
-                    updateFrameChildren(id, newChildren);
-                }
-                break;
+            switch (type) {
+                    /*
+                     * FIGURE CHILDREN UPDATE
+                     */
+                case __GO_FIGURE__ :
+                    updateFigureChildren(id, newChildren);
+                    break;
+                    /*
+                     * CONSOLE CHILDREN UPDATE
+                     */
+                case __GO_CONSOLE__ :
+                    updateConsoleChildren(id, newChildren);
+                    break;
+                    /*
+                     * MENU CHILDREN UPDATE
+                     */
+                case __GO_UIMENU__ :
+                    updateMenuChildren(id, newChildren);
+                    break;
+                    /*
+                     * CONTEXTMENU CHILDREN UPDATE
+                     */
+                case __GO_UICONTEXTMENU__ :
+                    updateContextMenuChildren(id, newChildren);
+                    break;
+                    /*
+                     * UICONTROL "FRAME" CHILDREN UPDATE
+                     */
+                case __GO_UICONTROL__ :
+                    int style = (Integer) GraphicController.getController().getProperty(id, __GO_STYLE__);
+                    if (style == __GO_UI_FRAME__) {
+                        updateFrameChildren(id, newChildren);
+                    }
+                    break;
             }
         }
 
@@ -638,21 +640,21 @@ public final class SwingView implements GraphicView {
             if (type == __GO_UIMENU__) {
                 TypedObject updatedObject = allObjects.get(id);
                 switch (updatedObject.getType()) {
-                case UiParentMenu:
-                    allObjects.put(id, CreateObjectFromType(__GO_UICHECKEDMENU__, id));
-                    registeredObject = allObjects.get(id);
-                    break;
-                case UiChildMenu:
-                    String parentId = (String) GraphicController.getController().getProperty(id, __GO_PARENT__);
-                    int index = ((SwingScilabMenu) allObjects.get(parentId).getValue())
-                        .getComponentZOrder((SwingScilabMenuItem) allObjects.get(id).getValue());
-                    ((SwingScilabMenu) allObjects.get(parentId).getValue()).remove((SwingScilabMenuItem) allObjects.get(id).getValue());
-                    allObjects.put(id, CreateObjectFromType(__GO_UICHECKEDMENU__, id));
-                    registeredObject = allObjects.get(id);
-                    ((SwingScilabMenu) allObjects.get(parentId).getValue()).add((SwingScilabCheckBoxMenuItem) allObjects.get(id).getValue(), index);
-                    return;
-                default:
-                    break;
+                    case UiParentMenu:
+                        allObjects.put(id, CreateObjectFromType(__GO_UICHECKEDMENU__, id));
+                        registeredObject = allObjects.get(id);
+                        break;
+                    case UiChildMenu:
+                        String parentId = (String) GraphicController.getController().getProperty(id, __GO_PARENT__);
+                        int index = ((SwingScilabMenu) allObjects.get(parentId).getValue())
+                                    .getComponentZOrder((SwingScilabMenuItem) allObjects.get(id).getValue());
+                        ((SwingScilabMenu) allObjects.get(parentId).getValue()).remove((SwingScilabMenuItem) allObjects.get(id).getValue());
+                        allObjects.put(id, CreateObjectFromType(__GO_UICHECKEDMENU__, id));
+                        registeredObject = allObjects.get(id);
+                        ((SwingScilabMenu) allObjects.get(parentId).getValue()).add((SwingScilabCheckBoxMenuItem) allObjects.get(id).getValue(), index);
+                        return;
+                    default:
+                        break;
                 }
             }
         }
@@ -727,14 +729,14 @@ public final class SwingView implements GraphicView {
                 if (childType == __GO_UIMENU__) {
                     TypedObject childAsTypedObject = allObjects.get(childId);
                     switch (childAsTypedObject.getType()) {
-                    case UiChildMenu:
-                    case UiCheckedMenu:
-                        allObjects.put(childId, CreateObjectFromType(__GO_UIPARENTMENU__, childId));
-                        ((Container) ((SwingScilabTab) updatedComponent).getMenuBar().getAsSimpleMenuBar()).add((SwingScilabMenu) allObjects.get(childId).getValue());
-                        break;
-                    default: /* UiParentMenu */
-                        ((Container) ((SwingScilabTab) updatedComponent).getMenuBar().getAsSimpleMenuBar()).add((SwingScilabMenu) allObjects.get(childId).getValue());
-                        break;
+                        case UiChildMenu:
+                        case UiCheckedMenu:
+                            allObjects.put(childId, CreateObjectFromType(__GO_UIPARENTMENU__, childId));
+                            ((Container) ((SwingScilabTab) updatedComponent).getMenuBar().getAsSimpleMenuBar()).add((SwingScilabMenu) allObjects.get(childId).getValue());
+                            break;
+                        default: /* UiParentMenu */
+                            ((Container) ((SwingScilabTab) updatedComponent).getMenuBar().getAsSimpleMenuBar()).add((SwingScilabMenu) allObjects.get(childId).getValue());
+                            break;
                     }
                     needRevalidate = true;
                 }
@@ -754,7 +756,7 @@ public final class SwingView implements GraphicView {
                 int childType = (Integer) GraphicController.getController().getProperty(childId, __GO_TYPE__);
 
                 /* Remove an uicontrol */
-                if (childType ==__GO_UICONTROL__) {
+                if (childType == __GO_UICONTROL__) {
                     ((SwingScilabTab) updatedComponent).removeMember(allObjects.get(childId).getValue());
                     needRevalidate = true;
                 }
@@ -763,12 +765,12 @@ public final class SwingView implements GraphicView {
                 if (childType == __GO_UIMENU__) {
                     TypedObject childAsTypedObject = allObjects.get(childId);
                     switch (childAsTypedObject.getType()) {
-                    case UiCheckedMenu:
-                        ((Container) ((SwingScilabTab) updatedComponent).getMenuBar().getAsSimpleMenuBar()).remove((SwingScilabCheckBoxMenuItem) allObjects.get(childId).getValue());
-                        break;
-                    default: /* UiParentMenu */
-                        ((Container) ((SwingScilabTab) updatedComponent).getMenuBar().getAsSimpleMenuBar()).remove((SwingScilabMenu) allObjects.get(childId).getValue());
-                        break;
+                        case UiCheckedMenu:
+                            ((Container) ((SwingScilabTab) updatedComponent).getMenuBar().getAsSimpleMenuBar()).remove((SwingScilabCheckBoxMenuItem) allObjects.get(childId).getValue());
+                            break;
+                        default: /* UiParentMenu */
+                            ((Container) ((SwingScilabTab) updatedComponent).getMenuBar().getAsSimpleMenuBar()).remove((SwingScilabMenu) allObjects.get(childId).getValue());
+                            break;
                     }
                     needRevalidate = true;
                 }
@@ -852,14 +854,14 @@ public final class SwingView implements GraphicView {
                 if (childType == __GO_UIMENU__) {
                     TypedObject childAsTypedObject = allObjects.get(childId);
                     switch (childAsTypedObject.getType()) {
-                    case UiChildMenu:
-                    case UiCheckedMenu:
-                        allObjects.put(childId, CreateObjectFromType(__GO_UIPARENTMENU__, childId));
-                        ((Container) ((SwingScilabTab) updatedObject.getValue()).getMenuBar().getAsSimpleMenuBar()).add((SwingScilabMenu) allObjects.get(childId).getValue());
-                        break;
-                    default: /* UiParentMenu */
-                        ((Container) ((SwingScilabTab) updatedObject.getValue()).getMenuBar().getAsSimpleMenuBar()).add((SwingScilabMenu) allObjects.get(childId).getValue());
-                        break;
+                        case UiChildMenu:
+                        case UiCheckedMenu:
+                            allObjects.put(childId, CreateObjectFromType(__GO_UIPARENTMENU__, childId));
+                            ((Container) ((SwingScilabTab) updatedObject.getValue()).getMenuBar().getAsSimpleMenuBar()).add((SwingScilabMenu) allObjects.get(childId).getValue());
+                            break;
+                        default: /* UiParentMenu */
+                            ((Container) ((SwingScilabTab) updatedObject.getValue()).getMenuBar().getAsSimpleMenuBar()).add((SwingScilabMenu) allObjects.get(childId).getValue());
+                            break;
                     }
                     needRevalidate = true;
                 }
@@ -914,83 +916,83 @@ public final class SwingView implements GraphicView {
                     Object addedChild = allObjects.get(childId).getValue();
                     JComponent parent = null;
                     switch (updatedObject.getType()) {
-                    case UiChildMenu:
-                        updatedComponent = (SwingScilabMenuItem) updatedObject.getValue();
-                        parent = (JComponent) updatedComponent.getParent();
-                        switch (childAsTypedObject.getType()) {
                         case UiChildMenu:
-                            /* Replace the item by a parent menu */
-                            updatedObjectPosition = parent.getComponentZOrder((SwingScilabMenuItem) allObjects.get(id).getValue());
-                            parent.remove((SwingScilabMenuItem) allObjects.get(id).getValue());
-                            newParent = CreateObjectFromType(__GO_UIPARENTMENU__, id);
-                            allObjects.put(id, newParent);
-                            newParent.addChild(childId);
-                            parent.add((SwingScilabMenu) allObjects.get(id).getValue(), updatedObjectPosition);
-                            /* Update the created menu */
-                            ((SwingScilabMenu) allObjects.get(id).getValue()).add((SwingScilabMenuItem) addedChild);
+                            updatedComponent = (SwingScilabMenuItem) updatedObject.getValue();
+                            parent = (JComponent) updatedComponent.getParent();
+                            switch (childAsTypedObject.getType()) {
+                                case UiChildMenu:
+                                    /* Replace the item by a parent menu */
+                                    updatedObjectPosition = parent.getComponentZOrder((SwingScilabMenuItem) allObjects.get(id).getValue());
+                                    parent.remove((SwingScilabMenuItem) allObjects.get(id).getValue());
+                                    newParent = CreateObjectFromType(__GO_UIPARENTMENU__, id);
+                                    allObjects.put(id, newParent);
+                                    newParent.addChild(childId);
+                                    parent.add((SwingScilabMenu) allObjects.get(id).getValue(), updatedObjectPosition);
+                                    /* Update the created menu */
+                                    ((SwingScilabMenu) allObjects.get(id).getValue()).add((SwingScilabMenuItem) addedChild);
+                                    break;
+                                case UiCheckedMenu:
+                                    /* Replace the item by a parent menu */
+                                    updatedObjectPosition = parent.getComponentZOrder((SwingScilabCheckBoxMenuItem) allObjects.get(id).getValue());
+                                    parent.remove((SwingScilabCheckBoxMenuItem) allObjects.get(id).getValue());
+                                    newParent = CreateObjectFromType(__GO_UIPARENTMENU__, id);
+                                    allObjects.put(id, newParent);
+                                    newParent.addChild(childId);
+                                    parent.add((SwingScilabMenu) allObjects.get(id).getValue(), updatedObjectPosition);
+                                    /* Update the created menu */
+                                    ((SwingScilabMenu) allObjects.get(id).getValue()).add((SwingScilabCheckBoxMenuItem) addedChild);
+                                    break;
+                                default: /* UiParentMenu */
+                                    ((SwingScilabMenu) allObjects.get(id).getValue()).add((SwingScilabMenu) addedChild);
+                                    break;
+                            }
                             break;
                         case UiCheckedMenu:
-                            /* Replace the item by a parent menu */
-                            updatedObjectPosition = parent.getComponentZOrder((SwingScilabCheckBoxMenuItem) allObjects.get(id).getValue());
-                            parent.remove((SwingScilabCheckBoxMenuItem) allObjects.get(id).getValue());
-                            newParent = CreateObjectFromType(__GO_UIPARENTMENU__, id);
-                            allObjects.put(id, newParent);
-                            newParent.addChild(childId);
-                            parent.add((SwingScilabMenu) allObjects.get(id).getValue(), updatedObjectPosition);
-                            /* Update the created menu */
-                            ((SwingScilabMenu) allObjects.get(id).getValue()).add((SwingScilabCheckBoxMenuItem) addedChild);
+                            updatedComponent = (SwingScilabCheckBoxMenuItem) updatedObject.getValue();
+                            parent = (JComponent) updatedComponent.getParent();
+                            switch (childAsTypedObject.getType()) {
+                                case UiChildMenu:
+                                    /* Replace the item by a parent menu */
+                                    updatedObjectPosition = parent.getComponentZOrder((SwingScilabCheckBoxMenuItem) allObjects.get(id).getValue());
+                                    parent.remove((SwingScilabCheckBoxMenuItem) allObjects.get(id).getValue());
+                                    newParent = CreateObjectFromType(__GO_UIPARENTMENU__, id);
+                                    allObjects.put(id, newParent);
+                                    newParent.addChild(childId);
+                                    parent.add((SwingScilabMenu) allObjects.get(id).getValue(), updatedObjectPosition);
+                                    /* Update the created menu */
+                                    ((SwingScilabMenu) allObjects.get(id).getValue()).add((SwingScilabMenuItem) allObjects.get(childId).getValue());
+                                    break;
+                                case UiCheckedMenu:
+                                    /* Replace the item by a parent menu */
+                                    updatedObjectPosition = parent.getComponentZOrder((SwingScilabCheckBoxMenuItem) allObjects.get(id).getValue());
+                                    parent.remove((SwingScilabCheckBoxMenuItem) allObjects.get(id).getValue());
+                                    newParent = CreateObjectFromType(__GO_UIPARENTMENU__, id);
+                                    allObjects.put(id, newParent);
+                                    newParent.addChild(childId);
+                                    parent.add((SwingScilabMenu) allObjects.get(id).getValue(), updatedObjectPosition);
+                                    /* Update the created menu */
+                                    ((SwingScilabMenu) allObjects.get(id).getValue()).add((SwingScilabCheckBoxMenuItem) allObjects.get(childId).getValue());
+                                    break;
+                                default: /* UiParentMenu */
+                                    ((SwingScilabMenu) allObjects.get(id).getValue()).add((SwingScilabMenu) allObjects.get(childId).getValue());
+                                    break;
+                            }
                             break;
                         default: /* UiParentMenu */
-                            ((SwingScilabMenu) allObjects.get(id).getValue()).add((SwingScilabMenu) addedChild);
-                            break;
-                        }
-                        break;
-                    case UiCheckedMenu:
-                        updatedComponent = (SwingScilabCheckBoxMenuItem) updatedObject.getValue();
-                        parent = (JComponent) updatedComponent.getParent();
-                        switch (childAsTypedObject.getType()) {
-                        case UiChildMenu:
-                            /* Replace the item by a parent menu */
-                            updatedObjectPosition = parent.getComponentZOrder((SwingScilabCheckBoxMenuItem) allObjects.get(id).getValue());
-                            parent.remove((SwingScilabCheckBoxMenuItem) allObjects.get(id).getValue());
-                            newParent = CreateObjectFromType(__GO_UIPARENTMENU__, id);
-                            allObjects.put(id, newParent);
-                            newParent.addChild(childId);
-                            parent.add((SwingScilabMenu) allObjects.get(id).getValue(), updatedObjectPosition);
-                            /* Update the created menu */
-                            ((SwingScilabMenu) allObjects.get(id).getValue()).add((SwingScilabMenuItem) allObjects.get(childId).getValue());
+                            SwingScilabMenu updatedMenu = (SwingScilabMenu) updatedObject.getValue();
+                            updatedComponent = updatedMenu;
+                            switch (childAsTypedObject.getType()) {
+                                case UiChildMenu:
+                                    updatedMenu.add((SwingScilabMenuItem) allObjects.get(childId).getValue());
+                                    break;
+                                case UiCheckedMenu:
+                                    updatedMenu.add((SwingScilabCheckBoxMenuItem) allObjects.get(childId).getValue());
+                                    break;
+                                default: /* UiParentMenu */
+                                    updatedMenu.add((SwingScilabMenu) allObjects.get(childId).getValue());
+                                    break;
+                            }
                             break;
-                        case UiCheckedMenu:
-                            /* Replace the item by a parent menu */
-                            updatedObjectPosition = parent.getComponentZOrder((SwingScilabCheckBoxMenuItem) allObjects.get(id).getValue());
-                            parent.remove((SwingScilabCheckBoxMenuItem) allObjects.get(id).getValue());
-                            newParent = CreateObjectFromType(__GO_UIPARENTMENU__, id);
-                            allObjects.put(id, newParent);
-                            newParent.addChild(childId);
-                            parent.add((SwingScilabMenu) allObjects.get(id).getValue(), updatedObjectPosition);
-                            /* Update the created menu */
-                            ((SwingScilabMenu) allObjects.get(id).getValue()).add((SwingScilabCheckBoxMenuItem) allObjects.get(childId).getValue());
-                            break;
-                        default: /* UiParentMenu */
-                            ((SwingScilabMenu) allObjects.get(id).getValue()).add((SwingScilabMenu) allObjects.get(childId).getValue());
-                            break;
-                        }
-                        break;
-                    default: /* UiParentMenu */
-                        SwingScilabMenu updatedMenu = (SwingScilabMenu) updatedObject.getValue();
-                        updatedComponent = updatedMenu;
-                        switch (childAsTypedObject.getType()) {
-                        case UiChildMenu:
-                            updatedMenu.add((SwingScilabMenuItem) allObjects.get(childId).getValue());
-                            break;
-                        case UiCheckedMenu:
-                            updatedMenu.add((SwingScilabCheckBoxMenuItem) allObjects.get(childId).getValue());
-                            break;
-                        default: /* UiParentMenu */
-                            updatedMenu.add((SwingScilabMenu) allObjects.get(childId).getValue());
-                            break;
-                        }
-                        break;
                     }
                     needRevalidate = true;
                 }
@@ -1011,15 +1013,15 @@ public final class SwingView implements GraphicView {
                 Object removedMenu = allObjects.get(childId).getValue();
 
                 switch (childAsTypedObject.getType()) {
-                case UiChildMenu:
-                    updatedMenu.remove((SwingScilabMenuItem) removedMenu);
-                    break;
-                case UiCheckedMenu:
-                    updatedMenu.remove((SwingScilabCheckBoxMenuItem) removedMenu);
-                    break;
-                default:
-                    updatedMenu.remove((SwingScilabMenu) removedMenu);
-                    break;
+                    case UiChildMenu:
+                        updatedMenu.remove((SwingScilabMenuItem) removedMenu);
+                        break;
+                    case UiCheckedMenu:
+                        updatedMenu.remove((SwingScilabCheckBoxMenuItem) removedMenu);
+                        break;
+                    default:
+                        updatedMenu.remove((SwingScilabMenu) removedMenu);
+                        break;
                 }
                 needRevalidate = true;
             }
@@ -1051,15 +1053,15 @@ public final class SwingView implements GraphicView {
                     SwingScilabContextMenu updatedMenu = (SwingScilabContextMenu) updatedObject.getValue();
                     updatedComponent = updatedMenu;
                     switch (childAsTypedObject.getType()) {
-                    case UiChildMenu:
-                        updatedMenu.add((SwingScilabMenuItem) allObjects.get(childId).getValue());
-                        break;
-                    case UiCheckedMenu:
-                        updatedMenu.add((SwingScilabCheckBoxMenuItem) allObjects.get(childId).getValue());
-                        break;
-                    default: /* UiParentMenu */
-                        updatedMenu.add((SwingScilabMenu) allObjects.get(childId).getValue());
-                        break;
+                        case UiChildMenu:
+                            updatedMenu.add((SwingScilabMenuItem) allObjects.get(childId).getValue());
+                            break;
+                        case UiCheckedMenu:
+                            updatedMenu.add((SwingScilabCheckBoxMenuItem) allObjects.get(childId).getValue());
+                            break;
+                        default: /* UiParentMenu */
+                            updatedMenu.add((SwingScilabMenu) allObjects.get(childId).getValue());
+                            break;
                     }
                     needRevalidate = true;
                 }
@@ -1078,15 +1080,15 @@ public final class SwingView implements GraphicView {
                 Object removedMenu = allObjects.get(childId).getValue();
 
                 switch (childAsTypedObject.getType()) {
-                case UiChildMenu:
-                    updatedMenu.remove((SwingScilabMenuItem) removedMenu);
-                    break;
-                case UiCheckedMenu:
-                    updatedMenu.remove((SwingScilabCheckBoxMenuItem) removedMenu);
-                    break;
-                default:
-                    updatedMenu.remove((SwingScilabMenu) removedMenu);
-                    break;
+                    case UiChildMenu:
+                        updatedMenu.remove((SwingScilabMenuItem) removedMenu);
+                        break;
+                    case UiCheckedMenu:
+                        updatedMenu.remove((SwingScilabCheckBoxMenuItem) removedMenu);
+                        break;
+                    default:
+                        updatedMenu.remove((SwingScilabMenu) removedMenu);
+                        break;
                 }
                 needRevalidate = true;
             }
index ab761da..358be7d 100644 (file)
@@ -222,8 +222,8 @@ public final class SwingViewWidget {
                 double minorSliderStep = sliderStep[0].doubleValue();
                 double majorSliderStep = sliderStep[1].doubleValue();
                 if (minValue <= maxValue) {
-                    ((SwingScilabSlider) uiControl).setMinorTickSpacing((int) (minorSliderStep * (maxValue - minValue)));
-                    ((SwingScilabSlider) uiControl).setMajorTickSpacing((int) (majorSliderStep * (maxValue - minValue)));
+                    ((SwingScilabSlider) uiControl).setMinorTickSpacing(minorSliderStep);
+                    ((SwingScilabSlider) uiControl).setMajorTickSpacing(majorSliderStep);
                 }
             } else if (uiControl instanceof SwingScilabListBox) {
                 // Enable/Disable multiple selection
@@ -247,8 +247,8 @@ public final class SwingViewWidget {
                 double minorSliderStep = sliderStep[0].doubleValue();
                 double majorSliderStep = sliderStep[1].doubleValue();
                 if (minValue <= maxValue) {
-                    ((SwingScilabSlider) uiControl).setMinorTickSpacing((int) (minorSliderStep * (maxValue - minValue)));
-                    ((SwingScilabSlider) uiControl).setMajorTickSpacing((int) (majorSliderStep * (maxValue - minValue)));
+                    ((SwingScilabSlider) uiControl).setMinorTickSpacing(minorSliderStep);
+                    ((SwingScilabSlider) uiControl).setMajorTickSpacing(majorSliderStep);
                 }
             } else if (uiControl instanceof SwingScilabListBox) {
                 // Enable/Disable multiple selection
index 2d40842..08ace49 100644 (file)
@@ -21,6 +21,7 @@ import java.awt.event.AdjustmentEvent;
 import java.awt.event.AdjustmentListener;
 
 import javax.swing.JScrollBar;
+import javax.swing.SwingUtilities;
 
 import org.scilab.modules.graphic_objects.graphicController.GraphicController;
 import org.scilab.modules.gui.SwingViewWidget;
@@ -48,7 +49,7 @@ public class SwingScilabSlider extends JScrollBar implements SwingViewObject, Si
     private static final int MIN_KNOB_SIZE = 40;
 
     private static final int MINIMUM_VALUE = 0;
-    private static final int MAXIMUM_VALUE = 1000;
+    private static final int MAXIMUM_VALUE = 10000;
 
     private String uid;
 
@@ -207,7 +208,7 @@ public class SwingScilabSlider extends JScrollBar implements SwingViewObject, Si
      * @param value the minimum value
      */
     public void setMinimumValue(double value) {
-        updateModel();
+        updateModel(); /* Update the model according to the knob position */
     }
 
     /**
@@ -215,7 +216,7 @@ public class SwingScilabSlider extends JScrollBar implements SwingViewObject, Si
      * @param value the maximum value
      */
     public void setMaximumValue(double value) {
-        updateModel();
+        updateModel(); /* Update the model according to the knob position */
     }
 
     /**
@@ -234,9 +235,11 @@ public class SwingScilabSlider extends JScrollBar implements SwingViewObject, Si
         /* Remove the listener to avoid the callback to be executed */
         removeAdjustmentListener(adjustmentListener);
 
-        setBlockIncrement((int) (space * (MAXIMUM_VALUE - MINIMUM_VALUE)));
+        double userMin = (Double) GraphicController.getController().getProperty(uid, __GO_UI_MIN__);
+        double userMax = (Double) GraphicController.getController().getProperty(uid, __GO_UI_MAX__);
+        setBlockIncrement((int) (space * (MAXIMUM_VALUE - MINIMUM_VALUE) / (userMax - userMin)));
         int oldMax = getMaximum() - getVisibleAmount();
-        setVisibleAmount(Math.max((int) (space * (MAXIMUM_VALUE - MINIMUM_VALUE)), MIN_KNOB_SIZE));
+        setVisibleAmount(Math.max((int) ((MAXIMUM_VALUE - MINIMUM_VALUE) / space), MIN_KNOB_SIZE));
         setMaximum(oldMax + getVisibleAmount());
 
         /* Put back the listener */
@@ -251,7 +254,9 @@ public class SwingScilabSlider extends JScrollBar implements SwingViewObject, Si
         /* Remove the listener to avoid the callback to be executed */
         removeAdjustmentListener(adjustmentListener);
 
-        setUnitIncrement((int) (space * (MAXIMUM_VALUE - MINIMUM_VALUE)));
+        double userMin = (Double) GraphicController.getController().getProperty(uid, __GO_UI_MIN__);
+        double userMax = (Double) GraphicController.getController().getProperty(uid, __GO_UI_MAX__);
+        setUnitIncrement((int) (space * (MAXIMUM_VALUE - MINIMUM_VALUE) / (userMax - userMin)));
 
         /* Put back the listener */
         addAdjustmentListener(adjustmentListener);
@@ -301,15 +306,17 @@ public class SwingScilabSlider extends JScrollBar implements SwingViewObject, Si
      * @param value the new value
      */
     public void setUserValue(double value) {
-        /* Remove the listener to avoid the callback to be executed */
-        removeAdjustmentListener(adjustmentListener);
+        if (!SwingUtilities.isEventDispatchThread()) { /* Avoid double-update when Model is updated from the callback */
+            /* Remove the listener to avoid the callback to be executed */
+            removeAdjustmentListener(adjustmentListener);
 
-        double userMin = (Double) GraphicController.getController().getProperty(uid, __GO_UI_MIN__);
-        double userMax = (Double) GraphicController.getController().getProperty(uid, __GO_UI_MAX__);
-        super.setValue(MINIMUM_VALUE + (int) ((value - userMin) * (MAXIMUM_VALUE - MINIMUM_VALUE) / (userMax - userMin)));
+            double userMin = (Double) GraphicController.getController().getProperty(uid, __GO_UI_MIN__);
+            double userMax = (Double) GraphicController.getController().getProperty(uid, __GO_UI_MAX__);
+            super.setValue(MINIMUM_VALUE + (int) ((value - userMin) * (MAXIMUM_VALUE - MINIMUM_VALUE) / (userMax - userMin)));
 
-        /* Put back the listener */
-        addAdjustmentListener(adjustmentListener);
+            /* Put back the listener */
+            addAdjustmentListener(adjustmentListener);
+        }
     }
 
     /**
diff --git a/scilab/modules/gui/tests/nonreg_tests/bug_11489.tst b/scilab/modules/gui/tests/nonreg_tests/bug_11489.tst
new file mode 100644 (file)
index 0000000..5db5f00
--- /dev/null
@@ -0,0 +1,106 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2012 - Scilab Enterprises - Vincent COUVERT
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- Non-regression test for bug 11489 -->
+// <-- TEST WITH GRAPHIC -->
+// <-- INTERACTIVE TEST -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/11489
+//
+// <-- Short Description -->
+// 'SliderStep' property was ignored for uicontrols.
+
+// 1 - Create a slider without setting the SliderStep property
+f = gcf();
+editH = uicontrol("Parent", f, ..
+        "Style", "edit", ..
+        "Position", [60 36 50 16], ..
+        "String", "500", ..
+        "Backgroundcolor", [1 1 1], ..
+        "Tag", "edit");
+
+sliderH = uicontrol("Parent", f, ..
+        "Style", "slider", ..
+        "Position", [10 8 200 20], ..
+        "Value", 500, ..
+        "Min", 0, ..
+        "Max", 1000, ..
+        "Tag", "slider", ..
+        "Callback", "cbSlider");
+
+function cbSlider()
+    s = findobj("Tag", "slider");
+    e = findobj("Tag", "edit");
+    sVal = get(s, "value");
+    set(e, "String", string(sVal));
+endfunction
+
+// Click on the slider arrows and check that the value in the edit change with a step of 10
+// Click in the slider (arround the knob) and check that the value in the edit change with a step of 100
+
+delete(gcf())
+
+// 2 - Create a slider setting only the first value of the SliderStep property
+f = gcf();
+editH = uicontrol("Parent", f, ..
+        "Style", "edit", ..
+        "Position", [60 36 50 16], ..
+        "String", "500", ..
+        "Backgroundcolor", [1 1 1], ..
+        "Tag", "edit");
+
+sliderH = uicontrol("Parent", f, ..
+        "Style", "slider", ..
+        "Position", [10 8 200 20], ..
+        "Value", 500, ..
+        "Min", 0, ..
+        "Max", 1000, ..
+        "Tag", "slider", ..
+        "SliderStep", 50, ..
+        "Callback", "cbSlider");
+
+function cbSlider()
+    s = findobj("Tag", "slider");
+    e = findobj("Tag", "edit");
+    sVal = get(s, "value");
+    set(e, "String", string(sVal));
+endfunction
+
+// Click on the slider arrows and check that the value in the edit change with a step of 50
+// Click in the slider (arround the knob) and check that the value in the edit change with a step of 100
+
+// 3 - Create a slider setting the SliderStep property
+f = gcf();
+editH = uicontrol("Parent", f, ..
+        "Style", "edit", ..
+        "Position", [60 36 50 16], ..
+        "String", "500", ..
+        "Backgroundcolor", [1 1 1], ..
+        "Tag", "edit");
+
+sliderH = uicontrol("Parent", f, ..
+        "Style", "slider", ..
+        "Position", [10 8 200 20], ..
+        "Value", 500, ..
+        "Min", 0, ..
+        "Max", 1000, ..
+        "Tag", "slider", ..
+        "SliderStep", [100 200], ..
+        "Callback", "cbSlider");
+
+function cbSlider()
+    s = findobj("Tag", "slider");
+    e = findobj("Tag", "edit");
+    sVal = get(s, "value");
+    set(e, "String", string(sVal));
+endfunction
+
+// Click on the slider arrows and check that the value in the edit change with a step of 100
+// Click in the slider (arround the knob) and check that the value in the edit change with a step of 200
+
+delete(gcf())