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));
}
}
}
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));
}
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);
}
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;
}
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;
}
Aggregations