| /******************************************************************************* |
| * Copyright (c) 2018 Agence spatiale canadienne / Canadian Space Agency |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * Pierre Allard, |
| * Regent L'Archeveque, |
| * Olivier L. Larouche - initial API and implementation |
| * SPDX-License-Identifier: EPL-1.0 |
| * |
| *******************************************************************************/ |
| package org.eclipse.apogy.common.emf.provider; |
| |
| import java.util.Collection; |
| |
| import org.eclipse.apogy.common.emf.ApogyCommonEMFFactory; |
| import org.eclipse.apogy.common.emf.ApogyCommonEMFPackage; |
| import org.eclipse.apogy.common.emf.ListFeatureNode; |
| import org.eclipse.apogy.common.emf.ListRootNode; |
| import org.eclipse.emf.common.notify.AdapterFactory; |
| import org.eclipse.emf.ecore.EClass; |
| import org.eclipse.emf.ecore.EStructuralFeature; |
| |
| public class AbstractFeatureListNodeCustomItemProvider extends AbstractFeatureListNodeItemProvider { |
| public AbstractFeatureListNodeCustomItemProvider(AdapterFactory adapterFactory) { |
| super(adapterFactory); |
| } |
| |
| @Override |
| protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) { |
| super.collectNewChildDescriptors(newChildDescriptors, object); |
| |
| if (object instanceof ListRootNode) { |
| ListRootNode root = (ListRootNode) object; |
| |
| if (root.getSourceClass() != null) { |
| newChildDescriptors |
| .add(createChildParameter(ApogyCommonEMFPackage.Literals.ABSTRACT_FEATURE_LIST_NODE__CHILD, |
| ApogyCommonEMFFactory.eINSTANCE.createListFeatureNode())); |
| } |
| } else if (object instanceof ListFeatureNode) { |
| ListFeatureNode listFeatureNode = (ListFeatureNode) object; |
| EStructuralFeature eStructuralFeature = listFeatureNode.getStructuralFeature(); |
| |
| // Provide new child descriptor only if the current feature is an EClass. |
| if (eStructuralFeature != null && eStructuralFeature.getEType() instanceof EClass) { |
| newChildDescriptors |
| .add(createChildParameter(ApogyCommonEMFPackage.Literals.ABSTRACT_FEATURE_LIST_NODE__CHILD, |
| ApogyCommonEMFFactory.eINSTANCE.createListFeatureNode())); |
| } |
| } |
| } |
| } |