use of org.talend.dq.nodes.SourceFileRepNode 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.SourceFileRepNode 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.SourceFileRepNode in project tdq-studio-se by Talend.
the class UnitTestBuildHelper method createRealSourceFileNode.
public static SourceFileRepNode createRealSourceFileNode(String name, RepositoryNode parentNode, IPath createPath, Boolean isDelete) {
SourceFileRepNode fileRepNode = null;
TDQSourceFileItem sourceFileItem = PropertiesFactoryImpl.eINSTANCE.createTDQSourceFileItem();
org.talend.core.model.properties.Property fileProperty = PropertiesFactory.eINSTANCE.createProperty();
fileProperty.setId(EcoreUtil.generateUUID());
fileProperty.setItem(sourceFileItem);
fileProperty.setLabel(name);
sourceFileItem.setProperty(fileProperty);
sourceFileItem.setFilename(name);
sourceFileItem.setName(name);
ByteArray byteArray = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createByteArray();
byteArray.setInnerContent(PluginConstant.EMPTY_STRING.getBytes());
sourceFileItem.setContent(byteArray);
ItemState itemState = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createItemState();
itemState.setDeleted(isDelete);
sourceFileItem.setState(itemState);
try {
ProxyRepositoryFactory.getInstance().create(sourceFileItem, createPath, false);
IRepositoryViewObject fileViewObject = new RepositoryViewObject(fileProperty);
fileRepNode = new SourceFileRepNode(fileViewObject, parentNode, ENodeType.REPOSITORY_ELEMENT, null);
fileRepNode.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.TDQ_SOURCE_FILE_ELEMENT);
fileRepNode.setProperties(EProperties.LABEL, ERepositoryObjectType.TDQ_SOURCE_FILE_ELEMENT);
fileViewObject.setRepositoryNode(fileRepNode);
} catch (PersistenceException e) {
Assert.fail(e.getMessage());
}
return fileRepNode;
}
use of org.talend.dq.nodes.SourceFileRepNode in project tdq-studio-se by Talend.
the class WorkspaceResourceHelperTest method testCheckSourceFileNodeOpening.
/**
* Test method for
* {@link org.talend.dataprofiler.core.helper.WorkspaceResourceHelper#checkSourceFileNodeOpening(org.talend.dq.nodes.SourceFileRepNode)}
* .
*/
@Test
public void testCheckSourceFileNodeOpening() {
SourceFileRepNode fileNodeMock = mock(SourceFileRepNode.class);
// $NON-NLS-1$
String nodeLabel = "nodeLabel";
when(fileNodeMock.getLabel()).thenReturn(nodeLabel);
// $NON-NLS-1$
stub(method(WorkspaceResourceHelper.class, "sourceFileHasBeenOpened", SourceFileRepNode.class)).toReturn(Boolean.TRUE);
ReturnCode rc = WorkspaceResourceHelper.checkSourceFileNodeOpening(fileNodeMock);
assertTrue(rc.isOk());
assertTrue(rc.getMessage().startsWith(nodeLabel));
}
use of org.talend.dq.nodes.SourceFileRepNode in project tdq-studio-se by Talend.
the class RepositoryNodeHelper method recursiveFindFile.
/**
* DOC msjian Comment method "recursiveFindFile".
*
* @param file
* @return
*/
public static DQRepositoryNode recursiveFindFile(IFile file) {
if (file == null) {
return null;
}
String fileName = file.getName();
List<?> fileRepNodes = null;
if (fileName.toLowerCase().endsWith(PluginConstant.JRXML_STRING)) {
fileRepNodes = getJrxmlFileRepNodes(getLibrariesFolderNode(EResourceConstant.JRXML_TEMPLATE), true);
} else if (fileName.toLowerCase().endsWith(PluginConstant.SQL_STRING)) {
fileRepNodes = getSourceFileRepNodes(getLibrariesFolderNode(EResourceConstant.SOURCE_FILES), true);
}
if (fileRepNodes != null) {
for (int i = 0; i < fileRepNodes.size(); i++) {
DQRepositoryNode childNode = (DQRepositoryNode) fileRepNodes.get(i);
String childNodeFileName = PluginConstant.EMPTY_STRING;
if (childNode instanceof JrxmlTempleteRepNode) {
childNodeFileName = childNode.getObject().getProperty().eResource().getURI().lastSegment().replaceAll(PluginConstant.PROPERTIES_STRING, PluginConstant.JRXML_STRING);
} else if (childNode instanceof SourceFileRepNode) {
childNodeFileName = childNode.getObject().getProperty().eResource().getURI().lastSegment().replaceAll(PluginConstant.PROPERTIES_STRING, PluginConstant.SQL_STRING);
}
if (fileName.equals(childNodeFileName)) {
return childNode;
}
}
}
return null;
}
Aggregations