codegen.presenter.vm Maven / Gradle / Ivy
Show all versions of tsl2.nano.h5 Show documentation
/*
* File: $HeadURL$
* Id : $Id$
*
* created by: Generated through velocity template (presenter.vm)
* created on: ----/--/-- (not filled with property 'time' to simplify version-diffs)
*
* ${copyright}
*/
package ${package};
#define($attKey) KEY_${util.toUpperCase(${att.Name})}#end
#define($attKeyTooltip) KEY_TOOLTIP_${util.toUpperCase(${att.Name})}#end
#define($attName) ATTR_${util.toUpperCase(${att.Name})}#end
import java.util.Collection;
import java.util.Hashtable;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.List;
//import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.graphics.Point;
import ${class.Clazz.CanonicalName};
import ${constClass};
import de.tsl2.nano.core.Messages;
import de.tsl2.nano.action.IAction;
import de.tsl2.nano.ui.presenter.DefaultPresenter;
import de.tsl2.nano.ui.presenter.IBeanController;
import de.tsl2.nano.ui.presenter.IBeanEditor;
import de.tsl2.nano.ui.presenter.IBeanLayout;
import de.tsl2.nano.ui.presenter.IBeanTableLayout;
import de.tsl2.nano.fielddescriptor.FieldDependency;
import de.tsl2.nano.fielddescriptor.FField;
import de.tsl2.nano.fielddescriptor.IComponentDescriptor;
import de.tsl2.nano.fielddescriptor.IFieldDescriptor;
import de.tsl2.nano.fielddescriptor.IFieldDependency;
import de.tsl2.nano.fielddescriptor.ListDescriptor;
import de.tsl2.nano.validator.MandatoryValidator;
import de.tsl2.nano.validator.AbstractValidator;
import de.tsl2.nano.validator.ObjectInListValidator;
import de.tsl2.nano.validator.ObjectInTableValidator;
import de.tsl2.nano.util.RegExpFormat;
import de.tsl2.nano.core.cls.BeanAttribute;
import de.tsl2.nano.component.StructuredComponent;
import de.tsl2.nano.component.binding.Observables;
/**
* Default presenter for bean ${class.Name}!
*
* Extend this class to create a presenter for your special view.
*
* Generated do not modify!!!
*
* No specific type will be used as generic to let the DefaultPresenter use a bean instance or its class!
* Please don't change that!
*
* @author ts 22.11.2008
* @version $Revision$
*/
public class ${class.Name}${postfix} extends DefaultPresenter implements ${class.Name}Beanconstant {
/**
* Constructor with specific bean data.
*
* @param data bean instance
*/
public ${class.Name}${postfix} (T data) {
this(data, new LinkedList());
}
/**
* Constructor with specific bean data.
*
* @param data bean instance
* @param attributeNameFilter attribute names to filter.
*/
public ${class.Name}${postfix} (T data, Collection attributeNameFilter) {
this(data, attributeNameFilter, false);
}
/**
* Constructor with specific bean data.
*
* @param data bean instance
* @param attributeNameFilter attribute names to filter.
* @param useInversFilter if true, only elements, that are not contained in the filter will be shown.
*/
public ${class.Name}${postfix} (T data, Collection attributeNameFilter,
boolean useInversFilter) {
super(data, attributeNameFilter, useInversFilter);
//if an attribute filter was defined, use its order
if (!useInversFilter && attributeNameFilter instanceof List && ((List) attributeNameFilter).size() > 0)
swapToFilterOrder();
}
/**
* {@inheritDoc}
*/
@Override
protected void init(T data) {
//create table columns
createColumns(null);
//dependencies between editors
createDependencies(null);
//create editors
createEditors(null);
}
/**
* {@inheritDoc}
*/
@Override
protected void createColumns(Collection beanAttributes) {
listDescriptor = new ListDescriptor();
//table informations
#foreach( $att in $class.Attributes)
if (!hideAttribute(${attName}))
listDescriptor.getColumnAttributes().put(Messages.getString(${attKey}), ${attName});
#end
}
/**
* {@inheritDoc}
*/
@Override
protected void createEditors(Collection beanAttributes) {
//editor descriptions
if (data != null) {
#foreach( $att in $class.Attributes)
if (!hideAttribute(${attName})) {
IComponentDescriptor e = new FField(${attKey}, data, ${attName},
${util.getFormatter(${att})},
useLabel ? Messages.getString(${attKey}) : "",
getStyle(null), Messages.getString(${attKeyTooltip}),
${util.getEditorTypeString(${att})},
${util.getValidator(${att})},
null, null, true, true);
editors.put(${attKey}, e);
if (FField.isListType(e)) {
// e.setDefaultValue(StructuredComponent.DEFAULT_FIRSTITEM);
}
}
#end
}
}
/**
* {@inheritDoc}
*/
@Override
public T save() {
${util.get("PERSIST_INSTANCE")}
return super.save();
}
/**
* {@inheritDoc}
*/
@Override
protected int getStyle(BeanAttribute beanAttribute) {
return SWT.NONE;
}
}