| /******************************************************************************* |
| * 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.common.topology.addons.primitives.bindings.ui.impl; |
| |
| import java.util.List; |
| |
| import org.eclipse.apogy.common.emf.transaction.ApogyCommonTransactionFacade; |
| import org.eclipse.apogy.common.emf.ui.EClassSettings; |
| import org.eclipse.apogy.common.emf.ui.MapBasedEClassSettings; |
| import org.eclipse.apogy.common.topology.Node; |
| import org.eclipse.apogy.common.topology.addons.primitives.ApogyCommonTopologyAddonsPrimitivesPackage; |
| import org.eclipse.apogy.common.topology.addons.primitives.SpotLight; |
| import org.eclipse.apogy.common.topology.addons.primitives.bindings.ApogyCommonTopologyAddonsPrimitivesBindingsFactory; |
| import org.eclipse.apogy.common.topology.addons.primitives.bindings.ApogyCommonTopologyAddonsPrimitivesBindingsPackage; |
| import org.eclipse.apogy.common.topology.addons.primitives.bindings.SpotLightBinding; |
| import org.eclipse.apogy.common.topology.bindings.ui.TopologyUIBindingsConstants; |
| import org.eclipse.apogy.common.topology.bindings.ui.wizards.TopologyNodeSelectionWizardPage; |
| import org.eclipse.emf.common.util.BasicEList; |
| import org.eclipse.emf.common.util.EList; |
| import org.eclipse.emf.ecore.EClass; |
| import org.eclipse.emf.ecore.EObject; |
| import org.eclipse.jface.wizard.WizardPage; |
| |
| public class SpotLightBindingWizardPagesProviderCustomImpl extends SpotLightBindingWizardPagesProviderImpl { |
| |
| @Override |
| public EObject createEObject(EClass eClass, EClassSettings settings) { |
| SpotLightBinding spotLightBinding = ApogyCommonTopologyAddonsPrimitivesBindingsFactory.eINSTANCE |
| .createSpotLightBinding(); |
| return spotLightBinding; |
| } |
| |
| @SuppressWarnings("unchecked") |
| @Override |
| public EList<WizardPage> instantiateWizardPages(EObject eObject, EClassSettings settings) { |
| EList<WizardPage> list = new BasicEList<>(); |
| list.addAll(super.instantiateWizardPages(eObject, settings)); |
| |
| // Add topology node selection page. |
| List<Node> nodes = null; |
| if (settings instanceof MapBasedEClassSettings) { |
| MapBasedEClassSettings mapBasedEClassSettings = (MapBasedEClassSettings) settings; |
| nodes = (List<Node>) mapBasedEClassSettings.getUserDataMap() |
| .get(TopologyUIBindingsConstants.NODES_LIST_USER_ID); |
| } |
| |
| SpotLightBinding binding = (SpotLightBinding) eObject; |
| |
| TopologyNodeSelectionWizardPage topologyNodeSelectionWizardPage = new TopologyNodeSelectionWizardPage( |
| "Select Spot Light", "Select the Spot Light that this binding is controlling.", binding, |
| ApogyCommonTopologyAddonsPrimitivesPackage.Literals.SPOT_LIGHT, nodes) { |
| @Override |
| protected void nodeSelected(Node nodeSelected) { |
| if (this.abstractTopologyBinding != null && nodeSelected instanceof SpotLight) { |
| ApogyCommonTransactionFacade.INSTANCE.basicSet(this.abstractTopologyBinding, |
| ApogyCommonTopologyAddonsPrimitivesBindingsPackage.Literals.SPOT_LIGHT_BINDING__SPOT_LIGHT, |
| nodeSelected, true); |
| |
| setMessage("Node selected : " + nodeSelected.getNodeId()); |
| setErrorMessage(null); |
| } else { |
| setErrorMessage("The selected Node is not a Spot Light !"); |
| } |
| } |
| }; |
| |
| list.add(topologyNodeSelectionWizardPage); |
| |
| return list; |
| } |
| } // SpotLightBindingWizardPagesProviderImpl |