use of org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl in project xtext-eclipse by eclipse.
the class PersistableResourceDescriptionsTest method setUp.
@Before
public void setUp() throws Exception {
fileSystem = Maps.newHashMap();
builderState = builderInjector.getInstance(ClusteringBuilderState.class);
uriConverter = new ExtensibleURIConverterImpl() {
@Override
public InputStream createInputStream(org.eclipse.emf.common.util.URI uri, Map<?, ?> options) throws IOException {
return new StringInputStream(fileSystem.get(uri.toString()));
}
};
}
use of org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl in project archi-modelrepository-plugin by archi-contribs.
the class GraficoModelExporter method exportModel.
/**
* Export the IArchimateModel as Grafico files
* @throws IOException
*/
public void exportModel() throws IOException {
// Define target folders for model and images
// Delete them and re-create them (remark: FileUtils.deleteFolder() does sanity checks)
File modelFolder = new File(fLocalRepoFolder, IGraficoConstants.MODEL_FOLDER);
FileUtils.deleteFolder(modelFolder);
modelFolder.mkdirs();
File imagesFolder = new File(fLocalRepoFolder, IGraficoConstants.IMAGES_FOLDER);
FileUtils.deleteFolder(imagesFolder);
imagesFolder.mkdirs();
// Save model images (if any): this has to be done on original model (not a copy)
saveImages();
// Create ResourceSet
fResourceSet = new ResourceSetImpl();
// $NON-NLS-1$
fResourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("*", new XMLResourceFactoryImpl());
// Add a URIConverter that will be used to map full filenames to logical names
fResourceSet.setURIConverter(new ExtensibleURIConverterImpl());
// Now work on a copy
IArchimateModel copy = EcoreUtil.copy(fModel);
// Create directory structure and prepare all Resources
createAndSaveResourceForFolder(copy, modelFolder);
// Now save all Resources
int maxThreads = ModelRepositoryPlugin.INSTANCE.getPreferenceStore().getInt(IPreferenceConstants.PREFS_EXPORT_MAX_THREADS);
// $NON-NLS-1$
JobGroup jobgroup = new JobGroup("GraficoModelExporter", maxThreads, 1);
final ExceptionProgressMonitor pm = new ExceptionProgressMonitor();
for (Resource resource : fResourceSet.getResources()) {
Job job = new // $NON-NLS-1$
Job(// $NON-NLS-1$
"Resource Save Job") {
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
resource.save(null);
} catch (IOException ex) {
pm.catchException(ex);
}
return Status.OK_STATUS;
}
};
job.setJobGroup(jobgroup);
job.schedule();
}
try {
jobgroup.join(0, pm);
} catch (OperationCanceledException | InterruptedException ex) {
throw new IOException(ex);
}
// Throw on any exception
if (pm.ex != null) {
throw pm.ex;
}
}
Aggregations