public Panel getResourcePanel ( Resource resource ) { List < Folder > resourceFolders = new ArrayList < Folder > ( ) ; Resource current = resource ; Folder folder = current instanceof Folder ? ( Folder ) current : current == null ? null : current . getParentFolder ( ) ; while ( folder != null ) { resourceFolders . add ( folder ) ; current = folder ; folder = current . getParentFolder ( ) ; } Folder panelFolder = null ; int panelIndex = resourceFolders . size ( ) - 2 ; if ( panelIndex >= 0 ) { panelFolder = resourceFolders . get ( panelIndex ) ; } if ( panelFolder != null ) { return panelDAO . findByRootFolder ( panelFolder ) ; } return null ; }
Returns a panel for given resource