-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split up result tree node instead of reusing for multiple things
- Loading branch information
Showing
5 changed files
with
139 additions
and
137 deletions.
There are no files selected for viewing
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
47 changes: 47 additions & 0 deletions
47
src/main/java/org/infernus/idea/checkstyle/toolwindow/FileResultTreeNode.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,47 @@ | ||
package org.infernus.idea.checkstyle.toolwindow; | ||
|
||
import com.intellij.icons.AllIcons; | ||
import org.infernus.idea.checkstyle.CheckStyleBundle; | ||
|
||
public class FileResultTreeNode extends ResultTreeNode { | ||
|
||
private final String fileName; | ||
private final int totalProblems; | ||
private int visibleProblems; | ||
|
||
/** | ||
* Construct a file node. | ||
* | ||
* @param fileName the name of the file. | ||
* @param problemCount the number of problems in the file. | ||
*/ | ||
public FileResultTreeNode(final String fileName, final int problemCount) { | ||
super(CheckStyleBundle.message("plugin.results.scan-file-result", fileName, problemCount)); | ||
|
||
if (fileName == null) { | ||
throw new IllegalArgumentException("Filename may not be null"); | ||
} | ||
|
||
this.fileName = fileName; | ||
this.totalProblems = problemCount; | ||
this.visibleProblems = problemCount; | ||
|
||
updateTextForFileNode(); | ||
|
||
setIcon(AllIcons.FileTypes.Java); | ||
} | ||
|
||
private void updateTextForFileNode() { | ||
if (totalProblems == visibleProblems) { | ||
setText(CheckStyleBundle.message("plugin.results.scan-file-result", fileName, totalProblems)); | ||
} else { | ||
setText(CheckStyleBundle.message("plugin.results.scan-file-result.filtered", fileName, visibleProblems, totalProblems - visibleProblems)); | ||
} | ||
} | ||
|
||
void setVisibleProblems(final int visibleProblems) { | ||
this.visibleProblems = visibleProblems; | ||
|
||
updateTextForFileNode(); | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
src/main/java/org/infernus/idea/checkstyle/toolwindow/ProblemResultTreeNode.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,77 @@ | ||
package org.infernus.idea.checkstyle.toolwindow; | ||
|
||
import com.intellij.icons.AllIcons; | ||
import com.intellij.psi.PsiFile; | ||
import org.infernus.idea.checkstyle.CheckStyleBundle; | ||
import org.infernus.idea.checkstyle.checker.Problem; | ||
import org.infernus.idea.checkstyle.csapi.SeverityLevel; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class ProblemResultTreeNode extends ResultTreeNode { | ||
|
||
private final PsiFile file; | ||
private final Problem problem; | ||
private final SeverityLevel severity; | ||
|
||
/** | ||
* Construct a node for a given problem. | ||
* | ||
* @param file the file the problem exists in. | ||
* @param problem the problem. | ||
*/ | ||
public ProblemResultTreeNode(@NotNull final PsiFile file, | ||
@NotNull final Problem problem) { | ||
super(CheckStyleBundle.message("plugin.results.file-result", | ||
file.getName(), | ||
problem.message(), | ||
problem.line(), | ||
Integer.toString(problem.column()), | ||
problem.sourceCheck())); | ||
|
||
this.file = file; | ||
this.problem = problem; | ||
|
||
severity = problem.severityLevel(); | ||
|
||
updateIconsForProblem(); | ||
} | ||
|
||
private void updateIconsForProblem() { | ||
if (SeverityLevel.Ignore.equals(severity)) { | ||
setIcon(AllIcons.General.Note); | ||
} else if (SeverityLevel.Warning.equals(severity)) { | ||
setIcon(AllIcons.General.Warning); | ||
} else if (SeverityLevel.Info.equals(severity)) { | ||
setIcon(AllIcons.General.Information); | ||
} else { | ||
setIcon(AllIcons.General.Error); | ||
} | ||
} | ||
|
||
/** | ||
* Get the file associated with this node. | ||
* | ||
* @return the file associated with this node. | ||
*/ | ||
public PsiFile getFile() { | ||
return file; | ||
} | ||
|
||
/** | ||
* Get the problem associated with this node. | ||
* | ||
* @return the problem associated with this node. | ||
*/ | ||
public Problem getProblem() { | ||
return problem; | ||
} | ||
|
||
/** | ||
* Get the severity of the problem. | ||
* | ||
* @return the severity, or null if not applicable. | ||
*/ | ||
public SeverityLevel getSeverity() { | ||
return severity; | ||
} | ||
} |
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
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