We have created our own modules with custom components and containers, but we can not find how to add binding and scripting (Jython code on mouseClicked event for example) to them.
We have to draw hundreds of components with very specific locations and orientations, and that’s the reason why we had to create our own modules to automate this part, but we also need these components to have bound properties to tags and custom scripts to be executed on interaction events, without having to configure them all manually.
Could you help us to figure this out? or to point us to right documentation and examples?
You don’t add binding to your component, but simply support binding to your properties by marking them as such in your component’s beaninfo. Bindings themselves are not part of a component–they are stored in a window’s InteractionController.
Event script support is automatically available to all components. Extension functions can be supported by setting them up in the beaninfo. This post from last year shows all of this:
Note that all of these features are intended to allow your users to attach functionality to your components at design-time. If you want functionality to be built-in, you should be attaching your own event listeners (in java) to your components at component creation time. You should not be populating design-time data structures.
Some implementation notes for built-in functionality:
The designer’s mouse events, key events, and propertyChange listeners simply implement the corresponding java listeners. Your components would implement built-in functionality directly in java, and add them to the component either at creation or in the startup method.
Property bindings you wish to implement would simply be listeners of the appropriate types for all of the relevant source data. If the source data is on a different component, add a listener defined in the destination component to listen to the source component. (In the startup method, to ensure source components have been created.)
Tag bindings are subscriptions–TagChangeListeners. You’d add them in the startup method of the destination component.
SQL Bindings and Tag History Bindings are runnable background tasks that your destination component would kick off when the desired conditions are met (other listeners’ data arrival, perhaps). The final step in such background tasks is to place a runnable on the foreground thread to make the final assignment to the target property.
Be sure to remove all created listeners in the shutdown method.