| /******************************************************************************* |
| * 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.common.topology.bindings.ui.parts; |
| |
| import java.util.Collection; |
| import java.util.HashMap; |
| |
| import org.eclipse.apogy.common.emf.ui.parts.AbstractEObjectSelectionPart; |
| import org.eclipse.apogy.common.topology.Node; |
| import org.eclipse.apogy.common.topology.bindings.BindingsSet; |
| import org.eclipse.apogy.common.topology.bindings.ui.composites.BindingsSetComposite; |
| import org.eclipse.e4.ui.workbench.modeling.ISelectionListener; |
| import org.eclipse.emf.ecore.EObject; |
| import org.eclipse.swt.widgets.Composite; |
| |
| public abstract class BindingsSetPart extends AbstractEObjectSelectionPart { |
| @SuppressWarnings("unused") |
| private BindingsSet bindingsSet; |
| private BindingsSetComposite bindingsSetComposite; |
| |
| @Override |
| protected void setCompositeContents(EObject eObject) { |
| if (eObject == null || eObject instanceof BindingsSet) { |
| setBindingsSet((BindingsSet) eObject); |
| } |
| } |
| |
| @Override |
| protected void createContentComposite(Composite parent, int style) { |
| this.bindingsSetComposite = new BindingsSetComposite(parent, style) { |
| @Override |
| public Collection<Node> getAvailableNodes() { |
| return BindingsSetPart.this.getAvailableNodes(); |
| } |
| }; |
| } |
| |
| @Override |
| protected HashMap<String, ISelectionListener> getSelectionProvidersIdsToSelectionListeners() { |
| HashMap<String, ISelectionListener> selectionProvidersIdsToSelectionListeners = new HashMap<String, ISelectionListener>(); |
| return selectionProvidersIdsToSelectionListeners; |
| } |
| |
| protected void setBindingsSet(BindingsSet newBindingsSet) { |
| this.bindingsSet = newBindingsSet; |
| |
| if (this.bindingsSetComposite != null && !this.bindingsSetComposite.isDisposed()) { |
| this.bindingsSetComposite.setBindingsSet(newBindingsSet); |
| } |
| } |
| |
| /** |
| * Returns the list of Node available for binding. |
| * |
| * @return The collection of Node, can be empty, never null. |
| */ |
| public abstract Collection<Node> getAvailableNodes(); |
| } |