use of org.apache.jmeter.gui.JMeterGUIComponent in project jmeter by apache.
the class EditCommand method doAction.
@Override
public void doAction(ActionEvent e) {
GuiPackage guiPackage = GuiPackage.getInstance();
JMeterGUIComponent currentGui = guiPackage.getCurrentGui();
guiPackage.getMainFrame().setMainPanel((javax.swing.JComponent) currentGui);
guiPackage.getMainFrame().setEditMenu(guiPackage.getTreeListener().getCurrentNode().createPopupMenu());
guiPackage.getMainFrame().setFileLoadEnabled(true);
guiPackage.getMainFrame().setFileSaveEnabled(true);
}
use of org.apache.jmeter.gui.JMeterGUIComponent in project jmeter by apache.
the class MenuFactory method initializeMenus.
private static void initializeMenus() {
try {
List<String> guiClasses = ClassFinder.findClassesThatExtend(JMeterUtils.getSearchPaths(), new Class[] { JMeterGUIComponent.class, TestBean.class });
Collections.sort(guiClasses);
for (String name : guiClasses) {
/*
* JMeterTreeNode and TestBeanGUI are special GUI classes, and
* aren't intended to be added to menus
*
* TODO: find a better way of checking this
*/
if (// $NON-NLS-1$
name.endsWith("JMeterTreeNode") || name.endsWith("TestBeanGUI")) {
// Don't try to instantiate these
continue;
}
if (elementsToSkip.contains(name)) {
// No point instantiating class
log.info("Skipping {}", name);
continue;
}
// Should the TestBean be hidden?
boolean hideBean = false;
JMeterGUIComponent item = null;
try {
Class<?> c = Class.forName(name);
if (TestBean.class.isAssignableFrom(c)) {
TestBeanGUI tbgui = new TestBeanGUI(c);
hideBean = tbgui.isHidden() || (tbgui.isExpert() && !JMeterUtils.isExpertMode());
item = tbgui;
} else {
item = (JMeterGUIComponent) c.newInstance();
}
} catch (NoClassDefFoundError e) {
log.warn("Configuration error, probably corrupt or missing third party library(jar) ? Could not create class: {}. {}", name, e, e);
continue;
} catch (HeadlessException e) {
// NOSONAR
log.warn("Could not instantiate class: {}", name, e);
continue;
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
// NOSONAR
log.warn("Could not instantiate class: {}", name, e);
continue;
}
if (hideBean || elementsToSkip.contains(item.getStaticLabel())) {
log.info("Skipping {}", name);
continue;
} else {
// Don't add it again
elementsToSkip.add(name);
}
Collection<String> categories = item.getMenuCategories();
if (categories == null) {
log.debug("{} participates in no menus.", name);
continue;
}
if (categories.contains(THREADS)) {
threads.add(new MenuInfo(item, name));
}
if (categories.contains(FRAGMENTS)) {
fragments.add(new MenuInfo(item, name));
}
if (categories.contains(TIMERS)) {
timers.add(new MenuInfo(item, name));
}
if (categories.contains(POST_PROCESSORS)) {
postProcessors.add(new MenuInfo(item, name));
}
if (categories.contains(PRE_PROCESSORS)) {
preProcessors.add(new MenuInfo(item, name));
}
if (categories.contains(CONTROLLERS)) {
controllers.add(new MenuInfo(item, name));
}
if (categories.contains(SAMPLERS)) {
samplers.add(new MenuInfo(item, name));
}
if (categories.contains(NON_TEST_ELEMENTS)) {
nonTestElements.add(new MenuInfo(item, name));
}
if (categories.contains(LISTENERS)) {
listeners.add(new MenuInfo(item, name));
}
if (categories.contains(CONFIG_ELEMENTS)) {
configElements.add(new MenuInfo(item, name));
}
if (categories.contains(ASSERTIONS)) {
assertions.add(new MenuInfo(item, name));
}
}
} catch (IOException e) {
log.error("IO Exception while initializing menus.", e);
}
}
use of org.apache.jmeter.gui.JMeterGUIComponent in project jmeter by apache.
the class JMeterTest method suiteGUIComponents.
/*
* Test GUI elements - create the suite of tests
*/
private static Test suiteGUIComponents() throws Exception {
TestSuite suite = new TestSuite("GuiComponents");
for (Object o : getObjects(JMeterGUIComponent.class)) {
JMeterGUIComponent item = (JMeterGUIComponent) o;
if (item instanceof JMeterTreeNode) {
System.out.println("o.a.j.junit.JMeterTest INFO: JMeterGUIComponent: skipping all tests " + item.getClass().getName());
continue;
}
if (item instanceof ObsoleteGui) {
continue;
}
TestSuite ts = new TestSuite(item.getClass().getName());
ts.addTest(new JMeterTest("GUIComponents1", item));
if (item instanceof TestBeanGUI) {
System.out.println("o.a.j.junit.JMeterTest INFO: JMeterGUIComponent: skipping some tests " + item.getClass().getName());
} else {
ts.addTest(new JMeterTest("GUIComponents2", item));
ts.addTest(new JMeterTest("runGUITitle", item));
}
suite.addTest(ts);
}
return suite;
}
Aggregations