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.KeyStroke ; 34 import javax.swing.JOptionPane ; 35 36 41 42 public class CutAction extends ClipboardAction { 43 44 47 48 public CutAction () { 49 putValue(NAME, "Cut"); 50 putValue(SHORT_DESCRIPTION, "Cut"); 51 putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke("control X")); 52 URL url = getClass().getResource( 53 "/org/objectweb/fractal/gui/resources/editcut.gif"); 54 putValue(SMALL_ICON, new ImageIcon (url)); 55 setEnabled(false); 56 } 57 58 62 public void selectionChanged () { 63 Object o = selection.getSelection(); 64 if (o instanceof Component) { 65 setEnabled(clipboard.canCut((Component)o)); 66 } else { 67 setEnabled(clipboard.canCut(null)); 68 } 69 } 70 71 75 public void actionPerformed (final ActionEvent e) { 76 Object o = selection.getSelection(); 77 try { 78 clipboard.cut((Component)o, graph, factory); 79 } catch (IllegalOperationException ioe) { 80 JOptionPane.showMessageDialog( 81 null, ioe.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); 82 } 83 selection.clearSelection(); 84 } 85 } 86 | Popular Tags |