Singleton service for checking application version against GitHub releases.
More...
|
| | VersionService () |
| | Initializes the HTTP client with TLS 1.3 and 5-second timeout.
|
| |
| SwingWorker< Boolean, Void > | checkLatestVersion (String currentVersion, JButton updateButton) |
| | Asynchronously checks whether the current application version matches the latest GitHub release tag.
|
| |
|
| SwingWorker< Boolean, Void > | npeCheckLatestVersion (String currentVersion, JButton updateButton) |
| | Validates input for version check.
|
| |
| Boolean | requestAndVerify (String currentVersion) throws IOException, InterruptedException |
| | Sends an HTTP request to the GitHub tags API and verifies if the latest release tag matches the current version.
|
| |
| void | updateButtonState (JButton button, boolean enabled, String tooltip) |
| | Updates the state and tooltip of the given button based on application logic.
|
| |
Singleton service for checking application version against GitHub releases.
Uses the GitHub API to compare the current version with the latest tagged release.
◆ VersionService()
| fr.softsf.canscan.service.VersionService.VersionService |
( |
| ) |
|
Initializes the HTTP client with TLS 1.3 and 5-second timeout.
Sets httpClient to null if initialization fails.
◆ checkLatestVersion()
| SwingWorker< Boolean, Void > fr.softsf.canscan.service.VersionService.checkLatestVersion |
( |
String | currentVersion, |
|
|
JButton | updateButton ) |
Asynchronously checks whether the current application version matches the latest GitHub release tag.
If an update is available, the specified button is made enabled; otherwise, it remains disabled.
- Parameters
-
| currentVersion | the current version of the application (e.g., "1.0.0.0") |
| updateButton | the button to toggle enabled state based on update status |
- Returns
- a
SwingWorker that returns true if the version is up-to-date,
false if an update is available
◆ npeCheckLatestVersion()
| SwingWorker< Boolean, Void > fr.softsf.canscan.service.VersionService.npeCheckLatestVersion |
( |
String | currentVersion, |
|
|
JButton | updateButton ) |
|
private |
Validates input for version check.
If null, returns a fallback SwingWorker that disables the update button; otherwise returns null.
- Parameters
-
| currentVersion | current app version |
| updateButton | button to toggle state |
- Returns
- fallback worker if input is null;
null otherwise
◆ requestAndVerify()
| Boolean fr.softsf.canscan.service.VersionService.requestAndVerify |
( |
String | currentVersion | ) |
throws IOException, InterruptedException |
|
private |
Sends an HTTP request to the GitHub tags API and verifies if the latest release tag matches the current version.
- Parameters
-
| currentVersion | the current version of the application |
- Returns
true if the version is up-to-date or if verification fails; false if an update is available
- Exceptions
-
| IOException | if the request fails due to network issues |
| InterruptedException | if the thread is interrupted during the request |
◆ updateButtonState()
| void fr.softsf.canscan.service.VersionService.updateButtonState |
( |
JButton | button, |
|
|
boolean | enabled, |
|
|
String | tooltip ) |
|
private |
Updates the state and tooltip of the given button based on application logic.
- Parameters
-
| button | the JButton to update |
| enabled | whether the button should be enabled |
| tooltip | the tooltip text to display on hover |
◆ CLOSE_HTML
| final String fr.softsf.canscan.service.VersionService.CLOSE_HTML = "</html>" |
|
staticprivate |
◆ GITHUB_TAGS_API_URL
| final String fr.softsf.canscan.service.VersionService.GITHUB_TAGS_API_URL |
|
staticprivate |
Initial value:=
"https://api.github.com/repos/Lob2018/CanScan/tags"
◆ HTTP_STATUS_CODE_OK
| final int fr.softsf.canscan.service.VersionService.HTTP_STATUS_CODE_OK = 200 |
|
staticprivate |
◆ httpClient
| final HttpClient fr.softsf.canscan.service.VersionService.httpClient |
|
private |
◆ INSTANCE
| fr.softsf.canscan.service.VersionService.INSTANCE |
◆ LATEST_RELEASES_REPO_URL
| final String fr.softsf.canscan.service.VersionService.LATEST_RELEASES_REPO_URL |
|
staticprivate |
Initial value:=
"https://github.com/Lob2018/CanScan/releases/latest"
◆ TAG_PATTERN
| final Pattern fr.softsf.canscan.service.VersionService.TAG_PATTERN = Pattern.compile("\"name\"\\s*:\\s*\"([^\"]+)\"") |
|
staticprivate |
The documentation for this enum was generated from the following file: