1 19 20 package org.netbeans.modules.tasklist.usertasks.actions; 21 22 import java.awt.event.ActionEvent ; 23 import java.util.Iterator ; 24 import javax.swing.event.ListSelectionEvent ; 25 26 import org.netbeans.modules.tasklist.usertasks.model.UserTask; 27 import org.netbeans.modules.tasklist.usertasks.UserTaskView; 28 import org.openide.DialogDisplayer; 29 import org.openide.NotifyDescriptor; 30 import org.openide.util.NbBundle; 31 32 37 public class ClearCompletedAction extends UTViewAction { 38 private static final long serialVersionUID = 2; 39 40 45 public ClearCompletedAction(UserTaskView utv) { 46 super(utv, NbBundle.getMessage(ClearCompletedAction.class, 47 "ClearCompleted")); } 49 50 56 private void clearCompleted(UserTask ut) { 57 if (!ut.isValuesComputed()) 58 ut.setDone(false); 59 Iterator it = ut.getSubtasks().iterator(); 60 while (it.hasNext()) { 61 clearCompleted((UserTask) it.next()); 62 } 63 } 64 65 public void actionPerformed(ActionEvent arg0) { 66 NotifyDescriptor nd = new NotifyDescriptor.Confirmation( 67 NbBundle.getMessage(PurgeTasksAction.class, "ClearCompletedQuestion"), NbBundle.getMessage(PurgeTasksAction.class, "ClearCompletedTitle"), NotifyDescriptor.OK_CANCEL_OPTION 70 ); 71 if (DialogDisplayer.getDefault().notify(nd) == NotifyDescriptor.OK_OPTION) { 72 clearCompleted(getSingleSelectedTask()); 73 85 } 86 } 87 88 public void valueChanged(ListSelectionEvent arg0) { 89 setEnabled(getSingleSelectedTask() != null); 91 } 92 } 93 | Popular Tags |