Package reportgen.math.reference.objectfield

Source Code of reportgen.math.reference.objectfield.ObjPropertyContextGroup

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package reportgen.math.reference.objectfield;

import java.awt.Window;
import java.util.List;
import javax.swing.ListCellRenderer;
import reportgen.prototype.context.Context;
import reportgen.prototype.context.group.ContextGroupTitled;
import reportgen.prototype.context.group.ExpressionEditorPanel;
import reportgen.prototype.entity.QEntity;
import reportgen.prototype.entity.QEntityProperty;
import reportgen.math.reference.MathExpressionSubOptionPanel;
import reportgen.math.reference.field.EntityProperyRenderer;

/**
*
* @author axe
*/
public class ObjPropertyContextGroup extends ContextGroupTitled<MathExpressionEntityObjectFieldRef> {

    public ObjPropertyContextGroup() {
        super(null, "Объектное свойство");
    }

    @Override
    protected ExpressionEditorPanel getPanel(Window parent, Context context, MathExpressionEntityObjectFieldRef expression) {
        return new MathExpressionSubOptionPanel
            <QEntity, QEntityProperty, MathExpressionEntityObjectFieldRef>(parent, context, expression) {

            private ListCellRenderer cr = new EntityProperyRenderer();

            @Override
            protected List getSubOptions(QEntity type) {
                //fixme: redefine context?
                return context.getProperties(ObjPropertyContextGroup.this, type);
            }

            @Override
            protected QEntity getOption(MathExpressionEntityObjectFieldRef expression) {
                return expression.getRef().getEntity();
            }

            @Override
            protected QEntityProperty getSubValue(MathExpressionEntityObjectFieldRef expression) {
                return expression.getRef();
            }

            @Override
            protected MathExpressionEntityObjectFieldRef initNew(QEntityProperty option) {
                return new MathExpressionEntityObjectFieldRef(option, context);
            }
            @Override
            protected ListCellRenderer getValueCellRendeder() {
                return cr;
            }

            @Override
            protected List<QEntity> getOptions(Context context) {
                return context.getEntities(ObjPropertyContextGroup.this);
            }

            @Override
            protected void update(QEntityProperty option) {
                me.setRef(option);
            }
        };
    }


}
TOP

Related Classes of reportgen.math.reference.objectfield.ObjPropertyContextGroup

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.