01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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.action;
20:
21: import java.awt.event.ActionEvent;
22: import java.util.Collections;
23: import java.util.HashSet;
24: import java.util.Set;
25:
26: import org.apache.jmeter.exceptions.IllegalUserActionException;
27: import org.apache.jmeter.gui.GuiPackage;
28: import org.apache.jmeter.gui.tree.JMeterTreeNode;
29: import org.apache.jmeter.testelement.TestElement;
30: import org.apache.jorphan.logging.LoggingManager;
31:
32: /**
33: *
34: * Debug class to show details of the currently selected object
35: * Currently shows TestElement and GUI class names
36: *
37: * Also enables/disables debug for the test element.
38: *
39: */
40: public class What implements Command {
41:
42: private static final Set commandSet;
43:
44: static {
45: HashSet commands = new HashSet();
46: commands.add(ActionNames.WHAT_CLASS);
47: commands.add(ActionNames.DEBUG_ON);
48: commands.add(ActionNames.DEBUG_OFF);
49: commandSet = Collections.unmodifiableSet(commands);
50: }
51:
52: public void doAction(ActionEvent e)
53: throws IllegalUserActionException {
54: JMeterTreeNode node = GuiPackage.getInstance()
55: .getTreeListener().getCurrentNode();
56: TestElement te = (TestElement) node.getUserObject();
57: if (ActionNames.WHAT_CLASS.equals(e.getActionCommand())) {
58: String guiClassName = te
59: .getPropertyAsString(TestElement.GUI_CLASS);
60: System.out.println(te.getClass().getName());
61: System.out.println(guiClassName);
62: } else if (ActionNames.DEBUG_ON.equals(e.getActionCommand())) {
63: LoggingManager.setPriorityFullName(
64: "DEBUG", te.getClass().getName());//$NON-NLS-1$
65: } else if (ActionNames.DEBUG_OFF.equals(e.getActionCommand())) {
66: LoggingManager.setPriorityFullName(
67: "INFO", te.getClass().getName());//$NON-NLS-1$
68: }
69: }
70:
71: /**
72: * Provide the list of Action names that are available in this command.
73: */
74: public Set getActionNames() {
75: return commandSet;
76: }
77: }
|