/** * Get special meta property path object for dynamic attribute by code */ @Nullable public static MetaPropertyPath getMetaPropertyPath(MetaClass metaClass, String attributeCode) { return AppBeans.get(DynamicAttributesTools.NAME, DynamicAttributesTools.class) .getMetaPropertyPath(metaClass, attributeCode); }
@Override public String getLocCaption() { if (Strings.isNullOrEmpty(caption)) { Messages messages = AppBeans.get(Messages.class); return messages.getMainMessage("filter.ftsCondition.caption"); } else { MessageTools messageTools = AppBeans.get(MessageTools.class); return messageTools.loadString(messagesPack, caption); } }
@Override public LocalDate 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); } DateTimeFormatter formatter = DateTimeFormatter.ofPattern(formatPattern); return LocalDate.parse(value.trim(), formatter); }
protected String compileLink(CollectionDatasource ds) { StringBuilder sb = new StringBuilder(); Messages messages = AppBeans.get(Messages.NAME); sb.append(messages.getMainMessage("table.showLinkAction.link")).append("<br/>"); sb.append("<textarea class=\"c-table-showlink-textarea\" autofocus=\"true\" readonly=\"true\">"). append(handler.makeLink(ds.getItem()).replace("&", "&")).append("</textarea>"); return sb.toString(); } }
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(); }
protected List<AppFolder> getReloadedFolders() { List<AppFolder> folders = appFoldersTree.getItems() .collect(Collectors.toList()); FoldersService service = AppBeans.get(FoldersService.NAME); return service.reloadAppFolders(folders); }
protected MetaClass resolveTargetMetaClass(MetaClass metaClass) { if (metaClass == null) { return null; } Metadata metadata = AppBeans.get(Metadata.NAME); MetaClass targetMetaClass = metadata.getExtendedEntities().getOriginalMetaClass(metaClass); if (targetMetaClass == null) { targetMetaClass = metaClass; } return targetMetaClass; }
@MetaProperty public String getDisplayUser() { UserFormatTools formatTools = AppBeans.get(UserFormatTools.NAME); return formatTools.formatUser(user, substitutedUser); }
@Override public void setIconFromSet(Icons.Icon icon) { String iconPath = AppBeans.get(Icons.class) // todo replace .get(icon); setIcon(iconPath); }
protected void processDeletePolicy(Entity entity) { DeletePolicyProcessor processor = AppBeans.get(DeletePolicyProcessor.NAME); // prototype processor.setEntity(entity); processor.process(); } }
public FilterEntity createFakeFilterEntity(String xml) { if (filterEntity != null) { return filterEntity; } Metadata metadata = AppBeans.get(Metadata.NAME); FilterEntity fakeFilterEntity = metadata.create(FilterEntity.class); fakeFilterEntity.setXml(xml); return fakeFilterEntity; } }
/** * Method returns the current value that should be displayed in the UI. The method takes into account the {@link #secret} * property value and displays a value placeholder if it should not be visible */ @MetaProperty public String getDisplayedCurrentValue() { if (Boolean.TRUE.equals(secret) && isDatatypeMayBeHidden()) { return AppBeans.get(Messages.class).getMessage(AppPropertyEntity.class, "AppPropertyEntity.valueIsSecret"); } else { return currentValue; } }
protected String getWebJarResourcePath(String webJar, String resource, String overridePath) { String staticResourcePath = getWebJarStaticResourcePath(overridePath, resource); if (staticResourcePath != null && !staticResourcePath.isEmpty()) { return staticResourcePath; } WebJarResourceResolver resolver = AppBeans.get(WebJarResourceResolver.NAME); String webJarPath = resolver.getWebJarPath(webJar, resource); return resolver.translateToWebPath(webJarPath); }
@Override public String format(Object value, Locale locale) { if (value == null) return ""; FormatStrings formatStrings = AppBeans.get(FormatStringsRegistry.class).getFormatStrings(locale); if (formatStrings == null) return format(value); DecimalFormatSymbols formatSymbols = formatStrings.getFormatSymbols(); NumberFormat format = new DecimalFormat(formatStrings.getIntegerFormat(), formatSymbols); return format.format(value); }
@Override public String getNodeName() { Configuration configuration = AppBeans.get(Configuration.NAME); GlobalConfig globalConfig = configuration.getConfig(GlobalConfig.class); return globalConfig.getWebHostName() + ":" + globalConfig.getWebPort(); } }
@Override protected void createResource() { String name = StringUtils.isNotEmpty(fileName) ? fileName : FilenameUtils.getName(path); resource = new StreamResource(() -> AppBeans.get(Resources.class).getResourceAsStream(path), name); StreamResource streamResource = (StreamResource) this.resource; streamResource.setMIMEType(mimeType); streamResource.setCacheTime(cacheTime); streamResource.setBufferSize(bufferSize); }
@Override protected void doHandle(App app, String className, String message, @Nullable Throwable throwable) { Messages messages = AppBeans.get(Messages.NAME); app.getWindowManager().showNotification( messages.getMainMessage("validationFail.caption"), messages.getMainMessage("validationFail"), Frame.NotificationType.TRAY ); } }
@Override public void setIcon(String icon) { this.icon = icon; if (icon != null) { Resource iconResource = AppBeans.get(IconResolver.class) .getIconResource(this.icon); delegateItem.setIcon(iconResource); } else { delegateItem.setIcon(null); } }
protected List<Entity> loadEntityList(String[] ids) { Metadata metadata = AppBeans.get(Metadata.class); MetaClass metaClass = metadata.getSession().getClassNN(javaClass); LoadContext ctx = new LoadContext(javaClass); LoadContext.Query query = ctx.setQueryString("select e from " + metaClass.getName() + " e where e.id in :ids"); query.setParameter("ids", Arrays.asList(ids)); DataManager dataManager = AppBeans.get(DataManager.class); return dataManager.loadList(ctx); }
@PostConstruct protected void init() { UserSession userSession = AppBeans.get(UserSessionSource.class).getUserSession(); setUser(userSession.getUser()); setSubstitutedUser(userSession.getSubstitutedUser()); } }