use of org.talend.dataprofiler.core.ui.views.provider.ResourceViewContentProvider 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()));
}
}
}
}
// ~
}
use of org.talend.dataprofiler.core.ui.views.provider.ResourceViewContentProvider in project tdq-studio-se by Talend.
the class ImportMatchRuleAction method run.
@Override
public void run() {
MatchRuleElementTreeSelectionDialog dialog = new MatchRuleElementTreeSelectionDialog(null, new DQRepositoryViewLabelProvider(), new ResourceViewContentProvider(), MatchRuleElementTreeSelectionDialog.MATCH_ANALYSIS_TYPE);
List<String> inputColumnNames = new ArrayList<String>();
Map<String, String> columnName2Type = new HashMap<String, String>();
Analysis analysis = masterPage.getCurrentModelElement();
EList<ModelElement> elements = analysis.getContext().getAnalysedElements();
for (ModelElement me : elements) {
inputColumnNames.add(me.getName());
if (me instanceof MetadataColumn) {
columnName2Type.put(me.getName(), ((MetadataColumn) me).getTalendType());
}
}
dialog.setInputColumnNames(inputColumnNames);
dialog.setColumnName2Type(columnName2Type);
AnalysisResult anaResults = analysis.getResults();
if (anaResults != null) {
for (Indicator ind : anaResults.getIndicators()) {
if (ind != null && ind instanceof RecordMatchingIndicator) {
RecordMatchingIndicator rmInd = (RecordMatchingIndicator) ind;
MatchRuleDefinition builtInMatchRuleDefinition = rmInd.getBuiltInMatchRuleDefinition();
if (builtInMatchRuleDefinition != null) {
if (builtInMatchRuleDefinition.getBlockKeys() != null && builtInMatchRuleDefinition.getBlockKeys().size() > 0) {
List<String> blockKeyName = new ArrayList<String>();
for (BlockKeyDefinition blockKey : builtInMatchRuleDefinition.getBlockKeys()) {
blockKeyName.add(blockKey.getName());
}
dialog.setCurrentAnaBlockKeys(blockKeyName);
}
List<String> matchKeysName = new ArrayList<String>();
for (MatchRule matchRule : builtInMatchRuleDefinition.getMatchRules()) {
EList<MatchKeyDefinition> matchKeys = matchRule.getMatchKeys();
for (MatchKeyDefinition mkd : matchKeys) {
// same
if (!matchKeysName.contains(mkd.getName())) {
matchKeysName.add(mkd.getName());
}
}
}
dialog.setAnalysisCurrentMatchKeys(matchKeysName);
List<String> pdsdKeysName = new ArrayList<String>();
for (ParticularDefaultSurvivorshipDefinitions pdsd : builtInMatchRuleDefinition.getParticularDefaultSurvivorshipDefinitions()) {
pdsdKeysName.add(pdsd.getColumn());
}
dialog.setAnalysisCurrentParticularColumns(pdsdKeysName);
}
}
}
}
dialog.create();
if (dialog.open() == Window.OK) {
Object[] results = dialog.getResult();
for (Object obj : results) {
if (obj instanceof RuleRepNode) {
RuleRepNode node = (RuleRepNode) obj;
MatchRuleDefinition matchRule = (MatchRuleDefinition) node.getRule();
if (matchRule != null) {
updateMatchRule(matchRule, dialog.isOverwrite());
}
}
}
}
}
use of org.talend.dataprofiler.core.ui.views.provider.ResourceViewContentProvider in project tdq-studio-se by Talend.
the class PatternLabelProvider method createPatternCheckedTreeSelectionDialog.
/**
* create CheckedTreeSelectionDialog for patterns.
*
* @param node Pattern root RepositoryNode.
* @return
*/
public static CheckedTreeSelectionDialog createPatternCheckedTreeSelectionDialog(IRepositoryNode node) {
CheckedTreeSelectionDialog dialog = new CheckedTreeSelectionDialog(null, new DQRepositoryViewLabelProvider(), new ResourceViewContentProvider());
dialog.setInput(node);
dialog.setValidator(new ISelectionStatusValidator() {
public IStatus validate(Object[] selection) {
for (Object patte : selection) {
if (patte instanceof PatternRepNode) {
PatternRepNode patternNode = (PatternRepNode) patte;
Pattern findPattern = patternNode.getPattern();
boolean validStatus = TaggedValueHelper.getValidStatus(findPattern);
if (!validStatus) {
return new Status(IStatus.ERROR, CorePlugin.PLUGIN_ID, DefaultMessagesImpl.getString(// $NON-NLS-1$
"AnalysisColumnTreeViewer.chooseValidPatterns"));
}
}
}
return new // $NON-NLS-1$
Status(// $NON-NLS-1$
IStatus.OK, // $NON-NLS-1$
PlatformUI.PLUGIN_ID, // $NON-NLS-1$
IStatus.OK, // $NON-NLS-1$
"", null);
}
});
dialog.setContainerMode(true);
// $NON-NLS-1$
dialog.setTitle(DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.patternSelector"));
// $NON-NLS-1$
dialog.setMessage(DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.patterns"));
dialog.setSize(80, 30);
return dialog;
}
Aggregations