summaryrefslogtreecommitdiff
path: root/pdf-over-gui/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'pdf-over-gui/src/main')
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SimpleConfigurationComposite.java57
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ErrorMarker.java110
2 files changed, 44 insertions, 123 deletions
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 84a97e9c..2e3e7e81 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
@@ -164,18 +164,18 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
this.txtMobileNumber = new Text(compMobileNumerContainer, SWT.BORDER | SWT.RESIZE);
this.fd_txtMobileNumber = new FormData();
- this.fd_txtMobileNumber.top = new FormAttachment(0);
this.fd_txtMobileNumber.left = new FormAttachment(0, 5);
this.fd_txtMobileNumber.right = new FormAttachment(100, -42);
+ this.fd_txtMobileNumber.top = new FormAttachment(0);
this.txtMobileNumber.setLayoutData(this.fd_txtMobileNumber);
+
this.txtMobileNumberErrorMarker = new ErrorMarker(compMobileNumerContainer,
- SWT.NATIVE, null, "", this.txtMobileNumber); //$NON-NLS-1$
+ SWT.NONE, ""); //$NON-NLS-1$
this.txtMobileNumberErrorMarker.setVisible(false);
this.fd_txtMobileNumberErrorMarker = new FormData();
- this.fd_txtMobileNumberErrorMarker.top = new FormAttachment(0);
- this.fd_txtMobileNumberErrorMarker.left = new FormAttachment(100, -32);
this.fd_txtMobileNumberErrorMarker.right = new FormAttachment(100);
+ this.fd_txtMobileNumberErrorMarker.top = new FormAttachment(0);
this.txtMobileNumberErrorMarker
.setLayoutData(this.fd_txtMobileNumberErrorMarker);
@@ -410,6 +410,7 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
fd_cmbSignatureLang.left = new FormAttachment(0, 10);
fd_cmbSignatureLang.right = new FormAttachment(100, -10);
fd_cmbSignatureLang.top = new FormAttachment(0, 10);
+ fd_cmbSignatureLang.bottom = new FormAttachment(100, -10);
this.cmbSignatureLang.setLayoutData(fd_cmbSignatureLang);
FontData[] fD_cmbSignatureLang = this.cmbSignatureLang.getFont()
@@ -563,14 +564,13 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
this.txtProxyHost.setFont(new Font(Display.getCurrent(),
fD_txtProxyHost[0]));
- this.proxyHostErrorMarker = new ErrorMarker(compProxyHostContainer, SWT.NONE, null,
- "", this.txtProxyHost); //$NON-NLS-1$
+ this.proxyHostErrorMarker = new ErrorMarker(compProxyHostContainer, SWT.NONE, ""); //$NON-NLS-1$
- FormData fd_marker = new FormData();
- fd_marker.right = new FormAttachment(100, -32);
- fd_marker.top = new FormAttachment(0);
+ FormData fd_proxyHostErrorMarker = new FormData();
+ fd_proxyHostErrorMarker.right = new FormAttachment(100);
+ fd_proxyHostErrorMarker.top = new FormAttachment(0);
- this.proxyHostErrorMarker.setLayoutData(fd_marker);
+ this.proxyHostErrorMarker.setLayoutData(fd_proxyHostErrorMarker);
this.proxyHostErrorMarker.setVisible(false);
this.txtProxyHost.setLayoutData(fd_txtProxyHost);
@@ -628,11 +628,10 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
}
});
- this.txtProxyPortErrorMarker = new ErrorMarker(compProxyPortContainer, SWT.NATIVE,
- null, "", this.txtProxyPort); //$NON-NLS-1$
+ this.txtProxyPortErrorMarker = new ErrorMarker(compProxyPortContainer, SWT.NONE, ""); //$NON-NLS-1$
this.fd_txtProxyPortErrorMarker = new FormData();
+ this.fd_txtProxyPortErrorMarker.right = new FormAttachment(100);
this.fd_txtProxyPortErrorMarker.top = new FormAttachment(0);
- this.fd_txtProxyPortErrorMarker.left = new FormAttachment(100, -32);
this.txtProxyPortErrorMarker
.setLayoutData(this.fd_txtProxyPortErrorMarker);
this.txtProxyPortErrorMarker.setVisible(false);
@@ -647,38 +646,6 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite {
// Load localized strings
reloadResources();
-
- this.addListener(SWT.Resize, new Listener() {
- @Override
- public void handleEvent(Event event) {
-
- // Number resize with error Marker
-
- Point numberSize = new Point(
- SimpleConfigurationComposite.this.txtMobileNumber
- .getSize().y,
- SimpleConfigurationComposite.this.txtMobileNumber
- .getSize().y);
- SimpleConfigurationComposite.this.txtMobileNumberErrorMarker
- .resize(numberSize);
- SimpleConfigurationComposite.this.fd_txtMobileNumberErrorMarker.left = new FormAttachment(
- 100, -1 * numberSize.y);
- SimpleConfigurationComposite.this.fd_txtMobileNumber.right = new FormAttachment(
- 100, -1 * (numberSize.y + 10));
-
- Point portSize = new Point(
- SimpleConfigurationComposite.this.txtProxyPort
- .getSize().y,
- SimpleConfigurationComposite.this.txtProxyPort
- .getSize().y);
- SimpleConfigurationComposite.this.txtProxyPortErrorMarker
- .resize(numberSize);
- SimpleConfigurationComposite.this.fd_txtProxyPortErrorMarker.left = new FormAttachment(
- 100, -1 * portSize.y);
- SimpleConfigurationComposite.this.fd_txtProxyPort.right = new FormAttachment(
- 100, -1 * (portSize.y + 10));
- }
- });
}
/**
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ErrorMarker.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ErrorMarker.java
index 01505895..655a0975 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ErrorMarker.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ErrorMarker.java
@@ -18,11 +18,12 @@ package at.asit.pdfover.gui.controls;
// Imports
import java.io.InputStream;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
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.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -30,7 +31,7 @@ import org.slf4j.LoggerFactory;
/**
*
*/
-public class ErrorMarker {
+public class ErrorMarker extends Label {
/**
* SLF4J Logger instance
@@ -39,89 +40,42 @@ public class ErrorMarker {
private static final Logger log = LoggerFactory
.getLogger(ErrorMarker.class);
- private Label lbl;
-
- /**
- * @param parent
- * @param style
- * @param exception
- * @param message
- * @param control
- */
- public ErrorMarker(Composite parent, int style, Throwable exception,
- String message, Control control) {
- //super(parent, style);
-
- this.lbl = new Label(parent, style);
-
- String imgPath = "/img/error.png"; //$NON-NLS-1$
-
- InputStream stream = this.getClass().getResourceAsStream(imgPath);
-
- Point size = control.getSize();
+ private static final String IMG_PATH = "/img/error.png"; //$NON-NLS-1$
- int width = size.x == 0 ? 32 : size.x;
- int height = size.y == 0 ? 32 : size.y;
-
- this.lbl.setSize(new Point(width, height));
-
- this.orig = new Image(this.lbl.getDisplay(), new ImageData(stream).scaledTo(width, height));
+ Image errorImg;
- this.lbl.setToolTipText(message);
-
- this.lbl.setImage(this.orig);
- }
-
- /**
- * Sets the layout data
- * @param object the layout data
- */
- public void setLayoutData(Object object) {
- this.lbl.setLayoutData(object);
- }
-
/**
- * Sets the visibilty
- * @param visible the visibilty
+ * Draw an error marker for a faulty entry
+ * @param parent the parent composite
+ * @param style the SWT style
+ * @param message a message describing the error (can be set later through setToolTipText)
*/
- public void setVisible(boolean visible) {
- this.lbl.setVisible(visible);
- }
+ public ErrorMarker(Composite parent, int style,
+ String message) {
+ super(parent, style);
+
+ InputStream stream = this.getClass().getResourceAsStream(IMG_PATH);
- /**
- * Sets the tooltip text
- * @param msg the tooltip text
- */
- public void setToolTipText(String msg) {
- this.lbl.setToolTipText(msg);
- }
-
-
- /**
- * Scales the image to the new size
- * @param size
- */
- public void resize(Point size) {
- String imgPath = "/img/error.png"; //$NON-NLS-1$
+ this.errorImg = new Image(getDisplay(), new ImageData(stream));
+ this.addPaintListener(new PaintListener() {
+ @Override
+ public void paintControl(PaintEvent e) {
+ Image img = ErrorMarker.this.errorImg;
+ Rectangle imgSize = img.getBounds();
+ Rectangle dstSize = ErrorMarker.this.getBounds();
+ e.gc.fillRectangle(0, 0, dstSize.width, dstSize.height);
+ e.gc.drawImage(img, 0, 0, imgSize.width, imgSize.height,
+ 0, 0, dstSize.width, dstSize.height);
+ }
+ });
- InputStream stream = this.getClass().getResourceAsStream(imgPath);
-
- int width = size.x == 0 ? 32 : size.x;
- int height = size.y == 0 ? 32 : size.y;
+ setToolTipText(message);
- this.orig = new Image(this.lbl.getDisplay(), new ImageData(stream).scaledTo(width, height));
-
- this.lbl.setSize(size);
- this.lbl.setImage(this.orig);
+ setImage(this.errorImg);
}
- /**
- * Gets the size of the underlying label
- * @return the size
- */
- public Point getSize() {
- return this.lbl.getSize();
+ @Override
+ protected void checkSubclass() {
+ // Allow subclassing
}
-
- private Image orig;
}