Search in sources :

Example 6 with ClientConfig

use of com.haulmont.cuba.client.ClientConfig in project cuba by cuba-platform.

the class EditAction method setConfiguration.

@Inject
protected void setConfiguration(Configuration configuration) {
    ClientConfig clientConfig = configuration.getConfig(ClientConfig.class);
    setShortcut(clientConfig.getTableEditShortcut());
}
Also used : ClientConfig(com.haulmont.cuba.client.ClientConfig) Inject(javax.inject.Inject)

Example 7 with ClientConfig

use of com.haulmont.cuba.client.ClientConfig in project cuba by cuba-platform.

the class SystemInfoWindow method init.

@Override
public void init(Map<String, Object> params) {
    super.init(params);
    paramsDs.setInstance(item);
    paramsDs.setInstanceMetaClass((MetaClass) params.get("metaClass"));
    String cubaLogContentClass = "c-system-info-log-content";
    String cubaCopyLogContentClass = cubaLogContentClass + "-" + UUID.randomUUID();
    scriptArea.setStyleName(cubaLogContentClass);
    scriptArea.addStyleName(cubaCopyLogContentClass);
    paramsDs.refresh();
    Companion companion = getCompanion();
    if (companion != null) {
        companion.initInfoTable(infoTable);
        companion.addCopyButton(buttonsPanel, messages.getMainMessage("systemInfoWindow.copy"), messages.getMainMessage("systemInfoWindow.copingSuccessful"), messages.getMainMessage("systemInfoWindow.copingFailed"), cubaCopyLogContentClass, uiComponents);
    }
    infoTable.removeAllActions();
    ClientConfig clientConfig = configuration.getConfig(ClientConfig.class);
    if (!clientConfig.getSystemInfoScriptsEnabled() || item == null || !metadata.getTools().isPersistent(item.getMetaClass())) {
        buttonsPanel.setVisible(false);
    }
}
Also used : ClientConfig(com.haulmont.cuba.client.ClientConfig)

Example 8 with ClientConfig

use of com.haulmont.cuba.client.ClientConfig in project cuba by cuba-platform.

the class CreateAction method setConfiguration.

@Inject
protected void setConfiguration(Configuration configuration) {
    ClientConfig clientConfig = configuration.getConfig(ClientConfig.class);
    setShortcut(clientConfig.getTableInsertShortcut());
}
Also used : ClientConfig(com.haulmont.cuba.client.ClientConfig) Inject(javax.inject.Inject)

Example 9 with ClientConfig

use of com.haulmont.cuba.client.ClientConfig in project cuba by cuba-platform.

the class AbstractWindow method beforeClose.

@Order(Events.HIGHEST_PLATFORM_PRECEDENCE + 10)
@Subscribe
protected void beforeClose(Screen.BeforeCloseEvent event) {
    CloseAction closeAction = event.getCloseAction();
    boolean checkSavedChanges = !(closeAction instanceof ChangeTrackerCloseAction) || ((ChangeTrackerCloseAction) closeAction).isCheckForUnsavedChanges();
    if (checkSavedChanges) {
        String actionId = closeAction instanceof StandardCloseAction ? ((StandardCloseAction) closeAction).getActionId() : UNKNOWN_CLOSE_ACTION_ID;
        boolean close = preClose(actionId);
        if (!close) {
            event.preventWindowClose();
        }
    }
    if (!event.isClosePrevented()) {
        if (closeAction instanceof ChangeTrackerCloseAction && ((ChangeTrackerCloseAction) closeAction).isCheckForUnsavedChanges() && hasUnsavedChanges()) {
            Configuration configuration = getBeanLocator().get(Configuration.NAME);
            ClientConfig clientConfig = configuration.getConfig(ClientConfig.class);
            ScreenValidation screenValidation = getBeanLocator().get(ScreenValidation.NAME);
            UnknownOperationResult result = new UnknownOperationResult();
            if (this instanceof Committable && clientConfig.getUseSaveConfirmation()) {
                Committable committable = (Committable) this;
                screenValidation.showSaveConfirmationDialog(this, closeAction).onCommit(committable::commitAndClose).onDiscard(() -> result.resolveWith(closeWithDiscard())).onCancel(result::fail);
            } else {
                screenValidation.showUnsavedChangesDialog(this, closeAction).onDiscard(() -> result.resolveWith(closeWithDiscard())).onCancel(result::fail);
            }
            event.preventWindowClose(result);
        }
    }
}
Also used : Configuration(com.haulmont.cuba.core.global.Configuration) UnknownOperationResult(com.haulmont.cuba.gui.util.UnknownOperationResult) ClientConfig(com.haulmont.cuba.client.ClientConfig) Order(org.springframework.core.annotation.Order)

Example 10 with ClientConfig

use of com.haulmont.cuba.client.ClientConfig in project cuba by cuba-platform.

the class AbstractFrame method showValidationErrors.

/**
 * Show validation errors alert. Can be overridden in subclasses.
 *
 * @param errors the list of validation errors. Caller fills it by errors found during the default validation.
 */
public void showValidationErrors(ValidationErrors errors) {
    StringBuilder buffer = new StringBuilder();
    for (ValidationErrors.Item error : errors.getAll()) {
        buffer.append(error.description).append("\n");
    }
    Configuration configuration = AppBeans.get(Configuration.NAME);
    ClientConfig clientConfig = configuration.getConfig(ClientConfig.class);
    NotificationType notificationType = NotificationType.valueOf(clientConfig.getValidationNotificationType());
    showNotification(messages.getMainMessage("validationFail.caption"), buffer.toString(), notificationType);
}
Also used : 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