Search in sources :

Example 1 with ContextFolderRepNode

use of org.talend.dq.nodes.ContextFolderRepNode in project tdq-studio-se by Talend.

the class ResourceViewContentProvider method createNewRepNode.

private DQRepositoryNode createNewRepNode(ERepositoryObjectType type, org.talend.core.model.general.Project inWhichProject) {
    IRepositoryViewObject viewObject = null;
    FolderItem folderItem = ProxyRepositoryFactory.getInstance().getFolderItem(inWhichProject, type, Path.EMPTY);
    if (folderItem == null) {
        String folderName = ERepositoryObjectType.getFolderName(type);
        viewObject = new Folder(folderName, folderName);
    } else {
        viewObject = new Folder(folderItem.getProperty(), type);
    }
    DQRepositoryNode node = new DQRepositoryNode(viewObject, null, ENodeType.SYSTEM_FOLDER, inWhichProject);
    if (ERepositoryObjectType.CONTEXT == type) {
        node = new ContextFolderRepNode(viewObject, null, ENodeType.SYSTEM_FOLDER, inWhichProject);
    }
    viewObject.setRepositoryNode(node);
    return node;
}
Also used : DQRepositoryNode(org.talend.dq.nodes.DQRepositoryNode) FolderItem(org.talend.core.model.properties.FolderItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) Folder(org.talend.core.model.repository.Folder) IFolder(org.eclipse.core.resources.IFolder) ContextFolderRepNode(org.talend.dq.nodes.ContextFolderRepNode)

Example 2 with ContextFolderRepNode

use of org.talend.dq.nodes.ContextFolderRepNode in project tdq-studio-se by Talend.

the class ResourceViewContentProvider method getRepositoryNodeChildren.

/**
 * DOC talend Comment method "getRepositoryNodeChildren".
 *
 * @param element
 * @param instance
 * @return
 * @throws PersistenceException
 * @throws CoreException
 */
private Object[] getRepositoryNodeChildren(Object element) throws PersistenceException, CoreException {
    final DQRepositoryNode node = (DQRepositoryNode) element;
    // MOD gdbu 2011-7-20 bug : 23220
    DQRepositoryNode.setIsReturnAllNodesWhenFiltering(false);
    List<IRepositoryNode> children = node.getChildren();
    DQRepositoryNode.setIsReturnAllNodesWhenFiltering(true);
    if ((node instanceof DBTableFolderRepNode || node instanceof DBViewFolderRepNode || node instanceof DBColumnFolderRepNode) && !DQRepositoryNode.isOnFilterring()) {
        if (0 < children.size()) {
            try {
                StructuredSelection structSel = new StructuredSelection(node);
                if (null != treeViewer) {
                    ISelection tempSelection = treeViewer.getSelection();
                    treeViewer.setSelection(structSel);
                    TreeItem[] selectionItems = treeViewer.getTree().getSelection();
                    if (0 != selectionItems.length) {
                        selectionItems[0].setText(node.getLabel());
                        treeViewer.setSelection(tempSelection);
                    }
                } else {
                    ISelection dqTreeSelection = RepositoryNodeHelper.getDQCommonViewer().getSelection();
                    RepositoryNodeHelper.getDQCommonViewer().setSelection(structSel);
                    TreeItem[] selections = RepositoryNodeHelper.getDQCommonViewer().getTree().getSelection();
                    if (0 != selections.length) {
                        selections[0].setText(node.getLabel());
                    }
                    RepositoryNodeHelper.getDQCommonViewer().setSelection(dqTreeSelection);
                }
            } catch (Exception e) {
                log.error(e.toString());
            }
        }
    }
    if (children.size() <= 0) {
        // ~23220
        List<EResourceConstant> resContants = new ArrayList<EResourceConstant>();
        IRepositoryViewObject viewObject = node.getObject();
        String label = viewObject == null ? null : viewObject.getLabel();
        if (EResourceConstant.DATA_PROFILING.getName().equals(label)) {
            resContants.add(EResourceConstant.ANALYSIS);
            if (PluginChecker.isTDQLoaded()) {
                resContants.add(EResourceConstant.REPORTS);
            }
        } else if (EResourceConstant.LIBRARIES.getName().equals(label)) {
            // MOD TDQ-10933 msjian 20150915: Hide the Exchange node
            if (!TalendPropertiesUtil.isHideExchange()) {
                resContants.add(EResourceConstant.EXCHANGE);
            }
            // TDQ-10933~
            resContants.add(EResourceConstant.INDICATORS);
            if (PluginChecker.isTDQLoaded()) {
                resContants.add(EResourceConstant.JRXML_TEMPLATE);
            }
            resContants.add(EResourceConstant.PATTERNS);
            resContants.add(EResourceConstant.RULES);
            resContants.add(EResourceConstant.SOURCE_FILES);
        } else if (EResourceConstant.METADATA.getName().equals(label)) {
            resContants.add(EResourceConstant.DB_CONNECTIONS);
            resContants.add(EResourceConstant.FILEDELIMITED);
            if (PluginChecker.isTDQLoaded() && HadoopClusterUtils.getDefault().isServiceInstalled()) {
                resContants.add(EResourceConstant.HADOOP_CLUSTER);
            }
        }
        if (resContants.size() > 0) {
            RepositoryNodeBuilder.getInstance().createRepositoryNodeSystemFolders(node, resContants, node.getProject());
        }
    } else {
        // to avoid can not get reference project nodes when open the select udi/pattern/rule dialog
        if (EResourceConstant.REFERENCED_PROJECT.getName().equals(node.getProperties(EProperties.LABEL))) {
            if (!ProxyRepositoryManager.getInstance().isMergeRefProject()) {
                for (IRepositoryNode refProjectNode : node.getChildren()) {
                    for (IRepositoryNode refProjectItemNode : refProjectNode.getChildren()) {
                        getRepositoryNodeChildren(refProjectItemNode);
                    }
                }
            }
        }
    }
    if (node instanceof ContextFolderRepNode) {
        children = ((ContextFolderRepNode) node).getChildren();
    }
    return sortRepositoryNode(children.toArray());
}
Also used : DBTableFolderRepNode(org.talend.dq.nodes.DBTableFolderRepNode) EResourceConstant(org.talend.resource.EResourceConstant) IRepositoryNode(org.talend.repository.model.IRepositoryNode) TreeItem(org.eclipse.swt.widgets.TreeItem) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) ArrayList(java.util.ArrayList) DBViewFolderRepNode(org.talend.dq.nodes.DBViewFolderRepNode) DBColumnFolderRepNode(org.talend.dq.nodes.DBColumnFolderRepNode) CoreException(org.eclipse.core.runtime.CoreException) MissingDriverException(org.talend.utils.exceptions.MissingDriverException) PersistenceException(org.talend.commons.exception.PersistenceException) DQRepositoryNode(org.talend.dq.nodes.DQRepositoryNode) ISelection(org.eclipse.jface.viewers.ISelection) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ContextFolderRepNode(org.talend.dq.nodes.ContextFolderRepNode)

