1 19 20 package org.netbeans.modules.loadgenerator.actions; 21 22 import java.awt.event.ActionEvent ; 23 import java.beans.PropertyChangeEvent ; 24 import java.beans.PropertyChangeListener ; 25 import javax.swing.AbstractAction ; 26 import javax.swing.ImageIcon ; 27 import org.netbeans.modules.loadgenerator.spi.Engine; 28 import org.netbeans.modules.loadgenerator.spi.ProcessInstance; 29 import org.openide.util.Utilities; 30 import org.openide.util.WeakListeners; 31 32 36 public class RemoveStoppedAction extends AbstractAction { 37 private static final String ICON = "org/netbeans/modules/j2ee/deployment/impl/ui/resources/start.png"; private static final String PROP_ENABLED = "enabled"; 40 private Engine engine = null; 41 42 private PropertyChangeListener listener = new PropertyChangeListener () { 43 public void propertyChange(PropertyChangeEvent evt) { 44 firePropertyChange(PROP_ENABLED, !((Boolean )evt.getOldValue()).booleanValue(), !((Boolean )evt.getNewValue()).booleanValue()); 46 } 47 }; 48 49 50 public RemoveStoppedAction(final Engine engine) { 51 super("Remove All Stopped", new ImageIcon (Utilities.loadImage(ICON))); 52 this.engine = engine; 53 this.engine.addPropertyChangeListener(ProcessInstance.STATE, WeakListeners.propertyChange(listener, engine)); 54 } 55 56 public void actionPerformed(ActionEvent e) { 57 engine.cleanup(); 58 } 59 60 public boolean isEnabled() { 61 return engine.canCleanup(); 62 } 63 } 64 | Popular Tags |