Search in sources :

Example 1 with System

use of org.palladiosimulator.pcm.system.System in project Palladio-Editors-Sirius by PalladioSimulator.

the class AddATAction method execute.

/**
 * Creates an {@link ArchitecturalTemplateSelectEObjectDialog} that queries the user for an
 * {@link AT} and applies the corresponding {@link Stereotype} to the selected {@link System}.
 */
@Override
public void execute(final Collection<? extends EObject> selections, final Map<String, Object> parameters) {
    final ArchitecturalTemplateSelectionDialog profileSelectionDialog = new ArchitecturalTemplateSelectionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
    profileSelectionDialog.setElements(ArchitecturalTemplateAPI.getRegisteredArchitecturalTemplates().toArray(new AT[ArchitecturalTemplateAPI.getRegisteredArchitecturalTemplates().size()]));
    profileSelectionDialog.setMessage(DIALOG_MESSAGE);
    if (profileSelectionDialog.open() != Dialog.OK) {
        return;
    }
    final AT at = profileSelectionDialog.getResultArchitecturalTemplate();
    final EObject eObject = selections.iterator().next();
    if (eObject instanceof System) {
        final System system = (System) eObject;
        ArchitecturalTemplateAPI.applyArchitecturalTemplate(system, at);
    } else if (eObject instanceof ResourceEnvironment) {
        final ResourceEnvironment resourceenvironment = (ResourceEnvironment) eObject;
        ArchitecturalTemplateAPI.applyArchitecturalTemplate(resourceenvironment, at);
    } else {
        throw new RuntimeException("Unsupported eObject: " + eObject);
    }
}
Also used : ResourceEnvironment(org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment) AT(org.palladiosimulator.architecturaltemplates.AT) ArchitecturalTemplateSelectionDialog(org.palladiosimulator.architecturaltemplates.ui.dialogs.ArchitecturalTemplateSelectionDialog) EObject(org.eclipse.emf.ecore.EObject) System(org.palladiosimulator.pcm.system.System)

Example 2 with System

use of org.palladiosimulator.pcm.system.System in project Palladio-Editors-Sirius by PalladioSimulator.

the class RemoveATAction method execute.

/**
 * Removes the selected Architectural Template from the {@link System}
 *
 * @edited by Edith to unapply ResourceEnvironment stereotypesApplications too
 */
@Override
public void execute(final Collection<? extends EObject> selections, final Map<String, Object> parameters) {
    final EObject selection = selections.iterator().next();
    if (selection instanceof StereotypeApplication) {
        final StereotypeApplication stereotypeApplication = (StereotypeApplication) selection;
        if (stereotypeApplication.getAppliedTo() instanceof System) {
            final System system = (System) stereotypeApplication.getAppliedTo();
            ArchitecturalTemplateAPI.unapplyArchitecturalTemplate(system, stereotypeApplication.getStereotype().getProfile());
        } else
            throw new RuntimeException("Unsupported stereoApplication removal: " + stereotypeApplication.getAppliedTo());
    } else if (selection instanceof ProfileImport) {
        final ProfileImport profileImport = (ProfileImport) selection;
        ProfileAPI.unapplyProfile(profileImport.eResource(), profileImport.getProfile());
    }
}
Also used : EObject(org.eclipse.emf.ecore.EObject) StereotypeApplication(org.modelversioning.emfprofileapplication.StereotypeApplication) ProfileImport(org.modelversioning.emfprofileapplication.ProfileImport) System(org.palladiosimulator.pcm.system.System)

Aggregations

EObject (org.eclipse.emf.ecore.EObject)2 System (org.palladiosimulator.pcm.system.System)2 ProfileImport (org.modelversioning.emfprofileapplication.ProfileImport)1 StereotypeApplication (org.modelversioning.emfprofileapplication.StereotypeApplication)1 AT (org.palladiosimulator.architecturaltemplates.AT)1 ArchitecturalTemplateSelectionDialog (org.palladiosimulator.architecturaltemplates.ui.dialogs.ArchitecturalTemplateSelectionDialog)1 ResourceEnvironment (org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment)1