| /** |
| * 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 v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation |
| * |
| * |
| * This copyright notice shows up in the generated Java code |
| */ |
| package org.eclipse.osbp.xtext.perspective.scoping; |
| |
| import com.google.common.base.Objects; |
| import java.util.ArrayList; |
| import org.eclipse.emf.common.util.EList; |
| import org.eclipse.emf.ecore.EObject; |
| import org.eclipse.emf.ecore.EReference; |
| import org.eclipse.emf.ecore.resource.Resource; |
| import org.eclipse.emf.ecore.resource.ResourceSet; |
| import org.eclipse.osbp.dsl.semantic.dto.LDto; |
| import org.eclipse.osbp.dsl.xtext.lazyresolver.api.EcoreUtil3; |
| import org.eclipse.osbp.ecview.semantic.uimodel.UiBeanSlot; |
| import org.eclipse.osbp.ecview.semantic.uimodel.UiIDEView; |
| import org.eclipse.osbp.ecview.semantic.uimodel.UiView; |
| import org.eclipse.osbp.xtext.blip.Blip; |
| import org.eclipse.osbp.xtext.blip.BlipItem; |
| import org.eclipse.osbp.xtext.blip.BlipUserTask; |
| import org.eclipse.osbp.xtext.dialogdsl.Dialog; |
| import org.eclipse.osbp.xtext.perspective.Perspective; |
| import org.eclipse.osbp.xtext.perspective.PerspectiveDialog; |
| import org.eclipse.osbp.xtext.perspective.PerspectiveDslPackage; |
| import org.eclipse.osbp.xtext.perspective.PerspectiveElement; |
| import org.eclipse.osbp.xtext.perspective.PerspectiveGrid; |
| import org.eclipse.osbp.xtext.perspective.PerspectivePartStack; |
| import org.eclipse.osbp.xtext.perspective.PerspectiveSashContainer; |
| import org.eclipse.osbp.xtext.perspective.PerspectiveSelection; |
| import org.eclipse.osbp.xtext.perspective.PerspectiveTable; |
| import org.eclipse.osbp.xtext.table.Table; |
| import org.eclipse.osbp.xtext.table.TableDtoDatasource; |
| import org.eclipse.osbp.xtext.table.TableGrid; |
| import org.eclipse.osbp.xtext.table.TableOption; |
| import org.eclipse.osbp.xtext.table.TableSelection; |
| import org.eclipse.osbp.xtext.table.TableTable; |
| import org.eclipse.xtext.common.types.JvmType; |
| import org.eclipse.xtext.common.types.JvmTypeReference; |
| import org.eclipse.xtext.resource.EObjectDescription; |
| import org.eclipse.xtext.resource.IEObjectDescription; |
| import org.eclipse.xtext.scoping.IScope; |
| import org.eclipse.xtext.scoping.impl.MapBasedScope; |
| import org.eclipse.xtext.xbase.annotations.typesystem.XbaseWithAnnotationsBatchScopeProvider; |
| import org.eclipse.xtext.xbase.lib.CollectionLiterals; |
| |
| @SuppressWarnings("all") |
| public class PerspectiveScopeProvider extends XbaseWithAnnotationsBatchScopeProvider { |
| @Override |
| public IScope getScope(final EObject context, final EReference reference) { |
| boolean _equals = Objects.equal(reference, PerspectiveDslPackage.Literals.PERSPECTIVE_SASH_CONTAINER__SELECTED_ELEMENT); |
| if (_equals) { |
| return this.getScope_CCPerspectiveSashContainer_selected_element(context); |
| } else { |
| boolean _equals_1 = Objects.equal(reference, PerspectiveDslPackage.Literals.PERSPECTIVE_PART_STACK__SELECTED_ELEMENT); |
| if (_equals_1) { |
| return this.getScope_CCPerspectivePartStack_selected_element(context); |
| } else { |
| boolean _equals_2 = Objects.equal(reference, PerspectiveDslPackage.Literals.PERSPECTIVE__USER_TASK); |
| if (_equals_2) { |
| return this.getScope_CCPerspectivePartStack_USER_TASK(((Perspective) context)); |
| } else { |
| boolean _equals_3 = Objects.equal(reference, PerspectiveDslPackage.Literals.PERSPECTIVE_DIALOG__REF); |
| if (_equals_3) { |
| return this.getScope_CCPerspectivePartStack_PERSPECTIVE_DIALOG__REF(((PerspectiveDialog) context), reference); |
| } else { |
| boolean _equals_4 = Objects.equal(reference, PerspectiveDslPackage.Literals.PERSPECTIVE_SELECTION__REF); |
| if (_equals_4) { |
| return this.getScope_CCPerspectivePartStack_PERSPECTIVE_SELECTION__REF(((PerspectiveSelection) context), reference); |
| } else { |
| boolean _equals_5 = Objects.equal(reference, PerspectiveDslPackage.Literals.PERSPECTIVE_TABLE__REF); |
| if (_equals_5) { |
| return this.getScope_CCPerspectivePartStack_PERSPECTIVE_TABLE__REF(((PerspectiveTable) context), reference); |
| } else { |
| boolean _equals_6 = Objects.equal(reference, PerspectiveDslPackage.Literals.PERSPECTIVE_GRID__REF); |
| if (_equals_6) { |
| return this.getScope_CCPerspectivePartStack_PERSPECTIVE_GRID__REF(((PerspectiveGrid) context), reference); |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| return super.getScope(context, reference); |
| } |
| |
| public IScope getScope_CCPerspectivePartStack_PERSPECTIVE_DIALOG__REF(final PerspectiveDialog dialogView, final EReference reference) { |
| final IScope superScope = super.getScope(dialogView, reference); |
| ArrayList<IEObjectDescription> result = CollectionLiterals.<IEObjectDescription>newArrayList(); |
| EObject perspective = dialogView.eContainer(); |
| while (((!Objects.equal(perspective, null)) && (!(perspective instanceof Perspective)))) { |
| EObject _eContainer = perspective.eContainer(); |
| perspective = _eContainer; |
| } |
| BlipUserTask _userTask = null; |
| if (((Perspective) perspective)!=null) { |
| _userTask=((Perspective) perspective).getUserTask(); |
| } |
| boolean _equals = Objects.equal(_userTask, null); |
| if (_equals) { |
| return superScope; |
| } else { |
| BlipUserTask _userTask_1 = null; |
| if (((Perspective) perspective)!=null) { |
| _userTask_1=((Perspective) perspective).getUserTask(); |
| } |
| Resource _eResource = dialogView.eResource(); |
| ResourceSet _resourceSet = _eResource.getResourceSet(); |
| EObject _resolve = EcoreUtil3.resolve(_userTask_1, _resourceSet); |
| final BlipUserTask humanTask = ((BlipUserTask) _resolve); |
| final LDto operativeDto = humanTask.getOperativeLDto(); |
| String _name = null; |
| if (operativeDto!=null) { |
| _name=operativeDto.getName(); |
| } |
| boolean _equals_1 = Objects.equal(_name, null); |
| if (_equals_1) { |
| return superScope; |
| } else { |
| Iterable<IEObjectDescription> _allElements = superScope.getAllElements(); |
| for (final IEObjectDescription element : _allElements) { |
| EObject _eObjectOrProxy = element.getEObjectOrProxy(); |
| if ((_eObjectOrProxy instanceof Dialog)) { |
| EObject _eObjectOrProxy_1 = element.getEObjectOrProxy(); |
| Dialog dialog = ((Dialog) _eObjectOrProxy_1); |
| Resource _eResource_1 = dialogView.eResource(); |
| ResourceSet _resourceSet_1 = _eResource_1.getResourceSet(); |
| EObject _resolve_1 = EcoreUtil3.resolve(dialog, _resourceSet_1); |
| dialog = ((Dialog) _resolve_1); |
| UiView _uiView = dialog.getUiView(); |
| boolean _notEquals = (!Objects.equal(_uiView, null)); |
| if (_notEquals) { |
| UiView _uiView_1 = dialog.getUiView(); |
| Resource _eResource_2 = dialogView.eResource(); |
| ResourceSet _resourceSet_2 = _eResource_2.getResourceSet(); |
| final EObject uiViewObj = EcoreUtil3.resolve(((EObject) _uiView_1), _resourceSet_2); |
| if ((uiViewObj instanceof UiIDEView)) { |
| final UiIDEView uiView = ((UiIDEView) uiViewObj); |
| EList<UiBeanSlot> _beanSlots = uiView.getBeanSlots(); |
| for (final UiBeanSlot beanSlot : _beanSlots) { |
| String _name_1 = operativeDto.getName(); |
| JvmTypeReference _jvmType = null; |
| if (beanSlot!=null) { |
| _jvmType=beanSlot.getJvmType(); |
| } |
| JvmType _type = null; |
| if (_jvmType!=null) { |
| _type=_jvmType.getType(); |
| } |
| String _simpleName = null; |
| if (_type!=null) { |
| _simpleName=_type.getSimpleName(); |
| } |
| boolean _equals_2 = _name_1.equals(_simpleName); |
| if (_equals_2) { |
| result.add(element); |
| } |
| } |
| } |
| } else { |
| LDto _dto = dialog.getDto(); |
| boolean _notEquals_1 = (!Objects.equal(_dto, null)); |
| if (_notEquals_1) { |
| String _name_2 = operativeDto.getName(); |
| LDto _dto_1 = dialog.getDto(); |
| String _name_3 = _dto_1.getName(); |
| boolean _equals_3 = _name_2.equals(_name_3); |
| if (_equals_3) { |
| result.add(element); |
| } |
| } |
| } |
| } |
| } |
| } |
| return MapBasedScope.createScope(IScope.NULLSCOPE, result); |
| } |
| } |
| |
| public IScope getScope_CCPerspectivePartStack_PERSPECTIVE_TABLE__REF(final PerspectiveTable tableView, final EReference reference) { |
| IScope superScope = super.getScope(tableView, reference); |
| ArrayList<IEObjectDescription> result = CollectionLiterals.<IEObjectDescription>newArrayList(); |
| Iterable<IEObjectDescription> _allElements = superScope.getAllElements(); |
| for (final IEObjectDescription element : _allElements) { |
| EObject _eObjectOrProxy = element.getEObjectOrProxy(); |
| if ((_eObjectOrProxy instanceof Table)) { |
| EObject _eObjectOrProxy_1 = element.getEObjectOrProxy(); |
| Table table = ((Table) _eObjectOrProxy_1); |
| Resource _eResource = tableView.eResource(); |
| ResourceSet _resourceSet = _eResource.getResourceSet(); |
| EObject _resolve = EcoreUtil3.resolve(table, _resourceSet); |
| table = ((Table) _resolve); |
| TableOption _tabletype = table.getTabletype(); |
| if ((_tabletype instanceof TableTable)) { |
| result.add(element); |
| } else { |
| TableOption _tabletype_1 = table.getTabletype(); |
| if ((_tabletype_1 instanceof TableGrid)) { |
| result.add(element); |
| } |
| } |
| } |
| } |
| IScope _createScope = MapBasedScope.createScope(IScope.NULLSCOPE, result); |
| superScope = _createScope; |
| ArrayList<IEObjectDescription> _newArrayList = CollectionLiterals.<IEObjectDescription>newArrayList(); |
| result = _newArrayList; |
| EObject perspective = tableView.eContainer(); |
| while (((!Objects.equal(perspective, null)) && (!(perspective instanceof Perspective)))) { |
| EObject _eContainer = perspective.eContainer(); |
| perspective = _eContainer; |
| } |
| BlipUserTask _userTask = null; |
| if (((Perspective) perspective)!=null) { |
| _userTask=((Perspective) perspective).getUserTask(); |
| } |
| boolean _equals = Objects.equal(_userTask, null); |
| if (_equals) { |
| return superScope; |
| } else { |
| Blip _process = null; |
| if (((Perspective) perspective)!=null) { |
| _process=((Perspective) perspective).getProcess(); |
| } |
| Resource _eResource_1 = tableView.eResource(); |
| ResourceSet _resourceSet_1 = _eResource_1.getResourceSet(); |
| EcoreUtil3.resolve(_process, _resourceSet_1); |
| BlipUserTask _userTask_1 = null; |
| if (((Perspective) perspective)!=null) { |
| _userTask_1=((Perspective) perspective).getUserTask(); |
| } |
| Resource _eResource_2 = tableView.eResource(); |
| ResourceSet _resourceSet_2 = _eResource_2.getResourceSet(); |
| EObject _resolve_1 = EcoreUtil3.resolve(_userTask_1, _resourceSet_2); |
| final BlipUserTask humanTask = ((BlipUserTask) _resolve_1); |
| final LDto operativeDto = humanTask.getOperativeLDto(); |
| String _name = null; |
| if (operativeDto!=null) { |
| _name=operativeDto.getName(); |
| } |
| boolean _equals_1 = Objects.equal(_name, null); |
| if (_equals_1) { |
| return superScope; |
| } else { |
| Iterable<IEObjectDescription> _allElements_1 = superScope.getAllElements(); |
| for (final IEObjectDescription element_1 : _allElements_1) { |
| EObject _eObjectOrProxy_2 = element_1.getEObjectOrProxy(); |
| if ((_eObjectOrProxy_2 instanceof Table)) { |
| EObject _eObjectOrProxy_3 = element_1.getEObjectOrProxy(); |
| Table table_1 = ((Table) _eObjectOrProxy_3); |
| Resource _eResource_3 = tableView.eResource(); |
| ResourceSet _resourceSet_3 = _eResource_3.getResourceSet(); |
| EObject _resolve_2 = EcoreUtil3.resolve(table_1, _resourceSet_3); |
| table_1 = ((Table) _resolve_2); |
| TableOption _tabletype_2 = table_1.getTabletype(); |
| if ((_tabletype_2 instanceof TableGrid)) { |
| TableOption _tabletype_3 = table_1.getTabletype(); |
| final TableGrid tableGrid = ((TableGrid) _tabletype_3); |
| TableDtoDatasource _source = null; |
| if (tableGrid!=null) { |
| _source=tableGrid.getSource(); |
| } |
| final TableDtoDatasource tableDtoDatasource = _source; |
| LDto _dtoSource = null; |
| if (tableDtoDatasource!=null) { |
| _dtoSource=tableDtoDatasource.getDtoSource(); |
| } |
| final LDto rootTypeDto = _dtoSource; |
| String _name_1 = operativeDto.getName(); |
| String _name_2 = rootTypeDto.getName(); |
| boolean _equals_2 = _name_1.equals(_name_2); |
| if (_equals_2) { |
| result.add(element_1); |
| } |
| } else { |
| TableOption _tabletype_4 = table_1.getTabletype(); |
| if ((_tabletype_4 instanceof TableTable)) { |
| result.add(element_1); |
| } |
| } |
| } |
| } |
| } |
| return MapBasedScope.createScope(IScope.NULLSCOPE, result); |
| } |
| } |
| |
| public IScope getScope_CCPerspectivePartStack_PERSPECTIVE_SELECTION__REF(final PerspectiveSelection selectionView, final EReference reference) { |
| IScope superScope = super.getScope(selectionView, reference); |
| ArrayList<IEObjectDescription> result = CollectionLiterals.<IEObjectDescription>newArrayList(); |
| Iterable<IEObjectDescription> _allElements = superScope.getAllElements(); |
| for (final IEObjectDescription element : _allElements) { |
| EObject _eObjectOrProxy = element.getEObjectOrProxy(); |
| if ((_eObjectOrProxy instanceof Table)) { |
| EObject _eObjectOrProxy_1 = element.getEObjectOrProxy(); |
| Table table = ((Table) _eObjectOrProxy_1); |
| Resource _eResource = selectionView.eResource(); |
| ResourceSet _resourceSet = _eResource.getResourceSet(); |
| EObject _resolve = EcoreUtil3.resolve(table, _resourceSet); |
| table = ((Table) _resolve); |
| TableOption _tabletype = table.getTabletype(); |
| if ((_tabletype instanceof TableSelection)) { |
| result.add(element); |
| } |
| } |
| } |
| IScope _createScope = MapBasedScope.createScope(IScope.NULLSCOPE, result); |
| superScope = _createScope; |
| ArrayList<IEObjectDescription> _newArrayList = CollectionLiterals.<IEObjectDescription>newArrayList(); |
| result = _newArrayList; |
| EObject perspective = selectionView.eContainer(); |
| while (((!Objects.equal(perspective, null)) && (!(perspective instanceof Perspective)))) { |
| EObject _eContainer = perspective.eContainer(); |
| perspective = _eContainer; |
| } |
| BlipUserTask _userTask = null; |
| if (((Perspective) perspective)!=null) { |
| _userTask=((Perspective) perspective).getUserTask(); |
| } |
| boolean _equals = Objects.equal(_userTask, null); |
| if (_equals) { |
| return superScope; |
| } else { |
| Blip _process = null; |
| if (((Perspective) perspective)!=null) { |
| _process=((Perspective) perspective).getProcess(); |
| } |
| Resource _eResource_1 = selectionView.eResource(); |
| ResourceSet _resourceSet_1 = _eResource_1.getResourceSet(); |
| EcoreUtil3.resolve(_process, _resourceSet_1); |
| BlipUserTask _userTask_1 = null; |
| if (((Perspective) perspective)!=null) { |
| _userTask_1=((Perspective) perspective).getUserTask(); |
| } |
| Resource _eResource_2 = selectionView.eResource(); |
| ResourceSet _resourceSet_2 = _eResource_2.getResourceSet(); |
| EObject _resolve_1 = EcoreUtil3.resolve(_userTask_1, _resourceSet_2); |
| final BlipUserTask humanTask = ((BlipUserTask) _resolve_1); |
| final LDto operativeDto = humanTask.getOperativeLDto(); |
| String _name = null; |
| if (operativeDto!=null) { |
| _name=operativeDto.getName(); |
| } |
| boolean _equals_1 = Objects.equal(_name, null); |
| if (_equals_1) { |
| return superScope; |
| } else { |
| Iterable<IEObjectDescription> _allElements_1 = superScope.getAllElements(); |
| for (final IEObjectDescription element_1 : _allElements_1) { |
| EObject _eObjectOrProxy_2 = element_1.getEObjectOrProxy(); |
| if ((_eObjectOrProxy_2 instanceof Table)) { |
| EObject _eObjectOrProxy_3 = element_1.getEObjectOrProxy(); |
| Table table_1 = ((Table) _eObjectOrProxy_3); |
| Resource _eResource_3 = selectionView.eResource(); |
| ResourceSet _resourceSet_3 = _eResource_3.getResourceSet(); |
| EObject _resolve_2 = EcoreUtil3.resolve(table_1, _resourceSet_3); |
| table_1 = ((Table) _resolve_2); |
| TableOption _tabletype_1 = table_1.getTabletype(); |
| if ((_tabletype_1 instanceof TableSelection)) { |
| result.add(element_1); |
| } |
| } |
| } |
| } |
| return MapBasedScope.createScope(IScope.NULLSCOPE, result); |
| } |
| } |
| |
| public IScope getScope_CCPerspectivePartStack_PERSPECTIVE_GRID__REF(final PerspectiveGrid gridView, final EReference reference) { |
| final IScope superScope = super.getScope(gridView, reference); |
| ArrayList<IEObjectDescription> result = CollectionLiterals.<IEObjectDescription>newArrayList(); |
| Iterable<IEObjectDescription> _allElements = superScope.getAllElements(); |
| for (final IEObjectDescription element : _allElements) { |
| EObject _eObjectOrProxy = element.getEObjectOrProxy(); |
| if ((_eObjectOrProxy instanceof Table)) { |
| EObject _eObjectOrProxy_1 = element.getEObjectOrProxy(); |
| Table table = ((Table) _eObjectOrProxy_1); |
| Resource _eResource = gridView.eResource(); |
| ResourceSet _resourceSet = _eResource.getResourceSet(); |
| EObject _resolve = EcoreUtil3.resolve(table, _resourceSet); |
| table = ((Table) _resolve); |
| TableOption _tabletype = table.getTabletype(); |
| if ((_tabletype instanceof TableGrid)) { |
| result.add(element); |
| } |
| } |
| } |
| return MapBasedScope.createScope(IScope.NULLSCOPE, result); |
| } |
| |
| public IScope getScope_CCPerspectivePartStack_USER_TASK(final Perspective perspective) { |
| ArrayList<IEObjectDescription> result = CollectionLiterals.<IEObjectDescription>newArrayList(); |
| Blip blipProcess = perspective.getProcess(); |
| boolean _notEquals = (!Objects.equal(blipProcess, null)); |
| if (_notEquals) { |
| EList<BlipItem> _items = blipProcess.getItems(); |
| for (final BlipItem item : _items) { |
| if ((item instanceof BlipUserTask)) { |
| String _name = ((BlipUserTask)item).getName(); |
| IEObjectDescription _create = EObjectDescription.create(_name, item); |
| result.add(_create); |
| } |
| } |
| } |
| return MapBasedScope.createScope(IScope.NULLSCOPE, result); |
| } |
| |
| public IScope getScope_CCPerspectivePartStack_selected_element(final EObject object) { |
| ArrayList<IEObjectDescription> result = CollectionLiterals.<IEObjectDescription>newArrayList(); |
| if ((object instanceof PerspectivePartStack)) { |
| PerspectivePartStack stack = ((PerspectivePartStack) object); |
| EList<PerspectiveElement> _elements = stack.getElements(); |
| for (final PerspectiveElement part : _elements) { |
| String _elementId = part.getElementId(); |
| IEObjectDescription _create = EObjectDescription.create(_elementId, part); |
| result.add(_create); |
| } |
| } |
| return MapBasedScope.createScope(IScope.NULLSCOPE, result); |
| } |
| |
| public IScope getScope_CCPerspectiveSashContainer_selected_element(final EObject object) { |
| ArrayList<IEObjectDescription> result = CollectionLiterals.<IEObjectDescription>newArrayList(); |
| if ((object instanceof PerspectiveSashContainer)) { |
| PerspectiveSashContainer sash = ((PerspectiveSashContainer) object); |
| EList<PerspectiveElement> _elements = sash.getElements(); |
| for (final PerspectiveElement part : _elements) { |
| String _elementId = part.getElementId(); |
| IEObjectDescription _create = EObjectDescription.create(_elementId, part); |
| result.add(_create); |
| } |
| } |
| return MapBasedScope.createScope(IScope.NULLSCOPE, result); |
| } |
| } |