Search in sources :

Example 46 with ImageLoader

use of com.biglybt.ui.swt.imageloader.ImageLoader in project BiglyBT by BiglySoftware.

the class ConfigSectionPlugins method configSectionCreate.

@Override
public Composite configSectionCreate(final Composite parent) {
    if (!CoreFactory.isCoreRunning()) {
        Composite cSection = new Composite(parent, SWT.NULL);
        cSection.setLayout(new FillLayout());
        Label lblNotAvail = new Label(cSection, SWT.WRAP);
        Messages.setLanguageText(lblNotAvail, "core.not.available");
        return cSection;
    }
    GridLayout layout;
    GridData gridData;
    Label label;
    ImageLoader imageLoader = ImageLoader.getInstance();
    imgRedLed = imageLoader.getImage("redled");
    imgGreenLed = imageLoader.getImage("greenled");
    Composite infoGroup = new Composite(parent, SWT.NULL);
    gridData = new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL);
    Utils.setLayoutData(infoGroup, gridData);
    layout = new GridLayout();
    layout.numColumns = 1;
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    infoGroup.setLayout(layout);
    infoGroup.setLayout(new GridLayout());
    String sep = System.getProperty("file.separator");
    File fUserPluginDir = FileUtil.getUserFile("plugins");
    String sUserPluginDir;
    try {
        sUserPluginDir = fUserPluginDir.getCanonicalPath();
    } catch (Throwable e) {
        sUserPluginDir = fUserPluginDir.toString();
    }
    if (!sUserPluginDir.endsWith(sep)) {
        sUserPluginDir += sep;
    }
    File fAppPluginDir = FileUtil.getApplicationFile("plugins");
    String sAppPluginDir;
    try {
        sAppPluginDir = fAppPluginDir.getCanonicalPath();
    } catch (Throwable e) {
        sAppPluginDir = fAppPluginDir.toString();
    }
    if (!sAppPluginDir.endsWith(sep)) {
        sAppPluginDir += sep;
    }
    label = new Label(infoGroup, SWT.WRAP);
    Utils.setLayoutData(label, new GridData(GridData.FILL_HORIZONTAL));
    Messages.setLanguageText(label, "ConfigView.pluginlist.whereToPut");
    label = new Label(infoGroup, SWT.WRAP);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalIndent = 10;
    Utils.setLayoutData(label, gridData);
    label.setText(sUserPluginDir.replaceAll("&", "&&"));
    label.setForeground(Colors.blue);
    label.setCursor(label.getDisplay().getSystemCursor(SWT.CURSOR_HAND));
    final String _sUserPluginDir = sUserPluginDir;
    label.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseUp(MouseEvent arg0) {
            if (_sUserPluginDir.endsWith("/plugins/") || _sUserPluginDir.endsWith("\\plugins\\")) {
                File f = new File(_sUserPluginDir);
                String dir = _sUserPluginDir;
                if (!(f.exists() && f.isDirectory())) {
                    dir = _sUserPluginDir.substring(0, _sUserPluginDir.length() - 9);
                }
                Utils.launch(dir);
            }
        }
    });
    label = new Label(infoGroup, SWT.WRAP);
    Utils.setLayoutData(label, new GridData(GridData.FILL_HORIZONTAL));
    Messages.setLanguageText(label, "ConfigView.pluginlist.whereToPutOr");
    label = new Label(infoGroup, SWT.WRAP);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalIndent = 10;
    Utils.setLayoutData(label, gridData);
    label.setText(sAppPluginDir.replaceAll("&", "&&"));
    label.setForeground(Colors.blue);
    label.setCursor(label.getDisplay().getSystemCursor(SWT.CURSOR_HAND));
    final String _sAppPluginDir = sAppPluginDir;
    // TODO : Fix it for windows
    label.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseUp(MouseEvent arg0) {
            if (_sAppPluginDir.endsWith("/plugins/") || _sAppPluginDir.endsWith("\\plugins\\")) {
                File f = new File(_sAppPluginDir);
                if (f.exists() && f.isDirectory()) {
                    Utils.launch(_sAppPluginDir);
                } else {
                    String appDir = _sAppPluginDir.substring(0, _sAppPluginDir.length() - 9);
                    System.out.println(appDir);
                    Utils.launch(appDir);
                }
            }
        }
    });
    pluginIFs = rebuildPluginIFs();
    Collections.sort(pluginIFs, new Comparator() {

        @Override
        public int compare(Object o1, Object o2) {
            return (((PluginInterface) o1).getPluginName().compareToIgnoreCase(((PluginInterface) o2).getPluginName()));
        }
    });
    Label labelInfo = new Label(infoGroup, SWT.WRAP);
    Utils.setLayoutData(labelInfo, new GridData(GridData.FILL_HORIZONTAL));
    Messages.setLanguageText(labelInfo, "ConfigView.pluginlist.info");
    table = new Table(infoGroup, SWT.BORDER | SWT.SINGLE | SWT.CHECK | SWT.VIRTUAL | SWT.FULL_SELECTION);
    gridData = new GridData(GridData.FILL_BOTH);
    gridData.heightHint = 200;
    gridData.widthHint = 200;
    Utils.setLayoutData(table, gridData);
    for (int i = 0; i < COLUMN_HEADERS.length; i++) {
        final TableColumn tc = new TableColumn(table, COLUMN_ALIGNS[i]);
        tc.setWidth(Utils.adjustPXForDPI(COLUMN_SIZES[i]));
        tc.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                boolean ascending = comparator.setField(table.indexOf(tc));
                try {
                    table.setSortColumn(tc);
                    table.setSortDirection(ascending ? SWT.UP : SWT.DOWN);
                } catch (NoSuchMethodError ignore) {
                // Ignore Pre 3.0
                }
                Collections.sort(pluginIFs, comparator);
                table.clearAll();
            }
        });
        Messages.setLanguageText(tc, HEADER_PREFIX + COLUMN_HEADERS[i]);
    }
    table.setHeaderVisible(true);
    Composite cButtons = new Composite(infoGroup, SWT.NONE);
    layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.numColumns = 5;
    cButtons.setLayout(layout);
    Utils.setLayoutData(cButtons, new GridData());
    final Button btnUnload = new Button(cButtons, SWT.PUSH);
    Utils.setLayoutData(btnUnload, new GridData());
    Messages.setLanguageText(btnUnload, "ConfigView.pluginlist.unloadSelected");
    btnUnload.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            final int[] items = table.getSelectionIndices();
            new AEThread2("unload") {

                @Override
                public void run() {
                    for (int i = 0; i < items.length; i++) {
                        int index = items[i];
                        if (index >= 0 && index < pluginIFs.size()) {
                            PluginInterface pluginIF = (PluginInterface) pluginIFs.get(index);
                            if (pluginIF.getPluginState().isOperational()) {
                                if (pluginIF.getPluginState().isUnloadable()) {
                                    try {
                                        pluginIF.getPluginState().unload();
                                    } catch (PluginException e1) {
                                        // TODO Auto-generated catch block
                                        e1.printStackTrace();
                                    }
                                }
                            }
                            Utils.execSWTThread(new Runnable() {

                                @Override
                                public void run() {
                                    pluginIFs = rebuildPluginIFs();
                                    table.setItemCount(pluginIFs.size());
                                    Collections.sort(pluginIFs, comparator);
                                    table.clearAll();
                                }
                            });
                        }
                    }
                }
            }.start();
        }
    });
    btnUnload.setEnabled(false);
    final Button btnLoad = new Button(cButtons, SWT.PUSH);
    Utils.setLayoutData(btnUnload, new GridData());
    Messages.setLanguageText(btnLoad, "ConfigView.pluginlist.loadSelected");
    btnLoad.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            final int[] items = table.getSelectionIndices();
            new AEThread2("load") {

                @Override
                public void run() {
                    for (int i = 0; i < items.length; i++) {
                        int index = items[i];
                        if (index >= 0 && index < pluginIFs.size()) {
                            PluginInterface pluginIF = (PluginInterface) pluginIFs.get(index);
                            // Already loaded.
                            if (pluginIF.getPluginState().isOperational()) {
                                continue;
                            }
                            // initialise.
                            if (pluginIF.getPluginState().isDisabled()) {
                                if (pluginIF.getPluginState().hasFailed()) {
                                    continue;
                                }
                                pluginIF.getPluginState().setDisabled(false);
                            }
                            try {
                                pluginIF.getPluginState().reload();
                            } catch (PluginException e1) {
                                // TODO Auto-generated catch block
                                Debug.printStackTrace(e1);
                            }
                            Utils.execSWTThread(new Runnable() {

                                @Override
                                public void run() {
                                    if (table == null || table.isDisposed()) {
                                        return;
                                    }
                                    pluginIFs = rebuildPluginIFs();
                                    table.setItemCount(pluginIFs.size());
                                    Collections.sort(pluginIFs, comparator);
                                    table.clearAll();
                                }
                            });
                        }
                    }
                }
            }.start();
        }
    });
    btnLoad.setEnabled(false);
    // scan
    final Button btnScan = new Button(cButtons, SWT.PUSH);
    Utils.setLayoutData(btnScan, new GridData());
    Messages.setLanguageText(btnScan, "ConfigView.pluginlist.scan");
    btnScan.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            CoreFactory.getSingleton().getPluginManager().refreshPluginList(false);
            pluginIFs = rebuildPluginIFs();
            table.setItemCount(pluginIFs.size());
            Collections.sort(pluginIFs, comparator);
            table.clearAll();
        }
    });
    // uninstall
    final Button btnUninstall = new Button(cButtons, SWT.PUSH);
    Utils.setLayoutData(btnUninstall, new GridData());
    Messages.setLanguageText(btnUninstall, "ConfigView.pluginlist.uninstallSelected");
    btnUninstall.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            btnUninstall.setEnabled(false);
            final int[] items = table.getSelectionIndices();
            new AEThread2("uninstall") {

                @Override
                public void run() {
                    try {
                        List<PluginInterface> pis = new ArrayList<>();
                        for (int i = 0; i < items.length; i++) {
                            int index = items[i];
                            if (index >= 0 && index < pluginIFs.size()) {
                                PluginInterface pluginIF = (PluginInterface) pluginIFs.get(index);
                                pis.add(pluginIF);
                            }
                        }
                        if (pis.size() > 0) {
                            PluginInterface[] ps = new PluginInterface[pis.size()];
                            pis.toArray(ps);
                            try {
                                final AESemaphore wait_sem = new AESemaphore("unist:wait");
                                ps[0].getPluginManager().getPluginInstaller().uninstall(ps, new PluginInstallationListener() {

                                    @Override
                                    public void completed() {
                                        wait_sem.release();
                                    }

                                    @Override
                                    public void cancelled() {
                                        wait_sem.release();
                                    }

                                    @Override
                                    public void failed(PluginException e) {
                                        wait_sem.release();
                                    }
                                });
                                wait_sem.reserve();
                            } catch (Exception e) {
                                Debug.printStackTrace(e);
                            }
                        }
                    } finally {
                        Utils.execSWTThread(new Runnable() {

                            @Override
                            public void run() {
                                pluginIFs = rebuildPluginIFs();
                                table.setItemCount(pluginIFs.size());
                                Collections.sort(pluginIFs, comparator);
                                table.clearAll();
                                table.setSelection(new int[0]);
                            }
                        });
                    }
                }
            }.start();
        }
    });
    btnUninstall.setEnabled(false);
    table.addListener(SWT.SetData, new Listener() {

        @Override
        public void handleEvent(Event event) {
            TableItem item = (TableItem) event.item;
            int index = table.indexOf(item);
            PluginInterface pluginIF = (PluginInterface) pluginIFs.get(index);
            for (int i = 0; i < COLUMN_HEADERS.length; i++) {
                if (i == FilterComparator.FIELD_NAME)
                    item.setImage(i, pluginIF.getPluginState().isOperational() ? imgGreenLed : imgRedLed);
                String sText = comparator.getFieldValue(i, pluginIF);
                if (sText == null)
                    sText = "";
                item.setText(i, sText);
            }
            item.setGrayed(pluginIF.getPluginState().isMandatory());
            boolean bEnabled = pluginIF.getPluginState().isLoadedAtStartup();
            Utils.setCheckedInSetData(item, bEnabled);
            item.setData("PluginID", pluginIF.getPluginID());
            Utils.alternateRowBackground(item);
        }
    });
    table.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDoubleClick(MouseEvent e) {
            TableItem[] items = table.getSelection();
            if (items.length == 1) {
                int index = table.indexOf(items[0]);
                PluginInterface pluginIF = (PluginInterface) pluginIFs.get(index);
                PluginConfigModel[] models = pluginIF.getUIManager().getPluginConfigModels();
                for (PluginConfigModel model : models) {
                    if (model.getPluginInterface() == pluginIF) {
                        if (model instanceof BasicPluginConfigModel) {
                            String id = ((BasicPluginConfigModel) model).getSection();
                            UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions();
                            if (uiFunctions != null) {
                                uiFunctions.getMDI().showEntryByID(MultipleDocumentInterface.SIDEBAR_SECTION_CONFIG, id);
                            }
                        }
                    }
                }
            }
        }
    });
    table.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            TableItem item = (TableItem) e.item;
            int index = table.indexOf(item);
            PluginInterface pluginIF = (PluginInterface) pluginIFs.get(index);
            if (e.detail == SWT.CHECK) {
                if (item.getGrayed()) {
                    if (!item.getChecked())
                        item.setChecked(true);
                    return;
                }
                pluginIF.getPluginState().setDisabled(!item.getChecked());
                pluginIF.getPluginState().setLoadedAtStartup(item.getChecked());
            }
            btnUnload.setEnabled(pluginIF.getPluginState().isOperational() && pluginIF.getPluginState().isUnloadable());
            btnLoad.setEnabled(!pluginIF.getPluginState().isOperational() && !pluginIF.getPluginState().hasFailed());
            btnUninstall.setEnabled(!(pluginIF.getPluginState().isBuiltIn() || pluginIF.getPluginState().isMandatory()));
        }
    });
    table.setItemCount(pluginIFs.size());
    return infoGroup;
}
Also used : ParameterListener(com.biglybt.core.config.ParameterListener) PluginInstallationListener(com.biglybt.pif.installer.PluginInstallationListener) GridLayout(org.eclipse.swt.layout.GridLayout) PluginInstallationListener(com.biglybt.pif.installer.PluginInstallationListener) UIFunctions(com.biglybt.ui.UIFunctions) SelectionEvent(org.eclipse.swt.events.SelectionEvent) BasicPluginConfigModel(com.biglybt.pif.ui.model.BasicPluginConfigModel) PluginConfigModel(com.biglybt.pif.ui.model.PluginConfigModel) MouseEvent(org.eclipse.swt.events.MouseEvent) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) PluginInterface(com.biglybt.pif.PluginInterface) PluginException(com.biglybt.pif.PluginException) MouseAdapter(org.eclipse.swt.events.MouseAdapter) FillLayout(org.eclipse.swt.layout.FillLayout) PluginException(com.biglybt.pif.PluginException) GridData(org.eclipse.swt.layout.GridData) MouseEvent(org.eclipse.swt.events.MouseEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ImageLoader(com.biglybt.ui.swt.imageloader.ImageLoader) File(java.io.File) BasicPluginConfigModel(com.biglybt.pif.ui.model.BasicPluginConfigModel)

Example 47 with ImageLoader

use of com.biglybt.ui.swt.imageloader.ImageLoader in project BiglyBT by BiglySoftware.

the class ConfigSectionSecurity method configSectionDelete.

@Override
public void configSectionDelete() {
    ImageLoader imageLoader = ImageLoader.getInstance();
    imageLoader.releaseImage("openFolderButton");
}
Also used : ImageLoader(com.biglybt.ui.swt.imageloader.ImageLoader)

Example 48 with ImageLoader

use of com.biglybt.ui.swt.imageloader.ImageLoader in project BiglyBT by BiglySoftware.

the class ConfigSectionStats method configSectionDelete.

@Override
public void configSectionDelete() {
    ImageLoader imageLoader = ImageLoader.getInstance();
    imageLoader.releaseImage("openFolderButton");
}
Also used : ImageLoader(com.biglybt.ui.swt.imageloader.ImageLoader)

Example 49 with ImageLoader

use of com.biglybt.ui.swt.imageloader.ImageLoader in project BiglyBT by BiglySoftware.

the class ConfigSectionStats method configSectionCreate.

@Override
public Composite configSectionCreate(final Composite parent) {
    ImageLoader imageLoader = ImageLoader.getInstance();
    Image imgOpenFolder = imageLoader.getImage("openFolderButton");
    GridData gridData;
    GridLayout layout;
    Composite gOutter = new Composite(parent, SWT.NULL);
    gridData = new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL);
    gOutter.setLayoutData(gridData);
    layout = new GridLayout();
    layout.numColumns = 1;
    gOutter.setLayout(layout);
    // general
    Group gGeneral = new Group(gOutter, SWT.NULL);
    Messages.setLanguageText(gGeneral, "ConfigView.section.general");
    layout = new GridLayout(2, false);
    gGeneral.setLayout(layout);
    gGeneral.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    Label lSmooth = new Label(gGeneral, SWT.NULL);
    Messages.setLanguageText(lSmooth, "stats.general.smooth_secs");
    IntParameter smooth_secs = new IntParameter(gGeneral, "Stats Smoothing Secs", 30, 30 * 60);
    // display
    Group gDisplay = new Group(gOutter, SWT.NULL);
    Messages.setLanguageText(gDisplay, "stats.display.group");
    layout = new GridLayout(1, false);
    gDisplay.setLayout(layout);
    gDisplay.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    gridData = new GridData();
    BooleanParameter graph_dividers = new BooleanParameter(gDisplay, "Stats Graph Dividers", "ConfigView.section.stats.graph_update_dividers");
    graph_dividers.setLayoutData(gridData);
    // snapshots
    Group gSnap = new Group(gOutter, SWT.NULL);
    Messages.setLanguageText(gSnap, "stats.snapshot.group");
    layout = new GridLayout(3, false);
    gSnap.setLayout(layout);
    gSnap.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    // row
    gridData = new GridData();
    gridData.horizontalSpan = 3;
    BooleanParameter enableStats = new BooleanParameter(gSnap, "Stats Enable", "ConfigView.section.stats.enable");
    enableStats.setLayoutData(gridData);
    Control[] controls = new Control[13];
    // row
    Label lStatsPath = new Label(gSnap, SWT.NULL);
    // $NON-NLS-1$
    Messages.setLanguageText(lStatsPath, "ConfigView.section.stats.defaultsavepath");
    gridData = new GridData();
    gridData.widthHint = 150;
    // $NON-NLS-1$ //$NON-NLS-2$
    final StringParameter pathParameter = new StringParameter(gSnap, "Stats Dir", "");
    pathParameter.setLayoutData(gridData);
    controls[0] = lStatsPath;
    controls[1] = pathParameter.getControl();
    Button browse = new Button(gSnap, SWT.PUSH);
    browse.setImage(imgOpenFolder);
    imgOpenFolder.setBackground(browse.getBackground());
    browse.setToolTipText(MessageText.getString("ConfigView.button.browse"));
    controls[2] = browse;
    browse.addListener(SWT.Selection, new Listener() {

        /* (non-Javadoc)
       * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
       */
        @Override
        public void handleEvent(Event event) {
            DirectoryDialog dialog = new DirectoryDialog(parent.getShell(), SWT.APPLICATION_MODAL);
            dialog.setFilterPath(pathParameter.getValue());
            // $NON-NLS-1$
            dialog.setText(MessageText.getString("ConfigView.section.stats.choosedefaultsavepath"));
            String path = dialog.open();
            if (path != null) {
                pathParameter.setValue(path);
            }
        }
    });
    // row
    Label lSaveFile = new Label(gSnap, SWT.NULL);
    // $NON-NLS-1$
    Messages.setLanguageText(lSaveFile, "ConfigView.section.stats.savefile");
    controls[3] = lSaveFile;
    gridData = new GridData();
    gridData.widthHint = 150;
    final StringParameter fileParameter = new StringParameter(gSnap, "Stats File", StatsWriterPeriodic.DEFAULT_STATS_FILE_NAME);
    fileParameter.setLayoutData(gridData);
    controls[4] = fileParameter.getControl();
    new Label(gSnap, SWT.NULL);
    // row
    Label lxslFile = new Label(gSnap, SWT.NULL);
    // $NON-NLS-1$
    Messages.setLanguageText(lxslFile, "ConfigView.section.stats.xslfile");
    controls[5] = lxslFile;
    gridData = new GridData();
    gridData.widthHint = 150;
    final StringParameter xslParameter = new StringParameter(gSnap, "Stats XSL File", "");
    xslParameter.setLayoutData(gridData);
    controls[6] = xslParameter.getControl();
    Label lxslDetails = new Label(gSnap, SWT.NULL);
    // $NON-NLS-1$
    Messages.setLanguageText(lxslDetails, "ConfigView.section.stats.xslfiledetails");
    final String linkFAQ = Constants.PLUGINS_WEB_SITE + "faq.php#20";
    lxslDetails.setCursor(lxslDetails.getDisplay().getSystemCursor(SWT.CURSOR_HAND));
    lxslDetails.setForeground(Colors.blue);
    lxslDetails.setData(linkFAQ);
    lxslDetails.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDoubleClick(MouseEvent arg0) {
            Utils.launch(linkFAQ);
        }

        @Override
        public void mouseDown(MouseEvent arg0) {
            Utils.launch(linkFAQ);
        }
    });
    ClipboardCopy.addCopyToClipMenu(lxslDetails);
    controls[7] = lxslDetails;
    // row
    Label lSaveFreq = new Label(gSnap, SWT.NULL);
    Messages.setLanguageText(lSaveFreq, "ConfigView.section.stats.savefreq");
    controls[8] = lSaveFreq;
    final String[] spLabels = new String[statsPeriods.length];
    final int[] spValues = new int[statsPeriods.length];
    for (int i = 0; i < statsPeriods.length; i++) {
        int num = statsPeriods[i];
        if (num % 3600 == 0)
            spLabels[i] = " " + (statsPeriods[i] / 3600) + " " + MessageText.getString("ConfigView.section.stats.hours");
        else if (num % 60 == 0)
            spLabels[i] = " " + (statsPeriods[i] / 60) + " " + MessageText.getString("ConfigView.section.stats.minutes");
        else
            spLabels[i] = " " + statsPeriods[i] + " " + MessageText.getString("ConfigView.section.stats.seconds");
        spValues[i] = statsPeriods[i];
    }
    controls[9] = lSaveFreq;
    controls[10] = new IntListParameter(gSnap, "Stats Period", defaultStatsPeriod, spLabels, spValues).getControl();
    new Label(gSnap, SWT.NULL);
    // ROW
    gridData = new GridData();
    gridData.horizontalSpan = 3;
    BooleanParameter exportPeers = new BooleanParameter(gSnap, "Stats Export Peer Details", "ConfigView.section.stats.exportpeers");
    exportPeers.setLayoutData(gridData);
    controls[11] = exportPeers.getControl();
    // ROW
    gridData = new GridData();
    gridData.horizontalSpan = 3;
    BooleanParameter exportFiles = new BooleanParameter(gSnap, "Stats Export File Details", "ConfigView.section.stats.exportfiles");
    exportFiles.setLayoutData(gridData);
    controls[12] = exportFiles.getControl();
    // control stuff
    enableStats.setAdditionalActionPerformer(new ChangeSelectionActionPerformer(controls));
    // xfer
    Group gXfer = new Group(gOutter, SWT.NULL);
    Messages.setLanguageText(gXfer, "ConfigView.section.transfer");
    layout = new GridLayout(3, false);
    gXfer.setLayout(layout);
    gXfer.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    List<Button> buttons = new ArrayList<>();
    // set mark
    Label set_mark_label = new Label(gXfer, SWT.NULL);
    Messages.setLanguageText(set_mark_label, "ConfigView.section.transfer.setmark");
    Button set_mark_button = new Button(gXfer, SWT.PUSH);
    buttons.add(set_mark_button);
    Messages.setLanguageText(set_mark_button, "Button.set");
    set_mark_button.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(Event event) {
            OverallStats stats = StatsFactory.getStats();
            stats.setMark();
        }
    });
    Button clear_mark_button = new Button(gXfer, SWT.PUSH);
    buttons.add(clear_mark_button);
    Messages.setLanguageText(clear_mark_button, "Button.clear");
    clear_mark_button.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(Event event) {
            OverallStats stats = StatsFactory.getStats();
            stats.clearMark();
        }
    });
    // long term
    Group gLong = new Group(gOutter, SWT.NULL);
    Messages.setLanguageText(gLong, "stats.longterm.group");
    layout = new GridLayout(2, false);
    gLong.setLayout(layout);
    gLong.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    // row
    gridData = new GridData();
    gridData.horizontalSpan = 2;
    BooleanParameter enableLongStats = new BooleanParameter(gLong, "long.term.stats.enable", "ConfigView.section.stats.enable");
    enableLongStats.setLayoutData(gridData);
    // week start
    Label lWeekStart = new Label(gLong, SWT.NULL);
    Messages.setLanguageText(lWeekStart, "stats.long.weekstart");
    final String[] wsLabels = new String[7];
    final int[] wsValues = new int[7];
    Calendar cal = new GregorianCalendar();
    SimpleDateFormat format = new SimpleDateFormat("E");
    for (int i = 0; i < 7; i++) {
        // sun = 1 etc
        int dow = i + 1;
        cal.set(Calendar.DAY_OF_WEEK, dow);
        wsLabels[i] = format.format(cal.getTime());
        wsValues[i] = i + 1;
    }
    IntListParameter week_start = new IntListParameter(gLong, "long.term.stats.weekstart", Calendar.SUNDAY, wsLabels, wsValues);
    // month start
    Label lMonthStart = new Label(gLong, SWT.NULL);
    Messages.setLanguageText(lMonthStart, "stats.long.monthstart");
    IntParameter month_start = new IntParameter(gLong, "long.term.stats.monthstart", 1, 28);
    enableLongStats.setAdditionalActionPerformer(new ChangeSelectionActionPerformer(new Control[] { lWeekStart, lMonthStart }));
    enableLongStats.setAdditionalActionPerformer(new ChangeSelectionActionPerformer(week_start, month_start));
    // reset
    Label lt_reset_label = new Label(gLong, SWT.NULL);
    Messages.setLanguageText(lt_reset_label, "ConfigView.section.transfer.lts.reset");
    Button lt_reset_button = new Button(gLong, SWT.PUSH);
    buttons.add(lt_reset_button);
    Messages.setLanguageText(lt_reset_button, "Button.clear");
    lt_reset_button.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(Event event) {
            MessageBoxShell mb = new MessageBoxShell(SWT.ICON_WARNING | SWT.OK | SWT.CANCEL, MessageText.getString("ConfigView.section.security.resetcerts.warning.title"), MessageText.getString("ConfigView.section.transfer.ltsreset.warning.msg"));
            mb.setDefaultButtonUsingStyle(SWT.CANCEL);
            mb.setParent(parent.getShell());
            mb.open(new UserPrompterResultListener() {

                @Override
                public void prompterClosed(int returnVal) {
                    if (returnVal != SWT.OK) {
                        return;
                    }
                    Utils.getOffOfSWTThread(new AERunnable() {

                        @Override
                        public void runSupport() {
                            StatsFactory.clearLongTermStats();
                        }
                    });
                }
            });
        }
    });
    Utils.makeButtonsEqualWidth(buttons);
    return gOutter;
}
Also used : AERunnable(com.biglybt.core.util.AERunnable) Group(org.eclipse.swt.widgets.Group) UserPrompterResultListener(com.biglybt.ui.UserPrompterResultListener) Listener(org.eclipse.swt.widgets.Listener) OverallStats(com.biglybt.core.stats.transfer.OverallStats) Label(org.eclipse.swt.widgets.Label) ArrayList(java.util.ArrayList) Image(org.eclipse.swt.graphics.Image) GridLayout(org.eclipse.swt.layout.GridLayout) Control(org.eclipse.swt.widgets.Control) Button(org.eclipse.swt.widgets.Button) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog) MouseEvent(org.eclipse.swt.events.MouseEvent) Composite(org.eclipse.swt.widgets.Composite) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) MouseAdapter(org.eclipse.swt.events.MouseAdapter) GregorianCalendar(java.util.GregorianCalendar) MessageBoxShell(com.biglybt.ui.swt.shells.MessageBoxShell) UserPrompterResultListener(com.biglybt.ui.UserPrompterResultListener) GridData(org.eclipse.swt.layout.GridData) Event(org.eclipse.swt.widgets.Event) MouseEvent(org.eclipse.swt.events.MouseEvent) ImageLoader(com.biglybt.ui.swt.imageloader.ImageLoader) SimpleDateFormat(java.text.SimpleDateFormat)

