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 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); }
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); }