use of org.modelversioning.emfprofile.Stereotype 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);
}
use of org.modelversioning.emfprofile.Stereotype in project Palladio-Editors-Sirius by PalladioSimulator.
the class ApplyUnapplyStereotypeAction method execute.
@SuppressWarnings("unchecked")
@Override
public void execute(final Collection<? extends EObject> selections, final Map<String, Object> parameters) {
final EObject target = ((DSemanticDecorator) selections.iterator().next()).getTarget();
final boolean targetHasProfileApplication = ProfileAPI.hasProfileApplication(target.eResource());
final FeatureEditorDialog stereotypeSelectionDialog = new FeatureEditorDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), LABEL_PROVIDER, target, target.eClass().getEAllStructuralFeatures().get(0).getEType(), targetHasProfileApplication ? StereotypeAPI.getAppliedStereotypes(target) : Collections.EMPTY_LIST, SELECT_APPLIED_STEREOTYPES_MESSAGE, targetHasProfileApplication ? StereotypeAPI.getApplicableStereotypes(target) : Collections.EMPTY_LIST, true, false, false);
if (stereotypeSelectionDialog.open() == Dialog.OK) {
StereotypeAPI.updateStereotypeApplications(target, (EList<Stereotype>) stereotypeSelectionDialog.getResult());
}
}
Aggregations