Here some exmaples of what i did:
create a json file simalar to like for the props:
{
"extensionFunctions": [
{
"name": "onRowStartEdit",
"description": "Fired when rows in the table are being triggered to edited, if not enabled the default grids update popup will show up which will trigger an event onRowUpdated \nIf you return True the default popup will also show (example to first filter on user role)",
"default": "\tsystem.perspective.sendMessage(messageType \u003d\"handleButtonEdit\", payload\u003d{\"data\":[x.data for x in rows]})\n\treturn False",
"arguments":[{
"name": "rows",
"description": "Array of data of the selected rows each row has id (index of the selected row) and data (rows[0].data)"
},
{
"name": "columns",
"description": "The columns in order which are editable"
}]
}
]
}
then add it to the schema (this is probably not the most effective way of adding it but it realy doesnt matter and it works xd
public static final JsonObject EXTENSIONS_OBJECT = (new JsonParser()).parse(new InputStreamReader(GridComponents.class.getResourceAsStream("/grid.extensions.json"), StandardCharsets.UTF_8)).getAsJsonObject();
public static final List EXTENSIONS;
static {
EXTENSIONS = new ArrayList();
JsonArray jsonExt = EXTENSIONS_OBJECT.get("extensionFunctions").getAsJsonArray();
jsonExt.forEach(eventElem -> {
JsonObject eventDef = eventElem.getAsJsonObject();
List<ExtensionFunctionDescriptor.ExtensionFunctionArgument> Arguments = new ArrayList<ExtensionFunctionDescriptor.ExtensionFunctionArgument>();
JsonArray args = eventDef.get("arguments").getAsJsonArray();
args.forEach(argsElem -> {
JsonObject argDef = argsElem.getAsJsonObject();
Arguments.add(new ExtensionFunctionDescriptor.ExtensionFunctionArgument(argDef.get("name").getAsString(), argDef.get("description").getAsString()));
});
EXTENSIONS.add(new ExtensionFunctionDescriptor(eventDef.get("name").getAsString(), eventDef.get("description").getAsString(), eventDef.get("default").getAsString(), Arguments ));
});
}
public static ComponentDescriptor DESCRIPTOR = ComponentDescriptorImpl.ComponentBuilder.newBuilder()
.setPaletteCategory(GridComponents.COMPONENT_CATEGORY)
.setId(COMPONENT_ID)
.setModuleId(GridComponents.MODULE_ID)
.setSchema(SCHEMA)
.setName("Grid")
.addPaletteEntry("", "Grid", "An Grid component.", null, null)
.setDefaultMetaName("grid")
.setEvents(EVENTS)
.setExtensionFunctions(EXTENSIONS)
.setResources(GridComponents.BROWSER_RESOURCES)
.build();
Than add it to the descriptor
.setExtensionFunctions(EXTENSIONS)