urChat v0.5.1 release - Bug fixes, managing profiles, and custom nick formatting
urChat v0.5.1 release - Bug fixes, managing profiles, and custom nick formatting
urChat is a Java based IRC Client designed around simplicity and minimal resource impact on your system. - GitHub - matty-r/urChat: urChat is a Java based IRC Client designed around simplicity and...
Version 0.5.1 of my IRC Client has been released. This time around it was mostly focussed around bug fixes largely to do with updating the styles. But I also added a couple of features. This was a shorter release from 0.4.0 as the changes weren't as significant.
Profile Handling
I wanted a way to easily manage profiles, especially during development. With this release i've added a Profiles page, which allows you to Create new profiles, clone an existing profile, rename, and delete profiles. You can also set a profile as the default to be used when loading the app.
A majority of the effort went into keeping the Profile Picker (the combobox that changes the active profile) and the profiles page in sync which was done using listeners. New listeners were created for DELETE,CREATE, and CHANGE events as other components needed to add their own listeners to the queue to make sure they were also kept in sync, but also to update styles etc when the profile changes.
public static void fireListeners (EventType eventType)
{
if(!listenerLists.containsKey(eventType))
listenerLists.put(eventType, new EventListenerList());
Object[] listeners = listenerLists.get(eventType).getListenerList();
// Reverse order
for (int i = listeners.length - 2; i >= 0; i -= 2)
{
if (listeners[i] == ActionListener.class)
{
if (actionEvent == null)
{
actionEvent = new ActionEvent(listeners, i, null);
}
((ActionListener) listeners[i + 1]).actionPerformed(actionEvent);
}
}
}
All of this profile work was also used to centralise the loading and saving of profile information through the URProfileUtil helper class. This should hopefully help down the track.
Custom Nick Format
This was similarly difficult to when I implemented the custom Date formatting. At least this time around I had an idea of how it might be implemented. However the difference was that I couldn't treat the resultant String as a whole, for example setting the Date format to [HHmm] i'd just return [0652] then insert that into the document, I had to contend with nick styles as well.
In the end I settled with splitting whatever was placed into the Nick format field into three parts (Prefix, nick, Suffix). If you want something just on the right side of the nick, you put nick in the Nick format field, then whatever you want next to that. When placing the nick in the document, I set the attributes according to which part and then use this when updating the styles etc.