Search in sources :

Example 11 with UIManager

use of com.biglybt.pif.ui.UIManager in project BiglyBT by BiglySoftware.

the class SBC_DevicesView method initColumns.

/**
 * @since 4.1.0.5
 */
private void initColumns(Core core) {
    if (columnsAdded) {
        return;
    }
    columnsAdded = true;
    UIManager uiManager = PluginInitializer.getDefaultInterface().getUIManager();
    TableManager tableManager = uiManager.getTableManager();
    tableManager.registerColumn(TranscodeFile.class, ColumnTJ_Rank.COLUMN_ID, new TableColumnCreationListener() {

        @Override
        public void tableColumnCreated(TableColumn column) {
            new ColumnTJ_Rank(column);
            if (!column.getTableID().equals(TABLE_TRANSCODE_QUEUE)) {
                column.setVisible(false);
            }
        }
    });
    tableManager.registerColumn(TranscodeFile.class, ColumnThumbnail.COLUMN_ID, new TableColumnCreationListener() {

        @Override
        public void tableColumnCreated(TableColumn column) {
            new ColumnThumbnail(column);
            column.setWidth(70);
            column.setVisible(false);
        }
    });
    tableManager.registerColumn(TranscodeFile.class, ColumnTJ_Name.COLUMN_ID, new TableColumnCreationListener() {

        @Override
        public void tableColumnCreated(TableColumn column) {
            new ColumnTJ_Name(column);
            if (column.getTableID().equals(TABLE_TRANSCODE_QUEUE)) {
                column.setWidth(200);
            } else if (!column.getTableID().endsWith(":type=1")) {
                column.setWidth(140);
            }
        }
    });
    tableManager.registerColumn(TranscodeFile.class, ColumnTJ_Duration.COLUMN_ID, new TableColumnCreationListener() {

        @Override
        public void tableColumnCreated(TableColumn column) {
            new ColumnTJ_Duration(column);
        }
    });
    tableManager.registerColumn(TranscodeFile.class, ColumnTJ_Device.COLUMN_ID, new TableColumnCreationListener() {

        @Override
        public void tableColumnCreated(TableColumn column) {
            new ColumnTJ_Device(column);
            column.setVisible(false);
        }
    });
    tableManager.registerColumn(TranscodeFile.class, ColumnTJ_Profile.COLUMN_ID, new TableColumnCreationListener() {

        @Override
        public void tableColumnCreated(TableColumn column) {
            new ColumnTJ_Profile(column);
            if (column.getTableID().equals(TABLE_TRANSCODE_QUEUE)) {
                column.setWidth(70);
            }
        }
    });
    tableManager.registerColumn(TranscodeFile.class, ColumnTJ_Resolution.COLUMN_ID, new TableColumnCreationListener() {

        @Override
        public void tableColumnCreated(TableColumn column) {
            new ColumnTJ_Resolution(column);
            column.setVisible(false);
            if (column.getTableID().equals(TABLE_TRANSCODE_QUEUE)) {
                column.setWidth(95);
            }
        }
    });
    tableManager.registerColumn(TranscodeFile.class, ColumnTJ_Status.COLUMN_ID, new TableColumnCreationListener() {

        @Override
        public void tableColumnCreated(TableColumn column) {
            new ColumnTJ_Status(column);
        }
    });
    tableManager.registerColumn(TranscodeFile.class, ColumnTJ_Completion.COLUMN_ID, new TableColumnCreationListener() {

        @Override
        public void tableColumnCreated(TableColumn column) {
            new ColumnTJ_Completion(column);
            column.setWidth(145);
        }
    });
    tableManager.registerColumn(TranscodeFile.class, ColumnTJ_CopiedToDevice.COLUMN_ID, new TableColumnCreationListener() {

        @Override
        public void tableColumnCreated(TableColumn column) {
            new ColumnTJ_CopiedToDevice(column);
            if (column.getTableID().endsWith(":type=1") || column.getTableID().equals(TABLE_TRANSCODE_QUEUE)) {
                column.setVisible(false);
            }
        }
    });
    tableManager.registerColumn(TranscodeFile.class, ColumnTJ_Category.COLUMN_ID, new TableColumnCreationListener() {

        @Override
        public void tableColumnCreated(TableColumn column) {
            new ColumnTJ_Category(column);
        }
    });
    tableManager.registerColumn(TranscodeFile.class, ColumnTJ_Tags.COLUMN_ID, new TableColumnCreationListener() {

        @Override
        public void tableColumnCreated(TableColumn column) {
            new ColumnTJ_Tags(column);
        }
    });
    TableColumnManager tcm = TableColumnManager.getInstance();
    String[] defaultLibraryColumns = { ColumnTJ_Rank.COLUMN_ID, ColumnTJ_Name.COLUMN_ID, ColumnTJ_Duration.COLUMN_ID, ColumnTJ_Device.COLUMN_ID, ColumnTJ_Status.COLUMN_ID, ColumnTJ_Completion.COLUMN_ID };
    tcm.setDefaultColumnNames(TABLE_TRANSCODE_QUEUE, defaultLibraryColumns);
    String[] defaultQColumns = { ColumnTJ_Name.COLUMN_ID, ColumnTJ_Duration.COLUMN_ID, ColumnTJ_Profile.COLUMN_ID, ColumnTJ_Status.COLUMN_ID, ColumnTJ_Completion.COLUMN_ID };
    tcm.setDefaultColumnNames(TABLE_DEVICE_LIBRARY, defaultQColumns);
}
Also used : UIManager(com.biglybt.pif.ui.UIManager) ColumnThumbnail(com.biglybt.ui.swt.columns.torrent.ColumnThumbnail) TableColumn(com.biglybt.pif.ui.tables.TableColumn) TableColumnManager(com.biglybt.ui.common.table.impl.TableColumnManager) TableColumnCreationListener(com.biglybt.pif.ui.tables.TableColumnCreationListener) TableManager(com.biglybt.pif.ui.tables.TableManager)

