use of io.jmix.dashboards.entity.WidgetTemplate in project jmix by jmix-framework.
the class WidgetTemplateEdit method openWidgetEditor.
protected void openWidgetEditor(Widget widget) {
if (openWidgetEditor) {
screenBuilders.editor(Widget.class, this).withOpenMode(OpenMode.THIS_TAB).editEntity(widget).withParentDataContext(dataContext).build().show().addAfterCloseListener(e -> {
StandardCloseAction closeAction = (StandardCloseAction) e.getCloseAction();
if (COMMIT_ACTION_ID.equals(closeAction.getActionId())) {
WidgetTemplate widgetTemplate = widgetTemplateDc.getItem();
widgetTemplate.setWidgetModel(converter.widgetToJson(widget));
} else {
Widget prevWidget = converter.widgetFromJson(widgetTemplateDc.getItem().getWidgetModel());
openWidgetEditor = false;
setWidgetTypeComboBoxValue(prevWidget, widgetTypeComboBox);
openWidgetEditor = true;
}
});
}
}
use of io.jmix.dashboards.entity.WidgetTemplate in project jmix by jmix-framework.
the class PaletteFragment method updateWidgetTemplates.
protected void updateWidgetTemplates() {
ddWidgetTemplateBox.removeAll();
Collection<WidgetTemplate> templates = widgetTemplatesDc.getItems().stream().sorted(Comparator.comparing(WidgetTemplate::getName)).collect(Collectors.toList());
for (WidgetTemplate wt : templates) {
try {
PaletteButton widgetBtn = factory.createWidgetTemplateButton(wt);
ddWidgetTemplateBox.add(widgetBtn);
} catch (Exception e) {
log.error(String.format("Unable to create widget template %s <%s>. Cause: %s", wt.getName(), wt.getId(), e.getMessage()), e);
}
}
}
use of io.jmix.dashboards.entity.WidgetTemplate in project jmix by jmix-framework.
the class PaletteFragment method onCreateWidgetTemplate.
@EventListener
public void onCreateWidgetTemplate(CreateWidgetTemplateEvent event) {
Widget widget = event.getSource();
WidgetTemplate widgetTemplate = metadata.create(WidgetTemplate.class);
widgetTemplate.setWidgetModel(converter.widgetToJson(widget));
screenBuilders.editor(WidgetTemplate.class, this).newEntity(widgetTemplate).withContainer(widgetTemplatesDc).withOpenMode(OpenMode.DIALOG).build().show();
}
use of io.jmix.dashboards.entity.WidgetTemplate in project jmix by jmix-framework.
the class WidgetTemplateEdit method createEditWidgetButton.
private Button createEditWidgetButton() {
Button editWidgetButton = components.create(Button.class);
editWidgetButton.setWidth("100%");
editWidgetButton.setCaption(messages.getMessage(WidgetTemplateEdit.class, "customize"));
editWidgetButton.setIconFromSet(JmixIcon.GEAR);
editWidgetButton.setAction(new BaseAction("openWidgetEditor") {
@Override
public void actionPerform(Component component) {
WidgetTemplate widgetTemplate = widgetTemplateDc.getItem();
if (StringUtils.isNotEmpty(widgetTemplate.getWidgetModel())) {
Widget widget = converter.widgetFromJson(widgetTemplateDc.getItem().getWidgetModel());
widget = dataContext.merge(widget);
openWidgetEditor(widget);
}
}
});
return editWidgetButton;
}
Aggregations