Button handy |
---|
blank | true |
---|
color | #0052CC |
---|
name | Send Feedback |
---|
link | https://docs.google.com/forms/d/e/1FAIpQLScmToBe3vynAlb5fdKwCGxYqnTbDc66sIBgeecG2BuFDuHc7g/viewform?entry.2002826954=Step+3%3A+Creating+a+Custom+Field+Descriptor+-+15486516 |
---|
width | auto |
---|
|
Project Picker CF
Let's say you need to provide support for a certain custom field. Power Scripts™ for Jira does offer support for the project picker CF but for educational purposes, let's see how you could add the support if it didn't.
...
Code Block |
---|
firstline | 1 |
---|
title | BundleActivator.java |
---|
linenumbers | true |
---|
|
@Override
public void doAtLaunch() {
super.doAtLaunch();
//register the routinefunction
RoutineRegistryFunctionRegistry.register(new ReverseStringRoutineReverseStringFunction("myReverseString"));
//register the CF descriptor
customFieldDescriptorRegistry.register("com.atlassian.jira.plugin.system.customfieldtypes:project", //this is the real key of the CF
new AbstractCustomFieldDescriptorFactory(
"example.project.cfdf", //internal identification. Must be unique in the SIL system
"Project Key to String", //short description, followed by a longer one
"Extract the project key using GenericValue or project") {
// Descriptors are created when needed, and some of them might be contextual. This is why you register here a creator of a
// descriptor and not the real descriptor
@Override
public FieldDescriptor createDescriptor(Issue issue, CustomField cf) {
return new ProjectCFDescriptor(projectManager);
}
}
);
}
@Override
public void doAtStop() {
//first, make sure that super is called, even if it has an exception here
try {
//unregister the routinefunction
RoutineRegistryFunctionRegistry.unregister("myReverseString");
//unregister the CF descriptor
customFieldDescriptorRegistry.unregister("com.atlassian.jira.plugin.system.customfieldtypes:project"); //this is the real key of the CF
} catch(Exception e) {
LOG.error("Failed to unregister!", e);
}
super.doAtStop();
} |
...