Friday, 25 November 2016

Ionic Mobile App Tutorial


Friday, 8 January 2016

Open Eclipse RCP application as maximized

Open Eclipse RCP application as maximized

Open File :

ApplicationWorkbenchWindowAdvisor.java in you RCP application and override the method "postWindowOpen()" and write the code as mentioned below :

@Override
 public void postWindowOpen() {
  super.postWindowOpen();
  IWorkbenchWindowConfigurer configurer = getWindowConfigurer();

  configurer.getWindow().getShell().setMaximized( true );
 }

Following Books are good to refer :


Wednesday, 30 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 dialogbox as shown below :


Click on Finish.
Now, go to MANIFEST.MF and add "org.eclipse.core.expressions" to "Required Plug-ins".

Enter code as follow in the AllMenuItems.java file


Code :
===========
public void createContributionItems(IServiceLocator serviceLocator,IContributionRoot additions) {

CommandContributionItemParameter commandContributionItemParameter = new CommandContributionItemParameter(
                serviceLocator, "",
                "org.eclipse.ui.file.exit",
                SWT.PUSH);
commandContributionItemParameter.label = "Exit the application";
commandContributionItemParameter.icon = Activator.getImageDescriptor("icons/alt_window_16.gif");

        CommandContributionItem commandContributionItem = new CommandContributionItem(commandContributionItemParameter);
        commandContributionItem.setVisible(true);
        additions.addContributionItem(commandContributionItem, null);
}


============



Step 4. Run the application

Run your application and your toolbar with Menu is ready.





Monday, 28 December 2015

Add Method Body Using EMF ( Add code inside EOperaion)

Add Method Body Using EMF ( Add code inside EOperaion )


Steps : 
  1. Create Ecore model with Code
  2. Create GenModel
  3. Verify generated Code



1. Create Ecore model with CodeIn 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"


Now, Add Details Entry by right clicking on EAnnotation and selecting New Child.
In Properties view, enter "body" in Key .

In body part, enter the code you want to define in the method
E.g.
int i=10;
i=i*200;
return i;

2. Create Gen model

Create Generate Model, by clicking on new and select "EMF Generator Model"

Give name as , "Office.genmodel" to the generator model. ( you can give any name with prefix ".genmodel" to this Generator model file.
Generate the Gen Model from the "Ecore Model" and select the office.ecore model from the directory.


Select Finish and, GenModel is ready now.


Right click on the Gen model and select "Generate Model Code".


3. Verify generated Code

In the class EmployeeImpl, you check the method "calculateSalary()", it will contains the code which you want to enter into the method. 





Wednesday, 9 December 2015

Creating Image Registry in Eclipse RCP


Advantage of Creating Image Registry in Eclipse RCP


  1. Share same image between different plugin.
  2. Don't dispose the image and keep it for another plugin.



How to crate 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(
            imageRegistry.getDescriptor( Activator.MY_IMAGE_ID) );

In Different plugin :

AbstractUIPlugin.imageDescriptorFromPlugin( "org.harikrushnav.myplugin.name", "myimage.save" );

Saturday, 8 November 2014

How to get Workspace location in Eclipse RCP Plug-in ?

Try following :


//get object which represents the workspace
IWorkspace workspace = ResourcesPlugin.getWorkspace();

//get location of workspace (java.io.File)
File workspaceDirectory = workspace.getRoot().getLocation().toFile()


Add Following Package to dependency in Manifiest.MF
org.eclipse.core.resources