/*................................................................................................*/ private boolean hireFillers(String directoryPath) { String[] files = directory.list(); String treePath; for (int i = 0; i < files.length; i++) { if (files[i] != null) { String fileLowerCase = files[i].toLowerCase(); if (fileLowerCase.endsWith(".nex") || fileLowerCase.endsWith(".nexus")) { treePath = directoryPath + MesquiteFile.fileSeparator + files[i]; File treeFile = new File(treePath); String treeFileName = treeFile.getName(); if (StringUtil.blank(treeFileName)) { return false; } TreeBlockFiller newFiller; newFiller = (TreeBlockFiller) hireNamedEmployee(TreeBlockFiller.class, "#SampleOneTreeFromFile"); // treePath); if (newFiller != null) { if (((SampleOneTreeFromFile) newFiller).setFilePath(treePath) && ((SampleOneTreeFromFile) newFiller).processFile()) { fillerTasks.addElement(newFiller); } else Debugg.println( "Filler " + i + " processFile = " + ((SampleOneTreeFromFile) newFiller).processFile()); } } } } return true; }
/*................................................................................................*/ public boolean startJob(String arguments, Object condition, boolean hiredByName) { addMenuItem("Directory for Sample Trees From Directory...", makeCommand("setDirPath", this)); fillerTasks = new Vector(); if (!MesquiteThread .isScripting()) { // enclosed in conditional to avoid hiring query when opening file; should // be handled by snapshot/doCommand when file is opened. String directoryPath = MesquiteFile.chooseDirectory( "Choose directory containing tree files:", previousDirectory); // MesquiteFile.saveFileAsDialog("Base name for files (files will // be named <name>1.nex, <name>2.nex, etc.)", baseName); if (StringUtil.blank(directoryPath)) { // TODO: clean this up? return false; } else { directory = new File(directoryPath); previousDirectory = directory.getParent(); if (directory.exists() && directory.isDirectory()) { return hireFillers(directoryPath); } } } return true; // Add something to make sure directory paths are set up correctly, when not // scripting... }