01: package salomeTMF_plug.mantis;
02:
03: import java.awt.BorderLayout;
04: import java.util.ArrayList;
05: import java.util.Vector;
06:
07: import javax.swing.JPanel;
08: import javax.swing.JScrollPane;
09: import javax.swing.JTable;
10: import javax.swing.ListSelectionModel;
11:
12: import org.objectweb.salome_tmf.ihm.models.MyTableModel;
13: import org.objectweb.salome_tmf.ihm.models.TableSorter;
14:
15: import salomeTMF_plug.mantis.languages.Language;
16: import salomeTMF_plug.mantis.sqlWrapper.HistoryWrapper;
17:
18: public class HistoryPanel extends JPanel {
19:
20: MyTableModel historyTableModel;
21: TableSorter sorter;
22: JTable historyTable;
23: MantisPlugin pMantisPlugin;
24:
25: HistoryPanel(MantisPlugin pMantisPlugin, Vector history) {
26: super ();
27: setLayout(new BorderLayout());
28: this .pMantisPlugin = pMantisPlugin;
29: historyTable = new JTable();
30: historyTableModel = new MyTableModel();
31: historyTableModel.addColumnNameAndColumn("Date");
32: historyTableModel.addColumnNameAndColumn(Language.getInstance()
33: .getText("User")); //Produit
34: historyTableModel.addColumnNameAndColumn(Language.getInstance()
35: .getText("Field")); //Produit
36: historyTableModel.addColumnNameAndColumn(Language.getInstance()
37: .getText("Change")); //Etat
38:
39: sorter = new TableSorter(historyTableModel);
40: historyTable.setModel(sorter);
41: sorter.setTableHeader(historyTable.getTableHeader());
42: historyTable
43: .setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
44: JScrollPane defectsTableScrollPane = new JScrollPane(
45: historyTable);
46: add(defectsTableScrollPane, BorderLayout.CENTER);
47: loadData(history);
48: }
49:
50: void loadData(Vector history) {
51: if (history != null) {
52: int size = history.size();
53: for (int i = 0; i < size; i++) {
54: HistoryWrapper pHistoryWrapper = (HistoryWrapper) history
55: .elementAt(i);
56: ArrayList data = new ArrayList();
57: data.add(pHistoryWrapper.getDate());
58: data.add(pHistoryWrapper.getUsername());
59: data.add(pHistoryWrapper.getField());
60: data.add(pHistoryWrapper.getChange(pMantisPlugin));
61: historyTableModel.addRow(data);
62: }
63: }
64: }
65: }
|