From de0a9b985152428c2a9c39c1252d5566648472b6 Mon Sep 17 00:00:00 2001 From: k-tamura Date: Sat, 18 Feb 2017 09:02:04 +0900 Subject: [PATCH] Improve usability --- .../easybuggy/others/IntegerOverflowServlet.java | 8 +++----- .../others/LossOfTrailingDigitsServlet.java | 14 +++++++------- .../easybuggy/others/RoundOffErrorServlet.java | 8 +++----- .../easybuggy/others/TruncationErrorServlet.java | 12 +++++------- .../easybuggy/troubles/EndlessWaitingServlet.java | 3 ++- src/main/resources/messages_en.properties | 3 ++- src/main/resources/messages_ja.properties | 9 +++++---- 7 files changed, 27 insertions(+), 30 deletions(-) diff --git a/src/main/java/org/t246osslab/easybuggy/others/IntegerOverflowServlet.java b/src/main/java/org/t246osslab/easybuggy/others/IntegerOverflowServlet.java index 84736c6c..3723d9c4 100644 --- a/src/main/java/org/t246osslab/easybuggy/others/IntegerOverflowServlet.java +++ b/src/main/java/org/t246osslab/easybuggy/others/IntegerOverflowServlet.java @@ -26,7 +26,6 @@ protected void service(HttpServletRequest req, HttpServletResponse res) throws S int days = -1; int hours = -1; PrintWriter writer = null; - String errorMessage = ""; try { Locale locale = req.getLocale(); String strDays = req.getParameter("days"); @@ -39,14 +38,14 @@ protected void service(HttpServletRequest req, HttpServletResponse res) throws S if (days >= 0) { // days * 24 => hours hours = days * 24; - } else { - errorMessage = "" + MessageUtils.getMsg("msg.enter.positive.number", locale) - + ""; } } StringBuilder bodyHtml = new StringBuilder(); bodyHtml.append("
"); + bodyHtml.append(MessageUtils.getMsg("msg.enter.positive.number", locale)); + bodyHtml.append("
"); + bodyHtml.append("
"); if (days >= 0) { bodyHtml.append(""); } else { @@ -60,7 +59,6 @@ protected void service(HttpServletRequest req, HttpServletResponse res) throws S bodyHtml.append("
"); bodyHtml.append(""); bodyHtml.append("
"); - bodyHtml.append(errorMessage); bodyHtml.append("
"); bodyHtml.append(MessageUtils.getMsg("msg.note.positive.number", new String[] { String.valueOf(Integer.MAX_VALUE / 24) }, locale)); diff --git a/src/main/java/org/t246osslab/easybuggy/others/LossOfTrailingDigitsServlet.java b/src/main/java/org/t246osslab/easybuggy/others/LossOfTrailingDigitsServlet.java index 85bdc8f3..444c89a0 100644 --- a/src/main/java/org/t246osslab/easybuggy/others/LossOfTrailingDigitsServlet.java +++ b/src/main/java/org/t246osslab/easybuggy/others/LossOfTrailingDigitsServlet.java @@ -26,7 +26,7 @@ protected void service(HttpServletRequest req, HttpServletResponse res) throws S PrintWriter writer = null; double number = Double.NaN; String strNumber = null; - String errorMessage = null; + boolean isValid = true; try { Locale locale = req.getLocale(); try { @@ -38,28 +38,28 @@ protected void service(HttpServletRequest req, HttpServletResponse res) throws S // ignore } if (Double.isNaN(number) || number <= -1 || number == 0 || 1 <= number) { - errorMessage = MessageUtils.getMsg("msg.enter.decimal.value", locale); + isValid = false; } StringBuilder bodyHtml = new StringBuilder(); bodyHtml.append(""); - if (!Double.isNaN(number) && errorMessage == null) { + bodyHtml.append(MessageUtils.getMsg("msg.enter.decimal.value", locale)); + bodyHtml.append("
"); + bodyHtml.append("
"); + if (!Double.isNaN(number) && isValid) { bodyHtml.append(""); } else { bodyHtml.append(""); } bodyHtml.append(" + 1 = "); - if (!Double.isNaN(number) && errorMessage == null) { + if (!Double.isNaN(number) && isValid) { bodyHtml.append(String.valueOf(number + 1)); } bodyHtml.append("
"); bodyHtml.append("
"); bodyHtml.append(""); bodyHtml.append("
"); - if (errorMessage != null && strNumber != null) { - bodyHtml.append("" + errorMessage + ""); - } bodyHtml.append("
"); bodyHtml.append(MessageUtils.getMsg("msg.note.enter.decimal.value", locale)); bodyHtml.append("
"); diff --git a/src/main/java/org/t246osslab/easybuggy/others/RoundOffErrorServlet.java b/src/main/java/org/t246osslab/easybuggy/others/RoundOffErrorServlet.java index 38718cfd..3a2609a6 100644 --- a/src/main/java/org/t246osslab/easybuggy/others/RoundOffErrorServlet.java +++ b/src/main/java/org/t246osslab/easybuggy/others/RoundOffErrorServlet.java @@ -26,7 +26,6 @@ protected void service(HttpServletRequest req, HttpServletResponse res) throws S PrintWriter writer = null; int number = -1; double result = 0; - String errorMessage = ""; try { Locale locale = req.getLocale(); String strNumber = req.getParameter("number"); @@ -38,14 +37,14 @@ protected void service(HttpServletRequest req, HttpServletResponse res) throws S } if (1 <= number && number <= 9) { result = number - 0.9; - } else { - errorMessage = "" + MessageUtils.getMsg("msg.enter.positive.number", locale) - + ""; } } StringBuilder bodyHtml = new StringBuilder(); bodyHtml.append("
"); + bodyHtml.append(MessageUtils.getMsg("msg.enter.positive.number", locale)); + bodyHtml.append("
"); + bodyHtml.append("
"); if (result != 0) { bodyHtml.append(""); @@ -60,7 +59,6 @@ protected void service(HttpServletRequest req, HttpServletResponse res) throws S bodyHtml.append("
"); bodyHtml.append(""); bodyHtml.append("
"); - bodyHtml.append(errorMessage); bodyHtml.append("
"); bodyHtml.append(MessageUtils.getMsg("msg.note.enter.one", locale)); bodyHtml.append("
"); diff --git a/src/main/java/org/t246osslab/easybuggy/others/TruncationErrorServlet.java b/src/main/java/org/t246osslab/easybuggy/others/TruncationErrorServlet.java index e93e7121..c84a75be 100644 --- a/src/main/java/org/t246osslab/easybuggy/others/TruncationErrorServlet.java +++ b/src/main/java/org/t246osslab/easybuggy/others/TruncationErrorServlet.java @@ -26,7 +26,6 @@ protected void service(HttpServletRequest req, HttpServletResponse res) throws S PrintWriter writer = null; double number = -1; double result = 0; - String errorMessage = ""; try { Locale locale = req.getLocale(); @@ -39,18 +38,18 @@ protected void service(HttpServletRequest req, HttpServletResponse res) throws S } if (0 < number && number < 10) { result = 10.0 / number; - } else { - errorMessage = "" + MessageUtils.getMsg("msg.enter.positive.number", locale) - + ""; } } StringBuilder bodyHtml = new StringBuilder(); bodyHtml.append("
"); + bodyHtml.append(MessageUtils.getMsg("msg.enter.positive.number", locale)); + bodyHtml.append("
"); + bodyHtml.append("
"); bodyHtml.append("10.0 " + MessageUtils.getMsg("label.obelus", locale) + " "); if (result != 0) { - bodyHtml.append(""); + bodyHtml.append( + ""); } else { bodyHtml.append(""); } @@ -62,7 +61,6 @@ protected void service(HttpServletRequest req, HttpServletResponse res) throws S bodyHtml.append("
"); bodyHtml.append(""); bodyHtml.append("
"); - bodyHtml.append(errorMessage); bodyHtml.append("
"); bodyHtml.append(MessageUtils.getMsg("msg.note.enter.specific.nembers", locale)); bodyHtml.append("
"); diff --git a/src/main/java/org/t246osslab/easybuggy/troubles/EndlessWaitingServlet.java b/src/main/java/org/t246osslab/easybuggy/troubles/EndlessWaitingServlet.java index 86c19393..c8144b05 100644 --- a/src/main/java/org/t246osslab/easybuggy/troubles/EndlessWaitingServlet.java +++ b/src/main/java/org/t246osslab/easybuggy/troubles/EndlessWaitingServlet.java @@ -65,7 +65,8 @@ protected void service(HttpServletRequest req, HttpServletResponse res) throws S Process process = pb.start(); process.waitFor(); bodyHtml.append(MessageUtils.getMsg("msg.executed.batch", locale) + batFile.getAbsolutePath() - + "

"); + + "

"); + bodyHtml.append(MessageUtils.getMsg("label.execution.result", locale) + "

"); bodyHtml.append(printInputStream(process.getInputStream(), res)); bodyHtml.append(printInputStream(process.getErrorStream(), res)); } diff --git a/src/main/resources/messages_en.properties b/src/main/resources/messages_en.properties index 6aac6fd4..752ab922 100644 --- a/src/main/resources/messages_en.properties +++ b/src/main/resources/messages_en.properties @@ -4,6 +4,7 @@ label.asc=asc label.calculate=Calculate label.character.count=Character Count label.desc=desc +label.execution.result=Execution Result: label.name=Name label.multiplication.sign=* label.obelus=/ @@ -22,7 +23,7 @@ msg.deadlock.occurs=A lock could not be obtained due to a deadlock. msg.enter.name.and.passwd=If you enter your name and password, then your secret number is shown. msg.enter.name=Please enter your name. msg.enter.positive.number=Please enter a positive number. -msg.enter.decimal.value=Please enter a decimal value. +msg.enter.decimal.value=Please enter a decimal number less than 1. msg.error.user.not.exist=User does not exist or password does not match. msg.example.name.and.passwd=For example, Mark and password msg.executed.batch=Created and executed the batch: diff --git a/src/main/resources/messages_ja.properties b/src/main/resources/messages_ja.properties index a7953c53..891be1a5 100644 --- a/src/main/resources/messages_ja.properties +++ b/src/main/resources/messages_ja.properties @@ -4,9 +4,10 @@ label.asc=\u6607\u9806 label.calculate=\u8a08\u7b97\u3059\u308b label.character.count=\u6587\u5b57\u6570 label.desc=\u964d\u9806 +label.execution.result=\u5b9f\u884c\u7d50\u679c: label.name=\u540d\u524d -label.multiplication.sign=× -label.obelus=÷ +label.multiplication.sign=\u00d7 +label.obelus=\u00f7 label.order=\u9806\u5e8f label.password=\u30d1\u30b9\u30ef\u30fc\u30c9 label.reversed.name=\u9006\u8ee2\u3057\u305f\u540d\u524d @@ -22,7 +23,7 @@ msg.deadlock.occurs=\u30c7\u30c3\u30c9\u30ed\u30c3\u30af\u306b\u3088\u308a\u30ed msg.enter.name.and.passwd=\u540d\u524d\u3068\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u5165\u529b\u3059\u308b\u3068\u3001\u6697\u8a3c\u756a\u53f7\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002 msg.enter.name=\u540d\u524d\u3092\u5165\u529b\u3057\u3066\u4e0b\u3055\u3044\u3002 msg.enter.positive.number=\u6b63\u306e\u6574\u6570\u3092\u5165\u529b\u3057\u3066\u4e0b\u3055\u3044\u3002 -msg.enter.decimal.value=\u5c0f\u6570\u3092\u5165\u529b\u3057\u3066\u4e0b\u3055\u3044\u3002 +msg.enter.decimal.value=1\u672a\u6e80\u306e\u5c0f\u6570\u3092\u5165\u529b\u3057\u3066\u4e0b\u3055\u3044\u3002 msg.error.user.not.exist=\u30e6\u30fc\u30b6\u30fc\u304c\u5b58\u5728\u3057\u306a\u3044\u304b\u3001\u30d1\u30b9\u30ef\u30fc\u30c9\u304c\u4e00\u81f4\u3057\u307e\u305b\u3093\u3002 msg.example.name.and.passwd=\u4f8b\u3048\u3070\u3001Mark \u3068 password msg.executed.batch=\u30d0\u30c3\u30c1\u3092\u4f5c\u6210\u3001\u5b9f\u884c\u3057\u307e\u3057\u305f: @@ -41,7 +42,7 @@ msg.note.enter.decimal.value= msg.note.positive.number=  \ {0}\u3088\u308a\u5927\u304d\u3044\u6570\u3092\u5165\u529b\u3059\u308b\u3068\u3001\u6574\u6570\u30aa\u30fc\u30d0\u30fc\u30d5\u30ed\u30fc\u304c\u767a\u751f\u3057\u307e\u3059\u3002 msg.note.sql.deadlock=  \ -\u300c\u964d\u9806\u300d\u3092\u9078\u629e\u3057\u3066\u300c\u66f4\u65b0\u300d\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u305f\u76f4\u5f8c\u306b\u300c\u6607\u9806\u300d\u3092\u9078\u629e\u3057\u3001\ +\u300c\u964d\u9806\u300d\u3092\u9078\u629e\u3057\u3066\u300c\u66f4\u65b0\u300d\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u305f\u76f4\u5f8c\u306b\u3001\u300c\u6607\u9806\u300d\u3092\u9078\u629e\u3057\u3066\ \u300c\u66f4\u65b0\u300d\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u3068\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3067\u30c7\u30c3\u30c9\u30ed\u30c3\u30af\u304c\u767a\u751f\u3057\u307e\u3059\u3002 msg.note.sql.injection=  \ \u30d1\u30b9\u30ef\u30fc\u30c9\u306b\u300c' OR '1'='1\u300d\u3092\u8a2d\u5b9a\u3059\u308b\u3068\u3001SQL\u30a4\u30f3\u30b8\u30a7\u30af\u30b7\u30e7\u30f3\u304c\u767a\u751f\u3057\u307e\u3059\u3002