1 19 20 package org.netbeans.modules.xml.tools.actions; 21 22 import org.netbeans.api.xml.cookies.ValidateXMLCookie; 23 import org.netbeans.modules.xml.core.actions.CollectXMLAction; 24 import org.netbeans.modules.xml.core.actions.InputOutputReporter; 25 import org.openide.nodes.Node; 26 import org.openide.util.HelpCtx; 27 import org.openide.util.RequestProcessor; 28 import org.openide.util.actions.CookieAction; 29 30 35 public class ValidateAction extends CookieAction implements CollectXMLAction.XMLAction { 36 37 38 private static final long serialVersionUID = -8772119268950444993L; 39 40 41 42 protected Class [] cookieClasses () { 43 return new Class [] { ValidateXMLCookie.class }; 44 } 45 46 47 protected int mode () { 48 return MODE_ALL; 49 } 50 51 52 protected void performAction (Node[] nodes) { 53 54 if (nodes == null) return; 55 56 RequestProcessor.getDefault().post( 57 new ValidateAction.RunAction (nodes) 58 ); 59 } 60 61 62 public String getName() { 63 return Util.THIS.getString("NAME_Validate_XML"); 64 } 65 66 protected String iconResource () { 67 return "org/netbeans/modules/xml/tools/resources/validate_xml.png"; } 69 70 71 public HelpCtx getHelpCtx () { 72 return new HelpCtx (ValidateAction.class); 73 } 74 75 protected boolean asynchronous() { 76 return false; 77 } 78 79 private class RunAction implements Runnable { 80 private Node[] nodes; 81 82 RunAction (Node[] nodes){ 83 this.nodes = nodes; 84 } 85 86 public void run() { 87 InputOutputReporter console = new InputOutputReporter(); 88 console.message(Util.THIS.getString("MSG_XML_valid_start")); 89 console.moveToFront(); 90 for (int i = 0; i<nodes.length; i++) { 91 Node node = nodes[i]; 92 ValidateXMLCookie cake = (ValidateXMLCookie) node.getCookie(ValidateXMLCookie.class); 93 if (cake == null) continue; 94 console.setNode(node); cake.validateXML(console); 96 } 97 98 console.message(Util.THIS.getString("MSG_XML_valid_end")); 99 console.moveToFront(true); 100 } 101 } 102 } 103 | Popular Tags |