Scarab commit: svn commit: r10822 - trunk/src: java/org/tigris/scarab/om sql sql/upgrade webapp/WEB-INF/templates/macros webapp/skins

Hussayn Dabbous <[email protected]>
Newsgroups gmane.comp.java.scarab.cvs
Message-ID <[email protected]>
Author: dabbous
Date: 2009-07-22 23:46:13-0700
New Revision: 10822

Modified:
   trunk/src/java/org/tigris/scarab/om/Attribute.java
   trunk/src/java/org/tigris/scarab/om/AttributeType.java
   trunk/src/java/org/tigris/scarab/om/AttributeTypePeer.java
   trunk/src/java/org/tigris/scarab/om/Issue.java
   trunk/src/sql/scarab-required-data.sql
   trunk/src/sql/upgrade/upgrade-0.23-attribute.sql
   trunk/src/webapp/WEB-INF/templates/macros/GlobalMacros.vm
   trunk/src/webapp/skins/custom.css

Log:
SCB2979 : 
- Separated TreeView Popup from standard ComboBox popup. So now we have 2 AttributeOption types (ComboBox and ComboTreeBox)
- Added new api function public String AttributeType:getClassName() for convenience. It returns the LeafNode of the ClassPath
instead of the full class name.
- Added OPTION_PKS as a new collection of compatible attribute types
- Added new API function Issue.getASttribute(String name) Good for checking if a specific attribute exists for an Issue
- Added new AttributreType to sql required data and added a corresponding insert statement into the upgrade sql-script
- Added new Icon for TreeViewPopups
- Adjusted the css style sheets


Modified: trunk/src/java/org/tigris/scarab/om/Attribute.java
Url: http://scarab.tigris.org/source/browse/scarab/trunk/src/java/org/tigris/scarab/om/Attribute.java?view=diff&pathrev=10822&r1=10821&r2=10822
==============================================================================
--- trunk/src/java/org/tigris/scarab/om/Attribute.java	(original)
+++ trunk/src/java/org/tigris/scarab/om/Attribute.java	2009-07-22 23:46:13-0700
@@ -303,6 +303,12 @@
                     crit.addIn(AttributeTypePeer.ATTRIBUTE_TYPE_ID, AttributeTypePeer.TEXT_PKS);
                     result = AttributeTypePeer.doSelect(crit);                
                 }
+                else if (this.isOptionAttribute())
+                {
+                    final Criteria crit = new Criteria();
+                    crit.addIn(AttributeTypePeer.ATTRIBUTE_TYPE_ID, AttributeTypePeer.OPTION_PKS);
+                    result = AttributeTypePeer.doSelect(crit);                
+                }
                 else 
                 {
                     result = Collections.EMPTY_LIST;

Modified: trunk/src/java/org/tigris/scarab/om/AttributeType.java
Url: http://scarab.tigris.org/source/browse/scarab/trunk/src/java/org/tigris/scarab/om/AttributeType.java?view=diff&pathrev=10822&r1=10821&r2=10822
==============================================================================
--- trunk/src/java/org/tigris/scarab/om/AttributeType.java	(original)
+++ trunk/src/java/org/tigris/scarab/om/AttributeType.java	2009-07-22 23:46:13-0700
@@ -164,6 +164,34 @@
         }
         return result;
     }
+
+    /**
+     * returns the leaf classname of the attributeType (removes the full classPath). 
+     * Note: If you need the exact classname then use getJavaClassName() instead. 
+     * That will return the full java path.
+     * This method is used as a convenience method for velocity templates, who need to
+     * distinguish classes of the same attributeClass buit with different implementations.
+     * The first need for this distinguishing is the introduction of the ComboTreeBoxAttribute
+     * which has the same class as the ComboBoxAttribute but uses a differnet representation
+     * on the GUI level.
+     * @param type
+     * @return
+     */
+    public String getClassName()
+    {
+        String result;
+        String cn = getJavaClassName();
+        int index = cn.lastIndexOf('.');
+        if(index > -1)
+        {
+            result = cn.substring(index+1);
+        }
+        else
+        {
+            result = cn;
+        }
+        return result;
+    }
 }
 
 

Modified: trunk/src/java/org/tigris/scarab/om/AttributeTypePeer.java
Url: http://scarab.tigris.org/source/browse/scarab/trunk/src/java/org/tigris/scarab/om/AttributeTypePeer.java?view=diff&pathrev=10822&r1=10821&r2=10822
==============================================================================
--- trunk/src/java/org/tigris/scarab/om/AttributeTypePeer.java	(original)
+++ trunk/src/java/org/tigris/scarab/om/AttributeTypePeer.java	2009-07-22 23:46:13-0700
@@ -61,5 +61,8 @@
     public static final Integer USER_TYPE_KEY = new Integer(8);
     public static final Integer[] TEXT_PKS = 
         {new Integer(1), new Integer(11), new Integer(12), new Integer(13)};
