use scrollable property to disable word wrap in editbox 43/13943/3
Antoine ELIAS [Thu, 6 Mar 2014 16:15:22 +0000 (17:15 +0100)]
Change-Id: I5bd1ab0bc390ad4173c63e3c9fffa99aae14080c

scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/xmlloader/GOBuilder.java
scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/xmlloader/XmlSaver.java
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/editbox/SwingScilabEditBox.java

index 8748351..47ab97d 100644 (file)
@@ -528,9 +528,9 @@ public class GOBuilder {
                         }
                     }
 
-                    item = xmlAttributes.get("columns");
-                    if (item != null) {
-                        controller.setProperty(uic, __GO_UI_MAX__, Double.parseDouble(item));
+                    item = xmlAttributes.get("scrollable");
+                    if (item != null && (item.equals("true") || item.equals("on"))) {
+                        controller.setProperty(uic, __GO_UI_SCROLLABLE__, true);
                     }
 
                     //callback
index fe37950..b6ef830 100644 (file)
@@ -394,9 +394,6 @@ public class XmlSaver {
                 appendChild(elemUi, createBorders(doc, iBorders));
             }
 
-            //Scrollable
-            setAttribute(elemUi, "scrollable", createAttribute(uic.getScrollable()), createAttribute(defaultUi.getScrollable()));
-
             //Layout
             setAttribute(elemUi, "layout", createAttribute(uic.getLayout()), createAttribute(defaultUi.getLayout()));
             //Layout_options
@@ -408,6 +405,11 @@ public class XmlSaver {
             }
         }
 
+        if (uic.getStyleAsEnum() == UicontrolStyle.FRAME || uic.getStyleAsEnum() == UicontrolStyle.EDIT) {
+            //Scrollable
+            setAttribute(elemUi, "scrollable", createAttribute(uic.getScrollable()), createAttribute(defaultUi.getScrollable()));
+        }
+
         controller.deleteObject(defaultUi.getIdentifier());
         //children
         Integer[] children = uic.getChildren();
index bcf894a..efaa88f 100644 (file)
 
 package org.scilab.modules.gui.bridge.editbox;
 
-import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_BACKGROUNDCOLOR__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_SCROLLABLE__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_MAX__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_BACKGROUNDCOLOR__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_MIN__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_STRING__;
 
+import java.awt.BorderLayout;
 import java.awt.Color;
 import java.awt.Font;
 import java.awt.event.ActionEvent;
@@ -28,6 +30,7 @@ import java.awt.event.KeyEvent;
 
 import javax.swing.AbstractAction;
 import javax.swing.InputMap;
+import javax.swing.JPanel;
 import javax.swing.JScrollPane;
 import javax.swing.JTextPane;
 import javax.swing.KeyStroke;
@@ -84,6 +87,8 @@ public class SwingScilabEditBox extends JScrollPane implements SwingViewObject,
     private SimpleAttributeSet docAttributes = new SimpleAttributeSet();
 
     private JTextPane textPane = new JTextPane();
+    //use to disable wordwarp
+    private JPanel noWrapPanel = new JPanel(new BorderLayout());
 
     private Object enterKeyAction;
     private Object tabKeyAction;
@@ -500,6 +505,10 @@ public class SwingScilabEditBox extends JScrollPane implements SwingViewObject,
                 }
                 break;
             }
+            case __GO_UI_SCROLLABLE__ : {
+                setScrollable((Boolean)value);
+                break;
+            }
             default: {
                 SwingViewWidget.update(this, property, value);
                 break;
@@ -507,6 +516,15 @@ public class SwingScilabEditBox extends JScrollPane implements SwingViewObject,
         }
     }
 
+    public void setScrollable(Boolean scrollable) {
+        if (scrollable) {
+            setViewportView(noWrapPanel);
+            noWrapPanel.add(textPane);
+        } else {
+            setViewportView(textPane);
+        }
+    }
+
     public String getText() {
         return textPane.getText();
     }