title: Dynamic refresh of a composite
body: <p>I have a tree viewer next to a specialized viewer. When something is selected in the tree viewer, details about this object are shown in the specialized viewer. <code>TreeViewer tree</code>, <code>Composite control</code>, and <code>MySpecializedViewer viewer</code> are instance variables.</p>
  
  <pre><code>public TheEverythingViewer(Composite parent) {
      control = new Composite(parent, SWT.NONE);
      control.setLayout(new GridLayout(2, false));
  
      tree = new TreeViewer(control);
      tree.setContentProvider(new MyContentProvider());
      tree.setLabelProvider(new MyLabelProvider());
      tree.setUseHashlookup(true);
      tree.getControl().setLayoutData(new GridData(GridData.BEGINNING, GridData.FILL, false, true, 1, 1));
  
      tree.addSelectionChangedListener(new ISelectionChangedListener() {
          @Override public void selectionChanged(SelectionChangedEvent event) {
              try {
                  IStructuredSelection sel = (IStructuredSelection) event.getSelection();
                  MyClass myInput = (MyClass) sel.getFirstElement();
  
                  if (viewer != null)
                      if (!viewer.getControl().isDisposed())
                          viewer.getControl().dispose();
                  viewer = new MySpecializedViewer(control, table);
  
                  control.getShell().layout();
              } catch (Exception e) {
                  if (viewer != null)
                      if (!viewer.getControl().isDisposed())
                          viewer.getControl().dispose();
                  viewer = null;
              }
          }
      });
  }
  </code></pre>
  
  <p>Am I doing something wrong? I just want:</p>
  
  <pre><code>+--------------+--------------------------------------------+
  | + Node       |                                            |
  |   - Node     |                                            |
  |   + Node     |                       My                   |
  |     - Node   |                                            |
  |   - Node     |      Specialized                           |
  |              |                              Viewer        |
  |              |                                            |
  |              |                                            |
  |              |                                            |
  |              |                                            |
  |              |                                            |
  |              |                                            |
  |              |                +--------+                  |
  |              |                |        |                  |
  |              |                |        |                  |
  |              |                |        |                  |
  |              |                +--------+                  |
  |              |                                            |
  |              |                                            |
  |              |                                            |
  |              |                                            |
  +--------------+--------------------------------------------+
  </code></pre>
  
  <p>The specialized viewer has tables that need to consume more or less space depending on the selected node. And currently, creating a new instance of the specialized viewer is much, much simpler than changing it's input (that wouldn't work ATM).</p>