diff options
Diffstat (limited to 'trunk/pdf-over-gui')
12 files changed, 301 insertions, 469 deletions
diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/AdvancedConfigurationComposite.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/AdvancedConfigurationComposite.java index 7cc49d18..e264aa48 100644 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/AdvancedConfigurationComposite.java +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/AdvancedConfigurationComposite.java @@ -16,6 +16,8 @@ package at.asit.pdfover.gui.composites; // Imports +import java.io.File; + import org.eclipse.swt.SWT; import org.eclipse.swt.events.FocusAdapter; import org.eclipse.swt.events.FocusEvent; @@ -66,7 +68,7 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite { * @param parent * @param style * @param state - * @param container + * @param container */ public AdvancedConfigurationComposite(Composite parent, int style, State state, ConfigurationContainer container) { @@ -74,7 +76,8 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite { setLayout(new FormLayout()); Group grpSignatur = new Group(this, SWT.NONE); - grpSignatur.setText(Messages.getString("advanced_config.Signature_Title")); //$NON-NLS-1$ + grpSignatur.setText(Messages + .getString("advanced_config.Signature_Title")); //$NON-NLS-1$ FormLayout layout = new FormLayout(); layout.marginHeight = 10; layout.marginWidth = 5; @@ -87,84 +90,100 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite { FontData[] fD_grpSignaturPosition = grpSignatur.getFont().getFontData(); fD_grpSignaturPosition[0].setHeight(TEXT_SIZE_NORMAL); - grpSignatur.setFont(new Font(Display.getCurrent(), fD_grpSignaturPosition[0])); - - this.btnAutomatischePositionierung = new Button(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); - this.btnAutomatischePositionierung.setText(Messages.getString("advanced_config.AutoPosition")); //$NON-NLS-1$ - - FontData[] fD_btnAutomatischePositionierung = this.btnAutomatischePositionierung.getFont().getFontData(); - fD_btnAutomatischePositionierung[0].setHeight(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()); - } - }); - log.debug(this.btnAutomatischePositionierung.getBounds().toString()); - - Label lblTransparenz = new Label(grpSignatur, SWT.HORIZONTAL); - FormData fd_lblTransparenz = new FormData(); - fd_lblTransparenz.top = new FormAttachment(this.btnAutomatischePositionierung, 5); - fd_lblTransparenz.left = new FormAttachment(0, 5); - lblTransparenz.setLayoutData(fd_lblTransparenz); - lblTransparenz.setText(Messages.getString("advanced_config.SigPHTransparency")); //$NON-NLS-1$ - - FontData[] fD_lblTransparenz = lblTransparenz.getFont().getFontData(); - fD_lblTransparenz[0].setHeight(TEXT_SIZE_NORMAL); - lblTransparenz.setFont(new Font(Display.getCurrent(), fD_lblTransparenz[0])); - - Label lblTransparenzLinks = new Label(grpSignatur, SWT.HORIZONTAL); - FormData fd_lblTransparenzLinks = new FormData(); - fd_lblTransparenzLinks.top = new FormAttachment(lblTransparenz, 5); - fd_lblTransparenzLinks.left = new FormAttachment(0, 15); - lblTransparenzLinks.setLayoutData(fd_lblTransparenzLinks); - lblTransparenzLinks.setText(Messages.getString("advanced_config.SigPHTransparencyMin")); //$NON-NLS-1$ - - FontData[] fD_lblTransparenzLinks = lblTransparenzLinks.getFont().getFontData(); - fD_lblTransparenzLinks[0].setHeight(TEXT_SIZE_NORMAL); - lblTransparenzLinks.setFont(new Font(Display.getCurrent(), fD_lblTransparenzLinks[0])); - - Label lblTransparenzRechts = new Label(grpSignatur, SWT.HORIZONTAL); - FormData fd_lblTransparenzRechts = new FormData(); - fd_lblTransparenzRechts.top = new FormAttachment(lblTransparenz, 5); - fd_lblTransparenzRechts.right = new FormAttachment(100, -5); - lblTransparenzRechts.setLayoutData(fd_lblTransparenzRechts); - lblTransparenzRechts.setText(Messages.getString("advanced_config.SigPHTransparencyMax")); //$NON-NLS-1$ - - FontData[] fD_lblTransparenzRechts = lblTransparenzRechts.getFont().getFontData(); - fD_lblTransparenzRechts[0].setHeight(TEXT_SIZE_NORMAL); - lblTransparenzRechts.setFont(new Font(Display.getCurrent(), fD_lblTransparenzRechts[0])); - - this.sclTransparenz = new Scale(grpSignatur, SWT.HORIZONTAL); - FormData fd_sldTransparenz = new FormData(); - fd_sldTransparenz.right = new FormAttachment(lblTransparenzRechts, -5); - fd_sldTransparenz.top = new FormAttachment(lblTransparenz, 5); - fd_sldTransparenz.left = new FormAttachment(lblTransparenzLinks, 5); - this.sclTransparenz.setLayoutData(fd_sldTransparenz); - this.sclTransparenz.setMinimum(0); - this.sclTransparenz.setMaximum(255); - this.sclTransparenz.setIncrement(1); - this.sclTransparenz.setPageIncrement(10); - this.sclTransparenz.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - performPlaceholderTransparency(AdvancedConfigurationComposite.this.sclTransparenz.getSelection()); - } - }); + grpSignatur.setFont(new Font(Display.getCurrent(), + fD_grpSignaturPosition[0])); + + this.btnAutomatischePositionierung = new Button(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); + this.btnAutomatischePositionierung.setText(Messages + .getString("advanced_config.AutoPosition")); //$NON-NLS-1$ + + FontData[] fD_btnAutomatischePositionierung = this.btnAutomatischePositionierung + .getFont().getFontData(); + fD_btnAutomatischePositionierung[0].setHeight(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()); + } + }); + log.debug(this.btnAutomatischePositionierung.getBounds().toString()); + + Label lblTransparenz = new Label(grpSignatur, SWT.HORIZONTAL); + FormData fd_lblTransparenz = new FormData(); + fd_lblTransparenz.top = new FormAttachment( + this.btnAutomatischePositionierung, 5); + fd_lblTransparenz.left = new FormAttachment(0, 5); + lblTransparenz.setLayoutData(fd_lblTransparenz); + lblTransparenz.setText(Messages + .getString("advanced_config.SigPHTransparency")); //$NON-NLS-1$ + + FontData[] fD_lblTransparenz = lblTransparenz.getFont().getFontData(); + fD_lblTransparenz[0].setHeight(TEXT_SIZE_NORMAL); + lblTransparenz.setFont(new Font(Display.getCurrent(), + fD_lblTransparenz[0])); + + Label lblTransparenzLinks = new Label(grpSignatur, SWT.HORIZONTAL); + FormData fd_lblTransparenzLinks = new FormData(); + fd_lblTransparenzLinks.top = new FormAttachment(lblTransparenz, 5); + fd_lblTransparenzLinks.left = new FormAttachment(0, 15); + lblTransparenzLinks.setLayoutData(fd_lblTransparenzLinks); + lblTransparenzLinks.setText(Messages + .getString("advanced_config.SigPHTransparencyMin")); //$NON-NLS-1$ + + FontData[] fD_lblTransparenzLinks = lblTransparenzLinks.getFont() + .getFontData(); + fD_lblTransparenzLinks[0].setHeight(TEXT_SIZE_NORMAL); + lblTransparenzLinks.setFont(new Font(Display.getCurrent(), + fD_lblTransparenzLinks[0])); + + Label lblTransparenzRechts = new Label(grpSignatur, SWT.HORIZONTAL); + FormData fd_lblTransparenzRechts = new FormData(); + fd_lblTransparenzRechts.top = new FormAttachment(lblTransparenz, 5); + fd_lblTransparenzRechts.right = new FormAttachment(100, -5); + lblTransparenzRechts.setLayoutData(fd_lblTransparenzRechts); + lblTransparenzRechts.setText(Messages + .getString("advanced_config.SigPHTransparencyMax")); //$NON-NLS-1$ + + FontData[] fD_lblTransparenzRechts = lblTransparenzRechts.getFont() + .getFontData(); + fD_lblTransparenzRechts[0].setHeight(TEXT_SIZE_NORMAL); + lblTransparenzRechts.setFont(new Font(Display.getCurrent(), + fD_lblTransparenzRechts[0])); + + this.sclTransparenz = new Scale(grpSignatur, SWT.HORIZONTAL); + FormData fd_sldTransparenz = new FormData(); + fd_sldTransparenz.right = new FormAttachment(lblTransparenzRechts, -5); + fd_sldTransparenz.top = new FormAttachment(lblTransparenz, 5); + fd_sldTransparenz.left = new FormAttachment(lblTransparenzLinks, 5); + this.sclTransparenz.setLayoutData(fd_sldTransparenz); + this.sclTransparenz.setMinimum(0); + this.sclTransparenz.setMaximum(255); + this.sclTransparenz.setIncrement(1); + this.sclTransparenz.setPageIncrement(10); + this.sclTransparenz.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + performPlaceholderTransparency(AdvancedConfigurationComposite.this.sclTransparenz + .getSelection()); + } + }); Group grpBkuAuswahl = new Group(this, SWT.NONE); - grpBkuAuswahl.setText(Messages.getString("advanced_config.BKUSelection_Title")); //$NON-NLS-1$ + grpBkuAuswahl.setText(Messages + .getString("advanced_config.BKUSelection_Title")); //$NON-NLS-1$ layout = new FormLayout(); layout.marginHeight = 10; layout.marginWidth = 5; @@ -177,45 +196,53 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite { FontData[] fD_grpBkuAuswahl = grpBkuAuswahl.getFont().getFontData(); fD_grpBkuAuswahl[0].setHeight(TEXT_SIZE_NORMAL); - grpBkuAuswahl.setFont(new Font(Display.getCurrent(), fD_grpBkuAuswahl[0])); - - this.cmbBKUAuswahl = new Combo(grpBkuAuswahl, SWT.READ_ONLY); - FormData fd_cmbBKUAuswahl = new FormData(); - fd_cmbBKUAuswahl.right = new FormAttachment(100, -5); - fd_cmbBKUAuswahl.top = new FormAttachment(0); - fd_cmbBKUAuswahl.left = new FormAttachment(0, 5); - - FontData[] fD_cmbBKUAuswahl = this.cmbBKUAuswahl.getFont().getFontData(); - fD_cmbBKUAuswahl[0].setHeight(TEXT_SIZE_NORMAL); - this.cmbBKUAuswahl.setFont(new Font(Display.getCurrent(), fD_cmbBKUAuswahl[0])); - - int blen = BKUs.values().length; - - this.bkuStrings = new String[blen]; - - for (int i = 0; i < blen; i++) { - String lookup = "BKU." + BKUs.values()[i].toString(); //$NON-NLS-1$ - this.bkuStrings[i] = Messages.getString(lookup); - } - - this.cmbBKUAuswahl.setItems(this.bkuStrings); - - this.cmbBKUAuswahl.setLayoutData(fd_cmbBKUAuswahl); - - this.cmbBKUAuswahl.addSelectionListener(new SelectionAdapter() { - - @Override - public void widgetSelected(SelectionEvent e) { - int selectionIndex = getBKUElementIndex(AdvancedConfigurationComposite.this.configurationContainer.getBKUSelection()); - if(AdvancedConfigurationComposite.this.cmbBKUAuswahl.getSelectionIndex() != selectionIndex) { - selectionIndex = AdvancedConfigurationComposite.this.cmbBKUAuswahl.getSelectionIndex(); - performBKUSelectionChanged(AdvancedConfigurationComposite.this.cmbBKUAuswahl.getItem(selectionIndex)); - } + grpBkuAuswahl.setFont(new Font(Display.getCurrent(), + fD_grpBkuAuswahl[0])); + + this.cmbBKUAuswahl = new Combo(grpBkuAuswahl, SWT.READ_ONLY); + FormData fd_cmbBKUAuswahl = new FormData(); + fd_cmbBKUAuswahl.right = new FormAttachment(100, -5); + fd_cmbBKUAuswahl.top = new FormAttachment(0); + fd_cmbBKUAuswahl.left = new FormAttachment(0, 5); + + FontData[] fD_cmbBKUAuswahl = this.cmbBKUAuswahl.getFont() + .getFontData(); + fD_cmbBKUAuswahl[0].setHeight(TEXT_SIZE_NORMAL); + this.cmbBKUAuswahl.setFont(new Font(Display.getCurrent(), + fD_cmbBKUAuswahl[0])); + + int blen = BKUs.values().length; + + this.bkuStrings = new String[blen]; + + for (int i = 0; i < blen; i++) { + String lookup = "BKU." + BKUs.values()[i].toString(); //$NON-NLS-1$ + this.bkuStrings[i] = Messages.getString(lookup); + } + + this.cmbBKUAuswahl.setItems(this.bkuStrings); + + this.cmbBKUAuswahl.setLayoutData(fd_cmbBKUAuswahl); + + this.cmbBKUAuswahl.addSelectionListener(new SelectionAdapter() { + + @Override + public void widgetSelected(SelectionEvent e) { + int selectionIndex = getBKUElementIndex(AdvancedConfigurationComposite.this.configurationContainer + .getBKUSelection()); + if (AdvancedConfigurationComposite.this.cmbBKUAuswahl + .getSelectionIndex() != selectionIndex) { + selectionIndex = AdvancedConfigurationComposite.this.cmbBKUAuswahl + .getSelectionIndex(); + performBKUSelectionChanged(AdvancedConfigurationComposite.this.cmbBKUAuswahl + .getItem(selectionIndex)); } - }); + } + }); Group grpSpeicherort = new Group(this, SWT.NONE); - grpSpeicherort.setText(Messages.getString("advanced_config.OutputFolder_Title")); //$NON-NLS-1$ + grpSpeicherort.setText(Messages + .getString("advanced_config.OutputFolder_Title")); //$NON-NLS-1$ layout = new FormLayout(); layout.marginHeight = 10; layout.marginWidth = 5; @@ -228,88 +255,100 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite { FontData[] fD_grpSpeicherort = grpSpeicherort.getFont().getFontData(); fD_grpSpeicherort[0].setHeight(TEXT_SIZE_NORMAL); - grpSpeicherort.setFont(new Font(Display.getCurrent(), fD_grpSpeicherort[0])); - - Label lblDefaultOutputFolder = new Label(grpSpeicherort, SWT.NONE); - FormData fd_lblDefaultOutputFolder = new FormData(); - fd_lblDefaultOutputFolder.top = new FormAttachment(0); - fd_lblDefaultOutputFolder.left = new FormAttachment(0, 5); - lblDefaultOutputFolder.setLayoutData(fd_lblDefaultOutputFolder); - lblDefaultOutputFolder.setText(Messages.getString("advanced_config.OutputFolder")); //$NON-NLS-1$ - - FontData[] fD_lblDefaultOutputFolder = lblDefaultOutputFolder.getFont().getFontData(); - fD_lblDefaultOutputFolder[0].setHeight(TEXT_SIZE_NORMAL); - lblDefaultOutputFolder.setFont(new Font(Display.getCurrent(), fD_lblDefaultOutputFolder[0])); - - this.txtOutputFolder = new Text(grpSpeicherort, SWT.BORDER); - FormData fd_text = new FormData(); - fd_text.top = new FormAttachment(lblDefaultOutputFolder, 5); - fd_text.left = new FormAttachment(0, 15); - this.txtOutputFolder.setLayoutData(fd_text); - - FontData[] fD_txtOutputFolder = this.txtOutputFolder.getFont().getFontData(); - fD_txtOutputFolder[0].setHeight(TEXT_SIZE_NORMAL); - 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()); - } - }); - - Button btnBrowse = new Button(grpSpeicherort, SWT.NONE); - fd_text.right = new FormAttachment(btnBrowse, -5); - - FontData[] fD_btnBrowse = btnBrowse.getFont().getFontData(); - fD_btnBrowse[0].setHeight(TEXT_SIZE_BUTTON); - btnBrowse.setFont(new Font(Display.getCurrent(), fD_btnBrowse[0])); - - FormData fd_btnBrowse = new FormData(); - fd_btnBrowse.top = new FormAttachment(lblDefaultOutputFolder, 5); - fd_btnBrowse.right = new FormAttachment(100, -5); - btnBrowse.setLayoutData(fd_btnBrowse); - btnBrowse.setText(Messages.getString("common.browse")); //$NON-NLS-1$ - - btnBrowse.addSelectionListener(new SelectionAdapter() { - - @Override - public void widgetSelected(SelectionEvent e) { - 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()); - - // Change the title bar text - 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$ - - // Calling open() will open and run the dialog. - // It will return the selected directory, or - // null if user cancels - String dir = dlg.open(); - if (dir != null) { - // Set the text box to the new selection - performOutputFolderChanged(dir); - } + grpSpeicherort.setFont(new Font(Display.getCurrent(), + fD_grpSpeicherort[0])); + + Label lblDefaultOutputFolder = new Label(grpSpeicherort, SWT.NONE); + FormData fd_lblDefaultOutputFolder = new FormData(); + fd_lblDefaultOutputFolder.top = new FormAttachment(0); + fd_lblDefaultOutputFolder.left = new FormAttachment(0, 5); + lblDefaultOutputFolder.setLayoutData(fd_lblDefaultOutputFolder); + lblDefaultOutputFolder.setText(Messages + .getString("advanced_config.OutputFolder")); //$NON-NLS-1$ + + FontData[] fD_lblDefaultOutputFolder = lblDefaultOutputFolder.getFont() + .getFontData(); + fD_lblDefaultOutputFolder[0].setHeight(TEXT_SIZE_NORMAL); + lblDefaultOutputFolder.setFont(new Font(Display.getCurrent(), + fD_lblDefaultOutputFolder[0])); + + this.txtOutputFolder = new Text(grpSpeicherort, SWT.BORDER); + FormData fd_text = new FormData(); + fd_text.top = new FormAttachment(lblDefaultOutputFolder, 5); + fd_text.left = new FormAttachment(0, 15); + this.txtOutputFolder.setLayoutData(fd_text); + + FontData[] fD_txtOutputFolder = this.txtOutputFolder.getFont() + .getFontData(); + fD_txtOutputFolder[0].setHeight(TEXT_SIZE_NORMAL); + 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()); + } + }); + + Button btnBrowse = new Button(grpSpeicherort, SWT.NONE); + fd_text.right = new FormAttachment(btnBrowse, -5); + + FontData[] fD_btnBrowse = btnBrowse.getFont().getFontData(); + fD_btnBrowse[0].setHeight(TEXT_SIZE_BUTTON); + btnBrowse.setFont(new Font(Display.getCurrent(), fD_btnBrowse[0])); + + FormData fd_btnBrowse = new FormData(); + fd_btnBrowse.top = new FormAttachment(lblDefaultOutputFolder, 5); + fd_btnBrowse.right = new FormAttachment(100, -5); + btnBrowse.setLayoutData(fd_btnBrowse); + btnBrowse.setText(Messages.getString("common.browse")); //$NON-NLS-1$ + + btnBrowse.addSelectionListener(new SelectionAdapter() { + + @Override + public void widgetSelected(SelectionEvent e) { + 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()); + + // Change the title bar text + 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$ + + // Calling open() will open and run the dialog. + // It will return the selected directory, or + // null if user cancels + String dir = dlg.open(); + if (dir != null) { + // Set the text box to the new selection + performOutputFolderChanged(dir); } - }); + } + }); } - /* (non-Javadoc) - * @see at.asit.pdfover.gui.composites.BaseConfigurationComposite#signerChanged() + /* + * (non-Javadoc) + * + * @see + * at.asit.pdfover.gui.composites.BaseConfigurationComposite#signerChanged() */ @Override protected void signerChanged() { // Nothing to do here (yet) } - + void performOutputFolderChanged(String foldername) { log.debug("Selected Output folder: " + foldername); //$NON-NLS-1$ this.configurationContainer.setOutputFolder(foldername); @@ -319,18 +358,18 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite { int getBKUElementIndex(BKUs bku) { String lookup = "BKU." + bku.toString(); //$NON-NLS-1$ String bkuName = Messages.getString(lookup); - - for(int i = 0; i < this.bkuStrings.length; i++) { - if(this.bkuStrings[i].equals(bkuName)) { + + for (int i = 0; i < this.bkuStrings.length; i++) { + if (this.bkuStrings[i].equals(bkuName)) { log.debug("BKU: " + bkuName + " IDX: " + i); //$NON-NLS-1$ //$NON-NLS-2$ return i; } } - + log.warn("NO BKU match for " + bkuName); //$NON-NLS-1$ return 0; } - + void performBKUSelectionChanged(BKUs selected) { log.debug("Selected BKU: " + selected.toString()); //$NON-NLS-1$ this.configurationContainer.setBKUSelection(selected); @@ -343,24 +382,24 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite { this.performBKUSelectionChanged(bkuvalue); } catch (Exception ex) { log.error("Failed to parse BKU value: " + selected, ex); //$NON-NLS-1$ - ErrorDialog dialog = new ErrorDialog(getShell(), SWT.NONE, Messages.getString("error.InvalidBKU"), ex, false); //$NON-NLS-1$ + ErrorDialog dialog = new ErrorDialog(getShell(), Messages.getString("error.InvalidBKU"), false); //$NON-NLS-1$ dialog.open(); } } - + BKUs resolvBKU(String localizedBKU) { int blen = BKUs.values().length; for (int i = 0; i < blen; i++) { String lookup = "BKU." + BKUs.values()[i].toString(); //$NON-NLS-1$ - if(Messages.getString(lookup).equals(localizedBKU)) { + if (Messages.getString(lookup).equals(localizedBKU)) { return BKUs.values()[i]; } } return BKUs.NONE; } - + void performPositionSelection(boolean automatic) { log.debug("Selected Position: " + automatic); //$NON-NLS-1$ this.configurationContainer.setAutomaticPosition(automatic); @@ -391,20 +430,41 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite { @Override public void loadConfiguration() { // load advanced settings - this.performBKUSelectionChanged(this.configurationContainer.getBKUSelection()); + this.performBKUSelectionChanged(this.configurationContainer + .getBKUSelection()); String outputFolder = this.configurationContainer.getOutputFolder(); - if(outputFolder != null) { + if (outputFolder != null) { this.performOutputFolderChanged(outputFolder); } - this.performPositionSelection(this.configurationContainer.getAutomaticPosition()); - this.sclTransparenz.setSelection(this.configurationContainer.getPlaceholderTransparency()); + this.performPositionSelection(this.configurationContainer + .getAutomaticPosition()); + this.sclTransparenz.setSelection(this.configurationContainer + .getPlaceholderTransparency()); } - /* (non-Javadoc) - * @see at.asit.pdfover.gui.composites.BaseConfigurationComposite#validateSettings() + /* + * (non-Javadoc) + * + * @see + * at.asit.pdfover.gui.composites.BaseConfigurationComposite#validateSettings + * () */ @Override public void validateSettings() throws Exception { - // Nothing to do here (yet) + + String foldername = this.configurationContainer.getOutputFolder(); + + if (foldername != null && !foldername.equals("")) { + File outputFolder = new File(foldername); + if (!outputFolder.exists()) { + throw new Exception("Path " + outputFolder.getAbsolutePath() + + " doesnot exists!"); + } + + if (!outputFolder.isDirectory()) { + throw new Exception("Path " + outputFolder.getAbsolutePath() + + " is not a directory!"); + } + } } } diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java index c7536d17..b7b0aa1d 100644 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java @@ -338,9 +338,8 @@ public class ConfigurationComposite extends StateComposite { log.error("Settings validation failed!", e); //$NON-NLS-1$ ErrorDialog dialog = new ErrorDialog( getShell(), - SWT.NONE, - Messages.getString("error.InvalidSettings"), //$NON-NLS-1$ - e, false); + e.getMessage(), //$NON-NLS-1$ + false); dialog.open(); return false; } @@ -355,8 +354,8 @@ public class ConfigurationComposite extends StateComposite { status = true; } catch (IOException e) { log.error("Failed to save configuration to file!", e); //$NON-NLS-1$ - ErrorDialog dialog = new ErrorDialog(getShell(), SWT.NONE, - Messages.getString("error.FailedToSaveSettings"), e, true); //$NON-NLS-1$ + ErrorDialog dialog = new ErrorDialog(getShell(), + Messages.getString("error.FailedToSaveSettings"), true); //$NON-NLS-1$ redo = dialog.open(); //return false; diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SimpleConfigurationComposite.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SimpleConfigurationComposite.java index 36b571de..d5f0b2e7 100644 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SimpleConfigurationComposite.java +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SimpleConfigurationComposite.java @@ -711,8 +711,8 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite { setEmblemFile(filename); } catch (Exception ex) { log.error("processEmblemChanged: ", ex); //$NON-NLS-1$ - ErrorDialog dialog = new ErrorDialog(getShell(), SWT.NONE, - Messages.getString("error.FailedToLoadEmblem"), ex, false); //$NON-NLS-1$ + ErrorDialog dialog = new ErrorDialog(getShell(), + Messages.getString("error.FailedToLoadEmblem"), false); //$NON-NLS-1$ dialog.open(); } } @@ -866,8 +866,7 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite { log.error("Failed to load emblem: ", e1); //$NON-NLS-1$ ErrorDialog dialog = new ErrorDialog( getShell(), - SWT.NONE, - Messages.getString("error.FailedToLoadEmblem"), e1, false); //$NON-NLS-1$ + Messages.getString("error.FailedToLoadEmblem"), false); //$NON-NLS-1$ dialog.open(); } } diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ErrorDialog.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ErrorDialog.java index 6d04b33f..88392d98 100644 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ErrorDialog.java +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ErrorDialog.java @@ -16,273 +16,47 @@ package at.asit.pdfover.gui.controls; // Imports -import java.io.InputStream; - import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.ScrolledComposite; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.ImageData; -import org.eclipse.swt.layout.FormAttachment; -import org.eclipse.swt.layout.FormData; -import org.eclipse.swt.layout.FormLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Dialog; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.MessageBox; import org.eclipse.swt.widgets.Shell; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import at.asit.pdfover.gui.Messages; /** * */ -public class ErrorDialog extends Dialog { - - private static final boolean VERBOSE_ERROR = false; +public class ErrorDialog { + private MessageBox box; + /** * @param parent - * @param style * @param message - * @param exception * @param canRetry */ - public ErrorDialog(Shell parent, int style, String message, - Throwable exception, boolean canRetry) { - super(parent, style); - this.message = message; - this.canRetry = canRetry; - final StringBuilder result = new StringBuilder(); - result.append(exception.getLocalizedMessage()); - final String NEW_LINE = System.getProperty("line.separator"); //$NON-NLS-1$ - result.append(NEW_LINE); - result.append(NEW_LINE); - result.append(NEW_LINE); - - // add each element of the stack trace - for (StackTraceElement element : exception.getStackTrace()) { - result.append(element); - result.append(NEW_LINE); + public ErrorDialog(Shell parent, String message, boolean canRetry) { + int boxstyle = SWT.ICON_ERROR ; + if(canRetry) { + boxstyle |= SWT.RETRY| SWT.CANCEL; + } else { + boxstyle |= SWT.OK; } - this.details = result.toString(); - } - - /** - * @param parent - * @param style - * @param message - * @param details - * @param canRetry - */ - public ErrorDialog(Shell parent, int style, String message, String details, - boolean canRetry) { - super(parent, style); - this.message = message; - this.details = details; - this.canRetry = canRetry; + + this.box = new MessageBox(parent, boxstyle); + this.box.setMessage(message); + this.box.setText(Messages.getString("error.title")); //$NON-NLS-1$ } - private String message = null; - - private boolean canRetry = false; - - boolean doRetry = false; - - private String details = null; - - /** - * SLF4J Logger instance - **/ - @SuppressWarnings("unused") - private static final Logger log = LoggerFactory - .getLogger(ErrorDialog.class); - /** * Open error dialog * * @return if the user wants to retry the action which caused the error */ public boolean open() { - Shell parent = getParent(); - final Shell shell = new Shell(parent, SWT.DIALOG_TRIM - | SWT.APPLICATION_MODAL); - shell.setText(getText()); - shell.setLayout(new FormLayout()); - - Label lblErrorImage = new Label(shell, SWT.NONE); - FormData fd_lblErrorImage = new FormData(); - fd_lblErrorImage.top = new FormAttachment(50, -16); - fd_lblErrorImage.left = new FormAttachment(0, 5); - lblErrorImage.setLayoutData(fd_lblErrorImage); - lblErrorImage.setText(""); //$NON-NLS-1$ - - String imgPath = "/img/error.png"; //$NON-NLS-1$ - - InputStream stream = this.getClass().getResourceAsStream(imgPath); - - Image orig = new Image(Display.getCurrent(), - new ImageData(stream).scaledTo(32, 32)); - - lblErrorImage.setImage(orig); - - Label lblerrorMessage = new Label(shell, SWT.NONE); - FormData fd_lblerrorMessage = new FormData(); - fd_lblerrorMessage.top = new FormAttachment(0, 5); - fd_lblerrorMessage.left = new FormAttachment(0, 42); - lblerrorMessage.setLayoutData(fd_lblerrorMessage); - lblerrorMessage.setText(this.message); - - if (VERBOSE_ERROR) { - - Group group = new Group(shell, SWT.NONE); - group.setLayout(new FormLayout()); - FormData fd_group = new FormData(); - - fd_group.right = new FormAttachment(100, -5); - fd_group.top = new FormAttachment(lblerrorMessage, 5); - fd_group.left = new FormAttachment(lblErrorImage, 5); - group.setLayoutData(fd_group); - group.setText(Messages.getString("error.Details")); //$NON-NLS-1$ - - if (!this.canRetry) { - - Button btnOk = new Button(shell, SWT.NONE); - btnOk.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - shell.dispose(); - } - }); - fd_group.bottom = new FormAttachment(btnOk, -5); - - ScrolledComposite scrolledComposite = new ScrolledComposite( - group, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); - FormData fd_scrolledComposite = new FormData(); - fd_scrolledComposite.top = new FormAttachment(0, 5); - fd_scrolledComposite.left = new FormAttachment(0, 5); - fd_scrolledComposite.bottom = new FormAttachment(100, -5); - fd_scrolledComposite.right = new FormAttachment(100, -5); - scrolledComposite.setLayoutData(fd_scrolledComposite); - scrolledComposite.setExpandHorizontal(true); - scrolledComposite.setExpandVertical(true); - - Label lblDetails = new Label(scrolledComposite, SWT.NONE); - - lblDetails.setText(this.details); - - scrolledComposite.setContent(lblDetails); - scrolledComposite.setMinSize(lblDetails.computeSize( - SWT.DEFAULT, SWT.DEFAULT)); - FormData fd_btnOk = new FormData(); - fd_btnOk.bottom = new FormAttachment(100, -5); - fd_btnOk.right = new FormAttachment(100, -5); - btnOk.setLayoutData(fd_btnOk); - btnOk.setText(Messages.getString("common.Ok")); //$NON-NLS-1$ - } else { - Button btnCancel = new Button(shell, SWT.NONE); - Button btnRetry = new Button(shell, SWT.NONE); - - btnCancel.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - shell.dispose(); - } - }); - - btnRetry.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - ErrorDialog.this.doRetry = true; - shell.dispose(); - } - }); - fd_group.bottom = new FormAttachment(btnCancel, -5); - - ScrolledComposite scrolledComposite = new ScrolledComposite( - group, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); - FormData fd_scrolledComposite = new FormData(); - fd_scrolledComposite.top = new FormAttachment(0, 5); - fd_scrolledComposite.left = new FormAttachment(0, 5); - fd_scrolledComposite.bottom = new FormAttachment(100, -5); - fd_scrolledComposite.right = new FormAttachment(100, -5); - scrolledComposite.setLayoutData(fd_scrolledComposite); - scrolledComposite.setExpandHorizontal(true); - scrolledComposite.setExpandVertical(true); - - Label lblDetails = new Label(scrolledComposite, SWT.NONE); - - lblDetails.setText(this.details); - - scrolledComposite.setContent(lblDetails); - scrolledComposite.setMinSize(lblDetails.computeSize( - SWT.DEFAULT, SWT.DEFAULT)); - FormData fd_btnCancel = new FormData(); - fd_btnCancel.bottom = new FormAttachment(100, -5); - fd_btnCancel.right = new FormAttachment(100, -5); - btnCancel.setLayoutData(fd_btnCancel); - btnCancel.setText(Messages.getString("common.Cancel")); //$NON-NLS-1$ - - FormData fd_btnRetry = new FormData(); - fd_btnRetry.bottom = new FormAttachment(100, -5); - fd_btnRetry.right = new FormAttachment(btnCancel, -10); - btnRetry.setLayoutData(fd_btnRetry); - btnRetry.setText(Messages.getString("error.Retry")); //$NON-NLS-1$ - } - - } else { - - Button btnCancel = new Button(shell, SWT.NONE); - - btnCancel.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - shell.dispose(); - } - }); - - FormData fd_btnCancel = new FormData(); - fd_btnCancel.bottom = new FormAttachment(100, -5); - fd_btnCancel.right = new FormAttachment(100, -5); - fd_btnCancel.top = new FormAttachment(lblerrorMessage, 10); - btnCancel.setLayoutData(fd_btnCancel); - btnCancel.setText(Messages.getString("common.Ok")); //$NON-NLS-1$ - - - if(this.canRetry) { - btnCancel.setText(Messages.getString("common.Cancel")); //$NON-NLS-1$ - - Button btnRetry = new Button(shell, SWT.NONE); - - - btnRetry.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - ErrorDialog.this.doRetry = true; - shell.dispose(); - } - }); - FormData fd_btnRetry = new FormData(); - - fd_btnRetry.bottom = new FormAttachment(100, -5); - fd_btnRetry.right = new FormAttachment(btnCancel, -10); - btnRetry.setLayoutData(fd_btnRetry); - btnRetry.setText(Messages.getString("error.Retry")); //$NON-NLS-1$ - } - } - shell.pack(); - shell.open(); - shell.pack(); - Display display = parent.getDisplay(); - while (!shell.isDisposed()) { - if (!display.readAndDispatch()) - display.sleep(); - } - - return this.doRetry; + int rc = this.box.open(); + if(rc == SWT.RETRY) { + return true; + } + return false; } } diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StateMachineImpl.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StateMachineImpl.java index 3abecd39..0cdc459c 100644 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StateMachineImpl.java +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StateMachineImpl.java @@ -88,7 +88,7 @@ public class StateMachineImpl implements StateMachine, GUIProvider { } catch (Exception e) { log.error("StateMachine update: ", e); //$NON-NLS-1$ ErrorDialog errorState = new ErrorDialog(this.getMainShell(), - SWT.NONE, Messages.getString("error.Unexpected"), e, false); //$NON-NLS-1$ + Messages.getString("error.Unexpected"), false); //$NON-NLS-1$ //errorState.setException(e); //jumpToState(errorState); errorState.open(); diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/LocalBKUState.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/LocalBKUState.java index 0c8c7047..e09f2a03 100644 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/LocalBKUState.java +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/LocalBKUState.java @@ -170,9 +170,9 @@ public class LocalBKUState extends State { if (this.threadException != null) { ErrorDialog dialog = new ErrorDialog( - this.stateMachine.getGUIProvider().getMainShell(), SWT.NONE, + this.stateMachine.getGUIProvider().getMainShell(), Messages.getString("error.LocalBKU"), //$NON-NLS-1$ - this.threadException, true); + true); if (!dialog.open()) { this.stateMachine.exit(); return; diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java index bf624083..326eb12f 100644 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java @@ -152,8 +152,7 @@ public class MobileBKUState extends State { if (this.threadException != null) { ErrorDialog error = new ErrorDialog( this.stateMachine.getGUIProvider().getMainShell(), - SWT.NONE, - Messages.getString("error.Unexpected"), this.threadException, false); //$NON-NLS-1$ + Messages.getString("error.Unexpected"), false); //$NON-NLS-1$ // error.setException(this.threadException); // this.setNextState(error); error.open(); diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OutputState.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OutputState.java index e6ba02d8..5ed273ca 100644 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OutputState.java +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OutputState.java @@ -99,8 +99,8 @@ public class OutputState extends State { output.close(); } catch (IOException e) { log.error("Failed to save signed document to configured output folder.", e); //$NON-NLS-1$ - ErrorDialog dialog = new ErrorDialog(outputComposite.getShell(), SWT.NONE, - Messages.getString("error.SaveOutputFolder"), e, false); //$NON-NLS-1$ + ErrorDialog dialog = new ErrorDialog(outputComposite.getShell(), + Messages.getString("error.SaveOutputFolder"), false); //$NON-NLS-1$ dialog.open(); } } diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java index b4398581..22dfe56a 100644 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java @@ -243,9 +243,9 @@ public class PrepareConfigurationState extends State { } catch (InitializationException e) { log.error("Failed to initialize: ", e); //$NON-NLS-1$ ErrorDialog error = new ErrorDialog(this.stateMachine - .getGUIProvider().getMainShell(), SWT.NONE, + .getGUIProvider().getMainShell(), Messages.getString("error.Initialization"), //$NON-NLS-1$ - e, false); + false); // error.setException(e); // this.setNextState(error); error.open(); diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java index f51a3289..6381038f 100644 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java @@ -154,7 +154,7 @@ public class PrepareSigningState extends State { if(this.threadException != null) { ErrorDialog error = new ErrorDialog(this.stateMachine.getGUIProvider().getMainShell(), - SWT.NONE, Messages.getString("error.PrepareDocument"), this.threadException, //$NON-NLS-1$ + Messages.getString("error.PrepareDocument"), //$NON-NLS-1$ true); this.threadException = null; if(error.open()) { diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/SigningState.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/SigningState.java index 3b782119..a173bb21 100644 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/SigningState.java +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/SigningState.java @@ -88,7 +88,7 @@ public class SigningState extends State { if(this.threadException != null) { ErrorDialog error = new ErrorDialog(this.stateMachine.getGUIProvider().getMainShell(), - SWT.NONE, Messages.getString("error.Signatur"), this.threadException, true); //$NON-NLS-1$ + Messages.getString("error.Signatur"), true); //$NON-NLS-1$ this.threadException = null; if(error.open()) { this.setNextState(new BKUSelectionState(this.stateMachine)); diff --git a/trunk/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages.properties b/trunk/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages.properties index 84086ae1..872eef8a 100644 --- a/trunk/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages.properties +++ b/trunk/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages.properties @@ -72,6 +72,7 @@ error.SaveOutputFolder=Failed to save signed document to configured output folde error.Signatur=Signature error error.TanTooLong=Entered TAN too long error.Unexpected=Unexpected Error +error.title=Error exception.InvalidEmblemFile=is an invalid signature logo file\! exception.InvalidPort=is invalid has to be between 1 and exception.PasswordTooLong=Given password is too long\! |