Skip to content

Added a toggle Action Button to allow the user to switch the labelling of warnings in the plugin #134

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rdaultonGT
Copy link

Added a toggle Action Button to allow the user to switch the labelling of warnings in the plugin between RuleId or Description. This is useful for users who prefer to see the RuleId instead of the Description, or vice versa.

…g of warnings in the plugin

between RuleId or Description. This is useful for users who prefer to see the RuleId instead of
the Description, or vice versa.
Copy link
Collaborator

@adrienpessu adrienpessu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With few modifications it should work.
Can you also make this toggle saved in the SettingsState

Comment on lines +59 to +63
var key = "init"
if (view.ruleIdToggle)
key = result.rule?.id ?: result.correlationGuid?.toString() ?: result.message.text
else
key = result.rule?.id ?: result.correlationGuid?.toString() ?: result.ruleId
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

var key = if (view.ruleIdToggle)
                                (result?.message?.text ?: result.rule?.id ?: result.correlationGuid?.toString())!!
                            else
                                (result?.ruleId ?: result.rule?.id ?: result.correlationGuid?.toString())!!

extractSarifFromFile = extractSarifFromFile(selectedFile)
treeBuilding(extractSarifFromFile)
}
}
fun openLocalFile() {
val fileChooser = JFileChooser()
fileChooser.fileFilter = FileNameExtensionFilter("SARIF files", "sarif")
SwingUtilities.invokeLater {
val returnValue = fileChooser.showOpenDialog(null)
if (returnValue == JFileChooser.APPROVE_OPTION) {
val selectedFile: File = fileChooser.selectedFile
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
val selectedFile: File = fileChooser.selectedFile
selectedFile = fileChooser.selectedFile

without that the selectedFile attribute is never initiated and the toggle doesn't refresh the tree

@@ -10,6 +10,8 @@
<resource-bundle>messages.MyBundle</resource-bundle>

<actions>
<action id="RuleIDorDescriptionAction" icon="AllIcons.Actions.Diff" class="com.github.adrienpessu.sarifviewer.actions.RuleIDorDescriptionAction" text="Toggle Rule ID or Description">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found the AllIcons.Actions.Diff misleading.
Could you use a more neutral icon like : AllIcons.Debugger.VariablesTab and make it change color when toggled (using AllIcons.Debugger.Value for example)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants