1 23 24 package org.objectweb.fractal.gui.clipboard.control; 25 26 import org.objectweb.fractal.gui.model.Component; 27 import org.objectweb.fractal.gui.model.IllegalOperationException; 28 29 import java.net.URL ; 30 import java.awt.event.ActionEvent ; 31 32 import javax.swing.ImageIcon ; 33 import javax.swing.JOptionPane ; 34 import javax.swing.KeyStroke ; 35 36 42 43 public class PasteAsSharedAction extends ClipboardAction { 44 45 48 49 public PasteAsSharedAction () { 50 putValue(NAME, "Paste as shared"); 51 putValue(SHORT_DESCRIPTION, "Paste as shared"); 52 putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke("control shift V")); 53 URL url = getClass().getResource( 54 "/org/objectweb/fractal/gui/resources/empty.gif"); 55 putValue(SMALL_ICON, new ImageIcon (url)); 56 setEnabled(false); 57 } 58 59 63 public void selectionChanged () { 64 Object o = selection.getSelection(); 65 if (o instanceof Component) { 66 setEnabled(clipboard.canPasteAsShared((Component)o)); 67 } else { 68 setEnabled(clipboard.canPasteAsShared(null)); 69 } 70 } 71 72 76 public void actionPerformed (final ActionEvent e) { 77 Object o = selection.getSelection(); 78 try { 79 clipboard.pasteAsShared((Component)o, graph, factory); 80 } catch (IllegalOperationException ioe) { 81 JOptionPane.showMessageDialog( 82 null, ioe.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); 83 } 84 } 85 } 86 | Popular Tags |