Exemplo n.º 1
0
 /** @return True if any of the elements of the build are modified; false otherwise */
 public boolean hasModifiedElements() {
   boolean rv = false;
   for (BuildElement e : elements) {
     if (e.isModified()) {
       rv = true;
     }
   }
   return rv;
 }
Exemplo n.º 2
0
 public Build(String path) throws IOException {
   hasMainWindow = false;
   if (path == null) {
     mainFilename = null;
     name = "Untitled";
     folder = new File("~");
     BuildElement code = new BuildCode(null, null);
     openedElement = code;
     code.setModified(true);
     elements.add(code);
   } else {
     File mainFile = new File(path);
     mainFilename = mainFile.getName();
     String suffix = "";
     int lastIdx = mainFilename.lastIndexOf('.');
     if (lastIdx > 0) {
       suffix = mainFilename.substring(lastIdx + 1);
       name = mainFilename.substring(0, lastIdx);
     } else {
       name = mainFilename;
     }
     String parentPath = new File(path).getParent();
     if (parentPath == null) {
       parentPath = ".";
     }
     folder = new File(parentPath);
     if ("stl".equalsIgnoreCase(suffix)
         || "obj".equalsIgnoreCase(suffix)
         || "dae".equalsIgnoreCase(suffix)) {
       modelFile = mainFile;
     }
     loadCode();
     loadModel();
     if (("gcode".equalsIgnoreCase(suffix) || "ngc".equalsIgnoreCase(suffix))
         && getCode() != null) {
       openedElement = getCode();
     } else {
       openedElement = getModel();
     }
   }
 }
Exemplo n.º 3
0
  public BuilderElement makeBuilder(Component cpt) throws ContentError, ParseError {
    String psel = cpt.getPathParameterPath(pFrom);
    SelectionParser sp = new SelectionParser();
    SelectionExpression pselexp = sp.parse(psel);

    String qsel = cpt.getPathParameterPath(qFrom);
    SelectionExpression qselexp = sp.parse(qsel);

    GatherPairsBuilder ret = new GatherPairsBuilder(pselexp, qselexp, collection);

    // TODO shouldn't need to put this in explicitly
    super.makeChildBuilders(cpt, ret);
    return ret;
  }
Exemplo n.º 4
0
  /**
   * path is location of the main .gcode file, because this is also simplest to use when opening the
   * file from the finder/explorer.
   */
  public Build(MainWindow editor, String path) throws IOException {
    hasMainWindow = true;
    this.editor = editor;
    if (path == null) {
      mainFilename = null;
      name = "Untitled";
      folder = new File("~");
      BuildElement code = new BuildCode(null, null);
      openedElement = code;
      code.setModified(true);
      elements.add(code);
    } else {

      File mainFile = new File(path);
      mainFilename = mainFile.getName();
      String suffix = "";
      int lastIdx = mainFilename.lastIndexOf('.');
      if (lastIdx > 0) {
        suffix = mainFilename.substring(lastIdx + 1);
        name = mainFilename.substring(0, lastIdx);
      } else {
        name = mainFilename;
      }

      // protect against loading files that may have caused a crash last time
      File crashCheck = new File(name + ".crash");
      if (crashCheck.exists()) {
        crashCheck.delete();
        int op =
            JOptionPane.showConfirmDialog(
                null,
                "It looks as though ReplicatorG may have crashed\n"
                    + "last time it tried to load this file.\nRe-loading the same file could cause another crash,\n"
                    + "would you like to load this file anyway?",
                "Remnants of a crash detected!",
                JOptionPane.OK_OPTION,
                JOptionPane.WARNING_MESSAGE);
        if (op != 0) return;
      }
      crashCheck.createNewFile();

      String parentPath = new File(path).getParent();
      if (parentPath == null) {
        parentPath = ".";
      }
      folder = new File(parentPath);
      if ("stl".equalsIgnoreCase(suffix)
          || "obj".equalsIgnoreCase(suffix)
          || "dae".equalsIgnoreCase(suffix)) {
        modelFile = mainFile;
      }
      loadCode();
      loadModel();
      if (("gcode".equalsIgnoreCase(suffix) || "ngc".equalsIgnoreCase(suffix))
          && getCode() != null) {
        openedElement = getCode();
      } else {
        openedElement = getModel();
      }

      crashCheck.delete();
    }
  }