Search in sources :

Example 16 with GridColumn

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

the class TdColumnHeaderRenderer method computeSize.

/**
 * {@inheritDoc}
 */
public Point computeSize(GC gc, int wHint, int hHint, Object value) {
    GridColumn column = (GridColumn) value;
    gc.setFont(column.getHeaderFont());
    int x = leftMargin;
    int y = topMargin + gc.getFontMetrics().getHeight() + bottomMargin;
    if (column.getImage() != null) {
        x += column.getImage().getBounds().width + imageSpacing;
        y = Math.max(y, topMargin + column.getImage().getBounds().height + bottomMargin);
    }
    if (!isWordWrap()) {
        x += gc.stringExtent(column.getText()).x + rightMargin;
        y += gc.stringExtent(column.getText()).x * sinRotation;
    } else {
        int plainTextWidth;
        if (wHint == SWT.DEFAULT) {
            plainTextWidth = getBounds().width - x - rightMargin;
        } else {
            plainTextWidth = wHint - x - rightMargin;
        }
        getTextLayout(gc, column);
        textLayout.setText(column.getText());
        textLayout.setWidth(plainTextWidth < 1 ? 1 : plainTextWidth);
        x += plainTextWidth + rightMargin;
        int textHeight = topMargin;
        textHeight += textLayout.getBounds().height;
        textHeight += bottomMargin;
        y = Math.max(y, textHeight);
    }
    y += computeControlSize(column).y;
    return new Point(x, y);
}
Also used : GridColumn(org.eclipse.nebula.widgets.grid.GridColumn) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point)

Example 17 with GridColumn

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

the class AbstractIndicatorSelectGrid method handleColumnHighlight.

protected void handleColumnHighlight(int columnIndex) {
    GridColumn currentColumn = getColumn(columnIndex);
    GridVisibleRange range = this.getVisibleRange();
    if (currentColumn != null && !isDraggingColumn()) {
        int currentColumnIndex = columnIndex;
        for (GridItem item : range.getItems()) {
            for (GridColumn column : range.getColumns()) {
                int j = indexOf(column);
                if (j == currentColumnIndex) {
                    item.setBackground(j, highlightBlue);
                } else {
                    item.setBackground(j, getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
                }
            }
            item.setBackground(0, gray);
            item.setBackground(1, null);
        }
        for (GridColumn column : range.getColumns()) {
            int j = indexOf(column);
            column.getHeaderRenderer().setSelected(j == currentColumnIndex);
        }
    }
}
Also used : TalendGridItem(org.eclipse.nebula.widgets.grid.TalendGridItem) GridItem(org.eclipse.nebula.widgets.grid.GridItem) TalendGridColumn(org.eclipse.nebula.widgets.grid.TalendGridColumn) GridColumn(org.eclipse.nebula.widgets.grid.GridColumn) Point(org.eclipse.swt.graphics.Point)

Example 18 with GridColumn

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

the class AbstractIndicatorSelectGrid method createIndicatorLabelColumn.

/**
 * This column just used to take in space so that visible is false
 */
protected void createIndicatorLabelColumn() {
    GridColumn indicatorLabelColumn = new TalendGridColumn(this, SWT.NONE);
    indicatorLabelColumn.setHeaderRenderer(getColumnHeaderRenderer());
    indicatorLabelColumn.setTree(true);
    indicatorLabelColumn.setWidth(200);
    // $NON-NLS-1$
    indicatorLabelColumn.setText("Indicators");
    // hide the label column, but it is actually visible in the fixed
    indicatorLabelColumn.setVisible(false);
}
Also used : TalendGridColumn(org.eclipse.nebula.widgets.grid.TalendGridColumn) GridColumn(org.eclipse.nebula.widgets.grid.GridColumn) TalendGridColumn(org.eclipse.nebula.widgets.grid.TalendGridColumn)

Example 19 with GridColumn

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

the class AbstractIndicatorSelectGrid method handleColumnHeaderHighlight.

private void handleColumnHeaderHighlight(MouseEvent e, GridVisibleRange range) {
    GridColumn currentColumn = getColumn(new Point(e.x, e.y));
    if (currentColumn != null && !isDraggingColumn()) {
        int currentColumnIndex = indexOf(currentColumn);
        for (GridItem item : range.getItems()) {
            for (GridColumn column : range.getColumns()) {
                int j = indexOf(column);
                if (j == currentColumnIndex) {
                    item.setBackground(j, highlightBlue);
                } else {
                    item.setBackground(j, getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
                }
            }
            item.setBackground(0, gray);
            item.setBackground(1, null);
        }
        for (GridColumn column : range.getColumns()) {
            int j = indexOf(column);
            column.getHeaderRenderer().setSelected(j == currentColumnIndex);
        }
    }
}
Also used : TalendGridItem(org.eclipse.nebula.widgets.grid.TalendGridItem) GridItem(org.eclipse.nebula.widgets.grid.GridItem) TalendGridColumn(org.eclipse.nebula.widgets.grid.TalendGridColumn) GridColumn(org.eclipse.nebula.widgets.grid.GridColumn) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point)

Example 20 with GridColumn

use of org.eclipse.nebula.widgets.grid.GridColumn 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);
    }
}
Also used : MouseMoveListener(org.eclipse.swt.events.MouseMoveListener) Listener(org.eclipse.swt.widgets.Listener) MouseListener(org.eclipse.swt.events.MouseListener) IRepositoryNode(org.talend.repository.model.IRepositoryNode) TalendGridColumn(org.eclipse.nebula.widgets.grid.TalendGridColumn) DBColumnRepNode(org.talend.dq.nodes.DBColumnRepNode) Point(org.eclipse.swt.graphics.Point) TalendGridItem(org.eclipse.nebula.widgets.grid.TalendGridItem) GridItem(org.eclipse.nebula.widgets.grid.GridItem) Event(org.eclipse.swt.widgets.Event) MouseEvent(org.eclipse.swt.events.MouseEvent) TalendGridColumn(org.eclipse.nebula.widgets.grid.TalendGridColumn) GridColumn(org.eclipse.nebula.widgets.grid.GridColumn) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator)

Aggregations

GridColumn (org.eclipse.nebula.widgets.grid.GridColumn)45 Point (org.eclipse.swt.graphics.Point)38 GridItem (org.eclipse.nebula.widgets.grid.GridItem)16 Rectangle (org.eclipse.swt.graphics.Rectangle)14 TalendGridColumn (org.eclipse.nebula.widgets.grid.TalendGridColumn)7 GC (org.eclipse.swt.graphics.GC)7 TalendGridItem (org.eclipse.nebula.widgets.grid.TalendGridItem)6 GridData (org.eclipse.swt.layout.GridData)6 Color (org.eclipse.swt.graphics.Color)5 Image (org.eclipse.swt.graphics.Image)5 GridLayout (org.eclipse.swt.layout.GridLayout)5 Grid (org.eclipse.nebula.widgets.grid.Grid)4 DisposeEvent (org.eclipse.swt.events.DisposeEvent)4 DisposeListener (org.eclipse.swt.events.DisposeListener)4 TextLayout (org.eclipse.swt.graphics.TextLayout)4 Composite (org.eclipse.swt.widgets.Composite)4 Event (org.eclipse.swt.widgets.Event)4 Listener (org.eclipse.swt.widgets.Listener)4 GridCellRenderer (org.eclipse.nebula.widgets.grid.GridCellRenderer)3 SelectionEvent (org.eclipse.swt.events.SelectionEvent)3