use of org.knime.workbench.ui.wizards.workflowgroup.KnimeResourceLabelProviderWithRoot in project knime-core by knime.
the class ResourceSelectDialog method createDialogArea.
@Override
protected Control createDialogArea(final Composite parent) {
TreeSelectionControl tree = new TreeSelectionControl();
tree.setContentProvider(new KnimeResourceContentProviderWithRoot());
tree.setLabelProvider(new KnimeResourceLabelProviderWithRoot());
tree.setInitialSelection(m_initialSelection);
tree.setInput(m_root);
tree.setMessage(m_message);
tree.setValidator(new ISelectionValidator() {
public String isValid(final Object selection) {
if (m_validator != null) {
String result = m_validator.isValid(selection);
Button b = getButton(IDialogConstants.OK_ID);
// store it in case button is not created yet
m_valid = result == null;
if (b != null) {
b.setEnabled(m_valid);
}
return result;
}
return null;
}
});
tree.setChangeListener(new TreeSelectionChangeListener() {
public void treeSelectionChanged(final Object newSelection, final boolean valid) {
m_selectedContainer = findSelectedContainer(newSelection);
}
});
return tree.createTreeControl(parent);
}
use of org.knime.workbench.ui.wizards.workflowgroup.KnimeResourceLabelProviderWithRoot in project knime-core by knime.
the class WorkflowSelectionDialog method createDialogArea.
/**
* {@inheritDoc}
*/
@Override
protected Control createDialogArea(final Composite parent) {
// a tree viewer to select a workflow group or workflow
Group overall = new Group(parent, SWT.SHADOW_ETCHED_IN);
overall.setText("Export selection:");
overall.setLayout(new GridLayout(1, false));
GridData shellLayout = new GridData(GridData.FILL_BOTH);
shellLayout.widthHint = 300;
shellLayout.heightHint = 350;
overall.setLayoutData(shellLayout);
GridData fillBoth = new GridData(GridData.FILL_BOTH);
m_viewer = new TreeViewer(overall, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI);
m_viewer.getTree().setLayoutData(fillBoth);
m_viewer.setLabelProvider(new KnimeResourceLabelProviderWithRoot());
m_viewer.setContentProvider(new KnimeResourceContentProviderWithRoot());
m_viewer.addFilter(new ViewerFilter() {
@Override
public boolean select(final Viewer viewer, final Object parentElement, final Object element) {
if (element instanceof IWorkspaceRoot) {
return true;
}
IResource resource = null;
if (element instanceof NodeContainer) {
ProjectWorkflowMap.findProjectFor(((NodeContainer) element).getID());
} else if (element instanceof IResource) {
resource = (IResource) element;
}
if (KnimeResourceUtil.isWorkflow(resource)) {
return true;
}
if (KnimeResourceUtil.isWorkflowGroup(resource)) {
return true;
}
return false;
}
});
m_viewer.setInput(ResourcesPlugin.getWorkspace().getRoot());
m_viewer.addPostSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(final SelectionChangedEvent event) {
m_selectedObjs = (IStructuredSelection) m_viewer.getSelection();
}
});
if (m_initialSelection != null) {
m_viewer.setSelection(m_initialSelection);
}
m_viewer.expandAll();
return overall;
}
Aggregations