esoe
3 years ago
13 changed files with 226 additions and 132 deletions
@ -0,0 +1,130 @@ |
|||||||
|
package ru.egspt; |
||||||
|
|
||||||
|
import java.awt.Color; |
||||||
|
import java.awt.BorderLayout; |
||||||
|
|
||||||
|
import javax.swing.JButton; |
||||||
|
import javax.swing.JPanel; |
||||||
|
import javax.swing.JScrollPane; |
||||||
|
import javax.swing.JTable; |
||||||
|
import javax.swing.border.LineBorder; |
||||||
|
import javax.swing.border.TitledBorder; |
||||||
|
|
||||||
|
public class DataPane extends JPanel{ |
||||||
|
private JPanel controlPane = new JPanel();//панель кнопок - пока не надо
|
||||||
|
private JButton generateXLSXButton = new JButton("create xlsx"); |
||||||
|
private JButton generateTXTButton = new JButton("create txt"); |
||||||
|
private JPanel usersPane = new JPanel();//панель пользователей
|
||||||
|
private JPanel quizesPane = new JPanel();//панель опросов
|
||||||
|
private JPanel resultsPane = new JPanel();//панель результатов
|
||||||
|
private JTable usersTable; |
||||||
|
private JTable quizesTable; |
||||||
|
private JTable resultsTable; |
||||||
|
private UsersTableModel usersTableModel; |
||||||
|
private QuizesTableModel quizesTableModel; |
||||||
|
private ResultsTableModel resultsTableModel; |
||||||
|
public DataPane(){} |
||||||
|
public DataPane(App app){ |
||||||
|
setupUsersPane(app); |
||||||
|
setupQuizesPane(app); |
||||||
|
setupResultsPane(app); |
||||||
|
} |
||||||
|
public void init(){ |
||||||
|
this.setupControlPane(); |
||||||
|
this.setLayout(new BorderLayout()); |
||||||
|
this.add(controlPane, BorderLayout.NORTH); |
||||||
|
this.add(usersPane, BorderLayout.WEST); |
||||||
|
this.add(quizesPane, BorderLayout.CENTER); |
||||||
|
this.add(resultsPane, BorderLayout.EAST); |
||||||
|
TitledBorder border = new TitledBorder(new LineBorder(Color.black), "data", TitledBorder.CENTER, TitledBorder.CENTER); |
||||||
|
this.setBorder(border); |
||||||
|
this.setVisible(true); |
||||||
|
} |
||||||
|
public void setupControlPane(){ |
||||||
|
controlPane.add(generateXLSXButton); |
||||||
|
controlPane.add(generateTXTButton); |
||||||
|
TitledBorder border = new TitledBorder(new LineBorder(Color.black), "ControlPane", TitledBorder.CENTER, TitledBorder.CENTER); |
||||||
|
controlPane.setBorder(border); |
||||||
|
} |
||||||
|
/** |
||||||
|
* Настройка панели пользователей |
||||||
|
*/ |
||||||
|
public void setupUsersPane(App app){ |
||||||
|
usersTableModel = new UsersTableModel(app.getData()); |
||||||
|
usersTable = new JTable(usersTableModel); |
||||||
|
//настройка заголовков
|
||||||
|
int i = 0; |
||||||
|
while (i < usersTable.getColumnCount()){ |
||||||
|
usersTable.getColumnModel().getColumn(i).setHeaderValue(usersTableModel.getHeader()[i]); |
||||||
|
i++; |
||||||
|
} |
||||||
|
JScrollPane scrollPane = new JScrollPane(usersTable, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); |
||||||
|
usersPane.setLayout(new BorderLayout()); |
||||||
|
usersPane.add(scrollPane); |
||||||
|
usersPane.add(app.getTagPane(), BorderLayout.NORTH);//добавили панель тегов
|
||||||
|
TitledBorder border = new TitledBorder(new LineBorder(Color.black), "Users", TitledBorder.CENTER, TitledBorder.CENTER); |
||||||
|
usersPane.setBorder(border); |
||||||
|
} |
||||||
|
/** |
||||||
|
* Настройка панели опросов |
||||||
|
*/ |
||||||
|
public void setupQuizesPane(App app){ |
||||||
|
quizesTableModel = new QuizesTableModel(app.getData()); |
||||||
|
quizesTable = new JTable(quizesTableModel); |
||||||
|
//настройка заголовков
|
||||||
|
int i = 0; |
||||||
|
while (i < quizesTable.getColumnCount()){ |
||||||
|
quizesTable.getColumnModel().getColumn(i).setHeaderValue(quizesTableModel.getHeader()[i]); |
||||||
|
i++; |
||||||
|
} |
||||||
|
JScrollPane scrollPane = new JScrollPane(quizesTable, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); |
||||||
|
quizesPane.setLayout(new BorderLayout()); |
||||||
|
quizesPane.add(scrollPane, BorderLayout.CENTER); |
||||||
|
TitledBorder border = new TitledBorder(new LineBorder(Color.black), "Quizes", TitledBorder.CENTER, TitledBorder.CENTER); |
||||||
|
quizesPane.setBorder(border); |
||||||
|
} |
||||||
|
/** |
||||||
|
* Настройка панели результатов |
||||||
|
*/ |
||||||
|
public void setupResultsPane(App app){ |
||||||
|
resultsTableModel = new ResultsTableModel(app.getData()); |
||||||
|
resultsTable = new JTable(resultsTableModel); |
||||||
|
//настройка заголовков
|
||||||
|
int i = 0; |
||||||
|
while (i < resultsTable.getColumnCount()){ |
||||||
|
resultsTable.getColumnModel().getColumn(i).setHeaderValue(resultsTableModel.getHeader()[i]); |
||||||
|
i++; |
||||||
|
} |
||||||
|
JScrollPane scrollPane = new JScrollPane(resultsTable, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); |
||||||
|
resultsPane.setLayout(new BorderLayout()); |
||||||
|
resultsPane.add(scrollPane, BorderLayout.CENTER); |
||||||
|
TitledBorder border = new TitledBorder(new LineBorder(Color.black), "Results", TitledBorder.CENTER, TitledBorder.CENTER); |
||||||
|
resultsPane.setBorder(border); |
||||||
|
} |
||||||
|
public void setQuizes(Data data){ |
||||||
|
getQuizesTableModel().setData(data); |
||||||
|
} |
||||||
|
|
||||||
|
public void setUsers(Data data){ |
||||||
|
getUsersTableModel().setData(data); |
||||||
|
} |
||||||
|
public void setResults(Data data){ |
||||||
|
getResultsTableModel().setData(data); |
||||||
|
} |
||||||
|
/** |
||||||
|
* @return the tableModel |
||||||
|
*/ |
||||||
|
public UsersTableModel getUsersTableModel() { |
||||||
|
return usersTableModel; |
||||||
|
} |
||||||
|
/** |
||||||
|
* @return the quizesTableModel |
||||||
|
*/ |
||||||
|
public QuizesTableModel getQuizesTableModel() { |
||||||
|
return quizesTableModel; |
||||||
|
} |
||||||
|
public ResultsTableModel getResultsTableModel() { |
||||||
|
return resultsTableModel; |
||||||
|
} |
||||||
|
|
||||||
|
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in new issue