| /** |
| * 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.derivedstate; |
| |
| import java.util.Arrays; |
| import java.util.function.Consumer; |
| import org.eclipse.emf.common.util.EList; |
| import org.eclipse.emf.ecore.EObject; |
| import org.eclipse.osbp.xtext.perspective.Perspective; |
| import org.eclipse.osbp.xtext.perspective.PerspectiveElement; |
| import org.eclipse.osbp.xtext.perspective.PerspectiveModel; |
| import org.eclipse.osbp.xtext.perspective.PerspectivePackage; |
| import org.eclipse.osbp.xtext.perspective.PerspectivePart; |
| import org.eclipse.osbp.xtext.perspective.PerspectivePartStack; |
| import org.eclipse.osbp.xtext.perspective.PerspectiveSashContainer; |
| import org.eclipse.xtext.resource.DerivedStateAwareResource; |
| import org.eclipse.xtext.xbase.jvmmodel.JvmModelAssociator; |
| import org.eclipse.xtext.xbase.lib.Exceptions; |
| import org.slf4j.Logger; |
| import org.slf4j.LoggerFactory; |
| |
| @SuppressWarnings("all") |
| public class PerspectiveModelDerivedStateComputerx extends JvmModelAssociator { |
| private final static Logger log = LoggerFactory.getLogger(PerspectiveModelDerivedStateComputerx.class); |
| |
| private DerivedStateAwareResource resource; |
| |
| public void installDerivedState(final DerivedStateAwareResource resource, final boolean preLinkingPhase) { |
| PerspectiveModelDerivedStateComputerx.log.debug("PerspectiveModelDerivedStateComputerx called"); |
| super.installDerivedState(resource, preLinkingPhase); |
| this.resource = resource; |
| EList<EObject> _contents = resource.getContents(); |
| boolean _isEmpty = _contents.isEmpty(); |
| if (_isEmpty) { |
| return; |
| } |
| if ((!preLinkingPhase)) { |
| EList<EObject> _contents_1 = resource.getContents(); |
| EObject _get = _contents_1.get(0); |
| final PerspectiveModel eObject = ((PerspectiveModel) _get); |
| try { |
| EList<EObject> _eContents = eObject.eContents(); |
| final Consumer<EObject> _function = new Consumer<EObject>() { |
| public void accept(final EObject it) { |
| PerspectiveModelDerivedStateComputerx.this.map(it); |
| } |
| }; |
| _eContents.forEach(_function); |
| } catch (final Throwable _t) { |
| if (_t instanceof Exception) { |
| final Exception ex = (Exception)_t; |
| PerspectiveModelDerivedStateComputerx.log.error("{}", ex); |
| } else { |
| throw Exceptions.sneakyThrow(_t); |
| } |
| } |
| } |
| } |
| |
| protected void _map(final PerspectivePackage object) { |
| PerspectiveModelDerivedStateComputerx.log.debug("CCPerspectivePackage"); |
| EList<Perspective> _perspectives = object.getPerspectives(); |
| final Consumer<Perspective> _function = new Consumer<Perspective>() { |
| public void accept(final Perspective it) { |
| PerspectiveModelDerivedStateComputerx.this.map(it); |
| } |
| }; |
| _perspectives.forEach(_function); |
| } |
| |
| protected void _map(final Perspective object) { |
| PerspectiveModelDerivedStateComputerx.log.debug("CCPerspective"); |
| EList<PerspectiveElement> _elements = object.getElements(); |
| final Consumer<PerspectiveElement> _function = new Consumer<PerspectiveElement>() { |
| public void accept(final PerspectiveElement it) { |
| PerspectiveModelDerivedStateComputerx.this.map(it); |
| } |
| }; |
| _elements.forEach(_function); |
| } |
| |
| protected void _map(final PerspectiveSashContainer object) { |
| PerspectiveModelDerivedStateComputerx.log.debug("CCPerspectiveSashContainer"); |
| EList<PerspectiveElement> _elements = object.getElements(); |
| final Consumer<PerspectiveElement> _function = new Consumer<PerspectiveElement>() { |
| public void accept(final PerspectiveElement it) { |
| PerspectiveModelDerivedStateComputerx.this.map(it); |
| } |
| }; |
| _elements.forEach(_function); |
| } |
| |
| protected void _map(final PerspectivePartStack object) { |
| PerspectiveModelDerivedStateComputerx.log.debug("CCPerspectivePartStack"); |
| EList<PerspectiveElement> _elements = object.getElements(); |
| final Consumer<PerspectiveElement> _function = new Consumer<PerspectiveElement>() { |
| public void accept(final PerspectiveElement it) { |
| PerspectiveModelDerivedStateComputerx.this.map(it); |
| } |
| }; |
| _elements.forEach(_function); |
| } |
| |
| protected void _map(final PerspectivePart object) { |
| PerspectiveModelDerivedStateComputerx.log.debug("CCPerspectivePart"); |
| } |
| |
| protected void _map(final Void object) { |
| PerspectiveModelDerivedStateComputerx.log.debug("void"); |
| } |
| |
| public void map(final EObject object) { |
| if (object instanceof Perspective) { |
| _map((Perspective)object); |
| return; |
| } else if (object instanceof PerspectivePackage) { |
| _map((PerspectivePackage)object); |
| return; |
| } else if (object instanceof PerspectivePart) { |
| _map((PerspectivePart)object); |
| return; |
| } else if (object instanceof PerspectivePartStack) { |
| _map((PerspectivePartStack)object); |
| return; |
| } else if (object instanceof PerspectiveSashContainer) { |
| _map((PerspectiveSashContainer)object); |
| return; |
| } else if (object == null) { |
| _map((Void)null); |
| return; |
| } else { |
| throw new IllegalArgumentException("Unhandled parameter types: " + |
| Arrays.<Object>asList(object).toString()); |
| } |
| } |
| } |