/*
* Copyright (C) 2014 GG-Net GmbH - Oliver Günther
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package eu.ggnet.dwoss.report.returns;
import java.awt.BorderLayout;
import org.jdesktop.beansbinding.AutoBinding;
import org.metawidget.swing.SwingMetawidget;
import eu.ggnet.dwoss.report.ReportLineUtil;
import eu.ggnet.dwoss.report.entity.ReportLine;
import eu.ggnet.dwoss.util.MetawidgetConfig;
/**
*
* @author bastian.venz
*/
//////////////////////////////////////////////////////////////////////////////////////////////////////
// //
// TODO/FIXME: This class just sucks, do not try to enhance it, just fix small bugs or reimplement. //
// //
//////////////////////////////////////////////////////////////////////////////////////////////////////
public class TableAndSumViewCask extends javax.swing.JPanel {
// TODO: remove model hier.
protected ReportTableModel model;
/**
* This Cask has 5 textFields and labels that are counted up and are setted with default names.
* - sumCp
* - sumVk
* - sumEk
* -sumMargin
* -sumPercentCp
*/
public TableAndSumViewCask() {
initComponents();
reportLineTable.setAutoCreateRowSorter(true);
}
public ReportTableModel getModel() {
return model;
}
/**
* Set the {@link AbstractTableAndSumTableModel} to the Table in the Cask.
* <p/>
* @param model that will be the TableModel.
*/
public void setModel(ReportTableModel model) {
this.model = model;
reportLineTable.setModel(model);
SwingMetawidget mw = MetawidgetConfig.builder().updateStrategy(AutoBinding.UpdateStrategy.READ_WRITE).numberOfColums(6).readOnly(true).build();
mw.setToInspect(model.getSummary());
summaryPanel.add(mw, BorderLayout.CENTER);
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jScrollPane1 = new javax.swing.JScrollPane();
reportLineTable = new javax.swing.JTable();
summaryPanel = new javax.swing.JPanel();
setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
setLayout(new java.awt.BorderLayout());
reportLineTable.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
reportLineTableMouseClicked(evt);
}
});
jScrollPane1.setViewportView(reportLineTable);
add(jScrollPane1, java.awt.BorderLayout.CENTER);
summaryPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());
summaryPanel.setPreferredSize(new java.awt.Dimension(20, 28));
summaryPanel.setLayout(new java.awt.BorderLayout());
add(summaryPanel, java.awt.BorderLayout.SOUTH);
}// </editor-fold>//GEN-END:initComponents
private void reportLineTableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_reportLineTableMouseClicked
if ( evt.getClickCount() != 2 ) return;
int convertRowIndexToModel = reportLineTable.convertRowIndexToModel(reportLineTable.getSelectedRow());
ReportLine rl = model.getLines().get(convertRowIndexToModel).getReportLine();
ReportLineUtil.show(this, rl);
}//GEN-LAST:event_reportLineTableMouseClicked
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTable reportLineTable;
private javax.swing.JPanel summaryPanel;
// End of variables declaration//GEN-END:variables
}