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.

2014-07-28_13-57-09

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

2014-07-28_14-02-55

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 “com.perforce.team.ui” and the element in tree is P4PendingChangelist.

2014-07-28_14-08-36

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.team.ui
  • com.perforce.p4api
  • com.perfroce.team.core

2014-07-28_14-16-31

NOTE: Here is a bug of Eclipse PDE 3.x. Even we declare the com.perforce.team.ui is needed, but Eclipse can’t build through and there will be build errors. The root cause is com.perforce.team.ui 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 com.perforce.team.ui 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.

2014-07-28_14-22-41

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 com.perforce.team.core.p4java.IP4PendingChangelist.

2014-07-28_14-26-35

Add new action into it,

2014-07-28_14-29-12

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:

 

Eclipse必装插件之Emacs+

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

Emacs+可以让你在Eclipse里完美体验Emacs的键位,比Eclipse自带的好很多!必装,强烈推荐!

Eclipse必装插件之Color Theme

想想自用Java开发以来,Eclipse都是主力的开发IDE。这两年多时间内,也积累了一些使用技巧。打今儿起,写几篇小文章总结一下。

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