Search in sources :

Example 1 with TreeSelectionChangeListener

use of org.knime.workbench.ui.navigator.actions.selection.TreeSelectionControl.TreeSelectionChangeListener 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);
}
Also used : KnimeResourceContentProviderWithRoot(org.knime.workbench.ui.wizards.workflowgroup.KnimeResourceContentProviderWithRoot) Button(org.eclipse.swt.widgets.Button) TreeSelectionChangeListener(org.knime.workbench.ui.navigator.actions.selection.TreeSelectionControl.TreeSelectionChangeListener) KnimeResourceLabelProviderWithRoot(org.knime.workbench.ui.wizards.workflowgroup.KnimeResourceLabelProviderWithRoot) ISelectionValidator(org.eclipse.ui.dialogs.ISelectionValidator)

Aggregations

Button (org.eclipse.swt.widgets.Button)1 ISelectionValidator (org.eclipse.ui.dialogs.ISelectionValidator)1 TreeSelectionChangeListener (org.knime.workbench.ui.navigator.actions.selection.TreeSelectionControl.TreeSelectionChangeListener)1 KnimeResourceContentProviderWithRoot (org.knime.workbench.ui.wizards.workflowgroup.KnimeResourceContentProviderWithRoot)1 KnimeResourceLabelProviderWithRoot (org.knime.workbench.ui.wizards.workflowgroup.KnimeResourceLabelProviderWithRoot)1