List of usage examples for com.google.gwt.user.client.ui Widget getLayoutData
public Object getLayoutData()
From source file:co.fxl.gui.gwt.ObservableSplitLayoutPanel.java
License:Open Source License
void updatePosition() { if (getWidgetCount() == 0) return;/* w w w. j av a 2s.c o m*/ final Widget left = getWidget(0); LayoutData layout = (LayoutData) left.getLayoutData(); layout.oldSize = layout.size; layout.size = owner.splitPosition; animate(500, new AnimationCallback() { @Override public void onLayout(Layer layer, double progress) { } @Override public void onAnimationComplete() { left.getElement().getParentElement().getStyle().setWidth(owner.splitPosition, Unit.PX); left.setWidth(owner.splitPosition + "px"); } }); }
From source file:com.appkit.ui.client.layouts.splitlayout.SplitLayoutPanelBase.java
License:Apache License
private void insertSplitter(Widget widget, Widget before) { assert getChildren().size() > 0 : "Can't add a splitter before any children"; LayoutData layout = (LayoutData) widget.getLayoutData(); Splitter splitter = null;/*w w w . j ava 2s. com*/ switch (getResolvedDirection(layout.direction)) { case WEST: splitter = new HSplitter(widget, false); break; case EAST: splitter = new HSplitter(widget, true); break; case NORTH: splitter = new VSplitter(widget, false); break; case SOUTH: splitter = new VSplitter(widget, true); break; default: assert false : "Unexpected direction"; } super.insert(splitter, layout.direction, splitterSize, before); }
From source file:com.puzzlebazar.client.ui.OverflowLayoutPanel.java
License:Apache License
public void insert(Widget widget, int beforeIndex) { super.insert(widget, beforeIndex); ((Layer) widget.getLayoutData()).getContainerElement().getStyle().setOverflow(Overflow.VISIBLE); }
From source file:com.ritchey.client.view.DockPanel.java
License:Apache License
/** * Gets the layout direction of the given child widget. * * @param w the widget to be queried/*w w w. java 2s. c om*/ * @return the widget's layout direction, or <code>null</code> if it is not * a child of this panel */ public DockLayoutConstant getWidgetDirection(Widget w) { if (w.getParent() != this) { return null; } return ((LayoutData) w.getLayoutData()).direction; }
From source file:com.ritchey.client.view.DockPanel.java
License:Apache License
@Override public void setCellHeight(Widget w, String height) { LayoutData data = (LayoutData) w.getLayoutData(); data.height = height;//from w w w. j a v a 2 s . c o m if (data.td != null) { data.td.getStyle().setProperty("height", data.height); } }
From source file:com.ritchey.client.view.DockPanel.java
License:Apache License
@Override public void setCellHorizontalAlignment(Widget w, HorizontalAlignmentConstant align) { LayoutData data = (LayoutData) w.getLayoutData(); data.hAlign = align.getTextAlignString(); if (data.td != null) { setCellHorizontalAlignment(data.td, align); }/*from w ww. ja v a 2 s. c o m*/ }
From source file:com.ritchey.client.view.DockPanel.java
License:Apache License
@Override public void setCellVerticalAlignment(Widget w, VerticalAlignmentConstant align) { LayoutData data = (LayoutData) w.getLayoutData(); data.vAlign = align.getVerticalAlignString(); if (data.td != null) { setCellVerticalAlignment(data.td, align); }/* w w w . j a v a 2 s .com*/ }
From source file:com.ritchey.client.view.DockPanel.java
License:Apache License
@Override public void setCellWidth(Widget w, String width) { LayoutData data = (LayoutData) w.getLayoutData(); data.width = width;/*w w w . j ava 2 s . c o m*/ if (data.td != null) { data.td.getStyle().setProperty("width", data.width); } }
From source file:com.ritchey.client.view.DockPanel.java
License:Apache License
/** * {@link DockPanel} supports adding more than one cell in a direction, so an * integer will be appended to the end of the debug id. For example, the first * north cell is labeled "north1", the second is "north2", and the third is * "north3".//www . j av a2 s . c om * * This widget recreates its structure every time a {@link Widget} is added, * so you must call this method after adding a new {@link Widget} or all debug * IDs will be lost. * * <p> * <b>Affected Elements:</b> * <ul> * <li>-center = the center cell.</li> * <li>-north# = the northern cell.</li> * <li>-south# = the southern cell.</li> * <li>-east# = the eastern cell.</li> * <li>-west# = the western cell.</li> * </ul> * </p> * * @see UIObject#onEnsureDebugId(String) */ @Override protected void onEnsureDebugId(String baseID) { super.onEnsureDebugId(baseID); Map<DockLayoutConstant, Integer> dirCount = new HashMap<DockLayoutConstant, Integer>(); Iterator<Widget> it = getChildren().iterator(); while (it.hasNext()) { Widget child = it.next(); DockLayoutConstant dir = ((LayoutData) child.getLayoutData()).direction; // Get a debug id Integer countObj = dirCount.get(dir); int count = countObj == null ? 1 : countObj.intValue(); String debugID = generateDebugId(dir, count); ensureDebugId(DOM.getParent(child.getElement()), baseID, debugID); // Increment the count dirCount.put(dir, count + 1); } }
From source file:com.ritchey.client.view.DockPanel.java
License:Apache License
/** * (Re)creates the DOM structure of the table representing the DockPanel, * based on the order and layout of the children. */// w w w . j a va 2 s. com private void realizeTable() { Element bodyElem = getBody(); while (DOM.getChildCount(bodyElem) > 0) { bodyElem.removeChild(DOM.getChild(bodyElem, 0)); } int rowCount = 1, colCount = 1; for (Iterator<Widget> it = getChildren().iterator(); it.hasNext();) { Widget child = it.next(); DockLayoutConstant dir = ((LayoutData) child.getLayoutData()).direction; if ((dir == NORTH) || (dir == SOUTH)) { ++rowCount; } else if ((dir == EAST) || (dir == WEST) || (dir == LINE_START) || (dir == LINE_END)) { ++colCount; } } TmpRow[] rows = new TmpRow[rowCount]; for (int i = 0; i < rowCount; ++i) { rows[i] = new TmpRow(); rows[i].tr = DOM.createTR(); DOM.appendChild(bodyElem, rows[i].tr); } int logicalLeftCol = 0, logicalRightCol = colCount - 1; int northRow = 0, southRow = rowCount - 1; Element centerTd = null; for (Iterator<Widget> it = getChildren().iterator(); it.hasNext();) { Widget child = it.next(); LayoutData layout = (LayoutData) child.getLayoutData(); Element td = DOM.createTD(); layout.td = td; layout.td.setPropertyString("align", layout.hAlign); layout.td.getStyle().setProperty("verticalAlign", layout.vAlign); layout.td.setPropertyString("width", layout.width); layout.td.setPropertyString("height", layout.height); if (layout.direction == NORTH) { DOM.insertChild(rows[northRow].tr, td, rows[northRow].center); DOM.appendChild(td, child.getElement()); td.setPropertyInt("colSpan", logicalRightCol - logicalLeftCol + 1); ++northRow; } else if (layout.direction == SOUTH) { DOM.insertChild(rows[southRow].tr, td, rows[southRow].center); DOM.appendChild(td, child.getElement()); td.setPropertyInt("colSpan", logicalRightCol - logicalLeftCol + 1); --southRow; } else if (layout.direction == CENTER) { // Defer adding the center widget, so that it can be added after all // the others are complete. centerTd = td; } else if (shouldAddToLogicalLeftOfTable(layout.direction)) { TmpRow row = rows[northRow]; DOM.insertChild(row.tr, td, row.center++); DOM.appendChild(td, child.getElement()); td.setPropertyInt("rowSpan", southRow - northRow + 1); ++logicalLeftCol; } else if (shouldAddToLogicalRightOfTable(layout.direction)) { TmpRow row = rows[northRow]; DOM.insertChild(row.tr, td, row.center); DOM.appendChild(td, child.getElement()); td.setPropertyInt("rowSpan", southRow - northRow + 1); --logicalRightCol; } } // If there is a center widget, add it at the end (centerTd is guaranteed // to be initialized because it will have been set in the CENTER case in // the above loop). if (center != null) { TmpRow row = rows[northRow]; DOM.insertChild(row.tr, centerTd, row.center); DOM.appendChild(centerTd, center.getElement()); } }