Search in sources :

Example 1 with ParameterChangeListener

use of com.biglybt.ui.swt.config.ParameterChangeListener 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)

Aggregations

IntListParameter (com.biglybt.ui.swt.config.IntListParameter)1 IntParameter (com.biglybt.ui.swt.config.IntParameter)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 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1