|
|
@ -8,6 +8,7 @@ import javax.swing.JScrollPane; |
|
|
|
import javax.swing.JTable; |
|
|
|
import javax.swing.JTable; |
|
|
|
import javax.swing.border.LineBorder; |
|
|
|
import javax.swing.border.LineBorder; |
|
|
|
import javax.swing.border.TitledBorder; |
|
|
|
import javax.swing.border.TitledBorder; |
|
|
|
|
|
|
|
import javax.swing.table.DefaultTableModel; |
|
|
|
|
|
|
|
|
|
|
|
public class ReportPane extends JPanel { |
|
|
|
public class ReportPane extends JPanel { |
|
|
|
private JPanel reportTablePane = new JPanel(); |
|
|
|
private JPanel reportTablePane = new JPanel(); |
|
|
@ -50,6 +51,71 @@ public class ReportPane extends JPanel { |
|
|
|
public void setReportData(Data data){ |
|
|
|
public void setReportData(Data data){ |
|
|
|
getReportTableModel().setData(data); |
|
|
|
getReportTableModel().setData(data); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void setReportHeader(Data report){ |
|
|
|
|
|
|
|
//настройка заголовков таблицы
|
|
|
|
|
|
|
|
System.out.println("настраиваем отображение заголовков таблицы отчетов ... "); |
|
|
|
|
|
|
|
reportTableModel = new ReportTableModel(report); |
|
|
|
|
|
|
|
System.out.println("reportTableModel.getColumnCount(): " + reportTableModel.getColumnCount()); |
|
|
|
|
|
|
|
System.out.println("reportTableModel.getHeader().length: " + reportTableModel.getHeader().length); |
|
|
|
|
|
|
|
reportTable = new JTable(reportTableModel); |
|
|
|
|
|
|
|
System.out.println("reportTable.getColumnModel().getColumnCount(): " + reportTable.getColumnModel().getColumnCount()); |
|
|
|
|
|
|
|
int j = 0; |
|
|
|
|
|
|
|
while (j < getReportTableModel().getHeader().length){ |
|
|
|
|
|
|
|
getReportTable().getColumnModel().getColumn(j).setHeaderValue(getReportTableModel().getHeader()[j]); |
|
|
|
|
|
|
|
System.out.println(j + " Заголовок модели: " + getReportTableModel().getHeader()[j]); |
|
|
|
|
|
|
|
System.out.println("Заголовок таблицы: " + getReportTable().getColumnName(j)); |
|
|
|
|
|
|
|
j++; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//getReportTableModel().fireTableStructureChanged();
|
|
|
|
|
|
|
|
//getReportTableModel().fireTableDataChanged();
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* формирование таблицы с новым отчетом |
|
|
|
|
|
|
|
* обработка заголовков таблицы и данных в одном методе, |
|
|
|
|
|
|
|
* замещаем методы: |
|
|
|
|
|
|
|
* setReportHeader() |
|
|
|
|
|
|
|
* setReportData() |
|
|
|
|
|
|
|
* setReportContent() |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param report |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public void updateReport(Data report){ |
|
|
|
|
|
|
|
//подготовка новой модели данных для отображения в таблице
|
|
|
|
|
|
|
|
System.out.println("подготовка новой модели данных для отображения в таблице отчета ... "); |
|
|
|
|
|
|
|
setReportTableModel(new ReportTableModel(report)); |
|
|
|
|
|
|
|
DefaultTableModel dm = new DefaultTableModel(getReportTableModel().getData(), getReportTableModel().getHeader()); |
|
|
|
|
|
|
|
getReportTable().setModel(dm); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//отображение в таблице отчета по тегу
|
|
|
|
|
|
|
|
//System.out.println("отображение в таблице отчета по тегу " + " ... ");
|
|
|
|
|
|
|
|
//setReportTable(new JTable(getReportTableModel()));
|
|
|
|
|
|
|
|
getReportTable().revalidate(); |
|
|
|
|
|
|
|
//отображение заголовков таблицы
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|
|
|
int j = 0; |
|
|
|
|
|
|
|
while (j < getReportTableModel().getHeader().length){ |
|
|
|
|
|
|
|
getReportTable().getColumnModel().getColumn(j).setHeaderValue(getReportTableModel().getHeader()[j]); |
|
|
|
|
|
|
|
j++; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
//getReportTableModel().toConsole();
|
|
|
|
|
|
|
|
putTableToConsole(getReportTable()); |
|
|
|
|
|
|
|
getReportTableModel().fireTableDataChanged();//оповещаем об изменении данных
|
|
|
|
|
|
|
|
getReportTableModel().fireTableStructureChanged();//оповещаем об изменении структуры модели-таблицы!!!
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public void setReportContent(Data report){ |
|
|
|
|
|
|
|
//устанавливаем заголовки
|
|
|
|
|
|
|
|
setReportHeader(report); |
|
|
|
|
|
|
|
//устанавливаем данные
|
|
|
|
|
|
|
|
setReportData(report); |
|
|
|
|
|
|
|
getReportTableModel().fireTableStructureChanged();//оповещаем об изменении структуры модели-таблицы!!!
|
|
|
|
|
|
|
|
getReportTableModel().fireTableDataChanged();//оповещаем об изменении данных
|
|
|
|
|
|
|
|
//getReportTable().repaint();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
public void setupReportTextPane(){} |
|
|
|
public void setupReportTextPane(){} |
|
|
|
public void setupReportSettingsPane(){} |
|
|
|
public void setupReportSettingsPane(){} |
|
|
|
/** |
|
|
|
/** |
|
|
@ -58,5 +124,45 @@ public class ReportPane extends JPanel { |
|
|
|
public ReportTableModel getReportTableModel() { |
|
|
|
public ReportTableModel getReportTableModel() { |
|
|
|
return reportTableModel; |
|
|
|
return reportTableModel; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* @param reportTableModel the reportTableModel to set |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public void setReportTableModel(ReportTableModel reportTableModel) { |
|
|
|
|
|
|
|
this.reportTableModel = reportTableModel; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* @param reportTable the reportTable to set |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public void setReportTable(JTable reportTable) { |
|
|
|
|
|
|
|
this.reportTable = reportTable; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* @return the reportTable |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public JTable getReportTable() { |
|
|
|
|
|
|
|
return reportTable; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public void putTableToConsole(JTable table){ |
|
|
|
|
|
|
|
//Данные таблицы в консоль
|
|
|
|
|
|
|
|
//table.getModel();
|
|
|
|
|
|
|
|
//заголовки
|
|
|
|
|
|
|
|
int i = 0; |
|
|
|
|
|
|
|
while (i < table.getModel().getColumnCount()){ |
|
|
|
|
|
|
|
System.out.print(table.getModel().getColumnName(i) + " "); |
|
|
|
|
|
|
|
i++; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
System.out.println(); |
|
|
|
|
|
|
|
//данные
|
|
|
|
|
|
|
|
i = 0; |
|
|
|
|
|
|
|
while (i < table.getModel().getRowCount()){ |
|
|
|
|
|
|
|
int j = 0; |
|
|
|
|
|
|
|
while (j < table.getModel().getColumnCount()){ |
|
|
|
|
|
|
|
System.out.print(table.getModel().getValueAt(i, j) + " "); |
|
|
|
|
|
|
|
j++; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
System.out.println(); |
|
|
|
|
|
|
|
i++; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|