com.google.gwt.i18n.client.ConstantsWithLookup Java Examples

The following examples show how to use com.google.gwt.i18n.client.ConstantsWithLookup. 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: InitializeFormCreator.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 6 votes vote down vote up
public InitializeFormCreator(JField modelField) {
	this.modelField = modelField;
	this.fieldType = modelField.getType();

	Initialize initializeAnnotation = modelField.getAnnotation(Initialize.class);
	this.constantClassName = initializeAnnotation.constantsClass();
	if (ConstantsWithLookup.class.equals(this.constantClassName)) {
		this.constantClassName = null;
	}
	if (this.fieldType instanceof JParameterizedType) {
		JParameterizedType paramType = (JParameterizedType) this.fieldType;
		this.beanType = paramType.getTypeArgs()[0];
	} else {
		throw new RuntimeException("modelField can not be injected as Model");
	}
}
 
Example #2
Source File: MessageHelper.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 6 votes vote down vote up
public String findMessage(Class<?> propertyType, String key) {
	if (key == null) {
		return null;
	}
	Class<?> typeToLookup = propertyType == null ? Object.class : propertyType;
	String label = null;
	while (typeToLookup != null && label == null) {
		try {
			ConstantsWithLookup constants = this.constantRegistry.get(typeToLookup);
			if (constants != null) {
				label = constants.getString(key);
			}
		} catch (MissingResourceException exc) {
			label = null;
		}
		typeToLookup = typeToLookup.getSuperclass();
	}

	return label;
}
 
Example #3
Source File: InitializeFormCreator.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void initComposer(ClassSourceFileComposerFactory composerFactory) {
	composerFactory.addImport(GWT.class.getName());
	composerFactory.addImport(MessageHelper.class.getName());
	composerFactory.addImport(ConstantsWithLookup.class.getName());
	composerFactory.addImport(this.beanType.getQualifiedSourceName());
}
 
Example #4
Source File: SampleWebApp.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 4 votes vote down vote up
@EntryPointHandler
void onModuleStart() {
	SimpleErrorDisplayer errorDisplayer = new SimpleErrorDisplayer();
	errorDisplayer.setConstants((ConstantsWithLookup) GWT.create(ErrorConstants.class));
	ErrorManager.get().setErrorDisplayer(errorDisplayer);
}
 
Example #5
Source File: SimpleErrorDisplayer.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void setConstants(ConstantsWithLookup constants) {
	this.constants = constants;
}
 
Example #6
Source File: AbstractStatusCodeErrorHandler.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 4 votes vote down vote up
public AbstractStatusCodeErrorHandler(ConstantsWithLookup constants, String constantsPrefix) {
	this.constants = constants;
	this.constantsPrefix = constantsPrefix;
}
 
Example #7
Source File: AbstractStatusCodeErrorHandler.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 4 votes vote down vote up
protected ConstantsWithLookup getConstants() {
	return this.constants;
}
 
Example #8
Source File: MessageHelper.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 4 votes vote down vote up
public MessageHelper(ConstantsWithLookup defaultConstants) {
	if (defaultConstants != null) {
		this.registerConstants(defaultConstants, Object.class);
	}
}
 
Example #9
Source File: MessageHelper.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void registerConstants(ConstantsWithLookup constants, Class<?> propertyType) {
	if (constants != null) {
		this.constantRegistry.put(propertyType == null ? Object.class : propertyType, constants);
	}
}