Example 12 with UIManager

use of com.biglybt.pif.ui.UIManager in project BiglyBT by BiglySoftware.

the class MainWindowDelayStub method checkMainWindow.

private void checkMainWindow() {
    boolean activated = false;
    synchronized (this) {
        if (main_window == null) {
            UIManager ui_manager = PluginInitializer.getDefaultInterface().getUIManager();
            ui_manager.removeUIEventListener(ui_listener);
            final AESemaphore wait_sem = new AESemaphore("cmw");
            CoreLifecycleListener listener = new CoreLifecycleAdapter() {

                @Override
                public void componentCreated(Core core, CoreComponent component) {
                    if (component instanceof UIFunctions) {
                        wait_sem.release();
                    }
                }
            };
            core.addLifecycleListener(listener);
            main_window = new MainWindowImpl(core, null);
            if (!wait_sem.reserve(30 * 1000)) {
                Debug.out("Gave up waiting for UIFunction component to be created");
            }
            activated = true;
        }
    }
    if (activated) {
        AERunStateHandler.setResourceMode(AERunStateHandler.RS_ALL_ACTIVE);
    }
}
Also used : UIManager(com.biglybt.pif.ui.UIManager) UISWTViewCore(com.biglybt.ui.swt.pifimpl.UISWTViewCore)

Example 13 with UIManager

use of com.biglybt.pif.ui.UIManager in project BiglyBT by BiglySoftware.

the class OpenTorrentWindow method TorrentDownloaderEvent.

