本文整理汇总了Java中com.google.web.bindery.event.shared.HandlerRegistration类的典型用法代码示例。如果您正苦于以下问题:Java HandlerRegistration类的具体用法?Java HandlerRegistration怎么用?Java HandlerRegistration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
HandlerRegistration类属于com.google.web.bindery.event.shared包,在下文中一共展示了HandlerRegistration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configureSwipe
import com.google.web.bindery.event.shared.HandlerRegistration; //导入依赖的package包/类
private void configureSwipe() {
if (isSwipeDisabled()) {
for (HandlerRegistration registration : touchHandlers) {
registration.removeHandler();
}
touchHandlers.clear();
setVisiblePageCount(1);
} else {
RootPanel rootPanel = rootPanelDelegate.getRootPanel();
HasTouchHandlers touchHandler = touchRecognitionFactory.getTouchRecognition(rootPanel, false);
touchHandlers.add(touchHandler.addTouchHandler(multiPageTouchHandler, TouchEvent.getType(TouchTypes.TOUCH_START)));
touchHandlers.add(touchHandler.addTouchHandler(multiPageTouchHandler, TouchEvent.getType(TouchTypes.TOUCH_MOVE)));
touchHandlers.add(touchHandler.addTouchHandler(multiPageTouchHandler, TouchEvent.getType(TouchTypes.TOUCH_END)));
setVisiblePageCount(3);
}
panelsCache.setSwipeType(swipeType.get());
}
示例2: removeHandler
import com.google.web.bindery.event.shared.HandlerRegistration; //导入依赖的package包/类
@Test
public void removeHandler() {
prepare();
// handler globalny
HandlerRegistration asyncRegistration = eventsBus.addAsyncHandler(PlayerEvent.getType(PlayerEventTypes.CREATE_MEDIA_WRAPPER), eventHandler);
// handler na scope
HandlerRegistration registration = eventsBus
.addHandler(PlayerEvent.getType(PlayerEventTypes.CREATE_MEDIA_WRAPPER), scopeEventHandler, new CurrentPageScope(0));
eventsBus.fireEvent(playerEvent);
Mockito.verify(eventHandler, Mockito.times(1)).onPlayerEvent(playerEvent);
Mockito.verify(scopeEventHandler, Mockito.times(1)).onPlayerEvent(playerEvent);
asyncRegistration.removeHandler();
registration.removeHandler();
eventsBus.fireEvent(playerEvent);
Mockito.verify(eventHandler, Mockito.times(1)).onPlayerEvent(playerEvent);
Mockito.verify(scopeEventHandler, Mockito.times(1)).onPlayerEvent(playerEvent);
}
示例3: dragStartHandlerTest
import com.google.web.bindery.event.shared.HandlerRegistration; //导入依赖的package包/类
@Test
public void dragStartHandlerTest() {
DragStartHandler dragStartHandler = mock(DragStartHandler.class);
ArgumentCaptor<DragStartEventWrapper> captor = ArgumentCaptor.forClass(DragStartEventWrapper.class);
when(draggableWidget.addDragStartHandler(Matchers.any(DragStartEventHandler.class))).then(new Answer<HandlerRegistration>() {
@Override
public HandlerRegistration answer(InvocationOnMock invocation) throws Throwable {
startHandler = (DragStartEventHandler) invocation.getArguments()[0];
return null;
}
});
doNothing().when(instance).setData(Matchers.anyString(), Matchers.anyString());
doReturn(null).when(instance).getData(Matchers.anyString());
instance.wrap(dragStartHandler);
startHandler.onDragStart(Mockito.mock(DragStartEvent.class));
verify(dragStartHandler).onDragStart(captor.capture());
DragStartEventWrapper event = captor.getValue();
event.setData("text", "text");
event.getData("text");
verify(instance).setData(Matchers.eq("text"), Matchers.eq("text"));
verify(instance).getData(Matchers.eq("text"));
}
示例4: dragEndHandlerTest
import com.google.web.bindery.event.shared.HandlerRegistration; //导入依赖的package包/类
@Test
public void dragEndHandlerTest() {
DragEndHandler endHandler = mock(DragEndHandler.class);
ArgumentCaptor<DragEndEventWrapper> captor = ArgumentCaptor.forClass(DragEndEventWrapper.class);
when(draggableWidget.addDragStopHandler(Matchers.any(DragStopEventHandler.class))).then(new Answer<HandlerRegistration>() {
@Override
public HandlerRegistration answer(InvocationOnMock invocation) throws Throwable {
stopHandler = (DragStopEventHandler) invocation.getArguments()[0];
return null;
}
});
doNothing().when(instance).setData(Matchers.anyString(), Matchers.anyString());
doReturn(null).when(instance).getData(Matchers.anyString());
instance.wrap(endHandler);
stopHandler.onDragStop(mock(DragStopEvent.class));
verify(endHandler).onDragEnd(captor.capture());
DragEndEventWrapper event = captor.getValue();
event.setData("text", "text");
event.getData("text");
verify(instance).setData(Matchers.eq("text"), Matchers.eq("text"));
verify(instance).getData(Matchers.eq("text"));
}
示例5: addConnectivityHandler
import com.google.web.bindery.event.shared.HandlerRegistration; //导入依赖的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: initialize
import com.google.web.bindery.event.shared.HandlerRegistration; //导入依赖的package包/类
/**
* Initialize this place history handler.
* @return a registration object to de-register the handler
*/
public HandlerRegistration initialize(final PlaceManager placeManager,
final EventBus eventBus,
final PlaceRequest defaultPlaceRequest) {
this.placeManager = placeManager;
this.defaultPlaceRequest = defaultPlaceRequest;
final HandlerRegistration historyReg =
historian.addValueChangeHandler(event -> {
//Temporarily disabled until https://issues.jboss.org/browse/AF-523 is ready
// handleHistoryToken(event.getValue());
});
return () -> {
PlaceHistoryHandler.this.defaultPlaceRequest = DefaultPlaceRequest.NOWHERE;
PlaceHistoryHandler.this.placeManager = null;
historyReg.removeHandler();
};
}
示例7: addDirtyHandler
import com.google.web.bindery.event.shared.HandlerRegistration; //导入依赖的package包/类
@Override
public HandlerRegistration addDirtyHandler(Handler handler) {
if (this.clickHandlerRegistration == null) {
this.clickHandlerRegistration = this.addDomHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
if (!InputBoolean.this.eventTargetsLabelOrChild(event)) {
InputBoolean.this.setInputValue(!InputBoolean.this.getInputValue());
}
DirtyEvent.fire(InputBoolean.this);
ValueChangeEvent.fire(InputBoolean.this, InputBoolean.this.getInputValue());
}
}, ClickEvent.getType());
}
return super.addDirtyHandler(handler);
}
示例8: postConstruct
import com.google.web.bindery.event.shared.HandlerRegistration; //导入依赖的package包/类
@PostConstruct
public void postConstruct() {
if (isSynchronizationNeeded()) { // powoduje problemy na
// mobilnych
// synchronizacja pomiedzy dwoma obiektami video
HandlerRegistration addHandlerToSource = eventsBus.addHandlerToSource(MediaEvent.getType(MediaEventTypes.ON_FULL_SCREEN_OPEN),
fullScreanMediaWrapper, this, pageScopeFactory.getCurrentPageScope());
handlersRegistration.add(addHandlerToSource);
addHandlerToSource = eventsBus.addHandlerToSource(MediaEvent.getType(MediaEventTypes.ON_FULL_SCREEN_EXIT), fullScreanMediaWrapper, this,
pageScopeFactory.getCurrentPageScope());
handlersRegistration.add(addHandlerToSource);
}
}
示例9: removeHandler
import com.google.web.bindery.event.shared.HandlerRegistration; //导入依赖的package包/类
protected void removeHandler(MediaEventTypes mediaEventType) {
Set<Entry<MediaEventTypes, HandlerRegistration>> handleRegistrationsEntrySet = handlerRegistrations.entrySet();
for (Entry<MediaEventTypes, HandlerRegistration> handlerRegistrationEntry : handleRegistrationsEntrySet) {
MediaEventTypes entryMediaEventType = handlerRegistrationEntry.getKey();
if (entryMediaEventType.equals(mediaEventType)) {
HandlerRegistration handlerRegistration = handlerRegistrationEntry.getValue();
handlerRegistration.removeHandler();
}
}
}
示例10: onAttachOrDetach
import com.google.web.bindery.event.shared.HandlerRegistration; //导入依赖的package包/类
@Override
public void onAttachOrDetach(AttachEvent event) {
if (event.isAttached()) {
final HandlerRegistration pauseHandlerRegistration = registerPauseHandlerOnPageChange();
this.handlerRegistration = Optional.of(pauseHandlerRegistration);
} else {
clearHandler();
}
}
示例11: addTouchHandlers
import com.google.web.bindery.event.shared.HandlerRegistration; //导入依赖的package包/类
@Override
public HandlerRegistration[] addTouchHandlers(TouchHandler handler, EventType<TouchHandler, TouchTypes>... events) {
for (EventType<TouchHandler, TouchTypes> event : events) {
addTouchHandlers((TouchTypes) event.getType());
}
return addHandlers(handler, events);
}
示例12: doAddAll
import com.google.web.bindery.event.shared.HandlerRegistration; //导入依赖的package包/类
private <H extends EventHandler, T extends Enum<T>> HandlerRegistration[] doAddAll(final EventType<H, T> types[], final Object source, final H handler,
final boolean async, final EventScope<?> eventScope) {
HandlerRegistration[] registrations = new HandlerRegistration[types.length];
for (int x = 0; x < types.length; ++x) {
registrations[x] = doAdd(types[x], source, handler, async, eventScope);
}
return registrations;
}
示例13: doAdd
import com.google.web.bindery.event.shared.HandlerRegistration; //导入依赖的package包/类
@SuppressWarnings({"unchecked", "rawtypes", "PMD"})
private <H extends EventHandler, T extends Enum<T>> HandlerRegistration doAdd(final EventType<H, T> type, final Object source, final H handler,
final boolean async, final EventScope<?> eventScope) {
if (type == null) {
throw new NullPointerException("Cannot add a handler with a null type");
}
if (handler == null) {
throw new NullPointerException("Cannot add a null handler");
}
Map<Object, Map<EventScope<?>, List<?>>> handlerMap = async ? asyncMap.get(type) : syncMap.get(type);
if (handlerMap == null) {
handlerMap = new HashMap<Object, Map<EventScope<?>, List<?>>>();
if (async) {
asyncMap.put(type, handlerMap);
} else {
syncMap.put(type, handlerMap);
}
}
Map<EventScope<?>, List<?>> handlersScope = handlerMap.get(source);
if (handlersScope == null) {
handlersScope = new HashMap<EventScope<?>, List<?>>();
handlerMap.put(source, handlersScope);
handlersScope.put(eventScope, new ArrayList());
}
List handlers = handlersScope.get(eventScope);
if (handlers == null) {
handlers = new ArrayList();
handlersScope.put(eventScope, handlers);
}
handlers.add(handler);
return new HandlerRegistration() {
@Override
public void removeHandler() {
doRemove(type, source, handler, eventScope, async);
}
};
}
示例14: fireDragEnterHandlerTest
import com.google.web.bindery.event.shared.HandlerRegistration; //导入依赖的package包/类
@Test
public void fireDragEnterHandlerTest() {
when(droppableWidget.addOverDroppableHandler(Matchers.any(OverDroppableEventHandler.class))).then(new Answer<HandlerRegistration>() {
@Override
public HandlerRegistration answer(InvocationOnMock invocation) throws Throwable {
droppableEventHandler = (OverDroppableEventHandler) invocation.getArguments()[0];
return null;
}
});
DragEnterHandler handler = mock(DragEnterHandler.class);
instance.wrap(handler);
droppableEventHandler.onOverDroppable(null);
verify(handler).onDragEnter(Matchers.any(DragEnterEvent.class));
}
示例15: fireDragLeaveHandlerTest
import com.google.web.bindery.event.shared.HandlerRegistration; //导入依赖的package包/类
@Test
public void fireDragLeaveHandlerTest() {
when(droppableWidget.addOutDroppableHandler(Matchers.any(OutDroppableEventHandler.class))).then(new Answer<HandlerRegistration>() {
@Override
public HandlerRegistration answer(InvocationOnMock invocation) throws Throwable {
outDroppableEventHandler = (OutDroppableEventHandler) invocation.getArguments()[0];
return null;
}
});
DragLeaveHandler handler = mock(DragLeaveHandler.class);
instance.wrap(handler);
outDroppableEventHandler.onOutDroppable(null);
verify(handler).onDragLeave(Matchers.any(DragLeaveEvent.class));
}