Archive for 2012

VFSJFileChooser and XPontus are unmaintained

  Both VFSJFileChooser and XPontus XML Editor are currently "very inactive", I just needed to make it "very official"!

  Surprisingly, as soon as I stopped working on those projects, I started getting tons of emails related to features requests, bugs or general questions.

 It was a nice run...

 While I may still work on Open Source projects, they will always be small to medium. Nowadays, I focus pretty much all my energy on my Consulting company, Rimero Solutions.

 Below is the short story of XPontus and VFSJFilechooser.

XPontus
  XPontus is probably my most successful project in terms of downloads and interest. Sadly the code was written very late at night without "much love" from an API perspective.
   Beer was often around to ease the pain, that's the poor man's truth! I was awake and coding almost all the time...

Audience and expectations
  The first release introduced a basic text editor with syntax highlighting, as well as few features for validating and transforming XML. The program was fast and simple.
  I started getting feedback quickly as well as many requests about code completion and other missing features.

  Around the last release, I realized that editor was widely used. On Sourceforge there was about 30 000 downloads. I would estimate about the same number of combined downloads  from many other sites such as Freshmeat(now freecode it seems), Softpedia, etc.

  XPontus was then expected to reach quickly the same level of functionality than Altova XML Spy and others. One Open Source Developer against many dedicated Corporate developers...

Planning
  It took me a while to get comfortable with Sourceforge. Between research and related coding activities, I kinda rushed things.

  With too many users' requests, I felt like 24h wasn't enough, especially with a full-time on-site job.

  I was still learning some parts of Java Swing while writing the software and I never could perform a full cleanup. I just kept adding new features to please users at the expense of maintenance issues and additional bugs...

Failure to involve other developers
  Maven is often an issue among Java Developers. In real life, not that many people are comfortable with it, especially when it's a multi-project module.

  Because the API was a bit crappy and not very flexible, people got discouraged. I also had to answer tons of questions related to design and the various technologies that I was using.


Support, later on

 Initially, I generated all the installers manually, more control, but time consuming for testing on many platforms. Later on, ej-technologies gave me a free license of Install4j while I received a free copy of IntelliJ by JetBrainsApama designed the new XPontus logo.


Last effort
  I attempted a rewrite in late 2009 using OSGI but I had the impression that it would become a bit like Eclipse Framework, but for Swing.

  The new rewrite was better designed, higher quality but it was too time consuming. I thought about making the project commercial after ensuring that I was using only Apache Licensed libraries.

  I wish that I had the same programming abilities few years ago...

VFSJFileChooser 

Audience
  I always expected VFSJFileChooser to draw interest but not that much. It was a product by a developer and for developers. The library was meant to provide a file dialog component with out-of-the-box remote browsing features. The project was not much advertised.

  VFSJFileChooser was originally supposed to complement XPontus XML Editor by providing a filesystem abstraction layer. The component was then extracted to make it generic.

General planning
  Because it was my second Open Source project, I came prepared.

  I was both organized and I knew my entire Open Source workflow well. My growing Swing experience also helped a lot.

  The scope of the project allowed to be more focused in general. I was more disciplined in terms of programming habits and time allocation.

Community involvement
  As it was a relatively small project that used Ant (and not the evil Maven), I received lots of valuable contributions very quickly.

  Some new members joined the team and were were able to get along very quickly. I didn't have to provide any explanations, nor did I answer more than few technical questions.

  We did two releases together, if I recall correctly, and I was really happy about it. I also didn't feel "alone" anymore.

  My life was getting very unbalanced and I was also exploring new career opportunities, so that was pretty much the end of  it.

Other alternatives

  • otrosvfsbrowser is a File browser for Apache Commons VFS version 2. It was created as alternative to "VFS JFileChooser" and "Commons VFS - UI".
  • vfsjfilechooser2 is a mavenized fork of the dormant vfsjfilechooser project on sf.net.

Posted in , , , | Leave a comment

emacs-grails-mode enhancements

I'm now using Emacs again as my main Anything (Text Editing, Mail Reading, Blogging, Chat, etc.).

