TransferPanelpublic class TransferPanel extends org.gudy.azureus2.ui.swt.wizard.AbstractWizardPanel
Fields Summary |
---|
org.eclipse.swt.widgets.Label | nbMaxActive | org.eclipse.swt.widgets.Label | nbMaxDownloads | org.eclipse.swt.widgets.Label | nbMaxUploadsPerTorrent | private static final int[] | upRates |
Methods Summary |
---|
public void | computeAll(int maxUploadSpeed)
if (maxUploadSpeed != 0) {
int nbMaxActive = (int) (Math.pow(maxUploadSpeed,0.34) * 0.92);
int nbMaxUploads = (int) (Math.pow(maxUploadSpeed,0.25) * 1.68);
int nbMaxDownloads = (nbMaxActive * 4) / 5;
if (nbMaxDownloads == 0)
nbMaxDownloads = 1;
if (nbMaxUploads > 50)
nbMaxUploads = 50;
((ConfigureWizard) wizard).maxActiveTorrents = nbMaxActive;
((ConfigureWizard) wizard).maxDownloads = nbMaxDownloads;
((ConfigureWizard) wizard).nbUploadsPerTorrent = nbMaxUploads;
}
else {
((ConfigureWizard) wizard).maxActiveTorrents = 0;
((ConfigureWizard) wizard).maxDownloads = 0;
((ConfigureWizard) wizard).nbUploadsPerTorrent = 4;
}
refresh();
| private int | findIndex(int value, int[] values)
for (int i = 0; i < values.length; i++) {
if (values[i] == value)
return i;
}
return 0;
| public org.gudy.azureus2.ui.swt.wizard.IWizardPanel | getNextPanel()
return new NatPanel(((ConfigureWizard)wizard),this);
| public boolean | isNextEnabled()
return true;
| public void | refresh()
nbMaxActive.setText("" + ((ConfigureWizard) wizard).maxActiveTorrents);
nbMaxDownloads.setText("" + ((ConfigureWizard) wizard).maxDownloads);
nbMaxUploadsPerTorrent.setText("" + ((ConfigureWizard) wizard).nbUploadsPerTorrent);
| public void | show()
wizard.setTitle(MessageText.getString("configureWizard.transfer.title"));
wizard.setCurrentInfo(MessageText.getString("configureWizard.transfer.hint"));
Composite rootPanel = wizard.getPanel();
GridLayout layout = new GridLayout();
layout.numColumns = 1;
rootPanel.setLayout(layout);
Composite panel = new Composite(rootPanel, SWT.NULL);
GridData gridData = new GridData(GridData.FILL_BOTH);
panel.setLayoutData(gridData);
layout = new GridLayout();
layout.numColumns = 2;
panel.setLayout(layout);
Label label = new Label(panel, SWT.WRAP);
gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalSpan = 2;
label.setLayoutData(gridData);
Messages.setLanguageText(label, "configureWizard.transfer.message");
label = new Label(panel, SWT.NULL);
Messages.setLanguageText(label, "configureWizard.transfer.connection");
final Combo connections = new Combo(panel, SWT.SINGLE | SWT.READ_ONLY);
for (int i = 0; i < 8; i++) {
connections.add(MessageText.getString("configureWizard.transfer.connection." + i));
}
label = new Label(panel, SWT.NULL);
Messages.setLanguageText(label, "configureWizard.transfer.maxUpSpeed");
final String upsLabels[] = new String[upRates.length];
final int upsValues[] = new int[upRates.length];
upsLabels[0] = MessageText.getString("ConfigView.unlimited"); //$NON-NLS-1$
upsValues[0] = 0;
for (int i = 1; i < upRates.length; i++) {
upsLabels[i] = " " + upRates[i] + " KB/s"; //$NON-NLS-1$ //$NON-NLS-2$
upsValues[i] = 1024 * upRates[i];
}
final Combo cMaxUpSpeed = new Combo(panel, SWT.SINGLE | SWT.READ_ONLY);
for (int i = 0; i < upRates.length; i++) {
cMaxUpSpeed.add(upsLabels[i]);
}
//final Text textMaxUpSpeed = new Text(panel, SWT.BORDER);
gridData = new GridData();
gridData.widthHint = 100;
cMaxUpSpeed.setLayoutData(gridData);
label = new Label(panel, SWT.NULL);
Messages.setLanguageText(label, "configureWizard.transfer.maxActiveTorrents");
nbMaxActive = new Label(panel, SWT.NULL);
gridData = new GridData();
gridData.widthHint = 100;
nbMaxActive.setLayoutData(gridData);
label = new Label(panel, SWT.NULL);
Messages.setLanguageText(label, "configureWizard.transfer.maxDownloads");
nbMaxDownloads = new Label(panel, SWT.NULL);
gridData = new GridData();
gridData.widthHint = 100;
nbMaxDownloads.setLayoutData(gridData);
label = new Label(panel, SWT.NULL);
Messages.setLanguageText(label, "configureWizard.transfer.maxUploadsPerTorrent");
nbMaxUploadsPerTorrent = new Label(panel, SWT.NULL);
gridData = new GridData();
gridData.widthHint = 100;
nbMaxUploadsPerTorrent.setLayoutData(gridData);
connections.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
int index = connections.getSelectionIndex();
((ConfigureWizard) wizard).upSpeed = index;
if (index == 0) {
cMaxUpSpeed.setEnabled(true);
}
else {
cMaxUpSpeed.setEnabled(false);
int upSpeeds[] = { 0, 5, 13, 25, 40, 55, 85, 110 };
cMaxUpSpeed.select(findIndex(upSpeeds[index], upRates));
int maxUp = upRates[cMaxUpSpeed.getSelectionIndex()];
((ConfigureWizard) wizard).maxUpSpeed = maxUp;
computeAll(maxUp);
}
}
});
cMaxUpSpeed.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
int maxUp = upRates[cMaxUpSpeed.getSelectionIndex()];
((ConfigureWizard) wizard).maxUpSpeed = maxUp;
computeAll(maxUp);
}
});
connections.select(((ConfigureWizard) wizard).upSpeed);
cMaxUpSpeed.select(findIndex(((ConfigureWizard) wizard).maxUpSpeed, upRates));
cMaxUpSpeed.setEnabled(((ConfigureWizard) wizard).upSpeed == 0);
computeAll(((ConfigureWizard) wizard).maxUpSpeed);
|
|