Search in sources :

Example 11 with BufferedLabel

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

the class GeneralView method swt_refreshInfo.

private void swt_refreshInfo() {
    if (manager == null || parent == null || parent.isDisposed()) {
        ViewUtils.setViewRequiresOneDownload(genComposite);
        return;
    }
    Utils.disposeComposite(genComposite, false);
    piecesStateCache = new int[manager.getNbPieces()];
    piecesStateSkippedMarker = 0;
    piecesStateFileBoundariesDone = false;
    this.display = parent.getDisplay();
    gFile = new Composite(genComposite, SWT.SHADOW_OUT);
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(gFile, gridData);
    GridLayout fileLayout = new GridLayout();
    fileLayout.marginHeight = 0;
    fileLayout.marginWidth = 10;
    fileLayout.numColumns = 3;
    gFile.setLayout(fileLayout);
    Label piecesInfo = new Label(gFile, SWT.LEFT);
    Messages.setLanguageText(piecesInfo, "GeneralView.section.downloaded");
    gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
    Utils.setLayoutData(piecesInfo, gridData);
    piecesImage = new Canvas(gFile, SWT.DOUBLE_BUFFERED);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.widthHint = 150;
    gridData.heightHint = 25;
    Utils.setLayoutData(piecesImage, gridData);
    piecesPercent = new BufferedLabel(gFile, SWT.RIGHT | SWT.DOUBLE_BUFFERED);
    gridData = new GridData(GridData.HORIZONTAL_ALIGN_END);
    gridData.widthHint = 50;
    Utils.setLayoutData(piecesPercent, gridData);
    Label availabilityInfo = new Label(gFile, SWT.LEFT);
    Messages.setLanguageText(availabilityInfo, "GeneralView.section.availability");
    gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
    Utils.setLayoutData(availabilityInfo, gridData);
    availabilityImage = new Canvas(gFile, SWT.DOUBLE_BUFFERED);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.widthHint = 150;
    gridData.heightHint = 25;
    Utils.setLayoutData(availabilityImage, gridData);
    Messages.setLanguageText(availabilityImage, "GeneralView.label.status.pieces_available.tooltip");
    availabilityPercent = new BufferedLabel(gFile, SWT.RIGHT | SWT.DOUBLE_BUFFERED);
    gridData = new GridData(GridData.HORIZONTAL_ALIGN_END);
    gridData.widthHint = 50;
    Utils.setLayoutData(availabilityPercent, gridData);
    Messages.setLanguageText(availabilityPercent.getWidget(), "GeneralView.label.status.pieces_available.tooltip");
    gTransfer = new Group(genComposite, SWT.SHADOW_OUT);
    // $NON-NLS-1$
    Messages.setLanguageText(gTransfer, "GeneralView.section.transfer");
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(gTransfer, gridData);
    GridLayout layoutTransfer = new GridLayout();
    layoutTransfer.numColumns = 6;
    gTransfer.setLayout(layoutTransfer);
    Label label = new Label(gTransfer, SWT.LEFT);
    // $NON-NLS-1$
    Messages.setLanguageText(label, "GeneralView.label.timeelapsed");
    timeElapsed = new BufferedLabel(gTransfer, SWT.LEFT | SWT.DOUBLE_BUFFERED);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(timeElapsed, gridData);
    label = new Label(gTransfer, SWT.LEFT);
    // $NON-NLS-1$
    Messages.setLanguageText(label, "GeneralView.label.remaining");
    timeRemaining = new BufferedLabel(gTransfer, SWT.LEFT | SWT.DOUBLE_BUFFERED);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(timeRemaining, gridData);
    // $NON-NLS-1$
    label = new Label(gTransfer, SWT.LEFT);
    Messages.setLanguageText(label, "GeneralView.label.shareRatio");
    // $NON-NLS-1$
    shareRatio = new BufferedLabel(gTransfer, SWT.LEFT | SWT.DOUBLE_BUFFERED);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(shareRatio, gridData);
    label = new Label(gTransfer, SWT.LEFT);
    // $NON-NLS-1$
    Messages.setLanguageText(label, "GeneralView.label.downloaded");
    download = new BufferedLabel(gTransfer, SWT.LEFT | SWT.DOUBLE_BUFFERED);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(download, gridData);
    label = new Label(gTransfer, SWT.LEFT);
    // $NON-NLS-1$
    Messages.setLanguageText(label, "GeneralView.label.downloadspeed");
    downloadSpeed = new BufferedLabel(gTransfer, SWT.LEFT | SWT.DOUBLE_BUFFERED);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(downloadSpeed, gridData);
    // $NON-NLS-1$
    label = new Label(gTransfer, SWT.LEFT);
    Messages.setLanguageText(label, "GeneralView.label.hashfails");
    // $NON-NLS-1$
    hashFails = new BufferedLabel(gTransfer, SWT.LEFT);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(hashFails, gridData);
    label = new Label(gTransfer, SWT.LEFT);
    // $NON-NLS-1$
    Messages.setLanguageText(label, "GeneralView.label.uploaded");
    upload = new BufferedLabel(gTransfer, SWT.LEFT | SWT.DOUBLE_BUFFERED);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(upload, gridData);
    label = new Label(gTransfer, SWT.LEFT);
    // $NON-NLS-1$
    Messages.setLanguageText(label, "GeneralView.label.uploadspeed");
    uploadSpeed = new BufferedLabel(gTransfer, SWT.LEFT | SWT.DOUBLE_BUFFERED);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalSpan = 3;
    Utils.setLayoutData(uploadSpeed, gridData);
    // blah
    label = new Label(gTransfer, SWT.LEFT);
    Messages.setLanguageText(label, "GeneralView.label.seeds");
    seeds = new BufferedLabel(gTransfer, SWT.LEFT | SWT.DOUBLE_BUFFERED);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(seeds, gridData);
    label = new Label(gTransfer, SWT.LEFT);
    Messages.setLanguageText(label, "GeneralView.label.peers");
    peers = new BufferedLabel(gTransfer, SWT.LEFT | SWT.DOUBLE_BUFFERED);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(peers, gridData);
    label = new Label(gTransfer, SWT.LEFT);
    Messages.setLanguageText(label, "GeneralView.label.completed");
    completedLbl = new BufferedLabel(gTransfer, SWT.LEFT | SWT.DOUBLE_BUFFERED);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(completedLbl, gridData);
    label = new Label(gTransfer, SWT.LEFT);
    Messages.setLanguageText(label, "GeneralView.label.totalspeed");
    totalSpeed = new BufferedLabel(gTransfer, SWT.LEFT | SWT.DOUBLE_BUFFERED);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(totalSpeed, gridData);
    label = new Label(gTransfer, SWT.LEFT);
    Messages.setLanguageText(label, "GeneralView.label.swarm_average_completion");
    ave_completion = new BufferedLabel(gTransfer, SWT.LEFT | SWT.DOUBLE_BUFFERED);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(ave_completion, gridData);
    label = new Label(gTransfer, SWT.LEFT);
    Messages.setLanguageText(label, "GeneralView.label.distributedCopies");
    distributedCopies = new BufferedLabel(gTransfer, SWT.LEFT | SWT.DOUBLE_BUFFERED);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(distributedCopies, gridData);
    // //////////////////////
    gInfo = new Group(genComposite, SWT.SHADOW_OUT);
    Messages.setLanguageText(gInfo, "GeneralView.section.info");
    gridData = new GridData(GridData.FILL_BOTH);
    Utils.setLayoutData(gInfo, gridData);
    GridLayout layoutInfo = new GridLayout();
    layoutInfo.numColumns = 4;
    gInfo.setLayout(layoutInfo);
    label = new Label(gInfo, SWT.LEFT);
    // $NON-NLS-1$
    Messages.setLanguageText(label, "GeneralView.label.filename");
    fileName = new BufferedLabel(gInfo, SWT.LEFT);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(fileName, gridData);
    label = new Label(gInfo, SWT.LEFT);
    // $NON-NLS-1$
    Messages.setLanguageText(label, "GeneralView.label.status");
    torrentStatus = new BufferedLabel(gInfo, SWT.LEFT);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(torrentStatus, gridData);
    label = new Label(gInfo, SWT.LEFT);
    // $NON-NLS-1$
    Messages.setLanguageText(label, "GeneralView.label.savein");
    saveIn = new BufferedLabel(gInfo, SWT.LEFT);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalSpan = 3;
    Utils.setLayoutData(saveIn, gridData);
    label = new Label(gInfo, SWT.LEFT);
    // $NON-NLS-1$
    Messages.setLanguageText(label, "GeneralView.label.totalsize");
    fileSize = new BufferedLabel(gInfo, SWT.LEFT);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(fileSize, gridData);
    label = new Label(gInfo, SWT.LEFT);
    // $NON-NLS-1$
    Messages.setLanguageText(label, "GeneralView.label.numberofpieces");
    pieceNumber = new BufferedLabel(gInfo, SWT.LEFT);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(pieceNumber, gridData);
    label = new Label(gInfo, SWT.LEFT);
    // $NON-NLS-1$
    Messages.setLanguageText(label, "GeneralView.label.hash");
    hash = new BufferedLabel(gInfo, SWT.LEFT);
    Messages.setLanguageText(hash.getWidget(), "GeneralView.label.hash.tooltip", true);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(hash, gridData);
    // click on hash -> copy to clipboard
    hash.setCursor(display.getSystemCursor(SWT.CURSOR_HAND));
    hash.setForeground(Colors.blue);
    label.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDoubleClick(MouseEvent arg0) {
            String hash_str = hash.getText();
            if (hash_str != null && hash_str.length() != 0)
                new Clipboard(display).setContents(new Object[] { hash_str.replaceAll(" ", "") }, new Transfer[] { TextTransfer.getInstance() });
        }

        @Override
        public void mouseDown(MouseEvent arg0) {
            String hash_str = hash.getText();
            if (hash_str != null && hash_str.length() != 0)
                new Clipboard(display).setContents(new Object[] { hash_str.replaceAll(" ", "") }, new Transfer[] { TextTransfer.getInstance() });
        }
    });
    hash.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDoubleClick(MouseEvent arg0) {
            String hash_str = hash.getText();
            if (hash_str != null && hash_str.length() != 0)
                new Clipboard(display).setContents(new Object[] { hash_str.replaceAll(" ", "") }, new Transfer[] { TextTransfer.getInstance() });
        }

        @Override
        public void mouseDown(MouseEvent arg0) {
            String hash_str = hash.getText();
            if (hash_str != null && hash_str.length() != 0)
                new Clipboard(display).setContents(new Object[] { hash_str.replaceAll(" ", "") }, new Transfer[] { TextTransfer.getInstance() });
        }
    });
    label = new Label(gInfo, SWT.LEFT);
    Messages.setLanguageText(label, "GeneralView.label.size");
    pieceSize = new BufferedLabel(gInfo, SWT.LEFT);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(pieceSize, gridData);
    label = new Label(gInfo, SWT.LEFT);
    Messages.setLanguageText(label, "GeneralView.label.creationdate");
    creation_date = new BufferedLabel(gInfo, SWT.LEFT);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(creation_date, gridData);
    label = new Label(gInfo, SWT.LEFT);
    Messages.setLanguageText(label, "GeneralView.label.private");
    privateStatus = new BufferedLabel(gInfo, SWT.LEFT);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(privateStatus, gridData);
    // empty row
    label = new Label(gInfo, SWT.LEFT);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalSpan = 4;
    Utils.setLayoutData(label, gridData);
    label = new Label(gInfo, SWT.LEFT);
    label.setCursor(display.getSystemCursor(SWT.CURSOR_HAND));
    label.setForeground(Colors.blue);
    Messages.setLanguageText(label, "GeneralView.label.user_comment");
    try {
        user_comment = new Link(gInfo, SWT.LEFT | SWT.WRAP);
        ((Link) user_comment).addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                Utils.launch(e.text);
            }
        });
    } catch (Throwable e) {
        user_comment = new Label(gInfo, SWT.LEFT | SWT.WRAP);
    }
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalSpan = 3;
    Utils.setLayoutData(user_comment, gridData);
    label.addMouseListener(new MouseAdapter() {

        private void editComment() {
            TorrentUtil.promptUserForComment(new DownloadManager[] { manager });
        }

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

        @Override
        public void mouseDown(MouseEvent arg0) {
            editComment();
        }
    });
    label = new Label(gInfo, SWT.LEFT);
    gridData = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
    Utils.setLayoutData(label, gridData);
    Messages.setLanguageText(label, "GeneralView.label.comment");
    try {
        lblComment = new Link(gInfo, SWT.LEFT | SWT.WRAP);
        ((Link) lblComment).addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                Utils.launch(e.text);
            }
        });
    } catch (Throwable e) {
        lblComment = new Label(gInfo, SWT.LEFT | SWT.WRAP);
    }
    gridData = new GridData(GridData.FILL_BOTH);
    gridData.horizontalSpan = 3;
    Utils.setLayoutData(lblComment, gridData);
    piecesImage.addListener(SWT.Paint, new Listener() {

        @Override
        public void handleEvent(Event e) {
            if (pImage == null || pImage.isDisposed()) {
                return;
            }
            e.gc.drawImage(pImage, 0, 0);
        }
    });
    availabilityImage.addListener(SWT.Paint, new Listener() {

        @Override
        public void handleEvent(Event e) {
            if (aImage == null || aImage.isDisposed()) {
                return;
            }
            e.gc.drawImage(aImage, 0, 0);
        }
    });
    genComposite.layout();
    updateAvailability();
    updatePiecesInfo(true);
    Utils.updateScrolledComposite(scrolled_comp);
