<commit_before>/*
 * Copyright 2003 - 2014 The eFaps Team
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * Revision:        $Rev$
 * Last Changed:    $Date$
 * Last Changed By: $Author$
 */

package org.efaps.ui.wicket.components.values;

import java.io.Serializable;

import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.model.Model;
import org.efaps.ui.wicket.models.cell.FieldConfiguration;
import org.efaps.ui.wicket.models.field.AbstractUIField;
import org.efaps.util.EFapsException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * TODO comment!
 *
 * @author The eFaps Team
 * @version $Id$
 * @param <T> Type extending Serializable
 */
public abstract class AbstractField<T extends Serializable>
    extends TextField<T>
    implements IFieldConfig, IUIField
{

    /**
     * Logging instance used in this class.
     */
    private static final Logger LOG = LoggerFactory.getLogger(AbstractField.class);

    /**
     * Needed for serialziation.
     */
    private static final long serialVersionUID = 1L;

    /**
     * FieldConfiguration for this field.
     */
    private final FieldConfiguration config;

    /**
     * value of this field.
     */
    private final AbstractUIField cellvalue;

    /**
     * @param _wicketId wicket id for this component
     * @param _model model for this component
     * @param _config Config
     * @throws EFapsException on error
     */
    @SuppressWarnings("unchecked")
    public AbstractField(final String _wicketId,
                         final Model<AbstractUIField> _model,
                         final FieldConfiguration _config)
        throws EFapsException
    {
        super(_wicketId, Model.of((T) _model.getObject().getValue().getEditValue(
                        _model.getObject().getParent().getMode())));
        this.config = _config;
        this.cellvalue = _model.getObject();
        this.add(new Validator<T>(this));
        setOutputMarkupId(true);
    }

    /**
     * @param _wicketId wicket id for this component
     * @param _config Config
     */
    public AbstractField(final String _wicketId,
                         final FieldConfiguration _config)
    {
        super(_wicketId);
        this.config = _config;
        this.cellvalue = null;
        setOutputMarkupId(true);
    }

    /**
     * Getter method for the instance variable {@link #config}.
     *
     * @return value of instance variable {@link #config}
     */
    protected FieldConfiguration getConfig()
    {
        return this.config;
    }

    /**
     * Getter method for the instance variable {@link #cellvalue}.<commit_msg>- webapp: field must have a valid Model<commit_after>/*
 * Copyright 2003 - 2014 The eFaps Team
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * Revision:        $Rev$
 * Last Changed:    $Date$
 * Last Changed By: $Author$
 */

package org.efaps.ui.wicket.components.values;

import java.io.Serializable;

import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.model.Model;
import org.efaps.ui.wicket.models.cell.FieldConfiguration;
import org.efaps.ui.wicket.models.field.AbstractUIField;
import org.efaps.util.EFapsException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * TODO comment!
 *
 * @author The eFaps Team
 * @version $Id$
 * @param <T> Type extending Serializable
 */
public abstract class AbstractField<T extends Serializable>
    extends TextField<T>
    implements IFieldConfig, IUIField
{

    /**
     * Logging instance used in this class.
     */
    private static final Logger LOG = LoggerFactory.getLogger(AbstractField.class);

    /**
     * Needed for serialziation.
     */
    private static final long serialVersionUID = 1L;

    /**
     * FieldConfiguration for this field.
     */
    private final FieldConfiguration config;

    /**
     * value of this field.
     */
    private final AbstractUIField cellvalue;

    /**
     * @param _wicketId wicket id for this component
     * @param _model model for this component
     * @param _config Config
     * @throws EFapsException on error
     */
    @SuppressWarnings("unchecked")
    public AbstractField(final String _wicketId,
                         final Model<AbstractUIField> _model,
                         final FieldConfiguration _config)
        throws EFapsException
    {
        super(_wicketId, Model.of((T) _model.getObject().getValue().getEditValue(
                        _model.getObject().getParent().getMode())));
        this.config = _config;
        this.cellvalue = _model.getObject();
        this.add(new Validator<T>(this));
        setOutputMarkupId(true);
    }

    /**
     * @param _wicketId wicket id for this component
     * @param _config Config
     */
    public AbstractField(final String _wicketId,
                         final FieldConfiguration _config)
    {
        super(_wicketId, Model.<T>of());
        this.config = _config;
        this.cellvalue = null;
        setOutputMarkupId(true);
    }

    /**
     * Getter method for the instance variable {@link #config}.
     *
     * @return value of instance variable {@link #config}
     */
    protected FieldConfiguration getConfig()
    {
        return this.config;
    }

    /**
     * Getter method for the instance variable {@link #cellvalue}.
{'fraction_non_alphanumeric': 0.09489843386571561, 'fraction_numerical': 0.0046518840130252755, 'mean_word_length': 2.6878216123499143, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4941420', 'n_tokens_mistral': 1818, 'n_tokens_neox': 1782, 'n_words': 547}