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);
});
}
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();
}
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());
}
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());
}
}
}
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);
}
Aggregations