// Utils.changeBackgroundComposite(genComposite,MainWindow.getWindow().getBackground());
}
Also used : Group(org.eclipse.swt.widgets.Group) BufferedLabel(com.biglybt.ui.swt.components.BufferedLabel) MouseEvent(org.eclipse.swt.events.MouseEvent) UIPluginViewToolBarListener(com.biglybt.pif.ui.UIPluginViewToolBarListener) ParameterListener(com.biglybt.core.config.ParameterListener) Listener(org.eclipse.swt.widgets.Listener) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) Canvas(org.eclipse.swt.widgets.Canvas) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) BufferedLabel(com.biglybt.ui.swt.components.BufferedLabel) Label(org.eclipse.swt.widgets.Label) MouseAdapter(org.eclipse.swt.events.MouseAdapter) DownloadManager(com.biglybt.core.download.DownloadManager) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) MouseEvent(org.eclipse.swt.events.MouseEvent) Event(org.eclipse.swt.widgets.Event) UISWTViewEvent(com.biglybt.ui.swt.pif.UISWTViewEvent) ControlEvent(org.eclipse.swt.events.ControlEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Clipboard(org.eclipse.swt.dnd.Clipboard) Link(org.eclipse.swt.widgets.Link)

Example 12 with BufferedLabel

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

the class ViewQuickNetInfo method initialize.

private void initialize(Composite parent) {
    parent.setLayout(new GridLayout());
    composite = new Composite(parent, SWT.BORDER);
    GridData gridData = new GridData(GridData.FILL_BOTH);
    Utils.setLayoutData(composite, gridData);
    GridLayout layout = new GridLayout(4, false);
    composite.setLayout(layout);
    // ASN
    Label label = new Label(composite, SWT.NONE);
    Messages.setLanguageText(label, "SpeedView.stats.asn");
    asn = new BufferedLabel(composite, SWT.NONE);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(asn, gridData);
    // IP
    label = new Label(composite, SWT.NONE);
    Messages.setLanguageText(label, "label.current_ip");
    current_ip = new BufferedLabel(composite, SWT.NONE);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(current_ip, gridData);
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) BufferedLabel(com.biglybt.ui.swt.components.BufferedLabel) GridData(org.eclipse.swt.layout.GridData) BufferedLabel(com.biglybt.ui.swt.components.BufferedLabel)

Example 13 with BufferedLabel

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

the class ViewQuickNotifications method initialize.

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

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

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

Example 14 with BufferedLabel

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

the class BuddyPluginViewBetaChat method buildSupport2.

private void buildSupport2(Composite parent) {
    boolean public_chat = !chat.isPrivateChat();
    if (chat.getViewType() == BuddyPluginBeta.VIEW_TYPE_DEFAULT || chat.isReadOnly()) {
        GridLayout layout = new GridLayout();
        layout.numColumns = 2;
        layout.marginHeight = 0;
        layout.marginWidth = 0;
        parent.setLayout(layout);
        GridData grid_data = new GridData(GridData.FILL_BOTH);
        Utils.setLayoutData(parent, grid_data);
        Composite sash_area = new Composite(parent, SWT.NONE);
        layout = new GridLayout();
        layout.numColumns = 1;
        layout.marginHeight = 0;
        layout.marginWidth = 0;
        sash_area.setLayout(layout);
        grid_data = new GridData(GridData.FILL_BOTH);
        grid_data.horizontalSpan = 2;
        Utils.setLayoutData(sash_area, grid_data);
        final SashForm sash = new SashForm(sash_area, SWT.HORIZONTAL);
        grid_data = new GridData(GridData.FILL_BOTH);
        Utils.setLayoutData(sash, grid_data);
        final Composite lhs = new Composite(sash, SWT.NONE);
        layout = new GridLayout();
        layout.numColumns = 2;
        layout.marginHeight = 0;
        layout.marginWidth = 0;
        layout.marginTop = 4;
        layout.marginLeft = 4;
        lhs.setLayout(layout);
        grid_data = new GridData(GridData.FILL_BOTH);
        grid_data.widthHint = 300;
        Utils.setLayoutData(lhs, grid_data);
        buildStatus(parent, lhs);
        Composite log_holder = buildFTUX(lhs, SWT.BORDER);
        // LOG panel
        layout = new GridLayout();
        layout.numColumns = 1;
        layout.marginHeight = 0;
        layout.marginWidth = 0;
        layout.marginLeft = 4;
        log_holder.setLayout(layout);
        // grid_data = new GridData(GridData.FILL_BOTH );
        // grid_data.horizontalSpan = 2;
        // Utils.setLayoutData(log_holder, grid_data);
        log = new StyledText(log_holder, SWT.READ_ONLY | SWT.V_SCROLL | SWT.WRAP | SWT.NO_FOCUS);
        grid_data = new GridData(GridData.FILL_BOTH);
        grid_data.horizontalSpan = 1;
        // grid_data.horizontalIndent = 4;
        Utils.setLayoutData(log, grid_data);
        // log.setIndent( 4 );
        log.setEditable(false);
        log_holder.setBackground(log.getBackground());
        final Menu log_menu = new Menu(log);
        log.setMenu(log_menu);
        log.addMenuDetectListener(new MenuDetectListener() {

            @Override
            public void menuDetected(MenuDetectEvent e) {
                e.doit = false;
                boolean handled = false;
                for (MenuItem mi : log_menu.getItems()) {
                    mi.dispose();
                }
                try {
                    Point mapped = log.getDisplay().map(null, log, new Point(e.x, e.y));
                    int offset = log.getOffsetAtLocation(mapped);
                    final StyleRange sr = log.getStyleRangeAtOffset(offset);
                    if (sr != null) {
                        Object data = sr.data;
                        if (data instanceof ChatParticipant) {
                            ChatParticipant cp = (ChatParticipant) data;
                            List<ChatParticipant> cps = new ArrayList<>();
                            cps.add(cp);
                            buildParticipantMenu(log_menu, cps);
                            handled = true;
                        } else if (data instanceof String) {
                            String url_str = (String) sr.data;
                            String str = url_str;
                            if (str.length() > 50) {
                                str = str.substring(0, 50) + "...";
                            }
                            if (chat.isAnonymous() && url_str.toLowerCase(Locale.US).startsWith("magnet:")) {
                                String[] magnet_uri = { url_str };
                                Set<String> networks = UrlUtils.extractNetworks(magnet_uri);
                                String i2p_only_uri = magnet_uri[0] + "&net=" + UrlUtils.encode(AENetworkClassifier.AT_I2P);
                                String i2p_only_str = i2p_only_uri;
                                if (i2p_only_str.length() > 50) {
                                    i2p_only_str = i2p_only_str.substring(0, 50) + "...";
                                }
                                i2p_only_str = lu.getLocalisedMessageText("azbuddy.dchat.open.i2p.magnet") + ": " + i2p_only_str;
                                final MenuItem mi_open_i2p_vuze = new MenuItem(log_menu, SWT.PUSH);
                                mi_open_i2p_vuze.setText(i2p_only_str);
                                mi_open_i2p_vuze.setData(i2p_only_uri);
                                mi_open_i2p_vuze.addSelectionListener(new SelectionAdapter() {

                                    @Override
                                    public void widgetSelected(SelectionEvent e) {
                                        String url_str = (String) mi_open_i2p_vuze.getData();
                                        if (url_str != null) {
                                            TorrentOpener.openTorrent(url_str);
                                        }
                                    }
                                });
                                if (networks.size() == 1 && networks.iterator().next() == AENetworkClassifier.AT_I2P) {
                                // already done above
                                } else {
                                    str = lu.getLocalisedMessageText("azbuddy.dchat.open.magnet") + ": " + str;
                                    final MenuItem mi_open_vuze = new MenuItem(log_menu, SWT.PUSH);
                                    mi_open_vuze.setText(str);
                                    mi_open_vuze.setData(url_str);
                                    mi_open_vuze.addSelectionListener(new SelectionAdapter() {

                                        @Override
                                        public void widgetSelected(SelectionEvent e) {
                                            String url_str = (String) mi_open_vuze.getData();
                                            if (url_str != null) {
                                                TorrentOpener.openTorrent(url_str);
                                            }
                                        }
                                    });
                                }
                            } else {
                                str = lu.getLocalisedMessageText("azbuddy.dchat.open.in.vuze") + ": " + str;
                                final MenuItem mi_open_vuze = new MenuItem(log_menu, SWT.PUSH);
                                mi_open_vuze.setText(str);
                                mi_open_vuze.setData(url_str);
                                mi_open_vuze.addSelectionListener(new SelectionAdapter() {

                                    @Override
                                    public void widgetSelected(SelectionEvent e) {
                                        String url_str = (String) mi_open_vuze.getData();
                                        if (url_str != null) {
                                            String lc_url_str = url_str.toLowerCase(Locale.US);
                                            if (lc_url_str.startsWith("chat:")) {
                                                try {
                                                    beta.handleURI(url_str, true);
                                                } catch (Throwable f) {
                                                    Debug.out(f);
                                                }
                                            } else {
                                                TorrentOpener.openTorrent(url_str);
                                            }
                                        }
                                    }
                                });
                            }
                            final MenuItem mi_open_ext = new MenuItem(log_menu, SWT.PUSH);
                            mi_open_ext.setText(lu.getLocalisedMessageText("azbuddy.dchat.open.in.browser"));
                            mi_open_ext.addSelectionListener(new SelectionAdapter() {

                                @Override
                                public void widgetSelected(SelectionEvent e) {
                                    String url_str = (String) mi_open_ext.getData();
                                    Utils.launch(url_str);
                                }
                            });
                            new MenuItem(log_menu, SWT.SEPARATOR);
                            if (chat.isAnonymous() && url_str.toLowerCase(Locale.US).startsWith("magnet:")) {
                                String[] magnet_uri = { url_str };
                                Set<String> networks = UrlUtils.extractNetworks(magnet_uri);
                                String i2p_only_uri = magnet_uri[0] + "&net=" + UrlUtils.encode(AENetworkClassifier.AT_I2P);
                                final MenuItem mi_copy_i2p_clip = new MenuItem(log_menu, SWT.PUSH);
                                mi_copy_i2p_clip.setText(lu.getLocalisedMessageText("azbuddy.dchat.copy.i2p.magnet"));
                                mi_copy_i2p_clip.setData(i2p_only_uri);
                                mi_copy_i2p_clip.addSelectionListener(new SelectionAdapter() {

                                    @Override
                                    public void widgetSelected(SelectionEvent e) {
                                        String url_str = (String) mi_copy_i2p_clip.getData();
                                        if (url_str != null) {
                                            ClipboardCopy.copyToClipBoard(url_str);
                                        }
                                    }
                                });
                                if (networks.size() == 1 && networks.iterator().next() == AENetworkClassifier.AT_I2P) {
                                // already done above
                                } else {
                                    final MenuItem mi_copy_clip = new MenuItem(log_menu, SWT.PUSH);
                                    mi_copy_clip.setText(lu.getLocalisedMessageText("azbuddy.dchat.copy.magnet"));
                                    mi_copy_clip.setData(url_str);
                                    mi_copy_clip.addSelectionListener(new SelectionAdapter() {

                                        @Override
                                        public void widgetSelected(SelectionEvent e) {
                                            String url_str = (String) mi_copy_clip.getData();
                                            if (url_str != null) {
                                                ClipboardCopy.copyToClipBoard(url_str);
                                            }
                                        }
                                    });
                                }
                            } else {
                                final MenuItem mi_copy_clip = new MenuItem(log_menu, SWT.PUSH);
                                mi_copy_clip.setText(lu.getLocalisedMessageText("label.copy.to.clipboard"));
                                mi_copy_clip.setData(url_str);
                                mi_copy_clip.addSelectionListener(new SelectionAdapter() {

                                    @Override
                                    public void widgetSelected(SelectionEvent e) {
                                        String url_str = (String) mi_copy_clip.getData();
                                        if (url_str != null) {
                                            ClipboardCopy.copyToClipBoard(url_str);
                                        }
                                    }
                                });
                            }
                            if (url_str.toLowerCase().startsWith("http")) {
                                mi_open_ext.setData(url_str);
                                mi_open_ext.setEnabled(true);
                            } else {
                                mi_open_ext.setEnabled(false);
                            }
                            handled = true;
                        } else {
                            if (Constants.isCVSVersion()) {
                                if (sr instanceof MyStyleRange) {
                                    final MyStyleRange msr = (MyStyleRange) sr;
                                    MenuItem item = new MenuItem(log_menu, SWT.NONE);
                                    item.setText(MessageText.getString("label.copy.to.clipboard"));
                                    item.addSelectionListener(new SelectionAdapter() {

                                        @Override
                                        public void widgetSelected(SelectionEvent e) {
                                            ClipboardCopy.copyToClipBoard(msr.message.getMessage());
                                        }
                                    });
                                    handled = true;
                                }
                            }
                        }
                    }
                } catch (Throwable f) {
                }
                if (!handled) {
                    final String text = log.getSelectionText();
                    if (text != null && text.length() > 0) {
                        MenuItem item = new MenuItem(log_menu, SWT.NONE);
                        item.setText(MessageText.getString("label.copy.to.clipboard"));
                        item.addSelectionListener(new SelectionAdapter() {

                            @Override
                            public void widgetSelected(SelectionEvent e) {
                                ClipboardCopy.copyToClipBoard(text);
                            }
                        });
                        handled = true;
                    }
                }
                if (handled) {
                    e.doit = true;
                }
            }
        });
        log.addListener(SWT.MouseDoubleClick, new Listener() {

            @Override
            public void handleEvent(Event e) {
                try {
                    final int offset = log.getOffsetAtLocation(new Point(e.x, e.y));
                    for (int i = 0; i < log_styles.length; i++) {
                        StyleRange sr = log_styles[i];
                        Object data = sr.data;
                        if (data != null && offset >= sr.start && offset < sr.start + sr.length) {
                            boolean anon_chat = chat.isAnonymous();
                            if (data instanceof String) {
                                final String url_str = (String) data;
                                String lc_url_str = url_str.toLowerCase(Locale.US);
                                if (lc_url_str.startsWith("chat:")) {
                                    if (anon_chat && !lc_url_str.startsWith("chat:anon:")) {
                                        return;
                                    }
                                    try {
                                        beta.handleURI(url_str, true);
                                    } catch (Throwable f) {
                                        Debug.out(f);
                                    }
                                } else {
                                    if (anon_chat) {
                                        try {
                                            String host = new URL(lc_url_str).getHost();
                                            if (AENetworkClassifier.categoriseAddress(host) == AENetworkClassifier.AT_PUBLIC) {
                                                return;
                                            }
                                        } catch (Throwable f) {
                                            return;
                                        }
                                    }
                                    if (lc_url_str.contains(".torrent") || UrlUtils.parseTextForMagnets(url_str) != null) {
                                        TorrentOpener.openTorrent(url_str);
                                    } else {
                                        if (url_str.toLowerCase(Locale.US).startsWith("http")) {
                                            // without this backoff we end up with the text widget
                                            // being left in a 'mouse down' state when returning to it :(
                                            Utils.execSWTThreadLater(100, new Runnable() {

                                                @Override
                                                public void run() {
                                                    Utils.launch(url_str);
                                                }
                                            });
                                        } else {
                                            TorrentOpener.openTorrent(url_str);
                                        }
                                    }
                                }
                                log.setSelection(offset);
                                e.doit = false;
                            } else if (data instanceof ChatParticipant) {
                                ChatParticipant participant = (ChatParticipant) data;
                                addNickString(participant);
                            }
                        }
                    }
                } catch (Throwable f) {
                }
            }
        });
        log.addMouseTrackListener(new MouseTrackListener() {

            private StyleRange old_range;

            private StyleRange temp_range;

            private int temp_index;

            @Override
            public void mouseHover(MouseEvent e) {
                boolean active = false;
                try {
                    int offset = log.getOffsetAtLocation(new Point(e.x, e.y));
                    for (int i = 0; i < log_styles.length; i++) {
                        StyleRange sr = log_styles[i];
                        Object data = sr.data;
                        if (data != null && offset >= sr.start && offset < sr.start + sr.length) {
                            if (old_range != null) {
                                if (temp_index < log_styles.length && log_styles[temp_index] == temp_range) {
                                    log_styles[temp_index] = old_range;
                                    old_range = null;
                                }
                            }
                            sr = log_styles[i];
                            String tt_extra = "";
                            if (data instanceof String) {
                                try {
                                    URL url = new URL((String) data);
                                    String query = url.getQuery();
                                    if (query != null) {
                                        String[] bits = query.split("&");
                                        int seeds = -1;
                                        int leechers = -1;
                                        for (String bit : bits) {
                                            String[] temp = bit.split("=");
                                            String lhs = temp[0];
                                            if (lhs.equals("_s")) {
                                                seeds = Integer.parseInt(temp[1]);
                                            } else if (lhs.equals("_l")) {
                                                leechers = Integer.parseInt(temp[1]);
                                            }
                                        }
                                        if (seeds != -1 && leechers != -1) {
                                            tt_extra = ": seeds=" + seeds + ", leechers=" + leechers;
                                        }
                                    }
                                } catch (Throwable f) {
                                }
                            }
                            log.setToolTipText(MessageText.getString("label.right.click.for.options") + tt_extra);
                            StyleRange derp;
                            if (sr instanceof MyStyleRange) {
                                derp = new MyStyleRange((MyStyleRange) sr);
                            } else {
                                derp = new StyleRange(sr);
                            }
                            derp.start = sr.start;
                            derp.length = sr.length;
                            derp.borderStyle = SWT.BORDER_DASH;
                            old_range = sr;
                            temp_range = derp;
                            temp_index = i;
                            log_styles[i] = derp;
                            log.setStyleRanges(log_styles);
                            active = true;
                            break;
                        }
                    }
                } catch (Throwable f) {
                }
                if (!active) {
                    log.setToolTipText("");
                    if (old_range != null) {
                        if (temp_index < log_styles.length && log_styles[temp_index] == temp_range) {
                            log_styles[temp_index] = old_range;
                            old_range = null;
                            log.setStyleRanges(log_styles);
                        }
                    }
                }
            }

            @Override
            public void mouseExit(MouseEvent e) {
            // TODO Auto-generated method stub
            }

            @Override
            public void mouseEnter(MouseEvent e) {
            // TODO Auto-generated method stub
            }
        });
        log.addKeyListener(new KeyAdapter() {

            @Override
            public void keyPressed(KeyEvent event) {
                int key = event.character;
                if (key <= 26 && key > 0) {
                    key += 'a' - 1;
                }
                if (key == 'a' && event.stateMask == SWT.MOD1) {
                    event.doit = false;
                    log.selectAll();
                }
            }
        });
        Composite rhs = new Composite(sash, SWT.NONE);
        layout = new GridLayout();
        layout.numColumns = 1;
        layout.marginHeight = 0;
        layout.marginWidth = 0;
        layout.marginTop = 4;
        layout.marginRight = 4;
        rhs.setLayout(layout);
        grid_data = new GridData(GridData.FILL_VERTICAL);
        int rhs_width = Constants.isWindows ? 150 : 160;
        grid_data.widthHint = rhs_width;
        Utils.setLayoutData(rhs, grid_data);
        // options
        Composite top_right = buildHelp(rhs);
        // nick name
        Composite nick_area = new Composite(top_right, SWT.NONE);
        layout = new GridLayout();
        layout.numColumns = 4;
        layout.marginHeight = 0;
        layout.marginWidth = 0;
        if (!Constants.isWindows) {
            layout.horizontalSpacing = 2;
            layout.verticalSpacing = 2;
        }
        nick_area.setLayout(layout);
        grid_data = new GridData(GridData.FILL_HORIZONTAL);
        grid_data.horizontalSpan = 3;
        Utils.setLayoutData(nick_area, grid_data);
        Label label = new Label(nick_area, SWT.NULL);
        label.setText(lu.getLocalisedMessageText("azbuddy.dchat.nick"));
        grid_data = new GridData();
        // grid_data.horizontalIndent=4;
        Utils.setLayoutData(label, grid_data);
        nickname = new Text(nick_area, SWT.BORDER);
        grid_data = new GridData(GridData.FILL_HORIZONTAL);
        grid_data.horizontalSpan = 1;
        Utils.setLayoutData(nickname, grid_data);
        nickname.setText(chat.getNickname(false));
        nickname.setMessage(chat.getDefaultNickname());
        label = new Label(nick_area, SWT.NULL);
        label.setText(lu.getLocalisedMessageText("label.shared"));
        label.setToolTipText(lu.getLocalisedMessageText("azbuddy.dchat.shared.tooltip"));
        shared_nick_button = new Button(nick_area, SWT.CHECK);
        shared_nick_button.setSelection(chat.isSharedNickname());
        shared_nick_button.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent arg0) {
                boolean shared = shared_nick_button.getSelection();
                chat.setSharedNickname(shared);
            }
        });
        nickname.addListener(SWT.FocusOut, new Listener() {

            @Override
            public void handleEvent(Event event) {
                String nick = nickname.getText().trim();
                if (chat.isSharedNickname()) {
                    if (chat.getNetwork() == AENetworkClassifier.AT_PUBLIC) {
                        beta.setSharedPublicNickname(nick);
                    } else {
                        beta.setSharedAnonNickname(nick);
                    }
                } else {
                    chat.setInstanceNickname(nick);
                }
            }
        });
        table_header_left = new BufferedLabel(top_right, SWT.DOUBLE_BUFFERED);
        grid_data = new GridData(GridData.FILL_HORIZONTAL);
        grid_data.horizontalSpan = 2;
        if (!Constants.isWindows) {
            grid_data.horizontalIndent = 2;
        }
        Utils.setLayoutData(table_header_left, grid_data);
        table_header_left.setText(MessageText.getString("PeersView.state.pending"));
        LinkLabel link = new LinkLabel(top_right, "Views.plugins.azbuddy.title", new Runnable() {

            @Override
            public void run() {
                if (!plugin.isClassicEnabled()) {
                    plugin.setClassicEnabled(true);
                }
                beta.selectClassicTab();
            }
        });
        // table
        buddy_table = new Table(rhs, SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION | SWT.VIRTUAL);
        String[] headers = { "azbuddy.ui.table.name" };
        int[] sizes = { rhs_width - 10 };
        int[] aligns = { SWT.LEFT };
        for (int i = 0; i < headers.length; i++) {
            TableColumn tc = new TableColumn(buddy_table, aligns[i]);
            tc.setWidth(Utils.adjustPXForDPI(sizes[i]));
            Messages.setLanguageText(tc, headers[i]);
        }
        buddy_table.setHeaderVisible(true);
        grid_data = new GridData(GridData.FILL_BOTH);
        // grid_data.heightHint = buddy_table.getHeaderHeight() * 3;
        Utils.setLayoutData(buddy_table, grid_data);
        buddy_table.addListener(SWT.SetData, new Listener() {

            @Override
            public void handleEvent(Event event) {
                TableItem item = (TableItem) event.item;
                setItemData(item);
            }
        });
        final Menu menu = new Menu(buddy_table);
        buddy_table.setMenu(menu);
        menu.addMenuListener(new MenuListener() {

            @Override
            public void menuShown(MenuEvent e) {
                MenuItem[] items = menu.getItems();
                for (int i = 0; i < items.length; i++) {
                    items[i].dispose();
                }
                final TableItem[] selection = buddy_table.getSelection();
                List<ChatParticipant> participants = new ArrayList<>(selection.length);
                for (int i = 0; i < selection.length; i++) {
                    TableItem item = selection[i];
                    ChatParticipant participant = (ChatParticipant) item.getData();
                    if (participant == null) {
                        // item data won't be set yet for items that haven't been
                        // visible...
                        participant = setItemData(item);
                    }
                    if (participant != null) {
                        participants.add(participant);
                    }
                }
                buildParticipantMenu(menu, participants);
            }

            @Override
            public void menuHidden(MenuEvent e) {
            }
        });
        buddy_table.addKeyListener(new KeyAdapter() {

            @Override
            public void keyPressed(KeyEvent event) {
                int key = event.character;
                if (key <= 26 && key > 0) {
                    key += 'a' - 1;
                }
                if (key == 'a' && event.stateMask == SWT.MOD1) {
                    event.doit = false;
                    buddy_table.selectAll();
                }
            }
        });
        buddy_table.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseDoubleClick(MouseEvent e) {
                TableItem[] selection = buddy_table.getSelection();
                if (selection.length != 1) {
                    return;
                }
                TableItem item = selection[0];
                ChatParticipant participant = (ChatParticipant) item.getData();
                addNickString(participant);
            }
        });
        Utils.maintainSashPanelWidth(sash, rhs, new int[] { 700, 300 }, "azbuddy.dchat.ui.sash.pos");
        /*
		    Listener sash_listener=
		    	new Listener()
		    	{
		    		private int	lhs_weight;
		    		private int	lhs_width;
	
			    	public void
					handleEvent(
						Event ev )
					{
			    		if ( ev.widget == lhs ){
	
			    			int[] weights = sash.getWeights();
	
	
			    			if ( lhs_weight != weights[0] ){
	
			    					// sash has moved
	
			    				lhs_weight = weights[0];
	
			    					// keep track of the width
	
			    				lhs_width = lhs.getBounds().width;
			    			}
			    		}else{
	
			    				// resize
	
			    			if ( lhs_width > 0 ){
	
					            int width = sash.getClientArea().width;
	
					            double ratio = (double)lhs_width/width;
	
					            lhs_weight = (int)(ratio*1000 );
	
					            sash.setWeights( new int[]{ lhs_weight, 1000 - lhs_weight });
			    			}
			    		}
				    }
			    };
	
		    lhs.addListener(SWT.Resize, sash_listener );
		    sash.addListener(SWT.Resize, sash_listener );
		    */
        // bottom area
        Composite bottom_area = new Composite(parent, SWT.NULL);
        layout = new GridLayout();
        layout.numColumns = 2;
        layout.marginHeight = 0;
        layout.marginWidth = 0;
        bottom_area.setLayout(layout);
        grid_data = new GridData(GridData.FILL_HORIZONTAL);
        grid_data.horizontalSpan = 2;
        bottom_area.setLayoutData(grid_data);
        // Text
        input_area = new Text(bottom_area, SWT.MULTI | SWT.V_SCROLL | SWT.WRAP | SWT.BORDER);
        grid_data = new GridData(GridData.FILL_HORIZONTAL);
        grid_data.horizontalSpan = 1;
        grid_data.heightHint = 30;
        grid_data.horizontalIndent = 4;
        Utils.setLayoutData(input_area, grid_data);
        // input_area.setIndent( 4 );
        input_area.setTextLimit(MAX_MSG_OVERALL_LENGTH);
        input_area.addVerifyListener(new VerifyListener() {

            @Override
            public void verifyText(VerifyEvent ev) {
                if (ev.text.equals("\t")) {
                    ev.doit = false;
                }
            }
        });
        input_area.addKeyListener(new KeyListener() {

            private LinkedList<String> history = new LinkedList<>();

            private int history_pos = -1;

            private String buffered_message = "";

            @Override
            public void keyPressed(KeyEvent e) {
                if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) {
                    e.doit = false;
                    if ((e.stateMask & SWT.ALT) != 0) {
                        input_area.insert("\n");
                        return;
                    }
                    String message = input_area.getText().trim();
                    if (message.length() > 0) {
                        sendMessage(message, true);
                        history.addFirst(message);
                        if (history.size() > 32) {
                            history.removeLast();
                        }
                        history_pos = -1;
                        buffered_message = "";
                        input_area.setText("");
                        text_cache.put(chat.getNetAndKey(), "");
                    }
                } else if (e.keyCode == SWT.ARROW_UP) {
                    history_pos++;
                    if (history_pos < history.size()) {
                        if (history_pos == 0) {
                            buffered_message = input_area.getText().trim();
                        }
                        String msg = history.get(history_pos);
                        input_area.setText(msg);
                        input_area.setSelection(msg.length());
                    } else {
                        history_pos = history.size() - 1;
                    }
                    e.doit = false;
                } else if (e.keyCode == SWT.ARROW_DOWN) {
                    history_pos--;
                    if (history_pos >= 0) {
                        String msg = history.get(history_pos);
                        input_area.setText(msg);
                        input_area.setSelection(msg.length());
                    } else {
                        if (history_pos == -1) {
                            input_area.setText(buffered_message);
                            if (buffered_message.length() > 0) {
                                input_area.setSelection(buffered_message.length());
                                buffered_message = "";
                            }
                        } else {
                            history_pos = -1;
                        }
                    }
                    e.doit = false;
                } else {
                    if (e.stateMask == SWT.MOD1) {
                        int key = e.character;
                        if (key <= 26 && key > 0) {
                            key += 'a' - 1;
                        }
                        if (key == 'a') {
                            input_area.selectAll();
                        } else if (key == 'b' || key == 'i') {
                            String emp = key == 'b' ? "**" : "*";
                            String sel = input_area.getSelectionText();
                            Point p = input_area.getSelection();
                            while (sel.endsWith(" ")) {
                                sel = sel.substring(0, sel.length() - 1);
                                p.y--;
                            }
                            if (!sel.isEmpty()) {
                                /*
										int[] range = input_area.getSelectionRanges();
										
										int emp_len = emp.length();
										
										if ( sel.startsWith( emp ) && sel.endsWith( emp ) && sel.length() >= emp_len * 2 ){
											
											input_area.replaceTextRange( range[0], range[1], sel.substring(emp_len, sel.length() - emp_len ));
											
											input_area.setSelection( range[0], range[0] + range[1] - emp_len*2 );
											
										}else{
											
											input_area.replaceTextRange( range[0], range[1], emp + sel + emp );
											
											input_area.setSelection( range[0], range[0] + range[1] + emp_len*2 );
										}
										*/
                                int emp_len = emp.length();
                                String text = input_area.getText();
                                if (sel.startsWith(emp) && sel.endsWith(emp) && sel.length() >= emp_len * 2) {
                                    input_area.setText(text.substring(0, p.x) + sel.substring(emp_len, sel.length() - emp_len) + text.substring(p.y));
                                    p.y -= emp_len * 2;
                                } else {
                                    input_area.setText(text.substring(0, p.x) + emp + sel + emp + text.substring(p.y));
                                    p.y += emp_len * 2;
                                }
                                input_area.setSelection(p);
                            }
                        }
                    }
                }
            }

            @Override
            public void keyReleased(KeyEvent e) {
            }
        });
        input_area.addDisposeListener(new DisposeListener() {

            @Override
            public void widgetDisposed(DisposeEvent arg0) {
                if (input_area != null) {
                    String text = input_area.getText();
                    text_cache.put(chat.getNetAndKey(), text);
                }
            }
        });
        String cached_text = text_cache.get(chat.getNetAndKey());
        if (cached_text != null && !cached_text.isEmpty()) {
            input_area.setText(cached_text);
            input_area.setSelection(cached_text.length());
        }
        Composite button_area = new Composite(bottom_area, SWT.NULL);
        layout = new GridLayout();
        layout.numColumns = 1;
        layout.marginHeight = 0;
        layout.marginWidth = 0;
        layout.marginRight = 4;
        button_area.setLayout(layout);
        buildRSSButton(button_area);
        hookFTUXListener();
        if (chat.isReadOnly()) {
            input_area.setText(MessageText.getString("azbuddy.dchat.ro"));
        }
        setInputAvailability(true);
        if (!chat.isReadOnly()) {
            drop_targets = new DropTarget[] { new DropTarget(log, DND.DROP_COPY), new DropTarget(input_area, DND.DROP_COPY) };
            for (DropTarget drop_target : drop_targets) {
                drop_target.setTransfer(new Transfer[] { FixedURLTransfer.getInstance(), FileTransfer.getInstance(), TextTransfer.getInstance() });
                drop_target.addDropListener(new DropTargetAdapter() {

                    @Override
                    public void dropAccept(DropTargetEvent event) {
                        event.currentDataType = FixedURLTransfer.pickBestType(event.dataTypes, event.currentDataType);
                    }

                    @Override
                    public void dragEnter(DropTargetEvent event) {
                    }

                    @Override
                    public void dragOperationChanged(DropTargetEvent event) {
                    }

                    @Override
                    public void dragOver(DropTargetEvent event) {
                        if ((event.operations & DND.DROP_LINK) > 0)
                            event.detail = DND.DROP_LINK;
                        else if ((event.operations & DND.DROP_COPY) > 0)
                            event.detail = DND.DROP_COPY;
                        else if ((event.operations & DND.DROP_DEFAULT) > 0)
                            event.detail = DND.DROP_COPY;
                        event.feedback = DND.FEEDBACK_SELECT | DND.FEEDBACK_SCROLL | DND.FEEDBACK_EXPAND;
                    }

                    @Override
                    public void dragLeave(DropTargetEvent event) {
                    }

                    @Override
                    public void drop(DropTargetEvent event) {
                        handleDrop(event.data, new DropAccepter() {

                            @Override
                            public void accept(String link) {
                                input_area.setText(input_area.getText() + link);
                            }
                        });
                    }
                });
            }
        }
        Control[] focus_controls = { log, input_area, buddy_table, nickname, shared_nick_button };
        Listener focus_listener = new Listener() {

            @Override
            public void handleEvent(Event event) {
                activate();
            }
        };
        for (Control c : focus_controls) {
            c.addListener(SWT.FocusIn, focus_listener);
        }
        BuddyPluginBeta.ChatParticipant[] existing_participants = chat.getParticipants();
        synchronized (participants) {
            participants.addAll(Arrays.asList(existing_participants));
        }
        table_resort_required = true;
        updateTable(false);
        BuddyPluginBeta.ChatMessage[] history = chat.getHistory();
        logChatMessages(history);
        boolean can_popout = shell == null && public_chat;
        if (can_popout && !ftux_ok && !auto_ftux_popout_done) {
            auto_ftux_popout_done = true;
            try {
                createChatWindow(view, plugin, chat.getClone(), true);
            } catch (Throwable e) {
            }
        }
    } else {
        GridLayout layout = new GridLayout();
        layout.numColumns = 2;
        layout.marginHeight = 0;
        layout.marginWidth = 0;
        parent.setLayout(layout);
        GridData grid_data = new GridData(GridData.FILL_BOTH);
        Utils.setLayoutData(parent, grid_data);
        Composite status_area = new Composite(parent, SWT.NULL);
        grid_data = new GridData(GridData.FILL_HORIZONTAL);
        status_area.setLayoutData(grid_data);
        layout = new GridLayout();
        layout.numColumns = 3;
        layout.marginHeight = 0;
        layout.marginWidth = 0;
        layout.marginTop = 4;
        layout.marginLeft = 4;
        status_area.setLayout(layout);
        buildStatus(parent, status_area);
        buildHelp(status_area);
        Composite ftux_parent = new Composite(parent, SWT.NULL);
        layout = new GridLayout();
        layout.numColumns = 2;
        layout.marginHeight = 0;
        layout.marginWidth = 0;
        ftux_parent.setLayout(layout);
        grid_data = new GridData(GridData.FILL_BOTH);
        grid_data.horizontalSpan = 2;
        ftux_parent.setLayoutData(grid_data);
        Composite share_area_holder = buildFTUX(ftux_parent, SWT.NULL);
        layout = new GridLayout();
        layout.numColumns = 1;
        layout.marginHeight = 0;
        layout.marginWidth = 0;
        share_area_holder.setLayout(layout);
        Canvas share_area = new Canvas(share_area_holder, SWT.NO_BACKGROUND);
        grid_data = new GridData(GridData.FILL_BOTH);
        share_area.setLayoutData(grid_data);
        share_area.setBackground(Colors.white);
        share_area.addPaintListener(new PaintListener() {

            @Override
            public void paintControl(PaintEvent e) {
                GC gc = e.gc;
                gc.setAdvanced(true);
                gc.setAntialias(SWT.ON);
                Rectangle bounds = share_area.getBounds();
                int width = bounds.width;
                int height = bounds.height;
                gc.setBackground(Colors.white);
                gc.fillRectangle(0, 0, width, height);
                Rectangle text_area = new Rectangle(50, 50, width - 100, height - 100);
                gc.setLineWidth(8);
                gc.setLineStyle(SWT.LINE_DOT);
                gc.setForeground(Colors.light_grey);
                gc.drawRoundRectangle(40, 40, width - 80, height - 80, 25, 25);
                gc.setForeground(Colors.dark_grey);
                gc.setFont(big_font);
                String msg = MessageText.getString("dchat.share.dnd.info", new String[] { MessageText.getString(chat.getNetwork() == AENetworkClassifier.AT_PUBLIC ? "label.publicly" : "label.anonymously"), chat.getName() });
                GCStringPrinter p = new GCStringPrinter(gc, msg, text_area, 0, SWT.CENTER | SWT.WRAP);
                p.printString();
            }
        });
        input_area = new Text(share_area, SWT.MULTI | SWT.V_SCROLL | SWT.WRAP | SWT.BORDER);
        input_area.setVisible(false);
        hookFTUXListener();
        drop_targets = new DropTarget[] { new DropTarget(share_area, DND.DROP_COPY) };
        for (DropTarget drop_target : drop_targets) {
            drop_target.setTransfer(new Transfer[] { FixedURLTransfer.getInstance(), FileTransfer.getInstance(), TextTransfer.getInstance() });
            drop_target.addDropListener(new DropTargetAdapter() {

                @Override
                public void dropAccept(DropTargetEvent event) {
                    event.currentDataType = FixedURLTransfer.pickBestType(event.dataTypes, event.currentDataType);
                }

                @Override
                public void dragEnter(DropTargetEvent event) {
                }

                @Override
                public void dragOperationChanged(DropTargetEvent event) {
                }

                @Override
                public void dragOver(DropTargetEvent event) {
                    if ((event.operations & DND.DROP_LINK) > 0)
                        event.detail = DND.DROP_LINK;
                    else if ((event.operations & DND.DROP_COPY) > 0)
                        event.detail = DND.DROP_COPY;
                    else if ((event.operations & DND.DROP_DEFAULT) > 0)
                        event.detail = DND.DROP_COPY;
                    event.feedback = DND.FEEDBACK_SELECT | DND.FEEDBACK_SCROLL | DND.FEEDBACK_EXPAND;
                }

                @Override
                public void dragLeave(DropTargetEvent event) {
                }

                @Override
                public void drop(DropTargetEvent event) {
                    if (!chat_available) {
                        MessageBoxShell mb = new MessageBoxShell(MessageText.getString("dchat.share.dnd.wait.title"), MessageText.getString("dchat.share.dnd.wait.text"));
                        mb.setButtons(0, new String[] { MessageText.getString("Button.ok") }, new Integer[] { 0 });
                        mb.open(null);
                        return;
                    }
                    MessageBoxShell mb = new MessageBoxShell(MessageText.getString("dchat.share.dnd.prompt.title"), MessageText.getString("dchat.share.dnd.prompt.text", new String[] { MessageText.getString(chat.getNetwork() == AENetworkClassifier.AT_PUBLIC ? "label.publicly" : "label.anonymously"), chat.getName() }));
                    mb.setRemember("chat.dnd." + chat.getKey(), false, MessageText.getString("MessageBoxWindow.nomoreprompting"));
                    mb.setButtons(0, new String[] { MessageText.getString("Button.yes"), MessageText.getString("Button.no") }, new Integer[] { 0, 1 });
                    mb.setRememberOnlyIfButton(0);
                    mb.open(new UserPrompterResultListener() {

                        @Override
                        public void prompterClosed(int result) {
                            if (result == 0) {
                                handleDrop(event.data, new DropAccepter() {

                                    @Override
                                    public void accept(String link) {
                                        link = link.trim();
                                        sendMessage(link, false);
                                        String rendered = renderMessage(link);
                                        MessageBoxShell mb = new MessageBoxShell(MessageText.getString("dchat.share.dnd.shared.title"), MessageText.getString("dchat.share.dnd.shared.text", new String[] { rendered }));
                                        mb.setButtons(0, new String[] { MessageText.getString("Button.ok") }, new Integer[] { 0 });
                                        mb.open(null);
                                        checkSubscriptions(false);
                                    }
                                });
                            }
                        }
                    });
                }
            });
        }
    }
}
Also used : GCStringPrinter(com.biglybt.ui.swt.shells.GCStringPrinter) MouseTrackListener(org.eclipse.swt.events.MouseTrackListener) KeyAdapter(org.eclipse.swt.events.KeyAdapter) TableItem(org.eclipse.swt.widgets.TableItem) BufferedLabel(com.biglybt.ui.swt.components.BufferedLabel) Label(org.eclipse.swt.widgets.Label) LinkLabel(com.biglybt.ui.swt.components.LinkLabel) Rectangle(org.eclipse.swt.graphics.Rectangle) DisposeEvent(org.eclipse.swt.events.DisposeEvent) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) StyledText(org.eclipse.swt.custom.StyledText) VerifyListener(org.eclipse.swt.events.VerifyListener) PaintListener(org.eclipse.swt.events.PaintListener) Canvas(org.eclipse.swt.widgets.Canvas) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent) TableColumn(org.eclipse.swt.widgets.TableColumn) DropTargetAdapter(org.eclipse.swt.dnd.DropTargetAdapter) MenuDetectEvent(org.eclipse.swt.events.MenuDetectEvent) DropTarget(org.eclipse.swt.dnd.DropTarget) DisposeListener(org.eclipse.swt.events.DisposeListener) UserPrompterResultListener(com.biglybt.ui.UserPrompterResultListener) PaintListener(org.eclipse.swt.events.PaintListener) ControlListener(org.eclipse.swt.events.ControlListener) Listener(org.eclipse.swt.widgets.Listener) UIInputReceiverListener(com.biglybt.pif.ui.UIInputReceiverListener) DisposeListener(org.eclipse.swt.events.DisposeListener) VerifyListener(org.eclipse.swt.events.VerifyListener) MouseTrackListener(org.eclipse.swt.events.MouseTrackListener) MenuListener(org.eclipse.swt.events.MenuListener) MenuDetectListener(org.eclipse.swt.events.MenuDetectListener) KeyListener(org.eclipse.swt.events.KeyListener) BufferedLabel(com.biglybt.ui.swt.components.BufferedLabel) MenuListener(org.eclipse.swt.events.MenuListener) StyleRange(org.eclipse.swt.custom.StyleRange) URL(java.net.URL) KeyEvent(org.eclipse.swt.events.KeyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) Control(org.eclipse.swt.widgets.Control) Menu(org.eclipse.swt.widgets.Menu) GC(org.eclipse.swt.graphics.GC) VerifyEvent(org.eclipse.swt.events.VerifyEvent) MenuEvent(org.eclipse.swt.events.MenuEvent) MouseEvent(org.eclipse.swt.events.MouseEvent) Table(org.eclipse.swt.widgets.Table) PaintEvent(org.eclipse.swt.events.PaintEvent) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) MouseAdapter(org.eclipse.swt.events.MouseAdapter) MessageBoxShell(com.biglybt.ui.swt.shells.MessageBoxShell) MenuItem(org.eclipse.swt.widgets.MenuItem) StyledText(org.eclipse.swt.custom.StyledText) Text(org.eclipse.swt.widgets.Text) MessageText(com.biglybt.core.internat.MessageText) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point) SashForm(org.eclipse.swt.custom.SashForm) UserPrompterResultListener(com.biglybt.ui.UserPrompterResultListener) LinkLabel(com.biglybt.ui.swt.components.LinkLabel) AERunnable(com.biglybt.core.util.AERunnable) GridData(org.eclipse.swt.layout.GridData) MenuDetectListener(org.eclipse.swt.events.MenuDetectListener) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent) MenuEvent(org.eclipse.swt.events.MenuEvent) KeyEvent(org.eclipse.swt.events.KeyEvent) MouseEvent(org.eclipse.swt.events.MouseEvent) MenuDetectEvent(org.eclipse.swt.events.MenuDetectEvent) ControlEvent(org.eclipse.swt.events.ControlEvent) DisposeEvent(org.eclipse.swt.events.DisposeEvent) PaintEvent(org.eclipse.swt.events.PaintEvent) UIManagerEvent(com.biglybt.pif.ui.UIManagerEvent) Event(org.eclipse.swt.widgets.Event) VerifyEvent(org.eclipse.swt.events.VerifyEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) KeyListener(org.eclipse.swt.events.KeyListener)

