當前位置: 首頁>>代碼示例>>Java>>正文


Java Configuration類代碼示例

本文整理匯總了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);
}
 
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:21,代碼來源:AppFolderEditWindow.java

示例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]);
                }
            }
        }
    }
}
 
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:22,代碼來源:DefaultDomainAliasesResolver.java

示例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;
}
 
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:17,代碼來源:WebAbstractUploadComponent.java

示例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;
}
 
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:18,代碼來源:FreeMarkerView.java

示例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;
}
 
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:18,代碼來源:SiteSettings.java

示例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);
    }
}
 
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:25,代碼來源:Connection.java

示例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);
}
 
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:19,代碼來源:MainWindowProperties.java

示例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();
    }
}
 
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:19,代碼來源:SessionMessagesNotifier.java

示例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);
}
 
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:24,代碼來源:ConfigProviderTest.java

示例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);
}
 
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:17,代碼來源:AmazonS3FileStorageTest.java

示例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;
}
 
開發者ID:cuba-platform,項目名稱:sample-timesheets,代碼行數:15,代碼來源:SecurityAssistant.java

示例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();
}
 
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:8,代碼來源:CubaVaadinServletService.java

示例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();
}
 
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:13,代碼來源:ControllerUtils.java

示例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;
    }
}
 
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:28,代碼來源:ControllerUtils.java

示例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);
}
 
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:33,代碼來源:CubaManagedTabSheet.java


注:本文中的com.haulmont.cuba.core.global.Configuration類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。