Search in sources :

Example 1 with EventProvider

use of org.develnext.jphp.swing.event.EventProvider in project jphp by jphp-compiler.

the class ComponentProperties method updateEvents.

public void updateEvents(final Environment env) {
    if (!initEvents) {
        Component component = getComponent();
        Class<?> cls = component.getClass();
        do {
            EventProvider provider = SwingExtension.getEventProvider((Class<? extends Component>) cls);
            if (provider != null) {
                provider.register(env, component, this);
            }
            if (cls == Component.class)
                break;
            cls = cls.getSuperclass();
        } while (true);
        initEvents = true;
    }
}
Also used : EventProvider(org.develnext.jphp.swing.event.EventProvider)

Example 2 with EventProvider

use of org.develnext.jphp.swing.event.EventProvider in project jphp by jphp-compiler.

the class UIElement method on.

@Signature({ @Arg("name"), @Arg("callback"), @Arg(value = "group", optional = @Optional("general")) })
public Memory on(Environment env, Memory... args) {
    Invoker invoker = Invoker.valueOf(env, null, args[1]);
    if (invoker == null) {
        env.exception(env.trace(), "Argument 2 must be callable");
        return Memory.NULL;
    }
    String name = args[0].toString().toLowerCase();
    EventProvider eventProvider = SwingExtension.isAllowedEventType(getComponent(), name);
    invoker.setTrace(env.trace());
    if (eventProvider == null) {
        if (allowedEvents == null || !allowedEvents.contains(name))
            throw new IllegalArgumentException("Unknown event type - " + args[0]);
    //env.exception(env.trace(), "Unknown event type - " + args[0]);
    }
    onBindEvent(env, name, invoker);
    ComponentProperties properties = SwingExtension.getProperties(getComponent(), true);
    properties.updateEvents(env);
    getEventContainer().addEvent(name, args[2].toString(), invoker);
    return Memory.NULL;
}
Also used : ComponentProperties(org.develnext.jphp.swing.ComponentProperties) Invoker(php.runtime.invoke.Invoker) EventProvider(org.develnext.jphp.swing.event.EventProvider)

Aggregations

EventProvider (org.develnext.jphp.swing.event.EventProvider)2 ComponentProperties (org.develnext.jphp.swing.ComponentProperties)1 Invoker (php.runtime.invoke.Invoker)1