Search in sources :

Example 66 with ImageLoader

use of com.biglybt.ui.swt.imageloader.ImageLoader in project BiglyBT by BiglySoftware.

the class SWTSkin method disposeSkin.

/**
 * @since 4.0.0.5
 */
private void disposeSkin() {
    ImageLoader imageLoaderInstance = ImageLoader.getInstance();
    for (Iterator<ImageLoader> iter = mapImageLoaders.values().iterator(); iter.hasNext(); ) {
        ImageLoader loader = iter.next();
        if (loader == imageLoaderInstance) {
            loader.unLoadImages();
        } else {
            loader.dispose();
        }
    }
    mapImageLoaders.clear();
}
Also used : ImageLoader(com.biglybt.ui.swt.imageloader.ImageLoader)

Example 67 with ImageLoader

use of com.biglybt.ui.swt.imageloader.ImageLoader in project BiglyBT by BiglySoftware.

the class SWTSkin method createImageLabel2.

private SWTSkinObject createImageLabel2(SWTSkinProperties properties, final String sConfigID, SWTSkinObject parentSkinObject) {
    Composite createOn;
    if (parentSkinObject == null) {
        createOn = skinComposite;
    } else {
        createOn = (Composite) parentSkinObject.getControl();
    }
    final Canvas drawable = new Canvas(createOn, SWT.NO_BACKGROUND);
    drawable.setVisible(false);
    final ImageLoader imageLoader = getImageLoader(properties);
    Image image = imageLoader.getImage(sConfigID);
    if (ImageLoader.isRealImage(image)) {
        imageLoader.releaseImage(sConfigID);
        image = imageLoader.getImage(sConfigID + ".image");
        drawable.addDisposeListener(new DisposeListener() {

            @Override
            public void widgetDisposed(DisposeEvent e) {
                imageLoader.releaseImage(sConfigID + ".image");
            }
        });
    } else {
        drawable.addDisposeListener(new DisposeListener() {

            @Override
            public void widgetDisposed(DisposeEvent e) {
                imageLoader.releaseImage(sConfigID);
            }
        });
    }
    drawable.setData("image", image);
    SWTSkinObjectBasic skinObject = new SWTSkinObjectBasic(this, properties, drawable, sConfigID, sConfigID, "image", parentSkinObject);
    addToControlMap(skinObject);
    ontopImages.add(skinObject);
    return skinObject;
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) ImageLoader(com.biglybt.ui.swt.imageloader.ImageLoader) DisposeEvent(org.eclipse.swt.events.DisposeEvent)

Example 68 with ImageLoader

use of com.biglybt.ui.swt.imageloader.ImageLoader in project BiglyBT by BiglySoftware.

the class BuddyPluginViewInstance method createBeta.

