KickJava   Java API By Example, From Geeks To Geeks.

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


1 // $Header: /home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/gui/action/Cut.java,v 1.6.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.JMeterTreeNode;
27
28 /**
29  * @author Thad Smith
30  * @version $Revision: 1.6.2.1 $
31  */

32 public class Cut extends AbstractAction
33 {
34     public final static String JavaDoc CUT = "Cut";
35     private static Set JavaDoc commands = new HashSet JavaDoc();
36     static {
37         commands.add(CUT);
38     }
39
40     /**
41      * @see Command#getActionNames()
42      */

43     public Set JavaDoc getActionNames()
44     {
45         return commands;
46     }
47
48     /**
49      * @see Command#doAction(ActionEvent)
50      */

51     public void doAction(ActionEvent JavaDoc e)
52     {
53         GuiPackage guiPack = GuiPackage.getInstance();
54         JMeterTreeNode[] currentNodes = guiPack.getTreeListener().getSelectedNodes();
55
56         Copy.setCopiedNodes(currentNodes);
57         for(int i=0;i<currentNodes.length;i++) {
58             guiPack.getTreeModel().removeNodeFromParent(currentNodes[i]);
59         }
60         guiPack.getMainFrame().repaint();
61     }
62 }
Popular Tags