Skip to content

Package: ValidationUpdateListener

ValidationUpdateListener

nameinstructionbranchcomplexitylinemethod
deregister(ValidationService, ValidationUpdateListener)
M: 8 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
register(ValidationService, ValidationUpdateListener)
M: 2 C: 9
82%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 1 C: 3
75%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2019 Christian W. Damus 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: * Christian W. Damus - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emf.ecp.view.spi.validation;
15:
16: import java.util.Collection;
17:
18: import org.eclipse.emf.common.util.Diagnostic;
19: import org.eclipse.emf.ecore.EObject;
20: import org.eclipse.emf.ecore.EStructuralFeature;
21:
22: /**
23: * An alternative validation listener that is most useful in applications that
24: * {@linkplain ValidationServiceConstants#PROPAGATION_LIMIT_KEY throttle problem reporting},
25: * to be notified of all problems found by validation, regardless of limits imposed by
26: * the presentation in the editor.
27: *
28: * @since 1.22
29: */
30: public interface ValidationUpdateListener {
31:
32:         /**
33:          * <p>
34:          * Notifies the listener of updates to the model validation state.
35:          * This is an incremental update: it provides validation status of settings
36:          * in model objects, including results that explicitly indicate absence
37:          * of problems (indicating that problems previously reported are resolved).
38:          * Every diagnostic in the collection has at least two elements in the
39:          * {@link Diagnostic#getData() data} list, of which the first two are:
40:          * </p>
41:          * <p>
42:          * <ol>
43:          * <li>the {@link EObject} that owns the feature that was validated</li>
44:          * <li>the {@link EStructuralFeature} of the object that was validated</li>
45:          * </ol>
46:          * </p>
47:          * <p>
48:          * If any feature of any object that was previously reported as having
49:          * problems no longer has problems, then an {@link Diagnostic#OK} diagnostic
50:          * will be present for that setting. Otherwise, there may be one or more
51:          * problem diagnostics for that setting. In any case, if the validation
52:          * state of a setting is changed, then this collection contains the entire
53:          * current validation state of that setting.
54:          * </p>
55:          *
56:          * @param diagnostics the current validation problems in settings (features
57:          * of objects) that were validated
58:          */
59:         void validationUpdated(Collection<Diagnostic> diagnostics);
60:
61:         /**
62:          * Register a {@code listener} with the given validation service, if it supports it.
63:          *
64:          * @param validationService a validation service
65:          * @param listener the listener to register
66:          * @return {@code true} if the {@code listener} was registered; {@code false}, otherwise
67:          */
68:         static boolean register(ValidationService validationService, ValidationUpdateListener listener) {
69:•                if (validationService instanceof IncrementalValidationService) {
70:                         ((IncrementalValidationService) validationService).registerValidationUpdateListener(listener);
71:                         return true;
72:                 }
73:
74:                 return false;
75:         }
76:
77:         /**
78:          * De-register a {@code listener} from the given validation service.
79:          *
80:          * @param validationService a validation service
81:          * @param listener the listener to deregister
82:          */
83:         static void deregister(ValidationService validationService, ValidationUpdateListener listener) {
84:•                if (validationService instanceof IncrementalValidationService) {
85:                         ((IncrementalValidationService) validationService).deregisterValidationUpdateListener(listener);
86:                 }
87:         }
88:
89: }