Search in sources :

Example 1 with CreateNewAnalysisAction

use of org.talend.dataprofiler.core.ui.action.actions.CreateNewAnalysisAction in project tdq-studio-se by Talend.

the class NewAnalysisActionProvider method fillContextMenu.

/**
 * Adds a submenu to the given menu with the name "New Component".
 */
@Override
public void fillContextMenu(IMenuManager menu) {
    // MOD mzhao user readonly role on svn repository mode.
    if (!isShowMenu()) {
        return;
    }
    // Object obj = ((TreeSelection) this.getContext().getSelection()).getFirstElement();
    // if (obj instanceof IFolder) {
    // IFolder folder = (IFolder) obj;
    // 
    // if (ResourceService.isSubFolder(ResourceManager.getAnalysisFolder(), folder)) {
    // CreateNewAnalysisAction createAnalysisAction = new CreateNewAnalysisAction(folder);
    // menu.add(createAnalysisAction);
    // }
    // }
    // DOC klliu 2010-11-23 set the node and path to the action
    Object obj = ((TreeSelection) this.getContext().getSelection()).getFirstElement();
    if (obj instanceof RepositoryNode) {
        RepositoryNode node = (RepositoryNode) obj;
        if ((node instanceof AnalysisFolderRepNode && !(node instanceof AnalysisSubFolderRepNode)) || (node instanceof AnalysisSubFolderRepNode && node.getObject() != null)) {
            CreateNewAnalysisAction createAnalysisAction = new CreateNewAnalysisAction(RepositoryNodeHelper.getPath(node), node);
            menu.add(createAnalysisAction);
        }
    }
// RepositoryNode node = (RepositoryNode) obj;
// if (ENodeType.SYSTEM_FOLDER.equals(node.getType()) || ENodeType.SIMPLE_FOLDER.equals(node.getType())) {
// IFolder ifolder = WorkbenchUtils.getFolder(node);
// if (ifolder != null && (ResourceService.isSubFolder(ResourceManager.getAnalysisFolder(), ifolder))) {
// CreateNewAnalysisAction createAnalysisAction = new CreateNewAnalysisAction(WorkbenchUtils.getPath(node),
// node);
// menu.add(createAnalysisAction);
// }
// }
}
Also used : TreeSelection(org.eclipse.jface.viewers.TreeSelection) AnalysisFolderRepNode(org.talend.dq.nodes.AnalysisFolderRepNode) RepositoryNode(org.talend.repository.model.RepositoryNode) CreateNewAnalysisAction(org.talend.dataprofiler.core.ui.action.actions.CreateNewAnalysisAction) AnalysisSubFolderRepNode(org.talend.dq.nodes.AnalysisSubFolderRepNode)

Aggregations

TreeSelection (org.eclipse.jface.viewers.TreeSelection)1 CreateNewAnalysisAction (org.talend.dataprofiler.core.ui.action.actions.CreateNewAnalysisAction)1 AnalysisFolderRepNode (org.talend.dq.nodes.AnalysisFolderRepNode)1 AnalysisSubFolderRepNode (org.talend.dq.nodes.AnalysisSubFolderRepNode)1 RepositoryNode (org.talend.repository.model.RepositoryNode)1