Thursday, September 12, 2013

Intellij Idea task repository plugin creation

Key notes
1) Reuse existing infrastructure
@Tag("Rally") // This is name of part in xml configuration file where your settings will be stored
public class RallyRepository extends BaseRepositoryImpl {

public class RallyRepositoryType extends BaseRepositoryType<RallyRepository> {
// UI things are located here (repository name, icon and stuff)

public class RallyTask extends Task {
// It's all about tasks. But nothing special here. Just implement all methods carefully

META-INF/plugin.xml
// In this file you may find some plugin configuration. But there is also nothing special

Making all the stuff works
All configuration goes through repository deitor which is responsible for reading changing and storing configuration. So extend existing one:

public class RallyRepositoryEditor extends BaseRepositoryEditor<RallyRepository> {

What is necesary to understand before implementation is that editor is tightly coupled with repository itself. Main items:
1) Editor check if something changed via equals method of repository (In our case RallyRepository)
2) Editor uses copying constructor of repository to create new changed instance of it
3) Editor serializes and deserializes repository according to bean conventions by default, so don't forget about appropriate getters and setters
4) Also don't use getXXX and setXXX methods for fields you don't whant to serialize. (There is @Transient annotation and you can use it)
5) Don't invoke logger in constructior of repository

You may refer my own plugin at github for additional implementation details (https://github.com/crc83/rallydev). I changed a lot from one that I forked (https://github.com/RallySoftware/intellij-plugin).

Download ready to use jar you can from here (http://dl.bintray.com/crc83/generic/rallydev.zip).

No comments:

Post a Comment