Implementing a drag and drop extension function

I’m working through some exercises on component development. In particular, I’m extending the ChartComponent part of the helloworld example. I’d like to implement a drag and drop extension function for the component for example to be able to drag data from a power table and drop it onto the chart. How do I go about putting that together?

I went into the oak forest, waved some mistletoe around, communed with the druidic ancestors, imagined a trip on peyote and came up with the following spells:

Make the component implement the ExtensibleComponent interface and put in the component constructor:

Map extFuncs = new HashMap<String, ExtensionFunction>(); extFuncs.put("myExtFunc", myExtFunc);
In the component body:

    Map<String, ExtensionFunction> extensionFunctions = null;
    private final ExtensionFunction myExtFunc = new ExtensionFunction(false, "");;
    
    @Override
    public Map<String, ExtensionFunction> getExtensionFunctions() {
        return extensionFunctions;
    }

    @Override
    public void setExtensionFunctions(Map<String, ExtensionFunction> map) {
        this.extensionFunctions = map;
    }[/code]
and in the component BeanInfo class:
[code]       List<ExtensionFunctionDescriptor> extfnlist = new ArrayList();
        ExtensionFunctionDescriptor.Builder myBuilder = new ExtensionFunctionDescriptor.Builder("myExtFunc");
        myBuilder.description("A hokey description");
        myBuilder.defaultImpl("");
        myBuilder.returns(void.class);
        extfnlist.add(myBuilder.build());
        
        bean.setValue(ExtensionFunctionDescriptor.EXTENSION_FUNCTIONS, extfnlist);

It puts “myExtFunc” on the list of available extension functions in the designer. Next step of course is to make it ready to do something useful when someone wants something useful done. Might need the three eyed raven for this part, but I’m guessing its mostly plain java swing. Of course for my original question, extending the existing “Chart” or “EasyChart” components did the job. However, I’m looking to extend to arbitrary components that a priori don’t implement the ExtensibleComponent interface.

Lug seems happy with this incantation within the importData method of my TransferHandler:

if ( ExtensionFunction.isDefined(mycomponent, "myExtFunc") ) { LoggerEx.Builder loggerbuilder = new LoggerEx.Builder(); LoggerEx log = loggerbuilder.build("MycomponentLogger"); return ExtensionFunction.invoke(mycomponent, log, "myExtFunc", Boolean.TYPE, false, (Object)nodes); } One face happily executes the provided python script when the extension function is enabled, the other face executes the default action of my importData method.

Now to see if I can determine what the multifaced god wants and needs.