use of com.biglybt.core.disk.DiskManagerFileInfo in project BiglyBT by BiglySoftware.
the class TaggingView method dataSourceChanged.
private void dataSourceChanged(Object ds) {
boolean wasNull = taggables == null;
if (ds instanceof Taggable) {
taggables = new ArrayList<>();
taggables.add((Taggable) ds);
} else if (ds instanceof Taggable[]) {
taggables = new ArrayList<>();
taggables.addAll(Arrays.asList((Taggable[]) ds));
} else if (ds instanceof Object[]) {
taggables = new ArrayList<>();
Object[] objects = (Object[]) ds;
for (Object o : objects) {
if (o instanceof Taggable) {
Taggable taggable = (Taggable) o;
if (!taggables.contains(taggable)) {
taggables.add(taggable);
}
} else if (o instanceof DiskManagerFileInfo) {
DownloadManager temp = ((DiskManagerFileInfo) o).getDownloadManager();
if (temp != null) {
if (!taggables.contains(temp)) {
taggables.add(temp);
}
}
}
}
if (taggables.size() == 0) {
taggables = null;
}
} else {
taggables = null;
}
boolean isNull = taggables == null;
if (isNull != wasNull) {
TagManager tm = TagManagerFactory.getTagManager();
TagType tagType;
/*
tagType = tm.getTagType(TagType.TT_DOWNLOAD_CATEGORY);
if (isNull) {
tagType.removeTagTypeListener(this);
} else {
tagType.addTagTypeListener(this, false);
}
*/
tagType = tm.getTagType(TagType.TT_DOWNLOAD_MANUAL);
if (isNull) {
tagType.removeTagTypeListener(this);
} else {
tagType.addTagTypeListener(this, false);
}
}
Utils.execSWTThread(new AERunnable() {
@Override
public void runSupport() {
swt_updateFields();
}
});
}
use of com.biglybt.core.disk.DiskManagerFileInfo in project BiglyBT by BiglySoftware.
the class MyTorrentsView method updateSelectedContent.
public void updateSelectedContent(boolean force) {
if (cTablePanel == null || cTablePanel.isDisposed()) {
return;
}
if (!isTableFocus()) {
if (!force) {
return;
}
}
Object[] dataSources = tv.getSelectedDataSources(true);
List<SelectedContent> listSelected = new ArrayList<>(dataSources.length);
for (Object ds : dataSources) {
if (ds instanceof DownloadManager) {
listSelected.add(new SelectedContent((DownloadManager) ds));
} else if (ds instanceof DiskManagerFileInfo) {
DiskManagerFileInfo fileInfo = (DiskManagerFileInfo) ds;
listSelected.add(new SelectedContent(fileInfo.getDownloadManager(), fileInfo.getIndex()));
}
}
SelectedContent[] content = listSelected.toArray(new SelectedContent[0]);
SelectedContentManager.changeCurrentlySelectedContent(tv.getTableID(), content, tv);
}
use of com.biglybt.core.disk.DiskManagerFileInfo in project BiglyBT by BiglySoftware.
the class FilesView method updateSelectedContent.
public void updateSelectedContent() {
long total_size = 0;
long total_dnd = 0;
long total_done = 0;
Object[] dataSources = tv.getSelectedDataSources(true);
List<SelectedContent> listSelected = new ArrayList<>(dataSources.length);
for (Object ds : dataSources) {
if (ds instanceof DiskManagerFileInfo) {
DiskManagerFileInfo fileInfo = (DiskManagerFileInfo) ds;
listSelected.add(new SelectedContent(fileInfo.getDownloadManager(), fileInfo.getIndex()));
if (fileInfo.isSkipped()) {
total_dnd += fileInfo.getLength();
} else {
total_size += fileInfo.getLength();
total_done += fileInfo.getDownloaded();
}
}
}
selection_size = total_size;
selection_size_with_dnd = total_dnd + total_size;
selection_done = total_done;
updateHeader();
SelectedContent[] sc = listSelected.toArray(new SelectedContent[0]);
SelectedContentManager.changeCurrentlySelectedContent(tv.getTableID(), sc, tv);
}
use of com.biglybt.core.disk.DiskManagerFileInfo in project BiglyBT by BiglySoftware.
the class FilesView method updateFlatView.
private void updateFlatView() {
DiskManagerFileInfo[] files = getFileInfo();
if (files != null && (this.force_refresh || !doAllExist(files))) {
this.force_refresh = false;
List<DiskManagerFileInfo> datasources = tv.getDataSources();
if (datasources.size() == files.length) {
// check if we actually have to replace anything
ArrayList<DiskManagerFileInfo> toAdd = new ArrayList<>(Arrays.asList(files));
ArrayList<DiskManagerFileInfo> toRemove = new ArrayList<>();
for (DiskManagerFileInfo info : datasources) {
if (info.getIndex() != -1 && files[info.getIndex()] == info)
toAdd.set(info.getIndex(), null);
else
toRemove.add(info);
}
tv.removeDataSources(toRemove.toArray(new DiskManagerFileInfo[toRemove.size()]));
tv.addDataSources(toAdd.toArray(new DiskManagerFileInfo[toAdd.size()]));
tv.tableInvalidate();
} else {
tv.removeAllTableRows();
DiskManagerFileInfo[] filesCopy = new DiskManagerFileInfo[files.length];
System.arraycopy(files, 0, filesCopy, 0, files.length);
tv.addDataSources(filesCopy);
}
tv.processDataSourceQueue();
}
}
use of com.biglybt.core.disk.DiskManagerFileInfo in project BiglyBT by BiglySoftware.
the class FilesView method defaultSelected.
// @see TableSelectionListener#defaultSelected(TableRowCore[])
@Override
public void defaultSelected(TableRowCore[] rows, int stateMask, int origin) {
DiskManagerFileInfo fileInfo = (DiskManagerFileInfo) tv.getFirstSelectedDataSource();
if (fileInfo == null) {
return;
}
boolean webInBrowser = COConfigurationManager.getBooleanParameter("Library.LaunchWebsiteInBrowser");
if (webInBrowser) {
if (ManagerUtils.browseWebsite(fileInfo)) {
return;
}
}
String mode = COConfigurationManager.getStringParameter("list.dm.dblclick");
if (origin == 1) {
String enter_mode = COConfigurationManager.getStringParameter("list.dm.enteraction");
if (!enter_mode.equals("-1")) {
mode = enter_mode;
}
}
switch(mode) {
case "1":
{
DownloadManager dm = fileInfo.getDownloadManager();
if (dm != null) {
UIFunctionsManager.getUIFunctions().getMDI().showEntryByID(MultipleDocumentInterface.SIDEBAR_SECTION_TORRENT_DETAILS, dm);
}
break;
}
case "2":
boolean openMode = COConfigurationManager.getBooleanParameter("MyTorrentsView.menu.show_parent_folder_enabled");
ManagerUtils.open(fileInfo, openMode);
break;
case "3":
case "4":
if (fileInfo.getAccessMode() == DiskManagerFileInfo.READ) {
if (mode.equals("4") && fileInfo.getDownloaded() == fileInfo.getLength() && Utils.isQuickViewSupported(fileInfo)) {
Utils.setQuickViewActive(fileInfo, true);
} else {
Utils.launch(fileInfo);
}
}
break;
case "5":
ManagerUtils.browse(fileInfo);
break;
default:
int file_index = fileInfo.getIndex();
DownloadManager dm = fileInfo.getDownloadManager();
boolean canPlay = PlayUtils.canPlayDS(dm, file_index, true) || PlayUtils.canStreamDS(dm, file_index, true);
UIFunctions uif = UIFunctionsManager.getUIFunctions();
if (uif != null) {
uif.playOrStreamDataSource(fileInfo, DLReferals.DL_REFERAL_PLAYDM, false, false);
return;
}
if (fileInfo.getAccessMode() == DiskManagerFileInfo.READ) {
Utils.launch(fileInfo);
}
break;
}
}
Aggregations