Search in sources :

Example 1 with Stereotype

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);
}
Also used : RoleStereotypeSelectionDialog(org.palladiosimulator.architecturaltemplates.ui.dialogs.RoleStereotypeSelectionDialog) EObject(org.eclipse.emf.ecore.EObject) Stereotype(org.modelversioning.emfprofile.Stereotype) LinkedList(java.util.LinkedList)

Example 2 with Stereotype

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());
    }
}
Also used : DSemanticDecorator(org.eclipse.sirius.viewpoint.DSemanticDecorator) FeatureEditorDialog(org.eclipse.emf.edit.ui.celleditor.FeatureEditorDialog) EObject(org.eclipse.emf.ecore.EObject) Stereotype(org.modelversioning.emfprofile.Stereotype)

Aggregations

EObject (org.eclipse.emf.ecore.EObject)2 Stereotype (org.modelversioning.emfprofile.Stereotype)2 LinkedList (java.util.LinkedList)1 FeatureEditorDialog (org.eclipse.emf.edit.ui.celleditor.FeatureEditorDialog)1 DSemanticDecorator (org.eclipse.sirius.viewpoint.DSemanticDecorator)1 RoleStereotypeSelectionDialog (org.palladiosimulator.architecturaltemplates.ui.dialogs.RoleStereotypeSelectionDialog)1