// possible.
final ExpandLayout exl = new ExpandLayout();
browser.setLayout(exl);
- exl.setSizeFull();
+ exl.getSize().setSizeFull();
// create the address combobox
final Select select = new Select();
+ " 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;
}
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() {
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;
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);
// 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);
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);
// 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
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);
}
public EmbeddedBrowserExample(String[] urls) {
- setSizeFull();
+ getSize().setSizeFull();
// create the address combobox
final Select select = new Select();
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;
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();
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);
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);
if (Layout.class.isAssignableFrom(component.getClass())) {
w.setLayout((Layout) component);
} else {
- w.getLayout().setSizeFull();
+ //w.getLayout().getSize().setSizeFull();
w.addComponent(component);
}
addWindow(w);
OrderedLayout.ALIGNMENT_TOP);
ts = new TabSheet();
- ts.setSizeFull();
+ ts.getSize().setSizeFull();
ts.addTab(new Label(""), "Choose example", null);
exp.addComponent(ts);
exp.expand(ts);
// "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
// "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
// 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
\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
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
--- /dev/null
+package com.itmill.toolkit.terminal;
+
+public interface HasSize {
+
+ public Size getSize();
+
+}
--- /dev/null
+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
* @version
* @VERSION@
* @since 3.0
+ * @deprecated
*/
public interface Sizeable {
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);
+ "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;
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;
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);
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;
"<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);
}
"<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);
"<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);
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,
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,
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;
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);
\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
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
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
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
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
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;
// 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);
// 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
\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
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
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() {
ol2.addComponent(commit);
status.addComponent(ol2);
- status.setHeight(300);
- status.setWidth(400);
+ status.getSize().setHeight(300);
+ status.getSize().setWidth(400);
ol.addComponent(status);
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;
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);
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");
});
status.addComponent(clear);
- status.setHeight(300);
- status.setWidth(400);
+ status.getSize().setHeight(300);
+ status.getSize().setWidth(400);
ol.addComponent(status);
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;
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();
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);
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;
setCaption("Properties");
addComponent(formsLayout);
- setWidth(100);
- setWidthUnits(Table.UNITS_PERCENTAGE);
- setHeight(100);
- setHeightUnits(Table.UNITS_PERCENTAGE);
+ getSize().setSizeFull();
// Target object
this.objectToConfigure = objectToConfigure;
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();
}
// 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);
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);
}
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);
// 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);
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;
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());
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);
// 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. */
/*
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");
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);
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;
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);
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,
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,
\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
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
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
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
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
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;
// 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);
// 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
ol2.addComponent(commit);
status.addComponent(ol2);
- status.setHeight(300);
- status.setWidth(400);
+ status.getSize().setHeight(300);
+ status.getSize().setWidth(400);
ol.addComponent(status);
});
status.addComponent(clear);
- status.setHeight(300);
- status.setWidth(400);
+ status.getSize().setHeight(300);
+ status.getSize().setWidth(400);
ol.addComponent(status);
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)
*
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)
*
// 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()]);
- }
}
}
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>
* @VERSION@
* @since 3.0
*/
-public class CustomLayout extends AbstractLayout {
+public class CustomLayout extends AbstractLayout implements HasSize {
/**
* Custom layout slots containing the components.
private String templateName;
+ private Size size;
+
/**
* Constructor for custom layout with given template name.
*/
public CustomLayout(String template) {
templateName = template;
+ size = new Size(this);
}
/**
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();) {
"CustomLayout does not support margins.");
}
+ public Size getSize() {
+ return size;
+ }
+
}
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
* 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) {
}
// 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
}
}
+ public Size getSize() {
+ return size;
+ }
+
}
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;
/**
* @VERSION@
* @since 3.0
*/
-public class GridLayout extends AbstractLayout {
+public class GridLayout extends AbstractLayout implements HasSize {
/**
* Initial grid columns.
*/
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
public GridLayout(int columns, int rows) {
setColumns(columns);
setRows(rows);
+ size = new Size(this);
}
/**
super.paintContent(target);
+ // Size
+ size.paint(target);
+
// TODO refactor attribute names in future release.
target.addAttribute("h", rows);
target.addAttribute("w", cols);
}
/**
- * 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();
}
/**
}
/**
- * 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();
}
/**
spacing = enabled;
}
+ public Size getSize() {
+ return size;
+ }
+
}
package com.itmill.toolkit.ui;
-import com.itmill.toolkit.terminal.Sizeable;
/**
* Extension to the {@link ComponentContainer} interface which adds the
* @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
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.
* @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.
*/
public Panel() {
setLayout(null);
+ size = new Size(this);
}
/**
*/
public Panel(Layout layout) {
setLayout(layout);
+ size = new Size(this);
}
/**
public Panel(String caption, Layout layout) {
this(layout);
setCaption(caption);
+ size = new Size(this);
}
/**
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()) {
// 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
}
}
- /*
- * (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();
}
}
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.
* @VERSION@
* @since 5.0
*/
-public class SplitPanel extends AbstractLayout {
+public class SplitPanel extends AbstractLayout implements HasSize {
/* Predefined orientations ***************************************** */
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
*/
public SplitPanel() {
orientation = ORIENTATION_VERTICAL;
- setSizeFull();
+ size = new Size(this);
+ size.setSizeFull();
}
/**
* the Orientation of the layout.
*/
public SplitPanel(int orientation) {
- this.orientation = orientation;
- setSizeFull();
+ this();
+ setOrientation(orientation);
}
/**
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);
* the new size of the first region in persentage
*/
public void setSplitPosition(int pos) {
- setSplitPosition(pos, UNITS_PERCENTAGE);
+ setSplitPosition(pos, Size.UNITS_PERCENTAGE);
}
/**
* @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) {
posUnit = unit;
}
+ public Size getSize() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
}
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.
* @VERSION@
* @since 3.0
*/
-public class TabSheet extends AbstractComponentContainer implements Sizeable {
+public class TabSheet extends AbstractComponentContainer implements HasSize {
/**
* Linked list of component tabs.
*/
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.
public TabSheet() {
super();
setImmediate(true);
+ size = new Size(this);
}
/**
*/
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);
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;
}
}
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
* @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;
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>
*/
public Table() {
setRowHeaderMode(ROW_HEADER_MODE_HIDDEN);
+ size = new Size(this);
}
/**
}
// 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();
}
/**
- * 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