use of php.runtime.invoke.Invoker in project jphp by jphp-compiler.
the class WrapSwingUtilities method setExceptionHandler.
@Signature(@Arg(value = "callback", type = HintType.CALLABLE, optional = @Optional("NULL")))
public static Memory setExceptionHandler(Environment env, Memory... args) {
if (args[0].isNull()) {
env.setUserValue(SwingExtension.NAMESPACE + "#exceptionHandler", null);
} else {
final Invoker invoker = Invoker.valueOf(env, null, args[0]);
env.setUserValue(SwingExtension.NAMESPACE + "#exceptionHandler", invoker);
}
return Memory.TRUE;
}
use of php.runtime.invoke.Invoker in project jphp by jphp-compiler.
the class UICombobox method onCellRender.
@Signature(@Arg(value = "handler", optional = @Optional("null")))
public Memory onCellRender(final Environment env, Memory... args) {
if (args[0].isNull())
component.setRenderer(defaultRenderer);
else {
final Invoker invoker = Invoker.valueOf(env, null, args[0]);
final ObjectMemory self = new ObjectMemory(this);
component.setRenderer(new ListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
JLabel template = (JLabel) defaultRenderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
Memory _value = MemoryUtils.valueOf(value);
Memory _index = LongMemory.valueOf(index);
Memory _isSelected = TrueMemory.valueOf(isSelected);
Memory _cellHasFocus = TrueMemory.valueOf(cellHasFocus);
Memory r = invoker.callNoThrow(self, new ObjectMemory(new UILabel(env, template)), _value, _index, _isSelected, _cellHasFocus);
if (r.isObject() && r.instanceOf(UIElement.class)) {
return r.toObject(UIElement.class).getComponent();
}
return template;
}
});
}
return Memory.NULL;
}
use of php.runtime.invoke.Invoker in project jphp by jphp-compiler.
the class UIFileChooser method addChoosableFilter.
@Signature({ @Arg(value = "filter", type = HintType.CALLABLE), @Arg(value = "description") })
public Memory addChoosableFilter(final Environment env, Memory... args) {
final Invoker invoker = Invoker.valueOf(env, null, args[0]);
final String description = args[1].toString();
component.addChoosableFileFilter(new FileFilter() {
@Override
public boolean accept(File f) {
return invoker.callNoThrow(new ObjectMemory(new FileObject(env, f))).toBoolean();
}
@Override
public String getDescription() {
return description;
}
});
return Memory.NULL;
}
use of php.runtime.invoke.Invoker in project jphp by jphp-compiler.
the class UIListbox method onCellRender.
@Signature(@Arg(value = "handler", optional = @Optional("null")))
public Memory onCellRender(final Environment env, Memory... args) {
if (args[0].isNull())
component.getContent().setCellRenderer(defaultRenderer);
else {
final Invoker invoker = Invoker.valueOf(env, null, args[0]);
final ObjectMemory self = new ObjectMemory(this);
component.getContent().setCellRenderer(new ListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
JLabel template = (JLabel) defaultRenderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
Memory _value = MemoryUtils.valueOf(value);
Memory _index = LongMemory.valueOf(index);
Memory _isSelected = TrueMemory.valueOf(isSelected);
Memory _cellHasFocus = TrueMemory.valueOf(cellHasFocus);
Memory r = invoker.callNoThrow(self, new ObjectMemory(new UILabel(env, template)), _value, _index, _isSelected, _cellHasFocus);
if (r.isObject() && r.instanceOf(UIElement.class)) {
return r.toObject(UIElement.class).getComponent();
}
return template;
}
});
}
return Memory.NULL;
}
use of php.runtime.invoke.Invoker in project jphp by jphp-compiler.
the class UIElement method setAction.
@Signature({ @Arg("name"), @Arg(value = "callback", type = HintType.CALLABLE, optional = @Optional("null")) })
public Memory setAction(Environment env, Memory... args) {
if (args[1].isNull()) {
getJComponent().getActionMap().remove(args[0].toString());
return Memory.NULL;
}
final Invoker invoker = Invoker.valueOf(env, null, args[1]);
getJComponent().getActionMap().put(args[0].toString(), new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
invoker.callNoThrow();
}
});
return Memory.NULL;
}
Aggregations