Search in sources :

Example 31 with UIFunctions

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

the class UpdateMonitor method performCheck.

public void performCheck(final boolean bForce, final boolean automatic, final boolean isRecheck, final UpdateCheckInstanceListener l) {
    long now = SystemTime.getCurrentTime();
    if (isRecheck) {
        if (last_recheck_time > now || now - last_recheck_time < 23 * 60 * 60 * 1000) {
            if (Logger.isEnabled())
                Logger.log(new LogEvent(LOGID, "skipping recheck as consecutive recheck too soon"));
            return;
        }
        last_recheck_time = now;
    } else {
        last_recheck_time = 0;
    }
    if (SystemProperties.isJavaWebStartInstance()) {
        // just in case we get here somehome!
        if (Logger.isEnabled())
            Logger.log(new LogEvent(LOGID, "skipping update check as java web start"));
        return;
    }
    if (current_update_window != null && !current_update_window.isDisposed()) {
        current_update_window.dispose();
    }
    if (current_update_instance != null) {
        current_update_instance.cancel();
    }
    if (bForce) {
        VersionCheckClient.getSingleton().clearCache();
    }
    UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions();
    if (uiFunctions != null) {
        uiFunctions.setStatusText("MainWindow.status.checking");
    }
    // take this off this GUI thread in case it blocks for a while
    AEThread2 t = new AEThread2("UpdateMonitor:kickoff", true) {

        @Override
        public void run() {
            UpdateManager um = PluginInitializer.getDefaultInterface().getUpdateManager();
            current_update_instance = um.createUpdateCheckInstance(bForce ? UpdateCheckInstance.UCI_INSTALL : UpdateCheckInstance.UCI_UPDATE, "update.instance.update");
            if (!automatic) {
                current_update_instance.setAutomatic(false);
            }
            if (l != null) {
                current_update_instance.addListener(l);
            }
            current_update_instance.start();
        }
    };
    t.start();
}
Also used : LogEvent(com.biglybt.core.logging.LogEvent) UIFunctions(com.biglybt.ui.UIFunctions)

Example 32 with UIFunctions

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

the class ViewQuickNotifications method initialize.

private void initialize(Composite parent) {
    parent.setLayout(new GridLayout());
    composite = new Composite(parent, SWT.BORDER);
    GridData gridData = new GridData(GridData.FILL_BOTH);
    Utils.setLayoutData(composite, gridData);
    GridLayout layout = new GridLayout(2, false);
    layout.marginLeft = layout.marginRight = layout.marginTop = layout.marginBottom = 0;
    composite.setLayout(layout);
    // icon
    notification_icon = new Label(composite, SWT.NONE);
    gridData = new GridData();
    gridData.widthHint = 20;
    Utils.setLayoutData(notification_icon, gridData);
    // text
    notification_text = new Label(composite, SWT.DOUBLE_BUFFERED);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(notification_text, gridData);
    MouseAdapter listener = new MouseAdapter() {

        @Override
        public void mouseDown(MouseEvent e) {
            UIFunctions uif = UIFunctionsManager.getUIFunctions();
            if (uif != null) {
                uif.getMDI().showEntryByID(MultipleDocumentInterface.SIDEBAR_SECTION_ACTIVITIES);
            }
        }
    };
    // text
    more_text = new BufferedLabel(composite, SWT.NONE);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalSpan = 2;
    Utils.setLayoutData(more_text, gridData);
    notification_text.setData("");
    Control[] controls = { composite, notification_icon, notification_text, more_text.getControl() };
    for (Control c : controls) {
        c.addMouseListener(listener);
        Messages.setLanguageTooltip(c, "label.click.to.view.tooltip");
    }
    notification_text.addPaintListener(new PaintListener() {

        @Override
        public void paintControl(PaintEvent e) {
            String text = (String) notification_text.getData();
            int style = SWT.LEFT;
            Rectangle bounds = notification_text.getBounds();
            bounds.x = 4;
            bounds.y = 0;
            bounds.width -= 8;
            GCStringPrinter sp = new GCStringPrinter(e.gc, text, bounds, true, true, style);
            sp.calculateMetrics();
            sp.printString();
        }
    });
}
Also used : MouseEvent(org.eclipse.swt.events.MouseEvent) BufferedLabel(com.biglybt.ui.swt.components.BufferedLabel) PaintEvent(org.eclipse.swt.events.PaintEvent) GCStringPrinter(com.biglybt.ui.swt.shells.GCStringPrinter) PaintListener(org.eclipse.swt.events.PaintListener) BufferedLabel(com.biglybt.ui.swt.components.BufferedLabel) MouseAdapter(org.eclipse.swt.events.MouseAdapter) Rectangle(org.eclipse.swt.graphics.Rectangle) GridLayout(org.eclipse.swt.layout.GridLayout) UIFunctions(com.biglybt.ui.UIFunctions) GridData(org.eclipse.swt.layout.GridData)

Example 33 with UIFunctions

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

the class CoreImpl method executeInternalCloseAction.

