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);
}
Aggregations