package org.minimalj.frontend.form.element;

import org.minimalj.frontend.editor.Editor.SimpleEditor;
import org.minimalj.frontend.form.Form;
import org.minimalj.util.CloneHelper;

public abstract class FormLookupFormElement<T> extends AbstractLookupFormElement<T> {

	public FormLookupFormElement(Object key, boolean editable) {
		super(key, editable);
	}

	@Override
	protected void lookup() {
		new ParserFormElementEditor().action();
	}

	@SuppressWarnings("unchecked")
	protected T createObject() {
		return getValue() != null ? CloneHelper.clone(getValue()) : (T) CloneHelper.newInstance(getProperty().getClazz());
	}

	protected abstract Form<T> createForm();

	public class ParserFormElementEditor extends SimpleEditor<T> {

		@Override
		public T createObject() {
			return FormLookupFormElement.this.createObject();
		}

		@Override
		public Form<T> createForm() {
			return FormLookupFormElement.this.createForm();
		}

		@Override
		protected T save(T object) {
			FormLookupFormElement.this.setValueInternal(object);
			return object;
		}
	}

}

@@ -172,16 +172,62 @@
 eHelper;
+%0Aimport org.minimalj.util.resources.Resources;
 %0A%0Apublic
@@ -602,17 +602,21 @@
 Value())
- 
+%0A%09%09%09%09
 : (T) Cl
@@ -683,103 +683,428 @@
 ted 
-abstract Form%3CT%3E createForm();%0A%0A%09public class ParserFormElementEditor extends SimpleEditor%3CT%3E %7B
+Object%5B%5D getNameArguments() %7B%0A%09%09Class%3C?%3E clazz = getProperty().getClazz();%0A%09%09String resourceName = Resources.getResourceName(clazz);%0A%09%09return new Object%5B%5D %7B Resources.getString(resourceName) %7D;%0A%09%7D%0A%0A%09protected abstract Form%3CT%3E createForm();%0A%0A%09public class ParserFormElementEditor extends SimpleEditor%3CT%3E %7B%0A%0A%09%09@Override%0A%09%09protected Object%5B%5D getNameArguments() %7B%0A%09%09%09return FormLookupFormElement.this.getNameArguments();%0A%09%09%7D
 %0A%0A%09%09

fix name of editor