1 19 20 package org.netbeans.modules.xml.xam.ui.actions; 21 22 import org.netbeans.modules.xml.xam.Component; 23 import org.netbeans.modules.xml.xam.ui.XAMUtils; 24 import org.netbeans.modules.xml.xam.ui.cookies.GetComponentCookie; 25 import org.netbeans.modules.xml.xam.ui.cookies.ViewComponentCookie; 26 import org.openide.nodes.Node; 27 import org.openide.util.actions.CookieAction; 28 29 35 public abstract class AbstractShowComponentAction extends CookieAction { 36 37 private static final long serialVersionUID = 1L; 38 39 42 public AbstractShowComponentAction() { 43 super(); 44 } 45 46 protected boolean asynchronous() { 47 return false; 48 } 49 50 protected final boolean enable(Node[] nodes) { 51 return nodes != null && super.enable(nodes) && 52 XAMUtils.getViewCookie(XAMUtils.getComponent( 53 nodes[0]), getView()) != null; 54 } 55 56 protected void performAction(Node[] nodes) { 57 Component comp = XAMUtils.getComponent(nodes[0]); 58 ViewComponentCookie.View view = getView(); 59 ViewComponentCookie cookie = XAMUtils.getViewCookie(comp, view); 60 if (cookie != null) { 61 cookie.view(view, comp); 62 } 63 } 64 65 70 protected abstract ViewComponentCookie.View getView(); 71 72 protected int mode() { 73 return MODE_EXACTLY_ONE; 74 } 75 76 protected Class [] cookieClasses() { 77 return new Class []{ 78 GetComponentCookie.class, 79 Component.class 80 }; 81 } 82 } 83 | Popular Tags |