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.ReportGuiPackage;
26: import org.apache.jmeter.report.gui.action.AbstractAction;
27: import org.apache.jmeter.report.gui.tree.ReportTreeListener;
28: import org.apache.jmeter.report.gui.tree.ReportTreeNode;
29:
30: /**
31: * Places a copied JMeterTreeNode under the selected node.
32: *
33: * @author Thad Smith
34: * @version $Revision: 571988 $
35: */
36: public class ReportPaste extends AbstractAction {
37:
38: public final static String PASTE = "Paste";
39:
40: private static Set commands = new HashSet();
41: static {
42: commands.add(PASTE);
43: }
44:
45: /**
46: * @see org.apache.jmeter.gui.action.Command#getActionNames()
47: */
48: public Set getActionNames() {
49: return commands;
50: }
51:
52: /**
53: * @see org.apache.jmeter.gui.action.Command#doAction(ActionEvent)
54: */
55: public void doAction(ActionEvent e) {
56: ReportTreeNode draggedNodes[] = ReportCopy.getCopiedNodes();
57: ReportTreeListener treeListener = ReportGuiPackage
58: .getInstance().getTreeListener();
59: ReportTreeNode currentNode = treeListener.getCurrentNode();
60: if (ReportDragNDrop.canAddTo(currentNode)) {
61: for (int i = 0; i < draggedNodes.length; i++) {
62: if (draggedNodes[i] != null) {
63: ReportGuiPackage.getInstance().getTreeModel()
64: .insertNodeInto(draggedNodes[i],
65: currentNode,
66: currentNode.getChildCount());
67: }
68: }
69: }
70: ReportGuiPackage.getInstance().getMainFrame().repaint();
71: }
72: }
|