import org.encog.workbench.dialogs.trainingdata.CreateEmptyTrainingDialog;
import org.encog.workbench.util.FileUtil;
public class CreateNewFile {
public static void performCreateFile() throws IOException {
CreateFileDialog dialog = new CreateFileDialog(EncogWorkBench
.getInstance().getMainWindow());
dialog.setType(CreateFileType.MachineLearningMethod);
if (dialog.process()) {
String name = dialog.getFilename();
if( name==null || name.length()==0 ) {
EncogWorkBench.displayError("Data Missing", "Must specify a filename.");
return;
}
File basePath = EncogWorkBench.getInstance().getMainWindow()
.getTree().getPath();
if (dialog.getType() == CreateFileType.MachineLearningMethod) {
name = FileUtil.forceExtension(new File(name).getName(), "eg");
File path = new File(basePath, name);
if (FileUtil.checkOverWrite(path)) {
CreateNeuralNetwork.process(path);
}
} else if (dialog.getType() == CreateFileType.TextFile) {
name = FileUtil.forceExtension(new File(name).getName(), "txt");
File path = new File(basePath, name);
if (FileUtil.checkOverWrite(path)) {
FileUtil.writeFileAsString(path, "");
}
} else if (dialog.getType() == CreateFileType.CSVFile) {
name = FileUtil.forceExtension(new File(name).getName(), "csv");
File path = new File(basePath, name);
if (FileUtil.checkOverWrite(path)) {
FileUtil.writeFileAsString(path, "");
}
} else if (dialog.getType() == CreateFileType.TrainingFile) {
name = FileUtil.forceExtension(new File(name).getName(), "egb");
File path = new File(basePath, name);
createNewEGB(path);
} else if( dialog.getType() == CreateFileType.NEAT ) {
name = FileUtil.forceExtension(new File(name).getName(), "eg");
File path = new File(basePath, name);
createNewPopulation(path);
}