1 19 package org.netbeans.modules.xml.tools.actions; 20 21 import java.util.*; 22 23 import org.openide.*; 24 import org.openide.nodes.*; 25 import org.openide.util.HelpCtx; 26 import org.openide.util.actions.CookieAction; 27 import org.openide.loaders.*; 28 29 import org.netbeans.tax.*; 30 import org.netbeans.modules.xml.core.*; 31 import org.netbeans.modules.xml.core.actions.*; 32 33 import org.netbeans.api.xml.cookies.*; 34 import org.openide.util.RequestProcessor; 35 36 42 public class CheckAction extends CookieAction implements CollectXMLAction.XMLAction { 43 44 45 private static final long serialVersionUID = -4617456591768900199L; 46 47 48 protected Class [] cookieClasses () { 49 return new Class [] { CheckXMLCookie.class }; 50 } 51 52 53 protected int mode () { 54 return MODE_ALL; 55 } 56 57 58 protected void performAction (Node[] nodes) { 59 60 if (nodes == null) return; 61 62 RequestProcessor.postRequest( 63 new CheckAction.RunAction (nodes)); 64 } 65 66 67 public String getName() { 68 return Util.THIS.getString("NAME_Check_XML"); 69 } 70 71 72 protected String iconResource () { 73 return "org/netbeans/modules/xml/tools/resources/check_xml.png"; } 75 76 77 public HelpCtx getHelpCtx () { 78 return new HelpCtx (CheckAction.class); 79 } 80 81 protected boolean asynchronous() { 82 return false; 83 } 84 85 private class RunAction implements Runnable { 86 private Node[] nodes; 87 88 RunAction (Node[] nodes){ 89 this.nodes = nodes; 90 } 91 92 public void run() { 93 InputOutputReporter console = new InputOutputReporter(); 94 console.message(Util.THIS.getString("MSG_XML_check_start")); 95 console.moveToFront(); 96 for (int i = 0; i<nodes.length; i++) { 97 Node node = nodes[i]; 98 CheckXMLCookie cake = (CheckXMLCookie) node.getCookie(CheckXMLCookie.class); 99 if (cake == null) continue; 100 console.setNode(node); cake.checkXML(console); 102 } 103 104 console.message(Util.THIS.getString("MSG_XML_check_end")); 105 console.moveToFront(true); 106 } 107 } 108 } 109 | Popular Tags |