forked from lowkeyfish/sonar-intellij-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
nanguoqiang
committed
Mar 14, 2023
1 parent
1b993be
commit 7f85d15
Showing
12 changed files
with
294 additions
and
14 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
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 |
---|---|---|
|
@@ -133,7 +133,12 @@ Project级别设置主要包含: | |
* 解决 | ||
* 已解决 | ||
* 未解决 | ||
|
||
* 严重程度 | ||
* 阻断 | ||
* 严重 | ||
* 主要 | ||
* 次要 | ||
* 提示 | ||
|
||
## 如何贡献 | ||
|
||
|
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
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
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
77 changes: 77 additions & 0 deletions
77
src/main/java/com/yujunyang/intellij/plugin/sonar/gui/toolwindow/SearchPanel.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 com.yujunyang.intellij.plugin.sonar.gui.toolwindow; | ||
|
||
import com.google.common.base.Splitter; | ||
import com.intellij.icons.AllIcons; | ||
import com.intellij.openapi.project.Project; | ||
import com.intellij.ui.components.JBBox; | ||
import com.intellij.ui.components.JBLabel; | ||
import com.intellij.ui.components.JBPanel; | ||
import com.intellij.ui.components.JBTextField; | ||
import com.intellij.util.ui.JBUI; | ||
import com.yujunyang.intellij.plugin.sonar.messages.MessageBusManager; | ||
import com.yujunyang.intellij.plugin.sonar.service.ProblemCacheService; | ||
import org.apache.commons.lang3.StringUtils; | ||
|
||
import javax.swing.*; | ||
import java.awt.*; | ||
import java.awt.event.KeyAdapter; | ||
import java.awt.event.KeyEvent; | ||
import java.util.Set; | ||
|
||
public class SearchPanel extends JBPanel { | ||
|
||
private final Project project; | ||
|
||
private JBTextField searchField; | ||
|
||
private JButton searchButton; | ||
|
||
public SearchPanel(Project project) { | ||
this.project = project; | ||
setLayout(new BorderLayout()); | ||
init(); | ||
} | ||
|
||
private void init() { | ||
JBBox horizontalBox = JBBox.createHorizontalBox(); | ||
horizontalBox.setBorder(JBUI.Borders.empty(2, 5)); | ||
|
||
horizontalBox.add(new JBLabel("RuleKey: ")); | ||
|
||
searchField = new JBTextField(""); | ||
searchField.getEmptyText().setText("Example:S112 S3518"); | ||
horizontalBox.add(searchField); | ||
|
||
searchButton = new JButton(AllIcons.Actions.Search); | ||
horizontalBox.add(searchButton); | ||
|
||
searchField.addKeyListener(new KeyAdapter() { | ||
@Override | ||
public void keyPressed(KeyEvent e) { | ||
if (e.getKeyCode() == KeyEvent.VK_ENTER) { | ||
searchButton.doClick(); | ||
} | ||
} | ||
}); | ||
|
||
searchButton.addActionListener(actionEvent -> { | ||
Set<String> ruleKeys = ProblemCacheService.getInstance(project).getRuleKeys(); | ||
ruleKeys.clear(); | ||
String ruleKey = searchField.getText(); | ||
if (StringUtils.isNoneBlank(ruleKey)) { | ||
Splitter.on(" ") | ||
.omitEmptyStrings() | ||
.trimResults() | ||
.split(ruleKey.toUpperCase()) | ||
.forEach(ruleKeys::add); | ||
} | ||
MessageBusManager.publishIssueFilter(project); | ||
}); | ||
|
||
add(horizontalBox, BorderLayout.CENTER); | ||
} | ||
|
||
public void reset() { | ||
searchField.setText(""); | ||
} | ||
} |
Oops, something went wrong.