<commit_before>package com.inepex.ineForm.client.form.widgets.upload;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.FileUpload;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.FormPanel;
import com.google.gwt.user.client.ui.FormPanel.SubmitCompleteEvent;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.Hidden;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.InlineLabel;
import com.google.gwt.user.client.ui.Label;
import com.inepex.ineForm.client.form.widgets.DenyingFormWidget;
import com.inepex.ineForm.shared.descriptorext.WidgetRDesc;
import com.inepex.inei18n.client.IneFormI18n_old;
import com.inepex.ineom.shared.descriptor.FDesc;
import com.inepex.ineom.shared.kvo.IFConsts;

public class FileUploadFw extends DenyingFormWidget {
	private static final String imageBaseUrl = "documents/";
	public static final String hasPreviewKey = "hasPreview";
	public static final String hasImageFinderKey = "withImageFinder";
	public static String customUploadUrl = "customUploadUrl";
	public static String customName = "name";

	private FlowPanel panelMain = new FlowPanel();
	private String uploadUrl = IFConsts.uploadServletUrl;
	private Image preview = new Image();
	private InlineLabel filename = new InlineLabel();
	private Button upload = new Button(IneFormI18n_old.imageuploadBtn());
	
	private ImageUploadPopup popup;
	
	private boolean withImageFinder = false;
	private boolean withPreview = false;
	
	private DefaultSearchParamProvider defaultSearchParamProvider;
	private String name = "fileupload";
	
	public interface DefaultSearchParamProvider {
		public String getDefaultSearchParam();
	}

	private class FileUploadForm extends FlexTable {
		private HTML title = new HTML("<h3>" + IneFormI18n_old.imagefinderUploadimage() + "</h3>");
		private FormPanel panelForm = new FormPanel();
		private FlowPanel panelInsideForm = new FlowPanel();
		private FileUpload fileupload = new FileUpload();
		private Button btnSubmit = new Button(IneFormI18n_old.imageuploadBtn());
		private Button btnCancel = new Button(IneFormI18n_old.CANCEL());
		private Label error = new Label();
		
		private FileUploadFw parent;
		
