Sun tech evangelist Netbeans will be getting first-class Groovy support

On Weds, July 18th, Gregg Sporar came to the Tampa Java Users Group and gave a presentation on NB 5.5.1 and some glances at NB 6.0 M10. During the talk, he mentioned several times of how the improvements were about bringing NB up to speed with the other IDEs. I couldn’t resist asking during the Q&A session when Groovy support in Netbeans will be brought up to speed with IntelliJ(ie code completion and Grails).

He mentioned Project Schliemann which can be used to add basic language support as a stopgap. He added that Tor Norbye(of Java Posse fame and referred to in the talk as the guy who added Ruby support) will be taking the lessons learned and adding Groovy first class Groovy support. There was no roadmap or time frame given other than after NB 6. Tor has been mum on the topic on the Java Posse. The most interesting point for me was that he said several people in the company questioned the motive behind adding Ruby support before Groovy support...So it seems we weren’t alone.

30Boxes Viewer

Without further ado, here is the 30Boxes widget I prepared for BarCamp but never got finished. Thanks to SwingX-WS, it was very easy to wrap REST calls, parse the responses, and react appropriately.

Here’s the wrapper function for deleting a Todo:


public void deleteTodo(todo) {
def response = session.get ("http://30boxes.com/api/api.php?method=todos.Delete" +
"&apiKey="+apiKey+"&authorizedUserToken="+authToken+
"&todoId="+todo)
def status = parseResponse(response.getBody())
if (status == "fail")
// Make this an option pane later
println "There was a problem deleting the todo."
}




The viewer works for simple creation and deletion of Todos and creation of Events. The pseudo-API(Groovy service layer) does have method calls for deletion of events[and some other stuff] but Swing was acting funny and I wanted to get it out the door since it wasn’t going to be feature-complete anyways. To run it with your own data, you must visit 30Boxes, get an API key and authorization token, and put them in the config.xml file. Unlike Facebook, these keys are per-user not per-application.

Concerning the layout, I used Nimbus for the look and feel. The task pane is nested inside a titled panel with a simple background painter applied to the title. Here is the code that draws the frame:

 frame = swing.frame(size:[300,300],defaultCloseOperation:WindowConstants.EXIT_ON_CLOSE) {
    titledPanel(title:"30Boxes Viewer", titlePainter:makeTitlePainter(), 
    border:new DropShadowBorder(Color.BLACK,15), size:[300,400],mousePressed:{menu.setVisible(true)}) {
        scrollPane() {
            taskPaneContainer() {
                todoPane = taskPane(title:"To Do:",layout:new MigLayout()) 
                eventPane = taskPane(title:"Events:", layout:new MigLayout())
            }
        }
    }

}

Download the Netbeans project here.

Enjoy!

btw, sorry about the formatting of the code snippets.

 

SwingXBuilder update

All’s been relatively quiet on the SwingXBuilder front. There has been a little bit going on though.

In an effort to have a full-fledged Groovy SwingX application, I’ve started working on a note-taking application like Tomboy. For the time being, its working title is GroovyNote. Instead of using XML files, I’m using Derby with a JPA middle-layer so that Groovy can manipulate plain objects and not deal with messy SQL calls, though Groovy SQL isn’t that bad really.

The remaining demo app from BarCamp which interfaces with 30Boxes is being rewritten. Some things were hard-coded in, some features are being added, and the Glossitope code is being taken out. Previously it was only able to view events and todos but not manage them.

My linux partition had issues after I had backed it up to try Foresight Linux. It seems the PnP bios is hosed so it’ll run but sound and video won’t work. I had originally thought it was a Foresight issue but it stayed when I reinstalled Ubuntu. So I’m stuck in Windows land for the time being. Hopefully it’s something that can be fixed by the kernel and I’ll just tough it out until Gusty comes out in October.

I’ve accepted an invitation to give a presentation in August at my local Java User Group here in Tampa. I did want to go to another BarCamp that month as well, having had a blast at my first but there aren’t any in FL and the ones that are worth flying to are only a day long, thus requiring a hotel stay($$$). Maybe BarCampDC will get more organized by then. I have fam close by.

SwingXBuilder Demo Calendar widget

As promised, here is one of the demos for BarCamp that I ported to Groovy with the SwingXBuilder. The original demo was a desklet using the Glossitope architecture but I decided to strip that stuff away since it never loaded correctly in Glossitope. It would run in Netbeans, but there was some sort of loading error. I guess when the SwingXBuilder reaches 1.0, I’ll talk to Josh Marinacci about that.

BarCamp Calendar Demo
Glossitope’s Calendar

