本文整理匯總了Java中com.haulmont.cuba.core.global.Configuration類的典型用法代碼示例。如果您正苦於以下問題:Java Configuration類的具體用法?Java Configuration怎麽用?Java Configuration使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Configuration類屬於com.haulmont.cuba.core.global包,在下文中一共展示了Configuration類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: create
import com.haulmont.cuba.core.global.Configuration; //導入依賴的package包/類
public static FolderEditWindow create(boolean isAppFolder, boolean adding,
Folder folder, Presentations presentations, Runnable commitHandler) {
Configuration configuration = AppBeans.get(Configuration.NAME);
GlobalConfig globalConfig = configuration.getConfig(GlobalConfig.class);
String className = isAppFolder ? globalConfig.getAppFolderEditWindowClassName()
: globalConfig.getFolderEditWindowClassName();
if (className != null) {
Class<FolderEditWindow> aClass = ReflectionHelper.getClass(className);
try {
Constructor constructor = aClass.
getConstructor(boolean.class, Folder.class, Presentations.class, Runnable.class);
return (FolderEditWindow) constructor.newInstance(adding, folder, presentations, commitHandler);
} catch (Exception e) {
throw new RuntimeException(e);
}
} else
return isAppFolder ? new AppFolderEditWindow(adding, folder, presentations, commitHandler)
: new FolderEditWindow(adding, folder, presentations, commitHandler);
}
示例2: DefaultDomainAliasesResolver
import com.haulmont.cuba.core.global.Configuration; //導入依賴的package包/類
@Inject
public DefaultDomainAliasesResolver(Configuration configuration) {
WebAuthConfig webConfig = configuration.getConfig(WebAuthConfig.class);
String aliasesConfig = webConfig.getActiveDirectoryAliases();
if (StringUtils.isNotBlank(aliasesConfig)) {
String[] aliasesPairs = StringUtils.split(aliasesConfig, ';');
for (String aliasDefinition : aliasesPairs) {
// skip blank parts
if (StringUtils.isNotBlank(aliasDefinition)) {
String[] aliasParts = StringUtils.split(aliasDefinition, '|');
if (aliasParts == null || aliasParts.length != 2 ||
StringUtils.isBlank(aliasParts[0]) || StringUtils.isBlank(aliasParts[1])) {
log.warn("Incorrect domain alias definition: '{}'", aliasDefinition);
} else {
aliases.put(aliasParts[0].toLowerCase(), aliasParts[1]);
}
}
}
}
}
示例3: getFileSizeLimitString
import com.haulmont.cuba.core.global.Configuration; //導入依賴的package包/類
protected String getFileSizeLimitString() {
String fileSizeLimitString;
if (fileSizeLimit > 0) {
if (fileSizeLimit % BYTES_IN_MEGABYTE == 0) {
fileSizeLimitString = String.valueOf(fileSizeLimit / BYTES_IN_MEGABYTE);
} else {
Datatype<Double> doubleDatatype = Datatypes.getNN(Double.class);
double fileSizeInMb = fileSizeLimit / ((double) BYTES_IN_MEGABYTE);
fileSizeLimitString = doubleDatatype.format(fileSizeInMb);
}
} else {
Configuration configuration = AppBeans.get(Configuration.NAME);
fileSizeLimitString = String.valueOf(configuration.getConfig(ClientConfig.class).getMaxUploadSizeMb());
}
return fileSizeLimitString;
}
示例4: buildTemplateModel
import com.haulmont.cuba.core.global.Configuration; //導入依賴的package包/類
@Override
protected SimpleHash buildTemplateModel(
Map<String, Object> model,
HttpServletRequest request,
HttpServletResponse response
) {
PortalConfig config = AppBeans.get(Configuration.class).getConfig(PortalConfig.class);
SimpleHash context = super.buildTemplateModel(model, request, response);
SecurityContext securityContext = AppContext.getSecurityContext();
if (securityContext != null)
context.put("userSession", securityContext.getSession());
context.put("messages", messages);
context.put("message", new MessageMethod());
context.put("theme", config.getTheme());
return context;
}
示例5: getFreeMarkerSettings
import com.haulmont.cuba.core.global.Configuration; //導入依賴的package包/類
public Properties getFreeMarkerSettings() {
Configuration configuration = AppBeans.get(Configuration.NAME);
GlobalConfig globalConfig = configuration.getConfig(GlobalConfig.class);
Map<String,Locale> availableLocales = globalConfig.getAvailableLocales();
if (availableLocales.isEmpty())
throw new IllegalStateException("Property cuba.availableLocales is not configured");
Locale locale = availableLocales.values().iterator().next();
FormatStrings formatStrings = Datatypes.getFormatStrings(locale);
final Properties freemarkerSettings = new Properties();
freemarkerSettings.setProperty("number_format", "#");
freemarkerSettings.setProperty("datetime_format", formatStrings.getDateTimeFormat());
freemarkerSettings.setProperty("date_format", formatStrings.getDateFormat());
freemarkerSettings.setProperty("template_exception_handler", "rethrow");
return freemarkerSettings;
}
示例6: setCredentialsParams
import com.haulmont.cuba.core.global.Configuration; //導入依賴的package包/類
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);
}
}
示例7: load
import com.haulmont.cuba.core.global.Configuration; //導入依賴的package包/類
public void load() {
Properties properties = new Properties();
try {
Configuration configuration = AppBeans.get(Configuration.NAME);
File file = new File(configuration.getConfig(GlobalConfig.class).getDataDir(), "main-window.properties");
if (file.exists()) {
FileInputStream stream = FileUtils.openInputStream(file);
try {
properties.load(stream);
} finally {
IOUtils.closeQuietly(stream);
}
}
} catch (IOException e) {
log.error("Error loading main window location", e);
}
loadProperties(properties);
}
示例8: activate
import com.haulmont.cuba.core.global.Configuration; //導入依賴的package包/類
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();
}
}
示例9: testDatabaseProperties
import com.haulmont.cuba.core.global.Configuration; //導入依賴的package包/類
@Test
public void testDatabaseProperties() throws Exception {
TestConfig config = AppBeans.get(Configuration.class).getConfig(TestConfig.class);
String dbProp = config.getDatabaseProp();
assertNull(dbProp);
config.setDatabaseProp("test_value");
dbProp = config.getDatabaseProp();
assertEquals("test_value", dbProp);
config.setDatabaseProp("test_value_1");
dbProp = config.getDatabaseProp();
assertEquals("test_value_1", dbProp);
AppContext.setProperty("cuba.test.databaseProp", "overridden_value");
dbProp = config.getDatabaseProp();
assertEquals("overridden_value", dbProp);
AppContext.setProperty("cuba.test.databaseProp", "");
dbProp = config.getDatabaseProp();
assertEquals("test_value_1", dbProp);
}
示例10: setUp
import com.haulmont.cuba.core.global.Configuration; //導入依賴的package包/類
@Before
public void setUp() throws Exception {
fileDescr = new FileDescriptor();
fileDescr.setCreateDate(new Date());
fileDescr.setSize((long) FILE_CONTENT.length());
fileDescr.setName("AmazonFileStorageTest");
fileDescr.setExtension("txt");
fileDescr2 = new FileDescriptor();
fileDescr2.setCreateDate(new Date());
fileDescr2.setSize((long) FILE_CONTENT.length());
fileDescr2.setName("AmazonFileStorageTest");
fileStorageAPI = new AmazonS3FileStorage();
fileStorageAPI.amazonS3Config = AppBeans.get(Configuration.class).getConfig(AmazonS3Config.class);
}
示例11: isUserCloser
import com.haulmont.cuba.core.global.Configuration; //導入依賴的package包/類
public boolean isUserCloser() {
User user = userSessionSource.getUserSession().getCurrentOrSubstitutedUser();
if (CollectionUtils.isEmpty(user.getUserRoles())) {
return false;
}
Configuration configuration = AppBeans.get(Configuration.NAME);
for (UserRole userRole : user.getUserRoles()) {
if (userRole.getRole().getId().equals(configuration.getConfig(TimeSheetsSettings.class).getCloserId())) {
return true;
}
}
return false;
}
示例12: getPushLongPollingSuspendTimeout
import com.haulmont.cuba.core.global.Configuration; //導入依賴的package包/類
@Override
protected int getPushLongPollingSuspendTimeout() {
Configuration configuration = AppBeans.get(Configuration.NAME);
WebConfig webConfig = configuration.getConfig(WebConfig.class);
return webConfig.getPushLongPollingSuspendTimeoutMs();
}
示例13: getControllerURL
import com.haulmont.cuba.core.global.Configuration; //導入依賴的package包/類
public static String getControllerURL(String mapping) {
if (mapping == null) throw new IllegalArgumentException("Mapping cannot be null");
Configuration configuration = AppBeans.get(Configuration.NAME);
GlobalConfig globalConfig = configuration.getConfig(GlobalConfig.class);
StringBuilder sb = new StringBuilder(globalConfig.getWebAppUrl()).append(getControllerPrefix());
if (!mapping.startsWith("/")) {
sb.append("/");
}
sb.append(mapping);
return sb.toString();
}
示例14: getUserSession
import com.haulmont.cuba.core.global.Configuration; //導入依賴的package包/類
public static UserSession getUserSession(HttpServletRequest req) {
String s = req.getParameter("s");
if (s != null) {
try {
UUID id = UUID.fromString(s);
WebAuthConfig webAuthConfig = AppBeans.get(Configuration.class).getConfig(WebAuthConfig.class);
TrustedClientService trustedClientService = AppBeans.get(TrustedClientService.NAME);
UserSession session = trustedClientService.findSession(webAuthConfig.getTrustedClientPassword(), id);
if (session != null) {
req.getSession().setAttribute(App.USER_SESSION_ATTR, session);
return session;
} else {
return null;
}
} catch (Exception e) {
log.warn("Unable to get session from Login Service", e);
return null;
}
} else {
//noinspection UnnecessaryLocalVariable
UserSession userSession = (UserSession) req.getSession().getAttribute(App.USER_SESSION_ATTR);
return userSession;
}
}
示例15: CubaManagedTabSheet
import com.haulmont.cuba.core.global.Configuration; //導入依賴的package包/類
public CubaManagedTabSheet() {
setPrimaryStyleName(MANAGED_TABSHEET_STYLENAME);
setSizeFull();
setImmediate(true);
tabSheetMode = AppBeans.get(Configuration.class)
.getConfig(WebConfig.class)
.getManagedMainTabSheetMode();
closeHandler = (tabSheet1, tabContent) ->
_closeTab(tabContent);
tabbedHeader = new CubaTabSheet() {
@Override
protected Component getActionTarget(Tab tab) {
return getContentTab(tab.getComponent()).getComponent();
}
};
tabbedHeader.setVisible(false);
tabbedHeader.addStyleName("framed padded-tabbar");
tabbedHeader.setCloseHandler((tabsheet, tabContent) ->
closeHandler.onTabClose(CubaManagedTabSheet.this, getContentTab(tabContent).getComponent()));
tabbedHeader.addSelectedTabChangeListener(event -> {
setSelected(tabToContentMap.get(tabbedHeader.getSelectedTab()));
fireSelectedTabChange();
});
addComponent(tabbedHeader);
behaviour = new TabSheetBehaviourImpl(this);
}