1 19 20 package org.netbeans.modules.tasklist.suggestions.ui; 21 22 import java.util.Iterator ; 23 import java.util.HashSet ; 24 import org.netbeans.modules.tasklist.client.SuggestionManager; 25 import org.netbeans.modules.tasklist.core.TaskNode; 26 import org.netbeans.modules.tasklist.suggestions.*; 27 import org.openide.nodes.Node; 28 import org.openide.util.HelpCtx; 29 import org.openide.util.NbBundle; 30 import org.openide.util.actions.NodeAction; 31 import org.openide.DialogDisplayer; 32 import org.openide.NotifyDescriptor; 33 34 35 40 41 public final class DisableAction extends NodeAction { 42 43 private static final long serialVersionUID = 1; 44 45 protected boolean asynchronous() { 46 return false; 47 } 48 49 protected boolean enable(Node[] node) { 50 return true; 51 } 52 53 protected void performAction(Node[] node) { 54 if (node == null) { 55 return; 56 } 57 58 SuggestionManagerImpl manager = 60 (SuggestionManagerImpl)SuggestionManager.getDefault(); 61 62 HashSet set = new HashSet (10); 63 64 for (int i = 0; i < node.length; i++) { 66 SuggestionImpl s = (SuggestionImpl)TaskNode.getTask(node[i]); 67 SuggestionType type = s.getSType(); 68 String message = NbBundle.getMessage(DisableAction.class, 69 "ConfirmDisable", type.getLocalizedName()); String title = NbBundle.getMessage(DisableAction.class, 71 "ConfirmDisableTitle"); NotifyDescriptor desc = new NotifyDescriptor.Confirmation( 73 message, title, NotifyDescriptor.YES_NO_OPTION); 74 if (!NotifyDescriptor.YES_OPTION.equals( 75 DialogDisplayer.getDefault().notify(desc))) { 76 continue; 77 } 78 set.add(s.getSType()); 79 } 80 Iterator it = set.iterator(); 82 while (it.hasNext()) { 83 SuggestionType type = (SuggestionType)it.next(); 84 manager.setEnabled(type.getName(), false, false); 85 } 86 } 87 88 public String getName() { 89 return NbBundle.getMessage(DisableAction.class, "LBL_Disable"); } 91 92 protected String iconResource() { 93 return "org/netbeans/modules/tasklist/suggestions/disableAction.gif"; } 95 96 public HelpCtx getHelpCtx() { 97 return HelpCtx.DEFAULT_HELP; 98 } 101 102 } 103 | Popular Tags |