diff --git a/drow/model.drawio b/drow/model.drawio
new file mode 100644
index 0000000..e59c804
--- /dev/null
+++ b/drow/model.drawio
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/ru/egspt/moodle/Base.java b/src/main/java/ru/egspt/moodle/Base.java
index 1b7b70e..c6d9eec 100644
--- a/src/main/java/ru/egspt/moodle/Base.java
+++ b/src/main/java/ru/egspt/moodle/Base.java
@@ -42,7 +42,9 @@ public class Base {
public Base(){
-
+ users = new ArrayList<>();
+ results = new ArrayList<>();
+ quizes = new ArrayList<>();
}
/**
diff --git a/src/main/java/ru/egspt/moodle/UsersModel.java b/src/main/java/ru/egspt/moodle/UsersModel.java
new file mode 100644
index 0000000..d9b66a1
--- /dev/null
+++ b/src/main/java/ru/egspt/moodle/UsersModel.java
@@ -0,0 +1,82 @@
+package ru.egspt.moodle;
+
+import javax.swing.table.TableModel;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.swing.event.TableModelListener;
+
+public class UsersModel implements TableModel{
+ private Set listeners = new HashSet();
+ private List users;
+
+ public UsersModel(List users) {
+ this.users = users;
+ }
+
+ public void addTableModelListener(TableModelListener listener) {
+ listeners.add(listener);
+ }
+
+
+ public Class> getColumnClass(int columnIndex) {
+ switch (columnIndex) {
+ case 0:
+ return int.class;
+ case 1:
+ return String.class;
+ case 2:
+ return String.class;
+ }
+ return String.class;
+ }
+
+ public int getColumnCount() {
+ return 3;
+ }
+
+ public String getColumnName(int columnIndex) {
+ switch (columnIndex) {
+ case 0:
+ return "id";
+ case 1:
+ return "name";
+ case 2:
+ return "mail";
+ }
+ return "";
+ }
+
+ public int getRowCount() {
+ return users.size();
+ }
+
+ public Object getValueAt(int rowIndex, int columnIndex) {
+ User user = users.get(rowIndex);
+ switch (columnIndex) {
+ case 0:
+ return user.getId();
+ case 1:
+ return user.getName();
+ case 2:
+ return user.getMail();
+ }
+ return "";
+ }
+
+ public boolean isCellEditable(int rowIndex, int columnIndex) {
+ return false;
+ }
+
+ public void removeTableModelListener(TableModelListener listener) {
+ listeners.remove(listener);
+ }
+
+ public void setValueAt(Object value, int rowIndex, int columnIndex) {
+
+ }
+
+
+
+}
diff --git a/src/main/java/ru/egspt/moodle/panel/TagPane.java b/src/main/java/ru/egspt/moodle/panel/TagPane.java
index 9037e82..e401e05 100644
--- a/src/main/java/ru/egspt/moodle/panel/TagPane.java
+++ b/src/main/java/ru/egspt/moodle/panel/TagPane.java
@@ -29,6 +29,6 @@ public class TagPane extends JPanel{
TagAddButton.addActionListener(new TagButtonListener(base, tagField.getText()));
this.add(TagAddButton);
//this.add(TagDelButton);
- this.add(usersPane);//данные надо передать тоже!!!!!!!!!!!!!!
+ this.add(usersPane);
}
}
diff --git a/src/main/java/ru/egspt/moodle/panel/UserByTagPane.java b/src/main/java/ru/egspt/moodle/panel/UserByTagPane.java
index feabff9..5489962 100644
--- a/src/main/java/ru/egspt/moodle/panel/UserByTagPane.java
+++ b/src/main/java/ru/egspt/moodle/panel/UserByTagPane.java
@@ -4,22 +4,26 @@ import java.awt.BorderLayout;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
+import javax.swing.JTable;
import javax.swing.JTextArea;
+import javax.swing.table.TableModel;
import ru.egspt.moodle.Base;
+import ru.egspt.moodle.UsersModel;
public class UserByTagPane extends JPanel{
JTextArea ta;
JScrollPane sp;
+ /**
+ * данные надо в таблицу отображать, а не в текстовой области
+ * [хороший пример модели данных, подходит для работы с jtable и xlsx в перспективе]
+ * https://javaswing.wordpress.com/2010/05/05/jtabletablemodel/
+ */
UserByTagPane(Base base){
- String text = "s;dfkjg s;dfhg so soigspoig psoigspfg ps sigh sp oigpssp oigspih soupsht";
- ta = new JTextArea();
- ta.setText(text);
- ta.append(text);
- ta.append(text);ta.append(text);ta.append(text);ta.append(text);ta.append(text);
-
- sp = new JScrollPane(ta);
+ TableModel model = new UsersModel(base.getUsers());
+ JTable table = new JTable(model);
+ sp = new JScrollPane(table);
setLayout(new BorderLayout());
add(sp, BorderLayout.CENTER);
}
diff --git a/target/classes/ru/egspt/moodle/Base.class b/target/classes/ru/egspt/moodle/Base.class
index eacd176..84a3313 100644
Binary files a/target/classes/ru/egspt/moodle/Base.class and b/target/classes/ru/egspt/moodle/Base.class differ
diff --git a/target/classes/ru/egspt/moodle/UsersModel.class b/target/classes/ru/egspt/moodle/UsersModel.class
new file mode 100644
index 0000000..2cf3aef
Binary files /dev/null and b/target/classes/ru/egspt/moodle/UsersModel.class differ
diff --git a/target/classes/ru/egspt/moodle/panel/UserByTagPane.class b/target/classes/ru/egspt/moodle/panel/UserByTagPane.class
index 5fce4b4..c9649ce 100644
Binary files a/target/classes/ru/egspt/moodle/panel/UserByTagPane.class and b/target/classes/ru/egspt/moodle/panel/UserByTagPane.class differ