@Override
public void TorrentDownloaderEvent(int state, TorrentDownloader inf) {
    // We set this flag to false if we detected the file was not a torrent
    if (!inf.getDeleteFileOnCancel() && (state == TorrentDownloader.STATE_CANCELLED || state == TorrentDownloader.STATE_ERROR || state == TorrentDownloader.STATE_DUPLICATE || state == TorrentDownloader.STATE_FINISHED)) {
        File file = inf.getFile();
        // we already know it isn't a torrent.. we are just using the call
        // to popup the message
        boolean done = false;
        if (RSSUtils.isRSSFeed(file)) {
            try {
                URL url = new URL(inf.getURL());
                UIManager ui_manager = StaticUtilities.getUIManager(10 * 1000);
                if (ui_manager != null) {
                    String details = MessageText.getString("subscription.request.add.message", new String[] { inf.getURL() });
                    long res = ui_manager.showMessageBox("subscription.request.add.title", "!" + details + "!", UIManagerEvent.MT_YES | UIManagerEvent.MT_NO);
                    if (res == UIManagerEvent.MT_YES) {
                        SubscriptionManager sm = PluginInitializer.getDefaultInterface().getUtilities().getSubscriptionManager();
                        sm.requestSubscription(url);
                        done = true;
                    }
                }
            } catch (Throwable e) {
                Debug.out(e);
            }
        }
        if (!done) {
            TorrentUtil.isFileTorrent(inf.getURL(), file, inf.getURL(), true);
        }
        if (file.exists()) {
            file.delete();
        }
        return;
    }
    if (state == TorrentDownloader.STATE_INIT) {
    } else if (state == TorrentDownloader.STATE_FINISHED) {
        File file = inf.getFile();
        TorrentOpenOptions torrentOptions = new TorrentOpenOptions();
        if (!TorrentOpener.mergeFileIntoTorrentInfo(file.getAbsolutePath(), inf.getURL(), torrentOptions)) {
            if (file.exists())
                file.delete();
        } else {
            UIFunctions uif = UIFunctionsManager.getUIFunctions();
            boolean b = uif.addTorrentWithOptions(false, torrentOptions);
            if (!b && file.exists()) {
                file.delete();
            }
        }
    } else if (state == TorrentDownloader.STATE_CANCELLED || state == TorrentDownloader.STATE_ERROR || state == TorrentDownloader.STATE_DUPLICATE) {
    } else if (state == TorrentDownloader.STATE_DOWNLOADING) {
        int count = inf.getLastReadCount();
        int numRead = inf.getTotalRead();
        if (!inf.getDeleteFileOnCancel() && numRead >= 16384) {
            inf.cancel();
        } else if (numRead == count && count > 0) {
            final byte[] bytes = inf.getLastReadBytes();
            if (bytes[0] != 'd' && bytes[0] != '<') {
                inf.setDeleteFileOnCancel(false);
            }
        }
    } else {
        return;
    }
}
Also used : TorrentOpenOptions(com.biglybt.core.torrent.impl.TorrentOpenOptions) UIFunctions(com.biglybt.ui.UIFunctions) UIManager(com.biglybt.pif.ui.UIManager) SubscriptionManager(com.biglybt.pif.utils.subscriptions.SubscriptionManager) File(java.io.File) URL(java.net.URL)

Example 14 with UIManager

use of com.biglybt.pif.ui.UIManager in project BiglyBT by BiglySoftware.

the class MainMDISetup method setupSidebarVuzeUI.

