| /******************************************************************************* |
| * 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 - initial API and implementation |
| * |
| * SPDX-License-Identifier: EPL-1.0 |
| *******************************************************************************/ |
| package org.eclipse.apogy.core.environment.earth.ui.impl; |
| |
| import java.util.Iterator; |
| |
| import org.eclipse.apogy.common.emf.transaction.ApogyCommonTransactionFacade; |
| import org.eclipse.apogy.core.environment.earth.ui.ApogyEarthEnvironmentUIFactory; |
| import org.eclipse.apogy.core.environment.earth.ui.EarthViewConfigurationList; |
| import org.eclipse.apogy.core.invocator.AbstractToolsListContainer; |
| import org.eclipse.apogy.core.invocator.ApogyCoreInvocatorFacade; |
| import org.eclipse.apogy.core.invocator.ApogyCoreInvocatorFactory; |
| import org.eclipse.apogy.core.invocator.ApogyCoreInvocatorPackage; |
| import org.eclipse.apogy.core.invocator.InvocatorSession; |
| import org.eclipse.apogy.core.invocator.ToolsList; |
| |
| public class EarthUIFacadeCustomImpl extends EarthUIFacadeImpl { |
| |
| public EarthViewConfigurationList getActiveEarthViewConfigurationList() { |
| EarthViewConfigurationList earthViewConfigurationList = null; |
| |
| InvocatorSession session = ApogyCoreInvocatorFacade.INSTANCE.getActiveInvocatorSession(); |
| if (session != null) { |
| ToolsList toolsList = session.getToolsList(); |
| if (toolsList == null) { |
| toolsList = ApogyCoreInvocatorFactory.eINSTANCE.createToolsList(); |
| ApogyCommonTransactionFacade.INSTANCE.basicSet(session, |
| ApogyCoreInvocatorPackage.Literals.INVOCATOR_SESSION__TOOLS_LIST, toolsList); |
| |
| } |
| |
| Iterator<AbstractToolsListContainer> it = toolsList.getToolsListContainers().iterator(); |
| while (earthViewConfigurationList == null && it.hasNext()) { |
| AbstractToolsListContainer abstractToolsListContainer = it.next(); |
| if (abstractToolsListContainer instanceof EarthViewConfigurationList) { |
| earthViewConfigurationList = (EarthViewConfigurationList) abstractToolsListContainer; |
| } |
| } |
| |
| // If none was found, create one. |
| if (earthViewConfigurationList == null) { |
| earthViewConfigurationList = ApogyEarthEnvironmentUIFactory.eINSTANCE |
| .createEarthViewConfigurationList(); |
| ApogyCommonTransactionFacade.INSTANCE.basicAdd(toolsList, |
| ApogyCoreInvocatorPackage.Literals.TOOLS_LIST__TOOLS_LIST_CONTAINERS, |
| earthViewConfigurationList); |
| } |
| |
| } |
| return earthViewConfigurationList; |
| } |
| |
| } // EarthUIFacadeImpl |