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]);
}
}
}
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();
}
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;
}
}
}
}
}
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);
}
}
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);
}
Aggregations