Search in sources :

Example 16 with BufferedLabel

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

the class BasicPluginViewImpl method initialize.

private void initialize(Composite composite) {
    GridData gridData;
    GridLayout gridLayout;
    String sConfigSectionID = model.getConfigSectionID();
    this.display = composite.getDisplay();
    panel = new Composite(composite, SWT.NULL);
    gridLayout = new GridLayout();
    gridLayout.numColumns = 2;
    panel.setLayout(gridLayout);
    gridData = new GridData(GridData.FILL_BOTH);
    Utils.setLayoutData(panel, gridData);
    /*
     * Status       : [Status Text]
     * Current Task : [Task Text]
     * Progress     : [||||||||||----------]
     * Log :
     * [
     *
     *
     * ]
     */
    Composite topSection = new Composite(panel, SWT.NONE);
    gridLayout = new GridLayout();
    gridLayout.numColumns = 2;
    gridLayout.marginHeight = 0;
    gridLayout.marginWidth = 0;
    topSection.setLayout(gridLayout);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    if (sConfigSectionID == null) {
        gridData.horizontalSpan = 2;
    }
    Utils.setLayoutData(topSection, gridData);
    if (model.getStatus().getVisible()) {
        Label statusTitle = new Label(topSection, SWT.NULL);
        Messages.setLanguageText(statusTitle, "plugins.basicview.status");
        status = new BufferedLabel(topSection, SWT.NULL);
        gridData = new GridData(GridData.FILL_HORIZONTAL);
        Utils.setLayoutData(status, gridData);
    }
    if (model.getActivity().getVisible()) {
        Label activityTitle = new Label(topSection, SWT.NULL);
        Messages.setLanguageText(activityTitle, "plugins.basicview.activity");
        task = new BufferedLabel(topSection, SWT.NULL);
        gridData = new GridData(GridData.FILL_HORIZONTAL);
        Utils.setLayoutData(task, gridData);
    }
    if (model.getProgress().getVisible()) {
        Label progressTitle = new Label(topSection, SWT.NULL);
        Messages.setLanguageText(progressTitle, "plugins.basicview.progress");
        progress = new ProgressBar(topSection, SWT.NULL);
        progress.setMaximum(100);
        progress.setMinimum(0);
        gridData = new GridData(GridData.FILL_HORIZONTAL);
        Utils.setLayoutData(progress, gridData);
    }
    if (sConfigSectionID != null) {
        Composite configSection = new Composite(panel, SWT.NONE);
        gridLayout = new GridLayout();
        gridLayout.numColumns = 1;
        gridLayout.marginHeight = 0;
        gridLayout.marginWidth = 2;
        configSection.setLayout(gridLayout);
        gridData = new GridData(GridData.END | GridData.VERTICAL_ALIGN_END);
        Utils.setLayoutData(configSection, gridData);
        // Label padding = new Label(configSection,SWT.NULL);
        // gridData = new GridData(GridData.FILL_HORIZONTAL);
        // Utils.setLayoutData(padding, gridData);
        Button btnConfig = new Button(configSection, SWT.PUSH);
        Messages.setLanguageText(btnConfig, "plugins.basicview.config");
        btnConfig.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions();
                if (uiFunctions != null) {
                    uiFunctions.getMDI().showEntryByID(MultipleDocumentInterface.SIDEBAR_SECTION_CONFIG, model.getConfigSectionID());
                }
            }
        });
        Utils.setLayoutData(btnConfig, new GridData());
    }
    if (model.getLogArea().getVisible()) {
        Label logTitle = new Label(topSection, SWT.NULL);
        Messages.setLanguageText(logTitle, "plugins.basicview.log");
        // gridData = new GridData(GridData.FILL_HORIZONTAL);
        // gridData.horizontalSpan = 1;
        // Utils.setLayoutData(logTitle, gridData);
        Button button = new Button(topSection, SWT.PUSH);
        Messages.setLanguageText(button, "plugins.basicview.clear");
        button.addListener(SWT.Selection, new Listener() {

            @Override
            public void handleEvent(Event event) {
                model.getLogArea().setText("");
            }
        });
        log = new StyledText(panel, SWT.READ_ONLY | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
        gridData = new GridData(GridData.FILL_BOTH);
        gridData.horizontalSpan = 2;
        Utils.setLayoutData(log, gridData);
        ClipboardCopy.addCopyToClipMenu(log, new ClipboardCopy.copyToClipProvider() {

            @Override
            public String getText() {
                return (log.getText().trim());
            }
        });
        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();
                }
            }
        });
        // String	text = model.getLogArea().getText().trim();
        // log.setText( text);
        // log.setTopIndex(log.getLineCount());
        model.getLogArea().addPropertyChangeListener(this);
        Composite bottomSection = new Composite(panel, SWT.NONE);
        gridLayout = new GridLayout();
        gridLayout.numColumns = 3;
        gridLayout.marginHeight = 0;
        gridLayout.marginWidth = 0;
        bottomSection.setLayout(gridLayout);
        gridData = new GridData(GridData.FILL_HORIZONTAL);
        gridData.horizontalSpan = 2;
        Utils.setLayoutData(bottomSection, gridData);
        // include
        Label label = new Label(bottomSection, SWT.NONE);
        Utils.setLayoutData(label, new GridData());
        Messages.setLanguageText(label, "LoggerView.includeOnly");
        final Text inclText = new Text(bottomSection, SWT.BORDER);
        gridData = new GridData();
        gridData.widthHint = 200;
        Utils.setLayoutData(inclText, gridData);
        inclText.addModifyListener(new ModifyListener() {

            @Override
            public void modifyText(ModifyEvent e) {
                String newExpression = inclText.getText();
                if (newExpression.length() == 0)
                    inclusionFilter = null;
                else {
                    try {
                        inclusionFilter = Pattern.compile(newExpression, Pattern.CASE_INSENSITIVE);
                        inclText.setBackground(null);
                    } catch (PatternSyntaxException e1) {
                        inclText.setBackground(Colors.colorErrorBG);
                    }
                }
            }
        });
        label = new Label(bottomSection, SWT.NONE);
        // exclude
        label = new Label(bottomSection, SWT.NONE);
        Utils.setLayoutData(label, new GridData());
        Messages.setLanguageText(label, "LoggerView.excludeAll");
        final Text exclText = new Text(bottomSection, SWT.BORDER);
        gridData = new GridData();
        gridData.widthHint = 200;
        Utils.setLayoutData(exclText, gridData);
        exclText.addModifyListener(new ModifyListener() {

            @Override
            public void modifyText(ModifyEvent e) {
                String newExpression = exclText.getText();
                if (newExpression.length() == 0)
                    exclusionFilter = null;
                else {
                    try {
                        exclusionFilter = Pattern.compile(newExpression, Pattern.CASE_INSENSITIVE);
                        exclText.setBackground(null);
                    } catch (PatternSyntaxException e1) {
                        exclText.setBackground(Colors.colorErrorBG);
                    }
                }
            }
        });
        label = new Label(bottomSection, SWT.NONE);
        // pause
        Button buttonPause = new Button(bottomSection, SWT.CHECK);
        Messages.setLanguageText(buttonPause, "LoggerView.pause");
        gridData = new GridData();
        Utils.setLayoutData(buttonPause, gridData);
        buttonPause.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                if (e.widget == null || !(e.widget instanceof Button))
                    return;
                Button btn = (Button) e.widget;
                paused = btn.getSelection();
            }
        });
    }
}
Also used : BufferedLabel(com.biglybt.ui.swt.components.BufferedLabel) UIPropertyChangeListener(com.biglybt.pif.ui.components.UIPropertyChangeListener) ModifyListener(org.eclipse.swt.events.ModifyListener) StyledText(org.eclipse.swt.custom.StyledText) ModifyListener(org.eclipse.swt.events.ModifyListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) KeyAdapter(org.eclipse.swt.events.KeyAdapter) BufferedLabel(com.biglybt.ui.swt.components.BufferedLabel) StyledText(org.eclipse.swt.custom.StyledText) ClipboardCopy(com.biglybt.ui.swt.mainwindow.ClipboardCopy) KeyEvent(org.eclipse.swt.events.KeyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) UIFunctions(com.biglybt.ui.UIFunctions) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) UISWTViewEvent(com.biglybt.ui.swt.pif.UISWTViewEvent) KeyEvent(org.eclipse.swt.events.KeyEvent) UIPropertyChangeEvent(com.biglybt.pif.ui.components.UIPropertyChangeEvent) ModifyEvent(org.eclipse.swt.events.ModifyEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) PatternSyntaxException(java.util.regex.PatternSyntaxException)