private static void setupSidebarVuzeUI(final MultipleDocumentInterfaceSWT mdi) {
    String[] preferredOrder = new String[] { MultipleDocumentInterface.SIDEBAR_HEADER_DASHBOARD, MultipleDocumentInterface.SIDEBAR_HEADER_TRANSFERS, MultipleDocumentInterface.SIDEBAR_HEADER_VUZE, MultipleDocumentInterface.SIDEBAR_HEADER_DISCOVERY, MultipleDocumentInterface.SIDEBAR_HEADER_DEVICES, MultipleDocumentInterface.SIDEBAR_HEADER_PLUGINS };
    mdi.setPreferredOrder(preferredOrder);
    sb_dashboard = new SB_Dashboard(mdi);
    for (int i = 0; i < preferredOrder.length; i++) {
        String id = preferredOrder[i];
        mdi.registerEntry(id, new MdiEntryCreationListener() {

            @Override
            public MdiEntry createMDiEntry(String id) {
                MdiEntry entry;
                if (id.equals(MultipleDocumentInterface.SIDEBAR_HEADER_DASHBOARD)) {
                    entry = sb_dashboard.setupMDIEntry();
                } else {
                    entry = mdi.createHeader(id, "sidebar." + id, null);
                    if (entry == null) {
                        return (null);
                    }
                    entry.setDefaultExpanded(true);
                    if (id.equals(MultipleDocumentInterface.SIDEBAR_HEADER_PLUGINS)) {
                        entry.addListener(new MdiChildCloseListener() {

                            @Override
                            public void mdiChildEntryClosed(MdiEntry parent, MdiEntry child, boolean user) {
                                if (mdi.getChildrenOf(parent.getId()).size() == 0) {
                                    parent.close(true);
                                }
                            }
                        });
                        PluginInterface pi = PluginInitializer.getDefaultInterface();
                        UIManager uim = pi.getUIManager();
                        MenuManager menuManager = uim.getMenuManager();
                        MenuItem menuItem;
                        menuItem = menuManager.addMenuItem("sidebar." + MultipleDocumentInterface.SIDEBAR_HEADER_PLUGINS, "label.plugin.options");
                        menuItem.setDisposeWithUIDetach(UIInstance.UIT_SWT);
                        menuItem.addListener(new MenuItemListener() {

                            @Override
                            public void selected(MenuItem menu, Object target) {
                                UIFunctions uif = UIFunctionsManager.getUIFunctions();
                                if (uif != null) {
                                    uif.getMDI().showEntryByID(MultipleDocumentInterface.SIDEBAR_SECTION_CONFIG, "plugins");
                                }
                            }
                        });
                    }
                }
                return entry;
            }
        });
    }
    sb_transfers = new SB_Transfers(mdi, true);
    sb_vuze = new SB_Vuze(mdi);
    new SB_Discovery(mdi);
    mdi.loadEntryByID(MultipleDocumentInterface.SIDEBAR_HEADER_DASHBOARD, false);
    mdi.loadEntryByID(MultipleDocumentInterface.SIDEBAR_SECTION_LIBRARY, false);
    if (COConfigurationManager.getBooleanParameter("Show New In Side Bar")) {
        mdi.loadEntryByID(MultipleDocumentInterface.SIDEBAR_SECTION_LIBRARY_UNOPENED, false);
    }
    mdi.loadEntryByID(MultipleDocumentInterface.SIDEBAR_SECTION_SUBSCRIPTIONS, false);
    mdi.loadEntryByID(MultipleDocumentInterface.SIDEBAR_SECTION_DEVICES, false);
    mdi.loadEntryByID(MultipleDocumentInterface.SIDEBAR_SECTION_ACTIVITIES, false);
}
Also used : PluginInterface(com.biglybt.pif.PluginInterface) UIManager(com.biglybt.pif.ui.UIManager) MenuItem(com.biglybt.pif.ui.menus.MenuItem) UIFunctions(com.biglybt.ui.UIFunctions) MenuManager(com.biglybt.pif.ui.menus.MenuManager) MenuItemListener(com.biglybt.pif.ui.menus.MenuItemListener)

Example 15 with UIManager

use of com.biglybt.pif.ui.UIManager in project BiglyBT by BiglySoftware.

the class MetaSearchManagerImpl method importEngine.

