Computered
Computered

Reputation: 490

Single selection and fire selecion of AbstractGraphicalEditPart

I Have an AbstractDecoratedTextEditor and it has a tab with components of AbstractGraphicalEditPart.

I want to

1) Select single components. If I select one component, other componentes was unselected

2) When I select one component, I wan to to fire the selection listenner of eclipse. Because this listenner will change the properties view of Eclipse.

I tried this code for number 2, but not work.

((IFigure) componentFigure).addMouseListener(new MouseAdapter() {
    @Override
    public void mousePressed(MouseEvent arg0) {
        ComponentEditPart.this.setSelected(SELECTED);
        fireSelectionChanged();
        super.mousePressed(arg0);
    }
}

Upvotes: 0

Views: 107

Answers (1)

aboyko
aboyko

Reputation: 1557

There is a selection listener in GEF, but it's on the EditPartViewer. Add a ISelectionChangedListener to your Graphical viewer. Each editpart has a method #getViewer() (i.e. AbstractGraphicalEditPart#getViewer()).

graphicalEditPart.getViewer().addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
// TODO: implement it to handle selection change
}
}};

Upvotes: 1

Related Questions