Search in sources :

Example 31 with UISWTViewBuilderCore

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);
}
Also used : ViewManagerSWT(com.biglybt.ui.swt.views.ViewManagerSWT) UISWTViewBuilderCore(com.biglybt.ui.swt.pifimpl.UISWTViewBuilderCore)

Example 32 with UISWTViewBuilderCore

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);
}
Also used : ViewManagerSWT(com.biglybt.ui.swt.views.ViewManagerSWT) UISWTViewBuilderCore(com.biglybt.ui.swt.pifimpl.UISWTViewBuilderCore)

Example 33 with UISWTViewBuilderCore

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;
}
Also used : DownloadManager(com.biglybt.core.download.DownloadManager) GlobalManager(com.biglybt.core.global.GlobalManager) CoreRunningListener(com.biglybt.core.CoreRunningListener) SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) UISWTViewBuilderCore(com.biglybt.ui.swt.pifimpl.UISWTViewBuilderCore) Core(com.biglybt.core.Core)

Aggregations

UISWTViewBuilderCore (com.biglybt.ui.swt.pifimpl.UISWTViewBuilderCore)33 ViewManagerSWT (com.biglybt.ui.swt.views.ViewManagerSWT)9 MultipleDocumentInterfaceSWT (com.biglybt.ui.swt.mdi.MultipleDocumentInterfaceSWT)5 DownloadManager (com.biglybt.core.download.DownloadManager)4 MenuItem (com.biglybt.pif.ui.menus.MenuItem)4 PluginInterface (com.biglybt.pif.PluginInterface)3 ViewTitleInfo (com.biglybt.ui.common.viewtitleinfo.ViewTitleInfo)3 Point (org.eclipse.swt.graphics.Point)3 Core (com.biglybt.core.Core)2 CoreFactory (com.biglybt.core.CoreFactory)2 CoreRunningListener (com.biglybt.core.CoreRunningListener)2 COConfigurationManager (com.biglybt.core.config.COConfigurationManager)2 ParameterListener (com.biglybt.core.config.ParameterListener)2 UnassociatedDevice (com.biglybt.core.devices.DeviceManager.UnassociatedDevice)2 DiskManagerFileInfoFile (com.biglybt.core.download.DiskManagerFileInfoFile)2 DiskManagerFileInfoURL (com.biglybt.core.download.DiskManagerFileInfoURL)2 MessageText (com.biglybt.core.internat.MessageText)2 com.biglybt.core.util (com.biglybt.core.util)2 PluginManager (com.biglybt.pif.PluginManager)2 Download (com.biglybt.pif.download.Download)2