예제 #1
0
  /** This is executed every time we launch the tool using the menu item in Processing IDE */
  public void run() {
    GCScheme.makeColorSchemes();

    //		Base base = editor.getBase();
    Sketch sketch = editor.getSketch();
    File sketchFolder = sketch.getFolder();
    File sketchbookFolder = Base.getSketchbookFolder();

    // Provide a warning (first time only) if G4P is not loaded
    if (!g4p_error_shown && !g4pJarExists(Base.getSketchbookLibrariesFolder())) {
      Base.showWarning(
          "GUI Builder error",
          "Although you can use this tool the sketch created will not \nwork because the G4P library needs to be installed.\nSee G4P at http://www.lagers.org.uk/g4p/",
          null);
      g4p_error_shown = true;
    }
    // The tool is not open so create the designer window
    if (dframe == null) {
      // If the gui.pde tab does not exist create it
      if (!guiTabExists(sketch)) {
        sketch.addFile(new File(sketchbookFolder, G4P_TOOL_DATA_FOLDER + SEP + PDE_TAB_NAME));
      }
      // Create data folder if necessary
      sketch.prepareDataFolder();

      // Create a sub-folder called 'GUI_BUILDER_DATA' inside the sketch folder if
      // it doesn't already exist
      File configFolder = new File(sketchFolder, CONFIG_FOLDER);
      if (!configFolder.exists()) {
        configFolder.mkdir();
      }
      dframe = new GuiDesigner(editor);
      System.out.println("===================================================");
      System.out.println("   G4PTool V2.2.1 created by Peter Lager");
      System.out.println("===================================================");

      //			try {
      //				BufferedImage img = ImageIO.read(new File(sketchbookFolder, G4P_TOOL_DATA_FOLDER + SEP +
      // "default_gui_palette.png"));
      //				System.out.println("Image " + img);
      //			} catch (IOException e) {
      //				System.out.println("Unable to load colour schemes");
      //				e.printStackTrace();
      //			}
    }
    // Design window exists so make visible, open to normal size
    // and bring to front.
    dframe.setVisible(true);
    dframe.setExtendedState(JFrame.NORMAL);
    dframe.toFront();
  }
예제 #2
0
  protected void updateContributionListing() {
    if (editor != null) {
      List<Contribution> contributions = new ArrayList<Contribution>();

      List<Library> libraries = new ArrayList<Library>(editor.getMode().contribLibraries);

      // Only add core libraries that are installed in the sketchbook
      // https://github.com/processing/processing/issues/3688
      // libraries.addAll(editor.getMode().coreLibraries);
      final String sketchbookPath = Base.getSketchbookLibrariesFolder().getAbsolutePath();
      for (Library lib : editor.getMode().coreLibraries) {
        if (lib.getLibraryPath().startsWith(sketchbookPath)) {
          libraries.add(lib);
        }
      }

      contributions.addAll(libraries);

      Base base = editor.getBase();

      List<ToolContribution> tools = base.getToolContribs();
      contributions.addAll(tools);

      List<ModeContribution> modes = base.getModeContribs();
      contributions.addAll(modes);

      List<ExamplesContribution> examples = base.getExampleContribs();
      contributions.addAll(examples);

      //    ArrayList<LibraryCompilation> compilations = LibraryCompilation.list(libraries);
      //
      //    // Remove libraries from the list that are part of a compilations
      //    for (LibraryCompilation compilation : compilations) {
      //      Iterator<Library> it = libraries.iterator();
      //      while (it.hasNext()) {
      //        Library current = it.next();
      //        if (compilation.getFolder().equals(current.getFolder().getParentFile())) {
      //          it.remove();
      //        }
      //      }
      //    }

      contribListing.updateInstalledList(contributions);
    }
  }