<commit_before>package org.orienteer.core.component.command.modal;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.form.AjaxButton;
import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.upload.FileUpload;
import org.apache.wicket.markup.html.form.upload.FileUploadField;
import org.apache.wicket.markup.html.panel.Panel;
import ru.ydn.wicket.wicketorientdb.model.SimpleNamingModel;

/**
 * For uploading file from modal window
 *
 */

public abstract class AbstractUploadFilePanel extends Panel{
	private static final long serialVersionUID = 1L;

	public AbstractUploadFilePanel(String id, final ModalWindow modal) {
		super(id);
		modal.setMinimalHeight(300);
		Form<?> uploadForm = new Form<Object>("uploadForm");
		final FileUploadField inputFile = new FileUploadField("inputFile");
		uploadForm.add(inputFile);
		uploadForm.add(new AjaxButton("loadFile",getLoadButtonTitle(),uploadForm)
		{
			private static final long serialVersionUID = 1L;

			@Override
			protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
				FileUpload file = inputFile.getFileUpload();
				onLoadFile(file);
//				error(getLocalizer().getString("errors.load.file.error", this));
				modal.close(target);
				onModalClose(target);
			}
			
		});
		add(uploadForm);		
	}
	public abstract SimpleNamingModel<String> getLoadButtonTitle();
	public abstract void onLoadFile(FileUpload file);
	
	public void onModalClose(AjaxRequestTarget target){
		//may be empty
	};
}
<commit_msg>Fix case if user not select file and click "submit"<commit_after>package org.orienteer.core.component.command.modal;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.form.AjaxButton;
import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.upload.FileUpload;
import org.apache.wicket.markup.html.form.upload.FileUploadField;
import org.apache.wicket.markup.html.panel.Panel;
import ru.ydn.wicket.wicketorientdb.model.SimpleNamingModel;

/**
 * For uploading file from modal window
 *
 */

public abstract class AbstractUploadFilePanel extends Panel{
	private static final long serialVersionUID = 1L;

	public AbstractUploadFilePanel(String id, final ModalWindow modal) {
		super(id);
		modal.setMinimalHeight(300);
		Form<?> uploadForm = new Form<Object>("uploadForm");
		final FileUploadField inputFile = new FileUploadField("inputFile");
		uploadForm.add(inputFile);
		uploadForm.add(new AjaxButton("loadFile",getLoadButtonTitle(),uploadForm)
		{
			private static final long serialVersionUID = 1L;

			@Override
			protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
				FileUpload file = inputFile.getFileUpload();
				if (file!=null){
					onLoadFile(file);
	//				error(getLocalizer().getString("errors.load.file.error", this));
					modal.close(target);
					onModalClose(target);
				}
			}
			
		});
		add(uploadForm);		
	}
	public abstract SimpleNamingModel<String> getLoadButtonTitle();
	public abstract void onLoadFile(FileUpload file);
	
	public void onModalClose(AjaxRequestTarget target){
		//may be empty
	};
}

{'fraction_non_alphanumeric': 0.11423390752493201, 'fraction_numerical': 0.0030220610456331218, 'mean_word_length': 5.1638733705772815, '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': '7327026', 'n_tokens_mistral': 1115, 'n_tokens_neox': 1017, 'n_words': 199}