Search in sources :

Example 6 with SourceFileSubFolderNode

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

the class WorkspaceResourceHelperTest method testCheckSourceFileSubFolderNodeOpening.

/**
 * Test method for
 * {@link org.talend.dataprofiler.core.helper.WorkspaceResourceHelper#checkSourceFileSubFolderNodeOpening(org.talend.dq.nodes.SourceFileSubFolderNode)}
 * .
 */
@Test
public void testCheckSourceFileSubFolderNodeOpening() {
    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);
    ReturnCode rc2 = WorkspaceResourceHelper.checkSourceFileSubFolderNodeOpening(folderNodeMock);
    assertEquals(rc.isOk(), rc2.isOk());
    assertEquals(rc.getMessage(), rc2.getMessage());
}
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 7 with SourceFileSubFolderNode

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

the class DQDeleteAction method checkSourceFilesEditorOpening.

/**
 * DOC xqliu Comment method "checkSourceFilesEditorOpening".
 *
 * @param deleteElements
 * @return
 */
@SuppressWarnings({ "hiding", "rawtypes", "unchecked" })
private Object[] checkSourceFilesEditorOpening(Object[] deleteElements) {
    List list = new ArrayList();
    boolean opened = false;
    // $NON-NLS-1$
    String openSourceFileNames = "";
    for (Object obj : deleteElements) {
        if (obj instanceof SourceFileRepNode || obj instanceof JrxmlTempleteRepNode) {
            ReturnCode rc = WorkspaceResourceHelper.checkSourceFileNodeOpening((RepositoryNode) obj);
            if (rc.isOk()) {
                opened = rc.isOk();
                openSourceFileNames += rc.getMessage();
            } else {
                list.add(obj);
            }
        } else if (obj instanceof SourceFileSubFolderNode || obj instanceof JrxmlTempSubFolderNode) {
            ReturnCode rc = WorkspaceResourceHelper.checkSourceFileSubFolderNodeOpening((RepositoryNode) obj);
            if (rc.isOk()) {
                opened = rc.isOk();
                openSourceFileNames += rc.getMessage();
            } else {
                list.add(obj);
            }
        } else {
            list.add(obj);
        }
    }
    if (opened) {
        WorkspaceResourceHelper.showSourceFilesOpeningWarnMessages(openSourceFileNames);
    }
    return list.toArray();
}
Also used : ReturnCode(org.talend.utils.sugars.ReturnCode) ArrayList(java.util.ArrayList) SourceFileSubFolderNode(org.talend.dq.nodes.SourceFileSubFolderNode) List(java.util.List) ArrayList(java.util.ArrayList) SourceFileRepNode(org.talend.dq.nodes.SourceFileRepNode) JrxmlTempleteRepNode(org.talend.dq.nodes.JrxmlTempleteRepNode) DQRepositoryNode(org.talend.dq.nodes.DQRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) JrxmlTempSubFolderNode(org.talend.dq.nodes.JrxmlTempSubFolderNode)

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