List of usage examples for com.google.gwt.dom.client Style setPosition
public void setPosition(Position value)
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 a 2 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.graph.client.VGraphExplorer.java
License:Apache License
/** * The constructor should first call super() to initialize the component and * then handle any initialization relevant to Vaadin. *//* w ww. j ava 2 s .c o m*/ public VGraphExplorer() { initWidget(root); RootPanel.getBodyElement().getStyle().setBackgroundColor("green"); Style canvasStyle = canvas.getElement().getStyle(); canvasStyle.setPosition(Position.ABSOLUTE); canvasStyle.setBackgroundColor("white"); root.add(canvas); root.getElement().getStyle().setPosition(Position.ABSOLUTE); /* * This method call of the Paintable interface sets the component style * name in DOM tree */ setStyleName(CLASSNAME); }
From source file:com.vaadin.terminal.gwt.client.ui.FocusableScrollPanel.java
License:Open Source License
public FocusableScrollPanel() { // Prevent IE standard mode bug when a AbsolutePanel is contained. Style style = getElement().getStyle(); style.setOverflow(Overflow.AUTO);// www . j av a 2 s .c o m style.setProperty("zoom", "1"); style.setPosition(Position.RELATIVE); }
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);//from ww w. jav a 2s . com style.setLeft(0, Unit.PX); 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(); } } }
From source file:com.vaadin.terminal.gwt.client.ui.FocusElementPanel.java
License:Open Source 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);/*from w ww. ja v a2 s. c om*/ style.setLeft(0, Unit.PX); getElement().appendChild(focusElement); /* Sink from focusElement too as focus 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(); } }
From source file:com.vaadin.terminal.gwt.client.VDebugConsole.java
License:Open Source License
public void init() { panel = new FlowPanel(); if (!quietMode) { DOM.appendChild(getContainerElement(), caption); setWidget(panel);/*from w ww . j a v a2 s . co m*/ 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); 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); actions.add(hostedMode); if (Location.getParameter("gwt.codesvr") != null) { hostedMode.setValue(true); } hostedMode.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { if (hostedMode.getValue()) { addHMParameter(); } else { removeHMParameter(); } } private void addHMParameter() { UrlBuilder createUrlBuilder = Location.createUrlBuilder(); createUrlBuilder.setParameter("gwt.codesvr", "localhost:9997"); Location.assign(createUrlBuilder.buildString()); } private void removeHMParameter() { UrlBuilder createUrlBuilder = Location.createUrlBuilder(); createUrlBuilder.removeParameter("gwt.codesvr"); Location.assign(createUrlBuilder.buildString()); } }); autoScroll.setTitle("Automatically scroll so that new messages are visible"); panel.add(actions); panel.add(new HTML("<i>" + help + "</i>")); clear.addClickHandler(new ClickHandler() { 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() { 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() { public void onClick(ClickEvent event) { // TODO for each client in appconf force layout // VDebugConsole.this.client.forceLayout(); } }); analyzeLayout.addClickHandler(new ClickHandler() { 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() { public void onClick(ClickEvent event) { String pos = getAbsoluteLeft() + "," + getAbsoluteTop() + "," + getOffsetWidth() + "," + getOffsetHeight() + "," + autoScroll.getValue(); Cookies.setCookie(POS_COOKIE_NAME, pos); } }); highlight.addClickHandler(new ClickHandler() { 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)); } }); } log("Starting Vaadin client side engine. Widgetset: " + GWT.getModuleName()); log("Widget set is built on version: " + ApplicationConfiguration.VERSION); logToDebugWindow("<div class=\"v-theme-version v-theme-version-" + ApplicationConfiguration.VERSION.replaceAll("\\.", "_") + "\">Warning: widgetset version " + ApplicationConfiguration.VERSION + " does not seem to match theme version </div>", true); }
From source file:de.bonprix.gridstacklayout.client.GridStackLayoutWidget.java
License:Open Source License
public GridStackLayoutWidget() { this.gridstackId = DOM.createUniqueId(); this.gridstackDiv = DOM.createDiv(); this.gridstackDiv.addClassName("grid-stack"); this.gridstackDiv.setId(this.gridstackId); setElement(this.gridstackDiv); // Clear any unwanted styling final Style style = getElement().getStyle(); style.setBorderStyle(BorderStyle.NONE); style.setMargin(0, Unit.PX);/*from ww w . j a v a 2 s .com*/ style.setPadding(0, Unit.PX); if (BrowserInfo.get().isIE()) { style.setPosition(Position.RELATIVE); } setStyleName(CLASSNAME); addAttachHandler(new Handler() { @Override public void onAttachOrDetach(final AttachEvent event) { checkInit(); } }); setStackedModeWidth(60 * DEFAULT_COLUMNS); }
From source file:fi.jasoft.dragdroplayouts.client.ui.gridlayout.VDDGridLayout.java
License:Apache License
/** * Emphasizes a component container when user is hovering a dragged component over the container. * //from w w w.ja va2 s. c om * @param container The container * @param event */ protected void emphasis(CellDetails cell, VDragEvent event) { Style shadowStyle = dragShadow.getElement().getStyle(); shadowStyle.setPosition(Position.ABSOLUTE); shadowStyle.setWidth(cell.width, Unit.PX); shadowStyle.setHeight(cell.height, Unit.PX); shadowStyle.setLeft(cell.x, Unit.PX); shadowStyle.setTop(cell.y, Unit.PX); // Remove any existing empasis deEmphasis(); // Ensure we are not dragging ourself into ourself ComponentConnector draggedConnector = (ComponentConnector) event.getTransferable() .getData(Constants.TRANSFERABLE_DETAIL_COMPONENT); if (draggedConnector != null && draggedConnector.getWidget() == VDDGridLayout.this) { return; } HorizontalDropLocation hl = getHorizontalDropLocation(cell, event); VerticalDropLocation vl = getVerticalDropLocation(cell, event); // Apply over style UIObject.setStyleName(dragShadow.getElement(), OVER, true); // Add vertical location dependent style UIObject.setStyleName(dragShadow.getElement(), OVER + "-" + vl.toString().toLowerCase(), true); // Add horizontal location dependent style UIObject.setStyleName(dragShadow.getElement(), OVER + "-" + hl.toString().toLowerCase(), true); }
From source file:fi.jasoft.dragdroplayouts.client.ui.VLayoutDragDropMouseHandler.java
License:Apache License
/** * Called when the dragging a component should be initiated by both a mouse * down event as well as a touch start event * /*from w ww .ja va2s . c o m*/ * @param event */ protected void initiateDrag(NativeEvent event) { // Check that dragging is enabled if (dragMode == LayoutDragMode.NONE) { return; } // Dragging can only be done with left mouse button and no modifier keys if (!isMouseDragEvent(event) && !Util.isTouchEvent(event)) { return; } // Create the transfarable VTransferable transferable = VDragDropUtil.createLayoutTransferableFromMouseDown(event, root); // Are we trying to drag the root layout if (transferable == null) { VConsole.error("Creating transferable on mouse down returned null"); return; } // Resolve the component final Widget w; if (root instanceof VDDAccordion && transferable.getData(Constants.TRANSFERABLE_DETAIL_CAPTION) != null) { w = (Widget) transferable.getData(Constants.TRANSFERABLE_DETAIL_CAPTION); } else if (transferable.getData(Constants.TRANSFERABLE_DETAIL_COMPONENT) != null) { w = (Widget) transferable.getData(Constants.TRANSFERABLE_DETAIL_COMPONENT); } else { // Failsafe if no widget was found w = root; VConsole.log("Could not resolve component, using root as component"); } // Announce drag start to listeners for (DragStartListener dl : dragStartListeners) { if (!dl.dragStart(w, dragMode)) { VDragAndDropManager.get().interruptDrag(); return; } } /* * A hack to remove slider popup when dragging. This is done by first * focusing the slider and then unfocusing so we get a blur event which * will remove the popup. */ if (w instanceof VSlider) { VSlider slider = (VSlider) w; slider.setFocus(true); slider.setFocus(false); } currentDraggedWidget = w; // Announce to handler that we are starting a drag operation VDragEvent currentDragEvent = VDragAndDropManager.get().startDrag(transferable, event, true); if (w instanceof VButton && BrowserInfo.get().isIE()) { /* * Due to Buttons crazy implementation we need to simulate a mouse * move to get the drag going in IE without first focusing the * button. Crazy shit. */ VButton button = (VButton) w; NativeEvent evt = Document.get().createMouseMoveEvent(1, event.getScreenX(), event.getScreenY(), Util.getTouchOrMouseClientX(event), Util.getTouchOrMouseClientY(event), false, false, false, false, 0); button.getElement().dispatchEvent(evt); } // Create the drag image if (root instanceof VCssLayout) { /* * CSS Layout does not have an enclosing div so we just use the * component dov */ currentDragEvent.createDragImage((Element) w.getElement().cast(), true); } else { /* * Other layouts uses a enclosing div so we use it. */ currentDragEvent.createDragImage((Element) w.getElement().getParentNode().cast(), true); } if (BrowserInfo.get().isIE7() && w instanceof VTextField) { currentDragEvent.createDragImage(w.getElement(), true); // Capture something so focus is not applied to elements Event.setCapture(RootPanel.getBodyElement()); } Element clone = currentDragEvent.getDragImage(); Style cloneStyle = clone.getStyle(); if (BrowserInfo.get().isIE()) { // Fix IE not aligning the drag image correctly when dragging // layouts cloneStyle.setPosition(Position.ABSOLUTE); } currentDraggedWidget.addStyleName(ACTIVE_DRAG_SOURCE_STYLENAME); // Listen to mouse up for cleanup mouseUpHandlerReg = Event.addNativePreviewHandler(new Event.NativePreviewHandler() { public void onPreviewNativeEvent(NativePreviewEvent event) { if (event.getTypeInt() == Event.ONMOUSEUP || event.getTypeInt() == Event.ONTOUCHEND || event.getTypeInt() == Event.ONTOUCHCANCEL) { if (mouseUpHandlerReg != null) { mouseUpHandlerReg.removeHandler(); if (currentDraggedWidget != null) { currentDraggedWidget.removeStyleName(ACTIVE_DRAG_SOURCE_STYLENAME); currentDraggedWidget = null; } } // Ensure capturing is turned off at mouse up Event.releaseCapture(RootPanel.getBodyElement()); } } }); }
From source file:fr.putnami.pwt.core.widget.client.Affix.java
License:Open Source License
protected void toggleAffix(Affixed affix) { Element e = this.getElement(); Style style = e.getStyle(); if (this.affixed != affix) { this.clearElementStyle(); this.affixed = affix; StyleUtils.addStyle(e, this.affixed); }/* ww w. jav a2 s . c om*/ switch (affix) { case AFFIX: style.setTop(this.offsetTop, Unit.PX); style.setWidth(this.offsetWidth, Unit.PX); style.setHeight(this.offsetHeight, Unit.PX); style.setZIndex(this.layerIndex); e.getParentElement().getStyle().setPaddingTop(this.offsetHeight, Unit.PX); break; case BOTTOM: int docHeigth = Document.get().getScrollHeight(); int scrollTop = Window.getScrollTop(); int bottom = this.offsetBottom - (docHeigth - scrollTop - this.clientHeigth); if (this.fixBottom != Integer.MIN_VALUE) { bottom = Math.max(bottom, this.fixBottom); } style.setPosition(Position.FIXED); style.setBottom(bottom, Unit.PX); style.setWidth(this.offsetWidth, Unit.PX); style.setHeight(this.offsetHeight, Unit.PX); style.setZIndex(this.layerIndex); break; default: break; } }