use of com.haulmont.cuba.core.global.Configuration 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.core.global.Configuration in project cuba by cuba-platform.
the class RemotingServlet method checkConfiguration.
/**
* Check correctness of some configuration parameters and log the warning if necessary.
*/
protected void checkConfiguration(HttpServletRequest request) {
if (!checkCompleted) {
GlobalConfig config = AppBeans.get(Configuration.class).getConfig(GlobalConfig.class);
if (config.getLogIncorrectWebAppPropertiesEnabled()) {
StringBuilder sb = new StringBuilder();
if (!request.getServerName().equals(config.getWebHostName())) {
sb.append("***** cuba.webHostName=").append(config.getWebHostName()).append(", actual=").append(request.getServerName()).append("\n");
}
if (request.getServerPort() != Integer.parseInt(config.getWebPort())) {
sb.append("***** cuba.webPort=").append(config.getWebPort()).append(", actual=").append(request.getServerPort()).append("\n");
}
String contextPath = request.getContextPath();
if (contextPath.startsWith("/"))
contextPath = contextPath.substring(1);
if (!contextPath.equals(config.getWebContextName())) {
sb.append("***** cuba.webContextName=").append(config.getWebContextName()).append(", actual=").append(contextPath).append("\n");
}
if (sb.length() > 0) {
sb.insert(0, "\n*****\n");
sb.append("*****");
log.warn(" Invalid configuration parameters that may cause problems:" + sb.toString());
}
}
checkCompleted = true;
}
}
use of com.haulmont.cuba.core.global.Configuration in project cuba by cuba-platform.
the class Connection method setCredentialsParams.
protected void setCredentialsParams(AbstractClientCredentials credentials, Map<String, Object> loginParams) {
credentials.setClientInfo(makeClientInfo());
credentials.setClientType(ClientType.DESKTOP);
Optional<InetAddress> address = Optional.empty();
try {
address = Optional.ofNullable(InetAddress.getLocalHost());
} catch (UnknownHostException e) {
log.warn("Unable to obtain local IP address", e);
}
if (address.isPresent()) {
credentials.setIpAddress(address.get().getHostAddress());
credentials.setHostName(address.get().getHostName());
}
credentials.setParams(loginParams);
Configuration configuration = AppBeans.get(Configuration.class);
GlobalConfig globalConfig = configuration.getConfig(GlobalConfig.class);
if (!globalConfig.getLocaleSelectVisible()) {
credentials.setOverrideLocale(false);
}
}
use of com.haulmont.cuba.core.global.Configuration in project cuba by cuba-platform.
the class SessionMessagesNotifier method activate.
public void activate() {
if (timer != null) {
return;
}
Configuration configuration = AppBeans.get(Configuration.NAME);
int timeout = configuration.getConfig(DesktopConfig.class).getSessionMessagesIntervalSec();
if (timeout > 0) {
timer = new Timer(timeout * 1000, new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
syncMessages();
}
});
timer.start();
}
}
use of com.haulmont.cuba.core.global.Configuration in project cuba by cuba-platform.
the class LogWindow method initUI.
private 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.setSizeFull();
setContent(layout);
Panel scrollablePanel = new Panel();
scrollablePanel.setSizeFull();
VerticalLayout scrollContent = new VerticalLayout();
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.setWidth("100%");
topLayout.setHeightUndefined();
Messages messages = AppBeans.get(Messages.NAME);
Button refreshBtn = new CubaButton(messages.getMessage(getClass(), "logWindow.refreshBtn"), (Button.ClickListener) event -> label.setValue(writeLog()));
topLayout.addComponent(refreshBtn);
layout.addComponent(topLayout);
layout.addComponent(scrollablePanel);
layout.setExpandRatio(scrollablePanel, 1.0f);
}
Aggregations