Ejemplo n.º 1
0
 //  public void addPackageList(HashMap<String,Library> importToLibraryTable) {
 public void addPackageList(Map<String, List<Library>> importToLibraryTable) {
   //    PApplet.println(packages);
   for (String pkg : packageList) {
     //          pw.println(pkg + "\t" + libraryFolder.getAbsolutePath());
     //      PApplet.println(pkg + "\t" + getName());
     //      Library library = importToLibraryTable.get(pkg);
     List<Library> libraries = importToLibraryTable.get(pkg);
     if (libraries == null) {
       libraries = new ArrayList<Library>();
       importToLibraryTable.put(pkg, libraries);
     } else {
       if (Base.DEBUG) {
         System.err.println("The library found in");
         System.err.println(getPath());
         System.err.println("conflicts with");
         for (Library library : libraries) {
           System.err.println(library.getPath());
         }
         System.err.println("which already define(s) the package " + pkg);
         System.err.println("If you have a line in your sketch that reads");
         System.err.println("import " + pkg + ".*;");
         System.err.println("Then you'll need to first remove one of those libraries.");
         System.err.println();
       }
     }
     libraries.add(this);
   }
 }
Ejemplo n.º 2
0
  public static List<Library> list(File folder) {
    List<Library> libraries = new ArrayList<Library>();
    List<File> librariesFolders = new ArrayList<File>();
    librariesFolders.addAll(discover(folder));

    for (File baseFolder : librariesFolders) {
      libraries.add(new Library(baseFolder));
    }

    // Support libraries inside of one level of subfolders? I believe this was
    // the compromise for supporting library groups, but probably a bad idea
    // because it's not compatible with the Manager.
    String[] folderNames = folder.list(junkFolderFilter);
    if (folderNames != null) {
      for (String subfolderName : folderNames) {
        File subfolder = new File(folder, subfolderName);

        if (!librariesFolders.contains(subfolder)) {
          List<File> discoveredLibFolders = discover(subfolder);
          for (File discoveredFolder : discoveredLibFolders) {
            libraries.add(new Library(discoveredFolder, subfolderName));
          }
        }
      }
    }
    return libraries;
  }
Ejemplo n.º 3
0
  public static List<File> discover(File folder) {
    List<File> libraries = new ArrayList<File>();
    String[] folderNames = folder.list(junkFolderFilter);

    // if a bad folder or something like that, this might come back null
    if (folderNames != null) {
      // alphabetize list, since it's not always alpha order
      // replaced hella slow bubble sort with this feller for 0093
      Arrays.sort(folderNames, String.CASE_INSENSITIVE_ORDER);

      for (String potentialName : folderNames) {
        File baseFolder = new File(folder, potentialName);
        File libraryFolder = new File(baseFolder, "library");
        File libraryJar = new File(libraryFolder, potentialName + ".jar");
        // If a .jar file of the same prefix as the folder exists
        // inside the 'library' subfolder of the sketch
        if (libraryJar.exists()) {
          String sanityCheck = Sketch.sanitizeName(potentialName);
          if (sanityCheck.equals(potentialName)) {
            libraries.add(baseFolder);

          } else {
            String mess =
                "The library \""
                    + potentialName
                    + "\" cannot be used.\n"
                    + "Library names must contain only basic letters and numbers.\n"
                    + "(ASCII only and no spaces, and it cannot start with a number)";
            Messages.showMessage("Ignoring bad library name", mess);
            continue;
          }
        }
      }
    }
    return libraries;
  }