private static Column getRootColumn ( Resource rootResource , String itemResourceType ) { /* * Put a special path for columnId to avoid having the same columnId with the next column to avoid breaking the contract of columnId. * The contract of columnId is that it should be a path of the current column, i.e. the path should be a path representing a parent. * e.g. When columnId = "/", then the column will show the children of this path, such as "/a", "/b". * So for showRoot scenario, if we want to show the item with path = "/", we need to generate the column having a columnId with value of the parent of "/". * Since the cannot have a parent of "/", then we decide to just use a special convention ("parentof:<path>") to indicate this. * Other component (e.g. `.granite-collection-navigator`) reading the columnId can then understand this convention and handle it accordingly. */ String columnId = "parentof:" + rootResource . getPath ( ) ; Column column = new Column ( ) . columnId ( columnId ) . hasMore ( false ) ; column . addItem ( new ColumnItem ( rootResource ) . resourceType ( itemResourceType ) . active ( true ) ) ; return column ; }
Generate extra column representing the root resource .