com.google.web.bindery.event.shared.SimpleEventBus Java Examples

The following examples show how to use com.google.web.bindery.event.shared.SimpleEventBus. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ImportBatchItemEditor.java    From proarc with GNU General Public License v3.0 6 votes vote down vote up
private Canvas initDigitalObjectEditor(DigitalObjectEditor childEditor, SimpleEventBus eventBus) {
    childEditor.setImportView(true);
    RelationDataSource relationDataSource = RelationDataSource.getInstance();
    relationDataSource.addRelationChangeHandler(new RelationChangeHandler() {

        @Override
        public void onRelationChange(RelationChangeEvent event) {
            // issue 262: isVisible seems to be always true and isAttached is always null.
            // Add test isDrawn that seems to change for dettached widgets.
            if (batchItemGrid.isVisible() && batchItemGrid.isDrawn()) {
                updateCache();
            }
        }
    });
    ActivityManager activityManager = new ActivityManager(
            new ChildActivities(childEditor), eventBus);

    VLayout editorsLayout = new VLayout();
    editorsLayout.addStyleName("defaultBorder");
    activityManager.setDisplay(new ChildEditorDisplay(editorsLayout));
    return editorsLayout;
}
 
Example #2
Source File: EditorWorkFlow.java    From proarc with GNU General Public License v3.0 6 votes vote down vote up
public EditorWorkFlow(EventBus ebus, PlaceController placeController,
        ActivityManager activityManager, Layout delegate,
        PresenterFactory presenterFactory, ClientMessages i18n) {

    this.presenterFactory = presenterFactory;
    this.i18n = i18n;
    this.ebus = (ebus != null) ? ebus : new SimpleEventBus();
    // PlaceController uses delegate to ask user with blocking Window.confirm
    // whether to leave the current place.
    // In order to use non blocking SmartGWT dialog
    // it will be necessary to override PlaceController.goto method.
    this.placeController = (placeController != null) ? placeController
            : new PlaceController(this.ebus);
    this.activityManager = (activityManager != null) ? activityManager
            : new ActivityManager(new EditorActivityMapper(), this.ebus);
    this.activityManager.setDisplay(new EditorDisplay(delegate));
    EditorPlaceHistoryMapper historyMapper = GWT.create(EditorPlaceHistoryMapper.class);
    placeHistoryHandler = new PlaceHistoryHandler(historyMapper);
    placeHistoryHandler.register(this.placeController, this.ebus, Place.NOWHERE);
}
 
Example #3
Source File: ApplicationClientModule.java    From bitcoin-transaction-explorer with MIT License 6 votes vote down vote up
@Override
protected void configure() {
  // Binding application critical architecture
  bind(ActivityMapper.class).to(ApplicationActivityMapper.class).in(Singleton.class);;
  bind(Place.class).annotatedWith(DefaultPlace.class).to(StartupPlace.class).in(Singleton.class);
  bind(PlaceController.class).to(ApplicationPlaceController.class).in(Singleton.class);
  bind(BitcoinPlaceRouter.class).to(ApplicationPlaceController.class).in(Singleton.class);
  bind(PlaceHistoryMapper.class).to(ApplicationPlaceHistoryMapper.class).in(Singleton.class);
  bind(EventBus.class).to(SimpleEventBus.class).in(Singleton.class);
  bind(ColorPicker.class).to(SimpleColorPicker.class).in(Singleton.class);

  // Binding views
  bind(StartupView.class).to(StartupViewImpl.class).in(Singleton.class);
  bind(TransactionView.class).to(TransactionViewImpl.class);
  bind(BlockView.class).to(BlockViewImpl.class);
  bind(MineView.class).to(MineViewImpl.class);
  bind(ScriptView.class).to(ScriptViewImpl.class);
  bind(ConfigView.class).to(ConfigViewImpl.class);
  bind(ContributeView.class).to(ContributeViewImpl.class);
  bind(RPCResponseView.class).to(RPCResponseViewImpl.class);
  bind(AddressView.class).to(AddressViewImpl.class);

  install(new GinFactoryModuleBuilder().build(ActivityFactory.class));
}
 
Example #4
Source File: ApplicationRootView.java    From bitcoin-transaction-explorer with MIT License 6 votes vote down vote up
@Inject
public ApplicationRootView(final PlaceHistoryMapper historyMapper, final PlaceController placeController, final UserApplicationConfig appConfig,
    NotificationPanel notificationPanel, ThemeSwitcher themeSwitcher) {
  this.placeController = placeController;
  this.notificationPanel = notificationPanel;
  this.themeSwitcher = themeSwitcher;

  EventBus simpleEventBus = new SimpleEventBus();

  notificationPanel.setEventBus(simpleEventBus);
  NotificationUtil.setEventBus(simpleEventBus);

  initWidget(UI_BINDER.createAndBindUi(this));

  applicationTitle.setText(appConfig.getApplicationTitle());
  applicationSubTitle.setText(appConfig.getApplicationSubTitle());

  contributeLink.setHref("#" + historyMapper.getToken(new ContributePlace()));
}
 
