Search in sources :

Example 26 with IProfile

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

the class ProfilesManagerDialog method updateImagePreview.

/**
 * Update the image preview
 */
private void updateImagePreview() {
    disposePreviewImage();
    IProfile profile = (IProfile) fTableViewer.getStructuredSelection().getFirstElement();
    if (profile != null && profile.getImagePath() != null) {
        IArchiveManager archiveManager = (IArchiveManager) fArchimateModel.getAdapter(IArchiveManager.class);
        try {
            fPreviewImage = archiveManager.createImage(profile.getImagePath());
        } catch (Exception ex) {
            ex.printStackTrace();
            // $NON-NLS-1$
            Logger.logError("Could not create image!", ex);
        }
    }
    fImagePreview.redraw();
}
Also used : IProfile(com.archimatetool.model.IProfile) IArchiveManager(com.archimatetool.editor.model.IArchiveManager)

Example 27 with IProfile

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

the class ProfilesManagerDialog method okPressed.

/**
 * OK was pressed, so see what was added, changed or deleted and execute the Commands
 */
@Override
protected void okPressed() {
    super.okPressed();
    CompoundCommand compoundCmd = new CompoundCommand(Messages.ProfilesManagerDialog_16);
    // Iterate thru our temp list of Profiles
    for (IProfile profile : fProfilesTemp.values()) {
        // Is this a copy of the original?
        if (fProfilesModel.containsKey(profile.getId())) {
            IProfile profileOriginal = fProfilesModel.get(profile.getId());
            // The Profile has been edited
            if (!EcoreUtil.equals(profileOriginal, profile)) {
                List<IProfiles> usages = fProfilesUsage.get(profileOriginal.getId());
                compoundCmd.add(new ChangeProfileCommand(profileOriginal, profile, usages));
            }
        } else // A new Profile was added
        {
            compoundCmd.add(new AddListMemberCommand<IProfile>(fArchimateModel.getProfiles(), profile));
        }
    }
    // Iterate thru model's Profiles and compare with our temp list to see if any Profiles were deleted
    for (IProfile profile : fArchimateModel.getProfiles()) {
        if (!fProfilesTemp.containsKey(profile.getId())) {
            List<IProfiles> usages = fProfilesUsage.get(profile.getId());
            compoundCmd.add(new DeleteProfileCommand(profile, usages));
        }
    }
    // Execute the Commands
    CommandStack stack = (CommandStack) fArchimateModel.getAdapter(CommandStack.class);
    stack.execute(compoundCmd);
}
Also used : CommandStack(org.eclipse.gef.commands.CommandStack) IProfiles(com.archimatetool.model.IProfiles) IProfile(com.archimatetool.model.IProfile) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Example 28 with IProfile

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

the class ProfilesManagerDialog method clearImages.

/**
 * Clear all images and set selected Profiles' image paths to null
 */
private void clearImages() {
    IStructuredSelection selection = fTableViewer.getStructuredSelection();
    for (Object o : selection.toList()) {
        ((IProfile) o).setImagePath(null);
    }
    // Reselect to update image preview
    fTableViewer.setSelection(selection);
}
Also used : IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IProfile(com.archimatetool.model.IProfile)

Example 29 with IProfile

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

the class ModelImporter method doImport.

public void doImport(File importedFile, IArchimateModel targetModel) throws IOException, ImportException {
    if (!importedFile.exists()) {
        throw new IOException(NLS.bind(Messages.ModelImporter_2, importedFile));
    }
    importedModel = IEditorModelManager.INSTANCE.load(importedFile);
    this.targetModel = targetModel;
    objectCache = createObjectIDCache();
    statusMessages = new ArrayList<>();
    compoundCommand = new NonNotifyingCompoundCommand(Messages.ModelImporter_1);
    // Upate root model object if the option is set
    if (updateAll) {
        updateObject(importedModel, targetModel);
        logMessage(StatusMessageLevel.INFO, Messages.ModelImporter_3, targetModel);
    }
    // Iterate through all model contents
    for (Iterator<EObject> iter = importedModel.eAllContents(); iter.hasNext(); ) {
        EObject eObject = iter.next();
        // Update folders
        if (eObject instanceof IFolder) {
            new FolderImporter(this).importFolder((IFolder) eObject);
        } else // Update concepts
        if (eObject instanceof IArchimateConcept) {
            new ConceptImporter(this).importConcept((IArchimateConcept) eObject);
        } else // Update Views
        if (eObject instanceof IDiagramModel) {
            new ViewImporter(this).importView((IDiagramModel) eObject);
        } else // Update Profiles
        if (eObject instanceof IProfile) {
            new ProfileImporter(this).importProfile((IProfile) eObject);
        }
    }
    if (compoundCommand.canExecute()) {
        // Check view connection ends are valid if we have done some commands and even if update is off
        addCommand(new SetArchimateReconnectionCommand(targetModel));
    // Check duplicate names in Profiles
    // TODO: No more needed because we match profiles by name and can't generate duplicates
    // addCommand(new UnduplicateProfileNamesCommand(targetModel));
    }
    // Run Commands
    CommandStack stack = (CommandStack) targetModel.getAdapter(CommandStack.class);
    stack.execute(compoundCommand);
    objectCache.clear();
    objectCache = null;
    importedModel = null;
    this.targetModel = null;
}
Also used : NonNotifyingCompoundCommand(com.archimatetool.editor.model.commands.NonNotifyingCompoundCommand) CommandStack(org.eclipse.gef.commands.CommandStack) IOException(java.io.IOException) IDiagramModel(com.archimatetool.model.IDiagramModel) EObject(org.eclipse.emf.ecore.EObject) IArchimateConcept(com.archimatetool.model.IArchimateConcept) IProfile(com.archimatetool.model.IProfile) IFolder(com.archimatetool.model.IFolder)

Example 30 with IProfile

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

the class ProfileImporter method addNewProfile.

private void addNewProfile(IProfile importedProfile) throws IOException {
    // Clone the imported Profile
    IProfile newProfile = cloneObject(importedProfile);
    // Add the clone
    addCommand(new AddListMemberCommand<IProfile>(getTargetModel().getProfiles(), newProfile));
    // Import any image bytes
    importImageBytes(importedProfile, newProfile);
    // Log
    logMessage(StatusMessageLevel.INFO, Messages.ProfileImporter_1, newProfile);
}
Also used : IProfile(com.archimatetool.model.IProfile)

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