8

I'm using GEF. I have a graphical editor with some "boxes" implemented. Now, I want to add a double-click listener to each box (Rectangle). I tried to add a listener to the GraphicalViewer but it did not work.

Veger
  • 37,240
  • 11
  • 105
  • 116
jean24
  • 189
  • 3
  • 9

3 Answers3

17

In the GraphicalEditPart of the "box" for which you want to add the listener, you have to override the performRequest(Request req) method. When the framework identifies a double-click on the part's figure, it calls this method with a request that has req.getType()==RequestConstants.REQ_OPEN. You can take over from here. Complete code to test that his works:

@Override
public void performRequest(Request req) {
    if(req.getType() == RequestConstants.REQ_OPEN) {
        System.out.println("requested double-click."); 
    }
}

Hope this does the trick.

Balázs Édes
  • 13,452
  • 6
  • 54
  • 89
vainolo
  • 6,907
  • 4
  • 24
  • 47
0
viewer.getControl().addListener(SWT.MouseDoubleClick, new Listener() {

        @Override
        public void handleEvent(Event event) {
        //write the double click action
    });
Raj Perumalsamy
  • 156
  • 1
  • 1
  • 11
0

I am not familiar with GEF myself, however I found this in documentation:

  1. GraphicalEditor abstraction sets the EditDomain - handler for editing events
  2. EditDomain interface with methods for handling events - e.g. double click
  3. Tutorial on how to implement editing of models through GUI in GEF (using EditDomain)
Gabriel Ščerbák
  • 18,240
  • 8
  • 37
  • 52
  • As far as I can see this does absolutely not help with the problem. Each 'object' has an EditPart and interacting with objects is done using these EditParts. Your answer contains likes to APIs of the editor itself. So even if would be possible to catch double-clicks and react on it, it is not the preferred way as your are circumventing the GEF framework. Please correct me, if I am wrong. – Veger Feb 14 '12 at 13:37