+    
+    public static final Integer[] OPTION_PKS =
+        { new Integer(5), new Integer(6)};
 }
 

Modified: trunk/src/java/org/tigris/scarab/om/Issue.java
Url: http://scarab.tigris.org/source/browse/scarab/trunk/src/java/org/tigris/scarab/om/Issue.java?view=diff&pathrev=10822&r1=10821&r2=10822
==============================================================================
--- trunk/src/java/org/tigris/scarab/om/Issue.java	(original)
+++ trunk/src/java/org/tigris/scarab/om/Issue.java	2009-07-22 23:46:13-0700
@@ -4385,11 +4385,36 @@
         String attributeName = ScarabGlobalTool.getStatusAttributeName();
         if(attributeName != null)
         {
-            attribute = Attribute.getInstance(attributeName);
+            attribute = this.getAttribute(attributeName);
         }
         return attribute;
     }
-    
+
+    /**
+     * Get active Attribute by its name, if it exists for this issue.
+     * If the requested attribute does not exist, return null
+     * @param attributeName
+     * @return
+     * @throws TorqueException
+     */
+    public Attribute getAttribute(String attributeName) throws TorqueException 
+    {
+        Attribute result = null;
+        List<Attribute> attributes = this.getIssueType().getActiveAttributes(getModule());
+        Iterator<Attribute> iter = attributes.iterator();
+        while(iter.hasNext())
+        {
+            Attribute attrib = iter.next();
+            String attribName = attrib.getName();
+            if(attribName.equals(attributeName))
+            {
+                result = attrib;
+                break;
+            }
+        }
+        return result;
+    }
+
     /**
      * Returns the attribute instance, which contains the issues onHoldExpirationDate.
      * Note:  Currently Scarab expects that the Attribute is a DateAttribute
@@ -4402,7 +4427,7 @@
         String attributeName = ScarabGlobalTool.getOnHoldExpirationDateAttributeName();
         if(attributeName != null)
         {
-            attribute = Attribute.getInstance(attributeName);
+            attribute = this.getAttribute(attributeName);
         }
         return attribute;
     }

Modified: trunk/src/sql/scarab-required-data.sql
Url: http://scarab.tigris.org/source/browse/scarab/trunk/src/sql/scarab-required-data.sql?view=diff&pathrev=10822&r1=10821&r2=10822
==============================================================================
--- trunk/src/sql/scarab-required-data.sql	(original)
+++ trunk/src/sql/scarab-required-data.sql	2009-07-22 23:46:13-0700
@@ -16,6 +16,8 @@
 insert into SCARAB_ATTRIBUTE_TYPE(ATTRIBUTE_TYPE_ID, ATTRIBUTE_CLASS_ID, ATTRIBUTE_TYPE_NAME, JAVA_CLASS_NAME)
         values(5, 2, 'Dropdown list', 'org.tigris.scarab.attribute.ComboBoxAttribute');
 insert into SCARAB_ATTRIBUTE_TYPE(ATTRIBUTE_TYPE_ID, ATTRIBUTE_CLASS_ID, ATTRIBUTE_TYPE_NAME, JAVA_CLASS_NAME)
+        values(6, 2, 'Dropdown tree', 'org.tigris.scarab.attribute.ComboTreeBoxAttribute');
+insert into SCARAB_ATTRIBUTE_TYPE(ATTRIBUTE_TYPE_ID, ATTRIBUTE_CLASS_ID, ATTRIBUTE_TYPE_NAME, JAVA_CLASS_NAME)
         values(8, 4, 'user', 'org.tigris.scarab.attribute.UserAttribute');
 insert into SCARAB_ATTRIBUTE_TYPE(ATTRIBUTE_TYPE_ID, ATTRIBUTE_CLASS_ID, ATTRIBUTE_TYPE_NAME, JAVA_CLASS_NAME)
         values(11, 1, 'email', 'org.tigris.scarab.attribute.StringAttribute');

Modified: trunk/src/sql/upgrade/upgrade-0.23-attribute.sql
Url: http://scarab.tigris.org/source/browse/scarab/trunk/src/sql/upgrade/upgrade-0.23-attribute.sql?view=diff&pathrev=10822&r1=10821&r2=10822
==============================================================================
--- trunk/src/sql/upgrade/upgrade-0.23-attribute.sql	(original)
+++ trunk/src/sql/upgrade/upgrade-0.23-attribute.sql	2009-07-22 23:46:13-0700
@@ -25,4 +25,7 @@
  */
 
 ALTER TABLE SCARAB_R_MODULE_ATTRIBUTE    ADD ( VISIBLE INTEGER default 1);
