Associate action to button on an Eclipse RCP application

Discussion in 'Java' started by napo, Jul 14, 2007.

  1. napo

    napo Guest

    Hi all,
    I'm developing an Eclipse (3.3) RCP application and I have a problem.
    I created some custom actions like this:

    public class InsertTableRecordAction extends Action
    implements ISelectionListener, IWorkbenchAction {
    private final IWorkbenchWindow window;
    private IStructuredSelection selection;

    public InsertTableRecordAction(IWorkbenchWindow window) {
    this.window = window;
    setId("InsertTableRecordAction");
    ...
    window.getSelectionService().addSelectionListener(this);
    }

    public void selectionChanged(IWorkbenchPart part, ISelection incoming) {
    selection = (some kind of cast) incoming;
    setEnabled(depends on selection type);
    }
    }

    In the ActionBarAdvisor file I created the actions and filled all the menu
    and tool bar. And it works fine.

    Now, I created an EditorPart with some SWT widgets in it. Some of these
    widgets are normal Button.
    I want to link my custom action to these buttons, so they run the action
    code and they enables concerning the action logic.

    How can I associate an action to a button?

    Thanks
    Marco
     
    napo, Jul 14, 2007
    #1
    1. Advertising

  2. napo

    napo Guest

    I found the solution, using the ActionContributionItem class and the fill()
    method.

    Hi
    Marco
     
    napo, Jul 15, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dominik
    Replies:
    1
    Views:
    641
    Rhino
    Dec 6, 2004
  2. Replies:
    3
    Views:
    1,052
  3. Gerd Rother
    Replies:
    4
    Views:
    1,193
    Gerd Rother
    Mar 31, 2006
  4. Matthias Reining

    Finish a Eclipse RCP application

    Matthias Reining, Apr 12, 2006, in forum: Java
    Replies:
    0
    Views:
    380
    Matthias Reining
    Apr 12, 2006
  5. Replies:
    0
    Views:
    421
Loading...

Share This Page