Search in sources :

Example 6 with LinkLabel

use of com.biglybt.ui.swt.components.LinkLabel in project BiglyBT by BiglySoftware.

the class BuddyPluginViewBetaChat method buildHelp.

private Composite buildHelp(Composite rhs) {
    boolean public_chat = !chat.isPrivateChat();
    boolean sharing_view = chat.getViewType() == BuddyPluginBeta.VIEW_TYPE_SHARING;
    boolean can_popout = shell == null && public_chat;
    Composite top_right = new Composite(rhs, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 3;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    top_right.setLayout(layout);
    if (!sharing_view) {
        GridData grid_data = new GridData(GridData.FILL_HORIZONTAL);
        // grid_data.heightHint = 50;
        Utils.setLayoutData(top_right, grid_data);
        Label label = new Label(top_right, SWT.NULL);
        grid_data = new GridData(GridData.FILL_HORIZONTAL);
        grid_data.horizontalSpan = can_popout ? 1 : 2;
        Utils.setLayoutData(label, grid_data);
    }
    LinkLabel link = new LinkLabel(top_right, "label.help", lu.getLocalisedMessageText("azbuddy.dchat.link.url"));
    if (sharing_view) {
        buildRSSButton(top_right);
    }
    if (can_popout) {
        Label pop_out = new Label(top_right, SWT.NULL);
        Image image = ImageLoader.getInstance().getImage("popout_window");
        pop_out.setImage(image);
        GridData grid_data = new GridData();
        grid_data.widthHint = image.getBounds().width;
        grid_data.heightHint = image.getBounds().height;
        Utils.setLayoutData(pop_out, grid_data);
        pop_out.setCursor(pop_out.getDisplay().getSystemCursor(SWT.CURSOR_HAND));
        pop_out.setToolTipText(MessageText.getString("label.pop.out"));
        pop_out.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseUp(MouseEvent arg0) {
                try {
                    createChatWindow(view, plugin, chat.getClone(), true);
                } catch (Throwable e) {
                    Debug.out(e);
                }
            }
        });
    }
    return (top_right);
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) MouseEvent(org.eclipse.swt.events.MouseEvent) Composite(org.eclipse.swt.widgets.Composite) LinkLabel(com.biglybt.ui.swt.components.LinkLabel) GridData(org.eclipse.swt.layout.GridData) BufferedLabel(com.biglybt.ui.swt.components.BufferedLabel) Label(org.eclipse.swt.widgets.Label) LinkLabel(com.biglybt.ui.swt.components.LinkLabel) MouseAdapter(org.eclipse.swt.events.MouseAdapter) Image(org.eclipse.swt.graphics.Image)

Example 7 with LinkLabel

use of com.biglybt.ui.swt.components.LinkLabel in project BiglyBT by BiglySoftware.

the class BuddyPluginViewInstance method createClassic.

