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.report.gui.action;
20:
21: import java.awt.event.ActionEvent;
22: import java.util.HashSet;
23: import java.util.Set;
24:
25: import org.apache.jmeter.gui.action.Command;
26: import org.apache.jmeter.gui.ReportGuiPackage;
27: import org.apache.jmeter.report.gui.tree.ReportTreeNode;
28: import org.apache.jorphan.logging.LoggingManager;
29: import org.apache.log.Logger;
30:
31: /**
32: * @version $Revision: 493793 $
33: */
34: public class ReportEnableComponent implements Command {
35: private static Logger log = LoggingManager.getLoggerForClass();
36:
37: public static final String ENABLE = "enable";
38:
39: public static final String DISABLE = "disable";
40:
41: private static Set commands = new HashSet();
42: static {
43: commands.add(ENABLE);
44: commands.add(DISABLE);
45: }
46:
47: /**
48: * @see org.apache.jmeter.gui.action.Command#doAction(ActionEvent)
49: */
50: public void doAction(ActionEvent e) {
51: ReportTreeNode[] nodes = ReportGuiPackage.getInstance()
52: .getTreeListener().getSelectedNodes();
53:
54: if (e.getActionCommand().equals(ENABLE)) {
55: log.debug("enabling currently selected gui objects");
56: enableComponents(nodes, true);
57: } else if (e.getActionCommand().equals(DISABLE)) {
58: log.debug("disabling currently selected gui objects");
59: enableComponents(nodes, false);
60: }
61: }
62:
63: private void enableComponents(ReportTreeNode[] nodes, boolean enable) {
64: ReportGuiPackage pack = ReportGuiPackage.getInstance();
65: for (int i = 0; i < nodes.length; i++) {
66: nodes[i].setEnabled(enable);
67: pack.getGui(nodes[i].getTestElement()).setEnabled(enable);
68: }
69: }
70:
71: /**
72: * @see org.apache.jmeter.gui.action.Command#getActionNames()
73: */
74: public Set getActionNames() {
75: return commands;
76: }
77: }
|