use of com.haulmont.cuba.client.ClientConfig in project cuba by cuba-platform.
the class Screen method isSaveSettingsOnClose.
/**
* @param action close action
* @return true if UI settings should be saved
*/
protected boolean isSaveSettingsOnClose(@SuppressWarnings("unused") CloseAction action) {
Configuration configuration = beanLocator.get(Configuration.NAME);
ClientConfig clientConfig = configuration.getConfig(ClientConfig.class);
return !clientConfig.getManualScreenSettingsSaving();
}
use of com.haulmont.cuba.client.ClientConfig in project cuba by cuba-platform.
the class WebAbstractTable method applySettingsInternal.
protected void applySettingsInternal(Element element, boolean presentationSettings) {
if (!isSettingsEnabled()) {
return;
}
if (defaultSettings == null) {
// save default view before apply custom
defaultSettings = DocumentHelper.createDocument();
defaultSettings.setRootElement(defaultSettings.addElement("presentation"));
saveSettings(defaultSettings.getRootElement());
}
String textSelection = element.attributeValue("textSelection");
if (StringUtils.isNotEmpty(textSelection)) {
component.setTextSelectionEnabled(Boolean.parseBoolean(textSelection));
if (component.getPresentations() != null) {
((TablePresentations) component.getPresentations()).updateTextSelection();
}
}
Element columnsElem = getColumnsElement(element);
boolean refreshWasEnabled = component.disableContentBufferRefreshing();
Collection<String> modelIds = new ArrayList<>();
for (Object column : component.getVisibleColumns()) {
modelIds.add(String.valueOf(column));
}
Collection<String> loadedIds = new ArrayList<>();
for (Element colElem : columnsElem.elements("columns")) {
loadedIds.add(colElem.attributeValue("id"));
}
ClientConfig clientConfig = configuration.getConfig(ClientConfig.class);
if (clientConfig.getLoadObsoleteSettingsForTable() || CollectionUtils.isEqualCollection(modelIds, loadedIds)) {
applyColumnSettings(element, presentationSettings);
}
component.enableContentBufferRefreshing(refreshWasEnabled);
}
use of com.haulmont.cuba.client.ClientConfig in project cuba by cuba-platform.
the class NoUserSessionHandler method showNoUserSessionDialog.
protected void showNoUserSessionDialog(AppUI ui) {
Messages messages = beanLocator.get(Messages.class);
Connection connection = ui.getApp().getConnection();
// noinspection ConstantConditions
Locale locale = connection.getSession().getLocale();
Window dialog = new NoUserSessionExceptionDialog();
dialog.setStyleName("c-nousersession-dialog");
dialog.setCaption(messages.getMainMessage("dialogs.Information", locale));
dialog.setClosable(false);
dialog.setResizable(false);
dialog.setModal(true);
CubaLabel messageLab = new CubaLabel();
messageLab.setWidthUndefined();
messageLab.setValue(messages.getMainMessage("noUserSession.message", locale));
VerticalLayout layout = new VerticalLayout();
layout.setSpacing(true);
layout.setMargin(false);
layout.setWidthUndefined();
layout.setStyleName("c-nousersession-dialog-layout");
layout.setSpacing(true);
dialog.setContent(layout);
CubaButton reloginBtn = new CubaButton();
reloginBtn.addStyleName(WebButton.PRIMARY_ACTION_STYLENAME);
reloginBtn.addClickListener(event -> relogin());
reloginBtn.setCaption(messages.getMainMessage(Type.OK.getMsgKey()));
String iconName = beanLocator.get(Icons.class).get(Type.OK.getIconKey());
reloginBtn.setIcon(beanLocator.get(IconResolver.class).getIconResource(iconName));
ClientConfig clientConfig = beanLocator.get(Configuration.class).getConfig(ClientConfig.class);
setClickShortcut(reloginBtn, clientConfig.getCommitShortcut());
reloginBtn.focus();
layout.addComponent(messageLab);
layout.addComponent(reloginBtn);
layout.setComponentAlignment(reloginBtn, Alignment.BOTTOM_RIGHT);
ui.addWindow(dialog);
dialog.center();
if (ui.isTestMode()) {
dialog.setCubaId("optionDialog");
reloginBtn.setCubaId("reloginBtn");
}
if (ui.isPerformanceTestMode()) {
dialog.setId(ui.getTestIdManager().getTestId("optionDialog"));
reloginBtn.setId(ui.getTestIdManager().getTestId("reloginBtn"));
}
}
use of com.haulmont.cuba.client.ClientConfig in project cuba by cuba-platform.
the class WebWindow method close.
@Override
public boolean close(final String actionId) {
if (!forceClose) {
if (!delegate.preClose(actionId))
return false;
}
if (closing) {
return true;
}
Configuration configuration = AppBeans.get(Configuration.NAME);
ClientConfig clientConfig = configuration.getConfig(ClientConfig.class);
if (!forceClose && isModified()) {
final Committable committable = (getWrapper() instanceof Committable) ? (Committable) getWrapper() : (this instanceof Committable) ? (Committable) this : null;
if ((committable != null) && clientConfig.getUseSaveConfirmation()) {
windowManager.showOptionDialog(messages.getMainMessage("closeUnsaved.caption"), messages.getMainMessage("saveUnsaved"), MessageType.WARNING, new Action[] { new DialogAction(Type.OK, Status.PRIMARY).withCaption(messages.getMainMessage("closeUnsaved.save")).withHandler(event -> {
committable.commitAndClose();
}), new BaseAction("discard").withIcon(icons.get(CubaIcon.DIALOG_CANCEL)).withCaption(messages.getMainMessage("closeUnsaved.discard")).withHandler(event -> {
committable.close(actionId, true);
}), new DialogAction(Type.CANCEL).withIcon(null).withHandler(event -> {
doAfterClose = null;
// try to move focus back
findAndFocusChildComponent();
}) });
} else {
windowManager.showOptionDialog(messages.getMainMessage("closeUnsaved.caption"), messages.getMainMessage("closeUnsaved"), MessageType.WARNING, new Action[] { new DialogAction(Type.YES).withHandler(event -> getWrapper().close(actionId, true)), new DialogAction(Type.NO, Status.PRIMARY).withHandler(event -> {
doAfterClose = null;
// try to move focus back
findAndFocusChildComponent();
}) });
}
closing = false;
return false;
}
if (!clientConfig.getManualScreenSettingsSaving()) {
if (getWrapper() != null) {
getWrapper().saveSettings();
} else {
saveSettings();
}
}
delegate.disposeComponents();
windowManager.close(this);
boolean res = onClose(actionId);
if (res && doAfterClose != null) {
doAfterClose.run();
}
closing = res;
return res;
}
use of com.haulmont.cuba.client.ClientConfig in project cuba by cuba-platform.
the class WebAbstractTable method applySettings.
@Override
public void applySettings(Element element) {
if (!isSettingsEnabled()) {
return;
}
if (defaultSettings == null) {
// save default view before apply custom
defaultSettings = DocumentHelper.createDocument();
defaultSettings.setRootElement(defaultSettings.addElement("presentation"));
saveSettings(defaultSettings.getRootElement());
}
String textSelection = element.attributeValue("textSelection");
if (StringUtils.isNotEmpty(textSelection)) {
component.setTextSelectionEnabled(Boolean.parseBoolean(textSelection));
if (component.getPresentations() != null) {
component.getPresentations().updateTextSelection();
}
}
final Element columnsElem = element.element("columns");
if (columnsElem != null) {
boolean refreshWasEnabled = component.disableContentBufferRefreshing();
Collection<String> modelIds = new LinkedList<>();
for (Object column : component.getVisibleColumns()) {
modelIds.add(String.valueOf(column));
}
Collection<String> loadedIds = new LinkedList<>();
for (Element colElem : Dom4j.elements(columnsElem, "columns")) {
loadedIds.add(colElem.attributeValue("id"));
}
Configuration configuration = AppBeans.get(Configuration.NAME);
ClientConfig clientConfig = configuration.getConfig(ClientConfig.class);
if (clientConfig.getLoadObsoleteSettingsForTable() || CollectionUtils.isEqualCollection(modelIds, loadedIds)) {
applyColumnSettings(element);
}
component.enableContentBufferRefreshing(refreshWasEnabled);
}
}
Aggregations