Revision: 7559
          
http://languagetool.svn.sourceforge.net/languagetool/?rev=7559&view=rev
Author:   dnaber
Date:     2012-06-29 21:27:19 +0000 (Fri, 29 Jun 2012)
Log Message:
-----------
display sub id on rule page

Modified Paths:
--------------
    
trunk/ltcommunity/grails-app/controllers/org/languagetool/RuleController.groovy
    trunk/ltcommunity/grails-app/views/rule/show.gsp

Modified: 
trunk/ltcommunity/grails-app/controllers/org/languagetool/RuleController.groovy
===================================================================
--- 
trunk/ltcommunity/grails-app/controllers/org/languagetool/RuleController.groovy 
    2012-06-29 16:18:38 UTC (rev 7558)
+++ 
trunk/ltcommunity/grails-app/controllers/org/languagetool/RuleController.groovy 
    2012-06-29 21:27:19 UTC (rev 7559)
@@ -182,7 +182,7 @@
 
     def edit = {
         String lang = getLanguage()
-        SelectedRule rule = getRuleById(params.id, lang)
+        SelectedRule rule = getRuleById(params.id, params.subId, lang)
         Rule selectedRule = rule.rule
         render(view:'edit', model: [ rule: selectedRule, lang: lang,
                 isUserRule: rule.isUserRule, ruleId: params.id ],
@@ -261,13 +261,13 @@
 
     def show = {
         String lang = getLanguage()
-        SelectedRule rule = getRuleById(params.id, lang)
+        SelectedRule rule = getRuleById(params.id, params.subId, lang)
         Rule selectedRule = rule.rule
         boolean isUserRule = rule.isUserRule
         int disableId = getEnableDisableId(selectedRule, params.id, lang)
         if (!selectedRule) {
-            log.warn("No rule with id ${params.id} and language ${lang}")
-            flash.message = "No rule with id ${params.id.encodeAsHTML()}"
+            log.warn("No rule with id ${params.id}, subId ${params.subId} and 
language ${lang}")
+            flash.message = "No rule with id ${params.id.encodeAsHTML()}, 
subId ${params.subId.encodeAsHTML()}"
             redirect(action:list)
             return
         }
@@ -275,8 +275,12 @@
         if (params.textToCheck) {
             textToCheck = params.textToCheck
         }
+        String ruleSubId = null
+        if (selectedRule instanceof PatternRule) {
+            ruleSubId = ((PatternRule)selectedRule).getSubId()
+        }
         int corpusMatchCount = countCorpusMatches(lang, selectedRule.id)
-        render(view:'show', model: [ rule: selectedRule, isDisabled: disableId 
!= -1, disableId: disableId,
+        render(view:'show', model: [ rule: selectedRule, ruleSubId: ruleSubId, 
isDisabled: disableId != -1, disableId: disableId,
                 isUserRule: isUserRule, ruleId: params.id, textToCheck: 
textToCheck, corpusMatchCount: corpusMatchCount],
                 contentType: "text/html", encoding: "utf-8")
 
@@ -301,7 +305,7 @@
         return lang
     }
 
-    private SelectedRule getRuleById(String id, String lang) {
+    private SelectedRule getRuleById(String id, String subId, String lang) {
         Rule selectedRule
         boolean isUserRule
         try {
@@ -314,7 +318,7 @@
         } catch (NumberFormatException e) {
             JLanguageTool lt = new 
JLanguageTool(Language.getLanguageForShortName(lang))
             lt.activateDefaultPatternRules()
-            selectedRule = getSystemRuleById(params.id, params.subId, lt)
+            selectedRule = getSystemRuleById(id, subId, lt)
             isUserRule = false
         }
         return new SelectedRule(isUserRule: isUserRule, rule: selectedRule)

Modified: trunk/ltcommunity/grails-app/views/rule/show.gsp
===================================================================
--- trunk/ltcommunity/grails-app/views/rule/show.gsp    2012-06-29 16:18:38 UTC 
(rev 7558)
+++ trunk/ltcommunity/grails-app/views/rule/show.gsp    2012-06-29 21:27:19 UTC 
(rev 7559)
@@ -102,7 +102,14 @@
                 <g:if test="${!isUserRule}">
                        <tr class="additional">
                            <td><g:message code="ltc.rule.show.id" /></td>
-                           <td>${rule.id.encodeAsHTML()}</td>
+                        <td>
+                            <g:if test="${ruleSubId}">
+                                ${rule.id.encodeAsHTML()} 
[${ruleSubId.encodeAsHTML()}]
+                            </g:if>
+                            <g:else>
+                                ${rule.id.encodeAsHTML()}
+                            </g:else>
+                        </td>
                        </tr>
                 </g:if>
             </table>

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Languagetool-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/languagetool-cvs

Reply via email to