Extend the java "run" command in Eclipse [message #1737785] |
Tue, 12 July 2016 16:52  |
Eclipse User |
|
|
|
Hi!
As part of a research project, I am working, I need to develop one plug-in that sends a copy of the code that is opened in the editor to a server, each time the programmer (students) runs the code.
I've already done it for the IntelliJ IDE, but now the teachers moved to Eclipse, so I need to do the same thing for Eclipse.
I've developed the part of the code that gets the code from the editor and sends it to the server and it is working if a create a new options menu.
To avoid confusion from the students the action should be performed when the students "compile/run" the code.
My problem is how to call the code i've already developed when the programmer presses the "run" button...
Any ideas, links, etc. will be very welcome, even saying that is not possible to achieve... Tks.
Nuno.
|
|
|
Re: Extend the java "run" command in Eclipse [message #1737817 is a reply to message #1737785] |
Wed, 13 July 2016 04:49   |
Eclipse User |
|
|
|
Hello,
On 12-Jul-16 22:55, Nuno Fonseca wrote:
> Hi!
> As part of a research project, I am working, I need to develop one
> plug-in that sends a copy of the code that is opened in the editor to a
> server, each time the programmer (students) runs the code.
>
> I've already done it for the IntelliJ IDE, but now the teachers moved to
> Eclipse, so I need to do the same thing for Eclipse.
>
> I've developed the part of the code that gets the code from the editor
> and sends it to the server and it is working if a create a new options
> menu.
> To avoid confusion from the students the action should be performed when
> the students "compile/run" the code.
> My problem is how to call the code i've already developed when the
> programmer presses the "run" button...
>
> Any ideas, links, etc. will be very welcome, even saying that is not
> possible to achieve... Tks.
I just quickly checked the docs and: You add a dependency to
org.eclipse.debug.core and then you can use
DebugPlugin.getDefault().getLaunchManager().addLaunchListener() (or
getLaunchesListener(), not sure what the difference is).
Feel free to ask again if you need more help.
Felix
|
|
|
Re: Extend the java "run" command in Eclipse [message #1737846 is a reply to message #1737817] |
Wed, 13 July 2016 09:16   |
Eclipse User |
|
|
|
Hi Felix!
First of all, thank you so much for you answer. Since I am very fresh concerning the development of plugins for Eclipse, I would appreciate if you could help me a little bit mode...
Since I didn't knew how to do it like I wanted, I've created one plugin based on the "Hello, Word Command" and now my code is executed when the option menu is selected:
public void run(IAction action) {
// My code goes here...
}
From what I am understanding, with your suggestion I no longer need to have an Action and the run method, right?
Also, from your answer I think that I need to do something like this...
DebugPlugin.getDefault().getLaunchManager().addLaunchListener(new ILaunchListener() {
public void launchAdded(ILaunch launch) {
// My code goes here ?
}
public void launchChanged(ILaunch launch) {
// or here?
}
public void launchRemoved(ILaunch launch) {
}
});
My questions are:
- Where should I place my code in launchAdded or launchChanged?
- In which file should i place this code?
I hope I was able to explain myself...
Once again, thank you!
Best regards,
Nuno.
[Updated on: Wed, 13 July 2016 09:17] by Moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.07680 seconds