Search in sources :

Example 6 with IArchimateConcept

use of com.archimatetool.model.IArchimateConcept in project archi by archimatetool.

the class CSVExporter method writeElementsInFolder.

/**
 * Write all elements in a given folder and its child folders to Writer
 */
private void writeElementsInFolder(Writer writer, IFolder folder) throws IOException {
    if (folder == null) {
        return;
    }
    List<IArchimateConcept> concepts = getConcepts(folder);
    sort(concepts);
    for (IArchimateConcept concept : concepts) {
        if (concept instanceof IArchimateElement) {
            writer.write(CRLF);
            writer.write(createElementRow((IArchimateElement) concept));
        }
    }
}
Also used : IArchimateConcept(com.archimatetool.model.IArchimateConcept) IArchimateElement(com.archimatetool.model.IArchimateElement)

Example 7 with IArchimateConcept

use of com.archimatetool.model.IArchimateConcept in project archi by archimatetool.

the class CSVExporter method writeProperties.

/**
 * Write All Properties
 */
private void writeProperties(File file) throws IOException {
    // Are there any to write?
    if (!fWriteEmptyFile && !hasProperties()) {
        return;
    }
    Writer writer = createOutputStreamWriter(file);
    // Write BOM
    writeBOM(writer);
    // Write Header
    String header = createHeader(PROPERTIES_HEADER);
    writer.write(header);
    // Write Model Properties
    for (IProperty property : fModel.getProperties()) {
        writer.write(CRLF);
        writer.write(createPropertyRow(fModel.getId(), property));
    }
    // Write Element and Relationship Properties
    for (Iterator<EObject> iter = fModel.eAllContents(); iter.hasNext(); ) {
        EObject eObject = iter.next();
        if (eObject instanceof IArchimateConcept) {
            IArchimateConcept concept = (IArchimateConcept) eObject;
            for (IProperty property : concept.getProperties()) {
                writer.write(CRLF);
                writer.write(createPropertyRow(concept.getId(), property));
            }
            // Write special attributes as properties
            writeSpecialProperties(writer, concept);
        }
    }
    writer.close();
}
Also used : IProperty(com.archimatetool.model.IProperty) EObject(org.eclipse.emf.ecore.EObject) IArchimateConcept(com.archimatetool.model.IArchimateConcept) Writer(java.io.Writer) OutputStreamWriter(java.io.OutputStreamWriter)

Example 8 with IArchimateConcept

use of com.archimatetool.model.IArchimateConcept in project archi by archimatetool.

the class CSVExporter method writeRelationships.

/**
 * Write All Relationships
 */
private void writeRelationships(File file) throws IOException {
    List<IArchimateConcept> concepts = getConcepts(fModel.getFolder(FolderType.RELATIONS));
    sort(concepts);
    // Are there any to write?
    if (!fWriteEmptyFile && concepts.isEmpty()) {
        return;
    }
    Writer writer = createOutputStreamWriter(file);
    // Write BOM
    writeBOM(writer);
    // Write Header
    String header = createHeader(RELATIONSHIPS_HEADER);
    writer.write(header);
    // Write Relationships
    for (IArchimateConcept concept : concepts) {
        if (concept instanceof IArchimateRelationship) {
            writer.write(CRLF);
            writer.write(createRelationshipRow((IArchimateRelationship) concept));
        }
    }
    writer.close();
}
Also used : IArchimateConcept(com.archimatetool.model.IArchimateConcept) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) Writer(java.io.Writer) OutputStreamWriter(java.io.OutputStreamWriter)

Example 9 with IArchimateConcept

use of com.archimatetool.model.IArchimateConcept in project archi by archimatetool.

the class CSVImporter method createPropertyFromRecord.

/**
 * Create a Property from a given CSVRecord
 */