private void createBeta(Composite main) {
    Utils.disposeComposite(main, false);
    final BuddyPluginBeta plugin_beta = plugin.getBeta();
    GridLayout layout = new GridLayout();
    layout.numColumns = 3;
    main.setLayout(layout);
    GridData grid_data = new GridData(GridData.FILL_BOTH);
    main.setLayoutData(grid_data);
    beta_enabled = plugin.isBetaEnabled();
    if (!beta_enabled) {
        Label control_label = new Label(main, SWT.NULL);
        control_label.setText(lu.getLocalisedMessageText("azbuddy.disabled"));
        Label label = new Label(main, SWT.NULL);
        grid_data = new GridData(GridData.FILL_HORIZONTAL);
        label.setLayoutData(grid_data);
        final Button config_button = new Button(main, SWT.NULL);
        config_button.setText(lu.getLocalisedMessageText("plugins.basicview.config"));
        config_button.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                plugin.showConfig();
            }
        });
        return;
    }
    final BuddyPluginBeta beta = plugin.getBeta();
    boolean i2p_enabled = plugin_beta.isI2PAvailable();
    // info
    Composite info_area = new Composite(main, SWT.NULL);
    layout = new GridLayout();
    layout.numColumns = 4;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    info_area.setLayout(layout);
    grid_data = new GridData(GridData.FILL_HORIZONTAL);
    grid_data.horizontalSpan = 3;
    info_area.setLayoutData(grid_data);
    Label label = new Label(info_area, SWT.WRAP);
    grid_data = Utils.getWrappableLabelGridData(1, GridData.FILL_HORIZONTAL);
    label.setLayoutData(grid_data);
    label.setText(lu.getLocalisedMessageText("azbuddy.dchat.info"));
    new LinkLabel(info_area, "ConfigView.label.please.visit.here", Wiki.DECENTRALIZED_CHAT);
    label = new Label(info_area, SWT.NULL);
    grid_data = new GridData(GridData.FILL_HORIZONTAL);
    label.setLayoutData(grid_data);
    final Button config_button = new Button(info_area, SWT.NULL);
    config_button.setText(lu.getLocalisedMessageText("plugins.basicview.config"));
    config_button.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            plugin.showConfig();
        }
    });
    // install plugin
    label = new Label(info_area, SWT.NULL);
    label.setText(MessageText.getString("azmsgsync.install.text"));
    plugin_install_button = new Button(info_area, SWT.NULL);
    plugin_install_button.setText(MessageText.getString("UpdateWindow.columns.install"));
    plugin_install_button.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            plugin_install_button.setEnabled(false);
            new AEThread2("installer") {

                @Override
                public void run() {
                    boolean ok = false;
                    String msg;
                    try {
                        installMsgSyncPlugin();
                        msg = MessageText.getString("azmsgsync.install.ok.msg");
                        ok = true;
                    } catch (Throwable e) {
                        msg = MessageText.getString("azmsgsync.install.fail.msg", new String[] { Debug.getNestedExceptionMessage(e) });
                    } finally {
                        if (!checkMsgSyncPlugin()) {
                            if (ok) {
                                // something weird happened
                                ok = false;
                                msg = MessageText.getString("azmsgsync.install.fail.msg", new String[] { "Unexpected error, check logs" });
                            }
                        }
                    }
                    plugin.getPluginInterface().getUIManager().showMessageBox(ok ? "aztorplugin.browser.install.ok" : "aztorplugin.browser.install.fail", "!" + msg + "!", UIManagerEvent.MT_OK);
                }
            }.start();
        }
    });
    label = new Label(info_area, SWT.NULL);
    grid_data = new GridData(GridData.FILL_HORIZONTAL);
    grid_data.horizontalSpan = 2;
    label.setLayoutData(grid_data);
    checkMsgSyncPlugin();
    // UI
    final Group ui_area = new Group(main, SWT.NULL);
    layout = new GridLayout();
    layout.numColumns = 3;
    ui_area.setLayout(layout);
    grid_data = new GridData(GridData.FILL_HORIZONTAL);
    grid_data.horizontalSpan = 3;
    ui_area.setLayoutData(grid_data);
    ui_area.setText(lu.getLocalisedMessageText("ConfigView.section.style"));
    // shared public nick
    label = new Label(ui_area, SWT.NULL);
    label.setText(lu.getLocalisedMessageText("azbuddy.dchat.public.nick"));
    public_nickname = new Text(ui_area, SWT.BORDER);
    grid_data = new GridData();
    grid_data.widthHint = 200;
    public_nickname.setLayoutData(grid_data);
    public_nickname.setText(plugin_beta.getSharedPublicNickname());
    public_nickname.addListener(SWT.FocusOut, new Listener() {

        @Override
        public void handleEvent(Event event) {
            plugin_beta.setSharedPublicNickname(public_nickname.getText().trim());
        }
    });
    label = new Label(ui_area, SWT.NULL);
    // shared anon nick
    label = new Label(ui_area, SWT.NULL);
    label.setText(lu.getLocalisedMessageText("azbuddy.dchat.anon.nick"));
    anon_nickname = new Text(ui_area, SWT.BORDER);
    grid_data = new GridData();
    grid_data.widthHint = 200;
    anon_nickname.setLayoutData(grid_data);
    anon_nickname.setText(plugin_beta.getSharedAnonNickname());
    anon_nickname.addListener(SWT.FocusOut, new Listener() {

        @Override
        public void handleEvent(Event event) {
            plugin_beta.setSharedAnonNickname(anon_nickname.getText().trim());
        }
    });
    label = new Label(ui_area, SWT.NULL);
    // max lines
    IntSwtParameter max_lines = new IntSwtParameter(ui_area, "azbuddy.chat.temp.ui.max.lines", "azbuddy.dchat.ui.max.lines", null, 128, Integer.MAX_VALUE, null);
    max_lines.setValue(beta.getMaxUILines());
    max_lines.addChangeListener(p -> beta.setMaxUILines(p.getValue()));
    label = new Label(ui_area, SWT.NULL);
    // max chars
    IntSwtParameter max_chars = new IntSwtParameter(ui_area, "azbuddy.chat.temp.ui.max.chars", "azbuddy.dchat.ui.max.kb", null, 1, 512, null);
    max_chars.setValue(beta.getMaxUICharsKB());
    max_chars.addChangeListener(p -> beta.setMaxUICharsKB(p.getValue()));
    label = new Label(ui_area, SWT.NULL);
    // custom date format
    Button cd_enable = new Button(ui_area, SWT.CHECK);
    cd_enable.setText(lu.getLocalisedMessageText("ConfigView.section.style.customDateFormat"));
    String cdf = plugin_beta.getCustomDateFormat();
    cd_enable.setSelection(!cdf.isEmpty());
    Text cd_format = new Text(ui_area, SWT.BORDER);
    grid_data = new GridData();
    grid_data.widthHint = 200;
    cd_format.setText(cdf);
    cd_format.setLayoutData(grid_data);
    cd_enable.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent ev) {
            if (cd_enable.getSelection()) {
                cd_format.setEnabled(true);
                cd_format.setText(plugin_beta.getCustomDateFormat());
            } else {
                cd_format.setText("");
                plugin_beta.setCustomDateFormat("");
                cd_format.setEnabled(false);
            }
        }
    });
    cd_format.setEnabled(!cdf.isEmpty());
    cd_format.addListener(SWT.FocusOut, ev -> {
        plugin_beta.setCustomDateFormat(cd_format.getText().trim());
    });
    label = new Label(ui_area, SWT.NULL);
    // checks
    final Composite ui_area_checks = new Composite(ui_area, SWT.NULL);
    layout = new GridLayout();
    layout.marginHeight = layout.marginWidth = 0;
    layout.numColumns = 1;
    ui_area_checks.setLayout(layout);
    grid_data = new GridData(GridData.FILL_HORIZONTAL);
    grid_data.horizontalSpan = 3;
    ui_area_checks.setLayoutData(grid_data);
    // generate and look for dl-specific messages
    final Button do_dl_chats = new Button(ui_area_checks, SWT.CHECK);
    do_dl_chats.setText(lu.getLocalisedMessageText("azbuddy.dchat.ui.enable.auto.dl.chat"));
    do_dl_chats.setSelection(plugin_beta.getEnableAutoDownloadChats());
    do_dl_chats.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent ev) {
            plugin_beta.setEnableAutoDownloadChats(do_dl_chats.getSelection());
        }
    });
    // hide ratings
    final Button hide_ratings = new Button(ui_area_checks, SWT.CHECK);
    hide_ratings.setText(lu.getLocalisedMessageText("azbuddy.dchat.ui.hide.ratings"));
    hide_ratings.setSelection(plugin_beta.getHideRatings());
    hide_ratings.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent ev) {
            plugin_beta.setHideRatings(hide_ratings.getSelection());
        }
    });
    // hide search/subcriptions
    final Button hide_search_subs = new Button(ui_area_checks, SWT.CHECK);
    hide_search_subs.setText(lu.getLocalisedMessageText("azbuddy.dchat.ui.hide.search_subs"));
    hide_search_subs.setSelection(plugin_beta.getHideSearchSubs());
    hide_search_subs.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent ev) {
            plugin_beta.setHideSearchSubs(hide_search_subs.getSelection());
        }
    });
    // standalone windows
    final Button stand_alone = new Button(ui_area_checks, SWT.CHECK);
    stand_alone.setText(lu.getLocalisedMessageText("azbuddy.dchat.ui.standalone.windows"));
    stand_alone.setSelection(plugin_beta.getStandAloneWindows());
    stand_alone.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent ev) {
            plugin_beta.setStandAloneWindows(stand_alone.getSelection());
        }
    });
    // popout windows -> sidebar
    final Button windows_to_sidebar = new Button(ui_area_checks, SWT.CHECK);
    windows_to_sidebar.setText(lu.getLocalisedMessageText("azbuddy.dchat.ui.windows.to.sidebar"));
    windows_to_sidebar.setSelection(plugin_beta.getWindowsToSidebar());
    windows_to_sidebar.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent ev) {
            plugin_beta.setWindowsToSidebar(windows_to_sidebar.getSelection());
        }
    });
    // use IP Filter
    final Button use_ip_filter = new Button(ui_area_checks, SWT.CHECK);
    use_ip_filter.setText(lu.getLocalisedMessageText("azbuddy.dchat.ui.ipfilter.enable"));
    use_ip_filter.setSelection(plugin_beta.getUseIPFilter());
    use_ip_filter.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent ev) {
            plugin_beta.setUseIPFilter(use_ip_filter.getSelection());
        }
    });
    // notifications
    final Group noti_area = new Group(main, SWT.NULL);
    layout = new GridLayout();
    layout.numColumns = 4;
    noti_area.setLayout(layout);
    grid_data = new GridData(GridData.FILL_HORIZONTAL);
    grid_data.horizontalSpan = 3;
    noti_area.setLayoutData(grid_data);
    noti_area.setText(lu.getLocalisedMessageText("v3.MainWindow.tab.events"));
    final Button sound_enable = new Button(noti_area, SWT.CHECK);
    sound_enable.setText(lu.getLocalisedMessageText("azbuddy.dchat.noti.sound"));
    boolean sound_enabled = plugin_beta.getSoundEnabled();
    sound_enable.setSelection(sound_enabled);
    sound_enable.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent ev) {
            plugin_beta.setSoundEnabled(sound_enable.getSelection());
        }
    });
    final Text noti_file = new Text(noti_area, SWT.BORDER);
    grid_data = new GridData(GridData.FILL_HORIZONTAL);
    grid_data.widthHint = 400;
    noti_file.setLayoutData(grid_data);
    String sound_file = plugin_beta.getSoundFile();
    if (sound_file.length() == 0) {
        sound_file = "<default>";
    }
    noti_file.setText(sound_file);
    noti_file.addListener(SWT.FocusOut, new Listener() {

        @Override
        public void handleEvent(Event event) {
            String val = noti_file.getText().trim();
            if (val.length() == 0 || val.startsWith("<")) {
                noti_file.setText("<default>");
                val = "";
            }
            if (!val.equals(plugin_beta.getSoundFile())) {
                plugin_beta.setSoundFile(val);
            }
        }
    });
    final Button noti_browse = new Button(noti_area, SWT.PUSH);
    final ImageLoader imageLoader = ImageLoader.getInstance();
    final Image imgOpenFolder = imageLoader.getImage("openFolderButton");
    noti_area.addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            imageLoader.releaseImage("openFolderButton");
        }
    });
    noti_browse.setImage(imgOpenFolder);
    imgOpenFolder.setBackground(noti_browse.getBackground());
    Utils.setTT(noti_browse, MessageText.getString("ConfigView.button.browse"));
    noti_browse.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(Event event) {
            FileDialog dialog = new FileDialog(noti_area.getShell(), SWT.APPLICATION_MODAL);
            dialog.setFilterExtensions(new String[] { "*.wav" });
            dialog.setFilterNames(new String[] { "*.wav" });
            dialog.setText(MessageText.getString("ConfigView.section.interface.wavlocation"));
            String path = dialog.open();
            if (path != null) {
                path = path.trim();
                if (path.startsWith("<")) {
                    path = "";
                }
                plugin_beta.setSoundFile(path.trim());
            }
            view.playSound();
        }
    });
    label = new Label(noti_area, SWT.WRAP);
    label.setText(MessageText.getString("ConfigView.section.interface.wavlocation.info"));
    if (!sound_enabled) {
        noti_file.setEnabled(false);
        noti_browse.setEnabled(false);
    }
    final Button flash_enable = new Button(noti_area, SWT.CHECK);
    flash_enable.setText(lu.getLocalisedMessageText("azbuddy.dchat.noti.flash"));
    flash_enable.setSelection(plugin_beta.getFlashEnabled());
    flash_enable.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent ev) {
            plugin_beta.setFlashEnabled(flash_enable.getSelection());
        }
    });
    // private chats
    Group private_chat_area = new Group(main, SWT.NULL);
    layout = new GridLayout();
    layout.numColumns = 1;
    // layout.marginHeight = 0;
    // layout.marginWidth = 0;
    private_chat_area.setLayout(layout);
    grid_data = new GridData(GridData.FILL_HORIZONTAL);
    grid_data.horizontalSpan = 3;
    private_chat_area.setLayoutData(grid_data);
    private_chat_area.setText(lu.getLocalisedMessageText("label.private.chat"));
    final Button private_chat_enable = new Button(private_chat_area, SWT.CHECK);
    Messages.setLanguageText(private_chat_enable, "azbuddy.dchat.pc.enable");
    private_chat_enable.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent ev) {
            plugin_beta.setPrivateChatState(private_chat_enable.getSelection() ? BuddyPluginBeta.PRIVATE_CHAT_ENABLED : BuddyPluginBeta.PRIVATE_CHAT_DISABLED);
        }
    });
    final Button private_chat_pinned = new Button(private_chat_area, SWT.CHECK);
    Messages.setLanguageText(private_chat_pinned, "azbuddy.dchat.pc.pinned.only");
    private_chat_pinned.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent ev) {
            plugin_beta.setPrivateChatState(private_chat_pinned.getSelection() ? BuddyPluginBeta.PRIVATE_CHAT_PINNED_ONLY : BuddyPluginBeta.PRIVATE_CHAT_ENABLED);
        }
    });
    int pc_state = plugin_beta.getPrivateChatState();
    private_chat_enable.setSelection(pc_state != BuddyPluginBeta.PRIVATE_CHAT_DISABLED);
    private_chat_pinned.setSelection(pc_state == BuddyPluginBeta.PRIVATE_CHAT_PINNED_ONLY);
    private_chat_pinned.setEnabled(pc_state != BuddyPluginBeta.PRIVATE_CHAT_DISABLED);
    // integration
    Group integ_area = new Group(main, SWT.NULL);
    layout = new GridLayout();
    layout.numColumns = 1;
    integ_area.setLayout(layout);
    grid_data = new GridData(GridData.FILL_HORIZONTAL);
    grid_data.horizontalSpan = 3;
    integ_area.setLayoutData(grid_data);
    integ_area.setText(lu.getLocalisedMessageText("label.integration"));
    Label lab;
    Button integ_fk_enable = new Button(integ_area, SWT.CHECK);
    Messages.setLanguageText(integ_fk_enable, "azbuddy.dchat.send.friend.key");
    integ_fk_enable.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent ev) {
            plugin_beta.setPostFriendKey(integ_fk_enable.getSelection());
        }
    });
    integ_fk_enable.setSelection(plugin_beta.getPostFriendKey());
    lab = new Label(integ_area, SWT.WRAP);
    lab.setText(lu.getLocalisedMessageText("azbuddy.dchat.send.friend.key.info"));
    grid_data = Utils.getWrappableLabelGridData(1, GridData.FILL_HORIZONTAL);
    lab.setLayoutData(grid_data);
    // import
    Group import_area = new Group(main, SWT.NULL);
    layout = new GridLayout();
    layout.numColumns = 3;
    import_area.setLayout(layout);
    grid_data = new GridData(GridData.FILL_HORIZONTAL);
    grid_data.horizontalSpan = 3;
    import_area.setLayoutData(grid_data);
    import_area.setText(lu.getLocalisedMessageText("azbuddy.dchat.cannel.import"));
    label = new Label(import_area, SWT.NULL);
    label.setText(lu.getLocalisedMessageText("azbuddy.dchat.import.data"));
    final Text import_data = new Text(import_area, SWT.BORDER);
    grid_data = new GridData(GridData.FILL_HORIZONTAL);
    grid_data.widthHint = 400;
    import_data.setLayoutData(grid_data);
    final Button import_button = new Button(import_area, SWT.NULL);
    import_button.setText(lu.getLocalisedMessageText("br.restore"));
    import_button.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent ev) {
            import_button.setEnabled(false);
            final Display display = composite.getDisplay();
            final String data = import_data.getText().trim();
            new AEThread2("async") {

                @Override
                public void run() {
                    if (display.isDisposed()) {
                        return;
                    }
                    try {
                        final BuddyPluginBeta.ChatInstance inst = plugin_beta.importChat(data);
                        display.asyncExec(new Runnable() {

                            @Override
                            public void run() {
                                if (!display.isDisposed()) {
                                    BuddyPluginViewBetaChat.createChatWindow(view, plugin, inst);
                                    import_button.setEnabled(true);
                                }
                            }
                        });
                    } catch (Throwable e) {
                        display.asyncExec(new Runnable() {

                            @Override
                            public void run() {
                                if (!import_button.isDisposed()) {
                                    import_button.setEnabled(true);
                                }
                            }
                        });
                        Debug.out(e);
                    }
                }
            }.start();
        }
    });
    // Advanced
    Group adv_area = new Group(main, SWT.NULL);
    adv_area.setText(lu.getLocalisedMessageText("MyTorrentsView.menu.advancedmenu"));
    layout = new GridLayout();
    layout.numColumns = 1;
    adv_area.setLayout(layout);
    grid_data = new GridData(GridData.FILL_HORIZONTAL);
    grid_data.horizontalSpan = 3;
    adv_area.setLayoutData(grid_data);
    // shared endpoint
    final Button shared_endpoint = new Button(adv_area, SWT.CHECK);
    Messages.setLanguageText(shared_endpoint, "azbuddy.dchat.anon.share.endpoint");
    shared_endpoint.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent ev) {
            plugin_beta.setSharedAnonEndpoint(shared_endpoint.getSelection());
        }
    });
    shared_endpoint.setSelection(plugin_beta.getSharedAnonEndpoint());
    label = new Label(adv_area, SWT.NULL);
    label.setText(lu.getLocalisedMessageText("azbuddy.dchat.anon.share.endpoint.info"));
    grid_data = new GridData(GridData.FILL_HORIZONTAL);
    grid_data.horizontalIndent = 25;
    label.setLayoutData(grid_data);
    // testing
    Group test_area = new Group(main, SWT.NULL);
    test_area.setText(lu.getLocalisedMessageText("br.test"));
    layout = new GridLayout();
    layout.numColumns = 4;
    test_area.setLayout(layout);
    grid_data = new GridData(GridData.FILL_HORIZONTAL);
    grid_data.horizontalSpan = 3;
    test_area.setLayoutData(grid_data);
    // public beta channel
    label = new Label(test_area, SWT.NULL);
    label.setText(lu.getLocalisedMessageText("azbuddy.dchat.public.beta"));
    Button beta_button = new Button(test_area, SWT.NULL);
    // dead BuddyPluginBeta.LEGACY_BETA_CHAT_KEY });
    setupButton(beta_button, lu.getLocalisedMessageText("Button.open"), AENetworkClassifier.AT_PUBLIC, new String[] { BuddyPluginBeta.BETA_CHAT_KEY });
    label = new Label(test_area, SWT.NULL);
    grid_data = new GridData(GridData.FILL_HORIZONTAL);
    grid_data.horizontalSpan = 2;
    label.setLayoutData(grid_data);
    // anonymous beta channel
    label = new Label(test_area, SWT.NULL);
    label.setText(lu.getLocalisedMessageText("azbuddy.dchat.anon.beta"));
    Button beta_i2p_button = new Button(test_area, SWT.NULL);
    // dead BuddyPluginBeta.LEGACY_BETA_CHAT_KEY });
    setupButton(beta_i2p_button, lu.getLocalisedMessageText("Button.open"), AENetworkClassifier.AT_I2P, new String[] { BuddyPluginBeta.BETA_CHAT_KEY });
    beta_i2p_button.setEnabled(i2p_enabled);
    label = new Label(test_area, SWT.NULL);
    grid_data = new GridData(GridData.FILL_HORIZONTAL);
    grid_data.horizontalSpan = 2;
    label.setLayoutData(grid_data);
    // create custom channel
    label = new Label(test_area, SWT.NULL);
    label.setText(lu.getLocalisedMessageText("azbuddy.dchat.create.join.key"));
    final Text channel_key = new Text(test_area, SWT.BORDER);
    grid_data = new GridData();
    grid_data.widthHint = 200;
    channel_key.setLayoutData(grid_data);
    final Button create_i2p_button = new Button(test_area, SWT.CHECK);
    create_i2p_button.setText(lu.getLocalisedMessageText("label.anon.i2p"));
    create_i2p_button.setEnabled(i2p_enabled);
    final Button create_button = new Button(test_area, SWT.NULL);
    create_button.setText(lu.getLocalisedMessageText("Button.open"));
    create_button.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent ev) {
            create_button.setEnabled(false);
            final Display display = composite.getDisplay();
            final String network = create_i2p_button.getSelection() ? AENetworkClassifier.AT_I2P : AENetworkClassifier.AT_PUBLIC;
            final String key = channel_key.getText().trim();
            new AEThread2("async") {

                @Override
                public void run() {
                    if (display.isDisposed()) {
                        return;
                    }
                    try {
                        final BuddyPluginBeta.ChatInstance inst = plugin_beta.getChat(network, key);
                        display.asyncExec(new Runnable() {

                            @Override
                            public void run() {
                                if (!display.isDisposed()) {
                                    BuddyPluginViewBetaChat.createChatWindow(view, plugin, inst);
                                    create_button.setEnabled(true);
                                }
                            }
                        });
                    } catch (Throwable e) {
                        display.asyncExec(new Runnable() {

                            @Override
                            public void run() {
                                if (!create_button.isDisposed()) {
                                    create_button.setEnabled(true);
                                }
                            }
                        });
                        Debug.out(e);
                    }
                }
            }.start();
        }
    });
    // end of UI
    List<Button> buttons = new ArrayList<>();
    buttons.add(create_button);
    buttons.add(beta_button);
    buttons.add(beta_i2p_button);
    buttons.add(import_button);
    Utils.makeButtonsEqualWidth(buttons);
    plugin.addListener(new BuddyPluginAdapter() {

        @Override
        public void updated() {
            if (public_nickname.isDisposed()) {
                plugin.removeListener(this);
            } else {
                public_nickname.getDisplay().asyncExec(new Runnable() {

                    @Override
                    public void run() {
                        if (public_nickname.isDisposed()) {
                            return;
                        }
                        String nick = plugin_beta.getSharedPublicNickname();
                        if (!public_nickname.getText().equals(nick)) {
                            public_nickname.setText(nick);
                        }
                        nick = plugin_beta.getSharedAnonNickname();
                        if (!anon_nickname.getText().equals(nick)) {
                            anon_nickname.setText(nick);
                        }
                        shared_endpoint.setSelection(plugin_beta.getSharedAnonEndpoint());
                        int pc_state = plugin_beta.getPrivateChatState();
                        private_chat_enable.setSelection(pc_state != BuddyPluginBeta.PRIVATE_CHAT_DISABLED);
                        private_chat_pinned.setSelection(pc_state == BuddyPluginBeta.PRIVATE_CHAT_PINNED_ONLY);
                        private_chat_pinned.setEnabled(pc_state != BuddyPluginBeta.PRIVATE_CHAT_DISABLED);
                        integ_fk_enable.setSelection(plugin_beta.getPostFriendKey());
                        String str = plugin_beta.getSoundFile();
                        if (str.length() == 0) {
                            noti_file.setText("<default>");
                        } else {
                            noti_file.setText(str);
                        }
                        boolean se = plugin_beta.getSoundEnabled();
                        noti_file.setEnabled(se);
                        noti_browse.setEnabled(se);
                    }
                });
            }
        }
    });
}
Also used : UserPrompterResultListener(com.biglybt.ui.UserPrompterResultListener) CryptoManagerKeyListener(com.biglybt.core.security.CryptoManagerKeyListener) UIInputReceiverListener(com.biglybt.pif.ui.UIInputReceiverListener) LinkLabel(com.biglybt.ui.swt.components.LinkLabel) Image(org.eclipse.swt.graphics.Image) MessageText(com.biglybt.core.internat.MessageText) Point(org.eclipse.swt.graphics.Point) IntSwtParameter(com.biglybt.ui.swt.config.IntSwtParameter) LinkLabel(com.biglybt.ui.swt.components.LinkLabel) UIManagerEvent(com.biglybt.pif.ui.UIManagerEvent) ImageLoader(com.biglybt.ui.swt.imageloader.ImageLoader)

