Search in sources :

Example 1 with IntListParameter

use of com.biglybt.ui.swt.config.IntListParameter in project BiglyBT by BiglySoftware.

the class ConfigSectionSeedingFirstPriority method configSectionCreate.

@Override
public Composite configSectionCreate(Composite parent) {
    // Seeding Automation Setup
    GridData gridData;
    GridLayout layout;
    Label label;
    Composite cArea, cArea1;
    Composite cFirstPriorityArea = new Composite(parent, SWT.NULL);
    layout = new GridLayout();
    layout.numColumns = 2;
    layout.marginHeight = 0;
    cFirstPriorityArea.setLayout(layout);
    gridData = new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL);
    Utils.setLayoutData(cFirstPriorityArea, gridData);
    label = new Label(cFirstPriorityArea, SWT.WRAP);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalSpan = 2;
    gridData.widthHint = 300;
    Utils.setLayoutData(label, gridData);
    Messages.setLanguageText(label, "ConfigView.label.seeding.firstPriority.info");
    // ** Begin No Touch area
    // Group FP
    Composite cFP = new Group(cFirstPriorityArea, SWT.NULL);
    layout = new GridLayout();
    layout.numColumns = 2;
    layout.verticalSpacing = 6;
    cFP.setLayout(layout);
    gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL);
    Utils.setLayoutData(cFP, gridData);
    Messages.setLanguageText(cFP, "ConfigView.label.seeding.firstPriority.FP");
    // row
    cArea = new Composite(cFP, SWT.NULL);
    layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.numColumns = 3;
    cArea.setLayout(layout);
    gridData = new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL);
    gridData.horizontalSpan = 3;
    Utils.setLayoutData(cArea, gridData);
    label = new Label(cArea, SWT.NULL);
    Messages.setLanguageText(label, "ConfigView.label.seeding.firstPriority");
    String[] fpLabels = { MessageText.getString("ConfigView.text.all"), MessageText.getString("ConfigView.text.any") };
    int[] fpValues = { DefaultRankCalculator.FIRSTPRIORITY_ALL, DefaultRankCalculator.FIRSTPRIORITY_ANY };
    new IntListParameter(cArea, "StartStopManager_iFirstPriority_Type", fpLabels, fpValues);
    label = new Label(cArea, SWT.NULL);
    Messages.setLanguageText(label, "ConfigView.label.seeding.firstPriority.following");
    // row
    label = new Label(cFP, SWT.NULL);
    Messages.setLanguageText(label, "ConfigView.label.seeding.firstPriority.shareRatio");
    String[] minQueueLabels = new String[55];
    int[] minQueueValues = new int[55];
    minQueueLabels[0] = "1:2 (" + 0.5 + ")";
    minQueueValues[0] = 500;
    minQueueLabels[1] = "3:4 (" + 0.75 + ")";
    minQueueValues[1] = 750;
    minQueueLabels[2] = "1:1";
    minQueueValues[2] = 1000;
    minQueueLabels[3] = "5:4 (" + 1.25 + ")";
    minQueueValues[3] = 1250;
    minQueueLabels[4] = "3:2 (" + 1.50 + ")";
    minQueueValues[4] = 1500;
    minQueueLabels[5] = "7:4 (" + 1.75 + ")";
    minQueueValues[5] = 1750;
    for (int i = 6; i < minQueueLabels.length; i++) {
        minQueueLabels[i] = i - 4 + ":1";
        minQueueValues[i] = (i - 4) * 1000;
    }
    new IntListParameter(cFP, "StartStopManager_iFirstPriority_ShareRatio", minQueueLabels, minQueueValues);
    String sMinutes = MessageText.getString("ConfigView.text.minutes");
    String sHours = MessageText.getString("ConfigView.text.hours");
    // row
    label = new Label(cFP, SWT.NULL);
    Messages.setLanguageText(label, "ConfigView.label.seeding.firstPriority.DLMinutes");
    String[] dlTimeLabels = new String[15];
    int[] dlTimeValues = new int[15];
    dlTimeLabels[0] = MessageText.getString("ConfigView.text.ignore");
    dlTimeValues[0] = 0;
    for (int i = 1; i < dlTimeValues.length; i++) {
        dlTimeLabels[i] = "<= " + (i + 2) + " " + sHours;
        dlTimeValues[i] = (i + 2) * 60;
    }
    new IntListParameter(cFP, "StartStopManager_iFirstPriority_DLMinutes", dlTimeLabels, dlTimeValues);
    label = new Label(cFirstPriorityArea, SWT.WRAP);
    // row
    label = new Label(cFP, SWT.NULL);
    Messages.setLanguageText(label, "ConfigView.label.seeding.firstPriority.seedingMinutes");
    String[] seedTimeLabels = new String[15];
    int[] seedTimeValues = new int[15];
    seedTimeLabels[0] = MessageText.getString("ConfigView.text.ignore");
    seedTimeValues[0] = 0;
    seedTimeLabels[1] = "<= 90 " + sMinutes;
    seedTimeValues[1] = 90;
    for (int i = 2; i < seedTimeValues.length; i++) {
        seedTimeLabels[i] = "<= " + i + " " + sHours;
        seedTimeValues[i] = i * 60;
    }
    new IntListParameter(cFP, "StartStopManager_iFirstPriority_SeedingMinutes", seedTimeLabels, seedTimeValues);
    // Group Ignore FP
    Composite cIgnoreFP = new Group(cFirstPriorityArea, SWT.NULL);
    layout = new GridLayout();
    layout.numColumns = 2;
    layout.verticalSpacing = 6;
    cIgnoreFP.setLayout(layout);
    gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL);
    gridData.horizontalSpan = 2;
    Utils.setLayoutData(cIgnoreFP, gridData);
    Messages.setLanguageText(cIgnoreFP, "ConfigView.label.seeding.firstPriority.ignore");
    // Ignore S:P Ratio
    label = new Label(cIgnoreFP, SWT.NULL);
    Messages.setLanguageText(label, "ConfigView.label.seeding.firstPriority.ignoreSPRatio");
    String[] ignoreSPRatioLabels = new String[15];
    int[] ignoreSPRatioValues = new int[15];
    ignoreSPRatioLabels[0] = MessageText.getString("ConfigView.text.ignore");
    ignoreSPRatioValues[0] = 0;
    for (int i = 1; i < ignoreSPRatioLabels.length; i++) {
        ignoreSPRatioLabels[i] = i * 10 + " " + ":1";
        ignoreSPRatioValues[i] = i * 10;
    }
    new IntListParameter(cIgnoreFP, "StartStopManager_iFirstPriority_ignoreSPRatio", 0, ignoreSPRatioLabels, ignoreSPRatioValues);
    // Ignore 0 Peers
    new BooleanParameter(cIgnoreFP, "StartStopManager_bFirstPriority_ignore0Peer", "ConfigView.label.seeding.firstPriority.ignore0Peer");
    label = new Label(cIgnoreFP, SWT.NULL);
    // Ignore idle hours
    label = new Label(cIgnoreFP, SWT.NULL);
    Messages.setLanguageText(label, "ConfigView.label.seeding.firstPriority.ignoreIdleHours");
    int[] availIdleHours = { 2, 3, 4, 5, 6, 7, 8, 12, 18, 24, 48, 72, 168 };
    String[] ignoreIdleHoursLabels = new String[availIdleHours.length + 1];
    int[] ignoreIdleHoursValues = new int[availIdleHours.length + 1];
    ignoreIdleHoursLabels[0] = MessageText.getString("ConfigView.text.ignore");
    ignoreIdleHoursValues[0] = 0;
    for (int i = 0; i < availIdleHours.length; i++) {
        ignoreIdleHoursLabels[i + 1] = availIdleHours[i] + " " + sHours;
        ignoreIdleHoursValues[i + 1] = availIdleHours[i];
    }
    new IntListParameter(cIgnoreFP, "StartStopManager_iFirstPriority_ignoreIdleHours", 0, ignoreIdleHoursLabels, ignoreIdleHoursValues);
    // row
    cArea1 = new Composite(cIgnoreFP, SWT.NULL);
    layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.numColumns = 2;
    cArea1.setLayout(layout);
    gridData = new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL);
    gridData.horizontalSpan = 2;
    Utils.setLayoutData(cArea1, gridData);
    label = new Label(cArea1, SWT.NULL);
    Messages.setLanguageText(label, "ConfigView.label.seeding.firstPriority.ignore.info");
    new BooleanParameter(cFirstPriorityArea, "StartStopManager_bTagFirstPriority", "ConfigView.label.queue.tagfirstpriority");
    return cFirstPriorityArea;
}
Also used : Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) IntListParameter(com.biglybt.ui.swt.config.IntListParameter) BooleanParameter(com.biglybt.ui.swt.config.BooleanParameter)

Example 2 with IntListParameter

use of com.biglybt.ui.swt.config.IntListParameter in project BiglyBT by BiglySoftware.

the class ConfigSectionDownloading method configSectionCreate.

@Override
public Composite configSectionCreate(Composite parent) {
    // Seeding Automation Setup
    GridData gridData;
    GridLayout layout;
    Label label;
    Composite cDownloading = new Composite(parent, SWT.NULL);
    layout = new GridLayout();
    layout.numColumns = 2;
    layout.marginHeight = 0;
    cDownloading.setLayout(layout);
    gridData = new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL);
    Utils.setLayoutData(cDownloading, gridData);
    // wiki link
    final Label linkLabel = new Label(cDownloading, SWT.NULL);
    linkLabel.setText(MessageText.getString("ConfigView.label.please.visit.here"));
    linkLabel.setData(Constants.URL_WIKI + "w/Downloading_Rules");
    linkLabel.setCursor(linkLabel.getDisplay().getSystemCursor(SWT.CURSOR_HAND));
    linkLabel.setForeground(Colors.blue);
    gridData = new GridData();
    gridData.horizontalSpan = 2;
    Utils.setLayoutData(linkLabel, gridData);
    linkLabel.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDoubleClick(MouseEvent arg0) {
            Utils.launch((String) ((Label) arg0.widget).getData());
        }

        @Override
        public void mouseDown(MouseEvent arg0) {
            Utils.launch((String) ((Label) arg0.widget).getData());
        }
    });
    ClipboardCopy.addCopyToClipMenu(linkLabel);
    // sort type
    label = new Label(cDownloading, SWT.NULL);
    Messages.setLanguageText(label, "label.prioritize.downloads.based.on");
    String[] orderLabels = { MessageText.getString("label.order"), MessageText.getString("label.seed.count"), MessageText.getString("label.reverse.seed.count"), MessageText.getString("TableColumn.header.size"), MessageText.getString("label.reverse.size"), MessageText.getString("label.speed") };
    int[] orderValues = { DefaultRankCalculator.DOWNLOAD_ORDER_INDEX, DefaultRankCalculator.DOWNLOAD_ORDER_SEED_COUNT, DefaultRankCalculator.DOWNLOAD_ORDER_REVERSE_SEED_COUNT, DefaultRankCalculator.DOWNLOAD_ORDER_SIZE, DefaultRankCalculator.DOWNLOAD_ORDER_REVERSE_SIZE, DefaultRankCalculator.DOWNLOAD_ORDER_SPEED };
    final IntListParameter sort_type = new IntListParameter(cDownloading, "StartStopManager_Downloading_iSortType", orderLabels, orderValues);
    Group gSpeed = new Group(cDownloading, SWT.NULL);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    layout = new GridLayout();
    layout.numColumns = 2;
    // layout.marginHeight = 0;
    gSpeed.setLayout(layout);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalSpan = 2;
    Utils.setLayoutData(gSpeed, gridData);
    gSpeed.setText(MessageText.getString("label.speed.options"));
    // info
    label = new Label(gSpeed, SWT.WRAP);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalSpan = 2;
    gridData.widthHint = 300;
    Utils.setLayoutData(label, gridData);
    Messages.setLanguageText(label, "ConfigView.label.downloading.info");
    // test time
    label = new Label(gSpeed, SWT.NULL);
    Messages.setLanguageText(label, "ConfigView.label.downloading.testTime");
    gridData = new GridData();
    final IntParameter testTime = new IntParameter(gSpeed, "StartStopManager_Downloading_iTestTimeSecs");
    testTime.setLayoutData(gridData);
    testTime.setMinimumValue(60);
    // re-test
    label = new Label(gSpeed, SWT.NULL);
    Messages.setLanguageText(label, "ConfigView.label.downloading.reTest");
    gridData = new GridData();
    final IntParameter reTest = new IntParameter(gSpeed, "StartStopManager_Downloading_iRetestTimeMins");
    reTest.setLayoutData(gridData);
    reTest.setMinimumValue(0);
    ParameterChangeListener listener = new ParameterChangeAdapter() {

        @Override
        public void parameterChanged(Parameter p, boolean caused_internally) {
            boolean is_speed = ((Integer) sort_type.getValueObject()) == DefaultRankCalculator.DOWNLOAD_ORDER_SPEED;
            testTime.setEnabled(is_speed);
            reTest.setEnabled(is_speed);
        }
    };
    sort_type.addChangeListener(listener);
    listener.parameterChanged(null, false);
    return cDownloading;
}
Also used : ParameterChangeListener(com.biglybt.ui.swt.config.ParameterChangeListener) MouseEvent(org.eclipse.swt.events.MouseEvent) MouseAdapter(org.eclipse.swt.events.MouseAdapter) ParameterChangeAdapter(com.biglybt.ui.swt.config.ParameterChangeAdapter) IntListParameter(com.biglybt.ui.swt.config.IntListParameter) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) IntListParameter(com.biglybt.ui.swt.config.IntListParameter) IntParameter(com.biglybt.ui.swt.config.IntParameter) Parameter(com.biglybt.ui.swt.config.Parameter) IntParameter(com.biglybt.ui.swt.config.IntParameter)

