add some helpful links

This commit is contained in:
Rasmus Moorats 2024-07-04 14:25:37 +03:00
parent 8dd6563abe
commit b581c370b2
Signed by: xx
GPG key ID: FE14255A6AE7241C
2 changed files with 80 additions and 1 deletions

View file

@ -0,0 +1,72 @@
package ui
import burp.Log
import java.awt.Cursor
import java.awt.Desktop
import java.awt.event.MouseAdapter
import java.awt.event.MouseEvent
import java.awt.font.TextAttribute
import java.io.IOException
import java.net.URI
import javax.swing.JLabel
import javax.swing.SwingUtilities
import javax.swing.UIManager
class JHyperLink(
linkText: String,
uri: String
) : JLabel(linkText) {
private var linkUri: URI = URI.create(uri)
init {
toolTipText = linkUri.toString()
setUnderline(true)
foreground = UIManager.getColor("Component.linkColor")
UIManager.addPropertyChangeListener { e ->
if ("lookAndFeel" == e.propertyName) {
SwingUtilities.invokeLater {
foreground = UIManager.getColor("Component.linkColor")
}
}
}
addMouseListener(object : MouseAdapter() {
override fun mouseClicked(e: MouseEvent) {
open(linkUri)
}
override fun mouseEntered(e: MouseEvent) {
cursor = Cursor(Cursor.HAND_CURSOR)
setUnderline(false)
}
override fun mouseExited(e: MouseEvent) {
cursor = Cursor(Cursor.DEFAULT_CURSOR)
setUnderline(true)
}
})
}
private fun setUnderline(to: Boolean) {
val curFont = font
val attributes = curFont.attributes.toMutableMap()
attributes[TextAttribute.UNDERLINE] = if (to) TextAttribute.UNDERLINE_ON else -1
font = curFont.deriveFont(attributes)
}
companion object {
fun open(uri: URI) {
if (Desktop.isDesktopSupported()) {
try {
Desktop.getDesktop().browse(uri)
} catch (e: IOException) {
Log.error("Error when trying to open link: $uri", e)
}
} else {
Log.error("Attempted to open URI $uri, but Desktop is not supported")
}
}
}
}

View file

@ -9,6 +9,7 @@ import burp.api.montoya.core.ToolType
import burp.api.montoya.persistence.Preferences
import net.miginfocom.swing.MigLayout
import org.fife.ui.rtextarea.RTextScrollPane
import ui.JHyperLink
import java.awt.Component
import java.awt.Font
import java.awt.event.ComponentAdapter
@ -119,7 +120,13 @@ class MainActivity(
add(createToolsPanel())
add(JSeparator(), "growx")
add(JLabel("Settings").apply { font = font.deriveFont(Font.BOLD) })
add(JPanel(MigLayout()).apply { add(enabledToggle) })
add(JPanel(MigLayout("fillx, wrap", "[fill]")).apply {
add(enabledToggle, "align left top")
}, "growy, pushy")
add(JPanel(MigLayout("fillx, align left top, wrap, ins 0 n 0 n", "[][]")).apply {
add(JHyperLink("Source", "https://git.dog/xx/burp-elastic-pusher"), "split 2")
add(JHyperLink("Documentation", "https://git.dog/xx/burp-elastic-pusher/wiki"))
})
}
private fun createValuesPanel() = JPanel(MigLayout("", "[fill][fill]")).apply {