]> source.dussan.org Git - vaadin-framework.git/commitdiff
Major layout API changes: Sizeable is now deprecated. Use HasSize-interface instead...
authorJouni Koivuviita <jouni.koivuviita@itmill.com>
Thu, 13 Dec 2007 10:11:49 +0000 (10:11 +0000)
committerJouni Koivuviita <jouni.koivuviita@itmill.com>
Thu, 13 Dec 2007 10:11:49 +0000 (10:11 +0000)
svn changeset:3228/svn branch:trunk

47 files changed:
src/com/itmill/toolkit/demo/BrowserDemo.java
src/com/itmill/toolkit/demo/LayoutDemo.java
src/com/itmill/toolkit/demo/NativeWindowing.java
src/com/itmill/toolkit/demo/Parameters.java
src/com/itmill/toolkit/demo/TreeFilesystem.java
src/com/itmill/toolkit/demo/TreeFilesystemContainer.java
src/com/itmill/toolkit/demo/WindowedDemos.java
src/com/itmill/toolkit/demo/featurebrowser/EmbeddedBrowserExample.java
src/com/itmill/toolkit/demo/featurebrowser/FeatureBrowser.java
src/com/itmill/toolkit/demo/featurebrowser/TableExample.java
src/com/itmill/toolkit/demo/featurebrowser/TreeExample.java
src/com/itmill/toolkit/demo/reservation/ReservationApplication.java
src/com/itmill/toolkit/terminal/HasSize.java [new file with mode: 0644]
src/com/itmill/toolkit/terminal/Size.java [new file with mode: 0644]
src/com/itmill/toolkit/terminal/Sizeable.java
src/com/itmill/toolkit/tests/BasicRandomTest.java
src/com/itmill/toolkit/tests/RandomLayoutStress.java
src/com/itmill/toolkit/tests/TestBench.java
src/com/itmill/toolkit/tests/TestComponentsAndLayouts.java
src/com/itmill/toolkit/tests/TestForAlignments.java
src/com/itmill/toolkit/tests/TestForApplicationLayoutThatUsesWholeBrosersSpace.java
src/com/itmill/toolkit/tests/TestForBasicApplicationLayout.java
src/com/itmill/toolkit/tests/TestForContainerFilterable.java
src/com/itmill/toolkit/tests/TestForExpandLayout.java
src/com/itmill/toolkit/tests/TestForNativeWindowing.java
src/com/itmill/toolkit/tests/TestForPreconfiguredComponents.java
src/com/itmill/toolkit/tests/TestForTablesInitialColumnWidthLogicRendering.java
src/com/itmill/toolkit/tests/TestForTrees.java
src/com/itmill/toolkit/tests/featurebrowser/Feature.java
src/com/itmill/toolkit/tests/featurebrowser/FeatureWindow.java
src/com/itmill/toolkit/tests/featurebrowser/PropertyPanel.java
src/com/itmill/toolkit/tests/magi/MagiTestApplication.java
src/com/itmill/toolkit/tests/testbench/TestBench.java
src/com/itmill/toolkit/tests/testbench/TestForAlignments.java
src/com/itmill/toolkit/tests/testbench/TestForBasicApplicationLayout.java
src/com/itmill/toolkit/tests/testbench/TestForContainerFilterable.java
src/com/itmill/toolkit/tests/testbench/TestForPreconfiguredComponents.java
src/com/itmill/toolkit/tests/testbench/TestForTrees.java
src/com/itmill/toolkit/ui/AbstractLayout.java
src/com/itmill/toolkit/ui/CustomLayout.java
src/com/itmill/toolkit/ui/ExpandLayout.java
src/com/itmill/toolkit/ui/GridLayout.java
src/com/itmill/toolkit/ui/Layout.java
src/com/itmill/toolkit/ui/Panel.java
src/com/itmill/toolkit/ui/SplitPanel.java
src/com/itmill/toolkit/ui/TabSheet.java
src/com/itmill/toolkit/ui/Table.java

index 13d4bc5d0c005f97ff959e1d7758acff822cb6e0..e4b70b2bee7aff856ede9ac9c719381a9c8d5521 100644 (file)
@@ -37,7 +37,7 @@ public class BrowserDemo extends com.itmill.toolkit.Application implements
         // possible.
         final ExpandLayout exl = new ExpandLayout();
         browser.setLayout(exl);
-        exl.setSizeFull();
+        exl.getSize().setSizeFull();
 
         // create the address combobox
         final Select select = new Select();
index a3a671dffe3eb6aee20be4e4075252674cedeea9..0704a22dcd7a34f802600705c3880a6af3cacc28 100644 (file)
@@ -127,7 +127,7 @@ public class LayoutDemo extends com.itmill.toolkit.Application {
                                 + " Panel contains an layout where the actual contained components are added, "
                                 + "this layout may be switched on the fly.",
                         Label.CONTENT_XHTML));
-        panel.setWidth(222);
+        panel.getSize().setWidth(222);
         return panel;
     }
 
