| /******************************************************************************* |
| * 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.parts; |
| |
| import java.util.HashMap; |
| |
| import org.eclipse.apogy.common.emf.ui.parts.AbstractEObjectSelectionPart; |
| import org.eclipse.apogy.core.environment.earth.ui.ApogyEarthEnvironmentUIRCPConstants; |
| import org.eclipse.apogy.core.environment.earth.ui.EarthViewConfiguration; |
| import org.eclipse.apogy.core.environment.earth.ui.composites.EarthViewConfigurationComposite; |
| import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
| import org.eclipse.e4.ui.workbench.modeling.ISelectionListener; |
| import org.eclipse.emf.ecore.EObject; |
| import org.eclipse.swt.SWT; |
| import org.eclipse.swt.widgets.Composite; |
| |
| public class EarthViewConfigurationPart extends AbstractEObjectSelectionPart { |
| private EarthViewConfigurationComposite earthViewConfigurationComposite; |
| |
| @Override |
| protected void setCompositeContents(EObject eObject) { |
| if (eObject instanceof EarthViewConfiguration) { |
| this.earthViewConfigurationComposite.setEarthViewConfiguration((EarthViewConfiguration) eObject); |
| } else { |
| this.earthViewConfigurationComposite.setEarthViewConfiguration(null); |
| } |
| } |
| |
| @Override |
| protected void createContentComposite(Composite parent, int style) { |
| this.earthViewConfigurationComposite = new EarthViewConfigurationComposite(parent, SWT.BORDER); |
| } |
| |
| @Override |
| protected HashMap<String, ISelectionListener> getSelectionProvidersIdsToSelectionListeners() { |
| HashMap<String, ISelectionListener> map = new HashMap<>(); |
| |
| map.put(ApogyEarthEnvironmentUIRCPConstants.PART__EARTH_VIEW__ID, new ISelectionListener() { |
| @Override |
| public void selectionChanged(MPart part, Object selection) { |
| if (selection instanceof EarthViewConfiguration) { |
| EarthViewConfiguration earthViewConfiguration = (EarthViewConfiguration) selection; |
| setEObject(earthViewConfiguration); |
| } |
| } |
| }); |
| |
| return map; |
| } |
| } |