-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve search within Jenkins Tree
- Loading branch information
Showing
2 changed files
with
56 additions
and
29 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
src/main/java/org/codinjutsu/tools/jenkins/JenkinsTree.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package org.codinjutsu.tools.jenkins; | ||
|
||
import com.intellij.openapi.project.Project; | ||
import com.intellij.ui.TreeUIHelper; | ||
import com.intellij.ui.treeStructure.SimpleTree; | ||
import com.intellij.util.containers.Convertor; | ||
import org.codinjutsu.tools.jenkins.model.Jenkins; | ||
import org.codinjutsu.tools.jenkins.model.Job; | ||
import org.codinjutsu.tools.jenkins.view.BuildStatusEnumRenderer; | ||
import org.codinjutsu.tools.jenkins.view.JenkinsTreeRenderer; | ||
import org.codinjutsu.tools.jenkins.view.JobClickHandler; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import javax.swing.tree.DefaultMutableTreeNode; | ||
import javax.swing.tree.DefaultTreeModel; | ||
import javax.swing.tree.TreePath; | ||
|
||
public class JenkinsTree extends SimpleTree { | ||
private static final String LOADING = "Loading..."; | ||
private final transient Project project; | ||
@NotNull | ||
private final JenkinsSettings jenkinsSettings; | ||
private final Jenkins jenkins; | ||
|
||
public JenkinsTree(Project project, @NotNull JenkinsSettings jenkinsSettings, Jenkins jenkins) { | ||
super(); | ||
this.project = project; | ||
this.jenkinsSettings = jenkinsSettings; | ||
this.jenkins = jenkins; | ||
getEmptyText().setText(LOADING); | ||
setCellRenderer(new JenkinsTreeRenderer(this.jenkinsSettings::isFavoriteJob, | ||
BuildStatusEnumRenderer.getInstance(this.project))); | ||
setName("jobTree"); | ||
setModel(new DefaultTreeModel(new DefaultMutableTreeNode(this.jenkins), false)); | ||
//final JobTreeHandler jobTreeHandler = new JobTreeHandler(project); | ||
//addTreeWillExpandListener(jobTreeHandler); | ||
addMouseListener(new JobClickHandler()); | ||
} | ||
|
||
@Override | ||
protected void configureUiHelper(TreeUIHelper helper) { | ||
final Convertor<TreePath, String> convertor = treePath -> { | ||
final DefaultMutableTreeNode node = (DefaultMutableTreeNode) treePath.getLastPathComponent(); | ||
final Object userObject = node.getUserObject(); | ||
if (userObject instanceof Job) { | ||
//return ((Job) userObject).getNameToRenderSingleJob(); | ||
return ((Job) userObject).preferDisplayName(); | ||
} | ||
return ""; | ||
}; | ||
helper.installTreeSpeedSearch(this, convertor, true); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters