use of eu.esdihumboldt.hale.ui.views.typehierarchy.TypeHierarchyContentProvider.ParentPath in project hale by halestudio.
the class TypeHierarchyView method update.
/**
* Update the hierarchy view with the given selection
*
* @param selection the selection
*/
protected void update(ISelection selection) {
if (selection instanceof IStructuredSelection) {
Object element = ((IStructuredSelection) selection).getFirstElement();
if (element instanceof ParentPath) {
element = ((ParentPath) element).getHead();
}
if (element instanceof Entity) {
element = ((Entity) element).getDefinition();
}
if (element instanceof EntityDefinition) {
element = ((EntityDefinition) element).getDefinition();
}
viewer.setInput(element);
ParentPath path = TypeHierarchyContentProvider.createPath(element);
viewer.expandAll();
if (path != null) {
viewer.setSelection(new StructuredSelection(path.getMainPath()));
}
} else {
viewer.setInput(null);
}
}
use of eu.esdihumboldt.hale.ui.views.typehierarchy.TypeHierarchyContentProvider.ParentPath 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