use of com.biglybt.ui.common.table.TableColumnCore in project BiglyBT by BiglySoftware.
the class ColumnTC_NameInfo method cellPaint.
// @see com.biglybt.ui.swt.views.table.TableCellSWTPaintListener#cellPaint(org.eclipse.swt.graphics.GC, com.biglybt.ui.swt.views.table.TableCellSWT)
@Override
public void cellPaint(GC gc, TableCellSWT cell) {
TableColumnCore column = (TableColumnCore) cell.getDataSource();
String raw_key = column.getTitleLanguageKey(false);
String current_key = column.getTitleLanguageKey(true);
Rectangle bounds = cell.getBounds();
if (bounds == null || bounds.isEmpty()) {
return;
}
Font fontDefault = gc.getFont();
if (fontHeader == null) {
FontData[] fontData = gc.getFont().getFontData();
fontData[0].setStyle(SWT.BOLD);
fontData[0].setHeight(fontData[0].getHeight() + 1);
fontHeader = new Font(gc.getDevice(), fontData);
}
gc.setFont(fontHeader);
bounds.y += 3;
bounds.x += 7;
bounds.width -= 14;
String name = MessageText.getString(raw_key, column.getName());
if (!raw_key.equals(current_key)) {
String rename = MessageText.getString(current_key, "");
if (rename.length() > 0) {
name += " (->" + rename + ")";
}
}
GCStringPrinter sp = new GCStringPrinter(gc, name, bounds, GCStringPrinter.FLAG_SKIPCLIP, SWT.TOP);
sp.printString();
Point titleSize = sp.getCalculatedSize();
gc.setFont(fontDefault);
String info = MessageText.getString(raw_key + ".info", "");
Rectangle infoBounds = new Rectangle(bounds.x + 10, bounds.y + titleSize.y + 5, bounds.width - 15, bounds.height - 20);
GCStringPrinter.printString(gc, info, infoBounds, true, false);
TableColumnInfo columnInfo = (TableColumnInfo) cell.getTableRow().getData("columninfo");
if (columnInfo == null) {
final TableColumnManager tcm = TableColumnManager.getInstance();
columnInfo = tcm.getColumnInfo(column.getForDataSourceType(), column.getTableID(), column.getName());
cell.getTableRowCore().setData("columninfo", columnInfo);
}
Rectangle profBounds = new Rectangle(bounds.width - 100, bounds.y - 2, 100, 20);
byte proficiency = columnInfo.getProficiency();
if (proficiency > 0 && proficiency < profText.length) {
int alpha = gc.getAlpha();
gc.setAlpha(0xA0);
GCStringPrinter.printString(gc, MessageText.getString("ConfigView.section.mode." + profText[proficiency]), profBounds, true, false, SWT.RIGHT | SWT.TOP);
gc.setAlpha(alpha);
}
Rectangle hitArea;
TableView<?> tv = ((TableCellCore) cell).getTableRowCore().getView();
TableColumnSetupWindow tvs = (TableColumnSetupWindow) tv.getParentDataSource();
if (tvs.isColumnAdded(column)) {
hitArea = Utils.EMPTY_RECT;
} else {
int x = bounds.x + titleSize.x + 15;
int y = bounds.y - 1;
int h = 15;
String textAdd = MessageText.getString("Button.add");
GCStringPrinter sp2 = new GCStringPrinter(gc, textAdd, new Rectangle(x, y, 500, h), true, false, SWT.CENTER);
sp2.calculateMetrics();
int w = sp2.getCalculatedSize().x + 12;
gc.setAdvanced(true);
gc.setAntialias(SWT.ON);
gc.setBackground(ColorCache.getColor(gc.getDevice(), 255, 255, 255));
gc.fillRoundRectangle(x, y, w, h, 15, h);
gc.setBackground(ColorCache.getColor(gc.getDevice(), 215, 215, 215));
gc.fillRoundRectangle(x + 2, y + 2, w, h, 15, h);
gc.setForeground(ColorCache.getColor(gc.getDevice(), 145, 145, 145));
gc.drawRoundRectangle(x, y, w, h, 15, h);
gc.setForeground(ColorCache.getColor(gc.getDevice(), 50, 50, 50));
hitArea = new Rectangle(x, y, w + 2, h);
sp2.printString(gc, hitArea, SWT.CENTER);
bounds = cell.getBounds();
hitArea.x -= bounds.x;
hitArea.y -= bounds.y;
}
cell.getTableRowCore().setData("AddHitArea", hitArea);
}
use of com.biglybt.ui.common.table.TableColumnCore in project BiglyBT by BiglySoftware.
the class ColumnTC_NameInfo method cellMouseTrigger.
// @see com.biglybt.pif.ui.tables.TableCellMouseListener#cellMouseTrigger(com.biglybt.pif.ui.tables.TableCellMouseEvent)
@Override
public void cellMouseTrigger(TableCellMouseEvent event) {
if (event.button == 1 && event.eventType == TableRowMouseEvent.EVENT_MOUSEUP && (event.cell instanceof TableCellCore)) {
Object data = event.cell.getTableRow().getData("AddHitArea");
if (data instanceof Rectangle) {
Rectangle hitArea = (Rectangle) data;
if (hitArea.contains(event.x, event.y)) {
TableView<?> tv = ((TableCellCore) event.cell).getTableRowCore().getView();
TableColumnSetupWindow tvs = (TableColumnSetupWindow) tv.getParentDataSource();
Object dataSource = event.cell.getDataSource();
if (dataSource instanceof TableColumnCore) {
TableColumnCore column = (TableColumnCore) dataSource;
tvs.chooseColumn(column);
}
}
}
} else if (event.eventType == TableRowMouseEvent.EVENT_MOUSEMOVE) {
Object data = event.cell.getTableRow().getData("AddHitArea");
if (data instanceof Rectangle) {
Rectangle hitArea = (Rectangle) data;
if (hitArea.contains(event.x, event.y)) {
((TableCellSWT) event.cell).setCursorID(SWT.CURSOR_HAND);
return;
}
}
((TableCellSWT) event.cell).setCursorID(SWT.CURSOR_ARROW);
}
}
use of com.biglybt.ui.common.table.TableColumnCore in project BiglyBT by BiglySoftware.
the class TableCellPainted method getDataSource.
/* (non-Javadoc)
* @see com.biglybt.pif.ui.tables.TableCell#getDataSource()
*/
@Override
public Object getDataSource() {
// remove this because if a disposal-listener needs to get its hands on teh datasource to clean up
// properly we need to return it to them! (happens with the peers view PiecesItem for example)
// if (isDisposed()) {
// return null;
// }
TableRowCore row = tableRow;
TableColumnCore col = tableColumn;
if (row == null || col == null) {
return (null);
}
return row.getDataSource(col.getUseCoreDataSource());
}
use of com.biglybt.ui.common.table.TableColumnCore in project BiglyBT by BiglySoftware.
the class TableRowPainted method buildCells.
private void buildCells() {
// debug("buildCells " + Debug.getCompressedStackTrace());
TableColumnCore[] visibleColumns = getView().getVisibleColumns();
if (visibleColumns == null) {
return;
}
synchronized (lock) {
mTableCells = new LinkedHashMap<>(visibleColumns.length, 1);
TableColumn currentSortColumn = null;
if (cellSort != null) {
currentSortColumn = cellSort.getTableColumn();
}
TableRowCore parentRow = getParentRowCore();
// create all the cells for the column
for (int i = 0; i < visibleColumns.length; i++) {
if (visibleColumns[i] == null) {
continue;
}
if (parentRow != null && !visibleColumns[i].handlesDataSourceType(getDataSource(false).getClass())) {
mTableCells.put(visibleColumns[i].getName(), null);
continue;
}
// System.out.println(dataSource + ": " + tableColumns[i].getName() + ": " + tableColumns[i].getPosition());
TableCellCore cell = (currentSortColumn != null && visibleColumns[i].equals(currentSortColumn)) ? cellSort : new TableCellPainted(TableRowPainted.this, visibleColumns[i], i);
mTableCells.put(visibleColumns[i].getName(), cell);
// if (i == 10) cell.bDebug = true;
}
}
}
use of com.biglybt.ui.common.table.TableColumnCore in project BiglyBT by BiglySoftware.
the class TableRowPainted method setSortColumn.
@Override
public void setSortColumn(String columnID) {
synchronized (lock) {
if (mTableCells == null) {
if (cellSort != null && !cellSort.isDisposed()) {
if (cellSort.getTableColumn().getName().equals(columnID)) {
return;
}
cellSort.dispose();
cellSort = null;
}
TableColumnCore sortColumn = (TableColumnCore) getView().getTableColumn(columnID);
if (getParentRowCore() == null || sortColumn.handlesDataSourceType(getDataSource(false).getClass())) {
cellSort = new TableCellPainted(TableRowPainted.this, sortColumn, sortColumn.getPosition());
} else {
cellSort = null;
}
} else {
cellSort = mTableCells.get(columnID);
}
}
}
Aggregations