diff options
author | clemenso <clemenso@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4> | 2008-09-30 16:37:59 +0000 |
---|---|---|
committer | clemenso <clemenso@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4> | 2008-09-30 16:37:59 +0000 |
commit | 8ccd9ab69dc74762567930f4c576a359502f1071 (patch) | |
tree | 2f8d79a57801758a4c34a2f3129fc15785ea54a0 /BKUCommonGUI/src | |
parent | d0879e9058943c6afa1912ccbeae936db2811f26 (diff) | |
download | mocca-8ccd9ab69dc74762567930f4c576a359502f1071.tar.gz mocca-8ccd9ab69dc74762567930f4c576a359502f1071.tar.bz2 mocca-8ccd9ab69dc74762567930f4c576a359502f1071.zip |
showErrorDialog l10n
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@77 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
Diffstat (limited to 'BKUCommonGUI/src')
4 files changed, 69 insertions, 30 deletions
diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUI.java b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUI.java index 749207ee..b09669b8 100644 --- a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUI.java +++ b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUI.java @@ -41,6 +41,8 @@ import java.util.List; import java.util.Locale; import java.util.ResourceBundle; import java.util.StringTokenizer; +import java.util.logging.Level; +import java.util.logging.Logger; import javax.swing.GroupLayout; import javax.swing.ImageIcon; import javax.swing.JButton; @@ -94,7 +96,7 @@ public class BKUGUI implements BKUGUIFacade { private static final String MESSAGE_OVERWRITE = "message.overwrite"; private static final String LABEL_PIN = "label.pin"; private static final String LABEL_PINSIZE = "label.pinsize"; - private static final String ERROR_NO_HASHDATA = "error.no.hashdata"; +// private static final String ERROR_NO_HASHDATA = "error.no.hashdata"; private static final String BUTTON_OK = "button.ok"; private static final String BUTTON_CANCEL = "button.cancel"; @@ -798,7 +800,7 @@ public class BKUGUI implements BKUGUIFacade { } @Override - public void showErrorDialog(final String errorMsg, final ActionListener okListener, final String okCommand) { + public void showErrorDialog(final String errorMsgKey, final Object[] errorMsgParams, final ActionListener okListener, final String okCommand) { log.debug("scheduling error dialog"); @@ -815,9 +817,12 @@ public class BKUGUI implements BKUGUIFacade { titleLabel.setText(messages.getString(TITLE_ERROR)); // titleLabel.setForeground(defaultForground); + String errorMsgPattern = messages.getString(errorMsgKey); + String errorMsg = MessageFormat.format(errorMsgPattern, errorMsgParams); + JLabel errorMsgLabel = new JLabel(); errorMsgLabel.setFont(errorMsgLabel.getFont().deriveFont(errorMsgLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); - errorMsgLabel.setText("<html>" + errorMsg + "</html>"); + errorMsgLabel.setText(errorMsg); errorMsgLabel.setForeground(ERROR_COLOR); GroupLayout mainPanelLayout = new GroupLayout(mainPanel); @@ -860,7 +865,7 @@ public class BKUGUI implements BKUGUIFacade { } @Override - public void showErrorDialog(final String errorMsg) { + public void showErrorDialog(final String errorMsgKey, final Object[] errorMsgParams) { log.debug("scheduling error dialog"); @@ -877,10 +882,13 @@ public class BKUGUI implements BKUGUIFacade { titleLabel.setText(messages.getString(TITLE_ERROR)); // titleLabel.setForeground(defaultForground); - JLabel errorMsgLabel = new JLabel(); - errorMsgLabel.setFont(errorMsgLabel.getFont().deriveFont(errorMsgLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); - errorMsgLabel.setText("<html>" + errorMsg + "</html>"); - errorMsgLabel.setForeground(ERROR_COLOR); + String errorMsgPattern = messages.getString(errorMsgKey); + String errorMsg = MessageFormat.format(errorMsgPattern, errorMsgParams); + + JLabel errorMsgLabel = new JLabel(); + errorMsgLabel.setFont(errorMsgLabel.getFont().deriveFont(errorMsgLabel.getFont().getStyle() & ~java.awt.Font.BOLD)); + errorMsgLabel.setText(errorMsg); + errorMsgLabel.setForeground(ERROR_COLOR); GroupLayout mainPanelLayout = new GroupLayout(mainPanel); mainPanel.setLayout(mainPanelLayout); @@ -955,7 +963,7 @@ public class BKUGUI implements BKUGUIFacade { public void showHashDataInputDialog(final List<HashDataInput> signedReferences, final ActionListener okListener, final String okCommand) { if (signedReferences == null) { - showErrorDialog(messages.getString(ERROR_NO_HASHDATA), okListener, okCommand); + showErrorDialog(messages.getString(ERR_NO_HASHDATA), new Object[] {"No SignedReferences provided"}, okListener, okCommand); } if (signedReferences.size() == 1) { @@ -971,11 +979,12 @@ public class BKUGUI implements BKUGUIFacade { showSaveHashDataInputDialog(signedReferences, okListener, okCommand); } }; - String hashDataText = getText(signedReferences.get(0)); - if (hashDataText != null) { + + try { + String hashDataText = getText(signedReferences.get(0)); showPlainTextHashDataInputDialog(hashDataText, saveHashDataListener, "save", okListener, okCommand); - } else { - showErrorDialog(messages.getString(ERROR_NO_HASHDATA), okListener, okCommand); + } catch (IOException ex) { + showErrorDialog(messages.getString(ERR_NO_HASHDATA), new Object[] {ex.getMessage()}, okListener, okCommand); } } else { @@ -1300,7 +1309,7 @@ public class BKUGUI implements BKUGUIFacade { bos.close(); } catch (IOException ex) { log.error("Failed to write HashDataInput to file " + file + ": " + ex.getMessage()); - showErrorDialog("Failed to write signed reference to file: " + ex.getMessage(), null, null); + showErrorDialog(ERR_WRITE_HASHDATA, new Object[] {ex.getMessage()}, null, null); ex.printStackTrace(); } finally { try { @@ -1316,7 +1325,7 @@ public class BKUGUI implements BKUGUIFacade { }); } - private static String getText(HashDataInput hdi) { + private static String getText(HashDataInput hdi) throws IOException { ByteArrayOutputStream baos = null; try { InputStream hashDataIS = hdi.getHashDataInput(); @@ -1338,7 +1347,7 @@ public class BKUGUI implements BKUGUIFacade { } } catch (IOException ex) { log.error("Failed to read HashDataInput for reference " + hdi.getReferenceId() + ": " + ex.getMessage()); - return null; + throw ex; } finally { try { baos.close(); 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 f4b6325d..32eb4c3e 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 @@ -23,7 +23,15 @@ import java.awt.event.ActionListener; import java.util.List; public interface BKUGUIFacade { - + + public static final String ERR_UNKNOWN = "error.unknown"; + public static final String ERR_SERVICE_UNREACHABLE = "error.ws.unreachable"; + public static final String ERR_NO_PCSC = "error.pcsc"; + public static final String ERR_NO_CARDTERMINAL = "error.cardterminal"; + public static final String ERR_NO_HASHDATA = "error.no.hashdata"; + public static final String ERR_WRITE_HASHDATA = "error.write.hashdata"; + public static final String ERR_INVALID_HASH = "error.invalid.hash"; + public void init(Container contentPane, String localeString); public void showWelcomeDialog(); @@ -55,7 +63,7 @@ public interface BKUGUIFacade { // public void showPlainTextHashDataInputDialog(String text, ActionListener saveListener, String saveCommand, ActionListener cancelListener, String cancelCommand); - public void showErrorDialog(String errorMsg, ActionListener okListener, String actionCommand); + public void showErrorDialog(String errorMsgKey, Object[] errorMsgParams, ActionListener okListener, String actionCommand); - public void showErrorDialog(String errorMsg); + public void showErrorDialog(String errorMsgKey, Object[] errorMsgParams); } 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 a329ba86..79e23859 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 @@ -35,7 +35,6 @@ message.retries=<html>Noch {0} Versuche</html> message.overwrite=<html>M\u00F6chten Sie das existierende Dokument {0} \u00FCberschreiben?</html> label.pin=<html>{0}:</html> label.pinsize=<html>({0} stellig)</html> -error.no.hashdata=<html>Keine Signaturdaten verf\u00FCgbar</html> button.ok=OK button.cancel=Abbrechen button.back=Zur\u00FCck @@ -48,3 +47,13 @@ mimetype.desc.txt=Textdateien (.txt) mimetype.desc.pdf=Adobe PDF-Dateien (.pdf) mimetype.desc.bin=Bin\u00E4rdateien (.bin) save.hashdatainput.prefix=Signaturdaten + +# Error Messages +error.no.hashdata=<html>Keine Signaturdaten verf\u00FCgbar: {0}</html> +error.write.hashdata=<html>Die Signaturdaten konnten nicht gespeichert werden: {0}</html> +error.invalid.hash=<html>Die Signaturdaten sind ung\u00FCltig: {0}</html> +error.ws.unreachable=<html>Das Web-Service ist nicht erreichbar: {0}</html> +error.pcsc=<html>Java(TM) scheint keine PC/SC Schnittstelle f\u00FCr den Smartcard-Zugriff zur Verf\u00FCgung zu stellen.</html> +error.cardterminal=<html>Es konnte kein Smartcard-Leser gefunden werden.<p>Entweder ist kein Leser angeschlossen oder kein PC/SC Treiber installiert.</p></html> +error.unknown=<html>Leider trat ein Fehler auf: {0}</html> +error.test=<html>Fehler1 {0} - Fehler2 {1}</html>
\ No newline at end of file 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 909da4ad..0641bf58 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 @@ -186,13 +186,13 @@ public class BKUGUIWorker implements Runnable { // // Thread.sleep(2000); - gui.showWaitDialog(null); - - Thread.sleep(1000); - - gui.showWaitDialog("test"); - - Thread.sleep(1000); +// gui.showWaitDialog(null); +// +// Thread.sleep(1000); +// +// gui.showWaitDialog("test"); +// +// Thread.sleep(1000); // gui.showInsertCardDialog(cancelListener, "cancel"); @@ -218,11 +218,24 @@ public class BKUGUIWorker implements Runnable { // // Thread.sleep(2000); //// - gui.showErrorDialog("Testfehler occured", null, null); - +// gui.showErrorDialog(BKUGUIFacade.ERR_UNKNOWN, new Object[] {"Testfehler"}, null, null); +// +// Thread.sleep(2000); +// + + gui.showErrorDialog("error.test", new Object[] {"Testfehler", "noch ein TestFehler"}); + Thread.sleep(2000); // - gui.showErrorDialog("Testfehler occured"); + gui.showErrorDialog("error.no.hashdata", null); + + Thread.sleep(2000); +// + gui.showErrorDialog(BKUGUIFacade.ERR_UNKNOWN, new Object[] {"Testfehler"}); + + Thread.sleep(2000); +// + gui.showErrorDialog("error.unknown", null); // gui.showTextPlainHashDataInput("hallo,\n welt!", "12345", null, "cancel", null, "save"); |