use of org.talend.dataprofiler.core.ui.views.provider.DQRepositoryViewLabelProvider in project tdq-studio-se by Talend.
the class NominalValuesDPSelectionPage method addListeners.
/*
* (non-Javadoc)
*
* @see org.talend.dataprofiler.core.ui.wizard.analysis.column.ColumnAnalysisDOSelectionPage#addListeners()
*/
@Override
protected void addListeners() {
addListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
Object object = ((IStructuredSelection) event.getSelection()).getFirstElement();
if (object instanceof ColumnRepNode) {
RepositoryNode repositoryNode = (ColumnRepNode) object;
DFColumnRepNode columnNode = new DFColumnRepNode(repositoryNode.getObject(), repositoryNode.getParent(), ENodeType.TDQ_REPOSITORY_ELEMENT, ((DQRepositoryNode) repositoryNode).getProject());
int javaSQLType = TalendTypeConvert.convertToJDBCType(columnNode.getMetadataColumn().getTalendType());
// int javaSQLType = TalendTypeConvert.convertToJDBCType(column.getTalendType());
if (Java2SqlType.isTextInSQL(javaSQLType)) {
advanceToNextPageOrFinish();
} else {
List<DFColumnRepNode> tempList = new ArrayList<DFColumnRepNode>();
tempList.add(columnNode);
setAddTextIndicator(false);
if (!tempList.isEmpty()) {
ElementListSelectionDialog dialog = new ElementListSelectionDialog(null, new DQRepositoryViewLabelProvider());
dialog.setElements(tempList.toArray());
// $NON-NLS-1$
dialog.setTitle(DefaultMessagesImpl.getString("CreateNominalAnalysisAction.dataTypeWarning"));
// $NON-NLS-1$
dialog.setMessage(DefaultMessagesImpl.getString("CreateNominalAnalysisAction.string"));
dialog.setSize(80, 20);
dialog.create();
if (Window.OK == dialog.open()) {
// use MetadataHelper
for (DFColumnRepNode col : tempList) {
MetadataHelper.setDataminingType(DataminingType.NOMINAL, col.getMetadataColumn());
}
advanceToNextPageOrFinish();
}
}
}
}
}
});
addListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
try {
Object object = ((IStructuredSelection) event.getSelection()).getFirstElement();
nodes = new ArrayList<IRepositoryNode>();
if (object instanceof ColumnRepNode) {
List<IRepositoryNode> list = ((IStructuredSelection) event.getSelection()).toList();
nodes.addAll(list);
if (nodes.size() == 0 || RepNodeUtils.isValidSelectionFromSameTable(nodes)) {
List<DFColumnRepNode> tempList = new ArrayList<DFColumnRepNode>();
for (IRepositoryNode obj : nodes) {
if (object instanceof ColumnRepNode) {
RepositoryNode repositoryNode = (ColumnRepNode) obj;
DFColumnRepNode columnNode = new DFColumnRepNode(repositoryNode.getObject(), repositoryNode.getParent(), ENodeType.TDQ_REPOSITORY_ELEMENT, ((DQRepositoryNode) repositoryNode).getProject());
int javaSQLType = TalendTypeConvert.convertToJDBCType(columnNode.getMetadataColumn().getTalendType());
if (!Java2SqlType.isTextInSQL(javaSQLType)) {
tempList.add(columnNode);
setAddTextIndicator(false);
}
}
}
if (!tempList.isEmpty()) {
ElementListSelectionDialog dialog = new ElementListSelectionDialog(null, new DQRepositoryViewLabelProvider());
dialog.setElements(tempList.toArray());
// $NON-NLS-1$
dialog.setTitle(DefaultMessagesImpl.getString("CreateNominalAnalysisAction.dataTypeWarning"));
// $NON-NLS-1$
dialog.setMessage(DefaultMessagesImpl.getString("CreateNominalAnalysisAction.string"));
dialog.setSize(80, 20);
dialog.create();
if (Window.OK == dialog.open()) {
// zqin get the column and change their datamining type to "Nominal"
for (DFColumnRepNode column : tempList) {
MetadataHelper.setDataminingType(DataminingType.NOMINAL, column.getMetadataColumn());
}
setPageComplete(true);
setMessage(chooseConnStr);
}
} else {
setPageComplete(true);
setMessage(chooseConnStr);
}
} else {
setPageComplete(false);
// $NON-NLS-1$
setMessage(DefaultMessagesImpl.getString("ColumnAnalysisDOSelectionPage.selectColumnError1"), ERROR);
}
} else {
setPageComplete(false);
setMessage(chooseConnStr);
}
} catch (Exception e) {
log.error(e, e);
}
}
});
}
use of org.talend.dataprofiler.core.ui.views.provider.DQRepositoryViewLabelProvider in project tdq-studio-se by Talend.
the class UDIUtils method createUdiCheckedTreeSelectionDialog.
/**
* DOC xqliu Comment method "createUdiCheckedTreeSelectionDialog".
*
* @param meIndicator
* @return
*/
public static CheckedTreeSelectionDialog createUdiCheckedTreeSelectionDialog(ModelElementIndicator meIndicator) {
CheckedTreeSelectionDialog dialog = new CheckedTreeSelectionDialog(null, new DQRepositoryViewLabelProvider(), new ResourceViewContentProvider());
dialog.addFilter(new FolderObjFilter());
DQRepositoryNode udiDialogInputData = AnalysisUtils.getSelectDialogInputData(EResourceConstant.USER_DEFINED_INDICATORS);
dialog.setInput(udiDialogInputData);
dialog.setValidator(new ISelectionStatusValidator() {
public IStatus validate(Object[] selection) {
for (Object patte : selection) {
if (patte instanceof SysIndicatorDefinitionRepNode) {
SysIndicatorDefinitionRepNode udiNode = (SysIndicatorDefinitionRepNode) patte;
IndicatorDefinition indicatorDefinition = udiNode.getIndicatorDefinition();
boolean validStatus = TaggedValueHelper.getValidStatus(indicatorDefinition);
if (!validStatus) {
return new Status(IStatus.ERROR, CorePlugin.PLUGIN_ID, DefaultMessagesImpl.getString(// $NON-NLS-1$
"AnalysisColumnTreeViewer.chooseValidUdis"));
}
}
}
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);
dialog.setInitialSelections(getUDIFilesByIndicator(udiDialogInputData, meIndicator));
// $NON-NLS-1$
dialog.setTitle(DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.udiSelector"));
// $NON-NLS-1$
dialog.setMessage(DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.udis"));
dialog.setSize(80, 30);
return dialog;
}
use of org.talend.dataprofiler.core.ui.views.provider.DQRepositoryViewLabelProvider in project tdq-studio-se by Talend.
the class SetJDBCDriverPreferencePage method createConnSelectDialog.
private CheckedTreeSelectionDialog createConnSelectDialog() {
RepositoryNode node = (RepositoryNode) RepositoryNodeHelper.getMetadataFolderNode(EResourceConstant.DB_CONNECTIONS);
CheckedTreeSelectionDialog dialog = new CheckedTreeSelectionDialog(getShell(), new DQRepositoryViewLabelProvider(), new ResourceViewContentProvider());
dialog.setInput(node);
dialog.addFilter(new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (element instanceof DBConnectionRepNode) {
return isJdbcConnectionNode((DBConnectionRepNode) element);
} else if (element instanceof DBConnectionSubFolderRepNode) {
return hasJdbcConnNodeChild((DBConnectionSubFolderRepNode) element);
}
return false;
}
});
dialog.setValidator(new ISelectionStatusValidator() {
public IStatus validate(Object[] selection) {
for (Object object : selection) {
if (object instanceof DBConnectionRepNode) {
IRepositoryViewObject nodeObject = ((DBConnectionRepNode) object).getObject();
// when it's locked, can not modify
if (nodeObject != null && nodeObject.getProperty() != null && nodeObject.getProperty().getItem() != null && (nodeObject.getRepositoryStatus() == ERepositoryStatus.LOCK_BY_OTHER || nodeObject.getRepositoryStatus() == ERepositoryStatus.LOCK_BY_USER || RepositoryManager.isOpenedItemInEditor(nodeObject))) {
String displayName = nodeObject.getProperty().getDisplayName();
String version = nodeObject.getProperty().getVersion();
return new Status(IStatus.ERROR, CorePlugin.PLUGIN_ID, DefaultMessagesImpl.getString("SetJDBCDriverPreferencePage.isLocked", // $NON-NLS-1$ //$NON-NLS-2$
displayName + " " + version));
}
}
}
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("SetJDBCDriverPreferencePage.selectConnectionButton"));
// $NON-NLS-1$
dialog.setMessage(DefaultMessagesImpl.getString("SetJDBCDriverPreferencePage.ApplytoConnectionEditors"));
dialog.setSize(80, 30);
return dialog;
}
use of org.talend.dataprofiler.core.ui.views.provider.DQRepositoryViewLabelProvider 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.DQRepositoryViewLabelProvider in project tdq-studio-se by Talend.
the class TablesSelectionDialog method initProvider.
@Override
protected void initProvider() {
fLabelProvider = new DQRepositoryViewLabelProvider();
fContentProvider = new DBTreeViewContentProvider();
sLabelProvider = new TableLabelProvider();
sContentProvider = new TableContentProvider();
}
Aggregations