Tag Archive 'rcp'

Feb 11 2009

Automatic PDE build with Pluginbuilder

Published by under Eclipse

Pluginbuilder is Eclipse tool that generates build configuration based on PDE build. By default the tool generates map file containing the information how source code of the plug-ins should be obtained. Supported methods are: CVS, GET and COPY. Assuming that you want to build your features or product from source files that are checked-out from repository independently from the build process COPY options seems to look reasonable. There are few problems with that:

  • it requires absolute paths to plug-ins/features locations
  • every single plug-in has to be listed there

Workaround for this is not using map file at all and provide appropriate build directory structure outside. To skip fetching resources based on map file configuration one need to set skipMaps property in build.properties file. Next step is to configure getting plug-ins/features resources into build directory. Recommended phase for copying the source code is preSetup phase in PDE build. To hook into this phase standard ant task for copying the files/directories in to build directory have to be invoked in preSetup target in customTargets.xml (it is generated by Pluginbuilder as well as other configuratoin files in build-files directory).

Those two modifications allow to make use of Pluginbuilder generated scripts to build Eclipse based applications without coupling it tightly to version control system.

One response so far

Feb 04 2009

Eclipse Jobs API – Errata

Published by under Eclipse,IT,Java

My colleague Lukasz Milewski has just spotted a missing piece in a code sample for creating icons presented in previous post. In the screenshot you can see nice icons for currently running Jobs as well as for scheduled Jobs. You need to set two properties in your Job implementation to associate an icon with it.

	setProperty(IProgressConstants.KEEP_PROPERTY, Boolean.TRUE);
	setProperty(IProgressConstants.ICON_PROPERTY, ImageDescriptorFactory
		.createImageDescriptor(ICON_NAME));

4 responses so far

Jan 14 2009

Using Eclipse Jobs API

Published by under Eclipse,IT,Java

Eclipse platform offers great API for managing long running operations in the background. Besides the API for starting, stopping and monitoring progress of the Job – there is also standard UI for managing all those operations. I’m going to present sample usage of Jobs API in you own plug-in/application.

Creating and scheduling Job may look like this:

 TrainJob job = new TrainJob(TRAIN_JOB_NAME + file.getName(), classifier);
 job.setRule(file);
 job.setUser(true);
 job.setPriority(Job.SHORT);
 job.schedule(); // start as soon as possible

Sample of custom Job:

package pl.edu.agh.caracal.classifier.popup.jobs;
 
import static org.eclipse.core.runtime.Status.OK_STATUS;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.jobs.Job;
import pl.edu.agh.caracal.classifier.ext.classifiers.AbstractClassifier;
 
/**
 * Class for execution of training of a classifier
 *
 * @since 1.0
 */
public class TrainJob extends Job {
 private AbstractClassifier classifier;
 
/**
  * Public constructor TrainJob
  *
  * @param name Train job name
  * @param classifier Classifier to be trained
  */
 public TrainJob(String name, AbstractClassifier classifier) {
 	super(name);
 	this.classifier = classifier;
 }
 
 @Override
 protected IStatus run(IProgressMonitor monitor) {
 	// Long running operation - in this case classifier training
       // ...
       return OK_STATUS;
 }
 
}

Standard GUI for presenting Job progress:

Jobs API View

3 responses so far

Sep 09 2008

Eclipse RCP tips and tricks

Published by under Eclipse,IT,Java

Recently I had to do couple of tricks Eclipse RCP applications. Basically all of the pieces of code presented below need to be placed in method initialize(IWorkbenchConfigurer configurer). You need to override this method in WorkbenchAdvisor subclass.

  • Displaying icons in Navigator View
    final String ICONS_PATH = "icons/full/";
    final String PATH_OBJECT = ICONS_PATH + "obj16/";
    Bundle ideBundle = Platform.getBundle(IDEWorkbenchPlugin.IDE_WORKBENCH);
    declareWorkbenchImage(configurer, ideBundle,
    IDE.SharedImages.IMG_OBJ_PROJECT, PATH_OBJECT + "prj_obj.gif", true);
    declareWorkbenchImage(configurer, ideBundle,
    IDE.SharedImages.IMG_OBJ_PROJECT_CLOSED, PATH_OBJECT
    + "cprj_obj.gif", true);
  • Enabling Decoration Context
    DecorationContext dc = (DecorationContext) DecorationContext.DEFAULT_CONTEXT;
    dc.putProperty(IDecoration.ENABLE_REPLACE, Boolean.TRUE);
  • Enabling Jobs Progress Bar
    IWorkbench wb = PlatformUI.getWorkbench();
    wb.getProgressService();

