1 19 20 package org.netbeans.modules.xml.core.actions; 21 22 import java.util.Iterator ; 23 import org.netbeans.modules.xml.core.cookies.UpdateDocumentCookie; 24 import org.openide.nodes.Node; 25 import org.openide.util.HelpCtx; 26 import org.openide.util.Lookup; 27 import org.openide.util.RequestProcessor; 28 import org.openide.util.actions.CookieAction; 29 30 35 public final class XMLUpdateDocumentAction extends CookieAction { 36 37 38 private static final long serialVersionUID = -235822666875674523L; 39 40 41 protected int mode() { 42 return MODE_ALL; 43 } 44 45 49 public String getName () { 50 return Util.THIS.getString ("PROP_UpdateDocument"); 51 } 52 53 protected Class [] cookieClasses () { 54 return new Class [] { UpdateDocumentCookie.class }; 55 } 56 57 60 public HelpCtx getHelpCtx () { 61 return new HelpCtx (XMLUpdateDocumentAction.class); 62 } 63 64 protected void performAction (final Node[] activatedNodes) { 66 67 Lookup lookup = Lookup.getDefault(); 68 Lookup.Template template = new Lookup.Template(Performer.class); 69 final Lookup.Result result = lookup.lookup(template); 70 71 RequestProcessor.getDefault().postRequest(new Runnable () { 72 public void run() { 73 for (int i = 0; i < activatedNodes.length; i++) { 74 UpdateDocumentCookie rc = (UpdateDocumentCookie)activatedNodes[i].getCookie 75 (UpdateDocumentCookie.class); 76 if (rc != null) { 77 rc.updateDocumentRoot(); 78 } 79 80 83 Iterator it = result.allInstances().iterator(); 85 while (it.hasNext()) { 86 Performer next = (Performer) it.next(); 87 next.perform(activatedNodes[i]); 88 } 89 } 90 } 91 }); 92 } 93 94 protected boolean asynchronous() { 95 return false; 96 } 97 98 102 public static interface Performer { 103 104 108 void perform(Node node); 109 } 110 } 111 | Popular Tags |