Search in sources :

Example 1 with SourceFileSubFolderNode

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

the class NewSourceFileActionProvider 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) {
        RepositoryNode node = (RepositoryNode) treeSelection.getFirstElement();
        if (node instanceof SourceFileSubFolderNode) {
            menu.add(new AddSqlFileAction(node));
            menu.add(new ImportSqlFileAction(node));
            menu.add(new RenameTdqFolderAction(node));
        } else if (node instanceof SourceFileFolderRepNode) {
            menu.add(new AddSqlFileAction(node));
            menu.add(new ImportSqlFileAction(node));
        } else if (node instanceof SourceFileRepNode) {
            // MOD klliu bug TDQ-4797 2012-02-29
            menu.add(new RenameSqlFileAction(node));
        }
        boolean isSelectFile = computeSelectedFiles(treeSelection, selectedFiles);
        if (isSelectFile && !selectedFiles.isEmpty()) {
            menu.add(new OpenSqlFileAction(selectedFiles));
        }
    }
}
Also used : RenameSqlFileAction(org.talend.dataprofiler.core.sql.RenameSqlFileAction) IFile(org.eclipse.core.resources.IFile) ArrayList(java.util.ArrayList) RepositoryNode(org.talend.repository.model.RepositoryNode) SourceFileRepNode(org.talend.dq.nodes.SourceFileRepNode) AddSqlFileAction(org.talend.dataprofiler.core.sql.AddSqlFileAction) SourceFileFolderRepNode(org.talend.dq.nodes.SourceFileFolderRepNode) TreeSelection(org.eclipse.jface.viewers.TreeSelection) RenameTdqFolderAction(org.talend.dataprofiler.core.ui.action.actions.RenameTdqFolderAction) SourceFileSubFolderNode(org.talend.dq.nodes.SourceFileSubFolderNode) ImportSqlFileAction(org.talend.dataprofiler.core.sql.ImportSqlFileAction) OpenSqlFileAction(org.talend.dataprofiler.core.sql.OpenSqlFileAction)

Example 2 with SourceFileSubFolderNode

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

the class TOPRepositoryServiceTest method testSourceFileOpening2.

/**
 * Test method for
 * {@link org.talend.dataprofiler.core.service.TOPRepositoryService#sourceFileOpening(org.talend.repository.model.RepositoryNode)}
 * .
 */
