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);
}
Aggregations