Search in sources :

Example 1 with AbstractNodeTemplate

use of org.knime.workbench.repository.model.AbstractNodeTemplate in project knime-core by knime.

the class NodeDropTargetListener method isEnabled.

/**
 * {@inheritDoc}
 */
@Override
public boolean isEnabled(final DropTargetEvent event) {
    AbstractNodeTemplate snt = getSelectionNodeTemplate();
    if (snt != null) {
        event.feedback = DND.FEEDBACK_SELECT;
        event.operations = DND.DROP_COPY;
        event.detail = DND.DROP_COPY;
        return true;
    }
    return false;
}
Also used : AbstractNodeTemplate(org.knime.workbench.repository.model.AbstractNodeTemplate)

Example 2 with AbstractNodeTemplate

use of org.knime.workbench.repository.model.AbstractNodeTemplate in project knime-core by knime.

the class TanimotoTextualViewFilter method doSelect.

/**
 * Copied from {@link TextualViewFilter}.
 */
@Override
protected boolean doSelect(final Object parentElement, final Object element, final boolean recurse) {
    boolean selectThis = false;
    // Node Template : Match against name
    if (element instanceof AbstractNodeTemplate) {
        // check against node name
        selectThis = match(((AbstractNodeTemplate) element).getName());
        if (element instanceof MetaNodeTemplate) {
            // with meta nodes also check the name of the workflow manager
            selectThis |= match(((MetaNodeTemplate) element).getManager().getName());
        }
        if (selectThis) {
            return true;
        }
        // we must also check towards root, as we want to include all
        // children of a selected category
        IRepositoryObject temp = (IRepositoryObject) parentElement;
        while (!(temp instanceof Root)) {
            // check parent category, but do *not* recurse !!!!
            if (doSelect(temp.getParent(), temp, false)) {
                return true;
            }
            temp = temp.getParent();
        }
    } else // Category: Match against name and children
    if (element instanceof Category) {
        // check against node name
        selectThis = match(((Category) element).getName());
        if (selectThis) {
            return true;
        }
        // check recursively against children, if needed
        if (recurse) {
            Category category = (Category) element;
            IRepositoryObject[] children = category.getChildren();
            for (int i = 0; i < children.length; i++) {
                // recursively check. return true on first matching child
                if (doSelect(category, children[i], true)) {
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : AbstractNodeTemplate(org.knime.workbench.repository.model.AbstractNodeTemplate) Category(org.knime.workbench.repository.model.Category) Root(org.knime.workbench.repository.model.Root) MetaNodeTemplate(org.knime.workbench.repository.model.MetaNodeTemplate) IRepositoryObject(org.knime.workbench.repository.model.IRepositoryObject)

Example 3 with AbstractNodeTemplate

use of org.knime.workbench.repository.model.AbstractNodeTemplate in project knime-core by knime.

the class MetaNodeDropTargetListener method isEnabled.

/**
 * {@inheritDoc}
 */
@Override
public boolean isEnabled(final DropTargetEvent event) {
    AbstractNodeTemplate snt = getSelectionNodeTemplate();
    if (snt != null) {
        event.feedback = DND.FEEDBACK_SELECT;
        event.operations = DND.DROP_COPY;
        event.detail = DND.DROP_COPY;
        return true;
    }
    return false;
}
Also used : AbstractNodeTemplate(org.knime.workbench.repository.model.AbstractNodeTemplate)

Example 4 with AbstractNodeTemplate

use of org.knime.workbench.repository.model.AbstractNodeTemplate in project knime-core by knime.

the class RepositoryViewFilter method doSelect.

/**
 *  An element is selected if itself, a parent or a
 * child contains the query string in its name.
 * {@inheritDoc}
 */
@Override
protected boolean doSelect(final Object parentElement, final Object element, final boolean recurse) {
    boolean selectThis = false;
    // Node Template : Match against name
    if (element instanceof AbstractNodeTemplate) {
        // check against node name
        selectThis = match(((AbstractNodeTemplate) element).getName());
        if (element instanceof MetaNodeTemplate) {
            // with meta nodes also check the name of the workflow manager
            selectThis |= match(((MetaNodeTemplate) element).getManager().getName());
        }
        if (selectThis) {
            return true;
        }
        // we must also check towards root, as we want to include all
        // children of a selected category
        IRepositoryObject temp = (IRepositoryObject) parentElement;
        while (!(temp instanceof Root)) {
            // check parent category, but do *not* recurse !!!!
            if (doSelect(temp.getParent(), temp, false)) {
                return true;
            }
            temp = temp.getParent();
        }
    } else // Category: Match against name and children
    if (element instanceof Category) {
        // check against node name
        selectThis = match(((Category) element).getName());
        if (selectThis) {
            return true;
        }
        // check recursively against children, if needed
        if (recurse) {
            Category category = (Category) element;
            IRepositoryObject[] children = category.getChildren();
            for (int i = 0; i < children.length; i++) {
                // recursively check. return true on first matching child
                if (doSelect(category, children[i], true)) {
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : AbstractNodeTemplate(org.knime.workbench.repository.model.AbstractNodeTemplate) Category(org.knime.workbench.repository.model.Category) Root(org.knime.workbench.repository.model.Root) MetaNodeTemplate(org.knime.workbench.repository.model.MetaNodeTemplate) IRepositoryObject(org.knime.workbench.repository.model.IRepositoryObject)

Aggregations

AbstractNodeTemplate (org.knime.workbench.repository.model.AbstractNodeTemplate)4 Category (org.knime.workbench.repository.model.Category)2 IRepositoryObject (org.knime.workbench.repository.model.IRepositoryObject)2 MetaNodeTemplate (org.knime.workbench.repository.model.MetaNodeTemplate)2 Root (org.knime.workbench.repository.model.Root)2