Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / July 2007

Tip: Looking for answers? Try searching our database.

Associate action to button on an Eclipse RCP application

Thread view: 
napo - 14 Jul 2007 13:58 GMT
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 - 15 Jul 2007 22:06 GMT
I found the solution, using the ActionContributionItem class and the fill()
method.

Hi
Marco


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.