Creating Custom Collection - AttiliaTheHun/Songbook-Manager GitHub Wiki

Creating Custom Collection

With a bit of skill, effort and coffee, it is possible to create a custom collection. I will say it directly: it must be done programatically, you have to edit the source code. Nevertheless, the platform was made with this sort of scalability in mind, which means it should be just a regular pain, nothing that would make you wish to end your life prematurely.

Modifying the client

Creating the collection manager

On the client part things are going to be rather simple, as long as your are a little Java-savvy. What you need to do is to create a custom subclass of attilathehun.songbook.collection.CollectionManager, ideally in the same package (the attilathehun/songbook/collection directory). Then you need to @Override and implement all the methods so that your manager behaves the right way. You may want to take insipiration from StandardCollectionManager rather than from EasterCollectionManager, because the latter is somewhat special. Do not forget to change the data file paths.

Making the collection usable

There is the thing that you cannot access easter collection by default and you have to acquire the toggle switch so the program actually works with that collection. The same will be necessary for your new collection. By default, the program uses the standard collection and you need to tell him to use your collection instead. That is done by calling Environment#setCollectionManager(CollectionManager) somewhere in the program code, but you may want to implement some sort of switching mechanism as is done with the easter collection. You may also want to register the collection by calling Environment#registerCollectionManager(CollectionManager) for more complete integration.

Making the collection editable

Now if everything went well, you have created the collection and made it so the program actually respects it. However your collection still is not accessible through the very powerfull tool of the CollectionEditor. To fix this issue, you have to modify CollectionEditor#initTabbedPane() and create a tab for your collection there. That should do the trick.

More integration

The very basic part should be done: you have a collection, you can add songs to it, you can edit it, you can export it. There may be some places that require additional changes to the program, if you wish your collection to have better integration. For one you may need to make some changes to the VCS (the attilathehun.songbook.vcs package), which requires a solid knowledge of the VCS both client- and server-side and may prove quite complex to accomplish.

Modifying the server

If you want your collection to be compatible with the server part of the program, I am not going to help you. Integrating another collection to the server would require severe changes to the source code, at which point you should know what you are doing (and not need my help) or you should leave it be. If you follow the client part of this guide, the server should be able to back your collection up tho.