use of com.archimatetool.model.IDiagramModel in project archi by archimatetool.
the class CopySnapshot method createPasteObject.
private IDiagramModelObject createPasteObject(IDiagramModelContainer container, IDiagramModelObject snapshotObject) {
// Don't paste invalid objects
if (!isValidPasteComponent(fTargetDiagramModel, snapshotObject)) {
return null;
}
IDiagramModelObject pasteObject = (IDiagramModelObject) snapshotObject.getCopy();
createID(pasteObject);
// Offset top level objects if container is diagram
if (container instanceof IDiagramModel) {
IDiagramModelObject originalObject = (IDiagramModelObject) fOriginalToSnapshotComponentsMapping.getKey(snapshotObject);
IBounds bounds = originalObject.getBounds().getCopy();
Point pt = new Point(bounds.getX(), bounds.getY());
translateToAbsolute(originalObject, pt);
bounds.setX(pt.x + fXOffSet);
bounds.setY(pt.y + fYOffSet);
pasteObject.setBounds(bounds);
}
// If Archimate object
if (pasteObject instanceof IDiagramModelArchimateObject) {
IDiagramModelArchimateObject dmo = (IDiagramModelArchimateObject) pasteObject;
// Re-use original ArchiMate components
if (!fDoCreateNewArchimateComponents) {
IDiagramModelArchimateObject originalDiagramObject = (IDiagramModelArchimateObject) fOriginalToSnapshotComponentsMapping.getKey(snapshotObject);
IArchimateElement element = originalDiagramObject.getArchimateElement();
dmo.setArchimateElement(element);
}
// Provide new names if required
if (fDoCreateNewArchimateComponents && isSourceAndTargetArchiMateModelSame()) {
String name = dmo.getArchimateElement().getName();
// $NON-NLS-1$
dmo.getArchimateElement().setName(name + " " + Messages.CopySnapshot_1);
}
}
// Add to Mapping
fSnapshotToNewComponentMapping.put(snapshotObject, pasteObject);
// Object is Container, so recurse
if (snapshotObject instanceof IDiagramModelContainer) {
for (IDiagramModelObject child : ((IDiagramModelContainer) snapshotObject).getChildren()) {
IDiagramModelObject dmo = createPasteObject((IDiagramModelContainer) pasteObject, child);
if (dmo != null) {
((IDiagramModelContainer) pasteObject).getChildren().add(dmo);
}
}
}
return pasteObject;
}
use of com.archimatetool.model.IDiagramModel in project archi by archimatetool.
the class HTMLReportExporter method writeDiagrams.
/**
* Write diagrams
*/
private void writeDiagrams(File imagesFolder, File viewsFolder, ST stFrame) throws IOException {
if (fModel.getDiagramModels().isEmpty()) {
return;
}
// Save images
saveImages(imagesFolder);
for (IDiagramModel dm : fModel.getDiagramModels()) {
// Add the necessary bounds in order to get correct absolute coordinates for the elements in the generated image
Rectangle bounds = diagramBoundsMap.get(dm);
// process the children
for (IDiagramModelObject dmo : dm.getChildren()) {
addNewBounds(dmo, bounds.x * -1, bounds.y * -1);
}
// $NON-NLS-1$
File viewF = new File(viewsFolder, dm.getId() + ".html");
// $NON-NLS-1$
OutputStreamWriter viewW = new OutputStreamWriter(new FileOutputStream(viewF), "UTF8");
// $NON-NLS-1$
stFrame.remove("element");
// $NON-NLS-1$
stFrame.add("element", dm);
// $NON-NLS-1$
stFrame.remove("map");
// $NON-NLS-1$
stFrame.add("map", childBoundsMap);
viewW.write(stFrame.render());
viewW.close();
}
}
use of com.archimatetool.model.IDiagramModel in project archi by archimatetool.
the class JasperReportsExporter method writeDiagrams.
/**
* Write the diagrams to temp files
*/
void writeDiagrams(File tmpFolder) {
for (IDiagramModel dm : fModel.getDiagramModels()) {
Image image = DiagramUtils.createImage(dm, 1, 10);
// $NON-NLS-1$
String diagramName = dm.getId() + ".png";
try {
ImageLoader loader = new ImageLoader();
loader.data = new ImageData[] { image.getImageData(ImageFactory.getDeviceZoom()) };
File file = new File(tmpFolder, diagramName);
loader.save(file.getAbsolutePath(), SWT.IMAGE_PNG);
} finally {
image.dispose();
}
}
}
use of com.archimatetool.model.IDiagramModel in project archi by archimatetool.
the class CreateMapViewCheatSheetAction method run.
public void run(String[] params, ICheatSheetManager manager) {
IViewPart viewPart = ViewManager.showViewPart(ITreeModelView.ID, true);
if (viewPart == null) {
MessageDialog.openWarning(Display.getCurrent().getActiveShell(), Messages.CreateMapViewCheatSheetAction_0, Messages.CreateMapViewCheatSheetAction_1);
return;
}
IArchimateModel model = viewPart.getAdapter(IArchimateModel.class);
if (model == null) {
MessageDialog.openWarning(Display.getCurrent().getActiveShell(), Messages.CreateMapViewCheatSheetAction_2, Messages.CreateMapViewCheatSheetAction_3);
return;
}
EList<IDiagramModel> diagramModels = model.getDiagramModels();
if (diagramModels.size() < 2) {
MessageDialog.openWarning(Display.getCurrent().getActiveShell(), Messages.CreateMapViewCheatSheetAction_4, Messages.CreateMapViewCheatSheetAction_5);
return;
}
CommandStack stack = (CommandStack) model.getAdapter(CommandStack.class);
if (stack != null) {
stack.execute(new NewMapViewCommand(model));
}
}
use of com.archimatetool.model.IDiagramModel in project archi by archimatetool.
the class ArchimateModel method getDiagramModels.
/**
* <!-- begin-user-doc -->
* Return the Diagram Models - could be empty list
* <!-- end-user-doc -->
* @generated NOT
*/
public EList<IDiagramModel> getDiagramModels() {
EList<IDiagramModel> list = new BasicEList<IDiagramModel>();
IFolder folder = getFolder(FolderType.DIAGRAMS);
if (folder != null) {
for (Iterator<EObject> iter = folder.eAllContents(); iter.hasNext(); ) {
EObject eObject = iter.next();
if (eObject instanceof IDiagramModel) {
list.add((IDiagramModel) eObject);
}
}
}
return list;
}
Aggregations