Search in sources :

Example 1 with HadoopFolderRepositoryNode

use of org.talend.repository.hadoopcluster.node.HadoopFolderRepositoryNode in project tbd-studio-se by Talend.

the class CreateHadoopDBNodeAction method init.

/*
     * (non-Javadoc)
     *
     * @see org.talend.repository.hadoopcluster.action.common.CreateHadoopNodeAction#init(org.talend.repository.model.
     * RepositoryNode)
     */
@Override
protected void init(RepositoryNode node) {
    ERepositoryObjectType nodeType = (ERepositoryObjectType) node.getProperties(EProperties.CONTENT_TYPE);
    if (nodeType == null) {
        return;
    }
    if (hideAction(node)) {
        return;
    }
    IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    if (HCRepositoryUtil.isHadoopClusterNode(node) || (node instanceof HadoopFolderRepositoryNode && getNodeType().equals(nodeType) && isParentNode(node))) {
        if (factory.isUserReadOnlyOnCurrentProject() || !ProjectManager.getInstance().isInCurrentMainProject(node) || (node.getObject() != null && factory.getStatus(node.getObject()) == ERepositoryStatus.DELETED)) {
            setEnabled(false);
            return;
        }
        this.setText(getCreateLabel());
        collectChildNames(node);
        creation = true;
        setEnabled(true);
        return;
    }
    if (!nodeType.equals(getNodeType())) {
        return;
    }
    switch(node.getType()) {
        case SIMPLE_FOLDER:
            setEnabled(false);
            return;
        case SYSTEM_FOLDER:
            if (factory.isUserReadOnlyOnCurrentProject() || !ProjectManager.getInstance().isInCurrentMainProject(node) || !isParentNode(node)) {
                setEnabled(false);
                return;
            }
            this.setText(getCreateLabel());
            collectChildNames(node);
            creation = true;
            break;
        case REPOSITORY_ELEMENT:
            if (!isParentNode(node.getParent())) {
                setEnabled(false);
                return;
            }
            if (factory.isPotentiallyEditable(node.getObject())) {
                this.setText(getEditLabel());
                collectSiblingNames(node);
            } else {
                this.setText(getOpenLabel());
            }
            collectSiblingNames(node);
            creation = false;
            break;
        default:
            return;
    }
    setEnabled(true);
}
Also used : HadoopFolderRepositoryNode(org.talend.repository.hadoopcluster.node.HadoopFolderRepositoryNode) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 2 with HadoopFolderRepositoryNode

use of org.talend.repository.hadoopcluster.node.HadoopFolderRepositoryNode in project tbd-studio-se by Talend.

the class AbstractHadoopRepositoryContentHandler method createHadoopFolderNode.

protected RepositoryNode createHadoopFolderNode(RepositoryNode parentNode, ERepositoryObjectType nodeType, String folderName, int childrenNum) {
    StringBuffer floderName = new StringBuffer();
    floderName.append(folderName);
    // $NON-NLS-1$
    floderName.append("(");
    floderName.append(childrenNum);
    // $NON-NLS-1$
    floderName.append(")");
    RepositoryNode typeFolderNode = new HadoopFolderRepositoryNode(parentNode, floderName.toString());
    typeFolderNode.setProperties(EProperties.CONTENT_TYPE, nodeType);
    return typeFolderNode;
}
Also used : HadoopFolderRepositoryNode(org.talend.repository.hadoopcluster.node.HadoopFolderRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) HadoopFolderRepositoryNode(org.talend.repository.hadoopcluster.node.HadoopFolderRepositoryNode)

Example 3 with HadoopFolderRepositoryNode

use of org.talend.repository.hadoopcluster.node.HadoopFolderRepositoryNode in project tbd-studio-se by Talend.

the class CreateHadoopNodeAction method init.

@Override
protected void init(RepositoryNode node) {
    ERepositoryObjectType nodeType = (ERepositoryObjectType) node.getProperties(EProperties.CONTENT_TYPE);
    if (nodeType == null) {
        return;
    }
    if (hideAction(node)) {
        return;
    }
    IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    if (HCRepositoryUtil.isHadoopClusterNode(node) || (node instanceof HadoopFolderRepositoryNode && getNodeType().equals(nodeType))) {
        if (factory.isUserReadOnlyOnCurrentProject() || !ProjectManager.getInstance().isInCurrentMainProject(node) || (node.getObject() != null && factory.getStatus(node.getObject()) == ERepositoryStatus.DELETED)) {
            setEnabled(false);
            return;
        }
        this.setText(getCreateLabel());
        collectChildNames(node);
        creation = true;
        setEnabled(true);
        return;
    }
    if (!nodeType.equals(getNodeType())) {
        return;
    }
    switch(node.getType()) {
        case SIMPLE_FOLDER:
            if (node.getObject() != null && node.getObject().getProperty().getItem().getState().isDeleted()) {
                setEnabled(false);
                return;
            }
            break;
        case SYSTEM_FOLDER:
            if (factory.isUserReadOnlyOnCurrentProject() || !ProjectManager.getInstance().isInCurrentMainProject(node)) {
                setEnabled(false);
                return;
            }
            this.setText(getCreateLabel());
            collectChildNames(node);
            creation = true;
            break;
        case REPOSITORY_ELEMENT:
            if (factory.isPotentiallyEditable(node.getObject())) {
                this.setText(getEditLabel());
                collectSiblingNames(node);
            } else {
                this.setText(getOpenLabel());
            }
            collectSiblingNames(node);
            creation = false;
            break;
        default:
            return;
    }
    setEnabled(true);
}
Also used : HadoopFolderRepositoryNode(org.talend.repository.hadoopcluster.node.HadoopFolderRepositoryNode) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Aggregations

HadoopFolderRepositoryNode (org.talend.repository.hadoopcluster.node.HadoopFolderRepositoryNode)3 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)2 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)2 RepositoryNode (org.talend.repository.model.RepositoryNode)1