use of com.biglybt.ui.selectedcontent.SelectedContent in project BiglyBT by BiglySoftware.
the class SBC_DevicesView method updateSelectedContent.
public void updateSelectedContent() {
TableView tv = tvFiles != null ? tvFiles : tvDevices;
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()));
}
}
SelectedContent[] sc = listSelected.toArray(new SelectedContent[0]);
SelectedContentManager.changeCurrentlySelectedContent(tv.getTableID(), null, tv);
}
use of com.biglybt.ui.selectedcontent.SelectedContent in project BiglyBT by BiglySoftware.
the class TorrentUtil method toDMS.
private static DownloadManager[] toDMS(Object[] objects) {
int count = 0;
DownloadManager[] result = new DownloadManager[objects.length];
for (Object object : objects) {
if (object instanceof DownloadManager) {
DownloadManager dm = (DownloadManager) object;
result[count++] = dm;
} else if (object instanceof SelectedContent) {
SelectedContent sc = (SelectedContent) object;
if (sc.getFileIndex() == -1 && sc.getDownloadManager() != null) {
result[count++] = sc.getDownloadManager();
}
}
}
DownloadManager[] resultTrim = new DownloadManager[count];
System.arraycopy(result, 0, resultTrim, 0, count);
return resultTrim;
}
use of com.biglybt.ui.selectedcontent.SelectedContent in project BiglyBT by BiglySoftware.
the class TorrentUtil method toDMFI.
private static DiskManagerFileInfo[] toDMFI(Object[] objects) {
int count = 0;
DiskManagerFileInfo[] result = new DiskManagerFileInfo[objects.length];
for (Object object : objects) {
if (object instanceof DiskManagerFileInfo) {
DiskManagerFileInfo fileInfo = (DiskManagerFileInfo) object;
result[count++] = fileInfo;
} else if (object instanceof SelectedContent) {
SelectedContent sc = (SelectedContent) object;
int fileIndex = sc.getFileIndex();
if (fileIndex >= 0 && sc.getDownloadManager() != null) {
DownloadManager dm = sc.getDownloadManager();
if (dm != null) {
DiskManagerFileInfo[] infos = dm.getDiskManagerFileInfo();
if (fileIndex < infos.length) {
result[count++] = infos[fileIndex];
}
}
}
}
}
DiskManagerFileInfo[] resultTrim = new DiskManagerFileInfo[count];
System.arraycopy(result, 0, resultTrim, 0, count);
return resultTrim;
}
use of com.biglybt.ui.selectedcontent.SelectedContent in project BiglyBT by BiglySoftware.
the class GeneralView method eventOccurred.
@Override
public boolean eventOccurred(UISWTViewEvent event) {
switch(event.getType()) {
case UISWTViewEvent.TYPE_CREATE:
swtView = event.getView();
swtView.setTitle(getFullTitle());
swtView.setToolBarListener(this);
break;
case UISWTViewEvent.TYPE_DESTROY:
delete();
break;
case UISWTViewEvent.TYPE_INITIALIZE:
initialize((Composite) event.getData());
break;
case UISWTViewEvent.TYPE_LANGUAGEUPDATE:
Messages.updateLanguageForControl(getComposite());
swtView.setTitle(getFullTitle());
break;
case UISWTViewEvent.TYPE_DATASOURCE_CHANGED:
dataSourceChanged(event.getData());
break;
case UISWTViewEvent.TYPE_FOCUSGAINED:
String id = "DMDetails_General";
if (manager != null) {
if (manager.getTorrent() != null) {
id += "." + manager.getInternalName();
} else {
id += ":" + manager.getSize();
}
SelectedContentManager.changeCurrentlySelectedContent(id, new SelectedContent[] { new SelectedContent(manager) });
} else {
SelectedContentManager.changeCurrentlySelectedContent(id, null);
}
break;
case UISWTViewEvent.TYPE_FOCUSLOST:
SelectedContentManager.clearCurrentlySelectedContent();
break;
case UISWTViewEvent.TYPE_REFRESH:
refresh();
break;
case UISWTViewEvent.TYPE_OBFUSCATE:
Object data = event.getData();
if (data instanceof Map) {
obfuscatedImage((Image) MapUtils.getMapObject((Map) data, "image", null, Image.class));
}
break;
}
return true;
}
use of com.biglybt.ui.selectedcontent.SelectedContent in project BiglyBT by BiglySoftware.
the class PeersView method updateSelectedContent.
protected void updateSelectedContent() {
Object[] dataSources = tv.getSelectedDataSources(true);
if (dataSources.length == 0) {
String id = "DMDetails_Peers";
// do this here to pick up correct manager before rest of code
setFocused(true);
if (manager != null) {
if (manager.getTorrent() != null) {
id += "." + manager.getInternalName();
} else {
id += ":" + manager.getSize();
}
SelectedContentManager.changeCurrentlySelectedContent(id, new SelectedContent[] { new SelectedContent(manager) });
} else {
SelectedContentManager.changeCurrentlySelectedContent(id, null);
}
} else {
SelectedContent[] sc = new SelectedContent[dataSources.length];
for (int i = 0; i < sc.length; i++) {
sc[i] = new SelectedContent();
}
SelectedContentManager.changeCurrentlySelectedContent(tv.getTableID(), sc, tv);
}
}
Aggregations