use of com.biglybt.ui.common.table.impl.TableColumnManager in project BiglyBT by BiglySoftware.
the class TableColumnCreatorV3 method createCompleteDM.
public static TableColumnCore[] createCompleteDM(String tableID, boolean big) {
final String[] oldVisibleOrder = { ColumnUnopened.COLUMN_ID, ColumnThumbAndName.COLUMN_ID, "RatingColumn", "azsubs.ui.column.subs", "azbuddy.ui.column.msgpending", SizeItem.COLUMN_ID, StatusItem.COLUMN_ID, ShareRatioItem.COLUMN_ID, DateCompletedItem.COLUMN_ID };
final String[] defaultVisibleOrder = { RankItem.COLUMN_ID, ColumnThumbAndName.COLUMN_ID, ColumnStream.COLUMN_ID, StatusItem.COLUMN_ID, SizeItem.COLUMN_ID, ColumnTorrentSpeed.COLUMN_ID, "RatingColumn", "azsubs.ui.column.subs", "azbuddy.ui.column.msgpending", DateCompletedItem.COLUMN_ID };
TableColumnManager tcManager = TableColumnManager.getInstance();
Map<String, TableColumnCore> mapTCs = tcManager.getTableColumnsAsMap(DownloadTypeComplete.class, tableID);
tcManager.setDefaultColumnNames(tableID, defaultVisibleOrder);
if (!tcManager.loadTableColumnSettings(DownloadTypeComplete.class, tableID) || areNoneVisible(mapTCs)) {
setVisibility(mapTCs, defaultVisibleOrder, true);
DateCompletedItem tc = (DateCompletedItem) mapTCs.get(DateCompletedItem.COLUMN_ID);
if (tc != null) {
tcManager.setDefaultSortColumnName(tableID, DateCompletedItem.COLUMN_ID);
tc.setSortAscending(false);
}
} else {
upgradeColumns(oldVisibleOrder, defaultVisibleOrder, mapTCs);
}
// special changes
StatusItem tcStatusItem = (StatusItem) mapTCs.get(StatusItem.COLUMN_ID);
if (tcStatusItem != null) {
tcStatusItem.setChangeRowFG(false);
if (big) {
tcStatusItem.setChangeCellFG(false);
}
}
if (big) {
ShareRatioItem tcShareRatioItem = (ShareRatioItem) mapTCs.get(ShareRatioItem.COLUMN_ID);
if (tcShareRatioItem != null) {
tcShareRatioItem.setChangeFG(false);
tcShareRatioItem.setWidth(80);
}
}
return mapTCs.values().toArray(new TableColumnCore[0]);
}
use of com.biglybt.ui.common.table.impl.TableColumnManager in project BiglyBT by BiglySoftware.
the class TableColumnCreatorV3 method createUnopenedDM.
public static TableColumnCore[] createUnopenedDM(String tableID, boolean big) {
final String[] oldVisibleOrder = { ColumnUnopened.COLUMN_ID, ColumnThumbAndName.COLUMN_ID, "azsubs.ui.column.subs", "azbuddy.ui.column.msgpending", SizeItem.COLUMN_ID, ColumnProgressETA.COLUMN_ID, StatusItem.COLUMN_ID, DateCompletedItem.COLUMN_ID };
final String[] defaultVisibleOrder = { ColumnUnopened.COLUMN_ID, ColumnThumbAndName.COLUMN_ID, ColumnStream.COLUMN_ID, SizeItem.COLUMN_ID, "RatingColumn", "azsubs.ui.column.subs", "azbuddy.ui.column.msgpending", DateCompletedItem.COLUMN_ID };
TableColumnManager tcManager = TableColumnManager.getInstance();
Map<String, TableColumnCore> mapTCs = tcManager.getTableColumnsAsMap(DownloadTypeComplete.class, tableID);
tcManager.setDefaultColumnNames(tableID, defaultVisibleOrder);
if (!tcManager.loadTableColumnSettings(DownloadTypeComplete.class, tableID) || areNoneVisible(mapTCs)) {
setVisibility(mapTCs, defaultVisibleOrder, true);
DateCompletedItem tc = (DateCompletedItem) mapTCs.get(DateCompletedItem.COLUMN_ID);
if (tc != null) {
tcManager.setDefaultSortColumnName(tableID, DateCompletedItem.COLUMN_ID);
tc.setSortAscending(false);
}
} else {
upgradeColumns(oldVisibleOrder, defaultVisibleOrder, mapTCs);
}
// special changes
StatusItem tcStatusItem = (StatusItem) mapTCs.get(StatusItem.COLUMN_ID);
if (tcStatusItem != null) {
tcStatusItem.setChangeRowFG(false);
if (big) {
tcStatusItem.setChangeCellFG(false);
}
}
if (big) {
ShareRatioItem tcShareRatioItem = (ShareRatioItem) mapTCs.get(ShareRatioItem.COLUMN_ID);
if (tcShareRatioItem != null) {
tcShareRatioItem.setChangeFG(false);
tcShareRatioItem.setWidth(80);
}
}
return mapTCs.values().toArray(new TableColumnCore[0]);
}
use of com.biglybt.ui.common.table.impl.TableColumnManager in project BiglyBT by BiglySoftware.
the class SBC_SearchResultsView method initTable.
private void initTable(Composite control) {
tv_subs_results = TableViewFactory.createTableViewSWT(SBC_SearchResult.class, TABLE_SR, TABLE_SR, new TableColumnCore[0], ColumnSearchSubResultName.COLUMN_ID, SWT.MULTI | SWT.FULL_SELECTION | SWT.VIRTUAL);
TableColumnManager tableManager = TableColumnManager.getInstance();
tableManager.setDefaultColumnNames(TABLE_SR, new String[] { ColumnSearchSubResultType.COLUMN_ID, ColumnSearchSubResultName.COLUMN_ID, ColumnSearchSubResultActions.COLUMN_ID, ColumnSearchSubResultSize.COLUMN_ID, ColumnSearchSubResultSeedsPeers.COLUMN_ID, ColumnSearchSubResultRatings.COLUMN_ID, ColumnSearchSubResultAge.COLUMN_ID, ColumnSearchSubResultRank.COLUMN_ID, ColumnSearchSubResultCategory.COLUMN_ID, ColumnSearchResultSite.COLUMN_ID });
tableManager.setDefaultSortColumnName(TABLE_SR, ColumnSearchSubResultRank.COLUMN_ID);
if (txtFilter != null) {
tv_subs_results.enableFilterCheck(txtFilter, this);
}
tv_subs_results.setRowDefaultHeight(COConfigurationManager.getIntParameter("Search Subs Row Height"));
SWTSkinObject soSizeSlider = getSkinObject("table-size-slider");
if (soSizeSlider instanceof SWTSkinObjectContainer) {
SWTSkinObjectContainer so = (SWTSkinObjectContainer) soSizeSlider;
if (!tv_subs_results.enableSizeSlider(so.getComposite(), 16, 100)) {
so.setVisible(false);
}
}
table_parent = new Composite(control, SWT.NONE);
table_parent.setLayoutData(Utils.getFilledFormData());
GridLayout layout = new GridLayout();
layout.marginHeight = layout.marginWidth = layout.verticalSpacing = layout.horizontalSpacing = 0;
table_parent.setLayout(layout);
tv_subs_results.addSelectionListener(new TableSelectionListener() {
@Override
public void selected(TableRowCore[] _rows) {
updateSelectedContent();
}
@Override
public void mouseExit(TableRowCore row) {
}
@Override
public void mouseEnter(TableRowCore row) {
}
@Override
public void focusChanged(TableRowCore focus) {
UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions();
if (uiFunctions != null) {
uiFunctions.refreshIconBar();
}
}
@Override
public void deselected(TableRowCore[] rows) {
updateSelectedContent();
}
@Override
public void defaultSelected(TableRowCore[] rows, int stateMask) {
if (rows.length == 1) {
SBC_SearchResult rc = (SBC_SearchResult) rows[0].getDataSource();
downloadAction(rc);
}
}
private void updateSelectedContent() {
TableRowCore[] rows = tv_subs_results.getSelectedRows();
ArrayList<ISelectedContent> valid = new ArrayList<>();
last_selected_content.clear();
for (int i = 0; i < rows.length; i++) {
SBC_SearchResult rc = (SBC_SearchResult) rows[i].getDataSource();
last_selected_content.add(rc);
byte[] hash = rc.getHash();
if (hash != null && hash.length > 0) {
SelectedContent sc = new SelectedContent(Base32.encode(hash), rc.getName());
sc.setDownloadInfo(new DownloadUrlInfo(getDownloadURI(rc)));
valid.add(sc);
}
}
ISelectedContent[] sels = valid.toArray(new ISelectedContent[valid.size()]);
SelectedContentManager.changeCurrentlySelectedContent("IconBarEnabler", sels, tv_subs_results);
UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions();
if (uiFunctions != null) {
uiFunctions.refreshIconBar();
}
}
}, false);
tv_subs_results.addMenuFillListener(new TableViewSWTMenuFillListener() {
@Override
public void fillMenu(String sColumnName, Menu menu) {
Object[] _related_content = tv_subs_results.getSelectedDataSources().toArray();
final SBC_SearchResult[] results = new SBC_SearchResult[_related_content.length];
System.arraycopy(_related_content, 0, results, 0, results.length);
MenuItem item = new MenuItem(menu, SWT.PUSH);
item.setText(MessageText.getString("label.copy.url.to.clip"));
item.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
StringBuffer buffer = new StringBuffer(1024);
for (SBC_SearchResult result : results) {
if (buffer.length() > 0) {
buffer.append("\r\n");
}
buffer.append(getDownloadURI(result));
}
ClipboardCopy.copyToClipBoard(buffer.toString());
}
});
item.setEnabled(results.length > 0);
SearchSubsUtils.addMenu(results, menu);
new MenuItem(menu, SWT.SEPARATOR);
if (results.length == 1) {
if (SearchSubsUtils.addMenu(results[0], menu)) {
new MenuItem(menu, SWT.SEPARATOR);
}
}
}
@Override
public void addThisColumnSubMenu(String columnName, Menu menuThisColumn) {
}
});
tv_subs_results.initialize(table_parent);
control.layout(true);
}
use of com.biglybt.ui.common.table.impl.TableColumnManager in project BiglyBT by BiglySoftware.
the class SBC_SearchResultsView method initColumns.
private void initColumns(Core core) {
synchronized (SBC_SearchResultsView.class) {
if (columnsAdded) {
return;
}
columnsAdded = true;
}
TableColumnManager tableManager = TableColumnManager.getInstance();
tableManager.registerColumn(SBC_SearchResult.class, ColumnSearchSubResultType.COLUMN_ID, new TableColumnCreationListener() {
@Override
public void tableColumnCreated(TableColumn column) {
new ColumnSearchSubResultType(column);
}
});
tableManager.registerColumn(SBC_SearchResult.class, ColumnSearchSubResultName.COLUMN_ID, new TableColumnCreationListener() {
@Override
public void tableColumnCreated(TableColumn column) {
new ColumnSearchSubResultName(column);
}
});
tableManager.registerColumn(SBC_SearchResult.class, ColumnSearchSubResultActions.COLUMN_ID, new TableColumnCreationListener() {
@Override
public void tableColumnCreated(TableColumn column) {
new ColumnSearchSubResultActions(column);
}
});
tableManager.registerColumn(SBC_SearchResult.class, ColumnSearchSubResultSize.COLUMN_ID, new TableColumnCreationListener() {
@Override
public void tableColumnCreated(TableColumn column) {
new ColumnSearchSubResultSize(column);
}
});
tableManager.registerColumn(SBC_SearchResult.class, ColumnSearchSubResultSeedsPeers.COLUMN_ID, new TableColumnCreationListener() {
@Override
public void tableColumnCreated(TableColumn column) {
new ColumnSearchSubResultSeedsPeers(column);
}
});
tableManager.registerColumn(SBC_SearchResult.class, ColumnSearchSubResultRatings.COLUMN_ID, new TableColumnCreationListener() {
@Override
public void tableColumnCreated(TableColumn column) {
new ColumnSearchSubResultRatings(column);
}
});
tableManager.registerColumn(SBC_SearchResult.class, ColumnSearchSubResultAge.COLUMN_ID, new TableColumnCreationListener() {
@Override
public void tableColumnCreated(TableColumn column) {
new ColumnSearchSubResultAge(column);
}
});
tableManager.registerColumn(SBC_SearchResult.class, ColumnSearchSubResultRank.COLUMN_ID, new TableColumnCreationListener() {
@Override
public void tableColumnCreated(TableColumn column) {
new ColumnSearchSubResultRank(column);
}
});
tableManager.registerColumn(SBC_SearchResult.class, ColumnSearchSubResultCategory.COLUMN_ID, new TableColumnCreationListener() {
@Override
public void tableColumnCreated(TableColumn column) {
new ColumnSearchSubResultCategory(column);
}
});
tableManager.registerColumn(SBC_SearchResult.class, ColumnSearchResultSite.COLUMN_ID, new TableColumnCreationListener() {
@Override
public void tableColumnCreated(TableColumn column) {
new ColumnSearchResultSite(column);
}
});
tableManager.registerColumn(SBC_SearchResult.class, ColumnSearchSubResultHash.COLUMN_ID, new TableColumnCreationListener() {
@Override
public void tableColumnCreated(TableColumn column) {
new ColumnSearchSubResultHash(column);
}
});
tableManager.registerColumn(SBC_SearchResult.class, ColumnSearchSubResultExisting.COLUMN_ID, new TableColumnCreationListener() {
@Override
public void tableColumnCreated(TableColumn column) {
new ColumnSearchSubResultExisting(column);
}
});
}
use of com.biglybt.ui.common.table.impl.TableColumnManager 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