Author: degenaro
Date: Tue Feb 26 14:56:21 2013
New Revision: 1450196

URL: http://svn.apache.org/r1450196
Log:
UIMA-2676 DUCC webserver (WS) Services presentation improvements...support 
long/short Description preference

Modified:
    
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccAbstractHandler.java
    
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandlerJsonFormat.java
    
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandlerLegacy.java
    
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccWebUtil.java
    uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/webapp/root/js/ducc.js
    
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/webapp/root/preferences.jsp

Modified: 
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccAbstractHandler.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccAbstractHandler.java?rev=1450196&r1=1450195&r2=1450196&view=diff
==============================================================================
--- 
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccAbstractHandler.java
 (original)
+++ 
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccAbstractHandler.java
 Tue Feb 26 14:56:21 2013
@@ -134,6 +134,17 @@ public abstract class DuccAbstractHandle
                return retVal;
        }
        
+       public String getShortDescription(String description) {
+               String retVal = null;
+               if(description != null) {
+                       int index = description.lastIndexOf('/');
+                       if(index > 0) {
+                               retVal = description.substring(index);
+                       }
+               }
+               return retVal;
+       }
+       
        public String getTimeStamp(DateStyle dateStyle, String date) {
                String location = "getTimeStamp";
                StringBuffer sb = new StringBuffer();
@@ -464,6 +475,24 @@ public abstract class DuccAbstractHandle
                return dateStyle;
        }
        
+       public enum DescriptionStyle { Long, Short };
+       
+       public DescriptionStyle getDescriptionStyle(HttpServletRequest request) 
{
+               DescriptionStyle descriptionStyle = DescriptionStyle.Long;
+               try {
+                       String cookie = 
DuccWebUtil.getCookie(request,DuccWebUtil.cookieStyleDescription);
+                       
if(cookie.equals(DuccWebUtil.valueStyleDescriptionLong)) {
+                               descriptionStyle = DescriptionStyle.Long;
+                       }
+                       else 
if(cookie.equals(DuccWebUtil.valueStyleDescriptionShort)) {
+                               descriptionStyle = DescriptionStyle.Short;
+                       }
+               }
+               catch(Exception e) {
+               }
+               return descriptionStyle;
+       }
+       
        public enum FilterUsersStyle { Include, IncludePlusActive, Exclude, 
ExcludePlusActive };
        
        public FilterUsersStyle getFilterUsersStyle(HttpServletRequest request) 
{

Modified: 
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandlerJsonFormat.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandlerJsonFormat.java?rev=1450196&r1=1450195&r2=1450196&view=diff
==============================================================================
--- 
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandlerJsonFormat.java
 (original)
+++ 
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandlerJsonFormat.java
 Tue Feb 26 14:56:21 2013
@@ -356,9 +356,28 @@ public class DuccHandlerJsonFormat exten
                row.add(new JsonPrimitive(sb.toString()));
                // Description
                sb = new StringBuffer();
-               sb.append("<span>");
-               
sb.append(stringNormalize(job.getStandardInfo().getDescription(),messages.fetch("none")));
-               sb.append("</span>");
+               String description = 
stringNormalize(job.getStandardInfo().getDescription(),messages.fetch("none"));
+               switch(getDescriptionStyle(request)) {
+               case Long:
+               default:
+                       sb.append("<span>");
+                       sb.append(description);
+                       sb.append("</span>");
+                       break;
+               case Short:
+                       String shortDescription = 
getShortDescription(description);
+                       if(shortDescription == null) {
+                               sb.append("<span>");
+                               sb.append(description);
+                               sb.append("</span>");
+                       }
+                       else {
+                               sb.append("<span title=\""+description+"\">");
+                               sb.append(shortDescription);
+                               sb.append("</span>");
+                       }
+                       break;
+               }
                row.add(new JsonPrimitive(sb.toString()));
                
                return row;
@@ -812,9 +831,28 @@ public class DuccHandlerJsonFormat exten
                row.add(new JsonPrimitive(sb.toString()));
                // Description
                sb = new StringBuffer();
-               sb.append("<span>");
-               
sb.append(stringNormalize(duccwork.getStandardInfo().getDescription(),messages.fetch("none")));
-               sb.append("</span>");
+               String description = 
stringNormalize(duccwork.getStandardInfo().getDescription(),messages.fetch("none"));
+               switch(getDescriptionStyle(request)) {
+               case Long:
+               default:
+                       sb.append("<span>");
+                       sb.append(description);
+                       sb.append("</span>");
+                       break;
+               case Short:
+                       String shortDescription = 
getShortDescription(description);
+                       if(shortDescription == null) {
+                               sb.append("<span>");
+                               sb.append(description);
+                               sb.append("</span>");
+                       }
+                       else {
+                               sb.append("<span title=\""+description+"\">");
+                               sb.append(shortDescription);
+                               sb.append("</span>");
+                       }
+                       break;
+               }
                row.add(new JsonPrimitive(sb.toString()));
                
                return row;
@@ -1113,7 +1151,31 @@ public class DuccHandlerJsonFormat exten
                                // Size
                                row.add(new 
JsonPrimitive(getValue(propertiesSvc,IStateServices.process_memory_size,"")));
                                // Description
-                               row.add(new 
JsonPrimitive(getValue(propertiesSvc,IStateServices.description,"")));
+                               StringBuffer sb = new StringBuffer();
+                               String description = 
getValue(propertiesSvc,IStateServices.description,"");
+                               switch(getDescriptionStyle(request)) {
+                               case Long:
+                               default:
+                                       sb.append("<span>");
+                                       sb.append(description);
+                                       sb.append("</span>");
+                                       break;
+                               case Short:
+                                       String shortDescription = 
getShortDescription(description);
+                                       if(shortDescription == null) {
+                                               sb.append("<span>");
+                                               sb.append(description);
+                                               sb.append("</span>");
+                                       }
+                                       else {
+                                               sb.append("<span 
title=\""+description+"\">");
+                                               sb.append(shortDescription);
+                                               sb.append("</span>");
+                                       }
+                                       break;
+                               }
+                               row.add(new JsonPrimitive(sb.toString()));
+                               
                                data.add(row);
                        }
                }

