1 19 20 package org.netbeans.modules.tasklist.usertasks.actions; 21 22 import java.awt.event.ActionEvent ; 23 import javax.swing.AbstractAction ; 24 import javax.swing.Action ; 25 import javax.swing.ImageIcon ; 26 import javax.swing.event.ChangeEvent ; 27 import javax.swing.event.ChangeListener ; 28 import org.netbeans.modules.tasklist.usertasks.model.StartedUserTask; 29 import org.netbeans.modules.tasklist.usertasks.model.UserTask; 30 import org.openide.util.NbBundle; 31 import org.openide.util.Utilities; 32 33 38 public class PauseAction extends AbstractAction implements ChangeListener { 39 private static PauseAction INSTANCE = new PauseAction(); 40 41 46 public static PauseAction getInstance() { 47 return INSTANCE; 48 } 49 50 53 private PauseAction() { 54 putValue(Action.NAME, 55 NbBundle.getMessage(PauseAction.class, "Pause")); putValue(SMALL_ICON, new ImageIcon (Utilities.loadImage( 57 "org/netbeans/modules/tasklist/usertasks/" + "actions/pause.gif"))); StartedUserTask.getInstance().addChangeListener(this); 60 stateChanged(null); 61 } 62 63 public void stateChanged(ChangeEvent e) { 64 setEnabled(StartedUserTask.getInstance().getStarted() != null); 65 } 66 67 public void actionPerformed(ActionEvent e) { 68 StartedUserTask.getInstance().start(null); 69 } 70 } 71 | Popular Tags |