protected String loadShortcutFromAlias(String shortcut) { if (shortcut.endsWith("_SHORTCUT}")) { String alias = shortcut.substring(2, shortcut.length() - 1); if (SHORTCUT_ALIASES.containsKey(alias)) { ClientConfig clientConfig = getConfiguration().getConfig(ClientConfig.class); return SHORTCUT_ALIASES.get(alias).apply(clientConfig); } else { String message = String.format("An error occurred while loading shortcut. " + "Can't find shortcut for alias \"%s\"", alias); throw new GuiDevelopmentException(message, context.getFullFrameId()); } } return null; }
protected Action loadInvokeAction(ActionsHolder actionsHolder, Element element, String id, boolean shouldTrackSelection, String invokeMethod) { BaseAction action; String shortcut = loadShortcut(trimToNull(element.attributeValue("shortcut"))); if (shouldTrackSelection) { action = new DeclarativeTrackingAction( id, loadResourceString(element.attributeValue("caption")), loadResourceString(element.attributeValue("description")), getIconPath(element.attributeValue("icon")), element.attributeValue("enable"), element.attributeValue("visible"), ); loadActionConstraint(action, element); action = new DeclarativeAction( id, loadResourceString(element.attributeValue("caption")), loadResourceString(element.attributeValue("description")), getIconPath(element.attributeValue("icon")), element.attributeValue("enable"), element.attributeValue("visible"),
protected String loadResourceString(String caption) { if (StringUtils.isEmpty(caption)) { return caption; } return getMessageTools().loadString(messagesPack, caption); }
protected void initAction(Element element, Action targetAction) { String caption = element.attributeValue("caption"); if (StringUtils.isNotEmpty(caption)) { targetAction.setCaption(loadResourceString(caption)); } String description = element.attributeValue("description"); if (StringUtils.isNotEmpty(description)) { targetAction.setDescription(loadResourceString(description)); } String icon = element.attributeValue("icon"); if (StringUtils.isNotEmpty(icon)) { targetAction.setIcon(getIconPath(icon)); } String enable = element.attributeValue("enable"); if (StringUtils.isNotEmpty(enable)) { targetAction.setEnabled(Boolean.parseBoolean(enable)); } String visible = element.attributeValue("visible"); if (StringUtils.isNotEmpty(visible)) { targetAction.setVisible(Boolean.parseBoolean(visible)); } String shortcut = trimToNull(element.attributeValue("shortcut")); if (shortcut != null) { targetAction.setShortcut(loadShortcut(shortcut)); } }
validator = new ScriptValidator(validatorElement, getMessagesPack()); } else { Class aClass = getScripting().loadClass(className); if (aClass == null) throw new GuiDevelopmentException(String.format("Class %s is not found", className), context.getFullFrameId()); if (!StringUtils.isBlank(getMessagesPack())) try { validator = (Field.Validator) ReflectionHelper.newInstance(aClass, validatorElement, getMessagesPack()); } catch (NoSuchMethodException e) {
Class<Config> configClass = (Class<Config>) getScripting().loadClass(fqnConfigName); if (configClass != null) { Config config = getConfiguration().getConfig(configClass);
protected String loadThemeString(String value) { if (value != null && value.startsWith(ThemeConstants.PREFIX)) { value = getTheme().get(value.substring(ThemeConstants.PREFIX.length())); } return value; }
protected void loadIcon(Component.HasIcon component, Element element) { if (element.attribute("icon") != null) { String icon = element.attributeValue("icon"); component.setIcon(getIconPath(icon)); } }
protected ComponentLoader getLoader(Element element, String name) { Class<? extends ComponentLoader> loaderClass = layoutLoaderConfig.getLoader(name); if (loaderClass == null) { throw new GuiDevelopmentException("Unknown component: " + name, context.getFullFrameId()); } return getLoader(element, loaderClass); }
Class<?> aClass = getScripting().loadClass(className); if (aClass == null) { throw new GuiDevelopmentException(String.format("Class %s is not found", className), context.getFullFrameId());
@SuppressWarnings("unchecked") protected void loadContainer(T component, Element element) { String containerId = element.attributeValue("dataContainer"); String property = element.attributeValue("property"); // In case a component has only a property, // we try to obtain `dataContainer` from a parent element. // For instance, a component is placed within the Form component if (Strings.isNullOrEmpty(containerId) && property != null) { containerId = getParentDataContainer(element); } if (!Strings.isNullOrEmpty(containerId)) { if (property == null) { throw new GuiDevelopmentException( String.format("Can't set container '%s' for component '%s' because 'property' " + "attribute is not defined", containerId, component.getId()), context.getFullFrameId()); } FrameOwner frameOwner = context.getFrame().getFrameOwner(); ScreenData screenData = UiControllerUtils.getScreenData(frameOwner); InstanceContainer container = screenData.getContainer(containerId); if (component instanceof HasValueSource) { ((HasValueSource) component).setValueSource(new ContainerValueSource<>(container, property)); } } }
protected boolean loadVisible(Component component, Element element) { if (component instanceof DatasourceComponent && ((DatasourceComponent) component).getDatasource() != null) { DatasourceComponent wiredComponent = (DatasourceComponent) component; MetaClass metaClass = wiredComponent.getDatasource().getMetaClass(); MetaPropertyPath propertyPath = wiredComponent.getMetaPropertyPath(); if (propertyPath != null && !getSecurity().isEntityAttrReadPermitted(metaClass, propertyPath.toString())) { component.setVisible(false); return false; } } String visible = element.attributeValue("visible"); if (StringUtils.isNotEmpty(visible)) { boolean visibleValue = Boolean.parseBoolean(visible); component.setVisible(visibleValue); return visibleValue; } return true; }
@Deprecated protected Field.Validator getDefaultValidator(MetaProperty property) { Field.Validator validator = null; if (property.getRange().isDatatype()) { Messages messages = getMessages(); Class type = property.getRange().asDatatype().getJavaClass(); if (type.equals(Integer.class)) { validator = new IntegerValidator(messages.getMainMessage("validation.invalidNumber")); } else if (type.equals(Long.class)) { validator = new LongValidator(messages.getMainMessage("validation.invalidNumber")); } else if (type.equals(Double.class) || type.equals(BigDecimal.class)) { validator = new DoubleValidator(messages.getMainMessage("validation.invalidNumber")); } else if (type.equals(java.sql.Date.class)) { validator = new DateValidator(messages.getMainMessage("validation.invalidDate")); } } return validator; }
protected int loadThemeInt(String value) { if (value != null && value.startsWith(ThemeConstants.PREFIX)) { value = getTheme().get(value.substring(ThemeConstants.PREFIX.length())); } return value == null ? 0 : Integer.parseInt(value); }