use of com.biglybt.ui.common.table.TableSelectionAdapter in project BiglyBT by BiglySoftware.
the class SBC_LibraryTableView method initShow.
public void initShow(Core core) {
Object data = soParent.getControl().getData("TorrentFilterMode");
if (data instanceof Long) {
torrentFilterMode = (int) ((Long) data).longValue();
}
data = soParent.getControl().getData("DataSource");
boolean useBigTable = useBigTable();
SWTSkinObjectTextbox soFilter = (SWTSkinObjectTextbox) skin.getSkinObject("library-filter", soParent.getParent());
Text txtFilter = soFilter == null ? null : soFilter.getTextControl();
SWTSkinObjectContainer soCats = (SWTSkinObjectContainer) skin.getSkinObject("library-categories", soParent.getParent());
Composite cCats = soCats == null ? null : soCats.getComposite();
// columns not needed for small mode, all torrents
TableColumnCore[] columns = useBigTable || torrentFilterMode != SBC_LibraryView.TORRENTS_ALL ? getColumns() : null;
if (null != columns) {
TableColumnManager tcManager = TableColumnManager.getInstance();
tcManager.addColumns(columns);
}
if (useBigTable) {
if (torrentFilterMode == SBC_LibraryView.TORRENTS_COMPLETE || torrentFilterMode == SBC_LibraryView.TORRENTS_INCOMPLETE || torrentFilterMode == SBC_LibraryView.TORRENTS_UNOPENED) {
swtViewListener = torrentView = new MyTorrentsView_Big(core, torrentFilterMode, columns, txtFilter, cCats);
} else {
swtViewListener = torrentView = new MyTorrentsView_Big(core, torrentFilterMode, columns, txtFilter, cCats);
}
} else {
String tableID = SB_Transfers.getTableIdFromFilterMode(torrentFilterMode, false);
if (torrentFilterMode == SBC_LibraryView.TORRENTS_COMPLETE) {
swtViewListener = torrentView = new MyTorrentsView(core, tableID, true, columns, txtFilter, cCats, true);
} else if (torrentFilterMode == SBC_LibraryView.TORRENTS_INCOMPLETE) {
swtViewListener = torrentView = new MyTorrentsView(core, tableID, false, columns, txtFilter, cCats, true);
} else if (torrentFilterMode == SBC_LibraryView.TORRENTS_UNOPENED) {
swtViewListener = torrentView = new MyTorrentsView(core, tableID, true, columns, txtFilter, cCats, true) {
@Override
public boolean isOurDownloadManager(DownloadManager dm) {
if (PlatformTorrentUtils.getHasBeenOpened(dm)) {
return false;
}
return super.isOurDownloadManager(dm);
}
};
} else {
swtViewListener = new MyTorrentsSuperView(txtFilter, cCats) {
@Override
public void initializeDone() {
MyTorrentsView seedingview = getSeedingview();
if (seedingview != null) {
seedingview.overrideDefaultSelected(new TableSelectionAdapter() {
@Override
public void defaultSelected(TableRowCore[] rows, int stateMask, int origin) {
doDefaultClick(rows, stateMask, false, origin);
}
});
MyTorrentsView torrentview = getTorrentview();
if (torrentview != null) {
torrentview.overrideDefaultSelected(new TableSelectionAdapter() {
@Override
public void defaultSelected(TableRowCore[] rows, int stateMask, int origin) {
doDefaultClick(rows, stateMask, false, origin);
}
});
}
}
}
};
}
if (torrentView != null) {
torrentView.overrideDefaultSelected(new TableSelectionAdapter() {
@Override
public void defaultSelected(TableRowCore[] rows, int stateMask, int origin) {
doDefaultClick(rows, stateMask, false, origin);
}
});
}
}
if (torrentView != null) {
tv = torrentView.getTableView();
if (torrentFilterMode == SBC_LibraryView.TORRENTS_UNOPENED) {
torrentView.setRebuildListOnFocusGain(true);
}
}
try {
view = new UISWTViewImpl(ID + torrentFilterMode, UISWTInstance.VIEW_MAIN, false);
view.setDatasource(data);
view.setEventListener(swtViewListener, true);
} catch (Exception e) {
Debug.out(e);
}
SWTSkinObjectContainer soContents = new SWTSkinObjectContainer(skin, skin.getSkinProperties(), getUpdateUIName(), "", soMain);
skin.layout();
viewComposite = soContents.getComposite();
viewComposite.setLayoutData(Utils.getFilledFormData());
GridLayout gridLayout = new GridLayout();
gridLayout.horizontalSpacing = gridLayout.verticalSpacing = gridLayout.marginHeight = gridLayout.marginWidth = 0;
viewComposite.setLayout(gridLayout);
view.initialize(viewComposite);
SWTSkinObject soSizeSlider = skin.getSkinObject("table-size-slider", soParent.getParent());
if (soSizeSlider instanceof SWTSkinObjectContainer) {
SWTSkinObjectContainer so = (SWTSkinObjectContainer) soSizeSlider;
if (tv != null && !tv.enableSizeSlider(so.getComposite(), 16, 100)) {
so.setVisible(false);
}
}
if (torrentFilterMode == SBC_LibraryView.TORRENTS_ALL && tv != null) {
tv.addRefreshListener(new TableRowRefreshListener() {
@Override
public void rowRefresh(TableRow row) {
TableRowSWT rowCore = (TableRowSWT) row;
Object ds = rowCore.getDataSource(true);
if (!(ds instanceof DownloadManager)) {
return;
}
DownloadManager dm = (DownloadManager) ds;
boolean changed = false;
boolean assumedComplete = dm.getAssumedComplete();
if (!assumedComplete) {
changed |= rowCore.setAlpha(160);
} else if (!PlatformTorrentUtils.getHasBeenOpened(dm)) {
changed |= rowCore.setAlpha(255);
} else {
changed |= rowCore.setAlpha(255);
}
}
});
}
viewComposite.getParent().layout(true);
}
Aggregations