Browse Source

curr

master
esoe 3 years ago
parent
commit
ef7dc93db0
  1. 10
      drow/model.drawio
  2. 4
      src/main/java/ru/egspt/moodle/Base.java
  3. 82
      src/main/java/ru/egspt/moodle/UsersModel.java
  4. 2
      src/main/java/ru/egspt/moodle/panel/TagPane.java
  5. 18
      src/main/java/ru/egspt/moodle/panel/UserByTagPane.java
  6. BIN
      target/classes/ru/egspt/moodle/Base.class
  7. BIN
      target/classes/ru/egspt/moodle/UsersModel.class
  8. BIN
      target/classes/ru/egspt/moodle/panel/UserByTagPane.class

10
drow/model.drawio

@ -0,0 +1,10 @@
<mxfile host="65bd71144e">
<diagram id="ihwz2KHPgUZGItZvBWFA" name="Page-1">
<mxGraphModel dx="758" dy="518" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
<root>
<mxCell id="0"/>
<mxCell id="1" parent="0"/>
</root>
</mxGraphModel>
</diagram>
</mxfile>

4
src/main/java/ru/egspt/moodle/Base.java

@ -42,7 +42,9 @@ public class Base {
public Base(){ public Base(){
users = new ArrayList<>();
results = new ArrayList<>();
quizes = new ArrayList<>();
} }
/** /**

82
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<TableModelListener> listeners = new HashSet<TableModelListener>();
private List<User> users;
public UsersModel(List<User> 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) {
}
}

2
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())); TagAddButton.addActionListener(new TagButtonListener(base, tagField.getText()));
this.add(TagAddButton); this.add(TagAddButton);
//this.add(TagDelButton); //this.add(TagDelButton);
this.add(usersPane);//данные надо передать тоже!!!!!!!!!!!!!! this.add(usersPane);
} }
} }

18
src/main/java/ru/egspt/moodle/panel/UserByTagPane.java

@ -4,22 +4,26 @@ import java.awt.BorderLayout;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JScrollPane; import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextArea; import javax.swing.JTextArea;
import javax.swing.table.TableModel;
import ru.egspt.moodle.Base; import ru.egspt.moodle.Base;
import ru.egspt.moodle.UsersModel;
public class UserByTagPane extends JPanel{ public class UserByTagPane extends JPanel{
JTextArea ta; JTextArea ta;
JScrollPane sp; JScrollPane sp;
/**
* данные надо в таблицу отображать, а не в текстовой области
* [хороший пример модели данных, подходит для работы с jtable и xlsx в перспективе]
* https://javaswing.wordpress.com/2010/05/05/jtabletablemodel/
*/
UserByTagPane(Base base){ UserByTagPane(Base base){
String text = "s;dfkjg s;dfhg so soigspoig psoigspfg ps sigh sp oigpssp oigspih soupsht"; TableModel model = new UsersModel(base.getUsers());
ta = new JTextArea(); JTable table = new JTable(model);
ta.setText(text); sp = new JScrollPane(table);
ta.append(text);
ta.append(text);ta.append(text);ta.append(text);ta.append(text);ta.append(text);
sp = new JScrollPane(ta);
setLayout(new BorderLayout()); setLayout(new BorderLayout());
add(sp, BorderLayout.CENTER); add(sp, BorderLayout.CENTER);
} }

BIN
target/classes/ru/egspt/moodle/Base.class

Binary file not shown.

BIN
target/classes/ru/egspt/moodle/UsersModel.class

Binary file not shown.

BIN
target/classes/ru/egspt/moodle/panel/UserByTagPane.class

Binary file not shown.
Loading…
Cancel
Save