Search in sources :

Example 1 with IndicatorCheckedTreeSelectionDialog

use of org.talend.dataprofiler.core.ui.dialog.IndicatorCheckedTreeSelectionDialog in project tdq-studio-se by Talend.

the class AnalysisTableTreeViewer method showAddDQRuleDialog.

/**
 * DOC xqliu Comment method "showAddDQRuleDialog".
 *
 * @param treeItem
 * @param tableIndicator
 */
private void showAddDQRuleDialog(final TreeItem treeItem, final TableIndicator tableIndicator) {
    // MOD xqliu 2009-04-30 bug 6808
    IndicatorCheckedTreeSelectionDialog dialog = new IndicatorCheckedTreeSelectionDialog(null, new DQRepositoryViewLabelProvider(), new ResourceViewContentProvider());
    dialog.setInput(AnalysisUtils.getSelectDialogInputData(EResourceConstant.RULES_SQL));
    dialog.setValidator(new ISelectionStatusValidator() {

        public IStatus validate(Object[] selection) {
            for (Object ruleNode : selection) {
                if (ruleNode instanceof RuleRepNode) {
                    IndicatorDefinition findWhereRule = ((RuleRepNode) ruleNode).getRule();
                    boolean validStatus = TaggedValueHelper.getValidStatus(findWhereRule);
                    if (!validStatus) {
                        return new Status(IStatus.ERROR, CorePlugin.PLUGIN_ID, DefaultMessagesImpl.getString(// $NON-NLS-1$
                        "AnalysisTableTreeViewer.chooseValidDQRules"));
                    }
                }
            }
            // $NON-NLS-1$
            return new Status(IStatus.OK, PlatformUI.PLUGIN_ID, IStatus.OK, "", null);
        }
    });
    dialog.setContainerMode(true);
    // $NON-NLS-1$
    dialog.setTitle(DefaultMessagesImpl.getString("AnalysisTableTreeViewer.dqruleSelector"));
    // $NON-NLS-1$
    dialog.setMessage(DefaultMessagesImpl.getString("AnalysisTableTreeViewer.dqrules"));
    dialog.setSize(80, 30);
    dialog.create();
    // MOD xqliu 2009-04-30 bug 6808
    Object[] ownedWhereRuleNodes = getOwnedWhereRuleNodes(tableIndicator);
    dialog.setCheckedElements(ownedWhereRuleNodes);
    if (dialog.open() == Window.OK) {
        Object[] result = dialog.getResult();
        removeUncheckedWhereRuleIndicator(ownedWhereRuleNodes, result, tableIndicator);
        Object[] results = clearAddedResult(ownedWhereRuleNodes, result);
        for (Object obj : results) {
            if (obj instanceof RuleRepNode) {
                RuleRepNode node = (RuleRepNode) obj;
                TableIndicatorUnit addIndicatorUnit = DQRuleUtilities.createIndicatorUnit(node, tableIndicator, getAnalysis());
                if (addIndicatorUnit != null) {
                    createOneUnit(treeItem, addIndicatorUnit);
                    setDirty(true);
                } else {
                    IndicatorDefinition whereRule = node.getRule();
                    MessageUI.openError(// $NON-NLS-1$
                    DefaultMessagesImpl.getString(// $NON-NLS-1$
                    "AnalysisTableTreeViewer.ErrorWhenAddWhereRule", whereRule.getName()));
                }
            }
        }
    }
// ~
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) ResourceViewContentProvider(org.talend.dataprofiler.core.ui.views.provider.ResourceViewContentProvider) ISelectionStatusValidator(org.eclipse.ui.dialogs.ISelectionStatusValidator) TableIndicatorUnit(org.talend.dataprofiler.core.ui.editor.preview.TableIndicatorUnit) RuleRepNode(org.talend.dq.nodes.RuleRepNode) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) IndicatorCheckedTreeSelectionDialog(org.talend.dataprofiler.core.ui.dialog.IndicatorCheckedTreeSelectionDialog) DQRepositoryViewLabelProvider(org.talend.dataprofiler.core.ui.views.provider.DQRepositoryViewLabelProvider)

Aggregations

IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1 ISelectionStatusValidator (org.eclipse.ui.dialogs.ISelectionStatusValidator)1 IndicatorCheckedTreeSelectionDialog (org.talend.dataprofiler.core.ui.dialog.IndicatorCheckedTreeSelectionDialog)1 TableIndicatorUnit (org.talend.dataprofiler.core.ui.editor.preview.TableIndicatorUnit)1 DQRepositoryViewLabelProvider (org.talend.dataprofiler.core.ui.views.provider.DQRepositoryViewLabelProvider)1 ResourceViewContentProvider (org.talend.dataprofiler.core.ui.views.provider.ResourceViewContentProvider)1 IndicatorDefinition (org.talend.dataquality.indicators.definition.IndicatorDefinition)1 RuleRepNode (org.talend.dq.nodes.RuleRepNode)1