Jun
01
2010
Many times when working with Eclipse RCP I had to generate ad-hoc updatesites (usually containing some 3rd party plug-ins). What I usually did to achieve this (with Eclipse IDE):
- create new feature project
- add plug-ins to the feature
- create new updatesite project
- add the feature to the updatesite (pre-p2 style – site.xml)
- export newly created updatesite (letting Eclipse to deal with creating p2 meta data)
Since I needed to automate this process I started researching on p2 capabilities and found out that it can be done from command line using FeatureAndBundlesPublisher application. Sample command line invocation to do it:
%ECLIPSE_EXE% -application org.eclipse.equinox.p2.publisher.FeaturesAndBundlesPublisher -metadataRepository file:/%P2_TARGET% -artifactRepository file:/%P2_TARGET% -source %P2_SRC% -compress -configs win32.win32.x86 -publishArtifacts
Where:
- ECLIPSE_EXE – points to Eclipse executable;
- P2_TARGET – path to an empty directory where p2 repository should be created;
- P2_SRC – path to the directory with /plugins subdirectory and plug-ins to be published (jar files) inside;
- -compress parameter is optional. It compresses artifacts.xml and content.xml to jar (zip) files.
Tags: eclipse, FeaturesAndBundlesPublisher, generating, meta data, p2
Oct
27
2009
Step by step in Eclipse IDE
- Create new Eclipse plug-in: File -> New -> Other -> Plug-in Development -> Plug-in Project
- Add dependency: MANIFEST.MF -> Dependencies tab -> Add -> org.eclipse.ui
- Add extension point org.eclipse.ui.menus: plugin.xml -> Extension -> Add -> org.eclipse.ui.menus
- Right-click -> New -> menuContribution
- Enter locationURI: menu:file
- Right click -> New -> command
- Enter commandId: tk.urbas.eclipse.sample.sampleCommand
- Enter label: Sample Menu Item
- Add extension point org.eclipse.ui.commands: plugin.xml -> Extensions -> Add -> org.eclipse.ui.commands
- Right-click -> New -> command
- Enter id: tk.urbas.eclipse.sample.sampleCommand
- Enter label: Sample Command
- Add extension point org.eclipse.ui.handlers: plugin.xml -> Extensions -> Add -> org.eclipse.ui.handlers
- Right-click -> New -> handler
- Enter commandId: tk.urbas.eclipse.sample.sampleCommand
- Enter class: tk.urbas.eclipse.sample.SampleHandler
- Click class link and create class
- Provide sample implementation of the handler class implementing org.eclipse.core.commands.IHandler or extending org.eclipse.core.commands.AbstractHandler

