Skip to content

Package: RenderFailureView

RenderFailureView

nameinstructionbranchcomplexitylinemethod
RenderFailureView(Composite, ViewModelContext, ECPRendererException)
M: 0 C: 34
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 9
100%
M: 0 C: 1
100%
dispose()
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
getException()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getSWTControl()
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%
getViewModelContext()
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%

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.ui.view.swt;
15:
16: import org.eclipse.emf.ecp.ui.view.ECPRendererException;
17: import org.eclipse.emf.ecp.view.internal.swt.Activator;
18: import org.eclipse.emf.ecp.view.spi.context.ViewModelContext;
19: import org.eclipse.emfforms.spi.localization.EMFFormsLocalizationService;
20: import org.eclipse.osgi.util.NLS;
21: import org.eclipse.swt.SWT;
22: import org.eclipse.swt.widgets.Composite;
23: import org.eclipse.swt.widgets.Control;
24: import org.eclipse.swt.widgets.Label;
25:
26: /**
27: * A specialized view presenting a rendering exception.
28: *
29: * @since 1.22
30: */
31: public class RenderFailureView implements ECPSWTView {
32:
33:         private final ViewModelContext context;
34:         private final ECPRendererException exception;
35:         private final Label label;
36:
37:         /**
38:          * Initializes me with the {@code exception} to present.
39:          *
40:          * @param parent the parent composite in which to present the {@code exception}
41:          * @param context the view context
42:          * @param exception the rendering exception
43:          */
44:         public RenderFailureView(Composite parent, ViewModelContext context, ECPRendererException exception) {
45:                 super();
46:
47:                 this.context = context;
48:                 this.exception = exception;
49:
50:                 final EMFFormsLocalizationService l10n = context.getService(EMFFormsLocalizationService.class);
51:                 final String message = NLS.bind(l10n.getString(Activator.getDefault().getBundle(), "renderFailed"), //$NON-NLS-1$
52:                         exception.getMessage());
53:                 label = new Label(parent, SWT.NONE);
54:                 label.setText(message);
55:         }
56:
57:         @Override
58:         public void dispose() {
59:                 context.dispose();
60:                 label.dispose();
61:         }
62:
63:         /**
64:          * Obtains the SWT control presenting the exception.
65:          */
66:         @Override
67:         public Control getSWTControl() {
68:                 return label;
69:         }
70:
71:         @Override
72:         public ViewModelContext getViewModelContext() {
73:                 return context;
74:         }
75:
76:         /**
77:          * Queries the exception that I present.
78:          *
79:          * @return the rendering exception
80:          */
81:         public Throwable getException() {
82:                 return exception;
83:         }
84: }