| /******************************************************************************* |
| * 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 - initial API and implementation |
| * |
| * SPDX-License-Identifier: EPL-1.0 |
| * |
| *******************************************************************************/ |
| package org.eclipse.apogy.addons.vehicle.ui.impl; |
| |
| import java.util.List; |
| |
| import org.eclipse.apogy.addons.vehicle.ApogyAddonsVehicleFactory; |
| import org.eclipse.apogy.addons.vehicle.ApogyAddonsVehiclePackage; |
| import org.eclipse.apogy.addons.vehicle.Thruster; |
| import org.eclipse.apogy.addons.vehicle.ThrusterBinding; |
| 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.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 ThrusterBindingWizardPagesProviderCustomImpl extends ThrusterBindingWizardPagesProviderImpl { |
| |
| @Override |
| public EObject createEObject(EClass eClass, EClassSettings settings) { |
| ThrusterBinding thrusterBinding = ApogyAddonsVehicleFactory.eINSTANCE.createThrusterBinding(); |
| return thrusterBinding; |
| } |
| |
| @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); |
| } |
| |
| ThrusterBinding binding = (ThrusterBinding) eObject; |
| |
| TopologyNodeSelectionWizardPage topologyNodeSelectionWizardPage = new TopologyNodeSelectionWizardPage( |
| "Select Thruster", "Select the Thruster that this binding is controlling.", binding, |
| ApogyAddonsVehiclePackage.Literals.THRUSTER, nodes) { |
| @Override |
| protected void nodeSelected(Node nodeSelected) { |
| if (binding != null && nodeSelected instanceof Thruster) { |
| ApogyCommonTransactionFacade.INSTANCE.basicSet(binding, |
| ApogyAddonsVehiclePackage.Literals.THRUSTER_BINDING__THRUSTER, nodeSelected, true); |
| |
| setMessage("Node selected : " + nodeSelected.getNodeId()); |
| setErrorMessage(null); |
| } else { |
| setErrorMessage("The selected Node is not a Thruster !"); |
| } |
| } |
| }; |
| |
| list.add(topologyNodeSelectionWizardPage); |
| |
| return list; |
| } |
| } // ThrusterBindingWizardPagesProviderImpl |