Search in sources :

Example 6 with IntSwtParameter

use of com.biglybt.ui.swt.config.IntSwtParameter in project BiglyBT by BiglySoftware.

the class TorrentOptionsView method parameterChanged.

/* (non-Javadoc)
	 * @see com.biglybt.core.download.DownloadManagerStateAttributeListener#attributeEventOccurred(com.biglybt.core.download.DownloadManager, java.lang.String, int)
	 */
@Override
public void parameterChanged(DownloadManagerOptionsHandler manager) {
    Utils.execSWTThread(new Runnable() {

        @Override
        public void run() {
            Iterator<Entry<String, BaseSwtParameter<?, ?>>> it = ds_parameters.entrySet().iterator();
            while (it.hasNext()) {
                Map.Entry<String, BaseSwtParameter<?, ?>> entry = it.next();
                String key = entry.getKey();
                Object param = entry.getValue();
                if (param instanceof IntSwtParameter) {
                    IntSwtParameter int_param = (IntSwtParameter) param;
                    int value = manager.getIntParameter(key);
                    int_param.setValue(value);
                } else if (param instanceof BooleanSwtParameter) {
                    BooleanSwtParameter bool_param = (BooleanSwtParameter) param;
                    boolean value = manager.getBooleanParameter(key);
                    bool_param.setSelected(value);
                } else if (param instanceof FloatSwtParameter) {
                    FloatSwtParameter float_param = (FloatSwtParameter) param;
                    float value = manager.getIntParameter(key) / 1000f;
                    float_param.setValue(value);
                } else {
                    Debug.out("Unknown parameter type: " + param.getClass());
                }
            }
        }
    }, true);
}
Also used : TabbedEntry(com.biglybt.ui.swt.mdi.TabbedEntry) Entry(java.util.Map.Entry) FloatSwtParameter(com.biglybt.ui.swt.config.FloatSwtParameter) IntSwtParameter(com.biglybt.ui.swt.config.IntSwtParameter) BooleanSwtParameter(com.biglybt.ui.swt.config.BooleanSwtParameter) Iterator(java.util.Iterator) BaseSwtParameter(com.biglybt.ui.swt.config.BaseSwtParameter)

Example 7 with IntSwtParameter

use of com.biglybt.ui.swt.config.IntSwtParameter 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)

Aggregations

IntSwtParameter (com.biglybt.ui.swt.config.IntSwtParameter)7 BufferedLabel (com.biglybt.ui.swt.components.BufferedLabel)4 GridData (org.eclipse.swt.layout.GridData)4 GridLayout (org.eclipse.swt.layout.GridLayout)4 TabbedEntry (com.biglybt.ui.swt.mdi.TabbedEntry)3 Core (com.biglybt.core.Core)2 CoreLifecycleAdapter (com.biglybt.core.CoreLifecycleAdapter)2 MessageText (com.biglybt.core.internat.MessageText)2 BaseSwtParameter (com.biglybt.ui.swt.config.BaseSwtParameter)2 BooleanSwtParameter (com.biglybt.ui.swt.config.BooleanSwtParameter)2 FloatSwtParameter (com.biglybt.ui.swt.config.FloatSwtParameter)2 UISWTViewEvent (com.biglybt.ui.swt.pif.UISWTViewEvent)2 UISWTViewCoreEventListener (com.biglybt.ui.swt.pifimpl.UISWTViewCoreEventListener)2 Entry (java.util.Map.Entry)2 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 CoreFactory (com.biglybt.core.CoreFactory)1 CoreRunningListener (com.biglybt.core.CoreRunningListener)1 COConfigurationManager (com.biglybt.core.config.COConfigurationManager)1 TransferSpeedValidator (com.biglybt.core.config.impl.TransferSpeedValidator)1