Example 69 with ImageLoader

use of com.biglybt.ui.swt.imageloader.ImageLoader in project BiglyBT by BiglySoftware.

the class BuddyPluginView method init.

private void init(BuddyPlugin _plugin, UIInstance _ui_instance) {
    plugin = _plugin;
    ui_instance = (UISWTInstance) _ui_instance;
    buddyPluginAZ2Listener = new BuddyPluginAZ2Listener() {

        @Override
        public void chatCreated(final BuddyPluginAZ2.chatInstance chat) {
            final Display display = ui_instance.getDisplay();
            if (display.isDisposed()) {
                return;
            }
            display.asyncExec(() -> {
                if (!display.isDisposed()) {
                    new BuddyPluginViewChat(plugin, display, chat);
                }
            });
        }

        @Override
        public void chatDestroyed(BuddyPluginAZ2.chatInstance chat) {
        }
    };
    for (BuddyPluginNetwork pn : plugin.getPluginNetworks()) {
        pn.getAZ2Handler().addListener(buddyPluginAZ2Listener);
    }
    buddyStatusInit = SimpleTimer.addEvent("BuddyStatusInit", SystemTime.getOffsetTime(1000), event -> statusUpdater = new statusUpdater(ui_instance));
    Utils.execSWTThread(() -> {
        ImageLoader imageLoader = ImageLoader.getInstance();
        iconNLI = imageLoader.getImage("bbb_nli");
        iconIDLE = imageLoader.getImage("bbb_idle");
        iconIN = imageLoader.getImage("bbb_in");
        iconOUT = imageLoader.getImage("bbb_out");
        iconINOUT = imageLoader.getImage("bbb_inout");
    });
    ui_instance.registerView(UISWTInstance.VIEW_MAIN, ui_instance.createViewBuilder(FriendsView.VIEW_ID).setListenerInstantiator(true, (Builder, swtView) -> new FriendsView(this, plugin, ui_instance)));
    checkBetaInit();
}
Also used : java.util(java.util) FormattersImpl(com.biglybt.pifimpl.local.utils.FormattersImpl) I2PHelpers(com.biglybt.plugin.I2PHelpers) com.biglybt.pif.ui.menus(com.biglybt.pif.ui.menus) Image(org.eclipse.swt.graphics.Image) Rectangle(org.eclipse.swt.graphics.Rectangle) Download(com.biglybt.pif.download.Download) com.biglybt.pif.ui.tables(com.biglybt.pif.ui.tables) UIFunctionsManager(com.biglybt.ui.UIFunctionsManager) Point(org.eclipse.swt.graphics.Point) BuddyPluginTracker(com.biglybt.plugin.net.buddy.tracker.BuddyPluginTracker) ChatInstance(com.biglybt.plugin.net.buddy.BuddyPluginBeta.ChatInstance) MenuBuildUtils(com.biglybt.ui.swt.MenuBuildUtils) Utils(com.biglybt.ui.swt.Utils) AllTransfersBar(com.biglybt.ui.swt.minibar.AllTransfersBar) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) org.eclipse.swt.custom(org.eclipse.swt.custom) com.biglybt.core.tag(com.biglybt.core.tag) MenuItem(com.biglybt.pif.ui.menus.MenuItem) GridData(org.eclipse.swt.layout.GridData) UIInstance(com.biglybt.pif.ui.UIInstance) CoreFactory(com.biglybt.core.CoreFactory) PluginCoreUtils(com.biglybt.pifimpl.local.PluginCoreUtils) org.eclipse.swt.events(org.eclipse.swt.events) com.biglybt.core.security(com.biglybt.core.security) TableCellSWT(com.biglybt.ui.swt.views.table.TableCellSWT) ImageLoader(com.biglybt.ui.swt.imageloader.ImageLoader) com.biglybt.ui.swt.pif(com.biglybt.ui.swt.pif) org.eclipse.swt.widgets(org.eclipse.swt.widgets) MessageText(com.biglybt.core.internat.MessageText) DownloadManager(com.biglybt.core.download.DownloadManager) DiskManagerFileInfo(com.biglybt.pif.disk.DiskManagerFileInfo) com.biglybt.core.util(com.biglybt.core.util) com.biglybt.plugin.net.buddy(com.biglybt.plugin.net.buddy) List(java.util.List) ChatMessage(com.biglybt.plugin.net.buddy.BuddyPluginBeta.ChatMessage) MultipleDocumentInterface(com.biglybt.ui.mdi.MultipleDocumentInterface) TagUIUtils(com.biglybt.ui.swt.views.utils.TagUIUtils) SWT(org.eclipse.swt.SWT) UIFunctions(com.biglybt.ui.UIFunctions) BuddyPluginTrackerListener(com.biglybt.plugin.net.buddy.tracker.BuddyPluginTrackerListener) GridLayout(org.eclipse.swt.layout.GridLayout) TableColumn(com.biglybt.pif.ui.tables.TableColumn) ImageLoader(com.biglybt.ui.swt.imageloader.ImageLoader)

