@Test public void testGetChildCount() { RepositoryTreeModel treeModel = new RepositoryTreeModel(); assertNotNull( treeModel ); treeModel.setFileSystemRoot( repositoryRoot ); assertEquals( 0, treeModel.getChildCount( repositoryRoot ) ); FileObject[] childFiles = new FileObject[] { childFile1, childFile2, childFile3 }; try { doReturn( childFiles ).when( repositoryRoot ).getChildren(); doReturn( FileType.FOLDER ).when( repositoryRoot ).getType(); doReturn( FileType.FOLDER ).when( childFile1 ).getType(); doReturn( FileType.FOLDER ).when( childFile2 ).getType(); doReturn( FileType.FOLDER ).when( childFile3 ).getType(); } catch ( FileSystemException e ) { e.printStackTrace(); } assertEquals( 3, treeModel.getChildCount( repositoryRoot ) ); }
public int getChildCount( Object parent ) { if ( parent instanceof RepositoryTreeRoot ) { final RepositoryTreeRoot root1 = (RepositoryTreeRoot) parent; parent = root1.getRoot(); if ( parent == null ) { return 0; } } try { final FileObject parElement = (FileObject) parent; if ( parElement.getType() != FileType.FOLDER ) { return 0; } final FileObject[] children = parElement.getChildren(); int count = 0; for ( int i = 0; i < children.length; i++ ) { final FileObject child = children[i]; if ( isShowFoldersOnly() && child.getType() != FileType.FOLDER ) { continue; } if ( isShowHiddenFiles() == false && child.isHidden() ) { continue; } if ( child.getType() != FileType.FOLDER && PublishUtil.acceptFilter( filters, child.getName().getBaseName() ) == false ) { continue; } count += 1; } return count; } catch ( FileSystemException fse ) { logger.debug( "Failed", fse ); return 0; } }
RepositoryTreeModel implements TreeModel { public int getChildCount( Object parent ) { if ( parent instanceof RepositoryTreeRoot ) { final RepositoryTreeRoot root1 = (RepositoryTreeRoot) parent; parent = root1.getRoot(); if ( parent == null ) { return 0; } } try { final FileObject parElement = (FileObject) parent; if ( parElement.getType() != FileType.FOLDER ) { return 0; } final FileObject[] children = parElement.getChildren(); int count = 0; for ( int i = 0; i < children.length; i++ ) { final FileObject child = children[i]; if ( isShowFoldersOnly() && child.getType() != FileType.FOLDER ) { continue; } if ( isShowHiddenFiles() == false && child.isHidden() ) { continue; } if ( child.getType() != FileType.FOLDER && PublishUtil.acceptFilter( filters, child.getName().getBaseName() ) == false ) { continue; } count += 1; } return count; } catch ( FileSystemException fse ) { logger.debug( "Failed", fse ); return 0; } } }
RepositoryTreeModel implements TreeModel { public int getChildCount( Object parent ) { if ( parent instanceof RepositoryTreeRoot ) { final RepositoryTreeRoot root1 = (RepositoryTreeRoot) parent; parent = root1.getRoot(); if ( parent == null ) { return 0; } } try { final FileObject parElement = (FileObject) parent; if ( parElement.getType() != FileType.FOLDER ) { return 0; } final FileObject[] children = parElement.getChildren(); int count = 0; for ( int i = 0; i < children.length; i++ ) { final FileObject child = children[i]; if ( isShowFoldersOnly() && child.getType() != FileType.FOLDER ) { continue; } if ( isShowHiddenFiles() == false && child.isHidden() ) { continue; } if ( child.getType() != FileType.FOLDER && PublishUtil.acceptFilter( filters, child.getName().getBaseName() ) == false ) { continue; } count += 1; } return count; } catch ( FileSystemException fse ) { logger.debug( "Failed", fse ); return 0; } } RepositoryTreeModel();  RepositoryTreeModel( final FileObject repositoryRoot, final String[] filters, final boolean showFoldersOnly ); }
RepositoryTreeModel implements TreeModel { public int getChildCount( Object parent ) { if ( parent instanceof RepositoryTreeRoot ) { final RepositoryTreeRoot root1 = (RepositoryTreeRoot) parent; parent = root1.getRoot(); if ( parent == null ) { return 0; } } try { final FileObject parElement = (FileObject) parent; if ( parElement.getType() != FileType.FOLDER ) { return 0; } final FileObject[] children = parElement.getChildren(); int count = 0; for ( int i = 0; i < children.length; i++ ) { final FileObject child = children[i]; if ( isShowFoldersOnly() && child.getType() != FileType.FOLDER ) { continue; } if ( isShowHiddenFiles() == false && child.isHidden() ) { continue; } if ( child.getType() != FileType.FOLDER && PublishUtil.acceptFilter( filters, child.getName().getBaseName() ) == false ) { continue; } count += 1; } return count; } catch ( FileSystemException fse ) { logger.debug( "Failed", fse ); return 0; } } RepositoryTreeModel();  RepositoryTreeModel( final FileObject repositoryRoot, final String[] filters, final boolean showFoldersOnly ); void setShowFoldersOnly( final boolean showFoldersOnly ); boolean isShowFoldersOnly(); boolean isShowHiddenFiles(); void setShowHiddenFiles( final boolean showHiddenFiles ); String[] getFilters(); void setFilters( final String[] filters ); FileObject getFileSystemRoot(); void setFileSystemRoot( final FileObject root ); Object getRoot(); Object getChild( Object parent, final int index ); int getChildCount( Object parent ); boolean isLeaf( final Object node ); void valueForPathChanged( final TreePath path, final Object newValue ); int getIndexOfChild( Object parent, final Object childNode ); void addTreeModelListener( final TreeModelListener l ); void removeTreeModelListener( final TreeModelListener l ); void fireTreeDataChanged(); TreePath getTreePathForSelection( FileObject selectedFolder, final String selection ); static FileObject findNodeByName( final FileObject node, final String name ); }
RepositoryTreeModel implements TreeModel { public int getChildCount( Object parent ) { if ( parent instanceof RepositoryTreeRoot ) { final RepositoryTreeRoot root1 = (RepositoryTreeRoot) parent; parent = root1.getRoot(); if ( parent == null ) { return 0; } } try { final FileObject parElement = (FileObject) parent; if ( parElement.getType() != FileType.FOLDER ) { return 0; } final FileObject[] children = parElement.getChildren(); int count = 0; for ( int i = 0; i < children.length; i++ ) { final FileObject child = children[i]; if ( isShowFoldersOnly() && child.getType() != FileType.FOLDER ) { continue; } if ( isShowHiddenFiles() == false && child.isHidden() ) { continue; } if ( child.getType() != FileType.FOLDER && PublishUtil.acceptFilter( filters, child.getName().getBaseName() ) == false ) { continue; } count += 1; } return count; } catch ( FileSystemException fse ) { logger.debug( "Failed", fse ); return 0; } } RepositoryTreeModel();  RepositoryTreeModel( final FileObject repositoryRoot, final String[] filters, final boolean showFoldersOnly ); void setShowFoldersOnly( final boolean showFoldersOnly ); boolean isShowFoldersOnly(); boolean isShowHiddenFiles(); void setShowHiddenFiles( final boolean showHiddenFiles ); String[] getFilters(); void setFilters( final String[] filters ); FileObject getFileSystemRoot(); void setFileSystemRoot( final FileObject root ); Object getRoot(); Object getChild( Object parent, final int index ); int getChildCount( Object parent ); boolean isLeaf( final Object node ); void valueForPathChanged( final TreePath path, final Object newValue ); int getIndexOfChild( Object parent, final Object childNode ); void addTreeModelListener( final TreeModelListener l ); void removeTreeModelListener( final TreeModelListener l ); void fireTreeDataChanged(); TreePath getTreePathForSelection( FileObject selectedFolder, final String selection ); static FileObject findNodeByName( final FileObject node, final String name );  }