1 19 20 package org.netbeans.modules.tasklist.usertasks.actions; 21 22 import java.awt.datatransfer.Clipboard ; 23 import java.awt.event.ActionEvent ; 24 import javax.swing.TransferHandler ; 25 import javax.swing.event.ListSelectionEvent ; 26 import javax.swing.tree.TreePath ; 27 import org.netbeans.modules.tasklist.usertasks.UserTaskListTreeTableNode; 28 import org.netbeans.modules.tasklist.usertasks.UserTaskView; 29 import org.netbeans.modules.tasklist.usertasks.util.UTUtils; 30 31 36 public final class UTCopyAction extends UTViewAction { 37 42 public UTCopyAction(UserTaskView utv) { 43 super(utv, javax.swing.text.DefaultEditorKit.copyAction); 44 } 45 46 public void valueChanged(ListSelectionEvent e) { 47 TreePath [] paths = utv.getTreeTable().getSelectedPaths(); 48 boolean enabled = true; 49 for (int i = 0; i < paths.length; i++) { 50 if (paths[i].getLastPathComponent() instanceof 51 UserTaskListTreeTableNode) { 52 enabled = false; 53 break; 54 } 55 } 56 setEnabled(enabled); 58 } 59 60 public void actionPerformed(ActionEvent e) { 61 TransferHandler th = utv.getTreeTable().getTransferHandler(); 62 Clipboard clipboard = utv.getToolkit().getSystemClipboard(); 63 th.exportToClipboard(utv.getTreeTable(), 64 clipboard, TransferHandler.COPY); 65 } 66 } 67 | Popular Tags |