Search in sources :

Example 1 with TalendGridItem

use of org.eclipse.nebula.widgets.grid.TalendGridItem 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);
}
Also used : IndicatorEnum(org.talend.dq.nodes.indicator.type.IndicatorEnum) TalendGridItem(org.eclipse.nebula.widgets.grid.TalendGridItem) Point(org.eclipse.swt.graphics.Point) IIndicatorNode(org.talend.dq.nodes.indicator.IIndicatorNode) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator)

Example 2 with TalendGridItem

use of org.eclipse.nebula.widgets.grid.TalendGridItem in project tdq-studio-se by Talend.

the class ColumnPreviewGrid method createTableContent.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.dataprofiler.core.ui.grid.AbstractIndicatorSelectGrid#createTableContent()
     */
@Override
protected void createTableContent() {
    try {
        TalendGridItem PreviewItem = new TalendGridItem(this, SWT.NONE);
        for (int i = 0; i < this.getColumnCount(); i++) {
            PreviewItem.setCheckable(i, false);
        }
        // $NON-NLS-1$
        PreviewItem.setText(DefaultMessagesImpl.getString("ColumnPreviewGrid.PreviewItemLabel"));
        processNodePrivew(null, PreviewItem);
        PreviewItem.setExpanded(true);
    } catch (SQLException e) {
    }
}
Also used : SQLException(java.sql.SQLException) TalendGridItem(org.eclipse.nebula.widgets.grid.TalendGridItem) Point(org.eclipse.swt.graphics.Point)

Example 3 with TalendGridItem

use of org.eclipse.nebula.widgets.grid.TalendGridItem in project tdq-studio-se by Talend.

the class ColumnPreviewGrid method processNodePrivew.

/**
 * DOC talend Comment method "processNodePrivew".
 *
 * @param object
 * @param previewItem
 * @throws SQLException
 */
private void processNodePrivew(Object object, GridItem parentItem) throws SQLException {
    if (!checkSameTable()) {
        return;
    }
    for (int j = 0; j < limitNumber; j++) {
        TalendGridItem currentItem = new TalendGridItem(parentItem, SWT.NONE);
        currentItem.setCheckable(0, false);
        currentItem.setCheckable(1, false);
        for (int i = 2; i < this.getColumnCount(); i++) {
            GridColumn column = getColumn(i);
            currentItem.setCheckable(i, false);
            String columnValue = getColumnValue(i - 2, currentItem);
            if (columnValue == null) {
                this.remove(this.indexOf(currentItem));
                return;
            }
            int minWith = columnValue.length() * 7 > 100 ? 100 : columnValue.length() * 7;
            column.setWidth(COLUMN_WIDTH < minWith ? minWith : COLUMN_WIDTH);
            currentItem.setText(i, columnValue);
        }
    }
}
Also used : TalendGridItem(org.eclipse.nebula.widgets.grid.TalendGridItem) GridColumn(org.eclipse.nebula.widgets.grid.GridColumn) Point(org.eclipse.swt.graphics.Point)

Example 4 with TalendGridItem

use of org.eclipse.nebula.widgets.grid.TalendGridItem in project tdq-studio-se by Talend.

the class AbstractIndicatorSelectGrid method createTableContent.

/**
 * Create the Content of table
 */
protected void createTableContent() {
    IIndicatorNode[] branchNodes = IndicatorTreeModelBuilder.buildIndicatorCategory();
    for (IIndicatorNode indicatorNode : branchNodes) {
        TalendGridItem item = new TalendGridItem(this, SWT.NONE);
        item.setText(indicatorNode.getLabel());
        item.setData(indicatorNode);
        createChildNodes(null, item, indicatorNode);
        processNodeSelection(null, item);
    }
}
Also used : TalendGridItem(org.eclipse.nebula.widgets.grid.TalendGridItem) IIndicatorNode(org.talend.dq.nodes.indicator.IIndicatorNode)

Aggregations

TalendGridItem (org.eclipse.nebula.widgets.grid.TalendGridItem)4 Point (org.eclipse.swt.graphics.Point)3 IIndicatorNode (org.talend.dq.nodes.indicator.IIndicatorNode)2 SQLException (java.sql.SQLException)1 GridColumn (org.eclipse.nebula.widgets.grid.GridColumn)1 ModelElementIndicator (org.talend.dataprofiler.core.model.ModelElementIndicator)1 IndicatorEnum (org.talend.dq.nodes.indicator.type.IndicatorEnum)1