private void executeInternalCloseAction(final boolean obey_reset, final boolean download_trigger, final String action, final String reason) {
    // prevent immediate retriggering if user aborts
    ca_last_time_downloading = -1;
    ca_last_time_seeding = -1;
    String type_str = reason == null ? MessageText.getString(download_trigger ? "core.shutdown.dl" : "core.shutdown.se") : reason;
    String action_str = MessageText.getString("ConfigView.label.stop." + action);
    String message = MessageText.getString("core.shutdown.alert", new String[] { action_str, type_str });
    UIFunctions ui_functions = UIFunctionsManager.getUIFunctions();
    if (ui_functions != null) {
        ui_functions.forceNotify(UIFunctions.STATUSICON_NONE, null, message, null, new Object[0], -1);
    }
    Logger.log(new LogAlert(LogAlert.UNREPEATABLE, LogEvent.LT_INFORMATION, message));
    if (COConfigurationManager.getBooleanParameter("Prompt To Abort Shutdown")) {
        UIManager ui_manager = StaticUtilities.getUIManager(30 * 1000);
        if (ui_manager != null) {
            Map<String, Object> options = new HashMap<>();
            options.put(UIManager.MB_PARAM_AUTO_CLOSE_MS, 30 * 1000);
            if (ui_manager.showMessageBox("core.shutdown.prompt.title", "core.shutdown.prompt.msg", UIManagerEvent.MT_OK_DEFAULT | UIManagerEvent.MT_CANCEL, options) == UIManagerEvent.MT_CANCEL) {
                return;
            }
        }
    }
    executeCloseActionSupport(obey_reset, download_trigger, action, reason);
}
Also used : UIFunctions(com.biglybt.ui.UIFunctions) UIManager(com.biglybt.pif.ui.UIManager) LogAlert(com.biglybt.core.logging.LogAlert)

Example 34 with UIFunctions

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

the class AEPluginProxyHandler method installTor.

private static boolean installTor(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 (tor_install_lock) {
        Long decline = declines.get(decline_key);
        if (decline != null && SystemTime.getMonotonousTime() - decline < 60 * 1000) {
            return (false);
        }
        if (tor_installing) {
            Debug.out("Tor Helper already installing");
            return (false);
        }
        tor_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("aznettor.install");
        String text = "";
        if (extra_text != null) {
            text = extra_text + "\n\n";
        }
        text += MessageText.getString("aznettor.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("aznettor", "aznettor.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 (tor_install_lock) {
                            tor_installing = false;
                        }
                    }
                }
            });
        } else {
            declined = true;
            Debug.out("Tor Helper install declined (either user reply or auto-remembered)");
        }
        return (install);
    } finally {
        synchronized (tor_install_lock) {
            if (!installing) {
                tor_installing = false;
            }
            if (declined) {
                declines.put(decline_key, SystemTime.getMonotonousTime());
            }
        }
    }
}
Also used : UIFunctions(com.biglybt.ui.UIFunctions) UIFunctionsUserPrompter(com.biglybt.ui.UIFunctionsUserPrompter)

Example 35 with UIFunctions

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

the class PlayUtils method getMediaServerContentURL.

public static URL getMediaServerContentURL(DiskManagerFileInfo file) {
    // TorrentListViewsUtils.debugDCAD("enter - getMediaServerContentURL");
    PluginManager pm = CoreFactory.getSingleton().getPluginManager();
    PluginInterface pi = pm.getPluginInterfaceByID("azupnpav", false);
    if (pi == null) {
        Logger.log(new LogEvent(LogIDs.UI3, "Media server plugin not found"));
        return null;
    }
    if (!pi.getPluginState().isOperational()) {
        Logger.log(new LogEvent(LogIDs.UI3, "Media server plugin not operational"));
        return null;
    }
    try {
        if (hasQuickTime == null) {
            UIFunctions uif = UIFunctionsManager.getUIFunctions();
            if (uif != null) {
                hasQuickTime = uif.isProgramInstalled(".qtl", "Quicktime");
                try {
                    pi.getIPC().invoke("setQuickTimeAvailable", new Object[] { hasQuickTime });
                } catch (Throwable e) {
                    Logger.log(new LogEvent(LogIDs.UI3, LogEvent.LT_WARNING, "IPC to media server plugin failed", e));
                }
            }
        }
        boolean use_peek = tls_non_block_indicator.get()[0] > 0;
        Object url;
        if (use_peek && pi.getIPC().canInvoke("peekContentURL", new Object[] { file })) {
            url = pi.getIPC().invoke("peekContentURL", new Object[] { file });
        } else {
            url = pi.getIPC().invoke("getContentURL", new Object[] { file });
        }
        if (url instanceof String) {
            return new URL((String) url);
        }
    } catch (Throwable e) {
        Logger.log(new LogEvent(LogIDs.UI3, LogEvent.LT_WARNING, "IPC to media server plugin failed", e));
    }
    return null;
}
Also used : PluginManager(com.biglybt.pif.PluginManager) LogEvent(com.biglybt.core.logging.LogEvent) UIFunctions(com.biglybt.ui.UIFunctions) PluginInterface(com.biglybt.pif.PluginInterface) URL(java.net.URL)

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