--- a/src/net/timbusproject/context/converter/OWLExport.java
+++ b/src/net/timbusproject/context/converter/OWLExport.java
@@ -267,16 +267,29 @@
}
/** Exports the layout of the layered view ({@link IViewpoint#LAYERED_VIEWPOINT}) of a model to a CSV separated file */
- public static void exportLayout(IArchimateModel model, File layoutFile, String defaultIRI)
+ public static boolean exportLayout(IArchimateModel model, File layoutFile, String defaultIRI, String viewName)
throws FileNotFoundException {
- exportLayout(layoutFile, defaultIRI, getLayeredView(model));
+ System.out.println("OWLExport.exportLayout()");
+ ArchimateDiagramModel view = null;
+ if (viewName != null) {
+ System.out.print("Trying to find view '" + viewName + "'... ");
+ view = getViewByName(model, viewName);
+ System.out.println(view == null ? "found" : "not found");
+ }
+ if (view == null) {
+ System.out.print("Trying to find layered view... ");
+ view = getLayeredView(model);
+ System.out.println(view == null ? "found" : "not found");
+ }
+
+ return exportLayout(layoutFile, defaultIRI, view);
}
/** Exports the layout of a model to a CSV separated file */
- public static void exportLayout(File layoutFile, String defaultIRI, ArchimateDiagramModel layeredView)
+ public static boolean exportLayout(File layoutFile, String defaultIRI, ArchimateDiagramModel view)
throws FileNotFoundException {
- if (layeredView != null) {
- EList<IDiagramModelObject> children = layeredView.getChildren();
+ if (view != null) {
+ EList<IDiagramModelObject> children = view.getChildren();
ArrayList<String> export = new ArrayList<String>();
exportChildrenLayout(children, 0, 0, export, defaultIRI);
@@ -289,22 +302,34 @@
pw.flush();
pw.close();
+ return true;
+ } else {
+ return false;
}
}
public static ArchimateDiagramModel getLayeredView(IArchimateModel model) {
- IFolder diagramFolder = model.getFolder(FolderType.DIAGRAMS);
- ArchimateDiagramModel layeredView = null;
-
- for (EObject eObject : diagramFolder.getElements()) {
+ for (EObject eObject : model.getFolder(FolderType.DIAGRAMS).getElements()) {
if (eObject instanceof ArchimateDiagramModel) {
ArchimateDiagramModel diagramModel = (ArchimateDiagramModel) eObject;
if (diagramModel.getViewpoint() == IViewpoint.LAYERED_VIEWPOINT) {
- layeredView = diagramModel;
- }
- }
- }
- return layeredView;
+ return diagramModel;
+ }
+ }
+ }
+ return null;
+ }
+
+ public static ArchimateDiagramModel getViewByName(IArchimateModel model, String viewName) {
+ for (EObject eObject : model.getFolder(FolderType.DIAGRAMS).getElements()) {
+ if (eObject instanceof ArchimateDiagramModel) {
+ ArchimateDiagramModel diagramModel = (ArchimateDiagramModel) eObject;
+ if (diagramModel.getName().equals(viewName)) {
+ return diagramModel;
+ }
+ }
+ }
+ return null;
}
public static File getDefaultLayoutFile(File file) {