Example 70 with ImageLoader

use of com.biglybt.ui.swt.imageloader.ImageLoader in project BiglyBT by BiglySoftware.

the class SideBarEntrySWT method destroyEntry.

@Override
protected void destroyEntry(boolean userInitiated) {
    if (Utils.runIfNotSWTThread(() -> destroyEntry(userInitiated))) {
        return;
    }
    // System.out.println(id + " destroyEntry " + swtItem + "; " + Debug.getCompressedStackTrace());
    if (swtItem == null) {
        destroyEntryAlways();
        return;
    }
    // Must make a copy of swtItem because swtItem.dispose will end up in
    // this method again, with swtItem.isDisposed() still false.
    TreeItem item = swtItem;
    swtItem = null;
    // super can end up calling destroyEntry again (via SWT disposals), so
    // don't call super until after we nulled swtItem
    super.destroyEntry(userInitiated);
    try {
        if (!item.isDisposed()) {
            item.dispose();
        }
        // System.out.println(id + " dispose " + Debug.getCompressedStackTrace());
        ImageLoader imageLoader = ImageLoader.getInstance();
        imageLoader.releaseImage("image.sidebar.closeitem");
        imageLoader.releaseImage("image.sidebar.closeitem-selected");
    } catch (Exception e) {
        // on OSX, SWT does some misguided exceptions on disposal of TreeItem
        // We occasionally get SWTException of "Widget is Disposed" or
        // "Argument not valid", as well as NPEs
        Debug.outNoStack("Warning on SidebarEntry dispose: " + e.toString(), false);
    }
}
Also used : ImageLoader(com.biglybt.ui.swt.imageloader.ImageLoader)

