use of org.eclipse.nebula.widgets.grid.GridColumn in project tdq-studio-se by Talend.
the class AbstractIndicatorSelectGrid method handleRowHeaderHighlight.
private boolean handleRowHeaderHighlight(MouseEvent e, GridVisibleRange range) {
GridItem currentItem = getItem(new Point(e.x, e.y));
if (currentItem != null) {
// row header
if (overRowSelect(currentItem, new Point(e.x, e.y))) {
// handle hover event of row select cell
for (GridItem item : range.getItems()) {
int i = indexOf(item);
if (item.getCheckable(0)) {
if (i == indexOf(currentItem)) {
item.setBackground(0, highlightBlue);
item.setBackground(1, highlightBlue);
} else {
item.setBackground(0, gray);
item.setBackground(1, getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
}
}
for (GridColumn column : range.getColumns()) {
int j = indexOf(column);
if (i == indexOf(currentItem)) {
item.setBackground(j, highlightBlue);
} else {
item.setBackground(j, getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
}
}
}
for (GridColumn column : range.getColumns()) {
column.getHeaderRenderer().setSelected(false);
}
}
return true;
}
return false;
}
use of org.eclipse.nebula.widgets.grid.GridColumn in project tdq-studio-se by Talend.
the class IndicatorSelectGrid method update.
/*
* (non-Javadoc)
*
* @see org.talend.dataprofiler.core.ui.grid.utils.TDQObserver#update(java.lang.Object)
*/
public void update(ObserverEvent observerEvent) {
switch(observerEvent.getEventType()) {
case ColumnResize:
Object data = observerEvent.getData(ObserverEvent.COLUMN_HEADER_RESIZE);
if (data == null) {
return;
}
GridColumn sourceGridColumn = ((GridColumn) data);
for (GridColumn currColumn : this.getColumns()) {
Object oldmodelElementIndicator = sourceGridColumn.getData();
if (oldmodelElementIndicator == currColumn.getData()) {
currColumn.setWidth(sourceGridColumn.getWidth());
break;
}
}
break;
case MoveColumn:
data = observerEvent.getData(ObserverEvent.COLUMN_HEADER_MOVE);
if (data == null) {
return;
}
this.setColumnOrder((int[]) data);
if (result == null) {
result = new ModelElementIndicator[getColumnCount() - 2];
}
int[] order = getColumnOrder();
int j = 0;
for (int columnIndex : order) {
if (columnIndex > 1) {
// indicator selection starts from the 3rd
result[j] = _modelElementIndicators[columnIndex - 2];
// column
j++;
}
}
redraw();
break;
case HSrcollMove:
data = observerEvent.getData(ObserverEvent.HORIZONTAL_SCROLLBAR_MOVE);
if (data == null || getHorizontalBar() == null) {
return;
}
getHorizontalBar().setSelection(Integer.parseInt(data.toString()));
redraw(getClientArea().x, getClientArea().y, getClientArea().width, getClientArea().height, false);
break;
case VSrcollVisible:
data = observerEvent.getData(ObserverEvent.VERTICAL_SRCOLL_VISABLE);
if (data == null || getVerticalBar() == null) {
return;
}
if (!getVerticalBar().isVisible() && Boolean.parseBoolean(data.toString())) {
// make current table bounds change to small
GridData previewGridData = (GridData) this.getLayoutData();
previewGridData.widthHint = this.getBounds().width - 50 - getVerticalBar().getSize().x;
previewGridData.minimumWidth = this.getBounds().width - 50 - getVerticalBar().getSize().x;
previewGridData.horizontalAlignment = SWT.BEGINNING;
this.getParent().layout();
}
if (!getVerticalBar().isVisible() && !Boolean.parseBoolean(data.toString())) {
// make current table bounds change to big
GridData previewGridData = (GridData) this.getLayoutData();
if (previewGridData.horizontalAlignment == SWT.FILL) {
return;
}
previewGridData.minimumWidth = 650;
previewGridData.horizontalAlignment = SWT.FILL;
notifyVerticalBarShown(false);
}
break;
case ColumnHighlight:
data = observerEvent.getData(ObserverEvent.COLUMN_HIGH_LIGHT);
handleColumnHighlight(((Integer) data));
break;
}
}
use of org.eclipse.nebula.widgets.grid.GridColumn in project tdq-studio-se by Talend.
the class TdColumnHeaderRenderer method getControlBounds.
/**
* @return the bounds reserved for the control
*/
@Override
protected Rectangle getControlBounds(Object value, boolean preferred) {
Rectangle bounds = getBounds();
GridColumn column = (GridColumn) value;
Point controlSize = computeControlSize(column);
int y = getBounds().y + getBounds().height - bottomMargin - controlSize.y;
return new Rectangle(bounds.x + 3, y, bounds.width - 6, controlSize.y);
}
use of org.eclipse.nebula.widgets.grid.GridColumn in project tdq-studio-se by Talend.
the class TdColumnHeaderRenderer method paint.
/**
* {@inheritDoc}
*/
public void paint(GC gc, Object value) {
gc.setAntialias(SWT.ON);
gc.setTransform(_transform);
float[] original = { (float) getBounds().x - 2, (float) getBounds().y + (float) getBounds().height - 2 };
_transformInv.transform(original);
GridColumn column = (GridColumn) value;
// set the font to be used to display the text.
gc.setFont(column.getHeaderFont());
gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW));
if (isSelected()) {
gc.setBackground(IndicatorSelectGrid.highlightBlue);
gc.fillRectangle((int) original[0], (int) original[1] + 2, (int) (getBounds().height / sinRotation) + getBounds().width, (int) (getBounds().width * sinRotation));
}
int x = leftMargin;
int width = getBounds().width - x;
width -= rightMargin;
float[] cords = { (getBounds().x + width / 2 - leftMargin), (getBounds().y + (float) getBounds().height - topMargin) };
_transformInv.transform(cords);
if (column.getImage() != null) {
gc.drawImage(column.getImage(), (int) cords[0] + leftMargin + imageSpacing, (int) cords[1]);
x += column.getImage().getBounds().width;
}
gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_FOREGROUND));
String text = column.getText();
if (column.getAlignment() == SWT.RIGHT) {
int len = gc.stringExtent(text).x;
if (len < width) {
x += width - len;
}
} else if (column.getAlignment() == SWT.CENTER) {
int len = gc.stringExtent(text).x;
if (len < width) {
x += (width - len) / 2;
}
}
gc.drawString(text, (int) cords[0] + x + imageSpacing, (int) cords[1] + topMargin);
gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));
gc.drawLine((int) (original[0]), (int) (original[1]), (int) (original[0] + getBounds().height / sinRotation - imageSpacing), (int) (original[1]));
gc.drawLine((int) (original[0]), (int) (original[1] + getBounds().width * sinRotation), (int) (original[0] + getBounds().height / sinRotation + getBounds().width * cosRotation - imageSpacing - leftMargin), (int) (original[1] + getBounds().width * sinRotation));
gc.setTransform(null);
gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_FOREGROUND));
gc.drawLine(getBounds().x, getBounds().y + getBounds().height - 1, getBounds().x + getBounds().width, getBounds().y + getBounds().height - 1);
}
use of org.eclipse.nebula.widgets.grid.GridColumn in project tdq-studio-se by Talend.
the class TdRowHeaderRenderer method paint.
/**
* {@inheritDoc}
*/
public void paint(GC gc, Object value) {
GridItem item = (GridItem) value;
gc.setFont(item.getFont(getColumn()));
if (item.getParent().isEnabled()) {
Color back = item.getBackground(getColumn());
if (back != null) {
gc.setBackground(back);
}
} else {
gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
}
gc.setForeground(item.getForeground(getColumn()));
gc.fillRectangle(getBounds());
int x = leftMargin;
if (isTree()) {
boolean renderBranches = item.getParent().getTreeLinesVisible();
if (renderBranches) {
branchRenderer.setBranches(getBranches(item));
branchRenderer.setIndent(treeIndent);
// Take
branchRenderer.setBounds(getBounds().x + x, getBounds().y, getToggleIndent(item), getBounds().height + 1);
// into
// account
// border
}
x += getToggleIndent(item);
toggleRenderer.setExpanded(item.isExpanded());
toggleRenderer.setHover(getHoverDetail().equals("toggle"));
toggleRenderer.setLocation(getBounds().x + x, (getBounds().height - toggleRenderer.getBounds().height) / 2 + getBounds().y);
if (item.hasChildren())
toggleRenderer.paint(gc, null);
if (renderBranches) {
branchRenderer.setToggleBounds(toggleRenderer.getBounds());
branchRenderer.paint(gc, null);
}
x += toggleRenderer.getBounds().width + insideMargin;
}
Image image = item.getImage(getColumn());
if (image != null) {
int y = getBounds().y;
y += (getBounds().height - image.getBounds().height) / 2;
gc.drawImage(image, getBounds().x + x, y);
x += image.getBounds().width + insideMargin;
}
int width = getBounds().width - x - rightMargin;
gc.setForeground(item.getForeground(getColumn()));
if (!isWordWrap()) {
String text = TextUtils.getShortString(gc, item.getText(getColumn()), width);
if (getAlignment() == SWT.RIGHT) {
int len = gc.stringExtent(text).x;
if (len < width) {
x += width - len;
}
} else if (getAlignment() == SWT.CENTER) {
int len = gc.stringExtent(text).x;
if (len < width) {
x += (width - len) / 2;
}
}
gc.drawString(text, getBounds().x + x, getBounds().y + textTopMargin + topMargin, true);
} else {
if (textLayout == null) {
textLayout = new TextLayout(gc.getDevice());
item.getParent().addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
textLayout.dispose();
}
});
}
textLayout.setFont(gc.getFont());
textLayout.setText(item.getText(getColumn()));
textLayout.setAlignment(getAlignment());
textLayout.setWidth(width < 1 ? 1 : width);
if (item.getParent().isAutoHeight()) {
// Look through all columns (except this one) to get the max height needed for this item
int columnCount = item.getParent().getColumnCount();
int maxHeight = textLayout.getBounds().height + textTopMargin + textBottomMargin;
for (int i = 0; i < columnCount; i++) {
GridColumn column = item.getParent().getColumn(i);
if (i != getColumn() && column.getWordWrap()) {
int height = column.getCellRenderer().computeSize(gc, column.getWidth(), SWT.DEFAULT, item).y;
maxHeight = Math.max(maxHeight, height);
}
}
// Also look at the row header if necessary
if (item.getParent().isWordWrapHeader()) {
int height = item.getParent().getRowHeaderRenderer().computeSize(gc, SWT.DEFAULT, SWT.DEFAULT, item).y;
maxHeight = Math.max(maxHeight, height);
}
if (maxHeight != item.getHeight()) {
item.setHeight(maxHeight);
}
}
textLayout.draw(gc, getBounds().x + x, getBounds().y + textTopMargin + topMargin);
}
boolean checkable = item.getCheckable(1);
boolean checked = item.getChecked(1);
// fill background rectangle
Color systemBackColor = getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND);
if (checkable) {
gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
} else {
gc.setBackground(IndicatorSelectGrid.gray);
}
int originX = getBounds().x + getBounds().width - 50;
gc.fillRectangle(originX, getBounds().y, 50, getBounds().height);
// show row select cells
if (checkable) {
// draw highlight color as background
Color highlight = item.getBackground(1);
if (highlight != null) {
gc.setBackground(highlight);
gc.fillRectangle(originX, getBounds().y, 50, getBounds().height);
}
if (checked) {
// draw background oval
int offset = 50 - getBounds().height;
gc.setBackground(IndicatorSelectGrid.blue);
gc.fillOval(originX + offset / 2 + 2, getBounds().y + 2, 50 - offset - 4, getBounds().height - 4);
// draw a white oval for partially selected cells
if (item.getGrayed(1)) {
gc.setBackground(systemBackColor);
gc.setAlpha(160);
gc.fillOval(originX + offset / 2 + 2, getBounds().y + 2, 50 - offset - 4, getBounds().height - 4);
gc.setAlpha(-1);
}
// draw tick image
if (highlight != null) {
gc.setForeground(highlight);
} else {
gc.setForeground(systemBackColor);
}
gc.setLineWidth(3);
gc.drawLine(originX + 18, getBounds().y + 10, originX + 23, getBounds().y + 15);
gc.drawLine(originX + 21, getBounds().y + 15, originX + 30, getBounds().y + 6);
gc.setLineWidth(1);
}
}
if (item.getParent().getLinesVisible()) {
gc.setForeground(item.getParent().getLineColor());
gc.drawLine(getBounds().x, getBounds().y + getBounds().height, getBounds().x + getBounds().width - 1, getBounds().y + getBounds().height);
gc.drawLine(getBounds().x + getBounds().width - 51, getBounds().y, getBounds().x + getBounds().width - 51, getBounds().y + getBounds().height);
gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW));
gc.drawLine(getBounds().x + getBounds().width - 1, getBounds().y, getBounds().x + getBounds().width - 1, getBounds().y + getBounds().height);
}
}
Aggregations