July 16, 2008
Still working with a lot of Eclipse views, I got today a really strange behavior … The Window -> Show View menu creating my multi instance view with a null secondary id didn’t generate a call to the createPartControl method of my view !!!!!!
After several debug sessions I decided to clean my runtime workspace and the problem went ago. I guess this workspace was in a wrong state resulting of a lot of open and “dirty kill”.
Conclusion, just keep your runtime workspace clean when developing eclipse plug-ins.
No Comments » |
Eclipse Misc |
Permalink
Posted by Manuel
June 6, 2008
I spent time yesterday on a tricky bug. After a “long” one hour fight I finally found the cause of the problem. It was just a misunderstanding from myself of the java.util.Collections.bynarySearch method :
public static <T> int binarySearch(List<? extends T> list,
T key,
Comparator<? super T> c)
According to the contract of this method the return value will be >= 0 if and only if the key is found.
I was thinking that it was equivalent to say: “list.contains(key) is true”. I was wrong !!!! It really means if the key is found using the given comparator; i.e if the comparator.compare() method return 0 !!!
I am learning Java every day ;o) and it’s just another silly young Java developer problem that will no more make me waste time.
2 Comments |
Java |
Permalink
Posted by Manuel
May 30, 2008
While developing Eclipse’s plugins on my Linux RHEL3 (computers are administrated by the company’s IT service) work station I encountered SWT/JFace performances problem. More accurately, I had problems with Table Viewers / Table with a lot of entries. Google quickly told me that in some cases SWT’s performances problems come from the underneath layer : GTK.
Since the GTK version installed on RHEL3 systems is quite old I tried my plugins on a RHEL4 workstation and my performances problem went ago. Nice but I want to solve these problems on MY workstation.
Before asking for a new RHEL4 I decided to have a try on setting up a new GTK version on my workstation. After a long fight and a lot of ./configure - make - make install I successfully installed the last GTK release on my workstation. I am now able to launch Eclipse with this GTK version. I can also easily switch back to the old version just by changing my LD_LIBRARY_PATH.
Moreover, a lot of GTK widget have significant usability improvements … for example I can now browse hidden file when using File -> Open dialog instead of having to open a shell outside Eclipse to get the file path and to copy it in the file browser widget ;o)
No Comments » |
Eclipse Misc |
Permalink
Posted by Manuel
May 30, 2008
I participated yesterday to my first Eclipse Webinar about Memory Analyzer. It was really instructive ;o).
From now I will always keep an eye on the coming webinars in order to attend as much as possible and I recommend every one to jump into these webinars.
Thanks again to presenters.
3 Comments |
Eclipse Misc |
Permalink
Posted by Manuel
May 21, 2008
As discussed in a previous post I created an application with a View allowing multi instances.
An other problem I encountered with multi instances views is about Views persistence between several launches.
When the workbench is closed Eclipse automatically remember each opened view’s position. This way the next time I’ll start my workbench these opened views will be automatically displayed.
In my case this behavior is not the good one since view’s content is not persistent across launches. For example if the user leaves its workbench with 6 opened instances of my view he ‘ll get 6 empty views at next launch …
To solve this problem I just added an IWorkbenchListener closing all the opened instances of my view when the workbench is closing down. Closing a view is done by the IWorkbenchPage.hideView() method.
4 Comments |
Eclipse Misc |
Permalink
Posted by Manuel
May 15, 2008
I didn’t blogged for a while because I am working on a new Eclipse application. This application defines a new View. This view is created with allowMultiple = true.
This view is associated with a given file extension. Each time the user double click on such a file a new instance of the view is created using IWorkbenchPage.showView(primaryId, secondaryId).
I quickly got my multi instances view mechanism functional. The next step was to manage “correctly” the behavior of :
Window -> Show View -> MyMultiInstanceView ???
What happens when the user clicks other there … ???
Launching my app in debug mode told me than my view is created (by Eclipse and not explicitily by my code) in that case with a secondaryId == null. Of course this resulted in a famous NullPointerException ;0)
A first and simple solution is to check the secondaryId and provide an empty view (or a view with a simple message) when this Id is null …
I decided to use an other solution using the “master view” (the one displayed when the user clicks windows -> show view) to display informations about all the other opened views (the ones with a secondaryId != null associated to a file). This view just contains a ListViewer showing all the other opened views. A double click on a given element of that list gives brings the associated view to the top. When a view is closed by the user, the associated entry in the view is removed.
This solution help me to solve the problem of providing the user a way to open a “meaningless view” in its perspective.
Here I had to “search” for something to display in the master view. Since new instances can only be created programatically it could be nice in some cases for plug-ins developers to be able to tell the platform: “don’t create Show View menu entry for this view” …
2 Comments |
Eclipse Misc |
Permalink
Posted by Manuel
April 29, 2008
As Eclipse’s plug-in developer I often ask my self: what is the current workbench selection ?? Developers may need such information for example when they want to update a given view according to an other view selection but don’t know what the provided selection exactly is or when creating a new custom Selection provider. It can also be useful for simple debug purpose.
To answer this question I wrote a simple plug-in adding a new view to my workbench showing the content of the current selection in a simple JFace TableViewer.
The view is added to the PDE category :

