Get Current User

    
    /*
    * Get current user and assigned security roles
    * 
    * This button script snippet prints out the current user
    * and its assigned IJC security roles
    *
    * @author David Pech <dpech@chemaxon.com>
    */
    import com.im.df.api.capabilities.IJCUserLoginService
    import com.im.df.api.util.DIFUtilities
    init = { widget ->
    }
    destroy = { widget ->
    }
    // evaluate is called when the button is clicked to perform action
    //
    // widget is IJCWidget instance
    evaluate = { widget ->
        // obtain the schema object
        def rs = widget.form.resultSet
        def dataTree = rs.dataTree
        def schema  = dataTree.schema
    
        // find the appropriate capability and pass the schema to it
        def user = DIFUtilities.findCapability(schema, IJCUserLoginService.class).getMe() 
        // print out current user and assigned security roles
        println user.getUsername()
        println user.getRoles()
    
    }
    on_change = { widget, button ->
    
    }