MCPcopy Create free account
hub / github.com/GateNLP/gate-core / tableChanged

Method tableChanged

src/main/java/gate/swing/XJTable.java:605–683  ·  view source on GitHub ↗

This gets events from the source model and forwards them to the UI

(TableModelEvent e)

Source from the content-addressed store, hash-verified

603 * This gets events from the source model and forwards them to the UI
604 */
605 @Override
606 public void tableChanged(TableModelEvent e){
607 int type = e.getType();
608 int firstRow = e.getFirstRow();
609 int lastRow = e.getLastRow();
610 int column = e.getColumn();
611
612 //deal with the changes in the data
613 //we have no way to "repair" the sorting on data updates so we will need
614 //to rebuild the order every time
615
616 switch(type){
617 case TableModelEvent.UPDATE:
618 if(firstRow == TableModelEvent.HEADER_ROW){
619 //complete structure change -> reallocate the data
620 init(sourceModel);
621 newColumns();
622 fireTableStructureChanged();
623 if(isSortable()) sort();
624 }else if(lastRow == Integer.MAX_VALUE){
625 //all data changed (including the number of rows)
626 init(sourceModel);
627 if(isSortable()){
628 sort();
629 } else {
630 //this will re-create all rows (which deletes the rowModel in JTable)
631 componentSizedProperly = false;
632 fireTableDataChanged();
633 }
634 }else{
635 //the rows should have normal values
636 //if the sortedColumn is not affected we don't care
637 if(isSortable() &&
638 (column == sortedColumn ||
639 column == TableModelEvent.ALL_COLUMNS)){
640 //re-sorting will also fire the event upwards
641 sort();
642 }else{
643 componentSizedProperly = false;
644 fireTableChanged(new TableModelEvent(this,
645 sourceToTarget(firstRow),
646 sourceToTarget(lastRow), column, type));
647
648 }
649 }
650 break;
651 case TableModelEvent.INSERT:
652 //rows were inserted -> we need to rebuild
653 init(sourceModel);
654 if(firstRow != TableModelEvent.HEADER_ROW && firstRow == lastRow){
655 //single row insertion
656 if(isSortable()) sort();
657 else{
658 componentSizedProperly = false;
659 fireTableChanged(new TableModelEvent(this,
660 sourceToTarget(firstRow),
661 sourceToTarget(lastRow), column, type));
662 }

Callers

nothing calls this directly

Calls 8

initMethod · 0.95
sortMethod · 0.95
sourceToTargetMethod · 0.95
newColumnsMethod · 0.80
isSortableMethod · 0.80
fireTableDataChangedMethod · 0.80
getTypeMethod · 0.65
getColumnMethod · 0.65

Tested by

no test coverage detected