public void startPrint(String name)
      throws BadFieldException, PreprocessorException, ProcessorException, PostProcessorException {
    PrintJobSelection job;
    job = db.getPrintJobSelection(name);

    PrintJobConfiguration printJob;
    printJob = db.getPrintJobConfiguration(job);

    Normalizer normalizer = new Slic3rNormalizerImpl();
    SlicingEngineWrapper slicer = new Slic3rSlicingEngineWrapperImpl();
    PostProcessor post = new Slic3rPostProcessorImpl();

    normalizer.normalize(printJob);
    slicer.generateGCode(printJob);
    post.postprocess(printJob);

    StatusController statusController = new StatusController(printJob);
    statusController.display();
  }
 public ArrayList<String> loadPrintJobSelection(String name) {
   ArrayList<String> list = new ArrayList();
   PrintJobSelection job;
   job = db.getPrintJobSelection(name);
   list.add(job.getName());
   list.add(job.getPrinterConfiguration());
   MasterSubsectionPane pane = MainWindow.printJobPanel.getMasterSubsectionPane();
   pane.removeAllSubsections();
   for (SubsetSelection subset : job.getSubsetConfigurationList()) {
     pane.addNewSubsectionPanel(new SubsectionPanel(subset));
   }
   for (ExtruderMaterialSelection extruder : job.getMaterials()) {
     PrintJobPanel.extruderMaterialArrayListForPrintJob.add(extruder.getMaterial());
   }
   return list;
 }
  public Boolean savePrintJobConfiguration(
      String name,
      String printerName,
      ArrayList<SubsectionPanel> panels,
      JList extruderMaterialsMapList)
      throws BadFieldException {
    PrintJobSelection job = new PrintJobSelection();
    PrinterConfiguration printer = db.getPrinterConfiguration(printerName);
    job.setName(name);
    job.setPrinterConfiguration(printerName);
    if (printer.getExtruderList().size()
        < PrintJobPanel.extruderMaterialArrayListForPrintJob.size())
      throw new BadFieldException("You can not assign more Materials than you have extruders.");
    ArrayList<ExtruderMaterialSelection> extruderMaterialSelection = new ArrayList<>();
    for (int i = 0; i < PrintJobPanel.extruderMaterialArrayListForPrintJob.size(); i++) {
      extruderMaterialSelection.add(
          new ExtruderMaterialSelection(
              printer.getExtruderList().get(i).getName(),
              PrintJobPanel.extruderMaterialArrayListForPrintJob.get(i)));
    }
    job.setMaterials(extruderMaterialSelection);

    job.setSubsetConfigurationList(new ArrayList<SubsetSelection>());
    for (int i = 0; i < panels.size(); i++) {

      SubsetSelection subset = new SubsetSelection();

      if (panels.get(i).getFileList().size() != panels.get(i).getExtruderList().size()) {
        throw new BadFieldException("All files must have a material associated with it.");
      }

      subset.setFileConfigurations(new ArrayList<FileSelection>());

      for (int j = 0; j < panels.get(i).getFileList().size(); j++) {
        String extruderName = panels.get(i).getExtruderList().get(j);
        int extruderNum = Integer.parseInt(extruderName.substring(0, 2));
        String materialName =
            PrintJobPanel.extruderMaterialArrayListForPrintJob.get(j).substring(3);
        String fileName = panels.get(i).getFileList().get(j);

        FileSelection fileSelection = new FileSelection(extruderName, materialName, fileName);
        fileSelection.setExtruderNum(extruderNum);

        /*
        for(int k = 0; k < PrintJobPanel.extruderMaterialArrayListForPrintJob.size(); k++) {
            if(PrintJobPanel.extruderMaterialArrayListForPrintJob.get(k).equals(extruderName)) {
                fileSelection.setExtruderNum(k);
            }
        }
        */

        subset.getFileConfigurations().add(fileSelection);

        subset.setPrintConfiguration(panels.get(i).getPrint());
      }
      try {
        d = Double.valueOf(panels.get(i).getStartZ());
        if (d < 0)
          throw new BadFieldException(
              "Subset start must be a double precision value greater than or equal to 0.");
        subset.setBottomZ(d);
      } catch (NumberFormatException e) {
        throw new BadFieldException(
            "Subset start must be a double precision value greater than or equal to 0.");
      }

      try {
        d = Double.valueOf(panels.get(i).getFinishZ());
        if (d < 0)
          throw new BadFieldException(
              "Subset finish must be a double precision value greater than or equal to 0.");
        subset.setTopZ(d);
      } catch (NumberFormatException e) {
        throw new BadFieldException(
            "Subset finish must be a double precision value greater than or equal to 0.");
      }
      job.getSubsetConfigurationList().add(subset);
    }
    return db.savePrintJobSelection(job);
  }
 public PrintJobConfiguration loadPrintJobConfiguration(PrintJobSelection selected) {
   return db.getPrintJobConfiguration(selected);
 }
 public ArrayList<String> loadAvailableMaterials() {
   return db.getMaterialConfigurations();
 }
 public ArrayList<String> loadAvailableExtruders() {
   return db.getExtruderConfigurations();
 }
 public ArrayList<String> loadAvailablePrints() {
   return db.getPrintConfigurations();
 }
 public void deletePrintJobSelection(String name) {
   db.deletePrintJobSelection(name);
 }
 ArrayList<String> loadAvailablePrintJobs() {
   return db.getPrintJobSelectionss();
 }
 ArrayList<String> loadAvailableFiles() {
   return db.getStlFiles();
 }