use of org.talend.dataprofiler.core.ui.editor.preview.TableIndicatorUnit in project tdq-studio-se by Talend.
the class TableIndicator method createCategoryIndicatorUnits.
private TableIndicatorUnit[] createCategoryIndicatorUnits(IndicatorEnum[] indicatorEnums) {
List<TableIndicatorUnit> indicatorUnitList = new ArrayList<TableIndicatorUnit>();
TableIndicatorUnit indicatorUnit;
for (IndicatorEnum indicatorEnum : indicatorEnums) {
if (!IndicatorEnum.isPlainIndicatorEnum(indicatorEnum)) {
continue;
}
indicatorUnit = getIndicatorUnit(indicatorEnum);
indicatorUnitList.add(indicatorUnit);
}
return indicatorUnitList.toArray(new TableIndicatorUnit[indicatorUnitList.size()]);
}
use of org.talend.dataprofiler.core.ui.editor.preview.TableIndicatorUnit 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.dataprofiler.core.ui.editor.preview.TableIndicatorUnit in project tdq-studio-se by Talend.
the class AnalysisTableTreeViewer method createTree.
private Tree createTree(Composite parent) {
final Tree newTree = new TooltipTree(parent, SWT.MULTI | SWT.BORDER) {
@Override
protected boolean isValidItem(TreeItem item) {
if (item == null) {
return false;
}
Object itemData = item.getData(INDICATOR_UNIT_KEY);
if (itemData != null) {
TableIndicatorUnit indicatorUnit = (TableIndicatorUnit) item.getData(INDICATOR_UNIT_KEY);
if (indicatorUnit != null && !(indicatorUnit.getIndicator() instanceof CompositeIndicator)) {
return true;
}
return false;
} else {
return false;
}
}
@Override
protected String getItemTooltipText(TreeItem item) {
String expCont = isExpressionNull(item);
if (expCont == null) {
// $NON-NLS-1$
return DefaultMessagesImpl.getString("AnalysisTableTreeViewer.queryNotGen");
}
return expCont;
}
};
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(newTree);
newTree.setHeaderVisible(true);
// $NON-NLS-1$
createTreeItem(newTree, 190, "AnalysisTableTreeViewer.analyzedTables");
// $NON-NLS-1$
createTreeItem(newTree, 80, "AnalysisTableTreeViewer.dqrule");
// $NON-NLS-1$
createTreeItem(newTree, 80, "AnalysisColumnTreeViewer.operation");
parent.layout();
AbstractAnalysisActionHandler actionHandler = new AbstractAnalysisActionHandler(parent) {
@Override
protected void handleRemove() {
removeSelectedElements(newTree);
}
};
parent.setData(AbstractMetadataFormPage.ACTION_HANDLER, actionHandler);
TableViewerDND.installDND(newTree);
this.addTreeListener(newTree);
newTree.setData(this);
return newTree;
}
use of org.talend.dataprofiler.core.ui.editor.preview.TableIndicatorUnit in project tdq-studio-se by Talend.
the class AnalysisTableTreeViewer method removeUncheckedWhereRuleIndicator.
/**
* DOC xqliu Comment method "removeUncheckedWhereRuleIndicator". ADD xqliu 2009-04-30 bug 6808
*
* @param ownedWhereRuleNodes
* @param results
* @param tableIndicator
*/
private void removeUncheckedWhereRuleIndicator(Object[] ownedWhereRuleNodes, Object[] results, TableIndicator tableIndicator) {
ArrayList<Object> removeList = new ArrayList<Object>();
for (Object node : ownedWhereRuleNodes) {
boolean remove = true;
for (Object result : results) {
if (node.equals(result)) {
remove = false;
break;
}
}
if (remove) {
removeList.add(node);
}
}
TableIndicatorUnit[] indicatorUnits = tableIndicator.getIndicatorUnits();
for (TableIndicatorUnit unit : indicatorUnits) {
IndicatorDefinition indicatorDefinition = unit.getIndicator().getIndicatorDefinition();
if (indicatorDefinition instanceof WhereRule) {
WhereRule wr = (WhereRule) indicatorDefinition;
RuleRepNode recursiveFindNode = RepositoryNodeHelper.recursiveFindRuleSql(wr);
for (Object obj : removeList) {
RuleRepNode node = (RuleRepNode) obj;
if (recursiveFindNode.equals(node)) {
// the order can not be changed
removeItemBranch(this.indicatorTreeItemMap.get(unit));
deleteIndicatorItems(tableIndicator, unit);
// ~the order can not be changed
break;
}
}
}
}
}
use of org.talend.dataprofiler.core.ui.editor.preview.TableIndicatorUnit in project tdq-studio-se by Talend.
the class AnalysisTableTreeViewer method deleteIndicatorItems.
/**
* delete all TableIndicatorUnit which contain in the tableIndicator.
*/
private void deleteIndicatorItems(TableIndicator tableIndicator) {
for (TableIndicatorUnit indiUnit : tableIndicator.getIndicatorUnits()) {
tableIndicator.removeIndicatorUnit(indiUnit);
this.indicatorTreeItemMap.remove(indiUnit);
}
}
Aggregations