Search in sources :

Example 1 with BufferedLabel

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

the class TransferStatsView method createGeneralPanel.

private void createGeneralPanel() {
    generalPanel = new Composite(mainPanel, SWT.NULL);
    GridLayout outerLayout = new GridLayout();
    outerLayout.numColumns = 2;
    generalPanel.setLayout(outerLayout);
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(generalPanel, gridData);
    Composite generalStatsPanel = new Composite(generalPanel, SWT.BORDER);
    GridData generalStatsPanelGridData = new GridData(GridData.FILL_HORIZONTAL);
    generalStatsPanelGridData.grabExcessHorizontalSpace = true;
    Utils.setLayoutData(generalStatsPanel, generalStatsPanelGridData);
    GridLayout panelLayout = new GridLayout();
    panelLayout.numColumns = 5;
    panelLayout.makeColumnsEqualWidth = true;
    generalStatsPanel.setLayout(panelLayout);
    Label lbl = new Label(generalStatsPanel, SWT.NULL);
    lbl = new Label(generalStatsPanel, SWT.NULL);
    Messages.setLanguageText(lbl, "SpeedView.stats.downloaded");
    lbl = new Label(generalStatsPanel, SWT.NULL);
    Messages.setLanguageText(lbl, "SpeedView.stats.uploaded");
    lbl = new Label(generalStatsPanel, SWT.NULL);
    Messages.setLanguageText(lbl, "SpeedView.stats.ratio");
    lbl = new Label(generalStatsPanel, SWT.NULL);
    Messages.setLanguageText(lbl, "SpeedView.stats.uptime");
    lbl = new Label(generalStatsPanel, SWT.NULL);
    lbl = new Label(generalStatsPanel, SWT.NULL);
    lbl = new Label(generalStatsPanel, SWT.NULL);
    lbl = new Label(generalStatsPanel, SWT.NULL);
    lbl = new Label(generalStatsPanel, SWT.NULL);
    // ///// NOW /////////
    Label nowLabel = new Label(generalStatsPanel, SWT.NULL);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(nowLabel, gridData);
    Messages.setLanguageText(nowLabel, "SpeedView.stats.now");
    nowDown = new BufferedLabel(generalStatsPanel, SWT.DOUBLE_BUFFERED);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(nowDown, gridData);
    nowUp = new BufferedLabel(generalStatsPanel, SWT.DOUBLE_BUFFERED);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(nowUp, gridData);
    lbl = new Label(generalStatsPanel, SWT.NULL);
    lbl = new Label(generalStatsPanel, SWT.NULL);
    // ////// SESSION ////////
    Label sessionLabel = new Label(generalStatsPanel, SWT.NULL);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(sessionLabel, gridData);
    Messages.setLanguageText(sessionLabel, "SpeedView.stats.session");
    sessionDown = new BufferedLabel(generalStatsPanel, SWT.DOUBLE_BUFFERED);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(sessionDown, gridData);
    sessionUp = new BufferedLabel(generalStatsPanel, SWT.DOUBLE_BUFFERED);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(sessionUp, gridData);
    session_ratio = new BufferedLabel(generalStatsPanel, SWT.DOUBLE_BUFFERED);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(session_ratio, gridData);
    sessionTime = new BufferedLabel(generalStatsPanel, SWT.DOUBLE_BUFFERED);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(sessionTime, gridData);
    // /////// TOTAL ///////////
    totalLabel = new BufferedLabel(generalStatsPanel, SWT.DOUBLE_BUFFERED);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(totalLabel, gridData);
    Messages.setLanguageText(totalLabel.getWidget(), "SpeedView.stats.total");
    totalDown = new BufferedLabel(generalStatsPanel, SWT.DOUBLE_BUFFERED);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(totalDown, gridData);
    totalUp = new BufferedLabel(generalStatsPanel, SWT.DOUBLE_BUFFERED);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(totalUp, gridData);
    total_ratio = new BufferedLabel(generalStatsPanel, SWT.DOUBLE_BUFFERED);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(total_ratio, gridData);
    totalTime = new BufferedLabel(generalStatsPanel, SWT.DOUBLE_BUFFERED);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(totalTime, gridData);
    for (Object obj : new Object[] { nowLabel, sessionLabel, totalLabel }) {
        Control control;
        if (obj instanceof BufferedLabel) {
            control = ((BufferedLabel) obj).getControl();
        } else {
            control = (Label) obj;
        }
        final Menu menu = new Menu(control.getShell(), SWT.POP_UP);
        control.setMenu(menu);
        MenuItem item = new MenuItem(menu, SWT.NONE);
        Messages.setLanguageText(item, "MainWindow.menu.view.configuration");
        item.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                UIFunctions uif = UIFunctionsManager.getUIFunctions();
                if (uif != null) {
                    uif.getMDI().showEntryByID(MultipleDocumentInterface.SIDEBAR_SECTION_CONFIG, "Stats");
                }
            }
        });
    }
    // SOCKS area
    Composite generalSocksPanel = new Composite(generalPanel, SWT.BORDER);
    GridData generalSocksData = new GridData();
    Utils.setLayoutData(generalSocksPanel, generalSocksData);
    GridLayout socksLayout = new GridLayout();
    socksLayout.numColumns = 2;
    generalSocksPanel.setLayout(socksLayout);
    lbl = new Label(generalSocksPanel, SWT.NULL);
    Messages.setLanguageText(lbl, "label.socks");
    lbl = new Label(generalSocksPanel, SWT.NULL);
    // proxy state
    lbl = new Label(generalSocksPanel, SWT.NULL);
    lbl.setText(MessageText.getString("label.proxy") + ":");
    socksState = new Label(generalSocksPanel, SWT.NULL);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.widthHint = 120;
    Utils.setLayoutData(socksState, gridData);
    // current details
    lbl = new Label(generalSocksPanel, SWT.NULL);
    lbl.setText(MessageText.getString("PeersView.state") + ":");
    socksCurrent = new BufferedLabel(generalSocksPanel, SWT.DOUBLE_BUFFERED);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(socksCurrent, gridData);
    // fail details
    lbl = new Label(generalSocksPanel, SWT.NULL);
    lbl.setText(MessageText.getString("label.fails") + ":");
    socksFails = new BufferedLabel(generalSocksPanel, SWT.DOUBLE_BUFFERED);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(socksFails, gridData);
    // more info
    lbl = new Label(generalSocksPanel, SWT.NULL);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalAlignment = GridData.END;
    socksMore = new Label(generalSocksPanel, SWT.NULL);
    socksMore.setText(MessageText.getString("label.more") + "...");
    Utils.setLayoutData(socksMore, gridData);
    socksMore.setCursor(socksMore.getDisplay().getSystemCursor(SWT.CURSOR_HAND));
    socksMore.setForeground(Colors.blue);
    socksMore.addMouseListener(new MouseAdapter() {

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

        @Override
        public void mouseUp(MouseEvent arg0) {
            showSOCKSInfo();
        }
    });
    // got a rare layout bug that results in the generalStatsPanel not showing the bottom row correctly until the panel
    // is resized - attempt to fix by sizing based on the socks panel which seems to consistently layout OK
    Point socks_size = generalSocksPanel.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    Rectangle trim = generalSocksPanel.computeTrim(0, 0, socks_size.x, socks_size.y);
    generalStatsPanelGridData.heightHint = socks_size.y - (trim.height - socks_size.y);
}
Also used : BufferedLabel(com.biglybt.ui.swt.components.BufferedLabel) MouseEvent(org.eclipse.swt.events.MouseEvent) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) 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) Rectangle(org.eclipse.swt.graphics.Rectangle) MenuItem(org.eclipse.swt.widgets.MenuItem) Point(org.eclipse.swt.graphics.Point) GridLayout(org.eclipse.swt.layout.GridLayout) Control(org.eclipse.swt.widgets.Control) UIFunctions(com.biglybt.ui.UIFunctions) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Menu(org.eclipse.swt.widgets.Menu)

