Coverage Report - org.xmlhammer.gui.output.actions.CopyAction
 
Classes in this File Line Coverage Branch Coverage Complexity
CopyAction
0% 
N/A 
0
 
 1  
 package org.xmlhammer.gui.output.actions;
 2  
 
 3  
 import java.awt.Toolkit;
 4  
 import java.awt.datatransfer.Clipboard;
 5  
 import java.awt.datatransfer.StringSelection;
 6  
 import java.awt.event.KeyEvent;
 7  
 
 8  
 import javax.swing.ImageIcon;
 9  
 import javax.swing.KeyStroke;
 10  
 
 11  
 import org.bounce.RunnableAction;
 12  
 
 13  
 public class CopyAction extends RunnableAction {
 14  
     private static final long serialVersionUID = -6546100768134624390L;
 15  
 
 16  0
     private String text = null;
 17  
 
 18  
     public CopyAction() {
 19  0
         super("Copy");
 20  
 
 21  0
         putValue(MNEMONIC_KEY, new Integer('C'));
 22  0
         putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_C, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false));
 23  0
         putValue(SHORT_DESCRIPTION, "Copy");
 24  0
         putValue(SMALL_ICON, new ImageIcon(getClass().getResource("/org/xmlhammer/gui/icons/etool16/copy_edit.gif")));
 25  0
     }
 26  
     
 27  
     public void setText(String text) {
 28  0
         this.text = text;
 29  0
     }
 30  
     
 31  
     @Override
 32  
     public void run() {
 33  0
         Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
 34  0
         clipboard.setContents(new StringSelection(text), null);    
 35  0
     }
 36  
 }