| /******************************************************************************* |
| * 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.ui.parts; |
| |
| import java.util.HashMap; |
| |
| import org.eclipse.apogy.common.emf.ui.parts.AbstractEObjectSelectionPart; |
| import org.eclipse.apogy.core.invocator.AbstractResult; |
| import org.eclipse.apogy.core.invocator.ui.composites.AbstractResultValueDetailsComposite; |
| import org.eclipse.apogy.core.ui.ApogyCoreUIRCPConstants; |
| 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 DataProductResultValueDetails extends AbstractEObjectSelectionPart { |
| private AbstractResultValueDetailsComposite abstractResultValueDetailsComposite; |
| |
| @Override |
| protected void setCompositeContents(EObject eObject) { |
| if (this.abstractResultValueDetailsComposite != null |
| && !this.abstractResultValueDetailsComposite.isDisposed()) { |
| if (eObject instanceof AbstractResult) { |
| AbstractResult abstractResult = (AbstractResult) eObject; |
| this.abstractResultValueDetailsComposite.setAbstractResultValue(abstractResult.getResultValue()); |
| } else { |
| this.abstractResultValueDetailsComposite.setAbstractResultValue(null); |
| } |
| } |
| } |
| |
| @Override |
| protected void createContentComposite(Composite parent, int style) { |
| this.abstractResultValueDetailsComposite = new AbstractResultValueDetailsComposite(parent, SWT.BORDER); |
| } |
| |
| @Override |
| protected HashMap<String, ISelectionListener> getSelectionProvidersIdsToSelectionListeners() { |
| HashMap<String, ISelectionListener> map = new HashMap<>(); |
| |
| map.put(ApogyCoreUIRCPConstants.PART__POSITIONED_RESULT_SEARCH__ID, new ISelectionListener() { |
| @Override |
| public void selectionChanged(MPart part, Object selection) { |
| if (selection instanceof AbstractResult) { |
| AbstractResult result = (AbstractResult) selection; |
| setEObject(result); |
| } |
| } |
| }); |
| |
| return map; |
| } |
| } |