View TopComponents with icons on Netbeans RCP

This article explains an approach to enable tabs with icons to ‘view’ TopComponents.

This article appeared first on techtavern.wordpress.com

The Problem

A typical Netbeans RCP application always displays TopComponents with ‘editor’ mode with their icon and their title, even if the tab runs out of space. Here is an example:

EditorTopComponentTab

Tabs of editor TopComponents

TopComponents with other modes are displayed as ‘views’. Their tabs are extremely simplistic: they never show their icon and their title is shortened or even omitted in case of less space. Here is an example:

Copying from Git to Clearcase

This article is about my recent open source project, git-to-clearcase.

There are many old-fashioned IT business that still believe on Clearcase as their software configuration management.

I experienced that Clearcase imposes an extremely complex versioning model, is poorly supported on major IDEs and lacks some elementary features, like simple file undelete. Everything is complicated and slow on Clearcase and crashes happen frequently. Even worse, Clearcase completely fails to support some modern trends, like agile development, lean infrastructure, incremental design and refactoring.

Netbeans Platform: excluding locales from zip and installer distribution

This article explains how to prevent Netbeans RCP from packaging unwanted locales into the zip distribution and installers.

This article originally appeared on https://techtavern.wordpress.com

Current situation:

  • The default Netbeans RCP build always includes all localization jars from the harness directory: Russian, Chinese, Japanese and Brazilian Portuguese.
  • Netbeans project properties and branding properties lack configuration to select bundled languages.
  • The build templates did not foresee features to exclude locales.

Problem:

  • Annoying long build times. Proportional to the number of jars, build time increases by five if all default languages are included.
  • Larger distributable artifact size. Localization jars take about 500kB.

Solution:

  • Netbeans Ant build is reasonably organized by build templates. And Ant allows overriding targets inherited from templates.
  • We override the build-zip target. This target generates the .zip distribution artifact, which also serves a input for the installer.

The modified script:

The original build-zip target (netbeans 8.0) is found in the harness directory of your Netbeans installation. We place an adapted copy into the build.xml of your application root directory, thus overriding the behavior of the original target. The red lines were added to prevent adding localization for Russian, Chinese and Japanese.

Google AppEngine on Netbeans 8

Even though Google does not officially support Netbeans IDE, it is still possible to develop Google App Engine applications with Netbeans 8.

This article originally appeared on https://techtavern.wordpress.com

There has been a Netbeans plugin for Google App Engine hosted at Kenai, which seems to have been left on its own since June 2009. Fortunately, the project was forked by Gaelyk and who updated the plugin for Netbeans 7.4. I was pleased to confirm that his plugin also works for Netbeans 8.0 and for Google App Engine 1.9.x. And I assure that it work better than that dumb Eclipse Web Tools Platform.

Git Ignore file for Netbeans RCP projects

This article suggest a .gitignore file for GIT repositories that keep Netbeans RCP suite and module projects.

For short:

nbproject/private/
build/
dist/

As explained:

  • nbproject/private/ Matches the local, per-user configuration directories, which are suite/nbproject/private for suites and module/nbproject/private for module projects.
  • build/ Matches the module/build and suite/build directories. Modules store their compiled classes within the module/build directory. Suites write shareable artifacts into the module/build directory.
  • dist/ Matches the suite/dist directories, where suites store distributable artifacts like installation programs and java webstart.

If you prefer Eclipse EGit, then add following lines:

Ant task to remove signature from jar file

This article suggest an Ant macro that removes the publisher signature from an java .jar file, also known as to ‘unsign’ a jar.


    <macrodef name="unsignjar">
        <attribute name="jarFile" />
        <sequential>
            <jar update="yes"
                 jarfile="@{jarFile}.tmp">
                <zipfileset src="@{jarFile}">
                    <include name="**"/>
                    <exclude name="META-INF/*.SF"/>
                    <exclude name="META-INF/*.DSA"/>
                    <exclude name="META-INF/*.RSA"/>
                </zipfileset>
            </jar>
            <move file="@{jarFile}.tmp" 
                  tofile="@{jarFile}"
                  overwrite="true" />
        </sequential>
    </macrodef>

An example how to call the macro.

Portable Java 8 JDK on Windows

Yes, it is possible to extract the Java 8 JDK without administration privileges (a portable Java 8 JDK), although Oracle only provides an installer for windows. This recipe also works for Java 7.

Recipe for JDK 8 (update 93 and newer)

Prerequisite: Install 7-Zip file archiver (or its portable alternative).

  1. Download the Java 8 SDK for Windows from Oracle. You will get a file named like jdk-8u101-windows-x64.exe.
  2. Open the downloaded file with 7-Zip, which will show a a list of files and folders.
  3. Open folder ‘.rsrc’ (select and double click this folder within 7-Zip).
  4. Open folder ‘1033’ (or the folder of greatest size).
  5. Open folder ‘JAVA_CAB10’ (or the folder of greatest size).
  6. Open file ‘111’ (or the folder of greatest size).
  7. Open file ‘tools.zip’.
  8. Extract its contents to a directory where own write permissions, for example: C:\Users\Daniel\Documents\jdk-8u102-x64. To prevent issues, I recommend a directory without spaces.
  9. From within this directory, search for all .pack files and extract them using unpack2000.exe command line tool found in the bin subdirectory. Following windows prompt command does the trick when executed from within the extracted directory: for /r %i in (*.pack) do .\bin\unpack200.exe %i %~pi%~ni.jar

The downloaded .exe file also contains the JDK sources. Navigating through the folders ‘.rsrc’, ‘1033’, ‘JAVA_CAB9’, ‘110’.

Compiling your abstract syntax tree transformation with Netbeans IDE

This article explains how to configure the Netbeans IDE to recognize java code the uses compiler internal classes. These classes are not part of the standard JDK and are not recognized by IDEs such as Netbeans, which will refuse to compile the correct code.

The compiler internal classes are used mainly as a hack to define annotations that automatically generate code. The most significant example is the Project Lombok, which transparently generates getters, setters and other code bload. Under the hood, the “Pluggable Annotation Processing API”  (JSR 269) provides a mechanism that exposes internal classes from the java compiler. These classes provide methods that allow us change the abstract syntax tree.

Smaller font sizes for Netbeans on Linux

This article describes an approach to launch Netbeans on Linux with smaller and narrower font sizes.

Modern desktop environments like KDE or Gnome suggest larger font sizes to enhance screen readability. However, Netbeans users might not be willing to waste precious space on views around the source code that matters. Here are some alternatives one might consider.

This article originally appeared on https://techtavern.wordpress.com

1) To customize window manager and themes

The Gnome desktop provides nice dialogs to customize GTK+ and Gnome decorations and font sizes. The KDE desktop offers the QT-GTK binding that applies KDE design on GTK/Gnome applications. While simple, this alternative applies to Netbeans and all other application, which might not be your intention.

Copy files by extension that keeps directory structure

Some more essential Linux knowledge, written down to document it.

Problem:

Copy only files by their type (or file extension), while preserving the directory structure.

Solution:

I would recommend using rsync that copies files recursively and allows filtering them by their file name. The challenge is configuring a set of filter rules.

Command line:

To copy everything: rsync -avim –include=’*/’ –include=’*.doc’ –exclude=’*’ /source /destination

Explained:

Copy recursively. Go down into directory structure.