use of org.talend.dataprofiler.core.model.ModelElementIndicator in project tdq-studio-se by Talend.
the class IndicatorSelectDialog method isMatchCurrentIndicator.
public boolean isMatchCurrentIndicator(ModelElementIndicator currentIndicator, IIndicatorNode indicatorNode) {
boolean returnValueForCurrentIndicator = true;
IIndicatorNode parentNode = indicatorNode.getParent();
boolean isParentPhoneStatistics = parentNode != null && parentNode.getIndicatorInstance() != null && parentNode.getIndicatorInstance() instanceof PhoneNumbStatisticsIndicator;
if (!ModelElementIndicatorRule.match(indicatorNode, currentIndicator, this.language)) {
returnValueForCurrentIndicator = false;
}
Indicator indicatorInstance = indicatorNode.getIndicatorInstance();
if (null != indicatorInstance && !(indicatorInstance instanceof DatePatternFreqIndicator) && null != indicatorInstance.getIndicatorDefinition() && indicatorInstance.getIndicatorDefinition().getSqlGenericExpression().size() < 1 && ExecutionLanguage.SQL.equals(language) && !UDIHelper.isJavaUDI(indicatorInstance) && !indicatorNode.hasChildren() && !(currentIndicator instanceof DelimitedFileIndicator) && !isParentPhoneStatistics) {
returnValueForCurrentIndicator = false;
}
return returnValueForCurrentIndicator;
}
use of org.talend.dataprofiler.core.model.ModelElementIndicator in project tdq-studio-se by Talend.
the class AbstractIndicatorSelectGrid method tickCell.
private void tickCell(Point cell, boolean tick) {
if (!getItem(cell.y).getCheckable(cell.x)) {
return;
}
if (cell.x == 1) {
for (int i = 2; i < getColumnCount(); i++) {
tickCell(new Point(i, cell.y), tick);
}
}
getItem(cell.y).setChecked(cell.x, tick);
getItem(cell.y).setGrayed(cell.x, false);
IIndicatorNode indicatorNode = (IIndicatorNode) getItem(cell.y).getData();
IndicatorEnum indicatorEnum = indicatorNode.getIndicatorEnum();
ModelElementIndicator meIndicator = (ModelElementIndicator) getColumn(cell.x).getData();
if (meIndicator != null && indicatorEnum != null) {
if (tick) {
if (IndicatorEnum.isSpecialIndicatorEnum(indicatorEnum)) {
meIndicator.addTempSpecialIndicator(indicatorEnum, indicatorNode.createNewIndicatorInstance());
} else {
meIndicator.addTempIndicatorEnum(indicatorEnum);
}
} else {
if (IndicatorEnum.isSpecialIndicatorEnum(indicatorEnum)) {
meIndicator.removeTempSpecialIndicator(indicatorNode.getIndicatorInstance());
} else {
meIndicator.removeTempIndicatorEnum(indicatorEnum);
}
}
}
// select the entire indicator category
if (getItem(cell.y).hasChildren()) {
for (GridItem child : getItem(cell.y).getItems()) {
tickCell(new Point(cell.x, indexOf(child)), tick);
}
}
}
use of org.talend.dataprofiler.core.model.ModelElementIndicator in project tdq-studio-se by Talend.
the class AbstractIndicatorSelectGrid method createChildNodes.
/**
* recursively create tree nodes and checked the existing indicators.
*
* @param grid
* @param currentItem
* @param indicatorNode
*/
void createChildNodes(GridItem parentItem, GridItem currentItem, IIndicatorNode indicatorNode) {
Boolean[] hasCheckableInColumn = new Boolean[getColumnCount()];
for (int j = 1; j < getColumnCount(); j++) {
hasCheckableInColumn[j] = false;
}
for (int i = 0; i < indicatorNode.getChildren().length; i++) {
IIndicatorNode childNode = indicatorNode.getChildren()[i];
TalendGridItem childItem = new TalendGridItem(currentItem, SWT.NONE);
childItem.setImage(ImageLib.getImage(childNode.getImageName()));
if (childNode.hasChildren()) {
createChildNodes(currentItem, childItem, childNode);
}
childItem.setText(childNode.getLabel());
childItem.setData(childNode);
if (parentItem == null) {
childItem.setExpanded(true);
}
boolean hasCheckableInRow = false;
for (int j = 2; j < getColumnCount(); j++) {
// ignore indicator label column and row select column
IndicatorEnum indicatorEnum = childNode.getIndicatorEnum();
// DB columns
ModelElementIndicator meIndicator = null;
if (j - 2 < _modelElementIndicators.length) {
meIndicator = _modelElementIndicators[j - 2];
} else {
meIndicator = _modelElementIndicators[0];
}
// Enable/disable the check box
boolean isMatch = _dialog.isMatchCurrentIndicator(meIndicator, childNode);
childItem.setCheckable(j, isMatch);
if (isMatch) {
hasCheckableInRow = true;
hasCheckableInColumn[j] = true;
// Check the box if it is already selected
if (meIndicator != null && (meIndicator.tempContains(indicatorEnum) || meIndicator.specialTempContains(childNode.getIndicatorInstance()))) {
childItem.setChecked(j, true);
}
}
}
childItem.setCheckable(1, hasCheckableInRow);
}
boolean entireCategoryCheckable = false;
for (int j = 2; j < getColumnCount(); j++) {
if (hasCheckableInColumn[j]) {
entireCategoryCheckable = true;
} else {
currentItem.setCheckable(j, false);
}
}
currentItem.setCheckable(1, entireCategoryCheckable);
}
use of org.talend.dataprofiler.core.model.ModelElementIndicator in project tdq-studio-se by Talend.
the class AbstractIndicatorSelectGrid method initializeGrid.
protected void initializeGrid() {
// first column is for indicator labels, it is hided from the cells but shown as row header.
createIndicatorLabelColumn();
// column
// select all column
createRowSelectColumn();
// database columns
for (int index = 0; index < _modelElementIndicators.length; index++) {
ModelElementIndicator _modelElementIndicator = _modelElementIndicators[index];
final GridColumn newCol = new TalendGridColumn(this, SWT.CHECK);
AbstractColumnHerderRenderer headerRenderer = getColumnHeaderRenderer();
headerRenderer.setRotation(COLUMN_HEADER_ROTATION);
newCol.setHeaderRenderer(headerRenderer);
newCol.setCellRenderer(getCellRenderer());
newCol.setText(ModelElementIndicatorHelper.getModelElementDisplayName(_modelElementIndicator));
newCol.setWidth(getPreferWidth(index));
newCol.setData(_modelElementIndicator);
newCol.setMoveable(true);
newCol.setResizeable(true);
newCol.setHeaderFont(headerFont);
IRepositoryNode repNode = _modelElementIndicator.getModelElementRepositoryNode();
if (repNode instanceof DBColumnRepNode && ((DBColumnRepNode) repNode).isKey()) {
newCol.setImage(ImageLib.getImage(ImageLib.PK_ICON));
}
newCol.addListener(SWT.Resize, new Listener() {
public void handleEvent(Event event) {
notifyObservers(event);
}
});
newCol.addListener(SWT.Move, new Listener() {
public void handleEvent(Event event) {
notifyObservers(event);
isColumnMoved = true;
}
});
}
recalculateHeader();
// initialize grid contents
createTableContent();
// show fixed column header
setHeaderVisible(true);
setTopLeftRenderer(new TdTopLeftRenderer());
// setCellHeaderSelectionBackground(IndicatorSelectGrid.standardYellow);
setEmptyColumnHeaderRenderer(new TdEmptyColumnHeaderRenderer());
setEmptyRowHeaderRenderer(new TdEmptyCellRenderer());
setEmptyCellRenderer(new TdEmptyCellRenderer());
// show fixed row header
TdRowHeaderRenderer rowHeaderRenderer = new TdRowHeaderRenderer();
setRowHeaderRenderer(rowHeaderRenderer);
rowHeaderRenderer.setTree(true);
rowHeaderRenderer.setWordWrap(false);
setRowHeaderVisible(true);
setLinesVisible(true);
setColumnScrolling(true);
setSelectionEnabled(false);
setCellSelectionEnabled(false);
setRowsResizeable(false);
setItemHeight(21);
setLineColor(lineColor);
setFont(itemFont);
setFocusRenderer(null);
for (GridItem gridItem : getItems()) {
gridItem.setBackground(0, gray);
}
}
use of org.talend.dataprofiler.core.model.ModelElementIndicator in project tdq-studio-se by Talend.
the class ModelElementIndicatorHelper method getColumns.
/**
* Get columns from modelElementIndicators
*
* @param modelElementIndicators
* @return
*/
public static final List<MetadataColumn> getColumns(ModelElementIndicator[] modelElementIndicators) {
List<MetadataColumn> columns = new ArrayList<MetadataColumn>();
for (ModelElementIndicator modelElementIndicator : modelElementIndicators) {
ColumnIndicator switchColumnIndicator = switchColumnIndicator(modelElementIndicator);
if (switchColumnIndicator == null) {
continue;
}
columns.add(switchColumnIndicator.getTdColumn());
}
return columns;
}
Aggregations