November 26, 2009
Thanks to JFace viewers I can easily present anyone of my “model” inside an Eclipse view.
After several usages of this technology I am still sometime wondering how should I use it. Here is my dilemma:
Lets say we want to display a “model” (by model I mean here some Java POJOs representing application data) as a tree. Tree concepts are Children, Parent and Leaf. Of course these concepts must exist somewhere in my data model to present this model as a tree.
From here, depending on the relation between my data model and the tree concept, two solutions come in my mind (I am maybe missing something and that’s why I am blogging on the subject, so let me know about all your ideas, experiences …)
First solution: we perform ALL the “model to tree” mapping in the content provider (Note that this IS the content provider purpose)

This solution works perfectly when the data model IS a tree. I.e children, parent and leaf exists as it in the model. The data model of the first JFace TreeViewer Snippet is a good example of such a model.
Unfortunately, in real situations where we need to present data as trees, we must sometimes “Compute” the tree from the data. In such situations the ContentProvider implementation can quickly increase in terms of complexity and thus in terms of readability and maintainability.
Here’s come the second solution:
In this solution, we first compute a “tree model” of the original data model. Then the ContentProvider implementation becomes really easy, since (as in the previously mentioned snippet) we directly return model’s children, parent and leaf to the viewer. In this case we created an intermediate model: “the view model“
As I said previously, which solution I choose really depends on the context and mainly on the “Cost” and “Complexity” of the computation required to convert the model into a tree.
I will be interested in community feedback regarding this subject. How do you convert your data models to be presented in JFace viewers ??
5 Comments |
Eclipse Misc | Tagged: eclipse, JFace, Models, SWT, TreeViewer, Viewers |
Permalink
Posted by Manuel
November 19, 2009
This morning we encountered a strange difference while running the following code on two Windows workstations and directly clicking the OK button of the dialog.
FileDialog dialog = new FileDialog(window.getShell(), SWT.SAVE);
dialog.setText("Save as...");
dialog.setFileName("C:\\Test\\toSave.test");
dialog.setFilterPath("C:\\Test\\");
dialog.setFilterExtensions(new String[]{"*.sav"});
String path = dialog.open();
System.out.println(path);
The first workstation printed C:\Test\toSave.test while the second one printed C:\Test\toSave.test.sav
Of course the wanted behaviour is the second one !!!
After investigations we identified the difference on the workstations causing this “SWT” difference: the first workstation HAS the windows folder option called Hide Extensions For Known File Types checked while the second one HASN’T !!!
To fix the issue we had to modify the setFileName method call as following:
dialog.setFileName("C:\\Test\\toSave.test.sav");
Conclusion: Looking back to the initial code, it seems logic to have to set a file name matching the specified filter extensions.
Leave a Comment » |
SWT | Tagged: Hide Extensions For Known File Types, SWT |
Permalink
Posted by Manuel
October 23, 2009
I spent lot of time today to find how to zip an eclipse directory with ANT WHILE KEEPING the root directory in the archive, thus when unziping, clients get only one directory called eclipse containing all eclipse’s stuff.
Here’s my directories structure:
Here is the ant code to zip the eclipse directory into a zip called eclipse.zip containing the eclipse directory as root:
<zip destfile="eclipse.zip">
<zipfileset dir="buildfolder">
<include name="eclipse/**/**" />
</zipfileset>
</zip>
Leave a Comment » |
Eclipse Misc |
Permalink
Posted by Manuel
October 15, 2009
Hi there,
After pressing accidentally several keys on my keyboard I lost the Auto Completion in my PDE environment !!!
I already had the same problem long time ago but I wasn’t able to remember how I solved it. In order to solve it quickly next time and of course for others encountering it here is the solution:
Window -> Preferences -> Java -> Editor ->Content Assist Advanced -> Restore Defaults in order to have Java Proposals checked.
On a side note, I am curious to understand how I disabled this feature with my keyboard ….
Leave a Comment » |
Eclipse Misc |
Permalink
Posted by Manuel
July 10, 2009
Hi all,
Before leaving in a 4 days week end (July 14th is Bastille Day ;o)) I would like to like to get your inputs regarding -Xms Sun JVM’s option.
This week I tried to find the best way to manage memory usage of our Eclipse’s based product. This work led me to ask my self How should I manage OutOfMemoryErrors and also bring me to -Xmx and to the mysterious (to my blinded eyes) -Xms option.
In our product we are setting -Xmx to 512m. All is clear and works perfectly with this option.
Regarding -Xms things are more complicate (once again, to my blinded eyes).
Sun “Tuning Garbage Collection” document says: “If the value of -Xms is smaller than the value of the -Xmx parameter, not all of the space that is reserved is immediately committed to the virtual machine”
I am wondering :
- What “is immediately committed” exactly means ? Does it concern other running applications to the system ?
- What’s the best value for -Xms is order to increase product performances and in order to not decrease other system applications performances ?
- Is there any drawback to set this -Xms option to the same value than -Xmx ?? I am not a system expert at all, but it seems that setting this -Xms option to an high value doesn’t affect other running applications …
- Is there any Virtual memory management relationship there ?
I would appreciate any Java expert comment on that topic in order to have a clear view of what this -Xms option really do and to use it.
Thanks in advance and have a nice week end.
Manu
3 Comments |
Java | Tagged: Java |
Permalink
Posted by Manuel
July 6, 2009
Sometimes, depending on a lot of circumstances, Eclipse user can face the famous OutOfMemoryError. Unfortunately our users sometime face this error.
Eclipse default handling for such errors prompts the user as following:

