List of usage examples for com.google.gwt.dom.client Style setTop
public void setTop(double value, Unit unit)
From source file:com.vaadin.client.ui.FocusElementPanel.java
License:Apache License
@Override public void setWidget(Widget w) { super.setWidget(w); if (focusElement.getParentElement() == null) { Style style = focusElement.getStyle(); style.setPosition(Position.FIXED); style.setTop(0, Unit.PX); style.setLeft(0, Unit.PX);//w w w . ja v a 2 s . co m getElement().appendChild(focusElement); /* Sink from focusElement too as focus and blur don't bubble */ DOM.sinkEvents(focusElement, Event.FOCUSEVENTS); // revert to original, not focusable getElement().setPropertyObject("tabIndex", null); } else { moveFocusElementAfterWidget(); } }
From source file:com.vaadin.client.ui.layout.VLayoutSlot.java
License:Apache License
public void setCaption(VCaption caption) { if (this.caption != null) { this.caption.removeFromParent(); }/* ww w . j a v a 2 s.c o m*/ this.caption = caption; if (caption != null) { // Physical attach. DOM.insertBefore(wrapper, caption.getElement(), widget.getElement()); Style style = caption.getElement().getStyle(); style.setPosition(Position.ABSOLUTE); style.setTop(0, Unit.PX); } }
From source file:com.vaadin.client.ui.layout.VLayoutSlot.java
License:Apache License
public void positionVertically(double currentLocation, double allocatedSpace, double marginBottom) { Style style = wrapper.getStyle(); double contentHeight = allocatedSpace; int captionHeight; VCaption caption = getCaption();//from w w w. j a va 2 s. com if (caption == null || caption.shouldBePlacedAfterComponent()) { style.clearPaddingTop(); captionHeight = 0; } else { captionHeight = getCaptionHeight(); contentHeight -= captionHeight; if (contentHeight < 0) { contentHeight = 0; } style.setPaddingTop(captionHeight, Unit.PX); } if (marginBottom > 0) { style.setMarginBottom(marginBottom, Unit.PX); } else { style.clearMarginBottom(); } style.setHeight(contentHeight, Unit.PX); double allocatedContentHeight = 0; if (isRelativeHeight()) { String height = getWidget().getElement().getStyle().getHeight(); double percentage = parsePercent(height); allocatedContentHeight = contentHeight * (percentage / 100); reportActualRelativeHeight(Math.round((float) allocatedContentHeight)); } style.setTop(currentLocation, Unit.PX); double padding = 0; AlignmentInfo alignment = getAlignment(); if (!alignment.isTop()) { double usedHeight; if (isRelativeHeight()) { usedHeight = captionHeight + allocatedContentHeight; } else { usedHeight = getUsedHeight(); } if (alignment.isVerticalCenter()) { padding = (allocatedSpace - usedHeight) / 2d; } else { padding = (allocatedSpace - usedHeight); } padding += captionHeight; widget.getElement().getStyle().setTop(padding, Unit.PX); } else { // Reset top when changing back to align top widget.getElement().getStyle().clearTop(); } }
From source file:com.vaadin.client.ui.VWindow.java
License:Apache License
private void fixIE8FocusCaptureIssue() { Element e = DOM.createInputText(); Style elemStyle = e.getStyle(); elemStyle.setPosition(Position.ABSOLUTE); elemStyle.setTop(-10, Unit.PX); elemStyle.setWidth(0, Unit.PX);//w w w . j a v a2s. c o m elemStyle.setHeight(0, Unit.PX); contentPanel.getElement().appendChild(e); e.focus(); contentPanel.getElement().removeChild(e); }
From source file:com.vaadin.client.VDebugConsole.java
License:Apache License
@Override public void init() { panel = new FlowPanel(); if (!quietMode) { DOM.appendChild(getContainerElement(), caption); setWidget(panel);// w w w . ja v a2 s. c om caption.setClassName("v-debug-console-caption"); setStyleName("v-debug-console"); getElement().getStyle().setZIndex(20000); getElement().getStyle().setOverflow(Overflow.HIDDEN); sinkEvents(Event.ONDBLCLICK); sinkEvents(Event.MOUSEEVENTS); panel.setStyleName("v-debug-console-content"); caption.setInnerHTML("Debug window"); caption.getStyle().setHeight(25, Unit.PX); caption.setTitle(help); show(); setToDefaultSizeAndPos(); actions = new HorizontalPanel(); Style style = actions.getElement().getStyle(); style.setPosition(Position.ABSOLUTE); style.setBackgroundColor("#666"); style.setLeft(135, Unit.PX); style.setHeight(25, Unit.PX); style.setTop(0, Unit.PX); actions.add(clear); actions.add(restart); actions.add(forceLayout); actions.add(analyzeLayout); actions.add(highlight); actions.add(connectorStats); connectorStats.setTitle("Show connector statistics for client"); highlight.setTitle( "Select a component and print details about it to the server log and client side console."); actions.add(savePosition); savePosition.setTitle("Saves the position and size of debug console to a cookie"); actions.add(autoScroll); addDevMode(); addSuperDevMode(); autoScroll.setTitle("Automatically scroll so that new messages are visible"); panel.add(actions); panel.add(new HTML("<i>" + help + "</i>")); clear.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { int width = panel.getOffsetWidth(); int height = panel.getOffsetHeight(); panel = new FlowPanel(); panel.setPixelSize(width, height); panel.setStyleName("v-debug-console-content"); panel.add(actions); setWidget(panel); } }); restart.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { String queryString = Window.Location.getQueryString(); if (queryString != null && queryString.contains("restartApplications")) { Window.Location.reload(); } else { String url = Location.getHref(); String separator = "?"; if (url.contains("?")) { separator = "&"; } if (!url.contains("restartApplication")) { url += separator; url += "restartApplication"; } if (!"".equals(Location.getHash())) { String hash = Location.getHash(); url = url.replace(hash, "") + hash; } Window.Location.replace(url); } } }); forceLayout.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { for (ApplicationConnection applicationConnection : ApplicationConfiguration .getRunningApplications()) { applicationConnection.forceLayout(); } } }); analyzeLayout.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { List<ApplicationConnection> runningApplications = ApplicationConfiguration .getRunningApplications(); for (ApplicationConnection applicationConnection : runningApplications) { applicationConnection.analyzeLayouts(); } } }); analyzeLayout.setTitle("Analyzes currently rendered view and " + "reports possible common problems in usage of relative sizes." + "Will cause server visit/rendering of whole screen and loss of" + " all non committed variables form client side."); savePosition.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { String pos = getAbsoluteLeft() + "," + getAbsoluteTop() + "," + getOffsetWidth() + "," + getOffsetHeight() + "," + autoScroll.getValue(); Cookies.setCookie(POS_COOKIE_NAME, pos); } }); highlight.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { final Label label = new Label("--"); log("<i>Use mouse to select a component or click ESC to exit highlight mode.</i>"); panel.add(label); highlightModeRegistration = Event.addNativePreviewHandler(new HighlightModeHandler(label)); } }); } connectorStats.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { for (ApplicationConnection a : ApplicationConfiguration.getRunningApplications()) { dumpConnectorInfo(a); } } }); log("Starting Vaadin client side engine. Widgetset: " + GWT.getModuleName()); log("Widget set is built on version: " + Version.getFullVersion()); logToDebugWindow("<div class=\"v-theme-version v-theme-version-" + Version.getFullVersion().replaceAll("\\.", "_") + "\">Warning: widgetset version " + Version.getFullVersion() + " does not seem to match theme version </div>", true); }
From source file:com.vaadin.client.VUIDLBrowser.java
License:Apache License
static void highlight(ComponentConnector paintable) { if (paintable != null) { Widget w = paintable.getWidget(); Style style = highlight.getStyle(); style.setTop(w.getAbsoluteTop(), Unit.PX); style.setLeft(w.getAbsoluteLeft(), Unit.PX); style.setWidth(w.getOffsetWidth(), Unit.PX); style.setHeight(w.getOffsetHeight(), Unit.PX); RootPanel.getBodyElement().appendChild(highlight); }//from w w w.java 2s . c om }
From source file:com.vaadin.graph.client.ArcPresenter.java
License:Apache License
private Style updateLabel() { Style style = viewLabel.getElement().getStyle(); GraphProxy graph = parent.getGraph(); NodeProxy from = graph.getTail(model); double x = getLabelCenter(from.getX(), headX) - viewLabel.getOffsetWidth() / 2.0; style.setLeft(x, Unit.PX);/*w ww . j a v a 2 s .c o m*/ double y = getLabelCenter(from.getY(), headY) - viewLabel.getOffsetHeight() / 2.0; style.setTop(y, Unit.PX); return style; }
From source file:com.vaadin.graph.client.NodePresenter.java
License:Apache License
NodePresenter(VGraphExplorer parent, NodeProxy model) { this.parent = parent; this.model = model; graph = parent.getGraph();// w w w .j av a 2s. co m view.setTitle(model.getId()); Style style = view.getElement().getStyle(); style.setLeft(model.getX(), Unit.PX); style.setTop(model.getY(), Unit.PX); view.addDomHandler(this, MouseDownEvent.getType()); view.addDomHandler(this, MouseMoveEvent.getType()); view.addDomHandler(this, MouseUpEvent.getType()); parent.add(view); }
From source file:com.vaadin.graph.client.NodePresenter.java
License:Apache License
private void limitToBoundingBox() { Element element = view.getElement(); Style style = element.getStyle(); int width = element.getOffsetWidth(); model.setWidth(width);// w w w . ja va 2 s.c o m int xRadius = width / 2; int leftEdge = model.getX() - xRadius; leftEdge = limit(0, leftEdge, parent.getOffsetWidth() - width); model.setX(leftEdge + xRadius); style.setLeft(leftEdge, Unit.PX); int height = element.getOffsetHeight(); model.setHeight(height); int yRadius = height / 2; int topEdge = model.getY() - yRadius; topEdge = limit(0, topEdge, parent.getOffsetHeight() - height); model.setY(topEdge + yRadius); style.setTop(topEdge, Unit.PX); }
From source file:com.vaadin.terminal.gwt.client.ui.FocusableScrollPanel.java
License:Open Source License
@Override public void setWidget(Widget w) { super.setWidget(w); if (useFakeFocusElement()) { if (focusElement.getParentElement() == null) { Style style = focusElement.getStyle(); style.setPosition(Position.FIXED); style.setTop(0, Unit.PX); style.setLeft(0, Unit.PX);/*from w w w .ja v a2 s.c o m*/ getElement().appendChild(focusElement); /* Sink from focusElemet too as focusa and blur don't bubble */ DOM.sinkEvents((com.google.gwt.user.client.Element) focusElement.cast(), Event.FOCUSEVENTS); // revert to original, not focusable getElement().setPropertyObject("tabIndex", null); } else { moveFocusElementAfterWidget(); } } }