use of org.gephi.workspace.impl.WorkspaceImpl in project gephi by gephi.
the class GephiReader method readWorkspaceLegacy.
private static void readWorkspaceLegacy(XMLStreamReader reader, ProjectImpl project) throws Exception {
WorkspaceImpl workspace = project.getLookup().lookup(WorkspaceProviderImpl.class).newWorkspace();
WorkspaceInformationImpl info = workspace.getLookup().lookup(WorkspaceInformationImpl.class);
//Name
info.setName(reader.getAttributeValue(null, "name"));
//Status
String workspaceStatus = reader.getAttributeValue(null, "status");
if (workspaceStatus.equals("open")) {
info.open();
} else if (workspaceStatus.equals("closed")) {
info.close();
} else {
info.invalid();
}
Map<String, WorkspaceXMLPersistenceProvider> providers = new LinkedHashMap<>();
for (WorkspacePersistenceProvider w : Lookup.getDefault().lookupAll(WorkspacePersistenceProvider.class)) {
String id = w.getIdentifier();
if (id != null && !id.isEmpty() && w instanceof WorkspaceXMLPersistenceProvider) {
providers.put(w.getIdentifier(), (WorkspaceXMLPersistenceProvider) w);
}
}
boolean end = false;
while (reader.hasNext() && !end) {
Integer eventType = reader.next();
if (eventType.equals(XMLEvent.START_ELEMENT)) {
String name = reader.getLocalName();
WorkspaceXMLPersistenceProvider pp = providers.get(name);
if (pp != null) {
try {
pp.readXML(reader, workspace);
} catch (UnsupportedOperationException e) {
}
}
} else if (eventType.equals(XMLStreamReader.END_ELEMENT)) {
if ("workspace".equalsIgnoreCase(reader.getLocalName())) {
end = true;
}
}
}
}
Aggregations