本文整理汇总了Java中hudson.util.ListBoxModel.isEmpty方法的典型用法代码示例。如果您正苦于以下问题:Java ListBoxModel.isEmpty方法的具体用法?Java ListBoxModel.isEmpty怎么用?Java ListBoxModel.isEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hudson.util.ListBoxModel
的用法示例。
在下文中一共展示了ListBoxModel.isEmpty方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doFillCharsetItems
import hudson.util.ListBoxModel; //导入方法依赖的package包/类
static public ListBoxModel doFillCharsetItems() {
ListBoxModel list = new ListBoxModel();
try {
IOptionsServer p4 = ConnectionFactory.getConnection();
for (String set : p4.getKnownCharsets()) {
list.add(set);
}
} catch (Exception e) {
}
if (list.isEmpty()) {
list.add("none");
}
return list;
}
示例2: doFillRepositoryItems
import hudson.util.ListBoxModel; //导入方法依赖的package包/类
public ListBoxModel doFillRepositoryItems(@AncestorInPath SCMSourceOwner context,
@QueryParameter String serverUrl,
@QueryParameter String credentialsId,
@QueryParameter String repoOwner,
@QueryParameter String repository) throws IOException,
InterruptedException {
ListBoxModel result = new ListBoxModel();
if (context == null) {
if (!Jenkins.getActiveInstance().hasPermission(Jenkins.ADMINISTER)) {
// must have admin if you want the list without a context
result.add(repository);
return result;
}
} else {
if (!context.hasPermission(Item.EXTENDED_READ)
&& !context.hasPermission(CredentialsProvider.USE_ITEM)) {
// must be able to read the configuration or use the item credentials if you want the list
result.add(repository);
return result;
}
}
if (StringUtils.isBlank(repoOwner)) {
result.add(repository);
return result;
}
GiteaServer server = GiteaServers.get().findServer(serverUrl);
if (server == null) {
// you can only get the list for registered servers
result.add(repository);
return result;
}
StandardCredentials credentials = CredentialsMatchers.firstOrNull(
CredentialsProvider.lookupCredentials(
StandardCredentials.class,
context,
context instanceof Queue.Task ?
Tasks.getDefaultAuthenticationOf((Queue.Task) context)
: ACL.SYSTEM,
URIRequirementBuilder.fromUri(serverUrl).build()
),
CredentialsMatchers.allOf(
AuthenticationTokens.matcher(GiteaAuth.class),
CredentialsMatchers.withId(credentialsId)
)
);
try (GiteaConnection c = Gitea.server(serverUrl)
.as(AuthenticationTokens.convert(GiteaAuth.class, credentials))
.open()) {
for (GiteaRepository r : c.fetchRepositories(repoOwner)) {
result.add(r.getName());
}
return result;
} catch (IOException e) {
// TODO once enhanced <f:select> that can handle error responses, just throw
LOGGER.log(Level.FINE, "Could not populate repositories", e);
if (result.isEmpty()) {
result.add(repository);
}
return result;
}
}
示例3: getToolchainList
import hudson.util.ListBoxModel; //导入方法依赖的package包/类
/**
* Get a list of toolchains using given token and organization name.
* @param token
* @param orgName
* @return
*/
public static ListBoxModel getToolchainList(String token, String orgName, String environment, Boolean debug_mode) {
LOGGER.setLevel(Level.INFO);
if(debug_mode){
LOGGER.info("#######################");
LOGGER.info("TOKEN:" + token);
LOGGER.info("ORG:" + orgName);
LOGGER.info("ENVIRONMENT:" + environment);
}
String orgId = getOrgId(token, orgName, environment, debug_mode);
ListBoxModel emptybox = new ListBoxModel();
emptybox.add("","empty");
if(orgId == null) {
return emptybox;
}
CloseableHttpClient httpClient = HttpClients.createDefault();
String toolchains_url = chooseToolchainsUrl(environment);
if(debug_mode){
LOGGER.info("GET TOOLCHAIN LIST URL:" + toolchains_url + orgId);
}
HttpGet httpGet = new HttpGet(toolchains_url + orgId);
httpGet = addProxyInformation(httpGet);
httpGet.setHeader("Authorization", token);
CloseableHttpResponse response = null;
try {
response = httpClient.execute(httpGet);
String resStr = EntityUtils.toString(response.getEntity());
if(debug_mode){
LOGGER.info("RESPONSE FROM TOOLCHAINS API:" + response.getStatusLine().toString());
}
if (response.getStatusLine().toString().contains("200")) {
// get 200 response
JsonParser parser = new JsonParser();
JsonElement element = parser.parse(resStr);
JsonObject obj = element.getAsJsonObject();
JsonArray items = obj.getAsJsonArray("items");
ListBoxModel toolchainList = new ListBoxModel();
for (int i = 0; i < items.size(); i++) {
JsonObject toolchainObj = items.get(i).getAsJsonObject();
String toolchainName = String.valueOf(toolchainObj.get("name")).replaceAll("\"", "");
String toolchainID = String.valueOf(toolchainObj.get("toolchain_guid")).replaceAll("\"", "");
toolchainList.add(toolchainName,toolchainID);
}
if(debug_mode){
LOGGER.info("TOOLCHAIN LIST:" + toolchainList);
LOGGER.info("#######################");
}
if(toolchainList.isEmpty()) {
if(debug_mode){
LOGGER.info("RETURNED NO TOOLCHAINS.");
}
return emptybox;
}
return toolchainList;
} else {
LOGGER.info("RETURNED STATUS CODE OTHER THAN 200. RESPONSE: " + response.getStatusLine().toString());
return emptybox;
}
} catch (Exception e) {
e.printStackTrace();
}
return emptybox;
}