Here is what it looks like when two Java methods are selected in the outline view :

May be I missed something and such information is already available somewhere in the PDE … ?? If Yes, please let me know.
6 Comments |
Eclipse Misc | Tagged: Add new tag |
Permalink
Posted by Manuel
April 23, 2008
In the same series than Andy Maleh post to-if-else-or-not-to-if-else and after discussions with colleagues I am wondering how you write the following problem using Java If-Else.
Object a;
Object b;
a == null and b == null -> method1()
a == null and b != null -> method2()
a != null and b != null -> method3()
a != null and b == null -> method4()
Which method to choose taking into account performances and redability between:
if (a == null && b == null) {
method1();
} else if (a == null && b != null) {
method2();
} else if (a != null && b != null) {
method3();
} else {
method4();
}
Or
if (a == null) {
if (b == null) {
method1();
} else {
method2();
}
} else {
if (b != null) {
method3();
} else {
method4();
}
}
About readability I’ll personally choose the first solution. About performances … I am not sure there is a difference after JVm’s optimizations … ??
15 Comments |
Java |
Permalink
Posted by Manuel
April 16, 2008
Last weeks I played for the first time with JFace’s viewers (TableViewer and TreeViewer). It was really easy to integrate my first viewers inside my own Eclipse views.
All was working fine when I started to encounter performances problems when setting inputs containing thousands of entries (several seconds for ~50.000 rows in a TableViewer).
A quick look on Google pointed me to LAZY content providers and SWT.VIRTUAL in order to improve performances. Before going further with these content providers we have to identify bottle necks. When working with JFace’s viewers there is potentially 2 bottle necks:
- The retrieval of all the model objects from the viewer’s input (it’s the content provider’s job).
- The creation of UI elements.
As Tom Schindl said here (Snippet 29): “The bottle neck is often the UI and not the model“.
I checked the time consumed in my content provider to retrieve viewer’s entries. Only few milliseconds. My bottle neck is the UI !!
To solve this performances problem I just added the SWT.VIRTUAL style when creating my TableViewer. Creating the viewer this way tells JFace to create the SWT's TableItem objects on an on demand basis. TableItem objects are created only when they become visible (when the user scroll for example). As a conclusion, all I had to do to solve my performances problem is to set this magic style: SWT.VIRTUAL. It’s so easy to work with Eclipse !!!!! Isn’t it ??
Next i tried the same solution with TreeViewer. Unfortunately it didn’t worked. I had to use the SWT.VIRTUAL style WITH an ILazyTreeContentProvider in order to increase my performances as in TableViewer. It’s fine but this solution has one drawback: Sorting and Filtering are no longer available when using ILazyTreeContentProvider.
Someone told me on the Eclipse Platform newsgroup that the request to support SWT.VIRTUAL style and sorting and filtering for TreeViewer is already in the “pipe” but i can’t find such a request on Eclipse bugzilla. If someone can tell me more on that …
8 Comments |
Eclipse Misc, SWT |
Permalink
Posted by Manuel
April 9, 2008
Several months ago i discovered the Eclipse’s links directory. Today I saved again a lot of time setting up a new Eclipse installation thanks to this tip. I used Eclipse for long time before discovering this feature and that’s why i am posting about it.
Links directory allows you to tell Eclipse where to search for extensions when it starts. This directory just contains several .link files containing each one the path to an extension.
Personally I created a link directory separately from my Eclipse’s installation directory. Of course I also install my favorite plugins outside the Eclipse’installation. Each time I install a new Eclipse I just create a symbolic “link” (using ln -s , I am on a Linux workstation) in this new install pointing to my shared link directory. All my favorites plug-ins are there !!!
More Informations are available from the eclipse help
and from this old article.
No Comments » |
Eclipse Misc |
Permalink
Posted by Manuel