Search code examples
javaswteclipse-rcpe4

IEventBroker doesn't sent event in java


I want to send success message by IEventBroker and listen it from another class. I could not handle the message from listener function. What can be its cause?

I sent the message by this line :

eventBroker.post(IBackupRestoreEventConstants.TOPIC_BACKUP_SUCCESS, new Date());

I want to handle in this function:

@Inject
@Optional
public void whenBackupSuccess(@UIEventTopic(IBackupRestoreEventConstants.TOPIC_BACKUP_SUCCESS) long timeStamp) {
    MessageDialog.openInformation(shell, "Information", "Backup operation completed successfully");
}

Solution

  • You are posting an event with a Date value but you are using long as the argument in whenBackupSuccess, the event broker will not do this conversion for you. Since the method is @Optional it will just be ignored.

    Use Date in whenBackupSuccess:

    @Inject
    @Optional
    public void whenBackupSuccess(@UIEventTopic(IBackupRestoreEventConstants.TOPIC_BACKUP_SUCCESS) Date timeStamp)