diff options
author | Jakob Heher <jakob.heher@iaik.tugraz.at> | 2022-09-01 12:50:50 +0200 |
---|---|---|
committer | Jakob Heher <jakob.heher@iaik.tugraz.at> | 2022-09-01 12:50:50 +0200 |
commit | 8e553385ab268c216a99b03d15783c563ce748dc (patch) | |
tree | 2a0691bc868acd806b338da1efba22c55a8e7f5d /pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration | |
parent | 05b9f7da53be1b8baf9df913cbd4efc1e2dbb16a (diff) | |
download | pdf-over-8e553385ab268c216a99b03d15783c563ce748dc.tar.gz pdf-over-8e553385ab268c216a99b03d15783c563ce748dc.tar.bz2 pdf-over-8e553385ab268c216a99b03d15783c563ce748dc.zip |
add update check status to about config panel, cf. #119
Diffstat (limited to 'pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration')
-rw-r--r-- | pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/AboutComposite.java | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/AboutComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/AboutComposite.java index 825a6187..35b73e7b 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/AboutComposite.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/AboutComposite.java @@ -21,6 +21,7 @@ import org.slf4j.LoggerFactory; import at.asit.pdfover.commons.Constants; import at.asit.pdfover.commons.Messages; import at.asit.pdfover.gui.utils.SWTUtils; +import at.asit.pdfover.gui.utils.UpdateCheckManager; import at.asit.pdfover.gui.workflow.config.ConfigurationDataInMemory; import at.asit.pdfover.gui.workflow.config.ConfigurationManager; import at.asit.pdfover.gui.workflow.states.State; @@ -30,8 +31,10 @@ public class AboutComposite extends ConfigurationCompositeBase { private Link lnkAbout; private Link lnkDataProtection; private Label lblDataProtection; + private Link lnkUpdateCheckStatus; private Button btnUpdateCheck; private Button btnOpenLogDirectory; + private UpdateCheckManager.Status latestUpdateStatus; /** * @param parent * @param style @@ -54,15 +57,33 @@ public class AboutComposite extends ConfigurationCompositeBase { SWTUtils.anchor(lnkDataProtection).top(lblDataProtection,10).left(0,5).right(100,-5); SWTUtils.setFontHeight(lnkDataProtection, Constants.TEXT_SIZE_NORMAL); + this.lnkUpdateCheckStatus = new Link(this, SWT.NONE); + SWTUtils.anchor(lnkUpdateCheckStatus).bottom(100, -5).left(0,5); + SWTUtils.setFontHeight(lnkUpdateCheckStatus, Constants.TEXT_SIZE_BUTTON); + UpdateCheckManager.registerStatusCallback((s) -> { latestUpdateStatus = s; getDisplay().asyncExec(() -> { RefreshUpdateStatusText(); }); }); + SWTUtils.addSelectionListener(lnkUpdateCheckStatus, (e) -> { + if (latestUpdateStatus == UpdateCheckManager.Status.OUTDATED) + Program.launch(Constants.UPDATE_URL); + else + UpdateCheckManager.checkNow(getShell()); + }); + this.btnUpdateCheck = new Button(this, SWT.CHECK); - SWTUtils.anchor(btnUpdateCheck).bottom(100,-5).left(0,5); + SWTUtils.anchor(btnUpdateCheck).bottom(lnkUpdateCheckStatus,-5).left(0,5); SWTUtils.setFontHeight(btnUpdateCheck, Constants.TEXT_SIZE_BUTTON); - SWTUtils.addSelectionListener(btnUpdateCheck, e -> { this.configurationContainer.updateCheck = btnUpdateCheck.getSelection(); }); + SWTUtils.addSelectionListener(btnUpdateCheck, (e) -> { + boolean enabled = btnUpdateCheck.getSelection(); + this.configurationContainer.updateCheck = enabled; + if (enabled) + UpdateCheckManager.checkNow(getShell()); + }); this.btnOpenLogDirectory = new Button(this, SWT.NONE); SWTUtils.anchor(btnOpenLogDirectory).bottom(100, -5).right(100, -5); SWTUtils.setFontHeight(btnOpenLogDirectory, Constants.TEXT_SIZE_BUTTON); + SWTUtils.reanchor(lnkDataProtection).bottom(btnUpdateCheck,-5); + this.lnkAbout.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { @@ -129,6 +150,10 @@ public class AboutComposite extends ConfigurationCompositeBase { // Nothing to do here } + private void RefreshUpdateStatusText() { + SWTUtils.setLocalizedText(lnkUpdateCheckStatus, "config.UpdateStatus." + latestUpdateStatus.name()); + } + /* (non-Javadoc) * @see at.asit.pdfover.gui.composites.StateComposite#reloadResources() */ @@ -140,6 +165,7 @@ public class AboutComposite extends ConfigurationCompositeBase { SWTUtils.setLocalizedText(btnUpdateCheck, "advanced_config.UpdateCheck"); SWTUtils.setLocalizedToolTipText(btnUpdateCheck, "advanced_config.UpdateCheck_ToolTip"); SWTUtils.setLocalizedText(btnOpenLogDirectory, "config.ShowLogDirectory"); + RefreshUpdateStatusText(); } @Override |