@Test
public void testSourceFileOpening2() {
    // test for SourceFileSubFolderNode
    SourceFileSubFolderNode folderNodeMock = mock(SourceFileSubFolderNode.class);
    SourceFileRepNode nodeMock = mock(SourceFileRepNode.class);
    List<IRepositoryNode> nodeList = new ArrayList<IRepositoryNode>();
    nodeList.add(nodeMock);
    when(folderNodeMock.getChildren()).thenReturn(nodeList);
    boolean ok = Boolean.TRUE;
    // $NON-NLS-1$
    String msg = "msg";
    ReturnCode rc = new ReturnCode(msg, ok);
    // $NON-NLS-1$
    stub(method(WorkspaceResourceHelper.class, "checkSourceFileNodeOpening", SourceFileRepNode.class)).toReturn(rc);
    TOPRepositoryService service = new TOPRepositoryService();
    assertTrue(service.sourceFileOpening(folderNodeMock));
}
Also used : ReturnCode(org.talend.utils.sugars.ReturnCode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ArrayList(java.util.ArrayList) SourceFileSubFolderNode(org.talend.dq.nodes.SourceFileSubFolderNode) SourceFileRepNode(org.talend.dq.nodes.SourceFileRepNode) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 3 with SourceFileSubFolderNode

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

the class WorkspaceResourceHelper method checkSourceFileSubFolderNodeOpening.

/**
 * DOC xqliu Comment method "checkSourceFileSubFolderNodeOpening".
 *
 * @param node
 * @return
 */
public static ReturnCode checkSourceFileSubFolderNodeOpening(RepositoryNode node) {
    boolean opened = false;
    // $NON-NLS-1$
    String msg = "";
    List<IRepositoryNode> children = node.getChildren();
    for (IRepositoryNode iNode : children) {
        if (iNode instanceof SourceFileRepNode || iNode instanceof JrxmlTempleteRepNode) {
            ReturnCode rc = checkSourceFileNodeOpening((RepositoryNode) iNode);
            if (rc.isOk()) {
                opened = rc.isOk();
                msg += rc.getMessage();
            }
        } else if (iNode instanceof SourceFileSubFolderNode || iNode instanceof JrxmlTempSubFolderNode) {
            ReturnCode rc = checkSourceFileSubFolderNodeOpening((RepositoryNode) iNode);
            if (rc.isOk()) {
                opened = rc.isOk();
                msg += rc.getMessage();
            }
        }
    }
    return new ReturnCode(msg, opened);
}
Also used : ReturnCode(org.talend.utils.sugars.ReturnCode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) SourceFileSubFolderNode(org.talend.dq.nodes.SourceFileSubFolderNode) SourceFileRepNode(org.talend.dq.nodes.SourceFileRepNode) JrxmlTempleteRepNode(org.talend.dq.nodes.JrxmlTempleteRepNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) JrxmlTempSubFolderNode(org.talend.dq.nodes.JrxmlTempSubFolderNode)

Example 4 with SourceFileSubFolderNode

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

the class RepositoryNodeHelper method getSourceFileRepNodes.

/**
 * get SourceFileRepNodes which under the parentNode.
 *
 * @param parentNode
 * @param recursive
 * @return
 */
public static List<SourceFileRepNode> getSourceFileRepNodes(IRepositoryNode parentNode, boolean recursive) {
    List<SourceFileRepNode> result = new ArrayList<SourceFileRepNode>();
    List<IRepositoryNode> children = parentNode.getChildren();
    for (IRepositoryNode node : children) {
        if (node instanceof SourceFileRepNode) {
            result.add((SourceFileRepNode) node);
        } else if (node instanceof SourceFileFolderRepNode || node instanceof SourceFileSubFolderNode) {
            if (recursive) {
                result.addAll(getSourceFileRepNodes(node, recursive));
            }
        }
    }
    return result;
}
Also used : SourceFileFolderRepNode(org.talend.dq.nodes.SourceFileFolderRepNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ArrayList(java.util.ArrayList) SourceFileSubFolderNode(org.talend.dq.nodes.SourceFileSubFolderNode) SourceFileRepNode(org.talend.dq.nodes.SourceFileRepNode)

Example 5 with SourceFileSubFolderNode

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

the class UnitTestBuildHelper method createRealSourceFileSubFolderRepNode.

public static SourceFileSubFolderNode createRealSourceFileSubFolderRepNode(RepositoryNode parentNode, String folderName) {
    SourceFileSubFolderNode folderNode = null;
    // create the sub folder
    IFolder iFolder = RepositoryNodeHelper.getIFolder(parentNode);
    createRealFolder(iFolder, folderName);
    List<IRepositoryNode> subFolders = new ArrayList<IRepositoryNode>();
    if (parentNode instanceof SourceFileFolderRepNode) {
        subFolders = ((SourceFileFolderRepNode) parentNode).getChildren(false);
    } else if (parentNode instanceof SourceFileSubFolderNode) {
        subFolders = ((SourceFileSubFolderNode) parentNode).getChildren(false);
    }
    if (!subFolders.isEmpty()) {
        for (IRepositoryNode node : subFolders) {
            if (node instanceof SourceFileSubFolderNode) {
                SourceFileSubFolderNode subNode = (SourceFileSubFolderNode) node;
                if (folderName.equals(subNode.getLabel())) {
                    folderNode = subNode;
                    break;
                }
            }
        }
    }
    return folderNode;
}
Also used : SourceFileFolderRepNode(org.talend.dq.nodes.SourceFileFolderRepNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ArrayList(java.util.ArrayList) SourceFileSubFolderNode(org.talend.dq.nodes.SourceFileSubFolderNode) IFolder(org.eclipse.core.resources.IFolder)

Aggregations

SourceFileSubFolderNode (org.talend.dq.nodes.SourceFileSubFolderNode)7 ArrayList (java.util.ArrayList)6 SourceFileRepNode (org.talend.dq.nodes.SourceFileRepNode)6 IRepositoryNode (org.talend.repository.model.IRepositoryNode)6 ReturnCode (org.talend.utils.sugars.ReturnCode)4 SourceFileFolderRepNode (org.talend.dq.nodes.SourceFileFolderRepNode)3 RepositoryNode (org.talend.repository.model.RepositoryNode)3 Test (org.junit.Test)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 JrxmlTempSubFolderNode (org.talend.dq.nodes.JrxmlTempSubFolderNode)2 JrxmlTempleteRepNode (org.talend.dq.nodes.JrxmlTempleteRepNode)2 List (java.util.List)1 IFile (org.eclipse.core.resources.IFile)1 IFolder (org.eclipse.core.resources.IFolder)1 TreeSelection (org.eclipse.jface.viewers.TreeSelection)1 AddSqlFileAction (org.talend.dataprofiler.core.sql.AddSqlFileAction)1 ImportSqlFileAction (org.talend.dataprofiler.core.sql.ImportSqlFileAction)1 OpenSqlFileAction (org.talend.dataprofiler.core.sql.OpenSqlFileAction)1 RenameSqlFileAction (org.talend.dataprofiler.core.sql.RenameSqlFileAction)1 RenameTdqFolderAction (org.talend.dataprofiler.core.ui.action.actions.RenameTdqFolderAction)1