if (f instanceof ModelFileWriterFactory) {
list.add((ModelFileWriterFactory) f);
}
}
ModelFileWriterFactory selected = list.get(0);
if (list.size() > 1) {
// store model as temporary file
FactorySelectionDialog<ModelFileWriterFactory> dialog =
new FactorySelectionDialog<>(null, list, new JLabel(
"Select format to use."), "Select Format to store model in",
true, new FactoryDescriptionRenderer());
dialog.setVisible(true);
if (dialog.isOkButtonPressed()) {
List<ModelFileWriterFactory> selectedFactories =
dialog.getSelectedFactories();
if (selectedFactories != null && selectedFactories.size() > 0) {
selected = selectedFactories.get(0);
}
}
}
if (selected != null) {
File file =
File.createTempFile("jamesmodel", "." + selected.getFileEnding());
file.deleteOnExit();
modelURI = Files.getURIFromFile(file);
block.addSubBl(IURIHandling.URI, modelURI);
IModelWriter writer = selected.create(block, SimSystem.getRegistry().createContext());
writer.write(model, modelURI);
}
} catch (Throwable t) {
modelURI = null;