Example 2 with BufferedLabel

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

the class TransferStatsView method createCapacityPanel.

private void createCapacityPanel() {
    blahPanel = new Composite(mainPanel, SWT.NONE);
    GridData blahPanelData = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(blahPanel, blahPanelData);
    GridLayout panelLayout = new GridLayout();
    panelLayout.numColumns = 8;
    blahPanel.setLayout(panelLayout);
    Label label;
    GridData gridData;
    label = new Label(blahPanel, SWT.NONE);
    Messages.setLanguageText(label, "SpeedView.stats.asn");
    asn = new BufferedLabel(blahPanel, SWT.NONE);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(asn, gridData);
    label = new Label(blahPanel, SWT.NONE);
    Messages.setLanguageText(label, "label.current_ip");
    currentIP = new BufferedLabel(blahPanel, SWT.NONE);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(currentIP, gridData);
    label = new Label(blahPanel, SWT.NONE);
    Messages.setLanguageText(label, "SpeedView.stats.estupcap");
    estUpCap = new BufferedLabel(blahPanel, SWT.NONE);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(estUpCap, gridData);
    label = new Label(blahPanel, SWT.NONE);
    Messages.setLanguageText(label, "SpeedView.stats.estdowncap");
    estDownCap = new BufferedLabel(blahPanel, SWT.NONE);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(estDownCap, gridData);
    label = new Label(blahPanel, SWT.NONE);
    Messages.setLanguageText(label, "SpeedView.stats.upbias");
    uploadBiaser = new BufferedLabel(blahPanel, SWT.DOUBLE_BUFFERED);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalSpan = 7;
    Utils.setLayoutData(uploadBiaser, gridData);
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) BufferedLabel(com.biglybt.ui.swt.components.BufferedLabel) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) GridData(org.eclipse.swt.layout.GridData) BufferedLabel(com.biglybt.ui.swt.components.BufferedLabel) Label(org.eclipse.swt.widgets.Label)

