Search in sources :

Example 6 with JMeterGUIComponent

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);
}
Also used : GuiPackage(org.apache.jmeter.gui.GuiPackage) JMeterGUIComponent(org.apache.jmeter.gui.JMeterGUIComponent)

Example 7 with JMeterGUIComponent

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);
    }
}
Also used : HeadlessException(java.awt.HeadlessException) IOException(java.io.IOException) HeadlessException(java.awt.HeadlessException) IOException(java.io.IOException) TestBeanGUI(org.apache.jmeter.testbeans.gui.TestBeanGUI) JMeterGUIComponent(org.apache.jmeter.gui.JMeterGUIComponent)

Example 8 with JMeterGUIComponent

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;
}
Also used : TestBeanGUI(org.apache.jmeter.testbeans.gui.TestBeanGUI) TestSuite(junit.framework.TestSuite) JMeterTreeNode(org.apache.jmeter.gui.tree.JMeterTreeNode) JMeterGUIComponent(org.apache.jmeter.gui.JMeterGUIComponent) ObsoleteGui(org.apache.jmeter.config.gui.ObsoleteGui)

Aggregations

JMeterGUIComponent (org.apache.jmeter.gui.JMeterGUIComponent)8 GuiPackage (org.apache.jmeter.gui.GuiPackage)3 JMeterTreeNode (org.apache.jmeter.gui.tree.JMeterTreeNode)3 TestBeanGUI (org.apache.jmeter.testbeans.gui.TestBeanGUI)3 TestSuite (junit.framework.TestSuite)2 IllegalUserActionException (org.apache.jmeter.exceptions.IllegalUserActionException)2 HeadlessException (java.awt.HeadlessException)1 IOException (java.io.IOException)1 JComponent (javax.swing.JComponent)1 JTree (javax.swing.JTree)1 TreeNode (javax.swing.tree.TreeNode)1 TreePath (javax.swing.tree.TreePath)1 AbstractConfigGui (org.apache.jmeter.config.gui.AbstractConfigGui)1 ObsoleteGui (org.apache.jmeter.config.gui.ObsoleteGui)1 Controller (org.apache.jmeter.control.Controller)1 JMeterTreeModel (org.apache.jmeter.gui.tree.JMeterTreeModel)1 Clearable (org.apache.jmeter.samplers.Clearable)1 Printable (org.apache.jmeter.visualizers.Printable)1