use of io.jmix.ui.presentation.TablePresentations in project jmix by jmix-framework.
the class PresentationEditor method commit.
protected void commit() {
TablePresentations presentations = component.getPresentations();
String stringSettings = getStringSettings();
presentation.setSettings(stringSettings);
presentation.setName(nameField.getValue());
presentation.setAutoSave(autoSaveField.getValue());
presentation.setIsDefault(defaultField.getValue());
UserDetails user = currentUserSubstitution.getEffectiveUser();
boolean userOnly = !allowGlobalPresentations || !BooleanUtils.isTrue(globalField.getValue());
presentation.setUsername(userOnly ? user.getUsername() : null);
if (log.isTraceEnabled()) {
log.trace(String.format("Presentation: %s", stringSettings));
}
if (isNew) {
presentations.add(presentation);
} else {
presentations.modify(presentation);
}
presentations.commit();
addCloseListener(e -> {
if (isNew) {
component.applyPresentation(EntityValues.<UUID>getId(presentation));
}
});
}
use of io.jmix.ui.presentation.TablePresentations in project jmix by jmix-framework.
the class PresentationEditor method validate.
protected boolean validate() {
TablePresentations presentations = component.getPresentations();
// check that name is empty
if (StringUtils.isEmpty(nameField.getValue()) && AppUI.getCurrent() != null) {
AppUI.getCurrent().getNotifications().create(Notifications.NotificationType.HUMANIZED).withCaption(messages.getMessage("PresentationsEditor.error")).withDescription(messages.getMessage("PresentationsEditor.error.nameRequired")).show();
return false;
}
// check that name is unique
final TablePresentation pres = presentations.getPresentationByName(nameField.getValue());
if (pres != null && !pres.equals(presentation) && AppUI.getCurrent() != null) {
AppUI.getCurrent().getNotifications().create(Notifications.NotificationType.HUMANIZED).withCaption(messages.getMessage("PresentationsEditor.error")).withDescription(messages.getMessage("PresentationsEditor.error.nameAlreadyExists")).show();
return false;
}
return true;
}
use of io.jmix.ui.presentation.TablePresentations in project jmix by jmix-framework.
the class DeletePresentationAction method actionPerform.
@Override
public void actionPerform(Component component) {
tableImpl.hidePresentationsPopup();
TablePresentations presentations = table.getPresentations();
TablePresentation current = presentations.getCurrent();
presentations.remove(current);
presentations.commit();
}
use of io.jmix.ui.presentation.TablePresentations in project jmix by jmix-framework.
the class EditPresentationAction method actionPerform.
@Override
public void actionPerform(Component component) {
tableImpl.hidePresentationsPopup();
TablePresentations presentations = table.getPresentations();
TablePresentation current = presentations.getCurrent();
openEditor(current);
}
use of io.jmix.ui.presentation.TablePresentations in project jmix by jmix-framework.
the class WebTable method createTablePresentations.
@Override
protected TablePresentations createTablePresentations() {
Presentations presentations = applicationContext.getBean(Presentations.class, this);
presentationsDelegate = applicationContext.getBean(LegacyPresentationsDelegate.class, this, presentations, getSettingsBinder());
return presentations;
}
Aggregations