Posts

Smaller font sizes for Netbeans on Linux

3 min read

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

2 min read

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.

Netbeans actions toolbar with local lookup context

2 min read

This article talks about Netbeans and an action toolbar that is sensitive to a local selection lookup context. Actually, global selection context sensitive actions is powerful mechanism with a subtle limitation: everything happens globally. It is no use for a local actions menu or toolbar sensitive to a limited selection context restricted to a JPanel or TopComponent. Not surprisingly, the Netbeans Java IDE itself reinvents the wheel each time this requirement arises, for example, on the ‘variables’ and ‘breakpoint’ windows.

Simplest JTable icon cell renderer ever

2 min read

While there are many examples of JTable cell renderers spread on the Internet, they lack a clear understanding about how they were proposed to work. This article presents and explains a minimal and correct cell renderer, extending the default cell renderer as supposed by the Java API. The example explains how to display icons instead of text.

Originally published at https://techtavern.wordpress.com.

For the hurried, first the code:


public class EnumIconCellRenderer extends DefaultTableCellRenderer {

private final Map<!--?, ImageIcon--> icones;

  public EnumIconCellRenderer(final Map<!--?, ImageIcon--> icones) {
    // Initialize data used to render cells.
    this.icones = icones;

    // Set properties that never change.
    this.setHorizontalAlignment(JLabel.CENTER);
    this.setVerticalAlignment(JLabel.CENTER);
    this.setText(null);
  }

  @Override
  protected void setValue(Object value) {
    // Set properties that change on individual cells.
    this.setIcon(icones.get(value));
  }
}

A cell renderer works like a rubber-stamp for each cell in the table. The renders uses a Swing component to draw the first cell, changes the contents of that cell renderer, and for each following row shifts the origin of the component to the new location, then re-draws it. The default cell renderer uses the convenient JLabel to stamp a potentially inconvenient toString() representation of data objects. Note that getTableCellRendererComponent() returns itself (the JLabel), but properly configured for an individual cell. Therefore, setting properties of the renderes itself actually configures the component returned by getTableCellRendererComponent().

MySQL, Scheduled Events and Amazon RDS

1 min read

This article explains how to enable SQL database scheduled events for the Amazon Relational Database Service (RDS). By default, Amazon does not allow one to create (in other words, to schedule) events. Events are SQL code intended to execute periodically or in future. The solution is quite similar my last article. One needs to provide the ‘event_scheduler’ parameter set to “ON” or “1”. Parameters are set by creating a new parameter group (or editing an existing one) and assigning this parameter group to the database instance.

MySQL, Triggers and Amazon RDS

2 min read

This article explains how to enable SQL database triggers for the Amazon Relational Database Service (RDS).

If one attempts to create a SQL database trigger, then the database server will complain a confusing and misleading message like: “ERROR 1419 (HY000) at line #: You do not have the SUPER privilege and binary logging is enabled (you might want to use the less safe log_bin_trust_function_creators variable)“.

It happens that Amazon decided to disable all user defined SQL code, as binary procedures could compromise the RDS architecture. And for this purpose, Amazon blocked granting the missing ‘SUPER’ privileges to any database user except the ‘rdsadmin’ user owned by Amazon itself.

Logging practices on running solver processes in Java

7 min read

We implemented a java computer program that solves a certain mathematical problem. The program runs for a long time and produces a textual representation of the best solution found.

It was the opportunity to discover the importance of adopting two usually unnoticed components: the Simple Logging Facade for Java (SLF4J) and the Logback logging framework. By employing both components a step further than they were originally designed, we increased our coding, debugging, testing and validation productivity in means far away than expected for traditional logging. All benefits were nearly for free and required no additional coding.

SymmetricDS syncronizing two tables with different names

2 min read

While working with our newly discovered SymmetricDS tool, I realized that their manual does not clearly state how to synchronize two databases if their table names do not match. That might happen while matching tables between databases of two different companies, each one with its own table name policies. Blame those Database Administrators!

Here is how I accomplished synchronized two tables with different names:

First, I did the usual configuration: I defined two node groups A and B, defined a link between those node groups, defined a channel and a router for each direction (A to B  and B to A).

How SymmetricDS successfully replaced our complicated client-server architecture

2 min read

With SymmetricDS , we avoided investing effort in designing, implementing and testing a complex, asynchronous communication protocol over web-service layer. Instead, we achieved a simple, intuitive interface that allowed us to deliver out solution within few days.

Our application started with a local standalone server that processes long running transactions. It naturally evolved to a distributed architecture. While benefits of the new architecture were clear to us and our customers, an issue arose : we would force our customers to enable their applications with boring and non intuitive web-services to communicate with our transaction server.

Eclipse Subversive does not frustrate me anymore… Now I use EGit!

2 min read

A considerably time ago, I wrote down my frustration on using the Eclipse Subversive Plugin. At that time, I was annoyed just because refactoring did not work properly. Now, Subversive has gone worse.

SVN itself does a good job tracking history of moved and copied files, even if directories are moved or renamed. By 2009, the Subversive plugin stopped supporting this features and a simple directory rearrangements may now lead your local copy to an irreversible inconsistent state.