Example #5
Source File: EventBinderTest.java    From gwteventbinder with Apache License 2.0 6 votes vote down vote up
public void testEventBinder() {
  EventBus eventBus = new SimpleEventBus();
  TestPresenter presenter = new TestPresenter();
  TestPresenter.MyEventBinder binder = GWT.create(TestPresenter.MyEventBinder.class);
  binder.bindEventHandlers(presenter, eventBus);

  // Test one event
  assertEquals(0, presenter.firstEventsHandled);
  eventBus.fireEvent(new FirstEvent());
  assertEquals(1, presenter.firstEventsHandled);
  assertEquals(1, presenter.firstEventsWithoutParameterHandled);
  assertEquals(1, presenter.firstAndSecondEventsHandled);

  // Test another event twice
  assertEquals(0, presenter.secondEventsHandled);
  eventBus.fireEvent(new SecondEvent());
  eventBus.fireEvent(new SecondEvent());
  assertEquals(2, presenter.secondEventsHandled);
  assertEquals(3, presenter.firstAndSecondEventsHandled);
}
 
Example #6
Source File: EventBinderTest.java    From gwteventbinder with Apache License 2.0 6 votes vote down vote up
public void testEventBinder_withHandlersInSuperclass() {
  EventBus eventBus = new SimpleEventBus();
  SubPresenter presenter = new SubPresenter();
  SubPresenter.MyEventBinder binder = GWT.create(SubPresenter.MyEventBinder.class);
  binder.bindEventHandlers(presenter, eventBus);

  eventBus.fireEvent(new FirstEvent());
  eventBus.fireEvent(new SecondEvent());
  eventBus.fireEvent(new ThirdEvent());

  // FirstEvent has a handler in both classes, so it should be handled twice
  assertEquals(1, presenter.firstEventsHandled);
  assertEquals(1, presenter.firstEventsWithoutParameterHandled);
  assertEquals(1, presenter.subclassFirstEventsHandled);

  // SecondEvent's handler is overridden in the subclass, so it should only be handled there
  assertEquals(0, presenter.secondEventsHandled);
  assertEquals(1, presenter.subclassSecondEventsHandled);

  // ThirdEvent is only handled in the superclass
  assertEquals(1, presenter.thirdEventsHandled);

  // First+Second events are handled in superclass
  assertEquals(2, presenter.firstAndSecondEventsHandled);
}
 
Example #7
Source File: InteractionCoordinator.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Inject
public InteractionCoordinator(Dialog dialog, StatementContext parentContext, NavigationDelegate navigationDelegate) {
    this.dialog = dialog;
    this.bus = new SimpleEventBus();
    this.navigationDelegate = navigationDelegate;
    this.dialogState = new DialogState(dialog, parentContext, this);

    // coordinator handles all events except presentation & system events
    bus.addHandler(InteractionEvent.TYPE, this);
    bus.addHandler(NavigationEvent.TYPE, this);
    bus.addHandler(StatementEvent.TYPE, this);

    // global procedures

    addProcedure(new SelectStatementProcedure(this));
    addProcedure(new ActivationProcedure(this));
    addProcedure(new NavigationProcedure(this));

}
 
Example #8
Source File: DigitalObjectEditor.java    From proarc with GNU General Public License v3.0 5 votes vote down vote up
private OptionalEditor(ClientMessages i18n, Layout previewContainer) {
    SimpleEventBus eventBus = new SimpleEventBus();
    embeddedPlaces = new PlaceController(eventBus);
    DigitalObjectEditor embeddedEditor = new DigitalObjectEditor(i18n, embeddedPlaces, true);
    embeddedEditor.setOptionalView(true);
    ActivityManager activityManager = new ActivityManager(
            new ChildActivities(embeddedEditor), eventBus);
    activityManager.setDisplay(new ChildEditorDisplay(previewContainer));
}
 
