Search in sources :

Example 1 with ReverseCellGraphContentProvider

use of eu.esdihumboldt.hale.ui.common.graph.content.ReverseCellGraphContentProvider in project hale by halestudio.

the class TypeCellSelectionDialog method setupViewer.

/**
 * @see eu.esdihumboldt.hale.ui.util.selector.AbstractViewerSelectionDialog#setupViewer(org.eclipse.jface.viewers.StructuredViewer,
 *      java.lang.Object)
 */
@Override
protected void setupViewer(final GraphViewer viewer, Cell initialSelection) {
    // content and label provider
    viewer.setContentProvider(new ReverseCellGraphContentProvider());
    viewer.setLabelProvider(new GraphLabelProvider(viewer, HaleUI.getServiceProvider()));
    // layout
    final TreeLayoutAlgorithm layout = new TreeLayoutAlgorithm(TreeLayoutAlgorithm.RIGHT_LEFT);
    viewer.getControl().addControlListener(new ControlAdapter() {

        @Override
        public void controlResized(ControlEvent e) {
            int width = viewer.getControl().getSize().x;
            layout.setNodeSpace(new Dimension((width - 10) / 3, 30));
        }
    });
    viewer.setLayoutAlgorithm(layout, true);
    viewer.applyLayout();
    // input and selection
    AlignmentService as = PlatformUI.getWorkbench().getService(AlignmentService.class);
    viewer.setInput(as.getAlignment().getTypeCells());
    if (initialSelection != null)
        viewer.setSelection(new StructuredSelection(initialSelection));
}
Also used : ControlAdapter(org.eclipse.swt.events.ControlAdapter) TreeLayoutAlgorithm(org.eclipse.zest.layouts.algorithms.TreeLayoutAlgorithm) AlignmentService(eu.esdihumboldt.hale.ui.service.align.AlignmentService) GraphLabelProvider(eu.esdihumboldt.hale.ui.common.graph.labels.GraphLabelProvider) ReverseCellGraphContentProvider(eu.esdihumboldt.hale.ui.common.graph.content.ReverseCellGraphContentProvider) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Dimension(org.eclipse.draw2d.geometry.Dimension) ControlEvent(org.eclipse.swt.events.ControlEvent)

Aggregations

ReverseCellGraphContentProvider (eu.esdihumboldt.hale.ui.common.graph.content.ReverseCellGraphContentProvider)1 GraphLabelProvider (eu.esdihumboldt.hale.ui.common.graph.labels.GraphLabelProvider)1 AlignmentService (eu.esdihumboldt.hale.ui.service.align.AlignmentService)1 Dimension (org.eclipse.draw2d.geometry.Dimension)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 ControlAdapter (org.eclipse.swt.events.ControlAdapter)1 ControlEvent (org.eclipse.swt.events.ControlEvent)1 TreeLayoutAlgorithm (org.eclipse.zest.layouts.algorithms.TreeLayoutAlgorithm)1