Source code here – Gant is required

BarCamp Chicago Day 1

Yesterday(Sat) I woke up at 4A and drove to the airport to get my flight via Nashville to Chicago. Luckily the security checkpoints weren’t that bad and I was able to camp out a spot in line B[Southwest cattle call fun]. On the second flight, the pilot informed us that it was raining in Chicago. I wanted cooler not cold. It turned out to be brisk but not cold so I decided to keep on the shorts I was wearing. Worried about being the first arrival, I try to waste a little time before going to the venue. My plan worked out a little too well because I inadvertently got on the correct L-train line in the wrong direction. Thirteen stops later, I realized my mistake. I finally arrive at the general whereabouts at about 12:45 - 1P. Mind you, my flight landed at 9:40A! I thought the address was 1455 N Milwaukee. I walk up and down the street four or five times and see nothing. I see a sign for a public library and go in. I try to use the restroom, they have to buzz me in. WTF! This is a public library in a posh pseudo-SoHo area of Chicago. I try furiously to access their wifi network, the icon is spinning and spinning. I finally connect and realize the address is 1464, 3 blocks south of the library.

I arrive and am greeted by the organizer, Jason Rexilius, who points me toward all the pizza, chips, and snacks, all types of liquor, a cooler of Mountain Dew, a cooler of Red Bull, and a kiddie pool with 3 kegs, various bottled beers, and Gatorades. He may have mentioned something about the meeting space. About mid-day, he gave the keynote/welcome session noting that BarCamp Chicago is bigger than BarCamp New York[in terms of web traffic]. Throughout the day, there were some really cool demos. I got to see a OLPC XO-1 UP-CLOSE. I really want one. I would consider learning Python to get one. There was also a mini-talk on Nintendo DS Homebrew that I wasn’t able to get to because it coincided with a Ruby talk I wanted to check out.

There were technical difficulties all around. The guy who wanted to give an "Anatomy of Lisp" talk had a catastrophic pdf corruption. He’s gonna recover the file and give it today. There were several people who had projector issues, myself included. In my defense, there were 3 monitor cables in the presentation space. Ubuntu will do PnP if the component is plugged on bootup. I didn’t have as many people as I expected at my talk because it was so late in the day(8P). There were some good questions and I got the general feel that people liked it. They liked the demos... well, the ones that ran. Glossitope which uses Java Webstart to launch wouldn’t run. And this occured during a question about the differences between Webstart and Glossitope.(Argh!) About midway through the talk, I noticed my tick is saying the word "So..." at the end of slides. I pointed it out and got a couple of laughs when I would slip up and do it again. Some of my jokes flopped miserably, some went over well.

And then there was the dreaded question I knew would come: "Are there any visual GUI designers for Groovy?"
Alas, no.

Other than the free junk food, energy drinks, and alcohol, there were some great discussions. I felt free to express myself without having to dumb stuff down. These are really passionate people who read, know their industry, and didn’t learn just for a job. Jason Rexilius and I had a discussion about the merits and utility of Java. He thinks there is little to none but I still think he is a great guy. I talked to this kid Jess about the new JSRs and how the best ORM can’t make up for crappy DB design, and told a bunch of folks about my project.

One guy told me that at one point he counted 75 people so I’m guessing at least double that cycled in and out throughout the day.

Having been up for almost 24 hours, I turn in at 2A Chicago time. I curl up in a sleeping bag in a dim corner so my new friends can’t pull any frat boy tricks on the first to fall asleep. I wake up and shower to find that some of my compatriots have stayed up all night watching vids and drinking.

SwingX News

My webhost was having DB issues last week so that's why some of you might have gotten error pages. Anyways...

BarCamp is this week and I'm super excited to get out of Florida into slightly cooler weather. Last Saturday, it hit 90 degrees before 11AM. I think that's like 30 or 32 degrees for you Centigrade folks. I'm also looking forward to meeting fellow minded geeks.

So that this isn't a total fluff piece, and so that the aggregator picks it up, more Groovy SwingXBuilder demos are coming. I've been cramming to get stuff done so watch this space next week, I'll start putting stuff up. Due to BarCamp, the builder is basically in feature freeze until Monday save fixes, stuff from v1.0, and whatever I might need for a demo. Scott and Andres, thanks for the feedback.

Gratuitous use of ExpandoMetaClass