Example 17 with BufferedLabel

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

the class MessageBoxShell method _open.

private void _open() {
    if (instanceID != null) {
        if (mapInstances.containsKey(instanceID)) {
            MessageBoxShell mb = mapInstances.get(instanceID);
            if (mb.shell != null && !mb.shell.isDisposed()) {
                mb.shell.open();
                return;
            }
        }
        mapInstances.put(instanceID, this);
    }
    result = -1;
    boolean ourParent = false;
    if (parent == null || parent.isDisposed()) {
        parent = Utils.findAnyShell();
        ourParent = true;
        if (parent == null || parent.isDisposed()) {
            triggerResultListener(result);
            return;
        }
    }
    final Display display = parent.getDisplay();
    // APPLICATION_MODAL causes some crazy sht to happen on Windows.
    // Example: 5 windows open in APPLICATION MODAL mode,
    // and somehow none of them show until you do a "Window->Bring To Front"
    // which only makes ONE visible
    int shell_style = SWT.DIALOG_TRIM | SWT.RESIZE;
    if (modal) {
        shell_style |= SWT.APPLICATION_MODAL;
    }
    shell = ShellFactory.createShell(parent, shell_style);
    if (title != null) {
        shell.setText(title);
    }
    shell.setBackgroundMode(SWT.INHERIT_DEFAULT);
    shell.addListener(SWT.Dispose, new Listener() {

        @Override
        public void handleEvent(Event event) {
            mapInstances.remove(instanceID);
            if (iconImageID != null) {
                ImageLoader.getInstance().releaseImage(iconImageID);
            }
            triggerResultListener(result);
            if (display != null && !display.isDisposed() && filterListener != null) {
                display.removeFilter(SWT.Traverse, filterListener);
            }
            numOpen--;
        }
    });
    GridLayout gridLayout = new GridLayout();
    if (squish) {
        gridLayout.verticalSpacing = 0;
        gridLayout.horizontalSpacing = 0;
        gridLayout.marginLeft = 0;
        gridLayout.marginRight = 0;
        gridLayout.marginTop = 0;
        gridLayout.marginBottom = 0;
        gridLayout.marginWidth = 0;
        gridLayout.marginHeight = 0;
    }
    shell.setLayout(gridLayout);
    Utils.setShellIcon(shell);
    UISkinnableSWTListener[] listeners = UISkinnableManagerSWT.getInstance().getSkinnableListeners(MessageBoxShell.class.toString());
    for (int i = 0; i < listeners.length; i++) {
        listeners[i].skinBeforeComponents(shell, this, relatedObjects);
    }
    FormData formData;
    GridData gridData;
    Composite textComposite = shell;
    if (imgLeft != null) {
        textComposite = new Composite(shell, SWT.NONE);
        textComposite.setForeground(shell.getForeground());
        GridLayout gl = new GridLayout(2, false);
        gl.horizontalSpacing = 10;
        Utils.setLayout(textComposite, gl);
        Utils.setLayoutData(textComposite, new GridData(GridData.FILL_BOTH));
        Label lblImage = new Label(textComposite, SWT.NONE);
        lblImage.setImage(imgLeft);
        Utils.setLayoutData(lblImage, new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
    } else if (!squish) {
        textComposite = new Composite(shell, SWT.NONE);
        GridLayout gl = new GridLayout(2, false);
        gl.marginWidth = 5;
        Utils.setLayout(textComposite, gl);
        Utils.setLayoutData(textComposite, new GridData(GridData.FILL_BOTH));
    }
    Control linkControl;
    if (text != null && text.length() > 0) {
        if (useTextBox()) {
            linkControl = createTextBox(textComposite, text);
        } else {
            linkControl = createLinkLabel(textComposite, text);
        }
    } else {
        linkControl = null;
    }
    if ((html != null && html.length() > 0) || (url != null && url.length() > 0)) {
        try {
            final BrowserWrapper browser = Utils.createSafeBrowser(shell, SWT.NONE);
            if (url != null && url.length() > 0) {
                browser.setUrl(url);
            } else {
                browser.setText(html);
            }
            GridData gd = new GridData(GridData.FILL_BOTH);
            gd.heightHint = 200;
            Utils.setLayoutData(browser.getControl(), gd);
            browser.addProgressListener(new ProgressListener() {

                @Override
                public void completed(ProgressEvent event) {
                    if (shell == null || shell.isDisposed()) {
                        return;
                    }
                    browser.addLocationListener(new LocationListener() {

                        @Override
                        public void changing(LocationEvent event) {
                            event.doit = browser_follow_links;
                        }

                        @Override
                        public void changed(LocationEvent event) {
                        }
                    });
                    browser.addOpenWindowListener(new OpenWindowListener() {

                        @Override
                        public void open(WindowEvent event) {
                            event.required = true;
                        }
                    });
                }

                @Override
                public void changed(ProgressEvent event) {
                }
            });
            browser.addStatusTextListener(new StatusTextListener() {

                @Override
                public void changed(StatusTextEvent event) {
                    if (STATUS_TEXT_CLOSE.equals(event.text)) {
                        // For some reason disposing the shell / browser in the same Thread makes
                        // ieframe.dll crash on windows.
                        Utils.execSWTThreadLater(0, new Runnable() {

                            @Override
                            public void run() {
                                if (!browser.isDisposed() && !shell.isDisposed()) {
                                    shell.close();
                                }
                            }
                        });
                    }
                }
            });
        } catch (Exception e) {
            Debug.out(e);
            if (html != null) {
                Text text = new Text(shell, SWT.BORDER | SWT.READ_ONLY | SWT.WRAP);
                text.setText(html);
                GridData gd = new GridData(GridData.FILL_BOTH);
                gd.heightHint = 200;
                Utils.setLayoutData(text, gd);
            }
        }
        if (linkControl != null) {
            gridData = new GridData(GridData.FILL_HORIZONTAL);
            Utils.setLayoutData(linkControl, gridData);
        }
    } else {
        if (linkControl != null) {
            gridData = new GridData(GridData.FILL_BOTH);
            Utils.setLayoutData(linkControl, gridData);
        }
    }
    if (!squish && (autoCloseInMS > 0 || rememberID != null || (cbMessageID != null && Utils.getUserMode() >= cbMinUserMode))) {
        Label lblPadding = new Label(shell, SWT.NONE);
        gridData = new GridData(GridData.FILL_HORIZONTAL);
        gridData.heightHint = 5;
        Utils.setLayoutData(lblPadding, gridData);
    }
    // Closing in..
    if (autoCloseInMS > 0) {
        final BufferedLabel lblCloseIn = new BufferedLabel(shell, SWT.WRAP | SWT.DOUBLE_BUFFERED);
        lblCloseIn.setForeground(shell.getForeground());
        gridData = new GridData(GridData.FILL_HORIZONTAL);
        if (!squish) {
            gridData.horizontalIndent = 5;
        }
        lblCloseIn.setText(MessageText.getString("popup.closing.in", new String[] { String.valueOf(autoCloseInMS / 1000) }));
        Utils.setLayoutData(lblCloseIn, gridData);
        long endOn = SystemTime.getCurrentTime() + autoCloseInMS;
        lblCloseIn.setData("CloseOn", new Long(endOn));
        SimpleTimer.addPeriodicEvent("autoclose", 500, new TimerEventPerformer() {

            @Override
            public void perform(TimerEvent event) {
                if (shell.isDisposed()) {
                    event.cancel();
                    return;
                }
                Utils.execSWTThread(new AERunnable() {

                    @Override
                    public void runSupport() {
                        if (!shell.isDisposed()) {
                            boolean bDelayPaused = lblCloseIn.getData("DelayPaused") != null;
                            if (bDelayPaused) {
                                return;
                            }
                            long endOn = ((Long) lblCloseIn.getData("CloseOn")).longValue();
                            if (SystemTime.getCurrentTime() > endOn) {
                                result = defaultButtonPos;
                                autoClosed = true;
                                shell.dispose();
                            } else {
                                String sText = "";
                                if (lblCloseIn.isDisposed())
                                    return;
                                if (!bDelayPaused) {
                                    long delaySecs = (endOn - SystemTime.getCurrentTime()) / 1000;
                                    sText = MessageText.getString("popup.closing.in", new String[] { String.valueOf(delaySecs) });
                                }
                                lblCloseIn.setText(sText);
                            }
                        }
                    }
                });
            }
        });
        SimpleTimer.addPeriodicEvent("OverPopup", 100, new TimerEventPerformer() {

            boolean wasOver = true;

            long lEnterOn = 0;

            @Override
            public void perform(final TimerEvent event) {
                if (shell.isDisposed()) {
                    event.cancel();
                    return;
                }
                Utils.execSWTThread(new AERunnable() {

                    @Override
                    public void runSupport() {
                        if (shell.isDisposed()) {
                            event.cancel();
                            return;
                        }
                        boolean isOver = shell.getBounds().contains(shell.getDisplay().getCursorLocation());
                        if (isOver != wasOver) {
                            wasOver = isOver;
                            if (isOver) {
                                lblCloseIn.setData("DelayPaused", "");
                                lEnterOn = SystemTime.getCurrentTime();
                                lblCloseIn.setText("");
                            } else {
                                lblCloseIn.setData("DelayPaused", null);
                                if (lEnterOn > 0) {
                                    long diff = SystemTime.getCurrentTime() - lEnterOn;
                                    long endOn = ((Long) lblCloseIn.getData("CloseOn")).longValue() + diff;
                                    lblCloseIn.setData("CloseOn", new Long(endOn));
                                }
                            }
                        }
                    }
                });
            }
        });
    }
    if (cbMessageID != null && Utils.getUserMode() >= cbMinUserMode) {
        Button cb = new Button(shell, SWT.CHECK);
        cb.addSelectionListener(new SelectionListener() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                cbEnabled = ((Button) e.widget).getSelection();
            }

            @Override
            public void widgetDefaultSelected(SelectionEvent e) {
            }
        });
        Messages.setLanguageText(cb, cbMessageID);
        cb.setSelection(cbEnabled);
    }
    // Remember Me
    Button checkRemember = null;
    if (rememberID != null) {
        checkRemember = new Button(shell, SWT.CHECK);
        checkRemember.setText(rememberText);
        checkRemember.setSelection(rememberByDefault);
        isRemembered = rememberByDefault;
        checkRemember.addListener(SWT.Selection, new Listener() {

            @Override
            public void handleEvent(Event event) {
                Button checkRemember = (Button) event.widget;
                isRemembered = checkRemember.getSelection();
            }
        });
        checkRemember.addDisposeListener(new DisposeListener() {

            @Override
            public void widgetDisposed(DisposeEvent e) {
                Button checkRemember = (Button) e.widget;
                isRemembered = checkRemember != null && checkRemember.getSelection();
                if (rememberID != null && isRemembered && (rememberOnlyIfButtonPos == -1 || rememberOnlyIfButtonPos == result)) {
                    RememberedDecisionsManager.setRemembered(rememberID, getButtonVal(result));
                }
            }
        });
    } else {
        Button spacer = new Button(shell, SWT.CHECK);
        spacer.setVisible(false);
    }
    if (buttons.length > 0) {
        Canvas line = new Canvas(shell, SWT.NO_BACKGROUND);
        line.addListener(SWT.Paint, new Listener() {

            @Override
            public void handleEvent(Event e) {
                Rectangle clientArea = ((Canvas) e.widget).getClientArea();
                e.gc.setForeground(Colors.getSystemColor(e.display, SWT.COLOR_WIDGET_NORMAL_SHADOW));
                e.gc.drawRectangle(clientArea);
                clientArea.y++;
                e.gc.setForeground(Colors.getSystemColor(e.display, SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW));
                e.gc.drawRectangle(clientArea);
            }
        });
        gridData = new GridData(GridData.FILL_HORIZONTAL);
        gridData.heightHint = 2;
        Utils.setLayoutData(line, gridData);
        Composite cButtons = new Composite(shell, SWT.NONE);
        FormLayout layout = new FormLayout();
        cButtons.setLayout(layout);
        gridData = new GridData(GridData.HORIZONTAL_ALIGN_END);
        Utils.setLayoutData(cButtons, gridData);
        Control lastButton = null;
        Listener buttonListener = new Listener() {

            @Override
            public void handleEvent(Event event) {
                result = ((Integer) event.widget.getData()).intValue();
                shell.dispose();
            }
        };
        int buttonWidth = 0;
        Button[] swtButtons = new Button[buttons.length];
        for (int i = 0; i < buttons.length; i++) {
            Button button = new Button(cButtons, SWT.PUSH);
            swtButtons[i] = button;
            button.setData(Integer.valueOf(i));
            button.setText(buttons[i]);
            button.addListener(SWT.Selection, buttonListener);
            formData = new FormData();
            if (lastButton != null) {
                formData.left = new FormAttachment(lastButton, 5);
            }
            Utils.setLayoutData(button, formData);
            Point size = button.computeSize(SWT.DEFAULT, SWT.DEFAULT);
            if (size.x > buttonWidth) {
                buttonWidth = size.x;
            }
            if (i == defaultButtonPos) {
                button.setFocus();
                shell.setDefaultButton(button);
            }
            lastButton = button;
        }
        if (buttonWidth > 0) {
            if (buttonWidth < MIN_BUTTON_SIZE) {
                buttonWidth = MIN_BUTTON_SIZE;
            }
            for (int i = 0; i < buttons.length; i++) {
                Point size = swtButtons[i].computeSize(buttonWidth, SWT.DEFAULT);
                swtButtons[i].setSize(size);
                formData = (FormData) swtButtons[i].getLayoutData();
                formData.width = buttonWidth;
            }
        }
    }
    shell.addTraverseListener(new TraverseListener() {

        @Override
        public void keyTraversed(TraverseEvent event) {
            if (event.detail == SWT.TRAVERSE_ESCAPE) {
                shell.dispose();
            }
        }
    });
    filterListener = new Listener() {

        @Override
        public void handleEvent(Event event) {
            if (event.detail == SWT.TRAVERSE_ARROW_NEXT) {
                event.detail = SWT.TRAVERSE_TAB_NEXT;
                event.doit = true;
            } else if (event.detail == SWT.TRAVERSE_ARROW_PREVIOUS) {
                event.detail = SWT.TRAVERSE_TAB_PREVIOUS;
                event.doit = true;
            }
        }
    };
    display.addFilter(SWT.Traverse, filterListener);
    shell.pack();
    Point size = shell.getSize();
    if (size.x < min_size_x) {
        size.x = min_size_x;
        shell.setSize(size);
    } else if (size.x > max_size_x) {
        size = shell.computeSize(max_size_x, SWT.DEFAULT);
        shell.setSize(size);
    }
    if (size.y < min_size_y) {
        size.y = min_size_y;
        shell.setSize(size);
    }
    Shell centerRelativeToShell = parent;
    if (ourParent) {
        Control cursorControl = display.getCursorControl();
        if (cursorControl != null) {
            centerRelativeToShell = cursorControl.getShell();
        }
    }
    Utils.centerWindowRelativeTo(shell, centerRelativeToShell);
    for (int i = 0; i < listeners.length; i++) {
        listeners[i].skinAfterComponents(shell, this, relatedObjects);
    }
    shell.open();
    opened = true;
    numOpen++;
    return;
}
Also used : UISkinnableSWTListener(com.biglybt.ui.swt.UISkinnableSWTListener) UserPrompterResultListener(com.biglybt.ui.UserPrompterResultListener) BufferedLabel(com.biglybt.ui.swt.components.BufferedLabel) BufferedLabel(com.biglybt.ui.swt.components.BufferedLabel) BrowserWrapper(com.biglybt.ui.swt.BrowserWrapper) MessageText(com.biglybt.core.internat.MessageText) UISkinnableSWTListener(com.biglybt.ui.swt.UISkinnableSWTListener)

