List of usage examples for com.vaadin.client Profiler enter
public static void enter(String name)
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 w w w . jav a 2s .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:com.haulmont.cuba.web.toolkit.ui.client.label.CubaLabelConnector.java
License:Apache License
@Override public void onStateChanged(StateChangeEvent stateChangeEvent) { // CAUTION copied from superclass super.onStateChanged(stateChangeEvent); boolean sinkOnloads = false; Profiler.enter("LabelConnector.onStateChanged update content"); switch (getState().contentMode) { case PREFORMATTED: PreElement preElement = Document.get().createPreElement(); preElement.setInnerText(getState().text); // clear existing content getWidget().setHTML(""); // add preformatted text to dom getWidget().getElement().appendChild(preElement); break;//from ww w . ja v a 2 s. co m case TEXT: // clear existing content getWidget().setHTML(""); // set multiline text if needed // Haulmont API String text = getState().text; if (text != null && text.contains("\n")) { text = WidgetUtil.escapeHTML(text).replace("\n", "<br/>"); getWidget().setHTML(text); } else { getWidget().setText(text); } break; case HTML: case RAW: sinkOnloads = true; case XML: getWidget().setHTML(getState().text); break; default: getWidget().setText(""); break; } // Haulmont API if ("".equals(getWidget().getText()) || getWidget().getText() == null) { getWidget().addStyleDependentName("empty"); } else { getWidget().removeStyleDependentName("empty"); } updateIcon(); Profiler.leave("LabelConnector.onStateChanged update content"); if (sinkOnloads) { Profiler.enter("LabelConnector.onStateChanged sinkOnloads"); WidgetUtil.sinkOnloadForImages(getWidget().getElement()); Profiler.leave("LabelConnector.onStateChanged sinkOnloads"); } }
From source file:com.haulmont.cuba.web.toolkit.ui.client.tooltip.CubaTooltip.java
License:Apache License
@Override public void connectHandlersToWidget(Widget widget) { Profiler.enter("VTooltip.connectHandlersToWidget"); widget.addDomHandler(tooltipEventHandler, MouseOutEvent.getType()); widget.addDomHandler(tooltipEventHandler, MouseDownEvent.getType()); widget.addDomHandler(tooltipEventHandler, KeyDownEvent.getType()); if (!BrowserInfo.get().isIOS()) { widget.addDomHandler(tooltipEventHandler, MouseMoveEvent.getType()); widget.addDomHandler(tooltipEventHandler, FocusEvent.getType()); widget.addDomHandler(tooltipEventHandler, BlurEvent.getType()); }/* ww w . j av a2 s . c o m*/ Profiler.leave("VTooltip.connectHandlersToWidget"); }
From source file:com.haulmont.cuba.web.widgets.client.label.CubaLabelConnector.java
License:Apache License
@Override public void onStateChanged(StateChangeEvent stateChangeEvent) { // CAUTION copied from superclass // todo rework! extract extenstion points super.onStateChanged(stateChangeEvent); boolean sinkOnloads = false; Profiler.enter("LabelConnector.onStateChanged update content"); VLabel widget = getWidget();/* w w w. j av a 2 s. c o m*/ switch (getState().contentMode) { case PREFORMATTED: PreElement preElement = Document.get().createPreElement(); preElement.setInnerText(getState().text); // clear existing content widget.setHTML(""); // add preformatted text to dom widget.getElement().appendChild(preElement); break; case TEXT: // clear existing content widget.setHTML(""); // set multiline text if needed // Haulmont API String text = getState().text; if (text != null && text.contains("\n")) { text = WidgetUtil.escapeHTML(text).replace("\n", "<br/>"); widget.setHTML(text); } else { widget.setText(text); } break; case HTML: sinkOnloads = true; widget.setHTML(getState().text); break; } // Haulmont API if ("".equals(getWidget().getText()) || getWidget().getText() == null) { getWidget().addStyleDependentName("empty"); } else { getWidget().removeStyleDependentName("empty"); } updateIcon(); Profiler.leave("LabelConnector.onStateChanged update content"); if (sinkOnloads) { Profiler.enter("LabelConnector.onStateChanged sinkOnloads"); WidgetUtil.sinkOnloadForImages(widget.getElement()); Profiler.leave("LabelConnector.onStateChanged sinkOnloads"); } }
From source file:org.jpos.client.ui.XLabelConnector.java
License:Open Source License
@Override public void onStateChanged(StateChangeEvent stateChangeEvent) { super.onStateChanged(stateChangeEvent); boolean sinkOnloads = false; Profiler.enter("LabelConnector.onStateChanged update content"); switch (getState().contentMode) { case PREFORMATTED: Document doc = Document.get(); Element e = getWidget().getElement(); PreElement preElement = doc.createPreElement(); preElement.setInnerText(getState().text); // DO NOT clear existing content // getWidget().setHTML(""); // add preformatted text to dom e.appendChild(preElement);//from ww w . j a v a 2 s . c o m // e.appendChild(doc.createHRElement()); break; case TEXT: getWidget().setText(getState().text); break; case HTML: case RAW: sinkOnloads = true; case XML: getWidget().setHTML(getState().text); break; default: getWidget().setText(""); break; } Profiler.leave("LabelConnector.onStateChanged update content"); if (sinkOnloads) { Profiler.enter("LabelConnector.onStateChanged sinkOnloads"); WidgetUtil.sinkOnloadForImages(getWidget().getElement()); Profiler.leave("LabelConnector.onStateChanged sinkOnloads"); } }
From source file:org.vaadin.addons.portallayout.gwt.client.portal.strategy.AbsolutePortalHeightRedistributionStrategy.java
License:Apache License
@Override public void redistributeHeights(PortalLayoutConnector portalConnector) { Profiler.enter("PLC.recalcHeight"); for (ComponentConnector cc : portalConnector.getCurrentChildren()) { PortletConnector portletConnector = PortalLayoutUtil.getPortletConnectorForContent(cc); PortletSlot slot = portletConnector.getPortletChrome().getAssociatedSlot(); if (portletConnector.hasRelativeHeight()) { if (!portletConnector.isCollapsed()) { float relativeHeight = Util.parseRelativeSize(portletConnector.getState().height); slot.setHeight(relativeHeight + "%"); }//from w ww . j a va 2 s .co m } } Profiler.leave("PLC.recalcHeight"); }
From source file:org.vaadin.addons.portallayout.gwt.client.portal.strategy.StackHeightRedistributionStrategy.java
License:Apache License
@Override public void redistributeHeights(PortalLayoutConnector portalConnector) { Profiler.enter("PLC.recalcHeight"); Iterator<ComponentConnector> it = portalConnector.getCurrentChildren().iterator(); List<ComponentConnector> relativeHeightPortlets = new ArrayList<ComponentConnector>(); double totalPercentage = 0; int totalFixedHeightConsumption = 0; while (it.hasNext()) { ComponentConnector cc = it.next(); PortletConnector portletConnector = PortalLayoutUtil.getPortletConnectorForContent(cc); if (portletConnector != null) { if (portletConnector.hasRelativeHeight()) { totalPercentage += Util.parseRelativeSize(portletConnector.getState().height); relativeHeightPortlets.add(cc); } else { PortletChrome portletWidget = portletConnector.getPortletChrome(); totalFixedHeightConsumption += cc.getLayoutManager() .getOuterHeight(portletWidget.getAssociatedSlot().getElement()); }//from www . j a v a 2s. c o m } } if (totalPercentage > 0) { totalPercentage = Math.max(totalPercentage, 100); int totalPortalHeight = portalConnector.getLayoutManager() .getInnerHeight(portalConnector.getWidget().getElement()); boolean isSpacing = portalConnector.getState().spacing; int spacingConsumption = 0; if (isSpacing && portalConnector.getView().getWidgetCount() > 0) { Element spacingEl = portalConnector.getWidget().getElement().getChild(0).cast(); spacingConsumption += new ComputedStyle(spacingEl).getIntProperty("height") * portalConnector.getView().getWidgetCount() - 1; } int reservedForRelativeSize = totalPortalHeight - totalFixedHeightConsumption - spacingConsumption; double ratio = reservedForRelativeSize / (double) totalPortalHeight * 100d; for (ComponentConnector cc : relativeHeightPortlets) { PortletConnector portletConnector = PortalLayoutUtil.getPortletConnectorForContent(cc); if (!portletConnector.isCollapsed()) { float percentageHeight = Util.parseRelativeSize(portletConnector.getState().height); double slotHeight = (percentageHeight / totalPercentage * ratio); int headerHeight = portletConnector.getPortletChrome().getHeader().getOffsetHeight(); double headerHeightPercentage = (double) headerHeight / totalPortalHeight * 100d; String slotHeightStr = Math.max(slotHeight, headerHeightPercentage) + "%"; portletConnector.getPortletChrome().getAssociatedSlot().setHeight(slotHeightStr); } } } Profiler.leave("PLC.recalcHeight"); }