当前位置: 首页>>代码示例>>Java>>正文


Java AppBeans类代码示例

本文整理汇总了Java中com.haulmont.cuba.core.global.AppBeans的典型用法代码示例。如果您正苦于以下问题:Java AppBeans类的具体用法?Java AppBeans怎么用?Java AppBeans使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AppBeans类属于com.haulmont.cuba.core.global包,在下文中一共展示了AppBeans类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createResource

import com.haulmont.cuba.core.global.AppBeans; //导入依赖的package包/类
@Override
protected void createResource() {
    String name = StringUtils.isNotEmpty(fileName) ? fileName : fileDescriptor.getName();

    resource = new StreamResource(() -> {
        try {
            return new ByteArrayDataProvider(AppBeans.get(FileStorageService.class).loadFile(fileDescriptor))
                    .provide();
        } catch (FileStorageException e) {
            throw new RuntimeException(FILE_STORAGE_EXCEPTION_MESSAGE, e);
        }
    }, name);

    StreamResource streamResource = (StreamResource) this.resource;

    streamResource.setCacheTime(cacheTime);
    streamResource.setBufferSize(bufferSize);
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:19,代码来源:WebFileDescriptorResource.java

示例2: ParamEditor

import com.haulmont.cuba.core.global.AppBeans; //导入依赖的package包/类
public ParamEditor(AbstractCondition condition, boolean removeButtonVisible, boolean operationEditable) {
    this.condition = condition;
    this.removeButtonVisible = removeButtonVisible;

    componentsFactory = AppBeans.get(ComponentsFactory.class);
    labelAndOperationLayout = componentsFactory.createComponent(HBoxLayout.class);
    labelAndOperationLayout.setSpacing(true);
    labelAndOperationLayout.setAlignment(Alignment.MIDDLE_RIGHT);

    captionLbl = componentsFactory.createComponent(Label.class);
    captionLbl.setAlignment(Alignment.MIDDLE_RIGHT);
    captionLbl.setValue(condition.getLocCaption());
    labelAndOperationLayout.add(captionLbl);

    operationEditor = condition.createOperationEditor().getComponent();
    operationEditor.setEnabled(operationEditable);
    labelAndOperationLayout.add(operationEditor);

    createParamEditLayout();

    condition.addListener(this);
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:23,代码来源:ParamEditor.java

示例3: handle

import com.haulmont.cuba.core.global.AppBeans; //导入依赖的package包/类
@Override
public boolean handle(Thread thread, Throwable exception) {
    @SuppressWarnings("unchecked")
    List<Throwable> list = ExceptionUtils.getThrowableList(exception);
    for (Throwable throwable : list) {
        if (throwable instanceof RemoteAccessException) {
            Messages messages = AppBeans.get(Messages.NAME);
            String msg = messages.getMessage(getClass(), "connectException.message");
            if (throwable.getCause() == null) {
                App.getInstance().getMainFrame().showNotification(msg, Frame.NotificationType.ERROR);
            } else {
                String description = messages.formatMessage(getClass(), "connectException.description",
                        throwable.getCause().toString());
                App.getInstance().getMainFrame().showNotification(msg, description, Frame.NotificationType.ERROR);
            }
            return true;
        }
    }
    return false;
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:21,代码来源:ConnectExceptionHandler.java

示例4: initBeanValidator

import com.haulmont.cuba.core.global.AppBeans; //导入依赖的package包/类
protected void initBeanValidator() {
    MetadataTools metadataTools = AppBeans.get(MetadataTools.NAME);
    MetaClass propertyEnclosingMetaClass = metadataTools.getPropertyEnclosingMetaClass(metaPropertyPath);
    Class enclosingJavaClass = propertyEnclosingMetaClass.getJavaClass();

    if (enclosingJavaClass != KeyValueEntity.class
            && !DynamicAttributesUtils.isDynamicAttribute(metaProperty)) {
        BeanValidation beanValidation = AppBeans.get(BeanValidation.NAME);
        javax.validation.Validator validator = beanValidation.getValidator();
        BeanDescriptor beanDescriptor = validator.getConstraintsForClass(enclosingJavaClass);

        if (beanDescriptor.isBeanConstrained()) {
            addValidator(new BeanValidator(enclosingJavaClass, metaProperty.getName()));
        }
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:17,代码来源:DesktopAbstractField.java

示例5: DesktopTokenList

import com.haulmont.cuba.core.global.AppBeans; //导入依赖的package包/类
public DesktopTokenList() {
    rootPanel = new TokenListImpl();

    impl = rootPanel.getImpl();
    addButton = new DesktopButton();

    Messages messages = AppBeans.get(Messages.NAME);
    addButton.setCaption(messages.getMessage(TokenList.class, "actions.Add"));

    clearButton = new DesktopButton();
    clearButton.setCaption(messages.getMessage(TokenList.class, "actions.Clear"));

    lookupPickerField = new DesktopLookupPickerField();
    lookupPickerField.addValueChangeListener(lookupSelectListener);

    setMultiSelect(false);
    setWidth(Component.AUTO_SIZE);
    setHeight(Component.AUTO_SIZE);
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:20,代码来源:DesktopTokenList.java

示例6: fillParentSelect

import com.haulmont.cuba.core.global.AppBeans; //导入依赖的package包/类
protected void fillParentSelect() {
    parentSelect.removeAllItems();

    String root = getMessage("folders.searchFoldersRoot");
    parentSelect.addItem(root);
    parentSelect.setNullSelectionItemId(root);

    FoldersService service = AppBeans.get(FoldersService.NAME);
    List<SearchFolder> list = service.loadSearchFolders();
    for (SearchFolder folder : list) {
        if (!folder.equals(this.folder)) {
            parentSelect.addItem(folder);
            parentSelect.setItemCaption(folder, folder.getCaption());
        }
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:17,代码来源:FolderEditWindow.java

示例7: create

import com.haulmont.cuba.core.global.AppBeans; //导入依赖的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

示例8: fillParentSelect

import com.haulmont.cuba.core.global.AppBeans; //导入依赖的package包/类
@Override
protected void fillParentSelect() {
    parentSelect.removeAllItems();

    String root = getMessage("folders.appFoldersRoot");
    parentSelect.addItem(root);
    parentSelect.setNullSelectionItemId(root);

    FoldersService service = AppBeans.get(FoldersService.NAME);
    List<AppFolder> list = service.loadAppFolders();
    for (AppFolder folder : list) {
        if (!folder.equals(this.folder)) {
            parentSelect.addItem(folder);
            parentSelect.setItemCaption(folder, getMessage(folder.getName()));
        }
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:18,代码来源:AppFolderEditWindow.java

示例9: openUrl

import com.haulmont.cuba.core.global.AppBeans; //导入依赖的package包/类
protected void openUrl(Entity entity) {
    ScreenHistoryEntity screenHistoryEntity = (ScreenHistoryEntity) entity;
    Map<String, String> paramsScreen = new HashMap<>();
    String url = screenHistoryEntity.getUrl();
    url = url.substring(url.indexOf("\u003f") + 1);
    paramsScreen.put("local", "true");
    String[] params =  url.split("&");
    for (String param : params) {
        String name = param.split("=")[0];
        String value = param.split("=")[1];
        paramsScreen.put(name, value);
    }

    List<String> actions = configuration.getConfig(WebConfig.class).getLinkHandlerActions();
    LinkHandler linkHandler = AppBeans.getPrototype(LinkHandler.NAME,
            App.getInstance(),
            actions.isEmpty() ? "open" : actions.get(0),
            paramsScreen);
    if (linkHandler.canHandleLink()) {
        linkHandler.handle();
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:23,代码来源:ScreenHistoryBrowse.java

示例10: setValue

import com.haulmont.cuba.core.global.AppBeans; //导入依赖的package包/类
@Override
public void setValue(Object value) {
    if (!(value instanceof String)) {
        String formattedValue;

        Datatype<String> stringDatatype = Datatypes.getNN(String.class);
        Datatype datatype = getActualDatatype();

        if (datatype != null && stringDatatype != datatype) {
            formattedValue = datatype.format(value, locale);
        } else {
            MetadataTools metadataTools = AppBeans.get(MetadataTools.NAME);
            formattedValue = metadataTools.format(value);
        }

        super.setValue(formattedValue);
    } else {
        super.setValue(value);
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:21,代码来源:WebAbstractTextField.java

示例11: getTheme

import com.haulmont.cuba.core.global.AppBeans; //导入依赖的package包/类
@Override
public String getTheme(UICreateEvent event) {
    // get theme from cookies before app ui initialized for smooth theme enabling
    WebConfig webConfig = configuration.getConfig(WebConfig.class);
    GlobalConfig globalConfig = configuration.getConfig(GlobalConfig.class);

    String appWindowTheme = webConfig.getAppWindowTheme();
    String userAppTheme = getCookieValue(event.getRequest().getCookies(),
            App.APP_THEME_COOKIE_PREFIX + globalConfig.getWebContextName());
    if (userAppTheme != null) {
        if (!Objects.equals(userAppTheme, appWindowTheme)) {
            // check theme support
            ThemeConstantsRepository themeRepository = AppBeans.get(ThemeConstantsRepository.NAME);
            Set<String> supportedThemes = themeRepository.getAvailableThemes();
            if (supportedThemes.contains(userAppTheme)) {

                return userAppTheme;
            }
        }
    }

    return super.getTheme(event);
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:24,代码来源:CubaUIProvider.java

示例12: parse

import com.haulmont.cuba.core.global.AppBeans; //导入依赖的package包/类
@Override
public Date parse(String value, Locale locale) throws ParseException {
    if (StringUtils.isBlank(value)) {
        return null;
    }

    FormatStrings formatStrings = AppBeans.get(FormatStringsRegistry.class).getFormatStrings(locale);
    if (formatStrings == null) {
        return parse(value);
    }

    DateFormat format = new SimpleDateFormat(formatStrings.getDateFormat());
    format.setLenient(false);

    return normalize(format.parse(value.trim()));
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:17,代码来源:DateDatatype.java

示例13: buildTemplateModel

import com.haulmont.cuba.core.global.AppBeans; //导入依赖的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

示例14: formatFileSize

import com.haulmont.cuba.core.global.AppBeans; //导入依赖的package包/类
/**
 * Format file size for displaying in bytes, KB, MB.
 *
 * @param longSize      size in bytes
 * @param decimalPos    maximum fraction digits
 * @return  formatted value
 */
public static String formatFileSize(long longSize, int decimalPos) {
    Messages messages = AppBeans.get(Messages.NAME);

    NumberFormat fmt = NumberFormat.getNumberInstance();
    if (decimalPos >= 0) {
        fmt.setMaximumFractionDigits(decimalPos);
    }
    final double size = longSize;
    double val = size / (1024 * 1024);
    if (val > 1) {
        return fmt.format(val).concat(" " + messages.getMessage(FileDownloadHelper.class, "fmtMb"));
    }
    val = size / 1024;
    if (val > 10) {
        return fmt.format(val).concat(" " + messages.getMessage(FileDownloadHelper.class, "fmtKb"));
    }
    return fmt.format(size).concat(" " + messages.getMessage(FileDownloadHelper.class, "fmtB"));
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:26,代码来源:FileDownloadHelper.java

示例15: formatValue

import com.haulmont.cuba.core.global.AppBeans; //导入依赖的package包/类
public String formatValue(Object value) {
    String text;
    if (formatter == null) {
        if (value == null) {
            text = "";
        } else {
            MetadataTools metadataTools = AppBeans.get(MetadataTools.NAME);

            if (metaProperty != null) {
                text = metadataTools.format(value, metaProperty);
            } else {
                text = metadataTools.format(value);
            }
        }
    } else {
        text = formatter.format(value);
    }
    return text;
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:20,代码来源:WebLabel.java


注:本文中的com.haulmont.cuba.core.global.AppBeans类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。