Tidy up use of TestElement.ENABLED; use TestElement.isEnabled()/setEnabled() throughout

Bugzilla Id: 55548


git-svn-id: https://svn.apache.org/repos/asf/jmeter/trunk@1521971 13f79535-47bb-0310-9956-ffa450edef68

Former-commit-id: 4663f8f1af
This commit is contained in:
Sebastian Bazley 2013-09-11 18:18:00 +00:00
parent 61a7e09c5a
commit 42f07dc0c0
8 changed files with 19 additions and 35 deletions

View File

@ -32,8 +32,6 @@ import javax.swing.border.Border;
import org.apache.jmeter.gui.util.VerticalPanel;
import org.apache.jmeter.testelement.TestElement;
import org.apache.jmeter.testelement.property.BooleanProperty;
import org.apache.jmeter.testelement.property.NullProperty;
import org.apache.jmeter.testelement.property.StringProperty;
import org.apache.jmeter.util.JMeterUtils;
import org.apache.jmeter.visualizers.Printable;
@ -190,11 +188,7 @@ public abstract class AbstractJMeterGuiComponent extends JPanel implements JMete
@Override
public void configure(TestElement element) {
setName(element.getName());
if (element.getProperty(TestElement.ENABLED) instanceof NullProperty) {
enabled = true;
} else {
enabled = element.getPropertyAsBoolean(TestElement.ENABLED);
}
enabled = element.isEnabled();
getCommentPanel().setText(element.getComment());
}
@ -236,7 +230,7 @@ public abstract class AbstractJMeterGuiComponent extends JPanel implements JMete
// This stores the state of the TestElement
log.debug("setting element to enabled: " + enabled);
mc.setProperty(new BooleanProperty(TestElement.ENABLED, enabled));
mc.setEnabled(enabled);
mc.setComment(getComment());
}

View File

@ -34,7 +34,6 @@ import org.apache.jmeter.gui.JMeterGUIComponent;
import org.apache.jmeter.testelement.TestElement;
import org.apache.jmeter.testelement.TestPlan;
import org.apache.jmeter.testelement.WorkBench;
import org.apache.jmeter.testelement.property.NullProperty;
import org.apache.jorphan.collections.HashTree;
import org.apache.jorphan.collections.ListedHashTree;
@ -135,13 +134,8 @@ public class JMeterTreeModel extends DefaultTreeModel {
// This check the state of the TestElement and if returns false it
// disable the loaded node
try {
if (component.getProperty(TestElement.ENABLED) instanceof NullProperty
|| component.getPropertyAsBoolean(TestElement.ENABLED)) {
newNode.setEnabled(true);
} else {
newNode.setEnabled(false);
}
} catch (Exception e) {
newNode.setEnabled(component.isEnabled());
} catch (Exception e) { // TODO - can this eever happen?
newNode.setEnabled(true);
}

View File

@ -35,9 +35,7 @@ import javax.swing.tree.TreeNode;
import org.apache.jmeter.gui.GUIFactory;
import org.apache.jmeter.gui.GuiPackage;
import org.apache.jmeter.testbeans.TestBean;
import org.apache.jmeter.testelement.AbstractTestElement;
import org.apache.jmeter.testelement.TestElement;
import org.apache.jmeter.testelement.property.BooleanProperty;
import org.apache.jorphan.logging.LoggingManager;
import org.apache.log.Logger;
@ -64,11 +62,11 @@ public class JMeterTreeNode extends DefaultMutableTreeNode implements NamedTreeN
}
public boolean isEnabled() {
return ((AbstractTestElement) getTestElement()).getPropertyAsBoolean(TestElement.ENABLED);
return getTestElement().isEnabled();
}
public void setEnabled(boolean enabled) {
getTestElement().setProperty(new BooleanProperty(TestElement.ENABLED, enabled));
getTestElement().setEnabled(enabled);
treeModel.nodeChanged(this);
}

View File

