Skip to main content

Posts

Showing posts from December, 2015

Show Perspective switch bar in Eclipse RCP application

Show Perspective switch bar in Eclipse RCP application Open file ApplicationWorkbenchWindowAdvisor.java in your plug-in project. Override the method, preWindowOpen and as shown below, setShowPerspectiveBar as True. @Override public void preWindowOpen () { IWorkbenchWindowConfigurer configurer = getWindowConfigurer(); configurer.setShowPerspectiveBar( true ); } Run your RCP application, and on Right side top, you will be able to see perspective Switch. Following Books are good to refer :

Create (pulldown) Menu in Toolbar in Eclipse RCP

Create (pulldown) Menu in Toolbar Step 1. Create Toolbar with PullDown Step 2. Create MenuContribution  Step 3. Add items to MenuContribution Step 4. Run the application Step 1. Create Toolbar with PullDown Create your Eclipse RCP application ( with mail template). Suppose open command id is "HarikrushnaVToolbar.open" then create a toolbar with command in it,  as shown below: now, convert the style to "pulldown". Now, if you run the application, you will see a pulldown button next to toolbar icon as follow : Step 2: Create MenuContribution Now, create a MenuContribution, which will define the items for pulldown menu. Define, locationURI to the same name as the menu:commandId , here we provide the LocationURI as "menu:HarikrushnaVToolbar.open" Also Define Class name as "AllMenuItems". Step 3. Add items to MenuContribution Click on " class ", you will see the

Add Method Body Using EMF ( Add code inside EOperaion)

Add Method Body Using EMF ( Add code inside EOperaion ) Steps :  Create Ecore model with Code Create GenModel Verify generated Code 1. Create Ecore model with Code In RCP project create new Ecore model : Now, press on Next and give the name of the Ecore model. Here the name of the Ecore model is given as Office.ecore. Click on "Finish". It will create Ecore model in project. Now provide the name to the package. Here the name is given as "Office" Add a EClass to the package "Office" Give the name of the class as "Employee" Add attribute to the Employee class and give name. Add EOperation to the Class Employee. Give name as "calculateSalary" , set type as "EInt" to the EOperation. Add, EAnnotation to the EOperation "calculateSalary". In properties view, add source to "http://www.eclipse.org/emf/2002/GenModel"

Creating Image Registry in Eclipse RCP

Advantage of Creating Image Registry in Eclipse RCP Share the same image between different plugin. Don't dispose the image and keep it for another plugin. How to create Image Registry? Override the initializeImageRegistry method inside the Activator and you are ready to use t  public class Activator  {       public static final String MY_PLUGIN_ID = "org.harikrushnav.myplugin.name";       public static final String MY_IMAGE_ID = "myimage.save";     ....      @override       protected void initializeImageRegistry(ImageRegistry registry) {                Bundle bundle = Platform.getBundle(MY_PLUGIN_ID);          IPath path = new Path("icons/save_image.gif");          URL url = FileLocator.find(bundle, path, null);          ImageDescriptor desc = ImageDescriptor.createFromURL(url);          registry.put(MY_IMAGE_ID , desc);       }    } How to use in Code : In same plugin : ProfileAction.setImageDescriptor(             i