當前位置: 首頁>>代碼示例>>Java>>正文


Java DOM類代碼示例

本文整理匯總了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);
}
 
開發者ID:YoungDigitalPlanet,項目名稱:empiria.player,代碼行數:20,代碼來源:AccessibleCheckBox.java

示例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);
    }
}
 
開發者ID:knoobie,項目名稱:bootstrap-formgroup,代碼行數:24,代碼來源:ClientSideFormGroup.java

示例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);
}
 
開發者ID:ICT-BDA,項目名稱:EasyML,代碼行數:18,代碼來源:DatasetWidget.java

示例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;
}
 
開發者ID:ICT-BDA,項目名稱:EasyML,代碼行數:18,代碼來源:NodeShape.java

示例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);
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:26,代碼來源:SimpleEditPage.java

示例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);
}
 
開發者ID:mit-cml,項目名稱:appinventor-extensions,代碼行數:29,代碼來源:MockComponentsUtil.java

示例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;
    	}
    }
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:25,代碼來源:ImageButton.java

示例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);
}
 
開發者ID:mit-cml,項目名稱:appinventor-extensions,代碼行數:27,代碼來源:MockComponentsUtil.java

示例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;
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:11,代碼來源:FlowForm.java

示例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;
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:26,代碼來源:SimpleForm.java

示例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;
	}
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:22,代碼來源:HorizontalPanelWithHint.java

示例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);
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:20,代碼來源:SessionDatesSelector.java

示例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);
}
 
開發者ID:mit-cml,項目名稱:appinventor-extensions,代碼行數:22,代碼來源:MockButtonBase.java

示例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;
	}
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:23,代碼來源:InfoPanelImpl.java

示例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");
		}
	};
}
 
開發者ID:geowe,項目名稱:sig-seguimiento-vehiculos,代碼行數:23,代碼來源:JoinDataTool.java


注:本文中的com.google.gwt.user.client.DOM類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。