Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Opening dialog from E4 command/handler(Opening a dialog from Eclipse 4 command/handler)
Opening dialog from E4 command/handler [message #1219427] Tue, 03 December 2013 19:46 Go to next message
Joseph Gagnon is currently offline Joseph GagnonFriend
Messages: 68
Registered: June 2013
Member
I have developed a simple E4 application that is using JavaFX as the renderer. I am also using e(fx)clipse libraries to implement the dialogs. I have set up a command and handler in the .e4xmi file that I have attached to a menu. I would like to be able to trigger the opening of a dialog from one of those commands, but am not sure know how to do it.

I tried using injection to make the dialog available to the handler execute() method, but that did not work (didn't seem like the right way anyway). My next thought was to post some sort of event from the handler that another event handler could then intercept and react to. Does that make any sense or is there a better way?
Re: Opening dialog from E4 command/handler [message #1219447 is a reply to message #1219427] Tue, 03 December 2013 22:03 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
On 03.12.13 20:46, Joseph Gagnon wrote:
> I have developed a simple E4 application that is using JavaFX as the
> renderer. I am also using e(fx)clipse libraries to implement the
> dialogs. I have set up a command and handler in the .e4xmi file that I
> have attached to a menu. I would like to be able to trigger the opening
> of a dialog from one of those commands, but am not sure know how to do it.
>
> I tried using injection to make the dialog available to the handler
> execute() method, but that did not work (didn't seem like the right way


To make it available in the execute the dialog class needs to be
registered in the IEclipseContext.

> anyway). My next thought was to post some sort of event from the handler
> that another event handler could then intercept and react to. Does that
> make any sense or is there a better way?

Sort of, the other possibility is that you treat your PartImpl as the
Controller to your UI


public class MyPart {

@PostConstruct
void init(IEclipseContext ctx, ....) {
ctx.put(MyPart.class,this);
}

public void openDialog() {
// your dialog code
}
}


public class Handler {
void run(MyPart p) {
p.openDialog();
}
}
Re: Opening dialog from E4 command/handler [message #1219539 is a reply to message #1219447] Wed, 04 December 2013 14:03 Go to previous messageGo to next message
Joseph Gagnon is currently offline Joseph GagnonFriend
Messages: 68
Registered: June 2013
Member
> To make it available in the execute the dialog class needs to be registered in the IEclipseContext.

How (and when and where) do I register the dialog? Does a dialog object need to be instantiated?
Re: Opening dialog from E4 command/handler [message #1219579 is a reply to message #1219427] Wed, 04 December 2013 17:58 Go to previous messageGo to next message
Joseph Gagnon is currently offline Joseph GagnonFriend
Messages: 68
Registered: June 2013
Member
I guess what I'm really trying to understand is how to hook up E4 command handlers to do things in general, not just opening a dialog. Does the use of the application (or eclipse) context play an important role in this regard?

I need more examples I can look at where the underlying major players in eclipse 4 are used.
Re: Opening dialog from E4 command/handler [message #1219714 is a reply to message #1219447] Thu, 05 December 2013 14:31 Go to previous messageGo to next message
Joseph Gagnon is currently offline Joseph GagnonFriend
Messages: 68
Registered: June 2013
Member
OK, I think maybe I understand. I guess this is a variation on injection.

Let me know if I have this right. In some application class, I provide a means to execute needed code (in this case, opening a dialog). I register that class with the eclipse context like the following:

public class MainPanePart {

  @Inject
  private MApplication application;

  @PostConstruct
  public void init(BorderPane parent) {
    application.getContext().set(MainPanePart.class, this);
    ...
  }

  public void openDialog() {
    ...
  }

  ...
}


Then, in my handler class I "inject" the class above as an argument to the execute() method and execute my class logic as follows:

public class SearchHandler {

  @Execute
  public void execute(MainPanePart part) {
    System.out.println("SearchHandler called");
    part.openDialog();
  }

}


I've tried this and it appears to work. Is this the gist of how E4 command handlers are "attached" to business logic to execute the desired functionality?
Re: Opening dialog from E4 command/handler [message #1219854 is a reply to message #1219714] Fri, 06 December 2013 09:56 Go to previous message
Eclipse UserFriend
Yes
Previous Topic:PERSPECTIVE_BAR_EXTRAS and SHOW_OPEN_ON_PERSPECTIVE_BAR settings not taken into account
Next Topic:Can't find contributed HandledToolItem in MApplication
Goto Forum:
  


Current Time: Tue Apr 16 22:57:42 GMT 2024

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

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

Back to the top