KickJava   Java API By Example, From Geeks To Geeks.

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


1 // $Header: /home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/gui/action/Paste.java,v 1.3.2.1 2004/09/26 15:36:26 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.HashSet JavaDoc;
23 import java.util.Set JavaDoc;
24
25 import org.apache.jmeter.gui.GuiPackage;
26 import org.apache.jmeter.gui.tree.JMeterTreeListener;
27 import org.apache.jmeter.gui.tree.JMeterTreeNode;
28
29 /**
30  * Places a copied JMeterTreeNode under the selected node.
31  *
32  * @author Thad Smith
33  * @version $Revision: 1.3.2.1 $
34  */

35 public class Paste extends AbstractAction
36 {
37
38     public final static String JavaDoc PASTE = "Paste";
39     private static Set JavaDoc commands = new HashSet JavaDoc();
40     static {
41         commands.add(PASTE);
42     }
43
44     /**
45      * @see Command#getActionNames()
46      */

47     public Set JavaDoc getActionNames()
48     {
49         return commands;
50     }
51
52     /**
53      * @see Command#doAction(ActionEvent)
54      */

55     public void doAction(ActionEvent JavaDoc e)
56     {
57         JMeterTreeNode draggedNodes[] = Copy.getCopiedNodes();
58         JMeterTreeListener treeListener =
59                     GuiPackage.getInstance().getTreeListener();
60         JMeterTreeNode currentNode = treeListener.getCurrentNode();
61         if (DragNDrop.canAddTo(currentNode))
62         {
63             for(int i=0;i<draggedNodes.length;i++) {
64                 if (draggedNodes[i] != null)
65                 {
66                     GuiPackage.getInstance().getTreeModel().insertNodeInto(
67                         draggedNodes[i],
68                         currentNode,
69                         currentNode.getChildCount());
70                 }
71             }
72         }
73         GuiPackage.getInstance().getMainFrame().repaint();
74     }
75 }
Popular Tags