/** * This method is called via AJAX to obtain the context menu for this model object. */ public ContextMenu doContextMenu(StaplerRequest request, StaplerResponse response) throws Exception { if (false) { // this implementation is suffice for most ModelObjects. It uses sidepanel.jelly/.groovy to // generate the context menu return new ContextMenu().from(this,request,response); } else { // otherwise you can also programatically create them. // see the javadoc for various convenience methods to add items return new ContextMenu() .add("http://jenkins-ci.org/","Jenkins project") .add("http://www.cloudbees.com/","CloudBees") .add(new MenuItem().withContextRelativeUrl("/").withStockIcon("gear.png").withDisplayName("top page")); } }
/** * This method is called via AJAX to obtain the context menu for this model object. */ public ContextMenu doContextMenu(StaplerRequest request, StaplerResponse response) throws Exception { if (false) { // this implementation is suffice for most ModelObjects. It uses sidepanel.jelly/.groovy to // generate the context menu return new ContextMenu().from(this,request,response); } else { // otherwise you can also programatically create them. // see the javadoc for various convenience methods to add items return new ContextMenu() .add("http://jenkins-ci.org/","Jenkins project") .add("http://www.cloudbees.com/","CloudBees") .add(new MenuItem().withContextRelativeUrl("/").withStockIcon("gear.png").withDisplayName("top page")); } }
/** * Adds a node * * @since 1.513 */ public ContextMenu add(Node n) { Computer c = n.toComputer(); return add(new MenuItem() .withDisplayName(n.getDisplayName()) .withStockIcon((c==null) ? "computer.png" : c.getIcon()) .withContextRelativeUrl(n.getSearchUrl())); }
/** * Adds a computer * * @since 1.513 */ public ContextMenu add(Computer c) { return add(new MenuItem() .withDisplayName(c.getDisplayName()) .withStockIcon(c.getIcon()) .withContextRelativeUrl(c.getUrl())); }
public ContextMenu doChildrenContextMenu(StaplerRequest request, StaplerResponse response) throws Exception { ContextMenu menu = new ContextMenu(); for (View view : getViews()) { menu.add(new MenuItem().withContextRelativeUrl(view.getUrl()).withDisplayName(view.getDisplayName())); } return menu; }
/** * Adds a computer * * @since 1.513 */ public ContextMenu add(Computer c) { return add(new MenuItem() .withDisplayName(c.getDisplayName()) .withStockIcon(c.getIcon()) .withContextRelativeUrl(c.getUrl())); }
/** * Adds a node * * @since 1.513 */ public ContextMenu add(Node n) { Computer c = n.toComputer(); return add(new MenuItem() .withDisplayName(n.getDisplayName()) .withStockIcon((c==null) ? "computer.png" : c.getIcon()) .withContextRelativeUrl(n.getSearchUrl())); }