Skip to Content.
Sympa Menu

ndt-dev - [ndt-dev] [ndt] r848 committed - Merging branch applet_usability into trunk

Subject: NDT-DEV email list created

List archive

[ndt-dev] [ndt] r848 committed - Merging branch applet_usability into trunk


Chronological Thread 
  • From:
  • To:
  • Subject: [ndt-dev] [ndt] r848 committed - Merging branch applet_usability into trunk
  • Date: Fri, 18 Oct 2013 06:48:37 +0000

Revision: 848
Author:

Date: Fri Oct 18 06:48:19 2013 UTC
Log: Merging branch applet_usability into trunk
http://code.google.com/p/ndt/source/detail?r=848

Modified:
/trunk
/trunk/Applet/NDTUtils.java
/trunk/Applet/NewFrame.java
/trunk/Applet/Tcpbw100.java

=======================================
--- /trunk/Applet/NDTUtils.java Thu Oct 10 08:36:25 2013 UTC
+++ /trunk/Applet/NDTUtils.java Fri Oct 18 06:48:19 2013 UTC
@@ -1,3 +1,5 @@
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
import java.util.ResourceBundle;

/**
@@ -92,4 +94,55 @@
return str == null || str.length() == 0;
} // isEmpty() method ends

+ /**
+ * Utility method to check if the given string is not empty ("") or
null.
+ *
+ * @param str
+ * String to check
+ * @return true is the given string is not empty; otherwise false
+ */
+ public static boolean isNotEmpty(String str) {
+ return !isEmpty(str);
+ } // isNotEmpty() method ends
+
+
+ /**
+ * Utility method to create mailTo link
+ *
+ * @param name
+ * user identifier
+ * @param host
+ * fully qualified domain name
+ * @param subject
+ * email subject
+ * @param body
+ * email body
+ * @return created mailTo link with the encoded parameters
+ */
+ public static String mailTo(final String name, final String host,
+ final String
subject, final String body) {
+ return String.format(
+
"mailto:%s@%s?subject=%s&body=%s",
+ new Object[]{
+ urlEncode(name),
urlEncode(host),
+ urlEncode(subject),
urlEncode(body)
+ }
+ );
+ } // mailTo() method ends
+
+ /**
+ * Utility method to encode the given string using UTF-8 encoding
+ *
+ * @param str
+ * String to encode
+ * @return encoded string with replacing '+' to '%20'
+ */
+ public static String urlEncode(String str) {
+ try {
+ return URLEncoder.encode(str, "utf-8").replace("+",
"%20");
+ } catch (UnsupportedEncodingException e) {
+ throw new IllegalArgumentException(e);
+ }
+ } // urlEncode() method ends
+
}
=======================================
--- /trunk/Applet/NewFrame.java Mon Apr 30 20:46:39 2012 UTC
+++ /trunk/Applet/NewFrame.java Fri Oct 18 06:48:19 2013 UTC
@@ -1,7 +1,8 @@
+import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

-import javax.swing.JFrame;
+import javax.swing.*;

/**
* Utility class that creates a new "Frame" with a window closing functionality.
@@ -19,17 +20,16 @@
*/
private static final long serialVersionUID = 8990839319520684317L;

- /**
- * Constructor
- **/
- public NewFrame() {
+ /**
+ * Constructor
+ **/
+ public NewFrame(final JApplet parent) throws HeadlessException {
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent event) {
- // System.err.println("Handling window closing
event");
+ parent.requestFocus();
dispose();
}
});
- // System.err.println("Extended Frame class - RAC9/15/03");
}

} // class: NewFrame
=======================================
--- /trunk/Applet/Tcpbw100.java Mon Oct 14 13:20:21 2013 UTC
+++ /trunk/Applet/Tcpbw100.java Fri Oct 18 06:48:19 2013 UTC
@@ -79,7 +79,6 @@
import java.net.Inet6Address;
import java.net.InetAddress;
import java.net.InetSocketAddress;
-import java.net.MalformedURLException;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketException;
@@ -883,7 +882,6 @@
_chkboxDefaultTest = new JCheckBox(

_resBundDisplayMsgs.getString("defaultTests"));
_chkboxDefaultTest.setSelected(true);
- _chkboxDefaultTest.setEnabled(false);
// 3. configure number of tests
SpinnerNumberModel model = new SpinnerNumberModel();
model.setMinimum(new Integer(0));
@@ -909,7 +907,7 @@

// create new frame
if (_frameWeb100Vars == null) {
- _frameWeb100Vars = new NewFrame();
+ _frameWeb100Vars = new NewFrame(this);
}

// Get title for this window
@@ -948,7 +946,7 @@

// create new frame
if (_frameDetailedStats == null) {
- _frameDetailedStats = new NewFrame();
+ _frameDetailedStats = new NewFrame(this);
}
_frameDetailedStats.setTitle(_resBundDisplayMsgs
.getString("detailedStats"));
@@ -969,7 +967,7 @@
// Text area for Statistics, add "heading"
_txtStatistics = new JTextArea(
_resBundDisplayMsgs.getString(_sServerType + "Stats") +
":\n", 25, 70);
- _txtStatistics.setEditable(true);
+ _txtStatistics.setEditable(false);
_buttonStatsDismiss.setEnabled(true);
_buttonStatsCopy.setEnabled(_bCanCopy);

