gridData = new GridData();
gridData.horizontalIndent = 15;
gridData.horizontalSpan = 2;
cMaxActiveOptionsArea.setLayoutData(gridData);
ImageLoader imageLoader = ImageLoader.getInstance();
label = new Label(cMaxActiveOptionsArea, SWT.NULL);
imageLoader.setLabelImage(label, "subitem");
gridData = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
label.setLayoutData(gridData);
gridData = new GridData();
BooleanParameter maxActiveWhenSeedingEnabled = new BooleanParameter(
cMaxActiveOptionsArea,
"StartStopManager_bMaxActiveTorrentsWhenSeedingEnabled",
"ConfigView.label.queue.maxactivetorrentswhenseeding");
maxActiveWhenSeedingEnabled.setLayoutData(gridData);
gridData = new GridData();
final IntParameter maxActivWhenSeeding = new IntParameter(
cMaxActiveOptionsArea, "StartStopManager_iMaxActiveTorrentsWhenSeeding");
maxActivWhenSeeding.setLayoutData(gridData);
// row
label = new Label(cSection, SWT.NULL);
Messages.setLanguageText(label, "ConfigView.label.mindownloads");
gridData = new GridData();
final IntParameter minDLs = new IntParameter(cSection, "min downloads");
minDLs.setLayoutData(gridData);
minDLs.setMaximumValue(maxDLs.getValue() / 2);
// change controllers for above items
maxActiveWhenSeedingEnabled.setAdditionalActionPerformer(new ChangeSelectionActionPerformer(
maxActivWhenSeeding));
maxDLs.addChangeListener(new ParameterChangeAdapter() {
public void parameterChanged(Parameter p, boolean caused_internally) {
int iMaxDLs = maxDLs.getValue();
minDLs.setMaximumValue(iMaxDLs / 2);
int iMinDLs = minDLs.getValue();
int iMaxActive = maxActiv.getValue();
if ((iMaxDLs == 0 || iMaxDLs > iMaxActive) && iMaxActive != 0) {
maxActiv.setValue(iMaxDLs);
}
}
});
maxActiv.addChangeListener(new ParameterChangeAdapter() {
public void parameterChanged(Parameter p, boolean caused_internally) {
int iMaxDLs = maxDLs.getValue();
int iMaxActive = maxActiv.getValue();
if ((iMaxDLs == 0 || iMaxDLs > iMaxActive) && iMaxActive != 0) {
maxDLs.setValue(iMaxActive);
}
}
});
// row
final ArrayList values = new ArrayList();
int exp = 29;
for(int val = 0; val <= 8*1024*1024;)
{
values.add(new Integer(val));
if(val < 256)
val+=64;
else if(val < 1024)
val+=256;
else if(val < 16*1024)
val+=1024;
else
val = (int)(Math.pow(2, exp++/2) + (exp % 2 == 0 ? Math.pow(2, (exp-3)/2) : 0));
}
String[] activeDLLabels = new String[values.size()];
int[] activeDLValues = new int[activeDLLabels.length];
label = new Label(cSection, SWT.NULL);
Messages.setLanguageText(label, "ConfigView.label.minSpeedForActiveDL");
for(int i=0;i<activeDLLabels.length;i++)
{
activeDLValues[i] = ((Integer)values.get(i)).intValue();
activeDLLabels[i] = DisplayFormatters.formatByteCountToKiBEtcPerSec(
activeDLValues[i], true);
}
new IntListParameter(cSection, "StartStopManager_iMinSpeedForActiveDL",
activeDLLabels, activeDLValues);
// row
label = new Label(cSection, SWT.NULL);
Messages.setLanguageText(label, "ConfigView.label.minSpeedForActiveSeeding");
String[] activeSeedingLabels = new String[values.size()-4];
int[] activeSeedingValues = new int[activeSeedingLabels.length];
System.arraycopy(activeDLLabels, 0, activeSeedingLabels, 0, activeSeedingLabels.length);
System.arraycopy(activeDLValues, 0, activeSeedingValues, 0, activeSeedingValues.length);
new IntListParameter(cSection,
"StartStopManager_iMinSpeedForActiveSeeding", activeSeedingLabels,
activeSeedingValues);
// subrow
final Composite cMinSpeedActiveCDing = new Composite(cSection, SWT.NULL);
layout = new GridLayout();
layout.numColumns = 3;
layout.marginWidth = 0;
layout.marginHeight = 0;
cMinSpeedActiveCDing.setLayout(layout);
gridData = new GridData();
gridData.horizontalIndent = 15;
gridData.horizontalSpan = 2;
cMinSpeedActiveCDing.setLayoutData(gridData);
label = new Label(cMinSpeedActiveCDing, SWT.NULL);
imageLoader.setLabelImage(label, "subitem");
gridData = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
label.setLayoutData(gridData);
label = new Label(cMinSpeedActiveCDing, SWT.NULL);
Messages.setLanguageText(label, "ConfigView.label.maxStalledSeeding");