Modified: 
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandlerLegacy.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandlerLegacy.java?rev=1450196&r1=1450195&r2=1450196&view=diff
==============================================================================
--- 
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandlerLegacy.java
 (original)
+++ 
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandlerLegacy.java
 Tue Feb 26 14:56:21 2013
@@ -319,7 +319,28 @@ public class DuccHandlerLegacy extends D
                sb.append("</td>");
                // Description
                sb.append("<td valign=\"bottom\">");
-               
sb.append(stringNormalize(job.getStandardInfo().getDescription(),messages.fetch("none")));
+               String description = 
stringNormalize(job.getStandardInfo().getDescription(),messages.fetch("none"));
+               switch(getDescriptionStyle(request)) {
+               case Long:
+               default:
+                       sb.append("<span>");
+                       sb.append(description);
+                       sb.append("</span>");
+                       break;
+               case Short:
+                       String shortDescription = 
getShortDescription(description);
+                       if(shortDescription == null) {
+                               sb.append("<span>");
+                               sb.append(description);
+                               sb.append("</span>");
+                       }
+                       else {
+                               sb.append("<span title=\""+description+"\">");
+                               sb.append(shortDescription);
+                               sb.append("</span>");
+                       }
+                       break;
+               }
                sb.append("</td>");
                sb.append("</tr>");
        }
@@ -722,7 +743,28 @@ public class DuccHandlerLegacy extends D
                sb.append("</td>");
                // Description
                sb.append("<td>");
-               
sb.append(stringNormalize(duccwork.getStandardInfo().getDescription(),messages.fetch("none")));
+               String description = 
stringNormalize(duccwork.getStandardInfo().getDescription(),messages.fetch("none"));
+               switch(getDescriptionStyle(request)) {
+               case Long:
+               default:
+                       sb.append("<span>");
+                       sb.append(description);
+                       sb.append("</span>");
+                       break;
+               case Short:
+                       String shortDescription = 
getShortDescription(description);
+                       if(shortDescription == null) {
+                               sb.append("<span>");
+                               sb.append(description);
+                               sb.append("</span>");
+                       }
+                       else {
+                               sb.append("<span title=\""+description+"\">");
+                               sb.append(shortDescription);
+                               sb.append("</span>");
+                       }
+                       break;
+               }
                sb.append("</td>");
                sb.append("</tr>");
        }
@@ -975,7 +1017,28 @@ public class DuccHandlerLegacy extends D
                                sb.append("</td>");
                                // Description
                                sb.append("<td>");
-                               
sb.append(getValue(propertiesSvc,IServicesRegistry.description,""));
+                               String description = 
getValue(propertiesSvc,IServicesRegistry.description,"");
+                               switch(getDescriptionStyle(request)) {
+                               case Long:
+                               default:
+                                       sb.append("<span>");
+                                       sb.append(description);
+                                       sb.append("</span>");
+                                       break;
+                               case Short:
+                                       String shortDescription = 
getShortDescription(description);
+                                       if(shortDescription == null) {
+                                               sb.append("<span>");
+                                               sb.append(description);
+                                               sb.append("</span>");
+                                       }
+                                       else {
+                                               sb.append("<span 
title=\""+description+"\">");
+                                               sb.append(shortDescription);
+                                               sb.append("</span>");
+                                       }
+                                       break;
+                               }
                                sb.append("</td>");
                                sb.append("</tr>");
                        }

Modified: 
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccWebUtil.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccWebUtil.java?rev=1450196&r1=1450195&r2=1450196&view=diff
==============================================================================
--- 
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccWebUtil.java
 (original)
