Search in sources :

Example 6 with MdiEntrySWT

use of com.biglybt.ui.swt.mdi.MdiEntrySWT in project BiglyBT by BiglySoftware.

the class DeviceInfoArea method skinObjectInitialShow.

// @see SkinView#skinObjectInitialShow(SWTSkinObject, java.lang.Object)
@Override
public Object skinObjectInitialShow(SWTSkinObject skinObject, Object params) {
    MultipleDocumentInterfaceSWT mdi = UIFunctionsManagerSWT.getUIFunctionsSWT().getMDISWT();
    if (mdi != null) {
        MdiEntrySWT entry = mdi.getEntryFromSkinObject(skinObject);
        if (entry != null) {
            device = (DeviceMediaRenderer) entry.getDatasource();
        }
    }
    parent = (Composite) skinObject.getControl();
    return null;
}
Also used : MultipleDocumentInterfaceSWT(com.biglybt.ui.swt.mdi.MultipleDocumentInterfaceSWT) MdiEntrySWT(com.biglybt.ui.swt.mdi.MdiEntrySWT)

Example 7 with MdiEntrySWT

use of com.biglybt.ui.swt.mdi.MdiEntrySWT in project BiglyBT by BiglySoftware.

the class TorrentUtil method calculateToolbarStates.

