use of eu.esdihumboldt.hale.ui.util.viewer.tree.TreePathProviderAdapter in project hale by halestudio.
the class PageFunctions method createContents.
/**
* @see org.eclipse.jface.dialogs.DialogTray#createContents(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createContents(Composite parent) {
Composite comp = new Composite(parent, SWT.NONE);
GridLayoutFactory.fillDefaults().numColumns(1).applyTo(comp);
Label label = new Label(comp, SWT.NONE);
label.setText("Functions Overview");
label.setFont(JFaceResources.getHeaderFont());
// tree viwever
PatternFilter patternFilter = new TreePathPatternFilter();
patternFilter.setIncludeLeadingWildcard(true);
final FilteredTree filteredTree = new TreePathFilteredTree(comp, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER, patternFilter, true);
TreeViewer tree = filteredTree.getViewer();
tree.setUseHashlookup(true);
HelperFunctionLabelProvider labelProvider = new HelperFunctionLabelProvider();
tree.setLabelProvider(labelProvider);
IContentProvider contentProvider;
HelperFunctionsService functions = HaleUI.getServiceProvider().getService(HelperFunctionsService.class);
contentProvider = new TreePathProviderAdapter(new HelperFunctionContentProvider(functions));
tree.setContentProvider(contentProvider);
GridDataFactory.fillDefaults().grab(true, true).hint(280, 400).applyTo(filteredTree);
tree.setComparator(new HelperFunctionComparator());
tree.setInput(Category.ROOT);
// Examples
Label example = new Label(comp, SWT.NONE);
example.setText("Function documentation");
try {
browser = new Browser(comp, SWT.WRAP | SWT.BORDER);
browser.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(300, 250).create());
} catch (Throwable e) {
if (BROWSER_ERROR_REPORTED.compareAndSet(false, true)) {
log.error("Could not create embedded browser, using text field as fall-back", e);
}
textField = new Text(comp, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL);
textField.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(300, 250).create());
}
tree.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
String eg = null;
HelperFunctionSpecification hfs = null;
if (!event.getSelection().isEmpty()) {
TreeSelection treesel = (TreeSelection) event.getSelection();
TreePath[] paths = treesel.getPaths();
if (paths != null) {
TreePath path = paths[0];
for (int i = 0; i < path.getSegmentCount(); i++) {
if (path.getSegment(i) instanceof Category) {
eg = "Select a function to see its documentation.";
if (browser != null) {
browser.setText(eg);
} else if (textField != null) {
textField.setText(eg);
}
} else if (path.getSegment(i) instanceof HelperFunctionOrCategory) {
HelperFunctionOrCategory hfoc = ((HelperFunctionOrCategory) path.getSegment(i));
try {
hfs = (HelperFunctionSpecification) hfoc.asFunction().getSpec(hfoc.getName());
} catch (Exception e) {
log.error("There is a problem in retrieving the specification for a helper function.", e);
}
// displaying the specification
if (browser != null) {
eg = getFunctionSpecHTML(hfs);
browser.setText(eg);
} else if (textField != null) {
eg = getFunctionSpecText(hfs);
textField.setText(eg);
}
}
}
}
}
}
});
return comp;
}
use of eu.esdihumboldt.hale.ui.util.viewer.tree.TreePathProviderAdapter in project hale by halestudio.
the class PropertyDefinitionDialog method setupViewer.
@Override
protected void setupViewer(TreeViewer viewer, EntityDefinition initialSelection) {
viewer.setLabelProvider(new DefinitionLabelProvider(viewer));
viewer.setContentProvider(new TreePathProviderAdapter(new TypePropertyContentProvider(viewer)));
viewer.setInput(parentType);
if (initialSelection != null) {
viewer.setSelection(new StructuredSelection(initialSelection));
}
}
use of eu.esdihumboldt.hale.ui.util.viewer.tree.TreePathProviderAdapter in project hale by halestudio.
the class PropertyEntityDialog method setupViewer.
/**
* @see EntityDialog#setupViewer(TreeViewer, EntityDefinition)
*/
@Override
protected void setupViewer(TreeViewer viewer, EntityDefinition initialSelection) {
viewer.setLabelProvider(new StyledDefinitionLabelProvider(viewer));
EntityDefinitionService entityDefinitionService = PlatformUI.getWorkbench().getService(EntityDefinitionService.class);
if (parentType != null) {
viewer.setContentProvider(new TreePathProviderAdapter(new EntityTypePropertyContentProvider(entityDefinitionService, ssid)));
viewer.setInput(parentType);
} else {
flatRelevantProvider = new TreePathProviderAdapter(new EntityTypeIndexContentProvider(entityDefinitionService, ssid, true, false));
hierarchicalRelevantProvider = new TreePathProviderAdapter(new EntityTypeIndexHierarchy(entityDefinitionService, ssid, true, false));
flatAllProvider = new TreePathProviderAdapter(new EntityTypeIndexContentProvider(entityDefinitionService, ssid, false, false));
hierarchicalAllProvider = new TreePathProviderAdapter(new EntityTypeIndexHierarchy(entityDefinitionService, ssid, false, false));
viewer.setContentProvider(flatRelevantProvider);
SchemaService ss = PlatformUI.getWorkbench().getService(SchemaService.class);
viewer.setInput(ss.getSchemas(ssid));
}
if (initialSelection != null) {
viewer.setSelection(new StructuredSelection(initialSelection));
}
}
use of eu.esdihumboldt.hale.ui.util.viewer.tree.TreePathProviderAdapter in project hale by halestudio.
the class EntitySchemaExplorer method createContentProvider.
/**
* @see SchemaExplorer#createContentProvider(TreeViewer)
*/
@Override
protected IContentProvider createContentProvider(TreeViewer tree) {
EntityDefinitionService service = PlatformUI.getWorkbench().getService(EntityDefinitionService.class);
hierarchyProvider = new TreePathProviderAdapter(new EntityTypeIndexHierarchy(service, getSchemaSpace()));
listProvider = new TreePathProviderAdapter(new EntityTypeIndexContentProvider(service, getSchemaSpace()));
return listProvider;
}
use of eu.esdihumboldt.hale.ui.util.viewer.tree.TreePathProviderAdapter in project hale by halestudio.
the class TypeEntityDialog method setupViewer.
/**
* @see EntityDialog#setupViewer(TreeViewer, EntityDefinition)
*/
@Override
protected void setupViewer(TreeViewer viewer, EntityDefinition initialSelection) {
viewer.setLabelProvider(new StyledDefinitionLabelProvider(viewer));
EntityDefinitionService entityDefinitionService = PlatformUI.getWorkbench().getService(EntityDefinitionService.class);
flatRelevantProvider = new TreePathProviderAdapter(new EntityTypeIndexContentProvider(entityDefinitionService, ssid, true, true));
if (!onlyMappingRelevant) {
hierarchicalRelevantProvider = new TreePathProviderAdapter(new EntityTypeIndexHierarchy(entityDefinitionService, ssid, true, true));
flatAllProvider = new TreePathProviderAdapter(new EntityTypeIndexContentProvider(entityDefinitionService, ssid, false, true));
hierarchicalAllProvider = new TreePathProviderAdapter(new EntityTypeIndexHierarchy(entityDefinitionService, ssid, false, true));
viewer.setContentProvider(flatAllProvider);
} else {
viewer.setContentProvider(flatRelevantProvider);
}
SchemaService ss = PlatformUI.getWorkbench().getService(SchemaService.class);
viewer.setInput(ss.getSchemas(ssid));
if (initialSelection instanceof TypeEntityDefinition) {
viewer.setSelection(new StructuredSelection(initialSelection));
}
}
Aggregations