Search in sources :

Example 36 with GridItem

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

the class GridTableViewer method refreshRowHeaders.

/**
 * Refresh row headers only
 *
 * @param element
 *            the element to start or <code>null</code> if all rows should
 *            be refreshed
 */
public void refreshRowHeaders(Object element) {
    boolean refresh = element == null;
    GridItem[] items = getGrid().getItems();
    for (int i = 0; i < items.length; i++) {
        if (refresh || element.equals(items[i].getData())) {
            refresh = true;
            updateRowHeader(items[i]);
        }
    }
}
Also used : GridItem(org.eclipse.nebula.widgets.grid.GridItem) Point(org.eclipse.swt.graphics.Point)

Example 37 with GridItem

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

the class GridTableViewer method doSetSelection.

/**
 * {@inheritDoc}
 */
protected void doSetSelection(Item[] items) {
    GridItem[] items2 = new GridItem[items.length];
    for (int i = 0; i < items.length; i++) {
        items2[i] = (GridItem) items[i];
    }
    grid.setSelection(items2);
    grid.showSelection();
}
Also used : GridItem(org.eclipse.nebula.widgets.grid.GridItem) Point(org.eclipse.swt.graphics.Point)

Example 38 with GridItem

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

the class GridTableViewer method setSelectionToWidget.

/**
 * {@inheritDoc}
 */
protected void setSelectionToWidget(ISelection selection, boolean reveal) {
    if (!grid.isCellSelectionEnabled() || !(selection instanceof CellSelection)) {
        super.setSelectionToWidget(selection, reveal);
        if (selection instanceof SelectionWithFocusRow) {
            Object el = ((SelectionWithFocusRow) selection).getFocusElement();
            if (el != null) {
                GridItem[] items = grid.getItems();
                for (int i = 0; i < items.length; i++) {
                    GridItem item = items[i];
                    if (item.getData() == el || item.getData().equals(el) || (getComparer() != null && getComparer().equals(item.getData(), el))) {
                        grid.setFocusItem(item);
                        break;
                    }
                }
            }
        }
    } else {
        CellSelection cellSelection = (CellSelection) selection;
        List l = cellSelection.toList();
        GridItem[] items = grid.getItems();
        ArrayList pts = new ArrayList();
        for (int i = 0; i < items.length; i++) {
            Iterator it = l.iterator();
            Object itemObject = items[i].getData();
            while (it.hasNext()) {
                Object checkObject = it.next();
                if (itemObject == checkObject || (getComparer() != null && getComparer().equals(itemObject, checkObject))) {
                    Iterator idxIt = cellSelection.getIndices(checkObject).iterator();
                    while (idxIt.hasNext()) {
                        Integer idx = (Integer) idxIt.next();
                        pts.add(new Point(idx.intValue(), i));
                    }
                }
            }
        }
        Point[] tmp = new Point[pts.size()];
        pts.toArray(tmp);
        grid.setCellSelection(tmp);
        if (cellSelection.getFocusElement() != null) {
            Object el = cellSelection.getFocusElement();
            for (int i = 0; i < items.length; i++) {
                GridItem item = items[i];
                if (item.getData() == el || item.getData().equals(el) || (getComparer() != null && getComparer().equals(item.getData(), el))) {
                    grid.setFocusItem(item);
                    break;
                }
            }
        }
    }
}
Also used : GridItem(org.eclipse.nebula.widgets.grid.GridItem) CellSelection(org.eclipse.nebula.jface.gridviewer.internal.CellSelection) SelectionWithFocusRow(org.eclipse.nebula.jface.gridviewer.internal.SelectionWithFocusRow) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point)

Example 39 with GridItem

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

the class GridViewerColumn method setEditingSupport.

/**
 * {@inheritDoc}
 */
public void setEditingSupport(EditingSupport editingSupport) {
    if (editingSupport instanceof CheckEditingSupport) {
        if (checkEditingSupport == null) {
            final int colIndex = getColumn().getParent().indexOf(getColumn());
            getColumn().getParent().addListener(SWT.Selection, new Listener() {

                public void handleEvent(Event event) {
                    if (event.detail == SWT.CHECK && event.index == colIndex) {
                        GridItem item = (GridItem) event.item;
                        Object element = item.getData();
                        checkEditingSupport.setValue(element, new Boolean(item.getChecked(colIndex)));
                    }
                }
            });
        }
        checkEditingSupport = (CheckEditingSupport) editingSupport;
    } else {
        super.setEditingSupport(editingSupport);
    }
}
Also used : Listener(org.eclipse.swt.widgets.Listener) GridItem(org.eclipse.nebula.widgets.grid.GridItem) Event(org.eclipse.swt.widgets.Event)

Example 40 with GridItem

use of org.eclipse.nebula.widgets.grid.GridItem in project translationstudio8 by heartsome.

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