Things have been quietly and smoothly chugging along since the move to Groovy 1.1-BETA. I added support for a couple of the new SwingLabs Layout Managers. StackLayout, HorizontalLayout, and VerticalLayout being a couple of them. The latter two are great because they address the one sticking point I had with BoxLayout, the axis parameter. StackLayout, as its name implies, functions like CardLayout with one big difference. In CardLayout, each card obscures all the others. So I was wondering, what if you want to declare your components and have them added from front to back? Or vice versa? Could you do that with just one variable or function? Though you can set constraints, technically* you can't set one variable and change the direction. So I was thinking of using ExpandoMetaClass to add a direction property to the class. Is it unneeded? Kinda. Is it gratuitous complexity just to use a new feature? Probably.

Qu'en pensez-vous? [What do you think?]



*StackLayout defaults to Back to Front if you don't specify a constraint.

SwingXBuilder update my ears must have been burning

I guess my ears must’ve been burning and I didn’t notice it. Wednesday night, I decided to update the SwingX jars I was using because the ones I had were from a build in late April. So I do it and I get another idea. Why not merge the SwingXBuilder with main line since I now am getting a feel for how things should work? The manner I coded in, that is, to start anew and slowly mixing in proven and unproven code was just to get a better feel for how builders work but The plan had always been to subclass or merge. Besides some irreplaceable masterpiece, isn’t
it always better the second time around?

So on Thursday, I subclassed SwingBuilder and overrided the methods that have SwingX specific stuff. I would have been done quicker if I had realized that if a Groovy class is to override a Java class, the Groovy class must be typed. So now, my class is more concise and I don’t have to re-implement the new cool stuff in BETA such as the container widget. The unit tests combined the ones in mainline and mine; it all passes. So now that it is backward compatible with SVN HEAD, go ahead and use it. The one checked in Subversion was built with 1.1-Beta-2 on Java6, so if you aren’t running this, make sure you have Gant.

If there is sufficient demand, I could be convinced to back-port to v1.0.

Feel free to email me with any issues or problems: james.l.williams@gmail.com

Note: The widget registry in the SwingBuilder uses a HashMap. As such, the SwingX components override the classic Swing versions. This shouldn’t be a problem since the ones that exist in both are inherited. I don’t see a reason someone would explicitly use the classic Swing version of a widget over the SwingX version, given the chance.I should be updating the wiki sometime in the next week to let y’all know what is stable and what isn’t.

Oh yeah, supposedly if your ears are burning someone is talking about you[according to the old expression]. I checked Google Analytics and noticed Andres Almiray linked to me. That’s all for now.

Ayez un bon week-end!

It has been a good week

Lots has happened in the last week:

- My demo of the SwingXBuilder got me a crapload of hits .

- I’ve been dugg...no it wasn’t me or anyone I know...honest...

- I finally received the special start of coding gift from Leslie Hawthorne et al... I would love to tell y’all what it is but we have been sworn to secrecy until June 4th. I can tell you that it is signed copy of a totally appropriate book.

- I decided that I’m going to BarCamp Chicago and very likely presenting my work on the Groovy SwingXBuilder. It’ll motivate me to really work since I’ve been a little lazy the past couple of weeks. I haven’t been to Chicago in years and the last time I was, I was earning a slave’s wage babysitting and teaching little geeks 14 hours a day[I taught at Computer camp]. So why would anyone travel over a thousand miles from Florida to Illinois for an un-conference? Simple, BarCamp Jacksonville[FL] and Orlando are still in the planning phases, Miami already took place, and Chicago is much cooler than Albany. It’ll also be good practice and open my eyes to different perspectives that I may have not thought of.

Got any ideas for demos?

Edit: The suprise gift was Producing Open Source Software by Karl Vogel.

Groovy SwingXBuilder Demo

This is an reasonable approximation of the Painter Demo implemented using my Summer of Code project, the Groovy SwingXBuilder. It’s not a pixel perfect port since I used a different LayoutManager, namely MigLayout. The amount of options makes it a little overwhelming at first but I found it easy to tweak components.

Note: This is a WIP and thus not feature complete. Not ready for prime time yet.

Painter Demo Photo
This is not the full Painter demo. The glowing shield and wooden area are images. The following code shows how the compound painter was constructed for the header panel:

 def compoundPaint = swing.compoundPainter() {
    mattePainter(fillPaint:new Color(51,51,51))
    pinstripePainter(paint:new Color(1.0f,1.0f,1.0f,0.17f),spacing:5.0f)
    glossPainter(paint:new Color(1.0f,1.0f,1.0f,0.2f),position:GlossPainter.GlossPosition.TOP)
}

 

Using the builder cut down the lines of code from 441 lines in the Java version to 127 in the Groovy version. Most of that reduction comes from combined declaration and layout.

Download the Netbeans project here.