Example #9
Source File: EventBinderTest.java    From gwteventbinder with Apache License 2.0 5 votes vote down vote up
public void testEventBinder_unbindEventHandlers() {
  EventBus eventBus = new SimpleEventBus();
  TestPresenter presenter = new TestPresenter();
  TestPresenter.MyEventBinder binder = GWT.create(TestPresenter.MyEventBinder.class);
  HandlerRegistration registration = binder.bindEventHandlers(presenter, eventBus);
  assertEquals(0, presenter.firstEventsHandled);
  assertEquals(0, presenter.firstEventsWithoutParameterHandled);
  assertEquals(0, presenter.secondEventsHandled);

  // Before unregistering
  eventBus.fireEvent(new FirstEvent());
  eventBus.fireEvent(new SecondEvent());
  assertEquals(1, presenter.firstEventsHandled);
  assertEquals(1, presenter.firstEventsWithoutParameterHandled);
  assertEquals(1, presenter.secondEventsHandled);
  assertEquals(2, presenter.firstAndSecondEventsHandled);

  // After unregistering
  registration.removeHandler();
  eventBus.fireEvent(new FirstEvent());
  eventBus.fireEvent(new SecondEvent());
  assertEquals(1, presenter.firstEventsHandled);
  assertEquals(1, presenter.firstEventsWithoutParameterHandled);
  assertEquals(1, presenter.secondEventsHandled);
  assertEquals(2, presenter.firstAndSecondEventsHandled);

  // After re-registering
  binder.bindEventHandlers(presenter, eventBus);
  eventBus.fireEvent(new FirstEvent());
  eventBus.fireEvent(new SecondEvent());
  assertEquals(2, presenter.firstEventsHandled);
  assertEquals(2, presenter.firstEventsWithoutParameterHandled);
  assertEquals(2, presenter.secondEventsHandled);
  assertEquals(4, presenter.firstAndSecondEventsHandled);
}
 
Example #10
Source File: EventBinderTest.java    From gwteventbinder with Apache License 2.0 5 votes vote down vote up
public void testEventBinder_withLegacyEventBus() {
  com.google.gwt.event.shared.EventBus eventBus =
      new com.google.gwt.event.shared.SimpleEventBus();
  TestPresenter presenter = new TestPresenter();
  TestPresenter.MyEventBinder binder = GWT.create(TestPresenter.MyEventBinder.class);
  binder.bindEventHandlers(presenter, eventBus);

  assertEquals(0, presenter.firstEventsHandled);
  eventBus.fireEvent(new FirstEvent());
  assertEquals(1, presenter.firstEventsHandled);
}
 
Example #11
Source File: EventBinderTest.java    From gwteventbinder with Apache License 2.0 5 votes vote down vote up
public void testEventBinder_inDifferentPackage() {
  EventBus eventBus = new SimpleEventBus();
  TestPresenter presenter = new TestPresenter();
  SomeActivity.SomeEventBinder binder = GWT.create(SomeActivity.SomeEventBinder.class);
  binder.bindEventHandlers(presenter, eventBus);

  // Test one event
  assertEquals(0, presenter.firstEventsHandled);
  eventBus.fireEvent(new FirstEvent());
  assertEquals(1, presenter.firstEventsHandled);
}
 
Example #12
Source File: GroupValidator.java    From gwt-material with Apache License 2.0 4 votes vote down vote up
/**
 * Constructor.
 */
public GroupValidator() {
    fields = new LinkedHashMap<>();
    registrations = new LinkedHashMap<>();
    eventBus = new SimpleEventBus();
}
 
