Search in sources :

Example 6 with ImageLoader

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

the class ConfigSectionTransfer method configSectionCreate.

@Override
public Composite configSectionCreate(final Composite parent) {
    GridData gridData;
    GridLayout layout;
    Label label;
    Composite cSection = new Composite(parent, SWT.NULL);
    gridData = new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL);
    Utils.setLayoutData(cSection, gridData);
    layout = new GridLayout();
    layout.numColumns = 2;
    layout.marginHeight = 0;
    cSection.setLayout(layout);
    int userMode = COConfigurationManager.getIntParameter("User Mode");
    // store the initial d/l speed so we can do something sensible later
    final int[] manual_max_download_speed = { COConfigurationManager.getIntParameter("Max Download Speed KBs") };
    // max upload speed
    gridData = new GridData();
    label = new Label(cSection, SWT.NULL);
    Utils.setLayoutData(label, gridData);
    Messages.setLanguageText(label, "ConfigView.label.maxuploadspeed");
    gridData = new GridData();
    final IntParameter paramMaxUploadSpeed = new IntParameter(cSection, "Max Upload Speed KBs", 0, Integer.MAX_VALUE);
    paramMaxUploadSpeed.setLayoutData(gridData);
    // max upload speed when seeding
    final Composite cMaxUploadSpeedOptionsArea = new Composite(cSection, SWT.NULL);
    layout = new GridLayout();
    layout.numColumns = 3;
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    cMaxUploadSpeedOptionsArea.setLayout(layout);
    gridData = new GridData();
    gridData.horizontalIndent = 15;
    gridData.horizontalSpan = 2;
    Utils.setLayoutData(cMaxUploadSpeedOptionsArea, gridData);
    ImageLoader imageLoader = ImageLoader.getInstance();
    Image img = imageLoader.getImage("subitem");
    label = new Label(cMaxUploadSpeedOptionsArea, SWT.NULL);
    img.setBackground(label.getBackground());
    gridData = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
    Utils.setLayoutData(label, gridData);
    label.setImage(img);
    gridData = new GridData();
    final BooleanParameter enable_seeding_rate = new BooleanParameter(cMaxUploadSpeedOptionsArea, "enable.seedingonly.upload.rate", "ConfigView.label.maxuploadspeedseeding");
    enable_seeding_rate.setLayoutData(gridData);
    gridData = new GridData();
    final IntParameter paramMaxUploadSpeedSeeding = new IntParameter(cMaxUploadSpeedOptionsArea, "Max Upload Speed Seeding KBs", 0, Integer.MAX_VALUE);
    paramMaxUploadSpeedSeeding.setLayoutData(gridData);
    enable_seeding_rate.setAdditionalActionPerformer(new ChangeSelectionActionPerformer(paramMaxUploadSpeedSeeding.getControl()));
    if (userMode < 2) {
        // wiki link
        Composite cWiki = new Composite(cSection, SWT.COLOR_GRAY);
        gridData = new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL);
        gridData.horizontalSpan = 2;
        Utils.setLayoutData(cWiki, gridData);
        layout = new GridLayout();
        layout.numColumns = 4;
        layout.marginHeight = 0;
        cWiki.setLayout(layout);
        gridData = new GridData();
        gridData.horizontalIndent = 6;
        gridData.horizontalSpan = 2;
        label = new Label(cWiki, SWT.NULL);
        Utils.setLayoutData(label, gridData);
        label.setText(MessageText.getString("Utils.link.visit") + ":");
        gridData = new GridData();
        gridData.horizontalIndent = 10;
        gridData.horizontalSpan = 2;
        new LinkLabel(cWiki, gridData, "ConfigView.section.transfer.speeds.wiki", Constants.URL_WIKI + "w/Good_settings");
    }
    if (userMode > 1) {
        gridData = new GridData();
        label = new Label(cSection, SWT.NULL);
        Utils.setLayoutData(label, gridData);
        Messages.setLanguageText(label, "ConfigView.label.maxuploadswhenbusymin");
        gridData = new GridData();
        new IntParameter(cSection, "max.uploads.when.busy.inc.min.secs", 0, Integer.MAX_VALUE).setLayoutData(gridData);
    }
    // max download speed
    gridData = new GridData();
    label = new Label(cSection, SWT.NULL);
    Utils.setLayoutData(label, gridData);
    Messages.setLanguageText(label, "ConfigView.label.maxdownloadspeed");
    gridData = new GridData();
    final IntParameter paramMaxDownSpeed = new IntParameter(cSection, "Max Download Speed KBs", 0, Integer.MAX_VALUE);
    paramMaxDownSpeed.setLayoutData(gridData);
    // max upload/download limit dependencies
    Listener l = new Listener() {

        @Override
        public void handleEvent(Event event) {
            boolean disableAuto = false;
            boolean disableAutoSeeding = false;
            if (enable_seeding_rate.isSelected()) {
                disableAutoSeeding = event.widget == paramMaxUploadSpeedSeeding.getControl();
                disableAuto = event.widget == paramMaxDownSpeed.getControl() || event.widget == paramMaxUploadSpeed.getControl();
            } else {
                disableAuto = true;
                disableAutoSeeding = true;
            }
            if (disableAuto)
                COConfigurationManager.setParameter(TransferSpeedValidator.AUTO_UPLOAD_ENABLED_CONFIGKEY, false);
            if (disableAutoSeeding)
                COConfigurationManager.setParameter(TransferSpeedValidator.AUTO_UPLOAD_SEEDING_ENABLED_CONFIGKEY, false);
        }
    };
    paramMaxDownSpeed.getControl().addListener(SWT.Selection, l);
    paramMaxUploadSpeed.getControl().addListener(SWT.Selection, l);
    paramMaxUploadSpeedSeeding.getControl().addListener(SWT.Selection, l);
    paramMaxUploadSpeed.addChangeListener(new ParameterChangeAdapter() {

        ParameterChangeAdapter me = this;

        @Override
        public void parameterChanged(Parameter p, boolean internal) {
            CoreWaiterSWT.waitForCoreRunning(new CoreRunningListener() {

                @Override
                public void coreRunning(Core core) {
                    if (paramMaxUploadSpeed.isDisposed()) {
                        paramMaxUploadSpeed.removeChangeListener(me);
                        return;
                    }
                    if (TransferSpeedValidator.isAutoSpeedActive(core.getGlobalManager())) {
                        return;
                    }
                    int up_val = paramMaxUploadSpeed.getValue();
                    int down_val = paramMaxDownSpeed.getValue();
                    if (up_val != 0 && up_val < COConfigurationManager.CONFIG_DEFAULT_MIN_MAX_UPLOAD_SPEED) {
                        if ((down_val == 0) || down_val > (up_val * 2)) {
                            paramMaxDownSpeed.setValue(up_val * 2);
                        }
                    } else {
                        if (down_val != manual_max_download_speed[0]) {
                            paramMaxDownSpeed.setValue(manual_max_download_speed[0]);
                        }
                    }
                }
            });
        }
    });
    paramMaxDownSpeed.addChangeListener(new ParameterChangeAdapter() {

        ParameterChangeAdapter me = this;

        @Override
        public void parameterChanged(Parameter p, boolean internal) {
            CoreWaiterSWT.waitForCoreRunning(new CoreRunningListener() {

                @Override
                public void coreRunning(Core core) {
                    if (paramMaxDownSpeed.isDisposed()) {
                        paramMaxDownSpeed.removeChangeListener(me);
                        return;
                    }
                    if (TransferSpeedValidator.isAutoSpeedActive(core.getGlobalManager())) {
                        return;
                    }
                    int up_val = paramMaxUploadSpeed.getValue();
                    int down_val = paramMaxDownSpeed.getValue();
                    manual_max_download_speed[0] = down_val;
                    if (up_val < COConfigurationManager.CONFIG_DEFAULT_MIN_MAX_UPLOAD_SPEED) {
                        if (up_val != 0 && up_val < (down_val * 2)) {
                            paramMaxUploadSpeed.setValue((down_val + 1) / 2);
                        } else if (down_val == 0) {
                            paramMaxUploadSpeed.setValue(0);
                        }
                    }
                }
            });
        }
    });
    if (userMode > 0) {
        // bias upload to incomplete
        BooleanParameter bias_upload = new BooleanParameter(cSection, "Bias Upload Enable", "ConfigView.label.xfer.bias_up");
        gridData = new GridData();
        gridData.horizontalSpan = 2;
        bias_upload.setLayoutData(gridData);
        final Composite bias_slack_area = new Composite(cSection, SWT.NULL);
        layout = new GridLayout();
        layout.numColumns = 3;
        layout.marginWidth = 0;
        layout.marginHeight = 0;
        bias_slack_area.setLayout(layout);
        gridData = new GridData();
        gridData.horizontalIndent = 15;
        gridData.horizontalSpan = 2;
        Utils.setLayoutData(bias_slack_area, gridData);
        label = new Label(bias_slack_area, SWT.NULL);
        gridData = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
        Utils.setLayoutData(label, gridData);
        label.setImage(img);
        label = new Label(bias_slack_area, SWT.NULL);
        Messages.setLanguageText(label, "ConfigView.label.xfer.bias_slack");
        IntParameter bias_slack = new IntParameter(bias_slack_area, "Bias Upload Slack KBs", 1, Integer.MAX_VALUE);
        final Composite bias_unlimited_area = new Composite(cSection, SWT.NULL);
        layout = new GridLayout();
        layout.numColumns = 2;
        layout.marginWidth = 0;
        layout.marginHeight = 0;
        bias_unlimited_area.setLayout(layout);
        gridData = new GridData();
        gridData.horizontalIndent = 15;
        gridData.horizontalSpan = 2;
        Utils.setLayoutData(bias_unlimited_area, gridData);
        label = new Label(bias_unlimited_area, SWT.NULL);
        gridData = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
        Utils.setLayoutData(label, gridData);
        label.setImage(img);
        BooleanParameter bias_no_limit = new BooleanParameter(bias_unlimited_area, "Bias Upload Handle No Limit", "ConfigView.label.xfer.bias_no_limit");
        bias_upload.setAdditionalActionPerformer(new ChangeSelectionActionPerformer(new Parameter[] { bias_slack, bias_no_limit }));
    }
    if (userMode > 0) {
        // AUTO GROUP
        Group auto_group = new Group(cSection, SWT.NULL);
        Messages.setLanguageText(auto_group, "group.auto");
        GridLayout auto_layout = new GridLayout();
        auto_layout.numColumns = 2;
        auto_group.setLayout(auto_layout);
        gridData = new GridData(GridData.FILL_HORIZONTAL);
        gridData.horizontalSpan = 2;
        Utils.setLayoutData(auto_group, gridData);
        BooleanParameter auto_adjust = new BooleanParameter(auto_group, "Auto Adjust Transfer Defaults", "ConfigView.label.autoadjust");
        gridData = new GridData();
        gridData.horizontalSpan = 2;
        auto_adjust.setLayoutData(gridData);
        // max uploads
        gridData = new GridData();
        label = new Label(auto_group, SWT.NULL);
        Utils.setLayoutData(label, gridData);
        Messages.setLanguageText(label, "ConfigView.label.maxuploads");
        gridData = new GridData();
        IntParameter paramMaxUploads = new IntParameter(auto_group, "Max Uploads", 2, Integer.MAX_VALUE);
        paramMaxUploads.setLayoutData(gridData);
        // max uploads when seeding
        final Composite cMaxUploadsOptionsArea = new Composite(auto_group, SWT.NULL);
        layout = new GridLayout();
        layout.numColumns = 3;
        layout.marginWidth = 0;
        layout.marginHeight = 0;
        cMaxUploadsOptionsArea.setLayout(layout);
        gridData = new GridData();
        gridData.horizontalIndent = 15;
        gridData.horizontalSpan = 2;
        Utils.setLayoutData(cMaxUploadsOptionsArea, gridData);
        label = new Label(cMaxUploadsOptionsArea, SWT.NULL);
        img.setBackground(label.getBackground());
        gridData = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
        Utils.setLayoutData(label, gridData);
        label.setImage(img);
        gridData = new GridData();
        BooleanParameter enable_seeding_uploads = new BooleanParameter(cMaxUploadsOptionsArea, "enable.seedingonly.maxuploads", "ConfigView.label.maxuploadsseeding");
        enable_seeding_uploads.setLayoutData(gridData);
        gridData = new GridData();
        final IntParameter paramMaxUploadsSeeding = new IntParameter(cMaxUploadsOptionsArea, "Max Uploads Seeding", 2, Integer.MAX_VALUE);
        paramMaxUploadsSeeding.setLayoutData(gridData);
        // //
        gridData = new GridData();
        label = new Label(auto_group, SWT.NULL);
        Utils.setLayoutData(label, gridData);
        Messages.setLanguageText(label, "ConfigView.label.max_peers_per_torrent");
        gridData = new GridData();
        IntParameter paramMaxClients = new IntParameter(auto_group, "Max.Peer.Connections.Per.Torrent");
        paramMaxClients.setLayoutData(gridData);
        // ///
        // max peers when seeding
        final Composite cMaxPeersOptionsArea = new Composite(auto_group, SWT.NULL);
        layout = new GridLayout();
        layout.numColumns = 3;
        layout.marginWidth = 0;
        layout.marginHeight = 0;
        cMaxPeersOptionsArea.setLayout(layout);
        gridData = new GridData();
        gridData.horizontalIndent = 15;
        gridData.horizontalSpan = 2;
        Utils.setLayoutData(cMaxPeersOptionsArea, gridData);
        label = new Label(cMaxPeersOptionsArea, SWT.NULL);
        img.setBackground(label.getBackground());
        gridData = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
        Utils.setLayoutData(label, gridData);
        label.setImage(img);
        gridData = new GridData();
        BooleanParameter enable_max_peers_seeding = new BooleanParameter(cMaxPeersOptionsArea, "Max.Peer.Connections.Per.Torrent.When.Seeding.Enable", "ConfigView.label.maxuploadsseeding");
        enable_max_peers_seeding.setLayoutData(gridData);
        gridData = new GridData();
        final IntParameter paramMaxPeersSeeding = new IntParameter(cMaxPeersOptionsArea, "Max.Peer.Connections.Per.Torrent.When.Seeding", 0, Integer.MAX_VALUE);
        paramMaxPeersSeeding.setLayoutData(gridData);
        // ///
        gridData = new GridData();
        label = new Label(auto_group, SWT.NULL);
        Utils.setLayoutData(label, gridData);
        Messages.setLanguageText(label, "ConfigView.label.max_peers_total");
        gridData = new GridData();
        IntParameter paramMaxClientsTotal = new IntParameter(auto_group, "Max.Peer.Connections.Total");
        paramMaxClientsTotal.setLayoutData(gridData);
        gridData = new GridData();
        label = new Label(auto_group, SWT.NULL);
        Utils.setLayoutData(label, gridData);
        Messages.setLanguageText(label, "ConfigView.label.maxseedspertorrent");
        gridData = new GridData();
        IntParameter max_seeds_per_torrent = new IntParameter(auto_group, "Max Seeds Per Torrent");
        max_seeds_per_torrent.setLayoutData(gridData);
        final Parameter[] parameters = { paramMaxUploads, enable_seeding_uploads, paramMaxUploadsSeeding, paramMaxClients, enable_max_peers_seeding, paramMaxPeersSeeding, paramMaxClientsTotal, max_seeds_per_torrent };
        IAdditionalActionPerformer f_enabler = new GenericActionPerformer(new Control[0]) {

            @Override
            public void performAction() {
                boolean auto = COConfigurationManager.getBooleanParameter("Auto Adjust Transfer Defaults");
                for (Parameter p : parameters) {
                    Control[] c = p.getControls();
                    for (Control x : c) {
                        x.setEnabled(!auto);
                    }
                }
                if (!auto) {
                    paramMaxUploadsSeeding.getControl().setEnabled(COConfigurationManager.getBooleanParameter("enable.seedingonly.maxuploads"));
                    paramMaxPeersSeeding.getControl().setEnabled(COConfigurationManager.getBooleanParameter("Max.Peer.Connections.Per.Torrent.When.Seeding.Enable"));
                }
            }
        };
        f_enabler.performAction();
        enable_seeding_uploads.setAdditionalActionPerformer(f_enabler);
        enable_max_peers_seeding.setAdditionalActionPerformer(f_enabler);
        auto_adjust.setAdditionalActionPerformer(f_enabler);
        // NON PUBLIC PEERS GROUP
        Group npp_group = new Group(cSection, SWT.NULL);
        Messages.setLanguageText(npp_group, "label.non.public.peers");
        GridLayout npp_layout = new GridLayout();
        npp_layout.numColumns = 2;
        npp_group.setLayout(npp_layout);
        gridData = new GridData(GridData.FILL_HORIZONTAL);
        gridData.horizontalSpan = 2;
        Utils.setLayoutData(npp_group, gridData);
        label = new Label(npp_group, SWT.NULL);
        Messages.setLanguageText(label, "ConfigView.label.npp.slots");
        IntParameter npp_upload_slots = new IntParameter(npp_group, "Non-Public Peer Extra Slots Per Torrent", 0, Integer.MAX_VALUE);
        label = new Label(npp_group, SWT.NULL);
        Messages.setLanguageText(label, "ConfigView.label.npp.connections");
        IntParameter npp_connections = new IntParameter(npp_group, "Non-Public Peer Extra Connections Per Torrent", 0, Integer.MAX_VALUE);
        // END NON PUBLIC PEERS GROUP
        gridData = new GridData();
        gridData.horizontalSpan = 2;
        BooleanParameter useReqLimiting = new BooleanParameter(cSection, "Use Request Limiting", "ConfigView.label.userequestlimiting");
        useReqLimiting.setLayoutData(gridData);
        gridData = new GridData();
        gridData.horizontalSpan = 2;
        BooleanParameter useReqLimitingPrios = new BooleanParameter(cSection, "Use Request Limiting Priorities", "ConfigView.label.userequestlimitingpriorities");
        useReqLimitingPrios.setLayoutData(gridData);
        useReqLimiting.setAdditionalActionPerformer(new ChangeSelectionActionPerformer(useReqLimitingPrios.getControl()));
        // up limits include protocol
        gridData = new GridData();
        gridData.horizontalSpan = 2;
        BooleanParameter upIncludesProt = new BooleanParameter(cSection, "Up Rate Limits Include Protocol", "ConfigView.label.up.includes.prot");
        upIncludesProt.setLayoutData(gridData);
        // down limits include protocol
        gridData = new GridData();
        gridData.horizontalSpan = 2;
        BooleanParameter downIncludesProt = new BooleanParameter(cSection, "Down Rate Limits Include Protocol", "ConfigView.label.down.includes.prot");
        downIncludesProt.setLayoutData(gridData);
        // same IP
        gridData = new GridData();
        gridData.horizontalSpan = 2;
        BooleanParameter allowSameIP = new BooleanParameter(cSection, "Allow Same IP Peers", "ConfigView.label.allowsameip");
        allowSameIP.setLayoutData(gridData);
        // lazy bit field
        gridData = new GridData();
        gridData.horizontalSpan = 2;
        BooleanParameter lazybf = new BooleanParameter(cSection, "Use Lazy Bitfield", "ConfigView.label.lazybitfield");
        lazybf.setLayoutData(gridData);
        if (userMode > 1) {
            gridData = new GridData();
            gridData.horizontalSpan = 2;
            BooleanParameter hap = new BooleanParameter(cSection, "peercontrol.hide.piece", "ConfigView.label.hap");
            hap.setLayoutData(gridData);
            gridData = new GridData();
            gridData.horizontalSpan = 2;
            BooleanParameter hapds = new BooleanParameter(cSection, "peercontrol.hide.piece.ds", "ConfigView.label.hapds");
            hapds.setLayoutData(gridData);
            hap.setAdditionalActionPerformer(new ChangeSelectionActionPerformer(hapds.getControl()));
        }
        // prioritise first/last pieces
        gridData = new GridData();
        gridData.horizontalSpan = 2;
        BooleanParameter firstPiece = new BooleanParameter(cSection, "Prioritize First Piece", "ConfigView.label.prioritizefirstpiece");
        firstPiece.setLayoutData(gridData);
        // Further prioritize High priority files according to % complete and size of file
        gridData = new GridData();
        gridData.horizontalSpan = 2;
        BooleanParameter mostCompletedFiles = new BooleanParameter(cSection, "Prioritize Most Completed Files", "ConfigView.label.prioritizemostcompletedfiles");
        mostCompletedFiles.setLayoutData(gridData);
        // ignore ports
        Composite cMiniArea = new Composite(cSection, SWT.NULL);
        layout = new GridLayout();
        layout.numColumns = 2;
        layout.marginHeight = 0;
        layout.marginWidth = 0;
        cMiniArea.setLayout(layout);
        gridData = new GridData(GridData.FILL_HORIZONTAL);
        gridData.horizontalSpan = 2;
        Utils.setLayoutData(cMiniArea, gridData);
        gridData = new GridData();
        label = new Label(cMiniArea, SWT.NULL);
        Utils.setLayoutData(label, gridData);
        Messages.setLanguageText(label, "ConfigView.label.transfer.ignorepeerports");
        gridData = new GridData();
        gridData.widthHint = 125;
        StringParameter ignore_ports = new StringParameter(cMiniArea, "Ignore.peer.ports", "0");
        ignore_ports.setLayoutData(gridData);
    }
    return cSection;
}
Also used : Group(org.eclipse.swt.widgets.Group) CoreRunningListener(com.biglybt.core.CoreRunningListener) Listener(org.eclipse.swt.widgets.Listener) LinkLabel(com.biglybt.ui.swt.components.LinkLabel) Label(org.eclipse.swt.widgets.Label) Image(org.eclipse.swt.graphics.Image) GridLayout(org.eclipse.swt.layout.GridLayout) Control(org.eclipse.swt.widgets.Control) CoreRunningListener(com.biglybt.core.CoreRunningListener) Core(com.biglybt.core.Core) Composite(org.eclipse.swt.widgets.Composite) LinkLabel(com.biglybt.ui.swt.components.LinkLabel) GridData(org.eclipse.swt.layout.GridData) Event(org.eclipse.swt.widgets.Event) ImageLoader(com.biglybt.ui.swt.imageloader.ImageLoader)

