private void setSelectedTemplate ( String templateName ) { Object template = null ; if ( templateName != null && templateName . length ( ) > 0 ) { // pick the last used template template = fTemplateStore . findTemplate ( templateName , CardContextType . CONTEXT_TYPE ) ; } // no record of last used template so just pick first element if ( template == null ) { // just pick first element template = fTableViewer . getElementAt ( 0 ) ; } if ( template != null ) { IStructuredSelection selection = new StructuredSelection ( template ) ; fTableViewer . setSelection ( selection , true ) ; } }
Select a template in the table viewer given the template name . If template name cannot be found or templateName is null just select first item in table . If no items in table select nothing .