1 23 24 package org.objectweb.fractal.gui.clipboard.control; 25 26 import org.objectweb.fractal.gui.model.Component; 27 28 import java.net.URL ; 29 import java.awt.event.ActionEvent ; 30 31 import javax.swing.ImageIcon ; 32 import javax.swing.KeyStroke ; 33 34 39 40 public class CopyAction extends ClipboardAction { 41 42 45 46 public CopyAction () { 47 putValue(NAME, "Copy"); 48 putValue(SHORT_DESCRIPTION, "Copy"); 49 putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke("control C")); 50 URL url = getClass().getResource( 51 "/org/objectweb/fractal/gui/resources/editcopy.gif"); 52 putValue(SMALL_ICON, new ImageIcon (url)); 53 setEnabled(false); 54 } 55 56 60 public void selectionChanged () { 61 Object o = selection.getSelection(); 62 if (o instanceof Component) { 63 setEnabled(clipboard.canCopy((Component)o)); 64 } else { 65 setEnabled(clipboard.canCopy(null)); 66 } 67 } 68 69 73 public void actionPerformed (final ActionEvent e) { 74 Object o = selection.getSelection(); 75 clipboard.copy((Component)o, graph, factory); 76 } 77 } 78 | Popular Tags |