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.

Add watchpoint for variables in Eclipse

Sometimes, in debugging, we want program stopped when some variables are accessed or modified. To set traditional breakpoints for this case, you have to spend a lot of time to find all places to access or modify variables. It’s even harder when variables are passed to other object or the derivation hierarchy is complicated. In this case, watchpoint is a good helper.

In Eclipse, it’s quite easy to set watchpoint. In “Outline” view, you can right click on the variable you want to want and select “Toggle Watchpoint“. 2014-11-06_13-21-43

Then you can find a new watchpoint in “Breakpoints” view. You can see the icons of breakpoint and watchpoint are different.

2014-11-06_13-24-02

By default, watchpoint will be hit when accessing or modifying the watched variable. To change it, we can simply right-click the watchpoing and select “Breakpoint Properties…“.2014-11-06_13-27-11

 

 

Eclipse插件之EHEP

开发过程中偶然需要到查看Tar文件的格式,发现在Emacs里对Tar文件做了特别的处理,不能显然文件的原貌。网上搜索之后,发现Eclipse里有个很给力的插件。它就是EHEP。

安然很简单,用下面的Update Link,

http://ehep.sourceforge.net/update

当打开二进制文件时,在Editor中选择“Hex Editor“,

2014-11-04_12-01-52

然后就可以看到可爱的二进制文件了。

2014-11-04_12-03-40

 

Eclipse必必装插件之Mylyn

以前早听过Mylyn的大名,但因为公司没有配套的软件,一直无缘尝试体验。前段时间,公司把Perforce,JIRA都做了升级,让我终于可以一睹Mylyn的真容。当真是极好的!必装,必装,必装装啊!

Mylyn的好处真不是一句两句可以说清的,它可以和各种开发辅助软件相连,如代码仓库(Perforce,SVN等),代码Review工具(如Gerrit, ReviewBoard等),持续集成工具(如Hudson/Jenkins),问题追踪工具(如JIRA,Bugzilla)。比如你在Eclipse里可以查看/更新JIRA Ticket的状态;直接在Eclipse里Review别人的Code Change并Comment;在Eclipse里查看Jenkins的出错报告并重新集成一下。

我这里只想说说它的另一大好处——Task-focused的IDE工作环境。

先设想一下没有Mylyn的工作环境…

昨天打算要某JIRA Bug,突然QA又发了两个严重的Bug,都急着要修,昨天跟了很晚,没什么头绪。今天看着Eclipse,打开了50+ Java Editor,有意无意地迁出了30个P4上的文件,都在Default ChangeList里。简直一团糟!Java Editor不知该不该关,忘了打开Editor的原因,P4上迁出的文件一会还要分到不同的Checklist里。啊,简直要崩溃了!

也许你要说工作应该更有条理一些。可程序员都知道,活儿真多的时候,没人慢条丝理的在各种工具之间换来换去,至少我不会。:)

当我们有了Mylyn…

有什么工具来帮你把繁乱的工作变得条理清楚吗?Mylyn可以!它可以帮你把不同的工作分类管理好,让你方便的在不同任务间切换,而你只需要记得轻点几下。下面简要说说。

和JIRA连起来

选择JIRA的Connector,

2014-06-24_13-41-39

设置JIRA的登录账户(注意,JIRA服务器的Remote API要先Enable,不然没有办法连接上。)

2014-06-24_13-39-56

连接之后,要做一个所谓Query,其实就是在JIRA里寻找关注的Ticket,可以直接选择某个JIRA里的Filter,Connector也提供一些简单的Filter,比如“Assigned to me”.

2014-06-24_13-43-03

设置完成Query之后,就可以得到一个Task的列表。

2014-06-24_14-08-04

Make your environment Task-Focused

让整个Eclipse IDE进入Task-Focused状态非常容易,选中某个Task,在Context Menu里选择”Activate“。

2014-06-24_14-09-11

随后整个IDE就围绕这个Task进行调整。

  • 对于没有历史的Task,Eclipse Editor Area会被清空;对之前Activated过的Task,打开过的文件会被Restore在Editor Area中。新打开的文件也会加到Task的环境中。
  • Perforce Eclipse Plugin会把当前Task的Pending ChangeList设为Active ChangeList。如果之前Task没有Changelist,Perforce会新建一个。新的迁出都会放到Active CL里By Default。
  • 此外,所有有”Focus on Activated Task”图标的View,都会调整各自的内容,只把浏览过的文件/方法放到View中。2014-06-24_15-02-31包括Package Explorer,Outline,Task,Problems,新的Mylyn还支持Breakpoint等等。

退出Task-Focused状态,只需简单的Deactivate Task即可。切换到另一Task,只需Activate另一个Task即可,同时只能有一个被激活的Task。

总结

有了Mylyn这个好伙伴,开发人员可以轻松在多的Task之间切换,为不同Task打开不同文件,浏览不同的方法/函数都会被Mylyn很好的维护和重建,工作会更加有条理,效率也会大大提高。

我已经离不开它了! 😀

Integrate VisualVM with Eclipse IDE

Recently I got a task to evaluate sqlite, which is a good candidate for our new product. I wrote several samples in Eclipse IDE and run several cases to test its features and  use VisualVM to test its performance.

VisualVM is a lightweight profiling tool which is released with JDK now. It’s quite handy for easy cases. And it’s quite easy to integrate it with your Eclipse IDE.

First, go to visualvm website and download the launcher for Eclipse.

Unzip the launcher and Install it by Eclipse Update Center.

Restart your Eclipse and go to Run Configuration, you will find there is a new launcher for VisualVM. After switching to it, your run is connected with VisualVM now.

😀

Eclipse必装插件之Emacs+

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

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

Eclipse必装插件之Color Theme

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

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