Example 3 with ContextFolderRepNode

use of org.talend.dq.nodes.ContextFolderRepNode in project tdq-studio-se by Talend.

the class CreateNewRepositoryNodeFolder method fillContextMenu.

/**
 * Adds a submenu to the given menu with the name "New Component".
 */
@Override
public void fillContextMenu(IMenuManager menu) {
    if (!isShowMenu()) {
        return;
    }
    // ADD msjian TDQ-10444: fix get error when click on the exchange node
    if (isExchangeNode()) {
        return;
    }
    // TDQ-10444~
    Object obj = ((TreeSelection) this.getContext().getSelection()).getFirstElement();
    RepositoryNode node = (RepositoryNode) obj;
    RepositoryNode parent = node.getParent();
    if (!(parent instanceof ReportSubFolderRepNode)) {
        if (parent != null || node instanceof ContextFolderRepNode) {
            IFolder folder = WorkbenchUtils.getFolder(node);
            if (!(node instanceof ExchangeFolderRepNode) && !ResourceManager.getRulesFolder().equals(folder) && !ResourceManager.getPatternFolder().equals(folder) && !ResourceManager.getIndicatorFolder().equals(folder) && !ResourceService.isSubFolder(ResourceManager.getSystemIndicatorFolder(), folder) && (ENodeType.SYSTEM_FOLDER.equals(node.getType()) || ENodeType.SIMPLE_FOLDER.equals(node.getType())) && !(node instanceof HDFSOfHCFolderRepNode || node instanceof HiveOfHCFolderRepNode)) {
                // MOD qiongli 2011-1-20 don't add it for recycle bin elements
                if (node.getObject() != null && !node.getObject().getProperty().getItem().getState().isDeleted()) {
                    currentSelection = WorkbenchUtils.getFolder(node);
                    CreateRepositoryNodeAction createSubFolderAction = new CreateRepositoryNodeAction(currentSelection);
                    menu.add(createSubFolderAction);
                }
            }
        }
    }
}
Also used : HDFSOfHCFolderRepNode(org.talend.dq.nodes.hadoopcluster.HDFSOfHCFolderRepNode) HiveOfHCFolderRepNode(org.talend.dq.nodes.hadoopcluster.HiveOfHCFolderRepNode) CreateRepositoryNodeAction(org.talend.dataprofiler.core.ui.action.actions.CreateRepositoryNodeAction) TreeSelection(org.eclipse.jface.viewers.TreeSelection) ExchangeFolderRepNode(org.talend.dataprofiler.core.ui.exchange.ExchangeFolderRepNode) RepositoryNode(org.talend.repository.model.RepositoryNode) ReportSubFolderRepNode(org.talend.dq.nodes.ReportSubFolderRepNode) ContextFolderRepNode(org.talend.dq.nodes.ContextFolderRepNode) IFolder(org.eclipse.core.resources.IFolder)

Aggregations

ContextFolderRepNode (org.talend.dq.nodes.ContextFolderRepNode)3 IFolder (org.eclipse.core.resources.IFolder)2 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)2 DQRepositoryNode (org.talend.dq.nodes.DQRepositoryNode)2 ArrayList (java.util.ArrayList)1 CoreException (org.eclipse.core.runtime.CoreException)1 ISelection (org.eclipse.jface.viewers.ISelection)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 TreeSelection (org.eclipse.jface.viewers.TreeSelection)1 TreeItem (org.eclipse.swt.widgets.TreeItem)1 PersistenceException (org.talend.commons.exception.PersistenceException)1 FolderItem (org.talend.core.model.properties.FolderItem)1 Folder (org.talend.core.model.repository.Folder)1 CreateRepositoryNodeAction (org.talend.dataprofiler.core.ui.action.actions.CreateRepositoryNodeAction)1 ExchangeFolderRepNode (org.talend.dataprofiler.core.ui.exchange.ExchangeFolderRepNode)1 DBColumnFolderRepNode (org.talend.dq.nodes.DBColumnFolderRepNode)1 DBTableFolderRepNode (org.talend.dq.nodes.DBTableFolderRepNode)1 DBViewFolderRepNode (org.talend.dq.nodes.DBViewFolderRepNode)1 ReportSubFolderRepNode (org.talend.dq.nodes.ReportSubFolderRepNode)1 HDFSOfHCFolderRepNode (org.talend.dq.nodes.hadoopcluster.HDFSOfHCFolderRepNode)1