Search in sources :

Example 1 with IProfile

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

the class CSVImporter method setProfileForNewConcept.

// -------------------------------- Profile Helpers --------------------------------
/**
 * Set a profile for a newly created concept
 */
private void setProfileForNewConcept(IArchimateConcept newConcept, String specializationName) {
    // Do we have a matching Profile in the model?
    IProfile profile = findModelProfile(specializationName, newConcept.eClass().getName());
    // No, so create a new Profile and add it to the lookup list
    if (profile == null) {
        profile = createNewProfile(specializationName, newConcept.eClass().getName());
    }
    // Assign it
    newConcept.getProfiles().add(profile);
}
Also used : IProfile(com.archimatetool.model.IProfile)

Example 2 with IProfile

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

the class CSVExporter method createElementRow.

/**
 * Create a String Row for an Element
 */
String createElementRow(IArchimateElement element) {
    StringBuffer sb = new StringBuffer();
    // ID
    String id = element.getId();
    sb.append(surroundWithQuotes(id));
    sb.append(fDelimiter);
    // Class
    sb.append(surroundWithQuotes(element.eClass().getName()));
    sb.append(fDelimiter);
    // Name
    String name = normalise(element.getName());
    sb.append(surroundWithQuotes(name));
    sb.append(fDelimiter);
    // Documentation
    String documentation = normalise(element.getDocumentation());
    sb.append(surroundWithQuotes(documentation));
    sb.append(fDelimiter);
    // Specialization
    IProfile profile = element.getPrimaryProfile();
    // $NON-NLS-1$
    String specialization = normalise(profile != null ? profile.getName() : "");
    sb.append(surroundWithQuotes(specialization));
    return sb.toString();
}
Also used : IProfile(com.archimatetool.model.IProfile)

Example 3 with IProfile

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

the class CSVExporterTests method testCreateElementRow.

@Test
public void testCreateElementRow() {
    IArchimateElement element = IArchimateFactory.eINSTANCE.createBusinessActor();
    element.setId("a1234567");
    element.setName("The Main Man");
    element.setDocumentation("This is the Documentation");
    IProfile profile = IArchimateFactory.eINSTANCE.createProfile();
    profile.setName("Profile");
    element.getProfiles().add(profile);
    assertEquals("\"a1234567\",\"BusinessActor\",\"The Main Man\",\"This is the Documentation\",\"Profile\"", exporter.createElementRow(element));
}
Also used : IArchimateElement(com.archimatetool.model.IArchimateElement) IProfile(com.archimatetool.model.IProfile) Test(org.junit.Test)

Example 4 with IProfile

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

the class ProfilesManagerDialog method createNewProfile.

/**
 * Create a new Profile and add it to the temp profiles list
 */
private void createNewProfile() {
    IProfile profile = IArchimateFactory.eINSTANCE.createProfile();
    profile.setConceptType(fDefaultClass.getName());
    profile.setName(generateNewProfileName(profile.getConceptType()));
    fProfilesTemp.put(profile.getId(), profile);
    // fTableViewer.applyEditorValue(); // complete any current editing
    fTableViewer.refresh();
    fTableViewer.editElement(profile, 1);
}
Also used : IProfile(com.archimatetool.model.IProfile)

Example 5 with IProfile

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

the class ProfilesManagerDialog method chooseImage.

/**
 * Choose an image from the dialog and apply to selected profiles
 */
private void chooseImage() {
    IStructuredSelection selection = fTableViewer.getStructuredSelection();
    if (!selection.isEmpty()) {
        IProfile firstSelected = (IProfile) selection.getFirstElement();
        ImageManagerDialog dialog = new ImageManagerDialog(getParentShell());
        dialog.setSelected(fArchimateModel, firstSelected.getImagePath());
        if (dialog.open() == Window.OK) {
            try {
                IArchiveManager archiveManager = (IArchiveManager) fArchimateModel.getAdapter(IArchiveManager.class);
                String path = null;
                // Image from file
                if (dialog.getUserSelectedFile() != null && dialog.getUserSelectedFile().exists()) {
                    path = archiveManager.addImageFromFile(dialog.getUserSelectedFile());
                } else // Existing image which could be in this model or a different model
                if (dialog.getUserSelectedImagePath() != null) {
                    if (dialog.getUserSelectedModel() != fArchimateModel) {
                        // Different model
                        IArchiveManager selectedArchiveManager = (IArchiveManager) dialog.getUserSelectedModel().getAdapter(IArchiveManager.class);
                        path = archiveManager.copyImageBytes(selectedArchiveManager, dialog.getUserSelectedImagePath());
                    } else {
                        // Same model
                        path = dialog.getUserSelectedImagePath();
                    }
                }
                if (path != null) {
                    // Apply the image path to Profiles that can have an image
                    for (Object o : selection.toList()) {
                        IProfile profile = (IProfile) o;
                        if (canHaveImage(profile)) {
                            profile.setImagePath(path);
                        }
                    }
                }
            } catch (Exception ex) {
                ex.printStackTrace();
                // $NON-NLS-1$
                Logger.logError("Could not create image!", ex);
            }
            // Select to update image preview
            fTableViewer.setSelection(selection);
        }
    }
}
Also used : ImageManagerDialog(com.archimatetool.editor.propertysections.ImageManagerDialog) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IProfile(com.archimatetool.model.IProfile) IArchiveManager(com.archimatetool.editor.model.IArchiveManager)

Aggregations

IProfile (com.archimatetool.model.IProfile)34 Test (org.junit.Test)11 IArchimateModel (com.archimatetool.model.IArchimateModel)7 IArchimateConcept (com.archimatetool.model.IArchimateConcept)6 IArchimateElement (com.archimatetool.model.IArchimateElement)6 IDiagramModel (com.archimatetool.model.IDiagramModel)4 EObject (org.eclipse.emf.ecore.EObject)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)4 IArchimateModelObject (com.archimatetool.model.IArchimateModelObject)3 IArchimateRelationship (com.archimatetool.model.IArchimateRelationship)3 IDiagramModelArchimateObject (com.archimatetool.model.IDiagramModelArchimateObject)3 IProfiles (com.archimatetool.model.IProfiles)3 List (java.util.List)3 IArchiveManager (com.archimatetool.editor.model.IArchiveManager)2 IDiagramModelArchimateConnection (com.archimatetool.model.IDiagramModelArchimateConnection)2 IFolder (com.archimatetool.model.IFolder)2 ArrayList (java.util.ArrayList)2 CommandStack (org.eclipse.gef.commands.CommandStack)2 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)2 IStructuredContentProvider (org.eclipse.jface.viewers.IStructuredContentProvider)2