Search in sources :

Example 46 with UIFunctions

use of com.biglybt.ui.UIFunctions in project BiglyBT by BiglySoftware.

the class I2PHelpers method installI2PHelper.

public static boolean installI2PHelper(String extra_text, String remember_id, final boolean[] install_outcome, final Runnable callback) {
    String decline_key = remember_id;
    if (decline_key == null) {
        decline_key = extra_text;
    }
    if (decline_key == null) {
        decline_key = "generic";
    }
    synchronized (i2p_install_lock) {
        Long decline = declines.get(decline_key);
        if (decline != null && SystemTime.getMonotonousTime() - decline < 60 * 1000) {
            return (false);
        }
        if (i2p_installing) {
            Debug.out("I2P Helper already installing");
            return (false);
        }
        i2p_installing = true;
    }
    boolean installing = false;
    boolean declined = false;
    try {
        UIFunctions uif = UIFunctionsManager.getUIFunctions();
        if (uif == null) {
            Debug.out("UIFunctions unavailable - can't install plugin");
            return (false);
        }
        String title = MessageText.getString("azneti2phelper.install");
        String text = "";
        if (extra_text != null) {
            text = extra_text + "\n\n";
        }
        text += MessageText.getString("azneti2phelper.install.text");
        UIFunctionsUserPrompter prompter = uif.getUserPrompter(title, text, new String[] { MessageText.getString("Button.yes"), MessageText.getString("Button.no") }, 0);
        if (remember_id != null) {
            prompter.setRemember(remember_id, false, MessageText.getString("MessageBoxWindow.nomoreprompting"));
        }
        prompter.setAutoCloseInMS(0);
        prompter.open(null);
        boolean install = prompter.waitUntilClosed() == 0;
        if (install) {
            installing = true;
            uif.installPlugin("azneti2phelper", "azneti2phelper.install", new UIFunctions.actionListener() {

                @Override
                public void actionComplete(Object result) {
                    try {
                        if (callback != null) {
                            if (result instanceof Boolean) {
                                install_outcome[0] = (Boolean) result;
                            }
                            callback.run();
                        }
                    } finally {
                        synchronized (i2p_install_lock) {
                            i2p_installing = false;
                        }
                    }
                }
            });
        } else {
            declined = true;
            Debug.out("I2P Helper install declined (either user reply or auto-remembered)");
        }
        return (install);
    } finally {
        synchronized (i2p_install_lock) {
            if (!installing) {
                i2p_installing = false;
            }
            if (declined) {
                declines.put(decline_key, SystemTime.getMonotonousTime());
            }
        }
    }
}
Also used : UIFunctions(com.biglybt.ui.UIFunctions) UIFunctionsUserPrompter(com.biglybt.ui.UIFunctionsUserPrompter)

Example 47 with UIFunctions

use of com.biglybt.ui.UIFunctions in project BiglyBT by BiglySoftware.

the class BuddyPluginViewInstance method installMsgSyncPlugin.

private void installMsgSyncPlugin() throws Throwable {
    UIFunctions uif = UIFunctionsManager.getUIFunctions();
    if (uif == null) {
        throw (new Exception("UIFunctions unavailable - can't install plugin"));
    }
    final AESemaphore sem = new AESemaphore("installer_wait");
    final Throwable[] error = { null };
    uif.installPlugin("azmsgsync", "azmsgsync.install", new UIFunctions.actionListener() {

        @Override
        public void actionComplete(Object result) {
            try {
                if (result instanceof Boolean) {
                } else {
                    error[0] = (Throwable) result;
                }
            } finally {
                sem.release();
            }
        }
    });
    sem.reserve();
    if (error[0] instanceof Throwable) {
        throw ((Throwable) error[0]);
    }
}
Also used : UIFunctions(com.biglybt.ui.UIFunctions)

Example 48 with UIFunctions

use of com.biglybt.ui.UIFunctions in project BiglyBT by BiglySoftware.

the class SBC_ChatOverview method chatRemoved.

@Override
public void chatRemoved(ChatInstance chat) {
    tv.removeDataSource(chat);
    UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions();
    if (uiFunctions != null) {
        uiFunctions.refreshIconBar();
    }
}
Also used : UIFunctions(com.biglybt.ui.UIFunctions)

