File tree Expand file tree Collapse file tree 2 files changed +14
-5
lines changed
tray-util/src/main/scala/com/github/opengrabeso/loctio Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -27,10 +27,16 @@ class HtmlPanel(baseUri: String) extends Panel {
2727 }
2828 }
2929
30- def html : String = throw new UnsupportedOperationException (" HTML document is write only" )
30+ private var htmlValue : String = " "
31+
32+ def html : String = htmlValue
3133 def html_= (text : String ): Unit = {
32- val is = new ByteArrayInputStream (text.getBytes(Charset .forName(" UTF-8" )))
33- val url = baseUri
34- peer.setDocument(is, url + " /" )
34+ // avoid loading the document unless necessary, as loading is quite slow
35+ if (htmlValue != text) {
36+ htmlValue = text
37+ val is = new ByteArrayInputStream (text.getBytes(Charset .forName(" UTF-8" )))
38+ val url = baseUri
39+ peer.setDocument(is, url + " /" )
40+ }
3541 }
3642}
Original file line number Diff line number Diff line change @@ -428,7 +428,10 @@ object Start extends SimpleSwingApplication {
428428 assert(SwingUtilities .isEventDispatchThread)
429429 state = s
430430 val text = if (state.isEmpty) appName else state
431- icon.setToolTip(text)
431+ // setting tooltip is a system call, it might be quite slow, avoid it unless necessary
432+ if (text != icon.getToolTip) {
433+ icon.setToolTip(text)
434+ }
432435 }
433436 }
434437
You can’t perform that action at this time.
0 commit comments