// XXX Don't think *View's need this call anymore.  ToolBarView does it fo them
public static Map<String, Long> calculateToolbarStates(ISelectedContent[] currentContent, String viewID_unused) {
    // System.out.println("calculateToolbarStates(" + currentContent.length + ", " + viewID_unused + " via " + Debug.getCompressedStackTrace());
    /*
		String[] TBKEYS = new String[] {
			"download",
			"play",
			"stream",
			"run",
			"top",
			"up",
			"down",
			"bottom",
			"start",
			"stop",
			"remove"
		};
		*/
    Map<String, Long> mapNewToolbarStates = new HashMap<>();
    String[] itemsNeedingSelection = {};
    String[] itemsNeedingRealDMSelection = { "remove", "top", "bottom", "transcode", "startstop" };
    String[] itemsRequiring1DMwithHash = { "details", "comment", "up", "down" };
    String[] itemsRequiring1DMSelection = {};
    int numSelection = currentContent.length;
    boolean hasSelection = numSelection > 0;
    boolean has1Selection = numSelection == 1;
    for (int i = 0; i < itemsNeedingSelection.length; i++) {
        String itemID = itemsNeedingSelection[i];
        mapNewToolbarStates.put(itemID, hasSelection ? UIToolBarItem.STATE_ENABLED : 0);
    }
    TableView tv = SelectedContentManager.getCurrentlySelectedTableView();
    // not sure why we assume that the existance of any table view
    boolean hasRealDM = tv != null;
    if (!hasRealDM && numSelection > 0) {
        hasRealDM = true;
        for (int i = 0; i < currentContent.length; i++) {
            ISelectedContent content = currentContent[i];
            DownloadManager dm = content.getDownloadManager();
            if (dm == null) {
                hasRealDM = false;
                break;
            }
        }
    }
    if (!hasRealDM) {
        MultipleDocumentInterfaceSWT mdi = UIFunctionsManagerSWT.getUIFunctionsSWT().getMDISWT();
        if (mdi != null) {
            MdiEntrySWT entry = mdi.getCurrentEntrySWT();
            if (entry != null) {
                if (entry.getDatasource() instanceof DownloadManager) {
                    hasRealDM = true;
                } else if ((entry instanceof UIPluginView) && (((UIPluginView) entry).getDataSource() instanceof DownloadManager)) {
                    hasRealDM = true;
                }
            }
        }
    }
    boolean canStart = false;
    boolean canStop = false;
    boolean canRemoveFileInfo = false;
    boolean canRunFileInfo = false;
    boolean canCheckExist = false;
    boolean hasDM = false;
    boolean canRecheck = false;
    if (currentContent.length > 0 && hasRealDM) {
        // well, in fact, we can have hasRealDM set to true here (because tv isn't null) and actually not have a real dm.
        // fancy that - protect against null DownloadManagers...
        boolean canMoveUp = false;
        boolean canMoveDown = false;
        boolean canDownload = false;
        canCheckExist = true;
        GlobalManager gm = null;
        for (int i = 0; i < currentContent.length; i++) {
            ISelectedContent content = currentContent[i];
            DownloadManager dm = content.getDownloadManager();
            if (dm == null) {
                if (!canDownload && content.getDownloadInfo() != null) {
                    canDownload = true;
                }
                continue;
            }
            if (gm == null) {
                gm = dm.getGlobalManager();
            }
            int state = dm.getState();
            canCheckExist &= (state == DownloadManager.STATE_ERROR || state == DownloadManager.STATE_STOPPED || state == DownloadManager.STATE_QUEUED);
            int fileIndex = content.getFileIndex();
            if (fileIndex == -1) {
                if (!canMoveUp && gm.isMoveableUp(dm)) {
                    canMoveUp = true;
                }
                if (!canMoveDown && gm.isMoveableDown(dm)) {
                    canMoveDown = true;
                }
                hasDM = true;
                if (!canStart && ManagerUtils.isStartable(dm)) {
                    canStart = true;
                }
                if (!canStop && ManagerUtils.isStopable(dm)) {
                    canStop = true;
                }
            } else {
                DiskManagerFileInfoSet fileInfos = dm.getDiskManagerFileInfoSet();
                if (fileIndex < fileInfos.nbFiles()) {
                    DiskManagerFileInfo fileInfo = fileInfos.getFiles()[fileIndex];
                    if (!canStart && (fileInfo.isSkipped())) {
                        canStart = true;
                    }
                    if (!canStop && !fileInfo.isSkipped()) {
                        canStop = true;
                    }
                    if (!canRemoveFileInfo && !fileInfo.isSkipped()) {
                        int storageType = fileInfo.getStorageType();
                        if (storageType == DiskManagerFileInfo.ST_LINEAR || storageType == DiskManagerFileInfo.ST_COMPACT) {
                            canRemoveFileInfo = true;
                        }
                    }
                    if (!canRunFileInfo && fileInfo.getAccessMode() == DiskManagerFileInfo.READ && fileInfo.getDownloaded() == fileInfo.getLength() && fileInfo.getFile(true).exists()) {
                        canRunFileInfo = true;
                    }
                }
            }
            canRecheck = canRecheck || dm.canForceRecheck();
        }
        boolean canRemove = hasDM || canRemoveFileInfo;
        mapNewToolbarStates.put("remove", canRemove ? UIToolBarItem.STATE_ENABLED : 0);
        mapNewToolbarStates.put("download", canDownload ? UIToolBarItem.STATE_ENABLED : 0);
        if (currentContent.length == 1) {
            mapNewToolbarStates.put("up", canMoveUp ? UIToolBarItem.STATE_ENABLED : 0);
            mapNewToolbarStates.put("down", canMoveDown ? UIToolBarItem.STATE_ENABLED : 0);
        }
    }
    boolean canRun = has1Selection && ((hasDM && !canRunFileInfo) || (!hasDM && canRunFileInfo));
    if (canRun) {
        ISelectedContent content = currentContent[0];
        DownloadManager dm = content.getDownloadManager();
        if (dm == null) {
            canRun = false;
        } else {
            TOTorrent torrent = dm.getTorrent();
            if (torrent == null) {
                canRun = false;
            } else if (!dm.getAssumedComplete() && torrent.isSimpleTorrent()) {
                canRun = false;
            /*
									} else if (PlatformTorrentUtils.useEMP(torrent)
											&& PlatformTorrentUtils.embeddedPlayerAvail()
											&& PlayUtils.canProgressiveOrIsComplete(torrent)) {
										// play button enabled and not UMP.. don't need launch

										canRun = false;

									}
									*/
            }
        }
    }
    mapNewToolbarStates.put("run", canRun ? UIToolBarItem.STATE_ENABLED : 0);
    mapNewToolbarStates.put("start", canStart ? UIToolBarItem.STATE_ENABLED : 0);
    mapNewToolbarStates.put("stop", canStop ? UIToolBarItem.STATE_ENABLED : 0);
    mapNewToolbarStates.put("startstop", canStart || canStop ? UIToolBarItem.STATE_ENABLED : 0);
    for (int i = 0; i < itemsNeedingRealDMSelection.length; i++) {
        String itemID = itemsNeedingRealDMSelection[i];
        if (!mapNewToolbarStates.containsKey(itemID)) {
            mapNewToolbarStates.put(itemID, hasSelection && hasDM && hasRealDM ? UIToolBarItem.STATE_ENABLED : 0);
        }
    }
    for (int i = 0; i < itemsRequiring1DMSelection.length; i++) {
        String itemID = itemsRequiring1DMSelection[i];
        if (!mapNewToolbarStates.containsKey(itemID)) {
            mapNewToolbarStates.put(itemID, has1Selection && hasDM ? UIToolBarItem.STATE_ENABLED : 0);
        }
    }
    for (int i = 0; i < itemsRequiring1DMwithHash.length; i++) {
        String itemID = itemsRequiring1DMwithHash[i];
        if (!mapNewToolbarStates.containsKey(itemID)) {
            mapNewToolbarStates.put(itemID, hasDM ? UIToolBarItem.STATE_ENABLED : 0);
        }
    }
    mapNewToolbarStates.put("download", has1Selection && (!(currentContent[0] instanceof ISelectedVuzeFileContent)) && currentContent[0].getDownloadManager() == null && (currentContent[0].getHash() != null || currentContent[0].getDownloadInfo() != null) ? UIToolBarItem.STATE_ENABLED : 0);
    if (tv != null) {
        TableColumn tc = tv.getTableColumn(RankItem.COLUMN_ID);
        if (tc != null && !tc.isVisible()) {
            mapNewToolbarStates.put("up", 0L);
            mapNewToolbarStates.put("down", 0L);
        }
    }
    mapNewToolbarStates.put(TU_ITEM_RECHECK, canRecheck ? UIToolBarItem.STATE_ENABLED : 0);
    mapNewToolbarStates.put(TU_ITEM_CHECK_FILES, canCheckExist ? UIToolBarItem.STATE_ENABLED : 0);
    return mapNewToolbarStates;
}
Also used : ISelectedVuzeFileContent(com.biglybt.ui.selectedcontent.ISelectedVuzeFileContent) DiskManagerFileInfo(com.biglybt.core.disk.DiskManagerFileInfo) ISelectedContent(com.biglybt.ui.selectedcontent.ISelectedContent) DiskManagerFileInfoSet(com.biglybt.core.disk.DiskManagerFileInfoSet) MdiEntrySWT(com.biglybt.ui.swt.mdi.MdiEntrySWT) DownloadManager(com.biglybt.core.download.DownloadManager) TableColumn(com.biglybt.pif.ui.tables.TableColumn) GlobalManager(com.biglybt.core.global.GlobalManager) TOTorrent(com.biglybt.core.torrent.TOTorrent) UIPluginView(com.biglybt.pif.ui.UIPluginView) MultipleDocumentInterfaceSWT(com.biglybt.ui.swt.mdi.MultipleDocumentInterfaceSWT) TableView(com.biglybt.ui.common.table.TableView)

Example 8 with MdiEntrySWT

use of com.biglybt.ui.swt.mdi.MdiEntrySWT in project BiglyBT by BiglySoftware.

the class TableViewSWT_TabsCommon method addTabView.

// TabViews Functions
private MdiEntry addTabView(UISWTViewEventListenerWrapper listener, String afterID) {
    UISWTViewCore view = null;
    MdiEntrySWT entry = (MdiEntrySWT) tabbedMDI.createEntryFromEventListener(tv.getTableID(), listener, listener.getViewID(), true, null, afterID);
    if (entry instanceof UISWTViewCore) {
        view = (UISWTViewCore) entry;
    } else {
        return entry;
    }
    try {
        if (parentView != null) {
            view.setParentView(parentView);
        }
        triggerTabViewDataSourceChanged(entry, tv, null);
    } catch (Throwable e) {
        Debug.out(e);
    }
    return entry;
}
Also used : UISWTViewCore(com.biglybt.ui.swt.pifimpl.UISWTViewCore) MdiEntrySWT(com.biglybt.ui.swt.mdi.MdiEntrySWT)

Example 9 with MdiEntrySWT

use of com.biglybt.ui.swt.mdi.MdiEntrySWT in project BiglyBT by BiglySoftware.

the class SideBar method generate.

@Override
public void generate(IndentWriter writer) {
    MdiEntrySWT[] entries = getEntriesSWT();
    for (MdiEntrySWT entry : entries) {
        if (entry == null) {
            continue;
        }
        if (!(entry instanceof AEDiagnosticsEvidenceGenerator)) {
            writer.println("Sidebar View (No Generator): " + entry.getId());
            try {
                writer.indent();
                writer.println("Parent: " + entry.getParentID());
                writer.println("Title: " + entry.getTitle());
            } catch (Exception e) {
            } finally {
                writer.exdent();
            }
        }
    }
}
Also used : MdiEntrySWT(com.biglybt.ui.swt.mdi.MdiEntrySWT)

Example 10 with MdiEntrySWT

use of com.biglybt.ui.swt.mdi.MdiEntrySWT in project BiglyBT by BiglySoftware.

the class StatsView method initialize.

private void initialize(Composite composite) {
    parent = composite;
    // Call plugin listeners
    UIFunctionsSWT uiFunctions = UIFunctionsManagerSWT.getUIFunctionsSWT();
    if (uiFunctions != null) {
        tabbedMDI = uiFunctions.createTabbedMDI(composite, VIEW_ID);
        CTabFolder folder = tabbedMDI.getTabFolder();
        Label lblClose = new Label(folder, SWT.WRAP);
        lblClose.setText("x");
        lblClose.addListener(SWT.MouseUp, new Listener() {

            @Override
            public void handleEvent(Event event) {
                delete();
            }
        });
        folder.setTopRight(lblClose);
        UISWTInstance pluginUI = uiFunctions.getUISWTInstance();
        registerPluginViews(pluginUI);
        if (pluginUI != null) {
            UISWTViewEventListenerWrapper[] pluginViews = pluginUI.getViewListeners(UISWTInstance.VIEW_STATISTICS);
            for (int i = 0; i < pluginViews.length; i++) {
                UISWTViewEventListenerWrapper l = pluginViews[i];
                String name = l.getViewID();
                try {
                    MdiEntrySWT entry = (MdiEntrySWT) tabbedMDI.createEntryFromEventListener(UISWTInstance.VIEW_STATISTICS, l, name, false, null, null);
                    entry.setDestroyOnDeactivate(false);
                    if ((dataSource == null && i == 0) || name.equals(dataSource)) {
                        tabbedMDI.showEntry(entry);
                    }
                } catch (Exception e) {
                // skip
                }
            }
        }
    }
    updateThread = new UpdateThread();
    updateThread.setDaemon(true);
    updateThread.start();
    dataSourceChanged(dataSource);
}
Also used : CTabFolder(org.eclipse.swt.custom.CTabFolder) UIManagerListener(com.biglybt.pif.ui.UIManagerListener) Listener(org.eclipse.swt.widgets.Listener) Label(org.eclipse.swt.widgets.Label) UIFunctionsSWT(com.biglybt.ui.swt.UIFunctionsSWT) MdiEntrySWT(com.biglybt.ui.swt.mdi.MdiEntrySWT) Event(org.eclipse.swt.widgets.Event) UISWTViewEvent(com.biglybt.ui.swt.pif.UISWTViewEvent) UISWTViewEventListenerWrapper(com.biglybt.ui.swt.pif.UISWTInstance.UISWTViewEventListenerWrapper) UISWTInstance(com.biglybt.ui.swt.pif.UISWTInstance)

Aggregations

MdiEntrySWT (com.biglybt.ui.swt.mdi.MdiEntrySWT)10 MultipleDocumentInterfaceSWT (com.biglybt.ui.swt.mdi.MultipleDocumentInterfaceSWT)4 DiskManagerFileInfo (com.biglybt.core.disk.DiskManagerFileInfo)2 DownloadManager (com.biglybt.core.download.DownloadManager)2 UIPluginViewToolBarListener (com.biglybt.pif.ui.UIPluginViewToolBarListener)2 ISelectedContent (com.biglybt.ui.selectedcontent.ISelectedContent)2 ISelectedVuzeFileContent (com.biglybt.ui.selectedcontent.ISelectedVuzeFileContent)2 UIFunctionsSWT (com.biglybt.ui.swt.UIFunctionsSWT)2 DiskManagerFileInfoSet (com.biglybt.core.disk.DiskManagerFileInfoSet)1 DownloadManagerListener (com.biglybt.core.download.DownloadManagerListener)1 GlobalManager (com.biglybt.core.global.GlobalManager)1 TOTorrent (com.biglybt.core.torrent.TOTorrent)1 UIManagerListener (com.biglybt.pif.ui.UIManagerListener)1 UIPluginView (com.biglybt.pif.ui.UIPluginView)1 TableColumn (com.biglybt.pif.ui.tables.TableColumn)1 TableView (com.biglybt.ui.common.table.TableView)1 MdiEntry (com.biglybt.ui.mdi.MdiEntry)1 BaseMdiEntry (com.biglybt.ui.swt.mdi.BaseMdiEntry)1 PluginUISWTSkinObject (com.biglybt.ui.swt.pif.PluginUISWTSkinObject)1 UISWTInstance (com.biglybt.ui.swt.pif.UISWTInstance)1