本文整理汇总了Java中com.google.gwt.user.client.EventListener类的典型用法代码示例。如果您正苦于以下问题:Java EventListener类的具体用法?Java EventListener怎么用?Java EventListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EventListener类属于com.google.gwt.user.client包,在下文中一共展示了EventListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setEventHandler
import com.google.gwt.user.client.EventListener; //导入依赖的package包/类
/**
* Sets an event handler for an {@code Element}. All previous event handlers of this type of event are removed.
* @param element The element to bind the event handler for
* @param eventType The event type (e.g. {@code ClickEvent.getType()})
* @param handler The handler that handler the event
*/
public static <H extends EventHandler> void setEventHandler(final Element element, DomEvent.Type<H> eventType, H handler) {
if (element == null) {
return;
}
HandlerManager hm = handlerManagers.get(element);
if (hm == null) {
handlerManagers.put(element, hm = new HandlerManager(element));
DOM.setEventListener(element, new EventListener() {
@Override
public void onBrowserEvent(Event event) {
DomEvent.fireNativeEvent(event, handlerManagers.get(element), element);
}
});
}
DOM.sinkBitlessEvent(element, eventType.getName());
while (hm.getHandlerCount(eventType) > 0) {
hm.removeHandler(eventType, hm.getHandler(eventType, 0));
}
hm.addHandler(eventType, handler);
}
示例2: updateEventHandler
import com.google.gwt.user.client.EventListener; //导入依赖的package包/类
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));
}
}
示例3: addActivityTimer
import com.google.gwt.user.client.EventListener; //导入依赖的package包/类
protected void addActivityTimer() {
if (CMDBSession.get().getConfig().getDesktopLockTimeout() < 0) {
return;
}
lastActivityTime = System.currentTimeMillis();
//add event capture to detect user activity and reset idle timeout
DOM.setEventListener(RootPanel.get().getElement(), new EventListener() {
public void onBrowserEvent(Event event) {
lastActivityTime = System.currentTimeMillis();
}
});
DOM.sinkEvents(RootPanel.get().getElement(), Event.ONMOUSEDOWN);
}
示例4: onLoad
import com.google.gwt.user.client.EventListener; //导入依赖的package包/类
@Override
protected void onLoad() {
super.onLoad();
// Set page title & description
setLayoutTitle(cons.sideMenuTitle());
setLayoutDescription(cons.sideMenuDescription());
// Inject layout stylesheet
res.sideMenuLayoutCssResource().ensureInjected();
// Bind click event to menu button
DOM.setEventListener(menuLink, new EventListener() {
@Override public void onBrowserEvent(Event event) {
if (event.getTypeInt() == Event.ONCLICK) {
toggleClass(layout.getElement(), res.sideMenuLayoutCssResource().active());
toggleClass(menu, res.sideMenuLayoutCssResource().active());
toggleClass(menuLink, res.sideMenuLayoutCssResource().active());
event.preventDefault();
}
}
});
DOM.sinkEvents(menuLink, Event.ONCLICK);
}
示例5: addConnectivityHandler
import com.google.gwt.user.client.EventListener; //导入依赖的package包/类
@Override
public final HandlerRegistration addConnectivityHandler(final ConnectivityEvent.Handler handler) {
EventListener el = new EventListener() {
@Override
public void onBrowserEvent(Event event) {
handler.onConnectivity((ConnectivityEventJsoImpl) event.cast());
}
};
final HandlerRegistration hr1 = register(this, "online", el);
final HandlerRegistration hr2 = register(this, "offline", el);
return new HandlerRegistration() {
@Override
public void removeHandler() {
hr1.removeHandler();
hr2.removeHandler();
}
};
}
示例6: convertItemToOpenable
import com.google.gwt.user.client.EventListener; //导入依赖的package包/类
private Element convertItemToOpenable (String key, SafeHtml title) {
activateItem(key, false);
Element element = getItem(key);
ensureItems().remove(key);
element.setClassName("dropdown");
final AnchorElement a = AnchorElement
.as(element.getFirstChildElement());
a.removeAttribute("href");
Event.sinkEvents(a, Event.ONCLICK);
Event.setEventListener(a, new EventListener() {
@Override
public void onBrowserEvent (Event event) {
openableClick(a);
event.stopPropagation();
}
});
a.addClassName("dropdown-toggle");
a.setInnerSafeHtml(title);
Element ul = Document.get().createULElement();
ul.addClassName("dropdown-menu");
element.appendChild(ul);
ensureOpenables().put(key, element);
return element;
}
示例7: acquireLockOnDemand
import com.google.gwt.user.client.EventListener; //导入依赖的package包/类
public EventListener acquireLockOnDemand(final Element element) {
Event.sinkEvents(element,
lockDemandDetector.getLockDemandEventTypes());
EventListener lockDemandListener = new EventListener() {
@Override
public void onBrowserEvent(Event event) {
if (isLockedByCurrentUser()) {
return;
}
if (lockDemandDetector.isLockRequired(event)) {
acquireLock();
}
}
};
Event.setEventListener(element,
lockDemandListener);
return lockDemandListener;
}
示例8: addButton
import com.google.gwt.user.client.EventListener; //导入依赖的package包/类
private void addButton(String id, final Image image, VerticalPanel iconsPanel) {
Element element = layout.getElement(id);
image.setStyleName(STYLE_CLICKABLE);
if (element==null) {
image.addClickHandler(mainClickHandler);
iconsPanel.add(image);
iconsPanel.setCellHeight(image, "1%");
iconsPanel.setCellWidth(image, "100%");
} else {
com.google.gwt.user.client.Element el = (com.google.gwt.user.client.Element) element;
DOM.sinkEvents(el,Event.ONCLICK);
DOM.setEventListener(el, new EventListener(){
public void onBrowserEvent(Event event) {
processClick(image);
}
});
layout.addStyle(id, PlayerLayout.BUTTON_ON_STYLE);
}
}
示例9: appendInSpan
import com.google.gwt.user.client.EventListener; //导入依赖的package包/类
private void appendInSpan(final Widget widget, boolean wordWrap) {
Element el = DOM.createSpan();
Element oldEl = widget.getElement();
DOM.setInnerHTML(el, DOM.getInnerHTML(oldEl));
String style = widget.getStyleName();
if (style != null && style.length()>0) {
DOM.setElementProperty(el, "className", style);
}
if (wordWrap) {
DOM.setStyleAttribute(el, "whiteSpace", "normal");
} else {
DOM.setStyleAttribute(el, "whiteSpace", "nowrap");
}
EventListener eventListener = new EventListener() {
public void onBrowserEvent(Event event) {
widget.onBrowserEvent(event);
}
};
DOM.setEventListener(el, eventListener);
DOM.sinkEvents(el, DOM.getEventsSunk(oldEl));
DOM.appendChild(getElement(), el);
}
示例10: onLoad
import com.google.gwt.user.client.EventListener; //导入依赖的package包/类
@Override
protected void onLoad() {
super.onLoad();
// Set page title & description
setLayoutTitle(cons.sideMenuTitle());
setLayoutDescription(cons.sideMenuDescription());
// Inject layout stylesheet
SandboxResourceBundle.INSTANCE.sideMenuLayoutCssResource().ensureInjected();
// Bind click event to menu button
DOM.setEventListener(menuLink, new EventListener() {
@Override public void onBrowserEvent(Event event) {
if (event.getTypeInt() == Event.ONCLICK) {
toggleClass(layout.getElement(), res.sideMenuLayoutCssResource().active());
toggleClass(menu, res.sideMenuLayoutCssResource().active());
toggleClass(menuLink, res.sideMenuLayoutCssResource().active());
event.preventDefault();
}
}
});
DOM.sinkEvents(menuLink, Event.ONCLICK);
}
示例11: ImageTracker
import com.google.gwt.user.client.EventListener; //导入依赖的package包/类
public ImageTracker(String imageUrl) {
m_image = new Image(imageUrl);
Event.setEventListener(m_image.getElement(), new EventListener() {
@Override
public void onBrowserEvent(Event event) {
if(Event.ONLOAD == event.getTypeInt()) {
callHandlers();
m_loadComplete = true;
}
}
});
Element div = Document.get().getElementById(m_trackerDivId);
div.appendChild(m_image.getElement());
//Document.get().getBody().appendChild(m_image.getElement());
}
示例12: upload
import com.google.gwt.user.client.EventListener; //导入依赖的package包/类
public void upload(final Renderer3d renderer3d, final Texture texture, final int activeTexture) {
if ((texture.status & GpuObjectStatus.TEXTURE_UPLOADING) == 0) {
texture.status |= GpuObjectStatus.TEXTURE_UPLOADING;
Integer Integer = gl.createTexture();
textures.put(texture, Integer);
ImageElement textureImage = resourceLoader.getImage(texture.image);
if (textureImage == null) {
Window.alert("Texture image not found in resources: " + texture.image);
} else {
textureImages.put(texture, textureImage);
Event.setEventListener(textureImage, new EventListener() {
@Override
public void onBrowserEvent(Event event) {
textureLoaded(renderer3d, texture, activeTexture);
}
});
Event.sinkEvents(textureImage, Event.ONLOAD);
}
}
}
示例13: updateEventHandler
import com.google.gwt.user.client.EventListener; //导入依赖的package包/类
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));
}
}
示例14: addModule
import com.google.gwt.user.client.EventListener; //导入依赖的package包/类
public void addModule(final String entered) {
if (modules.add(entered)) {
final Element clone = Element.as(moduleTemplate.getElement().cloneNode(true));
clone.removeClassName(res.css().hidden());
Element el = clone.getFirstChildElement().getNextSiblingElement();
el.setInnerText(entered);
com.google.gwt.user.client.Element image = el.getNextSiblingElement().cast();
DOM.setEventListener(image, new EventListener() {
@Override
public void onBrowserEvent(Event event) {
modules.remove(entered);
clone.removeFromParent();
}
});
DOM.sinkEvents(image, Event.ONCLICK | Event.ONKEYDOWN);
selectedModules.appendChild(clone);
}
}
示例15: WebcamConnector
import com.google.gwt.user.client.EventListener; //导入依赖的package包/类
public WebcamConnector() {
getWidget().setClickListener(new EventListener() {
@Override
public void onBrowserEvent(Event event) {
// Commanded by the user clicking the client-side widget.
captureNow();
}
});
registerRpc(WebcamClientRpc.class, new WebcamClientRpc() {
@Override
public void capture() {
// Commanded by the server-side component.
captureNow();
}
});
}