Example #13
Source File: DigitalObjectChildrenEditor.java    From proarc with GNU General Public License v3.0 4 votes vote down vote up
public DigitalObjectChildrenEditor(ClientMessages i18n, PlaceController places, OptionalEditor preview) {
        this.i18n = i18n;
        this.places = places;
        this.preview = preview;
        this.actionSource = new ActionSource(this);
        this.goDownAction = DigitalObjectNavigateAction.child(i18n, places);
        relationDataSource = RelationDataSource.getInstance();
        childrenListGrid = initChildrenListGrid();
        this.selectionCache = SelectionCache.selector(childrenListGrid);
        VLayout childrenLayout = new VLayout();
        childrenLayout.setMembers(childrenListGrid);
        childrenLayout.setWidth("40%");
        childrenLayout.setShowResizeBar(true);

        SimpleEventBus eventBus = new SimpleEventBus();
        childPlaces = new PlaceController(eventBus);
        childEditor = new DigitalObjectEditor(i18n, childPlaces, true);
        ActivityManager activityManager = new ActivityManager(
                new ChildActivities(childEditor), eventBus);

        VLayout editorsLayout = new VLayout();
        VLayout editorsOuterLayout = new VLayout();
//        editorsLayout.setBorder("1px solid grey");
        editorsLayout.addStyleName("defaultBorder");
        editorsOuterLayout.setLayoutLeftMargin(4);
        editorsOuterLayout.setMembers(editorsLayout);
        activityManager.setDisplay(new ChildEditorDisplay(editorsLayout));

        widget = new HLayout();
        widget.setMembers(childrenLayout, editorsOuterLayout);
        relationDataSource.addRelationChangeHandler(new RelationChangeHandler() {

            @Override
            public void onRelationChange(RelationChangeEvent event) {
                // issue 262: isVisible seems to be always true and isAttached is always null.
                // Add test isDrawn that seems to change for dettached widgets.
                if (digitalObject != null && childrenListGrid.isVisible() && childrenListGrid.isDrawn()) {
                    String changedPid = event.getPid();
                    if (changedPid != null) {
                        Record changedRecord = childrenListGrid.getDataAsRecordList()
                                .find(RelationDataSource.FIELD_PID, changedPid);
                        if (changedRecord == null) {
                            // moved object(s)
                            // ListGrid does not remove selection of removed/moved rows
                            // and it does not fire selection change
                            // issue 246: clear selection of moved row
                            childrenListGrid.deselectAllRecords();
                            DigitalObjectCopyMetadataAction.resetSelection();
                            showCopySelection(new Record[0]);
                            return ;
                        }
                    }
                    final ListGridRecord[] selection = childrenListGrid.getSelectedRecords();
                    relationDataSource.updateCaches(digitalObject.getPid(), new BooleanCallback() {

                        @Override
                        public void execute(Boolean value) {
                            // refresh the copy selection as updated records are missing the copy attribute
                            showCopySelection(DigitalObjectCopyMetadataAction.getSelection());
                            // refresh the list selection
                            selectChildren(selection);
                        }
                    });
                }
            }
        });
    }
 
Example #14
Source File: ImportBatchItemEditor.java    From proarc with GNU General Public License v3.0 4 votes vote down vote up
public ImportBatchItemEditor(ClientMessages i18n) {
        this.i18n = i18n;
        this.setHeight100();
        this.setWidth100();
        this.actionSource = new ActionSource(this);
        
        VLayout layout = new VLayout();
        layout.setShowResizeBar(true);
        layout.setResizeBarTarget("next");

        batchItemGrid = createItemList();
        layout.addMember(batchItemGrid);

        // child editors
        SimpleEventBus eventBus = new SimpleEventBus();
        childPlaces = new PlaceController(eventBus);
        childEditor = new DigitalObjectEditor(i18n, childPlaces, true);
        childDisplay = initDigitalObjectEditor(childEditor, eventBus);
        layout.addMember(childDisplay);

        HLayout editorThumbLayout = new HLayout();
        editorThumbLayout.setHeight100();
        editorThumbLayout.addMember(layout);

        thumbViewer = createThumbViewer();
        editorThumbLayout.addMember(thumbViewer);

        this.selectionCache = new SelectionCache<>(
                Optional.empty(),
                r -> batchItemGrid.getRecordIndex(r));

        VLayout editorThumbToolbarLayout = new VLayout();
        editorThumbToolbarLayout.setShowResizeBar(true);
        editorThumbToolbarLayout.setResizeBarTarget("next");

        createActions();
        ToolStrip editorToolStrip = createEditorToolBar(actionSource);
        editorThumbToolbarLayout.addMember(editorToolStrip);
        editorThumbToolbarLayout.addMember(editorThumbLayout);

        addMember(editorThumbToolbarLayout);

        digitalObjectPreview = new MediaEditor(i18n, MediaEditor.SOURCE_IMPORT_BATCH_ITEM_EDITOR);
        digitalObjectPreview.addBackgroundColorListeners(thumbViewer);
        digitalObjectPreview.setShowRefreshButton(true);
        ToolStrip previewToolbar = Actions.createToolStrip();
        previewToolbar.setMembers(digitalObjectPreview.getToolbarItems());
        VLayout previewLayout = new VLayout();
        previewLayout.setMembers(previewToolbar, digitalObjectPreview.getUI());
        previewLayout.setWidth("40%");
        previewLayout.setHeight100();
//        previewLayout.setShowResizeBar(true);
//        previewLayout.setResizeFrom("L");
        addMember(previewLayout);
        createEditorContextMenu(batchItemGrid.getContextMenu(), this);
        createEditorContextMenu(thumbViewer.getContextMenu(), this);
    }
 
Example #15
Source File: EventBasedWebSocketListener.java    From gwt-websockets with Apache License 2.0 4 votes vote down vote up
/**
 * Construct the listener using a SimpleEventBus.
 */
public EventBasedWebSocketListener()
{
  this( new SimpleEventBus() );
}
 
Example #16
Source File: Html5ApplicationCache.java    From gwt-appcache with Apache License 2.0 4 votes vote down vote up
public Html5ApplicationCache()
{
  this( new SimpleEventBus() );
}