Aggregations

ImageLoader (com.biglybt.ui.swt.imageloader.ImageLoader)78 Image (org.eclipse.swt.graphics.Image)20 GridData (org.eclipse.swt.layout.GridData)16 GridLayout (org.eclipse.swt.layout.GridLayout)16 Rectangle (org.eclipse.swt.graphics.Rectangle)6 MessageText (com.biglybt.core.internat.MessageText)5 AERunnable (com.biglybt.core.util.AERunnable)5 UIFunctions (com.biglybt.ui.UIFunctions)5 UserPrompterResultListener (com.biglybt.ui.UserPrompterResultListener)5 File (java.io.File)5 ArrayList (java.util.ArrayList)5 Core (com.biglybt.core.Core)4 CoreRunningListener (com.biglybt.core.CoreRunningListener)4 MessageBoxShell (com.biglybt.ui.swt.shells.MessageBoxShell)4 MouseAdapter (org.eclipse.swt.events.MouseAdapter)4 MouseEvent (org.eclipse.swt.events.MouseEvent)4 Point (org.eclipse.swt.graphics.Point)4 Subscription (com.biglybt.core.subs.Subscription)3 MenuItem (com.biglybt.pif.ui.menus.MenuItem)3 TableColumnCreationListener (com.biglybt.pif.ui.tables.TableColumnCreationListener)3