+++ 
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccWebUtil.java
 Tue Feb 26 14:56:21 2013
@@ -63,11 +63,13 @@ public class DuccWebUtil {
        
        private static final String table_style = "table_style";
        private static final String date_style = "date_style";
+       private static final String description_style = "description_style";
        private static final String filter_users_style = "filter_users_style";
        private static final String role = "role";
        
        public static final String cookieStyleTable = 
application+join+table_style;
        public static final String cookieStyleDate = 
application+join+date_style;
+       public static final String cookieStyleDescription = 
application+join+description_style;
        public static final String cookieStyleFilterUsers = 
application+join+filter_users_style;
        public static final String cookieRole = application+join+role;
        
@@ -76,6 +78,10 @@ public class DuccWebUtil {
        public static final String valueStyleDateShort = "short";
        public static final String valueStyleDateDefault = valueStyleDateLong;
        
+       public static final String valueStyleDescriptionLong = "long";
+       public static final String valueStyleDescriptionShort = "short";
+       public static final String valueStyleDescriptionDefault = 
valueStyleDescriptionLong;
+       
        public static final String valueStyleFilterUsersInclude = "include";
        public static final String valueStyleFilterUsersIncludePlusActive = 
"include+active";
        public static final String valueStyleFilterUsersExclude = "exclude";

Modified: 
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/webapp/root/js/ducc.js
URL: 
http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/webapp/root/js/ducc.js?rev=1450196&r1=1450195&r2=1450196&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/webapp/root/js/ducc.js 
(original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/webapp/root/js/ducc.js 
Tue Feb 26 14:56:21 2013
@@ -2307,6 +2307,10 @@ function ducc_preferences_reset()
                var value = "long";
                //alert("ducc_preferences_reset"+" "+"key:"+key+" 
"+"value:"+value);
                ducc_put_cookie(key,value);
+               var key = ducc_appl("description_style");
+               var value = "long";
+               //alert("ducc_preferences_reset"+" "+"key:"+key+" 
"+"value:"+value);
+               ducc_put_cookie(key,value);
                var key = ducc_appl("filter_users_style");
                var value = "include";
                //alert("ducc_preferences_reset"+" "+"key:"+key+" 
"+"value:"+value);
@@ -2408,6 +2412,31 @@ function ducc_preferences_date_style() {
        }
 }
 
+function ducc_preferences_description_style() {
+       try {
+               var key = ducc_appl("description_style");
+               var value = ducc_get_cookie(key);
+               //alert("ducc_preferences"+" "+"key:"+key+" "+"value:"+value);
+               if(value == "long") {
+                       document.form_preferences.description_style[0].checked 
= true;
+                       document.form_preferences.description_style[1].checked 
= false;
+               }
+               else if(value == "short") {
+                       document.form_preferences.description_style[0].checked 
= false;
+                       document.form_preferences.description_style[1].checked 
= true;
+               }
+               else {
+                       value = "long";
+                       ducc_put_cookie(key, value);
+                       document.form_preferences.description_style[0].checked 
= true;
+                       document.form_preferences.description_style[1].checked 
= false;
+               }
+       }
+       catch(err) {
+               ducc_error("ducc_preferences_description_style",err);
+       }
+}
+
 function ducc_preferences_filter_users_style() {
        try {
                var key = ducc_appl("filter_users_style");
@@ -2481,6 +2510,7 @@ function ducc_preferences()
        try {
                ducc_preferences_table_style();
                ducc_preferences_date_style();
+               ducc_preferences_description_style();
                ducc_preferences_filter_users_style();
                ducc_preferences_role();
        }

Modified: 
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/webapp/root/preferences.jsp
URL: 
http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/webapp/root/preferences.jsp?rev=1450196&r1=1450195&r2=1450196&view=diff
==============================================================================
--- 
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/webapp/root/preferences.jsp 
(original)
+++ 
uima/sandbox/uima-ducc/trunk/uima-ducc-web/src/main/webapp/root/preferences.jsp 
Tue Feb 26 14:56:21 2013
@@ -19,6 +19,7 @@ under the License.
 <%@ page language="java" %>
 <%
 boolean dateStyle = true;
+boolean descriptionStyle = true;
 boolean role = true;
 %>
 <html>
@@ -137,6 +138,19 @@ if (dateStyle) {
 <%
 }
 %>
+<%
+if (descriptionStyle) {
+%>
+               <tr>
+               <tr>
+        <td><i><b>Description Style</b></i>
+               <td>&nbsp
+               <td><input type="radio"  name="description_style" value="long" 
checked onclick="ducc_preferences_set('description_style','long')" /> Long
+               <td>&nbsp
+               <td><input type="radio"  name="description_style" value="short" 
       onclick="ducc_preferences_set('description_style','short')" /> Short
+<%
+}
+%>
                <tr>
         <tr>
         <td><i><b>Filter Users</b></i>


Reply via email to