Out Of Memory handling
I am asking myself: is there any more useful information we can provide to the end user in order to prevent such errors to occur again ???
May be I can parse the Error message to check if it’s a heap or permanent generation out of memory ? Thus I will be able to tell the user: add the following option when launching the product.
It also appears that sometimes this dialog is not opened, and the error is only logged in the .log file. Does it depends on the thread throwing the error …
Do you handle these errors differently than Eclipse in you custom products ? If yes, how ?
I would be interested in any comments suggestions on that topic.
Manu
9 Comments |
Eclipse Misc | Tagged: eclipse, OutOfMemoryError |
Permalink
Posted by Manuel
June 23, 2009
For interested people I opened an enhancement request in bugzilla regarding “Labels on Polylines” in Draw2d.
As mentioned in the bugzilla entry the patch provided is a FIRST ugly patch and should be really improved. Any help, comments, enhancements are welcome ;o)
The next post regarding Draw2d Enhancements will concern a Graphics class able to scale according to x OR y independently.
Manu
Leave a Comment » |
Eclipse Misc | Tagged: Draw2d |
Permalink
Posted by Manuel
June 12, 2009
I recently discovered http://stackoverflow.com/ a very cool and dynamic “programming Q & A site that’s free”. This site is note specific to a given programming language and guess what …. ???? There is an eclipse section here.
I know the Eclipse foundation provides dynamic newsgroups, but for users as me behind enterprise firewalls who can access newsgroups only through the basic user interface I think it would be nice to see this Eclipse’s section more and more active.
Hope to see you on stackoverflow to give our Eclipse’s community more pertinent questions and answers.
Manu
5 Comments |
Eclipse Misc |
Permalink
Posted by Manuel
May 6, 2009
Long time ago I blogged about Draw2d here. In fact I have been working with Draw2d, without GEF, during the last 2 years.
I’ll try through several posts to show the “missing features required for my needs” I implemented from my side. “Missing” is quoted because it was until today, ALWAYS possible to implement these features thanks to Draw2d flexibility ;o)
The first one I want to share is “Label Decoration For Polylines“. Because A picture is worth a thousand words here it is:

May be this feature can be interesting for some of you and thus can be contributed ? May be it’s already existing somewhere and I missed it ?
Next post will show XYScaledGraphics able to scale X axis independtly from Y axis and vice versa.
Manu
3 Comments |
Eclipse Misc |
Permalink
Posted by Manuel
April 29, 2009
Several weeks ago I blogged a lot about headless build and mainly about the problems I encountered to set up this build. I must admit that it was difficult and long to have the final build working properly but I also MUST admit than the benefits are now really appreciable.
These benefits are mainly :
- Each time we have to release our features I feel confident. First, I am confident about the content of the packages thanks to automation. Then I am also confident about the compiled code build in the packages thanks to the integration of our J-Unit tests in the build.
- The workload to perform the release thanks to the headless build can be summed-up by: ./manu-linux-build.sh build.all. In other words, it’s FREE. Who wants a release ?? You or you ? You ? No problem I can do that in one click !! You need an engineering release ? Ok here it is !!!
If your are not already building your Eclipse’s product automatically I strongly encourage you to get started with headless build.
Manu
3 Comments |
Eclipse Tools |
Permalink
Posted by Manuel