Archive for the ‘Eclipse’ Category

Eclipse Plugin : Programatically Export/Create/Build WAR file

June 14, 2010
import org.eclipse.core.commands.ExecutionEvent; 

import org.eclipse.core.commands.ExecutionException; 

import org.eclipse.jst.j2ee.internal.web.archive.operations.WebComponentExportDataModelProvider; 


import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory; 

import org.eclipse.wst.common.frameworks.datamodel.IDataModel; 

public class SomeClass{



* @param projectName – Name of the web project

* @param destinationPath – Destination path to create the war (eg: C:\temp\webapp.war)


public void export(String projectName, String destinationPath) throws ExecutionException {

IDataModel model = DataModelFactory.createDataModel(new WebComponentExportDataModelProvider());


model.setProperty(IWebComponentExportDataModelProperties.ARCHIVE_DESTINATION, destinationPath);

model.getDefaultOperation().execute( null, null );


Many thanx to

Eclipse Plugin: Adding an overlay to an ImageDescriptor

June 2, 2010

Here’s the class. This will overlay to the bottom right corner.

import org.eclipse.jface.resource.CompositeImageDescriptor;
import org.eclipse.jface.resource.ImageDescriptor;

public class OverlayImageDescriptor extends CompositeImageDescriptor {
private ImageDescriptor imageDescriptor;
private ImageDescriptor overlayImage;
Point size;
Point overlaySize;

public OverlayImageDescriptor(ImageDescriptor imgDescriptor,ImageDescriptor overlayImage) {

protected void drawCompositeImage(int arg0, int arg1) {
drawImage(getImageDescriptor().getImageData(), 0, 0);
ImageData overlayImageData = getOverlayImage().getImageData();
int xValue = size.x-overlaySize.x;
int yValue = size.y-overlaySize.y;;
drawImage(overlayImageData, xValue, yValue);

protected Point getSize() {
return size;

public void setImageDescriptor(ImageDescriptor imageDescriptor) {
this.imageDescriptor = imageDescriptor;
Rectangle bounds = imageDescriptor.createImage().getBounds();
size=new Point(bounds.width,bounds.height);

public ImageDescriptor getImageDescriptor() {
return imageDescriptor;

public void setOverlayImage(ImageDescriptor overlayImage) {
this.overlayImage = overlayImage;
Rectangle bounds = overlayImage.createImage().getBounds();
overlaySize=new Point(bounds.width,bounds.height);

public ImageDescriptor getOverlayImage() {
return overlayImage;


Eclipse plugins – Programatically get the image associated with a file extension

February 11, 2010

Well this is extremely easy.

String extension="bmp"
Image img = PlatformUI.getWorkbench().getEditorRegistry().getImageDescriptor("test."+extension).createImage();

Or if the file is in the workspace

IContentType ct=IDE.getContentType(iFileObject);

then use the IContentType object to get the image.

Open or trigger eclipse wizard without using an extension point in eclipse

January 18, 2010
Display display = Display.getDefault();
display.asyncExec(new Runnable(){
   public void run() {
      RegistryBrowserWizard wizard = new RegistryBrowserWizard();
      WizardDialog dialog = new WizardDialog(new Shell(), wizard);

Helpful links to understand: FAQ How do I get a Display instance?

Trying to start learning Eclipse GEF? Here’s the best documentations I’ve found so far.

January 4, 2010

If you are looking for good GEF documentation then the chances are you already know how good GEF might be as a plugin. So straightway to the point. These steps are for java developers cause using java models you can get the full potential of GEF.

My advice,

1. Try to understand the basic architecture behind the Eclipse GEF

2. Start following a tutorial for creating an graphical editor using GEF step by step

3. Mess around with the tutorial example editor you just created.

4. Reverse engineer the example to create a simple editor of your choice

5. Start creating your editor using GEF

6. Use google and use the GEF news forum for problems which you will definitely have.

7. Take a break every 30-40 classes.

Some references



3. common sense

4. best way to dig in to something

5. good luck


7. you’ll understand what I mean when you get to this step 😉

Live Editing a Web Service or Making use of Axis2 Hotupdate feature in a cool way.

October 17, 2009

This is to inform that we now support the feature of making use of the hotupdate feature in axis2 web service feature.  Try this tutorial for more details. Basically it allows you to test your web service while you edit it. Really cool.

How to write a axis2 web service within seconds

October 9, 2009

It is literally within seconds, given that you already have the java class which you intend to make it a web service.  Here’s the link Will write a web service  which would be more close to a real world scenario next time. Any thoughts of improvement is welcome.

How to write a web service client with just 3 steps

October 9, 2009

I recently wrote an I article to WSO2 OT regarding creating a client to consume or should I say access a web service. Didn’t explain a complex scenario though. Only showed the simple case of accessing a Web Service. This is the link to access the tutorial Thinking of writing a tutorial with a more complex scenario of handling security or binary uploads/downloads.

WSO2 Eclipse IDE Tools Released

March 3, 2009

After a lot of hard work for the past few months, finally released the new wso2 eclipse ide tools for the public. Without beating by the bush I’ll just say whats on it.

    * Create Web services
    * Create web service client
    * Convert WSDL 1.1 to 2.0 and vice versa
    * Module and service validators
    * Creating wsdl from a java class
    * Create Axis2 archives
    * Hot update a Web service
    * Debug Web services
    * Test Web services
    * Creating Bpel archives for deploy
    * Start WSAS 3.0.x inside Eclipse
    * Run multiple instances of WSAS inside eclipse

You can get them from or via the online update site

I know its not much but I firmly believe they will be very helpful for the developers.  Hope everyone would like it and find it useful for their work.

Have fun.

How to programatically add classpaths to an eclipse project

December 3, 2008

This is very easy, All you need is the name of the project or IProject it self and the jar path list.

   public static void setClassPathToNewLibs(String projectName,String[] jarPathList){
        IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
        try {
            IJavaProject javaProject = (IJavaProject)project.getNature(JavaCore.NATURE_ID);
            IClasspathEntry[] rawClasspath = javaProject.getRawClasspath();
            List list = new LinkedList(java.util.Arrays.asList(rawClasspath));
            for(String path:jarPathList){
                String jarPath = path.toString();
                boolean isAlreadyAdded=false;
                for(IClasspathEntry cpe:rawClasspath){
                    if (isAlreadyAdded) break;
                if (!isAlreadyAdded){
                    IClasspathEntry jarEntry = JavaCore.newLibraryEntry(new Path(jarPath),null,null);
            IClasspathEntry[] newClasspath = (IClasspathEntry[])list.toArray(new IClasspathEntry[0]);
        } catch (CoreException e) {


Should work for any kind of eclipse project I guess.