Archive for the ‘plugins’ 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.jst.j2ee.web.datamodel.properties.IWebComponentExportDataModelProperties; 

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.PROJECT_NAME,projectName);

model.setProperty(IWebComponentExportDataModelProperties.ARCHIVE_DESTINATION, destinationPath);

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

}

}
Many thanx to http://www.eclipse.org/webtools/jst/components/j2ee/scenarios/WTPApis.html
Advertisements

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;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;

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

public OverlayImageDescriptor(ImageDescriptor imgDescriptor,ImageDescriptor overlayImage) {
setImageDescriptor(imgDescriptor);
setOverlayImage(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);
      dialog.create();
      dialog.open();
   }
});

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

1. http://wiki.eclipse.org/GEF_Description

2. http://www.eclipsecon.org/2008/?page=sub/&id=102

3. common sense

4. best way to dig in to something

5. good luck

6. http://www.eclipse.org/forums/index.php?t=thread&frm_id=81&

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 http://wso2.org/library/tutorials/live-edit-your-axis2-web-service-using-eclipse 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 http://wso2.org/library/tutorials/create-axis2-web-service-3-steps-using-eclipse. 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 http://wso2.org/library/tutorials/creating-web-service-client-3-steps-using-eclipse. 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 http://wso2.org/downloads/tools/eclipse or via the online update site http://tools.wso2.org/eclipse

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.

Data as a web service, why not?

November 11, 2008

Working in WSO2 I was recently asked to create an eclipse plugin for their latest WSO2 product WSO2 Data Dervices. As an open source project it is really an impressive product to bring data as a web service. If you hadn’t tried it yet try here. It supports many RDBMS data sources, excel files, csv files and JNDI sources. As a web service the applicability of policies and security given an extra value for using this product.

The plugin I created even though was planning to give user richer experience that the web counterpart was not much of a hit since the due to the time constraints I faced. If you wanna know how to use it check this tutorial.

However I’m talking about this here is to get ideas on how to improve this plugin in the users perspective. My current plan is to add an GUI editor which involves GEF rather than a wizard to create/edit a dataservice. But this takes some time since it requires considerable amount of research. Anyother ideas are appreciated.