forked from I2P_Developers/i2p.i2p
Wizard: Improve ajax
Drop unused test wrapper Enable first run detection Spelling fix
This commit is contained in:
@ -25,14 +25,10 @@ import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import com.vuze.plugins.mlab.tools.ndt.swingemu.Tcpbw100UIWrapper;
|
||||
import com.vuze.plugins.mlab.tools.ndt.swingemu.Tcpbw100UIWrapperListener;
|
||||
|
||||
import edu.internet2.ndt.Tcpbw100;
|
||||
|
||||
import net.minidev.json.JSONObject;
|
||||
@ -102,41 +98,6 @@ public class MLabRunner {
|
||||
try{
|
||||
_log.warn("Starting NDT Test");
|
||||
|
||||
new Tcpbw100UIWrapper(
|
||||
new Tcpbw100UIWrapperListener()
|
||||
{
|
||||
private LinkedList<String> history = new LinkedList<String>();
|
||||
|
||||
public void reportSummary(String str) {
|
||||
str = str.trim();
|
||||
log(str);
|
||||
if (listener != null){
|
||||
if (!str.startsWith("Click")) {
|
||||
listener.reportSummary(str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void reportDetail(String str) {
|
||||
str = str.trim();
|
||||
log(str);
|
||||
if (listener != null) {
|
||||
listener.reportDetail(str);
|
||||
}
|
||||
}
|
||||
|
||||
private void log(String str) {
|
||||
synchronized( history ){
|
||||
if (history.size() > 0 && history.getLast().equals(str)) {
|
||||
return;
|
||||
}
|
||||
history.add(str);
|
||||
}
|
||||
_log.warn(str);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// String host = "ndt.iupui.donar.measurement-lab.org";
|
||||
// String host = "jlab4.jlab.org";
|
||||
|
||||
@ -208,6 +169,10 @@ public class MLabRunner {
|
||||
public void cancelled() {
|
||||
test.killIt();
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return test.getStatus();
|
||||
}
|
||||
});
|
||||
|
||||
test.runIt();
|
||||
@ -253,7 +218,7 @@ public class MLabRunner {
|
||||
results.put("server_city", server_city);
|
||||
if (server_country != null)
|
||||
results.put("server_country", server_country);
|
||||
listener.complete( results );
|
||||
listener.complete(results);
|
||||
}
|
||||
if (_log.shouldWarn()) {
|
||||
long end = System.currentTimeMillis();
|
||||
@ -293,6 +258,7 @@ public class MLabRunner {
|
||||
public interface ToolRun {
|
||||
public void cancel();
|
||||
public void addListener(ToolRunListener l);
|
||||
public String getStatus();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -331,11 +297,18 @@ public class MLabRunner {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
synchronized(this) {
|
||||
return listeners.isEmpty() ? "" : listeners.get(0).getStatus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** The listener for ToolRun */
|
||||
public interface ToolRunListener {
|
||||
public void cancelled();
|
||||
public String getStatus();
|
||||
}
|
||||
|
||||
/** The parameter for runNDT() */
|
||||
|
@ -42,17 +42,6 @@ JTextArea
|
||||
append(
|
||||
String str )
|
||||
{
|
||||
Tcpbw100UIWrapperListener listener = Tcpbw100UIWrapper.current_adapter;
|
||||
|
||||
if ( listener != null ){
|
||||
|
||||
listener.reportDetail( str );
|
||||
|
||||
}else{
|
||||
|
||||
//System.out.println( "text: " + str );
|
||||
}
|
||||
|
||||
text += str;
|
||||
}
|
||||
|
||||
|
@ -42,17 +42,6 @@ StyledDocument
|
||||
|
||||
throws BadLocationException
|
||||
{
|
||||
Tcpbw100UIWrapperListener listener = Tcpbw100UIWrapper.current_adapter;
|
||||
|
||||
if ( listener != null ){
|
||||
|
||||
listener.reportSummary( s );
|
||||
|
||||
}else{
|
||||
|
||||
//System.out.println( "doc: " + s );
|
||||
}
|
||||
|
||||
str += s;
|
||||
}
|
||||
}
|
||||
|
@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Created on May 20, 2010
|
||||
* Created by Paul Gardner
|
||||
*
|
||||
* Copyright 2010 Vuze, Inc. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details ( see the LICENSE file ).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
|
||||
|
||||
package com.vuze.plugins.mlab.tools.ndt.swingemu;
|
||||
|
||||
public class
|
||||
Tcpbw100UIWrapper
|
||||
{
|
||||
public static Tcpbw100UIWrapperListener current_adapter;
|
||||
|
||||
public
|
||||
Tcpbw100UIWrapper(
|
||||
Tcpbw100UIWrapperListener adapter )
|
||||
{
|
||||
current_adapter = adapter;
|
||||
}
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
/*
|
||||
* Created on May 20, 2010
|
||||
* Created by Paul Gardner
|
||||
*
|
||||
* Copyright 2010 Vuze, Inc. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details ( see the LICENSE file ).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
|
||||
|
||||
package com.vuze.plugins.mlab.tools.ndt.swingemu;
|
||||
|
||||
public interface
|
||||
Tcpbw100UIWrapperListener
|
||||
{
|
||||
public void
|
||||
reportSummary(
|
||||
String str );
|
||||
|
||||
public void
|
||||
reportDetail(
|
||||
String str );
|
||||
}
|
@ -293,6 +293,7 @@ public class Tcpbw100 extends JApplet implements ActionListener {
|
||||
private boolean retry = false;
|
||||
|
||||
// I2P
|
||||
private String _displayStatus = "";
|
||||
private final Log _log = new Log(Tcpbw100.class);
|
||||
|
||||
/**
|
||||
@ -1279,7 +1280,18 @@ public class Tcpbw100 extends JApplet implements ActionListener {
|
||||
* @param msg String value of status
|
||||
* */
|
||||
public void showStatus(String msg) {
|
||||
_log.warn(msg);
|
||||
synchronized(this) {
|
||||
_displayStatus = msg;
|
||||
}
|
||||
_log.warn("NDT STATUS: " + msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* I2P
|
||||
* Translated status, not HTML escaped.
|
||||
*/
|
||||
public synchronized String getStatus() {
|
||||
return _displayStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -136,7 +136,7 @@ public class WizardHandler extends FormHandler {
|
||||
if (_helper == null) {
|
||||
addFormError("Bad state for test");
|
||||
} else if (_helper.cancelNDT()) {
|
||||
addFormNotice(_t("Candelled bandwidth test"));
|
||||
addFormNotice(_t("Cancelled bandwidth test"));
|
||||
} else {
|
||||
addFormError(_t("Bandwidth test was not running"));
|
||||
}
|
||||
|
@ -55,6 +55,19 @@ public class WizardHelper extends HelperBase {
|
||||
return _listener != null && !_listener.isComplete();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HTML-escaped status string or ""
|
||||
*/
|
||||
public synchronized String getTestStatus() {
|
||||
String rv = "";
|
||||
if (_runner != null) {
|
||||
String s = _runner.getStatus();
|
||||
if (s != null)
|
||||
rv = DataHelper.escapeHTML(s);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HTML-escaped status string or ""
|
||||
*/
|
||||
|
Reference in New Issue
Block a user