@@ -993,7 +991,7 @@
showStatus(_resBundDisplayMsgs.getString("showOptions"));

if (_frameOptions == null) {
- _frameOptions = new NewFrame();
+ _frameOptions = new NewFrame(this);

_frameOptions.setTitle(_resBundDisplayMsgs.getString("options"));

// main panel
@@ -1107,10 +1105,8 @@
}
// show details of tests since that button was clicked
else if (source == _buttonDetails) {
- _buttonDetails.setEnabled(false);
_frameWeb100Vars.setResizable(true);
_frameWeb100Vars.setVisible(true);
- _buttonDetails.setEnabled(true);
}
// "More Details" Web100 variables window to be closed
else if (source == _buttonDismiss) {
@@ -1145,14 +1141,16 @@
String sTemp = _txtStatistics.getText();
StringSelection ssTemp = new StringSelection(sTemp);
clipbd.setContents(ssTemp, ssTemp);
- _txtStatistics.selectAll();
}
// Show "statistics" window
else if (source == _buttonStatistics) {
- _buttonStatistics.setEnabled(false);
_frameDetailedStats.setResizable(true);
_frameDetailedStats.setVisible(true);
- _buttonStatistics.setEnabled(true);
+
+ if (NDTUtils.isNotEmpty(_txtStatistics.getText())) {
+ // enable copy button only if there is
statistics informations
+ _buttonStatsCopy.setEnabled(true);
+ }
}
// mail to functionality
else if (source == _buttonMailTo) {
@@ -1161,7 +1159,6 @@
// String to[], from[], comments[]; //commented out
unused variables
String sName, sHost;

- _buttonMailTo.setEnabled(false);
// invoke mailto: function

showStatus(_resBundDisplayMsgs.getString("invokingMailtoFunction")
+ "...");
@@ -1178,28 +1175,37 @@
throw new IllegalArgumentException("H
parameter Required:");
}

- String theURL = "; + sName + "@" +
sHost;
- String subject = getParameter("subject"); //
get subject
+ String sSubject = getParameter("subject"); //
get subject

- if (subject == null) {
- subject = _resBundDisplayMsgs
+ if (sSubject == null) {
+ sSubject = _resBundDisplayMsgs

.getString("troubleReportFrom")
+ " "
+
getCodeBase().getHost();
}
- theURL += "?subject=" + subject;
- theURL += "&body=" +
_resBundDisplayMsgs.getString("comments")
- + ":%0A%0A" + _sEmailText + "
"
- +
_resBundDisplayMsgs.getString("endOfEmail") + "\n%0A";
- // System.out.println("Message body is '" + emailText +
"'\n");
- _targetURL = new URL(theURL);

- } catch (MalformedURLException rsi) {
- throw new IllegalArgumentException("Can't create
mailto: URL"
- + rsi.getMessage());
- }
+ String sBody =
_resBundDisplayMsgs.getString("comments")
+ + ":\n\n" + _sEmailText +
"\n\n"
+ +
_resBundDisplayMsgs.getString("endOfEmail");

- getAppletContext().showDocument(_targetURL);
+ String sUrl = NDTUtils.mailTo(sName, sHost,
sSubject, sBody);
+
+ _targetURL = new URL(sUrl);
+
+ getAppletContext().showDocument(_targetURL);
+ } catch (Exception e) {
+ e.printStackTrace();
+
+ String sMessage =
NDTUtils.isEmpty(e.getMessage())
+ ?
_resBundDisplayMsgs.getString("withoutMessage")
+ : e.getMessage();
+
+ _sErrMsg =
_resBundDisplayMsgs.getString("unexpectedException")
+ + " (" + e.getClass().getName() +
"): "
+ + sMessage + "\n";
+
+ _resultsTxtPane.append(_sErrMsg);
+ }
} // end mail-to functionality
} // actionPerformed()

@@ -2348,17 +2354,17 @@
+ _resBundDisplayMsgs.getString("toRunTest") +
"\n");
// If IPv6 is preferred by Applet user, set property
for any further
// use
- if (_chkboxPreferIPv6.isSelected()) {
- try {
-
System.setProperty("java.net.preferIPv6Addresses",
- "true");
- } catch (SecurityException e) {
- System.err
- .println("Couldn't set system property. Check your security settings.");
- // retain this way for now
- }
- }
- _chkboxPreferIPv6.setEnabled(false);
+ try {
+ System.setProperty("java.net.preferIPv6Addresses",
+ _chkboxPreferIPv6.isSelected() ? "true" : "false");
+
+ System.setProperty("java.net.preferIPv4Stack",
+ _chkboxPreferIPv6.isSelected() ? "false" : "true");
+ } catch (SecurityException e) {
+ System.err
+ .println("Couldn't set system property. Check your security settings.");
+ // retain this way for now
+ }
// create socket to host specified by user and the
default port
ctlSocket = new Socket(sHostName, ctlport);
} catch (UnknownHostException e) {


  • [ndt-dev] [ndt] r848 committed - Merging branch applet_usability into trunk, ndt, 10/18/2013

Archive powered by MHonArc 2.6.16.

Top of Page