Package: EMFFormsSpreadsheetFormatDescriptionProviderImpl
EMFFormsSpreadsheetFormatDescriptionProviderImpl
name | instruction | branch | complexity | line | method | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
EMFFormsSpreadsheetFormatDescriptionProviderImpl() |
|
|
|
|
|
||||||||||||||||||||
getEAnnotations(EStructuralFeature) |
|
|
|
|
|
||||||||||||||||||||
getFormatDescription(EStructuralFeature) |
|
|
|
|
|
Coverage
1: /*******************************************************************************
2: * Copyright (c) 2015 Innoopract Informationssysteme 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: * Innoopract Informationssysteme GmbH - initial API and implementation
13: * EclipseSource - ongoing implementation
14: ******************************************************************************/
15: package org.eclipse.emfforms.internal.spreadsheet.core;
16:
17: import java.util.LinkedHashSet;
18: import java.util.Set;
19:
20: import org.eclipse.emf.common.util.EMap;
21: import org.eclipse.emf.ecore.EAnnotation;
22: import org.eclipse.emf.ecore.EStructuralFeature;
23: import org.eclipse.emf.ecore.util.ExtendedMetaData;
24: import org.eclipse.emfforms.spi.spreadsheet.core.EMFFormsSpreadsheetFormatDescriptionProvider;
25: import org.osgi.service.component.annotations.Component;
26:
27: /**
28: * Default implementation of the {@link EMFFormsSpreadsheetFormatDescriptionProvider}.
29: * It may be replaced by a service instance with a higher than standard priority.
30: */
31: @Component(name = "EMFFormsSpreadsheetFormatDescriptionProviderImpl")
32: public class EMFFormsSpreadsheetFormatDescriptionProviderImpl implements EMFFormsSpreadsheetFormatDescriptionProvider {
33:
34:         /**
35:          * {@inheritDoc}
36:          *
37:          * @see org.eclipse.emfforms.spi.spreadsheet.core.EMFFormsSpreadsheetFormatDescriptionProvider#getFormatDescription(org.eclipse.emf.ecore.EStructuralFeature)
38:          */
39:         @Override
40:         public String getFormatDescription(final EStructuralFeature structuralFeature) {
41:                 final StringBuilder sb = new StringBuilder();
42:•                for (final EAnnotation eAnnotation : getEAnnotations(structuralFeature)) {
43:                         final EMap<String, String> details = eAnnotation.getDetails();
44:•                        for (final String key : details.keySet()) {
45:•                                if (ExtendedMetaData.ANNOTATION_URI.equals(eAnnotation.getSource())) {
46:•                                        if ("kind".equals(key)) { //$NON-NLS-1$
47:                                                 continue;
48:                                         }
49:•                                        if ("name".equals(key)) { //$NON-NLS-1$
50:                                                 continue;
51:                                         }
52:•                                        if ("baseType".equals(key)) { //$NON-NLS-1$
53:                                                 continue;
54:                                         }
55:                                 }
56:•                                if ("appinfo".equals(key)) { //$NON-NLS-1$
57:                                         continue;
58:                                 }
59:                                 sb.append(key);
60:                                 sb.append("="); //$NON-NLS-1$
61:                                 sb.append(details.get(key));
62:                                 sb.append("\n"); //$NON-NLS-1$
63:                         }
64:                 }
65:                 return sb.toString().trim();
66:         }
67:
68:         private Set<EAnnotation> getEAnnotations(final EStructuralFeature structuralFeature) {
69:                 final Set<EAnnotation> annotations = new LinkedHashSet<EAnnotation>();
70:                 annotations.addAll(structuralFeature.getEAnnotations());
71:                 annotations.addAll(structuralFeature.getEType().getEAnnotations());
72:                 return annotations;
73:         }
74:
75: }