Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Extend the java "run" command in Eclipse(plugin development)
Extend the java "run" command in Eclipse [message #1737785] Tue, 12 July 2016 20:52 Go to next message
Nuno Fonseca is currently offline Nuno FonsecaFriend
Messages: 3
Registered: July 2016
Junior Member
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 08:49 Go to previous messageGo to next message
Felix Dorner is currently offline Felix DornerFriend
Messages: 301
Registered: December 2015
Senior Member
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 13:16 Go to previous messageGo to next message
Nuno Fonseca is currently offline Nuno FonsecaFriend
Messages: 3
Registered: July 2016
Junior Member
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 13:17]

Report message to a moderator

Re: Extend the java "run" command in Eclipse [message #1737944 is a reply to message #1737846] Thu, 14 July 2016 10:03 Go to previous messageGo to next message
Felix Dorner is currently offline Felix DornerFriend
Messages: 301
Registered: December 2015
Senior Member
On 13-Jul-16 15:16, Nuno Fonseca wrote:
> 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?

I have no idea :). Are you able to find the Javadoc for ILaunchListener
and LaunchManager? Maybe that would give you some clues.. Otherwise..
just try it out...


> - In which file should i place this code?
Does your plugin have any other UI elements, or are there any other
actions that the user performs when using it?


Felix
Re: Extend the java "run" command in Eclipse [message #1738129 is a reply to message #1737944] Fri, 15 July 2016 22:09 Go to previous message
Nuno Fonseca is currently offline Nuno FonsecaFriend
Messages: 3
Registered: July 2016
Junior Member
Hi!
Quote:

> - Where should I place my code in launchAdded or launchChanged?

I have no idea Smile. Are you able to find the Javadoc for ILaunchListener
and LaunchManager? Maybe that would give you some clues.. Otherwise..
just try it out...


I will have a look at the JavaDoc and also try both options...

Quote:

> - In which file should i place this code?
Does your plugin have any other UI elements, or are there any other
actions that the user performs when using it?


Right now it is only displaying a MessageDialog to the user with information the in/success of the "snapshot", it's not absolutely necessary and I was actually changing it to a message in the status bar. But in reality it is not crucial for the plugin to work... So in conclusion, I am using some UI elements, but can live without them... Smile
Best regards and thanks a lot for your help.
Nuno
Previous Topic:Building an action in Eclipse to execute several tasks
Next Topic:Need to generate Report dynamically
Goto Forum:
  


Current Time: Thu Jun 27 08:07:03 GMT 2019

Powered by FUDForum. Page generated in 0.04534 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top