1 19 20 package org.netbeans.modules.tasklist.usertasks.actions; 21 22 import java.awt.datatransfer.Clipboard ; 23 import java.awt.datatransfer.Transferable ; 24 import java.awt.event.ActionEvent ; 25 import javax.swing.TransferHandler ; 26 import javax.swing.event.ListSelectionEvent ; 27 import javax.swing.tree.TreePath ; 28 import org.netbeans.modules.tasklist.usertasks.UserTaskListTreeTableNode; 29 import org.netbeans.modules.tasklist.usertasks.UserTaskTreeTableNode; 30 import org.netbeans.modules.tasklist.usertasks.UserTaskView; 31 32 37 public final class UTPasteAction extends UTViewAction { 38 43 public UTPasteAction(UserTaskView utv) { 44 super(utv, javax.swing.text.DefaultEditorKit.pasteAction); 45 } 46 47 public void valueChanged(ListSelectionEvent e) { 48 TreePath [] paths = utv.getTreeTable().getSelectedPaths(); 49 if (paths.length == 1) { 50 Object last = paths[0].getLastPathComponent(); 51 setEnabled(last instanceof UserTaskTreeTableNode || 52 last instanceof UserTaskListTreeTableNode); 53 } else { 54 setEnabled(false); 55 } 56 } 57 58 public void actionPerformed(ActionEvent e) { 59 TransferHandler th = utv.getTreeTable().getTransferHandler(); 60 Clipboard clipboard = utv.getToolkit().getSystemClipboard(); 61 Transferable t = clipboard.getContents(this); 62 if (t != null) 63 th.importData(utv.getTreeTable(), t); 64 } 65 } 66 | Popular Tags |