Search in sources :

Example 6 with ViewerMenu

use of eu.esdihumboldt.hale.ui.util.viewer.ViewerMenu in project hale by halestudio.

the class TypeHierarchyView method createViewControl.

/**
 * @see eu.esdihumboldt.hale.ui.views.properties.PropertiesViewPart#createViewControl(org.eclipse.swt.widgets.Composite)
 */
@Override
public void createViewControl(Composite parent) {
    viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
    viewer.setContentProvider(new TypeHierarchyContentProvider());
    viewer.setLabelProvider(new TypeHierarchyLabelProvider(viewer));
    viewer.setComparator(new DefinitionComparator());
    contributeToActionBars();
    viewer.addDoubleClickListener(new IDoubleClickListener() {

        @Override
        public void doubleClick(DoubleClickEvent event) {
            update(event.getSelection());
        }
    });
    getSite().getWorkbenchWindow().getSelectionService().addPostSelectionListener(selectionListener = new ISelectionListener() {

        @Override
        public void selectionChanged(IWorkbenchPart part, ISelection selection) {
            if (!(part instanceof PropertiesViewPart)) {
                // selections
                return;
            }
            if (part != TypeHierarchyView.this) {
                update(selection);
            }
        }
    });
    getSite().setSelectionProvider(selectionProvider = new SelectionFilter(viewer) {

        @Override
        protected ISelection filter(ISelection selection) {
            if (selection != null && !selection.isEmpty() && selection instanceof IStructuredSelection) {
                List<Object> elements = new ArrayList<Object>();
                for (Object element : ((IStructuredSelection) selection).toList()) {
                    if (element instanceof ParentPath) {
                        // add parent path head instead of parent path
                        elements.add(((ParentPath) element).getHead());
                    } else {
                        elements.add(element);
                    }
                }
                return new StructuredSelection(elements);
            } else {
                return selection;
            }
        }
    });
    new ViewerMenu(getSite(), viewer);
}
Also used : TreeViewer(org.eclipse.jface.viewers.TreeViewer) DefinitionComparator(eu.esdihumboldt.hale.ui.common.definition.viewer.DefinitionComparator) ArrayList(java.util.ArrayList) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) SelectionFilter(eu.esdihumboldt.hale.ui.util.selection.SelectionFilter) ISelectionListener(org.eclipse.ui.ISelectionListener) ViewerMenu(eu.esdihumboldt.hale.ui.util.viewer.ViewerMenu) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) ParentPath(eu.esdihumboldt.hale.ui.views.typehierarchy.TypeHierarchyContentProvider.ParentPath) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) ISelection(org.eclipse.jface.viewers.ISelection) PropertiesViewPart(eu.esdihumboldt.hale.ui.views.properties.PropertiesViewPart)

Aggregations

ViewerMenu (eu.esdihumboldt.hale.ui.util.viewer.ViewerMenu)6 TreeViewer (org.eclipse.jface.viewers.TreeViewer)3 EntitySchemaExplorer (eu.esdihumboldt.hale.ui.views.schemas.explorer.EntitySchemaExplorer)2 ServiceSchemaExplorer (eu.esdihumboldt.hale.ui.views.schemas.explorer.ServiceSchemaExplorer)2 IMenuManager (org.eclipse.jface.action.IMenuManager)2 ISelection (org.eclipse.jface.viewers.ISelection)2 Composite (org.eclipse.swt.widgets.Composite)2 ExclusiveExtensionListener (de.fhg.igd.eclipse.util.extension.exclusive.ExclusiveExtension.ExclusiveExtensionListener)1 CompatibilityMode (eu.esdihumboldt.hale.common.align.compatibility.CompatibilityMode)1 ProjectInfo (eu.esdihumboldt.hale.common.core.io.project.ProjectInfo)1 Resource (eu.esdihumboldt.hale.common.core.io.project.model.Resource)1 DefinitionComparator (eu.esdihumboldt.hale.ui.common.definition.viewer.DefinitionComparator)1 FunctionContentProvider (eu.esdihumboldt.hale.ui.common.function.viewer.FunctionContentProvider)1 FunctionLabelProvider (eu.esdihumboldt.hale.ui.common.function.viewer.FunctionLabelProvider)1 CompatibilityModeFactory (eu.esdihumboldt.hale.ui.common.service.compatibility.CompatibilityModeFactory)1 CompatibilityService (eu.esdihumboldt.hale.ui.common.service.compatibility.CompatibilityService)1 SchemaSelection (eu.esdihumboldt.hale.ui.selection.SchemaSelection)1 DefaultSchemaSelection (eu.esdihumboldt.hale.ui.selection.impl.DefaultSchemaSelection)1 AlignmentService (eu.esdihumboldt.hale.ui.service.align.AlignmentService)1 AlignmentServiceAdapter (eu.esdihumboldt.hale.ui.service.align.AlignmentServiceAdapter)1