use of javax.swing.event.TableModelListener in project blue by kunstmusik.
the class LiveObjectsTableModel method fireTableDataChanged.
private void fireTableDataChanged(TableModelEvent tme) {
if (tableListeners == null) {
return;
}
for (Iterator iter = tableListeners.iterator(); iter.hasNext(); ) {
TableModelListener listener = (TableModelListener) iter.next();
listener.tableChanged(tme);
}
}
use of javax.swing.event.TableModelListener in project gephi by gephi.
the class AbstractWizardVisualPanel1 method refreshPreviewTable.
public void refreshPreviewTable() {
try (SheetParser parser = importer.createParser()) {
Map<String, Integer> headerMap = parser.getHeaderMap();
final String[] headers = headerMap.keySet().toArray(new String[0]);
columnCount = headers.length;
hasSourceNodeColumn = false;
hasTargetNodeColumn = false;
int sourceColumnIndex = 0;
int targetColumnIndex = 0;
for (String header : headers) {
if (header.equalsIgnoreCase("source")) {
hasSourceNodeColumn = true;
sourceColumnIndex = headerMap.get(header);
}
if (header.equalsIgnoreCase("target")) {
hasTargetNodeColumn = true;
targetColumnIndex = headerMap.get(header);
}
}
ArrayList<String[]> records = new ArrayList<>();
hasRowsMissingSourcesOrTargets = false;
final SpreadsheetGeneralConfiguration.Mode mode = getSelectedMode();
int maxRowSize = 0;
String[] currentRecord;
Iterator<SheetRow> iterator = parser.iterator();
int count = 0;
while (iterator.hasNext() && count < MAX_ROWS_PREVIEW) {
count++;
final SheetRow row = iterator.next();
final int rowSize = row.size();
maxRowSize = Math.max(maxRowSize, row.size());
currentRecord = new String[rowSize];
for (int i = 0; i < rowSize; i++) {
currentRecord[i] = row.get(i);
}
// Search for missing source or target columns for edges table
if (mode == SpreadsheetGeneralConfiguration.Mode.EDGES_TABLE) {
if (rowSize <= sourceColumnIndex || rowSize <= targetColumnIndex || currentRecord[sourceColumnIndex] == null || currentRecord[targetColumnIndex] == null) {
hasRowsMissingSourcesOrTargets = true;
}
}
records.add(currentRecord);
}
final String[] columnNames = headers;
final String[][] values = records.toArray(new String[0][]);
final int rowSize = maxRowSize;
final JTable table = getPreviewTable();
table.setModel(new TableModel() {
@Override
public int getRowCount() {
return values.length;
}
@Override
public int getColumnCount() {
return rowSize;
}
@Override
public String getColumnName(int columnIndex) {
if (columnIndex > columnNames.length - 1) {
return null;
}
return columnNames[columnIndex];
}
@Override
public Class<?> getColumnClass(int columnIndex) {
return String.class;
}
@Override
public boolean isCellEditable(int rowIndex, int columnIndex) {
return false;
}
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
if (values[rowIndex].length > columnIndex) {
return values[rowIndex][columnIndex];
} else {
return null;
}
}
@Override
public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
}
@Override
public void addTableModelListener(TableModelListener l) {
}
@Override
public void removeTableModelListener(TableModelListener l) {
}
});
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
boolean needsHeader = headers.length > 0;
getPreviewTableScrollPane().setColumnHeaderView(needsHeader ? table.getTableHeader() : null);
}
});
} catch (IOException ex) {
throw new RuntimeException(ex);
}
}
use of javax.swing.event.TableModelListener in project dna by leifeld.
the class CoderRelationTableModel method setValueAt.
@Override
public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
CoderRelation cr = Dna.data.getCoderRelations().get(rowIndex);
if (columnIndex == 0) {
Dna.data.getCoderById(cr.getOtherCoder()).setName((String) aValue);
} else if (columnIndex == 1) {
Dna.data.getCoderRelations().get(rowIndex).setViewStatements((boolean) aValue);
Dna.dna.sql.updateCoderRelationViewStatements(cr.getId(), (boolean) aValue);
} else if (columnIndex == 2) {
Dna.data.getCoderRelations().get(rowIndex).setEditStatements((boolean) aValue);
Dna.dna.sql.updateCoderRelationEditStatements(cr.getId(), (boolean) aValue);
} else if (columnIndex == 3) {
Dna.data.getCoderRelations().get(rowIndex).setViewDocuments((boolean) aValue);
Dna.dna.sql.updateCoderRelationViewDocuments(cr.getId(), (boolean) aValue);
} else if (columnIndex == 4) {
Dna.data.getCoderRelations().get(rowIndex).setEditDocuments((boolean) aValue);
Dna.dna.sql.updateCoderRelationEditDocuments(cr.getId(), (boolean) aValue);
}
TableModelEvent e = new TableModelEvent(this);
for (int i = 0, n = listeners.size(); i < n; i++) {
((TableModelListener) listeners.get(i)).tableChanged(e);
}
// fireTableCellUpdated(rowIndex, columnIndex);
// update statement-related GUI parts
Dna.dna.gui.textPanel.paintStatements();
Dna.dna.gui.rightPanel.statementPanel.statementFilter.updateFilter();
// update document-related GUI parts
Dna.dna.gui.documentPanel.documentFilter();
}
use of javax.swing.event.TableModelListener in project dna by leifeld.
the class StatementTableModel method clear.
public void clear() {
Dna.data.getStatements().clear();
TableModelEvent e = new TableModelEvent(this);
for (int i = 0, n = listeners.size(); i < n; i++) {
((TableModelListener) listeners.get(i)).tableChanged(e);
}
}
use of javax.swing.event.TableModelListener in project dna by leifeld.
the class DocumentTableModel method clear.
public void clear() {
Dna.data.getDocuments().clear();
TableModelEvent e = new TableModelEvent(this);
for (int i = 0, n = listeners.size(); i < n; i++) {
((TableModelListener) listeners.get(i)).tableChanged(e);
}
}
Aggregations