1 23 24 package org.objectweb.fractal.gui.menu.control; 25 26 import org.objectweb.fractal.gui.model.Component; 27 28 import java.awt.event.ActionEvent ; 29 import java.net.URL ; 30 31 import javax.swing.ImageIcon ; 32 import javax.swing.KeyStroke ; 33 34 37 38 public class NewComponentAction extends CreateAction { 39 40 43 44 public NewComponentAction () { 45 putValue(NAME, "New component"); 46 putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke("INSERT")); 47 URL url = getClass().getResource( 48 "/org/objectweb/fractal/gui/resources/empty.gif"); 49 putValue(SMALL_ICON, new ImageIcon (url)); 50 setEnabled(false); 51 } 52 53 57 public void selectionChanged () { 58 boolean enabled = false; 59 Object o = selection.getSelection(); 60 if (o instanceof Component) { 61 Component c = (Component)o; 62 enabled = c.getMasterComponent() == null; 63 } 64 setEnabled(enabled); 65 } 66 67 71 public void actionPerformed (final ActionEvent e) { 72 Object o = selection.getSelection(); 73 Component parent = (Component)o; 74 Component child = factory.createComponent(); 75 parent.addSubComponent(child); 76 } 78 } 79 | Popular Tags |