private void createPropertyFromRecord(CSVRecord csvRecord) throws CSVParseException {
    // ID
    String id = csvRecord.get(0);
    if (!StringUtils.isSet(id)) {
        throw new CSVParseException(Messages.CSVImporter_6);
    } else {
        checkIDForInvalidCharacters(id);
    }
    // Find referenced concept in newly created list
    IProperties propertiesObject = newConcepts.get(id);
    // Not found, check if it's referencing an existing element in the model
    if (propertiesObject == null) {
        EObject eObject = ArchimateModelUtils.getObjectByID(fModel, id);
        if (eObject instanceof IProperties) {
            propertiesObject = (IProperties) eObject;
        }
    }
    // Not found, check if it's referencing the model
    if (propertiesObject == null && id.equals(modelID)) {
        propertiesObject = fModel;
    }
    // Not found at all
    if (propertiesObject == null) {
        throw new CSVParseException(Messages.CSVImporter_7 + id);
    }
    String key = normalise(csvRecord.get(1));
    String value = normalise(csvRecord.get(2));
    // Special properties for relationship attributes
    if (INFLUENCE_STRENGTH.equals(key) && propertiesObject instanceof IInfluenceRelationship) {
        storeUpdatedConceptFeature((IArchimateConcept) propertiesObject, IArchimatePackage.Literals.INFLUENCE_RELATIONSHIP__STRENGTH, value);
        return;
    } else if (ACCESS_TYPE.equals(key) && propertiesObject instanceof IAccessRelationship) {
        int newvalue = ACCESS_TYPES.indexOf(value);
        storeUpdatedConceptFeature((IArchimateConcept) propertiesObject, IArchimatePackage.Literals.ACCESS_RELATIONSHIP__ACCESS_TYPE, newvalue);
        return;
    }
    // Is there already a property with this key?
    IProperty property = getProperty(propertiesObject, key);
    if (property != null) {
        updatedProperties.put(property, value);
    } else // No, create new one
    {
        property = IArchimateFactory.eINSTANCE.createProperty();
        property.setKey(key);
        property.setValue(value);
        newProperties.put(property, propertiesObject);
    }
}
Also used : IInfluenceRelationship(com.archimatetool.model.IInfluenceRelationship) IProperty(com.archimatetool.model.IProperty) EObject(org.eclipse.emf.ecore.EObject) IArchimateConcept(com.archimatetool.model.IArchimateConcept) IProperties(com.archimatetool.model.IProperties) IAccessRelationship(com.archimatetool.model.IAccessRelationship) CSVParseException(com.archimatetool.csv.CSVParseException)

Example 10 with IArchimateConcept

use of com.archimatetool.model.IArchimateConcept in project archi by archimatetool.

the class MagicConnectionCreationTool method addElementActions.

private void addElementActions(Menu menu, String menuText, IDiagramModelArchimateComponent sourceDiagramModelComponent, EClass[] list) {
    MenuItem item = new MenuItem(menu, SWT.CASCADE);
    item.setText(menuText);
    Menu subMenu = new Menu(item);
    item.setMenu(subMenu);
    IArchimateConcept sourceConcept = sourceDiagramModelComponent.getArchimateConcept();
    for (EClass type : list) {
        // Check if allowed by Viewpoint
        if (!isAllowedTargetTypeInViewpoint(sourceDiagramModelComponent, type)) {
            continue;
        }
        MenuItem subItem = addElementAction(subMenu, type);
        Menu childSubMenu = new Menu(subItem);
        subItem.setMenu(childSubMenu);
        for (EClass typeRel : ArchimateModelUtils.getRelationsClasses()) {
            if (ArchimateModelUtils.isValidRelationship(sourceConcept.eClass(), type, typeRel)) {
                addConnectionAction(childSubMenu, typeRel, false);
            }
        }
        if (childSubMenu.getItemCount() == 0) {
            // Nothing there
            subItem.dispose();
        }
    }
    if (subMenu.getItemCount() == 0) {
        // Nothing there
        item.dispose();
    }
}
Also used : EClass(org.eclipse.emf.ecore.EClass) IArchimateConcept(com.archimatetool.model.IArchimateConcept) MenuItem(org.eclipse.swt.widgets.MenuItem) Menu(org.eclipse.swt.widgets.Menu)

Aggregations

IArchimateConcept (com.archimatetool.model.IArchimateConcept)38 IArchimateRelationship (com.archimatetool.model.IArchimateRelationship)14 ArrayList (java.util.ArrayList)9 IDiagramModel (com.archimatetool.model.IDiagramModel)7 EObject (org.eclipse.emf.ecore.EObject)7 IArchimateElement (com.archimatetool.model.IArchimateElement)6 IDiagramModelArchimateComponent (com.archimatetool.model.IDiagramModelArchimateComponent)6 Test (org.junit.Test)6 IDiagramModelComponent (com.archimatetool.model.IDiagramModelComponent)5 IDiagramModelArchimateConnection (com.archimatetool.model.IDiagramModelArchimateConnection)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)4 IArchimateDiagramEditor (com.archimatetool.editor.diagram.IArchimateDiagramEditor)3 IDiagramModelEditor (com.archimatetool.editor.diagram.IDiagramModelEditor)3 IArchimateModel (com.archimatetool.model.IArchimateModel)3 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)3 CSVParseException (com.archimatetool.csv.CSVParseException)2 NonNotifyingCompoundCommand (com.archimatetool.editor.model.commands.NonNotifyingCompoundCommand)2 IConnectable (com.archimatetool.model.IConnectable)2 IDiagramModelArchimateObject (com.archimatetool.model.IDiagramModelArchimateObject)2 IDiagramModelConnection (com.archimatetool.model.IDiagramModelConnection)2