1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
| /**
* Initialise the table by using the PartVector of the main Appli
* @return the Table of the components
*/
public JTable createTable() {
// initialisation
//PartVector componentsSet = getAppli().getPartVector();
PartVector partVector = getAppli().getMainApplication().getDbPicker().
getComponents();
// HERE : to load the partVector takes an enormous amount of memory.
Iterator componentsIterator = partVector.iterator();
model = new PCellardTableModel();
sorter = new TableSorter(model);
//table = new JTable(model);
table = new JTable(sorter);
//sorter.addMouseListenerToHeaderInTable(table);
sorter.setTableHeader(table.getTableHeader());
int i = 0;
// filling the columns :
model.addColumn("ID");
model.addColumn("Name");
model.addColumn("NickName");
model.addColumn("Type");
model.addColumn("Price");
// filling the table with correct values :
while(componentsIterator.hasNext()){
Part c = (Part)(componentsIterator.next());
addRow(c);
}
// prohibiting cells permutations (would be useless)
table.getTableHeader().setReorderingAllowed(false);
// selection mode setting (in order to select only one row)
// please do not modify
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
ListSelectionModel rowSM = table.getSelectionModel();
rowSM.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
//Ignore extra messages.
if (e.getValueIsAdjusting()) return;
ListSelectionModel lsm = (ListSelectionModel)e.getSource();
if (lsm.isSelectionEmpty()) {
System.out.println("no row selected");
} else {
selectedRow = new Integer(lsm.getMinSelectionIndex());
displayOutline();
}
}
});
return table;
} |
Partager