1 19 20 package org.netbeans.modules.form.actions; 21 22 import org.netbeans.modules.form.*; 23 import org.netbeans.modules.form.CodeCustomizer; 24 import org.openide.nodes.Node; 25 import org.openide.util.HelpCtx; 26 import org.openide.util.actions.NodeAction; 27 28 public class CustomCodeAction extends NodeAction { 29 30 protected void performAction(Node[] activatedNodes) { 31 RADComponent metacomp = getComponent(activatedNodes); 32 if (metacomp != null) 33 CodeCustomizer.show(metacomp); 34 } 35 36 protected boolean asynchronous() { 37 return false; 38 } 39 40 protected boolean enable(Node[] activatedNodes) { 41 return getComponent(activatedNodes) != null; 42 } 43 44 private static RADComponent getComponent(Node[] nodes) { 45 if (nodes != null && nodes.length == 1) { 46 RADComponentCookie radCookie = (RADComponentCookie) 47 nodes[0].getCookie(RADComponentCookie.class); 48 if (radCookie != null) { 49 RADComponent metacomp = radCookie.getRADComponent(); 50 if (metacomp != null && metacomp != metacomp.getFormModel().getTopRADComponent()) 51 return metacomp; 52 } 53 } 54 return null; 55 } 56 57 public String getName() { 58 return org.openide.util.NbBundle.getMessage(CustomCodeAction.class, "ACT_CustomCode"); } 60 61 public HelpCtx getHelpCtx() { 62 return HelpCtx.DEFAULT_HELP; } 64 65 } 66 | Popular Tags |