use of com.biglybt.ui.swt.pifimpl.UISWTViewBuilderCore in project BiglyBT by BiglySoftware.
the class BaseMDI method canShowEntryByID.
public boolean canShowEntryByID(String id) {
if (id == null) {
return (false);
}
if (canCreateEntryByCreationListener(id)) {
return (true);
}
ViewManagerSWT vi = ViewManagerSWT.getInstance();
UISWTViewBuilderCore builder = vi.getBuilder(viewID, id);
if (builder == null) {
builder = vi.getBuilder(getDataSourceType(), id);
}
return (builder != null);
}
use of com.biglybt.ui.swt.pifimpl.UISWTViewBuilderCore in project BiglyBT by BiglySoftware.
the class BaseMDI method loadAndGetEntryByID.
private MdiEntry loadAndGetEntryByID(String id, boolean activate, boolean onlyLoadOnce, Object datasource) {
if (id == null) {
return (null);
}
@SuppressWarnings("deprecation") boolean loadedOnce = wasEntryLoadedOnce(id);
if (loadedOnce && onlyLoadOnce) {
return (null);
}
MdiEntry entry = getEntry(id);
if (entry != null) {
if (datasource != null) {
entry.setDatasource(datasource);
}
if (activate) {
showEntry(entry);
}
return (entry);
}
Map autoOpenInfo = new HashMap();
// DataSourceResolves is tooled for Dashboard.. can't use it yet
// Object value = DataSourceResolver.exportDataSource(datasource);
// if (value == null) {
// value = datasource;
// }
// datasource may not be writable to config, but assuming a MdiEntry is
// created, the autoopen map will be updated with a writable ds.
autoOpenInfo.put(AUTOOPENINFO_DS, datasource);
MdiEntry mdiEntry = createEntryByCreationListener(id, autoOpenInfo);
if (mdiEntry == null) {
ViewManagerSWT vi = ViewManagerSWT.getInstance();
UISWTViewBuilderCore builder = vi.getBuilder(viewID, id);
if (builder == null) {
builder = vi.getBuilder(getDataSourceType(), id);
}
if (builder != null) {
mdiEntry = createEntry(builder, true);
}
}
if (mdiEntry != null) {
if (onlyLoadOnce) {
setEntryLoadedOnce(id);
}
if (activate) {
showEntry(mdiEntry);
}
return (mdiEntry);
}
return (null);
}
use of com.biglybt.ui.swt.pifimpl.UISWTViewBuilderCore in project BiglyBT by BiglySoftware.
the class BaseMDI method processAutoOpenMap.
private boolean processAutoOpenMap(String id, Map<?, ?> autoOpenInfo, UISWTViewBuilderCore builder) {
try {
MdiEntry entry = getEntry(id);
if (entry != null) {
return true;
}
String title = MapUtils.getMapString(autoOpenInfo, "title", id);
MdiEntry mdiEntry = createEntryByCreationListener(id, autoOpenInfo);
if (mdiEntry != null) {
if (mdiEntry.getTitle().equals("") && !title.isEmpty()) {
mdiEntry.setTitle(title);
}
return true;
}
Object datasource = autoOpenInfo.get(AUTOOPENINFO_DS);
if (builder != null) {
entry = createEntry(builder, true);
if (entry != null) {
if (entry.getTitle().equals("") && !title.isEmpty()) {
entry.setTitle(title);
}
// Auto-Open stores last datasource used before close.
// Override builder's initialDataSource with stored one.
entry.setDatasource(datasource);
}
}
if (entry != null && datasource == null) {
final MdiEntry fEntry = entry;
final String dmHash = MapUtils.getMapString(autoOpenInfo, "dm", null);
if (dmHash != null) {
CoreFactory.addCoreRunningListener(new CoreRunningListener() {
@Override
public void coreRunning(Core core) {
GlobalManager gm = core.getGlobalManager();
HashWrapper hw = new HashWrapper(Base32.decode(dmHash));
DownloadManager dm = gm.getDownloadManager(hw);
if (dm != null) {
fEntry.setDatasource(dm);
}
}
});
} else {
final List<?> listHashes = MapUtils.getMapList(autoOpenInfo, "dms", null);
if (listHashes != null) {
CoreFactory.addCoreRunningListener(new CoreRunningListener() {
@Override
public void coreRunning(Core core) {
List<DownloadManager> listDMS = new ArrayList<>(1);
GlobalManager gm = core.getGlobalManager();
for (Object oDM : listHashes) {
if (oDM instanceof String) {
String hash = (String) oDM;
DownloadManager dm = gm.getDownloadManager(new HashWrapper(Base32.decode(hash)));
if (dm != null) {
listDMS.add(dm);
}
}
fEntry.setDatasource(listDMS.toArray(new DownloadManager[0]));
}
}
});
}
}
}
return entry != null;
} catch (Throwable e) {
Debug.out(e);
}
return false;
}
Aggregations