KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jmeter > gui > JMeterGUIComponent


1 // $Header: /home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/gui/JMeterGUIComponent.java,v 1.14 2004/03/05 13:18:38 sebb Exp $
2
/*
3  * Copyright 2002-2004 The Apache Software Foundation.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17 */

18
19 package org.apache.jmeter.gui;
20 import java.util.Collection JavaDoc;
21
22 import javax.swing.JPopupMenu JavaDoc;
23
24 import org.apache.jmeter.gui.tree.JMeterTreeNode;
25 import org.apache.jmeter.testelement.TestElement;
26 /**
27  * Implementing this interface indicates that the class is a JMeter GUI
28  * Component. A JMeter GUI Component is essentially the GUI display code
29  * associated with a JMeter Test Element. The writer of the component must
30  * take care to make the component be consistent with the rest of JMeter's
31  * GUI look and feel and behavior. Use of the provided abstract classes is
32  * highly recommended to make this task easier.
33  *
34  * @see AbstractJMeterGuiComponent
35  * @see org.apache.jmeter.config.gui.AbstractConfigGui
36  * @see org.apache.jmeter.assertions.gui.AbstractAssertionGui
37  * @see org.apache.jmeter.control.gui.AbstractControllerGui
38  * @see org.apache.jmeter.timers.gui.AbstractTimerGui
39  * @see org.apache.jmeter.visualizers.gui.AbstractVisualizer
40  * @see org.apache.jmeter.samplers.gui.AbstractSamplerGui
41  *
42  * @version $Revision: 1.14 $ on $Date: 2004/03/05 13:18:38 $
43  *
44  */

45
46 public interface JMeterGUIComponent
47 {
48
49     /**
50      * Sets the name of the JMeter GUI Component. The name
51      * of the component is used in the Test Tree as the name of the
52      * tree node.
53      *
54      * @param name the name of the component
55      */

56     void setName(String JavaDoc name);
57
58     /**
59      * Gets the name of the JMeter GUI component. The name
60      * of the component is used in the Test Tree as the name of the tree node.
61      *
62      * @return the name of the component
63      */

64     String JavaDoc getName();
65
66     /**
67      * Get the component's label. This label is used in drop down
68      * lists that give the user the option of choosing one type of
69      * component in a list of many. It should therefore be a descriptive
70      * name for the end user to see. It must be unique to the class.
71      *
72      * It is also used by Help to find the appropriate location in the documentation
73      *
74      * @return GUI label for the component.
75      */

76     String JavaDoc getStaticLabel();
77
78     /**
79      * Get the component's resource name, which getStaticLabel uses
80      * to derive the component's label in the local language.
81      * The resource name is fixed, and does not vary with the selected language.
82      *
83      * @return the resource name
84      */

85     String JavaDoc getLabelResource();
86     
87     /**
88      * Get the component's document anchor name.
89      * Used by Help to find the appropriate location in the documentation
90      *
91      * @return Document anchor (#ref) for the component.
92      */

93     String JavaDoc getDocAnchor();
94
95     /**
96      * JMeter test components are separated into a model and a GUI
97      * representation. The model holds the data and the GUI displays it. The
98      * GUI class is responsible for knowing how to create and initialize with
99      * data the model class that it knows how to display, and this method is
100      * called when new test elements are created.
101      *
102      * @return the Test Element object that the GUI component represents.
103      */

104     TestElement createTestElement();
105     
106     /**
107      * GUI components are responsible for populating TestElements they create
108      * with the data currently held in the GUI components. This method should
109      * overwrite whatever data is currently in the TestElement as it is called
110      * after a user has filled out the form elements in the gui with new
111      * information.
112      *
113      * @param element the TestElement to modify
114      */

115     void modifyTestElement(TestElement element);
116
117     /**
118      * Test GUI elements can be disabled, in which case
119      * they do not become part of the test when run.
120      *
121      * @return true if the element should be part of the test run, false
122      * otherwise
123      */

124     boolean isEnabled();
125
126     /**
127      * Set whether this component is enabled.
128      *
129      * @param enabled true for enabled, false for disabled.
130      */

131     void setEnabled(boolean enabled);
132
133     /**
134      * When a user right-clicks on the component in the test tree, or
135      * selects the edit menu when the component is selected, the
136      * component will be asked to return a JPopupMenu that provides
137      * all the options available to the user from this component.
138      *
139      * @return a JPopupMenu appropriate for the component.
140      */

141     JPopupMenu JavaDoc createPopupMenu();
142
143     /**
144      * The GUI must be able to extract the data from the TestElement and update
145      * all GUI fields to represent those data. This method is called to allow
146      * JMeter to show the user the GUI that represents the test element's data.
147      *
148      * @param element the TestElement to configure
149      */

150     void configure(TestElement element);
151
152     /**
153      * This is the list of add menu categories this gui component will be
154      * available under. For instance, if this represents a Controller, then the
155      * MenuFactory.CONTROLLERS category should be in the returned collection.
156      * When a user right-clicks on a tree element and looks through the "add"
157      * menu, which category your GUI component shows up in is determined by
158      * which categories are returned by this method. Most GUI's belong to only
159      * one category, but it is possible for a component to exist in multiple
160      * categories.
161      *
162      * @return a Collection of Strings, where each element is one of the
163      * constants defined in MenuFactory
164      *
165      * @see org.apache.jmeter.gui.util.MenuFactory
166      */

167     Collection JavaDoc getMenuCategories();
168
169     /**
170      * Sets the tree node which this component is associated with.
171      *
172      * @param node the tree node corresponding to this component
173      */

174     void setNode(JMeterTreeNode node);
175     
176     /**
177      * Clear the gui and return it to initial default values. This is
178      * necessary because most gui classes are instantiated just once and
179      * re-used for multiple test element objects and thus they need to be
180      * cleared between use.
181      * TODO: implement this in all gui classes.
182      */

183     public void clear();
184 }
185
Popular Tags