private void createClassic(Composite main) {
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    main.setLayout(layout);
    GridData grid_data = new GridData(GridData.FILL_BOTH);
    Utils.setLayoutData(main, grid_data);
    // 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;
    Utils.setLayoutData(info_area, grid_data);
    Label label = new Label(info_area, SWT.NULL);
    label.setText(lu.getLocalisedMessageText("azbuddy.classic.info"));
    new LinkLabel(info_area, "ConfigView.label.please.visit.here", lu.getLocalisedMessageText("azbuddy.classic.link.url"));
    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();
        }
    });
    classic_enabled = plugin.isClassicEnabled();
    if (!classic_enabled) {
        Label control_label = new Label(main, SWT.NULL);
        control_label.setText(lu.getLocalisedMessageText("azbuddy.disabled"));
        return;
    }
    // control area
    final Composite controls = new Composite(main, SWT.NONE);
    layout = new GridLayout();
    layout.numColumns = 5;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    controls.setLayout(layout);
    grid_data = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(controls, grid_data);
    Label control_label = new Label(controls, SWT.NULL);
    control_label.setText(lu.getLocalisedMessageText("azbuddy.ui.new_buddy") + " ");
    final Text control_text = new Text(controls, SWT.BORDER);
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(control_text, gridData);
    final Button control_button = new Button(controls, SWT.NULL);
    control_button.setText(lu.getLocalisedMessageText("Button.add"));
    control_button.setEnabled(false);
    control_text.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            control_button.setEnabled(plugin.verifyPublicKey(control_text.getText().trim()));
        }
    });
    control_button.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            plugin.addBuddy(control_text.getText().trim(), BuddyPlugin.SUBSYSTEM_AZ2);
            control_text.setText("");
        }
    });
    final Label control_lab_pk = new Label(controls, SWT.NULL);
    control_lab_pk.setText(lu.getLocalisedMessageText("azbuddy.ui.mykey") + " ");
    final Label control_val_pk = new Label(controls, SWT.NULL);
    gridData = new GridData();
    Utils.setLayoutData(control_val_pk, gridData);
    ClipboardCopy.addCopyToClipMenu(control_val_pk, new ClipboardCopy.copyToClipProvider() {

        @Override
        public String getText() {
            return ((String) control_val_pk.getData("key"));
        }
    });
    control_val_pk.setData("key", "");
    final CryptoManager crypt_man = CryptoManagerFactory.getSingleton();
    byte[] public_key = crypt_man.getECCHandler().peekPublicKey();
    if (public_key == null) {
        Messages.setLanguageText(control_val_pk, "ConfigView.section.security.publickey.undef");
    } else {
        String str = Base32.encode(public_key);
        control_val_pk.setData("key", str);
        control_val_pk.setText(truncate(str));
    }
    Messages.setLanguageText(control_val_pk, "ConfigView.copy.to.clipboard.tooltip", true);
    control_val_pk.setCursor(main.getDisplay().getSystemCursor(SWT.CURSOR_HAND));
    control_val_pk.setForeground(Colors.blue);
    control_val_pk.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDoubleClick(MouseEvent arg0) {
            copyToClipboard();
        }

        @Override
        public void mouseDown(MouseEvent arg0) {
            copyToClipboard();
        }

        protected void copyToClipboard() {
            new Clipboard(control_val_pk.getDisplay()).setContents(new Object[] { control_val_pk.getData("key") }, new Transfer[] { TextTransfer.getInstance() });
        }
    });
    cryptoManagerKeyListener = new CryptoManagerKeyListener() {

        @Override
        public void keyChanged(final CryptoHandler handler) {
            if (control_val_pk.isDisposed()) {
                crypt_man.removeKeyListener(this);
            } else if (handler.getType() == CryptoManager.HANDLER_ECC) {
                control_val_pk.getDisplay().asyncExec(new Runnable() {

                    @Override
                    public void run() {
                        byte[] public_key = handler.peekPublicKey();
                        if (public_key == null) {
                            Messages.setLanguageText(control_val_pk, "ConfigView.section.security.publickey.undef");
                            control_val_pk.setData("key", "");
                        } else {
                            String str = Base32.encode(public_key);
                            control_val_pk.setText(truncate(str));
                            control_val_pk.setData("key", str);
                        }
                        controls.layout();
                    }
                });
            }
        }

        @Override
        public void keyLockStatusChanged(CryptoHandler handler) {
        }
    };
    crypt_man.addKeyListener(cryptoManagerKeyListener);
    main.addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            if (cryptoManagerKeyListener != null) {
                CryptoManagerFactory.getSingleton().removeKeyListener(cryptoManagerKeyListener);
            }
        }
    });
    // table and log
    final Composite form = new Composite(main, SWT.NONE);
    FormLayout flayout = new FormLayout();
    flayout.marginHeight = 0;
    flayout.marginWidth = 0;
    form.setLayout(flayout);
    gridData = new GridData(GridData.FILL_BOTH);
    Utils.setLayoutData(form, gridData);
    final Composite child1 = new Composite(form, SWT.NULL);
    layout = new GridLayout();
    layout.numColumns = 1;
    layout.horizontalSpacing = 0;
    layout.verticalSpacing = 0;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    child1.setLayout(layout);
    final Sash sash = new Sash(form, SWT.HORIZONTAL);
    final Composite child2 = new Composite(form, SWT.NULL);
    layout = new GridLayout();
    layout.numColumns = 1;
    layout.horizontalSpacing = 0;
    layout.verticalSpacing = 0;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    child2.setLayout(layout);
    FormData formData;
    // child1
    formData = new FormData();
    formData.left = new FormAttachment(0, 0);
    formData.right = new FormAttachment(100, 0);
    formData.top = new FormAttachment(0, 0);
    Utils.setLayoutData(child1, formData);
    final FormData child1Data = formData;
    final int SASH_WIDTH = 4;
    // sash
    formData = new FormData();
    formData.left = new FormAttachment(0, 0);
    formData.right = new FormAttachment(100, 0);
    formData.top = new FormAttachment(child1);
    formData.height = SASH_WIDTH;
    Utils.setLayoutData(sash, formData);
    // child2
    formData = new FormData();
    formData.left = new FormAttachment(0, 0);
    formData.right = new FormAttachment(100, 0);
    formData.bottom = new FormAttachment(100, 0);
    formData.top = new FormAttachment(sash);
    Utils.setLayoutData(child2, formData);
    final PluginConfig pc = plugin.getPluginInterface().getPluginconfig();
    sash.setData("PCT", new Float(pc.getPluginFloatParameter("swt.sash.position", 0.7f)));
    sash.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (e.detail == SWT.DRAG) {
                return;
            }
            child1Data.height = e.y + e.height - SASH_WIDTH;
            form.layout();
            Float l = new Float((double) child1.getBounds().height / form.getBounds().height);
            sash.setData("PCT", l);
            pc.setPluginParameter("swt.sash.position", l.floatValue());
        }
    });
    form.addListener(SWT.Resize, new Listener() {

        @Override
        public void handleEvent(Event e) {
            Float l = (Float) sash.getData("PCT");
            if (l != null) {
                child1Data.height = (int) (form.getBounds().height * l.doubleValue());
                form.layout();
            }
        }
    });
    // table
    Comparator<BuddyPluginBuddy> comparator = addBuddyTable(child1);
    Label pblab = new Label(child1, SWT.NULL);
    pblab.setText(lu.getLocalisedMessageText("label.partial.friends"));
    Comparator<PartialBuddy> pbcomparator = addPartialBuddyTable(child1);
    // log area
    log = new StyledText(child2, SWT.READ_ONLY | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
    grid_data = new GridData(GridData.FILL_BOTH);
    grid_data.horizontalSpan = 1;
    grid_data.horizontalIndent = 4;
    Utils.setLayoutData(log, grid_data);
    log.setIndent(4);
    buddies = plugin.getBuddies();
    for (int i = 0; i < buddies.size(); i++) {
        buddyAdded(buddies.get(i));
    }
    Collections.sort(buddies, comparator);
    partial_buddies = plugin.getPartialBuddies();
    for (int i = 0; i < partial_buddies.size(); i++) {
        partialBuddyAdded(partial_buddies.get(i));
    }
    Collections.sort(partial_buddies, pbcomparator);
    plugin.addListener(this);
    plugin.addPartialBuddyListener(this);
    plugin.addRequestListener(this);
    init_complete = true;
    updateTable();
    updatePartialBuddyTable();
}
Also used : UserPrompterResultListener(com.biglybt.ui.UserPrompterResultListener) UIInputReceiverListener(com.biglybt.pif.ui.UIInputReceiverListener) LinkLabel(com.biglybt.ui.swt.components.LinkLabel) StyledText(org.eclipse.swt.custom.StyledText) StyledText(org.eclipse.swt.custom.StyledText) MessageText(com.biglybt.core.internat.MessageText) ClipboardCopy(com.biglybt.ui.swt.mainwindow.ClipboardCopy) Point(org.eclipse.swt.graphics.Point) PluginConfig(com.biglybt.pif.PluginConfig) LinkLabel(com.biglybt.ui.swt.components.LinkLabel) TextTransfer(org.eclipse.swt.dnd.TextTransfer) Transfer(org.eclipse.swt.dnd.Transfer) UIManagerEvent(com.biglybt.pif.ui.UIManagerEvent) Clipboard(org.eclipse.swt.dnd.Clipboard)

