use of org.talend.dq.nodes.SysIndicatorDefinitionRepNode in project tdq-studio-se by Talend.
the class AnalysisTableTreeViewer method createOneUnit.
public void createOneUnit(final TreeItem treeItem, TableIndicatorUnit indicatorUnit) {
final TreeItem indicatorItem = new TreeItem(treeItem, SWT.NONE);
final TableIndicatorUnit unit = indicatorUnit;
IndicatorEnum type = indicatorUnit.getType();
final IndicatorEnum indicatorEnum = type;
indicatorItem.setData(TABLE_INDICATOR_KEY, treeItem.getData(TABLE_INDICATOR_KEY));
indicatorItem.setData(INDICATOR_UNIT_KEY, unit);
indicatorItem.setData(VIEWER_KEY, this);
String label = indicatorUnit.getIndicatorName();
// $NON-NLS-1$
label = label != null ? label : "Unknown indicator";
SysIndicatorDefinitionRepNode recursiveFindIndicatorDefinition = RepositoryNodeHelper.recursiveFindIndicatorDefinition(indicatorUnit.getIndicator().getIndicatorDefinition());
if (recursiveFindIndicatorDefinition != null && !recursiveFindIndicatorDefinition.getProject().isMainProject()) {
label = label + recursiveFindIndicatorDefinition.getDisplayProjectName();
}
if (IndicatorEnum.WhereRuleIndicatorEnum.compareTo(type) == 0) {
indicatorItem.setImage(0, ImageLib.getImage(ImageLib.DQ_RULE));
} else if (IndicatorEnum.RowCountIndicatorEnum.compareTo(type) == 0) {
indicatorItem.setImage(0, ImageLib.getImage(ImageLib.IND_DEFINITION));
}
indicatorItem.setText(0, label);
TreeEditor optionEditor = new TreeEditor(tree);
// $NON-NLS-1$
final Label optionLabel = createTreeItemLabel(tree, ImageLib.OPTION, "AnalysisTableTreeViewer.options");
optionLabel.setData(indicatorUnit);
optionLabel.addMouseListener(new MouseAdapter() {
@Override
public void mouseDown(MouseEvent e) {
boolean hasIndicatorParameters = openIndicatorOptionDialog(Display.getCurrent().getActiveShell(), indicatorItem);
if (hasIndicatorParameters) {
optionLabel.setImage(ImageLib.getImage(ImageLib.INDICATOR_OPTION_CHECKED));
}
}
});
optionEditor.minimumWidth = optionLabel.getImage().getBounds().width;
optionEditor.horizontalAlignment = SWT.CENTER;
optionEditor.setEditor(optionLabel, indicatorItem, 1);
TreeEditor delEditor = null;
if (!(unit.getIndicator() instanceof RowCountIndicator)) {
delEditor = new TreeEditor(tree);
// $NON-NLS-1$
Label delLabel = createTreeItemLabel(tree, ImageLib.DELETE_ACTION, "AnalysisTableTreeViewer.delete");
delLabel.addMouseListener(new MouseAdapter() {
@Override
public void mouseDown(MouseEvent e) {
deleteIndicatorItems((TableIndicator) treeItem.getData(TABLE_INDICATOR_KEY), unit);
if (indicatorItem.getParentItem() != null && indicatorItem.getParentItem().getData(INDICATOR_UNIT_KEY) != null) {
setElements(tableIndicators);
} else {
removeItemBranch(indicatorItem);
indicatorTreeItemMap.remove(unit);
}
}
});
delEditor.minimumWidth = delLabel.getImage().getBounds().width;
delEditor.horizontalAlignment = SWT.CENTER;
delEditor.setEditor(delLabel, indicatorItem, 2);
}
if (delEditor == null) {
indicatorItem.setData(ITEM_EDITOR_KEY, new TreeEditor[] { optionEditor });
} else {
indicatorItem.setData(ITEM_EDITOR_KEY, new TreeEditor[] { optionEditor, delEditor });
}
if (indicatorEnum != null && indicatorEnum.hasChildren()) {
indicatorItem.setData(treeItem.getData(TABLE_INDICATOR_KEY));
createIndicatorItems(indicatorItem, indicatorUnit.getChildren());
}
if (hasIndicatorParameters(indicatorUnit)) {
optionLabel.setImage(ImageLib.getImage(ImageLib.INDICATOR_OPTION_CHECKED));
}
// ADD xqliu 2009-04-30 bug 6808
this.indicatorTreeItemMap.put(unit, indicatorItem);
}
use of org.talend.dq.nodes.SysIndicatorDefinitionRepNode in project tdq-studio-se by Talend.
the class RepositoryNodeHelper method recursiveFindIndicatorDefinition.
public static SysIndicatorDefinitionRepNode recursiveFindIndicatorDefinition(IndicatorDefinition indDef) {
if (indDef == null) {
return null;
}
String uuid = getUUID(indDef);
if (uuid == null) {
return null;
}
List<SysIndicatorDefinitionRepNode> indicatorDefinitionRepNodes;
if (ProxyRepositoryManager.getInstance().isMergeRefProject()) {
indicatorDefinitionRepNodes = getIndicatorDefinitionRepNodes(getLibrariesFolderNode(EResourceConstant.SYSTEM_INDICATORS), true, true);
indicatorDefinitionRepNodes.addAll(getIndicatorDefinitionRepNodes(getLibrariesFolderNode(EResourceConstant.USER_DEFINED_INDICATORS), true, true));
} else {
Project inWhichProject = getInWhichProject(indDef);
indicatorDefinitionRepNodes = getIndicatorDefinitionRepNodes(getLibrariesFolderNode(EResourceConstant.SYSTEM_INDICATORS, inWhichProject), true, true);
indicatorDefinitionRepNodes.addAll(getIndicatorDefinitionRepNodes(getLibrariesFolderNode(EResourceConstant.USER_DEFINED_INDICATORS, inWhichProject), true, true));
}
if (indicatorDefinitionRepNodes.size() > 0) {
for (SysIndicatorDefinitionRepNode childNode : indicatorDefinitionRepNodes) {
if (uuid.equals(getUUID(childNode.getIndicatorDefinition()))) {
return childNode;
}
}
}
return null;
}
use of org.talend.dq.nodes.SysIndicatorDefinitionRepNode in project tdq-studio-se by Talend.
the class ColumnViewerDND method installDND.
/**
* DOC qzhang Comment method "installDND".
*/
public static void installDND(final Tree targetControl) {
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
DQRespositoryView findView = (DQRespositoryView) activePage.findView(DQRespositoryView.ID);
final CommonViewer commonViewer = findView.getCommonViewer();
final LocalSelectionTransfer transfer = LocalSelectionTransfer.getTransfer();
int operations = DND.DROP_COPY | DND.DROP_MOVE;
Transfer[] transfers = new Transfer[] { transfer };
DropTarget dropTarget = new DropTarget(targetControl, operations);
dropTarget.setTransfer(transfers);
DropTargetListener dndListener = new TreeDropTargetEffect(targetControl) {
ISelectionReceiver receiver = null;
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.dnd.DropTargetAdapter#dragEnter(org.eclipse.swt .dnd.DropTargetEvent)
*/
@Override
public void dragEnter(DropTargetEvent event) {
super.dragEnter(event);
IStructuredSelection selection = (IStructuredSelection) LocalSelectionTransfer.getTransfer().getSelection();
Object object = selection.getFirstElement();
// if (object instanceof IFile) {
if (object instanceof SysIndicatorDefinitionRepNode) {
receiver = new UDIReceiver();
} else if (object instanceof PatternRepNode) {
receiver = new PatternReceiver();
}
// MOD klliu 15750 2011-01-17 for Drag&Drop On columnset
if (object instanceof DBColumnRepNode || object instanceof DBTableRepNode || object instanceof DFColumnRepNode) {
receiver = new ColumnReceiver();
}
if (receiver == null) {
event.detail = DND.DROP_NONE;
} else {
event.feedback = DND.FEEDBACK_EXPAND;
receiver.doDropValidation(event, commonViewer);
}
}
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.dnd.TreeDropTargetEffect#dragOver(org.eclipse .swt.dnd.DropTargetEvent)
*/
@Override
public void dragOver(DropTargetEvent event) {
super.dragOver(event);
// MOD yyi 2009-09-18 bug: 9044
if (null != receiver) {
receiver.doDropValidation(event, commonViewer);
}
}
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.dnd.DropTargetAdapter#drop(org.eclipse.swt.dnd .DropTargetEvent)
*/
@Override
public void drop(DropTargetEvent event) {
int index = targetControl.getItemCount();
super.drop(event);
if (event.item == null) {
// TreeItem item = new TreeItem(targetControl, SWT.NONE);
// item.setText(texts);
// item.setText(text);
index = 0;
} else {
TreeItem item = (TreeItem) event.item;
TreeItem[] items = targetControl.getItems();
for (int i = 0; i < items.length; i++) {
if (items[i] == item) {
index = i;
break;
}
}
}
receiver.drop(event, commonViewer, index);
}
};
dropTarget.addDropListener(dndListener);
}
use of org.talend.dq.nodes.SysIndicatorDefinitionRepNode in project tdq-studio-se by Talend.
the class ImageLib method getImageNameByRepositoryNode.
public static String getImageNameByRepositoryNode(IRepositoryNode node) {
String imageName = null;
IRepositoryViewObject viewObject = node.getObject();
ENodeType type = node.getType();
if (node instanceof ReportAnalysisRepNode) {
imageName = ImageLib.ANALYSIS_OBJECT;
} else if (node instanceof RecycleBinRepNode) {
imageName = ImageLib.RECYCLEBIN_EMPTY;
} else if (type.equals(ENodeType.SYSTEM_FOLDER)) {
String label = viewObject.getLabel();
if (label.equals(EResourceConstant.DATA_PROFILING.getName())) {
imageName = ImageLib.DATA_PROFILING;
} else if (label.equals(EResourceConstant.METADATA.getName())) {
imageName = ImageLib.METADATA;
} else if (node instanceof DBConnectionFolderRepNode) {
imageName = ImageLib.CONNECTION;
} else if (label.equals(EResourceConstant.FILEDELIMITED.getName())) {
imageName = ImageLib.FILE_DELIMITED;
} else if (label.equals(EResourceConstant.HADOOP_CLUSTER.getName())) {
imageName = ImageLib.HADOOP_CLUSTER;
} else if (label.equals(EResourceConstant.LIBRARIES.getName())) {
imageName = ImageLib.LIBRARIES;
} else if (label.equals(EResourceConstant.EXCHANGE.getName())) {
imageName = ImageLib.EXCHANGE;
} else {
imageName = ImageLib.FOLDERNODE_IMAGE;
}
} else if (type.equals(ENodeType.SIMPLE_FOLDER)) {
imageName = ImageLib.FOLDERNODE_IMAGE;
} else if (type.equals(ENodeType.REPOSITORY_ELEMENT)) {
if (node instanceof DBConnectionRepNode) {
imageName = ImageLib.TD_DATAPROVIDER;
} else if (node instanceof DFConnectionRepNode) {
imageName = ImageLib.FILE_DELIMITED;
} else if (node instanceof AnalysisRepNode) {
imageName = ImageLib.ANALYSIS_OBJECT;
} else if (node instanceof ReportRepNode) {
imageName = ImageLib.REPORT_OBJECT;
} else if (node instanceof SysIndicatorDefinitionRepNode) {
imageName = ImageLib.IND_DEFINITION;
} else if (node instanceof PatternRepNode) {
imageName = ImageLib.PATTERN_REG;
} else if (node instanceof RuleRepNode) {
imageName = ImageLib.DQ_RULE;
} else if (node instanceof SourceFileRepNode) {
imageName = ImageLib.SOURCE_FILE;
} else if (node instanceof ExchangeCategoryRepNode || node instanceof ExchangeComponentRepNode) {
imageName = ImageLib.EXCHANGE;
} else if (node instanceof JrxmlTempleteRepNode) {
imageName = ImageLib.JRXML_ICON;
}
} else if (type.equals(ENodeType.TDQ_REPOSITORY_ELEMENT)) {
if (node instanceof DBCatalogRepNode) {
imageName = ImageLib.CATALOG;
} else if (node instanceof DBSchemaRepNode) {
imageName = ImageLib.SCHEMA;
} else if (node instanceof DBTableFolderRepNode) {
imageName = ImageLib.FOLDERNODE_IMAGE;
} else if (node instanceof DBViewFolderRepNode) {
imageName = ImageLib.FOLDERNODE_IMAGE;
} else if (node instanceof DBTableRepNode || node instanceof DFTableRepNode) {
imageName = ImageLib.TABLE;
} else if (node instanceof DBViewRepNode) {
imageName = ImageLib.VIEW;
} else if (node instanceof DBColumnRepNode) {
if (((DBColumnRepNode) node).isKey()) {
imageName = ImageLib.PK_COLUMN;
} else {
imageName = ImageLib.TD_COLUMN;
}
} else if (node instanceof DFColumnRepNode) {
imageName = ImageLib.TD_COLUMN;
} else if (node instanceof DBColumnFolderRepNode || node instanceof DFColumnFolderRepNode) {
imageName = ImageLib.FOLDERNODE_IMAGE;
}
}
return imageName;
}
use of org.talend.dq.nodes.SysIndicatorDefinitionRepNode 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;
}
});
// ~
}
Aggregations