Package reportgen.math.generic.choose

Source Code of reportgen.math.generic.choose.MathExpressionDlg

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

package reportgen.math.generic.choose;

import java.awt.Window;
import reportgen.prototype.context.group.ExpressionEditorPanel;
import reportgen.math.ContextFilter;
import reportgen.math.MathExpression;
import reportgen.math.complex.emphases.MathExpressionEmphases;
import reportgen.math.reference.function.MathExpressionFunction;
import reportgen.utils.Message;
import reportgen.utils.ReportDialog;
import reportgen.utils.ReportException;

/**
*
* @author axe
*/
public abstract class MathExpressionDlg extends ReportDialog {

    protected ExpressionEditorPanel panel;
    protected final ContextFilter contextFilter;

    /**
     *
     * @param parent родительское окно
     * @param title заголовок диалога
     * @param context дочерний контекст
     * @param parentValue родительское значение
     */
    public MathExpressionDlg(Window parent, String title, ContextFilter contextFilter) {
        super(parent, title);
        this.contextFilter = contextFilter;
    }


    /**
     *
     * @return
     */
    public final MathExpression getValue() {
        if(panel == null) {
            return null;
        }
        return panel.getValue();
    }

    /**
     *
     */
    protected final void tryOK() {
        MathExpression val = getValue();
        if(val == null) {
            Message.warning(this, "Выберите один из вариантов");
        } else {
            try {
                if(!(val instanceof MathExpressionFunction)
                        && !(val instanceof MathExpressionEmphases)) {
                    val.validate();
                }
                setDlgResult(true);
                setVisible(false);
            } catch (ReportException ex) {
                Message.warning(this, ex);
            }
        }
    }
}
TOP

Related Classes of reportgen.math.generic.choose.MathExpressionDlg

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.