use of io.jmix.dashboards.model.Widget in project jmix by jmix-framework.
the class PersistentDashboardEdit method onOpenWidgetEditor.
@EventListener
public void onOpenWidgetEditor(WidgetEditEvent event) {
Widget widget = event.getSource().getWidget();
screenBuilders.editor(Widget.class, this).editEntity(widget).withOpenMode(OpenMode.DIALOG).build().show().addAfterCloseListener(e -> {
StandardCloseAction closeAction = (StandardCloseAction) e.getCloseAction();
if (Window.COMMIT_ACTION_ID.equals(closeAction.getActionId())) {
WidgetLayout widgetLayout = getDashboardModel().getWidgetLayout(widget.getId());
widgetLayout.setWidget(((WidgetEdit) e.getSource()).getEditedEntity());
uiEventPublisher.publishEvent(new DashboardRefreshEvent(getDashboardModel().getVisualModel(), widget.getId()));
}
});
}
use of io.jmix.dashboards.model.Widget in project jmix by jmix-framework.
the class DashboardImpl method refresh.
/**
* Refreshes widget with passed parameters.
* Dashboard will be refreshed with merged existed and new parameters.
* If existed parameter has the same name as one of the param from passed map, it will be overwritten by param from map.
*
* @param params map with new dashboard parameters
*/
@Override
public void refresh(Map<String, Object> params) {
DashboardModel dashboardModel = null;
if (isNotBlank(jsonPath)) {
dashboardModel = loadDashboardByJson(jsonPath);
} else if (isNotBlank(code)) {
dashboardModel = loadDashboardByCode(code);
}
if (MapUtils.isNotEmpty(params) && Objects.nonNull(dashboardModel)) {
Map<String, Parameter> newParams = params.keySet().stream().map(key -> {
Parameter parameter = metadata.create(Parameter.class);
parameter.setName(key);
parameter.setAlias(key);
parameter.setValue(parameterTransformer.createParameterValue(params.get(key)));
return parameter;
}).collect(Collectors.toMap(Parameter::getName, Function.identity()));
Map<String, Parameter> paramMap = dashboardModel.getParameters().stream().collect(Collectors.toMap(Parameter::getName, Function.identity()));
paramMap.putAll(newParams);
dashboardModel.setParameters(new ArrayList<>(paramMap.values()));
}
updateDashboard(dashboardModel);
}
use of io.jmix.dashboards.model.Widget in project jmix by jmix-framework.
the class PaletteComponentsFactoryImpl method createWidgetTemplateButton.
public PaletteButton createWidgetTemplateButton(WidgetTemplate wt) {
Widget widget = converter.widgetFromJson(wt.getWidgetModel());
widget.setName(widgetUtils.getWidgetType(widget.getFragmentId()));
WidgetTemplateLayout layout = metadata.create(WidgetTemplateLayout.class);
layout.setWidget(widget);
PaletteButton button = createCommonButton();
button.setCaption(String.format("%s (%s)", wt.getName(), widgetRepository.getLocalizedWidgetName(widget)));
button.setLayout(layout);
button.getLayout().setId(null);
return button;
}
use of io.jmix.dashboards.model.Widget in project jmix by jmix-framework.
the class PaletteFragment method initWidgetBox.
protected void initWidgetBox() {
for (Widget widget : getSketchWidgets()) {
PaletteButton widgetBtn = factory.createWidgetButton(widget);
ddWidgetBox.add(widgetBtn);
}
}
use of io.jmix.dashboards.model.Widget in project jmix by jmix-framework.
the class WidgetTemplateEdit method createWidgetTypeComboBox.
private ComboBox<String> createWidgetTypeComboBox() {
ComboBox<String> widgetTypeComboBox = components.create(ComboBox.TYPE_STRING);
widgetTypeComboBox.setWidth("100%");
widgetTypeComboBox.setOptionsMap(widgetUtils.getWidgetCaptions());
widgetTypeComboBox.addValueChangeListener(e -> {
String browserFragmentId = e.getValue();
if (browserFragmentId != null) {
Widget widget = dataContext.create(Widget.class);
widget.setFragmentId(browserFragmentId);
widget.setName(widgetUtils.getWidgetType(e.getValue()));
widget.setCreatedBy(accessHelper.getCurrentUsername());
openWidgetEditor(widget);
}
});
return widgetTypeComboBox;
}
Aggregations