001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: *
017: */
018:
019: package org.apache.jmeter.control.gui;
020:
021: import javax.swing.JMenu;
022: import javax.swing.JPopupMenu;
023:
024: import org.apache.jmeter.control.IncludeController;
025: import org.apache.jmeter.gui.action.ActionNames;
026: import org.apache.jmeter.gui.util.FilePanel;
027: import org.apache.jmeter.gui.util.MenuFactory;
028: import org.apache.jmeter.testelement.TestElement;
029: import org.apache.jmeter.util.JMeterUtils;
030: import org.apache.jorphan.gui.layout.VerticalLayout;
031:
032: public class IncludeControllerGui extends AbstractControllerGui
033: // implements UnsharedComponent
034: {
035:
036: private FilePanel includePanel = new FilePanel(JMeterUtils
037: .getResString("include_path"), ".jmx"); //$NON-NLS-1$ //$NON-NLS-2$
038:
039: /**
040: * Initializes the gui panel for the ModuleController instance.
041: */
042: public IncludeControllerGui() {
043: init();
044: }
045:
046: public String getLabelResource() {
047: return "include_controller";//$NON-NLS-1$
048: }
049:
050: /*
051: * (non-Javadoc)
052: *
053: * @see org.apache.jmeter.gui.JMeterGUIComponent#configure(TestElement)
054: */
055: public void configure(TestElement el) {
056: super .configure(el);
057: IncludeController controller = (IncludeController) el;
058: this .includePanel.setFilename(controller.getIncludePath());
059: }
060:
061: /*
062: * (non-Javadoc)
063: *
064: * @see org.apache.jmeter.gui.JMeterGUIComponent#createTestElement()
065: */
066: public TestElement createTestElement() {
067: IncludeController mc = new IncludeController();
068: configureTestElement(mc);
069: return mc;
070: }
071:
072: /*
073: * (non-Javadoc)
074: *
075: * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
076: */
077: public void modifyTestElement(TestElement element) {
078: configureTestElement(element);
079: IncludeController controller = (IncludeController) element;
080: controller.setIncludePath(this .includePanel.getFilename());
081: }
082:
083: /**
084: * Implements JMeterGUIComponent.clearGui
085: */
086: public void clearGui() {
087: super .clearGui();
088: includePanel.clearGui();
089: }
090:
091: public JPopupMenu createPopupMenu() {
092: JPopupMenu menu = new JPopupMenu();
093: JMenu addMenu = MenuFactory.makeMenus(new String[] {
094: MenuFactory.CONFIG_ELEMENTS, MenuFactory.ASSERTIONS,
095: MenuFactory.TIMERS, MenuFactory.LISTENERS, },
096: JMeterUtils.getResString("add"), // $NON-NLS-1$
097: ActionNames.ADD);
098: menu.add(addMenu);
099: MenuFactory.addEditMenu(menu, true);
100: MenuFactory.addFileMenu(menu);
101: return menu;
102: }
103:
104: private void init() {
105: setLayout(new VerticalLayout(5, VerticalLayout.BOTH,
106: VerticalLayout.TOP));
107: setBorder(makeBorder());
108: add(makeTitlePanel());
109:
110: add(includePanel);
111: }
112: }
|