Skip to content

Package: SWTValidationUiService

SWTValidationUiService

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 Koehler - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emfforms.spi.swt.core.ui;
15:
16: import org.eclipse.emf.common.util.Diagnostic;
17: import org.eclipse.emf.ecp.view.spi.context.ViewModelContext;
18: import org.eclipse.emf.ecp.view.spi.model.VElement;
19: import org.eclipse.swt.graphics.Color;
20: import org.eclipse.swt.graphics.Image;
21:
22: /**
23: * Service implementations provide visualizations (icons and colors) for validation results.
24: *
25: * @author Lucas Koehler
26: * @since 1.23
27: *
28: */
29: public interface SWTValidationUiService {
30:
31:         /**
32:          * Returns the validation icon matching the given Diagnostic, VElement
33:          * and view model context, if applicable.
34:          *
35:          * @param diagnostic the {@link Diagnostic} defining the validation visualization
36:          * @param vElement The {@link VElement} that is being rendered
37:          * @param viewModelContext The corresponding {@link ViewModelContext}
38:          * @return the icon to be displayed, or <code>null</code> when no icon is to be displayed
39:          */
40:         Image getValidationIcon(Diagnostic diagnostic, VElement vElement, ViewModelContext viewModelContext);
41:
42:         /**
43:          * Returns the validation icon matching the highest severity of the given VElement's diagnostic.
44:          *
45:          * @param vElement The {@link VElement} that is being rendered
46:          * @param viewModelContext The corresponding {@link ViewModelContext}
47:          * @return the icon to be displayed, or <code>null</code> when no icon is to be displayed
48:          */
49:         Image getValidationIcon(VElement vElement, ViewModelContext viewModelContext);
50:
51:         /**
52:          * Returns the foreground color for a control with the given Diagnostic, VElement
53:          * and view model context, if applicable.
54:          *
55:          * @param diagnostic the {@link Diagnostic} defining the validation visualization
56:          * @param vElement The {@link VElement} that is being rendered
57:          * @param viewModelContext The corresponding {@link ViewModelContext}
58:          * @return the color to be used as a foreground color
59:          */
60:         Color getValidationForegroundColor(Diagnostic diagnostic, VElement vElement, ViewModelContext viewModelContext);
61:
62:         /**
63:          * Returns the foreground color for a control matching the highest severity of the given VElement's diagnostic.
64:          *
65:          * @param vElement The {@link VElement} that is being rendered
66:          * @param viewModelContext The corresponding {@link ViewModelContext}
67:          * @return the color to be used as a foreground color
68:          */
69:         Color getValidationForegroundColor(VElement vElement, ViewModelContext viewModelContext);
70:
71:         /**
72:          * Returns the background color for a control with the given Diagnostic, VElement
73:          * and view model context, if applicable.
74:          *
75:          * @param diagnostic the {@link Diagnostic} defining the validation visualization
76:          * @param vElement The {@link VElement} that is being rendered
77:          * @param viewModelContext The corresponding {@link ViewModelContext}
78:          * @return the color to be used as a background color
79:          */
80:         Color getValidationBackgroundColor(Diagnostic diagnostic, VElement vElement, ViewModelContext viewModelContext);
81:
82:         /**
83:          * Returns the background color for a control matching the highest severity of the given VElement's diagnostic.
84:          *
85:          * @param vElement The {@link VElement} that is being rendered
86:          * @param viewModelContext The corresponding {@link ViewModelContext}
87:          * @return the color to be used as a background color
88:          */
89:         Color getValidationBackgroundColor(VElement vElement, ViewModelContext viewModelContext);
90:         // TODO more methods?
91: }