KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jmeter > control > gui > WorkBenchGui


1 // $Header: /home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/control/gui/WorkBenchGui.java,v 1.13 2004/03/05 01:34:05 sebb Exp $
2
/*
3  * Copyright 2001-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.control.gui;
20 import java.awt.BorderLayout JavaDoc;
21 import java.util.Collection JavaDoc;
22
23 import javax.swing.JMenu JavaDoc;
24 import javax.swing.JPopupMenu JavaDoc;
25
26 import org.apache.jmeter.gui.AbstractJMeterGuiComponent;
27 import org.apache.jmeter.gui.util.MenuFactory;
28 import org.apache.jmeter.testelement.TestElement;
29 import org.apache.jmeter.testelement.WorkBench;
30 import org.apache.jmeter.util.JMeterUtils;
31
32 /**
33  * JMeter GUI component representing a work bench where users can make
34  * preparations for the test plan.
35  *
36  * @version $Revision: 1.13 $ on $Date: 2004/03/05 01:34:05 $
37  */

38 public class WorkBenchGui extends AbstractJMeterGuiComponent
39 {
40     /**
41      * Create a new WorkbenchGui.
42      */

43     public WorkBenchGui()
44     {
45         super();
46         init();
47     }
48
49     /**
50      * This is the list of menu categories this gui component will be available
51      * under. This implementation returns null, since the WorkBench appears at
52      * the top level of the tree and cannot be added elsewhere.
53      *
54      * @return a Collection of Strings, where each element is one of the
55      * constants defined in MenuFactory
56      */

57     public Collection JavaDoc getMenuCategories()
58     {
59         return null;
60     }
61
62     /* Implements JMeterGUIComponent.createTestElement() */
63     public TestElement createTestElement()
64     {
65         WorkBench wb = new WorkBench();
66         modifyTestElement(wb);
67         return wb;
68     }
69
70     /* Implements JMeterGUIComponent.modifyTestElement(TestElement) */
71     public void modifyTestElement(TestElement wb)
72     {
73         super.configureTestElement(wb);
74     }
75
76     /**
77      * A newly created component can be initialized with the contents of
78      * a Test Element object by calling this method. The component is
79      * responsible for querying the Test Element object for the
80      * relevant information to display in its GUI.
81      *
82      * @param element the TestElement to configure
83      */

84     public void configure(TestElement element)
85     {
86         getNamePanel().configure(element);
87     }
88
89     /**
90      * When a user right-clicks on the component in the test tree, or
91      * selects the edit menu when the component is selected, the
92      * component will be asked to return a JPopupMenu that provides
93      * all the options available to the user from this component.
94      * <p>
95      * The WorkBench will return a popup menu allowing you to add Controllers,
96      * Samplers, Configuration Elements, and Non-test Elements.
97      *
98      * @return a JPopupMenu appropriate for the component.
99      */

100     public JPopupMenu JavaDoc createPopupMenu()
101     {
102         JPopupMenu JavaDoc menu = new JPopupMenu JavaDoc();
103         JMenu JavaDoc addMenu =
104             MenuFactory.makeMenus(
105                 new String JavaDoc[] {
106                     MenuFactory.CONTROLLERS,
107                     MenuFactory.SAMPLERS,
108                     MenuFactory.CONFIG_ELEMENTS,
109                     MenuFactory.NON_TEST_ELEMENTS },
110                 JMeterUtils.getResString("Add"),
111                 "Add");
112         menu.add(addMenu);
113         MenuFactory.addEditMenu(menu, false);
114         MenuFactory.addFileMenu(menu);
115         return menu;
116     }
117
118     public String JavaDoc getLabelResource()
119     {
120         return "workbench_title";
121     }
122
123     /**
124      * Initialize the components and layout of this component.
125      */

126     private void init()
127     {
128         setLayout(new BorderLayout JavaDoc());
129         setBorder(makeBorder());
130
131         add(makeTitlePanel(), BorderLayout.NORTH);
132     }
133 }
134
Popular Tags