January 31, 2008
You are interested in both double clicks and single clicks in your SWT application ??
You have a problem since when the user double clicks the code for single clicks is also called !!!
Here is a useful discussion on SWT news group proposing a solution. (You must login in eclipse forums to access this link).
This solution works, nevertheless i would be interested in any other way to do this … if you have a solution please let me know.
1 Comment |
SWT |
Permalink
Posted by Manuel
January 29, 2008
Eclipse Java development tool provides default Java templates such as for, syserr, sysout etc … When typing these templates in the Java editor and then pressing ctrl + space JDT insert automatically for you a for loop, a System.err.println(”") or a System.out.println(”"). Nice !!!
These shortcuts are really cool but what about creating our own shortcuts ??
For example as SWT developer we often need to write Display.getCurrent.getSystemColor(SWT.COLOR_XXXX);
Here is (from the JDT online help ) the way to follow to add this template :
To create your own templates, go to the Java > Editor > Templates preference page and press the New button to create a template. For our example, the template would look like this: Display.getCurrent().getSystemColor(SWT.COLOR_${cursor})
Using this feature, you can create all the templates you need !!! The previous sample adds a basic template but you can create complex templates depending on a lot of parameters of the current edited text. There is a lot of default templates provided within the JDT showing how to create complex templates.
More informations are available here.
No Comments » |
Eclipse Tools |
Permalink
Posted by Manuel
January 25, 2008
Are you looking for your Eclipse workspace Error Log ??
The error log can be accessed by the following ways
- For users with Eclipse 3.X and PDE installed : Window -> Show View -> Other -> PDE Runtime -> Error Log
- For users with Eclipse 3.4 : Window -> Show View -> General -> Error Log
- For every users : Help -> About Eclipse -> Configuration Details -> View Error Log
- For every users : the location of the file is : “workspaceLoaction/.metadata/.log”
No Comments » |
Eclipse Misc |
Permalink
Posted by Manuel
January 23, 2008
You are interested in any key events of an SWT application??
Unfortunately this can’t be done.
You have to add your KeyListener on a given widget. Your listener will receive events when the user types on the keyboard IF AND ONLY IF the listened widget has focus.
If this widget is the only one intersted in key events in your application then it will work perfectly !!!
If you have an other widget intersted in key events, the widget with focus will receive key events but NOT THE 2 widgets.
Focus is set when the user clicks on a widget having at least one KeyListener associated to it. As a consequence the notified listener depends on the user actions … You can also set the focus programmatically using setFocus() method.
For any further informations look here!
No Comments » |
SWT |
Permalink
Posted by Manuel
January 18, 2008
What’s hapen when writting using Java langage :
Integer myInt = new Integer(2);
myInt- -;
??
In fact, i had a Map and i was doing this on it :
Integer mynt = Map.get(myString);
myInt- -;
thinking that it would modified the map entry associated to myString.
I was wrong !!!!! Here the Java VM behaves the same way than writting :
myInt = new Integer(myInt.getValue() - 1);
What do you think about that ? To my eyes it’s quite confusing …
3 Comments |
Java |
Permalink
Posted by Manuel
January 16, 2008
Have you ever try to draw a very large shape on an SWT Canvas using GC drawing methods on a linux workstation ?
Try to draw a line from (245, 25
to (40000, 150) and it will sometimes result in bad rendering (see here for more details). You are thinking, why draw such a line since my screen resolution can’t exceed 1600 pixels …. ???
You are right so, to easily workaround this limitation we just have to compute the intersection between the line and the underlying Canvas’s client area.
Fine but ….. in some cases, when drawing very large scrollable diagrams for example, it can be very difficult to compute the visible part of a given shape. Have you for example, already computed the intersection between an SWT polygon == an int[] and an SWT Rectangle ??
It’s not so trivial, and the easyest way i found to do this is to use Java2Dclasses !!! and I don’t want to depend on Java2D. (I opened a new feature request to SWT here).
All this long story to ask these questions :
Have you ever encountered this limitation, how did you solved it ?
2 Comments |
SWT |
Permalink
Posted by Manuel
January 16, 2008
An other way to dump the JVM memory heap is to use javax.management and com.sun.management APIs . You can find here the way to do this.
Using this solution I wrote a simple Eclipse plugin just adding a tool bar button allowing me to dump the memory of the current running Eclipse’s JVM in a choosen file.
I can now profile my Eclipse’s plugins without living my favorite open extensible IDE for anything and nothing in particular.
3 Comments |
Eclipse Tools |
Permalink
Posted by Manuel
January 16, 2008
After quite a long time browsing the web i finally found a way to profile my Eclipse plugins using SAP Memory Analyzer. In fact i had troubles to generate an on demand memory dump to the JVM running Eclipse. It was easy to generate a memory dump on OutOfMemoryErrors using a simple jvm parameter but not so easy to have this dump at any time. Using jconsole 1.6 you can have this dump when you want
Here is the procedure i am using to analyze the JVM memory content of a running Eclipse :
0- You need : SAP Memory Analyzer (free registration required) and a JDK 6.
1- Set your Java environment (jconsole.exe + java.exe) to a JDK 1.6 (new jconsole tool and new com.sun.management mbean are required)
2- Edit your eclipse.ini file and add the following bold lines :
-vm /home/selvam/Softs/Java/jdk1.6.0_04/bin/java (path to a java.exe 1.6 to force Eclipse to create a new java.exe process)
-vmargs
-Dcom.sun.management.jmxremote (To start Eclipse with the management agent for local monitoring, MUST be added after -vmargs)
-Xms40m
-Xmx512m
3- Launch Eclipse
4- Launch jconsole.exe
5- You should see the process corresponding to the previously launched Eclipse (if not be sure to have correctly perform steps 1,2 and 3). Connect to this process.

6- Go to the Mbeans tab and to com.sun.management / HotSpotDiagnostic / Operations (No com.sun.management entry displayed means that the underlying JVM is older than 1.6)
7- Enter the full path of the memory dump file to generate in the first argument slot and then click dumpHeap button. Warning - The file name must have .hprof extension in order to be opened with SAP Memory Analyzer. After few seconds (depending on the size of your JVM memory heap) you should receive a confirmation message.
8- Finally, you just have to open the generated file with SAP Memory analyzer and have fun !!!!
2 Comments |
Eclipse Tools |
Permalink
Posted by Manuel