Ignore:
Timestamp:
Feb 8, 2010, 8:23:33 AM (11 years ago)
Author:
tabma
Message:
  • created taglibrary for importer and first implementation detection of (cell) datatypes
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/taglib/dbnp/importer/ImporterTagLib.groovy

    r169 r173  
    1818class ImporterTagLib {
    1919    static namespace = 'importer'
     20    def entities = [[value:0, name:"Study"], [value:1, name:"Subject"], [value:2, name:"Event"],
     21                        [value:3, name:"Protocol"], [value:4, name:"Sample"]]
     22
     23    def celltypes = [[value:0, name:"Numeric"], [value:1, name:"String"], [value:2, name:"Formula"],
     24                         [value:3, name:"Blank"], [value:4, name:"Boolean"], [value:5, name:"Error"]]
    2025
    2126    /**
     
    3237    }
    3338
     39    def createSelect(int selected, String name, ArrayList options) {
     40        def res = "<select style=\"font-size:10px\" name=\"${name}\">"
     41
     42        options.each { e ->
     43            res += "<option value=\"${e.value}\""
     44            res += (e.value == selected) ? " selected" : ""
     45            res += ">${e.name}</option>"
     46        }
     47
     48        res += "</select>"
     49        return res
     50    }
     51
     52    /**
     53     * @param selected selected entity
     54     * @param name name of the HTML select object
     55     **/
     56    def entitySelect = { attrs ->       
     57        def selected = (attrs['selected']==null) ? -1 : attrs['selected']
     58        out << createSelect(selected, attrs['name'], entities)
     59    }
     60
    3461    /**
    3562    * @param selected selected celltype
    3663    * @param name name of the HTML select object
    37     * @param celltypes built-in cell types, based on the cell type
    38     * @see org.apache.poi.ss.usermodel.Cell
     64    * @see org.apache.poi.ss.usermodel.Cell for the possible cell types
    3965    * @return HTML select object
    4066    */
    41     def celltypeselector = { attrs ->
    42         def selected = attrs['selected']
    43         def name = attrs['name']
    44         def celltypes = [[celltype:0, name:"Numeric"], [celltype:1, name:"String"], [celltype:2, name:"Formula"],
    45                          [celltype:3, name:"Blank"], [celltype:4, name:"Boolean"], [celltype:5, name:"Error"]]
    46 
    47         def res = "<select name=\"${name}\">"
    48 
    49         celltypes.each { c ->
    50             res += "<option value=\"${c.celltype}\""
    51             res += (c.celltype == selected) ? " selected" : ""
    52             res += ">${c.name}</option>"
    53         }
    54 
    55         res += "</select>"
    56 
    57         out << res
     67    def celltypeSelect = { attrs ->
     68        def selected = (attrs['selected']==null) ? -1 : attrs['selected']
     69        out << createSelect(selected, attrs['name'], celltypes)
    5870    }
    59 
    6071}
Note: See TracChangeset for help on using the changeset viewer.