Search in sources :

Example 1 with TableIndicatorUnit

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()]);
}
Also used : IndicatorEnum(org.talend.dq.nodes.indicator.type.IndicatorEnum) ArrayList(java.util.ArrayList) TableIndicatorUnit(org.talend.dataprofiler.core.ui.editor.preview.TableIndicatorUnit)

Example 2 with TableIndicatorUnit

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);
}
Also used : TableIndicator(org.talend.dataprofiler.core.model.TableIndicator) MouseEvent(org.eclipse.swt.events.MouseEvent) IndicatorEnum(org.talend.dq.nodes.indicator.type.IndicatorEnum) TreeEditor(org.eclipse.swt.custom.TreeEditor) TreeItem(org.eclipse.swt.widgets.TreeItem) SysIndicatorDefinitionRepNode(org.talend.dq.nodes.SysIndicatorDefinitionRepNode) Label(org.eclipse.swt.widgets.Label) MouseAdapter(org.eclipse.swt.events.MouseAdapter) TableIndicatorUnit(org.talend.dataprofiler.core.ui.editor.preview.TableIndicatorUnit) RowCountIndicator(org.talend.dataquality.indicators.RowCountIndicator)

Example 3 with TableIndicatorUnit

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;
}
Also used : AbstractAnalysisActionHandler(org.talend.dataprofiler.core.ui.editor.AbstractAnalysisActionHandler) TreeItem(org.eclipse.swt.widgets.TreeItem) CompositeIndicator(org.talend.dataquality.indicators.CompositeIndicator) TooltipTree(org.talend.dataprofiler.core.ui.dialog.composite.TooltipTree) Tree(org.eclipse.swt.widgets.Tree) TableIndicatorUnit(org.talend.dataprofiler.core.ui.editor.preview.TableIndicatorUnit) TooltipTree(org.talend.dataprofiler.core.ui.dialog.composite.TooltipTree)

Example 4 with TableIndicatorUnit

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;
                }
            }
        }
    }
}
Also used : WhereRule(org.talend.dataquality.rules.WhereRule) ArrayList(java.util.ArrayList) TableIndicatorUnit(org.talend.dataprofiler.core.ui.editor.preview.TableIndicatorUnit) RuleRepNode(org.talend.dq.nodes.RuleRepNode) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition)

Example 5 with TableIndicatorUnit

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);
    }
}
Also used : TableIndicatorUnit(org.talend.dataprofiler.core.ui.editor.preview.TableIndicatorUnit)

Aggregations

TableIndicatorUnit (org.talend.dataprofiler.core.ui.editor.preview.TableIndicatorUnit)24 ArrayList (java.util.ArrayList)8 TableIndicator (org.talend.dataprofiler.core.model.TableIndicator)5 Indicator (org.talend.dataquality.indicators.Indicator)5 TreeItem (org.eclipse.swt.widgets.TreeItem)4 RowCountIndicator (org.talend.dataquality.indicators.RowCountIndicator)4 CustomerDefaultCategoryDataset (org.talend.dataprofiler.common.ui.editor.preview.CustomerDefaultCategoryDataset)3 WhereRuleIndicator (org.talend.dataquality.indicators.sql.WhereRuleIndicator)3 ChartDataEntity (org.talend.dq.indicators.preview.table.ChartDataEntity)3 RuleRepNode (org.talend.dq.nodes.RuleRepNode)3 IndicatorEnum (org.talend.dq.nodes.indicator.type.IndicatorEnum)3 NamedColumnSet (orgomg.cwm.resource.relational.NamedColumnSet)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 List (java.util.List)2 Map (java.util.Map)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)2 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)2 GridData (org.eclipse.swt.layout.GridData)2 GridLayout (org.eclipse.swt.layout.GridLayout)2