Package: MultiSelectionValidator
MultiSelectionValidator
name | instruction | branch | complexity | line | method | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
MultiSelectionValidator() |
|
|
|
|
|
||||||||||||||||||||
isValid(EStructuralFeature) |
|
|
|
|
|
Coverage
1: /*******************************************************************************
2: * Copyright (c) 2011-2019 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: * lucas - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emfforms.internal.view.multisegment.tooling;
15:
16: import org.eclipse.emf.ecore.EReference;
17: import org.eclipse.emf.ecore.EStructuralFeature;
18: import org.eclipse.emf.ecp.view.spi.editor.controls.EStructuralFeatureSelectionValidator;
19:
20: /**
21: * Validates that the selected {@link EStructuralFeature} is a multi {@link EReference}.
22: *
23: * @author Lucas Koehler
24: *
25: */
26: public class MultiSelectionValidator implements EStructuralFeatureSelectionValidator {
27:
28:         /** The message for a failed validation. */
29:         static final String ERROR_MESSAGE = "A multi reference must be selected."; //$NON-NLS-1$
30:
31:         @Override
32:         public String isValid(EStructuralFeature structuralFeature) {
33:•                if (structuralFeature != null && EReference.class.isInstance(structuralFeature)
34:•                        && structuralFeature.isMany()) {
35:                         return null;
36:                 }
37:                 return ERROR_MESSAGE;
38:         }
39:
40: }