Exemple #1
0
  @Override
  public Control createControl(Composite parent) {
    SashForm sash = new SashForm(parent, SWT.HORIZONTAL);
    sash.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));

    Composite container = new Composite(sash, SWT.NONE);
    container.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));

    treeMap = new TreeMap<TaxonomyNode>(container);
    treeMap.setTreeMapLayout(new SquarifiedLayout<TaxonomyNode>(10));
    treeMap.setLabelProvider(
        new ILabelProvider<TaxonomyNode>() {
          @Override
          public String getLabel(
              ITreeModel<IRectangle<TaxonomyNode>> model, IRectangle<TaxonomyNode> rectangle) {
            return rectangle.getNode().getName();
          }
        });

    legend = new TreeMapLegend(container, treeMap, getModel(), getRenderer());

    final SecurityDetailsViewer details =
        new SecurityDetailsViewer(sash, SWT.NONE, getModel().getClient(), true);
    treeMap.addSelectionChangeListener(
        new ISelectionChangeListener<TaxonomyNode>() {
          @Override
          public void selectionChanged(
              ITreeModel<IRectangle<TaxonomyNode>> model,
              IRectangle<TaxonomyNode> rectangle,
              String label) {
            TaxonomyNode node = rectangle.getNode();
            details.setInput(node.getBackingSecurity());
          }
        });

    // layout tree map + legend
    GridLayoutFactory.fillDefaults().numColumns(1).margins(10, 10).applyTo(container);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(treeMap);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(legend);

    // layout sash
    details.getControl().pack();
    int width = details.getControl().getBounds().width;
    sash.setWeights(new int[] {parent.getParent().getParent().getBounds().width - width, width});

    treeMap.setRectangleRenderer(new ClassificationRectangleRenderer(getModel(), getRenderer()));
    treeMap.setTreeModel(new Model(getModel().getRootNode()));
    legend.setRootItem(getModel().getRootNode());

    return sash;
  }
Exemple #2
0
 @Override
 public void nodeChange(TaxonomyNode node) {
   treeMap.setTreeModel(new Model(getModel().getRootNode()));
   legend.setRootItem(getModel().getRootNode());
 }