Example 8 with LinkLabel

use of com.biglybt.ui.swt.components.LinkLabel in project BiglyBT by BiglySoftware.

the class BetaWizardStart method show.

@Override
public void show() {
    wizard.setTitle(MessageText.getString("beta.wizard.intro.title"));
    wizard.setCurrentInfo("");
    wizard.setPreviousEnabled(false);
    wizard.setNextEnabled(false);
    wizard.setFinishEnabled(true);
    Composite rootPanel = wizard.getPanel();
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    rootPanel.setLayout(layout);
    Label info_label = new Label(rootPanel, SWT.WRAP);
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(info_label, gridData);
    info_label.setText(MessageText.getString("beta.wizard.info"));
    LinkLabel link = new LinkLabel(rootPanel, "beta.wizard.link", MessageText.getString("beta.wizard.link.url"));
    Label link_label = link.getlabel();
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.verticalIndent = 10;
    Utils.setLayoutData(link_label, gridData);
    final Composite gRadio = new Composite(rootPanel, SWT.NULL);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.verticalIndent = 10;
    Utils.setLayoutData(gRadio, gridData);
    layout = new GridLayout();
    layout.numColumns = 1;
    gRadio.setLayout(layout);
    Button off_button = new Button(gRadio, SWT.RADIO);
    Messages.setLanguageText(off_button, "beta.wizard.off");
    final Button on_button = new Button(gRadio, SWT.RADIO);
    Messages.setLanguageText(on_button, "beta.wizard.on");
    SelectionAdapter l = new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent arg0) {
            wizard.setBetaEnabled(on_button.getSelection());
        }
    };
    off_button.addSelectionListener(l);
    on_button.addSelectionListener(l);
    on_button.setSelection(wizard.getBetaEnabled());
    off_button.setSelection(!wizard.getBetaEnabled());
    LinkLabel forum = new LinkLabel(rootPanel, "beta.wizard.forum", MessageText.getString("beta.wizard.forum.url"));
    Label forum_label = link.getlabel();
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.verticalIndent = 10;
    Utils.setLayoutData(forum_label, gridData);
    Label version_label = new Label(rootPanel, SWT.WRAP);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.verticalIndent = 10;
    Utils.setLayoutData(version_label, gridData);
    version_label.setText(MessageText.getString("beta.wizard.version", new String[] { Constants.AZUREUS_VERSION }));
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) LinkLabel(com.biglybt.ui.swt.components.LinkLabel) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) LinkLabel(com.biglybt.ui.swt.components.LinkLabel) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 9 with LinkLabel

use of com.biglybt.ui.swt.components.LinkLabel in project BiglyBT by BiglySoftware.

the class ConfigView method initSaveButton.

private void initSaveButton() {
    Composite cButtons = new Composite(cConfig, SWT.NONE);
    GridLayout gridLayout = new GridLayout();
    gridLayout.verticalSpacing = gridLayout.marginHeight = 0;
    // gridLayout.horizontalSpacing = gridLayout.verticalSpacing = gridLayout.marginHeight = gridLayout.marginWidth = 0;
    gridLayout.numColumns = 2;
    cButtons.setLayout(gridLayout);
    Utils.setLayoutData(cButtons, new GridData(GridData.FILL_HORIZONTAL));
    GridData gridData;
    LinkLabel ll = new LinkLabel(cButtons, "label.help", Constants.URL_WIKI);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    ll.getlabel().setLayoutData(gridData);
    final Button save = new Button(cButtons, SWT.PUSH);
    // $NON-NLS-1$
    Messages.setLanguageText(save, "ConfigView.button.save");
    gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
    gridData.horizontalSpan = 1;
    gridData.widthHint = 80;
    Utils.setLayoutData(save, gridData);
    save.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent event) {
            // force focusout on osx
            save.setFocus();
            save();
        }
    });
}
Also used : ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) LinkLabel(com.biglybt.ui.swt.components.LinkLabel)

Example 10 with LinkLabel

use of com.biglybt.ui.swt.components.LinkLabel in project BiglyBT by BiglySoftware.

the class PrivacyView method initialize.

