Search in sources :

Example 1 with ImportPatternsAction

use of org.talend.dataprofiler.core.pattern.actions.ImportPatternsAction in project tdq-studio-se by Talend.

the class NewSourcePatternActionProvider method fillContextMenu.

public void fillContextMenu(IMenuManager menu) {
    // MOD mzhao user readonly role on svn repository mode.
    if (!isShowMenu()) {
        return;
    }
    TreeSelection treeSelection = ((TreeSelection) this.getContext().getSelection());
    List<IFile> selectedFiles = new ArrayList<IFile>();
    if (treeSelection.size() == 1) {
        Object obj = treeSelection.getFirstElement();
        if (obj instanceof RepositoryNode) {
            RepositoryNode node = (RepositoryNode) obj;
            if (ENodeType.SYSTEM_FOLDER.equals(node.getType()) || ENodeType.SIMPLE_FOLDER.equals(node.getType())) {
                try {
                    IFolder folder = WorkbenchUtils.getFolder(node);
                    ExpressionType type = null;
                    if (ResourceService.isSubFolder(ResourceManager.getPatternRegexFolder(), folder)) {
                        type = ExpressionType.REGEXP;
                    } else if (ResourceService.isSubFolder(ResourceManager.getPatternSQLFolder(), folder)) {
                        type = ExpressionType.SQL_LIKE;
                    }
                    if (type != null) {
                        menu.add(new CreatePatternAction(folder, type));
                        menu.add(new ImportPatternsAction(node, type));
                        menu.add(new ExportPatternsAction(node, false));
                        menu.add(new ExportPatternsAction(node, true));
                    }
                } catch (Exception e) {
                    log.error(e, e);
                }
            }
        }
    // else if (obj instanceof IFile) {
    // IFile file = (IFile) obj;
    // if (EXTENSION_PATTERN.equalsIgnoreCase(file.getFileExtension())) {
    // // menu.add(new RenameSqlFileAction((IFile) obj));
    // }
    // }
    }
    boolean isSelectFile = computeSelectedFiles(treeSelection, selectedFiles);
    if (!isSelectFile && !selectedFiles.isEmpty()) {
    // menu.add(new OpenSqlFileAction(selectedFiles));
    // menu.add(new DeletePatternAction(selectedFiles));
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) ArrayList(java.util.ArrayList) ImportPatternsAction(org.talend.dataprofiler.core.pattern.actions.ImportPatternsAction) RepositoryNode(org.talend.repository.model.RepositoryNode) ExportPatternsAction(org.talend.dataprofiler.core.pattern.actions.ExportPatternsAction) TreeSelection(org.eclipse.jface.viewers.TreeSelection) CreatePatternAction(org.talend.dataprofiler.core.pattern.actions.CreatePatternAction) ExpressionType(org.talend.dataquality.domain.pattern.ExpressionType) IFolder(org.eclipse.core.resources.IFolder)

Aggregations

ArrayList (java.util.ArrayList)1 IFile (org.eclipse.core.resources.IFile)1 IFolder (org.eclipse.core.resources.IFolder)1 TreeSelection (org.eclipse.jface.viewers.TreeSelection)1 CreatePatternAction (org.talend.dataprofiler.core.pattern.actions.CreatePatternAction)1 ExportPatternsAction (org.talend.dataprofiler.core.pattern.actions.ExportPatternsAction)1 ImportPatternsAction (org.talend.dataprofiler.core.pattern.actions.ImportPatternsAction)1 ExpressionType (org.talend.dataquality.domain.pattern.ExpressionType)1 RepositoryNode (org.talend.repository.model.RepositoryNode)1