use of org.gephi.desktop.datalab.AvailableColumnsModel in project gephi by gephi.
the class DataLaboratoryPersistenceProvider method readDataTablesModel.
private void readDataTablesModel(XMLStreamReader reader, Workspace workspace) throws XMLStreamException {
GraphModel graphModel = workspace.getLookup().lookup(GraphModel.class);
Table nodesTable = graphModel.getNodeTable();
Table edgesTable = graphModel.getEdgeTable();
DataTablesModel dataTablesModel = workspace.getLookup().lookup(DataTablesModel.class);
if (dataTablesModel == null) {
workspace.add(dataTablesModel = new DataTablesModel(workspace));
}
AvailableColumnsModel nodeColumns = dataTablesModel.getNodeAvailableColumnsModel();
nodeColumns.removeAllColumns();
AvailableColumnsModel edgeColumns = dataTablesModel.getEdgeAvailableColumnsModel();
edgeColumns.removeAllColumns();
boolean end = false;
while (reader.hasNext() && !end) {
Integer eventType = reader.next();
if (eventType.equals(XMLEvent.START_ELEMENT)) {
String name = reader.getLocalName();
if (NODE_COLUMN.equalsIgnoreCase(name)) {
Integer id = Integer.parseInt(reader.getAttributeValue(null, "id"));
Column column = nodesTable.getColumn(id);
if (column != null) {
nodeColumns.addAvailableColumn(column);
}
} else if (EDGE_COLUMN.equalsIgnoreCase(name)) {
Integer id = Integer.parseInt(reader.getAttributeValue(null, "id"));
Column column = edgesTable.getColumn(id);
if (column != null) {
edgeColumns.addAvailableColumn(column);
}
}
} else if (eventType.equals(XMLStreamReader.END_ELEMENT)) {
if (AVAILABLE_COLUMNS.equalsIgnoreCase(reader.getLocalName())) {
end = true;
}
}
}
}
Aggregations