I still use vi and IDEs randomly but I will dedicate more time to master Emacs (don't quote me on that...) and a bit of Lisp.

I was looking for some Emacs packages for Grails Development and I found emacs-grails-mode.
It's nice, but it doesn't seem to provide few things such as running a random Grails command against a project.

During development, most of the time I'm jumping between files using find-file-in-project. Occasionally, I use few functions provided by emacs-grails-mode to switch between files associated to Grails domain classes.

Then, whenever I want to run a Grails command, I switch to a dedicated shell buffer. I read the output and I jump back to the file(s) that I'm working on...

I'm no Lisp coder which is a bit sad from my perspective. If I were fluent with it, I could write couple of Emacs packages or improve few things for my personal taste.


Below is my first attempt to improve emacs-grails-mode. I will soon create a basic project on my corporate GitHub account and push the code there. The license will be GPL v3.

I added the following extensions to emacs-grails-mode.

  • Few functions to run some Grails commands from the project folder.
  • There are are also 3 functions to browse API docs, Wiki docs as well as the latest reference guide.


;; ================================
;; Extensions for grails-mode
;; Author : Yves Zoundi
;; Created : 08-Dec-2012
;; 
;; License: GNU GPL v3 (http://www.gnu.org/licenses/gpl-3.0.txt)
;; Sypnosis:
;;    Run grails command on a project
;;
;; TODO:
;;   - Add some easy keybindings like in Rinari
;;   - Would be nice if auto-completion was there
;;     (including dynamic methods)
;;   - Anything else that would be useful for Grails development
;; ================================
(require 'grails-mode)

;; --------------------------------
;; Main functions
;; --------------------------------
(defun grails/command (str)
  "Run a Grails command (Non interactive)"
  
  (project-ensure-current)
  (setq shell-command-initial-directory 
        (project-default-directory (project-current)))
  ;; store old directory
  (setq old-dir default-directory)

  (setq command-initial-directory 
        (expand-file-name shell-command-initial-directory))
  (cd command-initial-directory)
  
  ;; runs the grails command from the project directory
  (async-shell-command (concat "grails " str) nil nil)

  ;; restore previous directory
  (cd old-dir)
  )

 (defun grails/read-param-and-run (input-hint grails-command)
  "Read an input parameter and invoke a given Grails command"
  (setq grails-command-argument 
        (read-from-minibuffer input-hint))  

  (grails/command 
        (concat grails-command " " grails-command-argument))
 )

;; --------------------------------
;; General functions
;; --------------------------------
(defun grails/icommand ()
  "Enter a Grails command (Interactive)"
  (interactive)  
  (grails/read-param-and-run "Goal:" "")
  )

(defun grails/create-domain ()
  "Create a Grails Domain Class"
  (interactive)
  (grails/read-param-and-run 
   "Domain class:" "create-domain-class")
  )

(defun grails/create-controller ()
  "Create a Grails Controller"
  (interactive)
  (grails/read-param-and-run 
   "Controller Domain class:" "create-controller")
  )

(defun grails/create-service ()
  "Create a Grails Service"
  (interactive)
  (grails/read-param-and-run 
   "Service Domain class:" "create-service")
  )

(defun grails/create-taglib ()
  "Create a Grails Taglib"
  (interactive)
  (grails/read-param-and-run 
   "TagLib Name:" "create-tag-lib")
  )

;; --------------------------------
;; Plugin functions
;; --------------------------------
(defun grails/install-plugin ()
  "Install a Grails plugin"
  (interactive)
  (grails/read-param-and-run 
   "name optionalversion:" "install-plugin")
  )

(defun grails/uninstall-plugin ()
  "Uninstall a Grails plugin"
  (interactive)
  (grails/read-param-and-run 
   "Plugin Name:" "uninstall-plugin")
  )

(defun grails/package-plugin ()
  "Package a Grails plugin"
  (interactive)
  (grails/command "package-plugin")
  )

(defun grails/refresh-dependencies ()
  "Refresh Grails Dependencies"
  (interactive)
  (grails/command "refresh-dependencies")
  )

;; --------------------------------
;; Browse docs (api, wiki, guide)
;; --------------------------------
(defun grails/browse-wiki-docs ()
   "Browse the Wiki Documentation"
   (interactive)
   (browse-url "http://grails.org/Documentation")
)

(defun grails/browse-api-docs ()
   "Browse the API Documentation"
   (interactive)
   (browse-url "http://grails.org/doc/latest/api/")
)

(defun grails/browse-latest-guide ()
   "Browse the official Grails Guide"
   (interactive)
   (browse-url "http://grails.org/doc/latest/guide/single.html")
)

(provide 'emacs-grails-mode-ext)

Posted in , , | Leave a comment

A quick look at Apache Karaf




Today, I decided to take a brief look at Apache Karaf. Apache Karaf is an OSGI runtime that embeds Apache Felix as OSGI container. It ships with couple of OSGI bundles and provides a nice shell interface.

I am not really covering some technical details in this post. I haven't deployed an application under Karaf yet, as I would want to do a bit more than the typical "Hello World".

My previous OSGI experience in context
Few years ago, I was trying to understand OSGI and I created an OSGI based IRC bot, called Jerkbot. Prior to that experience, OSGI looked inaccessible, unpopular with a low return value. Even after reading couple of OSGI articles, I still couldn't figure out 100% what to do with it.

Building Jerkbot
Within a day, I was able to deal with most of the bot features. I went quickly over Apache Felix tutorials and I was ready to write some code.

  • As soon I introduced a persistence layer, I hit minor issues with JPA(classloading). After struggling with OpenJPA and Hibernate, I settled with EclipseLink.
  • I used mainly Declarative Services with annotations to save time, instead of writing couple of BundleActivators and/or XML descriptors.
  • SpringSource had a Maven repository with OSGIfied jars, so I used it instead of wrapping every single non OSGI jar

My build process involved the following :

  • Run the Maven install goal at the root of the multi-module project
  • Copy all the files with rsync from  my desktop to a laptop running FreeBSD (/)
  • Setup the Apache Felix configuration to specify the startup order of each bundle depending on what I was testing
  • Start Apache Felix from the command line with my configuration

Alternatively, I could update the bundles within the Apache Felix console without restarting the program sometimes.

Packaging
When the time came to actually shipping the application, I was annoyed. I had to write a Maven assembly configuration to package the application as a zip file. After playing with couple of deployment options, I had generated few temporary folders and it became difficult to identify what was still needed.

I ended up only shipping source code, as the PAX Maven plugin could run the application from the project tree.

If I recall correctly Karaf already existed, as mentioned in a blog post about Apache Karaf history. I believe that I did look at it, but not in details. I probably couldn't figure out quickly whether or not it would be worth it (read 2 paragraphs and give a yes/no/maybe answer).

Application Frond-end
As the bot itself had a JMX interface, I could just use JConsole to hook into the bot admin interface. I wasn't really planning on hooking up some Apache Felix commands.
With Karaf, the shell extension process seems similar to the one provided by Apache Felix.


Discovering Karaf

I was really impressed by the product's features and usability. Below are some of the topics that got my interest.

Installation
Installing Karaf on my iMac was pretty straightforward. The only problem that I run into was launching the webconsole as soon as I installed it. I got a NullPointerException and I just restarted Karaf. I guess that some initialization logic is probably missing in the bundle activation or something related.

Documentation
I usually don't read much technical documentation. The Karaf folks did a decent job with the user guide. I found myself scrolling and jumping only to topics of interest.

Console
The console is really neat with tab completion. The contextual help for each command is brief and easy to grasp.

Deployment
In additional to standard OSGI bundles, Karaf also includes support for wrapping non OSGI jar files. I guess that they achieved that with some integration with the BND tool. What really surprised me was the Maven integration in addition to standard deployment options : http://stackoverflow.com/questions/9414375/karaf-development

It is also possible to configure the available Maven repositories: https://cwiki.apache.org/KARAF/66-installing-additional-features.html

Remoting
Apache Karaf exposes couple of JMX MBeans, it has a nice Web Console and SSH access is also supported.

Security
Karaf developers really made a decent effort here. The JAAS integration seems rather smooth in addition to basic encryption services. I found a blog with a JAAS module example and I didn't expect it to be that easy http://iocanel.blogspot.ca/2010/09/karafs-jaas-modules-in-action.html

Opened questions (running foreground)
If I recall correctly, it is possible to start Apache Felix in the foreground by specifying a config property (embedded or something). I didn't figure out how to do it with Karaf, but I didn't search a lot.


Conclusion
I easily see myself using Apache Karaf on side projects in the near future. It provides many  features out of the box that would require the following :

  • Adding couple of bundles to the OSGI container manually
  • Writing few modules to support administration services with additional options. Especially with you can grab few OSGI bundles here and there that I only provide basic functionalities(Felix config/admin bundles, PAX bundles, etc.).

I still don't seem much OSGI adoption even though there are more articles and tutorials available. I believe that Apache Karaf makes OSGI somehow more "accessible". However, the OSGI adoption in the corporate world is very slow from what I see. OSGI needs more simplicity, more mediatization, more real life examples to reach many companies' doors.


References


Posted in , , , | Leave a comment

GWT in general and the CellTree widget

    I've been toying a bit with GWT and it's quite nice.

     In the past, I've used many frameworks to some extent, depending on what was needed : raw JSP with or without JSTL, Struts, VRaptor 1.x,  Cocoon, JSF, Velocity, Wicket, etc.
     I had more fun using Wicket than something like Struts 1.x for example...
     I never liked Struts but it seemed good enough compared to other frameworks at the time(Early ASP.NET versions were already more usable for medium size apps). If I were compelled to use something similar to Struts today, with the luxury of choice, I would likely select Stripes or another technology close to it (simple but flexible).
     Overall, I've always preferred component based Web Frameworks to the Actions based ones.

A) GWT and its UI frameworks (more than UI usually)
   GXT and others such as SmartGWT seem to be much slower than raw GWT for rendering but it is expected as the default look and feel looks good without any effort. The default look and feel is cool.

   I stumbled upon GXT buttons rendering. While the buttons are VERY beautiful, the amount of nested elements required for rendering is almost incredible.


1) Normal HTML

<input type="button" value="OK" class='dummyClass' />

2) GXT (dummy example to illustrate the problem)
<table cellspacing="0" role="presentation"
class="x-btn x-component x-btn-noicon" id="x-auto-175"
style="margin-right: 5px;">
  <tbody class="x-btn-small x-btn-icon-small-left">
    <tr>
      <td class="x-btn-tl">
        <i> </i>
      </td>
      <td class="x-btn-tc"></td>
      <td class="x-btn-tr">
        <i> </i>
      </td>
    </tr>
    <tr>
      <td class="x-btn-ml">
        <i> </i>
      </td>
      <td class="x-btn-mc">
        <em unselectable="on" class="">
          <button style="position: relative; width: 69px;"
          type="button" class="x-btn-text" tabindex="0">
          Save</button>
        </em>
      </td>
      <td class="x-btn-mr">
        <i> </i>
      </td>
    </tr>
    <tr>
      <td class="x-btn-bl">
        <i> </i>
      </td>
      <td class="x-btn-bc"></td>
      <td class="x-btn-br">
        <i> </i>
      </td>
    </tr>
  </tbody>
</table>

The above example was taken from http://my.opera.com/lienngoc/blog/2010/08/10/how-to-improve-performance-in-a-gwt-gxt-application and is realistic enough.

B) GWT CellTree
The GWT CellTree is a very nice widget. I managed to use it with RPC calls within a small amount of time and minimal reading.

