From d24e3b908e53bf1d1a5584fd434df37c76b277e7 Mon Sep 17 00:00:00 2001 From: esoe Date: Fri, 3 Jun 2022 17:01:07 +0300 Subject: [PATCH] tables --- src/main/java/ru/egspt/App.java | 2 +- src/main/java/ru/egspt/BaseControls.java | 3 +-- src/main/java/ru/egspt/ReportPane.java | 12 +++++++----- src/main/java/ru/egspt/ReportTableModel.java | 16 ++++++++++++---- src/main/java/ru/egspt/TagControls.java | 5 ++++- target/classes/ru/egspt/App.class | Bin 2800 -> 2821 bytes target/classes/ru/egspt/BaseControls.class | Bin 2345 -> 2352 bytes target/classes/ru/egspt/ReportPane.class | Bin 2844 -> 2844 bytes .../classes/ru/egspt/ReportTableModel.class | Bin 3942 -> 4038 bytes target/classes/ru/egspt/TagControls.class | Bin 2086 -> 2086 bytes 10 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/main/java/ru/egspt/App.java b/src/main/java/ru/egspt/App.java index 3bc4719..e18ef9e 100644 --- a/src/main/java/ru/egspt/App.java +++ b/src/main/java/ru/egspt/App.java @@ -76,7 +76,7 @@ public class App extends JPanel{ } public static void main( String[] args ) { - System.out.println( "Работает подготовщик отчетов по результатам тестирования пользователей ..." ); + System.out.println( "Работает подготовщик отчетов по результатам тестирования пользователей App-moodle-anyreport ..." ); App anyreport = new App(); anyreport.initFrame(); anyreport.init(); diff --git a/src/main/java/ru/egspt/BaseControls.java b/src/main/java/ru/egspt/BaseControls.java index ee8d108..11a789d 100644 --- a/src/main/java/ru/egspt/BaseControls.java +++ b/src/main/java/ru/egspt/BaseControls.java @@ -22,9 +22,8 @@ public class BaseControls { app.getDataPane().setResults(app.getData()); app.getDataPane().setVisible(true); //данные в панель отчетов + app.getReportPane().setupReportTablePane(app.getData()); app.getReportPane().init(); - app.getReportPane().setReportData(app.getData()); - } public static void DisconnectFromServer(App app){ diff --git a/src/main/java/ru/egspt/ReportPane.java b/src/main/java/ru/egspt/ReportPane.java index 43a4b3b..4a263f1 100644 --- a/src/main/java/ru/egspt/ReportPane.java +++ b/src/main/java/ru/egspt/ReportPane.java @@ -16,9 +16,9 @@ public class ReportPane extends JPanel { private JPanel reportTextPane = new JPanel(); private JPanel reportSettingsPane = new JPanel(); - public ReportPane(){} + //панель по данным App public ReportPane(App app){ - setupReportTablePane(app); + setupReportTablePane(app.getData()); } public void init(){ this.setLayout(new BorderLayout()); @@ -29,15 +29,17 @@ public class ReportPane extends JPanel { this.setBorder(border); this.setVisible(true); } - public void setupReportTablePane(App app){ - reportTableModel = new ReportTableModel(app); + public void setupReportTablePane(Data report){ + reportTableModel = new ReportTableModel(report); reportTable = new JTable(reportTableModel); - //настройка заголовков + //настройка заголовков таблицы int i = 0; while (i < reportTableModel.getHeader().length){ reportTable.getColumnModel().getColumn(i).setHeaderValue(reportTableModel.getHeader()[i]); i++; } + reportTable.setAutoResizeMode(reportTable.AUTO_RESIZE_OFF); + JScrollPane scrollPane = new JScrollPane(reportTable, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); reportTablePane.setLayout(new BorderLayout()); reportTablePane.add(scrollPane); diff --git a/src/main/java/ru/egspt/ReportTableModel.java b/src/main/java/ru/egspt/ReportTableModel.java index bc6b3a3..bd59503 100644 --- a/src/main/java/ru/egspt/ReportTableModel.java +++ b/src/main/java/ru/egspt/ReportTableModel.java @@ -5,18 +5,20 @@ import java.util.ArrayList; import javax.swing.table.AbstractTableModel; public class ReportTableModel extends AbstractTableModel{ - private Object[] header;// = new String[]{"id", "login", "mail"}; + private Object[] header; private Object[][] data; + //создаем модель без данных public ReportTableModel(){} public ReportTableModel(Object[] header, Object[][] data){ setHeader(header); setData(data); } + //создаем модель по данным Data public ReportTableModel(Data data){ setHeader(getHeaderByQuize(data)); setData(data); } - + //создаем модель по данным предварительно переданным в App public ReportTableModel(App app){ setHeader(getHeaderByQuize(app.getData())); setData(app.getData()); @@ -62,7 +64,7 @@ public class ReportTableModel extends AbstractTableModel{ int i = 0; while (i < report.getQuizes().size()){ header.add(report.getQuizes().get(i).getName()); - System.out.println("Пишем заголовок: " + report.getQuizes().get(i).getName()); + //System.out.println("Пишем заголовок: " + report.getQuizes().get(i).getName()); header.add(""); i++; } @@ -86,6 +88,9 @@ public class ReportTableModel extends AbstractTableModel{ public void setData(Data report) { //создаем объект data - инициализация переменной Object[][] d = new Object[report.getUsers().size()][3 + 2*report.getQuizes().size()]; + System.out.println("Количество столбцов Object[][] d: " + (3 + 2*report.getQuizes().size())); + System.out.println("Количество строк Object[][] d: " + report.getUsers().size()); + //построчно заполняем модель отчета данными int userCurr = 0; while (userCurr < report.getUsers().size()){ @@ -115,13 +120,16 @@ public class ReportTableModel extends AbstractTableModel{ } //пишем строку в d int j = 0; - while (j < d[userCurr].length){ + while (j < string.size()){ + //while (j < 3){ d[userCurr][j] = string.toArray()[j]; j++; } + userCurr++; } this.data = d; + fireTableDataChanged(); } /** * @return the data diff --git a/src/main/java/ru/egspt/TagControls.java b/src/main/java/ru/egspt/TagControls.java index 3a57bf3..2cc2fd8 100644 --- a/src/main/java/ru/egspt/TagControls.java +++ b/src/main/java/ru/egspt/TagControls.java @@ -17,8 +17,10 @@ public class TagControls { app.getReportPane().getReportTableModel().setHeader(app.getReportPane().getReportTableModel().getHeaderByQuize(report)); //формирование данных в таблице app.getReportPane().getReportTableModel().setData(report); - //app.getReportPane().setupReportTablePane(app); + //app.getReportPane().setupReportTablePane(report); + //app.getReportPane() app.getReportPane().getReportTableModel().fireTableDataChanged(); + } //удаляем тег из модели public static void removeTag(App app){ @@ -34,6 +36,7 @@ public class TagControls { //app.getDataPane().setUsers(data); //app.getDataPane().getUsersTableModel().fireTableDataChanged(); app.getReportPane().setReportData(data); + //app.getReportPane().setupReportTablePane(app); app.getReportPane().getReportTableModel().fireTableDataChanged(); } } diff --git a/target/classes/ru/egspt/App.class b/target/classes/ru/egspt/App.class index 2386238263bb0c336a1df55c295befa97f4568c9..ebed3e19d4cac0026782ee0d7ea08895be8c530a 100644 GIT binary patch delta 39 vcmew$+A6l;8Y|=c$=6xiMH~wXbaV6bQ*u&u6Z0yIQVa5nN;b!`O=bZAJ-QEK delta 18 acmZn_`yjgE8Y^Shb%{`v-3T diff --git a/target/classes/ru/egspt/BaseControls.class b/target/classes/ru/egspt/BaseControls.class index ae979208ce509e921ac76d519a883963d1457e44..38e0b42b1daf1fef2769c2a91ce8cbb3aa3447b2 100644 GIT binary patch delta 97 zcmZ1}v_WVC4;$lz$-HcmiaZPx85$TFM2b^ON(+Kg3-XIfLK2g5QUen6Qn?uV7-}{< zu>D}<)7r)my^Wz4NOf*wm^9gqBZ&PdgA~IV2I(%WgMxh@(dgd3Jm-ViVWNg3=BLBj6hO=VKT!M OAkD}yA4oDWEC2xIT^cw5 diff --git a/target/classes/ru/egspt/ReportPane.class b/target/classes/ru/egspt/ReportPane.class index d7e1fad529e39c63038e01c8f901d213210d00e2..9cd003defb0a37f377ccd8914117d34da564e646 100644 GIT binary patch literal 2844 zcmai0Yg<%R6n;0uaAZ8lO;qG6l?{V3UJ%n!6HyZaG{zvb%mbWobeNfD&Inp*rQOT! z*|+RdU#lmFr+6NJK!2gX(o?-_?{Ve;KKX&!`|Q0g?^^F#YxCzne>?!thwm*^C^TmC zQFktv@uK5yCY|-pI4Rdcr9#7H=c=<9%`GHSbJ1ZrPAb%9wa{5-I_b)h!p4!caxsNE zpWtYER&-lNR=Ltv^d%M6`xMq#)sht2P!w_(HBN#w2XWW)2s39ORUJyC65bJo`f%Ch zKqeFGo=~V9B$^NcsJBsr28BSld!ib2X(Na#*=@41-t4y6uu&DlRd+bJ zNP5OePB__wq`r7q>0L_X6q?Fjjd@7}vlVbM8Ro2fD>+~WBs&&*s3_D$odqv?ES;To zvm?&6blwXgf_g#TYa@zX3e`kzu1I27^R1Q4*{G9p=G-ikyAFF4f@3VAOQPOqV;}kj z#_X&@w@+~}J)cRZ+>{qH#*z+8?DX_ycgCX`3(qKY_^WDKql=zRcu9BGK(%mCq3sbu zk~t$%jYBwM;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 1675 zcmZuxTTok76kR8;lUy$4F%6UsX^<%nk6;+4#SvmsAO0AB)lWyqFF%~|LtAj4n?eiIk7UkWd+)W^K6~AJ z-TwOq>4$~cc>tU6-K4b3V7A~eIyjD~cB57ALZ^Dav4FYN7Gr+w7=t}|IhpwBVsbip zwIDf@oJd|t&L`*SH$}hM>H-Nzaa@K4UIuINo-S99%jt9ZJY`qsTM5+&j)06H+8NA|K#E&J2oa93y1}&05fuV>ka|XZ zelt!nKte4ZlhKQE21D4}s|etXjI(OMFz7xngTpLgFP@fh5sgIbQ6dMzN+?V?$1@D+ zp{P^wgo6>MfF%rKNXB!5&Pb`d-4b5FOB^pUWZj;7w?CqIl#mP+FRSyWqK60Zs*Kk( z=D!3j}WNAxZONf=Q9IQjGx@f6q>(zScL1tIaOSNpHdR;nTDTNVb z#N$vmrWH%fOeF>~a7aCvc28`(qb!aFTO3W-&>Tl=96Ot*@aP?R zq$9gWWcKTsO=QGzdUP@2h~x1IVm6RqppwJ`55SCSWT1v5Zh;M3VaGNUl9e{&A+&U$ z4o9#ZodkAcCnW-}qR&w`oq{-qFg)mq!Ar0B3G%-WKT_y73jINWziIdXz|C}s zG9!A(x~EtUPP05Z7owLH;Sj698MYZ`HRrUG%V~*A&Y@GvIl0V^FKNL#BOmV0j`PDve{CleN-yUwh5M-$mbYf3uq$G zaSXE?FtY#9t@{^iZXk}jF^(5KBL Q+zpbJdK(zN(Xzh%A1S1el>h($ diff --git a/target/classes/ru/egspt/TagControls.class b/target/classes/ru/egspt/TagControls.class index 1d4757554073a78441366cd5a4719a3cc4d67b8e..a3e81930e2727451c754a8f24d5c9d28a129a713 100644 GIT binary patch delta 50 zcmZ1`uuNcsJ3Ffw!%PN=$v*7UWn~!n7~~iv859^)8I%}w8I&2E8PpiO88jF|88jzx Gr~v@-`v?O7 delta 50 zcmZ1`uuNcsJ3Ff=!%POT$v*7UWu+MS7-SeE8RQsL859_F859|u8B`d&fxJ)#wMiUm E0P$G|?f?J)