I’ve been sick with the Flu for the past week or so, so I haven’t really done any coding. I should be getting back to it real soon though.
First I made a new interface called Nameable:
Then I made all my data classes with names implement the Nameable interface. They all already had the methods setName() and getName(), so the majority of the work was done already:
public String getName() {
return this.sName;
}
Then in my application class I created a new general rename method:
That was the code that was duplicated several times with minor differences. Now I was able to replace those with the following short methods:
public void renameEffect() {
renameItem(”Effect”, selectedEffect);
effectTableViewer.refresh();
}
public void renameEffect() {
renameItem(”Effect”, selectedEffect);
effectTableViewer.refresh();
}
public void renamePalette() {
renameItem(”Palette”, selectedPalette);
paletteListViewer.refresh();
}
public void renamePlaylist() {
renameItem(”Playlist”, selectedPlaylist);
playlistListViewer.refresh();
}
public void renameSong() {
renameItem(”Song”, selectedSong);
songTableViewer.refresh();
}
Some additional things I might consider doing:
- Make renameItem return a boolean that determines wether the rename actually happened or was cancelled. If false is returned, I shouldn’t bother refreshing he Viewer for that item.
- Maybe nameable calsses should have a static string called sItemType and a method called getItemType(). Then I wouldn’t have to pass in the type of item in is as a string every time.
- I’m pretty sure refresh() is the least optimal way to inform a Viewer that it’s data has changed. I should look into improving that at some point.
- selectedEffect et al. are all application variables that are changed when each Viewer’s selected is changed. I wonder if that’s not the best way to keep track of them.
Basic support for Sound Effects is in.
Right now they work pretty much like Playlists for audio, except they don’t require any mode/looping controls. In the final app I’d like the user to be able to have a few up at once, but right now it’s just one Effects list at a time.
I did some more code clean up tonight. The main app now has a lot of methods and they were scattered all over the place, making it a pain to find them (hrm, I should probably be using the Filtering options in Eclipse), but now those are cleaned up a bit.
Here’s one thing I do over and over again that I should probably devise some more centralized way of doing:
Most of the data items in the program are named. So perhaps I should create a Named interface, then all these items can call on Rename function instead of having to use 8 copies of the same block of code.
Just haven’t update in a bit.
I’m still plugging away at the program. I’ve been looking at Environments and Effects and how they should be implemented both data and GUI-wise.
For now they’re all set in the same main window, but resizable a bit. They’ll eventually each have their own windows, but I’m not ready to tack RCP on top of what I’m already doing just yet.
We used the test app a little the other day at my friend’s Forgotten Realms session. I had a bunch of scenes set up ahead of time, so that made things easy for him. There are a few features I definitely need to add, but overall I think it worked pretty well. We even opened up a second instance and threw some sound effects in a few different “scenes” just for kicks.