Example 3 with BufferedLabel

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

the class TransferStatsView method buildRouteComponent.

private void buildRouteComponent(int rows) {
    boolean changed = false;
    if (rows <= route_labels.length) {
        for (int i = rows; i < route_labels.length; i++) {
            for (int j = 0; j < 3; j++) {
                route_labels[i][j].setText("");
            }
        }
    } else {
        Control[] labels = route_comp.getChildren();
        for (int i = 0; i < labels.length; i++) {
            labels[i].dispose();
        }
        Label h1 = new Label(route_comp, SWT.NULL);
        Utils.setLayoutData(h1, new GridData(GridData.FILL_HORIZONTAL));
        h1.setText(MessageText.getString("label.route"));
        Label h2 = new Label(route_comp, SWT.NULL);
        Utils.setLayoutData(h2, new GridData(GridData.FILL_HORIZONTAL));
        h2.setText(MessageText.getString("tps.type.incoming"));
        Label h3 = new Label(route_comp, SWT.NULL);
        Utils.setLayoutData(h3, new GridData(GridData.FILL_HORIZONTAL));
        h3.setText(MessageText.getString("label.outgoing"));
        new Label(route_comp, SWT.NULL);
        new Label(route_comp, SWT.NULL);
        new Label(route_comp, SWT.NULL);
        route_labels = new BufferedLabel[rows][3];
        for (int i = 0; i < rows; i++) {
            for (int j = 0; j < 3; j++) {
                BufferedLabel l = new BufferedLabel(route_comp, SWT.DOUBLE_BUFFERED);
                GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
                Utils.setLayoutData(l, gridData);
                route_labels[i][j] = l;
            }
        }
        changed = true;
    }
    Point size = route_comp.computeSize(route_comp.getParent().getSize().x, SWT.DEFAULT);
    changed = changed || !route_comp.getSize().equals(size);
    route_comp.setSize(size);
    if (!changed) {
        for (int i = 0; i < route_labels.length; i++) {
            for (int j = 0; j < 3; j++) {
                BufferedLabel lab = route_labels[i][j];
                if (lab.getControl().getSize().y == 0 && lab.getText().length() > 0) {
                    changed = true;
                }
            }
        }
    }
    if (changed) {
        route_comp.getParent().layout(true, true);
    }
    route_comp.update();
}
Also used : Control(org.eclipse.swt.widgets.Control) BufferedLabel(com.biglybt.ui.swt.components.BufferedLabel) BufferedLabel(com.biglybt.ui.swt.components.BufferedLabel) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point) TransportStartpoint(com.biglybt.core.networkmanager.TransportStartpoint)

Example 4 with BufferedLabel

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

the class BuddyPluginViewBetaChat method buildStatus.