Probably you don’t need any of those when running your plug-ins in Eclipse IDE. The tricky part is running it in a stripped to minimum RCP based applications.

One response so far

Aug 12 2008

Eclipse RCP launcher icon

Published by under Eclipse,IT,Java

Eclipse RCP allows easily create an application. Additional advantage of the platform is a native launcher of the application which allows it to behave more like “native” application. It much better to have a process called your_application.exe running instead of another java.exe process.  You will probably also want to have some nice icon attached to *.exe file of your application. This can be done easily in Eclipse 3.4. First you need to create *.ico file (containing all necassary images inside) – one of the generators available on the web can be used for this (for example).

Next step is configuration in *.product file:

   <launcher name="caracal">
      <solaris>
      <win useico="true">
         <ico path="/pl.edu.agh.caracal.application/icons/caracal.ico"></ico>
         <bmp></bmp>
      </win>
   </solaris>
</launcher>

You can also use product file editor for this (a lot of enhancements were added in Eclipse 3.4):

Launcher icon configuration

After building the application based on product file launcher will have your custom icon. No resource hacking, nor recompiling native C code is required!

Launcher custom icon

2 responses so far

Jul 26 2008

Help in Eclipse RCP application

Published by under Eclipse,IT,Java

Until you are working at Google or Apple your applications probably requires some sort of help system (UX). Eclipse help system can be easily reused in your custom application based on Eclipse RCP.

Let assume that you already have RCP application (if not you can use one of the wizards provided in Eclipse to get one).  In order to enable help there you need to add three dependencies explicitly in plugin.xml:

  • org.eclipse.help.ui
  • org.eclipse.help.ui.webapp
  • org.eclipse.equinox.http.jetty

After adding those make sure to update *.product configuration and add all new required dependencies.

The next step is adding an extension which will provide the help content in plug-ins that will contribute it. The extension point that provides this feature is: org.eclipse.help.toc (there is one template with dummy help content available to choose in Extension Point Selection form).

Now some menu item that will launch help needs to be added. It can be done in plugin.xml:

  • Add an extension (if you don’t have it already) : org.eclipse.ui.menus
  • Add new element: menuContribution with locationURI menu:file
  • Add new command with id: org.eclipse.ui.help.helpContents

Last step is registering an action that will be binded to previously created menu item. It can be done in a class that extends ActionBarAdvisor (if you created your RCP application using default wizard it will be called ApplicationActionBarAdvisor. You need to override one method:

protected void makeActions(IWorkbenchWindow window) {
	this.contentsHelpAction = ActionFactory.HELP_CONTENTS.create(window);
	register(this.contentsHelpAction);
}

Now help system with sample content should be available in Help menu. It will launch separate window and display content there. A help content can be provided by any plug-in extending org.eclipse.help.toc extension point. It is set of HTML documents which are displayed together in one common place, framework provides built-in search, index, table of contents etc (Eclipse uses Jetty as a web server, try this in a browser).

2 responses so far

May 22 2008

Eclipse DemoCamp is coming to town

Published by under Eclipse,IT,Java

Eclipe 3.4 Ganymede It looks like Eclipse DemoCamp will come to Krakow sometime in June. The agenda is not available now, but I hope it will be interesting. There is a lot of exciting stuff coming with Eclipse 3.4 (I’m currently working with Eclipse 3.4 M7 platform and looking forward for final release that is coming in end of June).

Agenda, specific date and place should be announced here

No responses yet