mercoledì 27 gennaio 2010

Organize extension point popupMenus

A popupMenu declares one or more insertionPoints that will be used by contributors to organize their contributions into a meaningful, more user-friendly, consistent list.
If clients only specify the "popupMenuId" attribute of the viewer element, then the set of insertionPoints used by the context menu will default to the following list in the given order:

"group.new" separator="true"
"group.goto"
"group.open" separator="true"
"group.openWith"
"group.show" separator="true"
"group.edit" separator="true"
"group.reorganize"
"group.port"
"group.generate" separator="true"
"group.search" separator="true"
"group.build" separator="true"
"additions" separator="true"
"group.properties" separator="true"


If not specified, the default group is additions.

Clients that wish to refer to these values programmatically may use the corresponding constants in org.eclipse.ui.navigator.ICommonMenuConstants.

Clients that wish to customize their menus are encouraged to start with this list and add or remove insertion points as necessary. Clients are also encouraged to follow the pattern of beginning each group name with "group.".

martedì 26 gennaio 2010

How to start a java application for remote debugging

In order to allow remote debugging for a java application the command line should be customized with the following arguments:
java -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n MyClass
-Xdebug enables debugging mode;
-Xrunjdwp configures Java Debug Wire Protocol with sub-options; like the communication mode between jvm and debugger, the listening port, whether wait until the debugger connection or not, etc. See links for further details

See also:
-Xrunjdwp sub-options
Remote Debugging with Eclipse

lunedì 23 novembre 2009

Java plugin per Firefox su Ubuntu

To execute applets in your Firefox browser you have to install the java plugin.

Follow this steps:
1) sudo apt-get install sun-java6-jdk
2) ln -s /usr/lib/jvm/__JDK-VERSION__/jre/plugin/i386/ns7/libjavaplugin_oji.so /home/__USER__/.mozilla/plugins/

giovedì 5 novembre 2009

Why hibernation doesn't work?

In my case the answer is easy: not enough space in the swap partition.
In order to hibernate the pc, Ubuntu copies the ram to the swap partition, so this must be at least as bigger as the installed ram.

You can verify ram and swap size with:
cat /proc/meminfo | grep SwapTotal; cat /proc/meminfo | grep MemTotal

domenica 1 novembre 2009

Mysql and the default value of a TIMESTAMP column

The DEFAULT value in CREATE TABLE specification indicates a default value for a column.

The default value must be a constant and it cannot be a function or an expression. This means, for example, that you cannot set the default for a date column to be the value of a function such as NOW(). The solution is to specify CURRENT_TIMESTAMP as the default for a TIMESTAMP column.

giovedì 29 ottobre 2009

Handler di Eclipse RCP
Classicamente, la definizione di un command per un plugin RCP prevede una classe handler di default, che definisca il comportamento dell'applicazione quando viene attivato il command.

id="it.sinossi.SinossiCommand"
categoryid="it.sinossi.command.SinossiCommandsCategory"
defaulthandler="it.sinossi.handlers.DefaultSinossiHandler"
name="SinossiCommand">



In questo caso, quando viene attivato il SinossiCommand, viene automaticamente eseguito il metodo execute(ExecutionEvent evt) della classe DefaultSinossiHandler.

Supponiamo ora che un plugin esterno abbia la necessità di personalizzare il comportamento dell'applicazione all'attivazione del SinossiCommand, cioè di definire un handler custom per tale command.
E' sufficiente inserire nel plugin.xml del progetto esterno un'extension di org.eclipse.ui.handler come la seguente:


commandid="it.sinossi.command.SinossiCommandsCategory">









L'handler CustomSinossiHandler viene utilizzato al posto del default handler se l'activePartId corrisponde a quello della vista SinossiView. Infatti, la porzione di xml compresa all'interno del tag "activeWhen" è una core expressione e permette di definire quali sono le condizioni in cui l'handler è attivato. Analogamente, si può definire quando l'handler è abilitato definendo una core expression all'interno del tag "enableWhen".
Per saperne di più..
Help - Eclipse SDK - Handlers
Eclipse wiki - Command Core Expressions

venerdì 23 ottobre 2009

Fare il debug dei test avviati con maven

Nel caso in cui si presenti la necessità di fare il debug di test avviati tramite maven è sufficiente aggiungere il flag -Dmaven.surefire.debug.
Da console:
mvn test -Dmaven.surefire.debug
questo fa in modo che i test, subito dopo l'avvio, si mettano in pausa in attesa che un debugger remoto si colleghi alla porta 5005 (valore di default eventualmente modificabile).

Se volessimo connettere Eclipse in debug non dovremmo fare altro che creare una nuova Debug Configuration (menù Run > Debug Configuration...), selezionare il tipo "Remote Java Application" e impostare nel campo Port il valore 5005. Cliccando su Debug, Eclipse si collegherà ai test, precedentemente entrati in pausa, facendoli immediatamente ripartire. L'esecuzione si fermerà su tutti breakpoint che avremo impostato permettendo il normale debug all'interno di Eclipse.

Vedi anche:
Maven Surefire Plugin > Examples > Debugging Tests