summaryrefslogtreecommitdiff
path: root/pdf-over-gui/src/main/java/at/asit
diff options
context:
space:
mode:
Diffstat (limited to 'pdf-over-gui/src/main/java/at/asit')
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/AdvancedConfigurationComposite.java10
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SimpleConfigurationComposite.java93
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ErrorDialog.java206
3 files changed, 191 insertions, 118 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/AdvancedConfigurationComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/AdvancedConfigurationComposite.java
index 19e56b68..b82150aa 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/AdvancedConfigurationComposite.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/AdvancedConfigurationComposite.java
@@ -69,16 +69,6 @@ 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$
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SimpleConfigurationComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SimpleConfigurationComposite.java
index 94d42a18..b0bfa40d 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SimpleConfigurationComposite.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SimpleConfigurationComposite.java
@@ -40,7 +40,6 @@ import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
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;
@@ -62,7 +61,6 @@ 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;
-import at.asit.pdfover.gui.exceptions.InvalidEmblemFile;
import at.asit.pdfover.gui.exceptions.InvalidNumberException;
import at.asit.pdfover.gui.exceptions.InvalidPortException;
import at.asit.pdfover.gui.workflow.ConfigurationContainer;
@@ -116,15 +114,21 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
// Text txtEmblemFile;
String emblemFile;
private Image origEmblem = null;
+ private Image origlogo = null;
void recalculateEmblemSize() {
- if (this.origEmblem != null) {
+ this.recalculateEmblemSize(this.origEmblem, this.lblEmblem);
+ this.recalculateEmblemSize(this.origlogo, this.lbl_logo);
+ }
+
+ void recalculateEmblemSize(Image image, Label parent) {
+ if (image != null) {
- int width = this.origEmblem.getBounds().width;
- int height = this.origEmblem.getBounds().height;
+ int width = image.getBounds().width;
+ int height = image.getBounds().height;
- int scaledWidth = this.lblEmblem.getSize().x;
- int scaledHeight = this.lblEmblem.getSize().y;
+ int scaledWidth = parent.getSize().x;
+ int scaledHeight = parent.getSize().y;
float scaleFactorWidth = (float) scaledWidth / (float) width;
float scaleFactorHeight = (float) scaledHeight / (float) height;
@@ -164,7 +168,7 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
betterFactor = 1.0f;
}
- BufferedImage awt_image = ImageConverter.convertToAWT(this.origEmblem.getImageData());
+ BufferedImage awt_image = ImageConverter.convertToAWT(image.getImageData());
java.awt.Image scaled_awt = awt_image.getScaledInstance((int) (width * betterFactor),
(int) (height * betterFactor), java.awt.Image.SCALE_SMOOTH);
@@ -175,16 +179,16 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
Image emblem = new Image(this.getDisplay(), ImageConverter.convertToSWT(scaled_buffered));
- Image old = this.lblEmblem.getImage();
+ Image old = parent.getImage();
if (old != null) {
old.dispose();
}
- this.lblEmblem.setText(""); //$NON-NLS-1$
- this.lblEmblem.setImage(emblem);
+ parent.setText(""); //$NON-NLS-1$
+ parent.setImage(emblem);
} else {
- this.lblEmblem.setImage(null);
+ parent.setImage(null);
}
}
@@ -210,6 +214,8 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
void setVisibleImage() {
String image = this.configurationContainer.getEmblem();
ImageData img = null;
+ ImageData logo = null;
+
try {
if (image == null || image.trim().equals("")) { //$NON-NLS-1$
@@ -227,6 +233,7 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
} else {
img = new ImageData(image);
}
+ logo = new ImageData(image);
}
} catch (Exception e) {
log.error("Failed to load image for display...", e); //$NON-NLS-1$
@@ -237,6 +244,12 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
} else {
this.origEmblem = null;
}
+
+ if (logo != null) {
+ this.origlogo = new Image(this.getDisplay(), logo);
+ } else {
+ this.origlogo = null;
+ }
this.recalculateEmblemSize();
}
@@ -272,6 +285,8 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
this.txtMobileNumberErrorMarker.setToolTipText(Messages
.getString("error.InvalidPhoneNumber")); //$NON-NLS-1$
log.error("processNumberChanged: ", ex); //$NON-NLS-1$
+ this.redraw();
+ this.doLayout();
}
}
@@ -476,7 +491,16 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
fd_containerComposite.top = new FormAttachment(0);
fd_containerComposite.bottom = new FormAttachment(100);
containerComposite.setLayoutData(fd_containerComposite);
- containerComposite.addPaintListener(new PaintListener() {
+
+ Composite controlComposite = new Composite(containerComposite, SWT.NONE);
+ controlComposite.setLayout(new FormLayout());
+ FormData fd_controlComposite = new FormData();
+ fd_controlComposite.left = new FormAttachment(0, 20);
+ fd_controlComposite.right = new FormAttachment(0, 300);
+ fd_controlComposite.top = new FormAttachment(0, 20);
+ fd_controlComposite.bottom = new FormAttachment(100, -20);
+ controlComposite.setLayoutData(fd_controlComposite);
+ controlComposite.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
@@ -488,24 +512,38 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
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);
+ Button btnBrowseEmblem = new Button(controlComposite, SWT.NONE);
+
+ Label lbl_drop = new Label(controlComposite, SWT.NATIVE);
+
+ this.lbl_logo = new Label(controlComposite, SWT.NATIVE);
+ this.lbl_logo.setAlignment(SWT.CENTER);
+ FormData fd_lbl_logo = new FormData();
+ fd_lbl_logo.left = new FormAttachment(0, 20);
+ fd_lbl_logo.right = new FormAttachment(100, -20);
+ fd_lbl_logo.top = new FormAttachment(0, 20);
+ fd_lbl_logo.bottom = new FormAttachment(lbl_drop, -20);
+
+ this.lbl_logo.setLayoutData(fd_lbl_logo);
+
+
+ lbl_drop.setText(Messages.getString("simple_config.EmblemEmpty")); //$NON-NLS-1$
+ this.btnClearImage = new Button(controlComposite, SWT.NATIVE);
FormData fd_lbl_drop = new FormData();
- // fd_lbl_drop.left = new FormAttachment(0);
+ fd_lbl_drop.left = new FormAttachment(0, 20);
fd_lbl_drop.right = new FormAttachment(100, -20);
- // fd_lbl_drop.top = new FormAttachment(0, 20);
- fd_lbl_drop.bottom = new FormAttachment(50, -10);
+ //fd_lbl_drop.top = new FormAttachment(50, -20);
+ fd_lbl_drop.bottom = new FormAttachment(btnBrowseEmblem, -20);
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.left = new FormAttachment(controlComposite, 20);
+ fd_lblEmblem.right = new FormAttachment(100, -20);
fd_lblEmblem.top = new FormAttachment(0, 20);
fd_lblEmblem.bottom = new FormAttachment(100, -20);
@@ -524,7 +562,7 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
fD_lblEmblem[0].setHeight(TEXT_SIZE_NORMAL);
this.lblEmblem.setFont(new Font(Display.getCurrent(), fD_lblEmblem[0]));
- DropTarget dnd_target = new DropTarget(containerComposite,
+ DropTarget dnd_target = new DropTarget(controlComposite,
DND.DROP_DEFAULT | DND.DROP_COPY);
final FileTransfer fileTransfer = FileTransfer.getInstance();
Transfer[] types = new Transfer[] { fileTransfer };
@@ -601,18 +639,16 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
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.bottom = new FormAttachment(100, -20);
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.bottom = new FormAttachment(100, -20);
fd_btnBrowseEmblem.right = new FormAttachment(100, -20);
btnBrowseEmblem.setLayoutData(fd_btnBrowseEmblem);
@@ -803,6 +839,7 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
FormData fd_txtProxyPort;
ErrorMarker txtProxyPortErrorMarker;
Button btnClearImage;
+ private Label lbl_logo;
/*
* (non-Javadoc)
@@ -811,7 +848,7 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
*/
@Override
public void doLayout() {
- // Nothing to do here
+ this.layout(true, true);
}
/*
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ErrorDialog.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ErrorDialog.java
index 017de3ef..6d04b33f 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ErrorDialog.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ErrorDialog.java
@@ -42,16 +42,18 @@ import at.asit.pdfover.gui.Messages;
*
*/
public class ErrorDialog extends Dialog {
+
+ private static final boolean VERBOSE_ERROR = false;
+
/**
* @param parent
* @param style
* @param message
* @param exception
- * @param canRetry
+ * @param canRetry
*/
public ErrorDialog(Shell parent, int style, String message,
- Throwable exception,
- boolean canRetry) {
+ Throwable exception, boolean canRetry) {
super(parent, style);
this.message = message;
this.canRetry = canRetry;
@@ -90,7 +92,7 @@ public class ErrorDialog extends Dialog {
private boolean canRetry = false;
boolean doRetry = false;
-
+
private String details = null;
/**
@@ -102,6 +104,7 @@ public class ErrorDialog extends Dialog {
/**
* Open error dialog
+ *
* @return if the user wants to retry the action which caused the error
*/
public boolean open() {
@@ -134,53 +137,106 @@ public class ErrorDialog extends Dialog {
lblerrorMessage.setLayoutData(fd_lblerrorMessage);
lblerrorMessage.setText(this.message);
- Group group = new Group(shell, SWT.NONE);
- group.setLayout(new FormLayout());
- FormData fd_group = new FormData();
+ if (VERBOSE_ERROR) {
- 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$
+ Group group = new Group(shell, SWT.NONE);
+ group.setLayout(new FormLayout());
+ FormData fd_group = new FormData();
- if (!this.canRetry) {
+ 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$
+ }
- 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
@@ -189,44 +245,34 @@ public class ErrorDialog extends Dialog {
}
});
- 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);
+ fd_btnCancel.top = new FormAttachment(lblerrorMessage, 10);
btnCancel.setLayoutData(fd_btnCancel);
- btnCancel.setText(Messages.getString("common.Cancel")); //$NON-NLS-1$
+ btnCancel.setText(Messages.getString("common.Ok")); //$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$
+ 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();
@@ -236,7 +282,7 @@ public class ErrorDialog extends Dialog {
if (!display.readAndDispatch())
display.sleep();
}
-
+
return this.doRetry;
}
}