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);
}
}
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));
}
}
}
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);
}
}
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);
}
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();
}
Aggregations