| /******************************************************************************* |
| * 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 java.util.List; |
| |
| import org.eclipse.apogy.common.emf.AbstractFeatureNode; |
| import org.eclipse.apogy.common.emf.ApogyCommonEMFFacade; |
| import org.eclipse.apogy.common.emf.ApogyCommonEMFPackage; |
| import org.eclipse.apogy.common.emf.TreeFeatureNode; |
| import org.eclipse.emf.common.notify.AdapterFactory; |
| import org.eclipse.emf.ecore.EStructuralFeature; |
| import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; |
| import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; |
| |
| public class TreeFeatureNodeCustomItemProvider extends TreeFeatureNodeItemProvider { |
| public TreeFeatureNodeCustomItemProvider(AdapterFactory adapterFactory) { |
| super(adapterFactory); |
| } |
| |
| @Override |
| protected void addStructuralFeaturePropertyDescriptor(Object object) { |
| this.itemPropertyDescriptors.add(new ItemPropertyDescriptor( |
| ((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), getResourceLocator(), |
| getString("_UI_AbstractFeatureSpecifier_structuralFeature_feature"), |
| getString("_UI_PropertyDescriptor_description", |
| "_UI_AbstractFeatureSpecifier_structuralFeature_feature", "_UI_AbstractFeatureSpecifier_type"), |
| ApogyCommonEMFPackage.Literals.ABSTRACT_FEATURE_SPECIFIER__STRUCTURAL_FEATURE, true, false, true, null, |
| null, null) { |
| @Override |
| protected Collection<?> getComboBoxObjects(Object object) { |
| TreeFeatureNode featureNode = (TreeFeatureNode) object; |
| AbstractFeatureNode parent = featureNode.getParent(); |
| |
| List<EStructuralFeature> childFeatures = ApogyCommonEMFFacade.INSTANCE |
| .getChildEStructuralFeatures(parent); |
| return childFeatures; |
| } |
| }); |
| } |
| |
| @Override |
| public String getText(Object object) { |
| TreeFeatureNode treeFeatureNode = (TreeFeatureNode) object; |
| |
| String label = ""; |
| |
| if (treeFeatureNode.getStructuralFeature() != null) { |
| label = treeFeatureNode.getStructuralFeature().getName(); |
| } else { |
| label = getString("_UI_TreeFeatureNode_type"); |
| } |
| |
| if (treeFeatureNode.getChildren() != null && treeFeatureNode.getChildren().size() > 0) { |
| label += " [" + treeFeatureNode.getChildren().size() + "]"; |
| } |
| |
| if (treeFeatureNode.isMultiValued()) { |
| label += " ( index = " + treeFeatureNode.getIndex() + ")"; |
| } |
| |
| return label; |
| } |
| |
| } |