use of org.talend.dq.nodes.DQRepositoryNode in project tdq-studio-se by Talend.
the class RepositoryNodeHelper method getRootNode.
public static RepositoryNode getRootNode(ERepositoryObjectType nodeType, boolean open, org.talend.core.model.general.Project project) {
DQRepositoryNode node = null;
FolderItem folderItem = ProxyRepositoryFactory.getInstance().getFolderItem(project, nodeType, Path.EMPTY);
CommonViewer commonViewer = getDQCommonViewer(open);
if (commonViewer != null) {
TreeItem[] items = commonViewer.getTree().getItems();
for (TreeItem item : items) {
node = (DQRepositoryNode) item.getData();
DQRepositoryNode matchNode = getMatchNode(project, node, folderItem);
if (matchNode != null) {
return matchNode;
}
}
// $NON-NLS-1$
log.error(Messages.getString("RepositoryNodeHelper.canNotFindRootNode") + nodeType.getLabel());
}
return node;
}
use of org.talend.dq.nodes.DQRepositoryNode in project tdq-studio-se by Talend.
the class ExportWizardPage method createRepositoryTree.
/**
* DOC bZhou Comment method "createRepositoryTree".
*
* @param top
*/
protected void createRepositoryTree(Composite top) {
Composite treeComposite = new Composite(top, SWT.NONE);
treeComposite.setLayout(new GridLayout(2, false));
treeComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
repositoryTree = new ContainerCheckedTreeViewer(treeComposite);
repositoryTree.setContentProvider(new FileTreeContentProvider());
repositoryTree.setLabelProvider(new FileTreeLabelProvider());
repositoryTree.setInput(writer.computeInput(specifiedPath));
repositoryTree.expandAll();
repositoryTree.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
// ADD msjian TDQ-14573: automatically checked the initial selected items.
if (intCheckedElements != null) {
List<ItemRecord> selectedItemRecords = new ArrayList<ItemRecord>();
for (Object intCheckedElement : intCheckedElements) {
getFileFromNode(selectedItemRecords, (IRepositoryNode) intCheckedElement);
}
repositoryTree.setCheckedElements(selectedItemRecords.toArray());
}
// show the same order with repository tree
repositoryTree.setComparator(new ViewerComparator() {
@Override
public int compare(Viewer iviewer, Object o1, Object o2) {
DQRepositoryNode recursiveFind = RepositoryNodeHelper.recursiveFind(((ItemRecord) o1).getElement());
DQRepositoryNode recursiveFind2 = RepositoryNodeHelper.recursiveFind(((ItemRecord) o2).getElement());
return new RepositoryNodeComparator().compare(recursiveFind, recursiveFind2);
}
});
// TDQ-14573~
createUtilityButtons(treeComposite);
}
use of org.talend.dq.nodes.DQRepositoryNode in project tdq-studio-se by Talend.
the class AnalysisWriter method addDependencies.
/*
* (non-Javadoc)
*
* @see org.talend.dq.writer.AElementPersistance#addDependencies(orgomg.cwm.objectmodel.core.ModelElement)
*/
@Override
public void addDependencies(ModelElement element) {
Analysis analysis = (Analysis) element;
List<IndicatorDefinition> udis = AnalysisHelper.getUserDefinedIndicators(analysis);
try {
for (IndicatorDefinition udi : udis) {
if (udi == null) {
continue;
}
InternalEObject iudi = (InternalEObject) udi;
if (!iudi.eIsProxy()) {
DQRepositoryNode recursiveFind = RepositoryNodeHelper.recursiveFind(udi);
// only do save when the dependency is not reference project node
if (recursiveFind != null && recursiveFind.getProject().isMainProject()) {
TypedReturnCode<Dependency> dependencyReturn = DependenciesHandler.getInstance().setDependencyOn(analysis, udi);
if (dependencyReturn.isOk()) {
Property property = PropertyHelper.getProperty(udi);
if (property != null) {
TDQItem udiItem = (TDQItem) property.getItem();
if (udiItem instanceof TDQIndicatorDefinitionItem) {
((TDQIndicatorDefinitionItem) udiItem).setIndicatorDefinition(udi);
} else if (udiItem instanceof TDQBusinessRuleItem) {
((TDQBusinessRuleItem) udiItem).setDqrule((DQRule) udi);
}
}
ProxyRepositoryFactory.getInstance().getRepositoryFactoryFromProvider().getResourceManager().saveResource(udi.eResource());
}
}
}
}
List<Pattern> patterns = AnalysisHelper.getPatterns(analysis);
for (Pattern pattern : patterns) {
InternalEObject iptn = (InternalEObject) pattern;
if (!iptn.eIsProxy()) {
DQRepositoryNode recursiveFind = RepositoryNodeHelper.recursiveFind(pattern);
// only do save when the dependency is not reference project node
if (recursiveFind != null && recursiveFind.getProject().isMainProject()) {
TypedReturnCode<Dependency> dependencyReturn = DependenciesHandler.getInstance().setDependencyOn(analysis, pattern);
if (dependencyReturn.isOk()) {
Property property = PropertyHelper.getProperty(pattern);
if (property != null && property.getItem() instanceof TDQPatternItem) {
TDQPatternItem patternItem = (TDQPatternItem) property.getItem();
patternItem.setPattern(pattern);
}
ProxyRepositoryFactory.getInstance().getRepositoryFactoryFromProvider().getResourceManager().saveResource(pattern.eResource());
// EMFUtil.saveSingleResource(pattern.eResource());
}
}
}
}
} catch (PersistenceException e) {
log.error(e, e);
}
}
use of org.talend.dq.nodes.DQRepositoryNode in project tdq-studio-se by Talend.
the class DQRespositoryView method createPartControl.
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.navigator.CommonNavigator#createPartControl(org.eclipse .swt.widgets.Composite)
*/
@Override
public void createPartControl(Composite parent) {
parent.setLayout(new BorderLayout());
Composite topComp = new Composite(parent, SWT.NONE);
topComp.setFont(parent.getFont());
topComp.setLayoutData(BorderLayout.NORTH);
Composite bottomComp = new Composite(parent, SWT.NONE);
bottomComp.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
bottomComp.setFont(parent.getFont());
bottomComp.setLayoutData(BorderLayout.CENTER);
topComp.setLayout(new BorderLayout());
FillLayout bottomLayout = new FillLayout(SWT.VERTICAL);
bottomComp.setLayout(bottomLayout);
createTreeFilter(topComp);
super.createPartControl(bottomComp);
// For removing the popup menu of DQRepositoryView.
// $NON-NLS-1$
MenuManager menuMgr = new MenuManager("org.talend.dataprofiler.core.ui.views.DQRespositoryView");
menuMgr.setRemoveAllWhenShown(true);
menuMgr.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager menuManager) {
ISelection selection = getCommonViewer().getSelection();
getNavigatorActionService().setContext(new ActionContext(selection));
getNavigatorActionService().fillContextMenu(menuManager);
}
});
Menu menu = menuMgr.createContextMenu(getCommonViewer().getTree());
getCommonViewer().getTree().setMenu(menu);
this.addViewerFilter(EMFObjFilter.FILTER_ID);
this.addViewerFilter(ReportingFilter.FILTER_ID);
this.addViewerFilter(FolderObjFilter.FILTER_ID);
adjustFilter();
activateContext();
getCommonViewer().setSorter(null);
getCommonViewer().getTree().addTreeListener(new TreeAdapter() {
@Override
public void treeExpanded(TreeEvent e) {
TreeItem item = (TreeItem) e.item;
if (!item.getText().endsWith(")")) {
// $NON-NLS-1$
Object obj = item.getData();
if (obj instanceof TableFolderNode || obj instanceof ViewFolderNode || obj instanceof ColumnFolderNode) {
// $NON-NLS-1$ //$NON-NLS-2$
item.setText(item.getText() + "(" + item.getItemCount() + ")");
}
}
super.treeExpanded(e);
}
});
getCommonViewer().getTree().addMouseListener(new MouseAdapter() {
@Override
public void mouseDoubleClick(MouseEvent e) {
boolean superDoubleClick = true;
Tree tree = (Tree) e.getSource();
Point point = new Point(e.x, e.y);
final TreeItem item = tree.getItem(point);
if (item != null) {
Object obj = item.getData();
if (obj instanceof AbstractFolderNode) {
AbstractFolderNode node = (AbstractFolderNode) obj;
node.loadChildren();
Object[] children = node.getChildren();
if (children != null) {
if (item.getText().indexOf("(") > 0) {
// $NON-NLS-1$
item.setText(// $NON-NLS-1$ //$NON-NLS-2$
item.getText().substring(0, item.getText().indexOf("(")) + "(" + children.length + // $NON-NLS-1$
")");
} else {
// $NON-NLS-1$ //$NON-NLS-2$
item.setText(item.getText() + "(" + children.length + ")");
}
}
}
if (obj instanceof IndicatorDefinition) {
IndicatorDefinition indicatorDefinition = (IndicatorDefinition) obj;
// reload object
indicatorDefinition = DefinitionHandler.getInstance().getIndicatorDefinition(indicatorDefinition.getLabel());
IndicatorEditorInput input = new IndicatorEditorInput(indicatorDefinition);
try {
CorePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(input, IndicatorEditor.class.getName());
} catch (PartInitException e1) {
log.error(e1, e1);
}
}
if (obj instanceof DQRepositoryNode) {
if (obj instanceof ReportFileRepNode) {
new OpenItemEditorAction(new IRepositoryNode[] { (IRepositoryNode) obj }).run();
} else if (obj instanceof DFConnectionRepNode) {
new EditFileDelimitedAction((IRepositoryNode) obj).run();
} else if (obj instanceof HadoopClusterConnectionRepNode && HadoopClusterUtils.getDefault().isServiceInstalled()) {
new EditHadoopClusterAction((IRepositoryNode) obj).run();
} else if (obj instanceof HDFSOfHCConnectionNode && HadoopClusterUtils.getDefault().isServiceInstalled()) {
new EditHDFSConnectionAction((IRepositoryNode) obj).run();
} else if (obj instanceof DFTableRepNode) {
new EditDFTableAction((IRepositoryNode) obj).run();
} else if (obj instanceof ContextRepNode) {
new DQEditContextAction((ContextRepNode) obj, false).run();
} else {
DQRepositoryNode repoNode = (DQRepositoryNode) obj;
if (RepositoryNodeHelper.canOpenEditor(repoNode)) {
OpenItemEditorAction openItemEditorAction = new OpenItemEditorAction(new IRepositoryNode[] { repoNode });
openItemEditorAction.run();
}
if (repoNode instanceof AnalysisRepNode || repoNode instanceof ReportRepNode || repoNode instanceof SysIndicatorDefinitionRepNode || repoNode instanceof PatternRepNode || repoNode instanceof RuleRepNode) {
superDoubleClick = false;
}
}
}
}
if (superDoubleClick) {
super.mouseDoubleClick(e);
}
}
});
getCommonViewer().getTree().addKeyListener(new KeyListener() {
public void keyPressed(KeyEvent e) {
if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) {
Tree tree = (Tree) e.getSource();
TreeItem[] selection = tree.getSelection();
for (TreeItem item : selection) {
Object data = item.getData();
DQRepositoryNode repoNode = (DQRepositoryNode) data;
if (RepositoryNodeHelper.canOpenEditor(repoNode)) {
OpenItemEditorAction openItemEditorAction = new OpenItemEditorAction(new IRepositoryNode[] { repoNode });
openItemEditorAction.run();
}
}
}
}
public void keyReleased(KeyEvent e) {
// do nothing here until now
}
});
// ~ADD mzhao for feature 6233 Load columns when selecting a table (or
// view) in DQ Repository view
getCommonViewer().addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
TreeSelection selection = (TreeSelection) event.getSelection();
Iterator<?> iterator = selection.iterator();
while (iterator.hasNext()) {
Object selectedElement = iterator.next();
if (selectedElement instanceof DBTableRepNode || selectedElement instanceof DBViewRepNode) {
((RepositoryNode) selectedElement).getChildren().get(0).getChildren();
}
}
}
});
// MOD mzhao 2011-03-10 bug 19147: filter MDM entries.
getCommonViewer().addFilter(new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (element instanceof IProject) {
return false;
}
return true;
}
});
// ~
}
use of org.talend.dq.nodes.DQRepositoryNode in project tdq-studio-se by Talend.
the class ResourceViewContentProvider method handleReferenced.
@SuppressWarnings("unchecked")
private void handleReferenced(RepositoryNode parent) {
Project currentProject = ((DQRepositoryNode) parent).getProject();
if (parent.getType().equals(ENodeType.SYSTEM_FOLDER)) {
for (ProjectReference refProject : (List<ProjectReference>) currentProject.getEmfProject().getReferencedProjects()) {
String parentBranch = ProjectManager.getInstance().getMainProjectBranch(currentProject);
// if not a DB ref project, modified by nma, order 12519
org.talend.core.model.properties.Project emfProject = refProject.getReferencedProject();
if (// $NON-NLS-1$
emfProject.getUrl() != null && emfProject.getUrl().startsWith("teneo") || (refProject.getBranch() != null && refProject.getBranch().equals(parentBranch))) {
DQRepositoryNode referencedProjectNode = new DQRepositoryNode(null, parent, ENodeType.REFERENCED_PROJECT, currentProject);
referencedProjectNode.setProperties(EProperties.LABEL, emfProject.getLabel());
referencedProjectNode.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.REFERENCED_PROJECTS);
parent.getChildren().add(referencedProjectNode);
try {
// org.talend.core.model.general.Project refGeneralProject = new
// org.talend.core.model.general.Project(
// emfProject, false);
Object[] createWorkspaceRootChildren = createWorkspaceRootChildren(ResourceManager.getRoot(), emfProject.getTechnicalLabel());
referencedProjectNode.getChildren().addAll((Collection<? extends IRepositoryNode>) Arrays.asList(createWorkspaceRootChildren));
} catch (CoreException e) {
log.error(e, e);
}
}
}
}
}
Aggregations