Search in sources :

Example 1 with BaseSwtParameter

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

the class MultiParameterImplListenerSWT method labelChanged.

@Override
public void labelChanged(final ParameterImpl p, final String text, final boolean bIsKey) {
    BaseSwtParameter parameter = mapParamToSwtParam.get(p);
    if (parameter == null) {
        return;
    }
    if (parameter.isDisposed()) {
        // lazy tidyup
        p.removeImplListener(this);
        return;
    }
    parameter.refreshControl();
    Control lbl = parameter.getRelatedControl();
    if (!(lbl instanceof Label)) {
        return;
    }
    Utils.execSWTThread(() -> {
        if (bIsKey) {
            Messages.setLanguageText(lbl, text);
        } else {
            lbl.setData("");
            ((Label) lbl).setText(text);
        }
        lbl.getParent().layout(true);
    });
}
Also used : Control(org.eclipse.swt.widgets.Control) Label(org.eclipse.swt.widgets.Label) BaseSwtParameter(com.biglybt.ui.swt.config.BaseSwtParameter)

Example 2 with BaseSwtParameter

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

the class MultiParameterImplListenerSWT method refreshControl.

@Override
public void refreshControl(ParameterImpl p) {
    BaseSwtParameter parameter = mapParamToSwtParam.get(p);
    if (parameter == null) {
        return;
    }
    parameter.refreshControl();
}
Also used : BaseSwtParameter(com.biglybt.ui.swt.config.BaseSwtParameter)

Example 3 with BaseSwtParameter

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

the class MultiParameterImplListenerSWT method enabledChanged.

@Override
public void enabledChanged(final ParameterImpl p) {
    BaseSwtParameter parameter = mapParamToSwtParam.get(p);
    if (parameter == null) {
        return;
    }
    if (parameter.isDisposed()) {
        // lazy tidyup
        p.removeImplListener(this);
        return;
    }
    parameter.setEnabled(p.isEnabled());
}
Also used : BaseSwtParameter(com.biglybt.ui.swt.config.BaseSwtParameter)

Example 4 with BaseSwtParameter

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

the class TorrentOptionsView method setDefaults.

protected void setDefaults() {
    Iterator<Entry<String, BaseSwtParameter<?, ?>>> it = ds_parameters.entrySet().iterator();
    while (it.hasNext()) {
        Map.Entry<String, BaseSwtParameter<?, ?>> entry = it.next();
        String key = entry.getKey();
        for (int i = 0; i < managers.length; i++) {
            managers[i].setParameterDefault(key);
        }
        // we need an explicit refresh here because of the way the reset works - by the time to code
        // runs to see if the displayed value has changed from the parameter value the value has been
        // reset and appears not to have changed (even though the parameter has...)
        entry.getValue().refreshControl();
    }
    it = adhoc_parameters.entrySet().iterator();
    while (it.hasNext()) {
        Map.Entry<String, BaseSwtParameter<?, ?>> entry = it.next();
        BaseSwtParameter<?, ?> param = entry.getValue();
        if (param instanceof IntSwtParameter) {
            IntSwtParameter int_param = (IntSwtParameter) param;
            int_param.setValue(0);
        } else {
            Debug.out("Unknown parameter type: " + param.getClass());
        }
    }
}
Also used : TabbedEntry(com.biglybt.ui.swt.mdi.TabbedEntry) Entry(java.util.Map.Entry) IntSwtParameter(com.biglybt.ui.swt.config.IntSwtParameter) BaseSwtParameter(com.biglybt.ui.swt.config.BaseSwtParameter) HashMap(java.util.HashMap) Map(java.util.Map)

Example 5 with BaseSwtParameter

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

the class TorrentOptionsView method parameterChanged.

/* (non-Javadoc)
	 * @see com.biglybt.core.download.DownloadManagerStateAttributeListener#attributeEventOccurred(com.biglybt.core.download.DownloadManager, java.lang.String, int)
	 */
@Override
public void parameterChanged(DownloadManagerOptionsHandler manager) {
    Utils.execSWTThread(new Runnable() {

        @Override
        public void run() {
            Iterator<Entry<String, BaseSwtParameter<?, ?>>> it = ds_parameters.entrySet().iterator();
            while (it.hasNext()) {
                Map.Entry<String, BaseSwtParameter<?, ?>> entry = it.next();
                String key = entry.getKey();
                Object param = entry.getValue();
                if (param instanceof IntSwtParameter) {
                    IntSwtParameter int_param = (IntSwtParameter) param;
                    int value = manager.getIntParameter(key);
                    int_param.setValue(value);
                } else if (param instanceof BooleanSwtParameter) {
                    BooleanSwtParameter bool_param = (BooleanSwtParameter) param;
                    boolean value = manager.getBooleanParameter(key);
                    bool_param.setSelected(value);
                } else if (param instanceof FloatSwtParameter) {
                    FloatSwtParameter float_param = (FloatSwtParameter) param;
                    float value = manager.getIntParameter(key) / 1000f;
                    float_param.setValue(value);
                } else {
                    Debug.out("Unknown parameter type: " + param.getClass());
                }
            }
        }
    }, true);
}
Also used : TabbedEntry(com.biglybt.ui.swt.mdi.TabbedEntry) Entry(java.util.Map.Entry) FloatSwtParameter(com.biglybt.ui.swt.config.FloatSwtParameter) IntSwtParameter(com.biglybt.ui.swt.config.IntSwtParameter) BooleanSwtParameter(com.biglybt.ui.swt.config.BooleanSwtParameter) Iterator(java.util.Iterator) BaseSwtParameter(com.biglybt.ui.swt.config.BaseSwtParameter)

Aggregations

BaseSwtParameter (com.biglybt.ui.swt.config.BaseSwtParameter)8 ParameterImpl (com.biglybt.pifimpl.local.ui.config.ParameterImpl)2 IntSwtParameter (com.biglybt.ui.swt.config.IntSwtParameter)2 TabbedEntry (com.biglybt.ui.swt.mdi.TabbedEntry)2 Map (java.util.Map)2 Entry (java.util.Map.Entry)2 GridData (org.eclipse.swt.layout.GridData)2 Composite (org.eclipse.swt.widgets.Composite)2 Label (org.eclipse.swt.widgets.Label)2 Connection (com.biglybt.core.config.ConfigKeys.Connection)1 MessageText (com.biglybt.core.internat.MessageText)1 NetworkAdmin (com.biglybt.core.networkmanager.admin.NetworkAdmin)1 NetworkAdminSocksProxy (com.biglybt.core.networkmanager.admin.NetworkAdminSocksProxy)1 AESemaphore (com.biglybt.core.util.AESemaphore)1 AEThread2 (com.biglybt.core.util.AEThread2)1 Debug (com.biglybt.core.util.Debug)1 ParameterListener (com.biglybt.pif.ui.config.ParameterListener)1 BooleanParameterImpl (com.biglybt.pifimpl.local.ui.config.BooleanParameterImpl)1 IntParameterImpl (com.biglybt.pifimpl.local.ui.config.IntParameterImpl)1 StringParameterImpl (com.biglybt.pifimpl.local.ui.config.StringParameterImpl)1