java left logo
java middle logo
java right logo
 

Home arrow Other API Tips
 
 
Main Menu
Home
Java Tutorials
Book Reviews
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Java Network
Java Forums
Java Blog




Most Visited Tips
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Book Reviews
Top Rated Tips
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Book Reviews


Statistics
Registered Users: 3947
Java SE Tips: 614
Java ME Tips: 202
Java EE Tips: 183
Other API Tips: 779
Java Applications: 298
Java Libraries: 209
Java Games: 16
Book Reviews:
 
 
 
How to use Retargetable action E-mail
User Rating: / 11
PoorBest 

Sometimes two different views need to behave differently for the same action item in the Menu Bar. For example: In Outlook Express when the calendar page is active and user triggers New action item from the menu then it will open new calendar entry form. And when the Address book is active and user triggers the same action item New through the menu then it will open the new contact entry form.

To implement this type of situation we need to use Retargetable action. Here one example is given to explain this approach.

Example:

Suppose we have two views: AddressView and CalenderView. And there is one action item New in the menu bar. When user selects this action item and AddressView is active, then new Contact entry form should be opened and when the CalenderView is opened then new Calender entry form should be opened. For that there are two action files OpenContactForm and OpenCalenderForm. So this New action item need to be associated with different action file depending on the current active view.

Steps need to be followed for implementing this.

  1. First it needs to declare the retargetable action (New) in the plugin.xml. ActionSets can define retargetable actions. The action is visible only when the corresponding actionSet is visible. But the action will be enabled when a view or editor that implements that action is active.
  2. Following is the code for defining retargetable action in plugin.xml.

    <extension point = "org.eclipse.ui.actionSets">

      <actionSet id="actionSetsID" label="New" visible="true">
        <action id="actionID" menubarPath="" toolbarPath="" 
          label ="Retargatable Action" retarget="true">
        </action>
      </actionSet>

    </extension>

  3. You can associate this retargetable action to the different action files in different views by using globalActionHandler.

    • In CalenderView this action need to be associated with action file OpenCalenderForm using the following code:

    •    getViewSite().getActionBars().setGlobalActionHandler(
          actionID, new OpenCalenderForm ());

    • In AddressView this action need to be associated with action file OpenContactForm using the following code:

    •    getViewSite().getActionBars().setGlobalActionHandler(
          actionID, new OpenContactForm());


 Related Tips

 
< Prev   Next >

Page 1 of 0 ( 0 comments )

You can share your information about this topic using the form below!

Please do not post your questions with this form! Thanks.


Name (required)


E-Mail (required)

Your email will not be displayed on the site - only to our administrator
Homepage(optional)



Comment Enable HTML code : Yes No



 
       
         
     
 
 
 
   
 
 
java bottom left
java bottom middle
java bottom right
RSS 0.91 FeedRSS 1.0 FeedRSS 2.0 FeedATOM FeedOPML Feed

Home - About Us - Privacy Policy
Copyright 2005 - 2008 www.java-tips.org
Java is a trademark of Sun Microsystems, Inc.