Search in sources :

Example 16 with ClientConfig

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();
}
Also used : Configuration(com.haulmont.cuba.core.global.Configuration) ClientConfig(com.haulmont.cuba.client.ClientConfig)

Example 17 with ClientConfig

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);
}
Also used : Element(org.dom4j.Element) TablePresentations(com.haulmont.cuba.web.gui.components.presentations.TablePresentations) ClientConfig(com.haulmont.cuba.client.ClientConfig)

Example 18 with ClientConfig

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"));
    }
}
Also used : Locale(java.util.Locale) Window(com.vaadin.ui.Window) CubaWindow(com.haulmont.cuba.web.widgets.CubaWindow) Messages(com.haulmont.cuba.core.global.Messages) CubaLabel(com.haulmont.cuba.web.widgets.CubaLabel) Configuration(com.haulmont.cuba.core.global.Configuration) CubaButton(com.haulmont.cuba.web.widgets.CubaButton) Connection(com.haulmont.cuba.web.Connection) VerticalLayout(com.vaadin.ui.VerticalLayout) Icons(com.haulmont.cuba.gui.icons.Icons) ClientConfig(com.haulmont.cuba.client.ClientConfig)

Example 19 with ClientConfig

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;
}
Also used : StringUtils(org.apache.commons.lang.StringUtils) Datasource(com.haulmont.cuba.gui.data.Datasource) WindowMode(com.vaadin.shared.ui.window.WindowMode) LoggerFactory(org.slf4j.LoggerFactory) CubaIcon(com.haulmont.cuba.gui.icons.CubaIcon) Settings(com.haulmont.cuba.gui.settings.Settings) AppBeans(com.haulmont.cuba.core.global.AppBeans) Icons(com.haulmont.cuba.gui.icons.Icons) BooleanUtils(org.apache.commons.lang.BooleanUtils) IconResolver(com.haulmont.cuba.web.gui.icons.IconResolver) com.haulmont.cuba.gui(com.haulmont.cuba.gui) Window(com.haulmont.cuba.gui.components.Window) Configuration(com.haulmont.cuba.core.global.Configuration) Instance(com.haulmont.chile.core.model.Instance) AppUI(com.haulmont.cuba.web.AppUI) Page(com.vaadin.server.Page) EventRouter(com.haulmont.bali.events.EventRouter) BaseAction(com.haulmont.cuba.gui.components.actions.BaseAction) Preconditions.checkNotNullArgument(com.haulmont.bali.util.Preconditions.checkNotNullArgument) com.haulmont.cuba.gui.components(com.haulmont.cuba.gui.components) Status(com.haulmont.cuba.gui.components.Action.Status) MainTabSheetMode(com.haulmont.cuba.web.toolkit.ui.MainTabSheetMode) Messages(com.haulmont.cuba.core.global.Messages) ApplicationListener(org.springframework.context.ApplicationListener) MarginInfo(com.vaadin.shared.ui.MarginInfo) CubaSingleModeContainer(com.haulmont.cuba.web.toolkit.ui.CubaSingleModeContainer) WebWrapperUtils(com.haulmont.cuba.web.gui.components.WebWrapperUtils) TabSheet(com.vaadin.ui.TabSheet) WebConfig(com.haulmont.cuba.web.WebConfig) ClientConfig(com.haulmont.cuba.client.ClientConfig) WebAbstractComponent(com.haulmont.cuba.web.gui.components.WebAbstractComponent) WebWindowManager(com.haulmont.cuba.web.WebWindowManager) java.util(java.util) LookupSelectionChangeNotifier(com.haulmont.cuba.gui.components.LookupComponent.LookupSelectionChangeNotifier) Timer(com.haulmont.cuba.gui.components.Timer) MetaClass(com.haulmont.chile.core.model.MetaClass) CubaVerticalActionsLayout(com.haulmont.cuba.web.toolkit.ui.CubaVerticalActionsLayout) WebFrameActionsHolder(com.haulmont.cuba.web.gui.components.WebFrameActionsHolder) ClientConnector(com.vaadin.server.ClientConnector) Component(com.haulmont.cuba.gui.components.Component) DsContext(com.haulmont.cuba.gui.data.DsContext) Nullable(javax.annotation.Nullable) Logger(org.slf4j.Logger) Type(com.haulmont.cuba.gui.components.DialogAction.Type) Preconditions(com.haulmont.bali.util.Preconditions) Button(com.vaadin.ui.Button) UiEventsMulticaster(com.haulmont.cuba.gui.events.sys.UiEventsMulticaster) WebComponentsHelper(com.haulmont.cuba.web.gui.components.WebComponentsHelper) Element(org.dom4j.Element) Unit(com.vaadin.server.Sizeable.Unit) Entity(com.haulmont.cuba.core.entity.Entity) com.vaadin.ui(com.vaadin.ui) Configuration(com.haulmont.cuba.core.global.Configuration) BaseAction(com.haulmont.cuba.gui.components.actions.BaseAction) ClientConfig(com.haulmont.cuba.client.ClientConfig)

Example 20 with ClientConfig

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);
    }
}
Also used : Element(org.dom4j.Element) ClientConfig(com.haulmont.cuba.client.ClientConfig)

Aggregations

ClientConfig (com.haulmont.cuba.client.ClientConfig)40 Configuration (com.haulmont.cuba.core.global.Configuration)14 Messages (com.haulmont.cuba.core.global.Messages)6 Inject (javax.inject.Inject)6 Icons (com.haulmont.cuba.gui.icons.Icons)5 Element (org.dom4j.Element)5 com.haulmont.cuba.gui.components (com.haulmont.cuba.gui.components)3 AbstractAction (com.haulmont.cuba.gui.components.AbstractAction)3 Component (com.haulmont.cuba.gui.components.Component)3 ShortcutListenerDelegate (com.haulmont.cuba.web.gui.components.util.ShortcutListenerDelegate)3 EventRouter (com.haulmont.bali.events.EventRouter)2 Preconditions (com.haulmont.bali.util.Preconditions)2 Preconditions.checkNotNullArgument (com.haulmont.bali.util.Preconditions.checkNotNullArgument)2 MetaClass (com.haulmont.chile.core.model.MetaClass)2 Entity (com.haulmont.cuba.core.entity.Entity)2 AppBeans (com.haulmont.cuba.core.global.AppBeans)2 TopLevelFrame (com.haulmont.cuba.desktop.TopLevelFrame)2 com.haulmont.cuba.gui (com.haulmont.cuba.gui)2 LayoutAnalyzer (com.haulmont.cuba.gui.app.core.dev.LayoutAnalyzer)2 Action (com.haulmont.cuba.gui.components.Action)2