Search in sources :

Example 1 with SecurityDetailsViewer

use of name.abuchen.portfolio.ui.views.SecurityDetailsViewer in project portfolio by buchen.

the class TreeMapViewer method createControl.

@Override
public Control createControl(Composite parent) {
    Composite sash = new Composite(parent, SWT.NONE);
    sash.setLayout(new SashLayout(sash, SWT.HORIZONTAL | SWT.END));
    Composite container = new Composite(sash, SWT.NONE);
    container.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
    treeMap = new TreeMap<>(container);
    treeMap.setTreeMapLayout(new SquarifiedLayout<TaxonomyNode>(10));
    treeMap.setLabelProvider((model, rectangle) -> rectangle.getNode().getName());
    legend = new TreeMapLegend(container, treeMap, getModel(), getRenderer());
    final SecurityDetailsViewer details = new SecurityDetailsViewer(sash, SWT.NONE, getModel().getClient(), true);
    treeMap.addSelectionChangeListener((model, rectangle, 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().setLayoutData(new SashLayoutData(SWTHelper.getPackedWidth(details.getControl())));
    treeMap.setRectangleRenderer(new ClassificationRectangleRenderer(getModel(), getRenderer()));
    treeMap.setTreeModel(new Model(getModel()));
    legend.setRootItem(getModel().getChartRenderingRootNode());
    return sash;
}
Also used : SashLayout(name.abuchen.portfolio.ui.util.swt.SashLayout) Composite(org.eclipse.swt.widgets.Composite) ITreeModel(de.engehausen.treemap.ITreeModel) IWeightedTreeModel(de.engehausen.treemap.IWeightedTreeModel) SecurityDetailsViewer(name.abuchen.portfolio.ui.views.SecurityDetailsViewer) SashLayoutData(name.abuchen.portfolio.ui.util.swt.SashLayoutData)

Aggregations

ITreeModel (de.engehausen.treemap.ITreeModel)1 IWeightedTreeModel (de.engehausen.treemap.IWeightedTreeModel)1 SashLayout (name.abuchen.portfolio.ui.util.swt.SashLayout)1 SashLayoutData (name.abuchen.portfolio.ui.util.swt.SashLayoutData)1 SecurityDetailsViewer (name.abuchen.portfolio.ui.views.SecurityDetailsViewer)1 Composite (org.eclipse.swt.widgets.Composite)1