From d7720b17c4b1cb479ead9b1dd92efde0925ca816 Mon Sep 17 00:00:00 2001 From: zoutairan Date: Tue, 1 Sep 2020 02:03:31 +0800 Subject: [PATCH 01/12] add feature: 1. refresh time minute to second; 2. auto load build --- .../java/org/codinjutsu/tools/jenkins/logic/RssLogic.java | 2 +- .../org/codinjutsu/tools/jenkins/view/BrowserPanel.java | 6 +++++- .../codinjutsu/tools/jenkins/view/ConfigurationPanel.form | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/codinjutsu/tools/jenkins/logic/RssLogic.java b/src/main/java/org/codinjutsu/tools/jenkins/logic/RssLogic.java index e31dade8..5abf3025 100644 --- a/src/main/java/org/codinjutsu/tools/jenkins/logic/RssLogic.java +++ b/src/main/java/org/codinjutsu/tools/jenkins/logic/RssLogic.java @@ -83,7 +83,7 @@ public void initScheduledJobs() { executor.remove(refreshRssBuildsJob); if (jenkinsAppSettings.isServerUrlSet() && jenkinsAppSettings.getRssRefreshPeriod() > 0) { - refreshRssBuildFutureTask = executor.scheduleWithFixedDelay(refreshRssBuildsJob, 0, jenkinsAppSettings.getRssRefreshPeriod(), TimeUnit.MINUTES); + refreshRssBuildFutureTask = executor.scheduleWithFixedDelay(refreshRssBuildsJob, 0, jenkinsAppSettings.getRssRefreshPeriod(), TimeUnit.SECONDS); } } diff --git a/src/main/java/org/codinjutsu/tools/jenkins/view/BrowserPanel.java b/src/main/java/org/codinjutsu/tools/jenkins/view/BrowserPanel.java index d31bc63c..405f9df9 100644 --- a/src/main/java/org/codinjutsu/tools/jenkins/view/BrowserPanel.java +++ b/src/main/java/org/codinjutsu/tools/jenkins/view/BrowserPanel.java @@ -156,7 +156,7 @@ public void initScheduledJobs() { executor.remove(refreshViewJob); if (jenkinsAppSettings.isServerUrlSet() && jenkinsAppSettings.getJobRefreshPeriod() > 0) { - refreshViewFutureTask = executor.scheduleWithFixedDelay(refreshViewJob, jenkinsAppSettings.getJobRefreshPeriod(), jenkinsAppSettings.getJobRefreshPeriod(), TimeUnit.MINUTES); + refreshViewFutureTask = executor.scheduleWithFixedDelay(refreshViewJob, jenkinsAppSettings.getJobRefreshPeriod(), jenkinsAppSettings.getJobRefreshPeriod(), TimeUnit.SECONDS); } } @@ -499,6 +499,10 @@ private void loadJobs() { jobList = requestManager.loadJenkinsView(currentSelectedView); } + for(Job job : jobList) { + job.setLastBuilds(requestManager.loadBuilds(job)); + } + jenkinsSettings.setLastSelectedView(currentSelectedView.getName()); jenkins.setJobs(jobList); diff --git a/src/main/java/org/codinjutsu/tools/jenkins/view/ConfigurationPanel.form b/src/main/java/org/codinjutsu/tools/jenkins/view/ConfigurationPanel.form index f1a1fffc..d8500134 100644 --- a/src/main/java/org/codinjutsu/tools/jenkins/view/ConfigurationPanel.form +++ b/src/main/java/org/codinjutsu/tools/jenkins/view/ConfigurationPanel.form @@ -254,7 +254,7 @@ - + @@ -262,7 +262,7 @@ - + From 8bf75bdcbac2887097cf8d2c8d0c626923b846d4 Mon Sep 17 00:00:00 2001 From: zoutairan Date: Wed, 9 Sep 2020 02:39:50 +0800 Subject: [PATCH 02/12] =?UTF-8?q?todo:=20=E5=AE=8C=E6=88=90=E5=B1=95?= =?UTF-8?q?=E7=A4=BA=E5=8F=82=E6=95=B0=E7=9A=84=E5=B7=A5=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gradle/wrapper/gradle-wrapper.properties | 2 + .../jenkins/logic/JenkinsJsonParser.java | 44 +++++++++++++++++-- .../tools/jenkins/logic/JenkinsParser.java | 2 + .../tools/jenkins/logic/UrlBuilder.java | 3 +- .../codinjutsu/tools/jenkins/model/Build.java | 3 ++ .../tools/jenkins/model/BuildParameter.java | 16 +++++++ 6 files changed, 66 insertions(+), 4 deletions(-) create mode 100644 src/main/java/org/codinjutsu/tools/jenkins/model/BuildParameter.java diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 4e1cc9db..9f147e10 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,3 +3,5 @@ distributionPath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists +systemProp.http.proxyHost=127.0.0.1 +systemProp.http.proxyPort=10809 diff --git a/src/main/java/org/codinjutsu/tools/jenkins/logic/JenkinsJsonParser.java b/src/main/java/org/codinjutsu/tools/jenkins/logic/JenkinsJsonParser.java index 1e3bd87e..424ba095 100644 --- a/src/main/java/org/codinjutsu/tools/jenkins/logic/JenkinsJsonParser.java +++ b/src/main/java/org/codinjutsu/tools/jenkins/logic/JenkinsJsonParser.java @@ -20,14 +20,33 @@ import com.github.cliftonlabs.json_simple.JsonKey; import com.github.cliftonlabs.json_simple.JsonObject; import com.github.cliftonlabs.json_simple.Jsoner; +import lombok.val; import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.ObjectUtils; import org.apache.log4j.Logger; -import org.codinjutsu.tools.jenkins.model.*; +import org.codinjutsu.tools.jenkins.model.Build; +import org.codinjutsu.tools.jenkins.model.BuildParameter; +import org.codinjutsu.tools.jenkins.model.BuildStatusEnum; +import org.codinjutsu.tools.jenkins.model.BuildType; +import org.codinjutsu.tools.jenkins.model.Computer; +import org.codinjutsu.tools.jenkins.model.Jenkins; +import org.codinjutsu.tools.jenkins.model.Job; +import org.codinjutsu.tools.jenkins.model.JobParameter; +import org.codinjutsu.tools.jenkins.model.JobParameterType; +import org.codinjutsu.tools.jenkins.model.JobType; +import org.codinjutsu.tools.jenkins.model.View; import org.codinjutsu.tools.jenkins.util.DateUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.EnumSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Optional; +import java.util.OptionalInt; import java.util.stream.Collectors; public class JenkinsJsonParser implements JenkinsParser { @@ -166,10 +185,29 @@ private Build getBuild(@Nullable JsonObject lastBuildObject) { if (duration != null) { builder.duration(duration); } - + // set parameter + // TODO: 2020/9/9 完成展示参数的工作 + val buildParameterList = ((JsonArray) lastBuildObject.getCollection(createJsonKey(ACTIONS))).stream() + .map(action -> action.getCollection(createJsonKey(PARAMETERS))) + .map(action -> getBuildParameters((JsonObject) action)) + .collect(Collectors.toList()); + LOG.info(buildParameterList); return builder.build(); } + private List getBuildParameters(JsonObject action) { + JsonArray parameters = action.getCollection(createJsonKey(PARAMETERS)); + return action.stream() + .map(parameter -> BuildParameter.of() + .setName(((JsonObject) parameter).getString(createJsonKey("name"))) + .setValue(((JsonObject) parameter).getString(createJsonKey("value")))) + .collect(Collectors.toList()); + } + + private boolean isContainParameters(JsonObject action) { + return ObjectUtils.isNotEmpty(action.getCollection(createJsonKey(PARAMETERS))); + } + @NotNull private List getBuilds(@NotNull JsonArray buildsObjects) { List builds = new LinkedList<>(); diff --git a/src/main/java/org/codinjutsu/tools/jenkins/logic/JenkinsParser.java b/src/main/java/org/codinjutsu/tools/jenkins/logic/JenkinsParser.java index ef336352..08312715 100644 --- a/src/main/java/org/codinjutsu/tools/jenkins/logic/JenkinsParser.java +++ b/src/main/java/org/codinjutsu/tools/jenkins/logic/JenkinsParser.java @@ -67,6 +67,8 @@ public interface JenkinsParser { String PARAMETER_CHOICE = "choices"; String CLASS = "_class"; String COMPUTER = "computer"; + String ACTIONS = "actions"; + String PARAMETERS = "parameters"; Jenkins createWorkspace(String jsonData); diff --git a/src/main/java/org/codinjutsu/tools/jenkins/logic/UrlBuilder.java b/src/main/java/org/codinjutsu/tools/jenkins/logic/UrlBuilder.java index cec93515..73a8d8c0 100644 --- a/src/main/java/org/codinjutsu/tools/jenkins/logic/UrlBuilder.java +++ b/src/main/java/org/codinjutsu/tools/jenkins/logic/UrlBuilder.java @@ -39,7 +39,8 @@ public class UrlBuilder { private static final String TREE_PARAM = "?tree="; private static final String URL = "url"; private static final String BASIC_JENKINS_INFO = URL + ",description,nodeName,nodeDescription,primaryView[name,url],views[name,url,views[name,url]]"; - private static final String BASIC_BUILD_INFO = URL + ",id,building,result,number,displayName,fullDisplayName,timestamp,duration"; + private static final String BASIC_BUILD_INFO = URL + ",id,building,result,number,displayName,fullDisplayName," + + "timestamp,duration,actions[parameters[name,value]]"; private static final String BASIC_JOB_INFO = "name,fullName,displayName,fullDisplayName,jobs," + URL + ",color,buildable,inQueue,healthReport[description,iconUrl],lastBuild[" + BASIC_BUILD_INFO + "],lastFailedBuild[" + URL + "],lastSuccessfulBuild[" + URL + "],property[parameterDefinitions[name,type,defaultParameterValue[value],description,choices]]"; private static final String BASIC_VIEW_INFO = "name," + URL + ",jobs[" + BASIC_JOB_INFO + "]"; private static final String CLOUDBEES_VIEW_INFO = "name," + URL + ",views[jobs[" + BASIC_JOB_INFO + "]]"; diff --git a/src/main/java/org/codinjutsu/tools/jenkins/model/Build.java b/src/main/java/org/codinjutsu/tools/jenkins/model/Build.java index 382abab1..b17377e4 100644 --- a/src/main/java/org/codinjutsu/tools/jenkins/model/Build.java +++ b/src/main/java/org/codinjutsu/tools/jenkins/model/Build.java @@ -24,6 +24,7 @@ import java.text.SimpleDateFormat; import java.util.Date; +import java.util.List; import java.util.Optional; @Value @@ -56,6 +57,8 @@ public class Build { @NotNull @Builder.Default private final BuildStatusEnum status = BuildStatusEnum.NULL; + @Nullable + private final List buildParameterList; @NotNull public static Build createBuildFromWorkspace(String buildUrl, int number, String status, boolean isBuilding, String buildDate, Long timestamp, Long duration) { diff --git a/src/main/java/org/codinjutsu/tools/jenkins/model/BuildParameter.java b/src/main/java/org/codinjutsu/tools/jenkins/model/BuildParameter.java new file mode 100644 index 00000000..4f7f5d18 --- /dev/null +++ b/src/main/java/org/codinjutsu/tools/jenkins/model/BuildParameter.java @@ -0,0 +1,16 @@ +package org.codinjutsu.tools.jenkins.model; + +import lombok.Data; +import lombok.experimental.Accessors; + +@Data +@Accessors(chain = true) +public class BuildParameter { + public static BuildParameter of() { + return new BuildParameter(); + } + + private String name; + + private String value; +} From 51f08547bc1fbc15e01e1933cc919def8c70886b Mon Sep 17 00:00:00 2001 From: zoutairan Date: Wed, 9 Sep 2020 18:52:38 +0800 Subject: [PATCH 03/12] =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=B1=95=E7=A4=BA?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jenkins/logic/JenkinsJsonParser.java | 23 +++++++------ .../tools/jenkins/model/BuildParameter.java | 5 +++ .../jenkins/view/JenkinsTreeRenderer.java | 21 ++++++++++-- .../jenkins/view/JenkinsTreeRendererTest.java | 32 +++++++++++++++++++ 4 files changed, 66 insertions(+), 15 deletions(-) create mode 100644 src/test/java/org/codinjutsu/tools/jenkins/view/JenkinsTreeRendererTest.java diff --git a/src/main/java/org/codinjutsu/tools/jenkins/logic/JenkinsJsonParser.java b/src/main/java/org/codinjutsu/tools/jenkins/logic/JenkinsJsonParser.java index 424ba095..c68dea81 100644 --- a/src/main/java/org/codinjutsu/tools/jenkins/logic/JenkinsJsonParser.java +++ b/src/main/java/org/codinjutsu/tools/jenkins/logic/JenkinsJsonParser.java @@ -20,7 +20,6 @@ import com.github.cliftonlabs.json_simple.JsonKey; import com.github.cliftonlabs.json_simple.JsonObject; import com.github.cliftonlabs.json_simple.Jsoner; -import lombok.val; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang3.ObjectUtils; import org.apache.log4j.Logger; @@ -186,22 +185,22 @@ private Build getBuild(@Nullable JsonObject lastBuildObject) { builder.duration(duration); } // set parameter - // TODO: 2020/9/9 完成展示参数的工作 - val buildParameterList = ((JsonArray) lastBuildObject.getCollection(createJsonKey(ACTIONS))).stream() - .map(action -> action.getCollection(createJsonKey(PARAMETERS))) - .map(action -> getBuildParameters((JsonObject) action)) - .collect(Collectors.toList()); - LOG.info(buildParameterList); + getActions(lastBuildObject).stream() + .filter(action -> isContainParameters((JsonObject) action)) + .findFirst() + .ifPresent(action -> builder.buildParameterList(getBuildParameters((JsonObject) action))); return builder.build(); } + private JsonArray getActions(@NotNull JsonObject lastBuildObject) { + return lastBuildObject.getCollection(createJsonKey(ACTIONS)); + } + private List getBuildParameters(JsonObject action) { - JsonArray parameters = action.getCollection(createJsonKey(PARAMETERS)); - return action.stream() - .map(parameter -> BuildParameter.of() + return action.getCollection(createJsonKey(PARAMETERS)) + .stream().map(parameter -> BuildParameter.of() .setName(((JsonObject) parameter).getString(createJsonKey("name"))) - .setValue(((JsonObject) parameter).getString(createJsonKey("value")))) - .collect(Collectors.toList()); + .setValue(((JsonObject) parameter).getString(createJsonKey("value")))).collect(Collectors.toList()); } private boolean isContainParameters(JsonObject action) { diff --git a/src/main/java/org/codinjutsu/tools/jenkins/model/BuildParameter.java b/src/main/java/org/codinjutsu/tools/jenkins/model/BuildParameter.java index 4f7f5d18..3a335d9c 100644 --- a/src/main/java/org/codinjutsu/tools/jenkins/model/BuildParameter.java +++ b/src/main/java/org/codinjutsu/tools/jenkins/model/BuildParameter.java @@ -13,4 +13,9 @@ public static BuildParameter of() { private String name; private String value; + + @Override + public String toString() { + return String.format("%s: %s", name, value); + } } diff --git a/src/main/java/org/codinjutsu/tools/jenkins/view/JenkinsTreeRenderer.java b/src/main/java/org/codinjutsu/tools/jenkins/view/JenkinsTreeRenderer.java index d72c9036..b52dde30 100644 --- a/src/main/java/org/codinjutsu/tools/jenkins/view/JenkinsTreeRenderer.java +++ b/src/main/java/org/codinjutsu/tools/jenkins/view/JenkinsTreeRenderer.java @@ -24,9 +24,15 @@ import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; import lombok.experimental.Delegate; +import lombok.val; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.time.DurationFormatUtils; -import org.codinjutsu.tools.jenkins.model.*; +import org.codinjutsu.tools.jenkins.model.Build; +import org.codinjutsu.tools.jenkins.model.BuildParameter; +import org.codinjutsu.tools.jenkins.model.BuildStatusEnum; +import org.codinjutsu.tools.jenkins.model.Jenkins; +import org.codinjutsu.tools.jenkins.model.Job; +import org.codinjutsu.tools.jenkins.model.JobType; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -121,9 +127,18 @@ public static String buildLabel(Build build) { final String buildNumberDisplay = build.getDisplayNumber(); final Optional duration = Optional.ofNullable(build.getDuration()); - return String.format("%s (%s) duration: %s %s", buildNumberDisplay, + val buildParameterList = Optional.ofNullable(build.getBuildParameterList()); + return String.format("%s (%s) duration: %s %s\nparameters: [%s]", + buildNumberDisplay, DateFormatUtil.formatDateTime(build.getTimestamp()), - DurationFormatUtils.formatDurationHMS(duration.orElse(0L)), status); + DurationFormatUtils.formatDurationHMS(duration.orElse(0L)), + status, + buildParameterList.flatMap(list -> + list.stream() + .map(BuildParameter::toString) + .reduce((a, b) -> String.format("%s %s",a,b)) + ).orElse("empty") + ); } @NotNull diff --git a/src/test/java/org/codinjutsu/tools/jenkins/view/JenkinsTreeRendererTest.java b/src/test/java/org/codinjutsu/tools/jenkins/view/JenkinsTreeRendererTest.java new file mode 100644 index 00000000..4bb2cf78 --- /dev/null +++ b/src/test/java/org/codinjutsu/tools/jenkins/view/JenkinsTreeRendererTest.java @@ -0,0 +1,32 @@ +package org.codinjutsu.tools.jenkins.view; + +import junit.framework.TestCase; +import org.junit.Test; + +import java.util.List; +import java.util.Optional; + +/** + * @Package: org.codinjutsu.tools.jenkins.view + * @ClassName: JenkinsTreeRendererTest + * @Description: + * @Author: zoutairan + * @CreateDate: 9/9/2020 10:44 AM + * @UpdateUser: zoutairan + * @UpdateDate: 9/9/2020 10:44 AM + * @UpdateRemark: + * @Version: 1.0 + * Copyright: Copyright (c) 2020 + */ +public class JenkinsTreeRendererTest extends TestCase { + @Test + public void testOptional() { + List integerList = null; + Optional> optional = Optional.ofNullable(integerList); + String result = optional.flatMap(integers -> integers.stream() + .map(Object::toString) + .reduce((a, b) -> a + b)).orElse("null") + ; + } + +} \ No newline at end of file From d6fc40c149c5fb9e6a9769d30439b038e193a23b Mon Sep 17 00:00:00 2001 From: zoutairan Date: Wed, 9 Sep 2020 23:25:31 +0800 Subject: [PATCH 04/12] feature: add build parameter display --- .../codinjutsu/tools/jenkins/JenkinsTree.java | 64 +++++++++++++------ .../tools/jenkins/view/JenkinsTreeNode.java | 18 ++++++ .../jenkins/view/JenkinsTreeNodeVisitor.java | 2 + .../jenkins/view/JenkinsTreeRenderer.java | 9 +++ 4 files changed, 73 insertions(+), 20 deletions(-) diff --git a/src/main/java/org/codinjutsu/tools/jenkins/JenkinsTree.java b/src/main/java/org/codinjutsu/tools/jenkins/JenkinsTree.java index e8528270..e88661c4 100644 --- a/src/main/java/org/codinjutsu/tools/jenkins/JenkinsTree.java +++ b/src/main/java/org/codinjutsu/tools/jenkins/JenkinsTree.java @@ -10,7 +10,9 @@ import com.intellij.ui.treeStructure.SimpleTree; import com.intellij.util.containers.Convertor; import com.intellij.util.ui.tree.TreeUtil; +import lombok.val; import org.codinjutsu.tools.jenkins.model.Build; +import org.codinjutsu.tools.jenkins.model.BuildParameter; import org.codinjutsu.tools.jenkins.model.Jenkins; import org.codinjutsu.tools.jenkins.model.Job; import org.codinjutsu.tools.jenkins.util.GuiUtil; @@ -23,13 +25,23 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; -import javax.swing.tree.*; -import java.util.*; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.DefaultTreeModel; +import javax.swing.tree.TreeNode; +import javax.swing.tree.TreePath; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; +import java.util.Enumeration; +import java.util.List; +import java.util.Optional; public class JenkinsTree implements PersistentStateComponent { private static final String LOADING = "Loading..."; private static final String UNAVAILABLE = "No Jenkins server available"; private static final TreeState NO_TREE_STATE = null; + private static final Logger LOG = Logger.getInstance(JenkinsTree.class); @NotNull private final JenkinsSettings jenkinsSettings; private final Jenkins jenkins; @@ -38,7 +50,6 @@ public class JenkinsTree implements PersistentStateComponent { private JenkinsTreeState state = new JenkinsTreeState(); @Nullable private TreeState lastTreeState = NO_TREE_STATE; - private static final Logger LOG = Logger.getInstance(JenkinsTree.class); public JenkinsTree(Project project, @NotNull JenkinsSettings jenkinsSettings, Jenkins jenkins) { super(); @@ -62,7 +73,16 @@ public static DefaultMutableTreeNode fillJobTree(@NotNull Job job, @NotNull Defa if (job.getJobType().containNestedJobs()) { job.getNestedJobs().stream().map(JenkinsTree::createJobTree).forEach(jobNode::add); } else { - job.getLastBuilds().stream().map(JenkinsTree::createNode).forEach(jobNode::add); + job.getLastBuilds().stream() + .map(build -> { + val buildNode = createNode(build); + Optional.ofNullable(build.getBuildParameterList()) + .ifPresent(buildParameters -> buildParameters.stream() + .map(JenkinsTree::createNode) + .forEach(buildNode::add)); + return buildNode; + }) + .forEach(jobNode::add); } return jobNode; } @@ -81,7 +101,7 @@ public static Optional getJob(@NotNull DefaultMutableTreeNode node) { @NotNull public static Optional getNode(@NotNull DefaultMutableTreeNode node, @NotNull Class expectedClass) { - return Optional.ofNullable(node.getUserObject()).filter(expectedClass::isInstance).map(expectedClass::cast); + return Optional.ofNullable(node.getUserObject()).filter(expectedClass::isInstance).map(expectedClass::cast); } @NotNull @@ -93,9 +113,14 @@ public static Optional getLastSelectedPath(@NotNull TreePath treePath, @N .filter(expectedClass::isInstance).map(expectedClass::cast); } + @NotNull + private static DefaultMutableTreeNode createNode(BuildParameter buildParameter) { + return new DefaultMutableTreeNode(new JenkinsTreeNode.BuildParameterNode(buildParameter), true); + } + @NotNull private static DefaultMutableTreeNode createNode(Build build) { - return new DefaultMutableTreeNode(new JenkinsTreeNode.BuildNode(build), false); + return new DefaultMutableTreeNode(new JenkinsTreeNode.BuildNode(build), true); } @NotNull @@ -109,6 +134,18 @@ private static DefaultMutableTreeNode createJobTree(Job job) { return fillJobTree(job, createNode(job)); } + @NotNull + private static Comparator wrapJobSorter(Comparator jobComparator) { + return (node1, node2) -> { + final Optional job1 = JenkinsTree.getJob(node1); + final Optional job2 = JenkinsTree.getJob(node2); + if (job1.isPresent() && job2.isPresent()) { + return jobComparator.compare(job1.get(), job2.get()); + } + return 0; + }; + } + @NotNull public JComponent asComponent() { return getTree(); @@ -183,8 +220,7 @@ public JenkinsTreeState getState() { try { state.treeState = new Element("root"); treeState.writeExternal(state.treeState); - } - catch (WriteExternalException e) { + } catch (WriteExternalException e) { LOG.warn(e); } }); @@ -248,18 +284,6 @@ public void sortJobs(Comparator comparator) { GuiUtil.runInSwingThread(() -> model.nodeStructureChanged((TreeNode) model.getRoot())); } - @NotNull - private static Comparator wrapJobSorter(Comparator jobComparator) { - return (node1, node2) -> { - final Optional job1 = JenkinsTree.getJob(node1); - final Optional job2 = JenkinsTree.getJob(node2); - if (job1.isPresent() && job2.isPresent()) { - return jobComparator.compare(job1.get(), job2.get()); - } - return 0; - }; - } - @SuppressWarnings("java:S110") private static class TreeWithoutDefaultSearch extends SimpleTree { diff --git a/src/main/java/org/codinjutsu/tools/jenkins/view/JenkinsTreeNode.java b/src/main/java/org/codinjutsu/tools/jenkins/view/JenkinsTreeNode.java index 25f72e23..cf123709 100644 --- a/src/main/java/org/codinjutsu/tools/jenkins/view/JenkinsTreeNode.java +++ b/src/main/java/org/codinjutsu/tools/jenkins/view/JenkinsTreeNode.java @@ -3,8 +3,10 @@ import com.intellij.ide.util.treeView.NodeDescriptorProvidingKey; import com.intellij.navigation.ItemPresentation; import com.intellij.navigation.NavigationItem; +import lombok.Data; import lombok.Value; import org.codinjutsu.tools.jenkins.model.Build; +import org.codinjutsu.tools.jenkins.model.BuildParameter; import org.codinjutsu.tools.jenkins.model.Jenkins; import org.codinjutsu.tools.jenkins.model.Job; import org.jetbrains.annotations.NotNull; @@ -50,6 +52,22 @@ default boolean canNavigateToSource() { void render(JenkinsTreeNodeVisitor treeNodeRenderer); + @Data + class BuildParameterNode implements JenkinsTreeNode { + private final BuildParameter buildParameter; + + @NotNull + @Override + public String getUrl() { + return ""; + } + + @Override + public void render(JenkinsTreeNodeVisitor treeNodeRenderer) { + treeNodeRenderer.visit(this); + } + } + @Value class BuildNode implements JenkinsTreeNode { diff --git a/src/main/java/org/codinjutsu/tools/jenkins/view/JenkinsTreeNodeVisitor.java b/src/main/java/org/codinjutsu/tools/jenkins/view/JenkinsTreeNodeVisitor.java index e5c101e5..8bc4f78f 100644 --- a/src/main/java/org/codinjutsu/tools/jenkins/view/JenkinsTreeNodeVisitor.java +++ b/src/main/java/org/codinjutsu/tools/jenkins/view/JenkinsTreeNodeVisitor.java @@ -7,4 +7,6 @@ public interface JenkinsTreeNodeVisitor { void visit(JenkinsTreeNode.BuildNode build); void visit(JenkinsTreeNode.JobNode job); + + void visit(JenkinsTreeNode.BuildParameterNode buildParameterNode); } diff --git a/src/main/java/org/codinjutsu/tools/jenkins/view/JenkinsTreeRenderer.java b/src/main/java/org/codinjutsu/tools/jenkins/view/JenkinsTreeRenderer.java index b52dde30..4c3486ac 100644 --- a/src/main/java/org/codinjutsu/tools/jenkins/view/JenkinsTreeRenderer.java +++ b/src/main/java/org/codinjutsu/tools/jenkins/view/JenkinsTreeRenderer.java @@ -77,6 +77,11 @@ public void visit(JenkinsTreeNode.BuildNode build) { public void visit(JenkinsTreeNode.JobNode job) { JenkinsTreeRenderer.this.render(job, parent); } + + @Override + public void visit(JenkinsTreeNode.BuildParameterNode buildParameterNode) { + JenkinsTreeRenderer.this.render(buildParameterNode); + } }); } @@ -201,6 +206,10 @@ private void render(JenkinsTreeNode.JobNode jobNode, @NotNull Optional } } + private void render(JenkinsTreeNode.BuildParameterNode buildParameterNode) { + append(buildParameterNode.getBuildParameter().toString(), SimpleTextAttributes.REGULAR_ITALIC_ATTRIBUTES); + } + private static class CompositeIcon implements Icon { @Delegate From d0460f9d99659fc205f69752b578a4dea1ad8fa4 Mon Sep 17 00:00:00 2001 From: zoutairan Date: Wed, 9 Sep 2020 23:50:50 +0800 Subject: [PATCH 05/12] feature: auto expand build parameter node --- .../codinjutsu/tools/jenkins/JenkinsTree.java | 58 ++++++++++--------- 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/src/main/java/org/codinjutsu/tools/jenkins/JenkinsTree.java b/src/main/java/org/codinjutsu/tools/jenkins/JenkinsTree.java index e88661c4..e40a07b3 100644 --- a/src/main/java/org/codinjutsu/tools/jenkins/JenkinsTree.java +++ b/src/main/java/org/codinjutsu/tools/jenkins/JenkinsTree.java @@ -67,26 +67,6 @@ public JenkinsTree(Project project, @NotNull JenkinsSettings jenkinsSettings, Je this.tree.addMouseListener(new JobClickHandler()); } - @NotNull - public static DefaultMutableTreeNode fillJobTree(@NotNull Job job, @NotNull DefaultMutableTreeNode jobNode) { - jobNode.removeAllChildren(); - if (job.getJobType().containNestedJobs()) { - job.getNestedJobs().stream().map(JenkinsTree::createJobTree).forEach(jobNode::add); - } else { - job.getLastBuilds().stream() - .map(build -> { - val buildNode = createNode(build); - Optional.ofNullable(build.getBuildParameterList()) - .ifPresent(buildParameters -> buildParameters.stream() - .map(JenkinsTree::createNode) - .forEach(buildNode::add)); - return buildNode; - }) - .forEach(jobNode::add); - } - return jobNode; - } - @NotNull public static Optional getJob(TreePath treePath) { final Class jobNodeClass = JenkinsTreeNode.JobNode.class; @@ -129,11 +109,6 @@ private static DefaultMutableTreeNode createNode(Job job) { return new DefaultMutableTreeNode(new JenkinsTreeNode.JobNode(job), allowsChildren); } - @NotNull - private static DefaultMutableTreeNode createJobTree(Job job) { - return fillJobTree(job, createNode(job)); - } - @NotNull private static Comparator wrapJobSorter(Comparator jobComparator) { return (node1, node2) -> { @@ -146,6 +121,35 @@ private static Comparator wrapJobSorter(Comparator }; } + @NotNull + public DefaultMutableTreeNode fillJobTree(@NotNull Job job, @NotNull DefaultMutableTreeNode jobNode) { + jobNode.removeAllChildren(); + if (job.getJobType().containNestedJobs()) { + job.getNestedJobs().stream().map(this::createJobTree).forEach(jobNode::add); + } else { + job.getLastBuilds().stream() + .map(build -> { + val buildNode = createNode(build); + Optional.ofNullable(build.getBuildParameterList()) + .ifPresent(buildParameters -> buildParameters.stream() + .map(buildParameter -> { + val buildParameterNode = createNode(buildParameter); + getTree().expandPath(new TreePath(buildParameterNode.getPath())); + return buildParameterNode; + }) + .forEach(buildNode::add)); + return buildNode; + }) + .forEach(jobNode::add); + } + return jobNode; + } + + @NotNull + private DefaultMutableTreeNode createJobTree(Job job) { + return fillJobTree(job, createNode(job)); + } + @NotNull public JComponent asComponent() { return getTree(); @@ -186,7 +190,7 @@ public void setJobs(@NotNull final Collection jobs) { private void setJobs(@NotNull final Collection jobs, @NotNull DefaultMutableTreeNode rootNode) { rootNode.removeAllChildren(); - jobs.stream().map(JenkinsTree::createJobTree).forEach(rootNode::add); + jobs.stream().map(this::createJobTree).forEach(rootNode::add); tree.setRootVisible(true); } @@ -247,7 +251,7 @@ public void loadState(@NotNull JenkinsTreeState state) { public void updateJobNode(@NotNull Job job) { final DefaultTreeModel model = getModel(); findNodes(job).forEach(jobNode -> { - JenkinsTree.fillJobTree(job, jobNode); + fillJobTree(job, jobNode); model.nodeChanged(jobNode); model.nodeStructureChanged(jobNode); }); From 0463504f3966199853ced6774f98320c80db0d72 Mon Sep 17 00:00:00 2001 From: zoutairan Date: Thu, 10 Sep 2020 23:19:28 +0800 Subject: [PATCH 06/12] 1. optimize code structure 2. add feature: auto load builds --- .../tools/jenkins/JenkinsAppSettings.java | 9 ++++ .../codinjutsu/tools/jenkins/JenkinsTree.java | 26 +++++----- .../jenkins/logic/JenkinsJsonParser.java | 24 ++++++---- .../tools/jenkins/model/BuildParameter.java | 16 +++++-- .../tools/jenkins/view/BrowserPanel.java | 7 +-- .../jenkins/view/ConfigurationPanel.form | 18 +++++-- .../jenkins/view/ConfigurationPanel.java | 47 ++++++++----------- .../jenkins/view/JenkinsTreeRenderer.java | 13 +---- 8 files changed, 87 insertions(+), 73 deletions(-) diff --git a/src/main/java/org/codinjutsu/tools/jenkins/JenkinsAppSettings.java b/src/main/java/org/codinjutsu/tools/jenkins/JenkinsAppSettings.java index 5689c5e2..b4398020 100644 --- a/src/main/java/org/codinjutsu/tools/jenkins/JenkinsAppSettings.java +++ b/src/main/java/org/codinjutsu/tools/jenkins/JenkinsAppSettings.java @@ -169,6 +169,14 @@ public void setShowAllInStatusbar(boolean showAllInStatusbar) { myState.setShowAllInStatusbar(showAllInStatusbar); } + public boolean isAutoLoadBuilds() { + return myState.isAutoLoadBuilds(); + } + + public void setAutoLoadBuilds(boolean showAllInStatusbar) { + myState.setAutoLoadBuilds(showAllInStatusbar); + } + @Data public static class State { @@ -182,6 +190,7 @@ public static class State { private RssSettings rssSettings = new RssSettings(); private boolean useGreenColor = false; private boolean showAllInStatusbar = false; + private boolean autoLoadBuilds = false; } @Data diff --git a/src/main/java/org/codinjutsu/tools/jenkins/JenkinsTree.java b/src/main/java/org/codinjutsu/tools/jenkins/JenkinsTree.java index e40a07b3..1da0e268 100644 --- a/src/main/java/org/codinjutsu/tools/jenkins/JenkinsTree.java +++ b/src/main/java/org/codinjutsu/tools/jenkins/JenkinsTree.java @@ -127,24 +127,22 @@ public DefaultMutableTreeNode fillJobTree(@NotNull Job job, @NotNull DefaultMuta if (job.getJobType().containNestedJobs()) { job.getNestedJobs().stream().map(this::createJobTree).forEach(jobNode::add); } else { - job.getLastBuilds().stream() - .map(build -> { - val buildNode = createNode(build); - Optional.ofNullable(build.getBuildParameterList()) - .ifPresent(buildParameters -> buildParameters.stream() - .map(buildParameter -> { - val buildParameterNode = createNode(buildParameter); - getTree().expandPath(new TreePath(buildParameterNode.getPath())); - return buildParameterNode; - }) - .forEach(buildNode::add)); - return buildNode; - }) - .forEach(jobNode::add); + job.getLastBuilds().stream().map(this::initBuildNode).forEach(jobNode::add); } return jobNode; } + @NotNull + private DefaultMutableTreeNode initBuildNode(Build build) { + val buildNode = createNode(build); + Optional.ofNullable(build.getBuildParameterList()) + .ifPresent(buildParameters -> buildParameters.stream() + .map(JenkinsTree::createNode) + .forEach(buildNode::add) + ); + return buildNode; + } + @NotNull private DefaultMutableTreeNode createJobTree(Job job) { return fillJobTree(job, createNode(job)); diff --git a/src/main/java/org/codinjutsu/tools/jenkins/logic/JenkinsJsonParser.java b/src/main/java/org/codinjutsu/tools/jenkins/logic/JenkinsJsonParser.java index c68dea81..cad79401 100644 --- a/src/main/java/org/codinjutsu/tools/jenkins/logic/JenkinsJsonParser.java +++ b/src/main/java/org/codinjutsu/tools/jenkins/logic/JenkinsJsonParser.java @@ -185,22 +185,30 @@ private Build getBuild(@Nullable JsonObject lastBuildObject) { builder.duration(duration); } // set parameter - getActions(lastBuildObject).stream() - .filter(action -> isContainParameters((JsonObject) action)) - .findFirst() - .ifPresent(action -> builder.buildParameterList(getBuildParameters((JsonObject) action))); + Optional.ofNullable(getActions(lastBuildObject)) + .flatMap(actions -> actions.stream() + .filter(action -> isContainParameters((JsonObject) action)) + .findFirst() + ) + .ifPresent(action -> + builder.buildParameterList(getBuildParameters((JsonObject) action)) + ); return builder.build(); } + @Nullable private JsonArray getActions(@NotNull JsonObject lastBuildObject) { return lastBuildObject.getCollection(createJsonKey(ACTIONS)); } + @NotNull private List getBuildParameters(JsonObject action) { - return action.getCollection(createJsonKey(PARAMETERS)) - .stream().map(parameter -> BuildParameter.of() - .setName(((JsonObject) parameter).getString(createJsonKey("name"))) - .setValue(((JsonObject) parameter).getString(createJsonKey("value")))).collect(Collectors.toList()); + return action.getCollection(createJsonKey(PARAMETERS)).stream() + .map(parameter -> BuildParameter.of( + ((JsonObject) parameter).getString(createJsonKey("name")), + ((JsonObject) parameter).getString(createJsonKey("value")) + )) + .collect(Collectors.toList()); } private boolean isContainParameters(JsonObject action) { diff --git a/src/main/java/org/codinjutsu/tools/jenkins/model/BuildParameter.java b/src/main/java/org/codinjutsu/tools/jenkins/model/BuildParameter.java index 3a335d9c..5e4beeaf 100644 --- a/src/main/java/org/codinjutsu/tools/jenkins/model/BuildParameter.java +++ b/src/main/java/org/codinjutsu/tools/jenkins/model/BuildParameter.java @@ -1,20 +1,26 @@ package org.codinjutsu.tools.jenkins.model; +import lombok.AllArgsConstructor; import lombok.Data; import lombok.experimental.Accessors; +import org.jetbrains.annotations.NotNull; @Data @Accessors(chain = true) +@AllArgsConstructor public class BuildParameter { - public static BuildParameter of() { - return new BuildParameter(); - } - + @NotNull private String name; - + @NotNull private String value; + @NotNull + public static BuildParameter of(@NotNull String name, @NotNull String value) { + return new BuildParameter(name, value); + } + @Override + @NotNull public String toString() { return String.format("%s: %s", name, value); } diff --git a/src/main/java/org/codinjutsu/tools/jenkins/view/BrowserPanel.java b/src/main/java/org/codinjutsu/tools/jenkins/view/BrowserPanel.java index 405f9df9..8c198f7c 100644 --- a/src/main/java/org/codinjutsu/tools/jenkins/view/BrowserPanel.java +++ b/src/main/java/org/codinjutsu/tools/jenkins/view/BrowserPanel.java @@ -498,9 +498,10 @@ private void loadJobs() { } else { jobList = requestManager.loadJenkinsView(currentSelectedView); } - - for(Job job : jobList) { - job.setLastBuilds(requestManager.loadBuilds(job)); + if (jenkinsAppSettings.isAutoLoadBuilds()) { + for(Job job : jobList) { + job.setLastBuilds(requestManager.loadBuilds(job)); + } } jenkinsSettings.setLastSelectedView(currentSelectedView.getName()); diff --git a/src/main/java/org/codinjutsu/tools/jenkins/view/ConfigurationPanel.form b/src/main/java/org/codinjutsu/tools/jenkins/view/ConfigurationPanel.form index d8500134..17319eb5 100644 --- a/src/main/java/org/codinjutsu/tools/jenkins/view/ConfigurationPanel.form +++ b/src/main/java/org/codinjutsu/tools/jenkins/view/ConfigurationPanel.form @@ -1,9 +1,9 @@
- + - + @@ -321,7 +321,7 @@ - + @@ -368,7 +368,7 @@ - + @@ -409,7 +409,7 @@ - + @@ -437,6 +437,14 @@ + + + + + + + + diff --git a/src/main/java/org/codinjutsu/tools/jenkins/view/ConfigurationPanel.java b/src/main/java/org/codinjutsu/tools/jenkins/view/ConfigurationPanel.java index 9600bf09..4ef3a413 100644 --- a/src/main/java/org/codinjutsu/tools/jenkins/view/ConfigurationPanel.java +++ b/src/main/java/org/codinjutsu/tools/jenkins/view/ConfigurationPanel.java @@ -27,7 +27,6 @@ import org.codinjutsu.tools.jenkins.exception.ConfigurationException; import org.codinjutsu.tools.jenkins.logic.ConfigurationValidator; import org.codinjutsu.tools.jenkins.logic.RequestManager; -import org.codinjutsu.tools.jenkins.model.Jenkins; import org.codinjutsu.tools.jenkins.security.AuthenticationException; import org.codinjutsu.tools.jenkins.security.JenkinsVersion; import org.codinjutsu.tools.jenkins.util.GuiUtil; @@ -37,20 +36,12 @@ import org.codinjutsu.tools.jenkins.view.validator.PositiveIntegerValidator; import org.codinjutsu.tools.jenkins.view.validator.UrlValidator; -import javax.swing.JButton; -import javax.swing.JCheckBox; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JPasswordField; -import javax.swing.JRadioButton; -import javax.swing.JTextField; -import javax.swing.JTextPane; +import javax.swing.*; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import javax.swing.text.html.HTMLDocument; import javax.swing.text.html.HTMLEditorKit; -import java.awt.Color; -import java.util.stream.Collectors; +import java.awt.*; import static org.codinjutsu.tools.jenkins.view.validator.ValidatorTypeEnum.POSITIVE_INTEGER; import static org.codinjutsu.tools.jenkins.view.validator.ValidatorTypeEnum.URL; @@ -59,33 +50,25 @@ public class ConfigurationPanel { private static final JBColor CONNECTION_TEST_SUCCESSFUL_COLOR = JBColor.GREEN; private static final JBColor CONNECTION_TEST_FAILED_COLOR = JBColor.RED; - + private final FormValidator formValidator; @GuiField(validators = URL) private JTextField serverUrl; - private JTextField crumbDataField; - private JTextField username; private JPasswordField passwordField; - private JTextField buildDelay; private JTextField jobRefreshPeriod; private JTextField rssRefreshPeriod; private JTextField numBuildRetries; - private JPanel rootPanel; - private JButton testConnectionButton; private JLabel connectionStatusLabel; private JPanel debugPanel; private JTextPane debugTextPane; - private JPanel rssStatusFilterPanel; - private JCheckBox successOrStableCheckBox; private JCheckBox unstableOrFailCheckBox; private JCheckBox abortedCheckBox; - private JPanel uploadPatchSettingsPanel; private JTextField replaceWithSuffix; private JRadioButton version1RadioButton; @@ -94,9 +77,7 @@ public class ConfigurationPanel { private JCheckBox useGreenColor; @GuiField(validators = POSITIVE_INTEGER) private JBIntSpinner timeout; - - private final FormValidator formValidator; - + private JCheckBox autoLoadBuilds; private boolean myPasswordModified = false; public ConfigurationPanel(final Project project) { @@ -211,6 +192,7 @@ public boolean isModified(JenkinsAppSettings jenkinsAppSettings, JenkinsSettings boolean isUseGreenColor = isUseGreenColor() != jenkinsAppSettings.isUseGreenColor(); boolean isShowAllInStatusbar = isShowAllInStatusbar() != jenkinsAppSettings.isShowAllInStatusbar(); + boolean isAutoLoadBuilds = getAutoLoadBuilds() != jenkinsAppSettings.isAutoLoadBuilds(); return !jenkinsAppSettings.getServerUrl().equals(serverUrl.getText()) || jenkinsAppSettings.getBuildDelay() != getBuildDelay() @@ -221,6 +203,7 @@ public boolean isModified(JenkinsAppSettings jenkinsAppSettings, JenkinsSettings || credentialModified || isUseGreenColor || isShowAllInStatusbar + || isAutoLoadBuilds || jenkinsSettings.getConnectionTimeout() != getConnectionTimeout() || statusToIgnoreModified || (!jenkinsAppSettings.getSuffix().equals(replaceWithSuffix.getText())); } @@ -247,6 +230,7 @@ public void applyConfigurationData(JenkinsAppSettings jenkinsAppSettings, Jenkin jenkinsAppSettings.setSuffix(getSuffix()); jenkinsAppSettings.setUseGreenColor(isUseGreenColor()); jenkinsAppSettings.setShowAllInStatusbar(isShowAllInStatusbar()); + jenkinsAppSettings.setAutoLoadBuilds(getAutoLoadBuilds()); jenkinsSettings.setConnectionTimeout(getConnectionTimeout()); if (StringUtils.isNotBlank(username.getText())) { @@ -274,6 +258,14 @@ private void setUseGreenColor(boolean useGreenColor) { this.useGreenColor.setSelected(useGreenColor); } + private boolean getAutoLoadBuilds() { + return autoLoadBuilds.isSelected(); + } + + private void setAutoLoadBuilds(boolean autoLoadBuilds) { + this.autoLoadBuilds.setSelected(autoLoadBuilds); + } + private boolean isShowAllInStatusbar() { return showAllInStatusbar.isSelected(); } @@ -306,6 +298,7 @@ public void loadConfigurationData(JenkinsAppSettings jenkinsAppSettings, Jenkins replaceWithSuffix.setText(String.valueOf(jenkinsAppSettings.getSuffix())); setUseGreenColor(jenkinsAppSettings.isUseGreenColor()); setShowAllInStatusbar(jenkinsAppSettings.isShowAllInStatusbar()); + setAutoLoadBuilds(jenkinsAppSettings.isAutoLoadBuilds()); timeout.setNumber(jenkinsSettings.getConnectionTimeout()); if (jenkinsSettings.getVersion().equals(JenkinsVersion.VERSION_1)) { @@ -336,14 +329,14 @@ private void resetPasswordModification() { myPasswordModified = false; } - private void setPassword(String password) { - passwordField.setText(StringUtils.isBlank(password) ? null : password); - } - private String getPassword() { return String.valueOf(passwordField.getPassword()); } + private void setPassword(String password) { + passwordField.setText(StringUtils.isBlank(password) ? null : password); + } + private int getRssRefreshPeriod() { String period = rssRefreshPeriod.getText(); if (StringUtils.isNotBlank(period)) { diff --git a/src/main/java/org/codinjutsu/tools/jenkins/view/JenkinsTreeRenderer.java b/src/main/java/org/codinjutsu/tools/jenkins/view/JenkinsTreeRenderer.java index 4c3486ac..7311d03e 100644 --- a/src/main/java/org/codinjutsu/tools/jenkins/view/JenkinsTreeRenderer.java +++ b/src/main/java/org/codinjutsu/tools/jenkins/view/JenkinsTreeRenderer.java @@ -132,18 +132,9 @@ public static String buildLabel(Build build) { final String buildNumberDisplay = build.getDisplayNumber(); final Optional duration = Optional.ofNullable(build.getDuration()); - val buildParameterList = Optional.ofNullable(build.getBuildParameterList()); - return String.format("%s (%s) duration: %s %s\nparameters: [%s]", - buildNumberDisplay, + return String.format("%s (%s) duration: %s %s", buildNumberDisplay, DateFormatUtil.formatDateTime(build.getTimestamp()), - DurationFormatUtils.formatDurationHMS(duration.orElse(0L)), - status, - buildParameterList.flatMap(list -> - list.stream() - .map(BuildParameter::toString) - .reduce((a, b) -> String.format("%s %s",a,b)) - ).orElse("empty") - ); + DurationFormatUtils.formatDurationHMS(duration.orElse(0L)), status); } @NotNull From 87dc2e5e99402eb44d32eefb68c6fe64451b2b73 Mon Sep 17 00:00:00 2001 From: zoutairan Date: Thu, 10 Sep 2020 23:48:36 +0800 Subject: [PATCH 07/12] restore refresh time unit from second to minute --- .../java/org/codinjutsu/tools/jenkins/logic/RssLogic.java | 2 +- .../java/org/codinjutsu/tools/jenkins/view/BrowserPanel.java | 2 +- .../org/codinjutsu/tools/jenkins/view/ConfigurationPanel.form | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/codinjutsu/tools/jenkins/logic/RssLogic.java b/src/main/java/org/codinjutsu/tools/jenkins/logic/RssLogic.java index 5abf3025..e31dade8 100644 --- a/src/main/java/org/codinjutsu/tools/jenkins/logic/RssLogic.java +++ b/src/main/java/org/codinjutsu/tools/jenkins/logic/RssLogic.java @@ -83,7 +83,7 @@ public void initScheduledJobs() { executor.remove(refreshRssBuildsJob); if (jenkinsAppSettings.isServerUrlSet() && jenkinsAppSettings.getRssRefreshPeriod() > 0) { - refreshRssBuildFutureTask = executor.scheduleWithFixedDelay(refreshRssBuildsJob, 0, jenkinsAppSettings.getRssRefreshPeriod(), TimeUnit.SECONDS); + refreshRssBuildFutureTask = executor.scheduleWithFixedDelay(refreshRssBuildsJob, 0, jenkinsAppSettings.getRssRefreshPeriod(), TimeUnit.MINUTES); } } diff --git a/src/main/java/org/codinjutsu/tools/jenkins/view/BrowserPanel.java b/src/main/java/org/codinjutsu/tools/jenkins/view/BrowserPanel.java index 8c198f7c..ca25edeb 100644 --- a/src/main/java/org/codinjutsu/tools/jenkins/view/BrowserPanel.java +++ b/src/main/java/org/codinjutsu/tools/jenkins/view/BrowserPanel.java @@ -156,7 +156,7 @@ public void initScheduledJobs() { executor.remove(refreshViewJob); if (jenkinsAppSettings.isServerUrlSet() && jenkinsAppSettings.getJobRefreshPeriod() > 0) { - refreshViewFutureTask = executor.scheduleWithFixedDelay(refreshViewJob, jenkinsAppSettings.getJobRefreshPeriod(), jenkinsAppSettings.getJobRefreshPeriod(), TimeUnit.SECONDS); + refreshViewFutureTask = executor.scheduleWithFixedDelay(refreshViewJob, jenkinsAppSettings.getJobRefreshPeriod(), jenkinsAppSettings.getJobRefreshPeriod(), TimeUnit.MINUTES); } } diff --git a/src/main/java/org/codinjutsu/tools/jenkins/view/ConfigurationPanel.form b/src/main/java/org/codinjutsu/tools/jenkins/view/ConfigurationPanel.form index 17319eb5..15d8dfc6 100644 --- a/src/main/java/org/codinjutsu/tools/jenkins/view/ConfigurationPanel.form +++ b/src/main/java/org/codinjutsu/tools/jenkins/view/ConfigurationPanel.form @@ -254,7 +254,7 @@ - + @@ -262,7 +262,7 @@ - + From 252a2070ddf138e479251e61039dae14c828eba6 Mon Sep 17 00:00:00 2001 From: zoutairan Date: Fri, 11 Sep 2020 00:09:28 +0800 Subject: [PATCH 08/12] restore gradle settings --- gradle/wrapper/gradle-wrapper.properties | 2 -- 1 file changed, 2 deletions(-) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 9f147e10..4e1cc9db 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,5 +3,3 @@ distributionPath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -systemProp.http.proxyHost=127.0.0.1 -systemProp.http.proxyPort=10809 From 44994ccd3fc88f43829b171675c148e13f43b53e Mon Sep 17 00:00:00 2001 From: zoutairan Date: Fri, 11 Sep 2020 00:14:34 +0800 Subject: [PATCH 09/12] optimize code structure --- .../tools/jenkins/JenkinsAppSettings.java | 4 +-- .../jenkins/view/JenkinsTreeRendererTest.java | 32 ------------------- 2 files changed, 2 insertions(+), 34 deletions(-) delete mode 100644 src/test/java/org/codinjutsu/tools/jenkins/view/JenkinsTreeRendererTest.java diff --git a/src/main/java/org/codinjutsu/tools/jenkins/JenkinsAppSettings.java b/src/main/java/org/codinjutsu/tools/jenkins/JenkinsAppSettings.java index b4398020..b080caf0 100644 --- a/src/main/java/org/codinjutsu/tools/jenkins/JenkinsAppSettings.java +++ b/src/main/java/org/codinjutsu/tools/jenkins/JenkinsAppSettings.java @@ -173,8 +173,8 @@ public boolean isAutoLoadBuilds() { return myState.isAutoLoadBuilds(); } - public void setAutoLoadBuilds(boolean showAllInStatusbar) { - myState.setAutoLoadBuilds(showAllInStatusbar); + public void setAutoLoadBuilds(boolean autoLoadBuilds) { + myState.setAutoLoadBuilds(autoLoadBuilds); } @Data diff --git a/src/test/java/org/codinjutsu/tools/jenkins/view/JenkinsTreeRendererTest.java b/src/test/java/org/codinjutsu/tools/jenkins/view/JenkinsTreeRendererTest.java deleted file mode 100644 index 4bb2cf78..00000000 --- a/src/test/java/org/codinjutsu/tools/jenkins/view/JenkinsTreeRendererTest.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.codinjutsu.tools.jenkins.view; - -import junit.framework.TestCase; -import org.junit.Test; - -import java.util.List; -import java.util.Optional; - -/** - * @Package: org.codinjutsu.tools.jenkins.view - * @ClassName: JenkinsTreeRendererTest - * @Description: - * @Author: zoutairan - * @CreateDate: 9/9/2020 10:44 AM - * @UpdateUser: zoutairan - * @UpdateDate: 9/9/2020 10:44 AM - * @UpdateRemark: - * @Version: 1.0 - * Copyright: Copyright (c) 2020 - */ -public class JenkinsTreeRendererTest extends TestCase { - @Test - public void testOptional() { - List integerList = null; - Optional> optional = Optional.ofNullable(integerList); - String result = optional.flatMap(integers -> integers.stream() - .map(Object::toString) - .reduce((a, b) -> a + b)).orElse("null") - ; - } - -} \ No newline at end of file From 1459a87fcf1d396add6d6680ba231b3de2f0f713 Mon Sep 17 00:00:00 2001 From: zoutairan Date: Fri, 11 Sep 2020 01:19:20 +0800 Subject: [PATCH 10/12] modify unit test --- .../org/codinjutsu/tools/jenkins/logic/UrlBuilderTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/java/org/codinjutsu/tools/jenkins/logic/UrlBuilderTest.java b/src/test/java/org/codinjutsu/tools/jenkins/logic/UrlBuilderTest.java index 48ac9bad..23a872e4 100644 --- a/src/test/java/org/codinjutsu/tools/jenkins/logic/UrlBuilderTest.java +++ b/src/test/java/org/codinjutsu/tools/jenkins/logic/UrlBuilderTest.java @@ -63,19 +63,19 @@ public void createJenkinsWorkspaceUrl() { @Test public void createViewUrlForClassicPlateform() { URL url = urlBuilder.createViewUrl(JenkinsPlateform.CLASSIC, "http://localhost:8080/jenkins/My%20View"); - assertThat(url.toString()).isEqualTo("http://localhost:8080/jenkins/My%20View/api/json?tree=name,url,jobs%5Bname,fullName,displayName,fullDisplayName,jobs,url,color,buildable,inQueue,healthReport%5Bdescription,iconUrl%5D,lastBuild%5Burl,id,building,result,number,displayName,fullDisplayName,timestamp,duration%5D,lastFailedBuild%5Burl%5D,lastSuccessfulBuild%5Burl%5D,property%5BparameterDefinitions%5Bname,type,defaultParameterValue%5Bvalue%5D,description,choices%5D%5D%5D"); + assertThat(url.toString()).isEqualTo("http://localhost:8080/jenkins/My%20View/api/json?tree=name,url,jobs%5Bname,fullName,displayName,fullDisplayName,jobs,url,color,buildable,inQueue,healthReport%5Bdescription,iconUrl%5D,lastBuild%5Burl,id,building,result,number,displayName,fullDisplayName,timestamp,duration,actions%5Bparameters%5Bname,value%5D%5D%5D,lastFailedBuild%5Burl%5D,lastSuccessfulBuild%5Burl%5D,property%5BparameterDefinitions%5Bname,type,defaultParameterValue%5Bvalue%5D,description,choices%5D%5D%5D"); } @Test public void createJobJSONUrl() { URL url = urlBuilder.createJobUrl("http://localhost:8080/jenkins/my%20Job"); - assertThat(url.toString()).isEqualTo("http://localhost:8080/jenkins/my%20Job/api/json?tree=name,fullName,displayName,fullDisplayName,jobs,url,color,buildable,inQueue,healthReport%5Bdescription,iconUrl%5D,lastBuild%5Burl,id,building,result,number,displayName,fullDisplayName,timestamp,duration%5D,lastFailedBuild%5Burl%5D,lastSuccessfulBuild%5Burl%5D,property%5BparameterDefinitions%5Bname,type,defaultParameterValue%5Bvalue%5D,description,choices%5D%5D"); + assertThat(url.toString()).isEqualTo("http://localhost:8080/jenkins/my%20Job/api/json?tree=name,fullName,displayName,fullDisplayName,jobs,url,color,buildable,inQueue,healthReport%5Bdescription,iconUrl%5D,lastBuild%5Burl,id,building,result,number,displayName,fullDisplayName,timestamp,duration,actions%5Bparameters%5Bname,value%5D%5D%5D,lastFailedBuild%5Burl%5D,lastSuccessfulBuild%5Burl%5D,property%5BparameterDefinitions%5Bname,type,defaultParameterValue%5Bvalue%5D,description,choices%5D%5D"); } @Test public void createViewUrlForCloudbeesPlateform() { URL url = urlBuilder.createViewUrl(JenkinsPlateform.CLOUDBEES, "http://localhost:8080/jenkins/My%20View"); - assertThat(url.toString()).isEqualTo("http://localhost:8080/jenkins/My%20View/api/json?tree=name,url,views%5Bjobs%5Bname,fullName,displayName,fullDisplayName,jobs,url,color,buildable,inQueue,healthReport%5Bdescription,iconUrl%5D,lastBuild%5Burl,id,building,result,number,displayName,fullDisplayName,timestamp,duration%5D,lastFailedBuild%5Burl%5D,lastSuccessfulBuild%5Burl%5D,property%5BparameterDefinitions%5Bname,type,defaultParameterValue%5Bvalue%5D,description,choices%5D%5D%5D%5D"); + assertThat(url.toString()).isEqualTo("http://localhost:8080/jenkins/My%20View/api/json?tree=name,url,views%5Bjobs%5Bname,fullName,displayName,fullDisplayName,jobs,url,color,buildable,inQueue,healthReport%5Bdescription,iconUrl%5D,lastBuild%5Burl,id,building,result,number,displayName,fullDisplayName,timestamp,duration,actions%5Bparameters%5Bname,value%5D%5D%5D,lastFailedBuild%5Burl%5D,lastSuccessfulBuild%5Burl%5D,property%5BparameterDefinitions%5Bname,type,defaultParameterValue%5Bvalue%5D,description,choices%5D%5D%5D%5D"); } @Test From 70502ced56e1056a0dfdc277d59fbe9a7939f2a4 Mon Sep 17 00:00:00 2001 From: mcmics Date: Wed, 7 Oct 2020 08:43:52 +0200 Subject: [PATCH 11/12] Review Changes for PR #246 --- .../codinjutsu/tools/jenkins/JenkinsTree.java | 18 ++++++++---------- .../codinjutsu/tools/jenkins/model/Build.java | 6 ++++-- .../tools/jenkins/model/BuildParameter.java | 11 +++-------- .../tools/jenkins/view/JenkinsTreeNode.java | 5 +++++ .../jenkins/view/JenkinsTreeRenderer.java | 11 ++++++++--- 5 files changed, 28 insertions(+), 23 deletions(-) diff --git a/src/main/java/org/codinjutsu/tools/jenkins/JenkinsTree.java b/src/main/java/org/codinjutsu/tools/jenkins/JenkinsTree.java index 1da0e268..4822649d 100644 --- a/src/main/java/org/codinjutsu/tools/jenkins/JenkinsTree.java +++ b/src/main/java/org/codinjutsu/tools/jenkins/JenkinsTree.java @@ -62,8 +62,6 @@ public JenkinsTree(Project project, @NotNull JenkinsSettings jenkinsSettings, Je BuildStatusEnumRenderer.getInstance(project))); this.tree.setName("jobTree"); this.tree.setModel(new DefaultTreeModel(new DefaultMutableTreeNode(new JenkinsTreeNode.RootNode(this.jenkins)), false)); - //final JobTreeHandler jobTreeHandler = new JobTreeHandler(project); - //addTreeWillExpandListener(jobTreeHandler); this.tree.addMouseListener(new JobClickHandler()); } @@ -94,7 +92,7 @@ public static Optional getLastSelectedPath(@NotNull TreePath treePath, @N } @NotNull - private static DefaultMutableTreeNode createNode(BuildParameter buildParameter) { + private static DefaultMutableTreeNode createNode(@NotNull BuildParameter buildParameter) { return new DefaultMutableTreeNode(new JenkinsTreeNode.BuildParameterNode(buildParameter), true); } @@ -122,20 +120,20 @@ private static Comparator wrapJobSorter(Comparator } @NotNull - public DefaultMutableTreeNode fillJobTree(@NotNull Job job, @NotNull DefaultMutableTreeNode jobNode) { + public static DefaultMutableTreeNode fillJobTree(@NotNull Job job, @NotNull DefaultMutableTreeNode jobNode) { jobNode.removeAllChildren(); if (job.getJobType().containNestedJobs()) { - job.getNestedJobs().stream().map(this::createJobTree).forEach(jobNode::add); + job.getNestedJobs().stream().map(JenkinsTree::createJobTree).forEach(jobNode::add); } else { - job.getLastBuilds().stream().map(this::initBuildNode).forEach(jobNode::add); + job.getLastBuilds().stream().map(JenkinsTree::initBuildNode).forEach(jobNode::add); } return jobNode; } @NotNull - private DefaultMutableTreeNode initBuildNode(Build build) { + private static DefaultMutableTreeNode initBuildNode(Build build) { val buildNode = createNode(build); - Optional.ofNullable(build.getBuildParameterList()) + Optional.of(build.getBuildParameterList()) .ifPresent(buildParameters -> buildParameters.stream() .map(JenkinsTree::createNode) .forEach(buildNode::add) @@ -144,7 +142,7 @@ private DefaultMutableTreeNode initBuildNode(Build build) { } @NotNull - private DefaultMutableTreeNode createJobTree(Job job) { + private static DefaultMutableTreeNode createJobTree(Job job) { return fillJobTree(job, createNode(job)); } @@ -188,7 +186,7 @@ public void setJobs(@NotNull final Collection jobs) { private void setJobs(@NotNull final Collection jobs, @NotNull DefaultMutableTreeNode rootNode) { rootNode.removeAllChildren(); - jobs.stream().map(this::createJobTree).forEach(rootNode::add); + jobs.stream().map(JenkinsTree::createJobTree).forEach(rootNode::add); tree.setRootVisible(true); } diff --git a/src/main/java/org/codinjutsu/tools/jenkins/model/Build.java b/src/main/java/org/codinjutsu/tools/jenkins/model/Build.java index b17377e4..9f3ed9d4 100644 --- a/src/main/java/org/codinjutsu/tools/jenkins/model/Build.java +++ b/src/main/java/org/codinjutsu/tools/jenkins/model/Build.java @@ -24,6 +24,7 @@ import java.text.SimpleDateFormat; import java.util.Date; +import java.util.LinkedList; import java.util.List; import java.util.Optional; @@ -57,8 +58,9 @@ public class Build { @NotNull @Builder.Default private final BuildStatusEnum status = BuildStatusEnum.NULL; - @Nullable - private final List buildParameterList; + @Builder.Default + @NotNull + private final List buildParameterList = new LinkedList<>(); @NotNull public static Build createBuildFromWorkspace(String buildUrl, int number, String status, boolean isBuilding, String buildDate, Long timestamp, Long duration) { diff --git a/src/main/java/org/codinjutsu/tools/jenkins/model/BuildParameter.java b/src/main/java/org/codinjutsu/tools/jenkins/model/BuildParameter.java index 5e4beeaf..baf712dc 100644 --- a/src/main/java/org/codinjutsu/tools/jenkins/model/BuildParameter.java +++ b/src/main/java/org/codinjutsu/tools/jenkins/model/BuildParameter.java @@ -4,6 +4,7 @@ import lombok.Data; import lombok.experimental.Accessors; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; @Data @Accessors(chain = true) @@ -11,17 +12,11 @@ public class BuildParameter { @NotNull private String name; - @NotNull + @Nullable private String value; @NotNull - public static BuildParameter of(@NotNull String name, @NotNull String value) { + public static BuildParameter of(@NotNull String name, @Nullable String value) { return new BuildParameter(name, value); } - - @Override - @NotNull - public String toString() { - return String.format("%s: %s", name, value); - } } diff --git a/src/main/java/org/codinjutsu/tools/jenkins/view/JenkinsTreeNode.java b/src/main/java/org/codinjutsu/tools/jenkins/view/JenkinsTreeNode.java index cf123709..edaccdb7 100644 --- a/src/main/java/org/codinjutsu/tools/jenkins/view/JenkinsTreeNode.java +++ b/src/main/java/org/codinjutsu/tools/jenkins/view/JenkinsTreeNode.java @@ -54,6 +54,7 @@ default boolean canNavigateToSource() { @Data class BuildParameterNode implements JenkinsTreeNode { + @NotNull private final BuildParameter buildParameter; @NotNull @@ -66,6 +67,10 @@ public String getUrl() { public void render(JenkinsTreeNodeVisitor treeNodeRenderer) { treeNodeRenderer.visit(this); } + + public boolean hasValue() { + return buildParameter.getValue() != null; + } } @Value diff --git a/src/main/java/org/codinjutsu/tools/jenkins/view/JenkinsTreeRenderer.java b/src/main/java/org/codinjutsu/tools/jenkins/view/JenkinsTreeRenderer.java index 7311d03e..1feec9cc 100644 --- a/src/main/java/org/codinjutsu/tools/jenkins/view/JenkinsTreeRenderer.java +++ b/src/main/java/org/codinjutsu/tools/jenkins/view/JenkinsTreeRenderer.java @@ -24,11 +24,9 @@ import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; import lombok.experimental.Delegate; -import lombok.val; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.time.DurationFormatUtils; import org.codinjutsu.tools.jenkins.model.Build; -import org.codinjutsu.tools.jenkins.model.BuildParameter; import org.codinjutsu.tools.jenkins.model.BuildStatusEnum; import org.codinjutsu.tools.jenkins.model.Jenkins; import org.codinjutsu.tools.jenkins.model.Job; @@ -198,7 +196,14 @@ private void render(JenkinsTreeNode.JobNode jobNode, @NotNull Optional } private void render(JenkinsTreeNode.BuildParameterNode buildParameterNode) { - append(buildParameterNode.getBuildParameter().toString(), SimpleTextAttributes.REGULAR_ITALIC_ATTRIBUTES); + final String parameter; + if (buildParameterNode.hasValue()) { + parameter = String.format("%s: %s", buildParameterNode.getBuildParameter().getName(), + buildParameterNode.getBuildParameter().getValue()); + } else { + parameter = buildParameterNode.getBuildParameter().getName(); + } + append(parameter, SimpleTextAttributes.REGULAR_ITALIC_ATTRIBUTES); } private static class CompositeIcon implements Icon { From 9228f834ac5c88c6c1e4c561ff5af3051d788c97 Mon Sep 17 00:00:00 2001 From: zoutairan Date: Mon, 12 Oct 2020 17:58:02 +0800 Subject: [PATCH 12/12] Optimize Code --- .../codinjutsu/tools/jenkins/logic/JenkinsJsonParser.java | 7 ++++--- .../codinjutsu/tools/jenkins/model/BuildParameter.java | 6 ++++-- .../codinjutsu/tools/jenkins/view/ConfigurationPanel.form | 4 ++-- .../codinjutsu/tools/jenkins/view/ConfigurationPanel.java | 6 +++--- .../codinjutsu/tools/jenkins/view/JenkinsTreeNode.java | 8 +++++++- 5 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/codinjutsu/tools/jenkins/logic/JenkinsJsonParser.java b/src/main/java/org/codinjutsu/tools/jenkins/logic/JenkinsJsonParser.java index cad79401..c148f4b2 100644 --- a/src/main/java/org/codinjutsu/tools/jenkins/logic/JenkinsJsonParser.java +++ b/src/main/java/org/codinjutsu/tools/jenkins/logic/JenkinsJsonParser.java @@ -191,7 +191,7 @@ private Build getBuild(@Nullable JsonObject lastBuildObject) { .findFirst() ) .ifPresent(action -> - builder.buildParameterList(getBuildParameters((JsonObject) action)) + builder.buildParameterList(getBuildParameters((JsonObject) action, url)) ); return builder.build(); } @@ -202,11 +202,12 @@ private JsonArray getActions(@NotNull JsonObject lastBuildObject) { } @NotNull - private List getBuildParameters(JsonObject action) { + private List getBuildParameters(JsonObject action, String buildUrl) { return action.getCollection(createJsonKey(PARAMETERS)).stream() .map(parameter -> BuildParameter.of( ((JsonObject) parameter).getString(createJsonKey("name")), - ((JsonObject) parameter).getString(createJsonKey("value")) + ((JsonObject) parameter).getString(createJsonKey("value")), + buildUrl )) .collect(Collectors.toList()); } diff --git a/src/main/java/org/codinjutsu/tools/jenkins/model/BuildParameter.java b/src/main/java/org/codinjutsu/tools/jenkins/model/BuildParameter.java index baf712dc..014a47e8 100644 --- a/src/main/java/org/codinjutsu/tools/jenkins/model/BuildParameter.java +++ b/src/main/java/org/codinjutsu/tools/jenkins/model/BuildParameter.java @@ -14,9 +14,11 @@ public class BuildParameter { private String name; @Nullable private String value; + @NotNull + private String buildUrl; @NotNull - public static BuildParameter of(@NotNull String name, @Nullable String value) { - return new BuildParameter(name, value); + public static BuildParameter of(@NotNull String name, @Nullable String value, @NotNull String buildUrl) { + return new BuildParameter(name, value, buildUrl); } } diff --git a/src/main/java/org/codinjutsu/tools/jenkins/view/ConfigurationPanel.form b/src/main/java/org/codinjutsu/tools/jenkins/view/ConfigurationPanel.form index 15d8dfc6..f1167963 100644 --- a/src/main/java/org/codinjutsu/tools/jenkins/view/ConfigurationPanel.form +++ b/src/main/java/org/codinjutsu/tools/jenkins/view/ConfigurationPanel.form @@ -437,12 +437,12 @@ - + - + diff --git a/src/main/java/org/codinjutsu/tools/jenkins/view/ConfigurationPanel.java b/src/main/java/org/codinjutsu/tools/jenkins/view/ConfigurationPanel.java index 4ef3a413..5cdee2b9 100644 --- a/src/main/java/org/codinjutsu/tools/jenkins/view/ConfigurationPanel.java +++ b/src/main/java/org/codinjutsu/tools/jenkins/view/ConfigurationPanel.java @@ -77,7 +77,7 @@ public class ConfigurationPanel { private JCheckBox useGreenColor; @GuiField(validators = POSITIVE_INTEGER) private JBIntSpinner timeout; - private JCheckBox autoLoadBuilds; + private JCheckBox autoLoadBuildsOnFirstLevel; private boolean myPasswordModified = false; public ConfigurationPanel(final Project project) { @@ -259,11 +259,11 @@ private void setUseGreenColor(boolean useGreenColor) { } private boolean getAutoLoadBuilds() { - return autoLoadBuilds.isSelected(); + return autoLoadBuildsOnFirstLevel.isSelected(); } private void setAutoLoadBuilds(boolean autoLoadBuilds) { - this.autoLoadBuilds.setSelected(autoLoadBuilds); + this.autoLoadBuildsOnFirstLevel.setSelected(autoLoadBuilds); } private boolean isShowAllInStatusbar() { diff --git a/src/main/java/org/codinjutsu/tools/jenkins/view/JenkinsTreeNode.java b/src/main/java/org/codinjutsu/tools/jenkins/view/JenkinsTreeNode.java index edaccdb7..9d6dad22 100644 --- a/src/main/java/org/codinjutsu/tools/jenkins/view/JenkinsTreeNode.java +++ b/src/main/java/org/codinjutsu/tools/jenkins/view/JenkinsTreeNode.java @@ -60,7 +60,13 @@ class BuildParameterNode implements JenkinsTreeNode { @NotNull @Override public String getUrl() { - return ""; + return buildParameter.getBuildUrl(); + } + + @NotNull + @Override + public String getName() { + return buildParameter.getName(); } @Override