本文整理汇总了Java中com.google.gwt.user.client.DOM类的典型用法代码示例。如果您正苦于以下问题:Java DOM类的具体用法?Java DOM怎么用?Java DOM使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DOM类属于com.google.gwt.user.client包,在下文中一共展示了DOM类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: AccessibleCheckBox
import com.google.gwt.user.client.DOM; //导入依赖的package包/类
protected AccessibleCheckBox(Element elem) {
super(DOM.createSpan());
inputElem = InputElement.as(elem);
labelElem = Document.get().createLabelElement();
getElement().appendChild(inputElem);
getElement().appendChild(labelElem);
String uid = DOM.createUniqueId();
inputElem.setPropertyString("id", uid);
labelElem.setHtmlFor(uid);
// Accessibility: setting tab index to be 0 by default, ensuring element
// appears in tab sequence. FocusWidget's setElement method already
// calls setTabIndex, which is overridden below. However, at the time
// that this call is made, inputElem has not been created. So, we have
// to call setTabIndex again, once inputElem has been created.
setTabIndex(0);
}
示例2: setWidget
import com.google.gwt.user.client.DOM; //导入依赖的package包/类
public void setWidget(Widget w, boolean delegateCaptionHandling) {
if (w != null) {
this.widgetType = VaadinWidgetUtils.getWidgetTypeByWidget(w);
this.widgetElement = VaadinWidgetUtils.getElementByVaadinWidget(w, this.widgetType);
if (this.widgetType.isAddStyle()) {
this.widgetElement.addClassName(this.widgetType.getCssStyle());
} else {
this.widgetElement.setClassName(this.widgetType.getCssStyle());
}
if (delegateCaptionHandling) {
getElement().appendChild(label = DOM.createLabel());
} else {
getElement().appendChild(label = DOM.createDiv());
}
getElement().appendChild(div);
}
super.setWidget(w);
if (w != null) {
getContainerElement().appendChild(small);
getContainerElement().appendChild(feedback);
}
}
示例3: init
import com.google.gwt.user.client.DOM; //导入依赖的package包/类
@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);
}
示例4: getContainerOffsetLeft
import com.google.gwt.user.client.DOM; //导入依赖的package包/类
protected int getContainerOffsetLeft() {
if (containerOffsetLeft < 0 || !sync) {
int scrollLeft = 0;
Element parent = DOM.getParent(getWidget().getElement());
while (parent != null) {
if (getScrollLeft(parent) > 0) {
scrollLeft += getScrollLeft(parent);
GWT.log("Scroll left detected : " + scrollLeft);
}
if (containerFinder.isContainer(parent)) {
containerOffsetLeft = DOM.getAbsoluteLeft(parent) - scrollLeft;
}
parent = DOM.getParent(parent);
}
}
return containerOffsetLeft;
}
示例5: onBrowserEvent
import com.google.gwt.user.client.DOM; //导入依赖的package包/类
public void onBrowserEvent(final Event event) {
Element td = getEventTargetCell(event);
if (td==null) return;
final Element tr = DOM.getParent(td);
int col = DOM.getChildIndex(tr, td);
Element body = DOM.getParent(tr);
int row = DOM.getChildIndex(body, tr);
Widget widget = getWidget(row, col);
if (widget != null && widget instanceof UniTimeHeaderPanel) {
super.onBrowserEvent(event);
return;
}
switch (DOM.eventGetType(event)) {
case Event.ONMOUSEOVER:
getRowFormatter().addStyleName(row, "hover");
break;
case Event.ONMOUSEOUT:
getRowFormatter().removeStyleName(row, "hover");
break;
}
super.onBrowserEvent(event);
}
示例6: setWidgetFontTypeface
import com.google.gwt.user.client.DOM; //导入依赖的package包/类
/**
* 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);
}
示例7: onBrowserEvent
import com.google.gwt.user.client.DOM; //导入依赖的package包/类
@Override
public void onBrowserEvent(Event event) {
if (!isEnabled()) return;
super.onBrowserEvent(event);
if ((event.getTypeInt() & Event.KEYEVENTS) != 0) {
int type = DOM.eventGetType(event);
char keyCode = (char) event.getKeyCode();
switch (type) {
case Event.ONKEYDOWN:
if (keyCode == ' ' || keyCode == '\n' || keyCode == '\r') {
if (iDown != null) setResource(iDown);
}
break;
case Event.ONKEYUP:
if (keyCode == ' ' || keyCode == '\n' || keyCode == '\r') {
setResource(iUp);
onClick();
}
break;
}
}
}
示例8: setWidgetTextAlign
import com.google.gwt.user.client.DOM; //导入依赖的package包/类
/**
* Sets the text alignment for the given widget.
*
* @param widget widget to change text alignment for
* @param align one of "0" for left, "1" for center or "2" for right
*/
static void setWidgetTextAlign(Widget widget, String align) {
switch (Integer.parseInt(align)) {
default:
// This should never happen
throw new IllegalArgumentException("align:" + align);
case 0:
align = "left";
break;
case 1:
align = "center";
break;
case 2:
align = "right";
break;
}
DOM.setStyleAttribute(widget.getElement(), "textAlign", align);
}
示例9: getCellForWidget
import com.google.gwt.user.client.DOM; //导入依赖的package包/类
public int getCellForWidget(Widget w) {
for (Element e = w.getElement(); e != null; e = DOM.getParent(e)) {
if (e.getPropertyString("tagName").equalsIgnoreCase("span")) {
if (DOM.getParent(e) == getElement())
return DOM.getChildIndex(getElement(), e);
}
if (e == getElement()) { return -1; }
}
return -1;
}
示例10: addRow
import com.google.gwt.user.client.DOM; //导入依赖的package包/类
public int addRow(Widget header, Widget widget, int colSpan) {
header.addStyleName("label-cell");
int row = getRowCount();
setWidget(row, 0, header);
getCellFormatter().setStyleName(row, 0, "label-td");
if (widget instanceof HasMobileScroll) {
ScrollPanel scroll = new ScrollPanel(widget);
scroll.addStyleName("table-cell");
setWidget(row, 1, scroll);
getCellFormatter().setStyleName(row, 1, "table-td");
} else {
widget.addStyleName("widget-cell");
setWidget(row, 1, widget);
getCellFormatter().setStyleName(row, 1, "widget-td");
}
if (colSpan != 1)
getFlexCellFormatter().setColSpan(row, 1, colSpan);
if (header.getElement().getId() == null || header.getElement().getId().isEmpty())
header.getElement().setId(DOM.createUniqueId());
if (widget instanceof UniTimeWidget)
Roles.getTextboxRole().setAriaLabelledbyProperty(((UniTimeWidget)widget).getWidget().getElement(), Id.of(header.getElement()));
else
Roles.getTextboxRole().setAriaLabelledbyProperty(widget.getElement(), Id.of(header.getElement()));
return row;
}
示例11: onBrowserEvent
import com.google.gwt.user.client.DOM; //导入依赖的package包/类
public void onBrowserEvent(Event event) {
int x = 10 + event.getClientX() + getElement().getOwnerDocument().getScrollLeft();
int y = 10 + event.getClientY() + getElement().getOwnerDocument().getScrollTop();
switch (DOM.eventGetType(event)) {
case Event.ONMOUSEMOVE:
if (iHint.isShowing()) {
iHint.setPopupPosition(x, y);
} else {
iShowHint.cancel();
iHint.setPopupPosition(x, y);
iShowHint.schedule(1000);
}
break;
case Event.ONMOUSEOUT:
iShowHint.cancel();
if (iHint.isShowing())
iHideHint.schedule(1000);
break;
}
}
示例12: onBrowserEvent
import com.google.gwt.user.client.DOM; //导入依赖的package包/类
@Override
public void onBrowserEvent(Event event) {
switch (DOM.eventGetType(event)) {
case Event.ONMOUSEDOWN:
SelectionMode mode = null;
for (SelectionMode m: SelectionMode.values())
if (hasUnselectedDays(m)) {
mode = m; break;
}
if (mode != null)
setAllSelected(true, mode);
else
setAllSelected(false, SelectionMode.All);
if (iCursor != null) iPanel.getWidget().setCursor(iCursor);
event.preventDefault();
break;
}
super.onBrowserEvent(event);
}
示例13: setImageProperty
import com.google.gwt.user.client.DOM; //导入依赖的package包/类
private void setImageProperty(String text) {
imagePropValue = text;
String url = convertImagePropertyValueToUrl(text);
if (url == null) {
hasImage = false;
url = "";
setBackgroundColorProperty(backgroundColor);
setShapeProperty(Integer.toString(shape));
} else {
hasImage = true;
// Android Buttons do not show a background color if they have an image.
// The container's background color shows through any transparent
// portions of the Image, an effect we can get in the browser by
// setting the widget's background color to COLOR_NONE.
MockComponentsUtil.setWidgetBackgroundColor(buttonWidget,
"&H" + COLOR_NONE);
DOM.setStyleAttribute(buttonWidget.getElement(), "borderRadius", "0px");
}
MockComponentsUtil.setWidgetBackgroundImage(buttonWidget, url);
image.setUrl(url);
}
示例14: onBrowserEvent
import com.google.gwt.user.client.DOM; //导入依赖的package包/类
public void onBrowserEvent(Event event) {
if (iHint.getText().isEmpty()) return;
iX = 10 + event.getClientX() + getElement().getOwnerDocument().getScrollLeft();
iY = 10 + event.getClientY() + getElement().getOwnerDocument().getScrollTop();
switch (DOM.eventGetType(event)) {
case Event.ONMOUSEMOVE:
if (iInfoPanel.isShowing()) {
int maxX = Window.getScrollLeft() + Window.getClientWidth() - iInfoPanel.getOffsetWidth() - 10;
iInfoPanel.setPopupPosition(Math.min(iX, maxX), iY);
} else if (iInfo.getRowCount() > 0) {
iShowInfo.cancel();
iShowInfo.schedule(1000);
}
break;
case Event.ONMOUSEOUT:
iShowInfo.cancel();
if (iInfoPanel.isShowing())
iHideInfo.schedule(1000);
break;
}
}
示例15: getSubmitCompleteHandler
import com.google.gwt.user.client.DOM; //导入依赖的package包/类
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");
}
};
}