Search in sources :

Example 1 with SelectionProviderFacade

use of eu.esdihumboldt.hale.ui.util.selection.SelectionProviderFacade in project hale by halestudio.

the class AbstractMappingView method createViewControl.

@Override
public void createViewControl(Composite parent) {
    viewer = new GraphViewer(parent, SWT.BORDER);
    viewer.setContentProvider(createContentProvider());
    // viewer.setContentProvider(new CellRelationshipContentProvider());
    // viewer.setContentProvider(new NestedCellRelationshipContentProvider());
    viewer.setLabelProvider(createLabelProvider(viewer));
    viewer.setInput(null);
    LayoutAlgorithm layout = createLayout();
    viewer.setLayoutAlgorithm(layout, true);
    viewer.applyLayout();
    fillToolBar();
    // set selection provider
    selectionFacade = new SelectionProviderFacade();
    selectionFacade.setSelectionProvider(getViewer());
    getSite().setSelectionProvider(new PostSelectionSupport(selectionFacade));
    viewer.getControl().addKeyListener(new KeyListener() {

        @Override
        public void keyReleased(KeyEvent e) {
            if (e.keyCode == 'a' && (e.stateMask & SWT.MODIFIER_MASK) == SWT.CTRL) {
                // XXX even though getSelection returns the current state, a
                // selection update is not triggered by the control
                // -> force selection change event after Ctrl+A
                ISelection sel = viewer.getSelection();
                selectionFacade.setSelection(sel);
            }
        }

        @Override
        public void keyPressed(KeyEvent e) {
        // nothing to do
        }
    });
    // create context menu
    new ViewerMenu(getSite(), getViewer()) {

        /**
         * @see eu.esdihumboldt.hale.ui.util.ViewContextMenu#menuAboutToShow(org.eclipse.jface.action.IMenuManager)
         */
        @Override
        public void menuAboutToShow(IMenuManager manager) {
            super.menuAboutToShow(manager);
            AbstractMappingView.this.menuAboutToShow(manager);
        }
    };
}
Also used : KeyEvent(org.eclipse.swt.events.KeyEvent) GraphViewer(org.eclipse.zest.core.viewers.GraphViewer) TreeLayoutAlgorithm(org.eclipse.zest.layouts.algorithms.TreeLayoutAlgorithm) LayoutAlgorithm(org.eclipse.zest.layouts.LayoutAlgorithm) SelectionProviderFacade(eu.esdihumboldt.hale.ui.util.selection.SelectionProviderFacade) ISelection(org.eclipse.jface.viewers.ISelection) KeyListener(org.eclipse.swt.events.KeyListener) IMenuManager(org.eclipse.jface.action.IMenuManager) PostSelectionSupport(eu.esdihumboldt.hale.ui.util.viewer.PostSelectionSupport) ViewerMenu(eu.esdihumboldt.hale.ui.util.viewer.ViewerMenu)

Aggregations

SelectionProviderFacade (eu.esdihumboldt.hale.ui.util.selection.SelectionProviderFacade)1 PostSelectionSupport (eu.esdihumboldt.hale.ui.util.viewer.PostSelectionSupport)1 ViewerMenu (eu.esdihumboldt.hale.ui.util.viewer.ViewerMenu)1 IMenuManager (org.eclipse.jface.action.IMenuManager)1 ISelection (org.eclipse.jface.viewers.ISelection)1 KeyEvent (org.eclipse.swt.events.KeyEvent)1 KeyListener (org.eclipse.swt.events.KeyListener)1 GraphViewer (org.eclipse.zest.core.viewers.GraphViewer)1 LayoutAlgorithm (org.eclipse.zest.layouts.LayoutAlgorithm)1 TreeLayoutAlgorithm (org.eclipse.zest.layouts.algorithms.TreeLayoutAlgorithm)1