Example 7 with ImageLoader

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

the class ConfigSectionInterfaceAlerts method configSectionCreate.

@Override
public Composite configSectionCreate(final Composite parent) {
    Image imgOpenFolder = null;
    ImageLoader imageLoader = ImageLoader.getInstance();
    imgOpenFolder = imageLoader.getImage("openFolderButton");
    GridData gridData;
    GridLayout layout;
    Composite cSection = new Composite(parent, SWT.NULL);
    gridData = new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL);
    cSection.setLayoutData(gridData);
    layout = new GridLayout();
    layout.marginWidth = 0;
    // layout.numColumns = 2;
    cSection.setLayout(layout);
    Composite cArea = new Composite(cSection, SWT.NONE);
    layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.numColumns = 4;
    cArea.setLayout(layout);
    cArea.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    // DOWNLOAD FINISHED
    playSoundWhen(cArea, imgOpenFolder, "Play Download Finished Announcement", "Play Download Finished Announcement Text", "ConfigView.label.playdownloadspeech", "Play Download Finished", "Play Download Finished File", "ConfigView.label.playdownloadfinished");
    // DOWNLOAD ERROR
    playSoundWhen(cArea, imgOpenFolder, "Play Download Error Announcement", "Play Download Error Announcement Text", "ConfigView.label.playdownloaderrorspeech", "Play Download Error", "Play Download Error File", "ConfigView.label.playdownloaderror");
    // FILE FINISHED
    playSoundWhen(cArea, imgOpenFolder, "Play File Finished Announcement", "Play File Finished Announcement Text", "ConfigView.label.playfilespeech", "Play File Finished", "Play File Finished File", "ConfigView.label.playfilefinished");
    // NOTIFICATION ADDED
    playSoundWhen(cArea, imgOpenFolder, "Play Notification Added Announcement", "Play Notification Added Announcement Text", "ConfigView.label.playnotificationaddedspeech", "Play Notification Added", "Play Notification Added File", "ConfigView.label.playnotificationadded");
    // xxxxxxxxxxxxxxxx
    boolean isAZ3 = COConfigurationManager.getStringParameter("ui").equals("az3");
    if (isAZ3) {
        BooleanParameter p = new BooleanParameter(cArea, "Request Attention On New Download", "ConfigView.label.dl.add.req.attention");
        gridData = new GridData();
        gridData.horizontalSpan = 3;
        p.setLayoutData(gridData);
    }
    BooleanParameter activate_win = new BooleanParameter(cArea, "Activate Window On External Download", "ConfigView.label.show.win.on.add");
    gridData = new GridData();
    gridData.horizontalSpan = 3;
    activate_win.setLayoutData(gridData);
    BooleanParameter no_auto_activate = new BooleanParameter(cArea, "Reduce Auto Activate Window", "ConfigView.label.reduce.auto.activate");
    gridData = new GridData();
    gridData.horizontalSpan = 3;
    no_auto_activate.setLayoutData(gridData);
    // popups group
    {
        Group gPopup = new Group(cSection, SWT.NULL);
        Messages.setLanguageText(gPopup, "label.popups");
        layout = new GridLayout();
        layout.numColumns = 2;
        gPopup.setLayout(layout);
        gPopup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        BooleanParameter popup_dl_added = new BooleanParameter(gPopup, "Popup Download Added", "ConfigView.label.popupdownloadadded");
        gridData = new GridData();
        gridData.horizontalSpan = 2;
        popup_dl_added.setLayoutData(gridData);
        BooleanParameter popup_dl_completed = new BooleanParameter(gPopup, "Popup Download Finished", "ConfigView.label.popupdownloadfinished");
        gridData = new GridData();
        gridData.horizontalSpan = 2;
        popup_dl_completed.setLayoutData(gridData);
        BooleanParameter popup_dl_error = new BooleanParameter(gPopup, "Popup Download Error", "ConfigView.label.popupdownloaderror");
        gridData = new GridData();
        gridData.horizontalSpan = 2;
        popup_dl_error.setLayoutData(gridData);
        BooleanParameter popup_file_completed = new BooleanParameter(gPopup, "Popup File Finished", "ConfigView.label.popupfilefinished");
        gridData = new GridData();
        gridData.horizontalSpan = 2;
        popup_file_completed.setLayoutData(gridData);
        // disable sliding
        BooleanParameter disable_sliding = new BooleanParameter(gPopup, "GUI_SWT_DisableAlertSliding", "ConfigView.section.style.disableAlertSliding");
        gridData = new GridData();
        gridData.horizontalSpan = 2;
        disable_sliding.setLayoutData(gridData);
        // Timestamps for popup alerts.
        BooleanParameter show_alert_timestamps = new BooleanParameter(gPopup, "Show Timestamp For Alerts", "ConfigView.label.popup.timestamp");
        gridData = new GridData();
        gridData.horizontalSpan = 2;
        show_alert_timestamps.setLayoutData(gridData);
        // Auto-hide popup setting.
        Label label = new Label(gPopup, SWT.WRAP);
        Messages.setLanguageText(label, "ConfigView.label.popup.autohide");
        label.setLayoutData(new GridData());
        IntParameter auto_hide_alert = new IntParameter(gPopup, "Message Popup Autoclose in Seconds", 0, 86400);
        gridData = new GridData();
        gridData.horizontalSpan = 1;
        auto_hide_alert.setLayoutData(gridData);
    }
    // notify group
    {
        Group nPopup = new Group(cSection, SWT.NULL);
        Messages.setLanguageText(nPopup, "label.native.notify");
        layout = new GridLayout();
        layout.numColumns = 2;
        nPopup.setLayout(layout);
        nPopup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        BooleanParameter popup_dl_completed = new BooleanParameter(nPopup, "Notify Download Finished", "ConfigView.label.nativedownloadfinished");
        gridData = new GridData();
        gridData.horizontalSpan = 2;
        popup_dl_completed.setLayoutData(gridData);
        BooleanParameter popup_dl_error = new BooleanParameter(nPopup, "Notify Download Error", "ConfigView.label.nativedownloaderror");
        gridData = new GridData();
        gridData.horizontalSpan = 2;
        popup_dl_error.setLayoutData(gridData);
    }
    return cSection;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) Image(org.eclipse.swt.graphics.Image) ImageLoader(com.biglybt.ui.swt.imageloader.ImageLoader)