Example 50 with ImageLoader

use of com.biglybt.ui.swt.imageloader.ImageLoader in project BiglyBT by BiglySoftware.

the class ConfigSectionTransfer method configSectionDelete.

@Override
public void configSectionDelete() {
    ImageLoader imageLoader = ImageLoader.getInstance();
    imageLoader.releaseImage("subitem");
}
Also used : ImageLoader(com.biglybt.ui.swt.imageloader.ImageLoader)

Aggregations

ImageLoader (com.biglybt.ui.swt.imageloader.ImageLoader)78 Image (org.eclipse.swt.graphics.Image)20 GridData (org.eclipse.swt.layout.GridData)16 GridLayout (org.eclipse.swt.layout.GridLayout)16 Rectangle (org.eclipse.swt.graphics.Rectangle)6 MessageText (com.biglybt.core.internat.MessageText)5 AERunnable (com.biglybt.core.util.AERunnable)5 UIFunctions (com.biglybt.ui.UIFunctions)5 UserPrompterResultListener (com.biglybt.ui.UserPrompterResultListener)5 File (java.io.File)5 ArrayList (java.util.ArrayList)5 Core (com.biglybt.core.Core)4 CoreRunningListener (com.biglybt.core.CoreRunningListener)4 MessageBoxShell (com.biglybt.ui.swt.shells.MessageBoxShell)4 MouseAdapter (org.eclipse.swt.events.MouseAdapter)4 MouseEvent (org.eclipse.swt.events.MouseEvent)4 Point (org.eclipse.swt.graphics.Point)4 Subscription (com.biglybt.core.subs.Subscription)3 MenuItem (com.biglybt.pif.ui.menus.MenuItem)3 TableColumnCreationListener (com.biglybt.pif.ui.tables.TableColumnCreationListener)3