Example 3 with IntListParameter

use of com.biglybt.ui.swt.config.IntListParameter in project BiglyBT by BiglySoftware.

the class ConfigSectionTransferAutoSpeedBeta method configSectionCreate.

@Override
public Composite configSectionCreate(final Composite parent) {
    GridData gridData;
    Composite cSection = new Composite(parent, SWT.NULL);
    gridData = new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL);
    cSection.setLayoutData(gridData);
    GridLayout subPanel = new GridLayout();
    subPanel.numColumns = 3;
    cSection.setLayout(subPanel);
    // add a comment to the debug log.
    // /////////////////////////////////
    // Comment group
    // /////////////////////////////////
    Group commentGroup = new Group(cSection, SWT.NULL);
    Messages.setLanguageText(commentGroup, "ConfigTransferAutoSpeed.add.comment.to.log.group");
    GridLayout commentLayout = new GridLayout();
    commentLayout.numColumns = 3;
    commentGroup.setLayout(commentLayout);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    commentGroup.setLayoutData(gridData);
    // Label
    Label commentLabel = new Label(commentGroup, SWT.NULL);
    Messages.setLanguageText(commentLabel, "ConfigTransferAutoSpeed.add.comment.to.log");
    gridData = new GridData();
    gridData.horizontalSpan = 1;
    commentLabel.setLayoutData(gridData);
    // Text-Box
    final Text commentBox = new Text(commentGroup, SWT.BORDER);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalSpan = 1;
    commentBox.setText("");
    commentBox.setLayoutData(gridData);
    // button
    Button commentButton = new Button(commentGroup, SWT.PUSH);
    // Messages.
    gridData = new GridData();
    gridData.horizontalSpan = 1;
    commentButton.setLayoutData(gridData);
    Messages.setLanguageText(commentButton, "ConfigTransferAutoSpeed.log.button");
    commentButton.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(Event event) {
            // Add a file to the log.
            AEDiagnosticsLogger dLog = AEDiagnostics.getLogger("AutoSpeed");
            String comment = commentBox.getText();
            if (comment != null) {
                if (comment.length() > 0) {
                    dLog.log("user-comment:" + comment);
                    commentBox.setText("");
                }
            }
        }
    });
    // spacer
    Label commentSpacer = new Label(cSection, SWT.NULL);
    gridData = new GridData();
    gridData.horizontalSpan = 3;
    commentSpacer.setLayoutData(gridData);
    // /////////////////////////
    // Upload Capacity used settings.
    // /////////////////////////
    Group uploadCapGroup = new Group(cSection, SWT.NULL);
    Messages.setLanguageText(uploadCapGroup, "ConfigTransferAutoSpeed.upload.capacity.usage");
    GridLayout uCapLayout = new GridLayout();
    uCapLayout.numColumns = 2;
    uploadCapGroup.setLayout(uCapLayout);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalSpan = 3;
    uploadCapGroup.setLayoutData(gridData);
    // Label column
    Label upCapModeLbl = new Label(uploadCapGroup, SWT.NULL);
    gridData = new GridData();
    upCapModeLbl.setLayoutData(gridData);
    Messages.setLanguageText(upCapModeLbl, "ConfigTransferAutoSpeed.mode");
    Label ucSetLbl = new Label(uploadCapGroup, SWT.NULL);
    gridData = new GridData();
    gridData.horizontalSpan = 2;
    Messages.setLanguageText(ucSetLbl, "ConfigTransferAutoSpeed.capacity.used");
    Label dlModeLbl = new Label(uploadCapGroup, SWT.NULL);
    Messages.setLanguageText(dlModeLbl, "ConfigTransferAutoSpeed.while.downloading");
    // add a drop down.
    String[] downloadModeNames = { " 80%", " 70%", " 60%", " 50%" };
    int[] downloadModeValues = { 80, 70, 60, 50 };
    new IntListParameter(uploadCapGroup, SpeedLimitMonitor.USED_UPLOAD_CAPACITY_DOWNLOAD_MODE, downloadModeNames, downloadModeValues);
    // spacer
    Label cSpacer = new Label(cSection, SWT.NULL);
    gridData = new GridData();
    gridData.horizontalSpan = 4;
    cSpacer.setLayoutData(gridData);
    // ////////////////////////
    // DHT Ping Group
    // ////////////////////////
    Group dhtGroup = new Group(cSection, SWT.NULL);
    Messages.setLanguageText(dhtGroup, "ConfigTransferAutoSpeed.data.update.frequency");
    dhtGroup.setLayout(subPanel);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalSpan = 3;
    dhtGroup.setLayoutData(gridData);
    // how much data to accumulate before making an adjustment.
    Label iCount = new Label(dhtGroup, SWT.NULL);
    gridData = new GridData();
    gridData.horizontalSpan = 2;
    gridData.horizontalAlignment = GridData.BEGINNING;
    iCount.setLayoutData(gridData);
    // iCount.setText("Adjustment interval: ");
    Messages.setLanguageText(iCount, "ConfigTransferAutoSpeed.adjustment.interval");
    IntParameter adjustmentInterval = new IntParameter(dhtGroup, SpeedManagerAlgorithmProviderV2.SETTING_INTERVALS_BETWEEN_ADJUST);
    gridData = new GridData();
    adjustmentInterval.setLayoutData(gridData);
    // spacer
    cSpacer = new Label(cSection, SWT.NULL);
    gridData = new GridData();
    gridData.horizontalSpan = 1;
    cSpacer.setLayoutData(gridData);
    // how much data to accumulate before making an adjustment.
    Label skip = new Label(dhtGroup, SWT.NULL);
    gridData = new GridData();
    gridData.horizontalSpan = 2;
    gridData.horizontalAlignment = GridData.BEGINNING;
    skip.setLayoutData(gridData);
    // skip.setText("Skip after adjustment: ");
    Messages.setLanguageText(skip, "ConfigTransferAutoSpeed.skip.after.adjust");
    BooleanParameter skipAfterAdjustment = new BooleanParameter(dhtGroup, SpeedManagerAlgorithmProviderV2.SETTING_WAIT_AFTER_ADJUST);
    gridData = new GridData();
    skipAfterAdjustment.setLayoutData(gridData);
    // spacer
    cSpacer = new Label(cSection, SWT.NULL);
    gridData = new GridData();
    gridData.horizontalSpan = 3;
    cSpacer.setLayoutData(gridData);
    return cSection;
}
Also used : IntListParameter(com.biglybt.ui.swt.config.IntListParameter) BooleanParameter(com.biglybt.ui.swt.config.BooleanParameter) GridLayout(org.eclipse.swt.layout.GridLayout) AEDiagnosticsLogger(com.biglybt.core.util.AEDiagnosticsLogger) GridData(org.eclipse.swt.layout.GridData) IntParameter(com.biglybt.ui.swt.config.IntParameter)

Aggregations

IntListParameter (com.biglybt.ui.swt.config.IntListParameter)3 GridData (org.eclipse.swt.layout.GridData)3 GridLayout (org.eclipse.swt.layout.GridLayout)3 BooleanParameter (com.biglybt.ui.swt.config.BooleanParameter)2 IntParameter (com.biglybt.ui.swt.config.IntParameter)2 AEDiagnosticsLogger (com.biglybt.core.util.AEDiagnosticsLogger)1 Parameter (com.biglybt.ui.swt.config.Parameter)1 ParameterChangeAdapter (com.biglybt.ui.swt.config.ParameterChangeAdapter)1 ParameterChangeListener (com.biglybt.ui.swt.config.ParameterChangeListener)1 MouseAdapter (org.eclipse.swt.events.MouseAdapter)1 MouseEvent (org.eclipse.swt.events.MouseEvent)1 Composite (org.eclipse.swt.widgets.Composite)1 Group (org.eclipse.swt.widgets.Group)1 Label (org.eclipse.swt.widgets.Label)1