| /** |
| * |
| * Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany) |
| * |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License 2.0 |
| * which accompanies this distribution, and is available at |
| * https://www.eclipse.org/legal/epl-2.0/ |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| * |
| * Contributors: |
| * Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation |
| * |
| */ |
| package org.eclipse.osbp.xtext.action.valueconverter; |
| |
| import org.eclipse.emf.ecore.EObject; |
| import org.eclipse.xtext.naming.QualifiedName; |
| import org.eclipse.xtext.xbase.scoping.XbaseQualifiedNameProvider; |
| |
| @SuppressWarnings("restriction") |
| public class ActionQualifiedNameProvider extends XbaseQualifiedNameProvider { |
| |
| // @Inject |
| // private IQualifiedNameConverter qualifiedNameConverter; |
| // |
| // @Inject |
| // private ModelExtensions extensions; |
| |
| @Override |
| public QualifiedName getFullyQualifiedName(EObject obj) { |
| if (obj == null) { |
| return QualifiedName.create(""); |
| } |
| // if (obj instanceof ActionToolbar) { |
| // ActionToolbar toolbar = (ActionToolbar) obj; |
| // if (toolbar.getName() == null) { |
| // return null; |
| // } |
| // return qualifiedNameConverter.toQualifiedName(toolbar.getName()); |
| // } |
| // else if (obj instanceof FunctionLibraryGroup) { |
| // return qualifiedCrossReferenceNameConverter(obj, |
| // ActionDSLPackage.eINSTANCE.getActionButton_Group()); |
| // } |
| // else if (obj instanceof FunctionLibraryFunction) { |
| // return qualifiedCrossReferenceNameConverter(obj, |
| // ActionDSLPackage.eINSTANCE.getActionButton_Canexecute()); |
| // } |
| return super.getFullyQualifiedName(obj); |
| } |
| |
| // // this method evaluates the cross referenced name of an object without |
| // causing cyclic lazy linking errors |
| // private QualifiedName qualifiedCrossReferenceNameConverter(EObject obj, |
| // EStructuralFeature feature) { |
| // List<INode> nodes = NodeModelUtils.findNodesForFeature(obj, feature); |
| // if (nodes.size() == 0) { |
| // return QualifiedName.create(""); |
| // } |
| // return |
| // qualifiedNameConverter.toQualifiedName(NodeModelUtils.getTokenText(nodes.get(0))); |
| // } |
| // |
| // public QualifiedName getFQN(LFeature lfeature){ |
| // if(lfeature.getName() == null){ |
| // return QualifiedName.create(""); |
| // } |
| // LType type = (LType) lfeature.eContainer(); |
| // LPackage pkg = extensions.getPackage(type); |
| // if (pkg != null && type != null) { |
| // final String qualifiedName = String.format("%s.%s.%s", |
| // pkg.getName(), type.getName(), lfeature.getName()); |
| // if (qualifiedName == null) |
| // return null; |
| // return qualifiedNameConverter.toQualifiedName(qualifiedName); |
| // } else { |
| // return lfeature.getName() != null ? qualifiedNameConverter |
| // .toQualifiedName(lfeature.getName()) : null; |
| // } |
| // } |
| } |