Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't display TestBeanGui items which are flagged as hidden #2641

Closed
asfimport opened this issue Nov 9, 2011 · 4 comments
Closed

Don't display TestBeanGui items which are flagged as hidden #2641

asfimport opened this issue Nov 9, 2011 · 4 comments

Comments

@asfimport
Copy link
Collaborator

stef (Bug 52160):
In order to hide programmatically a test bean from add menu, it would be nice if jmetter checks the BeanDescriptor hidden flag and not add the item to menu if true.

Find attached the patch to enable the feature, based on trunk r1199633.

Stef

Created attachment MenuFactory.zip: MenuFactory patch to enable the feature

OS: All

@asfimport
Copy link
Collaborator Author

Sebb (migrated from Bugzilla):
Could you provide the patch as a unified diff please?

That's the format generated by SVN and Eclipse (and various other tools).
If using Eclipse, please create a project-relative patch, not workspace-relative.

@asfimport
Copy link
Collaborator Author

stef (migrated from Bugzilla):
Here is the patch with unified diff format. It is based on trunk (r1199829)

Stef

Created attachment MenuFactory.diff: Patch in unified diff format

MenuFactory.diff
# This patch file was generated by NetBeans IDE
# This patch can be applied using context Tools: Apply Diff Patch action on respective folder.
# It uses platform neutral UTF-8 encoding.
# Above lines and this line are ignored by the patching process.
--- C:\JMeter\old\src\org\apache\jmeter\gui\util\MenuFactory.java
+++ C:\JMeter\new\src\org\apache\jmeter\gui\util\MenuFactory.java
@@ -19,6 +19,8 @@
 package org.apache.jmeter.gui.util;
 
 import java.awt.Component;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
 import java.io.IOException;
 import java.io.Serializable;
 import java.util.Collection;
@@ -436,11 +438,19 @@
                     continue;
                 }
 
+                //Handle BeanDescriptor hidden property
+                boolean isHiddenBean = false;
+
                 JMeterGUIComponent item;
                 try {
                     Class<?> c = Class.forName(name);
                     if (TestBean.class.isAssignableFrom(c)) {
                         item = new TestBeanGUI(c);
+                        try {
+                            isHiddenBean = Introspector.getBeanInfo(c).getBeanDescriptor().isHidden();
+                        } catch (IntrospectionException e) {
+                            log.warn("Cannot get bean info from class " + name + ". " + e);
+                        }
                     } else {
                         item = (JMeterGUIComponent) c.newInstance();
                     }
@@ -457,7 +467,7 @@
                     }
                     continue;
                 }
-                if (elementsToSkip.contains(item.getStaticLabel())) {
+                if (elementsToSkip.contains(item.getStaticLabel()) || isHiddenBean) {
                     log.info("Skipping " + name);
                     continue;
                 } else {

@asfimport
Copy link
Collaborator Author

Sebb (migrated from Bugzilla):
Patch format is better - the diff function now works in Bugzilla.

However, the patch uses path names that don't exist in the JMeter project:

--- C:\JMeter\old\src\org\apache\jmeter\gui\util\MenuFactory.java
+++ C:\JMeter\new\src\org\apache\jmeter\gui\util\MenuFactory.java

I would expect the patch to have a header such as:

Index: src/core/org/apache/jmeter/gui/util/MenuFactory.java

--- src/core/org/apache/jmeter/gui/util/MenuFactory.java (revision 1199781)
+++ src/core/org/apache/jmeter/gui/util/MenuFactory.java (working copy)

Note that the file is under src/core/org/..., not src/org/...

Luckily that is relatively easy to fix, but please ensure any future patches are generated relative to the JMeter root directory.

==

I applied a variation of the fix so that GUIs are treated the same as properties within the GUIs.

URL: http://svn.apache.org/viewvc?rev=1199895&view=rev
Log:
#2641 - Don't display TestBeanGui items which are flagged as hidden

Modified:
jmeter/trunk/src/core/org/apache/jmeter/gui/util/MenuFactory.java
jmeter/trunk/src/core/org/apache/jmeter/testbeans/gui/TestBeanGUI.java
jmeter/trunk/xdocs/changes.xml

@asfimport
Copy link
Collaborator Author

stef (migrated from Bugzilla):
(In reply to comment 3)

Great thanks!
I'll be careful to the diff headers if I'll propose another one.

Stef

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant