Skip to content

Commit

Permalink
Fixed tray issue on non-display devices.
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin committed Sep 30, 2018
1 parent 686657d commit 92adb3c
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion webapp/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#

version=1.0.0
version=1.0.1
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@

package cz.babi.gcunicorn.webapp.desktop

import cz.babi.gcunicorn.`fun`.loggerFor
import org.springframework.context.annotation.Condition
import org.springframework.context.annotation.ConditionContext
import org.springframework.core.type.AnnotatedTypeMetadata
import java.awt.AWTError
import java.awt.SystemTray

/**
Expand All @@ -33,5 +35,17 @@ import java.awt.SystemTray
* @since 1.0.0
*/
class TrayCondition : Condition {
override fun matches(context: ConditionContext, metadata: AnnotatedTypeMetadata) = SystemTray.isSupported() && context.environment.containsProperty("tray")

companion object {
private val LOG = loggerFor<TrayCondition>()
}

override fun matches(context: ConditionContext, metadata: AnnotatedTypeMetadata): Boolean {
return try {
context.environment.containsProperty("tray") && SystemTray.isSupported()
} catch (e: AWTError) {
LOG.warn("Tray is not supported.", e)
false
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ import org.springframework.web.bind.annotation.ModelAttribute
class VersionControllerAdvice {

@ModelAttribute(name = "versionCore")
fun coreVersion() = VersionControllerAdvice::class.java.`package`?.implementationVersion ?: "unknown"
fun versionCore() = Service::class.java.`package`?.implementationVersion ?: "unknown"

@ModelAttribute(name = "versionServer")
fun uiVersion() = Service::class.java.`package`?.implementationVersion ?: "unknown"
@ModelAttribute(name = "versionWebapp")
fun versionWebapp() = VersionControllerAdvice::class.java.`package`?.implementationVersion ?: "unknown"
}
2 changes: 1 addition & 1 deletion webapp/src/main/resources/templates/fragment/version.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<body>
<div th:fragment="version" th:utext="${'core: v' + versionCore + ' & server: v' + versionServer}"></div>
<div th:fragment="version" th:utext="${'core: v' + versionCore + ' & webapp: v' + versionWebapp}"></div>
</body>
</html>

0 comments on commit 92adb3c

Please sign in to comment.