Skip to content

Package: TableViewerCellEditorFactory$1

TableViewerCellEditorFactory$1

nameinstructionbranchcomplexitylinemethod
getLabelProvider()
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
{...}
M: 0 C: 8
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) 2015 RCP Vision (http://www.rcp-vision.com) and others.
3: * All rights reserved. This program and the accompanying materials
4: * are made available under the terms of the Eclipse Public License v1.0
5: * which accompanies this distribution, and is available at
6: * http://www.eclipse.org/legal/epl-v10.html
7: *
8: * Contributors:
9: * Lorenzo Bettini - Initial contribution and API
10: *******************************************************************************/
11: package org.eclipse.emf.parsley.viewers;
12:
13: import org.eclipse.emf.common.notify.Notifier;
14: import org.eclipse.emf.ecore.EStructuralFeature;
15: import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
16: import org.eclipse.emf.edit.ui.provider.PropertyDescriptor;
17: import org.eclipse.emf.parsley.edit.provider.AdapterFactoryHelper;
18: import org.eclipse.jface.viewers.CellEditor;
19: import org.eclipse.jface.viewers.ILabelProvider;
20: import org.eclipse.swt.widgets.Composite;
21:
22: import com.google.inject.Inject;
23:
24: /**
25: * Factory for {@link CellEditor}.
26: *
27: * This default implementation uses EMF {@link PropertyDescriptor}.
28: *
29: * @author Lorenzo Bettini - Initial contribution and API
30: *
31: */
32: public class TableViewerCellEditorFactory {
33:
34:         @Inject
35:         private ILabelProvider injectedLabelProvider;
36:
37:         @Inject
38:         private AdapterFactoryHelper adapterFactoryHelper;
39:
40:         public CellEditor createCellEditor(Composite composite, Object element, EStructuralFeature eStructuralFeature) {
41:                 if (!(element instanceof Notifier)) {
42:                         return null;
43:                 }
44:
45:                 Notifier notifier = (Notifier) element;
46:                 IItemPropertyDescriptor itemPropertyDescriptor = adapterFactoryHelper.getItemPropertyDescriptor(notifier,
47:                                 eStructuralFeature);
48:
49:                 if (itemPropertyDescriptor == null) {
50:                         return null;
51:                 }
52:
53:                 PropertyDescriptor propertyDescriptor = new PropertyDescriptor(element, itemPropertyDescriptor) {
54:                         @Override
55:                         public ILabelProvider getLabelProvider() {
56:                                 return injectedLabelProvider;
57:                         }
58:                 };
59:
60:                 return propertyDescriptor.createPropertyEditor(composite);
61:         }
62:
63: }