public BootDashUnifiedTreeSection(
     IPageWithSections owner, BootDashViewModel model, UserInteractions ui) {
   super(owner);
   Assert.isNotNull(ui);
   this.ui = ui;
   this.model = model;
   this.searchFilterModel = model.getFilter();
 }
 @Override
 public void dispose() {
   if (modelListener != null) {
     model.removeElementStateListener(modelListener);
     modelListener = null;
   }
   if (labelProvider != null) {
     labelProvider.dispose();
     labelProvider = null;
   }
   if (stylers != null) {
     stylers.dispose();
     stylers = null;
   }
 }
  @Override
  public void createContents(Composite page) {
    tv = new CustomTreeViewer(page, SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI);
    tv.setExpandPreCheckFilters(true);
    tv.setContentProvider(new BootDashTreeContentProvider());
    tv.setSorter(new BootModelViewerSorter(this.model));
    tv.setInput(model);
    tv.getTree().setLinesVisible(true);

    stylers = new Stylers(tv.getTree().getFont());
    tv.setLabelProvider(new BootDashTreeLabelProvider(stylers, tv));

    ColumnViewerToolTipSupport.enableFor(tv);

    GridDataFactory.fillDefaults().grab(true, true).applyTo(tv.getTree());

    new HiddenElementsLabel(page, tv.hiddenElementCount);

    tv.getControl()
        .addControlListener(
            new ControlListener() {
              public void controlResized(ControlEvent e) {
                ReflowUtil.reflow(owner, tv.getControl());
              }

              public void controlMoved(ControlEvent e) {}
            });

    actions = new BootDashActions(model, getSelection(), getSectionSelection(), ui);
    hookContextMenu();

    // Careful, either selection or tableviewer might be created first.
    // in either case we must make sure the listener is added when *both*
    // have been created.
    if (selection != null) {
      addViewerSelectionListener();
    }

    tv.addDoubleClickListener(
        new IDoubleClickListener() {
          public void doubleClick(DoubleClickEvent event) {
            if (selection != null) {
              BootDashElement selected = selection.getSingle();
              if (selected != null) {
                String url =
                    BootDashElementUtil.getUrl(selected, selected.getDefaultRequestMappingPath());
                if (url != null) {
                  UiUtil.openUrl(url);
                }
              } else if (sectionSelection.getValue() != null) {
                IAction openCloudAdminConsoleAction = actions.getOpenCloudAdminConsoleAction();
                if (openCloudAdminConsoleAction != null) {
                  openCloudAdminConsoleAction.run();
                }
              }
            }
          }
        });

    model.getRunTargets().addListener(RUN_TARGET_LISTENER);
    model.getSectionModels().addListener(ELEMENTS_SET_LISTENER_ADAPTER);

    model.addElementStateListener(ELEMENT_STATE_LISTENER);

    if (searchFilterModel != null) {
      searchFilterModel.addListener(FILTER_LISTENER);
      tv.addFilter(
          new ViewerFilter() {
            @Override
            public boolean select(Viewer viewer, Object parentElement, Object element) {
              if (searchFilterModel.getValue() != null && element instanceof BootDashElement) {
                return searchFilterModel.getValue().accept((BootDashElement) element);
              }
              return true;
            }
          });
    }

    tv.getTree()
        .addDisposeListener(
            new DisposeListener() {
              @Override
              public void widgetDisposed(DisposeEvent e) {
                model.removeElementStateListener(ELEMENT_STATE_LISTENER);
                model.getRunTargets().removeListener(RUN_TARGET_LISTENER);
                model.getSectionModels().removeListener(ELEMENTS_SET_LISTENER_ADAPTER);
                for (BootDashModel m : model.getSectionModels().getValue()) {
                  m.removeModelStateListener(MODEL_STATE_LISTENER);
                }

                if (searchFilterModel != null) {
                  searchFilterModel.removeListener(FILTER_LISTENER);
                }

                if (actions != null) {
                  actions.dispose();
                  actions = null;
                }
                if (stylers != null) {
                  stylers.dispose();
                  stylers = null;
                }
              }
            });

    addDragSupport(tv);
    addDropSupport(tv);
  }
  @Override
  public void createContents(final Composite page) {
    this.page = page;
    this.tv = new TableViewer(page, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL);
    tv.setContentProvider(new ContentProvider());
    tv.setSorter(sorter);
    //		tv.setLabelProvider(labelProvider = new RequestMappingLabelProvider(tv.getTable().getFont(),
    // input));
    tv.setInput(model);
    tv.getTable().setHeaderVisible(true);
    stylers = new Stylers(tv.getTable().getFont());

    for (RequestMappingsColumn colType : RequestMappingsColumn.values()) {
      TableViewerColumn col = new TableViewerColumn(tv, colType.getAlignment());
      col.setLabelProvider(new RequestMappingLabelProvider(stylers, input, colType));
      TableColumn colWidget = col.getColumn();
      colWidget.setText(colType.getLabel());
      colWidget.setWidth(colType.getDefaultWidth());
    }

    GridDataFactory.fillDefaults().grab(true, true).applyTo(tv.getTable());
    this.input.addListener(
        new UIValueListener<BootDashElement>() {
          public void uiGotValue(LiveExpression<BootDashElement> exp, BootDashElement value) {
            if (!tv.getControl().isDisposed()) {
              tv.setInput(value);
            }
          }
        });
    tv.getTable()
        .addControlListener(
            new ControlListener() {
              public void controlResized(ControlEvent e) {
                ReflowUtil.reflow(owner, tv.getControl());
              }

              @Override
              public void controlMoved(ControlEvent e) {}
            });
    tv.addDoubleClickListener(
        new IDoubleClickListener() {
          public void doubleClick(DoubleClickEvent event) {
            IStructuredSelection sel = (IStructuredSelection) event.getSelection();
            Object clicked = sel.getFirstElement();
            if (clicked instanceof RequestMapping) {
              RequestMapping rm = (RequestMapping) clicked;
              BootDashElement el = input.getValue();
              String url = getUrl(el, rm);
              if (url != null) {
                openUrl(url);
              }
              //					MessageDialog.openInformation(page.getShell(), "clickety click!",
              //							"Double-click on : "+ clicked);
            }
          }
        });
    model.addElementStateListener(
        modelListener =
            new ElementStateListener() {
              public void stateChanged(BootDashElement e) {
                if (e.equals(input.getValue())) {
                  if (!tv.getControl().isDisposed()) {
                    tv.getControl()
                        .getDisplay()
                        .asyncExec(
                            new Runnable() {
                              public void run() {
                                if (!tv.getControl().isDisposed()) {
                                  tv.refresh();
                                  page.layout(new Control[] {tv.getControl()});
                                }
                              }
                            });
                  }
                }
              }
            });
  }