Skip to content

Package: IViewProvider

IViewProvider

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2013 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: * EclipseSource Muenchen - initial API and implementation
13: *
14: *******************************************************************************/
15: package org.eclipse.emf.ecp.view.spi.provider;
16:
17: import org.eclipse.emf.ecore.EObject;
18: import org.eclipse.emf.ecp.view.spi.model.VView;
19: import org.eclipse.emf.ecp.view.spi.model.VViewModelProperties;
20:
21: /**
22: * This interface defines a generic way to provide a {@link VView}. First the can render method is called. The provider
23: * with the highest priority is then asked to {@link #provideViewModel(EObject, VViewModelProperties)} a {@link VView}.
24: *
25: * @author Eugen Neufeld
26: * @since 1.2
27: *
28: */
29: public interface IViewProvider {
30:
31:         /**
32:          * Constant indicating, that the provider cannot provide a {@link VView} for a specific {@link EObject}.
33:          */
34:         double NOT_APPLICABLE = -1;
35:
36:         /**
37:          * Called to check whether the provider can provide a {@link VView} for an {@link EObject}.
38:          *
39:          * @param eObject the {@link EObject} to create a
40:          * @param properties the {@link VViewModelProperties properties} for providing the view
41:          * @return a <b>positive</b> double indicating how well this provider is fitted to provide a {@link VView} for the
42:          * provided {@link EObject} or {@link #NOT_APPLICABLE} if it doesn't fit
43:          * @since 1.7
44:          */
45:         double canProvideViewModel(EObject eObject, VViewModelProperties properties);
46:
47:         /**
48:          * This method is only called if {@link #canProvideViewModel(EObject, VViewModelProperties)} returned the highest
49:          * positive
50:          * number of all {@link IViewProvider IViewProviders}.
51:          * It must then return a {@link VView} to the {@link EObject}.
52:          *
53:          * @param eObject the {@link EObject} to generate the {@link VView} for
54:          * @param properties the {@link VViewModelProperties properties} for providing the view
55:          * @return the generated {@link VView}
56:          * @since 1.7
57:          */
58:         VView provideViewModel(EObject eObject, VViewModelProperties properties);
59: }