Go Down

Topic: [Feature Request] Editor "Plugins/Tools" additional functions (Read 1 time) previous topic - next topic


As I don't give up so easily
I have now found a solution.
That don't uses the additional modifications to the Arduino source code as stated in previous post.

by having following init method in "extension" main class
Code: [Select]

public void init(Editor editor) { // required by tool loader
    this.editor = editor;

    editor.addWindowListener(new WindowAdapter() {
        public void windowOpened(WindowEvent e) {  init(); }
        public void windowClosed(WindowEvent e) { DisconnectServers(); } // this ensure that Disconnect is done on closed "Editors"
    editor.addComponentListener( new ComponentListener() {
        public void componentResized( ComponentEvent e ) {}
        public void componentMoved( ComponentEvent e ) {}
        public void componentShown( ComponentEvent e ) {}
        public void componentHidden( ComponentEvent e ) { DisconnectServers(); }
    } );

in the beginning of init have this:
Code: [Select]

if (PreferencesData.getBoolean("manicken.apiWebServer.DoDisconnectOnOtherEditors", true))

if (PreferencesData.getBoolean("manicken.apiWebServer.closeOtherEditors", false))

in the end of init method have this:
Code: [Select]

Timer timer = new Timer();
timer.schedule(new TimerTask(){
    public void run() {
}, 1000);

the above ensures that there is enough time for the previous servers to close down.

CloseOtherEditors & DoDisconnectOnOtherEditors implementations:
Code: [Select]

public static void CloseOtherEditors(Editor thisEditor)
    Base _base = (Base) Reflect.GetField("base", thisEditor);
    List<Editor> editors = _base.getEditors();
    boolean anyStopped = false;
    for (int ei = 0; ei < editors.size(); ei++)
        Editor _editor = editors.get(ei);
        if (thisEditor == _editor)
        _base.handleClose(_editor); // close other

public static void DoDisconnectOnOtherEditors(Editor thisEditor)
    Base _base = (Base) Reflect.GetField("base", thisEditor);
    List<Editor> editors = _base.getEditors();
    boolean anyStopped = false;
    for (int ei = 0; ei < editors.size(); ei++)
        Editor _editor = editors.get(ei);
        if (thisEditor == _editor)
        _editor.setVisible(false); // this triggers the componentHidden event
    // this makes the last editor window topmost

There is still a issue with the solution:
When not using the autoclose function
and closing the prev. editor window the midi device is disconnected.
But if that happens then I only need to go to
the extension menu and click on Start/Restart.

At least the Arduino IDE don't need to be completely restarted each time
the "Stop" extension menu item is forgotten to be used.

All the above also makes it possible to just open prev. sketch
after I have done a recompile of the "extension", without any extra issues.


Here is a list of all "extensions" I have developed so far:

1. https://github.com/manicken/arduinoAPIwebserver
this is developed mostly for my extended edition of
"Audio System Design Tool for Teensy Audio Library"
@ https://github.com/manicken/manicken.github.io (have readme)
webpage is @ https://manicken.github.io/

* WebServer for POST(ing) the JSON
which contains the exported Files,
it uses the GET request to execute
the Verify and Upload functions.

* WebSocketServer for Arduino Terminal Capture
used for send the terminal output from Arduino IDE
back to the webpage.

* WebSocketServer used to send data to/from the GUI - items
currently only used to send/receive midi commands,
but standard serial port is planned.

here is a thread describing the extended tool (same content as the readme):

2. https://github.com/manicken/arduinoPrefsSaver
makes it possible to have individual board settings for each "sketch".

3. https://github.com/manicken/arduinoIDEpluginTemplate
just a "extension" template.

4. https://github.com/manicken/arduinoIDEsketchBuildPath
make the build output the files to a build subfolder in the sketch
this ensures that there is no need to do a full compile every time the
sketch is reopened,
(this is a time saver on very big projects that take a lot time to compile)

5. https://github.com/manicken/arduinoUploadOnly
changes the behavior of the upload button so that it only
executes the upload function,
(this is a time saver when uploading to targets that often fail at the upload)
6. https://github.com/manicken/arduinoExtendedPrint
makes it possible to print the sketch in color/(black & white)
with or without line numbers.
A print preview is shown (where enabling/disabling color print,
and if line numbers should be shown)
There is two print options, the Alt one can be used on mac when print to PDF is used,
the downside with the Alt version is that paper orientation is current locked to Landscape,
setting will be available in future version.


now I have moved the AutoComplete functionality embedded into the API_WebServer
 to a separate repository
this autocomplete extension
is using 
because it's also the creator of RSyntaxTextArea
which is used by the Arduino IDE text editor

In this stage it can only be activated by ctrl+space
and contains no Arduino Keywords (only default C/C++ syntax)
I'm planning to do a automatic keyword generator that is gonna do a search in the embedded documentation.

Go Up