wizard.setTitle(MessageText.getString("SpeedTestWizard.set.upload.title"));
wizard.setCurrentInfo(MessageText.getString("SpeedTestWizard.set.upload.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_HORIZONTAL);
panel.setLayoutData(gridData);
layout = new GridLayout();
layout.numColumns = 4;
panel.setLayout(layout);
Label explain = new Label(panel, SWT.WRAP);
gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalSpan = 4;
explain.setLayoutData(gridData);
Messages.setLanguageText(explain,"SpeedTestWizard.set.upload.panel.explain");
//spacer line
Label spacer = new Label(panel, SWT.NULL);
gridData = new GridData();
gridData.horizontalSpan = 4;
spacer.setLayoutData(gridData);
Label spacer1 = new Label(panel, SWT.NULL);
gridData = new GridData();
spacer1.setLayoutData(gridData);
Label bytesCol = new Label(panel, SWT.NULL);
gridData = new GridData();
gridData.widthHint=80;
bytesCol.setLayoutData(gridData);
Messages.setLanguageText(bytesCol,"SpeedTestWizard.set.upload.bytes.per.sec");
Label bitsCol = new Label(panel, SWT.NULL);
gridData = new GridData();
gridData.widthHint=80;
bitsCol.setLayoutData(gridData);
Messages.setLanguageText(bitsCol,"SpeedTestWizard.set.upload.bits.per.sec");
Label confLevel = new Label(panel, SWT.NULL);
gridData = new GridData();
gridData.widthHint=80;
confLevel.setLayoutData(gridData);
Messages.setLanguageText(confLevel,"SpeedTestWizard.set.limit.conf.level");
//upload limit label.
Label ul = new Label(panel, SWT.NULL );
gridData = new GridData();
ul.setLayoutData(gridData);
Messages.setLanguageText(
ul,
"SpeedView.stats.estupcap",
new String[] { DisplayFormatters.getRateUnit(DisplayFormatters.UNIT_KB)});
final Text uploadLimitSetting = new Text(panel, SWT.BORDER );
gridData = new GridData(GridData.BEGINNING);
gridData.widthHint=80;
uploadLimitSetting.setLayoutData(gridData);
int uploadCapacity = determineRateSettingEx(measuredUploadKbps,uploadTestRan,true);
//don't accept any value less the 20 kb/s
if(uploadCapacity<20)
uploadCapacity=20;
uploadLimitSetting.setText( ""+uploadCapacity );
uploadLimitSetting.addListener(SWT.Verify, new NumberListener(uploadLimitSetting));
//echo
final Label echo = new Label(panel, SWT.NULL);
gridData = new GridData();
gridData.horizontalSpan = 1;
gridData.widthHint = 80;
echo.setLayoutData(gridData);
echo.setText( DisplayFormatters.formatByteCountToBitsPerSec(uploadCapacity*1024) );
//This space has a change listener the updates in bits/sec.
//want a change listener to update the echo label which has the value in bits/sec.
uploadLimitSetting.addListener(SWT.Modify, new ByteConversionListener(echo,uploadLimitSetting));
//confidence setting.
final String[] confName = helper.getSettableTypes();
final String[] confValue = helper.getSettableTypes();
//upload confidence setting.
int uploadDropIndex = setDefaultConfidenceLevelEx(measuredUploadKbps,uploadTestRan,true,confValue);
upConfLevelCombo = new Combo(panel, SWT.READ_ONLY );
addDropElements(upConfLevelCombo,confName);
upConfLevelCombo.select(uploadDropIndex);
//download limit label.
Label dl = new Label( panel, SWT.NULL );
gridData = new GridData();
dl.setLayoutData(gridData);
Messages.setLanguageText(
dl,
"SpeedView.stats.estdowncap",
new String[] { DisplayFormatters.getRateUnit(DisplayFormatters.UNIT_KB)});
final Text downloadLimitSetting = new Text(panel, SWT.BORDER);
gridData = new GridData(GridData.BEGINNING);
gridData.widthHint=80;
downloadLimitSetting.setLayoutData(gridData);
int bestDownloadSetting = determineRateSettingEx(measuredDownloadKbps,downloadTestRan,false);
downloadLimitSetting.setText( ""+bestDownloadSetting );
downloadLimitSetting.addListener(SWT.Verify, new NumberListener(downloadLimitSetting) );
//echo
final Label downEcho = new Label(panel, SWT.NULL);
gridData = new GridData();
gridData.horizontalSpan = 1;
gridData.widthHint = 80;
downEcho.setLayoutData(gridData);
downEcho.setText( DisplayFormatters.formatByteCountToBitsPerSec(bestDownloadSetting*1024) );
//convert bytes to bits on the fly for user.
downloadLimitSetting.addListener(SWT.Modify, new ByteConversionListener(downEcho, downloadLimitSetting) );
int downIndex = setDefaultConfidenceLevelEx(measuredDownloadKbps,downloadTestRan,false,confValue);
downConfLevelCombo = new Combo(panel, SWT.READ_ONLY );
addDropElements(downConfLevelCombo,confName);
downConfLevelCombo.select(downIndex);
//spacer col
Label c1 = new Label(panel, SWT.NULL);
gridData = new GridData();
gridData.horizontalSpan = 1;
gridData.widthHint = 80;
c1.setLayoutData(gridData);
SpeedManager sm = AzureusCoreFactory.getSingleton().getSpeedManager();
if ( uploadTestRan ){
//Since cable modems can over estimate upload need to drop type setting to estimate.
sm.setEstimatedUploadCapacityBytesPerSec(
measuredUploadKbps*1024,
uploadHitLimit?
SpeedManagerLimitEstimate.TYPE_ESTIMATED :SpeedManagerLimitEstimate.TYPE_ESTIMATED);
}
if ( downloadTestRan ){
sm.setEstimatedDownloadCapacityBytesPerSec(
measuredDownloadKbps*1024,
downloadHitLimit?
SpeedManagerLimitEstimate.TYPE_MEASURED_MIN :SpeedManagerLimitEstimate.TYPE_MEASURED);
}
apply = new Button(panel, SWT.PUSH);
Messages.setLanguageText(apply, "SpeedTestWizard.set.upload.button.apply" );
gridData = new GridData();
gridData.widthHint = 70;
apply.setLayoutData(gridData);
apply.addListener(SWT.Selection, new Listener(){
public void handleEvent(Event event){
//Turn the string into an int and make it kbps.
int uploadLimitKBPS = Integer.parseInt( uploadLimitSetting.getText() );
int downlaodLimitKBPS = Integer.parseInt( downloadLimitSetting.getText() );
//No value less then 20 kpbs should be allowed.
if(uploadLimitKBPS<20){
uploadLimitKBPS=20;
}
//download value can never be less then upload.
if( downlaodLimitKBPS < uploadLimitKBPS ){
downlaodLimitKBPS = uploadLimitKBPS;
}
//set upload limits
COConfigurationManager.setParameter( "AutoSpeed Max Upload KBs", uploadLimitKBPS );
COConfigurationManager.setParameter( TransferSpeedValidator.UPLOAD_CONFIGKEY, uploadLimitKBPS );
COConfigurationManager.setParameter( TransferSpeedValidator.UPLOAD_SEEDING_CONFIGKEY , uploadLimitKBPS );
// - Do we set these?
//COConfigurationManager.setParameter( TransferSpeedValidator.DOWNLOAD_CONFIGKEY, downlaodLimitKBPS );
if(downloadTestRan){
int dIndex = downConfLevelCombo.getSelectionIndex();
float downEstType = helper.textToType( confValue[dIndex] );
speedManager.setEstimatedUploadCapacityBytesPerSec( downlaodLimitKBPS , downEstType );
}
if(uploadTestRan){
int uIndex = upConfLevelCombo.getSelectionIndex();
float upEstType = helper.textToType( confValue[uIndex] );
speedManager.setEstimatedUploadCapacityBytesPerSec( uploadLimitKBPS , upEstType );
}
wizard.setFinishEnabled(true);
wizard.setPreviousEnabled(false);
}
});
//spacer col
Label c3 = new Label(panel, SWT.NULL);
gridData = new GridData();
gridData.horizontalSpan = 1;
c3.setLayoutData(gridData);
//spacer line
Label spacer2 = new Label(panel, SWT.NULL);
gridData = new GridData();
gridData.horizontalSpan = 3;
spacer2.setLayoutData(gridData);
//switch column width to 5 columns.
Composite resultsPanel = new Composite(rootPanel, SWT.NULL);
gridData = new GridData( GridData.VERTICAL_ALIGN_END | GridData.FILL_HORIZONTAL );
resultsPanel.setLayoutData(gridData);
layout = new GridLayout();
layout.numColumns = 5;
layout.makeColumnsEqualWidth=true;
resultsPanel.setLayout(layout);