use of org.talend.dataprofiler.core.model.ModelElementIndicator in project tdq-studio-se by Talend.
the class AnalysisColumnSetTreeViewer method moveElement.
/**
* DOC zshen Comment method "moveElement".
*
* @param columnsElementViewer
* @param step
*
* move the element of the columnList to up or down.
*/
private void moveElement(AnalysisColumnSetTreeViewer columnsElementViewer, int step) {
Tree currentTree = columnsElementViewer.getTree();
Object[] selectItem = currentTree.getSelection();
List<IRepositoryNode> columnList = columnsElementViewer.getColumnSetMultiValueList();
// get all the selected index list first which is used to check how to move
List<Object> allSelectedItemList = new ArrayList<Object>();
for (Object element : selectItem) {
allSelectedItemList.add(element);
}
int index = 0;
RepositoryNode moveElement = null;
List<Integer> indexArray = new ArrayList<Integer>();
for (Object element : selectItem) {
index = currentTree.indexOf((TreeItem) element);
int changeIndex = index + step;
if (changeIndex > -1 && changeIndex < columnList.size()) {
Object treeElement = ((TreeItem) element).getData(AnalysisColumnNominalIntervalTreeViewer.COLUMN_INDICATOR_KEY);
// MOD by zshen for bug 15750 TODO 39 columnset analysis move up/down one column will get exception.
if (treeElement instanceof ModelElement) {
moveElement = RepositoryNodeHelper.recursiveFind((ModelElement) treeElement);
} else if (treeElement instanceof RepositoryNode) {
moveElement = (RepositoryNode) treeElement;
}
columnList.remove(moveElement);
// when the changed one is the selected one too, get next one
while (allSelectedItemList.contains(currentTree.getItem(changeIndex))) {
++changeIndex;
}
columnList.add(changeIndex, moveElement);
indexArray.add(changeIndex);
ModelElementIndicator tmpElement = modelElementIndicators[changeIndex];
modelElementIndicators[changeIndex] = modelElementIndicators[index];
modelElementIndicators[index] = tmpElement;
allSelectedItemList.remove(element);
} else {
return;
}
}
// columnsElementViewer.setInput(columnList.toArray());
setElements(modelElementIndicators);
currentTree = columnsElementViewer.getTree();
for (int i = 0; i < indexArray.size(); i++) {
currentTree.select(currentTree.getItem(indexArray.get(i)));
}
}
use of org.talend.dataprofiler.core.model.ModelElementIndicator in project tdq-studio-se by Talend.
the class AnalysisColumnSetTreeViewer method setInput.
@Override
public void setInput(Object[] objs) {
if (objs != null && objs.length != 0) {
List<DBColumnRepNode> columnList = new ArrayList<DBColumnRepNode>();
for (Object obj : objs) {
// default is should be sql engine.
if (obj instanceof DBTableRepNode || obj instanceof DBViewRepNode) {
columnList.addAll((Collection<? extends DBColumnRepNode>) ((ColumnSetRepNode) obj).getAllColumns());
} else if (obj instanceof DBColumnRepNode) {
columnList.add((DBColumnRepNode) obj);
}
}
// MOD yyi 2010-05-13 12828
Collections.reverse(columnList);
// MOD qiongli 2011-3-15 set DataFilterText disabled except TdColumn.
if (masterPage.getDataFilterComp() != null) {
masterPage.getDataFilterComp().getDataFilterText().setEnabled(!columnList.isEmpty());
if (columnList.isEmpty()) {
// when the selected column is not DB type,will disable the execute engine
// combobox.
masterPage.changeExecuteLanguageToJava(true);
} else {
// when the selected column is back to DB type, should enable the execute engine combobox again.
masterPage.enableExecuteLanguage();
}
}
ModelElementIndicator[] newSelects = translateSelectedNodeIntoIndicator(objs);
List<ModelElementIndicator> indicatorList = new ArrayList<ModelElementIndicator>();
if (newSelects != null) {
// indicator;
for (ModelElementIndicator column : newSelects) {
// if the modelElementIndicators contains selected column, add the column in modelElementIndicators
// to ColumnIndicatorList
boolean isOld = false;
for (ModelElementIndicator oldColumn : modelElementIndicators) {
if (oldColumn.getModelElementRepositoryNode().equals(column.getModelElementRepositoryNode())) {
indicatorList.add(oldColumn);
isOld = true;
break;
}
}
// else add this column in filterInputData to ColumnIndicatorList
if (!isOld) {
indicatorList.add(column);
}
}
this.modelElementIndicators = indicatorList.toArray(new ModelElementIndicator[indicatorList.size()]);
this.setElements(modelElementIndicators);
}
} else {
TreeItem[] items = this.tree.getItems();
for (TreeItem item : items) {
this.removeItemBranch(item);
}
super.setInput(objs);
}
}
use of org.talend.dataprofiler.core.model.ModelElementIndicator in project tdq-studio-se by Talend.
the class AnalysisColumnSetTreeViewer method addElements.
@Override
public void addElements(final ModelElementIndicator[] elements) {
RepositoryNode[] columns = new RepositoryNode[elements.length];
for (int i = 0; i < elements.length; i++) {
columns[i] = (RepositoryNode) elements[i].getModelElementRepositoryNode();
}
List<IRepositoryNode> oriColumns = getColumnSetMultiValueList();
for (RepositoryNode column : columns) {
if (!RepositoryNodeHelper.containsModelElementNode(oriColumns, column)) {
oriColumns.add(column);
}
}
setInput(oriColumns.toArray());
// MOD qiongli 2010-6-4,bug 0012766,after drag and drop a column from left view,update the connection state
updateBindConnection(masterPage, tree);
// ADD msjian TDQ-11606: refresh the datapreview part after add a new element
ModelElementIndicator[] newsArray = new ModelElementIndicator[getAllTheElementIndicator().length + elements.length];
System.arraycopy(getAllTheElementIndicator(), 0, newsArray, 0, getAllTheElementIndicator().length);
for (int i = 0; i < elements.length; i++) {
newsArray[getAllTheElementIndicator().length + i] = elements[i];
}
masterPage.refreshPreviewTable(newsArray, true);
// ADD msjian TDQ-11606~
}
use of org.talend.dataprofiler.core.model.ModelElementIndicator in project tdq-studio-se by Talend.
the class AnalysisColumnTreeViewer method isExpressionNull.
private String isExpressionNull(TreeItem item) {
String expressContent = null;
ModelElement me = null;
IndicatorUnit indicatorUnit = (IndicatorUnit) item.getData(INDICATOR_UNIT_KEY);
ModelElementIndicator meIndicator = (ModelElementIndicator) item.getData(MODELELEMENT_INDICATOR_KEY);
if (indicatorUnit != null) {
IRepositoryViewObject reposViewObj = meIndicator.getModelElementRepositoryNode().getObject();
// MetadataXmlElementTypeRepositoryObject
if (reposViewObj instanceof MetadataColumnRepositoryObject) {
me = ((MetadataColumnRepositoryObject) reposViewObj).getTdColumn();
}
Connection dataprovider = ModelElementHelper.getTdDataProvider(me);
DbmsLanguage dbmsLang = DbmsLanguageFactory.createDbmsLanguage(dataprovider);
Expression expression = dbmsLang.getInstantiatedExpression(indicatorUnit.getIndicator());
if (expression != null) {
expressContent = expression.getBody();
}
} else {
IRepositoryNode parentNodeForColumnNode = RepositoryNodeHelper.getParentNodeForColumnNode(meIndicator.getModelElementRepositoryNode());
expressContent = DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.columnParent", // $NON-NLS-1$ //;
parentNodeForColumnNode.getObject().getLabel());
}
return expressContent;
}
use of org.talend.dataprofiler.core.model.ModelElementIndicator in project tdq-studio-se by Talend.
the class AnalysisColumnTreeViewer method getTheSuitedComposite.
/*
* (non-Javadoc)
*
* @see
* org.talend.dataprofiler.core.ui.editor.composite.AbstractColumnDropTree#getTheSuitedComposite(org.eclipse.swt
* .events.SelectionEvent)
*/
@Override
public ExpandableComposite getTheSuitedComposite(SelectionEvent e) {
Composite[] previewChartCompsites = masterPage.getPreviewChartCompsites();
if (previewChartCompsites == null) {
return null;
}
Object obj = e.item.getData(MODELELEMENT_INDICATOR_KEY);
if (obj instanceof ModelElementIndicator) {
ModelElementIndicator meIndicator = (ModelElementIndicator) obj;
for (Composite comp : previewChartCompsites) {
if (comp.getData() == meIndicator) {
return (ExpandableComposite) comp;
}
}
}
return null;
}
Aggregations