| /******************************************************************************* |
| * 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.core.environment.earth.surface.ui.parts; |
| |
| import javax.inject.Inject; |
| |
| import org.eclipse.apogy.core.environment.ApogyEnvironment; |
| import org.eclipse.apogy.core.environment.earth.surface.EarthSurfaceWorksite; |
| import org.eclipse.apogy.core.environment.earth.surface.ui.composites.EarthSurfaceWorksitesComposite; |
| import org.eclipse.apogy.core.invocator.InvocatorSession; |
| import org.eclipse.apogy.core.invocator.ui.parts.AbstractSessionBasedPart; |
| import org.eclipse.e4.ui.workbench.modeling.EPartService; |
| import org.eclipse.swt.SWT; |
| import org.eclipse.swt.layout.FillLayout; |
| import org.eclipse.swt.widgets.Composite; |
| |
| public class EarthSurfaceWorksitesPart extends AbstractSessionBasedPart { |
| @Inject |
| protected EPartService ePartService; |
| |
| private EarthSurfaceWorksitesComposite earthSurfaceWorksitesComposite; |
| |
| @Override |
| protected void newInvocatorSession(InvocatorSession invocatorSession) { |
| if (invocatorSession != null) { |
| if (invocatorSession.getEnvironment() instanceof ApogyEnvironment) { |
| ApogyEnvironment apogyEnvironment = (ApogyEnvironment) invocatorSession.getEnvironment(); |
| this.earthSurfaceWorksitesComposite.setApogyEnvironment(apogyEnvironment); |
| } else { |
| this.earthSurfaceWorksitesComposite.setApogyEnvironment(null); |
| } |
| } |
| } |
| |
| @Override |
| protected void createContentComposite(Composite parent, int style) { |
| parent.setLayout(new FillLayout()); |
| this.earthSurfaceWorksitesComposite = new EarthSurfaceWorksitesComposite(parent, SWT.NONE) { |
| @Override |
| protected void newEarthSurfaceWorksiteSelected(EarthSurfaceWorksite earthSurfaceWorksite) { |
| EarthSurfaceWorksitesPart.this.selectionService.setSelection(earthSurfaceWorksite); |
| } |
| }; |
| } |
| } |