Skip to content

Package: LabelAlignmentMigration

LabelAlignmentMigration

nameinstructionbranchcomplexitylinemethod
LabelAlignmentMigration()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
migrateAfter(Model, Metamodel)
M: 0 C: 47
100%
M: 0 C: 4
100%
M: 0 C: 3
100%
M: 0 C: 12
100%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2015 EclipseSource Muenchen GmbH and others.
3: *
4: * All rights reserved. This program and the accompanying materials
5: * are made available under the terms of the Eclipse Public License 2.0
6: * which accompanies this distribution, and is available at
7: * https://www.eclipse.org/legal/epl-2.0/
8: *
9: * SPDX-License-Identifier: EPL-2.0
10: *
11: * Contributors:
12: * Johannes Faltermeier - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emf.ecp.internal.view.model.edapt._160to170;
15:
16: import org.eclipse.emf.common.util.EList;
17: import org.eclipse.emf.ecore.EAttribute;
18: import org.eclipse.emf.ecore.EEnum;
19: import org.eclipse.emf.ecore.EEnumLiteral;
20: import org.eclipse.emf.edapt.migration.CustomMigration;
21: import org.eclipse.emf.edapt.migration.MigrationException;
22: import org.eclipse.emf.edapt.spi.migration.Instance;
23: import org.eclipse.emf.edapt.spi.migration.Metamodel;
24: import org.eclipse.emf.edapt.spi.migration.Model;
25:
26: /**
27: * This migration will make sure that after the default of the label alignment has been changed from left to default,
28: * left is still used for the old models.
29: *
30: * @author Johannes Faltermeier
31: *
32: */
33: public class LabelAlignmentMigration extends CustomMigration {
34:
35:         @Override
36:         public void migrateAfter(Model model, Metamodel metamodel) throws MigrationException {
37:                 final EAttribute eAttribute = metamodel
38:                         .getEAttribute("http://org/eclipse/emf/ecp/view/model/170.Control.labelAlignment"); //$NON-NLS-1$
39:                 final EEnum eenum = EEnum.class.cast(eAttribute.getEAttributeType());
40:                 final EEnumLiteral left = eenum.getEEnumLiteral("Left"); //$NON-NLS-1$
41:                 final EEnumLiteral def = eenum.getEEnumLiteral("Default"); //$NON-NLS-1$
42:
43:                 final EList<Instance> allControlsIncludingSubclasses = model
44:                         .getAllInstances("http://org/eclipse/emf/ecp/view/model/170.Control"); //$NON-NLS-1$
45:•                for (final Instance control : allControlsIncludingSubclasses) {
46:                         final Object object = control.get(eAttribute);
47:•                        if (def.getInstance() == object) {
48:                                 control.set(eAttribute, left.getInstance());
49:                         }
50:                 }
51:         }
52: }