Menu, command, handler
MANIFEST.MF
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Sample Handler
Bundle-SymbolicName: tk.urbas.eclipse.sample;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: urbas.tk
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Require-Bundle: org.eclipse.ui
plugin.xml
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI="menu:file">
<command
commandId="tk.urbas.eclipse.sample.sampleCommand"
label="Sample Menu Item"
style="push">
</command>
</menuContribution>
</extension>
<extension
point="org.eclipse.ui.commands">
<command
id="tk.urbas.eclipse.sample.sampleCommand"
name="Sample Command">
</command>
</extension>
<extension
point="org.eclipse.ui.handlers">
<handler
class="tk.urbas.eclipse.sample.SampleHandler"
commandId="tk.urbas.eclipse.sample.sampleCommand">
</handler>
</extension>
</plugin>
Handler – sample implementation showing a message
package tk.urbas.eclipse.sample;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.widgets.Display;
public class SampleHandler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
MessageDialog.openInformation(Display.getDefault().getActiveShell(),
"Sample Handler", "Sample Handler");
return null;
}
}
Tags: command, eclipse rcp, handler, menu item
Oct
17
2009
4th edition of Java Developers’ Day is over. It was the first time I attended this conference. I enjoyed most of the sessions and the organization was pretty good. I will definitely plan to be there next year as well. My favorite JDD09 speakers/sessions:
Tags: java conference, jdd, krakow, poland
Jul
30
2009
There are several new and exciting features in Galileo release. Multiple projects, hundreds of contributors, huge audience…
I decided to choose my very personal Top 5 for Galileo release:
- Update. New UI for installing and updating new features in Eclipse really leverages user experience. After introducing p2 in 3.4 a lot of people missed old Update Manager. With more stable and matured p2 in 3.5 version hopefully no one is missing 3.3 style updates any more. One capability I would find useful there is installing particular Installable Units instead just these which are based on Eclipse features. In p2 world all IUs are supposed to be equal.
- Setting the cookies in Browser. I’m really happy to finally see setCookie(value, url) method in SWT Browser class. That’s the part of API that was really missing there to make embedded browser more functional in Eclipse RCP world. Next step would be probably providing SWT support for the Webkit based browsers.
- Target Platforms. Galileo way of defining target platform is another item I find really useful for Eclipse RCP. Finally at least partially runtime for Eclipse RCP application can be independent from the plug-ins set in Eclipse IDE used for development!
- Mylyn. Previous Mylyn version satisfied most of my requirements to work with Bugzilla. But new Mylyn Editor just feels better for me even if it took me a day or two to get used to the context activation button being moved from right to left side of the toolbar.
- OSGi Declarative Services. I’m excited about declarative services in Equinox. I didn’t have opportunity to try it yet but I have high hopes for the near future!
Tags: 3.5, eclipse, galileo, review
Jul
21
2009
I’m considering learning new programming language or technology.
My very basic requirements:
- no for buying new laptop (I’m happy with my ThinkPad)
- no for buying new mobile device just to run something at all (I’m happy with my Nokia)
Any suggestions?
Jun
20
2009
Single click …
Downloading update from http://wordpress.org/wordpress-2.8.zip
Unpacking the core update
Verifying the unpacked files
Installing the latest version
Upgrading database
WordPress upgraded successfully
… and voilà! Upgrade completed!
Tags: 2.8, upgrade, wordpress
Jun
08
2009
The website of Państwowa Komisja Wyborcza (the institution responsible for the elections in Poland) around the time when the official results are supposed to be published.

Państwowa Komisja Wyborcza
May
18
2009
Recently I’m getting a bit confused about p2. There is an update site created with PDE headless build. There are IUs generated for each plug-in/fragment/feature. Everything looks great so far.
Let’s assume: plug-in A and fragment B with a defined host plug-in A are sitting together on single update site. Plug-in A in reality cannot run without appropriate version of fragment B (e.g. situation similar to SWT).
My understanding of p2-power was that I wouldn’t need to create separate feature C aggregating A and B just to make fragment B be automatically installed when I request installation of plug-in A.
I spent some time on reviewing Eclipse Bugzilla and mailing lists. Interesting findings:
http://wiki.eclipse.org/Equinox_p2_Meeting_2007#Fragments_optional_vs._requirement
https://bugs.eclipse.org/bugs/show_bug.cgi?id=256430
Any suggestions about handling such “required” fragment scenario without getting rid of autogenerated p2 repository and hand crafting p2 metadata?
Tags: fragment provisioning, p2
Mar
01
2009
One may need to run some task periodically in the background in Eclipse. This background task should run automatically and shouldn’t block user from regular usage of the application. My proposal for accomplishing this is using Eclipse Jobs API and org.eclipse.ui.startup extension-point.
- Adding org.eclipse.ui.startup extension:
- Implementing Job:
package tk.urbas.eclipse.urbanlife;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
public class RefreshDataJob extends Job {
public RefreshDataJob(String name) {
super(name);
}
@Override
protected IStatus run(IProgressMonitor monitor) {
// Work to do in the background
return Status.OK_STATUS;
}
}
- Scheduling Job to run periodically:
package tk.urbas.eclipse.urbanlife;
import org.eclipse.core.runtime.jobs.IJobChangeEvent;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.runtime.jobs.JobChangeAdapter;
import org.eclipse.ui.IStartup;
public class Startup implements IStartup {
private static final long STARTUP_DELAY = 5000; // 5 seconds delay for first run
protected static final long JOB_INTERVAL = 60000; // Job should run every 60 seconds
public void earlyStartup() {
final Job updateJob = new RefreshDataJob("Refreshing data in the background");
updateJob.schedule(STARTUP_DELAY);
updateJob.addJobChangeListener(new JobChangeAdapter() {
@Override
public void done(IJobChangeEvent event) {
super.done(event);
updateJob.schedule(JOB_INTERVAL);
}
});
}
}
Let me know if you have any better solution for implementing this. All improvements, suggestions and comments will be greatly appreciated.
Tags: earlystartup, eclipse jobs api, periodical task