private void initialize() {
    if (cMainComposite == null || cMainComposite.isDisposed()) {
        if (parent == null || parent.isDisposed()) {
            return;
        }
        sc = new ScrolledComposite(parent, SWT.V_SCROLL);
        sc.setExpandHorizontal(true);
        sc.setExpandVertical(true);
        sc.getVerticalBar().setIncrement(16);
        Layout parentLayout = parent.getLayout();
        if (parentLayout instanceof GridLayout) {
            GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
            Utils.setLayoutData(sc, gd);
        } else if (parentLayout instanceof FormLayout) {
            Utils.setLayoutData(sc, Utils.getFilledFormData());
        }
        cMainComposite = new Composite(sc, SWT.NONE);
        sc.setContent(cMainComposite);
    } else {
        Utils.disposeComposite(cMainComposite, false);
    }
    GridLayout layout = new GridLayout(1, false);
    layout.horizontalSpacing = 0;
    layout.verticalSpacing = 0;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    cMainComposite.setLayout(layout);
    GridData gd;
    // overview
    Composite overview_comp = new Composite(cMainComposite, SWT.NULL);
    overview_comp.setLayout(new GridLayout(3, false));
    gd = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(overview_comp, gd);
    Label label = new Label(overview_comp, SWT.NULL);
    label.setText(MessageText.getString("privacy.view.intro"));
    LinkLabel link = new LinkLabel(overview_comp, "label.read.more", MessageText.getString("privacy.view.wiki.url"));
    // slider component
    Composite slider_comp = new Composite(cMainComposite, SWT.NULL);
    layout = new GridLayout(3, false);
    layout.horizontalSpacing = 0;
    layout.verticalSpacing = 0;
    layout.marginHeight = 0;
    // layout.marginWidth = 0;
    slider_comp.setLayout(layout);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(slider_comp, gd);
    label = new Label(slider_comp, SWT.NULL);
    label.setText(MessageText.getString("privacy.view.level") + ":");
    Composite slider2_comp = new Composite(slider_comp, SWT.NULL);
    slider2_comp.setLayout(new GridLayout(6, true));
    gd = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(slider2_comp, gd);
    label = new Label(slider2_comp, SWT.NULL);
    label.setText(MessageText.getString("privacy.view.public.only"));
    label = new Label(slider2_comp, SWT.NULL);
    label.setText(MessageText.getString("privacy.view.public.anon"));
    label.setAlignment(SWT.CENTER);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    Utils.setLayoutData(label, gd);
    label = new Label(slider2_comp, SWT.NULL);
    label.setText(MessageText.getString("privacy.view.anon.only"));
    label.setAlignment(SWT.CENTER);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    Utils.setLayoutData(label, gd);
    label = new Label(slider2_comp, SWT.NULL);
    label.setText(MessageText.getString("label.invalid"));
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalAlignment = SWT.END;
    Utils.setLayoutData(label, gd);
    privacy_scale = new Scale(slider2_comp, SWT.HORIZONTAL);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 6;
    Utils.setLayoutData(privacy_scale, gd);
    privacy_scale.setMinimum(0);
    privacy_scale.setMaximum(30);
    final boolean[] slider_mouse_down = { false };
    privacy_scale.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseUp(MouseEvent e) {
            int pos = privacy_scale.getSelection();
            int level = ((pos + 5) / 10);
            if (level * 10 != pos) {
                privacy_scale.setSelection(level * 10);
            }
            setPrivacyLevel(level);
            slider_mouse_down[0] = false;
        }

        @Override
        public void mouseDown(MouseEvent e) {
            slider_mouse_down[0] = true;
        }
    });
    privacy_scale.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(Event event) {
            if (!slider_mouse_down[0]) {
                int pos = privacy_scale.getSelection();
                int level = ((pos + 5) / 10);
                setPrivacyLevel(level);
            }
        }
    });
    // network selection
    Composite network_comp = new Composite(slider_comp, SWT.NULL);
    gd = new GridData();
    Utils.setLayoutData(network_comp, gd);
    network_buttons = new Button[AENetworkClassifier.AT_NETWORKS.length];
    network_comp.setLayout(new GridLayout(1, false));
    label = new Label(network_comp, SWT.NULL);
    label.setText(MessageText.getString("ConfigView.section.connection.group.networks") + ":");
    for (int i = 0; i < network_buttons.length; i++) {
        final String nn = AENetworkClassifier.AT_NETWORKS[i];
        String msg_text = "ConfigView.section.connection.networks." + nn;
        Button button = new Button(network_comp, SWT.CHECK);
        Messages.setLanguageText(button, msg_text);
        network_buttons[i] = button;
        button.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                boolean selected = ((Button) e.widget).getSelection();
                if (current_dm != null) {
                    current_dm.getDownloadState().setNetworkEnabled(nn, selected);
                }
            }
        });
        GridData gridData = new GridData();
        Utils.setLayoutData(button, gridData);
    }
    label = new Label(slider_comp, SWT.NULL);
    final Composite tracker_webseed_comp = new Composite(slider_comp, SWT.NULL);
    layout = new GridLayout(2, true);
    layout.marginTop = layout.marginBottom = layout.marginLeft = layout.marginRight = 1;
    tracker_webseed_comp.setLayout(layout);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    Utils.setLayoutData(tracker_webseed_comp, gd);
    tracker_webseed_comp.addPaintListener(new PaintListener() {

        @Override
        public void paintControl(PaintEvent e) {
            Rectangle client_area = tracker_webseed_comp.getClientArea();
            Rectangle rect = new Rectangle(0, 0, client_area.width - 1, client_area.height - 1);
            e.gc.setAlpha(50);
            e.gc.drawRectangle(rect);
        }
    });
    // Tracker Info
    Composite tracker_comp = new Composite(tracker_webseed_comp, SWT.NULL);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(tracker_comp, gd);
    tracker_comp.setLayout(new GridLayout(2, false));
    label = new Label(tracker_comp, SWT.NULL);
    label.setText(MessageText.getString("label.trackers") + ":");
    tracker_info = new BufferedLabel(tracker_comp, SWT.DOUBLE_BUFFERED);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(tracker_info, gd);
    // Webseed Info
    Composite webseed_comp = new Composite(tracker_webseed_comp, SWT.NULL);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(webseed_comp, gd);
    webseed_comp.setLayout(new GridLayout(2, false));
    label = new Label(webseed_comp, SWT.NULL);
    label.setText(MessageText.getString("label.webseeds") + ":");
    webseed_info = new BufferedLabel(webseed_comp, SWT.DOUBLE_BUFFERED);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(webseed_info, gd);
    // Peer Info
    // label = new Label( slider_comp, SWT.NULL );
    Composite peer_comp = new Composite(tracker_webseed_comp, SWT.NULL);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(peer_comp, gd);
    peer_comp.setLayout(new GridLayout(2, false));
    label = new Label(peer_comp, SWT.NULL);
    label.setText(MessageText.getString("TableColumn.header.peers") + ":");
    peer_info = new BufferedLabel(peer_comp, SWT.DOUBLE_BUFFERED);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(peer_info, gd);
    // I2P install state
    Group i2p_group = new Group(cMainComposite, SWT.NULL);
    i2p_group.setText("I2P");
    // Composite i2p_group = new Composite( cMainComposite, SWT.NULL );
    gd = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(i2p_group, gd);
    i2p_group.setLayout(new GridLayout(4, false));
    label = new Label(i2p_group, SWT.NULL);
    label.setText(MessageText.getString("privacy.view.lookup.info"));
    gd = new GridData();
    gd.horizontalSpan = 2;
    Utils.setLayoutData(label, gd);
    label = new Label(i2p_group, SWT.NULL);
    label.setText(MessageText.getString("label.lookup.status") + ":");
    i2p_result_summary = new BufferedLabel(i2p_group, SWT.DOUBLE_BUFFERED);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    // gd.horizontalIndent = 4;
    Utils.setLayoutData(i2p_result_summary, gd);
    Composite i2p_button_comp = new Composite(i2p_group, SWT.NULL);
    i2p_button_comp.setLayout(new GridLayout(2, false));
    gd = new GridData(GridData.FILL_VERTICAL);
    Utils.setLayoutData(i2p_button_comp, gd);
    label = new Label(i2p_button_comp, SWT.NULL);
    label.setText(MessageText.getString("GeneralView.section.availability"));
    i2p_install_button = new Button(i2p_button_comp, SWT.PUSH);
    i2p_install_button.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent event) {
            final boolean[] result = { false };
            I2PHelpers.installI2PHelper(null, result, new Runnable() {

                @Override
                public void run() {
                    Utils.execSWTThread(new Runnable() {

                        @Override
                        public void run() {
                            updateI2PState();
                        }
                    });
                }
            });
        }
    });
    // I2P peer lookup
    i2p_lookup_comp = new Composite(i2p_group, SWT.BORDER);
    gd = new GridData();
    gd.widthHint = 300;
    gd.heightHint = 150;
    Utils.setLayoutData(i2p_lookup_comp, gd);
    i2p_lookup_comp.setBackground(Colors.white);
    // i2p results
    i2p_result_list = new Text(i2p_group, SWT.BORDER | SWT.READ_ONLY | SWT.V_SCROLL | SWT.WRAP | SWT.NO_FOCUS);
    gd = new GridData(GridData.FILL_BOTH);
    gd.horizontalSpan = 2;
    Utils.setLayoutData(i2p_result_list, gd);
    i2p_result_list.setEditable(false);
    // i2p lookup button
    label = new Label(i2p_button_comp, SWT.NULL);
    label.setText(MessageText.getString("button.lookup.peers"));
    i2p_lookup_button = new Button(i2p_button_comp, SWT.PUSH);
    i2p_lookup_button.setText(MessageText.getString("button.search.dht"));
    i2p_lookup_button.addSelectionListener(new SelectionAdapter() {

        private int search_count;

        @Override
        public void widgetSelected(SelectionEvent event) {
            Utils.disposeComposite(i2p_lookup_comp, false);
            i2p_result_summary.setText("");
            i2p_result_list.setText("");
            PluginInterface i2p_pi = CoreFactory.getSingleton().getPluginManager().getPluginInterfaceByID("azneti2phelper", true);
            if (i2p_pi != null) {
                IPCInterface ipc = i2p_pi.getIPC();
                Map<String, Object> options = new HashMap<>();
                options.put("server_id", "Scraper");
                options.put("server_id_transient", true);
                options.put("ui_composite", i2p_lookup_comp);
                final byte[] hash = (byte[]) i2p_lookup_button.getData("hash");
                search_count++;
                final int search_id = search_count;
                IPCInterface callback = new IPCInterface() {

                    @Override
                    public Object invoke(String methodName, final Object[] params) throws IPCException {
                        if (search_id != search_count) {
                            return (null);
                        }
                        if (methodName.equals("statusUpdate")) {
                            final int status = (Integer) params[0];
                            if (status != TrackerPeerSource.ST_INITIALISING && status != TrackerPeerSource.ST_UPDATING) {
                                Utils.execSWTThread(new Runnable() {

                                    @Override
                                    public void run() {
                                        if (i2p_lookup_button.isDisposed() || hash != i2p_lookup_button.getData("hash")) {
                                            return;
                                        }
                                        i2p_lookup_button.setEnabled(true);
                                        if (i2p_result_list.getText().length() == 0 && status != TrackerPeerSource.ST_UNAVAILABLE) {
                                            i2p_result_summary.setText(MessageText.getString("label.no.peers.found"));
                                        }
                                    }
                                });
                            }
                            if (params.length == 4) {
                                Utils.execSWTThread(new Runnable() {

                                    @Override
                                    public void run() {
                                        if (i2p_result_summary.isDisposed() || hash != i2p_lookup_button.getData("hash")) {
                                            return;
                                        }
                                        int seeds = (Integer) params[1];
                                        int leechers = (Integer) params[2];
                                        int peers = (Integer) params[3];
                                        i2p_result_summary.setText(MessageText.getString("privacy.view.lookup.msg", new String[] { String.valueOf(seeds), String.valueOf(leechers), String.valueOf(peers) }));
                                    }
                                });
                            }
                        } else if (methodName.equals("msgUpdate")) {
                            Utils.execSWTThread(new Runnable() {

                                @Override
                                public void run() {
                                    if (i2p_result_summary.isDisposed() || hash != i2p_lookup_button.getData("hash")) {
                                        return;
                                    }
                                    String msg = (String) params[0];
                                    i2p_result_summary.setText(msg);
                                }
                            });
                        } else if (methodName.equals("peerFound")) {
                            Utils.execSWTThread(new Runnable() {

                                @Override
                                public void run() {
                                    if (i2p_result_list.isDisposed() || hash != i2p_lookup_button.getData("hash")) {
                                        return;
                                    }
                                    String host = (String) params[0];
                                    int peer_type = (Integer) params[1];
                                    i2p_result_list.append(host + "\r\n");
                                }
                            });
                        }
                        return (null);
                    }

                    @Override
                    public boolean canInvoke(String methodName, Object[] params) {
                        return (true);
                    }
                };
                i2p_lookup_button.setEnabled(false);
                i2p_result_summary.setText(MessageText.getString("label.searching"));
                try {
                    ipc.invoke("lookupTorrent", new Object[] { "", hash, options, callback });
                } catch (Throwable e) {
                    i2p_lookup_button.setEnabled(true);
                    e.printStackTrace();
                }
            }
        }
    });
    Label i2p_options_info = new Label(i2p_button_comp, SWT.WRAP);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    gd.widthHint = 150;
    Utils.setLayoutData(i2p_options_info, gd);
    i2p_options_info.setText(MessageText.getString("privacy.view.check.bw.info"));
    if (!COConfigurationManager.getBooleanParameter("privacy.view.check.bw.clicked", false)) {
        FontData fontData = i2p_options_info.getFont().getFontData()[0];
        final Font bold_font = new Font(i2p_options_info.getDisplay(), new FontData(fontData.getName(), fontData.getHeight(), SWT.BOLD));
        i2p_options_info.setFont(bold_font);
        i2p_options_info.addDisposeListener(new DisposeListener() {

            @Override
            public void widgetDisposed(DisposeEvent e) {
                bold_font.dispose();
            }
        });
    }
    i2p_options_link = new Label(i2p_button_comp, SWT.NULL);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    Utils.setLayoutData(i2p_options_link, gd);
    i2p_options_link.setText(MessageText.getString("privacy.view.check.bw"));
    i2p_options_link.setCursor(i2p_options_link.getDisplay().getSystemCursor(SWT.CURSOR_HAND));
    i2p_options_link.setForeground(Colors.blue);
    i2p_options_link.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDoubleClick(MouseEvent arg0) {
            openOptions();
        }

        @Override
        public void mouseUp(MouseEvent arg0) {
            openOptions();
        }

        private void openOptions() {
            COConfigurationManager.setParameter("privacy.view.check.bw.clicked", true);
            UIFunctions uif = UIFunctionsManager.getUIFunctions();
            if (uif != null) {
                uif.getMDI().showEntryByID(MultipleDocumentInterface.SIDEBAR_SECTION_CONFIG, "azi2phelper.name");
            }
        }
    });
    updateI2PState();
    Utils.makeButtonsEqualWidth(Arrays.asList(new Button[] { i2p_install_button, i2p_lookup_button }));
    label = new Label(i2p_button_comp, SWT.NULL);
    gd = new GridData(GridData.FILL_BOTH);
    gd.horizontalSpan = 2;
    Utils.setLayoutData(label, gd);
    Group bottom_comp = new Group(cMainComposite, SWT.NULL);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(bottom_comp, gd);
    bottom_comp.setLayout(new GridLayout(2, false));
    // Torrent Info
    label = new Label(bottom_comp, SWT.NULL);
    label.setText(MessageText.getString("authenticator.torrent") + ":");
    Composite torrent_comp = new Composite(bottom_comp, SWT.NULL);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(torrent_comp, gd);
    torrent_comp.setLayout(removeMarginsAndSpacing(new GridLayout(2, false)));
    torrent_info = new BufferedLabel(torrent_comp, SWT.DOUBLE_BUFFERED);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(torrent_info, gd);
    // source selection
    label = new Label(bottom_comp, SWT.NULL);
    label.setText(MessageText.getString("ConfigView.section.connection.group.peersources") + ":");
    Composite sources_comp = new Composite(bottom_comp, SWT.NULL);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(sources_comp, gd);
    source_buttons = new Button[PEPeerSource.PS_SOURCES.length];
    sources_comp.setLayout(removeMargins(new GridLayout(source_buttons.length + 1, false)));
    for (int i = 0; i < source_buttons.length; i++) {
        final String src = PEPeerSource.PS_SOURCES[i];
        String msg_text = "ConfigView.section.connection.peersource." + src;
        Button button = new Button(sources_comp, SWT.CHECK);
        Messages.setLanguageText(button, msg_text);
        source_buttons[i] = button;
        button.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                boolean selected = ((Button) e.widget).getSelection();
                if (current_dm != null) {
                    current_dm.getDownloadState().setPeerSourceEnabled(src, selected);
                }
            }
        });
        GridData gridData = new GridData();
        Utils.setLayoutData(button, gridData);
    }
    // IP Filter
    label = new Label(bottom_comp, SWT.NULL);
    label.setText(MessageText.getString("label.ip.filter") + ":");
    Composite ipfilter_comp = new Composite(bottom_comp, SWT.NULL);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(ipfilter_comp, gd);
    ipfilter_comp.setLayout(removeMargins(new GridLayout(2, false)));
    ipfilter_enabled = new Button(ipfilter_comp, SWT.CHECK);
    ipfilter_enabled.setText(MessageText.getString("label.enabled"));
    ipfilter_enabled.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            current_dm.getDownloadState().setFlag(DownloadManagerState.FLAG_DISABLE_IP_FILTER, !ipfilter_enabled.getSelection());
        }
    });
    gd = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(ipfilter_enabled, gd);
    // VPN Info
    label = new Label(bottom_comp, SWT.NULL);
    label.setText(MessageText.getString("label.vpn.status") + ":");
    Composite vpn_comp = new Composite(bottom_comp, SWT.NULL);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(vpn_comp, gd);
    vpn_comp.setLayout(removeMargins(new GridLayout(2, false)));
    vpn_info = new BufferedLabel(vpn_comp, SWT.DOUBLE_BUFFERED);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(vpn_info, gd);
    // SOCKS Info
    label = new Label(bottom_comp, SWT.NULL);
    label.setText(MessageText.getString("label.socks.status") + ":");
    Composite socks_comp = new Composite(bottom_comp, SWT.NULL);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(socks_comp, gd);
    socks_comp.setLayout(removeMargins(new GridLayout(10, false)));
    label = new Label(socks_comp, SWT.NULL);
    label.setText(MessageText.getString("label.proxy") + ":");
    socks_state = new BufferedLabel(socks_comp, SWT.DOUBLE_BUFFERED);
    gd = new GridData();
    gd.widthHint = 120;
    Utils.setLayoutData(socks_state, gd);
    // current details
    label = new Label(socks_comp, SWT.NULL);
    label.setText(MessageText.getString("PeersView.state") + ":");
    socks_current = new BufferedLabel(socks_comp, SWT.DOUBLE_BUFFERED);
    gd = new GridData();
    gd.widthHint = 120;
    Utils.setLayoutData(socks_current, gd);
    // fail details
    label = new Label(socks_comp, SWT.NULL);
    label.setText(MessageText.getString("label.fails") + ":");
    socks_fails = new BufferedLabel(socks_comp, SWT.DOUBLE_BUFFERED);
    gd = new GridData();
    gd.widthHint = 120;
    Utils.setLayoutData(socks_fails, gd);
    // more info
    label = new Label(socks_comp, SWT.NULL);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING;
    socks_more = new Label(socks_comp, SWT.NULL);
    socks_more.setText(MessageText.getString("label.more") + "...");
    Utils.setLayoutData(socks_more, gd);
    socks_more.setCursor(socks_more.getDisplay().getSystemCursor(SWT.CURSOR_HAND));
    socks_more.setForeground(Colors.blue);
    socks_more.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDoubleClick(MouseEvent arg0) {
            showSOCKSInfo();
        }

        @Override
        public void mouseUp(MouseEvent arg0) {
            showSOCKSInfo();
        }
    });
    // the rest
    sc.addControlListener(new ControlAdapter() {

        @Override
        public void controlResized(ControlEvent e) {
            Rectangle r = sc.getClientArea();
            Point size = cMainComposite.computeSize(r.width, SWT.DEFAULT);
            sc.setMinSize(size);
        }
    });
    swt_updateFields(null, current_dm);
    updatePeersEtc(current_dm);
    updateVPNSocks();
    Rectangle r = sc.getClientArea();
    Point size = cMainComposite.computeSize(r.width, SWT.DEFAULT);
    sc.setMinSize(size);
    Utils.relayout(cMainComposite);
}
Also used : TOTorrentAnnounceURLGroup(com.biglybt.core.torrent.TOTorrentAnnounceURLGroup) DownloadManagerStateAttributeListener(com.biglybt.core.download.DownloadManagerStateAttributeListener) UISWTViewCoreEventListener(com.biglybt.ui.swt.pifimpl.UISWTViewCoreEventListener) BufferedLabel(com.biglybt.ui.swt.components.BufferedLabel) BufferedLabel(com.biglybt.ui.swt.components.BufferedLabel) LinkLabel(com.biglybt.ui.swt.components.LinkLabel) Rectangle(org.eclipse.swt.graphics.Rectangle) Font(org.eclipse.swt.graphics.Font) UIFunctions(com.biglybt.ui.UIFunctions) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) IPCInterface(com.biglybt.pif.ipc.IPCInterface) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) PluginInterface(com.biglybt.pif.PluginInterface) FontData(org.eclipse.swt.graphics.FontData) IPCException(com.biglybt.pif.ipc.IPCException) MessageText(com.biglybt.core.internat.MessageText) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point) LinkLabel(com.biglybt.ui.swt.components.LinkLabel) SWTRunnable(com.biglybt.ui.swt.utils.SWTRunnable) AERunnable(com.biglybt.core.util.AERunnable) UISWTViewEvent(com.biglybt.ui.swt.pif.UISWTViewEvent)

Aggregations

LinkLabel (com.biglybt.ui.swt.components.LinkLabel)16 GridData (org.eclipse.swt.layout.GridData)11 GridLayout (org.eclipse.swt.layout.GridLayout)11 Composite (org.eclipse.swt.widgets.Composite)8 Label (org.eclipse.swt.widgets.Label)8 MessageText (com.biglybt.core.internat.MessageText)6 Point (org.eclipse.swt.graphics.Point)4 UIInputReceiverListener (com.biglybt.pif.ui.UIInputReceiverListener)3 UIManagerEvent (com.biglybt.pif.ui.UIManagerEvent)3 UserPrompterResultListener (com.biglybt.ui.UserPrompterResultListener)3 BufferedLabel (com.biglybt.ui.swt.components.BufferedLabel)3 StyledText (org.eclipse.swt.custom.StyledText)3 Control (org.eclipse.swt.widgets.Control)3 AERunnable (com.biglybt.core.util.AERunnable)2 PluginInterface (com.biglybt.pif.PluginInterface)2 PlatformManager (com.biglybt.platform.PlatformManager)2 ImageLoader (com.biglybt.ui.swt.imageloader.ImageLoader)2 File (java.io.File)2 ArrayList (java.util.ArrayList)2 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)2