title: Programmatically Fire a RCP Selection Event
body: <p>In my Eclipse RCP application I use the Selection Service as described in this nice <a href="http://www.eclipse.org/articles/Article-WorkbenchSelections/article.html" rel="noreferrer">article</a>. There is a <em>TreeViewer</em> in one view registered as a <em>SelectionProvider</em>:</p>
  
  <p><code>getSite().setSelectionProvider(viewer);</code></p>
  
  <p>Another view is receiving the events from the <em>TreeViewer</em>:</p>
  
  <pre><code>selectionListener = new ISelectionListener() {
    public void selectionChanged(IWorkbenchPart part, ISelection selection) {
      pageSelectionChanged(part, selection);
    }
   };
   getSite().getPage().addSelectionListener(selectionListener);
  </code></pre>
  
  <p>Everything works fine, if the events are triggered my normal mouse clicks. I would like to programmatically fire a selection events by selection an item in the tree:</p>
  
  <pre><code>treeViewer.setSelection(new StructuredSelection(element),true);
  </code></pre>
  
  <p>This is not working. Method <em>selectionChanged</em> is not called in the receiver-view. The issue is discussed in this <a href="http://www.eclipse.org/forums/index.php/m/328232/" rel="noreferrer">forum thread</a>. There is no solution.</p>
  
  <p><strong>EDIT</strong> </p>
  
  <p>There is no proper way to handle a mouse triggered click the same way as a programmatically selection. A mouse click activates the view a programmatically selection does not.</p>
  
  <p>My Solution is to register the second view the same way by <code>Selection Service</code> as the first view. After that both view are getting selection events directly from the active editor.</p>