use of com.archimatetool.model.IDiagramModel in project archi by archimatetool.
the class SaveArchimateModelAsTemplateWizard method createManifest.
private String createManifest() throws IOException {
Document doc = new Document();
Element root = new Element(ITemplateXMLTags.XML_TEMPLATE_ELEMENT_MANIFEST);
doc.setRootElement(root);
// Type
root.setAttribute(ITemplateXMLTags.XML_TEMPLATE_ATTRIBUTE_TYPE, ArchimateModelTemplate.XML_TEMPLATE_ATTRIBUTE_TYPE_MODEL);
// Timestamp
root.setAttribute(ITemplateXMLTags.XML_TEMPLATE_ATTRIBUTE_TIMESTAMP, Long.toString(System.currentTimeMillis()));
// Name
Element elementName = new Element(ITemplateXMLTags.XML_TEMPLATE_ELEMENT_NAME);
elementName.setText(fTemplateName);
root.addContent(elementName);
// Description
Element elementDescription = new Element(ITemplateXMLTags.XML_TEMPLATE_ELEMENT_DESCRIPTION);
elementDescription.setText(fTemplateDescription);
root.addContent(elementDescription);
// Thumbnails
if (fIncludeThumbnails) {
if (fSelectedDiagramModel != null) {
int i = 1;
for (IDiagramModel dm : fModel.getDiagramModels()) {
if (dm == fSelectedDiagramModel) {
// $NON-NLS-1$
String keyThumb = TemplateManager.ZIP_ENTRY_THUMBNAILS + i + ".png";
Element elementKeyThumb = new Element(ITemplateXMLTags.XML_TEMPLATE_ELEMENT_KEY_THUMBNAIL);
elementKeyThumb.setText(keyThumb);
root.addContent(elementKeyThumb);
break;
}
i++;
}
}
}
return JDOMUtils.write2XMLString(doc);
}
use of com.archimatetool.model.IDiagramModel in project archi by archimatetool.
the class HTMLReportExporter method saveImages.
/**
* Save diagram images
*/
private void saveImages(File imagesFolder) {
// Use this to generate unique name for image file
Hashtable<IDiagramModel, String> nameTable = new Hashtable<IDiagramModel, String>();
int nameCount = 1;
for (IDiagramModel dm : fModel.getDiagramModels()) {
ModelReferencedImage geoImage = DiagramUtils.createModelReferencedImage(dm, 1, 10);
Image image = geoImage.getImage();
// Generate file name
String diagramName = dm.getId();
if (StringUtils.isSet(diagramName)) {
// removed this because ids can have hyphens in them (when imported from TOG format)
// Let's hope that ids are filename friendly...
// diagramName = FileUtils.getValidFileName(diagramName);
int j = 2;
// $NON-NLS-1$
String s = diagramName + ".png";
while (nameTable.containsValue(s)) {
// $NON-NLS-1$ //$NON-NLS-2$
s = diagramName + "_" + j++ + ".png";
}
diagramName = s;
} else {
// $NON-NLS-1$//$NON-NLS-2$
diagramName = Messages.HTMLReportExporter_1 + " " + nameCount++ + ".png";
}
nameTable.put(dm, diagramName);
// Get and store the bounds of the top-left element in the figure to act as overall x,y offset
Rectangle bounds = geoImage.getBounds();
// Account for device zoom level
bounds.performScale(ImageFactory.getDeviceZoom() / 100);
diagramBoundsMap.put(dm, bounds);
try {
ImageLoader loader = new ImageLoader();
loader.data = new ImageData[] { image.getImageData(ImageFactory.getDeviceZoom()) };
File file = new File(imagesFolder, diagramName);
loader.save(file.getAbsolutePath(), SWT.IMAGE_PNG);
} finally {
image.dispose();
}
}
}
use of com.archimatetool.model.IDiagramModel in project archi by archimatetool.
the class TreeModelView method eCoreChanged.
// =================================================================================
// React to ECore Model Changes
// =================================================================================
@Override
protected void eCoreChanged(Notification msg) {
int type = msg.getEventType();
Object notifier = msg.getNotifier();
Object feature = msg.getFeature();
// Attribute set
if (type == Notification.SET) {
// Viewpoint changed
if (feature == IArchimatePackage.Literals.ARCHIMATE_DIAGRAM_MODEL__VIEWPOINT) {
if (Preferences.STORE.getBoolean(IPreferenceConstants.VIEWPOINTS_FILTER_MODEL_TREE)) {
if (notifier instanceof IDiagramModel) {
IArchimateModel model = ((IDiagramModel) notifier).getArchimateModel();
getViewer().refreshInBackground(model);
}
}
} else {
super.eCoreChanged(msg);
}
} else {
super.eCoreChanged(msg);
}
}
use of com.archimatetool.model.IDiagramModel in project archi-modelrepository-plugin by archi-contribs.
the class GraficoModelImporter method resolveProxies.
/**
* Iterate through all model objects, and resolve proxies on known classes
*/
private void resolveProxies() {
for (Iterator<EObject> iter = fModel.eAllContents(); iter.hasNext(); ) {
EObject eObject = iter.next();
if (eObject instanceof IArchimateRelationship) {
// Resolve proxies for Relations
IArchimateRelationship relation = (IArchimateRelationship) eObject;
relation.setSource((IArchimateConcept) resolve(relation.getSource(), relation));
relation.setTarget((IArchimateConcept) resolve(relation.getTarget(), relation));
} else if (eObject instanceof IDiagramModelArchimateObject) {
// Resolve proxies for Elements
IDiagramModelArchimateObject element = (IDiagramModelArchimateObject) eObject;
element.setArchimateElement((IArchimateElement) resolve(element.getArchimateElement(), element));
// Update cross-references
element.getArchimateElement().getReferencingDiagramObjects().add(element);
} else if (eObject instanceof IDiagramModelArchimateConnection) {
// Resolve proxies for Connections
IDiagramModelArchimateConnection archiConnection = (IDiagramModelArchimateConnection) eObject;
archiConnection.setArchimateRelationship((IArchimateRelationship) resolve(archiConnection.getArchimateRelationship(), archiConnection));
// Update cross-reference
archiConnection.getArchimateRelationship().getReferencingDiagramConnections().add(archiConnection);
} else if (eObject instanceof IDiagramModelReference) {
// Resolve proxies for Model References
IDiagramModelReference element = (IDiagramModelReference) eObject;
element.setReferencedModel((IDiagramModel) resolve(element.getReferencedModel(), element));
}
}
}
use of com.archimatetool.model.IDiagramModel in project archi by archimatetool.
the class EditorModelManager method openModel.
@Override
public IArchimateModel openModel(File file) {
if (file == null || !file.exists()) {
return null;
}
// If it is already loaded return it
IArchimateModel model = locateLoadedModel(file);
if (model != null) {
return model;
}
model = loadModel(file);
if (model != null) {
// Open Views of newly opened model if set in Preferences
if (Preferences.doOpenDiagramsOnLoad()) {
for (IDiagramModel dm : model.getDiagramModels()) {
EditorManager.openDiagramEditor(dm);
}
}
firePropertyChange(this, PROPERTY_MODEL_OPENED, null, model);
}
return model;
}
Aggregations