Example 8 with ImageLoader

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

the class ConfigSectionInterfaceAlerts method configSectionDelete.

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

Example 9 with ImageLoader

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

the class ConfigSectionFile method configSectionCreate.

@Override
public Composite configSectionCreate(final Composite parent) {
    ImageLoader imageLoader = ImageLoader.getInstance();
    Image imgOpenFolder = imageLoader.getImage("openFolderButton");
    GridData gridData;
    Label label;
    String sCurConfigID;
    final ArrayList<String> allConfigIDs = new ArrayList<>();
    Composite gFile = new Composite(parent, SWT.NULL);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    layout.marginHeight = 0;
    gFile.setLayout(layout);
    int userMode = COConfigurationManager.getIntParameter("User Mode");
    // Default Dir Section
    final Group gDefaultDir = new Group(gFile, SWT.NONE);
    Messages.setLanguageText(gDefaultDir, "ConfigView.section.file.defaultdir.section");
    layout = new GridLayout();
    layout.numColumns = 3;
    gDefaultDir.setLayout(layout);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalSpan = 2;
    Utils.setLayoutData(gDefaultDir, gridData);
    if (userMode > 0) {
        // def dir: best guess
        sCurConfigID = "DefaultDir.BestGuess";
        allConfigIDs.add(sCurConfigID);
        BooleanParameter bestGuess = new BooleanParameter(gDefaultDir, sCurConfigID, "ConfigView.section.file.defaultdir.bestguess");
        gridData = new GridData(GridData.FILL_HORIZONTAL);
        gridData.horizontalSpan = 3;
        bestGuess.setLayoutData(gridData);
    }
    // Save Path
    sCurConfigID = "Default save path";
    allConfigIDs.add(sCurConfigID);
    Label lblDefaultDir = new Label(gDefaultDir, SWT.NONE);
    Messages.setLanguageText(lblDefaultDir, "ConfigView.section.file.defaultdir.ask");
    Utils.setLayoutData(lblDefaultDir, new GridData());
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    final StringParameter pathParameter = new StringParameter(gDefaultDir, sCurConfigID);
    pathParameter.setLayoutData(gridData);
    Button browse = new Button(gDefaultDir, SWT.PUSH);
    browse.setImage(imgOpenFolder);
    imgOpenFolder.setBackground(browse.getBackground());
    browse.setToolTipText(MessageText.getString("ConfigView.button.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());
            dialog.setMessage(MessageText.getString("ConfigView.dialog.choosedefaultsavepath"));
            dialog.setText(MessageText.getString("ConfigView.section.file.defaultdir.ask"));
            String path = dialog.open();
            if (path != null) {
                pathParameter.setValue(path);
            }
        }
    });
    // def dir: autoSave
    sCurConfigID = ConfigurationDefaults.CFG_TORRENTADD_OPENOPTIONS;
    allConfigIDs.add(sCurConfigID);
    Composite cOpenOptions = new Composite(gDefaultDir, SWT.NONE);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalSpan = 3;
    Utils.setLayoutData(cOpenOptions, gridData);
    RowLayout rowLayout = new RowLayout();
    rowLayout.marginBottom = rowLayout.marginLeft = rowLayout.marginRight = rowLayout.marginTop = 0;
    rowLayout.center = true;
    cOpenOptions.setLayout(rowLayout);
    label = new Label(cOpenOptions, SWT.NULL);
    Messages.setLanguageText(label, "ConfigView.section.file.showopentorrentoptions");
    String[] openValues = { ConfigurationDefaults.CFG_TORRENTADD_OPENOPTIONS_NEVER, ConfigurationDefaults.CFG_TORRENTADD_OPENOPTIONS_ALWAYS, ConfigurationDefaults.CFG_TORRENTADD_OPENOPTIONS_MANY };
    String[] openLabels = { MessageText.getString("OpenTorrentOptions.show.never"), MessageText.getString("OpenTorrentOptions.show.always"), MessageText.getString("OpenTorrentOptions.show.many") };
    new StringListParameter(cOpenOptions, sCurConfigID, openLabels, openValues);
    label = new Label(cOpenOptions, SWT.NULL);
    label.setText("    ");
    sCurConfigID = "ui.addtorrent.openoptions.sep";
    new BooleanParameter(cOpenOptions, sCurConfigID, "ConfigView.section.file.showopentorrentoptions.sep");
    if (userMode > 0) {
        // def dir: autoSave -> auto-rename
        sCurConfigID = "DefaultDir.AutoSave.AutoRename";
        allConfigIDs.add(sCurConfigID);
        BooleanParameter autoSaveAutoRename = new BooleanParameter(gDefaultDir, sCurConfigID, "ConfigView.section.file.defaultdir.autorename");
        gridData = new GridData(GridData.FILL_HORIZONTAL);
        gridData.horizontalSpan = 3;
        autoSaveAutoRename.setLayoutData(gridData);
        // IAdditionalActionPerformer aapDefaultDirStuff3 = new ChangeSelectionActionPerformer(
        // autoSaveAutoRename.getControls(), false);
        final Composite cHistory = new Composite(gDefaultDir, SWT.NONE);
        layout = new GridLayout();
        layout.numColumns = 6;
        layout.marginHeight = 0;
        layout.marginWidth = 0;
        cHistory.setLayout(layout);
        gridData = new GridData(GridData.FILL_HORIZONTAL);
        gridData.horizontalSpan = 3;
        Utils.setLayoutData(cHistory, gridData);
        // def dir: auto update
        sCurConfigID = "DefaultDir.AutoUpdate";
        allConfigIDs.add(sCurConfigID);
        BooleanParameter autoUpdateSaveDir = new BooleanParameter(cHistory, sCurConfigID, "ConfigView.section.file.defaultdir.lastused");
        Label padLabel = new Label(cHistory, SWT.NULL);
        gridData = new GridData(GridData.FILL_HORIZONTAL);
        Utils.setLayoutData(padLabel, gridData);
        sCurConfigID = "saveTo_list.max_entries";
        allConfigIDs.add(sCurConfigID);
        Label historyMax = new Label(cHistory, SWT.NULL);
        Messages.setLanguageText(historyMax, "ConfigView.label.save_list.max_entries");
        IntParameter paramhistoryMax = new IntParameter(cHistory, sCurConfigID);
        Label historyReset = new Label(cHistory, SWT.NULL);
        Messages.setLanguageText(historyReset, "ConfigView.label.save_list.clear");
        final Button clear_history_button = new Button(cHistory, SWT.PUSH);
        Messages.setLanguageText(clear_history_button, "Button.clear");
        clear_history_button.addListener(SWT.Selection, new Listener() {

            @Override
            public void handleEvent(Event event) {
                COConfigurationManager.setParameter("saveTo_list", new ArrayList());
                clear_history_button.setEnabled(false);
            }
        });
        java.util.List<String> dirList = COConfigurationManager.getStringListParameter("saveTo_list");
        clear_history_button.setEnabled(dirList.size() > 0);
    }
    label = new Label(gFile, SWT.NONE);
    gridData = new GridData();
    gridData.horizontalSpan = 2;
    label.setLayoutData(gridData);
    // //////////////////
    sCurConfigID = "XFS Allocation";
    allConfigIDs.add(sCurConfigID);
    if (userMode > 0 && !Constants.isWindows) {
        BooleanParameter xfsAllocation = new BooleanParameter(gFile, sCurConfigID, "ConfigView.label.xfs.allocation");
        gridData = new GridData();
        gridData.horizontalSpan = 2;
        xfsAllocation.setLayoutData(gridData);
    }
    BooleanParameter zeroNew = null;
    sCurConfigID = "Zero New";
    allConfigIDs.add(sCurConfigID);
    if (userMode > 0) {
        // zero new files
        zeroNew = new BooleanParameter(gFile, sCurConfigID, "ConfigView.label.zeronewfiles");
        gridData = new GridData();
        gridData.horizontalSpan = 2;
        zeroNew.setLayoutData(gridData);
    }
    BooleanParameter pieceReorder = null;
    sCurConfigID = "Enable reorder storage mode";
    allConfigIDs.add(sCurConfigID);
    if (userMode > 0) {
        pieceReorder = new BooleanParameter(gFile, sCurConfigID, "ConfigView.label.piecereorder");
        gridData = new GridData();
        gridData.horizontalSpan = 2;
        pieceReorder.setLayoutData(gridData);
        // Make the reorder checkbox (button) deselect when zero new is used
        Button[] btnReorder = { (Button) pieceReorder.getControl() };
        zeroNew.setAdditionalActionPerformer(new ExclusiveSelectionActionPerformer(btnReorder));
        // Make the zero new checkbox(button) deselct when reorder is used
        Button[] btnZeroNew = { (Button) zeroNew.getControl() };
        pieceReorder.setAdditionalActionPerformer(new ExclusiveSelectionActionPerformer(btnZeroNew));
    }
    sCurConfigID = "Reorder storage mode min MB";
    allConfigIDs.add(sCurConfigID);
    if (userMode > 0) {
        Label lblMinMB = new Label(gFile, SWT.NULL);
        Messages.setLanguageText(lblMinMB, "ConfigView.label.piecereorderminmb");
        gridData = new GridData();
        gridData.horizontalIndent = 25;
        Utils.setLayoutData(lblMinMB, gridData);
        IntParameter minMB = new IntParameter(gFile, sCurConfigID);
        gridData = new GridData();
        minMB.setLayoutData(gridData);
        pieceReorder.setAdditionalActionPerformer(new ChangeSelectionActionPerformer(lblMinMB));
        pieceReorder.setAdditionalActionPerformer(new ChangeSelectionActionPerformer(minMB));
    }
    sCurConfigID = "Enable incremental file creation";
    allConfigIDs.add(sCurConfigID);
    if (userMode > 0) {
        // incremental file creation
        BooleanParameter incremental = new BooleanParameter(gFile, sCurConfigID, "ConfigView.label.incrementalfile");
        gridData = new GridData();
        gridData.horizontalSpan = 2;
        incremental.setLayoutData(gridData);
        // Make the incremental checkbox (button) deselect when zero new is used
        Button[] btnIncremental = { (Button) incremental.getControl() };
        zeroNew.setAdditionalActionPerformer(new ExclusiveSelectionActionPerformer(btnIncremental));
        // Make the zero new checkbox(button) deselct when incremental is used
        Button[] btnZeroNew = { (Button) zeroNew.getControl() };
        incremental.setAdditionalActionPerformer(new ExclusiveSelectionActionPerformer(btnZeroNew));
    }
    // truncate too large
    sCurConfigID = "File.truncate.if.too.large";
    allConfigIDs.add(sCurConfigID);
    if (userMode > 0) {
        // truncate too large
        BooleanParameter truncateLarge = new BooleanParameter(gFile, sCurConfigID, "ConfigView.section.file.truncate.too.large");
        gridData = new GridData();
        gridData.horizontalSpan = 2;
        truncateLarge.setLayoutData(gridData);
    }
    // merge files of same size
    sCurConfigID = "Merge Same Size Files";
    allConfigIDs.add(sCurConfigID);
    BooleanParameter mergeSameSize = null;
    if (userMode > 0) {
        mergeSameSize = new BooleanParameter(gFile, sCurConfigID, "ConfigView.section.file.merge.same.size");
        gridData = new GridData();
        gridData.horizontalSpan = 2;
        mergeSameSize.setLayoutData(gridData);
    }
    // merge extended
    sCurConfigID = "Merge Same Size Files Extended";
    allConfigIDs.add(sCurConfigID);
    if (mergeSameSize != null) {
        BooleanParameter mergeSameSizeExt = new BooleanParameter(gFile, sCurConfigID, "ConfigView.section.file.merge.same.size.extended");
        gridData = new GridData();
        gridData.horizontalIndent = 25;
        gridData.horizontalSpan = 2;
        mergeSameSizeExt.setLayoutData(gridData);
        IAdditionalActionPerformer mergeAP = new ChangeSelectionActionPerformer(mergeSameSizeExt.getControls(), false);
        mergeSameSize.setAdditionalActionPerformer(mergeAP);
    }
    // recheck on complete
    sCurConfigID = "Check Pieces on Completion";
    allConfigIDs.add(sCurConfigID);
    if (userMode > 0) {
        // check on complete
        BooleanParameter checkOnComp = new BooleanParameter(gFile, sCurConfigID, "ConfigView.label.checkOncompletion");
        gridData = new GridData();
        gridData.horizontalSpan = 2;
        checkOnComp.setLayoutData(gridData);
    }
    sCurConfigID = "Seeding Piece Check Recheck Enable";
    allConfigIDs.add(sCurConfigID);
    if (userMode > 0) {
        // check on complete
        BooleanParameter checkOnSeeding = new BooleanParameter(gFile, sCurConfigID, "ConfigView.label.checkOnSeeding");
        gridData = new GridData();
        gridData.horizontalSpan = 2;
        checkOnSeeding.setLayoutData(gridData);
    }
    sCurConfigID = "File.strict.locking";
    allConfigIDs.add(sCurConfigID);
    if (userMode > 1) {
        BooleanParameter strictLocking = new BooleanParameter(gFile, sCurConfigID, "ConfigView.label.strictfilelocking");
        gridData = new GridData();
        gridData.horizontalSpan = 2;
        strictLocking.setLayoutData(gridData);
    }
    if (userMode == 0) {
        allConfigIDs.add("Use Resume");
        sCurConfigID = "Save Resume Interval";
        allConfigIDs.add(sCurConfigID);
        sCurConfigID = "On Resume Recheck All";
        allConfigIDs.add(sCurConfigID);
        sCurConfigID = "File.save.peers.enable";
        allConfigIDs.add(sCurConfigID);
        sCurConfigID = "File.save.peers.max";
        allConfigIDs.add(sCurConfigID);
    } else {
        // max links
        Composite maxLinksGroup = new Composite(gFile, SWT.NULL);
        layout = new GridLayout();
        layout.marginHeight = 0;
        layout.marginWidth = 0;
        layout.numColumns = 3;
        maxLinksGroup.setLayout(layout);
        gridData = new GridData(GridData.FILL_HORIZONTAL);
        gridData.horizontalSpan = 2;
        Utils.setLayoutData(maxLinksGroup, gridData);
        Label maxLinks = new Label(maxLinksGroup, SWT.NULL);
        Messages.setLanguageText(maxLinks, "ConfigView.label.max.file.links");
        sCurConfigID = "Max File Links Supported";
        allConfigIDs.add(sCurConfigID);
        new IntParameter(maxLinksGroup, sCurConfigID, 8, Integer.MAX_VALUE);
        Label maxLinksWarning = new Label(maxLinksGroup, SWT.NULL);
        Messages.setLanguageText(maxLinksWarning, "ConfigView.label.max.file.links.warning");
        gridData = new GridData(GridData.FILL_HORIZONTAL);
        maxLinksWarning.setLayoutData(gridData);
        // restart out of space downloads
        sCurConfigID = "Insufficient Space Download Restart Enable";
        allConfigIDs.add(sCurConfigID);
        // resume data
        final BooleanParameter OOSDRE = new BooleanParameter(gFile, sCurConfigID, "ConfigView.label.restart.no.space.dls");
        gridData = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
        gridData.horizontalSpan = 2;
        OOSDRE.setLayoutData(gridData);
        Composite cOOSDGroup = new Composite(gFile, SWT.NULL);
        layout = new GridLayout();
        layout.marginHeight = 0;
        layout.marginWidth = 4;
        layout.numColumns = 3;
        cOOSDGroup.setLayout(layout);
        gridData = new GridData(GridData.FILL_HORIZONTAL);
        gridData.horizontalIndent = 25;
        gridData.horizontalSpan = 2;
        Utils.setLayoutData(cOOSDGroup, gridData);
        sCurConfigID = "Insufficient Space Download Restart Period";
        allConfigIDs.add(sCurConfigID);
        Label lblOOSDRInterval = new Label(cOOSDGroup, SWT.NULL);
        Messages.setLanguageText(lblOOSDRInterval, "ConfigView.label.restart.no.space.dls.interval");
        IntParameter paramOOSDRInterval = new IntParameter(cOOSDGroup, sCurConfigID, 1, Integer.MAX_VALUE);
        gridData = new GridData();
        paramOOSDRInterval.setLayoutData(gridData);
        Label lblOOSDRMinutes = new Label(cOOSDGroup, SWT.NULL);
        Messages.setLanguageText(lblOOSDRMinutes, "ConfigView.text.minutes");
        final Control[] OOSDRContrls = { cOOSDGroup };
        IAdditionalActionPerformer OOSDREnabler = new GenericActionPerformer(OOSDRContrls) {

            @Override
            public void performAction() {
                controlsSetEnabled(controls, OOSDRE.isSelected());
            }
        };
        OOSDRE.setAdditionalActionPerformer(OOSDREnabler);
        // use resume
        sCurConfigID = "Use Resume";
        allConfigIDs.add(sCurConfigID);
        // resume data
        final BooleanParameter bpUseResume = new BooleanParameter(gFile, sCurConfigID, "ConfigView.label.usefastresume");
        bpUseResume.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
        Composite cResumeGroup = new Composite(gFile, SWT.NULL);
        layout = new GridLayout();
        layout.marginHeight = 0;
        layout.marginWidth = 4;
        layout.numColumns = 3;
        cResumeGroup.setLayout(layout);
        gridData = new GridData(GridData.FILL_HORIZONTAL);
        gridData.horizontalIndent = 25;
        gridData.horizontalSpan = 2;
        Utils.setLayoutData(cResumeGroup, gridData);
        sCurConfigID = "Save Resume Interval";
        allConfigIDs.add(sCurConfigID);
        Label lblSaveResumeInterval = new Label(cResumeGroup, SWT.NULL);
        Messages.setLanguageText(lblSaveResumeInterval, "ConfigView.label.saveresumeinterval");
        IntParameter paramSaveInterval = new IntParameter(cResumeGroup, sCurConfigID);
        gridData = new GridData();
        paramSaveInterval.setLayoutData(gridData);
        Label lblMinutes = new Label(cResumeGroup, SWT.NULL);
        Messages.setLanguageText(lblMinutes, "ConfigView.text.minutes");
        // save peers
        sCurConfigID = "On Resume Recheck All";
        allConfigIDs.add(sCurConfigID);
        final BooleanParameter recheck_all = new BooleanParameter(cResumeGroup, sCurConfigID, "ConfigView.section.file.resume.recheck.all");
        gridData = new GridData();
        gridData.horizontalSpan = 3;
        recheck_all.setLayoutData(gridData);
        // save peers
        sCurConfigID = "File.save.peers.enable";
        allConfigIDs.add(sCurConfigID);
        final BooleanParameter save_peers = new BooleanParameter(cResumeGroup, sCurConfigID, "ConfigView.section.file.save.peers.enable");
        gridData = new GridData();
        gridData.horizontalSpan = 3;
        save_peers.setLayoutData(gridData);
        // save peers max
        sCurConfigID = "File.save.peers.max";
        allConfigIDs.add(sCurConfigID);
        final Label lblSavePeersMax = new Label(cResumeGroup, SWT.NULL);
        Messages.setLanguageText(lblSavePeersMax, "ConfigView.section.file.save.peers.max");
        final IntParameter savePeersMax = new IntParameter(cResumeGroup, sCurConfigID);
        gridData = new GridData();
        savePeersMax.setLayoutData(gridData);
        final Label lblPerTorrent = new Label(cResumeGroup, SWT.NULL);
        Messages.setLanguageText(lblPerTorrent, "ConfigView.section.file.save.peers.pertorrent");
        final Control[] controls = { cResumeGroup };
        /*
			IAdditionalActionPerformer performer = new ChangeSelectionActionPerformer(controls);
			bpUseResume.setAdditionalActionPerformer(performer);
			*/
        IAdditionalActionPerformer f_enabler = new GenericActionPerformer(controls) {

            @Override
            public void performAction() {
                controlsSetEnabled(controls, bpUseResume.isSelected());
                if (bpUseResume.isSelected()) {
                    lblSavePeersMax.setEnabled(save_peers.isSelected());
                    savePeersMax.getControl().setEnabled(save_peers.isSelected());
                    lblPerTorrent.setEnabled(save_peers.isSelected());
                }
            }
        };
        bpUseResume.setAdditionalActionPerformer(f_enabler);
        save_peers.setAdditionalActionPerformer(f_enabler);
    }
    if (userMode > 0) {
        sCurConfigID = "priorityExtensions";
        allConfigIDs.add(sCurConfigID);
        // Auto-Prioritize
        label = new Label(gFile, SWT.WRAP);
        gridData = new GridData();
        gridData.widthHint = 180;
        Utils.setLayoutData(label, gridData);
        Messages.setLanguageText(label, "ConfigView.label.priorityExtensions");
        Composite cExtensions = new Composite(gFile, SWT.NULL);
        gridData = new GridData(GridData.FILL_HORIZONTAL);
        Utils.setLayoutData(cExtensions, gridData);
        layout = new GridLayout();
        layout.marginHeight = 0;
        layout.marginWidth = 0;
        layout.numColumns = 3;
        cExtensions.setLayout(layout);
        gridData = new GridData(GridData.FILL_HORIZONTAL);
        new StringParameter(cExtensions, sCurConfigID).setLayoutData(gridData);
        sCurConfigID = "priorityExtensionsIgnoreCase";
        allConfigIDs.add(sCurConfigID);
        new BooleanParameter(cExtensions, sCurConfigID, "ConfigView.label.ignoreCase");
    } else {
        sCurConfigID = "priorityExtensions";
        allConfigIDs.add(sCurConfigID);
        sCurConfigID = "priorityExtensionsIgnoreCase";
        allConfigIDs.add(sCurConfigID);
    }
    // quick view
    sCurConfigID = "quick.view.exts";
    allConfigIDs.add(sCurConfigID);
    label = new Label(gFile, SWT.WRAP);
    gridData = new GridData();
    gridData.widthHint = 180;
    Utils.setLayoutData(label, gridData);
    Messages.setLanguageText(label, "ConfigView.label.quickviewexts");
    Composite cQuickView = new Composite(gFile, SWT.NULL);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    Utils.setLayoutData(cQuickView, gridData);
    layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.numColumns = 3;
    cQuickView.setLayout(layout);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    new StringParameter(cQuickView, sCurConfigID).setLayoutData(gridData);
    label = new Label(cQuickView, SWT.NONE);
    Messages.setLanguageText(label, "ConfigView.label.quickviewmaxkb");
    sCurConfigID = "quick.view.maxkb";
    allConfigIDs.add(sCurConfigID);
    IntParameter qvmax = new IntParameter(cQuickView, sCurConfigID, 1, 9999);
    if (userMode > 0) {
        // rename incomplete files
        sCurConfigID = "Rename Incomplete Files";
        allConfigIDs.add(sCurConfigID);
        gridData = new GridData();
        gridData.horizontalSpan = 1;
        final BooleanParameter rename_incomplete = new BooleanParameter(gFile, sCurConfigID, "ConfigView.section.file.rename.incomplete");
        rename_incomplete.setLayoutData(gridData);
        sCurConfigID = "Rename Incomplete Files Extension";
        allConfigIDs.add(sCurConfigID);
        gridData = new GridData(GridData.FILL_HORIZONTAL);
        StringParameter rename_incomplete_ext = new StringParameter(gFile, sCurConfigID);
        rename_incomplete_ext.setLayoutData(gridData);
        IAdditionalActionPerformer incompFileAP = new ChangeSelectionActionPerformer(rename_incomplete_ext.getControls(), false);
        rename_incomplete.setAdditionalActionPerformer(incompFileAP);
        // put 'dnd' files in subdir
        sCurConfigID = "Enable Subfolder for DND Files";
        allConfigIDs.add(sCurConfigID);
        gridData = new GridData();
        gridData.horizontalSpan = 1;
        final BooleanParameter enable_subfolder = new BooleanParameter(gFile, sCurConfigID, "ConfigView.section.file.subfolder.dnd");
        rename_incomplete.setLayoutData(gridData);
        sCurConfigID = "Subfolder for DND Files";
        allConfigIDs.add(sCurConfigID);
        gridData = new GridData(GridData.FILL_HORIZONTAL);
        StringParameter subfolder_name = new StringParameter(gFile, sCurConfigID);
        subfolder_name.setLayoutData(gridData);
        IAdditionalActionPerformer subfolderAP = new ChangeSelectionActionPerformer(subfolder_name.getControls(), false);
        enable_subfolder.setAdditionalActionPerformer(subfolderAP);
        // dnd prefix
        sCurConfigID = "Use Incomplete File Prefix";
        allConfigIDs.add(sCurConfigID);
        gridData = new GridData();
        gridData.horizontalSpan = 2;
        gridData.horizontalIndent = 25;
        final BooleanParameter enable_dndprefix = new BooleanParameter(gFile, sCurConfigID, "ConfigView.section.file.dnd.prefix.enable");
        enable_dndprefix.setLayoutData(gridData);
        ParameterChangeListener listener = new ParameterChangeAdapter() {

            @Override
            public void parameterChanged(Parameter p, boolean caused_internally) {
                enable_dndprefix.setEnabled(enable_subfolder.isSelected() || rename_incomplete.isSelected());
            }
        };
        enable_subfolder.addChangeListener(listener);
        rename_incomplete.addChangeListener(listener);
        listener.parameterChanged(null, true);
    }
    // download history
    sCurConfigID = "Download History Enabled";
    allConfigIDs.add(sCurConfigID);
    BooleanParameter recordDLHistory = new BooleanParameter(gFile, sCurConfigID, "ConfigView.label.record.dl.history");
    gridData = new GridData();
    gridData.horizontalSpan = 2;
    recordDLHistory.setLayoutData(gridData);
    if (userMode > 0) {
        Group gIgnoredFiles = new Group(gFile, SWT.NONE);
        Messages.setLanguageText(gIgnoredFiles, "ConfigView.section.file.ignore.section");
        layout = new GridLayout();
        layout.numColumns = 2;
        layout.marginHeight = 5;
        gIgnoredFiles.setLayout(layout);
        gridData = new GridData(GridData.FILL_HORIZONTAL);
        gridData.horizontalSpan = 2;
        Utils.setLayoutData(gIgnoredFiles, gridData);
        // torrent add auto-skip file types
        Label lSkipFiles = new Label(gIgnoredFiles, SWT.NULL);
        Messages.setLanguageText(lSkipFiles, "ConfigView.section.file.torrent.autoskipfiles");
        gridData = new GridData(GridData.FILL_HORIZONTAL);
        new StringParameter(gIgnoredFiles, "File.Torrent.AutoSkipExtensions").setLayoutData(gridData);
        // torrent add auto-skip min size
        Label lSkipFilesMinSize = new Label(gIgnoredFiles, SWT.NULL);
        Messages.setLanguageText(lSkipFilesMinSize, "ConfigView.section.file.torrent.autoskipfilesminsize");
        new IntParameter(gIgnoredFiles, "File.Torrent.AutoSkipMinSizeKB", 0, Integer.MAX_VALUE);
        // torrent create/delete ignore files
        Label lIgnoreFiles = new Label(gIgnoredFiles, SWT.NULL);
        Messages.setLanguageText(lIgnoreFiles, "ConfigView.section.file.torrent.ignorefiles");
        gridData = new GridData(GridData.FILL_HORIZONTAL);
        new StringParameter(gIgnoredFiles, "File.Torrent.IgnoreFiles", TOTorrent.DEFAULT_IGNORE_FILES).setLayoutData(gridData);
        if (userMode > 1) {
            Label lFileCharConv = new Label(gFile, SWT.NULL);
            Messages.setLanguageText(lFileCharConv, "ConfigView.section.file.char.conversions");
            gridData = new GridData(GridData.FILL_HORIZONTAL);
            new StringParameter(gFile, "File.Character.Conversions", ConfigurationDefaults.DEFAULT_FILE_CONVERSION_CHARS).setLayoutData(gridData);
        }
    }
    // File Deletetion Group
    Group gDeletion = new Group(gFile, SWT.NONE);
    Messages.setLanguageText(gDeletion, "ConfigView.section.file.deletion.section");
    layout = new GridLayout();
    layout.numColumns = 2;
    layout.marginHeight = 5;
    gDeletion.setLayout(layout);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalSpan = 2;
    Utils.setLayoutData(gDeletion, gridData);
    if (userMode > 0) {
        Composite c = new Composite(gDeletion, SWT.NONE);
        layout = new GridLayout();
        layout.numColumns = 2;
        layout.marginHeight = 0;
        layout.marginWidth = 0;
        c.setLayout(layout);
        gridData = new GridData(GridData.FILL_HORIZONTAL);
        gridData.horizontalSpan = 2;
        Utils.setLayoutData(c, gridData);
        sCurConfigID = "tb.confirm.delete.content";
        label = new Label(c, SWT.NULL);
        Messages.setLanguageText(label, "ConfigView.section.file.tb.delete");
        int[] values = { 0, 1, 2 };
        String[] labels = { MessageText.getString("ConfigView.tb.delete.ask"), MessageText.getString("ConfigView.tb.delete.content"), MessageText.getString("ConfigView.tb.delete.torrent") };
        new IntListParameter(c, sCurConfigID, labels, values);
        sCurConfigID = "def.deletetorrent";
        allConfigIDs.add(sCurConfigID);
        gridData = new GridData();
        gridData.horizontalSpan = 2;
        new BooleanParameter(gDeletion, sCurConfigID, "ConfigView.section.file.delete.torrent").setLayoutData(gridData);
    }
    try {
        final PlatformManager platform = PlatformManagerFactory.getPlatformManager();
        if (platform.hasCapability(PlatformManagerCapabilities.RecoverableFileDelete)) {
            sCurConfigID = "Move Deleted Data To Recycle Bin";
            allConfigIDs.add(sCurConfigID);
            gridData = new GridData();
            gridData.horizontalSpan = 2;
            new BooleanParameter(gDeletion, sCurConfigID, "ConfigView.section.file.nativedelete").setLayoutData(gridData);
        }
    } catch (Throwable e) {
    }
    if (userMode > 0) {
        sCurConfigID = "File.delete.include_files_outside_save_dir";
        allConfigIDs.add(sCurConfigID);
        gridData = new GridData();
        gridData.horizontalSpan = 2;
        new BooleanParameter(gDeletion, sCurConfigID, "ConfigView.section.file.delete.include_files_outside_save_dir").setLayoutData(gridData);
        sCurConfigID = "Delete Partial Files On Library Removal";
        allConfigIDs.add(sCurConfigID);
        gridData = new GridData();
        gridData.horizontalSpan = 2;
        new BooleanParameter(gDeletion, sCurConfigID, "delete.partial.files").setLayoutData(gridData);
    }
    if (userMode > 0) {
        Group gConfigSettings = new Group(gFile, SWT.NONE);
        Messages.setLanguageText(gConfigSettings, "ConfigView.section.file.config.section");
        layout = new GridLayout();
        layout.numColumns = 2;
        layout.marginHeight = 5;
        gConfigSettings.setLayout(layout);
        gridData = new GridData(GridData.FILL_HORIZONTAL);
        gridData.horizontalSpan = 2;
        Utils.setLayoutData(gConfigSettings, gridData);
        // Configuration directory information.
        Label config_label = new Label(gConfigSettings, SWT.NULL);
        Messages.setLanguageText(config_label, "ConfigView.section.file.config.currentdir");
        Utils.setLayoutData(config_label, new GridData());
        Label config_link = new Label(gConfigSettings, SWT.NULL);
        config_link.setText(SystemProperties.getUserPath());
        Utils.setLayoutData(config_link, new GridData());
        LinkLabel.makeLinkedLabel(config_link, SystemProperties.getUserPath());
        sCurConfigID = "Use Config File Backups";
        allConfigIDs.add(sCurConfigID);
        // check on complete
        BooleanParameter backupConfig = new BooleanParameter(gConfigSettings, sCurConfigID, "ConfigView.label.backupconfigfiles");
        gridData = new GridData();
        gridData.horizontalSpan = 2;
        backupConfig.setLayoutData(gridData);
    }
    /*
		    Button buttonReset = new Button(gFile, SWT.PUSH);
		    Messages.setLanguageText(buttonReset, "Button.reset");
		    gridData = new GridData(GridData.FILL_VERTICAL | GridData.VERTICAL_ALIGN_END);
		  	gridData.horizontalSpan = 2;
		  	Utils.setLayoutData(buttonReset, gridData);
		  	buttonReset.addSelectionListener(new SelectionAdapter() {
		  		public void widgetSelected(SelectionEvent e) {
		  			for (Iterator iter = allConfigIDs.iterator(); iter.hasNext();) {
							String sConfigID = (String) iter.next();
							COConfigurationManager.removeParameter(sConfigID);
						}
		  		}
		  	});
		*/
    return gFile;
}
Also used : PlatformManager(com.biglybt.platform.PlatformManager) LinkLabel(com.biglybt.ui.swt.components.LinkLabel) ArrayList(java.util.ArrayList) Image(org.eclipse.swt.graphics.Image) GridLayout(org.eclipse.swt.layout.GridLayout) RowLayout(org.eclipse.swt.layout.RowLayout) GridData(org.eclipse.swt.layout.GridData) ImageLoader(com.biglybt.ui.swt.imageloader.ImageLoader)

