Package reportgen.gui.genepanel.resultspanel

Source Code of reportgen.gui.genepanel.resultspanel.ResultTableFunctionEditor

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

package reportgen.gui.genepanel.resultspanel;

import reportgen.math.agregate.agregate.AggregateFunction;
import reportgen.utils.ReportException;
import java.awt.Component;
import javax.swing.DefaultCellEditor;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JComboBox;
import javax.swing.JTable;
import reportgen.ren.report.column.ReportResultColumn;
import reportgen.utils.Message;

/**
*
* @author axe
*/
class ResultTableFunctionEditor extends DefaultCellEditor {

    JComboBox combo;
   
    public ResultTableFunctionEditor() {
        super(new JComboBox());
        combo = (JComboBox) getComponent();
       
    }

    @Override
    public Component getTableCellEditorComponent(JTable table, Object value,
            boolean isSelected, int row, int column) {
        ResultsTableModel model = (ResultsTableModel) table.getModel();
        ReportResultColumn field = model.getField(row);

        combo.removeAllItems();
        try {
            Object[] options = field.getContext().getAggregFunctions(field.getCls()).toArray();
            combo.setModel(new DefaultComboBoxModel(options));
            combo.setSelectedItem(field.getFunction());
        } catch (ReportException ex) {
            combo.addItem(AggregateFunction.ASIS);
            Message.warning(combo, ex.getLocalizedMessage(), "Выражение составлено некорректно");
        }
       
        return super.getTableCellEditorComponent(table, value, isSelected, row, column);
    }


   
}
TOP

Related Classes of reportgen.gui.genepanel.resultspanel.ResultTableFunctionEditor

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.