Wednesday, December 7, 2011

Multiline ToolTips

Funny, never thought about it, but when using a ToolTip with NbBundle.getMessage and a property in the it is of course possible to make a multipline ToolTip by using the <html> HTML tag. An two line example would be:

LBL_DeltaX_ToolTip=<html>Change in x direction in mm.<\br>Some other second line text</html>

Have this as ONE line in the file.

Saturday, December 3, 2011

Access currentVersion

The currentVersion property is used to for example show the version number of your RCP in the Title line. Now it can be set via branding 
${basedir}/branding/core/core.jar/org/netbeans/core/startup/ Nothing new here. The trick is if this holds information you would like to retrieve at runtime.

Naively one could try NbBundle.getMessage(Main.class, "currentVersion"); which will fail. 

I have found a way around which may not be the most obvious path - but at least a solution which might help others. I had to work around it by copying the content of that property to a file which is within my access space. I do this via Ant when building the app each time. Example:

In the main build.xml add a target 
<target name="build-brand" depends="-init">
<propertyfile file="${basedir}/../moduleA/com/mycode/xyz/" comment="Updated by build script for full version info">
<entry key="fullVersion" value="${app.version}" />

The target above will create a property in the file in the package
/com/mycode/xyz of moduleA You could here instead of using ${app.version} use ant command to read the currentVersion property if already set. If it is in your control you can of course set the currentVersion automatically as well like adding the following into the same ant target. ${build.number} and $(app.comment} are my own properties - but you get the point.
<propertyfile file="${basedir}/branding/core/core.jar/org/netbeans/core/startup/" comment="Updated by build script">
<entry key="key="currentVersion" " value="${app.title} ${app.version}.${build.number} ${app.comment}" />

If you do this first you can set the "fullVersion" (or whatever you would like to call it) property to the moduleA/com/mycode/xyz package and a method like

    public String getFullSoftwareVersion() {
        // This value is stored in the of this package
        return NbBundle.getMessage(MyClassXyz.class, "fullVersion");

 As this is within your code you can now read the value.