Methods Summary |
---|
public void | cancel()
if ( scheduled_test != null ){
scheduled_test.abort();
if ( !test.isDisposed()){
test.setEnabled(true);
abort.setEnabled(false);
wizard.setNextEnabled(false);
wizard.setFinishEnabled(false);
}
}
|
public void | complete(com.aelitis.azureus.core.networkmanager.admin.NetworkAdminSpeedTestScheduledTest test)
|
public void | complete(com.aelitis.azureus.core.networkmanager.admin.NetworkAdminSpeedTester tester, com.aelitis.azureus.core.networkmanager.admin.NetworkAdminSpeedTesterResult result)
SpeedTestData.getInstance().setResult( result );
reportComplete( result );
|
public void | finish()
test_running = true;
clListener = new WizardListener()
{
public void
closed()
{
cancel();
}
};
wizard.addListener(clListener);
wizard.setFinishEnabled( false );
// convert to mode
final int test_mode = NetworkAdminSpeedTester.TEST_TYPES[testCombo.getSelectionIndex()];
final boolean encState = encryptToggle.getSelection();
Thread t =
new AEThread("SpeedTest Performer")
{
public void
runSupport()
{
runTest(test_mode, encState);
}
};
t.setPriority(Thread.MIN_PRIORITY);
t.setDaemon(true);
t.start();
|
public org.gudy.azureus2.ui.swt.wizard.IWizardPanel | getFinishPanel()
return( this );
|
public org.gudy.azureus2.ui.swt.wizard.IWizardPanel | getNextPanel()
SpeedTestData persist = SpeedTestData.getInstance();
persist.setLastTestData( textMessages.getText() );
return new SpeedTestSetLimitPanel( wizard, this, uploadTest, maxUploadTest, downloadTest, maxDownloadTest);
|
private static int | getProgressBarValueFromString(java.lang.String step)
if(step==null)
return 0;
if( !step.startsWith("progress:") )
return 0;
String[] value = step.split(":");
if(value.length<2)
return 0;
int progress;
try{
progress = Integer.parseInt(value[1].trim());
}catch(Exception e){
return 0;
}
if( progress<0 || progress>100 )
return 0;
return progress;
|
private static int[] | getTimeLeftFromString(java.lang.String step)If you find the time left values then use them. On any error return null and the calling
function should handle that condition.
if(step==null)
return null;
if( !step.startsWith("progress:") )
return null;
String[] values = step.split(":");
if(values.length<5){
return null;
}
int[] times = new int[2];
try{
times[0] = Integer.parseInt( values[4].trim() );
times[1] = Integer.parseInt( values[5].trim() );
//don't allow time values less then zero.
if(times[0]<0){
times[0]=0;
}
if(times[1]<0){
times[1]=0;
}
}catch(Exception e){
return null;
}
return times;
|
private static int | getValueFromAveString(java.lang.String aveStr)Get the number after the last " " space in the String.
try{
int number=-2;
aveStr = aveStr.trim();
String[] parts = aveStr.split(" ");
//the last item should be the number.
if(parts!=null){
number = Integer.parseInt( parts[parts.length-1].trim() );
}
return number;
}catch(Throwable t){
return -1;
}
|
public boolean | isFinishEnabled()
return( !( switched_to_close || test_running ));
|
public boolean | isFinishSelectionOK()
return( !( switched_to_close || test_running ));
|
public boolean | isNextEnabled()
//only enable after the test completes correctly.
return ( (uploadTest>0 || downloadTest>0) && !test_running);
|
private static java.lang.String | modifyProgressStatusString(java.lang.String step)Change the "progress status" string into something that can be displayed.
if(step==null){
return " ";
}
if( !step.startsWith("progress:") ){
return " ";
}
String[] values = step.split(":");
//the expected format is:
// progress: 87 : download ave 0 : upload ave 512438 : 93 : 3
//values[2] should be download ave
//values[3] should be upload ave
if(values.length<4){
return " ";
}
int downAve = getValueFromAveString(values[2]);
int upAve = getValueFromAveString(values[3]);
//ToDo: If an upload test then do only an upload. If a download test, then do only a download.
//ToDo: need something that informs what the test type is.
StringBuffer sb = new StringBuffer();
sb.append(MessageText.getString("GeneralView.label.uploadspeed"));
sb.append( DisplayFormatters.formatByteCountToKiBEtcPerSec( upAve ) ).append(" , ");
sb.append(MessageText.getString("GeneralView.label.downloadspeed"));
sb.append( DisplayFormatters.formatByteCountToKiBEtcPerSec( downAve) );
sb.append("\n");
return sb.toString();
|
protected void | reportComplete(com.aelitis.azureus.core.networkmanager.admin.NetworkAdminSpeedTesterResult result)
if ( !textMessages.isDisposed()) {
display.asyncExec(new AERunnable(){
public void runSupport() {
if ( !textMessages.isDisposed()){
if ( result.hadError()){
String testFailed = MessageText.getString("SpeedTestWizard.test.panel.testfailed");//Test failed
textMessages.append( testFailed+": " + result.getLastError());
test.setEnabled( true );
abort.setEnabled(false);
encryptToggle.setEnabled(true);
wizard.setErrorMessage(testFailed);
}else{
uploadTest = result.getUploadSpeed();
downloadTest = result.getDownloadSpeed();
String uploadSpeedStr = MessageText.getString("GeneralView.label.uploadspeed");
String downlaodSpeedStr = MessageText.getString("GeneralView.label.downloadspeed");
textMessages.append(uploadSpeedStr+" " + DisplayFormatters.formatByteCountToKiBEtcPerSec(result.getUploadSpeed()) + Text.DELIMITER);
textMessages.append(downlaodSpeedStr+" " + DisplayFormatters.formatByteCountToKiBEtcPerSec(result.getDownloadSpeed()) + Text.DELIMITER);
wizard.setNextEnabled(true);
abort.setEnabled(false);
test.setEnabled(true);
encryptToggle.setEnabled(true);
}
if( !result.hadError() ){
switchToClose();
}
}
}
});
}
wizard.removeListener(clListener);
clListener=null;
|
protected void | reportStage(java.lang.String step)
if ( !textMessages.isDisposed()) {
display.asyncExec(new AERunnable(){
public void runSupport() {
if ( !textMessages.isDisposed()){
if(step==null)
return;
//intercept progress indications.
if( step.startsWith("progress:")){
//expect format of string to be "progress: # : ..." where # is 0-100
int progressAmount = getProgressBarValueFromString(step);
progress.setSelection(progressAmount);
int[] timeLeft = getTimeLeftFromString(step);
if(timeLeft!=null){
//ToDo: use SimpleDateFormat ... to internationalize this.
testCountDown1.setText( ""+timeLeft[0]+" sec " );//
testCountDown2.setText( ""+timeLeft[1]+" sec " );
}else{
testCountDown1.setText(START_VALUES);
testCountDown2.setText(START_VALUES);
}
String modified = modifyProgressStatusString(step);
textMessages.append(modified);
}else{
//print non-progress strings as is.
textMessages.append( step + Text.DELIMITER);
}
}
}
});
}
|
protected void | runTest(int test_mode, boolean encrypt_mode)
test_running = true;
if ( nasts.getCurrentTest() != null ){
reportStage( MessageText.getString("SpeedTestWizard.test.panel.already.running") );
}else{
// what's the contract here in terms of listener removal?
try{
reportStage( MessageText.getString("SpeedTestWizard.stage.message.requesting") );
scheduled_test = nasts.scheduleTest( NetworkAdminSpeedTestScheduler.TEST_TYPE_BT );
scheduled_test.getTester().setMode( test_mode );
scheduled_test.getTester().setUseCrypto( encrypt_mode );
scheduled_test.addListener( this );
scheduled_test.getTester().addListener( this );
maxUploadTest = scheduled_test.getMaxUpBytePerSec();
maxDownloadTest = scheduled_test.getMaxDownBytePerSec();
scheduled_test.start();
}catch( Throwable e ){
String requestNotAccepted = MessageText.getString("SpeedTestWizard.test.panel.not.accepted");
reportStage( requestNotAccepted + Debug.getNestedExceptionMessage(e));
if (!test.isDisposed()) {
display.asyncExec(new AERunnable(){
public void runSupport() {
test.setEnabled(true);
abort.setEnabled(false);
encryptToggle.setEnabled(true);
}
});
}
}
}//else
|
public void | show()
display = wizard.getDisplay();
wizard.setTitle(MessageText.getString( SpeedTestWizard.CFG_PREFIX + "run" ));
wizard.setCurrentInfo( MessageText.getString("SpeedTestWizard.test.panel.currinfo") );
wizard.setPreviousEnabled(false);
wizard.setFinishEnabled(false);
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);
/////////////////////////////////////////
//Add group to link to Azureus Wiki page.
/////////////////////////////////////////
Group azWiki = new Group(panel, SWT.WRAP);
GridData azwGridData = new GridData();
azwGridData.widthHint = 350;
azwGridData.horizontalSpan = 4;
azWiki.setLayoutData(azwGridData);
GridLayout azwLayout = new GridLayout();
azwLayout.numColumns = 1;
//azwLayout.marginHeight = 1;
azWiki.setLayout(azwLayout);
azWiki.setText(MessageText.getString("Utils.link.visit"));
final Label linkLabel = new Label(azWiki, SWT.NULL);
linkLabel.setText( "Azureus Wiki Speed Test" );
linkLabel.setData("http://azureus.aelitis.com/wiki/index.php/Speed_Test_FAQ");
linkLabel.setCursor(Cursors.handCursor);
linkLabel.setForeground(Colors.blue);
azwGridData = new GridData();
azwGridData.horizontalIndent = 10;
linkLabel.setLayoutData( azwGridData );
linkLabel.addMouseListener(new MouseAdapter() {
public void mouseDoubleClick(MouseEvent arg0) {
Utils.launch((String) ((Label) arg0.widget).getData());
}
public void mouseUp(MouseEvent arg0) {
Utils.launch((String) ((Label) arg0.widget).getData());
}
});
//space line
Label spacer = new Label(panel, SWT.NULL);
gridData = new GridData();
gridData.horizontalSpan = 4;
spacer.setLayoutData(gridData);
//label explain section.
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.test.panel.explain");
//space line
spacer = new Label(panel, SWT.NULL);
gridData = new GridData();
gridData.horizontalSpan = 4;
spacer.setLayoutData(gridData);
//label type and button section.
Label ul = new Label(panel, SWT.NULL );
gridData = new GridData();
ul.setLayoutData(gridData);
Messages.setLanguageText(ul,"SpeedTestWizard.test.panel.label");
testCombo = new Combo(panel, SWT.READ_ONLY);
gridData = new GridData(GridData.FILL_HORIZONTAL);
testCombo.setLayoutData(gridData);
int[] test_types = NetworkAdminSpeedTester.TEST_TYPES;
int up_only_index = 0;
for (int i=0;i<test_types.length;i++){
int test_type = test_types[i];
String resource = null;
if ( test_type == NetworkAdminSpeedTester.TEST_TYPE_UPLOAD_ONLY ){
resource = "up";
up_only_index = i;
}else if ( test_type == NetworkAdminSpeedTester.TEST_TYPE_DOWNLOAD_ONLY ){
resource = "down";
}else{
Debug.out( "Unknown test type" );
}
//List all test in drop-down.
testCombo.add( "BT " + MessageText.getString( "speedtest.wizard.test.mode." + resource ), i);
}
testCombo.select( up_only_index );
test = new Button(panel, SWT.PUSH);
Messages.setLanguageText(test,"dht.execute");//Run
gridData = new GridData();
gridData.widthHint = 70;
test.setLayoutData(gridData);
test.addListener(SWT.Selection, new RunButtonListener() );
abort = new Button(panel, SWT.PUSH);
Messages.setLanguageText(abort,"SpeedTestWizard.test.panel.abort");//Abort
gridData = new GridData();
gridData.widthHint = 70;
abort.setLayoutData(gridData);
abort.setEnabled(false);
abort.addListener(SWT.Selection, new AbortButtonListener() );
//toggle button line.
Label enc = new Label( panel, SWT.NULL );
gridData = new GridData();
enc.setLayoutData(gridData);
Messages.setLanguageText(enc,"SpeedTestWizard.test.panel.enc.label");
encryptToggle = new Button(panel, SWT.TOGGLE);
String statusString="SpeedTestWizard.test.panel.standard";
if( encryptToggle.getSelection() ){
statusString = "SpeedTestWizard.test.panel.encrypted";
}
Messages.setLanguageText(encryptToggle,statusString);
gridData = new GridData();
gridData.widthHint = 80;
encryptToggle.setLayoutData(gridData);
encryptToggle.addListener(SWT.Selection, new EncryptToggleButtonListener() );
//finish line
Label spacer2 = new Label(panel, SWT.NULL);
gridData = new GridData();
gridData.horizontalSpan = 2;
spacer2.setLayoutData(gridData);
//test count down section.
Label abortCountDown = new Label(panel, SWT.NULL);
gridData = new GridData();
abortCountDown.setLayoutData(gridData);
Messages.setLanguageText(abortCountDown,"SpeedTestWizard.test.panel.abort.countdown");
testCountDown1 = new Label(panel, SWT.NULL);
gridData = new GridData();
testCountDown1.setLayoutData(gridData);
testCountDown1.setText(START_VALUES);
Label testFinishCountDown = new Label(panel, SWT.NULL);
gridData = new GridData();
testFinishCountDown.setLayoutData(gridData);
Messages.setLanguageText(testFinishCountDown,"SpeedTestWizard.test.panel.test.countdown");
testCountDown2 = new Label(panel, SWT.NULL);
gridData = new GridData();
testCountDown2.setLayoutData(gridData);
testCountDown2.setText(START_VALUES);
//progress bar section.
progress = new ProgressBar(panel, SWT.SMOOTH);
progress.setMinimum(0);
progress.setMaximum(100);
gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalSpan = 4;
progress.setLayoutData(gridData);
//message text section.
textMessages = new Text(panel, SWT.BORDER | SWT.MULTI | SWT.READ_ONLY | SWT.V_SCROLL | SWT.H_SCROLL );
textMessages.setBackground(display.getSystemColor(SWT.COLOR_WHITE));
gridData = new GridData(GridData.FILL_BOTH);
gridData.horizontalSpan = 4;
gridData.heightHint = 60;
textMessages.setLayoutData(gridData);
//this should only be new when returning from a previous panel.
String lastData = SpeedTestData.getInstance().getLastTestData();
if(lastData!=null){
textMessages.setText(lastData);
}
|
public void | stage(com.aelitis.azureus.core.networkmanager.admin.NetworkAdminSpeedTestScheduledTest test, java.lang.String step)
reportStage( step );
|
public void | stage(com.aelitis.azureus.core.networkmanager.admin.NetworkAdminSpeedTester tester, java.lang.String step)
reportStage( step );
|
protected void | switchToClose()
switched_to_close = true;
wizard.switchToClose();
|