Associate action to button on an Eclipse RCP application

N

napo

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
 
N

napo

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

Hi
Marco
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,815
Latest member
treekmostly22

Latest Threads

Top