Example 15 with BufferedLabel

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

the class TorrentOptionsView method initialize.

private void initialize(Composite composite) {
    this.parent = composite;
    GridLayout layout;
    // I don't want to waste my time :) [tux]
    if (panel != null && !panel.isDisposed()) {
        Utils.disposeComposite(panel, false);
    } else {
        panel = new Composite(composite, SWT.NULL);
        layout = new GridLayout();
        layout.marginHeight = 0;
        layout.marginWidth = 0;
        layout.numColumns = 1;
        panel.setLayout(layout);
        Layout parentLayout = parent.getLayout();
        if (parentLayout instanceof FormLayout) {
            Utils.setLayoutData(panel, Utils.getFilledFormData());
        } else {
            Utils.setLayoutData(panel, new GridData(GridData.FILL_BOTH));
        }
    }
    if (managers == null) {
        return;
    }
    int userMode = COConfigurationManager.getIntParameter("User Mode");
    // header
    Composite cHeader = new Composite(panel, SWT.BORDER);
    GridLayout configLayout = new GridLayout();
    configLayout.marginHeight = 3;
    configLayout.marginWidth = 0;
    cHeader.setLayout(configLayout);
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_CENTER);
    Utils.setLayoutData(cHeader, gridData);
    Display d = panel.getDisplay();
    cHeader.setBackground(Colors.getSystemColor(d, SWT.COLOR_LIST_SELECTION));
    cHeader.setForeground(Colors.getSystemColor(d, SWT.COLOR_LIST_SELECTION_TEXT));
    Label lHeader = new Label(cHeader, SWT.NULL);
    lHeader.setBackground(Colors.getSystemColor(d, SWT.COLOR_LIST_SELECTION));
    lHeader.setForeground(Colors.getSystemColor(d, SWT.COLOR_LIST_SELECTION_TEXT));
    FontData[] fontData = lHeader.getFont().getFontData();
    fontData[0].setStyle(SWT.BOLD);
    int fontHeight = (int) (fontData[0].getHeight() * 1.2);
    fontData[0].setHeight(fontHeight);
    headerFont = new Font(d, fontData);
    lHeader.setFont(headerFont);
    if (managers.length == 1) {
        if (managers[0].getDownloadManager() == null) {
            lHeader.setText(" " + managers[0].getName().replaceAll("&", "&&"));
        } else {
            lHeader.setText(" " + MessageText.getString("authenticator.torrent") + " : " + managers[0].getName().replaceAll("&", "&&"));
        }
    } else {
        String str = "";
        for (int i = 0; i < Math.min(3, managers.length); i++) {
            str += (i == 0 ? "" : ", ") + managers[i].getName().replaceAll("&", "&&");
        }
        if (managers.length > 3) {
            str += "...";
        }
        lHeader.setText(" " + managers.length + " " + MessageText.getString("ConfigView.section.torrents") + " : " + str);
    }
    gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_CENTER);
    Utils.setLayoutData(lHeader, gridData);
    Group gTorrentOptions = new Group(panel, SWT.NULL);
    Messages.setLanguageText(gTorrentOptions, "ConfigView.section.transfer");
    gridData = new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL);
    Utils.setLayoutData(gTorrentOptions, gridData);
    layout = new GridLayout();
    layout.numColumns = 2;
    gTorrentOptions.setLayout(layout);
    // Disabled for release. Need to convert from user-specified units to
    // KB/s before restoring the following line
    // String k_unit = DisplayFormatters.getRateUnit(DisplayFormatters.UNIT_KB).trim()
    String k_unit = DisplayFormatters.getRateUnitBase10(DisplayFormatters.UNIT_KB).trim();
    // max upload speed
    Label label = new Label(gTorrentOptions, SWT.NULL);
    gridData = new GridData();
    Utils.setLayoutData(label, gridData);
    label.setText(k_unit + " " + MessageText.getString("GeneralView.label.maxuploadspeed.tooltip"));
    GenericIntParameter max_upload = new GenericIntParameter(adhoc_param_adapter, gTorrentOptions, MAX_UPLOAD);
    adhoc_parameters.put(MAX_UPLOAD, max_upload);
    gridData = new GridData();
    max_upload.setLayoutData(gridData);
    if (userMode > 0) {
        // max upload when busy
        label = new Label(gTorrentOptions, SWT.NULL);
        gridData = new GridData();
        Utils.setLayoutData(label, gridData);
        Messages.setLanguageText(label, "TorrentOptionsView.param.max.uploads.when.busy");
        GenericIntParameter max_upload_when_busy = new GenericIntParameter(ds_param_adapter, gTorrentOptions, DownloadManagerState.PARAM_MAX_UPLOAD_WHEN_BUSY);
        ds_parameters.put(DownloadManagerState.PARAM_MAX_UPLOAD_WHEN_BUSY, max_upload_when_busy);
        gridData = new GridData();
        max_upload_when_busy.setLayoutData(gridData);
    }
    // max download speed
    label = new Label(gTorrentOptions, SWT.NULL);
    gridData = new GridData();
    Utils.setLayoutData(label, gridData);
    label.setText(k_unit + " " + MessageText.getString("GeneralView.label.maxdownloadspeed.tooltip"));
    GenericIntParameter max_download = new GenericIntParameter(adhoc_param_adapter, gTorrentOptions, MAX_DOWNLOAD);
    adhoc_parameters.put(MAX_DOWNLOAD, max_download);
    gridData = new GridData();
    max_download.setLayoutData(gridData);
    if (userMode > 0) {
        label = new Label(gTorrentOptions, SWT.NULL);
        gridData = new GridData();
        Utils.setLayoutData(label, gridData);
        Messages.setLanguageText(label, "TorrentOptionsView.param.max.uploads");
        GenericIntParameter max_uploads = new GenericIntParameter(ds_param_adapter, gTorrentOptions, DownloadManagerState.PARAM_MAX_UPLOADS);
        ds_parameters.put(DownloadManagerState.PARAM_MAX_UPLOADS, max_uploads);
        max_uploads.setMinimumValue(2);
        gridData = new GridData();
        max_uploads.setLayoutData(gridData);
        // max uploads when seeding enabled
        final Composite cMaxUploadsOptionsArea = new Composite(gTorrentOptions, SWT.NULL);
        layout = new GridLayout();
        layout.numColumns = 3;
        layout.marginWidth = 0;
        layout.marginHeight = 0;
        cMaxUploadsOptionsArea.setLayout(layout);
        gridData = new GridData();
        gridData.horizontalIndent = 15;
        gridData.horizontalSpan = 2;
        Utils.setLayoutData(cMaxUploadsOptionsArea, gridData);
        label = new Label(cMaxUploadsOptionsArea, SWT.NULL);
        ImageLoader.getInstance().setLabelImage(label, "subitem");
        gridData = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
        Utils.setLayoutData(label, gridData);
        gridData = new GridData();
        GenericBooleanParameter max_uploads_when_seeding_enabled = new GenericBooleanParameter(ds_param_adapter, cMaxUploadsOptionsArea, DownloadManagerState.PARAM_MAX_UPLOADS_WHEN_SEEDING_ENABLED, false, "TorrentOptionsView.param.alternative.value.enable");
        ds_parameters.put(DownloadManagerState.PARAM_MAX_UPLOADS_WHEN_SEEDING_ENABLED, max_uploads_when_seeding_enabled);
        max_uploads_when_seeding_enabled.setLayoutData(gridData);
        GenericIntParameter max_uploads_when_seeding = new GenericIntParameter(ds_param_adapter, cMaxUploadsOptionsArea, DownloadManagerState.PARAM_MAX_UPLOADS_WHEN_SEEDING);
        ds_parameters.put(DownloadManagerState.PARAM_MAX_UPLOADS_WHEN_SEEDING, max_uploads_when_seeding);
        gridData = new GridData();
        max_uploads_when_seeding.setMinimumValue(2);
        max_uploads_when_seeding.setLayoutData(gridData);
        max_uploads_when_seeding_enabled.setAdditionalActionPerformer(new ChangeSelectionActionPerformer(max_uploads_when_seeding.getControl()));
        // max peers
        label = new Label(gTorrentOptions, SWT.NULL);
        gridData = new GridData();
        Utils.setLayoutData(label, gridData);
        Messages.setLanguageText(label, "TorrentOptionsView.param.max.peers");
        GenericIntParameter max_peers = new GenericIntParameter(ds_param_adapter, gTorrentOptions, DownloadManagerState.PARAM_MAX_PEERS);
        ds_parameters.put(DownloadManagerState.PARAM_MAX_PEERS, max_peers);
        gridData = new GridData();
        max_peers.setLayoutData(gridData);
        // max peers when seeding
        final Composite cMaxPeersOptionsArea = new Composite(gTorrentOptions, SWT.NULL);
        layout = new GridLayout();
        layout.numColumns = 3;
        layout.marginWidth = 0;
        layout.marginHeight = 0;
        cMaxPeersOptionsArea.setLayout(layout);
        gridData = new GridData();
        gridData.horizontalIndent = 15;
        gridData.horizontalSpan = 2;
        Utils.setLayoutData(cMaxPeersOptionsArea, gridData);
        label = new Label(cMaxPeersOptionsArea, SWT.NULL);
        ImageLoader.getInstance().setLabelImage(label, "subitem");
        gridData = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
        Utils.setLayoutData(label, gridData);
        gridData = new GridData();
        GenericBooleanParameter max_peers_when_seeding_enabled = new GenericBooleanParameter(ds_param_adapter, cMaxPeersOptionsArea, DownloadManagerState.PARAM_MAX_PEERS_WHEN_SEEDING_ENABLED, false, "TorrentOptionsView.param.alternative.value.enable");
        ds_parameters.put(DownloadManagerState.PARAM_MAX_PEERS_WHEN_SEEDING_ENABLED, max_peers_when_seeding_enabled);
        max_peers_when_seeding_enabled.setLayoutData(gridData);
        GenericIntParameter max_peers_when_seeding = new GenericIntParameter(ds_param_adapter, cMaxPeersOptionsArea, DownloadManagerState.PARAM_MAX_PEERS_WHEN_SEEDING);
        ds_parameters.put(DownloadManagerState.PARAM_MAX_PEERS_WHEN_SEEDING, max_peers_when_seeding);
        gridData = new GridData();
        max_peers_when_seeding.setLayoutData(gridData);
        max_peers_when_seeding_enabled.setAdditionalActionPerformer(new ChangeSelectionActionPerformer(max_peers_when_seeding.getControl()));
        // max seeds
        label = new Label(gTorrentOptions, SWT.NULL);
        gridData = new GridData();
        Utils.setLayoutData(label, gridData);
        Messages.setLanguageText(label, "TorrentOptionsView.param.max.seeds");
        GenericIntParameter max_seeds = new GenericIntParameter(ds_param_adapter, gTorrentOptions, DownloadManagerState.PARAM_MAX_SEEDS);
        ds_parameters.put(DownloadManagerState.PARAM_MAX_SEEDS, max_seeds);
        gridData = new GridData();
        max_seeds.setLayoutData(gridData);
    }
    if (userMode > 0) {
        label = new Label(gTorrentOptions, SWT.NULL);
        gridData = new GridData();
        Utils.setLayoutData(label, gridData);
        Messages.setLanguageText(label, "TorrentOptionsView.param.upload.priority");
        gridData = new GridData();
        GenericIntParameter upload_priority_enabled = new GenericIntParameter(ds_param_adapter, gTorrentOptions, DownloadManagerState.PARAM_UPLOAD_PRIORITY, 0, 1);
        ds_parameters.put(DownloadManagerState.PARAM_UPLOAD_PRIORITY, upload_priority_enabled);
        upload_priority_enabled.setLayoutData(gridData);
        // min sr
        label = new Label(gTorrentOptions, SWT.NULL);
        gridData = new GridData();
        Utils.setLayoutData(label, gridData);
        Messages.setLanguageText(label, "TableColumn.header.min_sr");
        gridData = new GridData();
        gridData.widthHint = 50;
        GenericFloatParameter min_sr = new GenericFloatParameter(ds_param_adapter, gTorrentOptions, DownloadManagerState.PARAM_MIN_SHARE_RATIO, 0, Float.MAX_VALUE, true, 3);
        ds_parameters.put(DownloadManagerState.PARAM_MIN_SHARE_RATIO, min_sr);
        min_sr.setLayoutData(gridData);
        // max sr
        label = new Label(gTorrentOptions, SWT.NULL);
        gridData = new GridData();
        Utils.setLayoutData(label, gridData);
        Messages.setLanguageText(label, "TableColumn.header.max_sr");
        gridData = new GridData();
        gridData.widthHint = 50;
        GenericFloatParameter max_sr = new GenericFloatParameter(ds_param_adapter, gTorrentOptions, DownloadManagerState.PARAM_MAX_SHARE_RATIO, 0, Float.MAX_VALUE, true, 3);
        ds_parameters.put(DownloadManagerState.PARAM_MAX_SHARE_RATIO, max_sr);
        max_sr.setLayoutData(gridData);
    }
    // reset
    Label reset_label = new Label(gTorrentOptions, SWT.NULL);
    Messages.setLanguageText(reset_label, "TorrentOptionsView.param.reset.to.default");
    Button reset_button = new Button(gTorrentOptions, SWT.PUSH);
    Messages.setLanguageText(reset_button, "TorrentOptionsView.param.reset.button");
    reset_button.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(Event event) {
            setDefaults();
        }
    });
    for (int i = 0; i < managers.length; i++) {
        managers[i].addListener(this);
    }
    Group gTorrentInfo = new Group(panel, SWT.NULL);
    Messages.setLanguageText(gTorrentInfo, "label.aggregate.info");
    gridData = new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL);
    Utils.setLayoutData(gTorrentInfo, gridData);
    layout = new GridLayout();
    layout.numColumns = 2;
    gTorrentInfo.setLayout(layout);
    // total size
    label = new Label(gTorrentInfo, SWT.NULL);
    label.setText(MessageText.getString("TableColumn.header.size") + ": ");
    agg_size = new BufferedLabel(gTorrentInfo, SWT.LEFT | SWT.DOUBLE_BUFFERED);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    agg_size.setLayoutData(gridData);
    // remaining
    label = new Label(gTorrentInfo, SWT.NULL);
    label.setText(MessageText.getString("TableColumn.header.remaining") + ": ");
    agg_remaining = new BufferedLabel(gTorrentInfo, SWT.LEFT | SWT.DOUBLE_BUFFERED);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    agg_remaining.setLayoutData(gridData);
    // uploaded
    label = new Label(gTorrentInfo, SWT.NULL);
    label.setText(MessageText.getString("MyTracker.column.uploaded") + ": ");
    agg_uploaded = new BufferedLabel(gTorrentInfo, SWT.LEFT | SWT.DOUBLE_BUFFERED);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    agg_uploaded.setLayoutData(gridData);
    // downloaded
    label = new Label(gTorrentInfo, SWT.NULL);
    label.setText(MessageText.getString("MyTracker.column.downloaded") + ": ");
    agg_downloaded = new BufferedLabel(gTorrentInfo, SWT.LEFT | SWT.DOUBLE_BUFFERED);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    agg_downloaded.setLayoutData(gridData);
    // upload speed
    label = new Label(gTorrentInfo, SWT.NULL);
    label.setText(MessageText.getString("SpeedView.uploadSpeed.title") + ": ");
    agg_upload_speed = new BufferedLabel(gTorrentInfo, SWT.LEFT | SWT.DOUBLE_BUFFERED);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    agg_upload_speed.setLayoutData(gridData);
    // download speed
    label = new Label(gTorrentInfo, SWT.NULL);
    label.setText(MessageText.getString("SpeedView.downloadSpeed.title") + ": ");
    agg_download_speed = new BufferedLabel(gTorrentInfo, SWT.LEFT | SWT.DOUBLE_BUFFERED);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    agg_download_speed.setLayoutData(gridData);
    // share ratio
    label = new Label(gTorrentInfo, SWT.NULL);
    label.setText(MessageText.getString("TableColumn.header.shareRatio") + ": ");
    agg_share_ratio = new BufferedLabel(gTorrentInfo, SWT.LEFT | SWT.DOUBLE_BUFFERED);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    agg_share_ratio.setLayoutData(gridData);
    // reset
    Label stats_reset_label = new Label(gTorrentInfo, SWT.NULL);
    Messages.setLanguageText(stats_reset_label, "TorrentOptionsView.param.reset.stats");
    Button stats_reset_button = new Button(gTorrentInfo, SWT.PUSH);
    Messages.setLanguageText(stats_reset_button, "TorrentOptionsView.param.reset.button");
    stats_reset_button.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(Event event) {
            for (DownloadManagerOptionsHandler dm : managers) {
                if (dm.getDownloadManager() != null) {
                    dm.getDownloadManager().getStats().resetTotalBytesSentReceived(0, 0);
                }
            }
        }
    });
    panel.layout(true, true);
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) UISWTViewCoreEventListener(com.biglybt.ui.swt.pifimpl.UISWTViewCoreEventListener) DownloadManagerStateAttributeListener(com.biglybt.core.download.DownloadManagerStateAttributeListener) BufferedLabel(com.biglybt.ui.swt.components.BufferedLabel) FontData(org.eclipse.swt.graphics.FontData) GenericIntParameter(com.biglybt.ui.swt.config.generic.GenericIntParameter) BufferedLabel(com.biglybt.ui.swt.components.BufferedLabel) GenericFloatParameter(com.biglybt.ui.swt.config.generic.GenericFloatParameter) Font(org.eclipse.swt.graphics.Font) GridLayout(org.eclipse.swt.layout.GridLayout) GenericBooleanParameter(com.biglybt.ui.swt.config.generic.GenericBooleanParameter) FormLayout(org.eclipse.swt.layout.FormLayout) GridLayout(org.eclipse.swt.layout.GridLayout) DownloadManagerOptionsHandler(com.biglybt.core.download.DownloadManagerOptionsHandler) GridData(org.eclipse.swt.layout.GridData) UISWTViewEvent(com.biglybt.ui.swt.pif.UISWTViewEvent) ChangeSelectionActionPerformer(com.biglybt.ui.swt.config.ChangeSelectionActionPerformer)

Aggregations

BufferedLabel (com.biglybt.ui.swt.components.BufferedLabel)18 GridData (org.eclipse.swt.layout.GridData)15 GridLayout (org.eclipse.swt.layout.GridLayout)13 SelectionEvent (org.eclipse.swt.events.SelectionEvent)8 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)7 Label (org.eclipse.swt.widgets.Label)7 UISWTViewEvent (com.biglybt.ui.swt.pif.UISWTViewEvent)6 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)6 Point (org.eclipse.swt.graphics.Point)6 Composite (org.eclipse.swt.widgets.Composite)5 UIFunctions (com.biglybt.ui.UIFunctions)4 UISWTViewCoreEventListener (com.biglybt.ui.swt.pifimpl.UISWTViewCoreEventListener)4 MouseAdapter (org.eclipse.swt.events.MouseAdapter)4 MouseEvent (org.eclipse.swt.events.MouseEvent)4 MessageText (com.biglybt.core.internat.MessageText)3 LinkLabel (com.biglybt.ui.swt.components.LinkLabel)3 Font (org.eclipse.swt.graphics.Font)3 FontData (org.eclipse.swt.graphics.FontData)3 Rectangle (org.eclipse.swt.graphics.Rectangle)3 Control (org.eclipse.swt.widgets.Control)3