use of com.archimatetool.model.IDiagramModelImageProvider in project archi-modelrepository-plugin by archi-contribs.
the class GraficoModelExporter method saveImages.
/**
* Extract and save images used inside a model
*
* @param model
* @param folder
* @throws IOException
*/
private void saveImages() throws IOException {
List<String> added = new ArrayList<String>();
IArchiveManager archiveManager = (IArchiveManager) fModel.getAdapter(IArchiveManager.class);
if (archiveManager == null) {
archiveManager = IArchiveManager.FACTORY.createArchiveManager(fModel);
}
byte[] bytes;
for (Iterator<EObject> iter = fModel.eAllContents(); iter.hasNext(); ) {
EObject eObject = iter.next();
if (eObject instanceof IDiagramModelImageProvider) {
IDiagramModelImageProvider imageProvider = (IDiagramModelImageProvider) eObject;
String imagePath = imageProvider.getImagePath();
if (imagePath != null && !added.contains(imagePath)) {
bytes = archiveManager.getBytesFromEntry(imagePath);
Files.write(Paths.get(fLocalRepoFolder.getAbsolutePath() + File.separator + imagePath), bytes, StandardOpenOption.CREATE);
added.add(imagePath);
}
}
}
}
use of com.archimatetool.model.IDiagramModelImageProvider in project archi by archimatetool.
the class ArchiveManager method saveImages.
private void saveImages(ZipOutputStream zOut) throws IOException {
List<String> added = new ArrayList<String>();
for (Iterator<EObject> iter = fModel.eAllContents(); iter.hasNext(); ) {
EObject eObject = iter.next();
if (eObject instanceof IDiagramModelImageProvider) {
IDiagramModelImageProvider imageProvider = (IDiagramModelImageProvider) eObject;
String imagePath = imageProvider.getImagePath();
if (imagePath != null && !added.contains(imagePath)) {
byte[] bytes = BYTE_ARRAY_STORAGE.getEntry(imagePath);
if (bytes != null) {
ZipEntry zipEntry = new ZipEntry(imagePath);
zOut.putNextEntry(zipEntry);
zOut.write(bytes);
zOut.closeEntry();
added.add(imagePath);
}
}
}
}
}
Aggregations