Example 18 with BufferedLabel

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

the class TransferStatsView method createConnectionPanel.

private void createConnectionPanel() {
    connectionPanel = new Composite(mainPanel, SWT.NONE);
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(connectionPanel, gridData);
    GridLayout panelLayout = new GridLayout();
    panelLayout.numColumns = 2;
    panelLayout.makeColumnsEqualWidth = true;
    connectionPanel.setLayout(panelLayout);
    Composite conn_area = new Composite(connectionPanel, SWT.NULL);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(conn_area, gridData);
    panelLayout = new GridLayout();
    panelLayout.numColumns = 2;
    conn_area.setLayout(panelLayout);
    Label label = new Label(conn_area, SWT.NULL);
    Messages.setLanguageText(label, "SpeedView.stats.con");
    connection_label = new BufferedLabel(conn_area, SWT.DOUBLE_BUFFERED);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(connection_label, gridData);
    Composite upload_area = new Composite(connectionPanel, SWT.NULL);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(upload_area, gridData);
    panelLayout = new GridLayout();
    panelLayout.numColumns = 2;
    upload_area.setLayout(panelLayout);
    label = new Label(upload_area, SWT.NULL);
    Messages.setLanguageText(label, "SpeedView.stats.upload");
    upload_label = new BufferedLabel(upload_area, SWT.DOUBLE_BUFFERED);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(upload_label, gridData);
    // connections
    con_folder = new TabFolder(connectionPanel, SWT.LEFT);
    gridData = new GridData(GridData.FILL_BOTH);
    gridData.horizontalSpan = 1;
    Utils.setLayoutData(con_folder, gridData);
    con_folder.setBackground(Colors.background);
    // connection counts
    TabItem conn_item = new TabItem(con_folder, SWT.NULL);
    conn_item.setText(MessageText.getString("label.connections"));
    Canvas connection_canvas = new Canvas(con_folder, SWT.NO_BACKGROUND);
    conn_item.setControl(connection_canvas);
    gridData = new GridData(GridData.FILL_BOTH);
    gridData.heightHint = 200;
    Utils.setLayoutData(connection_canvas, gridData);
    connection_graphic = SpeedGraphic.getInstance(new Scale(false), new ValueFormater() {

        @Override
        public String format(int value) {
            return (String.valueOf(value));
        }
    });
    connection_graphic.initialize(connection_canvas);
    Color[] colors = connection_graphic.colors;
    connection_graphic.setLineColors(colors);
    // route info
    TabItem route_info_tab = new TabItem(con_folder, SWT.NULL);
    route_info_tab.setText(MessageText.getString("label.routing"));
    Composite route_tab_comp = new Composite(con_folder, SWT.NULL);
    Utils.setLayoutData(route_tab_comp, new GridData(SWT.FILL, SWT.FILL, true, true));
    GridLayout routeTabLayout = new GridLayout();
    routeTabLayout.numColumns = 1;
    route_tab_comp.setLayout(routeTabLayout);
    route_info_tab.setControl(route_tab_comp);
    ScrolledComposite sc = new ScrolledComposite(route_tab_comp, SWT.V_SCROLL);
    Utils.setLayoutData(sc, new GridData(SWT.FILL, SWT.FILL, true, true));
    route_comp = new Composite(sc, SWT.NULL);
    Utils.setLayoutData(route_comp, new GridData(SWT.FILL, SWT.FILL, true, true));
    GridLayout routeLayout = new GridLayout();
    routeLayout.numColumns = 3;
    // routeLayout.makeColumnsEqualWidth = true;
    route_comp.setLayout(routeLayout);
    sc.setContent(route_comp);
    buildRouteComponent(5);
    // upload queued
    Canvas upload_canvas = new Canvas(connectionPanel, SWT.NO_BACKGROUND);
    gridData = new GridData(GridData.FILL_BOTH);
    gridData.heightHint = 200;
    Utils.setLayoutData(upload_canvas, gridData);
    upload_graphic = SpeedGraphic.getInstance(new ValueFormater() {

        @Override
        public String format(int value) {
            return DisplayFormatters.formatByteCountToKiBEtc(value);
        }
    });
    upload_graphic.initialize(upload_canvas);
}
Also used : BufferedLabel(com.biglybt.ui.swt.components.BufferedLabel) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) Canvas(org.eclipse.swt.widgets.Canvas) Color(org.eclipse.swt.graphics.Color) BufferedLabel(com.biglybt.ui.swt.components.BufferedLabel) Label(org.eclipse.swt.widgets.Label) TabFolder(org.eclipse.swt.widgets.TabFolder) ValueFormater(com.biglybt.ui.swt.components.graphics.ValueFormater) Scale(com.biglybt.ui.swt.components.graphics.Scale) TabItem(org.eclipse.swt.widgets.TabItem) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite)

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