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 37 43 public class CheckDTDAction extends CookieAction implements CollectDTDAction.DTDAction { 44 45 46 private static final long serialVersionUID = -8772119268950444992L; 47 48 49 protected Class [] cookieClasses () { 50 return new Class [] { CheckXMLCookie.class }; 51 } 52 53 54 protected int mode () { 55 return MODE_ALL; 56 } 57 58 59 protected void performAction (Node[] nodes) { 60 61 if (nodes == null) return; 62 63 RequestProcessor.postRequest( 64 new CheckDTDAction.RunAction (nodes)); 65 66 } 67 68 protected boolean asynchronous() { 69 return false; 70 } 71 72 73 public String getName() { 74 return Util.THIS.getString("NAME_Validate_DTD"); 75 } 76 77 protected String iconResource () { 78 return "org/netbeans/modules/xml/tools/resources/checkDTDAction.gif"; } 80 81 82 public HelpCtx getHelpCtx () { 83 return new HelpCtx (CheckDTDAction.class); 84 } 85 86 private class RunAction implements Runnable { 87 private Node[] nodes; 88 89 RunAction (Node[] nodes){ 90 this.nodes = nodes; 91 } 92 93 public void run() { 94 InputOutputReporter console = new InputOutputReporter(); 95 96 console.message(Util.THIS.getString("MSG_DTD_valid_start")); 97 console.moveToFront(); 98 99 for (int i = 0; i<nodes.length; i++) { 100 Node node = nodes[i]; 101 CheckXMLCookie cake = (CheckXMLCookie) node.getCookie(CheckXMLCookie.class); 102 if (cake == null) continue; 103 console.setNode(node); cake.checkXML(console); 105 } 106 107 console.message(Util.THIS.getString("MSG_DTD_valid_end")); 108 console.moveToFront(true); 109 } 110 } 111 } 112 | Popular Tags |