// Path: impl/src/main/java/br/gov/frameworkdemoiselle/vaadin/configuration/VaadinConfig.java
// @Configuration(prefix = "frameworkdemoiselle.vaadin")
// public class VaadinConfig {
// 
// 	@Name("upload.path")
// 	private String uploadPath = "/tmp/";
// 
// 	public String getUploadPath() {
// 		return uploadPath;
// 	}
// 
// }


import java.io.File;
import java.util.ResourceBundle;
import org.vaadin.easyuploads.FileFactory;
import org.vaadin.easyuploads.UploadField;
import org.vaadin.easyuploads.UploadField.FieldType;
import org.vaadin.easyuploads.UploadField.StorageMode;
import br.gov.frameworkdemoiselle.util.Beans;
import br.gov.frameworkdemoiselle.util.Strings;
import br.gov.frameworkdemoiselle.vaadin.configuration.VaadinConfig;
import com.vaadin.data.Property.ValueChangeListener;
import com.vaadin.ui.CheckBox;
import com.vaadin.ui.ComboBox;
import com.vaadin.ui.Field;
import com.vaadin.ui.OptionGroup;
import com.vaadin.ui.PasswordField;
import com.vaadin.ui.PopupDateField;
import com.vaadin.ui.RichTextArea;
import com.vaadin.ui.TextArea;
import com.vaadin.ui.TextField;
		setBasicProperties(field, caption);
		return field;
	}

	private static void setBasicProperties(Field field, String caption) {
		ResourceBundle bundle = Beans.getReference(ResourceBundle.class);
		if (Strings.isResourceBundleKeyFormat(caption)) {
			field.setCaption(bundle.getString(Strings.removeBraces(caption)));
		} else {
			field.setCaption(caption);
		}
	}

	private static String resolveProperties(final String message) {
		ResourceBundle bundle = Beans.getReference(ResourceBundle.class);
		String result = message;
		if (Strings.isResourceBundleKeyFormat(message)) {
			result = bundle.getString(Strings.removeBraces(message));
		}
		return result;
	}

	public static UploadField createFileField(String caption, String buttonCaption) {
		UploadField field = new UploadField();
		field.setFieldType(FieldType.BYTE_ARRAY);
		field.setCaption(resolveProperties(caption));
		field.setButtonCaption(resolveProperties(buttonCaption));
		field.setStorageMode(StorageMode.MEMORY);
		field.setFileFactory(new FileFactory() {

// Path: impl/src/main/java/br/gov/frameworkdemoiselle/vaadin/configuration/VaadinConfig.java
// @Configuration(prefix = "frameworkdemoiselle.vaadin")
// public class VaadinConfig {
// 
// 	@Name("upload.path")
// 	private String uploadPath = "/tmp/";
// 
// 	public String getUploadPath() {
// 		return uploadPath;
// 	}
// 
// }


// Path: impl/src/main/java/br/gov/frameworkdemoiselle/vaadin/util/FieldFactory.java
import java.io.File;
import java.util.ResourceBundle;
import org.vaadin.easyuploads.FileFactory;
import org.vaadin.easyuploads.UploadField;
import org.vaadin.easyuploads.UploadField.FieldType;
import org.vaadin.easyuploads.UploadField.StorageMode;
import br.gov.frameworkdemoiselle.util.Beans;
import br.gov.frameworkdemoiselle.util.Strings;
import br.gov.frameworkdemoiselle.vaadin.configuration.VaadinConfig;
import com.vaadin.data.Property.ValueChangeListener;
import com.vaadin.ui.CheckBox;
import com.vaadin.ui.ComboBox;
import com.vaadin.ui.Field;
import com.vaadin.ui.OptionGroup;
import com.vaadin.ui.PasswordField;
import com.vaadin.ui.PopupDateField;
import com.vaadin.ui.RichTextArea;
import com.vaadin.ui.TextArea;
import com.vaadin.ui.TextField;

		setBasicProperties(field, caption);
		return field;
	}

	private static void setBasicProperties(Field field, String caption) {
		ResourceBundle bundle = Beans.getReference(ResourceBundle.class);
		if (Strings.isResourceBundleKeyFormat(caption)) {
			field.setCaption(bundle.getString(Strings.removeBraces(caption)));
		} else {
			field.setCaption(caption);
		}
	}

	private static String resolveProperties(final String message) {
		ResourceBundle bundle = Beans.getReference(ResourceBundle.class);
		String result = message;
		if (Strings.isResourceBundleKeyFormat(message)) {
			result = bundle.getString(Strings.removeBraces(message));
		}
		return result;
	}

	public static UploadField createFileField(String caption, String buttonCaption) {
		UploadField field = new UploadField();
		field.setFieldType(FieldType.BYTE_ARRAY);
		field.setCaption(resolveProperties(caption));
		field.setButtonCaption(resolveProperties(buttonCaption));
		field.setStorageMode(StorageMode.MEMORY);
		field.setFileFactory(new FileFactory() {

			VaadinConfig config = Beans.getReference(VaadinConfig.class);