SHARE
TWEET

Untitled

a guest May 6th, 2012 101 Never
  1. public class PublishView
  2. {
  3.     @Inject
  4.     private IEventBroker eventBroker;
  5.    
  6.     @PostConstruct
  7.     public void createPartControl(Composite parent)
  8.     {
  9.         Button button = new Button(parent, SWT.PUSH);
  10.         button.setText("Publish!");
  11.         button.addSelectionListener(new SelectionListener() {
  12.             @Override
  13.             public void widgetSelected(SelectionEvent e)
  14.             {
  15.                 System.out.format("Publishing on foo\n");
  16.                 eventBroker.send("foo", "Hello");
  17.             }
  18.  
  19.             ...
  20.         });
  21.     }
  22. }
  23.  
  24. public class PublishViewPart extends DIViewPart<PublishView>
  25. {
  26.     public PublishViewPart()
  27.     {
  28.         super(PublishView.class);
  29.     }
  30. }
  31.  
  32. public class SubscribeView
  33. {
  34.     ...
  35.    
  36.     @Inject
  37.     public void handleFoo(@EventTopic("foo") Object data) {
  38.         System.out.format("Received foo: %s\n", data);
  39.     }
  40. }
  41.  
  42. public class SubscribeViewPart extends DIViewPart<SubscribeView>
  43. {
  44.     public SubscribeViewPart()
  45.     {
  46.         super(SubscribeView.class);
  47.     }
  48. }
RAW Paste Data
Top