From b93f035e2c9df0ad430300c4f755b775a4aa1ed3 Mon Sep 17 00:00:00 2001 From: clemenso Date: Mon, 24 Nov 2008 13:37:11 +0000 Subject: xhtml warning git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@192 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- .../main/java/at/gv/egiz/bku/gui/BKUGUIFacade.java | 3 +- .../main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java | 15 +++-- .../java/at/gv/egiz/bku/gui/HashDataViewer.java | 72 +++++++++++----------- .../at/gv/egiz/bku/gui/Messages.properties | 3 +- .../at/gv/egiz/bku/gui/Messages_en.properties | 3 +- .../test/java/at/gv/egiz/bku/gui/BKUGUITest.java | 6 +- .../test/java/at/gv/egiz/bku/gui/BKUGUIWorker.java | 5 +- 7 files changed, 59 insertions(+), 48 deletions(-) (limited to 'BKUCommonGUI') 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 7d912f11..d3cb76f2 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 @@ -62,11 +62,12 @@ public interface BKUGUIFacade { public static final String MESSAGE_INSERTCARD = "message.insertcard"; public static final String MESSAGE_ENTERPIN = "message.enterpin"; public static final String MESSAGE_HASHDATALINK = "message.hashdatalink"; - public static final String MESSAGE_HASHDATA = "message.hashdata"; +// public static final String MESSAGE_HASHDATA = "message.hashdata"; public static final String MESSAGE_HASHDATALIST = "message.hashdatalist"; public static final String MESSAGE_RETRIES = "message.retries"; public static final String MESSAGE_OVERWRITE = "message.overwrite"; public static final String MESSAGE_HELP = "message.help"; + public static final String WARNING_XHTML = "warning.xhtml"; public static final String LABEL_PIN = "label.pin"; public static final String LABEL_PINSIZE = "label.pinsize"; public static final String HELP_WELCOME = "help.welcome"; diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java index a190b9c0..c786a291 100644 --- a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java +++ b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java @@ -208,13 +208,16 @@ public class BKUGUIImpl implements BKUGUIFacade { if (background == null) { background = getClass().getResource(DEFAULT_BACKGROUND); } - if ("file".equals(background.getProtocol())) { - log.warn("file:// background images not permitted: " + background); - background = getClass().getResource(DEFAULT_BACKGROUND); + if (background == null) { + contentPanel = new JPanel(); + } else { + if ("file".equals(background.getProtocol())) { + log.warn("file:// background images not permitted: " + background); + background = getClass().getResource(DEFAULT_BACKGROUND); + } + log.debug("loading background " + background); + contentPanel = new ImagePanel(background); } - log.debug("loading background " + background); - contentPanel = new ImagePanel(background); - mainPanel = new JPanel(); mainPanel.setOpaque(false); buttonPanel = new JPanel(); 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 777e8960..6c097b2a 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 @@ -125,9 +125,7 @@ public class HashDataViewer extends JDialog InputStreamReader isr = new InputStreamReader(hashDataInput.getHashDataInput(), cs); Reader content = new BufferedReader(isr); - JPanel hashDataPanel = createViewerPanel( - messages.getString(BKUGUIFacade.MESSAGE_HASHDATA), - content, + JPanel hashDataPanel = createViewerPanel(content, hashDataInput.getMimeType(), helpListener); JPanel buttonPanel = createButtonPanel(saveListener, saveCommand); @@ -169,29 +167,28 @@ public class HashDataViewer extends JDialog * @param helpListener may be null * @return */ - private JPanel createViewerPanel(String viewerLabelText, - Reader content, + private JPanel createViewerPanel(Reader content, String mimeType, final ActionListener helpListener) { - log.debug("viewer dialog: " + mimeType); if (mimeType == null) { mimeType = "text/plain"; - } else if ("application/xhtml+xml".equals(mimeType)) { - mimeType = "text/html"; } + log.debug("viewer dialog: " + mimeType); JEditorPane viewer = new JEditorPane(); + viewer.setEditable(false); + viewer.setContentType(mimeType); if ("text/plain".equals(mimeType)) { viewer.setEditorKit(new StyledEditorKit()); viewer.setFont(new Font(PLAINTEXT_FONT, viewer.getFont().getStyle(), viewer.getFont().getSize())); // } else if ("text/html".equals(mimeType)) { // viewer.setEditorKit(new RestrictedHTMLEditorKit()); + } else if ("application/xhtml+xml".equals(mimeType)) { + viewer.setContentType("text/html"); } - viewer.setEditable(false); - viewer.setContentType(mimeType); - + EditorKit editorKit = viewer.getEditorKit(); Document document = editorKit.createDefaultDocument(); // document.putProperty("IgnoreCharsetDirective", new Boolean(true)); @@ -210,15 +207,23 @@ public class HashDataViewer extends JDialog scrollPane.setAlignmentX(LEFT_ALIGNMENT); viewer.setCaretPosition(0); - JLabel viewerLabel = new JLabel(); - viewerLabel.setText(viewerLabelText); - viewerLabel.setFont(viewerLabel.getFont().deriveFont(viewerLabel.getFont().getStyle() | java.awt.Font.BOLD)); - viewerLabel.setLabelFor(viewer); - JPanel viewerPanel = new JPanel(); GroupLayout viewerPanelLayout = new GroupLayout(viewerPanel); viewerPanel.setLayout(viewerPanelLayout); + GroupLayout.SequentialGroup infoHorizontal = viewerPanelLayout.createSequentialGroup(); + GroupLayout.ParallelGroup infoVertical = viewerPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING); + + if ("application/xhtml+xml".equals(mimeType)) { + JLabel viewerLabel = new JLabel(); + viewerLabel.setText(messages.getString(BKUGUIFacade.WARNING_XHTML)); + viewerLabel.setFont(viewerLabel.getFont().deriveFont(viewerLabel.getFont().getStyle() | java.awt.Font.BOLD)); + viewerLabel.setLabelFor(viewer); + + infoHorizontal.addComponent(viewerLabel); + infoVertical.addComponent(viewerLabel); + } + if (helpListener != null) { JLabel helpLabel = new JLabel(); helpLabel.setIcon(new ImageIcon(getClass().getResource(BKUGUIFacade.HELP_IMG))); @@ -232,27 +237,24 @@ public class HashDataViewer extends JDialog } }); helpLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); - viewerPanelLayout.setHorizontalGroup( - viewerPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(viewerPanelLayout.createSequentialGroup().addComponent(viewerLabel).addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 0, Short.MAX_VALUE).addComponent(helpLabel)).addComponent(scrollPane)); //, 0, 0, Short.MAX_VALUE)); - viewerPanelLayout.setVerticalGroup( - viewerPanelLayout.createSequentialGroup() - .addGroup(viewerPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addComponent(viewerLabel) - .addComponent(helpLabel)) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addComponent(scrollPane)); - } else { - viewerPanelLayout.setHorizontalGroup( - viewerPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addComponent(viewerLabel) - .addComponent(scrollPane)); - viewerPanelLayout.setVerticalGroup( - viewerPanelLayout.createSequentialGroup() - .addComponent(viewerLabel) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addComponent(scrollPane)); + infoHorizontal + .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 0, Short.MAX_VALUE) + .addComponent(helpLabel); + infoVertical + .addComponent(helpLabel); } + + viewerPanelLayout.setHorizontalGroup( + viewerPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addGroup(infoHorizontal) + .addComponent(scrollPane)); + viewerPanelLayout.setVerticalGroup( + viewerPanelLayout.createSequentialGroup() + .addGroup(infoVertical) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(scrollPane)); + return viewerPanel; } 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 88119fe2..a7363421 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 @@ -32,13 +32,14 @@ message.wait=Bitte warten... message.insertcard=Bitte die B\u00FCrgerkarte in den Kartenleser stecken message.enterpin={0} eingeben message.hashdatalink=Signaturdaten anzeigen -message.hashdata=Hinweis: Dies ist eine Voransicht des zu signierenden Inhalts. F\u00FCr eine standardkonforme Darstellung siehe Hilfe (i). +#message.hashdata=Hinweis: Dies ist eine Voransicht des zu signierenden Inhalts. F\u00FCr eine standardkonforme Darstellung siehe Hilfe (i). #message.hashdata=Dies ist eine Voransicht des zu signierenden Inhaltes. F\u00FCr Details siehe Hilfe (i). #verwenden sie bitte die von ihrem System zur Verf\u00FCgung gestellte {0} Anwendung. message.hashdatalist={0} Signaturdaten: message.retries=Noch {0} Versuch(e) message.overwrite=M\u00F6chten Sie das existierende Dokument {0} \u00FCberschreiben? message.help=Hilfe zu {0} +warning.xhtml=Hinweis: Dies ist eine Voransicht des zu signierenden Inhalts. F\u00FCr eine standardkonforme Darstellung siehe Hilfe (i). label.pin={0}: label.pinsize=({0} stellig) button.ok=OK 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 63c8bf77..7aae8eae 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 @@ -32,11 +32,12 @@ message.wait=Please wait... message.insertcard=Please insert your citizencard into the reader message.enterpin=Enter {0} message.hashdatalink=Display signature data -message.hashdata=Remark: This is a preview of the data to-be signed. For standards compliant display see help. +#message.hashdata=Remark: This is a preview of the data to-be signed. For standards compliant display see help. message.hashdatalist={0} signature data objects: message.retries={0} tries left message.overwrite=Overwrite {0}? message.help=Help topic {0} +warning.xhtml=Remark: This is a preview of the data to-be signed. For standards compliant display see help. label.pin={0}: label.pinsize=({0} digits) button.ok=OK diff --git a/BKUCommonGUI/src/test/java/at/gv/egiz/bku/gui/BKUGUITest.java b/BKUCommonGUI/src/test/java/at/gv/egiz/bku/gui/BKUGUITest.java index 0d2712dd..bc4bdb97 100644 --- a/BKUCommonGUI/src/test/java/at/gv/egiz/bku/gui/BKUGUITest.java +++ b/BKUCommonGUI/src/test/java/at/gv/egiz/bku/gui/BKUGUITest.java @@ -32,15 +32,15 @@ import org.junit.Test; * * @author clemens */ -//@Ignore +@Ignore public class BKUGUITest { @Test public void testBKUGUI() { JFrame testFrame = new JFrame("BKUGUITest"); Container contentPane = testFrame.getContentPane(); - contentPane.setPreferredSize(new Dimension(380, 150)); - BKUGUIFacade gui = BKUGUIFactory.createGUI(contentPane, null, BKUGUIFacade.Style.advanced, null, null); + contentPane.setPreferredSize(new Dimension(190, 130)); + BKUGUIFacade gui = BKUGUIFactory.createGUI(contentPane, null, BKUGUIFacade.Style.simple, null, null); BKUGUIWorker worker = new BKUGUIWorker(); worker.init(gui); testFrame.pack(); diff --git a/BKUCommonGUI/src/test/java/at/gv/egiz/bku/gui/BKUGUIWorker.java b/BKUCommonGUI/src/test/java/at/gv/egiz/bku/gui/BKUGUIWorker.java index fec097f5..4d97f9fb 100644 --- a/BKUCommonGUI/src/test/java/at/gv/egiz/bku/gui/BKUGUIWorker.java +++ b/BKUCommonGUI/src/test/java/at/gv/egiz/bku/gui/BKUGUIWorker.java @@ -147,10 +147,13 @@ public class BKUGUIWorker implements Runnable { // // Thread.sleep(2000); // - gui.showSignaturePINDialog(signPinSpec, signListener, "sign", cancelListener, "cancel", hashdataListener, "hashdata"); +// gui.showSignaturePINDialog(signPinSpec, signListener, "sign", cancelListener, "cancel", hashdataListener, "hashdata"); // // Thread.sleep(4000); // + + gui.showErrorDialog(BKUGUIFacade.ERR_NO_PCSC, null, null, null); + // gui.showSignaturePINRetryDialog(signPinSpec, 2, signListener, "sign", cancelListener, "cancel", hashdataListener, "hashdata"); // // Thread.sleep(2000); -- cgit v1.2.3