J-Unleashed!

On databases, programming and more

Archive for July, 2008

First ever Mac OS install

Posted by Joe on July 16, 2008

I work for an email service provider, and our development platform is Java and Flex. Our development machines are Macs. I have a really nice 2.8Ghz 24″ iMac with 4GB of memory. The company just bought us all OS X Leopard, so I decided to do the install this morning. A couple of my co-workers have already done the install, with mixed results. One seemed to have performance issues after upgrading. Another one did a complete wipe of his machine with a brand new install, as opposed to upgrading. His worked nicely. My boss upgraded his notebook, and gained some performance boosts. So, with all these mixed results, I was a little hesitant to upgrade mine. But, I took the plunge.

I’m happy to say that, so far, things look good. The install took a little over an hour. It would have been less if I realized I could skip the DVD consistency check prior to the install. But, for some dumb reason, I didn’t see the “Skip” button on that window. The upgrade was smooth, and when the system came back up, everything looks pretty much as it should.

I’m literally just 15 minutes into using Leopard, so I have nothing really to report, good or bad, except that my experience with the upgrade process was flawless. One minor thing to note is that the installer will install all the printer drivers. This takes up a whopping 1.6GB of hard drive space. If you’re low on space, you can limit the install significantly. I think it was the EPSON drivers that took up the most (769MB). I installed all of them ’cause I have plenty of space to spare. You might choose differently.

Posted in Mac | Tagged: , , | 1 Comment »

Deselecting radio buttons in Flex

Posted by Joe on July 11, 2008

This is a simple tip to deselect radio buttons in flex. The trick here is to have radio buttons as part of a RadioButtonGroup. Then, you simply need to set your RadioButtonGroup.selection to null.

Posted in Flex | Tagged: , | 2 Comments »

Flex DataGridColumn width management

Posted by Joe on July 10, 2008

I’ve been tasked at work with creating a dashboard in Flex that enables users to turn on and off Key Performance Indicators (KPIs). The main display is a DataGrid. The concept is simple enough. As the user checks which KPIs they want to see, the DataGrid will set the visible property of the specific column to true, and false if that KPI is unchecked. A problem appears with column widths, however. Flex likes to decide for you how wide each column should be given the area it has to work with. Sometimes, the decision is really bad, especially if the user has already resized columns, then adds a new column.

This dashboard also needs to be able to save the user’s KPI choices and column orders, then be able to redisplay data each time they log in and use the dashboard, all with their column order and pre-selected KPIs displaying nicely with the column widths they set previously.

Easy, right?

Well, not so much. After many hours of trying to get it working the way I want, I took another hard look at the Flex documentation. I found the key was in the horizontalScrollPolicy setting. You see, I really wanted to have a horizontal scroll bar only if necessary. I tried setting horizontalScrollPolicy to “auto”, but that just wasn’t reliable. In fact, the horizontal scroll bar was always on. So, I started managing the horizontal scroll bar myself by checking the widths of all the visible columns in the DataGrid. If the widths were less than my DataGrid size, I would set the horizontalScrollPolicy to “off”, otherwise, it would be “on”.

A funny thing happens when the horizontalScrollPolicy is “off”. It makes sense . . . sort of. Column widths are largely ignored if the horizontalScrollPolicy is “off”. The reason for this is because the DataGrid needs to readjust all the columns to fit within the DataGrid width. It doesn’t matter if you set the widths if the invisible columns to 0, either. These get assigned a width (though that seems like a bug to me). So, say you have 25 columns, but only want to display 6, and have them laid out nicely with pre-determined widths. How do you do this without having the DataGrid control mangle it up?

The answer is actually quite simple. Before setting any column widths, set the horizontalScrollPolicy to “on”. Then, set your widths. Set the widths of all the invisible columns to 0, and your visible columns to your desired widths. Then, set the horizontalScrollPolicy to your desired setting (“off”, if you don’t want a scroll bar).

Posted in Flex | Tagged: , , , , | 8 Comments »