Example 10 with ImageLoader

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

the class ConfigSectionBackupRestore method configSectionDelete.

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

Aggregations

ImageLoader (com.biglybt.ui.swt.imageloader.ImageLoader)71 Image (org.eclipse.swt.graphics.Image)18 GridData (org.eclipse.swt.layout.GridData)14 GridLayout (org.eclipse.swt.layout.GridLayout)14 CoreRunningListener (com.biglybt.core.CoreRunningListener)5 MessageText (com.biglybt.core.internat.MessageText)5 AERunnable (com.biglybt.core.util.AERunnable)5 UserPrompterResultListener (com.biglybt.ui.UserPrompterResultListener)5 ArrayList (java.util.ArrayList)5 Rectangle (org.eclipse.swt.graphics.Rectangle)5 Core (com.biglybt.core.Core)4 LinkLabel (com.biglybt.ui.swt.components.LinkLabel)4 MessageBoxShell (com.biglybt.ui.swt.shells.MessageBoxShell)4 File (java.io.File)4 DisposeEvent (org.eclipse.swt.events.DisposeEvent)4 DisposeListener (org.eclipse.swt.events.DisposeListener)4 MouseAdapter (org.eclipse.swt.events.MouseAdapter)4 MouseEvent (org.eclipse.swt.events.MouseEvent)4 FormData (org.eclipse.swt.layout.FormData)4 TableColumnCreationListener (com.biglybt.pif.ui.tables.TableColumnCreationListener)3