Bug 65449 - Add option to have JMeter UI embedded in another application
Summary: Add option to have JMeter UI embedded in another application
Status: NEW
Alias: None
Product: JMeter
Classification: Unclassified
Component: Main (show other bugs)
Version: 5.4.1
Hardware: All All
: P2 enhancement (vote)
Target Milestone: JMETER_5.5
Assignee: JMeter issues mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-07-14 09:19 UTC by Anthony Goubard
Modified: 2021-07-14 12:33 UTC (History)
1 user (show)



Attachments
Apache JMeter embedded in IntelliJ IDEA (66.91 KB, image/png)
2021-07-14 09:19 UTC, Anthony Goubard
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Anthony Goubard 2021-07-14 09:19:43 UTC
Created attachment 37951 [details]
Apache JMeter embedded in IntelliJ IDEA

At the moment, JMeter assume that it is started with a JFrame or as non gui mode. 
It would be nice to have an option to start JMeter in embedded mode to have it included in another application. For example in a Java IDE.

Here are the changes needed to make JMeter embeddable:
 * New "embedded" start-up option (JMeter.java)
 * Parse the option in JMeter.java#start
 * Do not initialize JMeterUIDefaults and look and feel in JMeter.java#startGui
 * Do not show the JFrame in JMeter.java#startGui (setLocationRelativeTo, setVisible, toFront)
 * Do not show or disallow the following menu:
 ** File -> Restart
 ** Options -> Look and Feel
 * Add a method to JMeter.java to get the JFrame or the JRootPane
 * Do not call System.exit if the start-up fails

Nice to have but could be solved with workaround:
 * Do not use the JFrame as parent component when opening a dialogue window. 
 ** Workaround calling GuiPackage.setMainFrame with frame of the main application.
 * Do not assume that the context class loader of the current thread or of the event dispatch thread contains the classpath like for example done in the menu creation and searching for plug-ins. Prefer getClass().getClassLoader() or MyObject.class.getClassLoader() in a static context. 
 ** Workaround change the context class loader of the thread starting JMeter and of the Event Dispatch Thread which can be dangerous as the EDT is used everywhere in an IDE for example.
 * NewDriver.java should first check the "jmeter.home" system property, as if the main application is started from a main Jar file, NewDriver assume it's the ApacheJMeter.jar which is not the case.
 ** Workaround change the "java.class.path" system property to have at least 2 entries before starting JMeter.
Comment 1 Anthony Goubard 2021-07-14 11:35:02 UTC
The "* Do not use the JFrame as parent component when opening a dialogue window." needs to be moved the the needed changes as setMainFrame uses the MainFrame class and not JFrame.
Comment 2 Anthony Goubard 2021-07-14 12:33:08 UTC
"Do not use the JFrame as parent component when opening a dialogue window" doesn't seem to be a problem (needs more investigation). The mainFrame.getLocationOnScreen() is failing as the mainFrame is not visible.

Also disable Zoom In and Zoom out actions in Embedded mode if we don't initialize JMeterUIDefaults.