Search in sources :

Example 26 with ClientConfig

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

the class SwingXTableSettings method apply.

@Override
public void apply(Element element, boolean sortable) {
    String horizontalScroll = element.attributeValue("horizontalScroll");
    if (!StringUtils.isBlank(horizontalScroll)) {
        table.setHorizontalScrollEnabled(Boolean.valueOf(horizontalScroll));
    }
    loadFontPreferences(element);
    final Element columnsElem = element.element("columns");
    if (columnsElem == null) {
        return;
    }
    Collection<String> modelIds = new LinkedList<>();
    for (TableColumn modelColumn : table.getColumns(true)) {
        modelIds.add(String.valueOf(modelColumn.getIdentifier()));
    }
    Collection<String> loadedIds = new LinkedList<>();
    for (Element colElem : Dom4j.elements(columnsElem, "column")) {
        String id = colElem.attributeValue("id");
        loadedIds.add(id);
    }
    Configuration configuration = AppBeans.get(Configuration.NAME);
    ClientConfig clientConfig = configuration.getConfig(ClientConfig.class);
    if (clientConfig.getLoadObsoleteSettingsForTable() || CollectionUtils.isEqualCollection(modelIds, loadedIds)) {
        applyColumnSettings(element, sortable);
    }
}
Also used : Configuration(com.haulmont.cuba.core.global.Configuration) Element(org.dom4j.Element) ClientConfig(com.haulmont.cuba.client.ClientConfig) TableColumn(javax.swing.table.TableColumn)

Example 27 with ClientConfig

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

the class ScreenHistorySupport method init.

@EventListener(AppContextInitializedEvent.class)
@Order(Events.HIGHEST_PLATFORM_PRECEDENCE + 300)
protected void init() {
    ClientConfig clientConfig = configuration.getConfig(ClientConfig.class);
    String property = clientConfig.getScreenIdsToSaveHistory();
    if (StringUtils.isNotBlank(property)) {
        screenIds.addAll(Arrays.asList(StringUtils.split(property, ',')));
    }
    for (MetaClass metaClass : metadata.getTools().getAllPersistentMetaClasses()) {
        Map<String, Object> attributes = metadata.getTools().getMetaAnnotationAttributes(metaClass.getAnnotations(), TrackEditScreenHistory.class);
        if (Boolean.TRUE.equals(attributes.get("value"))) {
            screenIds.add(windowConfig.getEditorScreenId(metaClass));
        }
    }
}
Also used : MetaClass(com.haulmont.chile.core.model.MetaClass) ClientConfig(com.haulmont.cuba.client.ClientConfig) Order(org.springframework.core.annotation.Order) EventListener(org.springframework.context.event.EventListener)

Example 28 with ClientConfig

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

the class StandardEditor method preventUnsavedChanges.

protected void preventUnsavedChanges(BeforeCloseEvent event) {
    CloseAction action = event.getCloseAction();
    if (action instanceof ChangeTrackerCloseAction && ((ChangeTrackerCloseAction) action).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 (clientConfig.getUseSaveConfirmation()) {
            screenValidation.showSaveConfirmationDialog(this, action).onCommit(() -> result.resume(closeWithCommit())).onDiscard(() -> result.resume(closeWithDiscard())).onCancel(result::fail);
        } else {
            screenValidation.showUnsavedChangesDialog(this, action).onDiscard(() -> result.resume(closeWithDiscard())).onCancel(result::fail);
        }
        event.preventWindowClose(result);
    }
}
Also used : UnknownOperationResult(com.haulmont.cuba.gui.util.UnknownOperationResult) ClientConfig(com.haulmont.cuba.client.ClientConfig)

Example 29 with ClientConfig

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

the class LogWindow method initUI.

protected void initUI() {
    ClientConfig clientConfig = AppBeans.<Configuration>get(Configuration.NAME).getConfig(ClientConfig.class);
    String closeShortcut = clientConfig.getCloseShortcut();
    KeyCombination closeCombination = KeyCombination.create(closeShortcut);
    com.vaadin.event.ShortcutAction closeShortcutAction = new com.vaadin.event.ShortcutAction("closeShortcutAction", closeCombination.getKey().getCode(), KeyCombination.Modifier.codes(closeCombination.getModifiers()));
    addActionHandler(new com.vaadin.event.Action.Handler() {

        @Override
        public com.vaadin.event.Action[] getActions(Object target, Object sender) {
            return new com.vaadin.event.Action[] { closeShortcutAction };
        }

        @Override
        public void handleAction(com.vaadin.event.Action action, Object sender, Object target) {
            if (Objects.equals(action, closeShortcutAction)) {
                close();
            }
        }
    });
    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setMargin(false);
    layout.setSizeFull();
    setContent(layout);
    Panel scrollablePanel = new Panel();
    scrollablePanel.setSizeFull();
    VerticalLayout scrollContent = new VerticalLayout();
    scrollContent.setMargin(false);
    scrollContent.setSpacing(false);
    scrollContent.setSizeUndefined();
    scrollablePanel.setContent(scrollContent);
    final Label label = new Label();
    label.setContentMode(ContentMode.HTML);
    label.setValue(writeLog());
    label.setSizeUndefined();
    label.setStyleName("c-log-content");
    ((Layout) scrollablePanel.getContent()).addComponent(label);
    HorizontalLayout topLayout = new HorizontalLayout();
    topLayout.setMargin(false);
    topLayout.setSpacing(false);
    topLayout.setWidth("100%");
    topLayout.setHeightUndefined();
    Messages messages = AppBeans.get(Messages.NAME);
    Button refreshBtn = new CubaButton(messages.getMessage(getClass(), "logWindow.refreshBtn"), event -> label.setValue(writeLog()));
    topLayout.addComponent(refreshBtn);
    layout.addComponent(topLayout);
    layout.addComponent(scrollablePanel);
    layout.setExpandRatio(scrollablePanel, 1.0f);
}
Also used : Messages(com.haulmont.cuba.core.global.Messages) KeyCombination(com.haulmont.cuba.gui.components.KeyCombination) CubaButton(com.haulmont.cuba.web.widgets.CubaButton) CubaButton(com.haulmont.cuba.web.widgets.CubaButton) ClientConfig(com.haulmont.cuba.client.ClientConfig)

Example 30 with ClientConfig

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

the class WebAbstractTable method setConfiguration.

@Inject
public void setConfiguration(Configuration configuration) {
    this.configuration = configuration;
    ClientConfig clientConfig = configuration.getConfig(ClientConfig.class);
    ignoreUnfetchedAttributes = clientConfig.getIgnoreUnfetchedAttributesInTable();
}
Also used : ClientConfig(com.haulmont.cuba.client.ClientConfig) Inject(javax.inject.Inject)

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