public ContextMenu add(String url, String text) { items.add(new MenuItem(url,null,text)); return this; }
ContextMenu result = new ContextMenu(); if (getStore().hasPermission(CREATE)) { result.add(new MenuItem( ContextMenuIconUtils.buildUrl(prefix, "newCredentials"), getMenuItemIconUrlByClassSpec("icon-credentials-new-credential icon-md"), result.add(new MenuItem(ContextMenuIconUtils.buildUrl(prefix, "configure"), getMenuItemIconUrlByClassSpec("icon-setting icon-md"), Messages.CredentialsStoreAction_ConfigureDomainAction() )); result.add(new MenuItem(ContextMenuIconUtils.buildUrl(prefix, "delete"), getMenuItemIconUrlByClassSpec("icon-edit-delete icon-md"), Messages.CredentialsStoreAction_DeleteDomainAction()
ContextMenu result = new ContextMenu(); if (getStore().hasPermission(UPDATE)) { result.add(new MenuItem( ContextMenuIconUtils.buildUrl(prefix, "update"), getMenuItemIconUrlByClassSpec("icon-setting icon-md"), result.add(new MenuItem(ContextMenuIconUtils.buildUrl(prefix, "delete"), getMenuItemIconUrlByClassSpec("icon-edit-delete icon-md"), Messages.CredentialsStoreAction_DeleteCredentialAction() )); result.add(new MenuItem(ContextMenuIconUtils.buildUrl(prefix, "move"), getMenuItemIconUrlByClassSpec("icon-credentials-move icon-md"), Messages.CredentialsStoreAction_MoveCredentialAction()
ContextMenu result = new ContextMenu(); if (getStore().hasPermission(UPDATE)) { result.add(new MenuItem( ContextMenuIconUtils.buildUrl(prefix, "update"), getMenuItemIconUrlByClassSpec("icon-setting icon-md"), result.add(new MenuItem(ContextMenuIconUtils.buildUrl(prefix, "delete"), getMenuItemIconUrlByClassSpec("icon-edit-delete icon-md"), Messages.CredentialsStoreAction_DeleteCredentialAction() )); result.add(new MenuItem(ContextMenuIconUtils.buildUrl(prefix, "move"), getMenuItemIconUrlByClassSpec("icon-credentials-move icon-md"), Messages.CredentialsStoreAction_MoveCredentialAction()
ContextMenu result = new ContextMenu(); if (getStore().hasPermission(CREATE)) { result.add(new MenuItem( ContextMenuIconUtils.buildUrl(prefix, "newCredentials"), getMenuItemIconUrlByClassSpec("icon-credentials-new-credential icon-md"), result.add(new MenuItem(ContextMenuIconUtils.buildUrl(prefix, "configure"), getMenuItemIconUrlByClassSpec("icon-setting icon-md"), Messages.CredentialsStoreAction_ConfigureDomainAction() )); result.add(new MenuItem(ContextMenuIconUtils.buildUrl(prefix, "delete"), getMenuItemIconUrlByClassSpec("icon-edit-delete icon-md"), Messages.CredentialsStoreAction_DeleteDomainAction()
/** * Helper method to produce the breadcrumb context menu. * * @param context the url prefix to put on all urls. * @return the selectable reports. * @see #doChildrenContextMenu(StaplerRequest, StaplerResponse) * @see com.sonyericsson.hudson.plugins.gerrit.trigger.GerritManagement#doContextMenu(StaplerRequest, StaplerResponse) */ @Restricted(NoExternalUse.class) public ContextMenu getContextMenu(String context) { ContextMenu menu = new ContextMenu(); String url = makeRelativeUrl(context, "buildMemory"); menu.add(new MenuItem() .withUrl(url) .withStockIcon("clipboard.png") .withDisplayName(Messages.BuildMemoryReport_DisplayName())); url = makeRelativeUrl(context, "eventListeners"); menu.add(new MenuItem() .withUrl(url) .withStockIcon("clipboard.png") .withDisplayName(Messages.EventListenersReport_DisplayName())); if (isDebugMode()) { menu.add("triggerDebugEvent", "warning.png", "Trigger Debug", false, true); } return menu; }
/** * Creates the children context menu with the supplied prefix to all URLs. * * @param prefix the prefix to prepend to relative urls. * @return the {@link ContextMenu} or {@code null} * @since 2.0 */ @CheckForNull public ContextMenu getChildrenContextMenu(String prefix) { ContextMenu menu = new ContextMenu(); for (Map.Entry<String, CredentialsWrapper> entry : getCredentials().entrySet()) { String p = ContextMenuIconUtils.buildUrl(prefix, "credential", entry.getKey()); MenuItem item = new MenuItem(p, getMenuItemIconUrlByClassSpec(entry.getValue().getIconClassName() + " icon-md"), entry.getValue().getDisplayName() ); item.subMenu = entry.getValue().getContextMenu(p); menu.add(item); } return menu.items.isEmpty() ? null : menu; }
/** * Creates the children context menu with the supplied prefix to all URLs. * * @param prefix the prefix to prepend to relative urls. * @return the {@link ContextMenu} or {@code null} * @since 2.0 */ @CheckForNull public ContextMenu getChildrenContextMenu(String prefix) { ContextMenu menu = new ContextMenu(); for (Domain d : getStore().getDomains()) { MenuItem item = new MenuItem(d.getUrl(), getMenuItemIconUrlByClassSpec("icon-credentials-domain icon-md"), d.isGlobal() ? Messages.CredentialsStoreAction_GlobalDomainDisplayName() : d.getName() ); item.subMenu = new DomainWrapper(this, d).getContextMenu(ContextMenuIconUtils.buildUrl(prefix, d.getUrl())); menu.add(item); } return menu.items.isEmpty() ? null : menu; }
/** * Adds a menu item for the specified action with the supplied prefix offset and optional sub menu. * * @param menu the menu to add to. * @param prefix the prefix offset of the action urls. * @param action the action. * @param subMenu the sub menu. */ public static void addMenuItem(@NonNull ModelObjectWithContextMenu.ContextMenu menu, @CheckForNull String prefix, @NonNull Action action, @CheckForNull ModelObjectWithContextMenu.ContextMenu subMenu) { if (isContextMenuVisible(action) && action.getIconFileName() != null) { Icon icon = action instanceof IconSpec ? ContextMenuIconUtils.getIcon(action) : null; String base = icon != null ? ContextMenuIconUtils.getQualifiedUrl(icon) : Functions.getIconFilePath(action); ModelObjectWithContextMenu.MenuItem item = new ModelObjectWithContextMenu.MenuItem( ContextMenuIconUtils.buildUrl(prefix, action.getUrlName()), ContextMenuIconUtils.getMenuItemIconUrl(base), action.getDisplayName() ); item.subMenu = subMenu; menu.add(item); } } /** TODO copied from {@link Functions} but currently restricted */
/** * Adds a menu item for the specified action with the supplied prefix offset and optional sub menu. * * @param menu the menu to add to. * @param prefix the prefix offset of the action urls. * @param action the action. * @param subMenu the sub menu. */ public static void addMenuItem(@NonNull ModelObjectWithContextMenu.ContextMenu menu, @CheckForNull String prefix, @NonNull Action action, @CheckForNull ModelObjectWithContextMenu.ContextMenu subMenu) { if (isContextMenuVisible(action) && action.getIconFileName() != null) { Icon icon = action instanceof IconSpec ? ContextMenuIconUtils.getIcon(action) : null; String base = icon != null ? ContextMenuIconUtils.getQualifiedUrl(icon) : Functions.getIconFilePath(action); ModelObjectWithContextMenu.MenuItem item = new ModelObjectWithContextMenu.MenuItem( ContextMenuIconUtils.buildUrl(prefix, action.getUrlName()), ContextMenuIconUtils.getMenuItemIconUrl(base), action.getDisplayName() ); item.subMenu = subMenu; menu.add(item); } } /** TODO copied from {@link Functions} but currently restricted */
/** * Creates the children context menu with the supplied prefix to all URLs. * * @param prefix the prefix to prepend to relative urls. * @return the {@link ContextMenu} or {@code null} * @since 2.0 */ @CheckForNull public ContextMenu getChildrenContextMenu(String prefix) { ContextMenu menu = new ContextMenu(); for (Map.Entry<String, CredentialsWrapper> entry : getCredentials().entrySet()) { String p = ContextMenuIconUtils.buildUrl(prefix, "credential", entry.getKey()); MenuItem item = new MenuItem(p, getMenuItemIconUrlByClassSpec(entry.getValue().getIconClassName() + " icon-md"), entry.getValue().getDisplayName() ); item.subMenu = entry.getValue().getContextMenu(p); menu.add(item); } return menu.items.isEmpty() ? null : menu; }
/** * Creates the children context menu with the supplied prefix to all URLs. * * @param prefix the prefix to prepend to relative urls. * @return the {@link ContextMenu} or {@code null} * @since 2.0 */ @CheckForNull public ContextMenu getChildrenContextMenu(String prefix) { ContextMenu menu = new ContextMenu(); for (Domain d : getStore().getDomains()) { MenuItem item = new MenuItem(d.getUrl(), getMenuItemIconUrlByClassSpec("icon-credentials-domain icon-md"), d.isGlobal() ? Messages.CredentialsStoreAction_GlobalDomainDisplayName() : d.getName() ); item.subMenu = new DomainWrapper(this, d).getContextMenu(ContextMenuIconUtils.buildUrl(prefix, d.getUrl())); menu.add(item); } return menu.items.isEmpty() ? null : menu; }
/** * 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")); } }
@Override public ContextMenu doContextMenu(StaplerRequest request, StaplerResponse response) throws Exception { checkPermission(); Jenkins jenkins = Jenkins.getInstance(); assert jenkins != null; ContextMenu menu = new ContextMenu(); menu.add("newServer", Functions.joinPath(jenkins.getRootUrl(), Functions.getResourcePath(), "images", "24x24", "new-package.png"), Messages.AddNewServer()); for (GerritServer server : getServers()) { menu.add(server); } MenuItem item = new MenuItem() .withUrl("diagnostics") .withDisplayName(DIAGNOSTICS) .withStockIcon("folder.png"); item.subMenu = DIAGNOSTICS.getContextMenu("diagnostics"); menu.add(item); return menu; }
/** * 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")); } }
public MenuItem withIcon(BallColor color) { return withStockIcon(color.getImage()); }
public MenuItem(String url, String icon, String displayName) { withUrl(url).withIcon(icon).withDisplayName(displayName); }
public ContextMenu add(String url, String text) { items.add(new MenuItem(url,null,text)); return this; }
public MenuItem withDisplayName(ModelObject o) { return withDisplayName(o.getDisplayName()); } }
/** @since 1.512 */ public ContextMenu add(String url, String icon, String text, boolean post, boolean requiresConfirmation) { if (text != null && icon != null && url != null) { MenuItem item = new MenuItem(url,icon,text); item.post = post; item.requiresConfirmation = requiresConfirmation; items.add(item); } return this; }