1 19 20 package org.netbeans.modules.form.actions; 21 22 import org.openide.util.HelpCtx; 23 import org.openide.util.actions.*; 24 import org.openide.nodes.*; 25 import org.netbeans.modules.form.*; 26 27 31 32 public class CustomizeLayoutAction extends CookieAction { 33 34 private static String name; 35 36 38 protected int mode() { 39 return MODE_EXACTLY_ONE; 40 } 41 42 46 protected Class [] cookieClasses() { 47 return new Class [] { RADComponentCookie.class }; 48 } 49 50 protected boolean asynchronous() { 51 return false; 52 } 53 54 58 public String getName() { 59 if (name == null) 60 name = org.openide.util.NbBundle.getBundle(CustomizeLayoutAction.class) 61 .getString("ACT_CustomizeLayout"); return name; 63 } 64 65 68 public HelpCtx getHelpCtx() { 69 return HelpCtx.DEFAULT_HELP; 70 } 71 72 77 protected void performAction(Node[] activatedNodes) { 78 RADComponentCookie radCookie = (RADComponentCookie) 79 activatedNodes[0].getCookie(RADComponentCookie.class); 80 if (radCookie != null) { 81 RADComponent metacomp = radCookie.getRADComponent(); 82 if (metacomp instanceof RADVisualContainer) { 83 Node layoutNode = ((RADVisualContainer)metacomp) 84 .getLayoutNodeReference(); 85 if (layoutNode != null && layoutNode.hasCustomizer()) 86 NodeOperation.getDefault().customize(layoutNode); 87 } 88 } 89 } 90 91 96 protected boolean enable(Node[] activatedNodes) { 97 if (super.enable(activatedNodes)) { 98 RADComponentCookie radCookie = (RADComponentCookie) 99 activatedNodes[0].getCookie(RADComponentCookie.class); 100 if (radCookie != null) { 101 RADComponent metacomp = radCookie.getRADComponent(); 102 if (metacomp instanceof RADVisualContainer) { 103 Node layoutNode = ((RADVisualContainer)metacomp) 104 .getLayoutNodeReference(); 105 return layoutNode != null && layoutNode.hasCustomizer(); 106 } 107 } 108 } 109 return false; 110 } 111 } 112 | Popular Tags |