diff options
author | tkellner <tkellner@3a0b52a2-8410-0410-bc02-ff6273a87459> | 2012-10-01 08:30:39 +0000 |
---|---|---|
committer | tkellner <tkellner@3a0b52a2-8410-0410-bc02-ff6273a87459> | 2012-10-01 08:30:39 +0000 |
commit | de9cabd09b90c701a2c41ce761ac199c5a4a20a6 (patch) | |
tree | 8578151320171a2f17377f8ef23e7bc02e41749f /trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls | |
parent | 99cc7141f302e16ec4a22e95e95015f74f09e894 (diff) | |
download | pdf-over-de9cabd09b90c701a2c41ce761ac199c5a4a20a6.tar.gz pdf-over-de9cabd09b90c701a2c41ce761ac199c5a4a20a6.tar.bz2 pdf-over-de9cabd09b90c701a2c41ce761ac199c5a4a20a6.zip |
Working on Configuration UI. (still work in progress!)
git-svn-id: https://svn.iaik.tugraz.at/svn/egiz/prj/current/12PDF-OVER-4.0@12533 3a0b52a2-8410-0410-bc02-ff6273a87459
Diffstat (limited to 'trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls')
-rw-r--r-- | trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ErrorMarker.java | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ErrorMarker.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ErrorMarker.java new file mode 100644 index 00000000..11cefa13 --- /dev/null +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ErrorMarker.java @@ -0,0 +1,109 @@ +/* + * 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.controls; + +// Imports +import java.io.InputStream; + +import org.eclipse.swt.events.PaintEvent; +import org.eclipse.swt.events.PaintListener; +import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.ImageData; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.widgets.Canvas; +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; + +/** + * + */ +public class ErrorMarker { + + /** + * SLF4J Logger instance + **/ + private static final Logger log = LoggerFactory + .getLogger(ErrorMarker.class); + + private Label lbl; + + /** + * @param parent + * @param style + * @param exception + * @param message + */ + 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(); + + 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)); + + this.lbl.setToolTipText(message); + + this.lbl.setImage(this.orig); + } + + public void setLayoutData(Object object) { + this.lbl.setLayoutData(object); + } + + public void setVisible(boolean visible) { + this.lbl.setVisible(visible); + } + + public void setToolTipText(String msg) { + this.lbl.setToolTipText(msg); + } + + + public void resize(Point size) { + String imgPath = "/img/error.png"; //$NON-NLS-1$ + + InputStream stream = this.getClass().getResourceAsStream(imgPath); + + int width = size.x == 0 ? 32 : size.x; + int height = size.y == 0 ? 32 : size.y; + + this.orig = new Image(this.lbl.getDisplay(), new ImageData(stream).scaledTo(width, height)); + + this.lbl.setSize(size); + this.lbl.setImage(this.orig); + } + + public Point getSize() { + return this.lbl.getSize(); + } + + private Image orig; +} |