Search in sources :

Example 1 with Volatility

use of org.contextmapper.dsl.contextMappingDSL.Volatility in project context-mapper-dsl by ContextMapper.

the class LikelihoodForChangeSelectionWizardPage method createControl.

@Override
public void createControl(Composite parent) {
    container = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    container.setLayout(layout);
    layout.numColumns = 2;
    // name label
    Label boundedContextNameLabel1 = new Label(container, SWT.NONE);
    boundedContextNameLabel1.setText("Volatility (Likelihood for Change):");
    // selection field
    selectionCombo = new Combo(container, SWT.DROP_DOWN);
    selectionCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    List<String> selectionStrings = Arrays.asList(Volatility.values()).stream().map(l -> l.getName()).collect(Collectors.toList());
    selectionCombo.setItems(selectionStrings.toArray(new String[selectionStrings.size()]));
    selectionCombo.select(selectionStrings.indexOf(Volatility.OFTEN.getName()));
    selectionCombo.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            setPageComplete(isPageComplete());
            updateValidationMessage();
        }
    });
    selectionCombo.addKeyListener(new KeyAdapter() {

        @Override
        public void keyReleased(KeyEvent e) {
            setPageComplete(isPageComplete());
            updateValidationMessage();
        }
    });
    setControl(container);
    setPageComplete(false);
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Arrays(java.util.Arrays) Combo(org.eclipse.swt.widgets.Combo) Volatility(org.contextmapper.dsl.contextMappingDSL.Volatility) Collectors(java.util.stream.Collectors) Program(org.eclipse.swt.program.Program) List(java.util.List) Composite(org.eclipse.swt.widgets.Composite) SWT(org.eclipse.swt.SWT) KeyEvent(org.eclipse.swt.events.KeyEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GridData(org.eclipse.swt.layout.GridData) KeyAdapter(org.eclipse.swt.events.KeyAdapter) Label(org.eclipse.swt.widgets.Label) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) KeyAdapter(org.eclipse.swt.events.KeyAdapter) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) KeyEvent(org.eclipse.swt.events.KeyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 2 with Volatility

use of org.contextmapper.dsl.contextMappingDSL.Volatility in project context-mapper-dsl by ContextMapper.

the class ExtractAggregatesByVolatilityRefactoringHandler method isEnabled.

@Override
public boolean isEnabled() {
    EObject obj = getSelectedElement();
    if (obj == null || !super.isEnabled())
        return false;
    // only allowed on bounded contexts
    if (!(obj instanceof BoundedContext))
        return false;
    BoundedContext bc = (BoundedContext) obj;
    List<Volatility> likelihoods = bc.getAggregates().stream().map(agg -> agg.getLikelihoodForChange()).collect(Collectors.toList());
    return likelihoods.size() > 1;
}
Also used : ExecutionEvent(org.eclipse.core.commands.ExecutionEvent) ExtractAggregatesByVolatility(org.contextmapper.dsl.refactoring.ExtractAggregatesByVolatility) List(java.util.List) Volatility(org.contextmapper.dsl.contextMappingDSL.Volatility) ExtractAggregatesByVolatilityContext(org.contextmapper.dsl.ui.handler.wizard.ExtractAggregatesByVolatilityContext) WizardDialog(org.eclipse.jface.wizard.WizardDialog) ExtractAggregatesByVolatilityRefactoringWizard(org.contextmapper.dsl.ui.handler.wizard.ExtractAggregatesByVolatilityRefactoringWizard) EObject(org.eclipse.emf.ecore.EObject) Collectors(java.util.stream.Collectors) CMLResource(org.contextmapper.dsl.cml.CMLResource) BoundedContext(org.contextmapper.dsl.contextMappingDSL.BoundedContext) HandlerUtil(org.eclipse.ui.handlers.HandlerUtil) ExtractAggregatesByVolatility(org.contextmapper.dsl.refactoring.ExtractAggregatesByVolatility) Volatility(org.contextmapper.dsl.contextMappingDSL.Volatility) EObject(org.eclipse.emf.ecore.EObject) BoundedContext(org.contextmapper.dsl.contextMappingDSL.BoundedContext)

Aggregations

List (java.util.List)2 Collectors (java.util.stream.Collectors)2 Volatility (org.contextmapper.dsl.contextMappingDSL.Volatility)2 Arrays (java.util.Arrays)1 CMLResource (org.contextmapper.dsl.cml.CMLResource)1 BoundedContext (org.contextmapper.dsl.contextMappingDSL.BoundedContext)1 ExtractAggregatesByVolatility (org.contextmapper.dsl.refactoring.ExtractAggregatesByVolatility)1 ExtractAggregatesByVolatilityContext (org.contextmapper.dsl.ui.handler.wizard.ExtractAggregatesByVolatilityContext)1 ExtractAggregatesByVolatilityRefactoringWizard (org.contextmapper.dsl.ui.handler.wizard.ExtractAggregatesByVolatilityRefactoringWizard)1 ExecutionEvent (org.eclipse.core.commands.ExecutionEvent)1 EObject (org.eclipse.emf.ecore.EObject)1 WizardDialog (org.eclipse.jface.wizard.WizardDialog)1 SWT (org.eclipse.swt.SWT)1 KeyAdapter (org.eclipse.swt.events.KeyAdapter)1 KeyEvent (org.eclipse.swt.events.KeyEvent)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Program (org.eclipse.swt.program.Program)1