jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1427580 - in /jmeter/trunk/src: core/org/apache/jmeter/gui/util/TristateCheckBox.java protocol/tcp/org/apache/jmeter/protocol/tcp/config/gui/TCPConfigGui.java
Date Tue, 01 Jan 2013 22:38:17 GMT
Author: pmouawad
Date: Tue Jan  1 22:38:17 2013
New Revision: 1427580

URL: http://svn.apache.org/viewvc?rev=1427580&view=rev
Log:
Move methods to TristateCheckBox

Modified:
    jmeter/trunk/src/core/org/apache/jmeter/gui/util/TristateCheckBox.java
    jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/config/gui/TCPConfigGui.java

Modified: jmeter/trunk/src/core/org/apache/jmeter/gui/util/TristateCheckBox.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/util/TristateCheckBox.java?rev=1427580&r1=1427579&r2=1427580&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/gui/util/TristateCheckBox.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/gui/util/TristateCheckBox.java Tue Jan  1 22:38:17
2013
@@ -44,6 +44,10 @@ import javax.swing.plaf.ActionMapUIResou
 import javax.swing.plaf.UIResource;
 import javax.swing.plaf.metal.MetalLookAndFeel;
 
+import org.apache.jmeter.testelement.TestElement;
+import org.apache.jmeter.testelement.property.JMeterProperty;
+import org.apache.jmeter.testelement.property.NullProperty;
+
 // derived from: http://www.javaspecialists.eu/archive/Issue145.html
 
 public final class TristateCheckBox extends JCheckBox {
@@ -99,6 +103,34 @@ public final class TristateCheckBox exte
         SwingUtilities.replaceUIActionMap(this, actions);
     }
 
+    /**
+     * Set state depending on property
+     * @param element TestElement
+     * @param propName String property name
+     */
+    public void setTristateFromProperty(TestElement element,String propName) {
+        JMeterProperty jmp = element.getProperty(propName);
+        if (jmp instanceof NullProperty) {
+            this.setIndeterminate();
+        } else {
+            this.setSelected(jmp.getBooleanValue());
+        }
+    }
+    
+    /**
+     * Sets a boolean property from a tristate checkbox.
+     * 
+     * @param element the test element
+     * @param propName the property name
+     */
+    public void setPropertyFromTristate(TestElement element, String propName) {
+        if (isIndeterminate()) {
+            element.removeProperty(propName);
+        } else {
+            element.setProperty(propName, isSelected());
+        }
+    }
+    
     // Next two methods implement new API by delegation to model
     public void setIndeterminate() {
         getTristateModel().setIndeterminate();

Modified: jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/config/gui/TCPConfigGui.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/config/gui/TCPConfigGui.java?rev=1427580&r1=1427579&r2=1427580&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/config/gui/TCPConfigGui.java
(original)
+++ jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/config/gui/TCPConfigGui.java
Tue Jan  1 22:38:17 2013
@@ -38,8 +38,6 @@ import org.apache.jmeter.gui.util.Trista
 import org.apache.jmeter.gui.util.VerticalPanel;
 import org.apache.jmeter.protocol.tcp.sampler.TCPSampler;
 import org.apache.jmeter.testelement.TestElement;
-import org.apache.jmeter.testelement.property.JMeterProperty;
-import org.apache.jmeter.testelement.property.NullProperty;
 import org.apache.jmeter.util.JMeterUtils;
 import org.apache.jorphan.gui.JLabeledTextField;
 
@@ -93,10 +91,10 @@ public class TCPConfigGui extends Abstra
         // filename.setText(element.getPropertyAsString(TCPSampler.FILENAME));
         serverPanel.setResponseTimeout(element.getPropertyAsString(TCPSampler.TIMEOUT));
         serverPanel.setConnectTimeout(element.getPropertyAsString(TCPSampler.TIMEOUT_CONNECT));
-        setTristateFromProperty(element, setNoDelay, TCPSampler.NODELAY);
+        setNoDelay.setTristateFromProperty(element, TCPSampler.NODELAY);
 //        setNoDelay.setSelected(element.getPropertyAsBoolean(TCPSampler.NODELAY));
         requestData.setText(element.getPropertyAsString(TCPSampler.REQUEST));
-        setTristateFromProperty(element, closeConnection, TCPSampler.CLOSE_CONNECTION);
+        closeConnection.setTristateFromProperty(element, TCPSampler.CLOSE_CONNECTION);
 //        closeConnection.setSelected(element.getPropertyAsBoolean(TCPSampler.CLOSE_CONNECTION,
TCPSampler.CLOSE_CONNECTION_DEFAULT));
         soLinger.setText(element.getPropertyAsString(TCPSampler.SO_LINGER));
         eolByte.setText(element.getPropertyAsString(TCPSampler.EOL_BYTE));
@@ -123,12 +121,12 @@ public class TCPConfigGui extends Abstra
         element.setProperty(TCPSampler.RE_USE_CONNECTION, reUseConnection.isSelected());
         element.setProperty(TCPSampler.PORT, serverPanel.getPort());
         // element.setProperty(TCPSampler.FILENAME, filename.getText());
-        setPropertyFromTristate(element, setNoDelay, TCPSampler.NODELAY);
+        setNoDelay.setPropertyFromTristate(element, TCPSampler.NODELAY);
 //        element.setProperty(TCPSampler.NODELAY, setNoDelay.isSelected());
         element.setProperty(TCPSampler.TIMEOUT, serverPanel.getResponseTimeout());
         element.setProperty(TCPSampler.TIMEOUT_CONNECT, serverPanel.getConnectTimeout(),"");
         element.setProperty(TCPSampler.REQUEST, requestData.getText());
-        setPropertyFromTristate(element, closeConnection, TCPSampler.CLOSE_CONNECTION); //
Don't use default for saving tristates
+        closeConnection.setPropertyFromTristate(element, TCPSampler.CLOSE_CONNECTION); //
Don't use default for saving tristates
 //        element.setProperty(TCPSampler.CLOSE_CONNECTION, closeConnection.isSelected(),
TCPSampler.CLOSE_CONNECTION_DEFAULT);
         element.setProperty(TCPSampler.SO_LINGER, soLinger.getText(), "");
         element.setProperty(TCPSampler.EOL_BYTE, eolByte.getText(), "");
@@ -278,31 +276,4 @@ public class TCPConfigGui extends Abstra
         // mainPanel.add(createFilenamePanel());
         add(mainPanel, BorderLayout.CENTER);
     }
-
-    // TODO should be moved somewhere shared, perhaps TristateCheckBox?
-    private void setTristateFromProperty(TestElement element, TristateCheckBox checkBox,
String propName) {
-        JMeterProperty jmp = element.getProperty(propName);
-        if (jmp instanceof NullProperty) {
-            checkBox.setIndeterminate();
-        } else {
-            checkBox.setSelected(jmp.getBooleanValue());
-        }
-    }
-
-    // TODO should be moved somewhere shared, perhaps TristateCheckBox?
-    /**
-     * Sets a boolean property from a tristate checkbox.
-     * 
-     * @param element the test element
-     * @param checkBox the tristate checkbox
-     * @param propName the property name
-     */
-    private void setPropertyFromTristate(TestElement element, TristateCheckBox checkBox,
String propName) {
-        if (checkBox.isIndeterminate()) {
-            element.removeProperty(propName);
-        } else {
-            element.setProperty(propName, checkBox.isSelected());
-        }
-    }
-
-}
+}
\ No newline at end of file



Mime
View raw message