Java Code Examples for com.google.gwt.user.client.DOM
The following examples show how to use
com.google.gwt.user.client.DOM. These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: EasyML Source File: DatasetWidget.java License: Apache License 2.0 | 6 votes |
@Override protected void init() { clientWidth = DOM.getElementPropertyInt(label.getElement(), "clientHeight"); clientWidth = DOM.getElementPropertyInt(label.getElement(), "clientHeight"); clientHeight = DOM.getElementPropertyInt(label.getElement(), "clientHeight"); offsetWidth = label.getOffsetWidth(); offsetHeight = label.getOffsetHeight(); offsetTop = DOM.getElementPropertyInt(label.getElement(), "offsetTop"); offsetLeft = DOM.getElementPropertyInt(label.getElement(), "offsetLeft"); boder = (offsetHeight - clientHeight) / 2; custom(); this.setPixelSize((int) offsetWidth + offsetLeft * 2, (int) offsetHeight + offsetTop * 2); }
Example 2
Source Project: cuba Source File: CubaScrollTableWidget.java License: Apache License 2.0 | 6 votes |
@Override protected void initCellWithText(String text, char align, String style, boolean textIsHTML, boolean sorted, String description, TableCellElement td) { super.initCellWithText(text, align, style, textIsHTML, sorted, description, td); final Element tdElement = td.cast(); Tools.textSelectionEnable(tdElement, _delegate.textSelectionEnabled); if ((_delegate.clickableColumns != null && _delegate.clickableColumns.contains(currentColumnKey)) || (_delegate.clickableTableColumns != null && _delegate.clickableTableColumns.contains(currentColumnKey))) { tdElement.addClassName(CUBA_TABLE_CLICKABLE_CELL_CONTENT); Element wrapperElement = tdElement.getFirstChildElement(); final Element clickableSpan = DOM.createSpan().cast(); clickableSpan.setClassName(CUBA_TABLE_CLICKABLE_CELL_STYLE); clickableSpan.setInnerText(wrapperElement.getInnerText()); wrapperElement.removeAllChildren(); DOM.appendChild(wrapperElement, clickableSpan); } if (_delegate.multiLineCells) { Style wrapperStyle = tdElement.getFirstChildElement().getStyle(); wrapperStyle.setWhiteSpace(Style.WhiteSpace.PRE_LINE); } }
Example 3
Source Project: SensorWebClient Source File: DiagramTab.java License: GNU General Public License v2.0 | 6 votes |
private Viewport getMainChartViewport() { Image mainChartImage = new Image("img/blank.gif"); Viewport mainchart = new Viewport("100%", "100%"); mainchart.setEnableZoomWhenShiftkeyPressed(true); mainchart.add(mainChartImage); // as it is focusable, we do not want to see an outline DOM.setStyleAttribute(mainchart.getElement(), "outline", "none"); DOM.setStyleAttribute(mainchart.getElement(), "overflow", "visible"); ImageViewImpl imageView = new ImageViewImpl(mainChartImage); new ImagePresenter(this.mainChartEventBus, imageView); new DragImageControl(this.mainChartEventBus); new MouseWheelControl(this.mainChartEventBus); return mainchart; }
Example 4
Source Project: document-management-system Source File: ExtendedFlexTable.java License: GNU General Public License v2.0 | 6 votes |
public void onBrowserEvent(Event event) { int selectedRow = 0; if (DOM.eventGetType(event) == Event.ONDBLCLICK) { Element td = getMouseEventTargetCell(event); if (td == null) return; Element tr = DOM.getParent(td); Element body = DOM.getParent(tr); selectedRow = DOM.getChildIndex(body, tr); if (selectedRow >= 0) { markSelectedRow(selectedRow); Main.get().onlineUsersPopup.enableAcceptButton(); DOM.eventCancelBubble(event, true); Main.get().onlineUsersPopup.executeAction(); } } super.onBrowserEvent(event); }
Example 5
Source Project: document-management-system Source File: ExtendedFlexTable.java License: GNU General Public License v2.0 | 6 votes |
/** * Method originally copied from HTMLTable superclass where it was defined private * Now implemented differently to only return target cell if it'spart of 'this' table */ private Element getMouseEventTargetCell(Event event) { Element td = DOM.eventGetTarget(event); //locate enclosing td element while (!DOM.getElementProperty(td, "tagName").equalsIgnoreCase("td")) { // If we run out of elements, or run into the table itself, then give up. if ((td == null) || td == getElement()) return null; td = DOM.getParent(td); } //test if the td is actually from this table Element tr = DOM.getParent(td); Element body = DOM.getParent(tr); if (body == this.getBodyElement()) { return td; } //Didn't find appropriate cell return null; }
Example 6
Source Project: calendar-component Source File: DateCell.java License: Apache License 2.0 | 6 votes |
public void setToday(Date today, int width) { this.today = today; addStyleDependentName("today"); Element lastChild = (Element) getElement().getLastChild(); if (lastChild.getClassName().equals("v-calendar-current-time")) { todaybar = lastChild; } else { todaybar = DOM.createDiv(); todaybar.setClassName("v-calendar-current-time"); getElement().appendChild(todaybar); } if (width != -1) { todaybar.getStyle().setWidth(width, Unit.PX); } // position is calculated later, when we know the cell heights }
Example 7
Source Project: incubator-retired-wave Source File: AnnotationSpreadRenderer.java License: Apache License 2.0 | 6 votes |
private void updateEventHandler(final ContentElement element, String eventHandlerId) { Element implNodelet = element.getImplNodelet(); final EventHandler handler = eventHandlerId == null ? null : AnnotationPaint.eventHandlerRegistry.get(eventHandlerId); if (handler != null) { DOM.sinkEvents(DomHelper.castToOld(implNodelet), MOUSE_LISTENER_EVENTS); DOM.setEventListener(DomHelper.castToOld(implNodelet), new EventListener() { @Override public void onBrowserEvent(Event event) { handler.onEvent(element, event); } }); } else { removeListener(DomHelper.castToOld(implNodelet)); } }
Example 8
Source Project: SensorWebClient Source File: DiagramTab.java License: GNU General Public License v2.0 | 6 votes |
private void initTooltips() { Element mousePointerElement = getMousePointerLineElement(); DOM.setStyleAttribute(mousePointerElement, "backgroundColor", "blue"); DOM.setStyleAttribute(mousePointerElement, "width", "0px"); DOM.setStyleAttribute(mousePointerElement, "height", "0px"); DOM.setStyleAttribute(mousePointerElement, "visibility", "hidden"); DOM.setStyleAttribute(mousePointerElement, "marginTop", "6px"); this.mainChartViewport.add(this.verticalMousePointerLine); this.tooltipPresenter = new TooltipPresenter(this.mainChartEventBus); this.tooltipPresenter.configureHoverMatch(true, false, false); this.tooltipPresenter.setTooltipZIndex(Constants.Z_INDEX_ON_TOP); GenericWidgetViewImpl widget = new GenericWidgetViewImpl(this.verticalMousePointerLine); MousePointerPresenter mpp = new MousePointerPresenter(this.mainChartEventBus, widget); mpp.configure(true, false); }
Example 9
Source Project: gwt-material-addins Source File: MaterialSubHeaderContainer.java License: Apache License 2.0 | 6 votes |
@Override public void load() { if (getType() == SubHeaderType.PINNED) { String subHeaderClass = DOM.createUniqueId(); for (Widget w : getChildren()) { if (w instanceof MaterialSubHeader) { w.addStyleName(subHeaderClass); subHeaders.add((MaterialSubHeader) w); } } JsSubHeader.initSubheader("." + subHeaderClass, getElement()); if (subHeaders.size() == 0) { $(getElement()).find(".top_holder").css("display", "none"); } } AddinsDarkThemeReloader.get().reload(MaterialSubheaderDarkTheme.class); }
Example 10
Source Project: appinventor-extensions Source File: MockComponentsUtil.java License: Apache License 2.0 | 6 votes |
/** * Sets the font typeface for the given widget. * * @param widget widget to change font typeface for * @param typeface "0" for normal, "1" for sans serif, "2" for serif and * "3" for monospace */ static void setWidgetFontTypeface(Widget widget, String typeface) { switch (Integer.parseInt(typeface)) { default: // This should never happen throw new IllegalArgumentException("Typeface:" + typeface); case 0: case 1: typeface = "sans-serif"; break; case 2: typeface = "serif"; break; case 3: typeface = "monospace"; break; } DOM.setStyleAttribute(widget.getElement(), "fontFamily", typeface); }
Example 11
Source Project: geowe-core Source File: JoinDataTool.java License: GNU General Public License v3.0 | 6 votes |
private SubmitCompleteHandler getSubmitCompleteHandler() { return new SubmitCompleteHandler() { public void onSubmitComplete(final SubmitCompleteEvent event) { final Element label = DOM.createLabel(); label.setInnerHTML(event.getResults()); final String csvData = label.getInnerText(); if (hasError(csvData)) { showAlert("Error: " + csvData); } else { parseCsvData(csvData); autoMessageBox.hide(); } } private boolean hasError(final String contentFile) { return contentFile.startsWith("413") || contentFile.startsWith("500"); } }; }
Example 12
Source Project: document-management-system Source File: SyntaxHighlighterPreview.java License: GNU General Public License v2.0 | 6 votes |
/** * HTMLPreview */ public SyntaxHighlighterPreview() { iframe = new Frame("about:blank"); DOM.setElementProperty(iframe.getElement(), "frameborder", "0"); DOM.setElementProperty(iframe.getElement(), "marginwidth", "0"); DOM.setElementProperty(iframe.getElement(), "marginheight", "0"); //DOM.setElementProperty(iframe.getElement(), "scrolling", "yes"); // Commented because on IE show clear if allowtransparency=true DOM.setElementProperty(iframe.getElement(), "allowtransparency", "false"); iframe.setStyleName("okm-Iframe"); iframe.addStyleName("okm-EnableSelect"); initWidget(iframe); }
Example 13
Source Project: vaadin-combobox-multiselect Source File: VComboBoxMultiselect.java License: Apache License 2.0 | 6 votes |
@Override protected void onPreviewNativeEvent(NativePreviewEvent event) { // Check all events outside the combobox to see if they scroll the // page. We cannot use e.g. Window.addScrollListener() because the // scrolled element can be at any level on the page. // Normally this is only called when the popup is showing, but make // sure we don't accidentally process all events when not showing. if (!this.scrollPending && isShowing() && !DOM.isOrHasChild(SuggestionPopup.this.getElement(), Element.as(event.getNativeEvent() .getEventTarget()))) { if (getDesiredLeftPosition() != this.leftPosition || getDesiredTopPosition() != this.topPosition) { updatePopupPositionOnScroll(); } } super.onPreviewNativeEvent(event); }
Example 14
Source Project: SensorWebClient Source File: DiagramTab.java License: GNU General Public License v2.0 | 6 votes |
private HTML buildSliderPart(String width, String height, String cursor, String color, double transparancy) { HTML container = new HTML(); container.setWidth(width); container.setHeight(height); DOM.setStyleAttribute(container.getElement(), "cursor", cursor); DOM.setStyleAttribute(container.getElement(), "backgroundColor", color); // transparency styling (see also bug#449 and http://www.quirksmode.org/css/opacity.html) // note: since GWT complains, '-msFilter' has to be in plain camelCase (w/o '-') // ordering is important here DOM.setStyleAttribute(container.getElement(), "opacity", Double.toString(transparancy)); DOM.setStyleAttribute(container.getElement(), "mozOpacity", Double.toString(transparancy)); String opacity = "(opacity=" +Double.toString(transparancy*100) + ")"; DOM.setStyleAttribute(container.getElement(), "msFilter", "\"progid:DXImageTransform.Microsoft.Alpha"+ opacity + "\""); DOM.setStyleAttribute(container.getElement(), "filter", "alpha" + opacity); return container; }
Example 15
Source Project: document-management-system Source File: ExtendedFlexTable.java License: GNU General Public License v2.0 | 6 votes |
/** * Method originally copied from HTMLTable superclass where it was defined private * Now implemented differently to only return target cell if it'spart of 'this' table */ private Element getMouseEventTargetCell(Event event) { Element td = DOM.eventGetTarget(event); //locate enclosing td element while (!DOM.getElementProperty(td, "tagName").equalsIgnoreCase("td")) { // If we run out of elements, or run into the table itself, then give up. if ((td == null) || td == getElement()) return null; td = DOM.getParent(td); } //test if the td is actually from this table Element tr = DOM.getParent(td); Element body = DOM.getParent(tr); if (body == this.getBodyElement()) { return td; } //Didn't find appropriate cell return null; }
Example 16
Source Project: vaadin-combobox-multiselect Source File: VComboBoxMultiselect.java License: Apache License 2.0 | 5 votes |
@Override public void onKeyDown(KeyDownEvent event) { if (this.enabled && !this.readonly) { int keyCode = event.getNativeKeyCode(); debug("VComboBoxMultiselect: key down: " + keyCode); if (this.dataReceivedHandler.isWaitingForFilteringResponse() && navigationKeyCodes.contains(keyCode) && (!this.allowNewItems || keyCode != KeyCodes.KEY_ENTER)) { /* * Keyboard navigation events should not be handled while we are * waiting for a response. This avoids flickering, disappearing * items, wrongly interpreted responses and more. */ debug("Ignoring " + keyCode + " because we are waiting for a filtering response"); DOM.eventPreventDefault(DOM.eventGetCurrentEvent()); event.stopPropagation(); return; } if (this.suggestionPopup.isAttached()) { debug("Keycode " + keyCode + " target is popup"); popupKeyDown(event); } else { debug("Keycode " + keyCode + " target is text field"); inputFieldKeyDown(event); } } }
Example 17
Source Project: gwt-material-addins Source File: MaterialAutoComplete.java License: Apache License 2.0 | 5 votes |
/** * Generate and build the List Items to be set on Auto Complete box. */ protected void setup(SuggestOracle suggestions) { if (itemBoxKeyDownHandler != null) { itemBoxKeyDownHandler.removeHandler(); } list.setStyleName(AddinsCssName.MULTIVALUESUGGESTBOX_LIST); this.suggestions = suggestions; final ListItem item = new ListItem(); item.setStyleName(AddinsCssName.MULTIVALUESUGGESTBOX_INPUT_TOKEN); suggestBox = new SuggestBox(suggestions, itemBox); suggestBox.addSelectionHandler(selectionEvent -> { Suggestion selectedItem = selectionEvent.getSelectedItem(); itemBox.setValue(""); if (addItem(selectedItem)) { ValueChangeEvent.fire(MaterialAutoComplete.this, getValue()); } itemBox.setFocus(true); }); loadHandlers(); setLimit(this.limit); String autocompleteId = DOM.createUniqueId(); itemBox.getElement().setId(autocompleteId); item.add(suggestBox); item.add(label); list.add(item); panel.add(list); panel.getElement().setAttribute("onclick", "document.getElementById('" + autocompleteId + "').focus()"); panel.add(errorLabel); suggestBox.setFocus(true); }
Example 18
Source Project: vaadin-combobox-multiselect Source File: VComboBoxMultiselect.java License: Apache License 2.0 | 5 votes |
/** * Should the previous page button be visible to the user * * @param active */ private void setPrevButtonActive(boolean active) { debug("VComboBoxMultiselect.SP: setPrevButtonActive(" + active + ")"); if (active) { DOM.sinkEvents(this.up, Event.ONCLICK); this.up.setClassName(VComboBoxMultiselect.this.getStylePrimaryName() + "-prevpage"); } else { DOM.sinkEvents(this.up, 0); this.up.setClassName(VComboBoxMultiselect.this.getStylePrimaryName() + "-prevpage-off"); } }
Example 19
Source Project: cuba Source File: CubaTreeTableWidget.java License: Apache License 2.0 | 5 votes |
public CubaTreeTableHeaderCell(String colId, String headerText) { super(colId, headerText); Element sortIndicator = td.getChild(1).cast(); DOM.sinkEvents(sortIndicator, Event.ONCONTEXTMENU | DOM.getEventsSunk(sortIndicator)); Element captionContainer = td.getChild(2).cast(); DOM.sinkEvents(captionContainer, Event.ONCONTEXTMENU | DOM.getEventsSunk(captionContainer)); }
Example 20
Source Project: gwt-material-addins Source File: MaterialTimePicker.java License: Apache License 2.0 | 5 votes |
@Override protected void onLoad() { super.onLoad(); setUniqueId(DOM.createUniqueId()); timeInput.setType(InputType.TEXT); container.add(timeInput); container.add(label); container.add(errorLabel); add(container); timeInput.getElement().setAttribute("type", "text"); load(); }
Example 21
Source Project: cuba Source File: TableAggregationRow.java License: Apache License 2.0 | 5 votes |
protected void addCellWithField(String text, char align, int colIndex) { final TableCellElement td = DOM.createTD().cast(); final DivElement container = DOM.createDiv().cast(); container.setClassName(tableWidget.getStylePrimaryName() + "-cell-wrapper" + " " + "widget-container"); setAlign(align, container); InputElement inputElement = DOM.createInputText().cast(); inputElement.setValue(text); inputElement.addClassName("v-textfield v-widget"); inputElement.addClassName("c-total-aggregation-textfield"); Style elemStyle = inputElement.getStyle(); elemStyle.setWidth(100, Style.Unit.PCT); container.appendChild(inputElement); if (inputsList == null) { inputsList = new ArrayList<>(); } inputsList.add(new AggregationInputFieldInfo(text, tableWidget.getColKeyByIndex(colIndex), inputElement)); DOM.sinkEvents(inputElement, Event.ONCHANGE | Event.ONKEYDOWN); td.setClassName(tableWidget.getStylePrimaryName() + "-cell-content"); td.addClassName(tableWidget.getStylePrimaryName() + "-aggregation-cell"); td.appendChild(container); tr.appendChild(td); }
Example 22
Source Project: gantt Source File: GanttWidget.java License: Apache License 2.0 | 5 votes |
public GanttWidget() { setElement(DivElement.as(DOM.createDiv())); setStyleName(STYLE_GANTT); nowElement.setClassName(STYLE_NOW_ELEMENT); moveElement.setClassName(STYLE_MOVE_ELEMENT); // not visible by default moveElement.getStyle().setDisplay(Display.NONE); timeline = GWT.create(TimelineWidget.class); container = DivElement.as(DOM.createDiv()); container.setClassName(STYLE_GANTT_CONTAINER); content = DivElement.as(DOM.createDiv()); content.setClassName(STYLE_GANTT_CONTENT); container.appendChild(content); content.appendChild(moveElement); content.appendChild(nowElement); scrollbarSpacer = DivElement.as(DOM.createDiv()); scrollbarSpacer.getStyle().setHeight(AbstractNativeScrollbar.getNativeScrollbarHeight(), Unit.PX); scrollbarSpacer.getStyle().setDisplay(Display.NONE); getElement().appendChild(timeline.getElement()); getElement().appendChild(container); getElement().appendChild(scrollbarSpacer); }
Example 23
Source Project: cuba Source File: CubaGridLayoutWidget.java License: Apache License 2.0 | 5 votes |
@Override public void onBrowserEvent(Event event) { super.onBrowserEvent(event); final int type = DOM.eventGetType(event); if (type == Event.ONKEYDOWN && shortcutHandler != null) { shortcutHandler.handleKeyboardEvent(event); } }
Example 24
Source Project: gwt-material-addins Source File: LanguageSelector.java License: Apache License 2.0 | 5 votes |
protected <T extends MaterialWidget & HasActivates> void setActivator(T widget) { String activator = DOM.createUniqueId(); widget.setActivates(activator); widget.addStyleName(IncubatorCssName.LANGUAGE_ACTIVATOR); add(widget); dropdown.setActivator(activator); dropdown.reload(); }
Example 25
Source Project: gwt-material-addins Source File: Kanban.java License: Apache License 2.0 | 5 votes |
@Override public void load() { setId(DOM.createUniqueId()); kanbanOptions = getOptions(); kanbanOptions.setElement("#" + getId()); kanban = new JKanban(getOptions()); if (responsive) { responsiveLoader.load(); } else { responsiveLoader.unload(); } }
Example 26
Source Project: unitime Source File: AriaSuggestBox.java License: Apache License 2.0 | 5 votes |
@Override public void onBrowserEvent(Event event) { switch (DOM.eventGetType(event)) { case Event.ONBLUR: BlurEvent.fireNativeEvent(event, this); break; case Event.ONFOCUS: FocusEvent.fireNativeEvent(event, this); break; } super.onBrowserEvent(event); }
Example 27
Source Project: appinventor-extensions Source File: MockComponentsUtil.java License: Apache License 2.0 | 5 votes |
/** * Sets the background color for the given widget. * * @param widget widget to change background color for * @param color new color (RGB value) */ static void setWidgetBackgroundColor(Widget widget, String color) { if (isNoneColor(color)) { DOM.setStyleAttribute(widget.getElement(), "backgroundColor", "transparent"); } else { DOM.setStyleAttribute(widget.getElement(), "backgroundColor", "#" + getHexString(color, 6)); } }
Example 28
Source Project: gantt Source File: GanttWidget.java License: Apache License 2.0 | 5 votes |
/** * @param child * Child widget. * @param container * Parent element. * @param beforeIndex * Target index of element in DOM. * @param domInsert * true: Insert at specific position. false: append at the end. */ @Override protected void insert(Widget child, Element container, int beforeIndex, boolean domInsert) { GWT.log("Count content elements: " + content.getChildCount() + " (" + getAdditionalNonWidgetContentElementCount() + " non-widget non-step elements, " + (getAdditonalContentElementCount() - getAdditionalNonWidgetContentElementCount()) + " non-step widgets.)"); // Validate index; adjust if the widget is already a child of this // panel. int adjustedBeforeStepIndex = adjustIndex(child, beforeIndex - getAdditionalNonWidgetContentElementCount()) - getAdditionalWidgetContentElementCount(); // Detach new child. Might also remove additional widgets like // predecessor arrows. May affect contentHeight. child.removeFromParent(); // Logical attach. getChildren().insert(child, adjustedBeforeStepIndex + getAdditionalWidgetContentElementCount()); // Physical attach. if (domInsert) { DOM.insertChild(container, child.getElement(), adjustedBeforeStepIndex + getAdditonalContentElementCount()); } else { DOM.appendChild(container, child.getElement()); } // Adopt. adopt(child); }
Example 29
Source Project: unitime Source File: FilterBox.java License: Apache License 2.0 | 5 votes |
@Override public void onBrowserEvent(Event event) { Element target = DOM.eventGetTarget(event); switch (DOM.eventGetType(event)) { case Event.ONMOUSEDOWN: boolean open = iFilterOpen.getElement().equals(target); boolean close = iFilterClose.getElement().equals(target); boolean clear = iFilterClear.getElement().equals(target); boolean filter = iFilter.getElement().equals(target); if (isFilterPopupShowing() || close) { hideFilterPopup(); } else if (open) { hideSuggestions(); showFilterPopup(); } if (clear) { iFilter.setText(""); removeAllChips(); setAriaLabel(toAriaString()); ValueChangeEvent.fire(FilterBox.this, getValue()); } if (!filter) { event.stopPropagation(); event.preventDefault(); Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute() { iFilter.setFocus(true); } }); } break; } }
Example 30
Source Project: unitime Source File: UniTimeTableHeader.java License: Apache License 2.0 | 5 votes |
@Override public void onBrowserEvent(Event event) { switch (DOM.eventGetType(event)) { case Event.ONKEYPRESS: MenuItem item = iAccessKeys.get(Character.toLowerCase((char)event.getCharCode())); if (item != null) { event.stopPropagation(); event.preventDefault(); item.getScheduledCommand().execute(); } } super.onBrowserEvent(event); }