| /** |
| * Copyright (c) 2011, 2015 - Lunifera GmbH (Gross Enzersdorf, Austria), 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: |
| * Florian Pirchner - Initial implementation |
| */ |
| |
| package org.eclipse.osbp.ecview.dsl.scope; |
| |
| import java.util.ArrayList; |
| import java.util.List; |
| |
| import org.eclipse.emf.ecore.EObject; |
| import org.eclipse.emf.ecore.util.EcoreUtil; |
| import org.eclipse.xtext.naming.IQualifiedNameConverter; |
| import org.eclipse.xtext.resource.EObjectDescription; |
| import org.eclipse.xtext.resource.IEObjectDescription; |
| import org.eclipse.xtext.resource.IResourceDescriptions; |
| import org.eclipse.xtext.scoping.IScope; |
| import org.eclipse.xtext.scoping.impl.AbstractScope; |
| import org.eclipse.osbp.ecview.semantic.uisemantics.UiSemanticsPackage; |
| import org.eclipse.osbp.ecview.semantic.uisemantics.UxAction; |
| |
| public class ViewActionReferenceScope extends AbstractScope { |
| |
| private IResourceDescriptions desc; |
| private EObject context; |
| private IQualifiedNameConverter converter; |
| |
| protected ViewActionReferenceScope(IResourceDescriptions desc, |
| EObject context, IQualifiedNameConverter converter) { |
| super(IScope.NULLSCOPE, true); |
| this.desc = desc; |
| this.context = context; |
| this.converter = converter; |
| } |
| |
| @Override |
| protected Iterable<IEObjectDescription> getAllLocalElements() { |
| List<IEObjectDescription> result = new ArrayList<IEObjectDescription>(); |
| for (IEObjectDescription des : desc |
| .getExportedObjectsByType(UiSemanticsPackage.Literals.UX_ACTION)) { |
| UxAction action = (UxAction) des.getEObjectOrProxy(); |
| action = (UxAction) EcoreUtil.resolve(action, context); |
| if (!action.eIsProxy()) { |
| result.add(EObjectDescription.create( |
| converter.toQualifiedName(action.getName()), action)); |
| } |
| } |
| return result; |
| } |
| } |