summaryrefslogtreecommitdiff
path: root/pdf-over-gui/src
diff options
context:
space:
mode:
authortkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7>2014-02-03 15:29:43 +0000
committertkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7>2014-02-03 15:29:43 +0000
commitafb1fa29ae33467c62d4927fa0b58d339cbdd6e7 (patch)
tree43e21af23e31bab0004697b095358a1e1e154d13 /pdf-over-gui/src
parent521431920bb0079a618ffe5d72bd6280608fc13f (diff)
downloadpdf-over-afb1fa29ae33467c62d4927fa0b58d339cbdd6e7.tar.gz
pdf-over-afb1fa29ae33467c62d4927fa0b58d339cbdd6e7.tar.bz2
pdf-over-afb1fa29ae33467c62d4927fa0b58d339cbdd6e7.zip
Check for updates on startup (configurable)
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-over/trunk@506 174cde9d-5d70-4d2a-aa98-46368bc2aaf7
Diffstat (limited to 'pdf-over-gui/src')
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/Constants.java12
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/AdvancedConfigurationComposite.java89
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/BaseConfigurationComposite.java4
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java7
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigManipulator.java6
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProvider.java6
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProviderImpl.java50
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationContainer.java12
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationContainerImpl.java20
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/PersistentConfigProvider.java6
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java43
-rw-r--r--pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages.properties5
-rw-r--r--pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages_de.properties5
13 files changed, 232 insertions, 33 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Constants.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Constants.java
index aae15703..3b848647 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Constants.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Constants.java
@@ -77,6 +77,15 @@ public class Constants {
/** PDF-Over User Agent string */
public static final String USER_AGENT_STRING = "PDF-Over " + (APP_VERSION == null ? "4.0" : APP_VERSION); //$NON-NLS-1$ //$NON-NLS-2$
+ /** Current release file */
+ public static final String CURRENT_RELEASE_URL = "http://webstart.buergerkarte.at/PDF-Over/Release.txt"; //$NON-NLS-1$
+
+ /** Update URL */
+ public static final String UPDATE_URL = "http://webstart.buergerkarte.at/PDF-Over/"; //$NON-NLS-1$
+
+ /** False */
+ public static final String FALSE = "false"; //$NON-NLS-1$
+
/* Configuration parameters */
@@ -118,6 +127,9 @@ public class Constants {
/** The signature locale config parameter */
public static final String CFG_SIGN_LOCALE = "SIGNLOCALE"; //$NON-NLS-1$
+ /** The update check config parameter */
+ public static final String CFG_UPDATE_CHECK = "UPDATE_CHECK"; //$NON-NLS-1$
+
/** The proxy host config parameter */
public static final String CFG_PROXY_HOST = "PROXY_HOST"; //$NON-NLS-1$
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/AdvancedConfigurationComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/AdvancedConfigurationComposite.java
index d7870f6a..548d5767 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/AdvancedConfigurationComposite.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/AdvancedConfigurationComposite.java
@@ -70,21 +70,28 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
**/
private static final Logger log = LoggerFactory
.getLogger(AdvancedConfigurationComposite.class);
- Text txtOutputFolder;
- Combo cmbBKUAuswahl;
- Combo cmbLocaleAuswahl;
- String[] bkuStrings;
+
+ private Group grpSignatur;
Button btnAutomatischePositionierung;
+ private Label lblTransparenz;
+ private Label lblTransparenzLinks;
+ private Label lblTransparenzRechts;
Scale sclTransparenz;
- private Group grpSignatur;
- private Group grpLocaleAuswahl;
- private Button btnBrowse;
- private Label lblDefaultOutputFolder;
- private Group grpSpeicherort;
+
private Group grpBkuAuswahl;
- private Label lblTransparenzRechts;
- private Label lblTransparenzLinks;
- private Label lblTransparenz;
+ Combo cmbBKUAuswahl;
+ String[] bkuStrings;
+
+ private Group grpSpeicherort;
+ private Label lblDefaultOutputFolder;
+ Text txtOutputFolder;
+ private Button btnBrowse;
+
+ private Group grpLocaleAuswahl;
+ Combo cmbLocaleAuswahl;
+
+ private Group grpUpdateCheck;
+ Button btnUpdateCheck;
private Group grpProxy;
private Label lblProxyHost;
@@ -147,7 +154,6 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
this.btnAutomatischePositionierung
.addSelectionListener(new SelectionAdapter() {
-
@Override
public void widgetSelected(SelectionEvent e) {
AdvancedConfigurationComposite.this
@@ -155,7 +161,6 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
.getSelection());
}
});
- log.debug(this.btnAutomatischePositionierung.getBounds().toString());
this.lblTransparenz = new Label(this.grpSignatur, SWT.HORIZONTAL);
FormData fd_lblTransparenz = new FormData();
@@ -403,10 +408,51 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
}
});
+ this.grpUpdateCheck = new Group(this, SWT.NONE);
+ FormLayout layout_grpUpdateCheck = new FormLayout();
+ layout_grpUpdateCheck.marginHeight = 10;
+ layout_grpUpdateCheck.marginWidth = 5;
+ this.grpUpdateCheck.setLayout(layout_grpUpdateCheck);
+ FormData fd_grpUpdateCheck = new FormData();
+ fd_grpUpdateCheck.top = new FormAttachment(this.grpLocaleAuswahl, 5);
+ fd_grpUpdateCheck.left = new FormAttachment(0, 5);
+ fd_grpUpdateCheck.right = new FormAttachment(100, -5);
+ this.grpUpdateCheck.setLayoutData(fd_grpUpdateCheck);
+
+ FontData[] fD_grpUpdateCheck = this.grpUpdateCheck.getFont().getFontData();
+ fD_grpUpdateCheck[0].setHeight(Constants.TEXT_SIZE_NORMAL);
+ this.grpUpdateCheck.setFont(new Font(Display.getCurrent(),
+ fD_grpUpdateCheck[0]));
+
+ this.btnUpdateCheck = new Button(this.grpUpdateCheck, SWT.CHECK);
+ FormData fd_btnUpdateCheck = new FormData();
+ fd_btnUpdateCheck.right = new FormAttachment(100, -5);
+ fd_btnUpdateCheck.top = new FormAttachment(0);
+ fd_btnUpdateCheck.left = new FormAttachment(0, 5);
+ this.btnUpdateCheck
+ .setLayoutData(fd_btnUpdateCheck);
+
+ FontData[] fD_btnUpdateCheck = this.btnUpdateCheck
+ .getFont().getFontData();
+ fD_btnUpdateCheck[0]
+ .setHeight(Constants.TEXT_SIZE_BUTTON);
+ this.btnUpdateCheck.setFont(new Font(Display
+ .getCurrent(), fD_btnUpdateCheck[0]));
+
+ this.btnUpdateCheck
+ .addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ AdvancedConfigurationComposite.this
+ .performUpdateCheckSelection(AdvancedConfigurationComposite.this.btnUpdateCheck
+ .getSelection());
+ }
+ });
+
this.grpProxy = new Group(this, SWT.NONE);
FormData fd_grpProxy = new FormData();
fd_grpProxy.right = new FormAttachment(100, -5);
- fd_grpProxy.top = new FormAttachment(this.grpLocaleAuswahl, 5);
+ fd_grpProxy.top = new FormAttachment(this.grpUpdateCheck, 5);
fd_grpProxy.left = new FormAttachment(0, 5);
this.grpProxy.setLayoutData(fd_grpProxy);
this.grpProxy.setLayout(new GridLayout(2, false));
@@ -733,6 +779,11 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
this.configurationContainer.setPlaceholderTransparency(transparency);
}
+ void performUpdateCheckSelection(boolean checkUpdate) {
+ this.configurationContainer.setUpdateCheck(checkUpdate);
+ this.btnUpdateCheck.setSelection(checkUpdate);
+ }
+
void processProxyHostChanged() {
try {
this.proxyHostErrorMarker.setVisible(false);
@@ -851,6 +902,7 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
this.sclTransparenz.setSelection(this.configurationContainer
.getPlaceholderTransparency());
this.performLocaleSelectionChanged(this.configurationContainer.getLocale());
+ this.performUpdateCheckSelection(this.configurationContainer.getUpdateCheck());
int port = this.configurationContainer.getProxyPort();
if (port > 0) {
@@ -949,6 +1001,13 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
this.cmbLocaleAuswahl.setToolTipText(Messages
.getString("advanced_config.LocaleSelection_ToolTip")); //$NON-NLS-1$
+ this.grpUpdateCheck.setText(Messages
+ .getString("advanced_config.UpdateCheck_Title")); //$NON-NLS-1$
+ this.btnUpdateCheck.setText(Messages
+ .getString("advanced_config.UpdateCheck")); //$NON-NLS-1$
+ this.btnUpdateCheck.setToolTipText(Messages
+ .getString("advanced_config.UpdateCheck_ToolTip")); //$NON-NLS-1$
+
this.grpProxy.setText(Messages.getString("advanced_config.Proxy_Title")); //$NON-NLS-1$
this.lblProxyHost.setText(Messages.getString("advanced_config.ProxyHost")); //$NON-NLS-1$
this.txtProxyHost.setToolTipText(Messages
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/BaseConfigurationComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/BaseConfigurationComposite.java
index 21520a4f..d341a9d3 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/BaseConfigurationComposite.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/BaseConfigurationComposite.java
@@ -67,12 +67,12 @@ public abstract class BaseConfigurationComposite extends StateComposite {
super(parent, style, state);
this.configurationContainer = configuration;
}
-
+
/**
* Load configuration from ConfigurationContainer
*/
public abstract void loadConfiguration();
-
+
/**
* Called before exit.
* The method validates every setting in the configuration before exit
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java
index e7b3d1c6..2f8abadb 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java
@@ -277,7 +277,6 @@ public class ConfigurationComposite extends StateComposite {
public void setConfigProvider(PersistentConfigProvider provider) {
this.configProvider = provider;
if (this.configProvider != null) {
-
// Initialize Configuration Container
this.configurationContainer
.setDefaultSignaturePosition(this.configProvider
@@ -312,6 +311,9 @@ public class ConfigurationComposite extends StateComposite {
this.configurationContainer.setOutputFolder(this.configProvider
.getDefaultOutputFolderPersistent());
+ this.configurationContainer.setUpdateCheck(this.configProvider.
+ getUpdateCheck());
+
this.configurationContainer.setProxyHost(this.configProvider
.getProxyHostPersistent());
try {
@@ -421,6 +423,9 @@ public class ConfigurationComposite extends StateComposite {
this.configManipulator.setSignatureNote(this.configurationContainer
.getSignatureNote());
+ this.configManipulator.setUpdateCheck(this.configurationContainer
+ .getUpdateCheck());
+
String hostOld = this.configProvider.getProxyHostPersistent();
String hostNew = this.configurationContainer.getProxyHost();
if (hostOld != null && !hostOld.isEmpty() &&
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigManipulator.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigManipulator.java
index 68b48242..d04d59c1 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigManipulator.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigManipulator.java
@@ -112,6 +112,12 @@ public interface ConfigManipulator {
public void setSignLocale(Locale locale);
/**
+ * Sets whether to automatically check for application updates
+ * @param checkUpdate whether to automatically check for application updates
+ */
+ public void setUpdateCheck(boolean checkUpdate);
+
+ /**
* Sets the default main window size
* @param size a Point describing the size
*/
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProvider.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProvider.java
index 91bd5ecf..0e3bda77 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProvider.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProvider.java
@@ -151,6 +151,12 @@ public interface ConfigProvider {
public Locale getSignLocale();
/**
+ * Gets whether to automatically check for application updates
+ * @return whether to automatically check for application updates
+ */
+ public boolean getUpdateCheck();
+
+ /**
* Gets the configured MainWindow size
* @return the configured MainWindow size
*/
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProviderImpl.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProviderImpl.java
index 3010868b..0d860ea0 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProviderImpl.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProviderImpl.java
@@ -86,45 +86,45 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator,
config.load(configSource);
// Set Emblem
- this.setDefaultEmblem(config
+ setDefaultEmblem(config
.getProperty(Constants.CFG_EMBLEM));
// Set Mobile Phone Number
- this.setDefaultMobileNumber(config
+ setDefaultMobileNumber(config
.getProperty(Constants.CFG_MOBILE_NUMBER));
// Set signature note
- this.setSignatureNote(config
+ setSignatureNote(config
.getProperty(Constants.CFG_SIGNATURE_NOTE));
// Set Proxy Host
- this.setProxyHost(config
+ setProxyHost(config
.getProperty(Constants.CFG_PROXY_HOST));
// Set Proxy User
- this.setProxyUser(config
+ setProxyUser(config
.getProperty(Constants.CFG_PROXY_USER));
// Set Proxy Password
- this.setProxyPass(config
+ setProxyPass(config
.getProperty(Constants.CFG_PROXY_PASS));
// Set Output Folder
- this.setDefaultOutputFolder(config
+ setDefaultOutputFolder(config
.getProperty(Constants.CFG_OUTPUT_FOLDER));
String localeString = config.getProperty(Constants.CFG_LOCALE);
Locale targetLocale = LocaleSerializer.parseFromString(localeString);
if (targetLocale != null) {
- this.setLocale(targetLocale);
+ setLocale(targetLocale);
}
String signlocalString = config.getProperty(Constants.CFG_SIGN_LOCALE);
Locale signtargetLocale = LocaleSerializer.parseFromString(signlocalString);
if (signtargetLocale != null) {
- this.setSignLocale(signtargetLocale);
+ setSignLocale(signtargetLocale);
}
String bkuUrl = config
@@ -155,7 +155,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator,
int port = Integer.parseInt(proxyPortString);
if (port > 0 && port <= 0xFFFF) {
- this.setProxyPort(port);
+ setProxyPort(port);
} else {
log.warn("Proxy port is out of range!: " + port); //$NON-NLS-1$
}
@@ -175,7 +175,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator,
defaultBKU = BKUs.NONE;
}
}
- this.setDefaultBKU(defaultBKU);
+ setDefaultBKU(defaultBKU);
// Set Signature placeholder transparency
int transparency = Constants.DEFAULT_SIGNATURE_PLACEHOLDER_TRANSPARENCY;
@@ -188,7 +188,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator,
// ignore parsing exception
}
}
- this.setPlaceholderTransparency(transparency);
+ setPlaceholderTransparency(transparency);
// Set MainWindow size
int width = Constants.DEFAULT_MAINWINDOW_WIDTH;
@@ -264,7 +264,12 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator,
log.error("Signature Position read from config failed: not matching string"); //$NON-NLS-1$
}
}
- this.setDefaultSignaturePosition(position);
+ setDefaultSignaturePosition(position);
+
+ // Set update check
+ String updateCheck = config.getProperty(Constants.CFG_UPDATE_CHECK);
+ if (updateCheck != null)
+ setUpdateCheck(!updateCheck.equalsIgnoreCase(Constants.FALSE));
}
/*
@@ -332,6 +337,9 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator,
if (Constants.THEME != Constants.Themes.DEFAULT)
props.setProperty(Constants.CFG_THEME, Constants.THEME.name());
+ if (!getUpdateCheck())
+ props.setProperty(Constants.CFG_UPDATE_CHECK, Constants.FALSE);
+
FileOutputStream outputstream = new FileOutputStream(configFile, false);
props.store(outputstream, "Configuration file was generated!"); //$NON-NLS-1$
@@ -1014,6 +1022,22 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator,
}
/* (non-Javadoc)
+ * @see at.asit.pdfover.gui.workflow.config.ConfigManipulator#setUpdateCheck(boolean)
+ */
+ @Override
+ public void setUpdateCheck(boolean checkUpdate) {
+ this.configuration.setUpdateCheck(checkUpdate);
+ }
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.workflow.config.ConfigProvider#getUpdateCheck()
+ */
+ @Override
+ public boolean getUpdateCheck() {
+ return this.configuration.getUpdateCheck();
+ }
+
+ /* (non-Javadoc)
* @see at.asit.pdfover.gui.workflow.ConfigManipulator#setMainWindowSize(org.eclipse.swt.graphics.Point)
*/
@Override
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationContainer.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationContainer.java
index 486647cc..46ae32c6 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationContainer.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationContainer.java
@@ -232,6 +232,18 @@ public interface ConfigurationContainer {
public void setDefaultSignaturePosition(SignaturePosition signaturePosition);
/**
+ * Gets whether to automatically check for application updates
+ * @return whether to automatically check for application updates
+ */
+ public boolean getUpdateCheck();
+
+ /**
+ * Sets whether to automatically check for application updates
+ * @param checkUpdate whether to automatically check for application updates
+ */
+ public void setUpdateCheck(boolean checkUpdate);
+
+ /**
* Gets the main window size
* @return the main window size
*/
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationContainerImpl.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationContainerImpl.java
index ec79b403..630b22e9 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationContainerImpl.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationContainerImpl.java
@@ -103,6 +103,9 @@ public class ConfigurationContainerImpl implements ConfigurationContainer {
/** Holds the default signature position */
protected SignaturePosition defaultSignaturePosition = null;
+ /** Whether to automatically check for updates */
+ protected boolean updateCheck = true;
+
/** Whether to skip the output state */
protected boolean skipFinish = false;
@@ -429,6 +432,23 @@ public class ConfigurationContainerImpl implements ConfigurationContainer {
/* (non-Javadoc)
+ * @see at.asit.pdfover.gui.workflow.config.ConfigurationContainer#getUpdateCheck()
+ */
+ @Override
+ public boolean getUpdateCheck() {
+ return this.updateCheck;
+ }
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.workflow.config.ConfigurationContainer#setUpdateCheck(boolean)
+ */
+ @Override
+ public void setUpdateCheck(boolean checkUpdate) {
+ this.updateCheck = checkUpdate;
+ }
+
+
+ /* (non-Javadoc)
* @see at.asit.pdfover.gui.workflow.ConfigurationContainer#getMainWindowSize()
*/
@Override
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/PersistentConfigProvider.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/PersistentConfigProvider.java
index fe4fceb3..9dcb38e5 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/PersistentConfigProvider.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/PersistentConfigProvider.java
@@ -128,6 +128,12 @@ public interface PersistentConfigProvider {
public Locale getSignLocale();
/**
+ * Gets whether to automatically check for application updates
+ * @return whether to automatically check for application updates
+ */
+ public boolean getUpdateCheck();
+
+ /**
* Gets the configured MainWindow size
* @return the configured MainWindow size
*/
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java
index bb715712..63c54c71 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java
@@ -16,14 +16,20 @@
package at.asit.pdfover.gui.workflow.states;
//Imports
+import java.awt.Desktop;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.net.URI;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.log4j.PropertyConfigurator;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.program.Program;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -43,12 +49,16 @@ import at.asit.pdfover.gui.cliarguments.ProxyPassArgument;
import at.asit.pdfover.gui.cliarguments.ProxyPortArgument;
import at.asit.pdfover.gui.cliarguments.ProxyUserArgument;
import at.asit.pdfover.gui.cliarguments.SkipFinishArgument;
-import at.asit.pdfover.gui.controls.ErrorDialog;
+import at.asit.pdfover.gui.controls.Dialog;
import at.asit.pdfover.gui.controls.Dialog.BUTTONS;
+import at.asit.pdfover.gui.controls.Dialog.ICON;
+import at.asit.pdfover.gui.controls.ErrorDialog;
import at.asit.pdfover.gui.exceptions.InitializationException;
import at.asit.pdfover.gui.utils.Messages;
import at.asit.pdfover.gui.utils.Unzipper;
+import at.asit.pdfover.gui.utils.VersionComparator;
import at.asit.pdfover.gui.workflow.StateMachine;
+import at.asit.pdfover.gui.workflow.states.mobilebku.MobileBKUHelper;
import at.asit.pdfover.signator.Signator;
/**
@@ -104,7 +114,6 @@ public class PrepareConfigurationState extends State {
getStateMachine().getConfigProvider().getConfigurationDirectory() + FILE_SEPARATOR + filename));
log.info("Loaded config from file : " + filename); //$NON-NLS-1$
-
} catch (FileNotFoundException ex) {
if (filename.equals(Constants.DEFAULT_CONFIG_FILENAME)) {
// we only check for resource config file if it is the
@@ -329,6 +338,36 @@ public class PrepareConfigurationState extends State {
getStateMachine().exit();
}
+ // Check for updates
+ if (getStateMachine().getConfigProvider().getUpdateCheck() && Constants.APP_VERSION != null) {
+ HttpClient client = MobileBKUHelper.getHttpClient();
+ GetMethod method = new GetMethod(Constants.CURRENT_RELEASE_URL);
+ try {
+ client.executeMethod(method);
+ String version = method.getResponseBodyAsString().trim();
+
+ if (VersionComparator.before(Constants.APP_VERSION, version)) {
+ Dialog info = new Dialog(getStateMachine()
+ .getGUIProvider().getMainShell(),
+ Messages.getString("version_check.UpdateTitle"), //$NON-NLS-1$
+ String.format(Messages.getString("version_check.UpdateText"), //$NON-NLS-1$
+ version),
+ BUTTONS.OK_CANCEL, ICON.INFORMATION);
+ if (info.open() == SWT.OK)
+ {
+ if (Desktop.isDesktopSupported()) {
+ Desktop.getDesktop().browse(new URI(Constants.UPDATE_URL));
+ } else {
+ log.info("SWT Desktop is not supported on this platform"); //$NON-NLS-1$
+ Program.launch(Constants.UPDATE_URL);
+ }
+ }
+ }
+ } catch (Exception e) {
+ log.error("Error downloading update information: ", e); //$NON-NLS-1$
+ }
+ }
+
// Set usedSignerLib ...
getStateMachine().getPDFSigner().setUsedPDFSignerLibrary(
Signator.Signers.PDFAS);
diff --git a/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages.properties b/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages.properties
index f109bfac..740fe99b 100644
--- a/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages.properties
+++ b/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages.properties
@@ -34,6 +34,9 @@ advanced_config.SigPHTransparency=Signature placeholder transparency
advanced_config.SigPHTransparencyMax=Opaque
advanced_config.SigPHTransparencyMin=Invisible
advanced_config.SigPHTransparencyTooltip=Set the transparency of the signature placeholder in the positioning step
+advanced_config.UpdateCheck_Title=Updates
+advanced_config.UpdateCheck=Automatically check for updates
+advanced_config.UpdateCheck_ToolTip=Shows a notification when a new version is available
argument.error.output=is not a directory
argument.help.autopos=Enables automatic signature positioning
argument.help.bku=Select the CCE to use. Values are: LOCAL, MOBILE. Example: -b MOBILE
@@ -155,4 +158,6 @@ tanEnter.ReferenceValue=Reference value:
tanEnter.TAN=TAN:
tanEnter.tries=%d tries left!
tanEnter.try=Only 1 try left!
+version_check.UpdateTitle=New version available!
+version_check.UpdateText=Version %s is available.\nOpen download page now?
waiting.message=Signature creation in progress...
diff --git a/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages_de.properties b/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages_de.properties
index 103f89ae..38c053cc 100644
--- a/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages_de.properties
+++ b/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages_de.properties
@@ -34,6 +34,9 @@ advanced_config.SigPHTransparency=Signaturplatzhalter-Transparenz
advanced_config.SigPHTransparencyMax=Undurchsichtig
advanced_config.SigPHTransparencyMin=Unsichtbar
advanced_config.SigPHTransparencyTooltip=Wählt die Transparenz des Signaturplatzhalters im Schritt "Positionierung"
+advanced_config.UpdateCheck_Title=Updates
+advanced_config.UpdateCheck=Automatisch auf Updates überprüfen
+advanced_config.UpdateCheck_ToolTip=Zeigt eine Benachrichtigung, wenn eine neue Version verfügbar ist
argument.error.output=ist kein Ordner
argument.help.autopos=Aktiviert automatische Positionierung der Signatur
argument.help.bku=Wählen Sie die BKU. Gültige Werte: LOCAL, MOBILE. Bsp.: -b MOBILE
@@ -155,4 +158,6 @@ tanEnter.ReferenceValue=Vergleichswert:
tanEnter.TAN=TAN:
tanEnter.tries=%d Versuche übrig!
tanEnter.try=Nur noch 1 Versuch übrig!
+version_check.UpdateTitle=Neue Version verfügbar!
+version_check.UpdateText=Version %s ist verfügbar\nJetzt Download-Seite öffnen?
waiting.message=Signaturerstellung läuft...