private void buildStatus(Composite main_component, Composite component) {
    boolean public_chat = !chat.isPrivateChat();
    final Label menu_drop = new Label(component, SWT.NULL);
    Messages.setLanguageTooltip(menu_drop, "TagSettingsView.title");
    FontData fontData = menu_drop.getFont().getFontData()[0];
    Display display = menu_drop.getDisplay();
    italic_font = new Font(display, new FontData(fontData.getName(), fontData.getHeight(), SWT.ITALIC));
    bold_font = new Font(display, new FontData(fontData.getName(), fontData.getHeight(), SWT.BOLD));
    big_font = new Font(display, new FontData(fontData.getName(), (int) (fontData.getHeight() * 1.5), SWT.BOLD));
    small_font = new Font(display, new FontData(fontData.getName(), (int) (fontData.getHeight() * 0.5), SWT.BOLD));
    ftux_dark_bg = new Color(display, 183, 200, 212);
    ftux_dark_fg = new Color(display, 0, 81, 134);
    ftux_light_bg = new Color(display, 236, 242, 246);
    component.addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent arg0) {
            Font[] fonts = { italic_font, bold_font, big_font, small_font };
            for (Font f : fonts) {
                if (f != null) {
                    f.dispose();
                }
            }
            Color[] colours = { ftux_dark_bg, ftux_dark_fg, ftux_light_bg };
            for (Color c : colours) {
                if (c != null) {
                    c.dispose();
                }
            }
            if (drop_targets != null) {
                for (DropTarget dt : drop_targets) {
                    dt.dispose();
                }
            }
            closed();
        }
    });
    status = new BufferedLabel(component, SWT.LEFT | SWT.DOUBLE_BUFFERED);
    GridData grid_data = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(status, grid_data);
    status.setText(MessageText.getString("PeersView.state.pending"));
    Image image = ImageLoader.getInstance().getImage("cog_down");
    menu_drop.setImage(image);
    grid_data = new GridData();
    grid_data.widthHint = image.getBounds().width;
    grid_data.heightHint = image.getBounds().height;
    Utils.setLayoutData(menu_drop, grid_data);
    menu_drop.setCursor(menu_drop.getDisplay().getSystemCursor(SWT.CURSOR_HAND));
    Control status_control = status.getControl();
    final Menu status_menu = new Menu(status_control);
    status.getControl().setMenu(status_menu);
    menu_drop.setMenu(status_menu);
    menu_drop.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDown(MouseEvent event) {
            try {
                Point p = status_menu.getDisplay().map(menu_drop, null, event.x, event.y);
                status_menu.setLocation(p);
                status_menu.setVisible(true);
            } catch (Throwable e) {
                Debug.out(e);
            }
        }
    });
    if (public_chat) {
        Menu status_clip_menu = new Menu(component.getShell(), SWT.DROP_DOWN);
        MenuItem status_clip_item = new MenuItem(status_menu, SWT.CASCADE);
        status_clip_item.setMenu(status_clip_menu);
        status_clip_item.setText(MessageText.getString("label.copy.to.clipboard"));
        MenuItem status_mi = new MenuItem(status_clip_menu, SWT.PUSH);
        status_mi.setText(MessageText.getString("azbuddy.dchat.copy.channel.key"));
        status_mi.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                ClipboardCopy.copyToClipBoard(chat.getKey());
            }
        });
        status_mi = new MenuItem(status_clip_menu, SWT.PUSH);
        status_mi.setText(MessageText.getString("azbuddy.dchat.copy.channel.url"));
        status_mi.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                ClipboardCopy.copyToClipBoard(chat.getURL());
            }
        });
        status_mi = new MenuItem(status_clip_menu, SWT.PUSH);
        status_mi.setText(MessageText.getString("azbuddy.dchat.copy.rss.url"));
        status_mi.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                ClipboardCopy.copyToClipBoard("azplug:?id=azbuddy&arg=" + UrlUtils.encode(chat.getURL() + "&format=rss"));
            }
        });
        status_mi = new MenuItem(status_clip_menu, SWT.PUSH);
        status_mi.setText(MessageText.getString("azbuddy.dchat.copy.channel.pk"));
        status_mi.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                ClipboardCopy.copyToClipBoard(Base32.encode(chat.getPublicKey()));
            }
        });
        status_mi = new MenuItem(status_clip_menu, SWT.PUSH);
        status_mi.setText(MessageText.getString("azbuddy.dchat.copy.channel.export"));
        status_mi.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                ClipboardCopy.copyToClipBoard(chat.export());
            }
        });
        if (!chat.isManaged()) {
            Menu status_channel_menu = new Menu(component.getShell(), SWT.DROP_DOWN);
            MenuItem status_channel_item = new MenuItem(status_menu, SWT.CASCADE);
            status_channel_item.setMenu(status_channel_menu);
            status_channel_item.setText(MessageText.getString("azbuddy.dchat.rchans"));
            // Managed channel
            status_mi = new MenuItem(status_channel_menu, SWT.PUSH);
            status_mi.setText(MessageText.getString("azbuddy.dchat.rchans.managed"));
            status_mi.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent event) {
                    try {
                        ChatInstance inst = chat.getManagedChannel();
                        BuddyPluginViewBetaChat.createChatWindow(view, plugin, inst);
                    } catch (Throwable e) {
                        Debug.out(e);
                    }
                }
            });
            // RO channel
            status_mi = new MenuItem(status_channel_menu, SWT.PUSH);
            status_mi.setText(MessageText.getString("azbuddy.dchat.rchans.ro"));
            status_mi.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent event) {
                    try {
                        ChatInstance inst = chat.getReadOnlyChannel();
                        createChatWindow(view, plugin, inst);
                    } catch (Throwable e) {
                        Debug.out(e);
                    }
                }
            });
            // Random sub-channel
            status_mi = new MenuItem(status_channel_menu, SWT.PUSH);
            status_mi.setText(MessageText.getString("azbuddy.dchat.rchans.rand"));
            status_mi.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent event) {
                    try {
                        byte[] rand = new byte[20];
                        RandomUtils.nextSecureBytes(rand);
                        ChatInstance inst = beta.getChat(chat.getNetwork(), chat.getKey() + " {" + Base32.encode(rand) + "}");
                        createChatWindow(view, plugin, inst);
                    } catch (Throwable e) {
                        Debug.out(e);
                    }
                }
            });
            if (beta.isI2PAvailable()) {
                status_mi = new MenuItem(status_channel_menu, SWT.PUSH);
                status_mi.setText(MessageText.getString(chat.getNetwork() == AENetworkClassifier.AT_I2P ? "azbuddy.dchat.rchans.pub" : "azbuddy.dchat.rchans.anon"));
                status_mi.addSelectionListener(new SelectionAdapter() {

                    @Override
                    public void widgetSelected(SelectionEvent event) {
                        try {
                            ChatInstance inst = beta.getChat(chat.getNetwork() == AENetworkClassifier.AT_I2P ? AENetworkClassifier.AT_PUBLIC : AENetworkClassifier.AT_I2P, chat.getKey());
                            createChatWindow(view, plugin, inst);
                        } catch (Throwable e) {
                            Debug.out(e);
                        }
                    }
                });
            }
        }
        final MenuItem fave_mi = new MenuItem(status_menu, SWT.CHECK);
        fave_mi.setText(MessageText.getString("label.fave"));
        fave_mi.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                chat.setFavourite(fave_mi.getSelection());
            }
        });
        final MenuItem sis_mi = new MenuItem(status_menu, SWT.PUSH);
        sis_mi.setText(MessageText.getString(Utils.isAZ2UI() ? "label.show.in.tab" : "label.show.in.sidebar"));
        sis_mi.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                BuddyPluginUI.openChat(chat.getNetwork(), chat.getKey());
            }
        });
        addFriendsMenu(status_menu);
        // advanced
        final Menu advanced_menu = new Menu(status_menu.getShell(), SWT.DROP_DOWN);
        MenuItem advanced_menu_item = new MenuItem(status_menu, SWT.CASCADE);
        advanced_menu_item.setMenu(advanced_menu);
        advanced_menu_item.setText(MessageText.getString("MyTorrentsView.menu.advancedmenu"));
        // rename
        final MenuItem rename_mi = new MenuItem(advanced_menu, SWT.PUSH);
        rename_mi.setText(MessageText.getString("MyTorrentsView.menu.rename"));
        rename_mi.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                String name = chat.getDisplayName();
                if (name == null) {
                    name = chat.getName();
                }
                UISWTInputReceiver entry = new SimpleTextEntryWindow();
                entry.setPreenteredText(name, false);
                entry.maintainWhitespace(false);
                entry.allowEmptyInput(false);
                entry.setLocalisedTitle(MessageText.getString("label.rename", new String[] { name }));
                entry.prompt(new UIInputReceiverListener() {

                    @Override
                    public void UIInputReceiverClosed(UIInputReceiver entry) {
                        if (!entry.hasSubmittedInput()) {
                            return;
                        }
                        String input = entry.getSubmittedInput().trim();
                        if (input.length() > 0) {
                            try {
                                chat.setDisplayName(input);
                            } catch (Throwable e) {
                                Debug.printStackTrace(e);
                            }
                        }
                    }
                });
            }
        });
        // view type
        final Menu vt_menu = new Menu(status_menu.getShell(), SWT.DROP_DOWN);
        MenuItem vt_menu_item = new MenuItem(advanced_menu, SWT.CASCADE);
        vt_menu_item.setMenu(vt_menu);
        vt_menu_item.setText(MessageText.getString("menu.view.options"));
        SelectionAdapter listener = new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                int vt = -1;
                for (MenuItem mi : vt_menu.getItems()) {
                    if (mi.getSelection()) {
                        vt = (Integer) mi.getData();
                    }
                }
                if (vt != -1) {
                    chat.setViewType(vt);
                    buildSupport(main_component);
                    main_component.layout(true, true);
                }
            }
        };
        MenuItem vt_mi = new MenuItem(vt_menu, SWT.RADIO);
        vt_mi.setText(MessageText.getString("label.full"));
        vt_mi.setData(BuddyPluginBeta.VIEW_TYPE_DEFAULT);
        vt_mi.addSelectionListener(listener);
        vt_mi = new MenuItem(vt_menu, SWT.RADIO);
        vt_mi.setText(MessageText.getString("ConfigView.section.sharing"));
        vt_mi.setData(BuddyPluginBeta.VIEW_TYPE_SHARING);
        if (chat.isReadOnly()) {
            vt_mi.setEnabled(false);
        }
        vt_mi.addSelectionListener(listener);
        vt_menu.addMenuListener(new MenuAdapter() {

            @Override
            public void menuShown(MenuEvent e) {
                int vt = chat.getViewType();
                for (MenuItem mi : vt_menu.getItems()) {
                    mi.setSelection(vt == (Integer) mi.getData());
                }
            }
        });
        // persist messages
        final MenuItem persist_mi = new MenuItem(advanced_menu, SWT.CHECK);
        persist_mi.setText(MessageText.getString("azbuddy.dchat.save.messages"));
        persist_mi.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                chat.setSaveMessages(persist_mi.getSelection());
            }
        });
        final MenuItem log_mi = new MenuItem(advanced_menu, SWT.CHECK);
        log_mi.setText(MessageText.getString("azbuddy.dchat.log.messages"));
        log_mi.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                chat.setLogMessages(log_mi.getSelection());
            }
        });
        final MenuItem automute_mi = new MenuItem(advanced_menu, SWT.CHECK);
        automute_mi.setText(MessageText.getString("azbuddy.dchat.auto.mute"));
        automute_mi.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                chat.setAutoMute(automute_mi.getSelection());
            }
        });
        final MenuItem postnotifications_mi = new MenuItem(advanced_menu, SWT.CHECK);
        postnotifications_mi.setText(MessageText.getString("azbuddy.dchat.post.to.notifcations"));
        postnotifications_mi.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                chat.setEnableNotificationsPost(postnotifications_mi.getSelection());
            }
        });
        final MenuItem disableindicators_mi = new MenuItem(advanced_menu, SWT.CHECK);
        disableindicators_mi.setText(MessageText.getString("azbuddy.dchat.disable.msg.indicators"));
        disableindicators_mi.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                chat.setDisableNewMsgIndications(disableindicators_mi.getSelection());
            }
        });
        // setup menu
        status_menu.addMenuListener(new MenuAdapter() {

            @Override
            public void menuShown(MenuEvent e) {
                fave_mi.setSelection(chat.isFavourite());
                persist_mi.setSelection(chat.getSaveMessages());
                log_mi.setSelection(chat.getLogMessages());
                automute_mi.setSelection(chat.getAutoMute());
                postnotifications_mi.setSelection(chat.getEnableNotificationsPost());
                boolean disable_indications = chat.getDisableNewMsgIndications();
                disableindicators_mi.setSelection(disable_indications);
                postnotifications_mi.setEnabled(!disable_indications);
            }
        });
    } else {
        final Menu status_priv_menu = new Menu(component.getShell(), SWT.DROP_DOWN);
        MenuItem status_priv_item = new MenuItem(status_menu, SWT.CASCADE);
        status_priv_item.setMenu(status_priv_menu);
        status_priv_item.setText(MessageText.getString("label.private.chat"));
        SelectionAdapter listener = new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                beta.setPrivateChatState((Integer) ((MenuItem) e.widget).getData());
            }
        };
        MenuItem status_mi = new MenuItem(status_priv_menu, SWT.RADIO);
        status_mi.setText(MessageText.getString("label.enabled"));
        status_mi.setData(BuddyPluginBeta.PRIVATE_CHAT_ENABLED);
        status_mi.addSelectionListener(listener);
        status_mi = new MenuItem(status_priv_menu, SWT.RADIO);
        status_mi.setText(MessageText.getString("label.pinned.only"));
        status_mi.setData(BuddyPluginBeta.PRIVATE_CHAT_PINNED_ONLY);
        status_mi.addSelectionListener(listener);
        status_mi = new MenuItem(status_priv_menu, SWT.RADIO);
        status_mi.setText(MessageText.getString("label.disabled"));
        status_mi.setData(BuddyPluginBeta.PRIVATE_CHAT_DISABLED);
        status_mi.addSelectionListener(listener);
        status_priv_menu.addMenuListener(new MenuAdapter() {

            @Override
            public void menuShown(MenuEvent e) {
                int pc_state = beta.getPrivateChatState();
                for (MenuItem mi : status_priv_menu.getItems()) {
                    mi.setSelection(pc_state == (Integer) mi.getData());
                }
            }
        });
        addFriendsMenu(status_menu);
        final MenuItem keep_alive_mi = new MenuItem(status_menu, SWT.CHECK);
        keep_alive_mi.setText(MessageText.getString("label.keep.alive"));
        status_menu.addMenuListener(new MenuAdapter() {

            @Override
            public void menuShown(MenuEvent e) {
                keep_alive_mi.setSelection(chat.getUserData("AC:KeepAlive") != null);
            }
        });
        keep_alive_mi.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                ChatInstance clone = (ChatInstance) chat.getUserData("AC:KeepAlive");
                if (clone != null) {
                    clone.destroy();
                    clone = null;
                } else {
                    try {
                        clone = chat.getClone();
                    } catch (Throwable f) {
                    }
                }
                chat.setUserData("AC:KeepAlive", clone);
            }
        });
        final MenuItem sis_mi = new MenuItem(status_menu, SWT.PUSH);
        sis_mi.setText(MessageText.getString("label.show.in.sidebar"));
        sis_mi.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                BuddyPluginUI.openChat(chat.getNetwork(), chat.getKey());
            }
        });
    }
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) BufferedLabel(com.biglybt.ui.swt.components.BufferedLabel) BufferedLabel(com.biglybt.ui.swt.components.BufferedLabel) Label(org.eclipse.swt.widgets.Label) LinkLabel(com.biglybt.ui.swt.components.LinkLabel) DisposeEvent(org.eclipse.swt.events.DisposeEvent) Image(org.eclipse.swt.graphics.Image) Font(org.eclipse.swt.graphics.Font) Control(org.eclipse.swt.widgets.Control) SimpleTextEntryWindow(com.biglybt.ui.swt.SimpleTextEntryWindow) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Menu(org.eclipse.swt.widgets.Menu) MenuEvent(org.eclipse.swt.events.MenuEvent) UISWTInputReceiver(com.biglybt.ui.swt.pif.UISWTInputReceiver) MouseEvent(org.eclipse.swt.events.MouseEvent) FontData(org.eclipse.swt.graphics.FontData) Color(org.eclipse.swt.graphics.Color) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) MouseAdapter(org.eclipse.swt.events.MouseAdapter) MenuAdapter(org.eclipse.swt.events.MenuAdapter) MenuItem(org.eclipse.swt.widgets.MenuItem) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point) UIInputReceiver(com.biglybt.pif.ui.UIInputReceiver) GridData(org.eclipse.swt.layout.GridData) UIInputReceiverListener(com.biglybt.pif.ui.UIInputReceiverListener) DropTarget(org.eclipse.swt.dnd.DropTarget) Display(org.eclipse.swt.widgets.Display)

