tools.dynamia.zk.ui.ZKUIToolsProvider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tools.dynamia.zk Show documentation
Show all versions of tools.dynamia.zk Show documentation
Classes for ZK web application
The newest version!
package tools.dynamia.zk.ui;
import tools.dynamia.integration.sterotypes.Component;
import tools.dynamia.ui.*;
import tools.dynamia.web.util.HttpUtils;
import tools.dynamia.zk.util.ZKUtil;
import java.util.List;
/**
* ZK Implementation of {@link UIToolsProvider}
* This class is used to provide UI tools for the ZK UI framework.
* It is annotated with @Component to make it a Spring-managed bean.
*/
@Component
public class ZKUIToolsProvider implements UIToolsProvider {
@Override
public boolean isInEventThread() {
return ZKUtil.isInEventListener();
}
@Override
public DialogComponent createDialog(String title) {
ZKDialog dialog = new ZKDialog();
dialog.setTitle(title);
dialog.setClosable(true);
dialog.setBorder("normal");
dialog.setPage(ZKUtil.getFirstPage());
return dialog;
}
@Override
public DialogComponent showDialog(String title, Object content, Object data, String width, String height, EventCallback onClose) {
var dialog = createDialog(title);
dialog.setContent(content);
dialog.setData(data);
dialog.onClose(onClose);
dialog.show();
if (HttpUtils.isSmartphone()) {
dialog.setWidth("99%");
dialog.setHeight("99%");
dialog.setDraggable(false);
}
return dialog;
}
@Override
public ListboxComponent createListbox(List data) {
ZKListbox listbox = new ZKListbox<>();
listbox.setData(data);
return listbox;
}
@Override
public ComboboxComponent createCombobox(List data) {
ZKCombobox combobox = new ZKCombobox<>();
combobox.setData(data);
return combobox;
}
@Override
public ButtonComponent createButton(String label, EventCallback onClick) {
ZKButton button = new ZKButton();
button.setLabel(label);
if (onClick != null) {
button.onClick(onClick);
}
return button;
}
}