KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jmeter > gui > action > AbstractAction


1 // $Header: /home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/gui/action/AbstractAction.java,v 1.12.2.1 2004/10/13 00:38:39 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.gui.action;
20
21 import java.awt.event.ActionEvent JavaDoc;
22 import java.util.Iterator JavaDoc;
23 import java.util.LinkedList JavaDoc;
24 import java.util.Set JavaDoc;
25
26 import org.apache.jmeter.control.ReplaceableController;
27 import org.apache.jmeter.gui.tree.JMeterTreeNode;
28 import org.apache.jmeter.testelement.TestElement;
29 import org.apache.jorphan.collections.HashTree;
30 import org.apache.jorphan.logging.LoggingManager;
31 import org.apache.log.Logger;
32
33 /**
34  * @author mstover
35  * @version $Revision: 1.12.2.1 $
36  */

37 public abstract class AbstractAction implements Command
38 {
39     private static final Logger log = LoggingManager.getLoggerForClass();
40
41     /**
42      * @see Command#doAction(ActionEvent)
43      */

44     public void doAction(ActionEvent JavaDoc e)
45     {
46     }
47
48     /**
49      * @see Command#getActionNames()
50      */

51     abstract public Set JavaDoc getActionNames();
52
53     protected void convertSubTree(HashTree tree)
54     {
55         Iterator JavaDoc iter = new LinkedList JavaDoc(tree.list()).iterator();
56         while (iter.hasNext())
57         {
58             JMeterTreeNode item = (JMeterTreeNode) iter.next();
59             if (item.isEnabled())
60             {
61                 if (item.getUserObject() instanceof ReplaceableController)
62                 {
63                     ReplaceableController rc =
64                         (ReplaceableController) item.getTestElement();
65                     HashTree subTree = tree.getTree(item);
66
67                     if (subTree != null)
68                     {
69                         rc.replace(subTree);
70                         convertSubTree(subTree);
71                         tree.replace(item, rc.getReplacement());
72                     }
73                 }
74                 else
75                 {
76                     convertSubTree(tree.getTree(item));
77                     TestElement testElement = item.getTestElement();
78                     tree.replace(item, testElement);
79                 }
80             }
81             else
82             {
83                 tree.remove(item);
84             }
85
86         }
87     }
88 }
89
Popular Tags