// possible.
final ExpandLayout exl = new ExpandLayout();
browser.setLayout(exl);
- exl.getSize().setSizeFull();
+ exl.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.getSize().setWidth(222);
+ panel.setWidth(222);
return panel;
}
main.addWindow(w);
w.setPositionX(100);
w.setPositionY(100);
- w.getSize().setWidth(200);
- w.getSize().setHeight(200);
+ w.setWidth(200);
+ w.setHeight(200);
- w.getSize().setWidth(100);
- w.getSize().setHeight(400);
+ w.setWidth(100);
+ w.setHeight(400);
final Button closebutton = new Button("Close "
+ w.getCaption(), new Button.ClickListener() {
params.addContainerProperty("Key", String.class, "");
params.addContainerProperty("Value", String.class, "");
final Panel panel2 = new Panel("Parameter Handler");
- params.getSize().setSizeFull();
+ params.setSizeFull();
panel2.setLayout(new ExpandLayout());
panel2.getLayout().setMargin(true);
// configure file structure panel
main.addComponent(explorerPanel);
explorerPanel.addComponent(tree);
- explorerPanel.getSize().setHeight(400);
+ explorerPanel.setHeight(400);
// "this" handles tree's expand event
tree.addListener(this);
import com.itmill.toolkit.data.util.FilesystemContainer;
import com.itmill.toolkit.data.util.FilesystemContainer.FileItem;
import com.itmill.toolkit.demo.util.SampleDirectory;
-import com.itmill.toolkit.terminal.Size;
import com.itmill.toolkit.ui.ExpandLayout;
import com.itmill.toolkit.ui.Field;
import com.itmill.toolkit.ui.Label;
main.setMargin(true);
main.setSpacing(true);
- propertyPanel.getSize().setHeight(120);
+ propertyPanel.setHeight(120);
main.addComponent(propertyPanel);
- explorerPanel.getSize().setHeight(100);
- explorerPanel.getSize().setHeightUnits(Size.UNITS_PERCENTAGE);
+ explorerPanel.setHeight(100);
+ explorerPanel.setHeightUnits(Panel.UNITS_PERCENTAGE);
main.addComponent(explorerPanel);
main.expand(explorerPanel);
// Create menu window.
final Window menu = new Window("Select demo");
- menu.getSize().setWidth(200);
- menu.getSize().setHeight(400);
+ menu.setWidth(200);
+ menu.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.getSize().setWidth(520);
- w.getSize().setHeight(500);
+ w.setWidth(520);
+ w.setHeight(500);
w.setPositionX(202);
windows.put(demoName, w);
getMainWindow().addWindow(w);
}
public EmbeddedBrowserExample(String[] urls) {
- getSize().setSizeFull();
+ 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.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, Size.UNITS_PIXELS);
+ split.setSplitPosition(200, SplitPanel.UNITS_PIXELS);
main.setLayout(split);
final HashMap sectionIds = new HashMap();
split.addComponent(tree);
final SplitPanel split2 = new SplitPanel();
- split2.setSplitPosition(200, Size.UNITS_PIXELS);
+ split2.setSplitPosition(200, SplitPanel.UNITS_PIXELS);
split.addComponent(split2);
table = new Table();
table.setDebugId("FeatureBrowser: Main Table");
- table.getSize().setSizeFull();
+ table.setSizeFull();
table.setColumnReorderingAllowed(true);
table.setColumnCollapsingAllowed(true);
table.setSelectable(true);
return;
}
Window w = new Window(caption);
- w.getSize().setWidth(640);
+ w.setWidth(640);
if (Layout.class.isAssignableFrom(component.getClass())) {
w.setLayout((Layout) component);
} else {
OrderedLayout.ALIGNMENT_TOP);
ts = new TabSheet();
- ts.getSize().setSizeFull();
+ ts.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.getSize().setWidth(550);\r
+ source.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.getSize().setWidth(550);\r
+ saved.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.getSize().setWidth(250);
+ p.setWidth(250);
// Description
p.addComponent(new Label(desc));
// Tree with a few items
allLayout.setMargin(true);\r
\r
allTable = new Table();\r
- allTable.getSize().setHeight(300);\r
- allTable.getSize().setWidth(700);\r
+ allTable.setHeight(300);\r
+ allTable.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 {
*/
public static final int UNITS_ROWS = 9;
+ public static final int SIZE_UNDEFINED = -1;
+
/**
* Textual representations of units symbols. Supported units and their
* symbols are:
}
}
+ updateComponentSize(component, uidl);
+
// Styles + disabled & readonly
component.setStyleName(component.getStylePrimaryName());
return false;
}
+ private void updateComponentSize(Widget component, UIDL uidl) {
+ String w = uidl.hasAttribute("width") ? uidl
+ .getStringAttribute("width") : "";
+ component.setWidth(w);
+ String h = uidl.hasAttribute("height") ? uidl
+ .getStringAttribute("height") : "";
+ component.setHeight(h);
+ }
+
/**
* Get either existing or new Paintable for given UIDL.
*
package com.itmill.toolkit.terminal.gwt.client.ui;
-import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.HTML;
import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection;
import com.itmill.toolkit.terminal.gwt.client.Paintable;
public class IEmbedded extends HTML implements Paintable {
+ private String heigth;
+ private String width;
+
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
if (client.updateComponent(this, uidl, true)) {
return;
}
- final String w = uidl.hasAttribute("width") ? uidl
- .getStringAttribute("width") : "100%";
- final String h = uidl.hasAttribute("height") ? uidl
- .getStringAttribute("height") : "100%";
- DOM.setStyleAttribute(getElement(), "width", w);
- DOM.setStyleAttribute(getElement(), "height", h);
if (uidl.hasAttribute("type")) {
final String type = uidl.getStringAttribute("type");
} else if (uidl.hasAttribute("mimetype")) {
final String mime = uidl.getStringAttribute("mimetype");
if (mime.equals("application/x-shockwave-flash")) {
- setHTML("<object width=\"" + w + "\" height=\"" + h
+ setHTML("<object width=\"" + width + "\" height=\"" + heigth
+ "\"><param name=\"movie\" value=\""
+ getSrc(uidl, client) + "\"><embed src=\""
- + getSrc(uidl, client) + "\" width=\"" + w
- + "\" height=\"" + h + "\"></embed></object>");
+ + getSrc(uidl, client) + "\" width=\"" + width
+ + "\" height=\"" + heigth + "\"></embed></object>");
} else {
ApplicationConnection.getConsole().log(
"Unknown Embedded mimetype '" + mime + "'");
private String getSrc(UIDL uidl, ApplicationConnection client) {
return client.translateToolkitUri(uidl.getStringAttribute("src"));
}
+
+ public void setWidth(String width) {
+ if (width == null || width.equals("")) {
+ width = "100%";
+ }
+ this.width = width;
+ super.setHeight(width);
+ }
+
+ public void setHeight(String height) {
+ if (height == null || height.equals("")) {
+ height = "100%";
+ }
+ heigth = height;
+ super.setHeight(height);
+ }
}
}
protected void handleMargins(UIDL uidl) {
- final MarginInfo margins = new MarginInfo(uidl
- .getIntAttribute("margins"));
- setStyleName(marginElement,
- CLASSNAME + "-" + StyleConstants.MARGIN_TOP, margins.hasTop());
- setStyleName(marginElement, CLASSNAME + "-"
- + StyleConstants.MARGIN_RIGHT, margins.hasRight());
- setStyleName(marginElement, CLASSNAME + "-"
- + StyleConstants.MARGIN_BOTTOM, margins.hasBottom());
- setStyleName(marginElement, CLASSNAME + "-"
- + StyleConstants.MARGIN_LEFT, margins.hasLeft());
+ if (uidl.hasAttribute("margins")) {
+ final MarginInfo margins = new MarginInfo(uidl
+ .getIntAttribute("margins"));
+ setStyleName(marginElement, CLASSNAME + "-"
+ + StyleConstants.MARGIN_TOP, margins.hasTop());
+ setStyleName(marginElement, CLASSNAME + "-"
+ + StyleConstants.MARGIN_RIGHT, margins.hasRight());
+ setStyleName(marginElement, CLASSNAME + "-"
+ + StyleConstants.MARGIN_BOTTOM, margins.hasBottom());
+ setStyleName(marginElement, CLASSNAME + "-"
+ + StyleConstants.MARGIN_LEFT, margins.hasLeft());
+ }
}
public boolean hasChildComponent(Widget component) {
this.client = client;
+ // Modify layout margins
+ handleMargins(uidl);
+
// Ensure correct implementation
if (client.updateComponent(this, uidl, false)) {
return;
}
- // Modify layout margins
- handleMargins(uidl);
-
- setWidth(uidl.hasAttribute("width") ? uidl.getStringAttribute("width")
- : "");
-
- setHeight(uidl.hasAttribute("height") ? uidl
- .getStringAttribute("height") : "");
-
hasComponentSpacing = uidl.getBooleanAttribute("spacing");
final ArrayList uidlWidgets = new ArrayList();
.getStringVariable("width") : null;
height = uidl.hasVariable("height") ? uidl.getStringVariable("height")
: null;
- setWidth(w != null ? w : "");
+ super.setWidth(w != null ? w : "");
// Restore default stylenames
DOM
}
}
+ /**
+ * Panal handles dimensions by itself
+ */
+ public void setHeight(String height) {
+ // NOP
+ }
+
+ /**
+ * Panal handles dimensions by itself
+ */
+ public void setWidth(String width) {
+ // NOP
+ }
+
}
if (height == null) {
bodyContainer.setHeight((tBody.getRowHeight() * pageLength) + "px");
} else {
- setHeight(height);
+ mySetHeight(height);
iLayout();
}
w += getScrollbarWidth();
bodyContainer.setWidth(w + "px");
tHead.setWidth(w + "px");
- setWidth(w + "px");
+ super.setWidth(w + "px");
} else {
if (width.indexOf("px") > 0) {
bodyContainer.setWidth(width);
tHead.setWidth(width);
- setWidth(width);
+ super.setWidth(width);
} else if (width.indexOf("%") > 0) {
if (!width.equals("100%")) {
- setWidth(width);
+ super.setWidth(width);
}
// contained blocks are relative to parents
bodyContainer.setWidth("100%");
* which is what users usually want. So recalculate pixels via
* setHeight.
*/
- setHeight(height);
+ mySetHeight(height);
}
int contentH = (DOM.getElementPropertyInt(getElement(),
return panel.remove(w);
}
- public void setHeight(String height) {
+ public void mySetHeight(String height) {
// workaround very common 100% height problem - extract borders
if (height.equals("100%")) {
final int borders = getBorderSpace();
- DOM.getElementPropertyInt(el, "clientHeight");
}
+ public void setWidth(String width) {
+ // NOP size handled internally
+ }
+
+ public void setHeight(String height) {
+ // NOP size handled internally
+ }
+
}
return;
}
- setWidth(uidl.getStringAttribute("width"));
- setHeight(uidl.getStringAttribute("height"));
-
setSplitPosition(uidl.getStringAttribute("position"));
- final Paintable newFirstChild = (Paintable) client.getPaintable(uidl
+ final Paintable newFirstChild = client.getPaintable(uidl
.getChildUIDL(0));
- final Paintable newSecondChild = (Paintable) client.getPaintable(uidl
+ final Paintable newSecondChild = client.getPaintable(uidl
.getChildUIDL(1));
if (firstChild != newFirstChild) {
if (firstChild != null) {
// Set proper values for content element
DOM.setStyleAttribute(contentNode, "height", newHeight + "px");
+ tp.setHeight("100%");
+
DOM.setStyleAttribute(contentNode, "overflow", "auto");
// Restore content to normal flow
id = uidl.getId();
disabled = uidl.hasAttribute("disabled");
- // Adjust width and height
- if (uidl.hasAttribute("height")) {
- setHeight(uidl.getStringAttribute("height"));
- } else {
- setHeight("");
- }
- if (uidl.hasAttribute("width")) {
- setWidth(uidl.getStringAttribute("width"));
- } else {
- setWidth("");
- }
-
// Render content
final UIDL tabs = uidl.getChildUIDL(0);
if (keepCurrentTabs(uidl)) {
final OrderedLayout setupLayout = new OrderedLayout(
OrderedLayout.ORIENTATION_HORIZONTAL);
final Panel statusPanel = new Panel("Status");
- statusPanel.getSize().setWidth(200);
+ statusPanel.setWidth(200);
setupLayout.addComponent(statusPanel);
statusPanel.addComponent(statusLabel);
setupLayout.addComponent(randomSeedValue);
tabCaption, null);
}
ts.setSelectedTab((ComponentContainer) tabs.get(selectedTab));
- result = (ComponentContainer) ts;
+ result = ts;
break;
}
+ "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).getSize().setWidth(250);
+ ((Panel) result).setWidth(250);
break;
case 6:
// Datefield
\r
t = new Table();\r
\r
- t.getSize().setWidth(500);\r
- t.getSize().setHeight(300);\r
+ t.setWidth(500);\r
+ t.setHeight(300);\r
\r
ta[0] = TestForTablesInitialColumnWidthLogicRendering\r
.getTestTable(3, 0);\r
import com.itmill.toolkit.Application;
import com.itmill.toolkit.data.Property;
import com.itmill.toolkit.data.util.HierarchicalContainer;
-import com.itmill.toolkit.terminal.Size;
import com.itmill.toolkit.ui.Component;
import com.itmill.toolkit.ui.CustomComponent;
import com.itmill.toolkit.ui.ExpandLayout;
menu.addListener(this);
menu.setImmediate(true);
+ menu.setNullSelectionAllowed(false);
mainLayout.addComponent(menu);
bodyLayout.addStyleName("light");
- bodyLayout.getSize().setHeight(100, Size.UNITS_PERCENTAGE);
+ bodyLayout.setHeight(100, Component.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.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.getSize().setHeight(250, Size.UNITS_PIXELS);
+ el.setHeight(250, Component.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.getSize().setHeight(250, Size.UNITS_PIXELS);
+ sp1l.setHeight(250, ExpandLayout.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.getSize().setHeight(250, Size.UNITS_PIXELS);
+ sp2l.setHeight(250, SplitPanel.UNITS_PIXELS);
final SplitPanel sp2 = new SplitPanel(
SplitPanel.ORIENTATION_HORIZONTAL);
sp2l.addComponent(sp2);
final Table t = TestForTablesInitialColumnWidthLogicRendering
.getTestTable(4, 100);
- t.getSize().setSizeFull();
+ t.setSizeFull();
topRight.addComponent(t);
topRight.expand(t);
\r
import java.util.Locale;\r
\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.getSize().setHeight(-1);\r
+ tab.setHeight(-1);\r
}\r
\r
});\r
click2 = new Button("Set height 100%", new ClickListener() {\r
\r
public void buttonClick(ClickEvent event) {\r
- tab.getSize().setHeight(100, Size.UNITS_PERCENTAGE);\r
+ tab.setHeight(100, TabSheet.UNITS_PERCENTAGE);\r
}\r
\r
});\r
\r
final SplitPanel sp = new SplitPanel(SplitPanel.ORIENTATION_HORIZONTAL);\r
- sp.setSplitPosition(290, Size.UNITS_PIXELS);\r
+ sp.setSplitPosition(290, SplitPanel.UNITS_PIXELS);\r
\r
final SplitPanel sp2 = new SplitPanel(SplitPanel.ORIENTATION_VERTICAL);\r
- sp2.setSplitPosition(255, Size.UNITS_PIXELS);\r
+ sp2.setSplitPosition(255, SplitPanel.UNITS_PIXELS);\r
\r
final Panel p = new Panel("Accordion Panel");\r
- p.getSize().setSizeFull();\r
+ p.setSizeFull();\r
\r
tab = new TabSheet();\r
- tab.getSize().setSizeFull();\r
+ tab.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.getSize().setHeight(100, Size.UNITS_PERCENTAGE);\r
+ report.setHeight(100, SplitPanel.UNITS_PERCENTAGE);\r
\r
sp2.setFirstComponent(report);\r
\r
table.setColumnCollapsingAllowed(true);\r
table.setColumnReorderingAllowed(true);\r
table.setSortDisabled(false);\r
- table.getSize().setSizeFull();\r
+ table.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.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.getSize().setWidth(100, Size.UNITS_PERCENTAGE);
+ filterPanel.setWidth(100, Panel.UNITS_PERCENTAGE);
lo.addComponent(filterPanel);
filterPanel.addComponent(fooFilter);
filterPanel.addComponent(barFilter);
// Table
lo.addComponent(t);
t.setPageLength(12);
- t.getSize().setWidth(100, Size.UNITS_PERCENTAGE);
+ t.setWidth(100, Table.UNITS_PERCENTAGE);
t.setContainerDataSource(ic);
// Handler
\r
package com.itmill.toolkit.tests;\r
\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.getSize().setHeight(1, Size.UNITS_EM);\r
+ el.setHeight(1, ExpandLayout.UNITS_EM);\r
}\r
main.addComponent(el);\r
}\r
\r
package com.itmill.toolkit.tests;\r
\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.ExpandLayout;\r
main = new ExpandLayout(ExpandLayout.ORIENTATION_HORIZONTAL);\r
\r
Panel left = new Panel("Left column");\r
- left.getSize().setHeight(100, Size.UNITS_PERCENTAGE);\r
- left.getSize().setWidth(150);\r
+ left.setHeight(100, Panel.UNITS_PERCENTAGE);\r
+ left.setWidth(150);\r
main.addComponent(left);\r
\r
ExpandLayout center = new ExpandLayout();\r
Panel mainContent = new Panel();\r
center.addComponent(mainContent);\r
center.expand(mainContent);\r
- mainContent.getSize().setSizeFull();\r
+ mainContent.setSizeFull();\r
\r
ExpandLayout buttons = new ExpandLayout(\r
ExpandLayout.ORIENTATION_HORIZONTAL);\r
- buttons.getSize().setHeight(30, Size.UNITS_PIXELS);\r
+ buttons.setHeight(30, ExpandLayout.UNITS_PIXELS);\r
Button b1 = new Button("Save");\r
Button b2 = new Button("Cancel");\r
Button b3 = new Button("Logout");\r
main.expand(center);\r
\r
Panel right = new Panel("Right column");\r
- right.getSize().setHeight(100, Size.UNITS_PERCENTAGE);\r
- right.getSize().setWidth(200);\r
+ right.setHeight(100, Panel.UNITS_PERCENTAGE);\r
+ right.setWidth(200);\r
\r
main.addComponent(right);\r
\r
\r
package com.itmill.toolkit.tests;\r
\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
el.expand(b);\r
el.setComponentAlignment(b, ExpandLayout.ALIGNMENT_HORIZONTAL_CENTER,\r
ExpandLayout.ALIGNMENT_VERTICAL_CENTER);\r
- el.getSize().setHeight(60, Size.UNITS_PIXELS);\r
+ el.setHeight(60, ExpandLayout.UNITS_PIXELS);\r
el.setMargin(true);\r
main.addComponent(el);\r
\r
el.expand(b);\r
el.setComponentAlignment(b, ExpandLayout.ALIGNMENT_RIGHT,\r
ExpandLayout.ALIGNMENT_BOTTOM);\r
- el.getSize().setHeight(100, Size.UNITS_PIXELS);\r
+ el.setHeight(100, ExpandLayout.UNITS_PIXELS);\r
el.setSpacing(true);\r
\r
main.addComponent(el);\r
main.addWindow(w);
w.setPositionX(100);
w.setPositionY(100);
- w.getSize().setWidth(200);
- w.getSize().setHeight(200);
+ w.setWidth(200);
+ w.setHeight(200);
- w.getSize().setWidth(100);
- w.getSize().setHeight(400);
+ w.setWidth(100);
+ w.setHeight(400);
final Button closebutton = new Button("Close "
+ w.getCaption(), new Button.ClickListener() {
ol2.addComponent(commit);
status.addComponent(ol2);
- status.getSize().setHeight(300);
- status.getSize().setWidth(400);
+ status.setHeight(300);
+ status.setWidth(400);
ol.addComponent(status);
import java.util.Vector;
-import com.itmill.toolkit.terminal.Size;
import com.itmill.toolkit.ui.Button;
import com.itmill.toolkit.ui.CustomComponent;
import com.itmill.toolkit.ui.Label;
import com.itmill.toolkit.ui.OrderedLayout;
import com.itmill.toolkit.ui.Table;
+import com.itmill.toolkit.ui.Button.ClickEvent;
/**
*
t = getTestTable(3, 40);
t
.setCaption("Table with some columns and wide explicit width. (Ought to widen columns to use all space)");
- t.getSize().setWidth(1000);
+ t.setWidth(1000);
main.addComponent(t);
t = getTestTable(12, 4);
t.setCaption("Table with some rows and lot of columns, width == 100%");
- t.getSize().setWidth(100, Size.UNITS_PERCENTAGE);
+ t.setWidth(100, Table.UNITS_PERCENTAGE);
main.addComponent(t);
t = getTestTable(12, 100);
t
.setCaption("Table with lot of rows and lot of columns, width == 50%");
- t.getSize().setWidth(50, Size.UNITS_PERCENTAGE);
+ t.setWidth(50, Table.UNITS_PERCENTAGE);
main.addComponent(t);
t = getTestTable(5, 100);
t = getTestTable(4, 4);
t.setCaption("Table with some rows and width = 200px");
- t.getSize().setWidth(200);
+ t.setWidth(200);
main.addComponent(t);
final Button b = new Button("refresh view", this, "createNewView");
for (int i = 0; i < cols; i++) {
t.addContainerProperty(testString[i], String.class, "");
}
+ t.addContainerProperty("button", Button.class, null);
for (int i = 0; i < rows; i++) {
final Vector content = new Vector();
for (int j = 0; j < cols; j++) {
content.add(rndString());
}
+ content.add(new Button("b", new Button.ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ System.out.println("b click");
+
+ }
+ }));
t.addItem(content.toArray(), "" + i);
}
return t;
});
status.addComponent(clear);
- status.getSize().setHeight(300);
- status.getSize().setWidth(400);
+ status.setHeight(300);
+ status.setWidth(400);
ol.addComponent(status);
private File file;
- private FileInputStream stream;
-
public TmpFileBuffer() {
final String tempFileName = "upload_tmpfile_"
+ System.currentTimeMillis();
ts = new TabSheet();
- ts.getSize().setSizeFull();
+ ts.setSizeFull();
// Description tab
final String title = getTitle();
package com.itmill.toolkit.tests.featurebrowser;
import com.itmill.toolkit.terminal.ClassResource;
-import com.itmill.toolkit.terminal.Sizeable;
import com.itmill.toolkit.ui.Component;
import com.itmill.toolkit.ui.Embedded;
import com.itmill.toolkit.ui.Form;
new Integer(Embedded.TYPE_IMAGE),
new Integer(Embedded.TYPE_OBJECT) }, new Object[] { "Image",
"Object" });
- final Object[] units = new Object[Sizeable.UNIT_SYMBOLS.length];
- final Object[] symbols = new Object[Sizeable.UNIT_SYMBOLS.length];
+ final Object[] units = new Object[Embedded.UNIT_SYMBOLS.length];
+ final Object[] symbols = new Object[Embedded.UNIT_SYMBOLS.length];
for (int i = 0; i < units.length; i++) {
units[i] = new Integer(i);
- symbols[i] = Sizeable.UNIT_SYMBOLS[i];
+ symbols[i] = Embedded.UNIT_SYMBOLS[i];
}
ap.replaceWithSelect("heightUnits", units, symbols);
ap.replaceWithSelect("widthUnits", units, symbols);
demoWindow = new Window("Feature Test Window");
demoWindow.addListener(this);
- demoWindow.getSize().setWidth(400);
- demoWindow.getSize().setHeight(200);
+ demoWindow.setWidth(400);
+ demoWindow.setHeight(200);
demoWindow.setTheme("default");
layoutUpper.addComponent(addButton);
setCaption("Properties");
addComponent(formsLayout);
- getSize().setSizeFull();
+ 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.getSize().setSizeFull();
+ allProperties.setSizeFull();
updatePropertyList();
}
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.Sizeable;
import com.itmill.toolkit.terminal.StreamResource;
import com.itmill.toolkit.terminal.UserError;
import com.itmill.toolkit.ui.AbstractSelect;
public DownloadStream handleURI(URL context, String relativeUri) {
// Let default implementation handle requests for
// application resources.
- if (relativeUri.startsWith("APP"))
+ if (relativeUri.startsWith("APP")) {
return super.handleURI(context, relativeUri);
+ }
String example;
String param = null;
void example_Tree(Window main, String param) {
final Object[][] planets = new Object[][] {
- new Object[] {"Mercury"},
- new Object[] {"Venus"},
- new Object[] {"Earth", "The Moon"},
- new Object[] {"Mars", "Phobos", "Deimos"},
- new Object[] {"Jupiter", "Io", "Europa", "Ganymedes", "Callisto"},
- new Object[] {"Saturn", "Titan", "Tethys", "Dione", "Rhea", "Iapetus"},
- new Object[] {"Uranus", "Miranda", "Ariel", "Umbriel", "Titania", "Oberon"},
- new Object[] {"Neptune", "Triton", "Proteus", "Nereid", "Larissa"}};
+ new Object[] { "Mercury" },
+ new Object[] { "Venus" },
+ new Object[] { "Earth", "The Moon" },
+ new Object[] { "Mars", "Phobos", "Deimos" },
+ new Object[] { "Jupiter", "Io", "Europa", "Ganymedes",
+ "Callisto" },
+ new Object[] { "Saturn", "Titan", "Tethys", "Dione", "Rhea",
+ "Iapetus" },
+ new Object[] { "Uranus", "Miranda", "Ariel", "Umbriel",
+ "Titania", "Oberon" },
+ new Object[] { "Neptune", "Triton", "Proteus", "Nereid",
+ "Larissa" } };
final Tree tree = new Tree("The Planets and Major Moons");
void example_UserError(final Window main, String param) {
if (param != null) {
if (param.equals("form")) {
-
+
final FormLayout layout = new FormLayout();
main.addComponent(layout);
-
+
final TextField textfield = new TextField("Enter name");
layout.addComponent(textfield);
textfield.setComponentError(null);
final Button button = new Button("Click me!");
layout.addComponent(button);
-
+
button.addListener(new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
- if (((String)textfield.getValue()).length() == 0)
- textfield.setComponentError(new UserError("Must not be empty"));
- else // Clear the error
+ if (((String) textfield.getValue()).length() == 0) {
+ textfield.setComponentError(new UserError(
+ "Must not be empty"));
+ } else {
textfield.setComponentError(null);
+ }
}
});
}
final Button button = new Button("Click me!");
main.addComponent(button);
-
+
button.addListener(new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
- if (((String)textfield.getValue()).length() == 0)
- textfield.setComponentError(new UserError("Must not be empty"));
- else // Clear the error
+ if (((String) textfield.getValue()).length() == 0) {
+ textfield.setComponentError(new UserError(
+ "Must not be empty"));
+ } else {
textfield.setComponentError(null);
+ }
}
});
}
}
-
+
void example_DateField(Window main, String param) {
/* Create a DateField with the calendar style. */
final DateField date = new DateField("Here is a calendar field");
void example_Panel(Window main, String param) {
// Create a panel with a caption.
final Panel panel = new Panel("Contact Information");
-
+
// Create a layout inside the panel
final OrderedLayout form = new FormLayout();
-
+
// Set the layout as the root layout of the panel
panel.setLayout(form);
-
+
// Add some components
form.addComponent(new TextField("Name"));
form.addComponent(new TextField("Email"));
main.setLayout(layout);
layout.addStyleName("example-alignment");
- layout.getSize().setWidth(400, Size.UNITS_PIXELS);
- layout.getSize().setHeight(400, Size.UNITS_PIXELS);
+ layout.setWidth(400, Sizeable.UNITS_PIXELS);
+ layout.setHeight(400, Sizeable.UNITS_PIXELS);
/* Define cells and their layouts to create. */
/*
layout.expand(table);
/* Set it to use all available area. */
- table.getSize().setSizeFull();
+ table.setSizeFull();
/* Add some component below the expanding one. */
final Button button2 = new Button("Ok");
image.addStyleName("omaimage");
main.addComponent(image);
- final EmbeddedButton button = new EmbeddedButton(new ClassResource("smiley.jpg", this));
+ final EmbeddedButton button = new EmbeddedButton(new ClassResource(
+ "smiley.jpg", this));
main.addComponent(button);
}
/* Add link to the second window in the main window. */
main.addComponent(new Label("Second window: <a href='"
- + mywindow.getURL() + "'>middle-click to open</a>",
- Label.CONTENT_XHTML));
- main.addComponent(new Label("The second window can be accessed through URL: "
- + mywindow.getURL()));
+ + mywindow.getURL() + "'>middle-click to open</a>",
+ Label.CONTENT_XHTML));
+ main.addComponent(new Label(
+ "The second window can be accessed through URL: "
+ + mywindow.getURL()));
}
return;
}
mywindow.addComponent(okbutton);
/* Set window size. */
- mywindow.getSize().setHeight(200);
- mywindow.getSize().setWidth(400);
+ mywindow.setHeight(200);
+ mywindow.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.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.getSize().setHeight(100, Size.UNITS_PERCENTAGE);
+ bodyLayout.setHeight(100, Component.UNITS_PERCENTAGE);
bodyLayout.setLayout(new ExpandLayout());
mainLayout.addComponent(bodyLayout);
\r
import com.itmill.toolkit.data.util.QueryContainer;\r
import com.itmill.toolkit.demo.util.SampleDatabase;\r
-import com.itmill.toolkit.terminal.Size;\r
import com.itmill.toolkit.ui.Button;\r
+import com.itmill.toolkit.ui.Component;\r
import com.itmill.toolkit.ui.CustomComponent;\r
import com.itmill.toolkit.ui.DateField;\r
import com.itmill.toolkit.ui.ExpandLayout;\r
click = new Button("Set height -1", new ClickListener() {\r
\r
public void buttonClick(ClickEvent event) {\r
- tab.getSize().setHeight(-1);\r
+ tab.setHeight(-1);\r
}\r
\r
});\r
click2 = new Button("Set height 100%", new ClickListener() {\r
\r
public void buttonClick(ClickEvent event) {\r
- tab.getSize().setHeight(100, Size.UNITS_PERCENTAGE);\r
+ tab.setHeight(100, TabSheet.UNITS_PERCENTAGE);\r
}\r
\r
});\r
\r
final SplitPanel sp = new SplitPanel(SplitPanel.ORIENTATION_HORIZONTAL);\r
- sp.setSplitPosition(290, Size.UNITS_PIXELS);\r
+ sp.setSplitPosition(290, Component.UNITS_PIXELS);\r
\r
final SplitPanel sp2 = new SplitPanel(SplitPanel.ORIENTATION_VERTICAL);\r
- sp2.setSplitPosition(255, Size.UNITS_PIXELS);\r
+ sp2.setSplitPosition(255, Component.UNITS_PIXELS);\r
\r
final Panel p = new Panel("Accordion Panel");\r
- p.getSize().setSizeFull();\r
+ p.setSizeFull();\r
\r
tab = new TabSheet();\r
- tab.getSize().setSizeFull();\r
+ tab.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.getSize().setHeight(100, Size.UNITS_PERCENTAGE);\r
+ report.setHeight(100, Component.UNITS_PERCENTAGE);\r
\r
sp2.setFirstComponent(report);\r
\r
table.setColumnCollapsingAllowed(true);\r
table.setColumnReorderingAllowed(true);\r
table.setSortDisabled(false);\r
- table.getSize().setSizeFull();\r
+ table.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.Size;
import com.itmill.toolkit.ui.Button;
+import com.itmill.toolkit.ui.Component;
import com.itmill.toolkit.ui.CustomComponent;
import com.itmill.toolkit.ui.Label;
import com.itmill.toolkit.ui.OrderedLayout;
// Init filtering view
final Panel filterPanel = new Panel("Filter", new OrderedLayout(
OrderedLayout.ORIENTATION_HORIZONTAL));
- filterPanel.getSize().setWidth(100, Size.UNITS_PERCENTAGE);
+ filterPanel.setWidth(100, Component.UNITS_PERCENTAGE);
lo.addComponent(filterPanel);
filterPanel.addComponent(firstFilter);
filterPanel.addComponent(secondFilter);
// Table
lo.addComponent(t);
t.setPageLength(12);
- t.getSize().setWidth(100, Size.UNITS_PERCENTAGE);
+ t.setWidth(100, Component.UNITS_PERCENTAGE);
t.setContainerDataSource(ic);
// Handler
ol2.addComponent(commit);
status.addComponent(ol2);
- status.getSize().setHeight(300);
- status.getSize().setWidth(400);
+ status.setHeight(300);
+ status.setWidth(400);
ol.addComponent(status);
});
status.addComponent(clear);
- status.getSize().setHeight(300);
- status.getSize().setWidth(400);
+ status.setHeight(300);
+ status.setWidth(400);
ol.addComponent(status);
private String testingId;
+ /* Sizeable fields */
+
+ private int width = SIZE_UNDEFINED;
+ private int height = SIZE_UNDEFINED;
+ private int widthUnit = UNITS_PIXELS;
+ private int heightUnit = UNITS_PIXELS;
+
/* Constructor ***************************************************** */
/**
// Paint the contents of the component
+ if (getHeight() >= 0) {
+ target.addAttribute("height", "" + getHeight()
+ + UNIT_SYMBOLS[getHeightUnits()]);
+ }
+ if (getWidth() >= 0) {
+ target.addAttribute("width", "" + getWidth()
+ + UNIT_SYMBOLS[getWidthUnits()]);
+ }
+
if (styles != null && styles.size() > 0) {
target.addAttribute("style", getStyle());
}
public Object getData() {
return applicationData;
}
+
+ /* Sizeable and other size related methods */
+
+ /*
+ * (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 unit) {
+ heightUnit = unit;
+ 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;
+ 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 unit) {
+ widthUnit = unit;
+ requestRepaint();
+ }
+
+ public void setWidth(int width, int unit) {
+ setWidth(width);
+ setWidthUnits(unit);
+ }
}
\ No newline at end of file
import com.itmill.toolkit.terminal.ErrorMessage;
import com.itmill.toolkit.terminal.Paintable;
import com.itmill.toolkit.terminal.Resource;
+import com.itmill.toolkit.terminal.Sizeable;
import com.itmill.toolkit.terminal.VariableOwner;
/**
* @VERSION@
* @since 3.0
*/
-public interface Component extends Paintable, VariableOwner {
+public interface Component extends Paintable, VariableOwner, Sizeable {
/**
* Gets style for component. Multiple styles are joined with spaces.
return testingId;
}
+ // TODO bridge sizeable methods to composition root and documentate
+
+ public int getHeight() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public int getHeightUnits() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public int getWidth() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public int getWidthUnits() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public void setHeight(int height) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setHeightUnits(int units) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setSizeFull() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setSizeUndefined() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setWidth(int width) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setWidthUnits(int units) {
+ // TODO Auto-generated method stub
+
+ }
+
}
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 implements HasSize {
+public class CustomLayout extends AbstractLayout {
/**
* 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.Hashtable;
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.Resource;
-import com.itmill.toolkit.terminal.Size;
/**
* Component for embedding external objects.
* @VERSION@
* @since 3.0
*/
-public class Embedded extends AbstractComponent implements HasSize {
+public class Embedded extends AbstractComponent {
/**
* General object type.
private String archive = null;
- private Size size = new Size(this);
-
/**
* Creates a new empty Embedded object.
*/
*/
public void paintContent(PaintTarget target) throws PaintException {
- size.paint(target);
-
switch (type) {
case TYPE_IMAGE:
target.addAttribute("type", "image");
}
}
- public Size getSize() {
- return size;
- }
-
- /* Compatibility methods for previous Sizeable interface */
-
- /**
- * @deprecated use Size object instead (getSize().setWidth()).
- */
- public void setWidth(int width) {
- size.setWidth(width);
- }
-
- /**
- * @deprecated use Size object instead (getSize().setWidthUnits()).
- */
- public void setWidthUnits(int unit) {
- size.setWidthUnits(unit);
- }
-
- /**
- * @deprecated use Size object instead (getSize().setHeight()).
- */
- public void setHeight(int height) {
- size.setHeight(height);
- }
-
- /**
- * @deprecated use Size object instead (getSize().setHeightUnits()).
- */
- public void setHeightUnits(int unit) {
- size.setHeightUnits(unit);
- }
-
- /**
- * @deprecated use Size object instead (getSize().getWidth()).
- */
- public int getWidth() {
- return size.getWidth();
- }
-
- /**
- * @deprecated use Size object instead (getSize().getWidthUnits()).
- */
- public int getWidthUnits() {
- return size.getWidthUnits();
- }
-
- /**
- * @deprecated use Size object instead (getSize().getHeight()).
- */
- public int getHeight() {
- return size.getHeight();
- }
-
- /**
- * @deprecated use Size object instead (getSize().getHeightUnits()).
- */
- 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.Size;
/**
* TODO finish documentation
* other components don't use. Or just provide expanded container.
*
*/
-public class ExpandLayout extends OrderedLayout implements HasSize {
+public class ExpandLayout extends OrderedLayout {
private Component expanded;
- private Size size;
public ExpandLayout() {
- size = new Size(this);
- size.setSizeFull();
+ setSizeFull();
}
public ExpandLayout(int orientation) {
target.addAttribute("spacing", true);
}
- // Size
- size.paint(target);
-
// Adds the attributes: orientation
// note that the default values (b/vertival) are omitted
if (getOrientation() == ORIENTATION_HORIZONTAL) {
}
}
- 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.Size;
import com.itmill.toolkit.terminal.gwt.client.ui.AlignmentInfo;
/**
* @VERSION@
* @since 3.0
*/
-public class GridLayout extends AbstractLayout implements HasSize {
+public class GridLayout extends AbstractLayout {
/**
* 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);
spacing = enabled;
}
- public Size getSize() {
- return size;
- }
-
}
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.Size;
/**
* Panel - a simple single component container.
* @VERSION@
* @since 3.0
*/
-public class Panel extends AbstractComponentContainer implements HasSize,
- Scrollable, ComponentContainer.ComponentAttachListener,
+public class Panel extends AbstractComponentContainer implements Scrollable,
+ ComponentContainer.ComponentAttachListener,
ComponentContainer.ComponentDetachListener, Action.Container {
public static final String STYLE_LIGHT = "light";
public static final String STYLE_EMPHASIZE = "emphasize";
-
- 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 (size.getHeight() > -1) {
- target.addVariable(this, "height", size.getHeight()
- + Size.UNIT_SYMBOLS[size.getHeightUnits()]);
+ if (getHeight() > -1) {
+ target.addVariable(this, "height", getHeight()
+ + UNIT_SYMBOLS[getHeightUnits()]);
}
- if (size.getWidth() > -1) {
- target.addVariable(this, "width", size.getWidth()
- + Size.UNIT_SYMBOLS[size.getWidthUnits()]);
+ if (getWidth() > -1) {
+ target.addVariable(this, "width", getWidth()
+ + UNIT_SYMBOLS[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() != size.getWidth()) {
- size.setWidth(newWidth.intValue());
+ if (newWidth != null && newWidth.intValue() != getWidth()) {
+ setWidth(newWidth.intValue());
// ensure units, as we are reading pixels
- size.setWidthUnits(Size.UNITS_PIXELS);
+ setWidthUnits(UNITS_PIXELS);
}
- if (newHeight != null && newHeight.intValue() != size.getHeight()) {
- size.setHeight(newHeight.intValue());
+ if (newHeight != null && newHeight.intValue() != getHeight()) {
+ setHeight(newHeight.intValue());
// ensure units, as we are reading pixels
- size.setHeightUnits(Size.UNITS_PIXELS);
+ setHeightUnits(UNITS_PIXELS);
}
// Scrolling
requestRepaint();
}
}
-
- public Size getSize() {
- return size;
- }
-
-
- /* Compatibility methods */
-
- /**
- * @deprecated use Size object instead (getSize().setWidth()).
- */
- public void setWidth(int width) {
- size.setWidth(width);
- }
-
- /**
- * @deprecated use Size object instead (getSize().setWidthUnits()).
- */
- public void setWidthUnits(int unit) {
- size.setWidthUnits(unit);
- }
-
- /**
- * @deprecated use Size object instead (getSize().setHeight()).
- */
- public void setHeight(int height) {
- size.setHeight(height);
- }
-
- /**
- * @deprecated use Size object instead (getSize().setHeightUnits()).
- */
- public void setHeightUnits(int unit) {
- size.setHeightUnits(unit);
- }
-
- /**
- * @deprecated use Size object instead (getSize().getWidth()).
- */
- public int getWidth() {
- return size.getWidth();
- }
-
- /**
- * @deprecated use Size object instead (getSize().getWidthUnits()).
- */
- public int getWidthUnits() {
- return size.getWidthUnits();
- }
-
- /**
- * @deprecated use Size object instead (getSize().getHeight()).
- */
- public int getHeight() {
- return size.getHeight();
- }
-
- /**
- * @deprecated use Size object instead (getSize().getHeightUnits()).
- */
- 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.Size;
/**
* SplitPanel.
* @VERSION@
* @since 5.0
*/
-public class SplitPanel extends AbstractLayout implements HasSize {
+public class SplitPanel extends AbstractLayout {
/* Predefined orientations ***************************************** */
private int pos = 50;
- private int posUnit = Size.UNITS_PERCENTAGE;
-
- private Size size;
+ private int posUnit = UNITS_PERCENTAGE;
/**
* Creates a new split panel. The orientation of the panels is
*/
public SplitPanel() {
orientation = ORIENTATION_VERTICAL;
- size = new Size(this);
- size.setSizeFull();
+ setSizeFull();
}
/**
public void paintContent(PaintTarget target) throws PaintException {
super.paintContent(target);
- size.paint(target);
-
- final String position = pos + Size.UNIT_SYMBOLS[posUnit];
+ final String position = pos + UNIT_SYMBOLS[posUnit];
target.addAttribute("position", position);
* the new size of the first region in persentage
*/
public void setSplitPosition(int pos) {
- setSplitPosition(pos, Size.UNITS_PERCENTAGE);
+ setSplitPosition(pos, UNITS_PERCENTAGE);
}
/**
* @param pos
* size of the first region
* @param unit
- * the unit (from {@link Size}) in which the size is
- * given.
+ * the unit (from {@link Size}) in which the size is given.
*/
public void setSplitPosition(int pos, int unit) {
this.pos = pos;
posUnit = unit;
}
- public Size getSize() {
- return size;
- }
-
}
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.Size;
/**
* Tabsheet component.
* @VERSION@
* @since 3.0
*/
-public class TabSheet extends AbstractComponentContainer implements HasSize {
+public class TabSheet extends AbstractComponentContainer {
/**
* Linked list of component tabs.
*/
private boolean tabsHidden;
- 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 {
- // Size
- size.paint(target);
-
if (areTabsHidden()) {
target.addAttribute("hidetabs", true);
}
fireEvent(new SelectedTabChangeEvent(this));
}
- 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.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, HasSize {
+ Container.Ordered, Container.Sortable {
private static final int CELL_KEY = 0;
private static final int CELL_FIRSTCOL = 4;
- private Size size;
-
/**
* Left column alignment. <b>This is the default behaviour. </b>
*/
*/
public Table() {
setRowHeaderMode(ROW_HEADER_MODE_HIDDEN);
- size = new Size(this);
}
/**
target.addAttribute("tabindex", getTabIndex());
}
- // Size
- size.paint(target);
-
// Initialize temps
final Object[] colids = getVisibleColumns();
final int cols = colids.length;
}
}
- public Size getSize() {
- return size;
- }
-
- /* Compatibility methods */
-
- /**
- * @deprecated use Size object instead (getSize().setWidth()).
- */
- public void setWidth(int width) {
- size.setWidth(width);
- }
-
- /**
- * @deprecated use Size object instead (getSize().setWidthUnits()).
- */
- public void setWidthUnits(int unit) {
- size.setWidthUnits(unit);
- }
-
- /**
- * @deprecated use Size object instead (getSize().setHeight()).
- */
- public void setHeight(int height) {
- size.setHeight(height);
- }
-
- /**
- * @deprecated use Size object instead (getSize().setHeightUnits()).
- */
- public void setHeightUnits(int unit) {
- size.setHeightUnits(unit);
- }
-
- /**
- * @deprecated use Size object instead (getSize().getWidth()).
- */
- public int getWidth() {
- return size.getWidth();
- }
-
- /**
- * @deprecated use Size object instead (getSize().getWidthUnits()).
- */
- public int getWidthUnits() {
- return size.getWidthUnits();
- }
-
- /**
- * @deprecated use Size object instead (getSize().getHeight()).
- */
- public int getHeight() {
- return size.getHeight();
- }
-
- /**
- * @deprecated use Size object instead (getSize().getHeightUnits()).
- */
- public int getHeightUnits() {
- return size.getHeightUnits();
- }
-
}
\ No newline at end of file