com.google.gwt.core.ext.PropertyOracle Java Examples
The following examples show how to use
com.google.gwt.core.ext.PropertyOracle.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GssResourceGenerator.java From gss.gwt with Apache License 2.0 | 6 votes |
private Set<String> getPermutationsConditions(ResourceContext context, List<String> permutationAxes) { Builder<String> setBuilder = ImmutableSet.builder(); PropertyOracle oracle = context.getGeneratorContext().getPropertyOracle(); for (String permutationAxis : permutationAxes) { String propValue = null; try { SelectionProperty selProp = oracle.getSelectionProperty(null, permutationAxis); propValue = selProp.getCurrentValue(); } catch (BadPropertyValueException e) { try { ConfigurationProperty confProp = oracle.getConfigurationProperty(permutationAxis); propValue = confProp.getValues().get(0); } catch (BadPropertyValueException e1) { e1.printStackTrace(); } } if (propValue != null) { setBuilder.add(permutationAxis + ":" + propValue); } } return setBuilder.build(); }
Example #2
Source File: GssResourceGenerator.java From gss.gwt with Apache License 2.0 | 5 votes |
private String getObfuscationPrefix(PropertyOracle propertyOracle, ResourceContext context) throws BadPropertyValueException { String prefix = propertyOracle.getConfigurationProperty(KEY_OBFUSCATION_PREFIX) .getValues().get(0); if ("empty".equalsIgnoreCase(prefix)) { return ""; } else if ("default".equalsIgnoreCase(prefix)) { return getDefaultObfuscationPrefix(context); } return prefix; }
Example #3
Source File: ProductConfigGenerator.java From core with GNU Lesser General Public License v2.1 | 5 votes |
private String failFastGetProperty(PropertyOracle propertyOracle, String name) throws BadPropertyValueException { ConfigurationProperty property = propertyOracle.getConfigurationProperty(name); if (property != null) { List<String> values = property.getValues(); if (values != null && !values.isEmpty()) { return values.get(0); } else { throw new BadPropertyValueException("Missing configuration property '" + name + "'!"); } } else { throw new BadPropertyValueException("Missing configuration property '" + name + "'!"); } }
Example #4
Source File: ProductConfigGenerator.java From core with GNU Lesser General Public License v2.1 | 5 votes |
private String failSafeGetProperty(PropertyOracle propertyOracle, String name, String defaultValue) { String value = defaultValue; try { ConfigurationProperty property = propertyOracle.getConfigurationProperty(name); if (property != null) { List<String> values = property.getValues(); if (values != null && !values.isEmpty()) { value = values.get(0); } } } catch (BadPropertyValueException e) { // ignore and return defaul value } return value; }
Example #5
Source File: GeneratorContextStub.java From mvp4g with Apache License 2.0 | 4 votes |
public PropertyOracle getPropertyOracle() { return propertyOracle; }
Example #6
Source File: ProductConfigGenerator.java From core with GNU Lesser General Public License v2.1 | 4 votes |
private void generateMethods(final TreeLogger logger, SourceWriter sourceWriter, GeneratorContext context) throws Throwable { PropertyOracle propertyOracle = context.getPropertyOracle(); // console.profile - mandatory String consoleProfile = failFastGetProperty(propertyOracle, "console.profile"); sourceWriter.println("public ProductConfig.Profile getProfile() { "); sourceWriter.indent(); if ("product".equals(consoleProfile)) { sourceWriter.println("return ProductConfig.Profile.PRODUCT;"); } else if ("community".equals(consoleProfile)) { sourceWriter.println("return ProductConfig.Profile.COMMUNITY;"); } else { throw new BadPropertyValueException( "Invalid value for 'console.profile'. Valid values are 'community' or 'product'!"); } sourceWriter.outdent(); sourceWriter.println("}"); // console.core.version - mandatory String coreConsoleVersion = failFastGetProperty(propertyOracle, "console.core.version"); sourceWriter.println("public String getCoreVersion() { "); sourceWriter.indent(); sourceWriter.println("return \"%s\";", coreConsoleVersion); sourceWriter.outdent(); sourceWriter.println("}"); // hal.version - optional // If this is not built using the HAL release stream, this property is undefined String consoleVersion = failSafeGetProperty(propertyOracle, "hal.version", null); sourceWriter.println("public String getConsoleVersion() { "); sourceWriter.indent(); if (consoleVersion == null) { sourceWriter.println("return null;"); } else { sourceWriter.println("return \"%s\";", consoleVersion); } sourceWriter.outdent(); sourceWriter.println("}"); // getProductName() - delegates to the BootstrapContext sourceWriter.println("public String getProductName() { "); sourceWriter.indent(); sourceWriter.println("return org.jboss.as.console.client.Console.MODULES.getBootstrapContext().getProductName();"); sourceWriter.outdent(); sourceWriter.println("}"); // getProductVersion() - delegates to the BootstrapContext sourceWriter.println("public String getProductVersion() { "); sourceWriter.indent(); sourceWriter.println("return org.jboss.as.console.client.Console.MODULES.getBootstrapContext().getProductVersion();"); sourceWriter.outdent(); sourceWriter.println("}"); // supported locales LocaleUtils localeUtils = LocaleUtils.getInstance(logger, context.getPropertyOracle(), context); Set<GwtLocale> locales = localeUtils.getAllCompileLocales(); sourceWriter.println("public List<String> getLocales() { "); sourceWriter.indent(); sourceWriter.println("List<String> locales = new LinkedList<String>();"); for (GwtLocale locale : locales) { if (locale.getAsString() != null && locale.getAsString().length() != 0) { sourceWriter.println("locales.add(\"" + locale.getAsString() + "\");"); } } sourceWriter.println("return locales;"); sourceWriter.outdent(); sourceWriter.println("}"); }