1) Rendering
I was expecting to be able to provide easily a custom renderer and that was the case. In the GWT showcase, for each level of the tree, the same kind of node is rendered which means a single renderer at each level of the tree. I was like well, it is just an 'example'. In real life, you usually have objects of different kinds at the same level of a tree and they need to be rendered differently.

I ended up using a single renderer and calling instanceof to select the appropriate styling for each node of the tree. I couldn't find another solution within a short amount of time.
public void render(Context context, MyObject value, SafeHtmlBuilder sb) {
 if (value != null) {
  sb.appendHtmlConstant((value instanceof MyBaseObject) ? baseImgHTML : advancedImgHTML).appendEscaped(" ");
  sb.appendHtmlConstant("");
  sb.appendEscaped(value.toString());
  sb.appendHtmlConstant("");
 }
}

2) Can I haz vertical scrollbars???
After testing a simple application, I noticed that Google Chrome was displaying a vertical scrollbar while I was expanding the CellTree nodes. Firefox didn't render any scrollbars.... I came accross a stackoverflow link, and for a second I thought 'this is it!', I guess it would've been too easy...
http://stackoverflow.com/questions/7854086/horizontal-scrollpanel-not-displaying-with-celltree

After 'googling' a bit and Firebug's help, I found a solution.
1. Add few CSS style attributes to the CellTree and its parent container
The celltree has the following CSS style : width:100%;height:100%;overflow:auto. It is enclosed within an HTMLPanel with the same CSS style. There's no need to combine a ScrollPanel with let's say a VerticalPanel. Same problem and additional widgets used.


2. Ensure that the first element has a visible overflow and a dummy size in pixels
I didn't test it with a small tree, but I figure that as long as you supply a dummy size that will always be lower than the height of a non empty tree, it'll be fine. I used 100px.
Style firstCellTreeChildStyle = cellTree.getElement().getFirstChildElement().getStyle();
firstCellTreeChildStyle.setOverflow(Overflow.VISIBLE);
firstCellTreeChildStyle.setHeight(100, Unit.PX);   

C) Overall opinion about pure GWT vs GWT frameworks

It looks like building a professional looking pure GWT application requires a serious commitment in terms of styling widgets. For medium-small applications, I think that using a framework will give good looking results with less time without many performance issues.

Posted in , | Leave a comment

Swedish Greys - a WordPress theme from Nordic Themepark. Converted by LiteThemes.com.