use of org.eclipse.nebula.widgets.grid.Grid.GridVisibleRange in project translationstudio8 by heartsome.
the class GridVisibleRangeSupport method calculateChange.
private void calculateChange() {
// FIXME Add back
if (rangeChangeListener != null) {
GridVisibleRange range = grid.getVisibleRange();
ArrayList lOrigItems = new ArrayList();
lOrigItems.addAll(Arrays.asList(oldRange.getItems()));
ArrayList lNewItems = new ArrayList();
lNewItems.addAll(Arrays.asList(range.getItems()));
Iterator it = lNewItems.iterator();
while (it.hasNext()) {
if (lOrigItems.remove(it.next())) {
it.remove();
}
}
ArrayList lOrigColumns = new ArrayList();
lOrigColumns.addAll(Arrays.asList(oldRange.getColumns()));
ArrayList lNewColumns = new ArrayList();
lNewColumns.addAll(Arrays.asList(range.getColumns()));
it = lNewColumns.iterator();
while (it.hasNext()) {
if (lOrigColumns.remove(it.next())) {
it.remove();
}
}
if (lOrigItems.size() != 0 || lNewItems.size() != 0 || lOrigColumns.size() != 0 || lNewColumns.size() != 0) {
RangeChangedEvent evt = new RangeChangedEvent(grid, range);
evt.addedRows = new GridItem[lNewItems.size()];
lNewItems.toArray(evt.addedRows);
evt.removedRows = new GridItem[lOrigItems.size()];
lOrigItems.toArray(evt.removedRows);
evt.addedColumns = new GridColumn[lNewColumns.size()];
lNewColumns.toArray(evt.addedColumns);
evt.removedColumns = new GridColumn[lOrigColumns.size()];
lNewColumns.toArray(evt.removedColumns);
it = rangeChangeListener.iterator();
while (it.hasNext()) {
((VisibleRangeChangedListener) it.next()).rangeChanged(evt);
}
}
oldRange = range;
}
}
use of org.eclipse.nebula.widgets.grid.Grid.GridVisibleRange in project translationstudio8 by heartsome.
the class GridCopyEnable method handleVerticalScroll.
void handleVerticalScroll(Event event) {
GridVisibleRange visibleR = gridTable.getVisibleRange();
GridItem[] items = visibleR.getItems();
boolean itemFlg = false;
for (GridItem item : items) {
if (focusItem == item) {
itemFlg = true;
}
}
boolean columnFlg = false;
GridColumn[] columns = visibleR.getColumns();
if (columns.length - 1 >= focusColIndex) {
columnFlg = true;
}
if (!itemFlg || !columnFlg) {
defaultCaret.setVisible(false);
return;
}
defaultCaret.setVisible(true);
GridColumn col = gridTable.getColumn(focusColIndex);
GridCellRenderer gcr = col.getCellRenderer();
int colIndex = gcr.getColumn();
if (gcr == null || !(gcr instanceof XGridCellRenderer) || !copyAbleColumnIndexs.contains(colIndex)) {
return;
}
XGridCellRenderer cellRender = (XGridCellRenderer) gcr;
Rectangle cellBounds = focusItem.getBounds(colIndex);
GC gc = new GC(Display.getDefault());
TextLayout layout = null;
try {
layout = cellRender.getTextLayout(gc, focusItem, colIndex, true, false);
if (layout == null) {
gc.dispose();
return;
}
Point point = layout.getLocation(caretOffset, false);
coordinateOffsetX = cellBounds.x + cellRender.leftMargin;
coordinateOffsetY = cellBounds.y + cellRender.topMargin + cellRender.textTopMargin;
defaultCaret.setLocation(point.x + coordinateOffsetX, point.y + coordinateOffsetY);
} finally {
if (layout != null) {
layout.dispose();
}
if (gc != null) {
gc.dispose();
}
}
}
Aggregations