Bug 428818 - @EventTopic only works with Fields and Parameters ond post requires data
Summary: @EventTopic only works with Fields and Parameters ond post requires data
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Runtime (show other bugs)
Version: 4.4   Edit
Hardware: Macintosh Mac OS X
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Platform-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-02-22 06:05 EST by Roger Gilliar CLA
Modified: 2014-02-24 10:24 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Roger Gilliar CLA 2014-02-22 06:05:16 EST
It would be nice if @EventTopic  would work with methods. Sometimes I just want to use an event as an trigger. For example I want to send an event if the undo is complete (no more command in the command stack). Right now I have to do something like: 

eventBroker.post(TOPIC_UNDO_COMPLETE, new PlaceHolderObject());

I would prefer to just call

eventBroker.post(TOPIC_UNDO_COMPLETE);
Comment 1 Paul Webster CLA 2014-02-22 06:31:14 EST
it's valid to use eventBroker.post(TOPIC,null);

As long as your method has @Optional @EventTopic it should get called.

PW
Comment 2 Roger Gilliar CLA 2014-02-22 06:45:30 EST
Yes it gets called, 

but I still have to declare the method like this:

@Inject
@Optional
public void test(@UIEventTopic("test") String notNeeded) {
   System.out.println(notNeeded);
}

I think it would be cleaner if we can just write:

@Inject
@UIEventTopic("test")
public void test() {
   System.out.println("received");
}

And just looking at the 'eventBroker.post(TOPIC,null)' call gives me no indication if the message should send null or should send nothing.
Comment 3 Paul Webster CLA 2014-02-24 10:24:17 EST
(In reply to Roger Gilliar from comment #2)
> Yes it gets called, 
> 
> but I still have to declare the method like this:
> 
> @Inject
> @Optional
> public void test(@UIEventTopic("test") String notNeeded) {
>    System.out.println(notNeeded);
> }

That's because we're using an object supplier to allow a DIed object to receive events.

> 
> I think it would be cleaner if we can just write:
> 
> @Inject
> @UIEventTopic("test")
> public void test() {
>    System.out.println("received");
> }

What you want is a way to trigger a method call against a DI object.  I'll leave this open as an enhancement, but I don't know how appropriate it is for the DI system to support this.

> 
> And just looking at the 'eventBroker.post(TOPIC,null)' call gives me no
> indication if the message should send null or should send nothing.

That's because IEventBroker knows it's firing events, it knows nothing about the @EventTopic add-on that tries to funnel events through the DI system.  Arguably the @EventTopic/@UIEventTopic should be the place to specify the pre/post conditions for success.

PW