@Override
public Engine importEngine(Map map, boolean warn_user) throws MetaSearchException {
    synchronized (import_lock) {
        try {
            EngineImpl engine = (EngineImpl) meta_search.importFromBEncodedMap(map);
            long id = engine.getId();
            Engine existing = meta_search.getEngine(id);
            if (existing != null) {
                if (existing.sameLogicAs(engine)) {
                    if (warn_user) {
                        UIManager ui_manager = StaticUtilities.getUIManager(120 * 1000);
                        String details = MessageText.getString("metasearch.addtemplate.dup.desc", new String[] { engine.getName() });
                        ui_manager.showMessageBox("metasearch.addtemplate.dup.title", "!" + details + "!", UIManagerEvent.MT_OK);
                    }
                    return (existing);
                }
            } else {
                try {
                    Engine[] engines = meta_search.getEngines(false, false);
                    for (Engine e : engines) {
                        if (e.sameLogicAs(engine)) {
                            return (e);
                        }
                    }
                } catch (Throwable e) {
                }
            }
            if (warn_user) {
                UIManager ui_manager = StaticUtilities.getUIManager(120 * 1000);
                String details = MessageText.getString("metasearch.addtemplate.desc", new String[] { engine.getName() });
                long res = ui_manager.showMessageBox("metasearch.addtemplate.title", "!" + details + "!", UIManagerEvent.MT_YES | UIManagerEvent.MT_NO);
                if (res != UIManagerEvent.MT_YES) {
                    throw (new MetaSearchException("User declined the template"));
                }
            }
            if (id >= 0 && id < Integer.MAX_VALUE) {
                id = getLocalTemplateID();
                engine.setId(id);
            }
            engine.setSource(Engine.ENGINE_SOURCE_LOCAL);
            engine.setSelectionState(Engine.SEL_STATE_MANUAL_SELECTED);
            meta_search.addEngine(engine);
            if (warn_user) {
                UIManager ui_manager = StaticUtilities.getUIManager(120 * 1000);
                String details = MessageText.getString("metasearch.addtemplate.done.desc", new String[] { engine.getName() });
                ui_manager.showMessageBox("metasearch.addtemplate.done.title", "!" + details + "!", UIManagerEvent.MT_OK);
            }
            return (engine);
        } catch (Throwable e) {
            if (warn_user) {
                UIManager ui_manager = StaticUtilities.getUIManager(120 * 1000);
                String details = MessageText.getString("metasearch.addtemplate.failed.desc", new String[] { Debug.getNestedExceptionMessage(e) });
                ui_manager.showMessageBox("metasearch.addtemplate.failed.title", "!" + details + "!", UIManagerEvent.MT_OK);
            }
            throw (new MetaSearchException("Failed to add engine", e));
        }
    }
}
Also used : UIManager(com.biglybt.pif.ui.UIManager) PluginEngine(com.biglybt.core.metasearch.impl.plugin.PluginEngine)

Aggregations

UIManager (com.biglybt.pif.ui.UIManager)48 UIInstance (com.biglybt.pif.ui.UIInstance)14 PluginInterface (com.biglybt.pif.PluginInterface)13 UIManagerListener (com.biglybt.pif.ui.UIManagerListener)13 UISWTInstance (com.biglybt.ui.swt.pif.UISWTInstance)10 MenuItemListener (com.biglybt.pif.ui.menus.MenuItemListener)8 MenuItem (com.biglybt.pif.ui.menus.MenuItem)7 MenuManager (com.biglybt.pif.ui.menus.MenuManager)7 LoggerChannelListener (com.biglybt.pif.logging.LoggerChannelListener)6 DownloadManager (com.biglybt.core.download.DownloadManager)5 BasicPluginConfigModel (com.biglybt.pif.ui.model.BasicPluginConfigModel)5 URL (java.net.URL)5 TableManager (com.biglybt.pif.ui.tables.TableManager)4 TableColumnManager (com.biglybt.ui.common.table.impl.TableColumnManager)4 ArrayList (java.util.ArrayList)4 VuzeFile (com.biglybt.core.vuzefile.VuzeFile)3 PluginListener (com.biglybt.pif.PluginListener)3 MenuItemFillListener (com.biglybt.pif.ui.menus.MenuItemFillListener)3 BasicPluginViewModel (com.biglybt.pif.ui.model.BasicPluginViewModel)3 DelayedTask (com.biglybt.pif.utils.DelayedTask)3