Java Code Examples for com.google.gwt.dom.client.Element#setId()

The following examples show how to use com.google.gwt.dom.client.Element#setId() . 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 File: ViewClientCriterion.java    From hawkbit with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Styles a multi-row selection with the number of elements.
 *
 * @param drag
 *            the current drag event holding the context.
 */
void setMultiRowDragDecoration(final VDragEvent drag) {
    final Widget widget = drag.getTransferable().getDragSource().getWidget();

    if (widget instanceof VScrollTable) {
        final VScrollTable table = (VScrollTable) widget;
        final int rowCount = table.selectedRowKeys.size();

        Element dragCountElement = Document.get().getElementById(SP_DRAG_COUNT);
        if (rowCount > 1 && table.selectedRowKeys.contains(table.focusedRow.getKey())) {
            if (dragCountElement == null) {
                dragCountElement = Document.get().createStyleElement();
                dragCountElement.setId(SP_DRAG_COUNT);
                final HeadElement head = HeadElement
                        .as(Document.get().getElementsByTagName(HeadElement.TAG).getItem(0));
                head.appendChild(dragCountElement);
            }
            final SafeHtml formattedCssStyle = getDraggableTemplate()
                    .multiSelectionStyle(determineActiveTheme(drag), String.valueOf(rowCount));
            final StyleElement dragCountStyleElement = StyleElement.as(dragCountElement);
            dragCountStyleElement.setInnerSafeHtml(formattedCssStyle);
        } else if (dragCountElement != null) {
            dragCountElement.removeFromParent();
        }
    }
}
 
Example 2
Source File: QRCodeWidget.java    From bitcoin-transaction-explorer with MIT License 5 votes vote down vote up
public QRCodeWidget() {
  id = DOM.createUniqueId();

  final Element div = Document.get().createDivElement();
  div.setId(id);

  setElement(div);
}
 
Example 3
Source File: Client.java    From unitime with Apache License 2.0 4 votes vote down vote up
public void onModuleLoadDeferred() {
	// register triggers
	GWT.runAsync(new RunAsyncCallback() {
		@Override
		public void onSuccess() {
			for (Triggers t: Triggers.values())
				t.register();
			callGwtOnLoadIfExists();
		}
		@Override
		public void onFailure(Throwable reason) {
		}
	});
	
	// load page
	if (RootPanel.get("UniTimeGWT:Body") != null) {
		LoadingWidget.getInstance().show(MESSAGES.waitLoadingPage());
		Scheduler.get().scheduleDeferred(new ScheduledCommand() {
			@Override
			public void execute() {
				initPageAsync(Window.Location.getParameter("page"));
			}
		});
	}
	
	// load components
	for (final Components c: Components.values()) {
		final RootPanel p = RootPanel.get(c.id());
		if (p != null) {
			Scheduler.get().scheduleDeferred(new ScheduledCommand() {
				@Override
				public void execute() {
					initComponentAsync(p, c);
				}
			});
		}
		if (p == null && c.isMultiple()) {
			NodeList<Element> x = getElementsByName(c.id());
			if (x != null && x.getLength() > 0)
				for (int i = 0; i < x.getLength(); i++) {
					Element e = x.getItem(i);
					e.setId(DOM.createUniqueId());
					final RootPanel q = RootPanel.get(e.getId());
					Scheduler.get().scheduleDeferred(new ScheduledCommand() {
						@Override
						public void execute() {
							initComponentAsync(q, c);
						}
					});
				}
		}
	}
	
	Window.addWindowClosingHandler(new Window.ClosingHandler() {
		@Override
		public void onWindowClosing(Window.ClosingEvent event) {
			if (isLoadingDisplayed() || LoadingWidget.getInstance().isShowing()) return;
			LoadingWidget.showLoading(MESSAGES.waitPlease());
			iPageLoadingTimer = new Timer() {
				@Override
				public void run() {
					RPC.execute(new IsSessionBusyRpcRequest(), new AsyncCallback<GwtRpcResponseBoolean>() {
						@Override
						public void onFailure(Throwable caught) {
							LoadingWidget.hideLoading();
						}
						@Override
						public void onSuccess(GwtRpcResponseBoolean result) {
							if (result.getValue()) {
								iPageLoadingTimer.schedule(500);
							} else {
								LoadingWidget.hideLoading();
							}
						}
					});
				}
			};
			iPageLoadingTimer.schedule(500);
		}
	});
}
 
Example 4
Source File: IdHelper.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public static void setId(Element element, WidgetType widgetType, String prefix, String id) {
    element.setId(widgetType.type + "_" + prefix.toLowerCase() + "_" + id.toLowerCase());
}