1 19 20 package org.netbeans.modules.tasklist.pmd; 21 22 import java.awt.Component ; 23 import java.awt.Dialog ; 24 import org.openide.DialogDescriptor; 25 import org.openide.DialogDisplayer; 26 import org.openide.NotifyDescriptor; 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 32 import org.openide.explorer.propertysheet.*; 33 import org.netbeans.modules.tasklist.client.Suggestion; 34 35 import pmd.config.PMDOptionsSettings; 36 import pmd.config.ui.RuleEditor; 37 38 44 45 public class EditRulesAction extends NodeAction { 46 47 private static final long serialVersionUID = 1; 48 49 protected boolean asynchronous() { 50 return false; 51 } 52 53 protected boolean enable(Node[] node) { 54 if ((node == null) || (node.length != 1)) { 55 return false; 56 } 57 Suggestion s = (Suggestion)node[0].getCookie(Suggestion.class); 58 if (s == null) { 59 return false; 60 } 61 return true; 62 } 63 64 protected void performAction(Node[] node) { 65 PMDOptionsSettings settings = PMDOptionsSettings.getDefault(); 66 String rules = settings.getRules(); 67 RuleEditor editor = new RuleEditor(); 68 editor.setValue(rules); 69 Component customizer = editor.getCustomEditor(); 70 71 DialogDescriptor d = new DialogDescriptor(customizer, 72 NbBundle.getMessage(EditRulesAction.class, 73 "TITLE_editRules")); d.setModal(true); 75 d.setMessageType(NotifyDescriptor.PLAIN_MESSAGE); 76 d.setOptionType(NotifyDescriptor.OK_CANCEL_OPTION); 77 Dialog dlg = DialogDisplayer.getDefault().createDialog(d); 78 dlg.pack(); 79 dlg.show(); 80 if (d.getValue() == NotifyDescriptor.OK_OPTION) { 81 Object value = editor.getValue(); 82 settings.setRules(value.toString()); 83 Suggestion s = (Suggestion)node[0].getCookie(Suggestion.class); 84 if (s != null) { 85 Object seed = s.getSeed(); 86 if (seed instanceof ViolationProvider) { 87 } 90 } 91 } 92 } 93 94 public String getName() { 95 return NbBundle.getMessage(EditRulesAction.class, 96 "EditRules"); } 98 99 104 105 public HelpCtx getHelpCtx() { 106 return HelpCtx.DEFAULT_HELP; 107 } 110 111 } 112 | Popular Tags |