@ -621,6 +621,7 @@ public abstract class AbstractTestElement implements TestElement, Serializable,
return getProperty(TestElement.ENABLED) instanceof NullProperty || getPropertyAsBoolean(TestElement.ENABLED);
}
@Override
public void setEnabled(boolean enabled) {
setProperty(new BooleanProperty(TestElement.ENABLED, enabled));
}

View File

@ -67,6 +67,12 @@ public interface TestElement extends Cloneable {
*/
boolean isEnabled();
/**
* Set the enabled status of the test element
* @param enabled the status to set
*/
void setEnabled(boolean enabled);
/**
* Returns true or false whether the element is the running version.
*/

View File

@ -33,7 +33,6 @@ import org.apache.jmeter.gui.JMeterGUIComponent;
import org.apache.jmeter.report.gui.tree.ReportTreeNode;
import org.apache.jmeter.testelement.TestElement;
import org.apache.jmeter.testelement.ReportPlan;
import org.apache.jmeter.testelement.property.NullProperty;
import org.apache.jorphan.collections.HashTree;
import org.apache.jorphan.collections.ListedHashTree;
@ -104,13 +103,8 @@ public class ReportTreeModel extends DefaultTreeModel {
// This check the state of the TestElement and if returns false it
// disable the loaded node
try {
if (component.getProperty(TestElement.ENABLED) instanceof NullProperty
|| component.getPropertyAsBoolean(TestElement.ENABLED)) {
newNode.setEnabled(true);
} else {
newNode.setEnabled(false);
}
} catch (Exception e) {
newNode.setEnabled(component.isEnabled());
} catch (Exception e) { // TODO can this ever happen?
newNode.setEnabled(true);
}

View File

@ -32,9 +32,7 @@ import org.apache.jmeter.gui.GUIFactory;
import org.apache.jmeter.gui.ReportGuiPackage;
import org.apache.jmeter.gui.tree.NamedTreeNode;
import org.apache.jmeter.testbeans.TestBean;
import org.apache.jmeter.testelement.AbstractTestElement;
import org.apache.jmeter.testelement.TestElement;
import org.apache.jmeter.testelement.property.BooleanProperty;
import org.apache.jorphan.logging.LoggingManager;
import org.apache.log.Logger;
@ -60,13 +58,11 @@ public class ReportTreeNode extends DefaultMutableTreeNode implements
}
public boolean isEnabled() {
return ((AbstractTestElement) getTestElement())
.getPropertyAsBoolean(TestElement.ENABLED);
return getTestElement().isEnabled();
}
public void setEnabled(boolean enabled) {
getTestElement().setProperty(
new BooleanProperty(TestElement.ENABLED, enabled));
getTestElement().setEnabled(enabled);
treeModel.nodeChanged(this);
}

View File

@ -454,11 +454,12 @@ Previously the default was 1, which could cause unexpected additional traffic.
<li><bugzilla>54903</bugzilla> - Remove the dependency on the Activation Framework. Contributed by Emmanuel Bourg (ebourg at apache.org)</li>
<li>Moved commons-lang (2.6) to lib/doc as it's only needed by Velocity.</li>
<li>Re-organised and simplified NOTICE and LICENSE files.</li>
<li><bugzilla>55411</bugzilla> - NativeCommand could be useful elsewhere. Copied code to o.a.jorphan.exec.</li>
<li><bugzilla>55411</bugzilla> - NativeCommand could be useful elsewhere. Copied code to o.a.jorphan.exec.</li>
<li><bugzilla>55435</bugzilla> - ComboStringEditor could be simplified to make most settings final</li>
<li><bugzilla>55436</bugzilla> - ComboStringEditor should implement ClearGui</li>
<li><bugzilla>55463</bugzilla> - Component.requestFocus() is discouraged; use requestFocusInWindow() instead</li>
<li><bugzilla>55486</bugzilla> - New JMeter Logo. Contributed by UBIK Load Pack (support at ubikloadpack.com)</li>
<li><bugzilla>55548</bugzilla> - Tidy up use of TestElement.ENABLED; use TestElement.isEnabled()/setEnabled() throughout</li>
</ul>
<h2>Thanks</h2>