Search in sources :

Example 1 with DeriveSubdomainsFromRequirementsWizard

use of org.contextmapper.dsl.ui.handler.wizard.DeriveSubdomainsFromRequirementsWizard in project context-mapper-dsl by ContextMapper.

the class GenerateSubdomainFromUserRequirementsRefactoringHandler method executeRefactoring.

@Override
protected void executeRefactoring(CMLResource resource, ExecutionEvent event) {
    Set<UserRequirement> userRequirements = getAllSelectedElements().stream().filter(o -> o instanceof UserRequirement).map(o -> (UserRequirement) o).collect(Collectors.toSet());
    List<String> allDomains = getCurrentContextMappingModel().getDomains().stream().map(d -> d.getName()).collect(Collectors.toList());
    String initialDomain = allDomains.isEmpty() ? "" : allDomains.iterator().next();
    DeriveSubdomainsFromRequirementsContext refactoringContext = new DeriveSubdomainsFromRequirementsContext(initialDomain, collectAllDomainsAndSubdomains(getCurrentContextMappingModel()));
    new WizardDialog(HandlerUtil.getActiveShell(event), new DeriveSubdomainsFromRequirementsWizard(refactoringContext, executionContext -> {
        return finishRefactoring(new DeriveSubdomainFromUserRequirements(executionContext.getDomainName(), executionContext.getSubdomainName(), userRequirements.stream().map(ur -> ur.getName()).collect(Collectors.toSet())), resource, event);
    })).open();
}
Also used : ExecutionEvent(org.eclipse.core.commands.ExecutionEvent) ContextMappingModel(org.contextmapper.dsl.contextMappingDSL.ContextMappingModel) DeriveSubdomainsFromRequirementsWizard(org.contextmapper.dsl.ui.handler.wizard.DeriveSubdomainsFromRequirementsWizard) Set(java.util.Set) DeriveSubdomainsFromRequirementsContext(org.contextmapper.dsl.ui.handler.wizard.DeriveSubdomainsFromRequirementsContext) EObject(org.eclipse.emf.ecore.EObject) Collectors(java.util.stream.Collectors) Maps(com.google.common.collect.Maps) HandlerUtil(org.eclipse.ui.handlers.HandlerUtil) DeriveSubdomainFromUserRequirements(org.contextmapper.dsl.refactoring.DeriveSubdomainFromUserRequirements) List(java.util.List) Domain(org.contextmapper.dsl.contextMappingDSL.Domain) UserRequirement(org.contextmapper.dsl.contextMappingDSL.UserRequirement) WizardDialog(org.eclipse.jface.wizard.WizardDialog) Map(java.util.Map) CMLResource(org.contextmapper.dsl.cml.CMLResource) DeriveSubdomainsFromRequirementsContext(org.contextmapper.dsl.ui.handler.wizard.DeriveSubdomainsFromRequirementsContext) UserRequirement(org.contextmapper.dsl.contextMappingDSL.UserRequirement) DeriveSubdomainFromUserRequirements(org.contextmapper.dsl.refactoring.DeriveSubdomainFromUserRequirements) DeriveSubdomainsFromRequirementsWizard(org.contextmapper.dsl.ui.handler.wizard.DeriveSubdomainsFromRequirementsWizard) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Aggregations

Maps (com.google.common.collect.Maps)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 CMLResource (org.contextmapper.dsl.cml.CMLResource)1 ContextMappingModel (org.contextmapper.dsl.contextMappingDSL.ContextMappingModel)1 Domain (org.contextmapper.dsl.contextMappingDSL.Domain)1 UserRequirement (org.contextmapper.dsl.contextMappingDSL.UserRequirement)1 DeriveSubdomainFromUserRequirements (org.contextmapper.dsl.refactoring.DeriveSubdomainFromUserRequirements)1 DeriveSubdomainsFromRequirementsContext (org.contextmapper.dsl.ui.handler.wizard.DeriveSubdomainsFromRequirementsContext)1 DeriveSubdomainsFromRequirementsWizard (org.contextmapper.dsl.ui.handler.wizard.DeriveSubdomainsFromRequirementsWizard)1 ExecutionEvent (org.eclipse.core.commands.ExecutionEvent)1 EObject (org.eclipse.emf.ecore.EObject)1 WizardDialog (org.eclipse.jface.wizard.WizardDialog)1 HandlerUtil (org.eclipse.ui.handlers.HandlerUtil)1