All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.efaps.admin.ui.field.FieldPicker Maven / Gradle / Ivy

/*
 * Copyright 2003 - 2012 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: 7483 $
 * Last Changed:    $Date: 2012-05-11 11:57:38 -0500 (Fri, 11 May 2012) $
 * Last Changed By: $Author: [email protected] $
 */


package org.efaps.admin.ui.field;

import org.efaps.admin.datamodel.Type;
import org.efaps.admin.ui.Command;
import org.efaps.ci.CIAdminUserInterface;
import org.efaps.util.EFapsException;


/**
 * TODO comment!
 *
 * @author The eFaps Team
 * @version $Id: FieldPicker.java 7483 2012-05-11 16:57:38Z [email protected] $
 */
public class FieldPicker
    extends Field
{
    /**
     * Command to be executed on the picker field.
     */
    private Command command;


    /**
     * @param _id       id of the field
     * @param _uuid     UUID of the field
     * @param _name     name of the field
     */
    public FieldPicker(final long _id,
                       final String _uuid,
                       final String _name)
    {
        super(_id, _uuid, _name);
    }

    /**
     * Getter method for the instance variable {@link #command}.
     *
     * @return value of instance variable {@link #command}
     */
    public Command getCommand()
    {
        return this.command;
    }

    /**
     *
     * Set a link property for the field.
     *
     * @param _linkType type of the link property
     * @param _toId to id
     * @param _toType to type
     * @param _toName to name
     * @throws EFapsException on error
     */
    @Override
    protected void setLinkProperty(final Type _linkType,
                                   final long _toId,
                                   final Type _toType,
                                   final String _toName)
        throws EFapsException
    {
        if (_linkType.isKindOf(CIAdminUserInterface.LinkField2Command.getType())) {
            this.command = Command.get(_toId);
        } else {
            super.setLinkProperty(_linkType, _toId, _toType, _toName);
        }
    }

    /**
     * Returns for given parameter _id the instance of class
     * {@link Field}.
     *
     * @param _id       id to search in the cache
     * @return instance of class {@link Field}
     */
    public static FieldPicker get(final long _id)
    {
        return (FieldPicker) Field.get(_id);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy