Beispiel #1
0
  public void populateMenu(JMenu menu, int flags) {
    if (flags == (Plugin.MENU_TOOLS | Plugin.MENU_MID)) {
      Sketch sketch = editor.getSketch();
      JMenuItem item = new JMenu("Program Bootloader");
      item.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              run();
            }
          });
      menu.add(item);

      PropertyFile props = sketch.mergeAllProperties();
      String blProgs = props.get("bootloader.upload");
      if (blProgs == null) {
        JMenuItem sub = new JMenuItem("No bootloader programmer defined!");
        item.add(sub);
        return;
      }
      String[] progs = blProgs.split("::");
      for (String prog : progs) {
        JMenuItem sub = new JMenuItem(sketch.parseString(props.get("upload." + prog + ".name")));
        sub.setActionCommand(prog);
        sub.addActionListener(
            new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                doProgram(e.getActionCommand());
              }
            });
        item.add(sub);
      }
    }
  }
 public void setObjectValues() {
   ((JTextField) (fields.get("board"))).setText(sketch.getBoard().getName());
   ((JTextField) (fields.get("core"))).setText(sketch.getCore().getName());
   ((JTextField) (fields.get("compiler"))).setText(sketch.getCompiler().getName());
   ((JTextField) (fields.get("port"))).setText(sketch.getDevice().toString());
   ((JTextField) (fields.get("programmer"))).setText(sketch.getProgrammer());
 }
Beispiel #3
0
  public void run() {
    Sketch sketch = editor.getSketch();

    Board board = sketch.getBoard();
    Core core = sketch.getCore();
    String programmer = sketch.getProgrammer();

    PropertyFile props = sketch.mergeAllProperties();
    String blProgs = props.get("bootloader.upload");

    System.err.println(blProgs);
  }
  public void save() {
    for (String key : fields.keySet()) {
      JComponent comp = fields.get(key);

      if (comp instanceof JTextField) {
        JTextField c = (JTextField) comp;

        if (c.getText().trim().equals("")) {
          sketch.configFile.unset(key);
        } else {
          sketch.configFile.set(key, c.getText());
        }
      } else if (comp instanceof JTextArea) {
        JTextArea c = (JTextArea) comp;

        if (c.getText().trim().equals("")) {
          sketch.configFile.unset(key);
        } else {
          sketch.configFile.set(key, c.getText());
        }
      }
    }

    sketch.saveConfig();
  }
Beispiel #5
0
  public void doProgram(String prog) {
    editor.clearConsole();
    Sketch sketch = editor.getSketch();
    PropertyFile props = sketch.mergeAllProperties();
    editor.message("Programming bootloader using " + prog);
    String bl = sketch.parseString(props.get("bootloader.file"));
    editor.message("Bootloader: " + bl);
    if (bl == null) {
      String url = sketch.parseString(props.get("bootloader.url"));
      if (url != null) {
        editor.error("The bootloader can be downloaded from " + url);
        return;
      }
    }

    sketch.programFile(prog, bl);
  }