Real World Flex/ColdFusion: Part 7
I think I should rename this series half way through because we might end up with part 9999! In this part we are going to get a few features out of the way. I want to take a look at the status bar along with updating the data grid based on the selected folder as well as cleaning up our grid.
The first thing we need to do is fix our status bar. We never want the user to know the exact location of where they are (absolute path) but we do from there on out. What we are going to do is replace whatever the root directory with a root label and from there on out we can display what directory they are in. The first thing we are going to do is to setup a root label. This is the text that will display on the folder as well as the text that will replace the absolute path of our base directory. In the init method we are going to call our setStatusText method to initialize the text. The next step is to head over to Google Code and grab the corelib. In that library you will find a great class called StringUtil which has a static function named replace. For those of you not familiar with a static method its a method that can be called without instantiating the class first. We are simply replacing baseDir in the location with our root label text.
Next we want a way to update the data grid when a folder is selected. This turns out is pretty easy to do. First we want to update our remote object. We want to add a new method called getFiles. As you might expect we need to update our FileManager component and add the method that will perform the magic. The get files method is pretty close to our get directories only were getting files. Again I am tapping into Java because it makes it easier when you only need to grab a directory or file listing of a path. We are setting a bunch of properties of the file so that we can present this information to the user.
Finally we will create a new variable files and set it as the data grids data provider. In the init method we will add a call to get files for our base directory. Finally to react to a user clicking on a folder we will add a change event handler to our tree that calls the onItemChange event.
While this looks we have accomplished our goals there is still one thing to do. You will notice that the grid is displaying everything about our file in no real order. This is because if you don't set your columns of the data grid Flex will display everything with no formatting for you. 
Updating our grid is a pretty easy task. We can define all of our columns as well as provide label functions. A label function is a way to take the data from a column, format it and display the formatted text for the user. In our case it would be a good idea to display a more meaningful file size to the user.
As you can our little changes made a big difference for the user. I think we are really starting to see some progress with this application. I think I might start changing the titles though. Something like RocketFM adding a context menu to our tree. I just hate to keep naming thme part something because its getting old.