		public FileUploadForm(FileUploadFw parent) {
			this.parent = parent;
			addStyleName("FileUploadForm");
			setWidget(0, 0, title);
			setWidget(1, 0, panelForm);
			panelForm.add(fileupload);
			setWidget(2, 0, error);
			setWidget(3, 0, btnSubmit);
			setWidget(3, 1, btnCancel);
			getFlexCellFormatter().setColSpan(0, 0, 2);
			getFlexCellFormatter().setColSpan(1, 0, 2);
			getFlexCellFormatter().setColSpan(2, 0, 2);
			getCellFormatter().setHorizontalAlignment(1, 1, HasHorizontalAlignment.ALIGN_RIGHT);

			btnSubmit.addClickHandler(new ClickHandler() {

				@Override
				public void onClick(ClickEvent event) {
					btnSubmit.setEnabled(false);
					panelForm.submit();
				}
			});
			panelForm.setAction(uploadUrl);
			panelForm.setEncoding(FormPanel.ENCODING_MULTIPART);
			panelForm.setMethod(FormPanel.METHOD_POST);
			panelForm.setWidget(panelInsideForm);
			panelInsideForm.add(fileupload);
			panelInsideForm.add(new Hidden("name", name));
			fileupload.setName("file");
			
			panelForm
					.addSubmitCompleteHandler(new FormPanel.SubmitCompleteHandler() {
						public void onSubmitComplete(SubmitCompleteEvent event) {
							btnSubmit.setEnabled(true);
							if (event.getResults().equals("<pre>-1</pre>") || event.getResults().equals("-1")){
								error.setText(IneFormI18n_old.imageuploadInvalidFileFormat());<commit_msg>wizardpanel customization, fileupload customization, StringListBoxFw, example wizard<commit_after>package com.inepex.ineForm.client.form.widgets.upload;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.FileUpload;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.FormPanel;
import com.google.gwt.user.client.ui.FormPanel.SubmitCompleteEvent;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.Hidden;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.InlineLabel;
import com.google.gwt.user.client.ui.Label;
import com.inepex.ineForm.client.form.widgets.DenyingFormWidget;
import com.inepex.ineForm.shared.descriptorext.WidgetRDesc;
import com.inepex.inei18n.client.IneFormI18n_old;
import com.inepex.ineom.shared.descriptor.FDesc;
import com.inepex.ineom.shared.kvo.IFConsts;

public class FileUploadFw extends DenyingFormWidget {
	private static final String imageBaseUrl = "documents/";
	public static final String hasPreviewKey = "hasPreview";
	public static final String hasImageFinderKey = "withImageFinder";
	public static String customUploadUrl = "customUploadUrl";
	public static String customName = "name";

	private FlowPanel panelMain = new FlowPanel();
	private String uploadUrl = IFConsts.uploadServletUrl;
	private Image preview = new Image();
	private InlineLabel filename = new InlineLabel();
	private Button upload = new Button(IneFormI18n_old.imageuploadBtn());
	
	private ImageUploadPopup popup;
	
	private boolean withImageFinder = false;
	private boolean withPreview = false;
	
	private DefaultSearchParamProvider defaultSearchParamProvider;
	private String name = "fileupload";
	
	public interface DefaultSearchParamProvider {
		public String getDefaultSearchParam();
	}

	private class FileUploadForm extends FlexTable {
		private HTML title = new HTML("<h3>" + IneFormI18n_old.imagefinderUploadimage() + "</h3>");
		private FormPanel panelForm = new FormPanel();
		private FlowPanel panelInsideForm = new FlowPanel();
		private FileUpload fileupload = new FileUpload();
		private Button btnSubmit = new Button(IneFormI18n_old.imageuploadBtn());
		private Button btnCancel = new Button(IneFormI18n_old.CANCEL());
		private Label error = new Label();
		
		private FileUploadFw parent;
		
		public FileUploadForm(FileUploadFw parent) {
			this.parent = parent;
			addStyleName("FileUploadForm");
			setWidget(0, 0, title);
			setWidget(1, 0, panelForm);
			panelForm.add(fileupload);
			setWidget(2, 0, error);
			setWidget(3, 0, btnSubmit);
			setWidget(3, 1, btnCancel);
			getFlexCellFormatter().setColSpan(0, 0, 2);
			getFlexCellFormatter().setColSpan(1, 0, 2);
			getFlexCellFormatter().setColSpan(2, 0, 2);
			getCellFormatter().setHorizontalAlignment(1, 1, HasHorizontalAlignment.ALIGN_RIGHT);

			btnSubmit.addClickHandler(new ClickHandler() {

				@Override
				public void onClick(ClickEvent event) {
					btnSubmit.setEnabled(false);
					panelForm.submit();
				}
			});
			panelForm.setAction(uploadUrl);
			panelForm.setEncoding(FormPanel.ENCODING_MULTIPART);
			panelForm.setMethod(FormPanel.METHOD_POST);
			panelForm.setWidget(panelInsideForm);
			panelInsideForm.add(fileupload);
			panelInsideForm.add(new Hidden("name", name));
			fileupload.setName("inefileupload");
			
			panelForm
					.addSubmitCompleteHandler(new FormPanel.SubmitCompleteHandler() {
						public void onSubmitComplete(SubmitCompleteEvent event) {
							btnSubmit.setEnabled(true);
							if (event.getResults().equals("<pre>-1</pre>") || event.getResults().equals("-1")){
								error.setText(IneFormI18n_old.imageuploadInvalidFileFormat());
{'fraction_non_alphanumeric': 0.11173533083645443, 'fraction_numerical': 0.009737827715355805, 'mean_word_length': 5.393455706304868, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3320284', 'n_tokens_mistral': 2768, 'n_tokens_neox': 2456, 'n_words': 477}