use of com.biglybt.ui.swt.views.table.impl.TableTooltips in project BiglyBT by BiglySoftware.
the class TableViewPainted method initialize.
@Override
public void initialize(UISWTView parentView, Composite parent) {
tvTabsCommon = new TableViewSWT_TabsCommon(parentView, this);
shell = parent.getShell();
mainComposite = tvTabsCommon.createSashForm(parent);
mainComposite.setData("Name", tableID);
mainComposite.setData("ObfuscateImage", this);
Composite cTableComposite = tvTabsCommon.tableComposite;
cTableComposite.setLayout(new FormLayout());
Layout layout = parent.getLayout();
if (layout instanceof FormLayout) {
FormData fd = Utils.getFilledFormData();
cTableComposite.setLayoutData(fd);
}
cHeaderArea = new Canvas(cTableComposite, SWT.DOUBLE_BUFFERED);
fontHeader = FontUtils.getFontWithHeight(cHeaderArea.getFont(), null, Utils.adjustPXForDPI(12));
fontHeaderSmall = FontUtils.getFontPercentOf(fontHeader, 0.8f);
cHeaderArea.setFont(fontHeader);
cTable = new Canvas(cTableComposite, SWT.NO_BACKGROUND | SWT.H_SCROLL | SWT.V_SCROLL);
int minRowHeight = FontUtils.getFontHeightInPX(cTable.getFont());
if (iHeightEM > 0) {
defaultRowHeight = (int) ((minRowHeight * iHeightEM) + iHeightEM);
iHeightEM = -1;
}
// good test
// cTable.setFont(FontUtils.getFontPercentOf(cTable.getFont(), 1.50f));
minRowHeight += Math.ceil(minRowHeight * 2.0 / 16.0);
if (defaultRowHeight < minRowHeight) {
defaultRowHeight = minRowHeight;
}
cTable.setBackground(Colors.getSystemColor(parent.getDisplay(), SWT.COLOR_LIST_BACKGROUND));
headerHeight = configMan.getIntParameter("Table.headerHeight");
if (headerHeight <= 0) {
headerHeight = Utils.adjustPXForDPI(DEFAULT_HEADER_HEIGHT);
}
FormData fd = Utils.getFilledFormData();
fd.height = headerHeight;
fd.bottom = null;
cHeaderArea.setLayoutData(fd);
fd = Utils.getFilledFormData();
fd.top = new FormAttachment(cHeaderArea);
cTable.setLayoutData(fd);
clientArea = cTable.getClientArea();
TableColumnCore[] tableColumns = getAllColumns();
TableColumnCore[] tmpColumnsOrdered = new TableColumnCore[tableColumns.length];
// Create all columns
int columnOrderPos = 0;
Arrays.sort(tableColumns, TableColumnManager.getTableColumnOrderComparator());
for (int i = 0; i < tableColumns.length; i++) {
int position = tableColumns[i].getPosition();
if (position != -1 && tableColumns[i].isVisible()) {
// table.createNewColumn(SWT.NULL);
// System.out.println(i + "] " + tableColumns[i].getName() + ";" + position);
tmpColumnsOrdered[columnOrderPos++] = tableColumns[i];
}
}
// int numSWTColumns = table.getColumnCount();
// int iNewLength = numSWTColumns - (bSkipFirstColumn ? 1 : 0);
TableColumnCore[] columnsOrdered = new TableColumnCore[columnOrderPos];
System.arraycopy(tmpColumnsOrdered, 0, columnsOrdered, 0, columnOrderPos);
setColumnsOrdered(columnsOrdered);
cTable.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
swt_paintComposite(e);
}
});
menu = createMenu();
cTable.setMenu(menu);
cHeaderArea.setMenu(menu);
setupHeaderArea(cHeaderArea);
cTable.addControlListener(new ControlListener() {
boolean inControlResize = false;
@Override
public void controlResized(ControlEvent e) {
if (inControlResize) {
return;
}
try {
inControlResize = true;
swt_calculateClientArea();
swt_fixupSize();
} finally {
inControlResize = false;
}
}
@Override
public void controlMoved(ControlEvent e) {
}
});
hBar = cTable.getHorizontalBar();
if (hBar != null) {
hBar.setValues(0, 0, 0, 10, 10, 100);
hBar.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
// swt_calculateClientArea();
if (DIRECT_DRAW) {
swt_calculateClientArea();
redrawTable();
} else {
cTable.redraw();
}
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
}
});
}
vBar = cTable.getVerticalBar();
if (vBar != null) {
vBar.setValues(0, 0, 0, 50, getRowDefaultHeight(), 50);
vBar.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
swt_vBarChanged();
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
}
});
}
if (DEBUG_WITH_SHELL) {
Shell shell = new Shell();
sCanvasImage = new Canvas(shell, SWT.DOUBLE_BUFFERED);
shell.setLayout(new FillLayout());
sCanvasImage.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
if (canvasImage == null) {
return;
}
e.gc.drawImage(canvasImage, 0, 0);
// System.out.println(System.currentTimeMillis() + "] Paint " + e.x + "x" + e.y + " " + e.width + "x" + e.height);
}
});
shell.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
sCanvasImage = null;
}
});
shell.setVisible(true);
}
cTable.addMouseListener(tvSWTCommon);
cTable.addMouseMoveListener(tvSWTCommon);
cTable.addKeyListener(tvSWTCommon);
// composite.addSelectionListener(tvSWTCommon);
cTable.addTraverseListener(new TraverseListener() {
@Override
public void keyTraversed(TraverseEvent e) {
e.doit = true;
}
});
cTable.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
if (canvasImage != null) {
canvasImage.dispose();
canvasImage = null;
}
}
});
SelectedContentManager.addCurrentlySelectedContentListener(new SelectedContentListener() {
@Override
public void currentlySelectedContentChanged(ISelectedContent[] currentContent, String viewID) {
if (cTable == null || cTable.isDisposed()) {
SelectedContentManager.removeCurrentlySelectedContentListener(this);
} else {
redrawTable();
}
}
});
cTable.addFocusListener(new FocusListener() {
@Override
public void focusLost(FocusEvent e) {
isFocused = false;
redrawTable();
}
@Override
public void focusGained(FocusEvent e) {
isFocused = true;
redrawTable();
}
});
isFocused = cTable.isFocusControl();
new TableTooltips(this, cTable);
TableColumnManager tcManager = TableColumnManager.getInstance();
String sSortColumn = tcManager.getDefaultSortColumnName(tableID);
if (sSortColumn == null || sSortColumn.length() == 0) {
sSortColumn = sDefaultSortOn;
}
TableColumnCore tc = tcManager.getTableColumnCore(tableID, sSortColumn);
if (tc == null && tableColumns.length > 0) {
tc = tableColumns[0];
}
setSortColumn(tc, false);
triggerLifeCycleListener(TableLifeCycleListener.EVENT_TABLELIFECYCLE_INITIALIZED);
configMan.addParameterListener("Graphics Update", this);
configMan.addParameterListener("ReOrder Delay", this);
configMan.addParameterListener("Table.extendedErase", this);
configMan.addParameterListener("Table.headerHeight", this);
Colors.getInstance().addColorsChangedListener(this);
// So all TableView objects of the same TableID have the same columns,
// and column widths, etc
TableStructureEventDispatcher.getInstance(tableID).addListener(this);
MessageText.addListener(this);
}
Aggregations