function fullFileArray = selectFiles(num, paths)
% selectFiles
%   selectFiles(num, paths) opens up a window to select files and folders
%   num can be any number
%   paths is a cell of paths that the tree stricture will open
%
%   The output is a cell of the selected paths and files

%   Project: IMPACT
%   Title of Code: selectFiles
%   Relevant additional documentation:
%   Developer: Carlos Gonzalez
%   External Dependencies: NA
%
%   Disclaimer
%   CAUTION: It is strongly recommended that changes to this code
%   should be avoided without first consulting with authors.

% num is useless
% the same function signature as old selectFiles.m

if isempty(paths)
    paths = {''};
end
mlsaddedapps = which('mlsaddedapps.jar');
javaaddpath(mlsaddedapps);

iconPath = which('icon.png');
filePath = [matlabroot, '/toolbox/matlab/icons/pageicon.gif'];
folderPath = [matlabroot, '/toolbox/matlab/icons/foldericon.gif'];
strrep(filePath, '/', filesep);
strrep(folderPath, '/', filesep);

strObj = javaObject('mlsaddedapps.TreeDir', [iconPath; filePath; folderPath; paths]);

while (~strObj.finished)
   pause(1);    
end

strings = strObj.fullFileArray;
fullFileArray = cell(numel(strings), 1);
for m = 1:numel(strings)
    fullFileArray{m} = strings(m).toCharArray';
end

