本文整理汇总了Java中com.haulmont.cuba.core.global.AppBeans类的典型用法代码示例。如果您正苦于以下问题:Java AppBeans类的具体用法?Java AppBeans怎么用?Java AppBeans使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AppBeans类属于com.haulmont.cuba.core.global包,在下文中一共展示了AppBeans类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: initComponents
import com.haulmont.cuba.core.global.AppBeans; //导入依赖的package包/类
protected void initComponents() {
required = (CheckBox) getComponent("required");
hidden = (CheckBox) getComponent("hidden");
width = (LookupField) getComponent("width");
if (width != null) {
List<Integer> widthValues = new ArrayList<>();
int conditionsColumnsCount = filter != null ? filter.getColumnsCount() : clientConfig.getGenericFilterColumnsCount();
for (int i = 1; i <= conditionsColumnsCount; i++) {
widthValues.add(i);
}
width.setOptionsList(widthValues);
FilterHelper filterHelper = AppBeans.get(FilterHelper.class);
filterHelper.setLookupNullSelectionAllowed(width, false);
}
}
开发者ID:cuba-platform,项目名称:cuba,代码行数:17,代码来源:ConditionFrame.java
示例17: getParam
import com.haulmont.cuba.core.global.AppBeans; //导入依赖的package包/类
protected String getParam(String[] args, int idx, TimeZone timeZone) {
String arg = args[idx].trim();
String unit = args[3].trim();
Matcher matcher = PARAM_PATTERN.matcher(arg);
if (!matcher.find())
throw new RuntimeException("Invalid macro argument: " + arg);
int num = 0;
try {
String expr = matcher.group(2);
if (!Strings.isNullOrEmpty(expr)) {
Scripting scripting = AppBeans.get(Scripting.class);
num = scripting.evaluateGroovy(expr, new Binding());
}
} catch (NumberFormatException e) {
throw new RuntimeException("Invalid macro argument: " + arg, e);
}
Date date = computeDate(num, unit, timeZone);
String paramName = args[0].trim().replace(".", "_") + "_" + count + "_" + idx;
params.put(paramName, date);
return paramName;
}
开发者ID:cuba-platform,项目名称:cuba,代码行数:27,代码来源:TimeBetweenQueryMacroHandler.java
示例18: getFileSizeLimitString
import com.haulmont.cuba.core.global.AppBeans; //导入依赖的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
示例19: handleTimeoutException
import com.haulmont.cuba.core.global.AppBeans; //导入依赖的package包/类
@Override
public boolean handleTimeoutException() {
boolean handled = wrappedTask.handleTimeoutException();
if (handled || wrappedTask.getOwnerFrame() == null) {
window.close("", true);
} else {
window.closeAndRun("close", () -> {
Messages messages = AppBeans.get(Messages.NAME);
wrappedTask.getOwnerFrame().showNotification(
messages.getMessage(LocalizedTaskWrapper.class, "backgroundWorkProgress.timeout"),
messages.getMessage(LocalizedTaskWrapper.class, "backgroundWorkProgress.timeoutMessage"),
NotificationType.WARNING);
});
handled = true;
}
return handled;
}
开发者ID:cuba-platform,项目名称:cuba,代码行数:19,代码来源:LocalizedTaskWrapper.java
示例20: validate
import com.haulmont.cuba.core.global.AppBeans; //导入依赖的package包/类
@Override
public void validate(Object value) throws ValidationException {
if (value == null)
return;
boolean result;
if (value instanceof String) {
try {
Datatype datatype = Datatypes.getNN(java.sql.Date.class);
UserSessionSource sessionSource = AppBeans.get(UserSessionSource.NAME);
datatype.parse((String) value, sessionSource.getLocale());
result = true;
} catch (ParseException e) {
result = false;
}
} else {
result = value instanceof Date;
}
if (!result) {
String msg = message != null ? messages.getTools().loadString(messagesPack, message) : "Invalid value '%s'";
throw new ValidationException(String.format(msg, value));
}
}
开发者ID:cuba-platform,项目名称:cuba,代码行数:24,代码来源:DateValidator.java
注:本文中的com.haulmont.cuba.core.global.AppBeans类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论