Example 49 with UIFunctions

use of com.biglybt.ui.UIFunctions in project BiglyBT by BiglySoftware.

the class BuddyPluginView method buildMenu.

private void buildMenu(final Set<ChatInstance> current_instances) {
    if (menu_items.size() == 0 || !menu_latest_instances.equals(current_instances)) {
        for (MenuItem mi : menu_items) {
            mi.remove();
        }
        menu_items.clear();
        final MenuManager menu_manager = plugin.getPluginInterface().getUIManager().getMenuManager();
        MenuContext mc = beta_status.getMenuContext();
        for (final ChatInstance chat : sortChats(current_instances)) {
            String short_name = chat.getShortName();
            MenuItem mi = menu_manager.addMenuItem(mc, "!" + short_name + "!");
            mi.addListener(new MenuItemListener() {

                @Override
                public void selected(MenuItem menu, Object target) {
                    try {
                        openChat(chat.getClone());
                    } catch (Throwable e) {
                        Debug.out(e);
                    }
                }
            });
            menu_items.add(mi);
        }
        boolean need_sep = true;
        if (current_instances.size() > 1) {
            MenuItem mi = menu_manager.addMenuItem(mc, "sep1");
            need_sep = false;
            mi.setStyle(MenuItem.STYLE_SEPARATOR);
            menu_items.add(mi);
            mi = menu_manager.addMenuItem(mc, "label.open.all");
            mi.addListener(new MenuItemListener() {

                @Override
                public void selected(MenuItem menu, Object target) {
                    for (ChatInstance chat : current_instances) {
                        try {
                            openChat(chat.getClone());
                        } catch (Throwable e) {
                            Debug.out(e);
                        }
                    }
                }
            });
            menu_items.add(mi);
        }
        if (need_sep) {
            MenuItem mi = menu_manager.addMenuItem(mc, "sep2");
            mi.setStyle(MenuItem.STYLE_SEPARATOR);
            menu_items.add(mi);
        }
        // create channel
        MenuItem mi = menu_manager.addMenuItem(mc, "chat.view.create.chat");
        mi.setStyle(MenuItem.STYLE_MENU);
        menu_items.add(mi);
        mi.addFillListener(new com.biglybt.pif.ui.menus.MenuItemFillListener() {

            @Override
            public void menuWillBeShown(MenuItem menu, Object data) {
                menu.removeAllChildItems();
                MenuItem mi = menu_manager.addMenuItem(menu, "!" + MessageText.getString("label.public") + "...!");
                mi.addListener(new MenuItemListener() {

                    @Override
                    public void selected(MenuItem menu, Object target) {
                        SimpleTextEntryWindow entryWindow = new SimpleTextEntryWindow("chat.view.enter.key.title", "chat.view.enter.key.msg");
                        entryWindow.prompt(new UIInputReceiverListener() {

                            @Override
                            public void UIInputReceiverClosed(UIInputReceiver receiver) {
                                if (!receiver.hasSubmittedInput()) {
                                    return;
                                }
                                String key = receiver.getSubmittedInput().trim();
                                BuddyPluginUtils.createBetaChat(AENetworkClassifier.AT_PUBLIC, key, null);
                            }
                        });
                    }
                });
                mi = menu_manager.addMenuItem(menu, "!" + MessageText.getString("label.anon") + "...!");
                mi.addListener(new MenuItemListener() {

                    @Override
                    public void selected(MenuItem menu, Object target) {
                        if (plugin.getBeta().isI2PAvailable()) {
                            SimpleTextEntryWindow entryWindow = new SimpleTextEntryWindow("chat.view.enter.key.title", "chat.view.enter.key.msg");
                            entryWindow.prompt(new UIInputReceiverListener() {

                                @Override
                                public void UIInputReceiverClosed(UIInputReceiver receiver) {
                                    if (!receiver.hasSubmittedInput()) {
                                        return;
                                    }
                                    String key = receiver.getSubmittedInput().trim();
                                    BuddyPluginUtils.createBetaChat(AENetworkClassifier.AT_I2P, key, null);
                                }
                            });
                        } else {
                            I2PHelpers.installI2PHelper(null, null, null);
                        }
                    }
                });
                if (I2PHelpers.isInstallingI2PHelper()) {
                    mi.setEnabled(false);
                    mi.setText(mi.getText() + " (" + MessageText.getString("PeersView.state.pending") + ")");
                }
            }
        });
        // chat overview
        mi = menu_manager.addMenuItem(mc, "!" + MessageText.getString("chats.view.heading") + "...!");
        mi.addListener(new MenuItemListener() {

            @Override
            public void selected(MenuItem menu, Object target) {
                UIFunctions uif = UIFunctionsManager.getUIFunctions();
                if (uif != null) {
                    uif.getMDI().showEntryByID(MultipleDocumentInterface.SIDEBAR_SECTION_CHAT);
                }
            }
        });
        menu_items.add(mi);
        mi = menu_manager.addMenuItem(mc, "sep3");
        mi.setStyle(MenuItem.STYLE_SEPARATOR);
        menu_items.add(mi);
        // options
        mi = menu_manager.addMenuItem(mc, "MainWindow.menu.view.configuration");
        mi.addListener(new MenuItemListener() {

            @Override
            public void selected(MenuItem menu, Object target) {
                ui_instance.openView(UISWTInstance.VIEW_MAIN, VIEW_ID, null);
            }
        });
        menu_items.add(mi);
        menu_latest_instances = current_instances;
    }
}
Also used : ChatInstance(com.biglybt.plugin.net.buddy.BuddyPluginBeta.ChatInstance) MenuItem(com.biglybt.pif.ui.menus.MenuItem) MenuContext(com.biglybt.pif.ui.menus.MenuContext) UIFunctions(com.biglybt.ui.UIFunctions) SimpleTextEntryWindow(com.biglybt.ui.swt.SimpleTextEntryWindow) UIInputReceiver(com.biglybt.pif.ui.UIInputReceiver) MenuManager(com.biglybt.pif.ui.menus.MenuManager) MenuItemListener(com.biglybt.pif.ui.menus.MenuItemListener) UIInputReceiverListener(com.biglybt.pif.ui.UIInputReceiverListener)

