public PreloaderCallback getPreloaderCallback() { final Panel preloaderPanel = new VerticalPanel(); preloaderPanel.setStyleName("gdx-preloader"); final Image logo = new Image(GWT.getModuleBaseURL() + "logo.png"); logo.setStyleName("logo"); preloaderPanel.add(logo); final Panel meterPanel = new SimplePanel(); meterPanel.setStyleName("gdx-meter"); meterPanel.addStyleName("red"); final InlineHTML meter = new InlineHTML(); final Style meterStyle = meter.getElement().getStyle(); meterStyle.setWidth(0, Unit.PCT); meterPanel.add(meter); preloaderPanel.add(meterPanel); getRootPanel().add(preloaderPanel); return new PreloaderCallback() { @Override public void error(String file) { System.out.println("error: " + file); } @Override public void update(PreloaderState state) { meterStyle.setWidth(100f * state.getProgress(), Unit.PCT); } }; }
public void handleUpdate(TimedRegionModel model) { clear(); double maxTime = model.getMaxTime(); LatLngBounds bounds = LatLngBounds.newInstance(); for (TimedRegion region : model.getRegions()) { String color = getColorForTime(region.getTime(), maxTime); LatLngBounds regionBounds = region.getBounds(); PatchMarker marker = new PatchMarker(regionBounds); Style style = marker.getStyle(); style.setProperty("backgroundColor", color); marker.addStyleName("patch"); // _overlays.add(marker); _mapOverlayManager.addOverlay(marker, 10, 15); bounds.extend(regionBounds.getNorthEast()); bounds.extend(regionBounds.getSouthWest()); } if (!bounds.isEmpty()) { MapWidget map = _mapOverlayManager.getMapWidget(); int zoom = map.getBoundsZoomLevel(bounds); map.setCenter(bounds.getCenter(), zoom); } }
@Test public void clone_Deep() { // Arrange AnchorElement child = Document.get().createAnchorElement(); child.setInnerText("child inner text"); child.getStyle().setBackgroundColor("black"); n.appendChild(child); // Act DivElement newNode = n.cloneNode(true).cast(); // Assert assertEquals(Node.ELEMENT_NODE, newNode.getNodeType()); DivElement source = n.cast(); assertEquals(source.getInnerText(), newNode.getInnerText()); assertEquals(source.getInnerHTML(), newNode.getInnerHTML()); assertEquals(source.toString(), newNode.toString()); assertNull(newNode.getParentNode()); assertEquals(n.getChildNodes().getLength(), newNode.getChildNodes().getLength()); assertEquals(Node.ELEMENT_NODE, newNode.getChildNodes().getItem(0).getNodeType()); AnchorElement childElement = newNode.getChildNodes().getItem(0).cast(); assertEquals("child inner text", childElement.getInnerText()); Style newStyle = childElement.getStyle(); assertTrue(newStyle != child.getStyle()); assertEquals("black", newStyle.getBackgroundColor()); }
private void setUIStyle(Element elem, GColor color) { GColor c = color.deriveWithAlpha(102); Style style = Dom.querySelectorForElement(elem, "ui-state-default").getStyle(); style.setBackgroundColor(GColor.getColorString(color)); style.setBorderColor(GColor.getColorString(c)); }
@ComponentBinding private void testCustomComponentBindingStyleUpdate(Style style) { if ("0".equals(getTestModel().getTestC())) { style.setVisibility(Style.Visibility.HIDDEN); } else { style.clearVisibility(); } }
protected Widget createGroupHeader(Object text, String textColor, String backgroundColor) { Label title = Widgets.text(text); Style style = title.getElement().getStyle(); style.setColor(textColor); style.setBackgroundColor(backgroundColor); style.setPadding(Widgets.defaultSpacing, Unit.PX); return title; }
/** * Sets a DOM element's opacity * * @param e * @param percent */ public static void setOpacity(final Element e, final int percent) { final Style s = e.getStyle(); final double d = ((double) percent / (double) 100); s.setProperty("opacity", String.valueOf(d)); s.setProperty("MozOpacity", String.valueOf(d)); s.setProperty("KhtmlOpacity", String.valueOf(d)); s.setProperty("filter", "alpha(opacity=" + percent + ")"); }
private TextArea createClipboardTextArea() { final TextArea pasteArea = new TextArea(); pasteArea.setPixelSize(0, 0); Style style = pasteArea.getElement().getStyle(); style.setPosition(Style.Position.FIXED); RootPanel.get().add(pasteArea); pasteArea.setFocus(true); return pasteArea; }
private Label createErrorLabel() { Label label = new Label(); Style style = label.getElement().getStyle(); style.setDisplay(Display.NONE); style.setColor("#cc0000"); style.setMarginTop(Widgets.defaultSpacing, Unit.PX); style.setMarginBottom(Widgets.defaultSpacing, Unit.PX); return label; }
@Override public double getOpacity(Element e) { Style s = e.getStyle(); String o = s.getProperty("filter"); if (o != null) { return !o.matches(".*opacity=.*") ? 1 : Double.valueOf(o.replaceAll("[^\\d]", "")) / 100; } return super.getOpacity(e); }
private SimplePanel horizontalWrapper(IsWidget child, String width) { SimplePanel wrapper = new SimplePanel(child.asWidget()); wrapper.setStyleName("goon-horizontalWrapper"); Style style = wrapper.getElement().getStyle(); style.setProperty("display", "table-cell"); if (childTextAlign != null) style.setTextAlign(childTextAlign); if (width != null) wrapper.setWidth(width); return wrapper; }
@Override public void hide() { super.hide(); // reset mouse cursor to default, when the dialog closes if (resizeSupportEnabled && parentElementStyle != null && !Cursor.DEFAULT.getCssName().equals(parentElementStyle.getCursor())) { parentElementStyle.setCursor(Cursor.DEFAULT); } }
private void formatRow(FlexTable table, int row) { String border = "1px solid #EEE"; for (int i = 0; i <= 4; i++) { Element element = table.getCellFormatter().getElement(row, i); Style style = element.getStyle(); style.setProperty("borderBottom", border); if (row == 0) style.setProperty("borderTop", border); if (i < 3 || i == 4) style.setProperty("borderLeft", border); if (i == 4) style.setProperty("borderRight", border); } }
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); elemStyle.setHeight(0, Unit.PX); contentPanel.getElement().appendChild(e); e.focus(); contentPanel.getElement().removeChild(e); }
public void updateColor(GColor color) { GColor c = color.deriveWithAlpha(102); // String sColor = GColor.getColorString(color); // minLabel.getElement().getStyle().setColor(sColor); // maxLabel.getElement().getStyle().setColor(sColor); // slider.asWidget().getElement().getStyle() // .setBackgroundColor(GColor.getColorString(c)); Style uiStyle = Dom.querySelectorForElement(getElement(), "ui-slider").getStyle(); uiStyle.setBackgroundColor(GColor.getColorString(c)); setUIStyle(getElement(), color); }
public VCustomLayout() { setElement(DOM.createDiv()); // Clear any unwanted styling Style style = getElement().getStyle(); style.setBorderStyle(BorderStyle.NONE); style.setMargin(0, Unit.PX); style.setPadding(0, Unit.PX); if (BrowserInfo.get().isIE()) { style.setPosition(Position.RELATIVE); } setStyleName(CLASSNAME); }
@Override protected void initWidget(Widget wrapperWidget) { super.initWidget(wrapperWidget); // Fix styles. getFormLabel().setVisible(false); // Style textBoxStyle = getContentWidgetElement().getStyle(); // textBoxStyle.setWidth(240, Style.Unit.PX); com.google.gwt.dom.client.Style panelStyle = getContentWidgetContainer().getElement().getStyle(); panelStyle.setFloat(com.google.gwt.dom.client.Style.Float.NONE); }
public void onMouseUp(MouseUpEvent event) { if (mouseMoveCanceled) { return; } Event.releaseCapture(getElement()); setFocus(false); if (moveRegistration != null) { moveRegistration.removeHandler(); moveRegistration = null; } int endX = event.getClientX(); int endY = event.getClientY(); int xDiff = startX - endX; int yDiff = startY - endY; startX = -1; startY = -1; mouseMoveStarted = false; Style s = getElement().getStyle(); s.setZIndex(1); if (!clickTargetsResize()) { // check if mouse has moved over threshold of 3 pixels boolean mouseMoved = (xDiff < -3 || xDiff > 3 || yDiff < -3 || yDiff > 3); if (!weekGrid.getCalendar().isDisabledOrReadOnly() && mouseMoved) { // Event Move: // - calendar must be enabled // - calendar must not be in read-only mode weekGrid.eventMoved(this); } else if (!weekGrid.getCalendar().isDisabled()) { // Event Click: // - calendar must be enabled (read-only is allowed) EventTarget et = event.getNativeEvent().getEventTarget(); Element e = Element.as(et); if (e == caption || e == eventContent || e.getParentElement() == caption) { if (weekGrid.getCalendar().getEventClickListener() != null) { weekGrid.getCalendar().getEventClickListener().eventClick(calendarEvent); } } } } else { // click targeted resize bar removeGlobalResizeStyle(); if (weekGrid.getCalendar().getEventResizeListener() != null) { weekGrid.getCalendar().getEventResizeListener().eventResized(calendarEvent); } } }
NodePresenter(VGraphExplorer parent, NodeProxy model) { this.parent = parent; this.model = model; graph = parent.getGraph(); 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); }
protected ProgressIndicator addProgressIndicator() { final SlideLabel label = new SlideLabel(true); Element labelEl = label.getElement(); Style labelStyle = labelEl.getStyle(); labelStyle.setPosition(Style.Position.ABSOLUTE); labelStyle.setLeft(0, Style.Unit.PX); labelStyle.setRight(0, Style.Unit.PX); labelStyle.setTop(-12, Style.Unit.PX); getWidget().getElement().getParentElement().appendChild(labelEl); return new ProgressIndicator() { public void onProgress(String message) { if (message == null) { label.setText("", true); if (showing_) endProgress(); } else { label.setText(message, false); if (!showing_) { enableControls(false); label.show(); showing_ = true; } } } public void onCompleted() { endProgress(); closeDialog(); } public void onError(String message) { endProgress(); RStudioGinjector.INSTANCE.getGlobalDisplay().showErrorMessage("Error", message); } private void endProgress() { if (showing_) { enableControls(true); label.hide(); showing_ = false; } } private boolean showing_; }; }
protected void onChildSizeChange() { ComponentConnector child = getContent(); if (child == null) { return; } Style childStyle = child.getWidget().getElement().getStyle(); /* * Must set absolute position if the child has relative height and * there's a chance of horizontal scrolling as some browsers will * otherwise not take the scrollbar into account when calculating the * height. Assuming v-ui does not have an undefined width for now, see * #8460. */ if (child.isRelativeHeight() && !BrowserInfo.get().isIE9()) { childStyle.setPosition(Position.ABSOLUTE); } else { childStyle.clearPosition(); } }
private void cancelMouseMove() { mouseMoveCanceled = true; // reset and remove everything related to the event handling Event.releaseCapture(getElement()); setFocus(false); if (moveRegistration != null) { moveRegistration.removeHandler(); moveRegistration = null; } mouseMoveStarted = false; removeGlobalResizeStyle(); Style s = getElement().getStyle(); s.setZIndex(1); // reset the position of the event int dateCellWidth = getDateCellWidth(); int dayOffset = startXrelative / dateCellWidth; s.clearLeft(); calendarEvent.setStartTime(startDatetimeFrom); calendarEvent.setEndTime(startDatetimeTo); long startFromMinutes = (startDatetimeFrom.getHours() * 60) + startDatetimeFrom.getMinutes(); long range = calendarEvent.getRangeInMinutes(); startFromMinutes = calculateStartFromMinute(startFromMinutes, startDatetimeFrom, startDatetimeTo, dayOffset); if (startFromMinutes < 0) { range += startFromMinutes; } updatePosition(startFromMinutes, range); startY = -1; startX = -1; // to reset the event width ((DateCell) getParent()).recalculateEventWidths(); }
@Ignore @Test public void checkParse() throws Exception { // Setup String html = "<div id=\"parent0\"></div><div id=\"parent1\"><div id=\"child0\"><span class=\"spanClass\" >test</span></div><BR><DIV id=\"child2\" style=\"color:red; font-style:italic; font-weight:bold; font-family:Arial\"></div>"; // Test NodeList<Node> nodes = GwtHtmlParser.parse(html); // Assert Assert.assertEquals(2, nodes.getLength()); DivElement parent0 = (DivElement) nodes.getItem(0); Assert.assertEquals("parent0", parent0.getId()); Assert.assertEquals(0, parent0.getChildCount()); DivElement parent1 = (DivElement) nodes.getItem(1); Assert.assertEquals("parent1", parent1.getId()); Assert.assertEquals(3, parent1.getChildCount()); DivElement child0 = (DivElement) parent1.getChild(0); Assert.assertEquals("child0", child0.getId()); Assert.assertEquals(1, child0.getChildCount()); SpanElement span = (SpanElement) child0.getChild(0); Assert.assertEquals("", span.getId()); Assert.assertEquals("spanClass", span.getClassName()); Assert.assertEquals(1, span.getChildCount()); Assert.assertEquals(Node.TEXT_NODE, span.getChild(0).getNodeType()); Text text = span.getChild(0).cast(); Assert.assertEquals("test", text.getData()); Assert.assertEquals("test", span.getInnerText()); BRElement br = (BRElement) parent1.getChild(1); Assert.assertEquals("", br.getId()); DivElement child2 = (DivElement) parent1.getChild(2); Assert.assertEquals("child2", child2.getId()); Assert.assertEquals(0, child2.getChildCount()); Style style = child2.getStyle(); Assert.assertEquals("red", style.getColor()); }
public LeftTabPanel() { initWidget(main); main.add(left); left.add(leftTree); DecoratorPanel decorator = new DecoratorPanel(); Style decoratorStyle = decorator.getElement().getStyle(); decoratorStyle.setPropertyPx("marginLeft", 15); Style rightStyle = right.getElement().getStyle(); rightStyle.setPropertyPx("margin", 5); decorator.add(right); main.add(decorator); leftTree.addSelectionHandler( new SelectionHandler<TreeItem>() { public void onSelection(SelectionEvent<TreeItem> event) { String name = event.getSelectedItem().getText(); setWidget(right, cogs.get(name)); } }); }
private void limitToBoundingBox() { Element element = view.getElement(); Style style = element.getStyle(); int width = element.getOffsetWidth(); model.setWidth(width); 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); }
/** {@inheritDoc} */ @Override public void showLocationDetails( final String name, final String htmlTitle, final String htmlContent) { final MQAPoi point = getMarker(name); if (point != null) { point.setInfoTitleHTML(htmlTitle); point.setInfoContentHTML(htmlContent); point.showInfoWindow(); final NodeList<Element> elements = Document.get().getElementsByTagName("div"); for (int i = 0; i < elements.getLength(); i++) { final Element e = elements.getItem(i); if (e.getClassName().equals("mqpoicontenttext")) { final Style s = e.getStyle(); s.setOverflow(Overflow.HIDDEN); break; } } } }
public void onMouseDown(MouseDownEvent event) { startX = event.getClientX(); startY = event.getClientY(); if (isDisabled() || event.getNativeButton() != NativeEvent.BUTTON_LEFT) { return; } clickTarget = Element.as(event.getNativeEvent().getEventTarget()); mouseMoveCanceled = false; if (weekGrid.getCalendar().isEventMoveAllowed() || clickTargetsResize()) { moveRegistration = addMouseMoveHandler(this); setFocus(true); try { startYrelative = (int) ((double) event.getRelativeY(caption) % slotHeight); startXrelative = (event.getRelativeX(weekGrid.getElement()) - weekGrid.timebar.getOffsetWidth()) % getDateCellWidth(); } catch (Exception e) { GWT.log("Exception calculating relative start position", e); } mouseMoveStarted = false; Style s = getElement().getStyle(); s.setZIndex(1000); startDatetimeFrom = (Date) calendarEvent.getStartTime().clone(); startDatetimeTo = (Date) calendarEvent.getEndTime().clone(); Event.setCapture(getElement()); } // make sure the right cursor is always displayed if (clickTargetsResize()) { addGlobalResizeStyle(); } /* * We need to stop the event propagation or else the WeekGrid * range select will kick in */ event.stopPropagation(); event.preventDefault(); }
/** * Sets the image to use in this menu button. * * @param image */ public void setImage(ImageResource image) { this.image = image; Image imageHtml = new Image(image.getSafeUri()); Style imageStyle = imageHtml.getElement().getStyle(); imageStyle.setDisplay(Display.BLOCK); imageStyle.setProperty("margin", "1.25em auto 0"); imageStyle.setProperty("maxWidth", "60%"); imageStyle.setPosition(Position.ABSOLUTE); imageStyle.setTop(0, Unit.PX); imageStyle.setRight(0, Unit.PX); imageStyle.setBottom(0, Unit.PX); imageStyle.setLeft(0, Unit.PX); panel.add(imageHtml); }
/** * Internal method which opens the gallery dialog. * * <p> */ protected void openGalleryDialog() { String title = org.opencms.gwt.client.Messages.get() .key(org.opencms.gwt.client.Messages.GUI_GALLERY_SELECT_DIALOG_TITLE_0); final CmsFramePopup popup = new CmsFramePopup(title, buildGalleryUrl()); popup.setCloseHandler( new Runnable() { public void run() { m_textbox.setGhostMode(false); } }); popup.setId(m_id); popup.getFrame().setSize("700px", "490px"); popup.center(); CmsPushButton button = new CmsPushButton(I_CmsImageBundle.INSTANCE.style().closeIcon()); Style style = button.getElement().getStyle(); style.setRight(4, Unit.PX); style.setTop(0, Unit.PX); style.setPosition(Position.ABSOLUTE); style.setCursor(Cursor.POINTER); button.addClickHandler( new ClickHandler() { /** * @see * com.google.gwt.event.dom.client.ClickHandler#onClick(com.google.gwt.event.dom.client.ClickEvent) */ public void onClick(ClickEvent event) { popup.hide(); } }); popup.insertFront(button); }
public DateCellDayEvent(DateCell dateCell, WeekGrid parent, CalendarEvent event) { super(); this.dateCell = dateCell; handlers = new LinkedList<HandlerRegistration>(); setStylePrimaryName("v-calendar-event"); setCalendarEvent(event); weekGrid = parent; Style s = getElement().getStyle(); if (event.getStyleName().length() > 0) { addStyleDependentName(event.getStyleName()); } s.setPosition(Position.ABSOLUTE); caption = DOM.createDiv(); caption.addClassName("v-calendar-event-caption"); getElement().appendChild(caption); eventContent = DOM.createDiv(); eventContent.addClassName("v-calendar-event-content"); getElement().appendChild(eventContent); VCalendar calendar = weekGrid.getCalendar(); if (weekGrid.getCalendar().isEventResizeAllowed()) { topResizeBar = DOM.createDiv(); bottomResizeBar = DOM.createDiv(); topResizeBar.addClassName("v-calendar-event-resizetop"); bottomResizeBar.addClassName("v-calendar-event-resizebottom"); getElement().appendChild(topResizeBar); getElement().appendChild(bottomResizeBar); } eventIndex = event.getIndex(); }