| /******************************************************************************* |
| * 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, |
| * Sebastien Gemme - initial API and implementation |
| * SPDX-License-Identifier: EPL-1.0 |
| * |
| *******************************************************************************/ |
| package org.eclipse.apogy.addons.ros.ui.parts; |
| |
| import javax.inject.Inject; |
| |
| import org.eclipse.apogy.addons.ros.ApogyROSRegistry; |
| import org.eclipse.apogy.addons.ros.ui.composites.ROSInterfacesComposite; |
| import org.eclipse.apogy.core.invocator.InvocatorSession; |
| import org.eclipse.apogy.core.invocator.ui.parts.AbstractSessionBasedPart; |
| import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
| 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 ROSRegistryPart extends AbstractSessionBasedPart { |
| @Inject |
| protected EPartService ePartService; |
| |
| private ROSInterfacesComposite rosInterfacesComposite; |
| |
| @Override |
| protected void newInvocatorSession(InvocatorSession invocatorSession) { |
| if (invocatorSession != null) { |
| this.rosInterfacesComposite.setApogyROSRegistry(ApogyROSRegistry.INSTANCE); |
| } else { |
| this.rosInterfacesComposite.setApogyROSRegistry(null); |
| } |
| |
| } |
| |
| @Override |
| protected void createContentComposite(Composite parent, int style) { |
| parent.setLayout(new FillLayout()); |
| this.rosInterfacesComposite = new ROSInterfacesComposite(parent, SWT.NONE); |
| } |
| |
| /** |
| * Method called before the Part is destroyed. |
| * |
| * @param mPart The reference to the Part model. |
| */ |
| @Override |
| public void userPreDestroy(MPart mPart) { |
| if (this.rosInterfacesComposite != null && !this.rosInterfacesComposite.isDisposed()) { |
| this.rosInterfacesComposite.setApogyROSRegistry(null); |
| } |
| } |
| } |