| /******************************************************************************* |
| * 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, |
| * Regent L'Archeveque, |
| * Olivier L. Larouche - initial API and implementation |
| * |
| * SPDX-License-Identifier: EPL-1.0 |
| * |
| *******************************************************************************/ |
| package org.eclipse.apogy.core.invocator.ui.impl; |
| |
| import java.util.HashMap; |
| |
| import org.eclipse.apogy.common.emf.ApogyCommonEMFFacade; |
| import org.eclipse.apogy.core.invocator.ui.ProgramUIFactory; |
| import org.eclipse.core.runtime.IConfigurationElement; |
| import org.eclipse.core.runtime.IExtensionPoint; |
| import org.eclipse.core.runtime.Platform; |
| import org.eclipse.emf.ecore.EClass; |
| import org.slf4j.Logger; |
| import org.slf4j.LoggerFactory; |
| |
| public class ProgramUIFactoriesRegistryCustomImpl extends ProgramUIFactoriesRegistryImpl { |
| |
| private static final Logger Logger = LoggerFactory.getLogger(ProgramUIFactoriesRegistryImpl.class); |
| |
| public HashMap<EClass, ProgramUIFactory> getProgramUIFactoriesMap() { |
| HashMap<EClass, ProgramUIFactory> map = super.getProgramUIFactoriesMap(); |
| |
| if (this.programUIFactoriesMap == null) { |
| map = new HashMap<EClass, ProgramUIFactory>(); |
| |
| IExtensionPoint extensionPoint = Platform.getExtensionRegistry() |
| .getExtensionPoint(getPROGRAM_FACTORY_PROVIDER_CONTRIBUTORS_POINT_ID()); |
| |
| IConfigurationElement[] contributors = extensionPoint.getConfigurationElements(); |
| |
| for (int i = 0; i < contributors.length; i++) { |
| IConfigurationElement contributor = contributors[i]; |
| try { |
| String eClassStr = contributor.getAttribute(getPROGRAM_FACTORY_PROVIDER_CONTRIBUTORS_ECLASS_ID()); |
| EClass eClass = ApogyCommonEMFFacade.INSTANCE.getEClass(eClassStr); |
| ProgramUIFactory programFactory = (ProgramUIFactory) contributor |
| .createExecutableExtension(getPROGRAM_FACTORY_PROVIDER_CONTRIBUTORS_FACTORY_ID()); |
| map.put(eClass, programFactory); |
| } catch (Exception e) { |
| Logger.error("Failed to load contributed ProgramUIFactory from <" + contributor.getClass().getName() |
| + ">", e); |
| } |
| } |
| setProgramUIFactoriesMap(map); |
| } |
| |
| return map; |
| } |
| |
| public ProgramUIFactory getFactory(EClass eClass) { |
| return getProgramUIFactoriesMap().get(eClass); |
| } |
| |
| } // ProgramUIFactoriesRegistryImpl |