use of com.haulmont.cuba.gui.presentations.Presentations in project cuba by cuba-platform.
the class WindowDelegate method saveSettings.
public void saveSettings() {
if (settings != null) {
ComponentsHelper.walkComponents(window, (component, name) -> {
if (component.getId() != null && component instanceof Component.HasSettings) {
log.trace("Saving settings for : {} : {}", name, component);
Element e = WindowDelegate.this.settings.get(name);
boolean modified = ((Component.HasSettings) component).saveSettings(e);
if (component instanceof Component.HasPresentations && ((Component.HasPresentations) component).isUsePresentations()) {
Object def = ((Component.HasPresentations) component).getDefaultPresentationId();
e.addAttribute("presentation", def != null ? def.toString() : "");
Presentations presentations = ((Component.HasPresentations) component).getPresentations();
if (presentations != null) {
presentations.commit();
}
}
WindowDelegate.this.settings.setModified(modified);
}
});
settings.commit();
}
}
use of com.haulmont.cuba.gui.presentations.Presentations in project cuba by cuba-platform.
the class FilterDelegateImpl method saveAsFolder.
protected void saveAsFolder(boolean isAppFolder) {
final AbstractSearchFolder folder;
if (isAppFolder)
folder = (metadata.create(AppFolder.class));
else
folder = (metadata.create(SearchFolder.class));
if (filterEntity.getCode() == null) {
String folderName = filterEntity != adHocFilter ? filterEntity.getName() : "";
folder.setName(folderName);
folder.setTabName(folderName);
} else {
String name = messages.getMainMessage(filterEntity.getCode());
folder.setName(name);
folder.setTabName(name);
}
String newXml = filterParser.getXml(conditions, Param.ValueProperty.VALUE);
folder.setFilterComponentId(filterEntity.getComponentId());
folder.setFilterXml(newXml);
if (!isAppFolder) {
if (uerCanEditGlobalFilter())
((SearchFolder) folder).setUser(filterEntity.getUser());
else
((SearchFolder) folder).setUser(userSessionSource.getUserSession().getCurrentOrSubstitutedUser());
}
Presentations presentations;
if (applyTo != null && applyTo instanceof HasPresentations) {
final HasPresentations presentationsOwner = (HasPresentations) applyTo;
presentations = presentationsOwner.isUsePresentations() ? presentationsOwner.getPresentations() : null;
} else {
presentations = null;
}
Runnable commitHandler;
if (isAppFolder) {
commitHandler = () -> {
AbstractSearchFolder savedFolder = saveFolder(folder);
filterEntity.setFolder(savedFolder);
};
} else {
commitHandler = () -> {
AbstractSearchFolder savedFolder = saveFolder(folder);
filterEntity.setFolder(savedFolder);
};
}
filterHelper.openFolderEditWindow(isAppFolder, folder, presentations, commitHandler);
}
use of com.haulmont.cuba.gui.presentations.Presentations in project cuba by cuba-platform.
the class ScreenSettings method saveSettings.
/**
* Save settings of screen.
*
* @param screen screen
* @param settings settings
*/
public void saveSettings(Screen screen, Settings settings) {
checkNotNullArgument(screen);
checkNotNullArgument(settings);
walkComponents(screen.getWindow(), (component, name) -> {
if (component.getId() != null && component instanceof HasSettings) {
log.trace("Saving settings for {} : {}", name, component);
Element e = settings.get(name);
boolean modified = ((HasSettings) component).saveSettings(e);
if (component instanceof HasPresentations && ((HasPresentations) component).isUsePresentations()) {
Object def = ((HasPresentations) component).getDefaultPresentationId();
e.addAttribute("presentation", def != null ? def.toString() : "");
Presentations presentations = ((HasPresentations) component).getPresentations();
if (presentations != null) {
presentations.commit();
}
}
if (modified) {
settings.setModified(true);
}
}
});
settings.commit();
}
use of com.haulmont.cuba.gui.presentations.Presentations in project cuba by cuba-platform.
the class WebAbstractTable method handleSpecificVariables.
protected boolean handleSpecificVariables(Map<String, Object> variables) {
if (isUsePresentations() && presentations != null) {
Presentations p = getPresentations();
if (p.getCurrent() != null && p.isAutoSave(p.getCurrent()) && needUpdatePresentation(variables)) {
Element e = p.getSettings(p.getCurrent());
saveSettings(e);
p.setSettings(p.getCurrent(), e);
}
}
return false;
}
use of com.haulmont.cuba.gui.presentations.Presentations in project cuba by cuba-platform.
the class TablePresentations method buildPresentationsList.
protected void buildPresentationsList() {
menuBar.removeItems();
presentationsMenuMap = new HashMap<>();
Presentations p = table.getPresentations();
for (Object presId : p.getPresentationIds()) {
MenuBar.MenuItem item = menuBar.addItem(defaultString(p.getCaption(presId)), selectedItem -> table.applyPresentation(presId));
Presentation current = p.getCurrent();
if (current != null && presId.equals(current.getId())) {
setCurrentItemStyle(item);
}
Presentation defaultPresentation = p.getDefault();
if (defaultPresentation != null && presId.equals(defaultPresentation.getId())) {
setDefaultItemStyle(item);
}
presentationsMenuMap.put(presId, item);
}
}
Aggregations