| /******************************************************************************* |
| * 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.TreeFeatureNode; |
| import org.eclipse.apogy.common.emf.TreeRootNode; |
| import org.eclipse.emf.common.notify.AdapterFactory; |
| import org.eclipse.emf.ecore.EClass; |
| import org.eclipse.emf.ecore.EStructuralFeature; |
| |
| public class AbstractFeatureTreeNodeCustomItemProvider extends AbstractFeatureTreeNodeItemProvider { |
| public AbstractFeatureTreeNodeCustomItemProvider(AdapterFactory adapterFactory) { |
| super(adapterFactory); |
| } |
| |
| @Override |
| protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) { |
| super.collectNewChildDescriptors(newChildDescriptors, object); |
| |
| if (object instanceof TreeRootNode) { |
| TreeRootNode root = (TreeRootNode) object; |
| |
| if (root.getSourceClass() != null) { |
| newChildDescriptors |
| .add(createChildParameter(ApogyCommonEMFPackage.Literals.ABSTRACT_FEATURE_TREE_NODE__CHILDREN, |
| ApogyCommonEMFFactory.eINSTANCE.createTreeFeatureNode())); |
| } |
| } else if (object instanceof TreeFeatureNode) { |
| TreeFeatureNode treeFeatureNode = (TreeFeatureNode) object; |
| EStructuralFeature eStructuralFeature = treeFeatureNode.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_TREE_NODE__CHILDREN, |
| ApogyCommonEMFFactory.eINSTANCE.createTreeFeatureNode())); |
| } |
| } |
| } |
| } |