List of usage examples for com.vaadin.client LayoutManager getOuterHeight
public final int getOuterHeight(Element element)
From source file:com.haulmont.cuba.web.toolkit.ui.client.groupbox.CubaGroupBoxConnector.java
License:Apache License
protected void layoutGroupBox() { CubaGroupBoxWidget panel = getWidget(); LayoutManager layoutManager = getLayoutManager(); if (isBordersVisible()) { int captionWidth = layoutManager.getOuterWidth(panel.captionNode); int captionStartWidth = layoutManager.getInnerWidth(panel.captionStartDeco); int totalMargin = captionWidth + captionStartWidth; panel.captionNode.getStyle().setWidth(captionWidth, Unit.PX); panel.captionWrap.getStyle().setPaddingLeft(totalMargin, Unit.PX); panel.captionStartDeco.getStyle().setMarginLeft(0 - totalMargin, Unit.PX); }/*from www .jav a 2 s . c o m*/ Profiler.enter("CubaGroupBoxConnector.layout getHeights"); // Haulmont API get max height of caption components int top = layoutManager.getOuterHeight(panel.captionNode); top = Math.max(layoutManager.getOuterHeight(panel.captionStartDeco), top); top = Math.max(layoutManager.getOuterHeight(panel.captionEndDeco), top); int bottom = layoutManager.getInnerHeight(panel.bottomDecoration); Profiler.leave("PanelConnector.layout getHeights"); Style style = panel.getElement().getStyle(); int paddingTop = 0; int paddingBottom = 0; if (panel.hasAnyOuterMargin()) { Profiler.enter("PanelConnector.layout get values from styles"); // Clear previously set values style.clearPaddingTop(); style.clearPaddingBottom(); // Calculate padding from styles ComputedStyle computedStyle = new ComputedStyle(panel.getElement()); paddingTop = computedStyle.getIntProperty("padding-top"); paddingBottom = computedStyle.getIntProperty("padding-bottom"); Profiler.leave("PanelConnector.layout get values from styles"); } Profiler.enter("PanelConnector.layout modify style"); panel.captionWrap.getStyle().setMarginTop(-top, Style.Unit.PX); panel.bottomDecoration.getStyle().setMarginBottom(-bottom, Style.Unit.PX); style.setPaddingTop(top + paddingTop, Style.Unit.PX); style.setPaddingBottom(bottom + paddingBottom, Style.Unit.PX); Profiler.leave("PanelConnector.layout modify style"); // Update scroll positions Profiler.enter("PanelConnector.layout update scroll positions"); panel.contentNode.setScrollTop(panel.scrollTop); panel.contentNode.setScrollLeft(panel.scrollLeft); Profiler.leave("PanelConnector.layout update scroll positions"); // Read actual value back to ensure update logic is correct Profiler.enter("PanelConnector.layout read scroll positions"); panel.scrollTop = panel.contentNode.getScrollTop(); panel.scrollLeft = panel.contentNode.getScrollLeft(); Profiler.leave("PanelConnector.layout read scroll positions"); }
From source file:org.vaadin.addons.portallayout.gwt.client.portal.connection.PortalLayoutConnector.java
License:Apache License
@Override protected Panel createWidget() { this.view = initView(); this.dropController = initDropController(); commonDragController.registerDropController(dropController); view.asWidget().addAttachHandler(new AttachEvent.Handler() { @Override/* ww w . jav a 2s . co m*/ public void onAttachOrDetach(AttachEvent event) { getLayoutManager().addElementResizeListener( ((ComponentConnector) getParent()).getWidget().getElement(), new ElementResizeListener() { @Override public void onElementResize(ElementResizeEvent e) { LayoutManager lm = e.getLayoutManager(); if (lm.getOuterHeight(e.getElement()) > lm .getOuterHeight(getWidget().getElement())) { //getWidget().getElement().getStyle().setProperty("height", lm.getOuterHeight(e.getElement()) + "px"); } } }); } }); return view.asWidget(); }