-ALTER TABLE SCARAB_R_ISSUETYPE_ATTRIBUTE ADD ( VISIBLE INTEGER default 1);
\ No newline at end of file
+ALTER TABLE SCARAB_R_ISSUETYPE_ATTRIBUTE ADD ( VISIBLE INTEGER default 1);
+
+insert into SCARAB_ATTRIBUTE_TYPE(ATTRIBUTE_TYPE_ID, ATTRIBUTE_CLASS_ID, ATTRIBUTE_TYPE_NAME, JAVA_CLASS_NAME)
+       values(6, 2, 'Dropdown tree', 'org.tigris.scarab.attribute.ComboTreeBoxAttribute');

Modified: trunk/src/webapp/WEB-INF/templates/macros/GlobalMacros.vm
Url: http://scarab.tigris.org/source/browse/scarab/trunk/src/webapp/WEB-INF/templates/macros/GlobalMacros.vm?view=diff&pathrev=10822&r1=10821&r2=10822
==============================================================================
--- trunk/src/webapp/WEB-INF/templates/macros/GlobalMacros.vm	(original)
+++ trunk/src/webapp/WEB-INF/templates/macros/GlobalMacros.vm	2009-07-22 23:46:13-0700
@@ -66,6 +66,8 @@
 #macro (attrValueLeafSelect $attrValue $optionFieldName $size $multiple $required)
   #set ($attrInput = $intake.AttributeValue.mapTo($attrValue))
   #set ($attr = $attrValue.Attribute)
+  #set ($attributeType = $attr.AttributeType)
+  #set ($attributeClassName = $attributeType.ClassName)
   #set ($issue = $attrValue.Issue)
   #set ($module = $issue.Module)
   #set ($issueType = $issue.IssueType)
@@ -106,12 +108,18 @@
 
   #else
 
+    #if ($attributeClassName == "ComboTreeBoxAttribute")
   <input id="$attrInput.get($optionFieldName).Key" value="$newValues" name="$attrInput.get($optionFieldName).Key" type="hidden"/>  
-  <input id="$attrInput.get($optionFieldName).Key:Display" type="text" size="$attr.FieldSize" readonly="" name="$attrInput.get($optionFieldName).Key:Display"/>
+      <span style="display:inline;">
+        <input id="$attrInput.get($optionFieldName).Key:Display" 
+               type="text" size="$attr.FieldSize" 
+               readonly="" 
+               name="$attrInput.get($optionFieldName).Key:Display"/>
     <a class="treeview_button"
        id="$attrInput.get($optionFieldName).Key:Anchor"
        href="javascript:toggleTreePopup('$attrInput.get($optionFieldName).Key')"
     >&nbsp;&nbsp;&nbsp;&nbsp;</a>
+      </span>
   
   #set ($attributeTreePopup = [])
   #set ($dummy = $attributeTreePopup.add($attrInput.get($optionFieldName).Key) )
@@ -120,6 +128,52 @@
   
   #set ($dummy = $attributeTreePopupHelper.add($attributeTreePopup) )
 
+    #elseif ($attributeClassName == "ComboBoxAttribute")
+      <select name="$attrInput.get($optionFieldName).Key"
+        #if($size.length())size="$size"#end #if($multiple.equals("true"))multiple="multiple"#end>
+        #if ($size.length() == 0 && (!$required || $newValues == '' ))
+          <option value="">$l10n.Choose</option>
+        #end
+        #foreach ($option in $module.getOptionTree($attr, $issueType, false))
+          #set ($canMakeTransition = "#CanMakeTransitionForOption ($newValues $option $issue $multiple)")
+
+          #if ($canMakeTransition.trim()=="true")
+
+            #set ($selected = false)
+            #if ($newValues && $newValues.toString() != '')
+              #if ($multiple.equals("true"))
+                #foreach ($value in $newValues)
+                  #if ($value.equals($option.OptionId))
+                    #set ($selected=true)
+                  #end
+                #end
+              #else
+                #if ($newValues.equals($option.OptionId))
+                  #set ($selected=true)
+                #end
+              #end
+            #end
+     
+	            #if($selected)
+	              <option value="$option.OptionId"#selected($selected)>
+              	  #foreach ($i in [0..$option.Level])#if($i != 0)&nbsp;&nbsp;&nbsp;&nbsp;#end#end
+		                #if ($option.Active) 
+                  		$option.DisplayValue
+		                #else
+                  		[I] $option.DisplayValue
+		                #end
+		              </option>
+	            #elseif($option.Active)
+	              <option value="$option.OptionId"#selected($selected)>
+              	  #foreach ($i in [0..$option.Level])#if($i != 0)&nbsp;&nbsp;&nbsp;&nbsp;#end#end
+                $option.DisplayValue
+              </option>
+	            #end
+          #end
+        #end
+      </select>
+    #end
+
  #end
 #end
 