Example 50 with UIFunctions

use of com.biglybt.ui.UIFunctions in project BiglyBT by BiglySoftware.

the class MyTorrentsView method showSelectedDetails.

private void showSelectedDetails() {
    Object[] dm_sources = tv.getSelectedDataSources().toArray();
    UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions();
    for (int i = 0; i < dm_sources.length; i++) {
        if (!(dm_sources[i] instanceof DownloadManager)) {
            continue;
        }
        if (uiFunctions != null) {
            uiFunctions.getMDI().showEntryByID(MultipleDocumentInterface.SIDEBAR_SECTION_TORRENT_DETAILS, dm_sources[i]);
        }
    }
}
Also used : UIFunctions(com.biglybt.ui.UIFunctions) DownloadManager(com.biglybt.core.download.DownloadManager)

Aggregations

UIFunctions (com.biglybt.ui.UIFunctions)68 DownloadManager (com.biglybt.core.download.DownloadManager)16 MenuItemListener (com.biglybt.pif.ui.menus.MenuItemListener)9 GridLayout (org.eclipse.swt.layout.GridLayout)9 PluginInterface (com.biglybt.pif.PluginInterface)8 MenuItem (com.biglybt.pif.ui.menus.MenuItem)8 File (java.io.File)8 SelectionEvent (org.eclipse.swt.events.SelectionEvent)8 GridData (org.eclipse.swt.layout.GridData)8 CoreRunningListener (com.biglybt.core.CoreRunningListener)7 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)7 Menu (org.eclipse.swt.widgets.Menu)7 Core (com.biglybt.core.Core)6 LogEvent (com.biglybt.core.logging.LogEvent)6 UIFunctionsUserPrompter (com.biglybt.ui.UIFunctionsUserPrompter)6 Composite (org.eclipse.swt.widgets.Composite)6 MenuItem (org.eclipse.swt.widgets.MenuItem)6 DiskManagerFileInfo (com.biglybt.core.disk.DiskManagerFileInfo)5 GlobalManager (com.biglybt.core.global.GlobalManager)5 LogAlert (com.biglybt.core.logging.LogAlert)5