Search in sources :

Example 1 with RoleStereotypeSelectionDialog

use of org.palladiosimulator.architecturaltemplates.ui.dialogs.RoleStereotypeSelectionDialog in project Palladio-Editors-Sirius by PalladioSimulator.

the class AddATRoleAction method execute.

/**
 * Asks the user to select a {@link Role} and attaches it to the given {@link AssemblyContext}.
 */
@Override
public void execute(final Collection<? extends EObject> selections, final Map<String, Object> parameters) {
    final EObject selection = selections.iterator().next();
    // final AssemblyContext assemblyContext = (AssemblyContext) selections.iterator().next();
    final LinkedList<Stereotype> unapplyedStereotypes = new LinkedList<>();
    for (final Stereotype stereotype : StereotypeAPI.getApplicableStereotypes(selection)) {
        if (!StereotypeAPI.isStereotypeApplied(selection, stereotype.getName())) {
            unapplyedStereotypes.add(stereotype);
        }
    }
    final RoleStereotypeSelectionDialog dialog = new RoleStereotypeSelectionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
    dialog.setMessage(DIALOG_MESSAGE + selection.eClass().getName());
    dialog.setElements(unapplyedStereotypes.toArray(new Stereotype[0]));
    if (dialog.open() != Dialog.OK) {
        return;
    }
    final Stereotype selectedRoleStereotype = dialog.getResultRoleStereotype();
    StereotypeAPI.applyStereotype(selection, selectedRoleStereotype);
}
Also used : RoleStereotypeSelectionDialog(org.palladiosimulator.architecturaltemplates.ui.dialogs.RoleStereotypeSelectionDialog) EObject(org.eclipse.emf.ecore.EObject) Stereotype(org.modelversioning.emfprofile.Stereotype) LinkedList(java.util.LinkedList)

Aggregations

LinkedList (java.util.LinkedList)1 EObject (org.eclipse.emf.ecore.EObject)1 Stereotype (org.modelversioning.emfprofile.Stereotype)1 RoleStereotypeSelectionDialog (org.palladiosimulator.architecturaltemplates.ui.dialogs.RoleStereotypeSelectionDialog)1