index 7dadd7c4bb0aea0062810de62fd213d701258c3a..4d98203cdc41afee64ae55065921086e334bca49 100644 (file)
@@ -29,11 +29,11 @@ public class NativeWindowing extends Application {
                         main.addWindow(w);
                         w.setPositionX(100);
                         w.setPositionY(100);
-                        w.setWidth(200);
-                        w.setHeight(200);
+                        w.getSize().setWidth(200);
+                        w.getSize().setHeight(200);
 
-                        w.setWidth(100);
-                        w.setHeight(400);
+                        w.getSize().setWidth(100);
+                        w.getSize().setHeight(400);
 
                         final Button closebutton = new Button("Close "
                                 + w.getCaption(), new Button.ClickListener() {
index 204860e44b08305c4bc544b15a80595131e2e7a1..65e203c729a65e01dcc735aaacc15b5c2903e476 100644 (file)
@@ -11,7 +11,6 @@ import java.util.Map;
 import com.itmill.toolkit.terminal.DownloadStream;
 import com.itmill.toolkit.terminal.ExternalResource;
 import com.itmill.toolkit.terminal.ParameterHandler;
-import com.itmill.toolkit.terminal.Sizeable;
 import com.itmill.toolkit.terminal.URIHandler;
 import com.itmill.toolkit.ui.ExpandLayout;
 import com.itmill.toolkit.ui.Label;
@@ -74,10 +73,7 @@ public class Parameters extends com.itmill.toolkit.Application implements
         params.addContainerProperty("Key", String.class, "");
         params.addContainerProperty("Value", String.class, "");
         final Panel panel2 = new Panel("Parameter Handler");
-        params.setHeight(100);
-        params.setHeightUnits(Sizeable.UNITS_PERCENTAGE);
-        panel2.setHeight(100);
-        panel2.setHeightUnits(Sizeable.UNITS_PERCENTAGE);
+        params.getSize().setSizeFull();
         panel2.setLayout(new ExpandLayout());
         panel2.getLayout().setMargin(true);
 
index 7fa1f3a1f4f8c0636bfb4f3972cfdba1e5171297..79f7c3624de7ec1f88caf78acf721e9e9f49dc93 100644 (file)
@@ -42,7 +42,7 @@ public class TreeFilesystem extends com.itmill.toolkit.Application implements
         // configure file structure panel
         main.addComponent(explorerPanel);
         explorerPanel.addComponent(tree);
-        explorerPanel.setHeight(400);
+        explorerPanel.getSize().setHeight(400);
 
         // "this" handles tree's expand event
         tree.addListener(this);
index 6ccc7522eccd960653888cdc555cb483728858ef..2831804443753a5e7ba2199e2219eac7f12d06c1 100644 (file)
@@ -51,10 +51,10 @@ public class TreeFilesystemContainer extends com.itmill.toolkit.Application
         main.setMargin(true);
         main.setSpacing(true);
 
-        propertyPanel.setHeight(120);
+        propertyPanel.getSize().setHeight(120);
         main.addComponent(propertyPanel);
-        explorerPanel.setHeight(100);
-        explorerPanel.setHeightUnits(Sizeable.UNITS_PERCENTAGE);
+        explorerPanel.getSize().setHeight(100);
+        explorerPanel.getSize().setHeightUnits(Sizeable.UNITS_PERCENTAGE);
         main.addComponent(explorerPanel);
         main.expand(explorerPanel);
 
index 6ec59bf629aae336cacf2830c06cf11d9d599978..f0102ac110760e9ef73e1cd0e37147a1d4963c02 100644 (file)
@@ -45,8 +45,8 @@ public class WindowedDemos extends com.itmill.toolkit.Application {
 
         // Create menu window.
         final Window menu = new Window("Select demo");
-        menu.setWidth(200);
-        menu.setHeight(400);
+        menu.getSize().setWidth(200);
+        menu.getSize().setHeight(400);
         main.addWindow(menu); // add to layout
 
         // Create a menu button for each demo
@@ -75,8 +75,8 @@ public class WindowedDemos extends com.itmill.toolkit.Application {
         Window w = (Window) windows.get(demoName);
         if (w == null) {
             w = new Window(demoName);
-            w.setWidth(520);
-            w.setHeight(500);
+            w.getSize().setWidth(520);
+            w.getSize().setHeight(500);
             w.setPositionX(202);
             windows.put(demoName, w);
             getMainWindow().addWindow(w);
index 7391fc135ecdf4db9a4632a9562e30a591f0128a..d592be5b537a0eca686cc52bcbc6e3c11148b223 100644 (file)
@@ -34,7 +34,7 @@ public class EmbeddedBrowserExample extends ExpandLayout implements
     }
 
     public EmbeddedBrowserExample(String[] urls) {
-        setSizeFull();
+        getSize().setSizeFull();
 
         // create the address combobox
         final Select select = new Select();
index 1088cd789d997c24f7fb47585c5109fe728589e0..0071b081b49498b79a6f67167d35fe7cb4678065 100644 (file)
@@ -12,7 +12,7 @@ import com.itmill.toolkit.data.Property.ValueChangeEvent;
 import com.itmill.toolkit.data.util.HierarchicalContainer;
 import com.itmill.toolkit.data.util.IndexedContainer;
 import com.itmill.toolkit.terminal.ExternalResource;
-import com.itmill.toolkit.terminal.Sizeable;
+import com.itmill.toolkit.terminal.Size;
 import com.itmill.toolkit.terminal.ThemeResource;
 import com.itmill.toolkit.ui.AbstractSelect;
 import com.itmill.toolkit.ui.Button;
@@ -110,7 +110,7 @@ public class FeatureBrowser extends com.itmill.toolkit.Application implements
 
         final SplitPanel split = new SplitPanel(
                 SplitPanel.ORIENTATION_HORIZONTAL);
-        split.setSplitPosition(200, Sizeable.UNITS_PIXELS);
+        split.setSplitPosition(200, Size.UNITS_PIXELS);
         main.setLayout(split);
 
         final HashMap sectionIds = new HashMap();
@@ -153,11 +153,11 @@ public class FeatureBrowser extends com.itmill.toolkit.Application implements
         split.addComponent(tree);
 
         final SplitPanel split2 = new SplitPanel();
-        split2.setSplitPosition(200, Sizeable.UNITS_PIXELS);
+        split2.setSplitPosition(200, Size.UNITS_PIXELS);
         split.addComponent(split2);
 
         table = new Table();
-        table.setSizeFull();
+        table.getSize().setSizeFull();
         table.setColumnReorderingAllowed(true);
         table.setColumnCollapsingAllowed(true);
         table.setSelectable(true);
@@ -193,11 +193,11 @@ public class FeatureBrowser extends com.itmill.toolkit.Application implements
                     return;
                 }
                 Window w = new Window(caption);
-                w.setWidth(640);
+                w.getSize().setWidth(640);
                 if (Layout.class.isAssignableFrom(component.getClass())) {
                     w.setLayout((Layout) component);
                 } else {
-                    w.getLayout().setSizeFull();
+                    //w.getLayout().getSize().setSizeFull();
                     w.addComponent(component);
                 }
                 getMainWindow().addWindow(w);
@@ -224,7 +224,7 @@ public class FeatureBrowser extends com.itmill.toolkit.Application implements
                     if (Layout.class.isAssignableFrom(component.getClass())) {
                         w.setLayout((Layout) component);
                     } else {
-                        w.getLayout().setSizeFull();
+                        //w.getLayout().getSize().setSizeFull();
                         w.addComponent(component);
                     }
                     addWindow(w);
@@ -240,7 +240,7 @@ public class FeatureBrowser extends com.itmill.toolkit.Application implements
                 OrderedLayout.ALIGNMENT_TOP);
 
         ts = new TabSheet();
-        ts.setSizeFull();
+        ts.getSize().setSizeFull();
         ts.addTab(new Label(""), "Choose example", null);
         exp.addComponent(ts);
         exp.expand(ts);
index 29c55f224d02996675e85e4811648dc3b1d92783..e42d50bebb1fc11ec340b06d9c1739fd5e164d96 100644 (file)
@@ -57,7 +57,7 @@ public class TableExample extends CustomComponent implements Action.Handler,
         // "source" table with bells & whistlesenabled\r
         source = new Table("All creatures");\r
         source.setPageLength(7);\r
-        source.setWidth(550);\r
+        source.getSize().setWidth(550);\r
         source.setColumnCollapsingAllowed(true);\r
         source.setColumnReorderingAllowed(true);\r
         source.setSelectable(true);\r
@@ -92,7 +92,7 @@ public class TableExample extends CustomComponent implements Action.Handler,
         // "saved" table, minimalistic\r
         saved = new Table("Saved creatures");\r
         saved.setPageLength(5);\r
-        saved.setWidth(550);\r
+        saved.getSize().setWidth(550);\r
         saved.setSelectable(false);\r
         saved.setColumnHeaderMode(Table.COLUMN_HEADER_MODE_HIDDEN);\r
         saved.setRowHeaderMode(Table.ROW_HEADER_MODE_ID);\r
index 694c839fb46b7b7a61b84a597fefd7ada3732de4..fb9f0a34ffc9ff17531d5f7ad95e2f17db6f2800 100644 (file)
@@ -45,7 +45,7 @@ public class TreeExample extends CustomComponent implements Action.Handler,
         // Panel w/ Tree
         Panel p = new Panel("Select item");
         p.setStyleName(Panel.STYLE_LIGHT);
-        p.setWidth(250);
+        p.getSize().setWidth(250);
         // Description
         p.addComponent(new Label(desc));
         // Tree with a few items
index db8b0c99bd529c23ddc92892b43431ead45c4c95..d53c7fd1d117fd53ee8d9261497efba2815eea90 100644 (file)
@@ -99,7 +99,7 @@ public class ReservationApplication extends Application {
 \r
         map = new GoogleMap();\r
         // TODO support EM\r
-        // map.setWidthUnits(Sizeable.UNITS_EM);\r
+        // map.setWidthUnits(Size.UNITS_EM);\r
         map.setWidth(266);\r
         map.setHeight(210);\r
         map.setItemMarkerHtmlPropertyId(SampleDB.Resource.PROPERTY_ID_NAME);\r
@@ -176,8 +176,8 @@ public class ReservationApplication extends Application {
         allLayout.setMargin(true);\r
 \r
         allTable = new Table();\r
-        allTable.setHeight(300);\r
-        allTable.setWidth(700);\r
+        allTable.getSize().setHeight(300);\r
+        allTable.getSize().setWidth(700);\r
         allTable.setColumnCollapsingAllowed(true);\r
         allTable.setColumnReorderingAllowed(true);\r
         allLayout.addComponent(allTable);\r
diff --git a/src/com/itmill/toolkit/terminal/HasSize.java b/src/com/itmill/toolkit/terminal/HasSize.java
new file mode 100644 (file)
index 0000000..d740924
--- /dev/null
@@ -0,0 +1,7 @@
+package com.itmill.toolkit.terminal;
+
+public interface HasSize {
+    
+    public Size getSize();
+
+}
diff --git a/src/com/itmill/toolkit/terminal/Size.java b/src/com/itmill/toolkit/terminal/Size.java
new file mode 100644 (file)
index 0000000..c8af640
--- /dev/null
@@ -0,0 +1,217 @@
+package com.itmill.toolkit.terminal;
+
+import com.itmill.toolkit.ui.Component;
+
+public class Size {
+
+    private Component component;
+    private int width;
+    private int height;
+    private int widthUnit;
+    private int heightUnit;
+
+    /**
+     * Unit code representing pixels.
+     */
+    public static final int UNITS_PIXELS = 0;
+
+    /**
+     * Unit code representing points (1/72nd of an inch).
+     */
+    public static final int UNITS_POINTS = 1;
+
+    /**
+     * Unit code representing picas (12 points).
+     */
+    public static final int UNITS_PICAS = 2;
+
+    /**
+     * Unit code representing the font-size of the relevant font.
+     */
+    public static final int UNITS_EM = 3;
+
+    /**
+     * Unit code representing the x-height of the relevant font.
+     */
+    public static final int UNITS_EX = 4;
+
+    /**
+     * Unit code representing millimeters.
+     */
+    public static final int UNITS_MM = 5;
+
+    /**
+     * Unit code representing centimeters.
+     */
+    public static final int UNITS_CM = 6;
+
+    /**
+     * Unit code representing inches.
+     */
+    public static final int UNITS_INCH = 7;
+
+    /**
+     * Unit code representing in percentage of the containing element defined by
+     * terminal.
+     */
+    public static final int UNITS_PERCENTAGE = 8;
+
+    /**
+     * Unit code representing in rows of text. This unit is only applicable to
+     * some components can it's meaning is specified by component
+     * implementation.
+     */
+    public static final int UNITS_ROWS = 9;
+
+    /**
+     * Textual representations of units symbols. Supported units and their
+     * symbols are:
+     * <ul>
+     * <li><code>UNITS_PIXELS</code>: "px"</li>
+     * <li><code>UNITS_POINTS</code>: "pt"</li>
+     * <li><code>UNITS_PICAS</code>: "pc"</li>
+     * <li><code>UNITS_EM</code>: "em"</li>
+     * <li><code>UNITS_EX</code>: "ex"</li>
+     * <li><code>UNITS_MM</code>: "mm"</li>
+     * <li><code>UNITS_CM</code>. "cm"</li>
+     * <li><code>UNITS_INCH</code>: "in"</li>
+     * <li><code>UNITS_PERCENTAGE</code>: "%"</li>
+     * <li><code>UNITS_ROWS</code>: "rows"</li>
+     * </ul>
+     * These can be used like <code>Size.UNIT_SYMBOLS[UNITS_PIXELS]</code>.
+     */
+    public static final String[] UNIT_SYMBOLS = { "px", "pt", "pc", "em", "ex",
+            "mm", "cm", "in", "%", "rows" };
+
+    public Size(Component c) {
+        component = c;
+        width = -1;
+        height = -1;
+        widthUnit = UNITS_PIXELS;
+        heightUnit = UNITS_PIXELS;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see com.itmill.toolkit.terminal.Sizeable#getHeight()
+     */
+    public int getHeight() {
+        return height;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see com.itmill.toolkit.terminal.Sizeable#getHeightUnits()
+     */
+    public int getHeightUnits() {
+        return heightUnit;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see com.itmill.toolkit.terminal.Sizeable#getWidth()
+     */
+    public int getWidth() {
+        return width;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see com.itmill.toolkit.terminal.Sizeable#getWidthUnits()
+     */
+    public int getWidthUnits() {
+        return widthUnit;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see com.itmill.toolkit.terminal.Sizeable#setHeight(int)
+     */
+    public void setHeight(int height) {
+        this.height = height;
+        component.requestRepaint();
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see com.itmill.toolkit.terminal.Sizeable#setHeightUnits(int)
+     */
+    public void setHeightUnits(int unit) {
+        heightUnit = unit;
+        component.requestRepaint();
+    }
+
+    public void setHeight(int height, int unit) {
+        setHeight(height);
+        setHeightUnits(unit);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see com.itmill.toolkit.terminal.Sizeable#setSizeFull()
+     */
+    public void setSizeFull() {
+        height = 100;
+        width = 100;
+        heightUnit = UNITS_PERCENTAGE;
+        widthUnit = UNITS_PERCENTAGE;
+        component.requestRepaint();
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see com.itmill.toolkit.terminal.Sizeable#setSizeUndefined()
+     */
+    public void setSizeUndefined() {
+        height = -1;
+        width = -1;
+        heightUnit = UNITS_PIXELS;
+        widthUnit = UNITS_PIXELS;
+        component.requestRepaint();
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see com.itmill.toolkit.terminal.Sizeable#setWidth(int)
+     */
+    public void setWidth(int width) {
+        this.width = width;
+        component.requestRepaint();
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see com.itmill.toolkit.terminal.Sizeable#setWidthUnits(int)
+     */
+    public void setWidthUnits(int unit) {
+        widthUnit = unit;
+        component.requestRepaint();
+    }
+
+    public void setWidth(int width, int unit) {
+        setWidth(width);
+        setWidthUnits(unit);
+    }
+
+    public void paint(PaintTarget target) throws PaintException {
+        if (getHeight() >= 0) {
+            target.addAttribute("height", "" + getHeight()
+                    + UNIT_SYMBOLS[getHeightUnits()]);
+        }
+        if (getWidth() >= 0) {
+            target.addAttribute("width", "" + getWidth()
+                    + UNIT_SYMBOLS[getWidthUnits()]);
+        }
+    }
+
+}
\ No newline at end of file
index 649be802f8b60a00c413aa8a908490d794de3fa5..8e17e9f2692d6c108a6f4e1d3065670d63acfaea 100644 (file)
@@ -12,6 +12,7 @@ package com.itmill.toolkit.terminal;
  * @version
  * @VERSION@
  * @since 3.0
+ * @deprecated
  */
 public interface Sizeable {
 
index fe3811657e2220b9e6649b6dd8ec2ae92570f96b..acc9beab7d7c10c6362134a4c8c13c96905dff93 100644 (file)
@@ -127,7 +127,7 @@ public class BasicRandomTest extends com.itmill.toolkit.Application implements
         final OrderedLayout setupLayout = new OrderedLayout(
                 OrderedLayout.ORIENTATION_HORIZONTAL);
         final Panel statusPanel = new Panel("Status");
-        statusPanel.setWidth(200);
+        statusPanel.getSize().setWidth(200);
         setupLayout.addComponent(statusPanel);
         statusPanel.addComponent(statusLabel);
         setupLayout.addComponent(randomSeedValue);
index 02a04f9860d4e38b9b018632e1e663139edf2cfb..6b66f39c5d23d5c6ccacde4368811d824e37a0c4 100644 (file)
@@ -154,12 +154,12 @@ public class RandomLayoutStress extends com.itmill.toolkit.Application {
                                     + "extremities and may have a caption to clarify the nature of the contained components' purpose."
                                     + " Panel contains an layout where the actual contained components are added, "
                                     + "this layout may be switched on the fly."));
-            ((Panel) result).setWidth(250);
+            ((Panel) result).getSize().setWidth(250);
             break;
         case 6:
             // Datefield
             result = new DateField();
-            ((DateField) result).setStyle("calendar");
+            ((DateField) result).setStyleName("calendar");
             ((DateField) result).setValue(new java.util.Date());
             result.setCaption("Calendar component " + caption);
             break;
index 48787515dc096ca78d1933c59416c202c003ad3d..92575cda82277475e04d8e67a94954651e60fb64 100644 (file)
@@ -15,7 +15,7 @@ import java.util.List;
 import com.itmill.toolkit.Application;
 import com.itmill.toolkit.data.Property;
 import com.itmill.toolkit.data.util.HierarchicalContainer;
-import com.itmill.toolkit.terminal.Sizeable;
+import com.itmill.toolkit.terminal.Size;
 import com.itmill.toolkit.ui.Component;
 import com.itmill.toolkit.ui.CustomComponent;
 import com.itmill.toolkit.ui.ExpandLayout;
@@ -112,8 +112,7 @@ public class TestBench extends com.itmill.toolkit.Application implements
         mainLayout.addComponent(menu);
 
         bodyLayout.addStyleName("light");
-        bodyLayout.setHeight(100);
-        bodyLayout.setHeightUnits(Sizeable.UNITS_PERCENTAGE);
+        bodyLayout.getSize().setHeight(100, Size.UNITS_PERCENTAGE);
         bodyLayout.setLayout(new ExpandLayout());
 
         mainLayout.addComponent(bodyLayout);
index 8183216757b5fbe8a2d1e3c18a4ab869487f850f..62beab9aeede9ce17900497b727308565a4f9731 100644 (file)
@@ -17,7 +17,7 @@ import com.itmill.toolkit.event.Action;
 import com.itmill.toolkit.terminal.ClassResource;
 import com.itmill.toolkit.terminal.ErrorMessage;
 import com.itmill.toolkit.terminal.ExternalResource;
-import com.itmill.toolkit.terminal.Sizeable;
+import com.itmill.toolkit.terminal.Size;
 import com.itmill.toolkit.terminal.UserError;
 import com.itmill.toolkit.ui.AbstractComponent;
 import com.itmill.toolkit.ui.Button;
@@ -141,8 +141,7 @@ public class TestComponentsAndLayouts extends Application implements Listener,
                             "<hr /><h1>Components inside ExpandLayout (height 250px)</h3>",
                             Label.CONTENT_XHTML));
             final ExpandLayout el = new ExpandLayout();
-            el.setHeight(250);
-            el.setHeightUnits(Sizeable.UNITS_PIXELS);
+            el.getSize().setHeight(250, Size.UNITS_PIXELS);
             populateLayout(el);
             target.addComponent(el);
         }
@@ -164,8 +163,7 @@ public class TestComponentsAndLayouts extends Application implements Listener,
                             "<hr /><h1>Components inside vertical SplitPanel (splitpanel is under 250height ExpandLayout)</h3>",
                             Label.CONTENT_XHTML));
             final ExpandLayout sp1l = new ExpandLayout();
-            sp1l.setHeight(250);
-            sp1l.setHeightUnits(Sizeable.UNITS_PIXELS);
+            sp1l.getSize().setHeight(250, Size.UNITS_PIXELS);
             final SplitPanel sp1 = new SplitPanel(
                     SplitPanel.ORIENTATION_VERTICAL);
             sp1l.addComponent(sp1);
@@ -185,8 +183,7 @@ public class TestComponentsAndLayouts extends Application implements Listener,
                             "<hr /><h1>Components inside horizontal SplitPanel (splitpanel is under 250px height ExpandLayout)</h3>",
                             Label.CONTENT_XHTML));
             final ExpandLayout sp2l = new ExpandLayout();
-            sp2l.setHeight(250);
-            sp2l.setHeightUnits(Sizeable.UNITS_PIXELS);
+            sp2l.getSize().setHeight(250, Size.UNITS_PIXELS);
             final SplitPanel sp2 = new SplitPanel(
                     SplitPanel.ORIENTATION_HORIZONTAL);
             sp2l.addComponent(sp2);
index 42cd5b874a4f1cdbe362f0429a120435f943bcb0..0bf8f2dad0dc63edd90db476aded13b123f5821c 100644 (file)
@@ -30,7 +30,7 @@ public class TestForAlignments extends CustomComponent {
         vert.addComponent(b2);
         vert.addComponent(t1);
         vert.addComponent(d1);
-        vert.setWidth(500);
+        //vert.getSize().setWidth(500);
         vert.setComponentAlignment(b1, OrderedLayout.ALIGNMENT_RIGHT,
                 OrderedLayout.ALIGNMENT_TOP);
         vert.setComponentAlignment(b2, OrderedLayout.ALIGNMENT_LEFT,
@@ -46,7 +46,7 @@ public class TestForAlignments extends CustomComponent {
         hori.addComponent(b4);
         hori.addComponent(t2);
         hori.addComponent(d2);
-        hori.setHeight(200);
+        //hori.getSize().setHeight(200);
         hori.setComponentAlignment(b3, OrderedLayout.ALIGNMENT_LEFT,
                 OrderedLayout.ALIGNMENT_BOTTOM);
         hori.setComponentAlignment(b4, OrderedLayout.ALIGNMENT_LEFT,
index 74a1e0e9ee63e5d0ee9882ab69c02f4abfac725b..5890cef0529dccd9ef845ed367739d98c8670cc3 100644 (file)
@@ -5,7 +5,6 @@
 package com.itmill.toolkit.tests;
 
 import com.itmill.toolkit.Application;
-import com.itmill.toolkit.terminal.Sizeable;
 import com.itmill.toolkit.ui.ExpandLayout;
 import com.itmill.toolkit.ui.Label;
 import com.itmill.toolkit.ui.SplitPanel;
@@ -40,10 +39,7 @@ public class TestForApplicationLayoutThatUsesWholeBrosersSpace extends
 
         final Table t = TestForTablesInitialColumnWidthLogicRendering
                 .getTestTable(4, 100);
-        t.setWidth(100);
-        t.setWidthUnits(Sizeable.UNITS_PERCENTAGE);
-        t.setHeight(100);
-        t.setHeightUnits(Sizeable.UNITS_PERCENTAGE);
+        t.getSize().setSizeFull();
         topRight.addComponent(t);
         topRight.expand(t);
 
index 8b0f6b5ca2b6483a9edf549c78b6a9d77f833ec5..b2f90d22123c2461dbeaf633e05f573711cad51b 100644 (file)
@@ -6,7 +6,7 @@ package com.itmill.toolkit.tests;
 \r
 import java.util.Locale;\r
 \r
-import com.itmill.toolkit.terminal.Sizeable;\r
+import com.itmill.toolkit.terminal.Size;\r
 import com.itmill.toolkit.ui.Button;\r
 import com.itmill.toolkit.ui.CustomComponent;\r
 import com.itmill.toolkit.ui.DateField;\r
@@ -31,7 +31,7 @@ public class TestForBasicApplicationLayout extends CustomComponent {
         click = new Button("Set height -1", new ClickListener() {\r
 \r
             public void buttonClick(ClickEvent event) {\r
-                tab.setHeight(-1);\r
+                tab.getSize().setHeight(-1);\r
             }\r
 \r
         });\r
@@ -39,23 +39,22 @@ public class TestForBasicApplicationLayout extends CustomComponent {
         click2 = new Button("Set height 100%", new ClickListener() {\r
 \r
             public void buttonClick(ClickEvent event) {\r
-                tab.setHeight(100);\r
-                tab.setHeightUnits(Sizeable.UNITS_PERCENTAGE);\r
+                tab.getSize().setHeight(100, Size.UNITS_PERCENTAGE);\r
             }\r
 \r
         });\r
 \r
         final SplitPanel sp = new SplitPanel(SplitPanel.ORIENTATION_HORIZONTAL);\r
-        sp.setSplitPosition(290, Sizeable.UNITS_PIXELS);\r
+        sp.setSplitPosition(290, Size.UNITS_PIXELS);\r
 \r
         final SplitPanel sp2 = new SplitPanel(SplitPanel.ORIENTATION_VERTICAL);\r
-        sp2.setSplitPosition(255, Sizeable.UNITS_PIXELS);\r
+        sp2.setSplitPosition(255, Size.UNITS_PIXELS);\r
 \r
         final Panel p = new Panel("Accordion Panel");\r
-        p.setSizeFull();\r
+        p.getSize().setSizeFull();\r
 \r
         tab = new TabSheet();\r
-        tab.setSizeFull();\r
+        tab.getSize().setSizeFull();\r
 \r
         final Panel report = new Panel("Monthly Program Runs",\r
                 new ExpandLayout());\r
@@ -71,8 +70,7 @@ public class TestForBasicApplicationLayout extends CustomComponent {
         report.addComponent(cal);\r
         ((ExpandLayout) report.getLayout()).expand(controls);\r
         report.addStyleName(Panel.STYLE_LIGHT);\r
-        report.setHeight(100);\r
-        report.setHeightUnits(Sizeable.UNITS_PERCENTAGE);\r
+        report.getSize().setHeight(100, Size.UNITS_PERCENTAGE);\r
 \r
         sp2.setFirstComponent(report);\r
 \r
@@ -84,7 +82,7 @@ public class TestForBasicApplicationLayout extends CustomComponent {
         table.setColumnCollapsingAllowed(true);\r
         table.setColumnReorderingAllowed(true);\r
         table.setSortDisabled(false);\r
-        table.setSizeFull();\r
+        table.getSize().setSizeFull();\r
         table.addStyleName("table-inline");\r
         sp2.setSecondComponent(table);\r
 \r
index 165abe503b23f14f0fd35de6194a92ff7236ff90..844168f9410bccee36b2944da62ec7db2c0485fb 100644 (file)
@@ -5,7 +5,7 @@
 package com.itmill.toolkit.tests;
 
 import com.itmill.toolkit.data.util.IndexedContainer;
-import com.itmill.toolkit.terminal.Sizeable;
+import com.itmill.toolkit.terminal.Size;
 import com.itmill.toolkit.ui.Button;
 import com.itmill.toolkit.ui.CustomComponent;
 import com.itmill.toolkit.ui.Label;
@@ -42,8 +42,7 @@ public class TestForContainerFilterable extends CustomComponent {
         // Init filtering view
         final Panel filterPanel = new Panel("Filter", new OrderedLayout(
                 OrderedLayout.ORIENTATION_HORIZONTAL));
-        filterPanel.setWidth(100);
-        filterPanel.setWidthUnits(Sizeable.UNITS_PERCENTAGE);
+        filterPanel.getSize().setWidth(100, Size.UNITS_PERCENTAGE);
         lo.addComponent(filterPanel);
         filterPanel.addComponent(fooFilter);
         filterPanel.addComponent(barFilter);
@@ -57,8 +56,7 @@ public class TestForContainerFilterable extends CustomComponent {
         // Table
         lo.addComponent(t);
         t.setPageLength(12);
-        t.setWidth(100);
-        t.setWidthUnits(Sizeable.UNITS_PERCENTAGE);
+        t.getSize().setWidth(100, Size.UNITS_PERCENTAGE);
         t.setContainerDataSource(ic);
 
         // Handler
index 7ce61ed53599fd2461082a56fca894e18f4252bc..c3bb09a4ae5e8b8ff6dac153fe24f8f945645246 100644 (file)
@@ -4,7 +4,7 @@
 \r
 package com.itmill.toolkit.tests;\r
 \r
-import com.itmill.toolkit.terminal.Sizeable;\r
+import com.itmill.toolkit.terminal.Size;\r
 import com.itmill.toolkit.ui.CustomComponent;\r
 import com.itmill.toolkit.ui.DateField;\r
 import com.itmill.toolkit.ui.ExpandLayout;\r
@@ -36,8 +36,7 @@ public class TestForExpandLayout extends CustomComponent {
                 el.addComponent(l);\r
             }\r
             if (i > 0) {\r
-                el.setHeight(1);\r
-                el.setHeightUnits(Sizeable.UNITS_EM);\r
+                el.getSize().setHeight(1, Size.UNITS_EM);\r
             }\r
             main.addComponent(el);\r
         }\r
index 5e7216101b801763401ec7f3a2030dab5952a634..dd872fc0da933d581cd0add5bea92713146972d7 100644 (file)
@@ -29,11 +29,11 @@ public class TestForNativeWindowing extends Application {
                         main.addWindow(w);
                         w.setPositionX(100);
                         w.setPositionY(100);
-                        w.setWidth(200);
-                        w.setHeight(200);
+                        w.getSize().setWidth(200);
+                        w.getSize().setHeight(200);
 
-                        w.setWidth(100);
-                        w.setHeight(400);
+                        w.getSize().setWidth(100);
+                        w.getSize().setHeight(400);
 
                         final Button closebutton = new Button("Close "
                                 + w.getCaption(), new Button.ClickListener() {
index 47c435ad82a9aa8eb111d42b8ae023d2ccc4db9a..0bff19a18b87983d81f3073dd88f5d1019b42f78 100644 (file)
@@ -154,8 +154,8 @@ public class TestForPreconfiguredComponents extends CustomComponent implements
         ol2.addComponent(commit);
         status.addComponent(ol2);
 
-        status.setHeight(300);
-        status.setWidth(400);
+        status.getSize().setHeight(300);
+        status.getSize().setWidth(400);
 
         ol.addComponent(status);
 
index 1304ef92980b032e4408121f1db3690d2bf91ae3..6abe000224695782f1ddc42414380eeb9ff5d4c8 100644 (file)
@@ -6,7 +6,7 @@ package com.itmill.toolkit.tests;
 
 import java.util.Vector;
 
-import com.itmill.toolkit.terminal.Sizeable;
+import com.itmill.toolkit.terminal.Size;
 import com.itmill.toolkit.ui.Button;
 import com.itmill.toolkit.ui.CustomComponent;
 import com.itmill.toolkit.ui.Label;
@@ -57,20 +57,18 @@ public class TestForTablesInitialColumnWidthLogicRendering extends
         t = getTestTable(3, 40);
         t
                 .setCaption("Table with some columns and wide explicit width. (Ought to widen columns to use all space)");
-        t.setWidth(1000);
+        t.getSize().setWidth(1000);
         main.addComponent(t);
 
         t = getTestTable(12, 4);
         t.setCaption("Table with  some rows and lot of columns, width == 100%");
-        t.setWidth(100);
-        t.setWidthUnits(Sizeable.UNITS_PERCENTAGE);
+        t.getSize().setWidth(100, Size.UNITS_PERCENTAGE);
         main.addComponent(t);
 
         t = getTestTable(12, 100);
         t
                 .setCaption("Table with  lot of rows and lot of columns, width == 50%");
-        t.setWidth(50);
-        t.setWidthUnits(Sizeable.UNITS_PERCENTAGE);
+        t.getSize().setWidth(50, Size.UNITS_PERCENTAGE);
         main.addComponent(t);
 
         t = getTestTable(5, 100);
@@ -80,7 +78,7 @@ public class TestForTablesInitialColumnWidthLogicRendering extends
         t = getTestTable(4, 4);
         t.setCaption("Table with some rows and width = 200px");
 
-        t.setWidth(200);
+        t.getSize().setWidth(200);
         main.addComponent(t);
 
         final Button b = new Button("refresh view", this, "createNewView");
index fd7624fce4d872a72d79e3e0b521adc93204cbd3..30658f8ffa564694ec4f3948541088ca205453d6 100644 (file)
@@ -134,8 +134,8 @@ public class TestForTrees extends CustomComponent implements Handler {
         });
         status.addComponent(clear);
 
-        status.setHeight(300);
-        status.setWidth(400);
+        status.getSize().setHeight(300);
+        status.getSize().setWidth(400);
 
         ol.addComponent(status);
 
index 3bd9d8e44ec57f394ec570ec0835ce11d7bcc9b5..a6f62c6d1bf9fd9740e531bb73be1e6b757295b8 100644 (file)
@@ -6,7 +6,6 @@ package com.itmill.toolkit.tests.featurebrowser;
 
 import com.itmill.toolkit.terminal.ClassResource;
 import com.itmill.toolkit.terminal.Resource;
-import com.itmill.toolkit.terminal.Sizeable;
 import com.itmill.toolkit.ui.Component;
 import com.itmill.toolkit.ui.CustomComponent;
 import com.itmill.toolkit.ui.Embedded;
@@ -79,10 +78,7 @@ public abstract class Feature extends CustomComponent {
 
         ts = new TabSheet();
 
-        ts.setWidth(100);
-        ts.setWidthUnits(Sizeable.UNITS_PERCENTAGE);
-        ts.setHeight(100);
-        ts.setHeightUnits(Sizeable.UNITS_PERCENTAGE);
+        ts.getSize().setSizeFull();
 
         // Description tab
         final String title = getTitle();
index 7e357e0e003e5dbcfe55f219962654fb3bebedd2..1aaacf329ef3ce8542227c6575374c92997ca236 100644 (file)
@@ -35,8 +35,8 @@ public class FeatureWindow extends Feature implements Window.CloseListener {
 
         demoWindow = new Window("Feature Test Window");
         demoWindow.addListener(this);
-        demoWindow.setWidth(400);
-        demoWindow.setHeight(200);
+        demoWindow.getSize().setWidth(400);
+        demoWindow.getSize().setHeight(200);
         demoWindow.setTheme("default");
 
         layoutUpper.addComponent(addButton);
index 29fb7ab02f649c210d7a147ac08502c7a436ea78..1ce835b80d2836778ec1f72fa57bf5051d6944b7 100644 (file)
@@ -28,6 +28,7 @@ import com.itmill.toolkit.ui.DateField;
 import com.itmill.toolkit.ui.Field;
 import com.itmill.toolkit.ui.Form;
 import com.itmill.toolkit.ui.GridLayout;
+import com.itmill.toolkit.ui.OptionGroup;
 import com.itmill.toolkit.ui.OrderedLayout;
 import com.itmill.toolkit.ui.Panel;
 import com.itmill.toolkit.ui.Select;
@@ -66,10 +67,7 @@ public class PropertyPanel extends Panel implements Button.ClickListener,
         setCaption("Properties");
         addComponent(formsLayout);
 
-        setWidth(100);
-        setWidthUnits(Table.UNITS_PERCENTAGE);
-        setHeight(100);
-        setHeightUnits(Table.UNITS_PERCENTAGE);
+        getSize().setSizeFull();
 
         // Target object
         this.objectToConfigure = objectToConfigure;
@@ -105,10 +103,7 @@ public class PropertyPanel extends Panel implements Button.ClickListener,
                 Table.ALIGN_LEFT, Table.ALIGN_CENTER, Table.ALIGN_CENTER });
         allProperties.setColumnHeaderMode(Table.COLUMN_HEADER_MODE_ID);
         allProperties.setPageLength(0);
-        allProperties.setWidth(100);
-        allProperties.setWidthUnits(Table.UNITS_PERCENTAGE);
-        allProperties.setHeight(100);
-        allProperties.setHeightUnits(Table.UNITS_PERCENTAGE);
+        allProperties.getSize().setSizeFull();
         updatePropertyList();
 
     }
@@ -119,7 +114,7 @@ public class PropertyPanel extends Panel implements Button.ClickListener,
         // Create new panel containing the form
         final Panel p = new Panel();
         p.setCaption(propertySetCaption);
-        p.setStyle("light");
+        p.setStyleName(Panel.STYLE_LIGHT);
         p.addComponent(properties);
         formsLayout.addComponent(p);
 
@@ -383,7 +378,7 @@ public class PropertyPanel extends Panel implements Button.ClickListener,
                     d
                             .setDescription("This is a DateField-component with text-style");
                     d.setResolution(DateField.RESOLUTION_MIN);
-                    d.setStyle("text");
+                    d.setStyleName("text");
                     ((AbstractComponentContainer) objectToConfigure)
                             .addComponent(d);
                 }
@@ -393,7 +388,7 @@ public class PropertyPanel extends Panel implements Button.ClickListener,
                     final DateField c = new DateField("Calendar", new Date());
                     c
                             .setDescription("DateField-component with calendar-style and day-resolution");
-                    c.setStyle("calendar");
+                    c.setStyleName("calendar");
                     c.setResolution(DateField.RESOLUTION_DAY);
                     ((AbstractComponentContainer) objectToConfigure)
                             .addComponent(c);
@@ -401,13 +396,12 @@ public class PropertyPanel extends Panel implements Button.ClickListener,
 
                 // Select option group style
                 if (value.equals("Option group")) {
-                    final Select s = new Select("Options");
+                    final OptionGroup s = new OptionGroup("Options");
                     s.setDescription("Select-component with optiongroup-style");
                     s.addItem("Linux");
                     s.addItem("Windows");
                     s.addItem("Solaris");
                     s.addItem("Symbian");
-                    s.setStyle("optiongroup");
 
                     ((AbstractComponentContainer) objectToConfigure)
                             .addComponent(s);
index fafd7ce63c76f16370eb238026879fb2873f47a7..afec7b3f33831c54f35f6255d4694d9daaed15ae 100644 (file)
@@ -15,6 +15,7 @@ import com.itmill.toolkit.data.validator.StringLengthValidator;
 import com.itmill.toolkit.terminal.ClassResource;
 import com.itmill.toolkit.terminal.DownloadStream;
 import com.itmill.toolkit.terminal.ExternalResource;
+import com.itmill.toolkit.terminal.Size;
 import com.itmill.toolkit.terminal.StreamResource;
 import com.itmill.toolkit.terminal.UserError;
 import com.itmill.toolkit.ui.AbstractSelect;
@@ -366,7 +367,7 @@ public class MagiTestApplication extends com.itmill.toolkit.Application {
     void example_DateField(Window main, String param) {
         /* Create a DateField with the calendar style. */
         final DateField date = new DateField("Here is a calendar field");
-        date.setStyle("calendar");
+        date.setStyleName("calendar");
 
         /* Set the date and time to present. */
         date.setValue(new java.util.Date());
@@ -491,7 +492,7 @@ public class MagiTestApplication extends com.itmill.toolkit.Application {
         grid.addComponent(new Button("3x1 button"), 1, 1, 3, 1);
         grid.addComponent(new Label("1x2 cell"), 1, 2, 1, 3);
         final DateField date = new DateField("A 2x2 date field");
-        date.setStyle("calendar");
+        date.setStyleName("calendar");
         grid.addComponent(date, 2, 2, 3, 3);
 
         main.addComponent(grid);
@@ -505,10 +506,8 @@ public class MagiTestApplication extends com.itmill.toolkit.Application {
             // OrderedLayout(OrderedLayout.ORIENTATION_VERTICAL);
             main.setLayout(layout);
             layout.addStyleName("example-alignment");
-            layout.setWidth(400);
-            layout.setWidthUnits(GridLayout.UNITS_PIXELS);
-            layout.setHeight(400);
-            layout.setHeightUnits(GridLayout.UNITS_PIXELS);
+            layout.getSize().setWidth(400, Size.UNITS_PIXELS);
+            layout.getSize().setHeight(400, Size.UNITS_PIXELS);
 
             /* Define cells and their layouts to create. */
             /*
@@ -586,10 +585,7 @@ public class MagiTestApplication extends com.itmill.toolkit.Application {
             layout.expand(table);
 
             /* Set it to use all available area. */
-            table.setHeight(100);
-            table.setHeightUnits(Table.UNITS_PERCENTAGE);
-            table.setWidth(100);
-            table.setWidthUnits(Table.UNITS_PERCENTAGE);
+            table.getSize().setSizeFull();
 
             /* Add some component below the expanding one. */
             final Button button2 = new Button("Ok");
@@ -667,8 +663,8 @@ public class MagiTestApplication extends com.itmill.toolkit.Application {
         mywindow.addComponent(okbutton);
 
         /* Set window size. */
-        mywindow.setHeight(200);
-        mywindow.setWidth(400);
+        mywindow.getSize().setHeight(200);
+        mywindow.getSize().setWidth(400);
 
         /* Set window position. */
         mywindow.setPositionX(200);
index 486a5270b7c4feeaa0329a92d9fa3e8d55dbc18e..fc18e8efb84cb6bc04c42c40f6ba6a4d8ada4959 100644 (file)
@@ -15,7 +15,7 @@ import java.util.List;
 import com.itmill.toolkit.Application;
 import com.itmill.toolkit.data.Property;
 import com.itmill.toolkit.data.util.HierarchicalContainer;
-import com.itmill.toolkit.terminal.Sizeable;
+import com.itmill.toolkit.terminal.Size;
 import com.itmill.toolkit.ui.Component;
 import com.itmill.toolkit.ui.CustomComponent;
 import com.itmill.toolkit.ui.ExpandLayout;
@@ -108,8 +108,7 @@ public class TestBench extends com.itmill.toolkit.Application implements
         mainLayout.addComponent(menu);
 
         bodyLayout.addStyleName("light");
-        bodyLayout.setHeight(100);
-        bodyLayout.setHeightUnits(Sizeable.UNITS_PERCENTAGE);
+        bodyLayout.getSize().setHeight(100, Size.UNITS_PERCENTAGE);
         bodyLayout.setLayout(new ExpandLayout());
 
         mainLayout.addComponent(bodyLayout);
index 3cdde28e707359fa2d966dfce4aa0846f4111e1c..f7b75645e5ac16737460fc00f62796c506966042 100644 (file)
@@ -30,7 +30,6 @@ public class TestForAlignments extends CustomComponent {
         vert.addComponent(b2);
         vert.addComponent(t1);
         vert.addComponent(d1);
-        vert.setWidth(500);
         vert.setComponentAlignment(b1, OrderedLayout.ALIGNMENT_RIGHT,
                 OrderedLayout.ALIGNMENT_TOP);
         vert.setComponentAlignment(b2, OrderedLayout.ALIGNMENT_LEFT,
@@ -46,7 +45,6 @@ public class TestForAlignments extends CustomComponent {
         hori.addComponent(b4);
         hori.addComponent(t2);
         hori.addComponent(d2);
-        hori.setHeight(200);
         hori.setComponentAlignment(b3, OrderedLayout.ALIGNMENT_LEFT,
                 OrderedLayout.ALIGNMENT_BOTTOM);
         hori.setComponentAlignment(b4, OrderedLayout.ALIGNMENT_LEFT,
index 171a262dcce06b01b49cafc9e4ac01163f2662ca..cd41e345e983330caed9dc931f1763cd8aed5936 100644 (file)
@@ -9,7 +9,7 @@ import java.util.Locale;
 \r
 import com.itmill.toolkit.data.util.QueryContainer;\r
 import com.itmill.toolkit.demo.util.SampleDatabase;\r
-import com.itmill.toolkit.terminal.Sizeable;\r
+import com.itmill.toolkit.terminal.Size;\r
 import com.itmill.toolkit.ui.Button;\r
 import com.itmill.toolkit.ui.CustomComponent;\r
 import com.itmill.toolkit.ui.DateField;\r
@@ -37,7 +37,7 @@ public class TestForBasicApplicationLayout extends CustomComponent {
         click = new Button("Set height -1", new ClickListener() {\r
 \r
             public void buttonClick(ClickEvent event) {\r
-                tab.setHeight(-1);\r
+                tab.getSize().setHeight(-1);\r
             }\r
 \r
         });\r
@@ -45,23 +45,22 @@ public class TestForBasicApplicationLayout extends CustomComponent {
         click2 = new Button("Set height 100%", new ClickListener() {\r
 \r
             public void buttonClick(ClickEvent event) {\r
-                tab.setHeight(100);\r
-                tab.setHeightUnits(Sizeable.UNITS_PERCENTAGE);\r
+                tab.getSize().setHeight(100, Size.UNITS_PERCENTAGE);\r
             }\r
 \r
         });\r
 \r
         final SplitPanel sp = new SplitPanel(SplitPanel.ORIENTATION_HORIZONTAL);\r
-        sp.setSplitPosition(290, Sizeable.UNITS_PIXELS);\r
+        sp.setSplitPosition(290, Size.UNITS_PIXELS);\r
 \r
         final SplitPanel sp2 = new SplitPanel(SplitPanel.ORIENTATION_VERTICAL);\r
-        sp2.setSplitPosition(255, Sizeable.UNITS_PIXELS);\r
+        sp2.setSplitPosition(255, Size.UNITS_PIXELS);\r
 \r
         final Panel p = new Panel("Accordion Panel");\r
-        p.setSizeFull();\r
+        p.getSize().setSizeFull();\r
 \r
         tab = new TabSheet();\r
-        tab.setSizeFull();\r
+        tab.getSize().setSizeFull();\r
 \r
         final Panel report = new Panel("Monthly Program Runs",\r
                 new ExpandLayout());\r
@@ -77,8 +76,7 @@ public class TestForBasicApplicationLayout extends CustomComponent {
         report.addComponent(cal);\r
         ((ExpandLayout) report.getLayout()).expand(controls);\r
         report.addStyleName(Panel.STYLE_LIGHT);\r
-        report.setHeight(100);\r
-        report.setHeightUnits(Sizeable.UNITS_PERCENTAGE);\r
+        report.getSize().setHeight(100, Size.UNITS_PERCENTAGE);\r
 \r
         sp2.setFirstComponent(report);\r
 \r
@@ -102,7 +100,7 @@ public class TestForBasicApplicationLayout extends CustomComponent {
         table.setColumnCollapsingAllowed(true);\r
         table.setColumnReorderingAllowed(true);\r
         table.setSortDisabled(false);\r
-        table.setSizeFull();\r
+        table.getSize().setSizeFull();\r
         table.addStyleName("table-inline");\r
         sp2.setSecondComponent(table);\r
 \r
index 73b93dc20c4a531c418f643afcdcab6b087a63c5..705d4881dcb0ef4de2d5c8f71a563a967a6d8526 100644 (file)
@@ -5,7 +5,7 @@
 package com.itmill.toolkit.tests.testbench;
 
 import com.itmill.toolkit.data.util.IndexedContainer;
-import com.itmill.toolkit.terminal.Sizeable;
+import com.itmill.toolkit.terminal.Size;
 import com.itmill.toolkit.ui.Button;
 import com.itmill.toolkit.ui.CustomComponent;
 import com.itmill.toolkit.ui.Label;
@@ -42,8 +42,7 @@ public class TestForContainerFilterable extends CustomComponent {
         // Init filtering view
         final Panel filterPanel = new Panel("Filter", new OrderedLayout(
                 OrderedLayout.ORIENTATION_HORIZONTAL));
-        filterPanel.setWidth(100);
-        filterPanel.setWidthUnits(Sizeable.UNITS_PERCENTAGE);
+        filterPanel.getSize().setWidth(100, Size.UNITS_PERCENTAGE);
         lo.addComponent(filterPanel);
         filterPanel.addComponent(firstFilter);
         filterPanel.addComponent(secondFilter);
@@ -57,8 +56,7 @@ public class TestForContainerFilterable extends CustomComponent {
         // Table
         lo.addComponent(t);
         t.setPageLength(12);
-        t.setWidth(100);
-        t.setWidthUnits(Sizeable.UNITS_PERCENTAGE);
+        t.getSize().setWidth(100, Size.UNITS_PERCENTAGE);
         t.setContainerDataSource(ic);
 
         // Handler
index 7ab15d7360fea9d4d473c35c8d32ac96edfdf90c..144640460a350ac2f30a8bae2c923f765c904022 100644 (file)
@@ -154,8 +154,8 @@ public class TestForPreconfiguredComponents extends CustomComponent implements
         ol2.addComponent(commit);
         status.addComponent(ol2);
 
-        status.setHeight(300);
-        status.setWidth(400);
+        status.getSize().setHeight(300);
+        status.getSize().setWidth(400);
 
         ol.addComponent(status);
 
index 71884144dbfed5d1333ce3b53d60d67ebda6bae3..1ea7ee2da85cb030c1cfd388909d7dd3d8259685 100644 (file)
@@ -134,8 +134,8 @@ public class TestForTrees extends CustomComponent implements Handler {
         });
         status.addComponent(clear);
 
-        status.setHeight(300);
-        status.setWidth(400);
+        status.getSize().setHeight(300);
+        status.getSize().setWidth(400);
 
         ol.addComponent(status);
 
index d66376052abecba82e535fb4f2049775be6b4fe7..43349e929a636e6ab1ef7d899affca3e8431191f 100644 (file)
@@ -23,30 +23,6 @@ public abstract class AbstractLayout extends AbstractComponentContainer
 
     protected MarginInfo margins = new MarginInfo(false, false, false, false);
 
-    /**
-     * Height of the layout. Set to -1 for undefined height.
-     */
-    private int height = -1;
-
-    /**
-     * Height unit.
-     * 
-     * @see com.itmill.toolkit.terminal.Sizeable.UNIT_SYMBOLS;
-     */
-    private int heightUnit = UNITS_PIXELS;
-
-    /**
-     * Width of the layout. Set to -1 for undefined width.
-     */
-    private int width = -1;
-
-    /**
-     * Width unit.
-     * 
-     * @see com.itmill.toolkit.terminal.Sizeable.UNIT_SYMBOLS;
-     */
-    private int widthUnit = UNITS_PIXELS;
-
     /*
      * (non-Javadoc)
      * 
@@ -78,108 +54,6 @@ public abstract class AbstractLayout extends AbstractComponentContainer
         requestRepaint();
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see com.itmill.toolkit.terminal.Sizeable#getHeight()
-     */
-    public int getHeight() {
-        return height;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see com.itmill.toolkit.terminal.Sizeable#getHeightUnits()
-     */
-    public int getHeightUnits() {
-        return heightUnit;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see com.itmill.toolkit.terminal.Sizeable#getWidth()
-     */
-    public int getWidth() {
-        return width;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see com.itmill.toolkit.terminal.Sizeable#getWidthUnits()
-     */
-    public int getWidthUnits() {
-        return widthUnit;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see com.itmill.toolkit.terminal.Sizeable#setHeight(int)
-     */
-    public void setHeight(int height) {
-        this.height = height;
-        requestRepaint();
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see com.itmill.toolkit.terminal.Sizeable#setHeightUnits(int)
-     */
-    public void setHeightUnits(int units) {
-        heightUnit = units;
-        requestRepaint();
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see com.itmill.toolkit.terminal.Sizeable#setSizeFull()
-     */
-    public void setSizeFull() {
-        height = 100;
-        width = 100;
-        heightUnit = UNITS_PERCENTAGE;
-        widthUnit = UNITS_PERCENTAGE;
-        requestRepaint();
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see com.itmill.toolkit.terminal.Sizeable#setSizeUndefined()
-     */
-    public void setSizeUndefined() {
-        height = -1;
-        width = -1;
-        heightUnit = UNITS_PIXELS;
-        widthUnit = UNITS_PIXELS;
-        requestRepaint();
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see com.itmill.toolkit.terminal.Sizeable#setWidth(int)
-     */
-    public void setWidth(int width) {
-        this.width = width;
-        requestRepaint();
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see com.itmill.toolkit.terminal.Sizeable#setWidthUnits(int)
-     */
-    public void setWidthUnits(int units) {
-        widthUnit = units;
-        requestRepaint();
-    }
-
     /*
      * (non-Javadoc)
      * 
@@ -190,15 +64,6 @@ public abstract class AbstractLayout extends AbstractComponentContainer
         // Add margin info. Defaults to false.
         target.addAttribute("margins", margins.getBitMask());
 
-        // Size
-        if (getHeight() >= 0) {
-            target.addAttribute("height", "" + getHeight()
-                    + Sizeable.UNIT_SYMBOLS[getHeightUnits()]);
-        }
-        if (getWidth() >= 0) {
-            target.addAttribute("width", "" + getWidth()
-                    + Sizeable.UNIT_SYMBOLS[getWidthUnits()]);
-        }
     }
 
 }
index 2b4ea0d481037b62b8888ba175823c542562e224..4fff2c9e10024338a2bb504b7ccd48dc6008848a 100644 (file)
@@ -7,8 +7,10 @@ package com.itmill.toolkit.ui;
 import java.util.HashMap;
 import java.util.Iterator;
 
+import com.itmill.toolkit.terminal.HasSize;
 import com.itmill.toolkit.terminal.PaintException;
 import com.itmill.toolkit.terminal.PaintTarget;
+import com.itmill.toolkit.terminal.Size;
 
 /**
  * <p>
@@ -37,7 +39,7 @@ import com.itmill.toolkit.terminal.PaintTarget;
  * @VERSION@
  * @since 3.0
  */
-public class CustomLayout extends AbstractLayout {
+public class CustomLayout extends AbstractLayout implements HasSize {
 
     /**
      * Custom layout slots containing the components.
@@ -46,11 +48,14 @@ public class CustomLayout extends AbstractLayout {
 
     private String templateName;
 
+    private Size size;
+
     /**
      * Constructor for custom layout with given template name.
      */
     public CustomLayout(String template) {
         templateName = template;
+        size = new Size(this);
     }
 
     /**
@@ -152,6 +157,9 @@ public class CustomLayout extends AbstractLayout {
     public void paintContent(PaintTarget target) throws PaintException {
         super.paintContent(target);
 
+        // Size
+        size.paint(target);
+
         target.addAttribute("template", templateName);
         // Adds all items in all the locations
         for (final Iterator i = slots.keySet().iterator(); i.hasNext();) {
@@ -252,4 +260,8 @@ public class CustomLayout extends AbstractLayout {
                 "CustomLayout does not support margins.");
     }
 
+    public Size getSize() {
+        return size;
+    }
+
 }
index dab5ee2cf10b57d9058118be1cf3ca5f7d456ec6..100fac872c33ede45d04a3435dc28ea78452916b 100644 (file)
@@ -6,9 +6,10 @@ package com.itmill.toolkit.ui;
 
 import java.util.Iterator;
 
+import com.itmill.toolkit.terminal.HasSize;
 import com.itmill.toolkit.terminal.PaintException;
 import com.itmill.toolkit.terminal.PaintTarget;
-import com.itmill.toolkit.terminal.Sizeable;
+import com.itmill.toolkit.terminal.Size;
 
 /**
  * TODO finish documentation
@@ -25,12 +26,14 @@ import com.itmill.toolkit.terminal.Sizeable;
  * other components don't use. Or just provide expanded container.
  * 
  */
-public class ExpandLayout extends OrderedLayout {
+public class ExpandLayout extends OrderedLayout implements HasSize {
 
     private Component expanded;
+    private Size size;
 
     public ExpandLayout() {
-        setSizeFull();
+        size = new Size(this);
+        size.setSizeFull();
     }
 
     public ExpandLayout(int orientation) {
@@ -62,14 +65,7 @@ public class ExpandLayout extends OrderedLayout {
         }
 
         // Size
-        if (getHeight() >= 0) {
-            target.addAttribute("height", "" + getHeight()
-                    + Sizeable.UNIT_SYMBOLS[getHeightUnits()]);
-        }
-        if (getWidth() >= 0) {
-            target.addAttribute("width", "" + getWidth()
-                    + Sizeable.UNIT_SYMBOLS[getWidthUnits()]);
-        }
+        size.paint(target);
 
         // Adds the attributes: orientation
         // note that the default values (b/vertival) are omitted
@@ -137,4 +133,8 @@ public class ExpandLayout extends OrderedLayout {
         }
     }
 
+    public Size getSize() {
+        return size;
+    }
+
 }
index e7f5293b2375c719a3cc64ac690bb47cce57609c..990ba634e218f4034ea643cb2f6fa94e6a3fa39f 100644 (file)
@@ -10,9 +10,10 @@ import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.Map;
 
+import com.itmill.toolkit.terminal.HasSize;
 import com.itmill.toolkit.terminal.PaintException;
 import com.itmill.toolkit.terminal.PaintTarget;
-import com.itmill.toolkit.terminal.Sizeable;
+import com.itmill.toolkit.terminal.Size;
 import com.itmill.toolkit.terminal.gwt.client.ui.AlignmentInfo;
 
 /**
@@ -35,7 +36,7 @@ import com.itmill.toolkit.terminal.gwt.client.ui.AlignmentInfo;
  * @VERSION@
  * @since 3.0
  */
-public class GridLayout extends AbstractLayout {
+public class GridLayout extends AbstractLayout implements HasSize {
 
     /**
      * Initial grid columns.
@@ -110,6 +111,11 @@ public class GridLayout extends AbstractLayout {
      */
     private boolean spacing = false;
 
+    /**
+     * Sizing object.
+     */
+    private Size size;
+
     /**
      * Constructor for grid of given size (number of cells). Note that grid's
      * final size depends on the items that are added into the grid. Grid grows
@@ -123,6 +129,7 @@ public class GridLayout extends AbstractLayout {
     public GridLayout(int columns, int rows) {
         setColumns(columns);
         setRows(rows);
+        size = new Size(this);
     }
 
     /**
@@ -386,6 +393,9 @@ public class GridLayout extends AbstractLayout {
 
         super.paintContent(target);
 
+        // Size
+        size.paint(target);
+
         // TODO refactor attribute names in future release.
         target.addAttribute("h", rows);
         target.addAttribute("w", cols);
@@ -801,31 +811,17 @@ public class GridLayout extends AbstractLayout {
     }
 
     /**
-     * Sets the width of the layout.
-     * <p>
-     * <strong>NOTE:</strong> The behaviour of this methdod has changed in
-     * version 5.0. Now this method won't set the number of columns in the grid
-     * like it used to (use {@link #setColumns()} for that). Instead, it sets
-     * the actual visual width of the layout in pixels or in another unit
-     * specified in {@link Sizeable}.UNIT_SYMBOLS.
-     * </p>
+     * @deprecated use setColumns instead.
      */
-    public void setWidth(int width) {
-        super.setWidth(width);
+    public void setWidth(int columns) {
+        setColumns(columns);
     }
 
     /**
-     * Gets the width of the layout.
-     * <p>
-     * <strong>NOTE:</strong> The behaviour of this methdod has changed in
-     * version 5.0. Now this method won't return the number of columns in the
-     * grid like it used to (use {@link #getColumns()} for that). Instead, it
-     * returns the actual visual width of the layout in pixels or in another
-     * unit specified in {@link Sizeable}.UNIT_SYMBOLS.
-     * </p>
+     * @deprecated use getColumns instead.
      */
     public int getWidth() {
-        return super.getWidth();
+        return getColumns();
     }
 
     /**
@@ -873,31 +869,17 @@ public class GridLayout extends AbstractLayout {
     }
 
     /**
-     * Set the height of the layout.
-     * <p>
-     * <strong>NOTE:</strong> The behaviour of this methdod has changed in
-     * version 5.0. Now this method won't set the number of rows in the grid
-     * like it used to (use {@link #setRows()} for that). Instead, it sets the
-     * actual visual height of the layout in pixels or in another unit specified
-     * in {@link Sizeable}.UNIT_SYMBOLS.
-     * </p>
+     * @deprecated use setRows() instead.
      */
-    public void setHeight(int height) {
-        super.setHeight(height);
+    public void setHeight(int rows) {
+        setRows(rows);
     }
 
     /**
-     * Gets the height of the layout.
-     * <p>
-     * <strong>NOTE:</strong> The behaviour of this methdod has changed in
-     * version 5.0. Now this method won't return the number of rows in the grid
-     * like it used to (use {@link #getRows()} for that). Instead, it returns
-     * the actual visual height of the layout in pixels or in another unit
-     * specified in {@link Sizeable}.UNIT_SYMBOLS.
-     * </p>
+     * @deprecated use getRows() instead.
      */
     public int getHeight() {
-        return super.getHeight();
+        return getRows();
     }
 
     /**
@@ -1044,4 +1026,8 @@ public class GridLayout extends AbstractLayout {
         spacing = enabled;
     }
 
+    public Size getSize() {
+        return size;
+    }
+
 }
index cdc7c4273013337dab1b37b306a655233ace2408..55430113c726ab9ba4b39f1e3d7b104dfabed345 100644 (file)
@@ -4,7 +4,6 @@
 
 package com.itmill.toolkit.ui;
 
-import com.itmill.toolkit.terminal.Sizeable;
 
 /**
  * Extension to the {@link ComponentContainer} interface which adds the
@@ -17,7 +16,7 @@ import com.itmill.toolkit.terminal.Sizeable;
  * @VERSION@
  * @since 3.0
  */
-public interface Layout extends ComponentContainer, Sizeable {
+public interface Layout extends ComponentContainer {
 
     /**
      * Enable layout margins. Affects all four sides of the layout. This will
index a2be804cd6198d7b73c587a1440bb5df68d346c5..22f87ac220391a954d6d2a3b074b2ee3a03face4 100644 (file)
@@ -11,11 +11,12 @@ import java.util.Map;
 import com.itmill.toolkit.event.Action;
 import com.itmill.toolkit.event.ShortcutAction;
 import com.itmill.toolkit.event.Action.Handler;
+import com.itmill.toolkit.terminal.HasSize;
 import com.itmill.toolkit.terminal.KeyMapper;
 import com.itmill.toolkit.terminal.PaintException;
 import com.itmill.toolkit.terminal.PaintTarget;
 import com.itmill.toolkit.terminal.Scrollable;
-import com.itmill.toolkit.terminal.Sizeable;
+import com.itmill.toolkit.terminal.Size;
 
 /**
  * Panel - a simple single component container.
@@ -25,37 +26,15 @@ import com.itmill.toolkit.terminal.Sizeable;
  * @VERSION@
  * @since 3.0
  */
-public class Panel extends AbstractComponentContainer implements Sizeable,
+public class Panel extends AbstractComponentContainer implements HasSize,
         Scrollable, ComponentContainer.ComponentAttachListener,
         ComponentContainer.ComponentDetachListener, Action.Container {
 
     public static final String STYLE_LIGHT = "light";
 
     public static final String STYLE_EMPHASIZE = "emphasize";
-
-    /**
-     * Height of the layout. Set to -1 for undefined height.
-     */
-    private int height = -1;
-
-    /**
-     * Height unit.
-     * 
-     * @see com.itmill.toolkit.terminal.Sizeable.UNIT_SYMBOLS;
-     */
-    private int heightUnit = UNITS_PIXELS;
-
-    /**
-     * Width of the layout. Set to -1 for undefined width.
-     */
-    private int width = -1;
-
-    /**
-     * Width unit.
-     * 
-     * @see com.itmill.toolkit.terminal.Sizeable.UNIT_SYMBOLS;
-     */
-    private int widthUnit = UNITS_PIXELS;
+    
+    private Size size;
 
     /**
      * Layout of the panel.
@@ -88,6 +67,7 @@ public class Panel extends AbstractComponentContainer implements Sizeable,
      */
     public Panel() {
         setLayout(null);
+        size = new Size(this);
     }
 
     /**
@@ -98,6 +78,7 @@ public class Panel extends AbstractComponentContainer implements Sizeable,
      */
     public Panel(Layout layout) {
         setLayout(layout);
+        size = new Size(this);
     }
 
     /**
@@ -121,6 +102,7 @@ public class Panel extends AbstractComponentContainer implements Sizeable,
     public Panel(String caption, Layout layout) {
         this(layout);
         setCaption(caption);
+        size = new Size(this);
     }
 
     /**
@@ -187,13 +169,13 @@ public class Panel extends AbstractComponentContainer implements Sizeable,
         layout.paint(target);
 
         // Add size info as variables
-        if (getHeight() > -1) {
-            target.addVariable(this, "height", getHeight()
-                    + UNIT_SYMBOLS[getHeightUnits()]);
+        if (size.getHeight() > -1) {
+            target.addVariable(this, "height", size.getHeight()
+                    + Size.UNIT_SYMBOLS[size.getHeightUnits()]);
         }
-        if (getWidth() > -1) {
-            target.addVariable(this, "width", getWidth()
-                    + UNIT_SYMBOLS[getWidthUnits()]);
+        if (size.getWidth() > -1) {
+            target.addVariable(this, "width", size.getWidth()
+                    + Size.UNIT_SYMBOLS[size.getWidthUnits()]);
         }
 
         if (isScrollable()) {
@@ -300,16 +282,16 @@ public class Panel extends AbstractComponentContainer implements Sizeable,
         // Get new size
         final Integer newWidth = (Integer) variables.get("width");
         final Integer newHeight = (Integer) variables.get("height");
-        if (newWidth != null && newWidth.intValue() != getWidth()) {
-            setWidth(newWidth.intValue());
-            // ensure units as we are reading pixels
-            setWidthUnits(UNITS_PIXELS);
+        if (newWidth != null && newWidth.intValue() != size.getWidth()) {
+            size.setWidth(newWidth.intValue());
+            // ensure units, as we are reading pixels
+            size.setWidthUnits(Size.UNITS_PIXELS);
 
         }
-        if (newHeight != null && newHeight.intValue() != getHeight()) {
-            setHeight(newHeight.intValue());
-            // ensure units as we are reading pixels
-            setHeightUnits(UNITS_PIXELS);
+        if (newHeight != null && newHeight.intValue() != size.getHeight()) {
+            size.setHeight(newHeight.intValue());
+            // ensure units, as we are reading pixels
+            size.setHeightUnits(Size.UNITS_PIXELS);
         }
 
         // Scrolling
@@ -481,106 +463,67 @@ public class Panel extends AbstractComponentContainer implements Sizeable,
         }
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see com.itmill.toolkit.terminal.Sizeable#getHeight()
-     */
-    public int getHeight() {
-        return height;
+    public Size getSize() {
+        return size;
     }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see com.itmill.toolkit.terminal.Sizeable#getHeightUnits()
-     */
-    public int getHeightUnits() {
-        return heightUnit;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see com.itmill.toolkit.terminal.Sizeable#getWidth()
+    
+    
+    /* Compatibility methods */
+    
+    /**
+     * @deprecated use Size object instead (getSize().setWidth()).
      */
-    public int getWidth() {
-        return width;
+    public void setWidth(int width) {
+        size.setWidth(width);
     }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see com.itmill.toolkit.terminal.Sizeable#getWidthUnits()
+    
+    /**
+     * @deprecated use Size object instead (getSize().setWidthUnits()).
      */
-    public int getWidthUnits() {
-        return widthUnit;
+    public void setWidthUnits(int unit) {
+        size.setWidthUnits(unit);
     }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see com.itmill.toolkit.terminal.Sizeable#setHeight(int)
+    
+    /**
+     * @deprecated use Size object instead (getSize().setHeight()).
      */
     public void setHeight(int height) {
-        this.height = height;
-        requestRepaint();
+        size.setHeight(height);
     }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see com.itmill.toolkit.terminal.Sizeable#setHeightUnits(int)
+    
+    /**
+     * @deprecated use Size object instead (getSize().setHeightUnits()).
      */
-    public void setHeightUnits(int units) {
-        heightUnit = units;
-        requestRepaint();
+    public void setHeightUnits(int unit) {
+        size.setHeightUnits(unit);
     }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see com.itmill.toolkit.terminal.Sizeable#setSizeFull()
+    
+    /**
+     * @deprecated use Size object instead (getSize().getWidth()).
      */
-    public void setSizeFull() {
-        height = 100;
-        width = 100;
-        heightUnit = UNITS_PERCENTAGE;
-        widthUnit = UNITS_PERCENTAGE;
-        requestRepaint();
+    public int getWidth() {
+        return size.getWidth();
     }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see com.itmill.toolkit.terminal.Sizeable#setSizeUndefined()
+    
+    /**
+     * @deprecated use Size object instead (getSize().getWidthUnits()).
      */
-    public void setSizeUndefined() {
-        height = -1;
-        width = -1;
-        heightUnit = UNITS_PIXELS;
-        widthUnit = UNITS_PIXELS;
-        requestRepaint();
+    public int getWidthUnits() {
+        return size.getWidthUnits();
     }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see com.itmill.toolkit.terminal.Sizeable#setWidth(int)
+    
+    /**
+     * @deprecated use Size object instead (getSize().getHeight()).
      */
-    public void setWidth(int width) {
-        this.width = width;
-        requestRepaint();
+    public int getHeight() {
+        return size.getHeight();
     }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see com.itmill.toolkit.terminal.Sizeable#setWidthUnits(int)
+    
+    /**
+     * @deprecated use Size object instead (getSize().getHeightUnits()).
      */
-    public void setWidthUnits(int units) {
-        widthUnit = units;
-        requestRepaint();
+    public int getHeightUnits() {
+        return size.getHeightUnits();
     }
 
 }
index c09b337b099c6a2ff16085e6efc119c5cf95541d..9f094f01538781a26b0dbf104d71ce8dd575233e 100644 (file)
@@ -6,9 +6,10 @@ package com.itmill.toolkit.ui;
 
 import java.util.Iterator;
 
+import com.itmill.toolkit.terminal.HasSize;
 import com.itmill.toolkit.terminal.PaintException;
 import com.itmill.toolkit.terminal.PaintTarget;
-import com.itmill.toolkit.terminal.Sizeable;
+import com.itmill.toolkit.terminal.Size;
 
 /**
  * SplitPanel.
@@ -21,7 +22,7 @@ import com.itmill.toolkit.terminal.Sizeable;
  * @VERSION@
  * @since 5.0
  */
-public class SplitPanel extends AbstractLayout {
+public class SplitPanel extends AbstractLayout implements HasSize {
 
     /* Predefined orientations ***************************************** */
 
@@ -46,7 +47,9 @@ public class SplitPanel extends AbstractLayout {
 
     private int pos = 50;
 
-    private int posUnit = UNITS_PERCENTAGE;
+    private int posUnit = Size.UNITS_PERCENTAGE;
+
+    private Size size;
 
     /**
      * Creates a new split panel. The orientation of the panels is
@@ -54,7 +57,8 @@ public class SplitPanel extends AbstractLayout {
      */
     public SplitPanel() {
         orientation = ORIENTATION_VERTICAL;
-        setSizeFull();
+        size = new Size(this);
+        size.setSizeFull();
     }
 
     /**
@@ -65,8 +69,8 @@ public class SplitPanel extends AbstractLayout {
      *                the Orientation of the layout.
      */
     public SplitPanel(int orientation) {
-        this.orientation = orientation;
-        setSizeFull();
+        this();
+        setOrientation(orientation);
     }
 
     /**
@@ -194,7 +198,9 @@ public class SplitPanel extends AbstractLayout {
     public void paintContent(PaintTarget target) throws PaintException {
         super.paintContent(target);
 
-        final String position = pos + UNIT_SYMBOLS[posUnit];
+        size.paint(target);
+
+        final String position = pos + Size.UNIT_SYMBOLS[posUnit];
 
         target.addAttribute("position", position);
 
@@ -254,7 +260,7 @@ public class SplitPanel extends AbstractLayout {
      *                the new size of the first region in persentage
      */
     public void setSplitPosition(int pos) {
-        setSplitPosition(pos, UNITS_PERCENTAGE);
+        setSplitPosition(pos, Size.UNITS_PERCENTAGE);
     }
 
     /**
@@ -263,7 +269,7 @@ public class SplitPanel extends AbstractLayout {
      * @param pos
      *                size of the first region
      * @param unit
-     *                the unit (from {@link Sizeable}) in which the size is
+     *                the unit (from {@link Size}) in which the size is
      *                given.
      */
     public void setSplitPosition(int pos, int unit) {
@@ -271,4 +277,9 @@ public class SplitPanel extends AbstractLayout {
         posUnit = unit;
     }
 
+    public Size getSize() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
 }
index 87ec3cfc16f738062ed94296e6c5eac8f159cb48..4780a8702d0ee18132f1e6958d4afc1336174201 100644 (file)
@@ -10,11 +10,12 @@ import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.Map;
 
+import com.itmill.toolkit.terminal.HasSize;
 import com.itmill.toolkit.terminal.KeyMapper;
 import com.itmill.toolkit.terminal.PaintException;
 import com.itmill.toolkit.terminal.PaintTarget;
 import com.itmill.toolkit.terminal.Resource;
-import com.itmill.toolkit.terminal.Sizeable;
+import com.itmill.toolkit.terminal.Size;
 
 /**
  * Tabsheet component.
@@ -24,7 +25,7 @@ import com.itmill.toolkit.terminal.Sizeable;
  * @VERSION@
  * @since 3.0
  */
-public class TabSheet extends AbstractComponentContainer implements Sizeable {
+public class TabSheet extends AbstractComponentContainer implements HasSize {
 
     /**
      * Linked list of component tabs.
@@ -53,29 +54,7 @@ public class TabSheet extends AbstractComponentContainer implements Sizeable {
      */
     private boolean tabsHidden;
 
-    /**
-     * Height of the layout. Set to -1 for undefined height.
-     */
-    private int height = -1;
-
-    /**
-     * Height unit.
-     * 
-     * @see com.itmill.toolkit.terminal.Sizeable.UNIT_SYMBOLS;
-     */
-    private int heightUnit = UNITS_PIXELS;
-
-    /**
-     * Width of the layout. Set to -1 for undefined width.
-     */
-    private int width = -1;
-
-    /**
-     * Width unit.
-     * 
-     * @see com.itmill.toolkit.terminal.Sizeable.UNIT_SYMBOLS;
-     */
-    private int widthUnit = UNITS_PIXELS;
+    private Size size;
 
     /**
      * Constructs a new Tabsheet. Tabsheet is immediate by default.
@@ -83,6 +62,7 @@ public class TabSheet extends AbstractComponentContainer implements Sizeable {
     public TabSheet() {
         super();
         setImmediate(true);
+        size = new Size(this);
     }
 
     /**
@@ -197,15 +177,8 @@ public class TabSheet extends AbstractComponentContainer implements Sizeable {
      */
     public void paintContent(PaintTarget target) throws PaintException {
 
-        // Add size info
-        if (getHeight() > -1) {
-            target.addAttribute("height", getHeight()
-                    + UNIT_SYMBOLS[getHeightUnits()]);
-        }
-        if (getWidth() > -1) {
-            target.addAttribute("width", getWidth()
-                    + UNIT_SYMBOLS[getWidthUnits()]);
-        }
+        // Size
+        size.paint(target);
 
         if (areTabsHidden()) {
             target.addAttribute("hidetabs", true);
@@ -509,106 +482,8 @@ public class TabSheet extends AbstractComponentContainer implements Sizeable {
         fireEvent(new SelectedTabChangeEvent(this));
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see com.itmill.toolkit.terminal.Sizeable#getHeight()
-     */
-    public int getHeight() {
-        return height;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see com.itmill.toolkit.terminal.Sizeable#getHeightUnits()
-     */
-    public int getHeightUnits() {
-        return heightUnit;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see com.itmill.toolkit.terminal.Sizeable#getWidth()
-     */
-    public int getWidth() {
-        return width;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see com.itmill.toolkit.terminal.Sizeable#getWidthUnits()
-     */
-    public int getWidthUnits() {
-        return widthUnit;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see com.itmill.toolkit.terminal.Sizeable#setHeight(int)
-     */
-    public void setHeight(int height) {
-        this.height = height;
-        requestRepaint();
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see com.itmill.toolkit.terminal.Sizeable#setHeightUnits(int)
-     */
-    public void setHeightUnits(int units) {
-        heightUnit = units;
-        requestRepaint();
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see com.itmill.toolkit.terminal.Sizeable#setSizeFull()
-     */
-    public void setSizeFull() {
-        height = 100;
-        width = 100;
-        heightUnit = UNITS_PERCENTAGE;
-        widthUnit = UNITS_PERCENTAGE;
-        requestRepaint();
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see com.itmill.toolkit.terminal.Sizeable#setSizeUndefined()
-     */
-    public void setSizeUndefined() {
-        height = -1;
-        width = -1;
-        heightUnit = UNITS_PIXELS;
-        widthUnit = UNITS_PIXELS;
-        requestRepaint();
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see com.itmill.toolkit.terminal.Sizeable#setWidth(int)
-     */
-    public void setWidth(int width) {
-        this.width = width;
-        requestRepaint();
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see com.itmill.toolkit.terminal.Sizeable#setWidthUnits(int)
-     */
-    public void setWidthUnits(int units) {
-        widthUnit = units;
-        requestRepaint();
+    public Size getSize() {
+        return size;
     }
 
 }
index 4be9b840e882ed71d0b4f73c59482030e561a8a3..5dbadf6d9c371a9acf17c62b115d91f9154169fc 100644 (file)
@@ -21,11 +21,12 @@ import com.itmill.toolkit.data.Property;
 import com.itmill.toolkit.data.util.ContainerOrderedWrapper;
 import com.itmill.toolkit.data.util.IndexedContainer;
 import com.itmill.toolkit.event.Action;
+import com.itmill.toolkit.terminal.HasSize;
 import com.itmill.toolkit.terminal.KeyMapper;
 import com.itmill.toolkit.terminal.PaintException;
 import com.itmill.toolkit.terminal.PaintTarget;
 import com.itmill.toolkit.terminal.Resource;
-import com.itmill.toolkit.terminal.Sizeable;
+import com.itmill.toolkit.terminal.Size;
 
 /**
  * <code>TableComponent</code> is used for representing data or components in
@@ -37,7 +38,7 @@ import com.itmill.toolkit.terminal.Sizeable;
  * @since 3.0
  */
 public class Table extends AbstractSelect implements Action.Container,
-        Container.Ordered, Container.Sortable, Sizeable {
+        Container.Ordered, Container.Sortable, HasSize {
 
     private static final int CELL_KEY = 0;
 
@@ -49,25 +50,7 @@ public class Table extends AbstractSelect implements Action.Container,
 
     private static final int CELL_FIRSTCOL = 4;
 
-    /**
-     * Width of the table or -1 if unspecified.
-     */
-    private int width = -1;
-
-    /**
-     * Height of the table or -1 if unspecified.
-     */
-    private int height = -1;
-
-    /**
-     * Width unit.
-     */
-    private int widthUnit = Sizeable.UNITS_PIXELS;
-
-    /**
-     * Height unit.
-     */
-    private int heightUnit = Sizeable.UNITS_PIXELS;
+    private Size size;
 
     /**
      * Left column alignment. <b>This is the default behaviour. </b>
@@ -308,6 +291,7 @@ public class Table extends AbstractSelect implements Action.Container,
      */
     public Table() {
         setRowHeaderMode(ROW_HEADER_MODE_HIDDEN);
+        size = new Size(this);
     }
 
     /**
@@ -1422,14 +1406,7 @@ public class Table extends AbstractSelect implements Action.Container,
         }
 
         // Size
-        if (getHeight() >= 0) {
-            target.addAttribute("height", "" + getHeight()
-                    + Sizeable.UNIT_SYMBOLS[getHeightUnits()]);
-        }
-        if (getWidth() >= 0) {
-            target.addAttribute("width", "" + getWidth()
-                    + Sizeable.UNIT_SYMBOLS[getWidthUnits()]);
-        }
+        size.paint(target);
 
         // Initialize temps
         final Object[] colids = getVisibleColumns();
@@ -2439,126 +2416,78 @@ public class Table extends AbstractSelect implements Action.Container,
     }
 
     /**
-     * Gets height property unit.
+     * Table does not support lazy options loading mode. Setting this true will
+     * throw UnsupportedOperationException.
      * 
-     * @see com.itmill.toolkit.terminal.Sizeable#getHeightUnits()
+     * @see com.itmill.toolkit.ui.Select#setLazyLoading(boolean)
      */
-    public int getHeightUnits() {
-        return heightUnit;
+    public void setLazyLoading(boolean useLazyLoading) {
+        if (useLazyLoading) {
+            throw new UnsupportedOperationException(
+                    "Lazy options loading is not supported by Table.");
+        }
     }
 
+    public Size getSize() {
+        return size;
+    }
+    
+    /* Compatibility methods */
+    
     /**
-     * Gets width property unit.
-     * 
-     * @see com.itmill.toolkit.terminal.Sizeable#getWidthUnits()
+     * @deprecated use Size object instead (getSize().setWidth()).
      */
-    public int getWidthUnits() {
-        return widthUnit;
+    public void setWidth(int width) {
+        size.setWidth(width);
     }
-
+    
     /**
-     * Sets height units.
-     * 
-     * @see com.itmill.toolkit.terminal.Sizeable#setHeightUnits(int)
+     * @deprecated use Size object instead (getSize().setWidthUnits()).
      */
-    public void setHeightUnits(int units) {
-        heightUnit = units;
+    public void setWidthUnits(int unit) {
+        size.setWidthUnits(unit);
     }
-
+    
     /**
-     * Sets width units. Table supports only Sizeable.UNITS_PIXELS and
-     * Sizeable.UNITS_PERCENTAGE. Setting to any other throws
-     * IllegalArgumentException.
-     * 
-     * @see com.itmill.toolkit.terminal.Sizeable#setWidthUnits(int)
+     * @deprecated use Size object instead (getSize().setHeight()).
      */
-    public void setWidthUnits(int units) {
-        if (units != Sizeable.UNITS_PIXELS
-                && units != Sizeable.UNITS_PERCENTAGE) {
-            throw new IllegalArgumentException();
-        }
-        widthUnit = units;
+    public void setHeight(int height) {
+        size.setHeight(height);
     }
-
+    
     /**
-     * Gets height.
-     * 
-     * @return height value as a positive integer or negative value if not
-     *         assigned.
-     * @see com.itmill.toolkit.terminal.Sizeable#getHeight()
+     * @deprecated use Size object instead (getSize().setHeightUnits()).
      */
-    public int getHeight() {
-        return height;
+    public void setHeightUnits(int unit) {
+        size.setHeightUnits(unit);
     }
-
+    
     /**
-     * Gets width.
-     * 
-     * @return width value as positive integer or negative value if not
-     *         assigned.
-     * @see com.itmill.toolkit.terminal.Sizeable#getWidth()
+     * @deprecated use Size object instead (getSize().getWidth()).
      */
     public int getWidth() {
-        return width;
+        return size.getWidth();
     }
-
+    
     /**
-     * Sets height. Use negative value to let the client decide the height.
-     * 
-     * @param height
-     *                the height to set.
+     * @deprecated use Size object instead (getSize().getWidthUnits()).
      */
-    public void setHeight(int height) {
-        this.height = height;
-        requestRepaint();
+    public int getWidthUnits() {
+        return size.getWidthUnits();
     }
-
+    
     /**
-     * Sets width. Use negative value to allow the client decide the width.
-     * 
-     * @param width
-     *                the width to set.
+     * @deprecated use Size object instead (getSize().getHeight()).
      */
-    public void setWidth(int width) {
-        this.width = width;
-        requestRepaint();
+    public int getHeight() {
+        return size.getHeight();
     }
-
+    
     /**
-     * Table does not support lazy options loading mode. Setting this true will
-     * throw UnsupportedOperationException.
-     * 
-     * @see com.itmill.toolkit.ui.Select#setLazyLoading(boolean)
+     * @deprecated use Size object instead (getSize().getHeightUnits()).
      */
-    public void setLazyLoading(boolean useLazyLoading) {
-        if (useLazyLoading) {
-            throw new UnsupportedOperationException(
-                    "Lazy options loading is not supported by Table.");
-        }
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see com.itmill.toolkit.terminal.Sizeable#setSizeFull()
-     */
-    public void setSizeFull() {
-        setWidth(100);
-        setHeight(100);
-        setWidthUnits(UNITS_PERCENTAGE);
-        setHeightUnits(UNITS_PERCENTAGE);
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see com.itmill.toolkit.terminal.Sizeable#setSizeUndefined()
-     */
-    public void setSizeUndefined() {
-        setWidth(-1);
-        setHeight(-1);
-        setWidthUnits(UNITS_PIXELS);
-        setHeightUnits(UNITS_PIXELS);
+    public int getHeightUnits() {
+        return size.getHeightUnits();
     }
 
 }
\ No newline at end of file