use of org.talend.dataprofiler.core.model.ModelElementIndicator in project tdq-studio-se by Talend.
the class AnalysisColumnTreeViewer method moveSelectedElements.
/**
* DOC yyi 7466 2010-03-22 change the order of appearence of indicators.
*
* @param newTree
* @param step
*/
protected void moveSelectedElements(Tree newTree, int step) {
TreeItem[] selection = newTree.getSelection();
if (selection != null) {
// used to set the selected columns focus at last
List<Object> selectedDataList = new ArrayList<Object>();
// TDQ-11530 msjian: get all selected data's list first to check how to move
List<IndicatorUnit> indicatorUnitList = new ArrayList<IndicatorUnit>();
List<ModelElementIndicator> dataList = new ArrayList<ModelElementIndicator>();
for (TreeItem item : selection) {
IndicatorUnit indicatorUnit = (IndicatorUnit) item.getData(INDICATOR_UNIT_KEY);
if (indicatorUnit != null) {
indicatorUnitList.add(indicatorUnit);
} else {
ModelElementIndicator data = (ModelElementIndicator) item.getData(MODELELEMENT_INDICATOR_KEY);
dataList.add(data);
}
}
for (TreeItem item : selection) {
IndicatorUnit indicatorUnit = (IndicatorUnit) item.getData(INDICATOR_UNIT_KEY);
ModelElementIndicator data = (ModelElementIndicator) item.getData(MODELELEMENT_INDICATOR_KEY);
if (indicatorUnit != null) {
TypedReturnCode<IndicatorUnit[]> code = sortIndicatorUnits(data.getIndicatorUnits(), indicatorUnit, step, indicatorUnitList);
if (code.isOk()) {
if (null != code.getObject()) {
Indicator[] inds = new Indicator[code.getObject().length];
for (int i = 0; i < code.getObject().length; i++) {
inds[i] = code.getObject()[i].getIndicator();
}
data.setIndicators(inds);
}
selectedDataList.add(indicatorUnit);
}
} else {
int index = ArrayUtils.indexOf(modelElementIndicators, data);
int changeIndex = index + step;
if (changeIndex > -1 && changeIndex < modelElementIndicators.length) {
ModelElementIndicator tmpElement = modelElementIndicators[changeIndex];
// when the changed one is the selected one too, get next one
while (dataList.contains(tmpElement)) {
tmpElement = modelElementIndicators[++changeIndex];
}
modelElementIndicators[changeIndex] = modelElementIndicators[index];
modelElementIndicators[index] = tmpElement;
// after the data changed successfully remove it from the selected list
dataList.remove(data);
selectedDataList.add(data);
}
}
}
setElements(modelElementIndicators, true, false);
for (Object obj : selectedDataList) {
selectElement(tree.getItems(), obj);
}
masterPage.synNagivatorStat();
}
}
use of org.talend.dataprofiler.core.model.ModelElementIndicator in project tdq-studio-se by Talend.
the class AnalysisColumnTreeViewer method addColumnUdi.
/**
* DOC xqliu Comment method "addColumnUdi". ADD xqliu 2010-02-23 feature 11617
*
* @param treeItem
* @param meIndicator
* @param columnIndex
* @return
*/
private TreeEditor addColumnUdi(final TreeItem treeItem, final ModelElementIndicator meIndicator, int columnIndex) {
TreeEditor addUdiEditor = new TreeEditor(tree);
// $NON-NLS-1$
Label addUdiLabl = createTreeItemLabel(tree, ImageLib.ADD_IND_DEFINITION, "AnalysisColumnTreeViewer.addUdi");
addUdiLabl.addMouseListener(new MouseAdapter() {
@Override
public void mouseDown(MouseEvent e) {
DataManager dm = getAnalysis().getContext().getConnection();
if (dm == null) {
masterPage.doSave(null);
}
CheckedTreeSelectionDialog dialog = UDIUtils.createUdiCheckedTreeSelectionDialog(meIndicator);
if (dialog.open() == Window.OK) {
// MOD qiongli 2012-10-24 TDQ-6308,just remove some deselected indicatorUnit then set dirty to
// true,just create new indicatorUnit for some new added UDI then set dirty to true.
List<IndicatorDefinition> allSelectedIndicatorDefinitions = new ArrayList<IndicatorDefinition>();
Set<String> allSelectedIndNames = new HashSet<String>();
for (Object obj : dialog.getResult()) {
if (obj instanceof SysIndicatorDefinitionRepNode) {
IndicatorDefinition udid = ((SysIndicatorDefinitionRepNode) obj).getIndicatorDefinition();
allSelectedIndicatorDefinitions.add(udid);
if (udid != null) {
allSelectedIndNames.add(udid.getName());
}
}
}
Set<String> oldSelectedIndNames = new HashSet<String>();
for (IndicatorUnit indicatorUnit : meIndicator.getIndicatorUnits()) {
Indicator indicator = indicatorUnit.getIndicator();
if (indicator instanceof UserDefIndicator) {
if (allSelectedIndNames.contains(indicator.getName())) {
oldSelectedIndNames.add(indicator.getName());
} else {
// remove the UDI from UI need to insert this UDI into removeList
deleteIndicatorItems(meIndicator, indicatorUnit);
if (!isDirty()) {
setDirty(true);
}
}
}
}
treeItem.removeAll();
for (IndicatorDefinition udid : allSelectedIndicatorDefinitions) {
if (udid != null && oldSelectedIndNames.contains(udid.getName())) {
continue;
}
IndicatorUnit[] addIndicatorUnits = null;
try {
addIndicatorUnits = UDIUtils.createIndicatorUnit(udid, meIndicator, getAnalysis());
} catch (Throwable e1) {
log.warn(e1, e1);
}
if (addIndicatorUnits != null && addIndicatorUnits.length > 0) {
for (IndicatorUnit unit : addIndicatorUnits) {
createOneUnit(treeItem, unit);
}
if (!isDirty()) {
setDirty(true);
}
}
}
treeItem.setExpanded(true);
masterPage.refreshTheTree(masterPage.getCurrentModelElementIndicators());
}
}
});
addUdiEditor.minimumWidth = addUdiLabl.getImage().getBounds().width;
addUdiEditor.setEditor(addUdiLabl, treeItem, columnIndex);
return addUdiEditor;
}
use of org.talend.dataprofiler.core.model.ModelElementIndicator in project tdq-studio-se by Talend.
the class ModelElementTreeMenuProvider method createColumnAnalysis.
/**
* DOC qiongli Comment method "createColumnAnalysis".bug 16252.
*
* @param newTree
*/
private void createColumnAnalysis(Tree newTree) {
TreeItem[] items = newTree.getSelection();
if (items.length > 0) {
TreePath[] paths = new TreePath[items.length];
for (int i = 0; i < items.length; i++) {
// MOD klliu bug 20820 change TDcolum to IRepositoryNode, then solve NPE 2011-04-29
// $NON-NLS-1$
ModelElementIndicator data = (ModelElementIndicator) items[i].getData("MODELELEMENT_INDICATOR_KEY");
IRepositoryNode modelElementRepositoryNode = data.getModelElementRepositoryNode();
paths[i] = new TreePath(new Object[] { modelElementRepositoryNode });
}
CreateColumnAnalysisAction analysisAction = new CreateColumnAnalysisAction();
analysisAction.setSelection(new TreeSelection(paths));
analysisAction.run();
}
}
use of org.talend.dataprofiler.core.model.ModelElementIndicator in project tdq-studio-se by Talend.
the class ModelElementTreeMenuProvider method viewQueryForSelectedElement.
/**
* DOC mzhao Comment method "viewQueryForSelectedElement".
*
* @param newTree
*/
private void viewQueryForSelectedElement(Tree newTree) {
TreeItem[] selection = newTree.getSelection();
for (TreeItem item : selection) {
ModelElementIndicator meIndicator = (ModelElementIndicator) item.getData(AbstractColumnDropTree.MODELELEMENT_INDICATOR_KEY);
ConnectionItem connItem = (ConnectionItem) meIndicator.getModelElementRepositoryNode().getObject().getProperty().getItem();
Connection dataprovider = connItem.getConnection();
IndicatorUnit indicatorUnit = (IndicatorUnit) item.getData(AbstractColumnDropTree.INDICATOR_UNIT_KEY);
DbmsLanguage dbmsLang = DbmsLanguageFactory.createDbmsLanguage(dataprovider);
Expression expression = dbmsLang.getInstantiatedExpression(indicatorUnit.getIndicator());
if (expression == null) {
MessageDialogWithToggle.openWarning(null, DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.Warn"), // $NON-NLS-1$ //$NON-NLS-2$
DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.NoQueryDefined"));
return;
}
SqlExplorerUtils.getDefault().runInDQViewer(dataprovider, expression.getBody(), meIndicator.getModelElementRepositoryNode().getObject().getProperty().getLabel());
}
}
use of org.talend.dataprofiler.core.model.ModelElementIndicator in project tdq-studio-se by Talend.
the class ModelElementTreeMenuProvider method getSelectedNode.
/**
* DOC msjian Comment method "getSelectedNode".
*
* @param selection
* @return
*/
protected RepositoryNode getSelectedNode(TreeItem[] selection) {
ModelElementIndicator meIndicator = (ModelElementIndicator) selection[0].getData(AbstractColumnDropTree.MODELELEMENT_INDICATOR_KEY);
ModelElement me = ((ISubRepositoryObject) meIndicator.getModelElementRepositoryNode().getObject()).getModelElement();
RepositoryNode recursiveFind = RepositoryNodeHelper.recursiveFind(me);
if (recursiveFind == null) {
recursiveFind = RepositoryNodeHelper.createRepositoryNode(me);
}
return recursiveFind;
}
Aggregations