@@ -493,6 +547,23 @@
  #end
 #end
 
+#macro (indexedRowsWithIdleHours $count $hours)
+ #if    ($hours <=  0) #set ($extra = "")
+ #elseif($hours <  12) #set ($extra = "_attention1")
+ #elseif($hours <  36) #set ($extra = "_attention2")
+ #elseif($hours < 120) #set ($extra = "_attention3")
+ #elseif($hours < 240) #set ($extra = "_attention4")
+ #else
+   #set ($extra = "_attention5")
+ #end
+  
+ #if ($count % 2 > 0)
+    <tr class="a$extra">
+ #else
+    <tr class="b$extra">
+ #end
+#end
+
 #macro (indexedRowsWithStyle $count $style)
  #if ($count % 2 > 0)
     <tr class="a" style=$style">
@@ -571,6 +642,24 @@
  $pageNum of $scarabR.NbrPages
  #if ($scarabR.NextPage != 0)
   #set ($nextLink = $link.setPathInfo("resultsperpage", "$resultsPerPage").setPathInfo("pageNum", "$scarabR.NextPage").setPathInfo("sortColumn", "$sortColumn").setPathInfo("sortPolarity", "$sortPolarity").setPathInfo("searchType", "$searchType").setPage($scarabR.getCurrentTemplate()))
+  | <a href="$nextLink" title="$l10n.PaginateNext" class="next_element"></a>
+ #end
+ </span>
+#end
+
+## Writes the pagination links for an issue list: "<< Pervious | n of N | Next >>"
+#macro (paginateIssueListInView $resultsPerPage $pageNum $sortColumn $sortPolarity $searchType $view)
+ #if (!$sortColumn) 
+   #set ($sortColumn='null')
+ #end
+ <span class="paginate">
+ #if($scarabR.PrevPage != 0)
+  #set ($prevLink = $link.setPathInfo("resultsperpage", "$resultsPerPage").setPathInfo("pageNum", "$scarabR.PrevPage").setPathInfo("sortColumn", "$sortColumn").setPathInfo("sortPolarity", "$sortPolarity").setPathInfo("searchType", "$searchType").setPathInfo("view","$view").setPage($scarabR.getCurrentTemplate()))
+  <a href="$prevLink">$l10n.PaginatePrevious</a> |
+ #end
+ $pageNum of $scarabR.NbrPages
+ #if ($scarabR.NextPage != 0)
+  #set ($nextLink = $link.setPathInfo("resultsperpage", "$resultsPerPage").setPathInfo("pageNum", "$scarabR.NextPage").setPathInfo("sortColumn", "$sortColumn").setPathInfo("sortPolarity", "$sortPolarity").setPathInfo("searchType", "$searchType").setPathInfo("view","$view").setPage($scarabR.getCurrentTemplate()))
   | <a href="$nextLink">$l10n.PaginateNext</a>
  #end
  </span>
@@ -1159,7 +1248,7 @@
 
                 #if ($linecount > 0 && $index > 6)
                     #set ($isHidden =  !( $currentIssue.isRequiredAttributeFor($att, $user) || $rma.Visible ) )
-                    <span id="${displayValue}:Container" #if ($isHidden) style="display:none;" #end>
+                    <span id="${displayValue}:Container" #if ($isHidden) style="display:none;" #else style="display:inline;" #end>
                     <span class="displayValue" style="white-space:nowrap;display:inline;margin-left:0px; margin-right:0px;width:95%;">#drawRequiredMarkupAsNeeded($user $currentIssue $att)$displayValue</span>
                 #else
                     #if ($linecount > 0)

Modified: trunk/src/webapp/skins/custom.css
Url: http://scarab.tigris.org/source/browse/scarab/trunk/src/webapp/skins/custom.css?view=diff&pathrev=10822&r1=10821&r2=10822
==============================================================================
--- trunk/src/webapp/skins/custom.css	(original)
+++ trunk/src/webapp/skins/custom.css	2009-07-22 23:46:13-0700
@@ -56,12 +56,12 @@
   
 
 .treeview_button {
- background-image: url(images/popup_open.gif);
- width:17px;
- height:17px;
+ background-image: url(images/treeview_open.gif);
+ width:19px;
+ height:14px;
  padding-left:0px;
  position:relative;
- left:-7px;
+ left:-3px;
  top:-1px;
  text-decoration:none;
  background-repeat: no-repeat;

------------------------------------------------------
http://scarab.tigris.org/ds/viewMessage.do?dsForumId=3577&dsMessageId=2374670
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.