use of eu.esdihumboldt.hale.ui.HALEContextProvider in project hale by halestudio.
the class NewRelationPage method createViewer.
/**
* @see ViewerWizardSelectionPage#createViewer(Composite)
*/
@Override
protected Pair<StructuredViewer, Control> createViewer(Composite parent) {
PatternFilter filter = new PatternFilter();
filter.setIncludeLeadingWildcard(true);
FilteredTree tree = new FilteredTree(parent, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL, filter, true);
viewer = tree.getViewer();
viewer.setContentProvider(new FunctionWizardNodeContentProvider(getContainer(), initialSelection, selectionMatcher));
viewer.setLabelProvider(new FunctionWizardNodeLabelProvider());
// no input needed, but we have to set something
viewer.setInput(Boolean.TRUE);
// set focus on viewer control to prevent odd behavior
viewer.getControl().setFocus();
// expand selection
viewer.expandAll();
// selection context
contextProvider = new HALEContextProvider(viewer, null);
// help update on page shown
if (getContainer() instanceof IPageChangeProvider) {
((IPageChangeProvider) getContainer()).addPageChangedListener(changeListener = new IPageChangedListener() {
@Override
public void pageChanged(PageChangedEvent event) {
if (event.getSelectedPage() == NewRelationPage.this) {
// update the help button
if (getContainer() instanceof HaleWizardDialog) {
((HaleWizardDialog) getContainer()).setHelpButtonEnabled(getHelpContext() != null);
}
}
}
});
}
// help update on selection change
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IContext context = getHelpContext();
// update the help button
if (getContainer() instanceof HaleWizardDialog) {
((HaleWizardDialog) getContainer()).setHelpButtonEnabled(context != null);
}
// update the help
if (context != null) {
TrayDialog trayDialog = (TrayDialog) getContainer();
if (trayDialog.getTray() != null) {
// if the tray is already open, update the help
performHelp();
}
}
}
});
// load page configuration
// XXX would be better if called from outside
ProjectService ps = PlatformUI.getWorkbench().getService(ProjectService.class);
restore(ps.getConfigurationService());
return new Pair<StructuredViewer, Control>(viewer, tree);
}
Aggregations