2020
2121import javax .swing .BorderFactory ;
2222import javax .swing .Box ;
23- import javax .swing .JComponent ;
2423import javax .swing .JPanel ;
2524
25+ import org .apache .jmeter .config .gui .AbstractConfigGui ;
2626import org .apache .jmeter .plugins .copilot .gui .CopilotChatPanel ;
27- import org .apache .jmeter .samplers .SampleResult ;
2827import org .apache .jmeter .testelement .TestElement ;
29- import org .apache .jmeter .visualizers .gui .AbstractVisualizer ;
3028import org .slf4j .Logger ;
3129import org .slf4j .LoggerFactory ;
3230
3331import com .google .auto .service .AutoService ;
3432
3533/**
36- * JMeter Visualizer plugin that provides a GitHub Copilot Chat interface
34+ * JMeter Config Element plugin that provides a GitHub Copilot Chat interface
3735 * for generating JMeter test plans through natural language conversation.
3836 *
3937 * This plugin allows users to describe the tests they want to create, and
4038 * Copilot will generate the appropriate JMeter elements and add them to
4139 * the test plan.
4240 */
4341@ AutoService (org .apache .jmeter .gui .JMeterGUIComponent .class )
44- public class CopilotChatVisualizer extends AbstractVisualizer {
42+ public class CopilotChatConfigGui extends AbstractConfigGui {
4543
4644 private static final long serialVersionUID = 1L ;
47- private static final Logger log = LoggerFactory .getLogger (CopilotChatVisualizer .class );
45+ private static final Logger log = LoggerFactory .getLogger (CopilotChatConfigGui .class );
4846
4947 private CopilotChatPanel chatPanel ;
5048 private JPanel mainPanel ;
5149
5250 /**
53- * Creates a new CopilotChatVisualizer instance.
51+ * Creates a new CopilotChatConfigGui instance.
5452 */
55- public CopilotChatVisualizer () {
53+ public CopilotChatConfigGui () {
5654 super ();
57- log .info ("Initializing Copilot Chat Visualizer " );
55+ log .info ("Initializing Copilot Chat Config Element " );
5856 init ();
5957 }
6058
@@ -89,8 +87,6 @@ private void init() {
8987 */
9088 private void onTestPlanGenerated (String testPlanXml ) {
9189 log .info ("Test plan generated by Copilot" );
92- // This will be implemented to integrate with JMeter's GUI
93- // to add the generated elements to the test plan tree
9490 try {
9591 JMeterTestPlanIntegrator .integrateTestPlan (testPlanXml );
9692 } catch (Exception e ) {
@@ -110,31 +106,16 @@ public String getStaticLabel() {
110106 }
111107
112108 @ Override
113- public void add (SampleResult sample ) {
114- // This visualizer doesn't process sample results
115- // It's used for test generation, not result visualization
116- }
117-
118- @ Override
119- public void clearData () {
120- // Clear the chat history if needed
121- if (chatPanel != null ) {
122- chatPanel .clearChat ();
123- }
124- }
125-
126- @ Override
127- public TestElement makeTestElement () {
109+ public TestElement createTestElement () {
128110 CopilotChatTestElement element = new CopilotChatTestElement ();
129111 modifyTestElement (element );
130112 return element ;
131113 }
132114
133115 @ Override
134116 public void modifyTestElement (TestElement element ) {
135- super . modifyTestElement (element );
117+ configureTestElement (element );
136118 if (element instanceof CopilotChatTestElement copilotElement ) {
137- // Save any configuration from the GUI to the test element
138119 copilotElement .setModel (chatPanel .getSelectedModel ());
139120 }
140121 }
@@ -143,18 +124,20 @@ public void modifyTestElement(TestElement element) {
143124 public void configure (TestElement element ) {
144125 super .configure (element );
145126 if (element instanceof CopilotChatTestElement copilotElement ) {
146- // Load configuration from the test element to the GUI
147127 chatPanel .setSelectedModel (copilotElement .getModel ());
148128 }
149129 }
150130
151131 @ Override
152- public JComponent getPrintableComponent () {
153- return mainPanel ;
132+ public void clearGui () {
133+ super .clearGui ();
134+ if (chatPanel != null ) {
135+ chatPanel .clearChat ();
136+ }
154137 }
155138
156139 /**
157- * Clean up resources when the visualizer is being disposed.
140+ * Clean up resources when the config element is being disposed.
158141 */
159142 public void dispose () {
160143 if (chatPanel != null ) {
0 commit comments