Manually uninstall OSGi bundle in the runtime

Sometimes in a RCP application, you may need to uninstall OSGi bundle in the runtime. With BundleContext, it’s doable. Here is a sample.

As you can see, you need to specify the bundle/plugin name.

How to extend p4eclipse plugin?

What’s p4eclipse?

Perforce provides is a very powerful and handy plugin for Eclipse – p4eclipse. With it, you can do everything in Eclipse enviornment, which is the same as in it p4 command line and p4v (a clicent of perforce).

Why to extend it?

Team also deployed ReviewBoard to do pre-check-in code review. And we have a command-line tool to post review request to it. The input is the id of perforce changelist.

Basically, we can see the changelist in Eclipse. The problem is how to combine them together and allow us to easily post the request from GUI directly.


When you right-click on the changelist, you can see some actions in the context menu.


Can we add another menu item into the context menu and post review request?

Ways to Extend p4eclipse

p4eclipse is also a Eclipse plugin and it follows the basic concept, such as extension, extension point, views and etc. It should be easily extended.

Find which view to extend

First, we need to find out the view class of P4 changelist. Simply move the mouse on view tab and click ATL+SHIFT+F1 to launch “Plug-in Selection Spy“. And the view name is PendingView, contained in plugin-in “” and the element in tree is P4PendingChangelist.


Create plugin-in project

Now we know to extend which view. It’s time to create our own plugin-in project. And in the MANIFEST.MF, besides basic plugins, we need explicitly declare we need p4eclipse plugins,

  • com.perforce.p4api


NOTE: Here is a bug of Eclipse PDE 3.x. Even we declare the is needed, but Eclipse can’t build through and there will be build errors. The root cause is is in a unpacking feature and PDE can’t revolve the dependency correctly in such case. To fix it, we have to download the jar file of to local and put it in to runtime class path manually. Remember, it’s only to fix PDE issue, we don’t need it in packaging.


Add new menu item into the context menu

Open the MANIFEST.MF file and file the context menu extension declaration. It’s in org.eclipse.ui.popupMenus and the menu id is


Add new action into it,


Next steps are easy

Now we finished the important part. If you are familiar with Eclipse RCP, you should understand next steps are easy. Basically, we need to launch a command line from Java code and implement an  action handler for the new created menu item. In my implementation, I also add a new preference page for team to setup the command location.

For details, please refer to my github project p4eclipse_ext.

Extened p4eclipse

After extension, the review request can be posted very easily, just like a build-in function of perforce. :lol:



想想上大学那会儿,非常不喜欢Emacs的键位,还在Visual Studio里搞了一套自己习惯的。随着工作后慢慢又接触了Emacs,越来越习惯它的键位,同时发现很多程序都可以使用Emacs的键位,工作的效率无形之中提升了很多。


Eclipse必装插件之Color Theme


今天就说说插件Color Theme。它帮你精选了几套的漂亮色彩搭配,可以瞬间让你的代码看起来再加美观。做程序员的,一天到晚盯着显示器,眼睛难免疲劳。如果你有同感的话,不防安装一下试试。我在用RecognEyes,还不错哦。