Refine search
public ListBoxModel doFillTriggerOpenMergeRequestOnPushItems(@QueryParameter String triggerOpenMergeRequestOnPush) { return new ListBoxModel(new Option("Never", "never", triggerOpenMergeRequestOnPush.matches("never")), new Option("On push to source branch", "source", triggerOpenMergeRequestOnPush.matches("source")), new Option("On push to source or target branch", "both", triggerOpenMergeRequestOnPush.matches("both"))); }
/** * Fill the dropdown for notification levels. * * @return the values. */ public ListBoxModel doFillNotificationLevelItems() { Map<Notify, String> levelTextsById = notificationLevelTextsById(); ListBoxModel items = new ListBoxModel(levelTextsById.size()); for (Entry<Notify, String> level : levelTextsById.entrySet()) { items.add(new Option(level.getValue(), level.getKey().toString())); } return items; } }
/** * For UI. */ @SuppressWarnings({"UnusedDeclaration", "JavaDoc"}) public void doComputerNameValues(StaplerRequest req, StaplerResponse resp, @QueryParameter("hostName") String hostName) throws IOException, ServletException { ListBoxModel m = new ListBoxModel(); List<VirtualBoxMachine> virtualMachines = getDefinedVirtualMachines(hostName); if (virtualMachines != null && virtualMachines.size() > 0) { for (VirtualBoxMachine vm : virtualMachines) { m.add(new ListBoxModel.Option(vm.getName(), vm.getName())); } m.get(0).selected = true; } m.writeTo(req, resp); }
/** * Adds an "empty" credential to signify selection of no credential. * * @return {@code this} for method chaining. * @since 2.1.0 */ @NonNull public AbstractIdCredentialsListBoxModel<T, C> includeEmptyValue() { for (Option a : this) { if (StringUtils.equals("", a.value)) { return this; } } add(0, new Option(Messages.AbstractIdCredentialsListBoxModel_EmptySelection(), "")); return this; }
/** * Adds an "empty" credential to signify selection of no credential. * * @return {@code this} for method chaining. * @since 2.1.0 */ @NonNull public AbstractIdCredentialsListBoxModel<T, C> includeEmptyValue() { for (Option a : this) { if (StringUtils.equals("", a.value)) { return this; } } add(0, new Option(Messages.AbstractIdCredentialsListBoxModel_EmptySelection(), "")); return this; }
public static ListBoxModel fillAuthenticationItems(Item project, String url) { if (project == null || !project.hasPermission(Item.CONFIGURE)) { return new StandardListBoxModel(); } List<Option> options = new ArrayList<>(); for (BasicDigestAuthentication basic : HttpRequestGlobalConfig.get().getBasicDigestAuthentications()) { options.add(new Option("(deprecated - use Jenkins Credentials) " + basic.getKeyName(), basic.getKeyName())); } for (FormAuthentication formAuthentication : HttpRequestGlobalConfig.get().getFormAuthentications()) { options.add(new Option(formAuthentication.getKeyName())); } AbstractIdCredentialsListBoxModel<StandardListBoxModel, StandardCredentials> items = new StandardListBoxModel() .includeEmptyValue() .includeAs(ACL.SYSTEM, project, StandardUsernamePasswordCredentials.class, URIRequirementBuilder.fromUri(url).build()); items.addMissing(options); return items; }
/** * Ensures that the current value is present so that the form can be idempotently saved in those cases where the * user saving the form cannot view the current credential * * @param value the current value. * @return {@code this} for method chaining. * @since 2.1.0 */ public AbstractIdCredentialsListBoxModel<T, C> includeCurrentValue(@NonNull String value) { if (StringUtils.isEmpty(value)) { return includeEmptyValue(); } for (Option a : this) { if (StringUtils.equals(value, a.value)) { return this; } } // the current should be the first (unless the first is the empty selection int index = isEmpty() ? 0 : "".equals(get(0).value) ? 1 : 0; add(index, new Option(Messages.AbstractIdCredentialsListBoxModel_CurrentSelection(), value)); return this; }
/** * Ensures that the current value is present so that the form can be idempotently saved in those cases where the * user saving the form cannot view the current credential * * @param value the current value. * @return {@code this} for method chaining. * @since 2.1.0 */ public AbstractIdCredentialsListBoxModel<T, C> includeCurrentValue(@NonNull String value) { if (StringUtils.isEmpty(value)) { return includeEmptyValue(); } for (Option a : this) { if (StringUtils.equals(value, a.value)) { return this; } } // the current should be the first (unless the first is the empty selection int index = isEmpty() ? 0 : "".equals(get(0).value) ? 1 : 0; add(index, new Option(Messages.AbstractIdCredentialsListBoxModel_CurrentSelection(), value)); return this; }
return new Option(Messages.NotificationLevel_DefaultValue(), ""); } else if (serverName != null) { GerritServer server = PluginImpl.getServer_(serverName); levelText = level.toString(); return new Option(Messages.NotificationLevel_DefaultValueFromServer(levelText), ""); return new Option(Messages.NotificationLevel_DefaultValueFromServer(defaultText), "");
/** * Fill the dropdown for notification levels. * @param serverName the server name. * @return the values. */ public ListBoxModel doFillNotificationLevelItems(@QueryParameter("serverName") final String serverName) { Map<Notify, String> levelTextsById = GerritServer.notificationLevelTextsById(); ListBoxModel items = new ListBoxModel(levelTextsById.size() + 1); items.add(getOptionForNotificationLevelDefault(serverName, levelTextsById)); for (Entry<Notify, String> level : levelTextsById.entrySet()) { items.add(new Option(level.getValue(), level.getKey().toString())); } return items; }
public ListBoxModel doFillGitHubAuthIdItems(@QueryParameter("gitHubAuthId") String gitHubAuthId) { ListBoxModel model = new ListBoxModel(); for (GhprbGitHubAuth auth : getGithubAuth()) { String description = Util.fixNull(auth.getDescription()); int length = description.length(); length = length > MAX_DESCRIPTION_LENGTH ? MAX_DESCRIPTION_LENGTH : length; Option next = new Option(auth.getServerAPIUrl() + " : " + description.substring(0, length), auth.getId()); if (!StringUtils.isEmpty(gitHubAuthId) && gitHubAuthId.equals(auth.getId())) { next.selected = true; } model.add(next); } return model; }
public ListBoxModel doFillVpceServiceNameItems(@QueryParameter String currentVpceServiceName) { List<ListBoxModel.Option> entries = new ArrayList<ListBoxModel.Option>(); // Create ListBoxModel for all VPCE configs for this AWS Device Farm account. try { System.out.print("Getting VPCE configs"); List<String> vpceServiceNames = getAWSDeviceFarmVpceConfigurations(); System.out.print(String.format("VPCE configs length = %d", vpceServiceNames.size())); for (String vpceServiceName : vpceServiceNames) { entries.add(new ListBoxModel.Option(vpceServiceName, vpceServiceName, vpceServiceName.equals(currentVpceServiceName))); } } catch (ServiceAccountException e) { System.out.println("Account does not have a VPC configured or has not been whitelisted for VPC. Note: VPC is a private device only feature"); } return new ListBoxModel(entries); }
public ListBoxModel doFillUpdateModeItems(@QueryParameter String updateMode) { ListBoxModel items = new ListBoxModel(); for (UpdateModeValue updateModeValue : UpdateModeValue.values()) { items.add(new ListBoxModel.Option(updateModeValue.getDisplayName(), updateModeValue.getMode(), updateModeValue.getMode().equals(updateMode))); } return items; }
/** * Populate the project drop-down Appium Version. * * @return The ListBoxModel for the UI. */ @SuppressWarnings("unused") public ListBoxModel doFillAppiumVersionJunitItems(@QueryParameter String currentAppiumVersion) { List<ListBoxModel.Option> entries = new ArrayList<ListBoxModel.Option>(); ArrayList<String> appiumVersions = new ArrayList<String>(); appiumVersions.add(APPIUM_VERSION_1_4_16); appiumVersions.add(APPIUM_VERSION_1_6_3); appiumVersions.add(APPIUM_VERSION_1_6_5); appiumVersions.add(APPIUM_VERSION_1_7_1); appiumVersions.add(APPIUM_VERSION_1_7_2); appiumVersions.add(APPIUM_VERSION_1_9_1); for (String appiumVersion: appiumVersions) { entries.add(new ListBoxModel.Option(appiumVersion, appiumVersion, appiumVersion.equals(currentAppiumVersion))); } return new ListBoxModel(entries); }
public ListBoxModel doFillUpdateModeItems(@QueryParameter String updateMode) { ListBoxModel items = new ListBoxModel(); for (UpdateModeValue updateModeValue : UpdateModeValue.values()) { items.add(new ListBoxModel.Option(updateModeValue.getDisplayName(), updateModeValue.getMode(), updateModeValue.getMode().equals(updateMode))); } return items; }
/** * Populate the project drop-down Appium Version. * * @return The ListBoxModel for the UI. */ @SuppressWarnings("unused") public ListBoxModel doFillAppiumVersionTestngItems(@QueryParameter String currentAppiumVersion) { List<ListBoxModel.Option> entries = new ArrayList<ListBoxModel.Option>(); ArrayList<String> appiumVersions = new ArrayList<String>(); appiumVersions.add(APPIUM_VERSION_1_4_16); appiumVersions.add(APPIUM_VERSION_1_6_3); appiumVersions.add(APPIUM_VERSION_1_6_5); appiumVersions.add(APPIUM_VERSION_1_7_1); appiumVersions.add(APPIUM_VERSION_1_7_2); appiumVersions.add(APPIUM_VERSION_1_9_1); for (String appiumVersion: appiumVersions) { // We don't ignore case because these *should* be unique. entries.add(new ListBoxModel.Option(appiumVersion, appiumVersion, appiumVersion.equals(currentAppiumVersion))); } return new ListBoxModel(entries); }