Search in sources :

Example 31 with GridItem

use of org.eclipse.nebula.widgets.grid.GridItem 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 32 with GridItem

use of org.eclipse.nebula.widgets.grid.GridItem 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)

Example 33 with GridItem

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

the class AbstractTdCellRenderer method computeSize.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.nebula.widgets.grid.IRenderer#computeSize(org.eclipse.swt.graphics.GC, int, int,
     * java.lang.Object)
     */
public Point computeSize(GC gc, int wHint, int hHint, Object value) {
    GridItem item = (GridItem) value;
    gc.setFont(item.getFont(getColumn()));
    int x = 0;
    x += leftMargin;
    if (isCheck()) {
        x += getBounds().width + insideMargin;
    }
    int y = 0;
    Image image = item.getImage(getColumn());
    if (image != null) {
        y = topMargin + image.getBounds().height + bottomMargin;
        x += image.getBounds().width + insideMargin;
    }
    return new Point(x, y);
}
Also used : GridItem(org.eclipse.nebula.widgets.grid.GridItem) Point(org.eclipse.swt.graphics.Point) Image(org.eclipse.swt.graphics.Image) Point(org.eclipse.swt.graphics.Point)

Example 34 with GridItem

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

the class SelectPatternsWizard method performFinish.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.wizard.Wizard#performFinish()
     */
@Override
public boolean performFinish() {
    Grid table = patternSelectPage.getTable();
    GridColumn[] gridColumns = table.getColumns();
    GridItem[] gridItems = table.getItems();
    for (GridItem item : gridItems) {
        for (GridColumn column : gridColumns) {
            int columnIndex = table.indexOf(column);
            if (!item.getChecked(columnIndex)) {
                // allMatchIndicator.getAllChildIndicators().remove(((Map<?, ?>) item.getData()).get(columnIndex));
                patternSelectPage.getTableInputList().get(table.indexOf(item)).put(columnIndex, null);
            }
        }
    }
    return true;
}
Also used : GridItem(org.eclipse.nebula.widgets.grid.GridItem) Grid(org.eclipse.nebula.widgets.grid.Grid) GridColumn(org.eclipse.nebula.widgets.grid.GridColumn)

Example 35 with GridItem

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

the class GridColumnLabelProvider method update.

/**
 * {@inheritDoc}
 */
public void update(ViewerCell cell) {
    super.update(cell);
    Object element = cell.getElement();
    String rowText = getRowHeaderText(element);
    int colSpan = getColumnSpan(element);
    int rowSpan = getRowSpan(element);
    GridItem gridItem = (GridItem) cell.getViewerRow().getItem();
    if (rowText != null) {
        gridItem.setHeaderText(rowText);
    }
    gridItem.setColumnSpan(cell.getColumnIndex(), colSpan);
    gridItem.setRowSpan(cell.getColumnIndex(), rowSpan);
}
Also used : GridItem(org.eclipse.nebula.widgets.grid.GridItem)

Aggregations

GridItem (org.eclipse.nebula.widgets.grid.GridItem)69 Point (org.eclipse.swt.graphics.Point)46 Image (org.eclipse.swt.graphics.Image)20 TextLayout (org.eclipse.swt.graphics.TextLayout)17 GridColumn (org.eclipse.nebula.widgets.grid.GridColumn)16 Color (org.eclipse.swt.graphics.Color)12 Grid (org.eclipse.nebula.widgets.grid.Grid)9 TalendGridItem (org.eclipse.nebula.widgets.grid.TalendGridItem)8 Rectangle (org.eclipse.swt.graphics.Rectangle)8 DisposeEvent (org.eclipse.swt.events.DisposeEvent)6 DisposeListener (org.eclipse.swt.events.DisposeListener)6 ArrayList (java.util.ArrayList)5 TalendGridColumn (org.eclipse.nebula.widgets.grid.TalendGridColumn)5 Event (org.eclipse.swt.widgets.Event)5 Listener (org.eclipse.swt.widgets.Listener)5 SQLException (java.sql.SQLException)3 List (java.util.List)3 DBOperator (net.heartsome.cat.database.DBOperator)3 GridCellRenderer (org.eclipse.nebula.widgets.grid.GridCellRenderer)3 GC (org.eclipse.swt.graphics.GC)3