summaryrefslogtreecommitdiff
path: root/trunk
diff options
context:
space:
mode:
Diffstat (limited to 'trunk')
-rw-r--r--trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/ImageConverter.java154
-rw-r--r--trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/AdvancedConfigurationComposite.java18
-rw-r--r--trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/BaseConfigurationComposite.java28
-rw-r--r--trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java27
-rw-r--r--trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/DataSourceSelectComposite.java2
-rw-r--r--trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SimpleConfigurationComposite.java300
-rw-r--r--trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/ConfigurationUIState.java2
-rw-r--r--trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OpenState.java2
8 files changed, 411 insertions, 122 deletions
diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/ImageConverter.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/ImageConverter.java
new file mode 100644
index 00000000..28fb55a6
--- /dev/null
+++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/ImageConverter.java
@@ -0,0 +1,154 @@
+/*
+ * 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;
+
+// Imports
+import java.awt.image.BufferedImage;
+import java.awt.image.ColorModel;
+import java.awt.image.DirectColorModel;
+import java.awt.image.IndexColorModel;
+import java.awt.image.WritableRaster;
+
+import org.eclipse.swt.graphics.ImageData;
+import org.eclipse.swt.graphics.PaletteData;
+import org.eclipse.swt.graphics.RGB;
+
+/**
+ *
+ */
+public class ImageConverter {
+
+ /**
+ * Convert Image Data to AWT Image
+ * @param data
+ * @return AWT Image
+ */
+ public static BufferedImage convertToAWT(ImageData data) {
+ ColorModel colorModel = null;
+ PaletteData palette = data.palette;
+ if (palette.isDirect) {
+ colorModel = new DirectColorModel(data.depth, palette.redMask,
+ palette.greenMask, palette.blueMask);
+ BufferedImage bufferedImage = new BufferedImage(colorModel,
+ colorModel.createCompatibleWritableRaster(data.width,
+ data.height), false, null);
+ WritableRaster raster = bufferedImage.getRaster();
+ int[] pixelArray = new int[3];
+ for (int y = 0; y < data.height; y++) {
+ for (int x = 0; x < data.width; x++) {
+ int pixel = data.getPixel(x, y);
+ RGB rgb = palette.getRGB(pixel);
+ pixelArray[0] = rgb.red;
+ pixelArray[1] = rgb.green;
+ pixelArray[2] = rgb.blue;
+ raster.setPixels(x, y, 1, 1, pixelArray);
+ }
+ }
+ return bufferedImage;
+ }
+ RGB[] rgbs = palette.getRGBs();
+ byte[] red = new byte[rgbs.length];
+ byte[] green = new byte[rgbs.length];
+ byte[] blue = new byte[rgbs.length];
+ for (int i = 0; i < rgbs.length; i++) {
+ RGB rgb = rgbs[i];
+ red[i] = (byte) rgb.red;
+ green[i] = (byte) rgb.green;
+ blue[i] = (byte) rgb.blue;
+ }
+ if (data.transparentPixel != -1) {
+ colorModel = new IndexColorModel(data.depth, rgbs.length, red,
+ green, blue, data.transparentPixel);
+ } else {
+ colorModel = new IndexColorModel(data.depth, rgbs.length, red,
+ green, blue);
+ }
+ BufferedImage bufferedImage = new BufferedImage(colorModel,
+ colorModel.createCompatibleWritableRaster(data.width,
+ data.height), false, null);
+ WritableRaster raster = bufferedImage.getRaster();
+ int[] pixelArray = new int[1];
+ for (int y = 0; y < data.height; y++) {
+ for (int x = 0; x < data.width; x++) {
+ int pixel = data.getPixel(x, y);
+ pixelArray[0] = pixel;
+ raster.setPixel(x, y, pixelArray);
+ }
+ }
+ return bufferedImage;
+
+ }
+
+ /**
+ * Convert AWT Image to SWT Image
+ *
+ * @param bufferedImage
+ * @return SWT Image data
+ */
+ public static ImageData convertToSWT(final BufferedImage bufferedImage) {
+ if (bufferedImage.getColorModel() instanceof DirectColorModel) {
+ DirectColorModel colorModel = (DirectColorModel) bufferedImage
+ .getColorModel();
+ PaletteData palette = new PaletteData(colorModel.getRedMask(),
+ colorModel.getGreenMask(), colorModel.getBlueMask());
+ ImageData data = new ImageData(bufferedImage.getWidth(),
+ bufferedImage.getHeight(), colorModel.getPixelSize(),
+ palette);
+ WritableRaster raster = bufferedImage.getRaster();
+ int[] pixelArray = new int[3];
+ for (int y = 0; y < data.height; y++) {
+ for (int x = 0; x < data.width; x++) {
+ raster.getPixel(x, y, pixelArray);
+ int pixel = palette.getPixel(new RGB(pixelArray[0],
+ pixelArray[1], pixelArray[2]));
+ data.setPixel(x, y, pixel);
+ }
+ }
+ return data;
+ } else if (bufferedImage.getColorModel() instanceof IndexColorModel) {
+ IndexColorModel colorModel = (IndexColorModel) bufferedImage
+ .getColorModel();
+ int size = colorModel.getMapSize();
+ byte[] reds = new byte[size];
+ byte[] greens = new byte[size];
+ byte[] blues = new byte[size];
+ colorModel.getReds(reds);
+ colorModel.getGreens(greens);
+ colorModel.getBlues(blues);
+ RGB[] rgbs = new RGB[size];
+ for (int i = 0; i < rgbs.length; i++) {
+ rgbs[i] = new RGB(reds[i] & 0xFF, greens[i] & 0xFF,
+ blues[i] & 0xFF);
+ }
+ PaletteData palette = new PaletteData(rgbs);
+ ImageData data = new ImageData(bufferedImage.getWidth(),
+ bufferedImage.getHeight(), colorModel.getPixelSize(),
+ palette);
+ data.transparentPixel = colorModel.getTransparentPixel();
+ WritableRaster raster = bufferedImage.getRaster();
+ int[] pixelArray = new int[1];
+ for (int y = 0; y < data.height; y++) {
+ for (int x = 0; x < data.width; x++) {
+ raster.getPixel(x, y, pixelArray);
+ data.setPixel(x, y, pixelArray[0]);
+ }
+ }
+ return data;
+ }
+ return null;
+ }
+
+}
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 c3b7973f..19e56b68 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
@@ -69,6 +69,16 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
fd_tabFolder.left = new FormAttachment(0, 5);
tabFolder.setLayoutData(fd_tabFolder);
+ tabFolder.addSelectionListener(new SelectionAdapter() {
+ /* (non-Javadoc)
+ * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ AdvancedConfigurationComposite.this.simpleComposite.signerChanged();
+ }
+ });
+
TabItem simpleTabItem = new TabItem(tabFolder, SWT.NULL);
simpleTabItem.setText(Messages.getString("config.Simple")); //$NON-NLS-1$
@@ -263,6 +273,14 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
tabFolder.setSelection(advancedTabItem);
}
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.composites.BaseConfigurationComposite#signerChanged()
+ */
+ @Override
+ protected void signerChanged() {
+ this.simpleComposite.setSigner(this.getSigner());
+ }
+
void performOutputFolderChanged(String foldername) {
log.debug("Selected Output folder: " + foldername); //$NON-NLS-1$
this.configurationContainer.setOutputFolder(foldername);
diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/BaseConfigurationComposite.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/BaseConfigurationComposite.java
index d97f3a5f..db3304d5 100644
--- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/BaseConfigurationComposite.java
+++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/BaseConfigurationComposite.java
@@ -19,6 +19,7 @@ package at.asit.pdfover.gui.composites;
import org.eclipse.swt.widgets.Composite;
import at.asit.pdfover.gui.workflow.ConfigurationContainer;
+import at.asit.pdfover.gui.workflow.PDFSigner;
import at.asit.pdfover.gui.workflow.states.State;
/**
@@ -32,6 +33,33 @@ public abstract class BaseConfigurationComposite extends StateComposite {
protected ConfigurationContainer configurationContainer;
/**
+ * The PDF Signer used to produce signature block preview
+ */
+ protected PDFSigner signer;
+
+ /**
+ * @return the signer
+ */
+ public PDFSigner getSigner() {
+ return this.signer;
+ }
+
+ /**
+ * @param signer the signer to set
+ */
+ public void setSigner(PDFSigner signer) {
+ this.signer = signer;
+ this.signerChanged();
+ }
+
+ /**
+ * Called when the signer is changed!
+ */
+ protected void signerChanged() {
+ // overwrite
+ }
+
+ /**
* @param parent
* @param style
* @param state
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 25cedaf0..105fcd54 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
@@ -33,6 +33,7 @@ import at.asit.pdfover.gui.workflow.ConfigManipulator;
import at.asit.pdfover.gui.workflow.ConfigProvider;
import at.asit.pdfover.gui.workflow.ConfigurationContainer;
import at.asit.pdfover.gui.workflow.ConfigurationContainerImpl;
+import at.asit.pdfover.gui.workflow.PDFSigner;
import at.asit.pdfover.gui.workflow.states.State;
import at.asit.pdfover.signator.SignaturePosition;
@@ -54,6 +55,28 @@ import org.eclipse.swt.layout.FormAttachment;
public class ConfigurationComposite extends StateComposite {
/**
+ * The PDF Signer used to produce signature block preview
+ */
+ protected PDFSigner signer;
+
+ /**
+ * @return the signer
+ */
+ public PDFSigner getSigner() {
+ return this.signer;
+ }
+
+ /**
+ * @param signer the signer to set
+ */
+ public void setSigner(PDFSigner signer) {
+ this.signer = signer;
+ if(this.configComposite != null) {
+ this.configComposite.setSigner(getSigner());
+ }
+ }
+
+ /**
* Configuration Mode selection listener
*/
private final class ConfigurationModeSelectionListener implements
@@ -76,6 +99,7 @@ public class ConfigurationComposite extends StateComposite {
ConfigurationComposite.this.style,
ConfigurationComposite.this.state,
ConfigurationComposite.this.configurationContainer);
+ ConfigurationComposite.this.configComposite.setSigner(getSigner());
ConfigurationComposite.this.btnAdvanced.setText(Messages.getString("config.Simple")); //$NON-NLS-1$
} else {
// switch to simple
@@ -85,6 +109,7 @@ public class ConfigurationComposite extends StateComposite {
ConfigurationComposite.this.style,
ConfigurationComposite.this.state,
ConfigurationComposite.this.configurationContainer);
+ ConfigurationComposite.this.configComposite.setSigner(getSigner());
ConfigurationComposite.this.btnAdvanced.setText(Messages.getString("config.Advanced")); //$NON-NLS-1$
}
@@ -225,7 +250,7 @@ public class ConfigurationComposite extends StateComposite {
this.configComposite = new SimpleConfigurationComposite(
this.containerComposite, SWT.FILL | style, state,
this.configurationContainer);
-
+
FormData fd_composite = new FormData();
fd_composite.top = new FormAttachment(0, 5);
fd_composite.bottom = new FormAttachment(90, -5);
diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/DataSourceSelectComposite.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/DataSourceSelectComposite.java
index af87e3c7..3ee71997 100644
--- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/DataSourceSelectComposite.java
+++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/DataSourceSelectComposite.java
@@ -149,7 +149,7 @@ public class DataSourceSelectComposite extends StateComposite {
super(parent, style, state);
this.activeBackground = new Color(getDisplay(),0xD4, 0xE7, 0xF1);
- this.inactiveBorder = this.activeBackground;
+ this.inactiveBorder = new Color(getDisplay(),0xB4, 0xCD, 0xEC);
this.activeBorder = new Color(getDisplay(),0x6B, 0xA5, 0xD9);
this.backgroundColor = this.getBackground();
this.borderColor = this.inactiveBorder;
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 9bc75be5..94d42a18 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
@@ -16,6 +16,7 @@
package at.asit.pdfover.gui.composites;
// Imports
+import java.awt.image.BufferedImage;
import java.io.File;
import org.eclipse.swt.SWT;
@@ -57,6 +58,7 @@ import org.eclipse.swt.widgets.Text;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import at.asit.pdfover.gui.ImageConverter;
import at.asit.pdfover.gui.Messages;
import at.asit.pdfover.gui.controls.ErrorDialog;
import at.asit.pdfover.gui.controls.ErrorMarker;
@@ -65,6 +67,8 @@ import at.asit.pdfover.gui.exceptions.InvalidNumberException;
import at.asit.pdfover.gui.exceptions.InvalidPortException;
import at.asit.pdfover.gui.workflow.ConfigurationContainer;
import at.asit.pdfover.gui.workflow.states.State;
+import at.asit.pdfover.signator.FileNameEmlbem;
+import at.asit.pdfover.signator.SignatureParameter;
/**
*
@@ -87,8 +91,8 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
FileDialog dialog = new FileDialog(
SimpleConfigurationComposite.this.getShell(), SWT.OPEN);
dialog.setFilterExtensions(new String[] { "*.jpg", "*.gif" }); //$NON-NLS-1$ //$NON-NLS-2$
- dialog.setFilterNames(new String[] {
- Messages.getString("common.JPGExtension_Description"), //$NON-NLS-1$
+ dialog.setFilterNames(new String[] {
+ Messages.getString("common.JPGExtension_Description"), //$NON-NLS-1$
Messages.getString("common.GIFExtension_Description") }); //$NON-NLS-1$
String fileName = dialog.open();
File file = null;
@@ -160,9 +164,16 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
betterFactor = 1.0f;
}
- Image emblem = new Image(this.getDisplay(), this.origEmblem
- .getImageData().scaledTo((int) (width * betterFactor),
- (int) (height * betterFactor)));
+ BufferedImage awt_image = ImageConverter.convertToAWT(this.origEmblem.getImageData());
+
+ java.awt.Image scaled_awt = awt_image.getScaledInstance((int) (width * betterFactor),
+ (int) (height * betterFactor), java.awt.Image.SCALE_SMOOTH);
+
+ BufferedImage scaled_buffered = new BufferedImage((int) (width * betterFactor),
+ (int) (height * betterFactor), BufferedImage.TYPE_INT_RGB);
+ scaled_buffered.getGraphics().drawImage(scaled_awt, 0, 0, null);
+
+ Image emblem = new Image(this.getDisplay(), ImageConverter.convertToSWT(scaled_buffered));
Image old = this.lblEmblem.getImage();
@@ -172,6 +183,8 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
this.lblEmblem.setText(""); //$NON-NLS-1$
this.lblEmblem.setImage(emblem);
+ } else {
+ this.lblEmblem.setImage(null);
}
}
@@ -189,40 +202,43 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
}
}
- try {
- this.configurationContainer.setEmblem(filename);
-
- if (filename == null || filename.trim().equals("")) { //$NON-NLS-1$
- return;
- }
+ this.configurationContainer.setEmblem(filename);
+ this.setVisibleImage();
+ this.doLayout();
+ }
- // this.txtEmblemFile.setText();
+ void setVisibleImage() {
+ String image = this.configurationContainer.getEmblem();
+ ImageData img = null;
+ try {
- this.emblemFile = this.configurationContainer.getEmblem();
- if (this.origEmblem != null) {
- this.origEmblem.dispose();
+ if (image == null || image.trim().equals("")) { //$NON-NLS-1$
+ if (this.signer != null) {
+ img = ImageConverter.convertToSWT((BufferedImage) this.signer
+ .getPDFSigner().newParameter().getPlaceholder());
+ }
+ } else {
+ if (this.signer != null) {
+ SignatureParameter param = this.signer.getPDFSigner()
+ .newParameter();
+ param.setEmblem(new FileNameEmlbem(image));
+ img = ImageConverter.convertToSWT((BufferedImage) param
+ .getPlaceholder());
+ } else {
+ img = new ImageData(image);
+ }
}
-
- this.origEmblem = new Image(this.getDisplay(), new ImageData(
- filename));
-
- this.lblEmblem.setText(""); //$NON-NLS-1$
-
- this.recalculateEmblemSize();
} catch (Exception e) {
- this.lblEmblem
- .setText(Messages.getString("simple_config.EmblemEmpty")); //$NON-NLS-1$
- this.lblEmblem.setImage(null);
- if (this.origEmblem != null) {
- this.origEmblem.dispose();
- }
+ log.error("Failed to load image for display...", e); //$NON-NLS-1$
+ }
+
+ if (img != null) {
+ this.origEmblem = new Image(this.getDisplay(), img);
+ } else {
this.origEmblem = null;
- throw e;
}
- // this.lblEmblem.pack();
- // this.lblEmblem.getParent().pack();
- this.doLayout();
+ this.recalculateEmblemSize();
}
void processEmblemChanged(String filename) {
@@ -231,7 +247,7 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
plainEmblemSetter(filename);
} catch (Exception ex) {
log.error("processEmblemChanged: ", ex); //$NON-NLS-1$
- ErrorDialog dialog = new ErrorDialog(getShell(), SWT.NONE,
+ ErrorDialog dialog = new ErrorDialog(getShell(), SWT.NONE,
Messages.getString("error.FailedToLoadEmblem"), ex, false); //$NON-NLS-1$
dialog.open();
}
@@ -242,9 +258,9 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
* @throws Exception
*/
private void plainEmblemSetter(String filename) throws Exception {
- this.emblemFile = filename;
+ //this.emblemFile = filename;
this.setEmblemFileInternal(filename);
- this.btnUseImage.setSelection(true);
+ // this.btnClearImage.setSelection(true);
}
void processNumberChanged() {
@@ -253,12 +269,20 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
plainMobileNumberSetter();
} catch (Exception ex) {
this.txtMobileNumberErrorMarker.setVisible(true);
- this.txtMobileNumberErrorMarker
- .setToolTipText(Messages.getString("error.InvalidPhoneNumber")); //$NON-NLS-1$
+ this.txtMobileNumberErrorMarker.setToolTipText(Messages
+ .getString("error.InvalidPhoneNumber")); //$NON-NLS-1$
log.error("processNumberChanged: ", ex); //$NON-NLS-1$
}
}
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.composites.BaseConfigurationComposite#signerChanged()
+ */
+ @Override
+ protected void signerChanged() {
+ this.setVisibleImage();
+ }
+
/**
* @throws InvalidNumberException
*/
@@ -355,23 +379,28 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
fd_grpHandySignatur.top = new FormAttachment(0, 5);
fd_grpHandySignatur.bottom = new FormAttachment(20, -5);
grpHandySignatur.setLayoutData(fd_grpHandySignatur);
- grpHandySignatur.setText(Messages.getString("simple_config.MobileBKU_Title")); //$NON-NLS-1$
+ grpHandySignatur.setText(Messages
+ .getString("simple_config.MobileBKU_Title")); //$NON-NLS-1$
grpHandySignatur.setLayout(new GridLayout(2, false));
- FontData[] fD_grpHandySignatur = grpHandySignatur.getFont().getFontData();
+ FontData[] fD_grpHandySignatur = grpHandySignatur.getFont()
+ .getFontData();
fD_grpHandySignatur[0].setHeight(TEXT_SIZE_NORMAL);
- grpHandySignatur.setFont(new Font(Display.getCurrent(), fD_grpHandySignatur[0]));
-
+ grpHandySignatur.setFont(new Font(Display.getCurrent(),
+ fD_grpHandySignatur[0]));
+
Label lblMobileNumber = new Label(grpHandySignatur, SWT.NONE
| SWT.RESIZE);
lblMobileNumber.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false,
false, 1, 1));
- lblMobileNumber.setText(Messages.getString("simple_config.PhoneNumber")); //$NON-NLS-1$
+ lblMobileNumber
+ .setText(Messages.getString("simple_config.PhoneNumber")); //$NON-NLS-1$
FontData[] fD_lblMobileNumber = lblMobileNumber.getFont().getFontData();
fD_lblMobileNumber[0].setHeight(TEXT_SIZE_NORMAL);
- lblMobileNumber.setFont(new Font(Display.getCurrent(), fD_lblMobileNumber[0]));
-
+ lblMobileNumber.setFont(new Font(Display.getCurrent(),
+ fD_lblMobileNumber[0]));
+
Composite composite_2 = new Composite(grpHandySignatur, SWT.NONE);
composite_2.setLayout(new FormLayout());
composite_2.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false,
@@ -396,10 +425,12 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
this.txtMobileNumberErrorMarker
.setLayoutData(this.fd_txtMobileNumberErrorMarker);
- FontData[] fD_txtMobileNumber = this.txtMobileNumber.getFont().getFontData();
+ FontData[] fD_txtMobileNumber = this.txtMobileNumber.getFont()
+ .getFontData();
fD_txtMobileNumber[0].setHeight(TEXT_SIZE_NORMAL);
- this.txtMobileNumber.setFont(new Font(Display.getCurrent(), fD_txtMobileNumber[0]));
-
+ this.txtMobileNumber.setFont(new Font(Display.getCurrent(),
+ fD_txtMobileNumber[0]));
+
this.txtMobileNumber.addTraverseListener(new TraverseListener() {
@Override
@@ -410,7 +441,8 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
}
});
- this.txtMobileNumber.setMessage(Messages.getString("simple_config.ExampleNumber")); //$NON-NLS-1$
+ this.txtMobileNumber.setMessage(Messages
+ .getString("simple_config.ExampleNumber")); //$NON-NLS-1$
this.txtMobileNumber.addFocusListener(new FocusAdapter() {
@@ -427,50 +459,73 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
fd_grpBildmarke.bottom = new FormAttachment(65, -5);
fd_grpBildmarke.top = new FormAttachment(20, 5);
grpBildmarke.setLayoutData(fd_grpBildmarke);
- grpBildmarke.setLayout(new GridLayout(5, false));
-
+ grpBildmarke.setLayout(new FormLayout());
+
FontData[] fD_grpBildmarke = grpBildmarke.getFont().getFontData();
fD_grpBildmarke[0].setHeight(TEXT_SIZE_NORMAL);
- grpBildmarke.setFont(new Font(Display.getCurrent(), fD_grpBildmarke[0]));
-
+ grpBildmarke
+ .setFont(new Font(Display.getCurrent(), fD_grpBildmarke[0]));
+
grpBildmarke.setText(Messages.getString("simple_config.Emblem_Title")); //$NON-NLS-1$
- new Label(grpBildmarke, SWT.NONE);
- new Label(grpBildmarke, SWT.NONE);
- this.lblEmblem = new Label(grpBildmarke, SWT.RESIZE);
- this.lblEmblem.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
- true, 3, 1));
- this.lblEmblem.setAlignment(SWT.CENTER);
- this.lblEmblem
- .setText(Messages.getString("simple_config.EmblemEmpty")); //$NON-NLS-1$
- this.lblEmblem.addListener(SWT.Resize, new Listener() {
+ Composite containerComposite = new Composite(grpBildmarke, SWT.NONE);
+ containerComposite.setLayout(new FormLayout());
+ FormData fd_containerComposite = new FormData();
+ fd_containerComposite.left = new FormAttachment(0);
+ fd_containerComposite.right = new FormAttachment(100);
+ fd_containerComposite.top = new FormAttachment(0);
+ fd_containerComposite.bottom = new FormAttachment(100);
+ containerComposite.setLayoutData(fd_containerComposite);
+ containerComposite.addPaintListener(new PaintListener() {
@Override
- public void handleEvent(Event event) {
- SimpleConfigurationComposite.this.recalculateEmblemSize();
- }
- });
-
- this.lblEmblem.addPaintListener(new PaintListener() {
-
- @Override
public void paintControl(PaintEvent e) {
- //e.gc.setForeground();
- e.gc.setForeground(new Color(getDisplay(),0x6B, 0xA5, 0xD9));
+ // e.gc.setForeground();
+ e.gc.setForeground(new Color(getDisplay(),0xB4, 0xCD, 0xEC));
e.gc.setLineWidth(3);
e.gc.setLineStyle(SWT.LINE_DASH);
- e.gc.drawRoundRectangle(e.x,
- e.y, e.width - 2, e.height - 2,
+ e.gc.drawRoundRectangle(e.x, e.y, e.width - 2, e.height - 2,
10, 10);
}
});
+ this.lblEmblem = new Label(containerComposite, SWT.RESIZE);
+
+ Label lbl_drop = new Label(containerComposite, SWT.NATIVE);
+ lbl_drop.setText(Messages.getString("simple_config.EmblemEmpty"));
+ this.btnClearImage = new Button(containerComposite, SWT.NATIVE);
+
+ FormData fd_lbl_drop = new FormData();
+ // fd_lbl_drop.left = new FormAttachment(0);
+ fd_lbl_drop.right = new FormAttachment(100, -20);
+ // fd_lbl_drop.top = new FormAttachment(0, 20);
+ fd_lbl_drop.bottom = new FormAttachment(50, -10);
+
+ lbl_drop.setLayoutData(fd_lbl_drop);
+
+ FormData fd_lblEmblem = new FormData();
+ fd_lblEmblem.left = new FormAttachment(0, 20);
+ fd_lblEmblem.right = new FormAttachment(lbl_drop, -20);
+ fd_lblEmblem.top = new FormAttachment(0, 20);
+ fd_lblEmblem.bottom = new FormAttachment(100, -20);
+
+ this.lblEmblem.setLayoutData(fd_lblEmblem);
+ this.lblEmblem.setAlignment(SWT.CENTER);
+
+ this.lblEmblem.addListener(SWT.Resize, new Listener() {
+
+ @Override
+ public void handleEvent(Event event) {
+ SimpleConfigurationComposite.this.recalculateEmblemSize();
+ }
+ });
+
FontData[] fD_lblEmblem = this.lblEmblem.getFont().getFontData();
fD_lblEmblem[0].setHeight(TEXT_SIZE_NORMAL);
this.lblEmblem.setFont(new Font(Display.getCurrent(), fD_lblEmblem[0]));
-
- DropTarget dnd_target = new DropTarget(this.lblEmblem, DND.DROP_DEFAULT
- | DND.DROP_COPY);
+
+ DropTarget dnd_target = new DropTarget(containerComposite,
+ DND.DROP_DEFAULT | DND.DROP_COPY);
final FileTransfer fileTransfer = FileTransfer.getInstance();
Transfer[] types = new Transfer[] { fileTransfer };
dnd_target.setTransfer(types);
@@ -531,47 +586,44 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
}
});
- new Label(grpBildmarke, SWT.NONE);
- new Label(grpBildmarke, SWT.NONE);
-
- this.btnUseImage = new Button(grpBildmarke, SWT.CHECK);
- this.btnUseImage.setText(Messages.getString("simple_config.UseEmblem")); //$NON-NLS-1$
- this.btnUseImage.addSelectionListener(new SelectionAdapter() {
+ this.btnClearImage.setText(Messages
+ .getString("simple_config.ClearEmblem")); //$NON-NLS-1$
+ this.btnClearImage.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- if (SimpleConfigurationComposite.this.btnUseImage
- .getSelection()) {
- processEmblemChanged(SimpleConfigurationComposite.this.emblemFile);
- } else {
- try {
- SimpleConfigurationComposite.this.configurationContainer
- .setEmblem(null);
- } catch (InvalidEmblemFile e1) {
- // This exception should not occur!
- log.error("Failed to load emblem", e1); //$NON-NLS-1$
- }
- }
+ SimpleConfigurationComposite.this.processEmblemChanged(null);
}
});
- new Label(grpBildmarke, SWT.NONE);
-
-
- FontData[] fD_btnUseImage = this.btnUseImage.getFont().getFontData();
+ FontData[] fD_btnUseImage = this.btnClearImage.getFont().getFontData();
fD_btnUseImage[0].setHeight(TEXT_SIZE_BUTTON);
- this.btnUseImage.setFont(new Font(Display.getCurrent(), fD_btnUseImage[0]));
-
- Button btnBrowseEmblem = new Button(grpBildmarke, SWT.NONE);
- btnBrowseEmblem.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER,
- false, false, 1, 1));
+ this.btnClearImage.setFont(new Font(Display.getCurrent(),
+ fD_btnUseImage[0]));
+
+ Button btnBrowseEmblem = new Button(containerComposite, SWT.NONE);
+
+ FormData fd_btnUseImage = new FormData();
+
+ fd_btnUseImage.top = new FormAttachment(50, 10);
+ fd_btnUseImage.right = new FormAttachment(btnBrowseEmblem, -10);
+
+ this.btnClearImage.setLayoutData(fd_btnUseImage);
+
+ FormData fd_btnBrowseEmblem = new FormData();
+
+ fd_btnBrowseEmblem.top = new FormAttachment(50, 10);
+ fd_btnBrowseEmblem.right = new FormAttachment(100, -20);
+
+ btnBrowseEmblem.setLayoutData(fd_btnBrowseEmblem);
btnBrowseEmblem.addSelectionListener(new ImageFileBrowser());
btnBrowseEmblem.setText(Messages.getString("common.browse")); //$NON-NLS-1$
FontData[] fD_btnBrowseEmblem = btnBrowseEmblem.getFont().getFontData();
fD_btnBrowseEmblem[0].setHeight(TEXT_SIZE_BUTTON);
- btnBrowseEmblem.setFont(new Font(Display.getCurrent(), fD_btnBrowseEmblem[0]));
-
+ btnBrowseEmblem.setFont(new Font(Display.getCurrent(),
+ fD_btnBrowseEmblem[0]));
+
Group grpProxy = new Group(this, SWT.NONE);
FormData fd_grpProxy = new FormData();
fd_grpProxy.right = new FormAttachment(100, -5);
@@ -585,7 +637,7 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
FontData[] fD_grpProxy = grpProxy.getFont().getFontData();
fD_grpProxy[0].setHeight(TEXT_SIZE_NORMAL);
grpProxy.setFont(new Font(Display.getCurrent(), fD_grpProxy[0]));
-
+
Label lblNewLabel = new Label(grpProxy, SWT.NONE);
GridData gd_lblNewLabel = new GridData(SWT.LEFT, SWT.CENTER, false,
false, 1, 1);
@@ -597,7 +649,7 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
FontData[] fD_lblNewLabel = lblNewLabel.getFont().getFontData();
fD_lblNewLabel[0].setHeight(TEXT_SIZE_NORMAL);
lblNewLabel.setFont(new Font(Display.getCurrent(), fD_lblNewLabel[0]));
-
+
Composite composite = new Composite(grpProxy, SWT.NONE);
composite.setLayout(new FormLayout());
composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false,
@@ -611,8 +663,9 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
FontData[] fD_txtProxyHost = this.txtProxyHost.getFont().getFontData();
fD_txtProxyHost[0].setHeight(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(composite, SWT.NONE, null,
"", this.txtProxyHost); //$NON-NLS-1$
@@ -625,7 +678,8 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
this.proxyHostErrorMarker.setVisible(false);
this.txtProxyHost.setLayoutData(fd_txtProxyHost);
- this.txtProxyHost.setMessage(Messages.getString("simple_config.ProxyHostTemplate")); //$NON-NLS-1$
+ this.txtProxyHost.setMessage(Messages
+ .getString("simple_config.ProxyHostTemplate")); //$NON-NLS-1$
this.txtProxyHost.addFocusListener(new FocusAdapter() {
@@ -651,8 +705,9 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
FontData[] fD_lblNewLabel_1 = lblNewLabel_1.getFont().getFontData();
fD_lblNewLabel_1[0].setHeight(TEXT_SIZE_NORMAL);
- lblNewLabel_1.setFont(new Font(Display.getCurrent(), fD_lblNewLabel_1[0]));
-
+ lblNewLabel_1.setFont(new Font(Display.getCurrent(),
+ fD_lblNewLabel_1[0]));
+
Composite composite_1 = new Composite(grpProxy, SWT.NONE);
composite_1.setLayout(new FormLayout());
composite_1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false,
@@ -665,11 +720,12 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
this.fd_txtProxyPort.right = new FormAttachment(100, -42);
this.fd_txtProxyPort.bottom = new FormAttachment(100);
this.txtProxyPort.setLayoutData(this.fd_txtProxyPort);
-
+
FontData[] fD_txtProxyPort = this.txtProxyPort.getFont().getFontData();
fD_txtProxyPort[0].setHeight(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
@@ -690,7 +746,8 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
.setLayoutData(this.fd_txtProxyPortErrorMarker);
this.txtProxyPortErrorMarker.setVisible(false);
- this.txtProxyPort.setMessage(Messages.getString("simple_config.ProxyPortTemplate")); //$NON-NLS-1$
+ this.txtProxyPort.setMessage(Messages
+ .getString("simple_config.ProxyPortTemplate")); //$NON-NLS-1$
this.txtProxyPort.addFocusListener(new FocusAdapter() {
@@ -745,7 +802,7 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
FormData fd_txtMobileNumber;
FormData fd_txtProxyPort;
ErrorMarker txtProxyPortErrorMarker;
- Button btnUseImage;
+ Button btnClearImage;
/*
* (non-Javadoc)
@@ -778,10 +835,13 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
this.emblemFile = emblemFile;
try {
this.setEmblemFileInternal(emblemFile, true);
- this.btnUseImage.setSelection(true);
+ this.btnClearImage.setSelection(true);
} catch (Exception e1) {
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$
+ ErrorDialog dialog = new ErrorDialog(
+ getShell(),
+ SWT.NONE,
+ Messages.getString("error.FailedToLoadEmblem"), e1, false); //$NON-NLS-1$
dialog.open();
}
}
@@ -796,6 +856,8 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
if (host != null) {
this.txtProxyHost.setText(host);
}
+
+ this.setVisibleImage();
}
/*
diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/ConfigurationUIState.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/ConfigurationUIState.java
index 333b82d5..d8ddc403 100644
--- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/ConfigurationUIState.java
+++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/ConfigurationUIState.java
@@ -37,6 +37,7 @@ public class ConfigurationUIState extends State {
.getLogger(ConfigurationUIState.class);
+
private ConfigurationComposite configurationComposite = null;
private ConfigurationComposite getConfigurationComposite() {
@@ -45,6 +46,7 @@ public class ConfigurationUIState extends State {
this.stateMachine.getGUIProvider().createComposite(ConfigurationComposite.class, SWT.RESIZE, this);
this.configurationComposite.setConfigManipulator(this.stateMachine.getConfigManipulator());
this.configurationComposite.setConfigProvider(this.stateMachine.getConfigProvider());
+ this.configurationComposite.setSigner(this.stateMachine.getPDFSigner());
}
return this.configurationComposite;
diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OpenState.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OpenState.java
index cafcc64e..bc8a9e83 100644
--- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OpenState.java
+++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OpenState.java
@@ -52,7 +52,7 @@ public class OpenState extends State {
this.selectionComposite =
this.stateMachine.getGUIProvider().createComposite(DataSourceSelectComposite.class, SWT.RESIZE, this);
}
-
+
return this.selectionComposite;
}