summaryrefslogtreecommitdiff
path: root/BKUCommonGUI/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'BKUCommonGUI/src/main')
-rw-r--r--BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIFacade.java1
-rw-r--r--BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/DefaultHelpListener.java62
-rw-r--r--BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/HashDataViewer.java15
-rw-r--r--BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/HelpViewer.java5
-rw-r--r--BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/ImagePanel.java4
-rw-r--r--BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/SimpleGUI.java6
-rw-r--r--BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/html/RestrictedHTMLEditorKit.java49
-rw-r--r--BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/html/RestrictedImageView.java67
-rw-r--r--BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages.properties4
-rw-r--r--BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages_en.properties3
-rw-r--r--BKUCommonGUI/src/main/resources/images/help.pngbin303 -> 441 bytes
-rw-r--r--BKUCommonGUI/src/main/resources/images/help_orig.pngbin0 -> 303 bytes
12 files changed, 207 insertions, 9 deletions
diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIFacade.java b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIFacade.java
index c7032f90..87982c79 100644
--- a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIFacade.java
+++ b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIFacade.java
@@ -89,6 +89,7 @@ public interface BKUGUIFacade {
public static final String BUTTON_SAVE = "button.save";
public static final String BUTTON_CLOSE = "button.close";
public static final String SAVE_HASHDATAINPUT_PREFIX = "save.hashdatainput.prefix";
+ public static final String ALT_HELP = "alt.help";
public void init(Container contentPane, Locale locale, URL background, ActionListener helpListener);
diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/DefaultHelpListener.java b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/DefaultHelpListener.java
new file mode 100644
index 00000000..ba968a48
--- /dev/null
+++ b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/DefaultHelpListener.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2008 Federal Chancellery Austria and
+ * Graz University of Technology
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package at.gv.egiz.bku.gui;
+
+import java.applet.AppletContext;
+import java.net.URL;
+import java.util.Locale;
+import javax.swing.SwingUtilities;
+
+/**
+ *
+ * @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at>
+ */
+public class DefaultHelpListener extends AbstractHelpListener {
+
+ protected AppletContext ctx;
+
+ public DefaultHelpListener(AppletContext ctx, URL helpURL, Locale locale) {
+ super(helpURL, locale);
+ this.ctx = ctx;
+ }
+
+ public DefaultHelpListener(URL helpURL, Locale locale) {
+ super(helpURL, locale);
+ this.ctx = null;
+ }
+
+ @Override
+ public void showDocument(final URL helpURL, final String helpTopic) throws Exception {
+ log.debug("schedule help dialog");
+
+ SwingUtilities.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+
+ log.debug("show help dialog");
+
+ if (ctx == null) {
+ HelpViewer.showHelpDialog(helpURL, helpTopic, messages);
+
+ } else {
+ HelpViewer.showHelpDialog(ctx, helpURL, helpTopic, messages);
+ }
+ }
+ });
+ }
+}
diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/HashDataViewer.java b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/HashDataViewer.java
index 8883098a..31887bde 100644
--- a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/HashDataViewer.java
+++ b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/HashDataViewer.java
@@ -16,6 +16,7 @@
*/
package at.gv.egiz.bku.gui;
+import at.gv.egiz.bku.gui.html.RestrictedHTMLEditorKit;
import at.gv.egiz.stal.HashDataInput;
import java.awt.Component;
import java.awt.Container;
@@ -23,6 +24,7 @@ import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Frame;
+import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
@@ -47,6 +49,11 @@ import javax.swing.JScrollPane;
import javax.swing.LayoutStyle;
import javax.swing.text.Document;
import javax.swing.text.EditorKit;
+import javax.swing.text.Element;
+import javax.swing.text.ViewFactory;
+import javax.swing.text.html.HTML;
+import javax.swing.text.html.HTMLEditorKit;
+import javax.swing.text.html.ImageView;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -184,11 +191,14 @@ public class HashDataViewer extends JDialog
}
JEditorPane viewer = new JEditorPane();
- viewer.setEditable(false);
- viewer.setContentType(mimeType);
+
if ("text/plain".equals(mimeType)) {
viewer.setFont(new Font(PLAINTEXT_FONT, viewer.getFont().getStyle(), viewer.getFont().getSize()));
+// } else if ("text/html".equals(mimeType)) {
+// viewer.setEditorKitForContentType("text/html", new RestrictedHTMLEditorKit());
}
+ viewer.setEditable(false);
+ viewer.setContentType(mimeType);
EditorKit editorKit = viewer.getEditorKit();
Document document = editorKit.createDefaultDocument();
@@ -220,6 +230,7 @@ public class HashDataViewer extends JDialog
if (helpListener != null) {
JLabel helpLabel = new JLabel();
helpLabel.setIcon(new ImageIcon(getClass().getResource(BKUGUIFacade.HELP_IMG)));
+ helpLabel.getAccessibleContext().setAccessibleName(messages.getString(BKUGUIFacade.ALT_HELP));
helpLabel.addMouseListener(new MouseAdapter() {
@Override
diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/HelpViewer.java b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/HelpViewer.java
index 42ca2090..173254e7 100644
--- a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/HelpViewer.java
+++ b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/HelpViewer.java
@@ -16,7 +16,6 @@
*/
package at.gv.egiz.bku.gui;
-import at.gv.egiz.bku.gui.*;
import java.applet.AppletContext;
import java.awt.Component;
import java.awt.Container;
@@ -30,7 +29,6 @@ import java.net.URL;
import java.text.MessageFormat;
import java.util.ResourceBundle;
import javax.swing.GroupLayout;
-import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JEditorPane;
@@ -136,6 +134,7 @@ public class HelpViewer extends JDialog
final JEditorPane viewer = new JEditorPane();
viewer.setEditable(false);
try {
+ viewer.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
viewer.setPage(helpURL);
viewer.addHyperlinkListener(new HyperlinkListener() {
@@ -165,7 +164,7 @@ public class HelpViewer extends JDialog
String p = messages.getString(BKUGUIFacade.ERR_VIEWER);
viewer.setText(MessageFormat.format(p, new Object[]{ex.getMessage()}));
}
-
+ viewer.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
JScrollPane scrollPane = new JScrollPane(viewer);
scrollPane.setPreferredSize(viewer.getPreferredSize());
scrollPane.setAlignmentX(LEFT_ALIGNMENT);
diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/ImagePanel.java b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/ImagePanel.java
index 1185cf53..271c0b65 100644
--- a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/ImagePanel.java
+++ b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/ImagePanel.java
@@ -24,8 +24,8 @@ import javax.swing.ImageIcon;
import javax.swing.JPanel;
/**
- *
- * @author clemens
+ *
+ * @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at>
*/
public class ImagePanel extends JPanel {
diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/SimpleGUI.java b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/SimpleGUI.java
index a810d34c..bb568b75 100644
--- a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/SimpleGUI.java
+++ b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/SimpleGUI.java
@@ -158,6 +158,11 @@ public class SimpleGUI implements BKUGUIFacade {
if (background == null) {
background = this.getClass().getResource(DEFAULT_BACKGROUND);
}
+ if ("file".equals(background.getProtocol())) {
+ log.warn("local background image not allowed: " + background);
+ background = this.getClass().getResource(DEFAULT_BACKGROUND);
+ }
+ log.debug("loading background " + background);
contentPanel = new ImagePanel(background);
// contentPanel.setBorder(new TitledBorder("content"));
@@ -179,6 +184,7 @@ public class SimpleGUI implements BKUGUIFacade {
helpLabel = new JLabel();
helpLabel.setIcon(new ImageIcon(getClass().getResource(HELP_IMG)));
+ helpLabel.getAccessibleContext().setAccessibleName(messages.getString(ALT_HELP));
helpLabel.addMouseListener(helpListener);
helpLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/html/RestrictedHTMLEditorKit.java b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/html/RestrictedHTMLEditorKit.java
new file mode 100644
index 00000000..680bf1a4
--- /dev/null
+++ b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/html/RestrictedHTMLEditorKit.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2008 Federal Chancellery Austria and
+ * Graz University of Technology
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package at.gv.egiz.bku.gui.html;
+
+import javax.swing.text.Element;
+import javax.swing.text.StyleConstants;
+import javax.swing.text.View;
+import javax.swing.text.html.HTML;
+import javax.swing.text.html.HTMLEditorKit;
+
+/**
+ *
+ * @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at>
+ */
+public class RestrictedHTMLEditorKit extends HTMLEditorKit {
+
+
+ public static class RestrictedHTMLFactory extends HTMLFactory {
+
+ @Override
+ public View create(Element elem) {
+ Object o =
+ elem.getAttributes().getAttribute(StyleConstants.NameAttribute);
+ if (o instanceof HTML.Tag) {
+ HTML.Tag kind = (HTML.Tag) o;
+ if (kind == HTML.Tag.IMG)
+ return new RestrictedImageView(elem);
+ }
+ return super.create( elem );
+ }
+
+ }
+
+}
diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/html/RestrictedImageView.java b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/html/RestrictedImageView.java
new file mode 100644
index 00000000..b1aa35db
--- /dev/null
+++ b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/html/RestrictedImageView.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2008 Federal Chancellery Austria and
+ * Graz University of Technology
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package at.gv.egiz.bku.gui.html;
+
+import javax.swing.text.Element;
+import javax.swing.text.html.HTML;
+import javax.swing.text.html.ImageView;
+
+/**
+ *
+ * @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at>
+ */
+/**
+ * ImageViewer.refreshImage() (and loadImage()) is private :-(
+ */
+ public class RestrictedImageView extends ImageView {
+
+ public RestrictedImageView(Element elem) {
+ super(elem);
+ }
+
+// @Override
+// public Image getImage() {
+// int s = state;
+// if ((s & RELOAD_IMAGE_FLAG) != 0) {
+// refreshImage();
+// }
+// s = state;
+// if ((s & RELOAD_FLAG) != 0) {
+// synchronized(this) {
+// state = (state | RELOAD_FLAG) ^ RELOAD_FLAG;
+// }
+// setPropertiesFromAttributes();
+// }
+// return super.getImage();
+// }
+
+ /**
+ * check whether this URL corresponds to the data URI scheme
+ * (and the referenced content is directly included in the document).
+ * @return
+ */
+ private boolean isDataURI() {
+ String src = (String)getElement().getAttributes().
+ getAttribute(HTML.Attribute.SRC);
+ if (src == null) {
+ return false;
+ }
+
+ return src.toLowerCase().startsWith("data");
+ }
+ } \ No newline at end of file
diff --git a/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages.properties b/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages.properties
index 6c049c85..5f62c05a 100644
--- a/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages.properties
+++ b/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages.properties
@@ -31,7 +31,8 @@ message.wait=<html>Bitte warten...</html>
message.insertcard=<html>Bitte die B\u00FCrgerkarte in den Kartenleser stecken</html>
message.enterpin=<html>{0} eingeben</html>
message.hashdatalink=<html><a href=\"anzeige\">Signaturdaten anzeigen</a></html>
-message.hashdata=<html>Dies ist eine Voransicht des zu signierenden Inhaltes. F\u00FCr Details siehe Hilfe.</html>
+message.hashdata=<html>Hinweis: Dies ist eine Voransicht des zu signierenden Inhalts. F\u00FCr eine standardkonforme Darstellung siehe Hilfe (i).</html>
+#message.hashdata=<html>Dies ist eine Voransicht des zu signierenden Inhaltes. F\u00FCr Details siehe Hilfe (i).</html>
#verwenden sie bitte die von ihrem System zur Verf\u00FCgung gestellte {0} Anwendung.
message.hashdatalist=<html>{0} Signaturdaten:</html>
message.retries=<html>Noch {0} Versuch(e)</html>
@@ -52,6 +53,7 @@ mimetype.desc.txt=Textdateien (.txt)
mimetype.desc.pdf=Adobe PDF-Dateien (.pdf)
mimetype.desc.bin=Bin\u00E4rdateien (.bin)
save.hashdatainput.prefix=Signaturdaten
+alt.help=Hilfe
# Error Messages
error.no.hashdata=<html>Keine Signaturdaten verf\u00FCgbar: {0}</html>
diff --git a/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages_en.properties b/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages_en.properties
index 80dc4234..d963fd5f 100644
--- a/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages_en.properties
+++ b/BKUCommonGUI/src/main/resources/at/gv/egiz/bku/gui/Messages_en.properties
@@ -31,7 +31,7 @@ message.wait=<html>Please wait...</html>
message.insertcard=<html>Please insert your citizen-card into the reader</html>
message.enterpin=<html>Enter {0}</html>
message.hashdatalink=<html><a href=\"anzeige\">Display signature data</a></html>
-message.hashdata=<html>Signature data:</html>
+message.hashdata=<html>Remark: This is a preview of the data to-be signed. For standards compliant display see help.</html>
message.hashdatalist=<html>{0} signature data objects:</html>
message.retries=<html>{0} tries left</html>
message.overwrite=<html>Overwrite {0}?</html>
@@ -51,6 +51,7 @@ mimetype.desc.txt=Textfiles (.txt)
mimetype.desc.pdf=Adobe PDF-files (.pdf)
mimetype.desc.bin=Binary files (.bin)
save.hashdatainput.prefix=signaturedata
+alt.help=help
# Error Messages
error.no.hashdata=<html>No signature data available: {0}</html>
diff --git a/BKUCommonGUI/src/main/resources/images/help.png b/BKUCommonGUI/src/main/resources/images/help.png
index 5d6da3bf..d1c36c33 100644
--- a/BKUCommonGUI/src/main/resources/images/help.png
+++ b/BKUCommonGUI/src/main/resources/images/help.png
Binary files differ
diff --git a/BKUCommonGUI/src/main/resources/images/help_orig.png b/BKUCommonGUI/src/main/resources/images/help_orig.png
new file mode 100644
index 00000000..5d6da3bf
--- /dev/null
+++ b/BKUCommonGUI/src/main/resources/images/help_orig.png
Binary files differ