0

In ViewA, I have a panel within a frame being displayed. When I click on an object within this panel, I would like to send the object to a function in ViewB.

public class ViewA extends ViewPart{

    public void createPartControl(Composite parent) {

          Composite swtAwtComponent = new Composite(parent, SWT.EMBEDDED);
          java.awt.Frame frame = SWT_AWT.new_Frame( swtAwtComponent );
          javax.swing.JPanel panel = new javax.swing.JPanel( );
           ...
     }
}


public class ViewB extends ViewPart{

...

        public void foo(Object o){
        }

}

I have seen many questions here regarding communicating between two views, using an ISelectionListener, and a link to the vogella tutorials on commands such as; Eclipse RCP let two views communicate, Eclipse RCP update a View after changes in the editor etc. However, every question's solution assumes the triggering event is a selection within a TableViewer (or any viewer) and not within a Frame/Panel mousePressed event. Please help.

Community
  • 1
  • 1
Sterls
  • 723
  • 12
  • 22
  • Implement your own `ISelectionProvider` for ViewA and set the selection on each mouse press event. – greg-449 Aug 07 '15 at 19:53
  • @greg-449 To test if the event is firing: In my ViewA creatPartControl function, I have: ' getSite().setSelectionProvider(this); ISelectionProvider selectionProvider = getViewSite().getSelectionProvider(); selectionProvider.setSelection(new StructuredSelection("test"));' And in ViewB createPartControl which implements ISelectionListener: 'getViewSite().getPage().addSelectionListener("version1.views.ViewA",(ISelectionListener)this); getViewSite().getPage().addSelectionListener(this);' I am not detecting the firing of the event although it is set to fire when the view is loaded. – Sterls Aug 11 '15 at 17:45

0 Answers0