summaryrefslogtreecommitdiff
path: root/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites
diff options
context:
space:
mode:
authortkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7>2013-04-10 18:59:29 +0000
committertkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7>2013-04-10 18:59:29 +0000
commite60e1df5284c93b25cf6f6a477b924850dffb9d5 (patch)
tree86a8bec1e0bcac482b742174a87d1a1190a405f8 /pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites
parentac47a525b1338100c7489ec60fed24ce10f57394 (diff)
downloadpdf-over-e60e1df5284c93b25cf6f6a477b924850dffb9d5.tar.gz
pdf-over-e60e1df5284c93b25cf6f6a477b924850dffb9d5.tar.bz2
pdf-over-e60e1df5284c93b25cf6f6a477b924850dffb9d5.zip
UI Improvements
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-over/trunk@69 174cde9d-5d70-4d2a-aa98-46368bc2aaf7
Diffstat (limited to 'pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites')
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/DataSourceSelectComposite.java74
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUEnterTANComposite.java15
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/OutputComposite.java131
3 files changed, 170 insertions, 50 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/DataSourceSelectComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/DataSourceSelectComposite.java
index 1784988a..ccc7121a 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/DataSourceSelectComposite.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/DataSourceSelectComposite.java
@@ -25,21 +25,23 @@ import org.eclipse.swt.dnd.DropTargetAdapter;
import org.eclipse.swt.dnd.DropTargetEvent;
import org.eclipse.swt.dnd.FileTransfer;
import org.eclipse.swt.dnd.Transfer;
+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.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
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.Composite;
import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -125,14 +127,31 @@ public class DataSourceSelectComposite extends StateComposite {
// Color back = new Color(Display.getCurrent(), 77, 190, 250);
- this.drop_area = new Composite(this, SWT.RESIZE | SWT.BORDER);
+ this.drop_area = new Composite(this, SWT.RESIZE);
FormData fd_drop_area = new FormData();
- fd_drop_area.left = new FormAttachment(0, 0);
- fd_drop_area.right = new FormAttachment(100, 0);
- fd_drop_area.top = new FormAttachment(0, 0);
- fd_drop_area.bottom = new FormAttachment(100, 0);
+ fd_drop_area.left = new FormAttachment(0, 30);
+ fd_drop_area.right = new FormAttachment(100, -30);
+ fd_drop_area.top = new FormAttachment(0, 30);
+ fd_drop_area.bottom = new FormAttachment(100, -30);
this.drop_area.setLayoutData(fd_drop_area);
this.drop_area.setLayout(new FormLayout());
+
+ this.drop_area.addPaintListener(new PaintListener() {
+
+ @Override
+ public void paintControl(PaintEvent e) {
+ Rectangle clientArea = DataSourceSelectComposite.this
+ .drop_area.getClientArea();
+
+ e.gc.setForeground(new Color(getDisplay(), 0x76, 0xC4, 0xC8));
+ e.gc.setLineStyle(SWT.LINE_DASH);
+ e.gc.drawRoundRectangle(clientArea.x,
+ clientArea.y, clientArea.width - 2, clientArea.height - 2,
+ 10, 10);
+ }
+ });
+
+ //this.drop_area.
// this.drop_area.setBackground(back);
DropTarget dnd_target = new DropTarget(this.drop_area, DND.DROP_DEFAULT
@@ -198,22 +217,42 @@ public class DataSourceSelectComposite extends StateComposite {
}
});
+ final Label lbl_drag2 = new Label(this.drop_area, SWT.NONE | SWT.RESIZE );
+
final Label lbl_drag = new Label(this.drop_area, SWT.NONE | SWT.RESIZE );
this.fd_lbl_drag = new FormData();
this.fd_lbl_drag.left = new FormAttachment(0, 10);
this.fd_lbl_drag.right = new FormAttachment(100, -10);
- this.fd_lbl_drag.top = new FormAttachment(0, 10);
- // fd_lbl_drag.bottom = new FormAttachment(100, -10);
+ //this.fd_lbl_drag.top = new FormAttachment(40, -10);
+ this.fd_lbl_drag.bottom = new FormAttachment(lbl_drag2, -10);
lbl_drag.setLayoutData(this.fd_lbl_drag);
FontData[] fD = lbl_drag.getFont().getFontData();
- fD[0].setHeight(18);
+ fD[0].setHeight(20);
lbl_drag.setFont(new Font(Display.getCurrent(), fD[0]));
lbl_drag.setText(Messages.getString("dataSourceSelection.DropLabel")); //$NON-NLS-1$
lbl_drag.setAlignment(SWT.CENTER);
+
+ this.fd_lbl_drag2 = new FormData();
+ this.fd_lbl_drag2.left = new FormAttachment(0, 10);
+ this.fd_lbl_drag2.right = new FormAttachment(100, -10);
+ this.fd_lbl_drag2.top = new FormAttachment(50, -10);
+ // fd_lbl_drag.bottom = new FormAttachment(100, -10);
+ lbl_drag2.setLayoutData(this.fd_lbl_drag2);
+ FontData[] fD2 = lbl_drag2.getFont().getFontData();
+ fD2[0].setHeight(12);
+ lbl_drag2.setFont(new Font(Display.getCurrent(), fD2[0]));
+ lbl_drag2.setText(Messages.getString("dataSourceSelection.DropLabel2")); //$NON-NLS-1$
+ lbl_drag2.setAlignment(SWT.CENTER);
+
final Button btn_open = new Button(this.drop_area, SWT.NATIVE | SWT.RESIZE);
- btn_open.setText(Messages.getString("common.browse")); //$NON-NLS-1$
+ btn_open.setText(Messages.getString("dataSourceSelection.browse")); //$NON-NLS-1$
+
+ FontData[] fD_open = btn_open.getFont().getFontData();
+ fD_open[0].setHeight(14);
+ btn_open.setFont(new Font(Display.getCurrent(), fD_open[0]));
+ /*
lbl_drag.addListener(SWT.Resize, new Listener() {
@Override
@@ -234,14 +273,16 @@ public class DataSourceSelectComposite extends StateComposite {
50, (lbl_drag.getSize().y / 2) + 10 + size.y);
}
});
+ */
// lbl_drag.setBackground(back);
Point size = btn_open.computeSize(SWT.DEFAULT, SWT.DEFAULT);
this.fd_btn_open = new FormData();
- this.fd_btn_open.left = new FormAttachment(100, size.x * -1 - 10);
- this.fd_btn_open.right = new FormAttachment(100, -5);
- this.fd_btn_open.top = new FormAttachment(100, size.y * -1 - 10);
- this.fd_btn_open.bottom = new FormAttachment(100, -5);
+ this.fd_btn_open.left = new FormAttachment(50, (size.x / 2 ) * -1);
+ //this.fd_btn_open.right = new FormAttachment(100, -5);
+ //this.fd_btn_open.top = new FormAttachment(100, size.y * -1 - 10);
+ this.fd_btn_open.top = new FormAttachment(lbl_drag2, 10);
+ //this.fd_btn_open.bottom = new FormAttachment(100, -5);
btn_open.setLayoutData(this.fd_btn_open);
// btn_open.setBackground(back);
@@ -251,9 +292,10 @@ public class DataSourceSelectComposite extends StateComposite {
private boolean press = false;
- private Composite drop_area;
+ Composite drop_area;
FormData fd_lbl_drag;
+ FormData fd_lbl_drag2;
FormData fd_btn_open;
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUEnterTANComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUEnterTANComposite.java
index f19ee361..9f232ca0 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUEnterTANComposite.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUEnterTANComposite.java
@@ -17,6 +17,8 @@ package at.asit.pdfover.gui.composites;
// Imports
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.FormAttachment;
@@ -204,6 +206,19 @@ public class MobileBKUEnterTANComposite extends StateComposite {
this.txt_tan.setEditable(true);
this.txt_tan.setLayoutData(fd_text);
+ this.txt_tan.addModifyListener(new ModifyListener() {
+
+ @Override
+ public void modifyText(ModifyEvent e) {
+
+ String text = MobileBKUEnterTANComposite.this.txt_tan.getText();
+
+ if(text.length() > 3 && MobileBKUEnterTANComposite.this.getVergleichswert().startsWith(text.trim())) {
+ MobileBKUEnterTANComposite.this.setMessage(Messages.getString("error.EnteredReferenceValue")); //$NON-NLS-1$
+ }
+ }
+ });
+
this.lbl_tries = new Label(this, SWT.WRAP | SWT.NATIVE);
FormData fd_lbl_tries = new FormData();
fd_lbl_tries.left = new FormAttachment(15, 5);
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 1b24b678..cf579b7b 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
@@ -18,8 +18,11 @@ 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;
@@ -28,7 +31,9 @@ import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Listener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -45,8 +50,66 @@ public class OutputComposite extends StateComposite {
/**
* SLF4J Logger instance
**/
- static final Logger log = LoggerFactory
- .getLogger(OutputComposite.class);
+ static final Logger log = LoggerFactory.getLogger(OutputComposite.class);
+
+ private File inputFile;
+
+ /**
+ * 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;
+ }
+
+ /**
+ * Saves the file
+ *
+ * @throws IOException
+ */
+ void saveFile() throws IOException {
+ FileDialog save = new FileDialog(OutputComposite.this.getShell(),
+ SWT.SAVE | SWT.NATIVE);
+ save.setFilterExtensions(new String[] { "*.pdf" }); //$NON-NLS-1$
+ save.setFilterNames(new String[] { Messages
+ .getString("common.PDFExtension_Description") }); //$NON-NLS-1$
+
+ String proposed = OutputComposite.this.getInputFile().getAbsolutePath();
+
+ String extension = FilenameUtils.getExtension(proposed);
+
+ proposed = FilenameUtils.removeExtension(proposed);
+
+ proposed = proposed + "_signed." + extension; //$NON-NLS-1$
+
+ save.setFileName(proposed);
+
+ String target = save.open();
+
+ if (target != null) {
+ File targetFile = new File(target);
+
+ DocumentSource source = OutputComposite.this.getSignedDocument();
+
+ FileOutputStream outstream = new FileOutputStream(targetFile);
+ outstream.write(source.getByteArray(), 0,
+ source.getByteArray().length);
+ outstream.close();
+
+ OutputComposite.this.savedFile = targetFile;
+ }
+ }
/**
* SelectionListener for save button
@@ -61,24 +124,7 @@ public class OutputComposite extends StateComposite {
@Override
public void widgetSelected(SelectionEvent e) {
try {
- FileDialog save = new FileDialog(OutputComposite.this.getShell(), SWT.SAVE | SWT.NATIVE);
- save.setFilterExtensions(new String[] {"*.pdf"}); //$NON-NLS-1$
- save.setFilterNames(new String[] {Messages.getString("common.PDFExtension_Description")}); //$NON-NLS-1$
-
- String target = save.open();
-
- File targetFile = new File(target);
-
- DocumentSource source = OutputComposite.this
- .getSignedDocument();
-
- FileOutputStream outstream = new FileOutputStream(targetFile);
- outstream.write(source.getByteArray(), 0,
- source.getByteArray().length);
- outstream.close();
-
- OutputComposite.this.savedFile = targetFile;
-
+ OutputComposite.this.saveFile();
} catch (Exception ex) {
log.error("SaveSelectionListener: ", ex); //$NON-NLS-1$
}
@@ -105,9 +151,11 @@ public class OutputComposite extends StateComposite {
File open = OutputComposite.this.savedFile;
if (open == null) {
// Save as temp file ...
- java.util.Date date= new java.util.Date();
- String fileName = String.format("%d_tmp_signed.pdf", date.getTime()); //$NON-NLS-1$
- open = new File(OutputComposite.this.tempDirectory + "/" + fileName); //$NON-NLS-1$
+ java.util.Date date = new java.util.Date();
+ String fileName = String.format(
+ "%d_tmp_signed.pdf", date.getTime()); //$NON-NLS-1$
+ open = new File(OutputComposite.this.tempDirectory
+ + "/" + fileName); //$NON-NLS-1$
FileOutputStream outstream = new FileOutputStream(open);
outstream.write(source.getByteArray(), 0,
source.getByteArray().length);
@@ -121,9 +169,11 @@ public class OutputComposite extends StateComposite {
}
} else {
log.error("OutputComposite:OpenSelectionListener:widgetSelected -> source is null!!"); //$NON-NLS-1$
- ErrorDialog dialog = new ErrorDialog(getShell(),
- SWT.NONE, Messages.getString("error.FailedToGetSignedDocument"),//$NON-NLS-1$
- "", false); //$NON-NLS-1$
+ ErrorDialog dialog = new ErrorDialog(
+ getShell(),
+ SWT.NONE,
+ Messages.getString("error.FailedToGetSignedDocument"),//$NON-NLS-1$
+ "", false); //$NON-NLS-1$
dialog.open();
}
} catch (Exception ex) {
@@ -155,10 +205,10 @@ public class OutputComposite extends StateComposite {
btn_open.setText(Messages.getString("common.open")); //$NON-NLS-1$
// Point mobile_size = btn_mobile.computeSize(SWT.DEFAULT, SWT.DEFAULT);
FormData fd_btn_open = new FormData();
- //fd_btn_open.left = new FormAttachment(40, 0);
+ // fd_btn_open.left = new FormAttachment(40, 0);
fd_btn_open.right = new FormAttachment(50, -5);
fd_btn_open.top = new FormAttachment(40, 0);
- //fd_btn_open.bottom = new FormAttachment(55, 0);
+ // fd_btn_open.bottom = new FormAttachment(55, 0);
btn_open.setLayoutData(fd_btn_open);
btn_open.addSelectionListener(new OpenSelectionListener());
@@ -171,26 +221,27 @@ public class OutputComposite extends StateComposite {
// Point card_size = btn_card.computeSize(SWT.DEFAULT, SWT.DEFAULT);
FormData fd_btn_save = new FormData();
fd_btn_save.left = new FormAttachment(50, 5);
- //fd_btn_save.right = new FormAttachment(60, 0);
+ // fd_btn_save.right = new FormAttachment(60, 0);
fd_btn_save.top = new FormAttachment(40, 0);
- //fd_btn_save.bottom = new FormAttachment(55, 0);
+ // fd_btn_save.bottom = new FormAttachment(55, 0);
btn_save.setLayoutData(fd_btn_save);
btn_save.addSelectionListener(new SaveSelectionListener());
- this.pack();
+ //this.pack();
}
String tempDirectory;
-
+
/**
* @param tempDirectory
*/
public void setTempDirectory(String tempDirectory) {
this.tempDirectory = tempDirectory;
}
-
+
/**
* Gets the signed document
+ *
* @return the signed document
*/
public DocumentSource getSignedDocument() {
@@ -199,7 +250,9 @@ public class OutputComposite extends StateComposite {
/**
* Sets the signed document
- * @param signedDocument the signed document
+ *
+ * @param signedDocument
+ * the signed document
*/
public void setSignedDocument(final DocumentSource signedDocument) {
this.signedDocument = signedDocument;
@@ -210,6 +263,8 @@ public class OutputComposite extends StateComposite {
// Disable the check that prevents subclassing of SWT components
}
+ private boolean save_showed = false;
+
/*
* (non-Javadoc)
*
@@ -218,6 +273,14 @@ public class OutputComposite extends StateComposite {
@Override
public void doLayout() {
// Nothing to do
+ try {
+ if (!this.save_showed) {
+ OutputComposite.this.saveFile();
+ this.save_showed = true;
+ }
+ } catch (Exception ex) {
+ log.error("SaveSelectionListener: ", ex); //$NON-NLS-1$
+ }
}
}