Example 5 with BufferedLabel

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

the class FilesView method initComposite.

/* (non-Javadoc)
	 * @see com.biglybt.ui.swt.views.table.impl.TableViewTab#initComposite(org.eclipse.swt.widgets.Composite)
	 */
@Override
public Composite initComposite(Composite composite) {
    Composite parent = new Composite(composite, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.marginHeight = layout.marginWidth = 0;
    parent.setLayout(layout);
    Layout compositeLayout = composite.getLayout();
    if (compositeLayout instanceof GridLayout) {
        parent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    } else if (compositeLayout instanceof FormLayout) {
        parent.setLayoutData(Utils.getFilledFormData());
    }
    Composite cTop = new Composite(parent, SWT.NONE);
    cTop.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
    cTop.setLayout(new FormLayout());
    // hide dnd
    btnShowDND = new Button(cTop, SWT.CHECK);
    Messages.setLanguageText(btnShowDND, "FilesView.hide.dnd");
    btnShowDND.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            COConfigurationManager.setParameter("FilesView.hide.dnd", !hide_dnd_files);
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
    hide_dnd_files = COConfigurationManager.getBooleanParameter("FilesView.hide.dnd");
    btnShowDND.setSelection(hide_dnd_files);
    // tree view
    btnTreeView = new Button(cTop, SWT.CHECK);
    Messages.setLanguageText(btnTreeView, "OpenTorrentWindow.tree.view");
    btnTreeView.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            tree_view = btnTreeView.getSelection();
            COConfigurationManager.setParameter("FilesView.use.tree", tree_view);
            force_refresh = true;
            tableRefresh();
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
    tree_view = COConfigurationManager.getBooleanParameter("FilesView.use.tree");
    btnTreeView.setSelection(tree_view);
    // dunno why but doesnt draw on Linux with double-buffering
    lblHeader = new BufferedLabel(cTop, SWT.CENTER | (Constants.isLinux ? 0 : SWT.DOUBLE_BUFFERED));
    BubbleTextBox bubbleTextBox = new BubbleTextBox(cTop, SWT.BORDER | SWT.SEARCH | SWT.ICON_SEARCH | SWT.ICON_CANCEL | SWT.SINGLE);
    bubbleTextBox.getTextWidget().setMessage(MessageText.getString("TorrentDetailsView.filter"));
    FormData fd = Utils.getFilledFormData();
    fd.left = null;
    bubbleTextBox.getParent().setLayoutData(fd);
    fd = new FormData();
    fd.top = new FormAttachment(bubbleTextBox.getParent(), 10, SWT.CENTER);
    fd.left = new FormAttachment(0, 0);
    btnShowDND.setLayoutData(fd);
    fd = new FormData();
    fd.top = new FormAttachment(bubbleTextBox.getParent(), 10, SWT.CENTER);
    fd.left = new FormAttachment(btnShowDND, 10);
    btnTreeView.setLayoutData(fd);
    fd = new FormData();
    fd.top = new FormAttachment(bubbleTextBox.getParent(), 10, SWT.CENTER);
    fd.left = new FormAttachment(btnTreeView, 10);
    fd.right = new FormAttachment(bubbleTextBox.getParent(), -10);
    lblHeader.setLayoutData(fd);
    tv.enableFilterCheck(bubbleTextBox.getTextWidget(), this, true);
    Composite tableParent = new Composite(parent, SWT.NONE);
    tableParent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    GridLayout gridLayout = new GridLayout();
    gridLayout.horizontalSpacing = gridLayout.verticalSpacing = 0;
    gridLayout.marginHeight = gridLayout.marginWidth = 0;
    tableParent.setLayout(gridLayout);
    parent.setTabList(new Control[] { tableParent, cTop });
    return tableParent;
}
Also used : BufferedLabel(com.biglybt.ui.swt.components.BufferedLabel) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SelectionListener(org.eclipse.swt.events.SelectionListener) BubbleTextBox(com.biglybt.ui.swt.components.BubbleTextBox)

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