本文整理匯總了Java中com.google.gwt.user.client.Element類的典型用法代碼示例。如果您正苦於以下問題:Java Element類的具體用法?Java Element怎麽用?Java Element使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Element類屬於com.google.gwt.user.client包,在下文中一共展示了Element類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: AccessibleCheckBox
import com.google.gwt.user.client.Element; //導入依賴的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: replaceInputElement
import com.google.gwt.user.client.Element; //導入依賴的package包/類
/**
* Replace the current input element with a new one. Preserves all state except for the name property, for nasty reasons related to radio button grouping.
* (See implementation of {@link RadioButton#setName}.)
*
* @param elem the new input element
*/
protected void replaceInputElement(Element elem) {
InputElement newInputElem = InputElement.as(elem);
// Collect information we need to set
int tabIndex = getTabIndex();
boolean checked = getValue();
boolean enabled = isEnabled();
String formValue = getFormValue();
String uid = inputElem.getId();
String accessKey = inputElem.getAccessKey();
int sunkEvents = Event.getEventsSunk(inputElem);
// Clear out the old input element
setEventListener(asOld(inputElem), null);
getElement().replaceChild(newInputElem, inputElem);
// Sink events on the new element
Event.sinkEvents(elem, Event.getEventsSunk(inputElem));
Event.sinkEvents(inputElem, 0);
inputElem = newInputElem;
// Setup the new element
Event.sinkEvents(inputElem, sunkEvents);
inputElem.setId(uid);
if (!"".equals(accessKey)) {
inputElem.setAccessKey(accessKey);
}
setTabIndex(tabIndex);
setValue(checked);
setEnabled(enabled);
setFormValue(formValue);
// Set the event listener
if (isAttached()) {
setEventListener(asOld(inputElem), this);
}
}
示例3: onAreaClickWrongCoordinates
import com.google.gwt.user.client.Element; //導入依賴的package包/類
@Test
public void onAreaClickWrongCoordinates() throws Exception {
ColorfillAreaClickListener colorfillAreaClickListener = mock(ColorfillAreaClickListener.class);
instance.setAreaClickListener(colorfillAreaClickListener);
when(canvasImageDataProvider.getCanvasImageData(canvasStubView)).thenReturn(imageData);
doReturn(-10).when(positionHelper)
.getXPositionRelativeToTarget(any(NativeEvent.class), Matchers.any(Element.class));
doReturn(-15).when(positionHelper)
.getYPositionRelativeToTarget(any(NativeEvent.class), Matchers.any(Element.class));
ArgumentCaptor<LoadHandler> loadHandlerCaptor = ArgumentCaptor.forClass(LoadHandler.class);
verify(canvasStubView).setImageLoadHandler(loadHandlerCaptor.capture());
loadHandlerCaptor.getValue()
.onLoad(null);
ArgumentCaptor<Command> commandCaptor = ArgumentCaptor.forClass(Command.class);
verify(userInteractionHandlerFactory).applyUserClickHandler(commandCaptor.capture(), eq(canvas));
NativeEvent nativeEvent = mock(NativeEvent.class);
commandCaptor.getValue()
.execute(nativeEvent);
verify(colorfillAreaClickListener, times(0)).onAreaClick(any(Area.class));
}
示例4: shouldTestInitNoConfiguration
import com.google.gwt.user.client.Element; //導入依賴的package包/類
@Test
public void shouldTestInitNoConfiguration() {
// given
Element element = mock(Element.class);
MediaWrapper<MediaBase> mediaDescriptor = mock(MediaWrapper.class);
when(mediaDescriptor.getMediaObject()).thenReturn(mediaBase);
when(mediaBase.getElement()).thenReturn(element);
instance.setMediaWrapper(mediaDescriptor);
mediaConfiguration = new BaseMediaConfiguration(new HashMap<String, String>(), false);
instance.setBaseMediaConfiguration(mediaConfiguration);
// when
instance.init();
// then
verify(mediaBase).setPreload(Matchers.eq(getAssumedMediaPreloadType()));
verify(mediaBase).setControls(Matchers.eq(true));
for (Map.Entry<HTML5MediaEventsType, MediaEventTypes> typePair : createEventsPairMap().entrySet()) {
verify(html5MediaNativeListeners).addListener(element, typePair.getKey().toString());
}
}
示例5: shouldInitiateValues_whenMediaBaseIsSet
import com.google.gwt.user.client.Element; //導入依賴的package包/類
@Test
public void shouldInitiateValues_whenMediaBaseIsSet() {
// given
Element element = mock(Element.class);
MediaWrapper<MediaBase> mediaDescriptor = mock(MediaWrapper.class);
when(mediaDescriptor.getMediaObject()).thenReturn(mediaBase);
when(mediaBase.getElement()).thenReturn(element);
instance.setMediaWrapper(mediaDescriptor);
instance.setBaseMediaConfiguration(mediaConfiguration);
// when
instance.init();
// then
verify(mediaBase).setPreload(Matchers.eq(getAssumedMediaPreloadType()));
verify(mediaBase).setControls(Matchers.eq(false));
for (Map.Entry<HTML5MediaEventsType, MediaEventTypes> typePair : createEventsPairMap().entrySet()) {
verify(html5MediaNativeListeners).addListener(element, typePair.getKey().toString());
}
}
示例6: getContainerOffsetLeft
import com.google.gwt.user.client.Element; //導入依賴的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;
}
示例7: getContainerOffsetTop
import com.google.gwt.user.client.Element; //導入依賴的package包/類
protected int getContainerOffsetTop() {
if (containerOffsetTop < 0 || !sync) {
int scrollTop = 0;
Element parent = DOM.getParent(getWidget().getElement());
while (parent != null) {
if (getScrollTop(parent) > 0) {
scrollTop += getScrollTop(parent);
GWT.log("Scroll Top detected : " + scrollTop);
}
if (containerFinder.isContainer(parent)) {
containerOffsetTop = DOM.getAbsoluteTop(parent) - scrollTop;
}
parent = DOM.getParent(parent);
}
}
return containerOffsetTop;
}
示例8: Thumb
import com.google.gwt.user.client.Element; //導入依賴的package包/類
public Thumb() {
visibleThumb = new SimplePanel();
Element visibleElem = visibleThumb.getElement();
Element touchElem = getElement();
visibleThumb.setStylePrimaryName(THUMB_CLASS_NAME);
BrowserUtils.setStyleAttributeAllBrowsers(visibleElem, "boxSizing", "border-box");
BrowserUtils.setStyleAttributeAllBrowsers(touchElem, "boxSizing", "border-box");
this.setWidget(visibleThumb);
if (!isPassive)
{
visibleThumb.addStyleName(INTERACTIVE_CLASS_NAME);
}
}
示例9: onBrowserEvent
import com.google.gwt.user.client.Element; //導入依賴的package包/類
@Override
public void onBrowserEvent(Event event) {
super.onBrowserEvent(event);
Element td = getEventTargetCell(event);
if (td == null)
return;
Element tr = DOM.getParent(td);
switch (DOM.eventGetType(event)) {
case Event.ONMOUSEOVER:
tr.addClassName(ROW_STYLE_NAME + "-mouseover");
break;
case Event.ONMOUSEOUT: {
tr.removeClassName(ROW_STYLE_NAME + "-mouseover");
break;
}
}
}
示例10: getMouseEventTargetCell
import com.google.gwt.user.client.Element; //導入依賴的package包/類
/**
* 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;
}
示例11: downloadFiles
import com.google.gwt.user.client.Element; //導入依賴的package包/類
/**
* Download files exported as zip
*
* @author danilo
*/
@Deprecated
public static void downloadFiles(List<String> path, String params) {
if (!params.equals("")) {
params = "&" + params;
}
final Element downloadIframe = RootPanel.get("__download").getElement();
String url = RPCService.DownloadServlet + "?export" + params;
for (String p : path) {
url += "&pathList=" + URL.encodeQueryString(p);
}
DOM.setElementAttribute(downloadIframe, "src", url);
}
示例12: onBrowserEvent
import com.google.gwt.user.client.Element; //導入依賴的package包/類
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);
}
示例13: onBrowserEvent
import com.google.gwt.user.client.Element; //導入依賴的package包/類
@Override
public void onBrowserEvent(Event event) {
super.onBrowserEvent(event);
if (DOM.eventGetType(event) == Event.ONSCROLL) {
Element element = getElement();
int scrollTop = element.getScrollTop();
int scrollLeft = element.getScrollLeft();
if (this.scrollTop != scrollTop || this.scrollLeft != scrollLeft) {
if (onScrollHandler != null) {
onScrollHandler.accept(scrollTop, scrollLeft);
}
this.scrollTop = scrollTop;
this.scrollLeft = scrollLeft;
}
}
}
示例14: onMouseOver
import com.google.gwt.user.client.Element; //導入依賴的package包/類
@Override
public void onMouseOver(MouseOverEvent<Appointment> event) {
final Element element = (Element)event.getElement();
final Appointment appt = event.getTarget();
final StringBuilder t = new StringBuilder("<p><b>").append(appt.getTitle()).append("</b></p>");
if (appt.getDescription() != null) {
t.append(appt.getDescription());
}
t.append("<p><i>").append(Constants.INSTANCE.dblClickToExplore()).append("</i></p>");
appointmentPopup.setWidget(new HTML(t.toString()));
int left = element.getAbsoluteLeft() + 10;
int top = element.getAbsoluteTop() + 10;
appointmentPopup.setPopupPosition(left, top);
appointmentPopup.show();
}
示例15: create
import com.google.gwt.user.client.Element; //導入依賴的package包/類
@Override
public Element create(String objectElementId, String swfUrl, String readyFn) {
Element obj = DOM.createElement("object");
DOM.setStyleAttribute(obj, "position", "absolute");
DOM.setStyleAttribute(obj, "top", "0px");
DOM.setStyleAttribute(obj, "left", "0px");
DOM.setStyleAttribute(obj, "zIndex", "0");
DOM.setElementAttribute(obj, "id", objectElementId);
DOM.setElementAttribute(obj, "width", "100%");
DOM.setElementAttribute(obj, "height","100%");
DOM.setElementAttribute(obj, "type", "application/x-shockwave-flash");
DOM.setElementAttribute(obj, "data", swfUrl);
add(obj, "FlashVars", "readyFn=" + readyFn);
add(obj, "quality", "autolow");
add(obj, "bgcolor", "#FFFFFF");
add(obj, "wmode", "opaque");
add(obj, "MENU", "false");
add(obj, "base", getModuleBaseURL());
add(obj, "allowScriptAccess", "always");
add(obj, "allowNetworking", "all");
return obj;
}