Search in sources :

Example 1 with ClassifierOperationExecutor

use of org.osate.ge.aadl2.internal.util.classifiers.ClassifierOperationExecutor in project osate2 by osate.

the class CreateClassifierPaletteCommand method getOperation.

@Override
public Optional<Operation> getOperation(final GetTargetedOperationContext ctx) {
    return ctx.getTarget().getBusinessObject(EObject.class).map(targetBo -> {
        if (!(targetBo instanceof AadlPackage || isValidBaseClassifier(targetBo))) {
            return null;
        }
        final BusinessObjectContext pkgBoc = getPackageBoc(ctx.getTarget(), ctx.getQueryService());
        if (pkgBoc == null) {
            return null;
        }
        final AadlPackage pkg = (AadlPackage) pkgBoc.getBusinessObject();
        final IProject project = ProjectUtil.getProjectForBoOrThrow(pkg);
        final ResourceSet rs = targetBo.eResource().getResourceSet();
        return Operation.createWithBuilder(builder -> {
            builder.supply(() -> {
                final ClassifierOperation args = buildCreateOperations(pkg, targetBo, project, rs);
                if (args == null) {
                    return StepResult.abort();
                }
                return StepResult.forValue(args);
            }).executeOperation(classifierOp -> Operation.createWithBuilder(innerBuilder -> {
                final ClassifierOperationExecutor opExec = new ClassifierOperationExecutor(rs, project);
                opExec.execute(innerBuilder, classifierOp, pkgBoc);
            }));
        });
    });
}
Also used : DefaultCreateSelectClassifierDialogModel(org.osate.ge.aadl2.ui.internal.dialogs.DefaultCreateSelectClassifierDialogModel) StepResult(org.osate.ge.operations.StepResult) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) ClassifierOperationDialog(org.osate.ge.aadl2.ui.internal.dialogs.ClassifierOperationDialog) ClassifierCreationHelper(org.osate.ge.aadl2.internal.util.classifiers.ClassifierCreationHelper) BusinessObjectContext(org.osate.ge.BusinessObjectContext) AadlImages(org.osate.ge.aadl2.internal.AadlImages) BasePaletteCommand(org.osate.ge.palette.BasePaletteCommand) IProject(org.eclipse.core.resources.IProject) EClass(org.eclipse.emf.ecore.EClass) Classifier(org.osate.aadl2.Classifier) ImmutableList(com.google.common.collect.ImmutableList) AadlUiUtil(org.osate.ge.aadl2.ui.internal.AadlUiUtil) Aadl2Package(org.osate.aadl2.Aadl2Package) EnumSet(java.util.EnumSet) ClassifierOperation(org.osate.ge.aadl2.internal.util.classifiers.ClassifierOperation) ClassifierOperationPartType(org.osate.ge.aadl2.internal.util.classifiers.ClassifierOperationPartType) GetTargetedOperationContext(org.osate.ge.palette.GetTargetedOperationContext) Operation(org.osate.ge.operations.Operation) Collection(java.util.Collection) ClassifierOperationExecutor(org.osate.ge.aadl2.internal.util.classifiers.ClassifierOperationExecutor) AadlClassifierUtil(org.osate.ge.aadl2.internal.util.AadlClassifierUtil) EObject(org.eclipse.emf.ecore.EObject) AadlPackage(org.osate.aadl2.AadlPackage) Display(org.eclipse.swt.widgets.Display) ProjectUtil(org.osate.ge.ProjectUtil) QueryService(org.osate.ge.services.QueryService) ComponentCategory(org.osate.aadl2.ComponentCategory) StringUtil(org.osate.ge.StringUtil) AadlCategories(org.osate.ge.aadl2.AadlCategories) Optional(java.util.Optional) AadlNamingUtil(org.osate.ge.aadl2.internal.AadlNamingUtil) ClassifierOperationPart(org.osate.ge.aadl2.internal.util.classifiers.ClassifierOperationPart) ExecutableQuery(org.osate.ge.query.ExecutableQuery) TargetedPaletteCommand(org.osate.ge.palette.TargetedPaletteCommand) AadlPackage(org.osate.aadl2.AadlPackage) ClassifierOperationExecutor(org.osate.ge.aadl2.internal.util.classifiers.ClassifierOperationExecutor) EObject(org.eclipse.emf.ecore.EObject) ClassifierOperation(org.osate.ge.aadl2.internal.util.classifiers.ClassifierOperation) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) BusinessObjectContext(org.osate.ge.BusinessObjectContext) IProject(org.eclipse.core.resources.IProject)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1 Collection (java.util.Collection)1 EnumSet (java.util.EnumSet)1 Optional (java.util.Optional)1 IProject (org.eclipse.core.resources.IProject)1 EClass (org.eclipse.emf.ecore.EClass)1 EObject (org.eclipse.emf.ecore.EObject)1 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)1 Display (org.eclipse.swt.widgets.Display)1 Aadl2Package (org.osate.aadl2.Aadl2Package)1 AadlPackage (org.osate.aadl2.AadlPackage)1 Classifier (org.osate.aadl2.Classifier)1 ComponentCategory (org.osate.aadl2.ComponentCategory)1 BusinessObjectContext (org.osate.ge.BusinessObjectContext)1 ProjectUtil (org.osate.ge.ProjectUtil)1 StringUtil (org.osate.ge.StringUtil)1 AadlCategories (org.osate.ge.aadl2.AadlCategories)1 AadlImages (org.osate.ge.aadl2.internal.AadlImages)1 AadlNamingUtil (org.osate.ge.aadl2.internal.AadlNamingUtil)1 AadlClassifierUtil (org.osate.ge.aadl2.internal.util.AadlClassifierUtil)1