summaryrefslogtreecommitdiff
path: root/pdf-over-gui/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'pdf-over-gui/src/main/java')
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/Constants.java19
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/ATrustStatus.java2
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/InvisibleProfile.java2
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/AdvancedConfigurationComposite.java838
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java1200
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUEnterNumberComposite.java2
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/OutputComposite.java985
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PositioningComposite.java1
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SimpleConfigurationComposite.java198
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/CertificateDownloadSource.java10
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/Messages.java15
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigManipulator.java7
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigOverlayManipulator.java6
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProvider.java15
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProviderImpl.java59
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationContainer.java22
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationContainerImpl.java31
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/PersistentConfigProvider.java8
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OutputState.java1
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java4
20 files changed, 1684 insertions, 1741 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 a1ebfc44..105eedd5 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
@@ -23,7 +23,7 @@ import java.util.Properties;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Display;
-import at.asit.pdfover.gui.bku.mobile.MobileBKUHelper;
+
import at.asit.pdfover.gui.bku.mobile.MobileBKUs;
/**
@@ -39,8 +39,11 @@ public class Constants {
/** Application name + version */
public static final String APP_NAME_VERSION = (APP_VERSION == null ? APP_NAME : APP_NAME + " v" + APP_VERSION); //$NON-NLS-1$
+
+ public static final String SIGNATURE_PROFILE = "SIGNATURE_PROFILE"; //$NON-NLS-1$
+ public static final String DEFAULT_POSTFIX = "_signed";
- static {
+ static {
// Has to be set before (implicitly) initializing Display
Display.setAppName(APP_NAME);
}
@@ -55,7 +58,7 @@ public class Constants {
/** Supported locales */
public static final Locale[] SUPPORTED_LOCALES = { Locale.GERMAN, Locale.ENGLISH };
-
+
/** Configuration directory */
public static final String CONFIG_DIRECTORY = System.getProperty("user.home") + File.separator + ".pdf-over"; //$NON-NLS-1$ //$NON-NLS-2$
@@ -78,7 +81,7 @@ public class Constants {
* The minimum PDF-AS configuration version (older ones will be backed up
* and updated
*/
- public static final String MIN_PDF_AS_CONFIG_VERSION = "4.1.0"; //$NON-NLS-1$
+ public static final String MIN_PDF_AS_CONFIG_VERSION = "4.1.6"; //$NON-NLS-1$
/** The configuration backup filename */
public static final String PDF_AS_CONFIG_BACKUP_FILENAME = "cfg_backup"; //$NON-NLS-1$
@@ -103,13 +106,13 @@ public class Constants {
public static final int SIGNATURE_KEYBOARD_POSITIONING_OFFSET = 15;
/** PDF-Over User Agent string */
- public static final String USER_AGENT_STRING = "PDF-Over " + (APP_VERSION == null ? "4.1" : APP_VERSION); //$NON-NLS-1$ //$NON-NLS-2$
+ public static final String USER_AGENT_STRING = "PDF-Over " + (APP_VERSION == null ? "4.3" : 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$
+ public static final String CURRENT_RELEASE_URL = "https://updates.a-sit.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$
+ public static final String UPDATE_URL = "https://technology.a-sit.at/en/pdf-over/"; //$NON-NLS-1$
/** True */
public static final String TRUE = "true"; //$NON-NLS-1$
@@ -207,6 +210,8 @@ public class Constants {
/** The output folder config parameter */
public static final String CFG_OUTPUT_FOLDER = "OUTPUT_FOLDER"; //$NON-NLS-1$
+ public static final String CFG_POSTFIX = "SAVE_FILE_POSTFIX";
+
/** The main window size (Format: width,height) */
public static final String CFG_MAINWINDOW_SIZE = "MAINWINDOW_SIZE"; //$NON-NLS-1$
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/ATrustStatus.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/ATrustStatus.java
index 4c8b42e8..fe91dfa9 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/ATrustStatus.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/ATrustStatus.java
@@ -245,7 +245,7 @@ public class ATrustStatus extends AbstractMobileBKUStatusImpl {
* @return the smsTan
*/
public boolean isSmsTan() {
- return smsTan;
+ return this.smsTan;
}
/**
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/InvisibleProfile.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/InvisibleProfile.java
index b833ce9d..4bb3890f 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/InvisibleProfile.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/InvisibleProfile.java
@@ -54,8 +54,8 @@ public class InvisibleProfile extends Argument {
log.info("Set Profile Invisible");
if (args.length > argOffset + 1) {
-
PdfAs4SignatureParameter.PROFILE_VISIBILITY=false;
+ log.debug("We are setting the profile visibility to false");
return argOffset + 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 bbcf6b9c..d2dabc5f 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
@@ -26,8 +26,6 @@ import org.eclipse.swt.events.FocusAdapter;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.TraverseEvent;
-import org.eclipse.swt.events.TraverseListener;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.layout.FormAttachment;
@@ -48,6 +46,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import at.asit.pdfover.gui.Constants;
+import at.asit.pdfover.commons.Profile;
import at.asit.pdfover.gui.controls.ErrorDialog;
import at.asit.pdfover.gui.controls.ErrorMarker;
import at.asit.pdfover.gui.controls.Dialog.BUTTONS;
@@ -72,19 +71,17 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
/**
* SLF4J Logger instance
**/
- private static final Logger log = LoggerFactory
- .getLogger(AdvancedConfigurationComposite.class);
-
+ private static final Logger log = LoggerFactory.getLogger(AdvancedConfigurationComposite.class);
private ConfigurationComposite configurationComposite;
private Group grpSignatur;
- private Group grpPlaceholder;
+ private Group grpPlaceholder;
Button btnAutomatischePositionierung;
Button btnPdfACompat;
Button btnPlatzhalterVerwenden;
- Button btnSignatureFieldsUsage;
- Button btnEnablePlaceholderUsage;
+ Button btnSignatureFieldsUsage;
+ Button btnEnablePlaceholderUsage;
private Label lblTransparenz;
private Label lblTransparenzLinks;
private Label lblTransparenzRechts;
@@ -95,12 +92,14 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
List<String> bkuStrings;
Button btnKeystoreEnabled;
- private Group grpSpeicherort;
- private Label lblDefaultOutputFolder;
+ private final Group grpSpeicherort;
+ private final Label lblDefaultOutputFolder;
Text txtOutputFolder;
- private Button btnBrowse;
+ private final Button btnBrowse;
+ private final Label lblSaveFilePostFix;
+ private final Text txtSaveFilePostFix;
- private Group grpLocaleAuswahl;
+ private final Group grpLocaleAuswahl;
Combo cmbLocaleAuswahl;
private Group grpUpdateCheck;
@@ -113,16 +112,9 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
private Label lblProxyPort;
private Text txtProxyPort;
private ErrorMarker txtProxyPortErrorMarker;
-// private Label lblProxyUser;
-// private Text txtProxyUser;
-// private ErrorMarker proxyUserErrorMarker;
-// private Label lblProxyPass;
-// private Text txtProxyPass;
-// private ErrorMarker proxyPassErrorMarker;
FormData fd_txtProxyPort;
FormData fd_txtProxyPortErrorMarker;
-
/**
* @param parent
* @param style
@@ -130,8 +122,7 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
* @param container
* @param config
*/
- public AdvancedConfigurationComposite(Composite parent, int style,
- State state, ConfigurationContainer container,
+ public AdvancedConfigurationComposite(Composite parent, int style, State state, ConfigurationContainer container,
ConfigurationComposite config) {
super(parent, style, state, container);
this.configurationComposite = config;
@@ -150,73 +141,55 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
FontData[] fD_grpSignaturPosition = this.grpSignatur.getFont().getFontData();
fD_grpSignaturPosition[0].setHeight(Constants.TEXT_SIZE_NORMAL);
- this.grpSignatur.setFont(new Font(Display.getCurrent(),
- fD_grpSignaturPosition[0]));
+ this.grpSignatur.setFont(new Font(Display.getCurrent(), fD_grpSignaturPosition[0]));
this.btnAutomatischePositionierung = new Button(this.grpSignatur, SWT.CHECK);
FormData fd_btnAutomatischePositionierung = new FormData();
fd_btnAutomatischePositionierung.right = new FormAttachment(100, -5);
fd_btnAutomatischePositionierung.top = new FormAttachment(0);
fd_btnAutomatischePositionierung.left = new FormAttachment(0, 5);
- this.btnAutomatischePositionierung
- .setLayoutData(fd_btnAutomatischePositionierung);
-
- FontData[] fD_btnAutomatischePositionierung = this.btnAutomatischePositionierung
- .getFont().getFontData();
- fD_btnAutomatischePositionierung[0]
- .setHeight(Constants.TEXT_SIZE_BUTTON);
- this.btnAutomatischePositionierung.setFont(new Font(Display
- .getCurrent(), fD_btnAutomatischePositionierung[0]));
-
- this.btnAutomatischePositionierung
- .addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- AdvancedConfigurationComposite.this
- .performPositionSelection(AdvancedConfigurationComposite.this.btnAutomatischePositionierung
- .getSelection());
- }
- });
-
-
+ this.btnAutomatischePositionierung.setLayoutData(fd_btnAutomatischePositionierung);
+
+ FontData[] fD_btnAutomatischePositionierung = this.btnAutomatischePositionierung.getFont().getFontData();
+ fD_btnAutomatischePositionierung[0].setHeight(Constants.TEXT_SIZE_BUTTON);
+ this.btnAutomatischePositionierung.setFont(new Font(Display.getCurrent(), fD_btnAutomatischePositionierung[0]));
+
+ this.btnAutomatischePositionierung.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ AdvancedConfigurationComposite.this.performPositionSelection(
+ AdvancedConfigurationComposite.this.btnAutomatischePositionierung.getSelection());
+ }
+ });
this.btnPdfACompat = new Button(this.grpSignatur, SWT.CHECK);
FormData fd_btnPdfACompat = new FormData();
fd_btnPdfACompat.right = new FormAttachment(100, -5);
- fd_btnPdfACompat.top = new FormAttachment(
- this.btnAutomatischePositionierung, 5);
+ fd_btnPdfACompat.top = new FormAttachment(this.btnAutomatischePositionierung, 5);
fd_btnPdfACompat.left = new FormAttachment(0, 5);
- this.btnPdfACompat
- .setLayoutData(fd_btnPdfACompat);
-
- FontData[] fD_btnPdfACompat = this.btnPdfACompat
- .getFont().getFontData();
- fD_btnPdfACompat[0]
- .setHeight(Constants.TEXT_SIZE_BUTTON);
- this.btnPdfACompat.setFont(new Font(Display
- .getCurrent(), fD_btnPdfACompat[0]));
-
- this.btnPdfACompat
- .addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- AdvancedConfigurationComposite.this
- .performPdfACompatSelection(AdvancedConfigurationComposite.this.btnPdfACompat
- .getSelection());
- }
- });
+ this.btnPdfACompat.setLayoutData(fd_btnPdfACompat);
+
+ FontData[] fD_btnPdfACompat = this.btnPdfACompat.getFont().getFontData();
+ fD_btnPdfACompat[0].setHeight(Constants.TEXT_SIZE_BUTTON);
+ this.btnPdfACompat.setFont(new Font(Display.getCurrent(), fD_btnPdfACompat[0]));
+
+ this.btnPdfACompat.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ AdvancedConfigurationComposite.this
+ .performPdfACompatSelection(AdvancedConfigurationComposite.this.btnPdfACompat.getSelection());
+ }
+ });
this.lblTransparenz = new Label(this.grpSignatur, SWT.HORIZONTAL);
FormData fd_lblTransparenz = new FormData();
- fd_lblTransparenz.top = new FormAttachment(
- this.btnPdfACompat, 5);
+ fd_lblTransparenz.top = new FormAttachment(this.btnPdfACompat, 5);
fd_lblTransparenz.left = new FormAttachment(0, 5);
this.lblTransparenz.setLayoutData(fd_lblTransparenz);
FontData[] fD_lblTransparenz = this.lblTransparenz.getFont().getFontData();
fD_lblTransparenz[0].setHeight(Constants.TEXT_SIZE_NORMAL);
- this.lblTransparenz.setFont(new Font(Display.getCurrent(),
- fD_lblTransparenz[0]));
+ this.lblTransparenz.setFont(new Font(Display.getCurrent(), fD_lblTransparenz[0]));
this.lblTransparenzLinks = new Label(this.grpSignatur, SWT.HORIZONTAL);
FormData fd_lblTransparenzLinks = new FormData();
@@ -224,11 +197,9 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
fd_lblTransparenzLinks.left = new FormAttachment(0, 15);
this.lblTransparenzLinks.setLayoutData(fd_lblTransparenzLinks);
- FontData[] fD_lblTransparenzLinks = this.lblTransparenzLinks.getFont()
- .getFontData();
+ FontData[] fD_lblTransparenzLinks = this.lblTransparenzLinks.getFont().getFontData();
fD_lblTransparenzLinks[0].setHeight(Constants.TEXT_SIZE_NORMAL);
- this.lblTransparenzLinks.setFont(new Font(Display.getCurrent(),
- fD_lblTransparenzLinks[0]));
+ this.lblTransparenzLinks.setFont(new Font(Display.getCurrent(), fD_lblTransparenzLinks[0]));
this.lblTransparenzRechts = new Label(this.grpSignatur, SWT.HORIZONTAL);
FormData fd_lblTransparenzRechts = new FormData();
@@ -236,11 +207,9 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
fd_lblTransparenzRechts.right = new FormAttachment(100, -5);
this.lblTransparenzRechts.setLayoutData(fd_lblTransparenzRechts);
- FontData[] fD_lblTransparenzRechts = this.lblTransparenzRechts.getFont()
- .getFontData();
+ FontData[] fD_lblTransparenzRechts = this.lblTransparenzRechts.getFont().getFontData();
fD_lblTransparenzRechts[0].setHeight(Constants.TEXT_SIZE_NORMAL);
- this.lblTransparenzRechts.setFont(new Font(Display.getCurrent(),
- fD_lblTransparenzRechts[0]));
+ this.lblTransparenzRechts.setFont(new Font(Display.getCurrent(), fD_lblTransparenzRechts[0]));
this.sclTransparenz = new Scale(this.grpSignatur, SWT.HORIZONTAL);
FormData fd_sldTransparenz = new FormData();
@@ -255,30 +224,26 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
this.sclTransparenz.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- performPlaceholderTransparency(AdvancedConfigurationComposite.this.sclTransparenz
- .getSelection());
+ performPlaceholderTransparency(AdvancedConfigurationComposite.this.sclTransparenz.getSelection());
}
});
-
-
+
this.grpPlaceholder = new Group(this, SWT.NONE);
FormLayout layout_grpPlaceholder = new FormLayout();
layout_grpPlaceholder.marginHeight = 10;
layout_grpPlaceholder.marginWidth = 5;
this.grpPlaceholder.setLayout(layout_grpPlaceholder);
-
+
FormData fd_grpPlaceholder = new FormData();
fd_grpPlaceholder.top = new FormAttachment(this.grpSignatur, 5);
fd_grpPlaceholder.right = new FormAttachment(100, -5);
fd_grpPlaceholder.left = new FormAttachment(0, 5);
this.grpPlaceholder.setLayoutData(fd_grpPlaceholder);
-
+
FontData[] fD_grpPlaceholder = this.grpPlaceholder.getFont().getFontData();
fD_grpPlaceholder[0].setHeight(Constants.TEXT_SIZE_NORMAL);
- this.grpPlaceholder.setFont(new Font(Display.getCurrent(),
- fD_grpPlaceholder[0]));
-
-
+ this.grpPlaceholder.setFont(new Font(Display.getCurrent(), fD_grpPlaceholder[0]));
+
this.btnEnablePlaceholderUsage = new Button(this.grpPlaceholder, SWT.CHECK);
FormData fd_btnEnablePlaceholderUsage = new FormData();
fd_btnEnablePlaceholderUsage.right = new FormAttachment(100, -5);
@@ -316,19 +281,18 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
AdvancedConfigurationComposite.this.btnPlatzhalterVerwenden.getSelection());
}
});
-
+
this.btnSignatureFieldsUsage = new Button(this.grpPlaceholder, SWT.RADIO);
FormData fd_btnSignatureFieldsUsage = new FormData();
fd_btnSignatureFieldsUsage.right = new FormAttachment(100, -5);
fd_btnSignatureFieldsUsage.top = new FormAttachment(this.btnPlatzhalterVerwenden, 5);
fd_btnSignatureFieldsUsage.left = new FormAttachment(0, 5);
this.btnSignatureFieldsUsage.setLayoutData(fd_btnSignatureFieldsUsage);
-
-
+
FontData[] fD_btnSignatureFieldsUsage = this.btnSignatureFieldsUsage.getFont().getFontData();
fD_btnSignatureFieldsUsage[0].setHeight(Constants.TEXT_SIZE_BUTTON);
this.btnSignatureFieldsUsage.setFont(new Font(Display.getCurrent(), fD_btnSignatureFieldsUsage[0]));
-
+
this.btnSignatureFieldsUsage.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
@@ -336,7 +300,6 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
AdvancedConfigurationComposite.this.btnSignatureFieldsUsage.getSelection());
}
});
-
this.grpBkuAuswahl = new Group(this, SWT.NONE);
layout = new FormLayout();
@@ -351,8 +314,7 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
FontData[] fD_grpBkuAuswahl = this.grpBkuAuswahl.getFont().getFontData();
fD_grpBkuAuswahl[0].setHeight(Constants.TEXT_SIZE_NORMAL);
- this.grpBkuAuswahl.setFont(new Font(Display.getCurrent(),
- fD_grpBkuAuswahl[0]));
+ this.grpBkuAuswahl.setFont(new Font(Display.getCurrent(), fD_grpBkuAuswahl[0]));
this.cmbBKUAuswahl = new Combo(this.grpBkuAuswahl, SWT.READ_ONLY);
FormData fd_cmbBKUAuswahl = new FormData();
@@ -361,14 +323,12 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
fd_cmbBKUAuswahl.left = new FormAttachment(0, 5);
this.cmbBKUAuswahl.setLayoutData(fd_cmbBKUAuswahl);
- FontData[] fD_cmbBKUAuswahl = this.cmbBKUAuswahl.getFont()
- .getFontData();
+ FontData[] fD_cmbBKUAuswahl = this.cmbBKUAuswahl.getFont().getFontData();
fD_cmbBKUAuswahl[0].setHeight(Constants.TEXT_SIZE_NORMAL);
- this.cmbBKUAuswahl.setFont(new Font(Display.getCurrent(),
- fD_cmbBKUAuswahl[0]));
+ this.cmbBKUAuswahl.setFont(new Font(Display.getCurrent(), fD_cmbBKUAuswahl[0]));
int blen = BKUs.values().length;
- this.bkuStrings = new ArrayList<String>(blen);
+ this.bkuStrings = new ArrayList<>(blen);
for (int i = 0; i < blen; i++) {
String lookup = "BKU." + BKUs.values()[i].toString(); //$NON-NLS-1$
String text = Messages.getString(lookup);
@@ -379,15 +339,11 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
@Override
public void widgetSelected(SelectionEvent e) {
int selectionIndex = getBKUElementIndex(
- AdvancedConfigurationComposite.this.configurationContainer
- .getDefaultBKU());
- if (AdvancedConfigurationComposite.this.cmbBKUAuswahl
- .getSelectionIndex() != selectionIndex) {
- selectionIndex = AdvancedConfigurationComposite.this.cmbBKUAuswahl
- .getSelectionIndex();
+ AdvancedConfigurationComposite.this.configurationContainer.getDefaultBKU());
+ if (AdvancedConfigurationComposite.this.cmbBKUAuswahl.getSelectionIndex() != selectionIndex) {
+ selectionIndex = AdvancedConfigurationComposite.this.cmbBKUAuswahl.getSelectionIndex();
performBKUSelectionChanged(
- AdvancedConfigurationComposite.this.cmbBKUAuswahl
- .getItem(selectionIndex));
+ AdvancedConfigurationComposite.this.cmbBKUAuswahl.getItem(selectionIndex));
}
}
});
@@ -395,18 +351,13 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
this.btnKeystoreEnabled = new Button(this.grpBkuAuswahl, SWT.CHECK);
FormData fd_btnKeystoreEnabled = new FormData();
fd_btnKeystoreEnabled.right = new FormAttachment(100, -5);
- fd_btnKeystoreEnabled.top = new FormAttachment(
- this.cmbBKUAuswahl, 5);
+ fd_btnKeystoreEnabled.top = new FormAttachment(this.cmbBKUAuswahl, 5);
fd_btnKeystoreEnabled.left = new FormAttachment(0, 5);
- this.btnKeystoreEnabled
- .setLayoutData(fd_btnKeystoreEnabled);
+ this.btnKeystoreEnabled.setLayoutData(fd_btnKeystoreEnabled);
- FontData[] fD_btnKeystoreEnabled = this.btnKeystoreEnabled
- .getFont().getFontData();
- fD_btnKeystoreEnabled[0]
- .setHeight(Constants.TEXT_SIZE_BUTTON);
- this.btnKeystoreEnabled.setFont(new Font(Display
- .getCurrent(), fD_btnKeystoreEnabled[0]));
+ FontData[] fD_btnKeystoreEnabled = this.btnKeystoreEnabled.getFont().getFontData();
+ fD_btnKeystoreEnabled[0].setHeight(Constants.TEXT_SIZE_BUTTON);
+ this.btnKeystoreEnabled.setFont(new Font(Display.getCurrent(), fD_btnKeystoreEnabled[0]));
this.btnKeystoreEnabled.addSelectionListener(new SelectionAdapter() {
@Override
@@ -417,85 +368,63 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
});
this.grpSpeicherort = new Group(this, SWT.NONE);
- layout = new FormLayout();
- layout.marginHeight = 10;
- layout.marginWidth = 5;
- this.grpSpeicherort.setLayout(layout);
+ GridLayout gl_grpSpeicherort = new GridLayout(3, false);
+ grpSpeicherort.setLayout(gl_grpSpeicherort);
FormData fd_grpSpeicherort = new FormData();
+ fd_grpSpeicherort.left = new FormAttachment(0,5);
fd_grpSpeicherort.top = new FormAttachment(this.grpBkuAuswahl, 5);
- fd_grpSpeicherort.left = new FormAttachment(0, 5);
fd_grpSpeicherort.right = new FormAttachment(100, -5);
this.grpSpeicherort.setLayoutData(fd_grpSpeicherort);
+
FontData[] fD_grpSpeicherort = this.grpSpeicherort.getFont().getFontData();
fD_grpSpeicherort[0].setHeight(Constants.TEXT_SIZE_NORMAL);
- this.grpSpeicherort.setFont(new Font(Display.getCurrent(),
- fD_grpSpeicherort[0]));
+ this.grpSpeicherort.setFont(new Font(Display.getCurrent(), fD_grpSpeicherort[0]));
this.lblDefaultOutputFolder = new Label(this.grpSpeicherort, SWT.NONE);
- FormData fd_lblDefaultOutputFolder = new FormData();
- fd_lblDefaultOutputFolder.top = new FormAttachment(0);
- fd_lblDefaultOutputFolder.left = new FormAttachment(0, 5);
- this.lblDefaultOutputFolder.setLayoutData(fd_lblDefaultOutputFolder);
- FontData[] fD_lblDefaultOutputFolder = this.lblDefaultOutputFolder.getFont()
- .getFontData();
+ FontData[] fD_lblDefaultOutputFolder = this.lblDefaultOutputFolder.getFont().getFontData();
fD_lblDefaultOutputFolder[0].setHeight(Constants.TEXT_SIZE_NORMAL);
- this.lblDefaultOutputFolder.setFont(new Font(Display.getCurrent(),
- fD_lblDefaultOutputFolder[0]));
+ this.lblDefaultOutputFolder.setFont(new Font(Display.getCurrent(), fD_lblDefaultOutputFolder[0]));
this.txtOutputFolder = new Text(this.grpSpeicherort, SWT.BORDER);
- FormData fd_text = new FormData();
- fd_text.top = new FormAttachment(this.lblDefaultOutputFolder, 5);
- fd_text.left = new FormAttachment(0, 15);
- this.txtOutputFolder.setLayoutData(fd_text);
+ GridData gd_txtOutputFolder = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
+ txtOutputFolder.setLayoutData(gd_txtOutputFolder);
- FontData[] fD_txtOutputFolder = this.txtOutputFolder.getFont()
- .getFontData();
+ FontData[] fD_txtOutputFolder = this.txtOutputFolder.getFont().getFontData();
fD_txtOutputFolder[0].setHeight(Constants.TEXT_SIZE_NORMAL);
- this.txtOutputFolder.setFont(new Font(Display.getCurrent(),
- fD_txtOutputFolder[0]));
+ this.txtOutputFolder.setFont(new Font(Display.getCurrent(), fD_txtOutputFolder[0]));
this.txtOutputFolder.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent e) {
- performOutputFolderChanged(AdvancedConfigurationComposite.this.txtOutputFolder
- .getText());
+ performOutputFolderChanged(AdvancedConfigurationComposite.this.txtOutputFolder.getText());
}
});
+ fD_txtOutputFolder[0].setHeight(Constants.TEXT_SIZE_NORMAL);
this.btnBrowse = new Button(this.grpSpeicherort, SWT.NONE);
- fd_text.right = new FormAttachment(this.btnBrowse, -5);
+ btnBrowse.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
FontData[] fD_btnBrowse = this.btnBrowse.getFont().getFontData();
fD_btnBrowse[0].setHeight(Constants.TEXT_SIZE_BUTTON);
this.btnBrowse.setFont(new Font(Display.getCurrent(), fD_btnBrowse[0]));
-
- FormData fd_btnBrowse = new FormData();
- fd_btnBrowse.top = new FormAttachment(this.lblDefaultOutputFolder, 5);
- fd_btnBrowse.right = new FormAttachment(100, -5);
- this.btnBrowse.setLayoutData(fd_btnBrowse);
-
this.btnBrowse.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- DirectoryDialog dlg = new DirectoryDialog(
- AdvancedConfigurationComposite.this.getShell());
+ DirectoryDialog dlg = new DirectoryDialog(AdvancedConfigurationComposite.this.getShell());
// Set the initial filter path according
// to anything they've selected or typed in
- dlg.setFilterPath(AdvancedConfigurationComposite.this.txtOutputFolder
- .getText());
+ dlg.setFilterPath(AdvancedConfigurationComposite.this.txtOutputFolder.getText());
// Change the title bar text
- dlg.setText(Messages
- .getString("advanced_config.OutputFolder.Dialog_Title")); //$NON-NLS-1$
+ dlg.setText(Messages.getString("advanced_config.OutputFolder.Dialog_Title")); //$NON-NLS-1$
// Customizable message displayed in the dialog
- dlg.setMessage(Messages
- .getString("advanced_config.OutputFolder.Dialog")); //$NON-NLS-1$
+ dlg.setMessage(Messages.getString("advanced_config.OutputFolder.Dialog")); //$NON-NLS-1$
// Calling open() will open and run the dialog.
// It will return the selected directory, or
@@ -507,22 +436,48 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
}
}
});
-
+
+ this.lblSaveFilePostFix = new Label(this.grpSpeicherort, SWT.NONE);
+ lblSaveFilePostFix.setText(Messages.getString("AdvancedConfigurationComposite.lblSaveFilePostFix.text"));
+
+ FontData[] fD_lblSaveFilePostFix = this.lblSaveFilePostFix.getFont().getFontData();
+ fD_lblSaveFilePostFix[0].setHeight(Constants.TEXT_SIZE_NORMAL);
+ this.lblSaveFilePostFix.setFont(new Font(Display.getCurrent(), fD_lblSaveFilePostFix[0]));
+
+ this.txtSaveFilePostFix = new Text(this.grpSpeicherort, SWT.BORDER);
+ GridData gd_txtSaveFilePostFix = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
+
+ txtSaveFilePostFix.setLayoutData(gd_txtSaveFilePostFix);
+
+ FontData[] fD_txtPostFix = this.txtSaveFilePostFix.getFont().getFontData();
+ fD_txtPostFix[0].setHeight(Constants.TEXT_SIZE_NORMAL);
+ this.txtSaveFilePostFix.setFont(new Font(Display.getCurrent(), fD_txtPostFix[0]));
+
+ this.txtSaveFilePostFix.addFocusListener(new FocusAdapter() {
+
+ @Override
+ public void focusLost(FocusEvent e) {
+ performPostFixChanged(AdvancedConfigurationComposite.this.txtSaveFilePostFix.getText());
+ }
+ });
+ new Label(grpSpeicherort, SWT.NONE);
+ fD_lblSaveFilePostFix[0].setHeight(Constants.TEXT_SIZE_NORMAL);
+ fD_txtPostFix[0].setHeight(Constants.TEXT_SIZE_NORMAL);
+
this.grpLocaleAuswahl = new Group(this, SWT.NONE);
FormLayout layout_grpLocaleAuswahl = new FormLayout();
layout_grpLocaleAuswahl.marginHeight = 10;
layout_grpLocaleAuswahl.marginWidth = 5;
this.grpLocaleAuswahl.setLayout(layout_grpLocaleAuswahl);
FormData fd_grpLocaleAuswahl = new FormData();
- fd_grpLocaleAuswahl.top = new FormAttachment(this.grpSpeicherort, 5);
+ fd_grpLocaleAuswahl.top = new FormAttachment(grpSpeicherort, 5);
fd_grpLocaleAuswahl.left = new FormAttachment(0, 5);
fd_grpLocaleAuswahl.right = new FormAttachment(100, -5);
this.grpLocaleAuswahl.setLayoutData(fd_grpLocaleAuswahl);
FontData[] fD_grpLocaleAuswahl = this.grpLocaleAuswahl.getFont().getFontData();
fD_grpLocaleAuswahl[0].setHeight(Constants.TEXT_SIZE_NORMAL);
- this.grpLocaleAuswahl.setFont(new Font(Display.getCurrent(),
- fD_grpLocaleAuswahl[0]));
+ this.grpLocaleAuswahl.setFont(new Font(Display.getCurrent(), fD_grpLocaleAuswahl[0]));
this.cmbLocaleAuswahl = new Combo(this.grpLocaleAuswahl, SWT.READ_ONLY);
FormData fd_cmbLocaleAuswahl = new FormData();
@@ -531,11 +486,9 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
fd_cmbLocaleAuswahl.left = new FormAttachment(0, 5);
this.cmbLocaleAuswahl.setLayoutData(fd_cmbLocaleAuswahl);
- FontData[] fD_cmbLocaleAuswahl = this.cmbLocaleAuswahl.getFont()
- .getFontData();
+ FontData[] fD_cmbLocaleAuswahl = this.cmbLocaleAuswahl.getFont().getFontData();
fD_cmbLocaleAuswahl[0].setHeight(Constants.TEXT_SIZE_NORMAL);
- this.cmbLocaleAuswahl.setFont(new Font(Display.getCurrent(),
- fD_cmbLocaleAuswahl[0]));
+ this.cmbLocaleAuswahl.setFont(new Font(Display.getCurrent(), fD_cmbLocaleAuswahl[0]));
String[] localeStrings = new String[Constants.SUPPORTED_LOCALES.length];
for (int i = 0; i < Constants.SUPPORTED_LOCALES.length; ++i) {
@@ -545,11 +498,9 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
this.cmbLocaleAuswahl.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- Locale currentLocale = AdvancedConfigurationComposite.this.configurationContainer
- .getLocale();
- Locale selectedLocale = Constants.
- SUPPORTED_LOCALES[AdvancedConfigurationComposite.this.cmbLocaleAuswahl
- .getSelectionIndex()];
+ Locale currentLocale = AdvancedConfigurationComposite.this.configurationContainer.getLocale();
+ Locale selectedLocale = Constants.SUPPORTED_LOCALES[AdvancedConfigurationComposite.this.cmbLocaleAuswahl
+ .getSelectionIndex()];
if (!currentLocale.equals(selectedLocale)) {
performLocaleSelectionChanged(selectedLocale);
}
@@ -569,33 +520,26 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
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.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.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();
@@ -610,21 +554,18 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
this.grpProxy.setFont(new Font(Display.getCurrent(), fD_grpProxy[0]));
this.lblProxyHost = new Label(this.grpProxy, SWT.NONE);
- GridData gd_lblProxyHost = new GridData(SWT.LEFT, SWT.CENTER, false,
- false, 1, 1);
+ GridData gd_lblProxyHost = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
gd_lblProxyHost.widthHint = 66;
this.lblProxyHost.setLayoutData(gd_lblProxyHost);
this.lblProxyHost.setBounds(0, 0, 57, 15);
FontData[] fD_lblProxyHost = this.lblProxyHost.getFont().getFontData();
fD_lblProxyHost[0].setHeight(Constants.TEXT_SIZE_NORMAL);
- this.lblProxyHost.setFont(new Font(Display.getCurrent(),
- fD_lblProxyHost[0]));
+ this.lblProxyHost.setFont(new Font(Display.getCurrent(), fD_lblProxyHost[0]));
Composite compProxyHostContainer = new Composite(this.grpProxy, SWT.NONE);
compProxyHostContainer.setLayout(new FormLayout());
- compProxyHostContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false,
- 1, 1));
+ compProxyHostContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
this.txtProxyHost = new Text(compProxyHostContainer, SWT.BORDER);
FormData fd_txtProxyHost = new FormData();
fd_txtProxyHost.right = new FormAttachment(100, -42);
@@ -633,8 +574,7 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
FontData[] fD_txtProxyHost = this.txtProxyHost.getFont().getFontData();
fD_txtProxyHost[0].setHeight(Constants.TEXT_SIZE_NORMAL);
- this.txtProxyHost.setFont(new Font(Display.getCurrent(),
- fD_txtProxyHost[0]));
+ this.txtProxyHost.setFont(new Font(Display.getCurrent(), fD_txtProxyHost[0]));
this.proxyHostErrorMarker = new ErrorMarker(compProxyHostContainer, SWT.NONE, ""); //$NON-NLS-1$
@@ -656,29 +596,22 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
}
});
- this.txtProxyHost.addTraverseListener(new TraverseListener() {
-
- @Override
- public void keyTraversed(TraverseEvent e) {
- if (e.detail == SWT.TRAVERSE_RETURN) {
- processProxyHostChanged();
- }
+ this.txtProxyHost.addTraverseListener(e -> {
+ if (e.detail == SWT.TRAVERSE_RETURN) {
+ processProxyHostChanged();
}
});
this.lblProxyPort = new Label(this.grpProxy, SWT.NONE);
this.lblProxyPort.setBounds(0, 0, 57, 15);
- FontData[] fD_lblProxyPort = this.lblProxyPort.getFont()
- .getFontData();
+ FontData[] fD_lblProxyPort = this.lblProxyPort.getFont().getFontData();
fD_lblProxyPort[0].setHeight(Constants.TEXT_SIZE_NORMAL);
- this.lblProxyPort.setFont(new Font(Display.getCurrent(),
- fD_lblProxyPort[0]));
+ this.lblProxyPort.setFont(new Font(Display.getCurrent(), fD_lblProxyPort[0]));
Composite compProxyPortContainer = new Composite(this.grpProxy, SWT.NONE);
compProxyPortContainer.setLayout(new FormLayout());
- compProxyPortContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false,
- 1, 1));
+ compProxyPortContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
this.txtProxyPort = new Text(compProxyPortContainer, SWT.BORDER);
this.fd_txtProxyPort = new FormData();
@@ -689,16 +622,11 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
FontData[] fD_txtProxyPort = this.txtProxyPort.getFont().getFontData();
fD_txtProxyPort[0].setHeight(Constants.TEXT_SIZE_NORMAL);
- this.txtProxyPort.setFont(new Font(Display.getCurrent(),
- fD_txtProxyPort[0]));
+ this.txtProxyPort.setFont(new Font(Display.getCurrent(), fD_txtProxyPort[0]));
- this.txtProxyPort.addTraverseListener(new TraverseListener() {
-
- @Override
- public void keyTraversed(TraverseEvent e) {
- if (e.detail == SWT.TRAVERSE_RETURN) {
- processProxyPortChanged();
- }
+ this.txtProxyPort.addTraverseListener(e -> {
+ if (e.detail == SWT.TRAVERSE_RETURN) {
+ processProxyPortChanged();
}
});
@@ -708,8 +636,7 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
this.fd_txtProxyPortErrorMarker.right = new FormAttachment(100);
this.fd_txtProxyPortErrorMarker.top = new FormAttachment(0);
this.fd_txtProxyPortErrorMarker.bottom = new FormAttachment(0, 32);
- this.txtProxyPortErrorMarker
- .setLayoutData(this.fd_txtProxyPortErrorMarker);
+ this.txtProxyPortErrorMarker.setLayoutData(this.fd_txtProxyPortErrorMarker);
this.txtProxyPortErrorMarker.setVisible(false);
this.txtProxyPort.addFocusListener(new FocusAdapter() {
@@ -719,120 +646,14 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
processProxyPortChanged();
}
});
+ reloadResources();
+ }
-// this.lblProxyUser = new Label(this.grpProxy, SWT.NONE);
-// GridData gd_lblProxyUser = new GridData(SWT.LEFT, SWT.CENTER, false,
-// false, 1, 1);
-// gd_lblProxyUser.widthHint = 80;
-// this.lblProxyUser.setLayoutData(gd_lblProxyUser);
-// this.lblProxyUser.setBounds(0, 0, 57, 15);
-//
-// FontData[] fD_lblProxyUser = this.lblProxyUser.getFont().getFontData();
-// fD_lblProxyUser[0].setHeight(Constants.TEXT_SIZE_NORMAL);
-// this.lblProxyUser.setFont(new Font(Display.getCurrent(),
-// fD_lblProxyUser[0]));
-//
-// Composite compProxyUserContainer = new Composite(this.grpProxy, SWT.NONE);
-// compProxyUserContainer.setLayout(new FormLayout());
-// compProxyUserContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false,
-// 1, 1));
-// this.txtProxyUser = new Text(compProxyUserContainer, SWT.BORDER);
-// FormData fd_txtProxyUser = new FormData();
-// fd_txtProxyUser.right = new FormAttachment(100, -42);
-// fd_txtProxyUser.top = new FormAttachment(0);
-// fd_txtProxyUser.left = new FormAttachment(0, 5);
-//
-// FontData[] fD_txtProxyUser = this.txtProxyUser.getFont().getFontData();
-// fD_txtProxyUser[0].setHeight(Constants.TEXT_SIZE_NORMAL);
-// this.txtProxyUser.setFont(new Font(Display.getCurrent(),
-// fD_txtProxyUser[0]));
-//
-// this.proxyUserErrorMarker = new ErrorMarker(compProxyUserContainer, SWT.NONE, ""); //$NON-NLS-1$
-//
-// FormData fd_proxyUserErrorMarker = new FormData();
-// fd_proxyUserErrorMarker.left = new FormAttachment(100, -32);
-// fd_proxyUserErrorMarker.right = new FormAttachment(100);
-// fd_proxyUserErrorMarker.top = new FormAttachment(0);
-// fd_proxyUserErrorMarker.bottom = new FormAttachment(0, 32);
-//
-// this.proxyUserErrorMarker.setLayoutData(fd_proxyUserErrorMarker);
-// this.proxyUserErrorMarker.setVisible(false);
-// this.txtProxyUser.setLayoutData(fd_txtProxyUser);
-//
-// this.txtProxyUser.addFocusListener(new FocusAdapter() {
-//
-// @Override
-// public void focusLost(FocusEvent e) {
-// processProxyUserChanged();
-// }
-// });
-//
-// this.txtProxyUser.addTraverseListener(new TraverseListener() {
-//
-// @Override
-// public void keyTraversed(TraverseEvent e) {
-// if (e.detail == SWT.TRAVERSE_RETURN) {
-// processProxyUserChanged();
-// }
-// }
-// });
-//
-// this.lblProxyPass = new Label(this.grpProxy, SWT.NONE);
-// this.lblProxyPass.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER,
-// false, false, 1, 1));
-// this.lblProxyPass.setBounds(0, 0, 57, 15);
-//
-// FontData[] fD_lblProxyPass = this.lblProxyPass.getFont().getFontData();
-// fD_lblProxyPass[0].setHeight(Constants.TEXT_SIZE_NORMAL);
-// this.lblProxyPass.setFont(new Font(Display.getCurrent(),
-// fD_lblProxyPass[0]));
-//
-// Composite compProxyPassContainer = new Composite(this.grpProxy, SWT.NONE);
-// compProxyPassContainer.setLayout(new FormLayout());
-// compProxyPassContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false,
-// 1, 1));
-// this.txtProxyPass = new Text(compProxyPassContainer, SWT.PASSWORD | SWT.BORDER);
-// FormData fd_txtProxyPass = new FormData();
-// fd_txtProxyPass.right = new FormAttachment(100, -42);
-// fd_txtProxyPass.top = new FormAttachment(0);
-// fd_txtProxyPass.left = new FormAttachment(0, 5);
-//
-// FontData[] fD_txtProxyPass = this.txtProxyPass.getFont().getFontData();
-// fD_txtProxyPass[0].setHeight(Constants.TEXT_SIZE_NORMAL);
-// this.txtProxyPass.setFont(new Font(Display.getCurrent(),
-// fD_txtProxyPass[0]));
-//
-// this.proxyPassErrorMarker = new ErrorMarker(compProxyPassContainer, SWT.NONE, ""); //$NON-NLS-1$
-//
-// FormData fd_proxyPassErrorMarker = new FormData();
-// fd_proxyPassErrorMarker.left = new FormAttachment(100, -32);
-// fd_proxyPassErrorMarker.right = new FormAttachment(100);
-// fd_proxyPassErrorMarker.top = new FormAttachment(0);
-// fd_proxyPassErrorMarker.bottom = new FormAttachment(0, 32);
-//
-// this.proxyPassErrorMarker.setLayoutData(fd_proxyPassErrorMarker);
-// this.proxyPassErrorMarker.setVisible(false);
-// this.txtProxyPass.setLayoutData(fd_txtProxyPass);
-//
-// this.txtProxyPass.addFocusListener(new FocusAdapter() {
-//
-// @Override
-// public void focusLost(FocusEvent e) {
-// processProxyPassChanged();
-// }
-// });
-//
-// this.txtProxyPass.addTraverseListener(new TraverseListener() {
-//
-// @Override
-// public void keyTraversed(TraverseEvent e) {
-// if (e.detail == SWT.TRAVERSE_RETURN) {
-// processProxyPassChanged();
-// }
-// }
-// });
+ private void performPostFixChanged(String postfix) {
- reloadResources();
+ log.debug("Save file postfix changed to : {}", postfix); //$NON-NLS-1$
+ this.configurationContainer.setSaveFilePostFix(postfix);
+ AdvancedConfigurationComposite.this.txtSaveFilePostFix.setText(postfix);
}
/*
@@ -847,7 +668,7 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
}
void performOutputFolderChanged(String foldername) {
- log.debug("Selected Output folder: " + foldername); //$NON-NLS-1$
+ log.debug("Selected Output folder: {}", foldername); //$NON-NLS-1$
this.configurationContainer.setOutputFolder(foldername);
AdvancedConfigurationComposite.this.txtOutputFolder.setText(foldername);
}
@@ -858,14 +679,14 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
int i = this.bkuStrings.indexOf(bkuName);
if (i == -1) {
- log.warn("NO BKU match for " + bkuName); //$NON-NLS-1$
+ log.warn("NO BKU match for {}", bkuName); //$NON-NLS-1$
return 0;
}
return i;
}
void performBKUSelectionChanged(BKUs selected) {
- log.debug("Selected BKU: " + selected.toString()); //$NON-NLS-1$
+ log.debug("Selected BKU: {}", selected); //$NON-NLS-1$
this.configurationContainer.setDefaultBKU(selected);
this.cmbBKUAuswahl.select(this.getBKUElementIndex(selected));
}
@@ -875,9 +696,8 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
BKUs bkuvalue = resolveBKU(selected);
this.performBKUSelectionChanged(bkuvalue);
} catch (Exception ex) {
- log.error("Failed to parse BKU value: " + selected, ex); //$NON-NLS-1$
- ErrorDialog dialog = new ErrorDialog(getShell(),
- Messages.getString("error.InvalidBKU"), BUTTONS.OK); //$NON-NLS-1$
+ log.error("Failed to parse BKU value: {} {}", selected, ex); //$NON-NLS-1$
+ ErrorDialog dialog = new ErrorDialog(getShell(), Messages.getString("error.InvalidBKU"), BUTTONS.OK); //$NON-NLS-1$
dialog.open();
}
}
@@ -898,23 +718,23 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
int getLocaleElementIndex(Locale locale) {
for (int i = 0; i < Constants.SUPPORTED_LOCALES.length; i++) {
if (Constants.SUPPORTED_LOCALES[i].equals(locale)) {
- log.debug("Locale: " + locale + " IDX: " + i); //$NON-NLS-1$ //$NON-NLS-2$
+ log.debug("Locale: {} IDX: {}", locale, i); //$NON-NLS-1$ //$NON-NLS-2$
return i;
}
}
- log.warn("NO Locale match for " + locale); //$NON-NLS-1$
+ log.warn("NO Locale match for {}", locale); //$NON-NLS-1$
return 0;
}
-
+
void performLocaleSelectionChanged(Locale selected) {
- log.debug("Selected Locale: " + selected); //$NON-NLS-1$
+ log.debug("Selected Locale: {}", selected); //$NON-NLS-1$
this.configurationContainer.setLocale(selected);
this.cmbLocaleAuswahl.select(this.getLocaleElementIndex(selected));
}
void performPositionSelection(boolean automatic) {
- log.debug("Selected Position: " + automatic); //$NON-NLS-1$
+ log.debug("Selected Position: {}", automatic); //$NON-NLS-1$
SignaturePosition pos = automatic ? new SignaturePosition() : null;
this.configurationContainer.setDefaultSignaturePosition(pos);
this.btnAutomatischePositionierung.setSelection(automatic);
@@ -929,14 +749,14 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
this.configurationContainer.setUseSignatureFields(useFields);
this.btnSignatureFieldsUsage.setSelection(useFields);
}
-
+
void performEnableUsePlaceholder(boolean enable) {
this.btnPlatzhalterVerwenden.setEnabled(enable);
this.btnSignatureFieldsUsage.setEnabled(enable);
this.configurationContainer.setEnablePlaceholderUsage(enable);
this.btnEnablePlaceholderUsage.setSelection(enable);
}
-
+
void performPdfACompatSelection(boolean compat) {
this.configurationContainer.setSignaturePdfACompat(compat);
this.btnPdfACompat.setSelection(compat);
@@ -990,44 +810,6 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
this.configurationContainer.setProxyHost(host);
}
-// void processProxyUserChanged() {
-// try {
-// this.proxyUserErrorMarker.setVisible(false);
-// plainProxyUserSetter();
-// } catch (Exception ex) {
-// this.proxyUserErrorMarker.setVisible(true);
-// this.proxyUserErrorMarker.setToolTipText(ex.getMessage());
-// log.error("processProxyUser: ", ex); //$NON-NLS-1$
-// }
-// }
-//
-// /**
-// *
-// */
-// private void plainProxyUserSetter() {
-// String user = this.txtProxyUser.getText();
-// this.configurationContainer.setProxyUser(user);
-// }
-//
-// void processProxyPassChanged() {
-// try {
-// this.proxyPassErrorMarker.setVisible(false);
-// plainProxyPassSetter();
-// } catch (Exception ex) {
-// this.proxyPassErrorMarker.setVisible(true);
-// this.proxyPassErrorMarker.setToolTipText(ex.getMessage());
-// log.error("processProxyPass: ", ex); //$NON-NLS-1$
-// }
-// }
-//
-// /**
-// *
-// */
-// private void plainProxyPassSetter() {
-// String pass = this.txtProxyPass.getText();
-// this.configurationContainer.setProxyPass(pass);
-// }
-
void processProxyPortChanged() {
try {
this.txtProxyPortErrorMarker.setVisible(false);
@@ -1059,6 +841,7 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
/*
* (non-Javadoc)
+ *
* @see at.asit.pdfover.gui.composites.StateComposite#doLayout()
*/
@Override
@@ -1066,76 +849,74 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
// Nothing to do here
}
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.gui.composites.BaseConfigurationComposite#initConfiguration(at.asit.pdfover.gui.workflow.config.PersistentConfigProvider)
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * at.asit.pdfover.gui.composites.BaseConfigurationComposite#initConfiguration(
+ * at.asit.pdfover.gui.workflow.config.PersistentConfigProvider)
*/
@Override
public void initConfiguration(PersistentConfigProvider provider) {
- this.configurationContainer.setDefaultSignaturePosition(
- provider.getDefaultSignaturePositionPersistent());
+ this.configurationContainer.setDefaultSignaturePosition(provider.getDefaultSignaturePositionPersistent());
this.configurationContainer.setUseMarker(provider.getUseMarker());
this.configurationContainer.setUseSignatureFields(provider.getUseSignatureFields());
this.configurationContainer.setEnablePlaceholderUsage(provider.getEnablePlaceholderUsage());
- /*this.configurationContainer.setDownloadURL(
- provider.getDownloadURL());*/
- this.configurationContainer.setSignaturePdfACompat(
- provider.getSignaturePdfACompat());
- this.configurationContainer.setPlaceholderTransparency(
- provider.getPlaceholderTransparency());
+ this.configurationContainer.setSignaturePdfACompat(provider.getSignaturePdfACompat());
+ this.configurationContainer.setPlaceholderTransparency(provider.getPlaceholderTransparency());
- this.configurationContainer.setDefaultBKU(
- provider.getDefaultBKUPersistent());
- this.configurationContainer.setKeyStoreEnabled(
- provider.getKeyStoreEnabledPersistent());
+ this.configurationContainer.setDefaultBKU(provider.getDefaultBKUPersistent());
+ this.configurationContainer.setKeyStoreEnabled(provider.getKeyStoreEnabledPersistent());
- this.configurationContainer.setOutputFolder(
- provider.getDefaultOutputFolderPersistent());
+ this.configurationContainer.setOutputFolder(provider.getDefaultOutputFolderPersistent());
+ this.configurationContainer.setSaveFilePostFix(provider.getSaveFilePostFix());
this.configurationContainer.setLocale(provider.getLocale());
- this.configurationContainer.setUpdateCheck(
- provider.getUpdateCheck());
+ this.configurationContainer.setUpdateCheck(provider.getUpdateCheck());
- this.configurationContainer.setProxyHost(
- provider.getProxyHostPersistent());
+ this.configurationContainer.setProxyHost(provider.getProxyHostPersistent());
try {
- this.configurationContainer.setProxyPort(
- provider.getProxyPortPersistent());
+ this.configurationContainer.setProxyPort(provider.getProxyPortPersistent());
} catch (InvalidPortException e) {
log.error("Failed to set proxy port!", e); //$NON-NLS-1$
}
- this.configurationContainer.setProxyUser(
- provider.getProxyUserPersistent());
- this.configurationContainer.setProxyPass(
- provider.getProxyPassPersistent());
+ this.configurationContainer.setProxyUser(provider.getProxyUserPersistent());
+ this.configurationContainer.setProxyPass(provider.getProxyPassPersistent());
+ this.configurationContainer.setSignatureProfile(Profile.getProfile(provider.getSignatureProfile()));
}
/*
* (non-Javadoc)
- * @see at.asit.pdfover.gui.composites.BaseConfigurationComposite#loadConfiguration()
+ *
+ * @see
+ * at.asit.pdfover.gui.composites.BaseConfigurationComposite#loadConfiguration()
*/
@Override
public void loadConfiguration() {
// load advanced settings
- performBKUSelectionChanged(this.configurationContainer
- .getDefaultBKU());
+ performBKUSelectionChanged(this.configurationContainer.getDefaultBKU());
String outputFolder = this.configurationContainer.getOutputFolder();
if (outputFolder != null) {
performOutputFolderChanged(outputFolder);
}
- SignaturePosition pos = this.configurationContainer
- .getDefaultSignaturePosition();
+ String postFix = this.configurationContainer.getSaveFilePostFix();
+ if (postFix != null) {
+ performPostFixChanged(postFix);
+ } else {
+ performPostFixChanged(Constants.DEFAULT_POSTFIX);
+ }
+ SignaturePosition pos = this.configurationContainer.getDefaultSignaturePosition();
performPositionSelection(pos != null && pos.useAutoPositioning());
performUseMarkerSelection(this.configurationContainer.getUseMarker());
performUseSignatureFieldsSelection(this.configurationContainer.getUseSignatureFields());
performEnableUsePlaceholder(this.configurationContainer.getEnablePlaceholderUsage());
- this.sclTransparenz.setSelection(this.configurationContainer
- .getPlaceholderTransparency());
+ this.sclTransparenz.setSelection(this.configurationContainer.getPlaceholderTransparency());
performLocaleSelectionChanged(this.configurationContainer.getLocale());
performPdfACompatSelection(this.configurationContainer.getSignaturePdfACompat());
performKeystoreEnabledSelection(this.configurationContainer.getKeyStoreEnabled());
performUpdateCheckSelection(this.configurationContainer.getUpdateCheck());
+ performSetSignatureProfile(this.configurationContainer.getSignatureProfile());
int port = this.configurationContainer.getProxyPort();
if (port > 0) {
@@ -1147,47 +928,58 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
this.txtProxyHost.setText(host);
}
- /*String user = this.configurationContainer.getProxyUser();
- if (user != null) {
- this.txtProxyUser.setText(user);
}
- String pass = this.configurationContainer.getProxyPass();
- if (pass != null) {
- this.txtProxyPass.setText(pass);
- }*/
-}
-
+ /**
+ * @param profile
+ *
+ */
+ public void performSetSignatureProfile(Profile profile) {
+ switch (profile) {
+ case INVISIBLE:
+ case AMTSSIGNATURBLOCK:
+ this.performPositionSelection(true);
+ this.btnAutomatischePositionierung.setEnabled(false);
+ this.btnEnablePlaceholderUsage.setEnabled(false);
+ this.performEnableUsePlaceholder(false);
+ break;
+ default:
+ this.btnAutomatischePositionierung.setEnabled(true);
+ this.btnEnablePlaceholderUsage.setEnabled(true);
+ }
+ }
- /* (non-Javadoc)
- * @see at.asit.pdfover.gui.composites.BaseConfigurationComposite#storeConfiguration(at.asit.pdfover.gui.workflow.config.ConfigManipulator, at.asit.pdfover.gui.workflow.config.PersistentConfigProvider)
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * at.asit.pdfover.gui.composites.BaseConfigurationComposite#storeConfiguration(
+ * at.asit.pdfover.gui.workflow.config.ConfigManipulator,
+ * at.asit.pdfover.gui.workflow.config.PersistentConfigProvider)
*/
@Override
- public void storeConfiguration(ConfigManipulator store,
- PersistentConfigProvider provider) {
- store.setDefaultSignaturePosition(
- this.configurationContainer.getDefaultSignaturePosition());
+ public void storeConfiguration(ConfigManipulator store, PersistentConfigProvider provider) {
+ store.setDefaultSignaturePosition(this.configurationContainer.getDefaultSignaturePosition());
store.setUseMarker(this.configurationContainer.getUseMarker());
store.setUseSignatureFields(this.configurationContainer.getUseSignatureFields());
store.setEnablePlaceholderUsage(this.configurationContainer.getEnablePlaceholderUsage());
- store.setSignaturePdfACompat(
- this.configurationContainer.getSignaturePdfACompat());
- store.setPlaceholderTransparency(
- this.configurationContainer.getPlaceholderTransparency());
+ store.setSignaturePdfACompat(this.configurationContainer.getSignaturePdfACompat());
+ store.setPlaceholderTransparency(this.configurationContainer.getPlaceholderTransparency());
store.setDefaultBKU(this.configurationContainer.getDefaultBKU());
store.setKeyStoreEnabled(this.configurationContainer.getKeyStoreEnabled());
store.setDefaultOutputFolder(this.configurationContainer.getOutputFolder());
-
+ store.setSaveFilePostFix(this.configurationContainer.getSaveFilePostFix());
store.setLocale(this.configurationContainer.getLocale());
store.setUpdateCheck(this.configurationContainer.getUpdateCheck());
+ store.setSignatureProfile(this.configurationContainer.getSignatureProfile().getName());
+
String hostOld = provider.getProxyHostPersistent();
String hostNew = this.configurationContainer.getProxyHost();
- if (hostOld != null && !hostOld.isEmpty() &&
- (hostNew == null || hostNew.isEmpty())) {
+ if (hostOld != null && !hostOld.isEmpty() && (hostNew == null || hostNew.isEmpty())) {
// Proxy has been removed, let's clear the system properties
// Otherwise, the proxy settings wouldn't get removed
System.clearProperty("http.proxyHost"); //$NON-NLS-1$
@@ -1206,8 +998,7 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
String userOld = provider.getProxyUserPersistent();
String userNew = this.configurationContainer.getProxyUser();
- if (userOld != null && !userOld.isEmpty() &&
- (userNew == null || userNew.isEmpty())) {
+ if (userOld != null && !userOld.isEmpty() && (userNew == null || userNew.isEmpty())) {
// cf. above
System.clearProperty("http.proxyUser"); //$NON-NLS-1$
System.clearProperty("https.proxyUser"); //$NON-NLS-1$
@@ -1223,121 +1014,102 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
}
store.setProxyPass(passNew);
}
+
/*
* (non-Javadoc)
- * @see at.asit.pdfover.gui.composites.BaseConfigurationComposite#validateSettings()
+ *
+ * @see
+ * at.asit.pdfover.gui.composites.BaseConfigurationComposite#validateSettings()
*/
@Override
public void validateSettings(int resumeIndex) throws Exception {
-
+
String foldername = this.configurationContainer.getOutputFolder();
-
+
switch (resumeIndex) {
- case 0:
- if (foldername != null && !foldername.isEmpty()) {
- File outputFolder = new File(foldername);
- if (!outputFolder.exists()) {
- throw new OutputfolderDoesntExistException(outputFolder, 1);
- }
- if (!outputFolder.isDirectory()) {
- throw new OutputfolderNotADirectoryException(outputFolder);
- }
+ case 0:
+ if (foldername != null && !foldername.isEmpty()) {
+ File outputFolder = new File(foldername);
+ if (!outputFolder.exists()) {
+ throw new OutputfolderDoesntExistException(outputFolder, 1);
}
- // Fall through
- case 1:
- this.plainProxyHostSetter();
- // Fall through
- case 2:
- this.plainProxyPortSetter();
- // Fall through
-// case 3:
-// this.plainProxyUserSetter();
-// // Fall through
-// case 4:
-// this.plainProxyPassSetter();
+ if (!outputFolder.isDirectory()) {
+ throw new OutputfolderNotADirectoryException(outputFolder);
+ }
+ }
+ // Fall through
+ case 1:
+ this.plainProxyHostSetter();
+ // Fall through
+ case 2:
+ this.plainProxyPortSetter();
+ // Fall through
+ // case 3:
+ // this.plainProxyUserSetter();
+ // // Fall through
+ // case 4:
+ // this.plainProxyPassSetter();
}
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see at.asit.pdfover.gui.composites.StateComposite#reloadResources()
*/
@Override
public void reloadResources() {
- this.grpSignatur.setText(Messages
- .getString("advanced_config.Signature_Title")); //$NON-NLS-1$
- this.btnAutomatischePositionierung.setText(Messages
- .getString("advanced_config.AutoPosition")); //$NON-NLS-1$
- this.btnAutomatischePositionierung.setToolTipText(Messages
- .getString("advanced_config.AutoPosition_ToolTip")); //$NON-NLS-1$
+ this.grpSignatur.setText(Messages.getString("advanced_config.Signature_Title")); //$NON-NLS-1$
+ this.btnAutomatischePositionierung.setText(Messages.getString("advanced_config.AutoPosition")); //$NON-NLS-1$
+ this.btnAutomatischePositionierung.setToolTipText(Messages.getString("advanced_config.AutoPosition_ToolTip")); //$NON-NLS-1$
this.grpPlaceholder.setText(Messages.getString("advanced_config.Placeholder_Title")); //$NON-NLS-1$
this.btnPlatzhalterVerwenden.setText(Messages.getString("advanced_config.UseMarker")); //$NON-NLS-1$
this.btnPlatzhalterVerwenden.setToolTipText(Messages.getString("advanced_config.UseMarker_ToolTip")); //$NON-NLS-1$
this.btnSignatureFieldsUsage.setText(Messages.getString("advanced_config.UseSignatureFields")); //$NON-NLS-1$
this.btnSignatureFieldsUsage.setToolTipText(Messages.getString("advanced_config.UseSignatureFields_ToolTip")); //$NON-NLS-1$
this.btnEnablePlaceholderUsage.setText(Messages.getString("advanced_config.Placeholder_Enabled"));
- this.btnPdfACompat.setText(Messages
- .getString("advanced_config.PdfACompat")); //$NON-NLS-1$
- this.btnPdfACompat.setToolTipText(Messages
- .getString("advanced_config.PdfACompat_ToolTip")); //$NON-NLS-1$
- this.lblTransparenz.setText(Messages
- .getString("advanced_config.SigPHTransparency")); //$NON-NLS-1$
- this.lblTransparenzLinks.setText(Messages
- .getString("advanced_config.SigPHTransparencyMin")); //$NON-NLS-1$
- this.lblTransparenzRechts.setText(Messages
- .getString("advanced_config.SigPHTransparencyMax")); //$NON-NLS-1$
- this.sclTransparenz.setToolTipText(Messages
- .getString("advanced_config.SigPHTransparencyTooltip")); //$NON-NLS-1$
-
- this.grpBkuAuswahl.setText(Messages
- .getString("advanced_config.BKUSelection_Title")); //$NON-NLS-1$
- this.cmbBKUAuswahl.setToolTipText(Messages
- .getString("advanced_config.BKUSelection_ToolTip")); //$NON-NLS-1$
- this.btnKeystoreEnabled.setText(Messages
- .getString("advanced_config.KeystoreEnabled")); //$NON-NLS-1$
- this.btnKeystoreEnabled.setToolTipText(Messages
- .getString("advanced_config.KeystoreEnabled_ToolTip")); //$NON-NLS-1$
-
- this.grpSpeicherort.setText(Messages
- .getString("advanced_config.OutputFolder_Title")); //$NON-NLS-1$
- this.lblDefaultOutputFolder.setText(Messages
- .getString("advanced_config.OutputFolder")); //$NON-NLS-1$
- this.txtOutputFolder.setToolTipText(Messages
- .getString("advanced_config.OutputFolder_ToolTip")); //$NON-NLS-1$
+ this.btnPdfACompat.setText(Messages.getString("advanced_config.PdfACompat")); //$NON-NLS-1$
+ this.btnPdfACompat.setToolTipText(Messages.getString("advanced_config.PdfACompat_ToolTip")); //$NON-NLS-1$
+ this.lblTransparenz.setText(Messages.getString("advanced_config.SigPHTransparency")); //$NON-NLS-1$
+ this.lblTransparenzLinks.setText(Messages.getString("advanced_config.SigPHTransparencyMin")); //$NON-NLS-1$
+ this.lblTransparenzRechts.setText(Messages.getString("advanced_config.SigPHTransparencyMax")); //$NON-NLS-1$
+ this.sclTransparenz.setToolTipText(Messages.getString("advanced_config.SigPHTransparencyTooltip")); //$NON-NLS-1$
+
+ this.grpBkuAuswahl.setText(Messages.getString("advanced_config.BKUSelection_Title")); //$NON-NLS-1$
+ this.cmbBKUAuswahl.setToolTipText(Messages.getString("advanced_config.BKUSelection_ToolTip")); //$NON-NLS-1$
+ this.btnKeystoreEnabled.setText(Messages.getString("advanced_config.KeystoreEnabled")); //$NON-NLS-1$
+ this.btnKeystoreEnabled.setToolTipText(Messages.getString("advanced_config.KeystoreEnabled_ToolTip")); //$NON-NLS-1$
+
+ this.grpSpeicherort.setText(Messages.getString("advanced_config.OutputFolder_Title")); //$NON-NLS-1$
+ this.lblDefaultOutputFolder.setText(Messages.getString("advanced_config.OutputFolder")); //$NON-NLS-1$
+ this.txtOutputFolder.setToolTipText(Messages.getString("advanced_config.OutputFolder_ToolTip")); //$NON-NLS-1$
this.btnBrowse.setText(Messages.getString("common.browse")); //$NON-NLS-1$
- this.grpLocaleAuswahl.setText(Messages
- .getString("advanced_config.LocaleSelection_Title")); //$NON-NLS-1$
- this.cmbLocaleAuswahl.setToolTipText(Messages
- .getString("advanced_config.LocaleSelection_ToolTip")); //$NON-NLS-1$
+ this.grpLocaleAuswahl.setText(Messages.getString("advanced_config.LocaleSelection_Title")); //$NON-NLS-1$
+ 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.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
- .getString("advanced_config.ProxyHost_ToolTip")); //$NON-NLS-1$
- this.txtProxyHost.setMessage(Messages
- .getString("advanced_config.ProxyHost_Template")); //$NON-NLS-1$
- this.lblProxyPort.setText(Messages
- .getString("advanced_config.ProxyPort")); //$NON-NLS-1$
- this.txtProxyPort.setToolTipText(Messages
- .getString("advanced_config.ProxyPort_ToolTip")); //$NON-NLS-1$
- this.txtProxyPort.setMessage(Messages
- .getString("advanced_config.ProxyPort_Template")); //$NON-NLS-1$
-// this.lblProxyUser.setText(Messages.getString("advanced_config.ProxyUser")); //$NON-NLS-1$
-// this.txtProxyUser.setToolTipText(Messages
-// .getString("advanced_config.ProxyUser_ToolTip")); //$NON-NLS-1$
-// this.txtProxyUser.setMessage(Messages
-// .getString("advanced_config.ProxyUser_Template")); //$NON-NLS-1$
-// this.lblProxyPass.setText(Messages.getString("advanced_config.ProxyPass")); //$NON-NLS-1$
-// this.txtProxyPass.setToolTipText(Messages
-// .getString("advanced_config.ProxyPass_ToolTip")); //$NON-NLS-1$
-// this.txtProxyPass.setMessage(Messages
-// .getString("advanced_config.ProxyPass_Template")); //$NON-NLS-1$
+ this.txtProxyHost.setToolTipText(Messages.getString("advanced_config.ProxyHost_ToolTip")); //$NON-NLS-1$
+ this.txtProxyHost.setMessage(Messages.getString("advanced_config.ProxyHost_Template")); //$NON-NLS-1$
+ this.lblProxyPort.setText(Messages.getString("advanced_config.ProxyPort")); //$NON-NLS-1$
+ this.txtProxyPort.setToolTipText(Messages.getString("advanced_config.ProxyPort_ToolTip")); //$NON-NLS-1$
+ this.txtProxyPort.setMessage(Messages.getString("advanced_config.ProxyPort_Template")); //$NON-NLS-1$
+ // this.lblProxyUser.setText(Messages.getString("advanced_config.ProxyUser"));
+ // //$NON-NLS-1$
+ // this.txtProxyUser.setToolTipText(Messages
+ // .getString("advanced_config.ProxyUser_ToolTip")); //$NON-NLS-1$
+ // this.txtProxyUser.setMessage(Messages
+ // .getString("advanced_config.ProxyUser_Template")); //$NON-NLS-1$
+ // this.lblProxyPass.setText(Messages.getString("advanced_config.ProxyPass"));
+ // //$NON-NLS-1$
+ // this.txtProxyPass.setToolTipText(Messages
+ // .getString("advanced_config.ProxyPass_ToolTip")); //$NON-NLS-1$
+ // this.txtProxyPass.setMessage(Messages
+ // .getString("advanced_config.ProxyPass_Template")); //$NON-NLS-1$
}
}
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 7396a6b0..0940ea67 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
@@ -1,599 +1,601 @@
-/*
- * Copyright 2012 by A-SIT, Secure Information Technology Center Austria
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://joinup.ec.europa.eu/software/page/eupl
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- */
-package at.asit.pdfover.gui.composites;
-
-// Imports
-import java.awt.Desktop;
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.ScrolledComposite;
-import org.eclipse.swt.custom.StackLayout;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.program.Program;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Link;
-import org.eclipse.swt.widgets.TabFolder;
-import org.eclipse.swt.widgets.TabItem;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.asit.pdfover.gui.Constants;
-import at.asit.pdfover.gui.controls.Dialog.BUTTONS;
-import at.asit.pdfover.gui.controls.ErrorDialog;
-import at.asit.pdfover.gui.exceptions.ResumableException;
-import at.asit.pdfover.gui.utils.Messages;
-import at.asit.pdfover.gui.workflow.PDFSigner;
-import at.asit.pdfover.gui.workflow.config.ConfigManipulator;
-import at.asit.pdfover.gui.workflow.config.ConfigurationContainer;
-import at.asit.pdfover.gui.workflow.config.ConfigurationContainerImpl;
-import at.asit.pdfover.gui.workflow.config.PersistentConfigProvider;
-import at.asit.pdfover.gui.workflow.states.State;
-
-/**
- * Composite for hosting configuration composites
- */
-public class ConfigurationComposite extends StateComposite {
-
- /**
- * The PDF Signer used to produce signature block preview
- */
- protected PDFSigner signer;
-
- /**
- * SLF4J Logger instance
- **/
- static final Logger log = LoggerFactory
- .getLogger(ConfigurationComposite.class);
-
- /**
- * configuration manipulator
- */
- ConfigManipulator configManipulator = null;
-
- /**
- * configuration provider
- */
- PersistentConfigProvider configProvider = null;
-
- /**
- * simple configuration composite
- */
- BaseConfigurationComposite simpleConfigComposite;
-
- /**
- * advanced configuration composite
- */
- BaseConfigurationComposite advancedConfigComposite;
-
- /**
- * advanced configuration composite
- */
- BaseConfigurationComposite keystoreConfigComposite = null;
-
- /**
- * The TabFolder
- */
- TabFolder tabFolder;
-
- /**
- * configuration container Keeps state for current configuration changes
- */
- ConfigurationContainer configurationContainer = new ConfigurationContainerImpl();
-
- /**
- * The stack layout
- */
- StackLayout compositeStack = new StackLayout();
-
- /**
- * SWT style
- */
- int style;
-
- /**
- * base configuration container
- */
- Composite containerComposite;
-
- /**
- * checks whether the user is done
- */
- boolean userDone = false;
-
- private TabItem simpleTabItem;
-
- private TabItem advancedTabItem;
-
- private TabItem keystoreTabItem;
-
- private TabItem aboutTabItem;
-
- private Button btnSpeichern;
-
- private Button btnAbbrechen;
-
- /**
- * @return the signer
- */
- public PDFSigner getSigner() {
- return this.signer;
- }
-
- /**
- * Create the composite.
- *
- * @param parent
- * @param style
- * @param state
- */
- public ConfigurationComposite(Composite parent, int style, State state) {
- super(parent, SWT.FILL | style, state);
- this.style = SWT.FILL | style;
-
- this.setLayout(new FormLayout());
-
- this.containerComposite = new Composite(this, SWT.FILL | SWT.RESIZE);
-
- this.tabFolder = new TabFolder(this.containerComposite, SWT.NONE);
- FormData fd_tabFolder = new FormData();
- fd_tabFolder.bottom = new FormAttachment(100, -5);
- fd_tabFolder.right = new FormAttachment(100, -5);
- fd_tabFolder.top = new FormAttachment(0, 5);
- fd_tabFolder.left = new FormAttachment(0, 5);
- this.tabFolder.setLayoutData(fd_tabFolder);
-
- FontData[] fD_tabFolder = this.tabFolder.getFont().getFontData();
- fD_tabFolder[0].setHeight(Constants.TEXT_SIZE_NORMAL);
- this.tabFolder.setFont(new Font(Display.getCurrent(), fD_tabFolder[0]));
-
- this.simpleTabItem = new TabItem(this.tabFolder, SWT.NONE);
- this.simpleTabItem.setText(Messages.getString("config.Simple")); //$NON-NLS-1$
-
- ScrolledComposite simpleCompositeScr = new ScrolledComposite(this.tabFolder,
- SWT.H_SCROLL | SWT.V_SCROLL);
- this.simpleTabItem.setControl(simpleCompositeScr);
- this.simpleConfigComposite = new SimpleConfigurationComposite(
- simpleCompositeScr, SWT.NONE, state,
- this.configurationContainer);
- simpleCompositeScr.setContent(this.simpleConfigComposite);
- simpleCompositeScr.setExpandHorizontal(true);
- simpleCompositeScr.setExpandVertical(true);
- simpleCompositeScr.setMinSize(this.simpleConfigComposite.computeSize(
- SWT.DEFAULT, SWT.DEFAULT));
-
- this.advancedTabItem = new TabItem(this.tabFolder, SWT.NONE);
- this.advancedTabItem.setText(Messages.getString("config.Advanced")); //$NON-NLS-1$
-
- ScrolledComposite advancedCompositeScr = new ScrolledComposite(
- this.tabFolder, SWT.H_SCROLL | SWT.V_SCROLL);
- this.advancedTabItem.setControl(advancedCompositeScr);
- this.advancedConfigComposite = new AdvancedConfigurationComposite(
- advancedCompositeScr, SWT.NONE, state,
- this.configurationContainer, this);
- advancedCompositeScr.setContent(this.advancedConfigComposite);
- advancedCompositeScr.setExpandHorizontal(true);
- advancedCompositeScr.setExpandVertical(true);
- advancedCompositeScr.setMinSize(this.advancedConfigComposite
- .computeSize(SWT.DEFAULT, SWT.DEFAULT));
-
- this.aboutTabItem = new TabItem(this.tabFolder, SWT.NONE);
- this.aboutTabItem.setText(String.format(Messages.getString("config.About"), Constants.APP_NAME)); //$NON-NLS-1$
-
- ScrolledComposite aboutCompositeScr = new ScrolledComposite(
- this.tabFolder, SWT.H_SCROLL | SWT.V_SCROLL);
- this.aboutTabItem.setControl(aboutCompositeScr);
- AboutComposite aboutConfigComposite = new AboutComposite(
- aboutCompositeScr, SWT.NONE);
- aboutCompositeScr.setContent(aboutConfigComposite);
- aboutCompositeScr.setExpandHorizontal(true);
- aboutCompositeScr.setExpandVertical(true);
- aboutCompositeScr.setMinSize(aboutConfigComposite
- .computeSize(SWT.DEFAULT, SWT.DEFAULT));
-
- this.tabFolder.setSelection(this.simpleTabItem);
-
- this.btnSpeichern = new Button(this, SWT.NONE);
- FormData fd_btnSpeichern = new FormData();
- fd_btnSpeichern.right = new FormAttachment(100, -5);
- fd_btnSpeichern.bottom = new FormAttachment(100);
- this.btnSpeichern.setLayoutData(fd_btnSpeichern);
- this.btnSpeichern.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- getShell().setText(Constants.APP_NAME);
- if (ConfigurationComposite.this.storeConfiguration()) {
- ConfigurationComposite.this.userDone = true;
- ConfigurationComposite.this.state.updateStateMachine();
- }
- }
- });
- this.btnSpeichern.setText(Messages.getString("common.Save")); //$NON-NLS-1$
- getShell().setDefaultButton(this.btnSpeichern);
-
- FontData[] fD_btnSpeichern = this.btnSpeichern.getFont().getFontData();
- fD_btnSpeichern[0].setHeight(Constants.TEXT_SIZE_BUTTON);
- this.btnSpeichern
- .setFont(new Font(Display.getCurrent(), fD_btnSpeichern[0]));
-
- this.btnAbbrechen = new Button(this, SWT.NONE);
- FormData fd_btnAbrechen = new FormData();
- fd_btnAbrechen.right = new FormAttachment(this.btnSpeichern, -10);
- fd_btnAbrechen.bottom = new FormAttachment(this.btnSpeichern, 0, SWT.BOTTOM);
- this.btnAbbrechen.setLayoutData(fd_btnAbrechen);
- this.btnAbbrechen.setText(Messages.getString("common.Cancel")); //$NON-NLS-1$
- this.btnAbbrechen.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- getShell().setText(Constants.APP_NAME);
- ConfigurationComposite.this.userDone = true;
- ConfigurationComposite.this.state.updateStateMachine();
- }
- });
-
- FontData[] fD_btnAbbrechen = this.btnAbbrechen.getFont().getFontData();
- fD_btnAbbrechen[0].setHeight(Constants.TEXT_SIZE_BUTTON);
- this.btnAbbrechen
- .setFont(new Font(Display.getCurrent(), fD_btnAbbrechen[0]));
-
- FormData fd_composite = new FormData();
- fd_composite.top = new FormAttachment(0, 5);
- fd_composite.bottom = new FormAttachment(this.btnSpeichern, -10);
- fd_composite.left = new FormAttachment(0, 5);
- fd_composite.right = new FormAttachment(100, -5);
- this.containerComposite.setLayoutData(fd_composite);
- this.containerComposite.setLayout(this.compositeStack);
- this.compositeStack.topControl = this.tabFolder;
-
- getShell().setText(Constants.APP_NAME_VERSION);
-
- this.doLayout();
- }
-
- /**
- * @param signer
- * the signer to set
- */
- public void setSigner(PDFSigner signer) {
- this.signer = signer;
- if (this.simpleConfigComposite != null) {
- this.simpleConfigComposite.setSigner(getSigner());
- }
- if (this.advancedConfigComposite != null) {
- // not needed at the moment
- this.advancedConfigComposite.setSigner(getSigner());
- }
- if (this.keystoreConfigComposite != null) {
- // not needed at the moment
- this.keystoreConfigComposite.setSigner(getSigner());
- }
- }
-
- private class AboutComposite extends StateComposite {
- private Link lnkAbout;
- /**
- * @param parent
- * @param style
- */
- public AboutComposite(Composite parent, int style) {
- super(parent, style, null);
-
- setLayout(new FormLayout());
-
- this.lnkAbout = new Link(this, SWT.WRAP);
-
- FormData fd_lnkAbout = new FormData();
- fd_lnkAbout.right = new FormAttachment(100, -5);
- fd_lnkAbout.left = new FormAttachment(0, 5);
- fd_lnkAbout.top = new FormAttachment(0, 5);
- fd_lnkAbout.width = 100;
- this.lnkAbout.setLayoutData(fd_lnkAbout);
-
- FontData[] fD_lnkAbout = this.lnkAbout.getFont().getFontData();
- fD_lnkAbout[0].setHeight(Constants.TEXT_SIZE_NORMAL);
- this.lnkAbout.setFont(new Font(Display.getCurrent(),
- fD_lnkAbout[0]));
-
- this.lnkAbout.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- try {
- URI url = new URI("https://technology.a-sit.at/lizenzbedingungen/"); //$NON-NLS-1$
- log.debug("Trying to open " + url.toString()); //$NON-NLS-1$
- if (Desktop.isDesktopSupported()) {
- Desktop.getDesktop().browse(url);
- } else {
- log.info("AWT Desktop is not supported on this platform"); //$NON-NLS-1$
- Program.launch(url.toString());
- }
- } catch (IOException ex) {
- log.error("AboutComposite: ", ex); //$NON-NLS-1$
- } catch (URISyntaxException ex) {
- log.error("AboutComposite: ", ex); //$NON-NLS-1$
- }
- }
- });
-
- // Load localized strings
- reloadResources();
- }
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.gui.composites.StateComposite#doLayout()
- */
- @Override
- public void doLayout() {
- // Nothing to do here
- }
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.gui.composites.StateComposite#reloadResources()
- */
- @Override
- public void reloadResources() {
- this.lnkAbout.setText(Messages.getString("config.AboutText")); //$NON-NLS-1$
- }
- }
-
- private boolean keystoreInitialized = false;
-
- /**
- * Set whether keystore tab is enabled
- * @param enabled whether keystore tab is enabled
- */
- public void keystoreEnabled(boolean enabled) {
- if (enabled && this.keystoreConfigComposite == null) {
- this.keystoreTabItem = new TabItem(this.tabFolder, SWT.NONE, 2);
- this.keystoreTabItem.setText(Messages.getString("config.Keystore")); //$NON-NLS-1$
-
- ScrolledComposite keystoreCompositeScr = new ScrolledComposite(
- this.tabFolder, SWT.H_SCROLL | SWT.V_SCROLL);
- this.keystoreTabItem.setControl(keystoreCompositeScr);
- this.keystoreConfigComposite = new KeystoreConfigurationComposite(
- keystoreCompositeScr, SWT.NONE, this.state,
- this.configurationContainer);
- keystoreCompositeScr.setContent(this.keystoreConfigComposite);
- keystoreCompositeScr.setExpandHorizontal(true);
- keystoreCompositeScr.setExpandVertical(true);
- keystoreCompositeScr.setMinSize(this.keystoreConfigComposite
- .computeSize(SWT.DEFAULT, SWT.DEFAULT));
- if (!this.keystoreInitialized) {
- this.keystoreConfigComposite.initConfiguration(this.configProvider);
- this.keystoreInitialized = true;
- }
- this.keystoreConfigComposite.loadConfiguration();
- } else if (!enabled && this.keystoreConfigComposite != null){
- this.keystoreTabItem.dispose();
- this.keystoreConfigComposite = null;
- }
- }
-
- /**
- * Sets the configuration manipulator
- *
- * @param manipulator
- */
- public void setConfigManipulator(ConfigManipulator manipulator) {
- this.configManipulator = manipulator;
- }
-
- /**
- * Sets the configuration provider
- *
- * @param provider
- */
- public void setConfigProvider(PersistentConfigProvider provider) {
- this.configProvider = provider;
- if (this.configProvider != null) {
- // Initialize Configuration Container
- this.simpleConfigComposite.initConfiguration(this.configProvider);
- this.advancedConfigComposite.initConfiguration(this.configProvider);
-
- this.simpleConfigComposite.loadConfiguration();
- this.advancedConfigComposite.loadConfiguration();
- if (this.keystoreConfigComposite != null)
- this.keystoreConfigComposite.loadConfiguration();
- }
- }
-
- boolean storeConfiguration() {
- boolean status = false;
- boolean redo = false;
- int resumeIndex = 0;
- try {
- do {
- try {
- this.simpleConfigComposite.validateSettings(resumeIndex);
-
- redo = false;
- status = true;
- } catch (ResumableException e) {
- log.error("Settings validation failed!", e); //$NON-NLS-1$
- ErrorDialog dialog = new ErrorDialog(getShell(),
- e.getMessage(), BUTTONS.ABORT_RETRY_IGNORE);
- int rc = dialog.open();
-
- redo = (rc == SWT.RETRY);
- if (rc == SWT.IGNORE)
- {
- resumeIndex = e.getResumeIndex();
- redo = true;
- }
- }
- } while (redo);
-
- if (!status) {
- return false;
- }
-
- status = false;
- redo = false;
- resumeIndex = 0;
-
- do {
- try {
- this.advancedConfigComposite.validateSettings(resumeIndex);
-
- redo = false;
- status = true;
- } catch (ResumableException e) {
- log.error("Settings validation failed!", e); //$NON-NLS-1$
- ErrorDialog dialog = new ErrorDialog(getShell(),
- e.getMessage(), BUTTONS.ABORT_RETRY_IGNORE);
- int rc = dialog.open();
-
- redo = (rc == SWT.RETRY);
- if (rc == SWT.IGNORE)
- {
- resumeIndex = e.getResumeIndex();
- redo = true;
- }
- }
- } while (redo);
-
- if (!status) {
- return false;
- }
-
- if (this.keystoreConfigComposite != null) {
- status = false;
- redo = false;
- resumeIndex = 0;
-
- do {
- try {
- this.keystoreConfigComposite.validateSettings(resumeIndex);
-
- redo = false;
- status = true;
- } catch (ResumableException e) {
- log.error("Settings validation failed!", e); //$NON-NLS-1$
- ErrorDialog dialog = new ErrorDialog(getShell(),
- e.getMessage(), BUTTONS.ABORT_RETRY_IGNORE);
- int rc = dialog.open();
-
- redo = (rc == SWT.RETRY);
- if (rc == SWT.IGNORE)
- {
- resumeIndex = e.getResumeIndex();
- redo = true;
- }
- }
- } while (redo);
-
- if (!status) {
- return false;
- }
- }
- } catch (Exception e) {
- log.error("Settings validation failed!", e); //$NON-NLS-1$
- String message = e.getMessage();
- if (message == null)
- message = Messages.getString("error.Unexpected"); //$NON-NLS-1$
- ErrorDialog dialog = new ErrorDialog(getShell(), message,
- BUTTONS.OK);
- dialog.open();
- return false;
- }
-
- if (!status) {
- return false;
- }
-
- // Write current Configuration
- this.simpleConfigComposite.storeConfiguration(
- this.configManipulator, this.configProvider);
- this.advancedConfigComposite.storeConfiguration(
- this.configManipulator, this.configProvider);
- if (this.keystoreConfigComposite != null)
- this.keystoreConfigComposite.storeConfiguration(
- this.configManipulator, this.configProvider);
-
- status = false;
- redo = false;
- do {
- // Save current config to file
- try {
- this.configManipulator.saveCurrentConfiguration();
- redo = false;
- status = true;
- } catch (IOException e) {
- log.error("Failed to save configuration to file!", e); //$NON-NLS-1$
- ErrorDialog dialog = new ErrorDialog(getShell(),
- Messages.getString("error.FailedToSaveSettings"), BUTTONS.RETRY_CANCEL); //$NON-NLS-1$
- redo = (dialog.open() == SWT.RETRY);
-
- // return false;
- }
- } while (redo);
-
- return status;
- }
-
- /**
- * Checks if the user has finished working with the configuration composite
- *
- * @return if the user is done
- */
- public boolean isUserDone() {
- return this.userDone;
- }
-
- @Override
- protected void checkSubclass() {
- // Disable the check that prevents subclassing of SWT components
- }
-
- /*
- * (non-Javadoc)
- *
- * @see at.asit.pdfover.gui.composites.StateComposite#doLayout()
- */
- @Override
- public void doLayout() {
- Control ctrl = this.compositeStack.topControl;
- this.containerComposite.layout(true, true);
- getShell().layout(true, true);
- // Note: SWT only layouts children! No grandchildren!
- if (ctrl instanceof StateComposite) {
- ((StateComposite) ctrl).doLayout();
- }
- setFocus();
- }
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.gui.composites.StateComposite#reloadResources()
- */
- @Override
- public void reloadResources() {
- this.simpleTabItem.setText(Messages.getString("config.Simple")); //$NON-NLS-1$
- this.advancedTabItem.setText(Messages.getString("config.Advanced")); //$NON-NLS-1$
- this.aboutTabItem.setText(String.format(Messages.getString("config.About"), Constants.APP_NAME)); //$NON-NLS-1$
- this.btnSpeichern.setText(Messages.getString("common.Save")); //$NON-NLS-1$
- this.btnAbbrechen.setText(Messages.getString("common.Cancel")); //$NON-NLS-1$
- }
-}
+/*
+ * Copyright 2012 by A-SIT, Secure Information Technology Center Austria
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://joinup.ec.europa.eu/software/page/eupl
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ */
+package at.asit.pdfover.gui.composites;
+
+// Imports
+import java.awt.Desktop;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.ScrolledComposite;
+import org.eclipse.swt.custom.StackLayout;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.program.Program;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Link;
+import org.eclipse.swt.widgets.TabFolder;
+import org.eclipse.swt.widgets.TabItem;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import at.asit.pdfover.gui.Constants;
+import at.asit.pdfover.gui.controls.Dialog.BUTTONS;
+import at.asit.pdfover.gui.controls.ErrorDialog;
+import at.asit.pdfover.gui.exceptions.ResumableException;
+import at.asit.pdfover.gui.utils.Messages;
+import at.asit.pdfover.gui.workflow.PDFSigner;
+import at.asit.pdfover.gui.workflow.config.ConfigManipulator;
+import at.asit.pdfover.gui.workflow.config.ConfigurationContainer;
+import at.asit.pdfover.gui.workflow.config.ConfigurationContainerImpl;
+import at.asit.pdfover.gui.workflow.config.PersistentConfigProvider;
+import at.asit.pdfover.gui.workflow.states.State;
+
+/**
+ * Composite for hosting configuration composites
+ */
+public class ConfigurationComposite extends StateComposite {
+
+ /**
+ * The PDF Signer used to produce signature block preview
+ */
+ protected PDFSigner signer;
+
+ /**
+ * SLF4J Logger instance
+ **/
+ static final Logger log = LoggerFactory
+ .getLogger(ConfigurationComposite.class);
+
+ /**
+ * configuration manipulator
+ */
+ ConfigManipulator configManipulator = null;
+
+ /**
+ * configuration provider
+ */
+ PersistentConfigProvider configProvider = null;
+
+ /**
+ * simple configuration composite
+ */
+ BaseConfigurationComposite simpleConfigComposite;
+
+ /**
+ * advanced configuration composite
+ */
+ BaseConfigurationComposite advancedConfigComposite;
+
+ /**
+ * advanced configuration composite
+ */
+ BaseConfigurationComposite keystoreConfigComposite = null;
+
+ /**
+ * The TabFolder
+ */
+ TabFolder tabFolder;
+
+ /**
+ * configuration container Keeps state for current configuration changes
+ */
+ ConfigurationContainer configurationContainer = new ConfigurationContainerImpl();
+
+ /**
+ * The stack layout
+ */
+ StackLayout compositeStack = new StackLayout();
+
+ /**
+ * SWT style
+ */
+ int style;
+
+ /**
+ * base configuration container
+ */
+ Composite containerComposite;
+
+ /**
+ * checks whether the user is done
+ */
+ boolean userDone = false;
+
+ private TabItem simpleTabItem;
+
+ private TabItem advancedTabItem;
+
+ private TabItem keystoreTabItem;
+
+ private TabItem aboutTabItem;
+
+ private Button btnSpeichern;
+
+ private Button btnAbbrechen;
+
+ /**
+ * @return the signer
+ */
+ public PDFSigner getSigner() {
+ return this.signer;
+ }
+
+ /**
+ * Create the composite.
+ *
+ * @param parent
+ * @param style
+ * @param state
+ */
+ public ConfigurationComposite(Composite parent, int style, State state) {
+ super(parent, SWT.FILL | style, state);
+ this.style = SWT.FILL | style;
+
+ this.setLayout(new FormLayout());
+
+ this.containerComposite = new Composite(this, SWT.FILL | SWT.RESIZE);
+
+ this.tabFolder = new TabFolder(this.containerComposite, SWT.NONE);
+ FormData fd_tabFolder = new FormData();
+ fd_tabFolder.bottom = new FormAttachment(100, -5);
+ fd_tabFolder.right = new FormAttachment(100, -5);
+ fd_tabFolder.top = new FormAttachment(0, 5);
+ fd_tabFolder.left = new FormAttachment(0, 5);
+ this.tabFolder.setLayoutData(fd_tabFolder);
+
+ FontData[] fD_tabFolder = this.tabFolder.getFont().getFontData();
+ fD_tabFolder[0].setHeight(Constants.TEXT_SIZE_NORMAL);
+ this.tabFolder.setFont(new Font(Display.getCurrent(), fD_tabFolder[0]));
+
+ this.simpleTabItem = new TabItem(this.tabFolder, SWT.NONE);
+ this.simpleTabItem.setText(Messages.getString("config.Simple")); //$NON-NLS-1$
+ System.out.println(Messages.getString("config.Simple"));
+
+ ScrolledComposite simpleCompositeScr = new ScrolledComposite(this.tabFolder,
+ SWT.H_SCROLL | SWT.V_SCROLL);
+ this.simpleTabItem.setControl(simpleCompositeScr);
+ this.simpleConfigComposite = new SimpleConfigurationComposite(
+ simpleCompositeScr, SWT.NONE, state,
+ this.configurationContainer);
+ simpleCompositeScr.setContent(this.simpleConfigComposite);
+ simpleCompositeScr.setExpandHorizontal(true);
+ simpleCompositeScr.setExpandVertical(true);
+ simpleCompositeScr.setMinSize(this.simpleConfigComposite.computeSize(
+ SWT.DEFAULT, SWT.DEFAULT));
+
+ this.advancedTabItem = new TabItem(this.tabFolder, SWT.NONE);
+ this.advancedTabItem.setText(Messages.getString("config.Advanced")); //$NON-NLS-1$
+ System.out.print(Messages.getString("config.Advanced"));
+
+ ScrolledComposite advancedCompositeScr = new ScrolledComposite(
+ this.tabFolder, SWT.H_SCROLL | SWT.V_SCROLL);
+ this.advancedTabItem.setControl(advancedCompositeScr);
+ this.advancedConfigComposite = new AdvancedConfigurationComposite(
+ advancedCompositeScr, SWT.NONE, state,
+ this.configurationContainer, this);
+ advancedCompositeScr.setContent(this.advancedConfigComposite);
+ advancedCompositeScr.setExpandHorizontal(true);
+ advancedCompositeScr.setExpandVertical(true);
+ advancedCompositeScr.setMinSize(this.advancedConfigComposite
+ .computeSize(SWT.DEFAULT, SWT.DEFAULT));
+
+ this.aboutTabItem = new TabItem(this.tabFolder, SWT.NONE);
+ this.aboutTabItem.setText(String.format(Messages.getString("config.About"), Constants.APP_NAME)); //$NON-NLS-1$
+
+ ScrolledComposite aboutCompositeScr = new ScrolledComposite(
+ this.tabFolder, SWT.H_SCROLL | SWT.V_SCROLL);
+ this.aboutTabItem.setControl(aboutCompositeScr);
+ AboutComposite aboutConfigComposite = new AboutComposite(
+ aboutCompositeScr, SWT.NONE);
+ aboutCompositeScr.setContent(aboutConfigComposite);
+ aboutCompositeScr.setExpandHorizontal(true);
+ aboutCompositeScr.setExpandVertical(true);
+ aboutCompositeScr.setMinSize(aboutConfigComposite
+ .computeSize(SWT.DEFAULT, SWT.DEFAULT));
+
+ this.tabFolder.setSelection(this.simpleTabItem);
+
+ this.btnSpeichern = new Button(this, SWT.NONE);
+ FormData fd_btnSpeichern = new FormData();
+ fd_btnSpeichern.right = new FormAttachment(100, -5);
+ fd_btnSpeichern.bottom = new FormAttachment(100);
+ this.btnSpeichern.setLayoutData(fd_btnSpeichern);
+ this.btnSpeichern.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ getShell().setText(Constants.APP_NAME);
+ if (ConfigurationComposite.this.storeConfiguration()) {
+ ConfigurationComposite.this.userDone = true;
+ ConfigurationComposite.this.state.updateStateMachine();
+ }
+ }
+ });
+ this.btnSpeichern.setText(Messages.getString("common.Save")); //$NON-NLS-1$
+ getShell().setDefaultButton(this.btnSpeichern);
+
+ FontData[] fD_btnSpeichern = this.btnSpeichern.getFont().getFontData();
+ fD_btnSpeichern[0].setHeight(Constants.TEXT_SIZE_BUTTON);
+ this.btnSpeichern
+ .setFont(new Font(Display.getCurrent(), fD_btnSpeichern[0]));
+
+ this.btnAbbrechen = new Button(this, SWT.NONE);
+ FormData fd_btnAbrechen = new FormData();
+ fd_btnAbrechen.right = new FormAttachment(this.btnSpeichern, -10);
+ fd_btnAbrechen.bottom = new FormAttachment(this.btnSpeichern, 0, SWT.BOTTOM);
+ this.btnAbbrechen.setLayoutData(fd_btnAbrechen);
+ this.btnAbbrechen.setText(Messages.getString("common.Cancel")); //$NON-NLS-1$
+ this.btnAbbrechen.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ getShell().setText(Constants.APP_NAME);
+ ConfigurationComposite.this.userDone = true;
+ ConfigurationComposite.this.state.updateStateMachine();
+ }
+ });
+
+ FontData[] fD_btnAbbrechen = this.btnAbbrechen.getFont().getFontData();
+ fD_btnAbbrechen[0].setHeight(Constants.TEXT_SIZE_BUTTON);
+ this.btnAbbrechen
+ .setFont(new Font(Display.getCurrent(), fD_btnAbbrechen[0]));
+
+ FormData fd_composite = new FormData();
+ fd_composite.top = new FormAttachment(0, 5);
+ fd_composite.bottom = new FormAttachment(this.btnSpeichern, -10);
+ fd_composite.left = new FormAttachment(0, 5);
+ fd_composite.right = new FormAttachment(100, -5);
+ this.containerComposite.setLayoutData(fd_composite);
+ this.containerComposite.setLayout(this.compositeStack);
+ this.compositeStack.topControl = this.tabFolder;
+
+ getShell().setText(Constants.APP_NAME_VERSION);
+
+ this.doLayout();
+ }
+
+ /**
+ * @param signer
+ * the signer to set
+ */
+ public void setSigner(PDFSigner signer) {
+ this.signer = signer;
+ if (this.simpleConfigComposite != null) {
+ this.simpleConfigComposite.setSigner(getSigner());
+ }
+ if (this.advancedConfigComposite != null) {
+ // not needed at the moment
+ this.advancedConfigComposite.setSigner(getSigner());
+ }
+ if (this.keystoreConfigComposite != null) {
+ // not needed at the moment
+ this.keystoreConfigComposite.setSigner(getSigner());
+ }
+ }
+
+ private class AboutComposite extends StateComposite {
+ private Link lnkAbout;
+ /**
+ * @param parent
+ * @param style
+ */
+ public AboutComposite(Composite parent, int style) {
+ super(parent, style, null);
+
+ setLayout(new FormLayout());
+
+ this.lnkAbout = new Link(this, SWT.WRAP);
+
+ FormData fd_lnkAbout = new FormData();
+ fd_lnkAbout.right = new FormAttachment(100, -5);
+ fd_lnkAbout.left = new FormAttachment(0, 5);
+ fd_lnkAbout.top = new FormAttachment(0, 5);
+ fd_lnkAbout.width = 100;
+ this.lnkAbout.setLayoutData(fd_lnkAbout);
+
+ FontData[] fD_lnkAbout = this.lnkAbout.getFont().getFontData();
+ fD_lnkAbout[0].setHeight(Constants.TEXT_SIZE_NORMAL);
+ this.lnkAbout.setFont(new Font(Display.getCurrent(),
+ fD_lnkAbout[0]));
+
+ this.lnkAbout.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ try {
+ URI url = new URI(Messages.getString("config.LicenseURL")); //$NON-NLS-1$
+ log.debug("Trying to open " + url.toString()); //$NON-NLS-1$
+ if (Desktop.isDesktopSupported()) {
+ Desktop.getDesktop().browse(url);
+ } else {
+ log.info("AWT Desktop is not supported on this platform"); //$NON-NLS-1$
+ Program.launch(url.toString());
+ }
+ } catch (IOException ex) {
+ log.error("AboutComposite: ", ex); //$NON-NLS-1$
+ } catch (URISyntaxException ex) {
+ log.error("AboutComposite: ", ex); //$NON-NLS-1$
+ }
+ }
+ });
+
+ // Load localized strings
+ reloadResources();
+ }
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.composites.StateComposite#doLayout()
+ */
+ @Override
+ public void doLayout() {
+ // Nothing to do here
+ }
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.composites.StateComposite#reloadResources()
+ */
+ @Override
+ public void reloadResources() {
+ this.lnkAbout.setText(Messages.getString("config.AboutText")); //$NON-NLS-1$
+ }
+ }
+
+ private boolean keystoreInitialized = false;
+
+ /**
+ * Set whether keystore tab is enabled
+ * @param enabled whether keystore tab is enabled
+ */
+ public void keystoreEnabled(boolean enabled) {
+ if (enabled && this.keystoreConfigComposite == null) {
+ this.keystoreTabItem = new TabItem(this.tabFolder, SWT.NONE, 2);
+ this.keystoreTabItem.setText(Messages.getString("config.Keystore")); //$NON-NLS-1$
+
+ ScrolledComposite keystoreCompositeScr = new ScrolledComposite(
+ this.tabFolder, SWT.H_SCROLL | SWT.V_SCROLL);
+ this.keystoreTabItem.setControl(keystoreCompositeScr);
+ this.keystoreConfigComposite = new KeystoreConfigurationComposite(
+ keystoreCompositeScr, SWT.NONE, this.state,
+ this.configurationContainer);
+ keystoreCompositeScr.setContent(this.keystoreConfigComposite);
+ keystoreCompositeScr.setExpandHorizontal(true);
+ keystoreCompositeScr.setExpandVertical(true);
+ keystoreCompositeScr.setMinSize(this.keystoreConfigComposite
+ .computeSize(SWT.DEFAULT, SWT.DEFAULT));
+ if (!this.keystoreInitialized) {
+ this.keystoreConfigComposite.initConfiguration(this.configProvider);
+ this.keystoreInitialized = true;
+ }
+ this.keystoreConfigComposite.loadConfiguration();
+ } else if (!enabled && this.keystoreConfigComposite != null){
+ this.keystoreTabItem.dispose();
+ this.keystoreConfigComposite = null;
+ }
+ }
+
+ /**
+ * Sets the configuration manipulator
+ *
+ * @param manipulator
+ */
+ public void setConfigManipulator(ConfigManipulator manipulator) {
+ this.configManipulator = manipulator;
+ }
+
+ /**
+ * Sets the configuration provider
+ *
+ * @param provider
+ */
+ public void setConfigProvider(PersistentConfigProvider provider) {
+ this.configProvider = provider;
+ if (this.configProvider != null) {
+ // Initialize Configuration Container
+ this.simpleConfigComposite.initConfiguration(this.configProvider);
+ this.advancedConfigComposite.initConfiguration(this.configProvider);
+
+ this.simpleConfigComposite.loadConfiguration();
+ this.advancedConfigComposite.loadConfiguration();
+ if (this.keystoreConfigComposite != null)
+ this.keystoreConfigComposite.loadConfiguration();
+ }
+ }
+
+ boolean storeConfiguration() {
+ boolean status = false;
+ boolean redo = false;
+ int resumeIndex = 0;
+ try {
+ do {
+ try {
+ this.simpleConfigComposite.validateSettings(resumeIndex);
+
+ redo = false;
+ status = true;
+ } catch (ResumableException e) {
+ log.error("Settings validation failed!", e); //$NON-NLS-1$
+ ErrorDialog dialog = new ErrorDialog(getShell(),
+ e.getMessage(), BUTTONS.ABORT_RETRY_IGNORE);
+ int rc = dialog.open();
+
+ redo = (rc == SWT.RETRY);
+ if (rc == SWT.IGNORE)
+ {
+ resumeIndex = e.getResumeIndex();
+ redo = true;
+ }
+ }
+ } while (redo);
+
+ if (!status) {
+ return false;
+ }
+
+ status = false;
+ redo = false;
+ resumeIndex = 0;
+
+ do {
+ try {
+ this.advancedConfigComposite.validateSettings(resumeIndex);
+
+ redo = false;
+ status = true;
+ } catch (ResumableException e) {
+ log.error("Settings validation failed!", e); //$NON-NLS-1$
+ ErrorDialog dialog = new ErrorDialog(getShell(),
+ e.getMessage(), BUTTONS.ABORT_RETRY_IGNORE);
+ int rc = dialog.open();
+
+ redo = (rc == SWT.RETRY);
+ if (rc == SWT.IGNORE)
+ {
+ resumeIndex = e.getResumeIndex();
+ redo = true;
+ }
+ }
+ } while (redo);
+
+ if (!status) {
+ return false;
+ }
+
+ if (this.keystoreConfigComposite != null) {
+ status = false;
+ redo = false;
+ resumeIndex = 0;
+
+ do {
+ try {
+ this.keystoreConfigComposite.validateSettings(resumeIndex);
+
+ redo = false;
+ status = true;
+ } catch (ResumableException e) {
+ log.error("Settings validation failed!", e); //$NON-NLS-1$
+ ErrorDialog dialog = new ErrorDialog(getShell(),
+ e.getMessage(), BUTTONS.ABORT_RETRY_IGNORE);
+ int rc = dialog.open();
+
+ redo = (rc == SWT.RETRY);
+ if (rc == SWT.IGNORE)
+ {
+ resumeIndex = e.getResumeIndex();
+ redo = true;
+ }
+ }
+ } while (redo);
+
+ if (!status) {
+ return false;
+ }
+ }
+ } catch (Exception e) {
+ log.error("Settings validation failed!", e); //$NON-NLS-1$
+ String message = e.getMessage();
+ if (message == null)
+ message = Messages.getString("error.Unexpected"); //$NON-NLS-1$
+ ErrorDialog dialog = new ErrorDialog(getShell(), message,
+ BUTTONS.OK);
+ dialog.open();
+ return false;
+ }
+
+ if (!status) {
+ return false;
+ }
+
+ // Write current Configuration
+ this.simpleConfigComposite.storeConfiguration(
+ this.configManipulator, this.configProvider);
+ this.advancedConfigComposite.storeConfiguration(
+ this.configManipulator, this.configProvider);
+ if (this.keystoreConfigComposite != null)
+ this.keystoreConfigComposite.storeConfiguration(
+ this.configManipulator, this.configProvider);
+
+ status = false;
+ redo = false;
+ do {
+ // Save current config to file
+ try {
+ this.configManipulator.saveCurrentConfiguration();
+ redo = false;
+ status = true;
+ } catch (IOException e) {
+ log.error("Failed to save configuration to file!", e); //$NON-NLS-1$
+ ErrorDialog dialog = new ErrorDialog(getShell(),
+ Messages.getString("error.FailedToSaveSettings"), BUTTONS.RETRY_CANCEL); //$NON-NLS-1$
+ redo = (dialog.open() == SWT.RETRY);
+
+ // return false;
+ }
+ } while (redo);
+
+ return status;
+ }
+
+ /**
+ * Checks if the user has finished working with the configuration composite
+ *
+ * @return if the user is done
+ */
+ public boolean isUserDone() {
+ return this.userDone;
+ }
+
+ @Override
+ protected void checkSubclass() {
+ // Disable the check that prevents subclassing of SWT components
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see at.asit.pdfover.gui.composites.StateComposite#doLayout()
+ */
+ @Override
+ public void doLayout() {
+ Control ctrl = this.compositeStack.topControl;
+ this.containerComposite.layout(true, true);
+ getShell().layout(true, true);
+ // Note: SWT only layouts children! No grandchildren!
+ if (ctrl instanceof StateComposite) {
+ ((StateComposite) ctrl).doLayout();
+ }
+ setFocus();
+ }
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.composites.StateComposite#reloadResources()
+ */
+ @Override
+ public void reloadResources() {
+ this.simpleTabItem.setText(Messages.getString("config.Simple")); //$NON-NLS-1$
+ this.advancedTabItem.setText(Messages.getString("config.Advanced")); //$NON-NLS-1$
+ this.aboutTabItem.setText(String.format(Messages.getString("config.About"), Constants.APP_NAME)); //$NON-NLS-1$
+ this.btnSpeichern.setText(Messages.getString("common.Save")); //$NON-NLS-1$
+ this.btnAbbrechen.setText(Messages.getString("common.Cancel")); //$NON-NLS-1$
+ }
+}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUEnterNumberComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUEnterNumberComposite.java
index f49ebdc4..f10ea855 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUEnterNumberComposite.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUEnterNumberComposite.java
@@ -360,6 +360,8 @@ public class MobileBKUEnterNumberComposite extends StateComposite {
public String getMobilePassword() {
return this.mobilePassword;
}
+
+
/**
* @param mobilePassword
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/OutputComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/OutputComposite.java
index f879f82c..31bf6f93 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/OutputComposite.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/OutputComposite.java
@@ -1,486 +1,499 @@
-/*
- * Copyright 2012 by A-SIT, Secure Information Technology Center Austria
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://joinup.ec.europa.eu/software/page/eupl
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- */
-package at.asit.pdfover.gui.composites;
-
-// Imports
-import java.awt.Desktop;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-
-import org.apache.commons.io.FilenameUtils;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.program.Program;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Link;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.asit.pdfover.gui.Constants;
-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.utils.Messages;
-import at.asit.pdfover.gui.workflow.states.State;
-import at.asit.pdfover.signator.DocumentSource;
-
-/**
- * GUI component for Output State
- */
-public class OutputComposite extends StateComposite {
-
- /**
- * SLF4J Logger instance
- **/
- static final Logger log = LoggerFactory.getLogger(OutputComposite.class);
-
- private Link lnk_saved_file;
-
- private Button btn_save;
-
- private Label lbl_success_message;
-
- private DocumentSource signedDocument;
-
- private File inputFile;
-
- String outputDir = null;
-
- String tempDirectory = null;
-
- File outputFile = null;
-
- private boolean saveFailed = false;
-
- /**
- * Create the composite.
- *
- * @param parent
- * The parent composite
- * @param style
- * The swt style
- * @param state
- * The owning state
- */
- public OutputComposite(Composite parent, int style, State state) {
- super(parent, style, state);
-
- this.setLayout(new FormLayout());
-
- this.lbl_success_message = new Label(this, SWT.NATIVE | SWT.RESIZE);
- FormData fd_lbl_success_message = new FormData();
- fd_lbl_success_message.top = new FormAttachment(40, 0);
- fd_lbl_success_message.left = new FormAttachment(0);
- fd_lbl_success_message.right = new FormAttachment(100);
- this.lbl_success_message.setLayoutData(fd_lbl_success_message);
- this.lbl_success_message.setAlignment(SWT.CENTER);
-
- FontData[] fD1 = this.lbl_success_message.getFont().getFontData();
- fD1[0].setHeight(Constants.TEXT_SIZE_BIG);
- this.lbl_success_message.setFont(new Font(Display.getCurrent(), fD1[0]));
-
- this.lnk_saved_file = new Link(this, SWT.NATIVE | SWT.RESIZE);
- FormData fd_lnk_saved_file = new FormData();
- fd_lnk_saved_file.top = new FormAttachment(this.lbl_success_message, 10);
- fd_lnk_saved_file.left = new FormAttachment(this.lbl_success_message, 0,
- SWT.CENTER);
- // fd_lnk_saved_file.right = new FormAttachment(100);
- this.lnk_saved_file.setLayoutData(fd_lnk_saved_file);
-
- this.lnk_saved_file.addSelectionListener(new OpenSelectionListener());
-
- FontData[] fD2 = this.lnk_saved_file.getFont().getFontData();
- fD2[0].setHeight(Constants.TEXT_SIZE_NORMAL);
- this.lnk_saved_file.setFont(new Font(Display.getCurrent(), fD2[0]));
-
- this.btn_save = new Button(this, SWT.NATIVE | SWT.RESIZE);
-
- FontData[] fD_btn_save = this.btn_save.getFont().getFontData();
- fD_btn_save[0].setHeight(Constants.TEXT_SIZE_BUTTON);
- this.btn_save.setFont(new Font(Display.getCurrent(), fD_btn_save[0]));
-
- FormData fd_btn_save = new FormData();
- fd_btn_save.top = new FormAttachment(this.lnk_saved_file, 10);
- fd_btn_save.left = new FormAttachment(this.lnk_saved_file, 0,
- SWT.CENTER);
- this.btn_save.setLayoutData(fd_btn_save);
-
- this.btn_save.addSelectionListener(new SaveSelectionListener());
- enableSaveButton(false);
-
- reloadResources();
- }
-
- /**
- * @param outputDir
- * the outputDir to set
- */
- public void setOutputDir(String outputDir) {
- this.outputDir = outputDir;
- }
-
- /**
- * @return the outputDir
- */
- public String getOutputDir() {
- return this.outputDir;
- }
-
- /**
- * Sets the input file
- *
- * @param inputFile
- * the input file
- */
- public void setInputFile(File inputFile) {
- this.inputFile = inputFile;
- }
-
- /**
- * Gets the input file
- *
- * @return the input file
- */
- public File getInputFile() {
- return this.inputFile;
- }
-
- /**
- * @param tempDirectory
- */
- public void setTempDir(String tempDirectory) {
- this.tempDirectory = tempDirectory;
- }
-
- /**
- * Gets the signed document
- *
- * @return the signed document
- */
- public DocumentSource getSignedDocument() {
- return this.signedDocument;
- }
-
- /**
- * Sets the signed document
- *
- * @param signedDocument
- * the signed document
- */
- public void setSignedDocument(final DocumentSource signedDocument) {
- this.signedDocument = signedDocument;
- }
-
- /**
- * Return whether the last save was successful
- * @return whether the last save was successful
- */
- public boolean getSaveSuccessful() {
- return !this.saveFailed;
- }
-
- private void enableSaveButton(boolean doEnable)
- {
- this.btn_save.setEnabled(doEnable);
- this.btn_save.setVisible(doEnable);
- }
-
- /**
- * Saves the signed document.
- *
- * If user has a default output directory set, try to save there.
- * If not (or if directory unavailable), ask user for location.
- */
- public void saveDocument() {
- File inputFolder = getInputFile().getAbsoluteFile().getParentFile();
- String fileName = getInputFile().getName();
- String proposedName = getSignedFileName(fileName);
- String outputFileName;
-
- String outputFolder = getOutputDir();
- if (!this.saveFailed && outputFolder != null && !outputFolder.trim().isEmpty()) {
- // Output folder configured, try to save there
-
- File f = new File(outputFolder);
- if (f.isDirectory()) {
- if (!outputFolder.endsWith(File.separator)) {
- outputFolder += File.separator;
- }
- outputFileName = outputFolder + proposedName;
- } else {
- outputFileName = outputFolder;
- }
- } else {
- // Ask user where to save
-
- FileDialog save = new FileDialog(this.getShell(),
- SWT.SAVE | SWT.NATIVE);
- save.setFilterExtensions(new String[] { "*.pdf", "*" }); //$NON-NLS-1$ //$NON-NLS-2$
- save.setFilterNames(new String[] {
- Messages.getString("common.PDFExtension_Description"), //$NON-NLS-1$
- Messages.getString("common.AllExtension_Description")}); //$NON-NLS-1$
- save.setFilterPath(inputFolder.getAbsolutePath());
- save.setFileName(proposedName);
-
- outputFileName = save.open();
- inputFolder = null;
- }
- log.debug("Trying to save to '" + outputFileName + "'"); //$NON-NLS-1$ //$NON-NLS-2$
-
- this.outputFile = saveResultAsFile(inputFolder, outputFileName);
- this.saveFailed = (this.outputFile == null);
-
- // If saving failed, enable save button
- enableSaveButton(this.saveFailed);
- reloadResources();
- layout(true);
- }
-
- /**
- * Save the signed document under the given filename
- * @param inputFolder the Folder the original document is located at
- * @param target the filename to save the document as
- *
- * @return saved File (or null if unsuccessful)
- * @throws FileNotFoundException
- * @throws IOException
- */
- private File saveResultAsFile(File inputFolder, String target) {
- if (target == null)
- return null;
-
- File targetFile = new File(target);
- if (!targetFile.isAbsolute())
- targetFile = new File(inputFolder, target);
-
- if (targetFile.exists()) {
- Dialog dialog = new Dialog(getShell(), Messages.getString("common.warning"), //$NON-NLS-1$
- String.format(Messages.getString("output.file_ask_overwrite"), targetFile.getName()), //$NON-NLS-1$
- BUTTONS.OK_CANCEL, ICON.QUESTION);
- if (dialog.open() == SWT.CANCEL)
- {
- return null;
- }
- }
-
- DocumentSource source = this.getSignedDocument();
- boolean retry;
-
- do {
- retry = false;
- try {
- FileOutputStream outstream = new FileOutputStream(targetFile);
- outstream.write(source.getByteArray(), 0,
- source.getByteArray().length);
- outstream.close();
- } catch (FileNotFoundException e) {
- log.error("File not found", e); //$NON-NLS-1$
- ErrorDialog dialog = new ErrorDialog(getShell(),
- String.format(Messages.getString("output.save_failed"), //$NON-NLS-1$
- targetFile.getName(), e.getLocalizedMessage()),
- BUTTONS.RETRY_CANCEL);
- if (dialog.open() == SWT.CANCEL)
- return null;
- retry = true;
- } catch (IOException e) {
- log.error("IO Error", e); //$NON-NLS-1$
- ErrorDialog dialog = new ErrorDialog(getShell(),
- String.format(Messages.getString("output.save_failed"), //$NON-NLS-1$
- targetFile.getName(), e.getLocalizedMessage()),
- BUTTONS.RETRY_CANCEL);
- if (dialog.open() == SWT.CANCEL)
- return null;
- retry = true;
- }
- } while (retry);
-
- if (!targetFile.exists())
- {
- log.error("Tried to save file " + targetFile.getName() + //$NON-NLS-1$
- ", but it doesn't exist"); //$NON-NLS-1$
- return null;
- }
- return targetFile;
- }
-
- /**
- * Get the proposed filename of a signed document for a given input filename
- * @param name input filename
- * @return proposed output filename
- */
- private static String getSignedFileName(String name) {
- name = FilenameUtils.getName(name);
- String extension = FilenameUtils.getExtension(name);
- name = FilenameUtils.removeExtension(name);
- return name + Constants.SIGNED_SUFFIX + FilenameUtils.EXTENSION_SEPARATOR + extension;
- }
-
- /**
- * SelectionListener for save button
- */
- private final class SaveSelectionListener extends SelectionAdapter {
- /**
- * Empty constructor
- */
- public SaveSelectionListener() {
- }
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- try {
- OutputComposite.this.saveDocument();
- } catch (Exception ex) {
- log.error("SaveSelectionListener: ", ex); //$NON-NLS-1$
- }
- }
- }
-
- /**
- * Selection Listener for open button
- */
- private final class OpenSelectionListener extends SelectionAdapter {
- /**
- * Empty constructor
- */
- public OpenSelectionListener() {
- }
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- try {
- if (OutputComposite.this.outputFile == null)
- return;
-
- if (!OutputComposite.this.outputFile.exists())
- return;
-
- // Normalize filename
- File f = new File(FilenameUtils.normalize(
- OutputComposite.this.outputFile.getAbsolutePath()));
- log.debug("Trying to open " + f.toString()); //$NON-NLS-1$
- // work around for the case of Linux and Java version 8
- if (isSpecialCase()) {
- reReloadResources(f.toString());
- return;
- }
- else if (Desktop.isDesktopSupported()) {
- Desktop.getDesktop().open(f);
- } else {
- log.info("AWT Desktop is not supported on this platform"); //$NON-NLS-1$
- Program.launch(f.getAbsolutePath());
- }
- } catch (IOException ex) {
- log.error("OpenSelectionListener: ", ex); //$NON-NLS-1$
- ErrorDialog error = new ErrorDialog(getShell(),
- String.format(Messages.getString("error.FailedToOpenDocument"), //$NON-NLS-1$
- ex.getLocalizedMessage()), BUTTONS.RETRY_CANCEL);
- if (error.open() == SWT.RETRY)
- widgetSelected(e);
- }
- }
- }
-
- @Override
- protected void checkSubclass() {
- // Disable the check that prevents subclassing of SWT components
- }
-
- /*
- * (non-Javadoc)
- *
- * @see at.asit.pdfover.gui.composites.StateComposite#doLayout()
- */
- @Override
- public void doLayout() {
- // Nothing to do
- this.layout(true);
- }
-
- /**
- * @return true when linux and java version <= 8
- *
- */
- public boolean isSpecialCase() {
-
- boolean isSCase = false;
- try {
- String os = System.getProperty("os.name").toLowerCase(); //$NON-NLS-1$
- if (os.contains("linux")) { //$NON-NLS-1$
- String version = System.getProperty("java.version"); //$NON-NLS-1$
- if (version.contains(".")) { //$NON-NLS-1$
- String[] parts = version.split("\\."); //$NON-NLS-1$
- isSCase = Integer.valueOf(parts[0]) <= 8 ? true : false;
- } else {
- isSCase = Integer.valueOf(version) <= 8 ? true : false;
- }
- }
- } catch (Exception e) {
- log.debug("Error: " + e.getMessage()); //$NON-NLS-1$
- isSCase = false;
- }
- return isSCase;
- }
-
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.gui.composites.StateComposite#reloadResources()
- */
- @Override
- public void reloadResources() {
- this.lbl_success_message.setText(Messages
- .getString("output.success_message")); //$NON-NLS-1$
- if (this.outputFile == null) {
- this.lnk_saved_file.setText(Messages
- .getString("output.link_save_message")); //$NON-NLS-1$
- } else {
- this.lnk_saved_file.setText(Messages
- .getString("output.link_open_message")); //$NON-NLS-1$
- }
- this.btn_save.setText(Messages.getString("common.Save")); //$NON-NLS-1$
- }
-
- /**
- * @param str
- */
- public void reReloadResources(String str) {
- this.lbl_success_message.setText(Messages.getString("output.success_message")); //$NON-NLS-1$
- if (this.outputFile == null) {
- this.lnk_saved_file.setText(Messages
- .getString("output.link_save_message")); //$NON-NLS-1$
- } else {
- String str2 = "File location: " + str; //$NON-NLS-1$
- this.lbl_success_message.setText(str2);
- this.lnk_saved_file.setText(""); //$NON-NLS-1$
- }
- this.btn_save.setText(Messages.getString("common.Save")); //$NON-NLS-1$
- }
-
-
-
-}
+/*
+ * Copyright 2012 by A-SIT, Secure Information Technology Center Austria
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://joinup.ec.europa.eu/software/page/eupl
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ */
+package at.asit.pdfover.gui.composites;
+
+// Imports
+import java.awt.Desktop;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+import org.apache.commons.io.FilenameUtils;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.program.Program;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Link;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import at.asit.pdfover.gui.Constants;
+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.utils.Messages;
+import at.asit.pdfover.gui.workflow.states.State;
+import at.asit.pdfover.signator.DocumentSource;
+
+/**
+ * GUI component for Output State
+ */
+public class OutputComposite extends StateComposite {
+
+ /**
+ * SLF4J Logger instance
+ **/
+ static final Logger log = LoggerFactory.getLogger(OutputComposite.class);
+
+ private Link lnk_saved_file;
+
+ private Button btn_save;
+
+ private Label lbl_success_message;
+
+ private DocumentSource signedDocument;
+
+ private File inputFile;
+
+ String outputDir = null;
+
+ String tempDirectory = null;
+
+ File outputFile = null;
+
+ private boolean saveFailed = false;
+
+ private String postFix = null;
+
+ /**
+ * Create the composite.
+ *
+ * @param parent
+ * The parent composite
+ * @param style
+ * The swt style
+ * @param state
+ * The owning state
+ */
+ public OutputComposite(Composite parent, int style, State state) {
+ super(parent, style, state);
+
+ this.setLayout(new FormLayout());
+
+ this.lbl_success_message = new Label(this, SWT.NATIVE | SWT.RESIZE);
+ FormData fd_lbl_success_message = new FormData();
+ fd_lbl_success_message.top = new FormAttachment(40, 0);
+ fd_lbl_success_message.left = new FormAttachment(0);
+ fd_lbl_success_message.right = new FormAttachment(100);
+ this.lbl_success_message.setLayoutData(fd_lbl_success_message);
+ this.lbl_success_message.setAlignment(SWT.CENTER);
+
+ FontData[] fD1 = this.lbl_success_message.getFont().getFontData();
+ fD1[0].setHeight(Constants.TEXT_SIZE_BIG);
+ this.lbl_success_message.setFont(new Font(Display.getCurrent(), fD1[0]));
+
+ this.lnk_saved_file = new Link(this, SWT.NATIVE | SWT.RESIZE);
+ FormData fd_lnk_saved_file = new FormData();
+ fd_lnk_saved_file.top = new FormAttachment(this.lbl_success_message, 10);
+ fd_lnk_saved_file.left = new FormAttachment(this.lbl_success_message, 0,
+ SWT.CENTER);
+ // fd_lnk_saved_file.right = new FormAttachment(100);
+ this.lnk_saved_file.setLayoutData(fd_lnk_saved_file);
+
+ this.lnk_saved_file.addSelectionListener(new OpenSelectionListener());
+
+ FontData[] fD2 = this.lnk_saved_file.getFont().getFontData();
+ fD2[0].setHeight(Constants.TEXT_SIZE_NORMAL);
+ this.lnk_saved_file.setFont(new Font(Display.getCurrent(), fD2[0]));
+
+ this.btn_save = new Button(this, SWT.NATIVE | SWT.RESIZE);
+
+ FontData[] fD_btn_save = this.btn_save.getFont().getFontData();
+ fD_btn_save[0].setHeight(Constants.TEXT_SIZE_BUTTON);
+ this.btn_save.setFont(new Font(Display.getCurrent(), fD_btn_save[0]));
+
+ FormData fd_btn_save = new FormData();
+ fd_btn_save.top = new FormAttachment(this.lnk_saved_file, 10);
+ fd_btn_save.left = new FormAttachment(this.lnk_saved_file, 0,
+ SWT.CENTER);
+ this.btn_save.setLayoutData(fd_btn_save);
+
+ this.btn_save.addSelectionListener(new SaveSelectionListener());
+ enableSaveButton(false);
+
+ reloadResources();
+ }
+
+ /**
+ * @param outputDir
+ * the outputDir to set
+ */
+ public void setOutputDir(String outputDir) {
+ this.outputDir = outputDir;
+ }
+
+ /**
+ * @return the outputDir
+ */
+ public String getOutputDir() {
+ return this.outputDir;
+ }
+
+ /**
+ * Sets the input file
+ *
+ * @param inputFile
+ * the input file
+ */
+ public void setInputFile(File inputFile) {
+ this.inputFile = inputFile;
+ }
+
+ /**
+ * Gets the input file
+ *
+ * @return the input file
+ */
+ public File getInputFile() {
+ return this.inputFile;
+ }
+
+ /**
+ * @param tempDirectory
+ */
+ public void setTempDir(String tempDirectory) {
+ this.tempDirectory = tempDirectory;
+ }
+
+ /**
+ * Gets the signed document
+ *
+ * @return the signed document
+ */
+ public DocumentSource getSignedDocument() {
+ return this.signedDocument;
+ }
+
+ /**
+ * Sets the signed document
+ *
+ * @param signedDocument
+ * the signed document
+ */
+ public void setSignedDocument(final DocumentSource signedDocument) {
+ this.signedDocument = signedDocument;
+ }
+
+ /**
+ * Return whether the last save was successful
+ * @return whether the last save was successful
+ */
+ public boolean getSaveSuccessful() {
+ return !this.saveFailed;
+ }
+
+ private void enableSaveButton(boolean doEnable)
+ {
+ this.btn_save.setEnabled(doEnable);
+ this.btn_save.setVisible(doEnable);
+ }
+
+ public void setSaveFilePostFix(String postFix){
+ this.postFix = postFix;
+ }
+
+ public String getSaveFilePostFix(){
+ if (this.postFix == null){
+ this.postFix = Constants.DEFAULT_POSTFIX;
+ }
+ return this.postFix;
+ }
+
+ /**
+ * Saves the signed document.
+ *
+ * If user has a default output directory set, try to save there.
+ * If not (or if directory unavailable), ask user for location.
+ */
+ public void saveDocument() {
+ File inputFolder = getInputFile().getAbsoluteFile().getParentFile();
+ String fileName = getInputFile().getName();
+ String proposedName = getSignedFileName(fileName);
+ String outputFileName;
+
+ String outputFolder = getOutputDir();
+ if (!this.saveFailed && outputFolder != null && !outputFolder.trim().isEmpty()) {
+ // Output folder configured, try to save there
+
+ File f = new File(outputFolder);
+ if (f.isDirectory()) {
+ if (!outputFolder.endsWith(File.separator)) {
+ outputFolder += File.separator;
+ }
+ outputFileName = outputFolder + proposedName;
+ } else {
+ outputFileName = outputFolder;
+ }
+ } else {
+ // Ask user where to save
+
+ FileDialog save = new FileDialog(this.getShell(),
+ SWT.SAVE | SWT.NATIVE);
+ save.setFilterExtensions(new String[] { "*.pdf", "*" }); //$NON-NLS-1$ //$NON-NLS-2$
+ save.setFilterNames(new String[] {
+ Messages.getString("common.PDFExtension_Description"), //$NON-NLS-1$
+ Messages.getString("common.AllExtension_Description")}); //$NON-NLS-1$
+ save.setFilterPath(inputFolder.getAbsolutePath());
+ save.setFileName(proposedName);
+
+ outputFileName = save.open();
+ inputFolder = null;
+ }
+ log.debug("Trying to save to '" + outputFileName + "'"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ this.outputFile = saveResultAsFile(inputFolder, outputFileName);
+ this.saveFailed = (this.outputFile == null);
+
+ // If saving failed, enable save button
+ enableSaveButton(this.saveFailed);
+ reloadResources();
+ layout(true);
+ }
+
+ /**
+ * Save the signed document under the given filename
+ * @param inputFolder the Folder the original document is located at
+ * @param target the filename to save the document as
+ *
+ * @return saved File (or null if unsuccessful)
+ * @throws FileNotFoundException
+ * @throws IOException
+ */
+ private File saveResultAsFile(File inputFolder, String target) {
+ if (target == null)
+ return null;
+
+ File targetFile = new File(target);
+ if (!targetFile.isAbsolute())
+ targetFile = new File(inputFolder, target);
+
+ if (targetFile.exists()) {
+ Dialog dialog = new Dialog(getShell(), Messages.getString("common.warning"), //$NON-NLS-1$
+ String.format(Messages.getString("output.file_ask_overwrite"), targetFile.getName()), //$NON-NLS-1$
+ BUTTONS.OK_CANCEL, ICON.QUESTION);
+ if (dialog.open() == SWT.CANCEL)
+ {
+ return null;
+ }
+ }
+
+ DocumentSource source = this.getSignedDocument();
+ boolean retry;
+
+ do {
+ retry = false;
+ try {
+ FileOutputStream outstream = new FileOutputStream(targetFile);
+ outstream.write(source.getByteArray(), 0,
+ source.getByteArray().length);
+ outstream.close();
+ } catch (FileNotFoundException e) {
+ log.error("File not found", e); //$NON-NLS-1$
+ ErrorDialog dialog = new ErrorDialog(getShell(),
+ String.format(Messages.getString("output.save_failed"), //$NON-NLS-1$
+ targetFile.getName(), e.getLocalizedMessage()),
+ BUTTONS.RETRY_CANCEL);
+ if (dialog.open() == SWT.CANCEL)
+ return null;
+ retry = true;
+ } catch (IOException e) {
+ log.error("IO Error", e); //$NON-NLS-1$
+ ErrorDialog dialog = new ErrorDialog(getShell(),
+ String.format(Messages.getString("output.save_failed"), //$NON-NLS-1$
+ targetFile.getName(), e.getLocalizedMessage()),
+ BUTTONS.RETRY_CANCEL);
+ if (dialog.open() == SWT.CANCEL)
+ return null;
+ retry = true;
+ }
+ } while (retry);
+
+ if (!targetFile.exists())
+ {
+ log.error("Tried to save file " + targetFile.getName() + //$NON-NLS-1$
+ ", but it doesn't exist"); //$NON-NLS-1$
+ return null;
+ }
+ return targetFile;
+ }
+
+ /**
+ * Get the proposed filename of a signed document for a given input filename
+ * @param name input filename
+ * @return proposed output filename
+ */
+ private String getSignedFileName(String name) {
+ name = FilenameUtils.getName(name);
+ String extension = FilenameUtils.getExtension(name);
+ name = FilenameUtils.removeExtension(name);
+ return name + getSaveFilePostFix() + FilenameUtils.EXTENSION_SEPARATOR + extension;
+ }
+
+ /**
+ * SelectionListener for save button
+ */
+ private final class SaveSelectionListener extends SelectionAdapter {
+ /**
+ * Empty constructor
+ */
+ public SaveSelectionListener() {
+ }
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ try {
+ OutputComposite.this.saveDocument();
+ } catch (Exception ex) {
+ log.error("SaveSelectionListener: ", ex); //$NON-NLS-1$
+ }
+ }
+ }
+
+ /**
+ * Selection Listener for open button
+ */
+ private final class OpenSelectionListener extends SelectionAdapter {
+ /**
+ * Empty constructor
+ */
+ public OpenSelectionListener() {
+ }
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ try {
+ if (OutputComposite.this.outputFile == null)
+ return;
+
+ if (!OutputComposite.this.outputFile.exists())
+ return;
+
+ // Normalize filename
+ File f = new File(FilenameUtils.normalize(
+ OutputComposite.this.outputFile.getAbsolutePath()));
+ log.debug("Trying to open " + f.toString()); //$NON-NLS-1$
+ // work around for the case of Linux and Java version 8
+ if (isSpecialCase()) {
+ reReloadResources(f.toString());
+ return;
+ }
+ else if (Desktop.isDesktopSupported()) {
+ Desktop.getDesktop().open(f);
+ } else {
+ log.info("AWT Desktop is not supported on this platform"); //$NON-NLS-1$
+ Program.launch(f.getAbsolutePath());
+ }
+ } catch (IOException ex) {
+ log.error("OpenSelectionListener: ", ex); //$NON-NLS-1$
+ ErrorDialog error = new ErrorDialog(getShell(),
+ String.format(Messages.getString("error.FailedToOpenDocument"), //$NON-NLS-1$
+ ex.getLocalizedMessage()), BUTTONS.RETRY_CANCEL);
+ if (error.open() == SWT.RETRY)
+ widgetSelected(e);
+ }
+ }
+ }
+
+ @Override
+ protected void checkSubclass() {
+ // Disable the check that prevents subclassing of SWT components
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see at.asit.pdfover.gui.composites.StateComposite#doLayout()
+ */
+ @Override
+ public void doLayout() {
+ // Nothing to do
+ this.layout(true);
+ }
+
+ /**
+ * @return true when linux and java version <= 8
+ *
+ */
+ public boolean isSpecialCase() {
+
+ boolean isSCase = false;
+ try {
+ String os = System.getProperty("os.name").toLowerCase(); //$NON-NLS-1$
+ if (os.contains("linux")) { //$NON-NLS-1$
+ String version = System.getProperty("java.version"); //$NON-NLS-1$
+ if (version.contains(".")) { //$NON-NLS-1$
+ String[] parts = version.split("\\."); //$NON-NLS-1$
+ isSCase = Integer.valueOf(parts[0]) <= 8 ? true : false;
+ } else {
+ isSCase = Integer.valueOf(version) <= 8 ? true : false;
+ }
+ }
+ } catch (Exception e) {
+ log.debug("Error: " + e.getMessage()); //$NON-NLS-1$
+ isSCase = false;
+ }
+ return isSCase;
+ }
+
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.composites.StateComposite#reloadResources()
+ */
+ @Override
+ public void reloadResources() {
+ this.lbl_success_message.setText(Messages
+ .getString("output.success_message")); //$NON-NLS-1$
+ if (this.outputFile == null) {
+ this.lnk_saved_file.setText(Messages
+ .getString("output.link_save_message")); //$NON-NLS-1$
+ } else {
+ this.lnk_saved_file.setText(Messages
+ .getString("output.link_open_message")); //$NON-NLS-1$
+ }
+ this.btn_save.setText(Messages.getString("common.Save")); //$NON-NLS-1$
+ }
+
+ /**
+ * @param str
+ */
+ public void reReloadResources(String str) {
+ this.lbl_success_message.setText(Messages.getString("output.success_message")); //$NON-NLS-1$
+ if (this.outputFile == null) {
+ this.lnk_saved_file.setText(Messages
+ .getString("output.link_save_message")); //$NON-NLS-1$
+ } else {
+ String str2 = "File location: " + str; //$NON-NLS-1$
+ this.lbl_success_message.setText(str2);
+ this.lnk_saved_file.setText(""); //$NON-NLS-1$
+ }
+ this.btn_save.setText(Messages.getString("common.Save")); //$NON-NLS-1$
+ }
+
+
+
+}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PositioningComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PositioningComposite.java
index 7f42db8f..22d18f2d 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PositioningComposite.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PositioningComposite.java
@@ -310,6 +310,7 @@ public class PositioningComposite extends StateComposite {
if (e.getWheelRotation() < 0) {
if (PositioningComposite.this.currentPage > 1)
+ System.out.println("################## page " + newPage);
newPage--;
} else if (e.getWheelRotation() > 0) {
if (PositioningComposite.this.currentPage < PositioningComposite.this.numPages)
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SimpleConfigurationComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SimpleConfigurationComposite.java
index e54b4a59..75482b60 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SimpleConfigurationComposite.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SimpleConfigurationComposite.java
@@ -22,6 +22,7 @@ import java.util.Locale;
import javax.imageio.ImageIO;
+import at.asit.pdfover.signator.SignaturePosition;
import org.eclipse.swt.SWT;
import org.eclipse.swt.dnd.DND;
import org.eclipse.swt.dnd.DropTarget;
@@ -32,11 +33,8 @@ import org.eclipse.swt.dnd.Transfer;
import org.eclipse.swt.events.FocusAdapter;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.TraverseEvent;
-import org.eclipse.swt.events.TraverseListener;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.Image;
@@ -62,6 +60,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import at.asit.pdfover.gui.Constants;
+import at.asit.pdfover.commons.Profile;
import at.asit.pdfover.gui.controls.Dialog.BUTTONS;
import at.asit.pdfover.gui.controls.ErrorDialog;
import at.asit.pdfover.gui.controls.ErrorMarker;
@@ -90,29 +89,35 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
private Group grpHandySignatur;
private Label lblMobileNumber;
- Text txtMobileNumber;
- FormData fd_txtMobileNumber;
- ErrorMarker txtMobileNumberErrorMarker;
- FormData fd_txtMobileNumberErrorMarker;
+ protected Text txtMobileNumber;
+ protected FormData fd_txtMobileNumber;
+ protected ErrorMarker txtMobileNumberErrorMarker;
+ protected FormData fd_txtMobileNumberErrorMarker;
private Group grpLogo;
private Canvas cLogo;
private Label lblDropLogo;
- Button btnClearImage;
+ protected Button btnClearImage;
private Button btnBrowseLogo;
- Canvas cSigPreview;
+ protected Canvas cSigPreview;
private Group grpSignatureNote;
private Label lblSignatureNote;
- Text txtSignatureNote;
+ protected Text txtSignatureNote;
private Button btnSignatureNoteDefault;
- private Group grpSignatureLang;
- Combo cmbSignatureLang;
+ protected final Group grpSignatureLang;
+ protected final Combo cmbSignatureLang;
- String logoFile;
- Image sigPreview = null;
- Image logo = null;
+ protected String logoFile = null;
+ protected Image sigPreview = null;
+ protected Image logo = null;
+
+ protected final Group grpSignatureProfile;
+ protected final Combo cmbSignatureProfiles;
+
+
+
/**
* @param parent
@@ -181,13 +186,9 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
this.txtMobileNumber.setFont(new Font(Display.getCurrent(),
fD_txtMobileNumber[0]));
- this.txtMobileNumber.addTraverseListener(new TraverseListener() {
-
- @Override
- public void keyTraversed(TraverseEvent e) {
- if (e.detail == SWT.TRAVERSE_RETURN) {
- processNumberChanged();
- }
+ this.txtMobileNumber.addTraverseListener(e -> {
+ if (e.detail == SWT.TRAVERSE_RETURN) {
+ processNumberChanged();
}
});
@@ -199,11 +200,62 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
}
});
+ this.grpSignatureProfile = new Group(this, SWT.NONE);
+ FormData fd_grpSingnatureProfile = new FormData();
+ fd_grpSingnatureProfile.right = new FormAttachment(100, -5);
+ fd_grpSingnatureProfile.left = new FormAttachment(0, 5);
+ fd_grpSingnatureProfile.top = new FormAttachment(this.grpHandySignatur, 5);
+ this.grpSignatureProfile.setLayoutData(fd_grpSingnatureProfile);
+ this.grpSignatureProfile.setText("Signature Profile"); //$NON-NLS-1$
+ this.grpSignatureProfile.setLayout(new FormLayout());
+
+ FontData[] fD_grpSignatureProfile = this.grpSignatureProfile.getFont()
+ .getFontData();
+ fD_grpSignatureProfile[0].setHeight(Constants.TEXT_SIZE_NORMAL);
+ this.grpSignatureProfile.setFont(new Font(Display.getCurrent(),
+ fD_grpSignatureProfile[0]));
+
+
+ this.cmbSignatureProfiles = new Combo(this.grpSignatureProfile, SWT.READ_ONLY);
+
+ FormData fd_cmbSingatureProfiles = new FormData();
+ fd_cmbSingatureProfiles.left = new FormAttachment(0, 10);
+ fd_cmbSingatureProfiles.right = new FormAttachment(100, -10);
+ fd_cmbSingatureProfiles.top = new FormAttachment(0, 10);
+ fd_cmbSingatureProfiles.bottom = new FormAttachment(100, -10);
+ this.cmbSignatureProfiles.setLayoutData(fd_cmbSingatureProfiles);
+
+ FontData[] fD_cmbSignatureProfile = this.cmbSignatureProfiles.getFont()
+ .getFontData();
+ fD_cmbSignatureProfile[0].setHeight(Constants.TEXT_SIZE_NORMAL);
+ this.cmbSignatureProfiles.setFont(new Font(Display.getCurrent(),
+ fD_cmbSignatureProfile[0]));
+
+ String[] items = new String[Profile.values().length];
+ int i = 0;
+ for (Profile profile : Profile.values()) {
+ items[i] = Messages.getString("simple_config." + profile.name());
+ i++;
+ }
+
+ this.cmbSignatureProfiles.setItems(items);
+ this.cmbSignatureProfiles.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ Profile current = SimpleConfigurationComposite.this.configurationContainer.getSignatureProfile();
+ Profile selected = Profile.getProfileByIndex(SimpleConfigurationComposite.this.cmbSignatureProfiles
+ .getSelectionIndex());
+ if (!current.equals(selected)) {
+ preformProfileSelectionChanged(selected);
+ }
+ }
+ });
+
this.grpLogo = new Group(this, SWT.NONE);
FormData fd_grpBildmarke = new FormData();
fd_grpBildmarke.left = new FormAttachment(0, 5);
fd_grpBildmarke.right = new FormAttachment(100, -5);
- fd_grpBildmarke.top = new FormAttachment(this.grpHandySignatur, 5);
+ fd_grpBildmarke.top = new FormAttachment(this.grpSignatureProfile, 5);
this.grpLogo.setLayoutData(fd_grpBildmarke);
this.grpLogo.setLayout(new FormLayout());
@@ -230,16 +282,13 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
fd_controlComposite.top = new FormAttachment(0, 20);
fd_controlComposite.bottom = new FormAttachment(100, -20);
controlComposite.setLayoutData(fd_controlComposite);
- controlComposite.addPaintListener(new PaintListener() {
- @Override
- public void paintControl(PaintEvent e) {
- e.gc.setForeground(Constants.DROP_BORDER_COLOR);
- e.gc.setLineWidth(3);
- e.gc.setLineStyle(SWT.LINE_DASH);
- Point size = controlComposite.getSize();
- e.gc.drawRoundRectangle(0, 0, size.x - 2, size.y - 2,
- 10, 10);
- }
+ controlComposite.addPaintListener(e -> {
+ e.gc.setForeground(Constants.DROP_BORDER_COLOR);
+ e.gc.setLineWidth(3);
+ e.gc.setLineStyle(SWT.LINE_DASH);
+ Point size = controlComposite.getSize();
+ e.gc.drawRoundRectangle(0, 0, size.x - 2, size.y - 2,
+ 10, 10);
});
this.cSigPreview = new Canvas(containerComposite, SWT.RESIZE);
@@ -257,19 +306,13 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
fd_cLogo.height = 40;
fd_cLogo.width = 40;
this.cLogo.setLayoutData(fd_cLogo);
- this.cLogo.addPaintListener(new PaintListener() {
- @Override
- public void paintControl(PaintEvent e) {
- imagePaintControl(e, SimpleConfigurationComposite.this.logo);
- }
- });
+ this.cLogo.addPaintListener(e -> imagePaintControl(e, SimpleConfigurationComposite.this.logo));
this.btnClearImage = new Button(controlComposite, SWT.NATIVE);
FormData fd_lbl_drop = new FormData();
fd_lbl_drop.left = new FormAttachment(0, 20);
fd_lbl_drop.right = new FormAttachment(100, -20);
- // fd_lbl_drop.top = new FormAttachment(50, -20);
fd_lbl_drop.bottom = new FormAttachment(this.btnBrowseLogo, -20);
this.lblDropLogo.setLayoutData(fd_lbl_drop);
@@ -281,12 +324,7 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
fd_cSigPreview.bottom = new FormAttachment(100, -20);
this.cSigPreview.setLayoutData(fd_cSigPreview);
- this.cSigPreview.addPaintListener(new PaintListener() {
- @Override
- public void paintControl(PaintEvent e) {
- imagePaintControl(e, SimpleConfigurationComposite.this.sigPreview);
- }
- });
+ this.cSigPreview.addPaintListener(e -> imagePaintControl(e, SimpleConfigurationComposite.this.sigPreview));
FontData[] fD_cSigPreview = this.cSigPreview.getFont().getFontData();
fD_cSigPreview[0].setHeight(Constants.TEXT_SIZE_NORMAL);
@@ -307,7 +345,7 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
// Only taking first file ...
File file = new File(files[0]);
if (!file.exists()) {
- log.error("File: " + files[0] + " does not exist!"); //$NON-NLS-1$//$NON-NLS-2$
+ log.error("File: {} does not exist!", files[0]); //$NON-NLS-1$//$NON-NLS-2$
return;
}
processEmblemChanged(file.getAbsolutePath());
@@ -418,8 +456,8 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
fD_cmbSignatureLang[0]));
String[] localeSignStrings = new String[Constants.SUPPORTED_LOCALES.length];
- for (int i = 0; i < Constants.SUPPORTED_LOCALES.length; ++i) {
- localeSignStrings[i] = Constants.SUPPORTED_LOCALES[i].getDisplayLanguage();
+ for (int idx = 0; idx < Constants.SUPPORTED_LOCALES.length; ++idx) {
+ localeSignStrings[idx] = Constants.SUPPORTED_LOCALES[idx].getDisplayLanguage();
}
this.cmbSignatureLang.setItems(localeSignStrings);
this.cmbSignatureLang.addSelectionListener(new SelectionAdapter() {
@@ -489,12 +527,9 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
}
});
- this.txtSignatureNote.addTraverseListener(new TraverseListener() {
- @Override
- public void keyTraversed(TraverseEvent e) {
- if (e.detail == SWT.TRAVERSE_RETURN) {
- processSignatureNoteChanged();
- }
+ this.txtSignatureNote.addTraverseListener(e -> {
+ if (e.detail == SWT.TRAVERSE_RETURN) {
+ processSignatureNoteChanged();
}
});
@@ -577,10 +612,6 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
if (fileName != null) {
file = new File(fileName);
if (file.exists()) {
- /*
- * SimpleConfigurationComposite.this.txtEmblemFile
- * .setText(fileName);
- */
processEmblemChanged(fileName);
}
}
@@ -593,11 +624,9 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
private void setEmblemFileInternal(final String filename, boolean force)
throws Exception {
- if (!force) {
- if (this.configurationContainer.getEmblem() != null) {
- if (this.configurationContainer.getEmblem().equals(filename)) {
- return; // Ignore ...
- }
+ if (!force && this.configurationContainer.getEmblem() != null) {
+ if (this.configurationContainer.getEmblem().equals(filename)) {
+ return; // Ignore ...
}
}
@@ -613,8 +642,7 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
try {
if (this.signer != null) {
- SignatureParameter param = this.signer.getPDFSigner()
- .newParameter();
+ SignatureParameter param = this.signer.getPDFSigner().newParameter();
if(this.configurationContainer.getSignatureNote() != null && !this.configurationContainer.getSignatureNote().isEmpty()) {
param.setProperty("SIG_NOTE", this.configurationContainer.getSignatureNote()); //$NON-NLS-1$
}
@@ -684,17 +712,17 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
int getLocaleElementIndex(Locale locale) {
for (int i = 0; i < Constants.SUPPORTED_LOCALES.length; i++) {
if (Constants.SUPPORTED_LOCALES[i].equals(locale)) {
- log.debug("Locale: " + locale + " IDX: " + i); //$NON-NLS-1$ //$NON-NLS-2$
+ log.debug("Locale: {} IDX: {}",locale, i); //$NON-NLS-1$ //$NON-NLS-2$
return i;
}
}
- log.warn("NO Locale match for " + locale); //$NON-NLS-1$
+ log.warn("NO Locale match for {}", locale); //$NON-NLS-1$
return 0;
}
void performSignatureLangSelectionChanged(Locale selected, Locale previous) {
- log.debug("Selected Sign Locale: " + selected); //$NON-NLS-1$
+ log.debug("Selected Sign Locale: {}", selected); //$NON-NLS-1$
this.configurationContainer.setSignatureLocale(selected);
this.cmbSignatureLang.select(this.getLocaleElementIndex(selected));
if (previous != null) {
@@ -705,6 +733,27 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
}
}
}
+
+ void preformProfileSelectionChanged(Profile selected) {
+ log.debug("Signature Profile {} was selected", selected.getName()); //$NON-NLS-1$
+ this.configurationContainer.setSignatureProfile(selected);
+ this.cmbSignatureProfiles.select(selected.ordinal());
+
+ if (selected.equals(Profile.AMTSSIGNATURBLOCK) || selected.equals(Profile.INVISIBLE)){
+ this.configurationContainer.setDefaultSignaturePosition(new SignaturePosition());
+ }
+
+ }
+
+ void setSignatureProfileSetting(){
+ try {
+ SignatureParameter param = this.signer.getPDFSigner().newParameter();
+ param.setSignatureProfile(this.configurationContainer.getSignatureProfile().getName());
+
+ } catch (Exception e){
+ log.debug("Cannot save signature profile {}", e.getMessage());
+ }
+ }
/*
* (non-Javadoc)
@@ -715,6 +764,7 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
@Override
protected void signerChanged() {
this.setVisibleImage();
+ this.setSignatureProfileSetting();
}
/**
@@ -788,7 +838,6 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
String emblemFile = this.configurationContainer.getEmblem();
if (emblemFile != null && !emblemFile.trim().isEmpty()) {
- // this.txtEmblemFile.setText(emblemFile);
this.logoFile = emblemFile;
try {
setEmblemFileInternal(emblemFile, true);
@@ -811,6 +860,9 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
this.setVisibleImage();
this.performSignatureLangSelectionChanged(this.configurationContainer.getSignatureLocale(), null);
+
+ this.preformProfileSelectionChanged(this.configurationContainer.getSignatureProfile());
+
}
/* (non-Javadoc)
@@ -826,6 +878,8 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
store.setSignatureLocale(this.configurationContainer.getSignatureLocale());
store.setSignatureNote(this.configurationContainer.getSignatureNote());
+
+ store.setSignatureProfile(this.configurationContainer.getSignatureProfile().getName());
}
/*
@@ -843,8 +897,10 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
// Fall through
case 1:
this.processSignatureNoteChanged();
+ break;
+ default:
+ //Fall through
}
- // this.plainEmblemSetter(this.emblemFile);
}
/*
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/CertificateDownloadSource.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/CertificateDownloadSource.java
index ad4fa70e..6ce5b176 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/CertificateDownloadSource.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/CertificateDownloadSource.java
@@ -85,7 +85,7 @@ public class CertificateDownloadSource {
- if (!cp.getProxyHost().equals("")) {
+ if (!cp.getProxyHost().equals("")) { //$NON-NLS-1$
log.info("Found PDF-Over Host settings: "+cp.getProxyHost().toString()); //$NON-NLS-1$
try{
@@ -103,7 +103,7 @@ public class CertificateDownloadSource {
{log.info("Illegal Argument for Proxy and/or Host)");} //$NON-NLS-1$
} else {
- log.info("Opening default connection");
+ log.info("Opening default connection"); //$NON-NLS-1$
connection = url.openConnection();
}
@@ -131,7 +131,7 @@ public class CertificateDownloadSource {
Document doc = dBuilder.newDocument();
// root element
- Node rootElement = doc.createElement("certificates");
+ Node rootElement = doc.createElement("certificates"); //$NON-NLS-1$
doc.appendChild(rootElement);
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
@@ -169,7 +169,7 @@ public class CertificateDownloadSource {
Node certificates_added = doc_added.getFirstChild();
NodeList certificates_added_list = certificates_added.getChildNodes();
- log.info("===== Starting to download accepted certificates =====");
+ log.info("===== Starting to download accepted certificates ====="); //$NON-NLS-1$
// identify the certificate that has to be downloaded
for (int i = 0; i < certificates_added_list.getLength(); i++) {
@@ -187,7 +187,7 @@ public class CertificateDownloadSource {
}
URLConnection connection;
- if (!certificateNode.getTextContent().equals("")) {
+ if (!certificateNode.getTextContent().equals("")) { //$NON-NLS-1$
String certResource = Constants.CERTIFICATE_DOWNLOAD_XML_URL
+ certificateNode.getTextContent();
URL url = new URL(certResource);
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/Messages.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/Messages.java
index 6271656c..c48337e6 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/Messages.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/Messages.java
@@ -38,10 +38,7 @@ public class Messages {
private static final String BUNDLE_NAME = "at.asit.pdfover.gui.messages"; //$NON-NLS-1$
- private static HashMap<Locale, ResourceBundle> bundles = new HashMap<Locale, ResourceBundle>();
-
- //private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
- // .getBundle(BUNDLE_NAME);
+ private static HashMap<Locale, ResourceBundle> bundles = new HashMap<>();
private static Locale currentLocale = getDefaultLocale();
@@ -71,17 +68,17 @@ public class Messages {
private static ResourceBundle getBundle(Locale locale) {
if(!bundles.containsKey(locale)) {
- log.debug("Loading resource bundle for " + locale); //$NON-NLS-1$
+ log.debug("Loading resource bundle for {}", locale); //$NON-NLS-1$
ResourceBundle tmp = null;
try {
tmp = ResourceBundle.getBundle(BUNDLE_NAME, locale);
- log.debug("Received bundle for " + tmp.getLocale()); //$NON-NLS-1$
+ log.debug("Received bundle for {}", tmp.getLocale()); //$NON-NLS-1$
} catch(Exception e) {
- log.error("NO RESOURCE BUNDLE FOR " + locale.toString(), e); //$NON-NLS-1$
+ log.error("NO RESOURCE BUNDLE FOR {} {}", locale, e); //$NON-NLS-1$
tmp = ResourceBundle.getBundle(BUNDLE_NAME);
}
if(tmp == null) {
- log.error("NO RESOURCE BUNDLE FOR " + locale.toString()); //$NON-NLS-1$
+ log.error("NO RESOURCE BUNDLE FOR {}", locale); //$NON-NLS-1$
tmp = ResourceBundle.getBundle(BUNDLE_NAME);
}
bundles.put(locale, tmp);
@@ -98,7 +95,6 @@ public class Messages {
public static String getString(String key) {
try {
return getBundle(currentLocale).getString(key);
- //return RESOURCE_BUNDLE.getString(key);
} catch (MissingResourceException e) {
return '!' + key + '!';
}
@@ -113,7 +109,6 @@ public class Messages {
public static String getString(String key, Locale locale) {
try {
return getBundle(locale).getString(key);
- //return RESOURCE_BUNDLE.getString(key);
} catch (MissingResourceException e) {
return '!' + key + '!';
}
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 abed492a..befb244b 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
@@ -197,6 +197,13 @@ public interface ConfigManipulator {
* @return
*/
public boolean getEnablePlaceholderUsage();
+
+ /**
+ * @param profile
+ */
+ public void setSignatureProfile(String profile);
+
+ public void setSaveFilePostFix(String postFix);
}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigOverlayManipulator.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigOverlayManipulator.java
index 44c4a9c9..9b54f4ee 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigOverlayManipulator.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigOverlayManipulator.java
@@ -131,4 +131,10 @@ public interface ConfigOverlayManipulator {
* @param configurationFile
*/
public void setConfigurationFile(String configurationFile);
+
+ /**
+ *
+ * @param profile
+ */
+ public void setSignatureProfile(String profile);
}
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 4c674d17..b6935206 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
@@ -265,4 +265,19 @@ public interface ConfigProvider {
* @return
*/
public boolean getEnablePlaceholderUsage();
+
+ /**
+ * @param profile
+ */
+ public void setSignatureProfile(String profile);
+
+
+ /**
+ * @return
+ */
+ public String getSignatureProfile();
+
+ public String getSaveFilePostFix();
}
+
+
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 bd149cf7..c3a15cb3 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
@@ -25,6 +25,7 @@ import java.util.Properties;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import at.asit.pdfover.commons.Profile;
import org.eclipse.swt.graphics.Point;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -112,11 +113,13 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator,
// Set Output Folder
setDefaultOutputFolder(config
.getProperty(Constants.CFG_OUTPUT_FOLDER));
-
- // Set Default Certificate Download URL
- // .getProperty(Constants.CFG_DOWNLOAD_URL));
-
-
+
+ String postFix = config.getProperty(Constants.CFG_POSTFIX);
+ if (postFix == null){
+ setSaveFilePostFix(Constants.DEFAULT_POSTFIX);
+ } else {
+ setSaveFilePostFix(postFix);
+ }
String localeString = config.getProperty(Constants.CFG_LOCALE);
@@ -146,6 +149,11 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator,
setEnablePlaceholderUsage(enablePlaceholder.equalsIgnoreCase(Constants.TRUE));
}
+ String signatureProfile = config.getProperty(Constants.SIGNATURE_PROFILE);
+ if (signatureProfile != null) {
+ this.configuration.setSignatureProfile(Profile.getProfile(signatureProfile));
+ this.configurationOverlay.setSignatureProfile(Profile.getProfile(signatureProfile));
+ }
String compat = config.getProperty(Constants.CFG_SIGNATURE_PDFA_COMPAT);
if (compat != null)
@@ -158,14 +166,6 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator,
this.configuration.setMobileBKUURL(bkuUrl);
}
- /*String downloadURL = config
- .getProperty(Constants.CFG_DOWNLOAD_URL);
-
- if (downloadURL != null && !downloadURL.isEmpty()) {
- this.configuration.setDownloadURL(downloadURL);
- }*/
-
-
String bkuType = config
.getProperty(Constants.CFG_MOBILE_BKU_TYPE);
@@ -358,6 +358,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator,
props.setProperty(Constants.CFG_SIGNATURE_NOTE, getSignatureNote());
props.setProperty(Constants.CFG_MOBILE_NUMBER, getDefaultMobileNumberPersistent());
props.setProperty(Constants.CFG_OUTPUT_FOLDER, getDefaultOutputFolderPersistent());
+ props.setProperty(Constants.CFG_POSTFIX, getSaveFilePostFix());
props.setProperty(Constants.CFG_SIGNATURE_PLACEHOLDER_TRANSPARENCY,
Integer.toString(getPlaceholderTransparency()));
@@ -434,6 +435,8 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator,
if (!getUpdateCheck())
props.setProperty(Constants.CFG_UPDATE_CHECK, Constants.FALSE);
+ props.setProperty(Constants.SIGNATURE_PROFILE, getSignatureProfile());
+
FileOutputStream outputstream = new FileOutputStream(configFile, false);
@@ -990,16 +993,6 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator,
}
}
-
- /*@Override
- public void setDefaultDownloadURL(String downloadURL) {
- if (downloadURL == null || downloadURL.trim().isEmpty()) {
- this.configuration.setDownloadURL(Constants.CERTIFICATE_DOWNLOAD_XML_URL+Constants.CERTIFICATE_XML_FILE);
- } else {
- this.configuration.setDownloadURL(downloadURL);
- }
- }
-
/* (non-Javadoc)
* @see at.asit.pdfover.gui.workflow.ConfigOverlayManipulator#setDefaultOutputFolderOverlay(java.lang.String)
*/
@@ -1511,6 +1504,26 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator,
if (useFields) setUseMarker(false);
}
+ @Override
+ public void setSignatureProfile(String profile) {
+ this.configurationOverlay.setSignatureProfile(Profile.getProfile(profile));
+ }
+
+ @Override
+ public void setSaveFilePostFix(String postFix) {
+ this.configurationOverlay.setSaveFilePostFix(postFix);
+ }
+
+ @Override
+ public String getSaveFilePostFix(){
+ return this.configurationOverlay.getSaveFilePostFix();
+ }
+
+ @Override
+ public String getSignatureProfile() {
+ return this.configurationOverlay.getSignatureProfile().getName();
+ }
+
@Override
public void setEnablePlaceholderUsage(boolean bool) {
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 d5976b3c..4c634fd6 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
@@ -17,6 +17,7 @@ package at.asit.pdfover.gui.workflow.config;
import java.util.Locale;
+import at.asit.pdfover.commons.Profile;
import org.eclipse.swt.graphics.Point;
import at.asit.pdfover.gui.bku.mobile.MobileBKUs;
@@ -152,10 +153,6 @@ public interface ConfigurationContainer {
* @return the default BKU
*/
public BKUs getDefaultBKU();
-
-
-
-
/**
* Sets the default BKU
@@ -412,4 +409,21 @@ public interface ConfigurationContainer {
* @return boolean
*/
public boolean getEnablePlaceholderUsage();
+
+
+ /**
+ * @param profile set the selected profile
+ */
+ public void setSignatureProfile(Profile profile);
+
+
+ /**
+ * @return selected signature profile as string
+ */
+ public Profile getSignatureProfile();
+
+
+ public void setSaveFilePostFix(String postFix);
+
+ public String getSaveFilePostFix();
}
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 8269cb0b..47094aa7 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
@@ -20,6 +20,7 @@ import java.io.File;
import java.io.FileNotFoundException;
import java.util.Locale;
+import at.asit.pdfover.commons.Profile;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.graphics.Point;
@@ -144,6 +145,11 @@ public class ConfigurationContainerImpl implements ConfigurationContainer {
/** Either QR-Code or signature fields as marker */
protected boolean useSignatureFields = false;
+
+ /** The Signature Profile */
+ protected Profile signatureProfile = null;
+
+ protected String saveFilePostFix = "_signed";
/* (non-Javadoc)
* @see at.asit.pdfover.gui.composites.ConfigurationContainer#getEmblem()
@@ -723,4 +729,29 @@ public class ConfigurationContainerImpl implements ConfigurationContainer {
return this.enabledPlaceholderUsage;
}
+
+ @Override
+ public Profile getSignatureProfile() {
+ if (this.signatureProfile == null) {
+ this.signatureProfile = Profile.SIGNATURBLOCK_SMALL;
+ }
+ return this.signatureProfile;
+ }
+
+ @Override
+ public String getSaveFilePostFix() {
+ return this.saveFilePostFix;
+ }
+
+ @Override
+ public void setSaveFilePostFix(String postfix){
+ this.saveFilePostFix = postfix;
+ }
+
+
+ @Override
+ public void setSignatureProfile(Profile profile) {
+ this.signatureProfile = profile;
+ }
+
}
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 e217b3c8..1175ca9a 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
@@ -199,4 +199,12 @@ public interface PersistentConfigProvider {
* @return
*/
public boolean getEnablePlaceholderUsage();
+
+ /***
+ *
+ * @return the signature profile
+ */
+ public String getSignatureProfile();
+
+ public String getSaveFilePostFix();
}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OutputState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OutputState.java
index 7b88f887..3b3c2098 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OutputState.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OutputState.java
@@ -59,6 +59,7 @@ public class OutputState extends State {
}
this.outputComposite.setOutputDir(config.getDefaultOutputFolder());
+ this.outputComposite.setSaveFilePostFix(config.getSaveFilePostFix());
this.outputComposite.setTempDir(tmpDir.getAbsolutePath());
this.outputComposite.setInputFile(status.getDocument());
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java
index f9827ba4..9d17a3e8 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java
@@ -166,6 +166,8 @@ public class PrepareSigningState extends State {
this.state.signatureParameter
.setSignaturePdfACompat(configuration.getSignaturePdfACompat());
+ this.state.signatureParameter.setSignatureProfile(configuration.getSignatureProfile());
+
this.state.signingState = this.state.signer
.prepare(this.state.signatureParameter);
@@ -199,7 +201,7 @@ public class PrepareSigningState extends State {
at.asit.pdfover.signator.SigningState signingState = null;
- Signer signer;
+ Signer signer;
Exception threadException = null;