blob: a563e3c16366fe9b730585269458fe522dffb328 [file] [log] [blame]
/*******************************************************************************
* 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,
* Olivier L. Larouche - initial API and implementation
*
* SPDX-License-Identifier: EPL-1.0
*******************************************************************************/
package org.eclipse.apogy.core.programs.controllers.ui.composite;
import org.eclipse.apogy.common.emf.transaction.ApogyCommonTransactionFacade;
import org.eclipse.apogy.common.emf.ui.composites.SubClassesListComposite;
import org.eclipse.apogy.common.emf.ui.emfforms.ApogyCommonEMFUiEMFFormsFacade;
import org.eclipse.apogy.common.io.jinput.EComponentQualifier;
import org.eclipse.apogy.core.programs.controllers.AbstractInputConditioning;
import org.eclipse.apogy.core.programs.controllers.ApogyCoreProgramsControllersPackage;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.TreeSelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
public class ConditioningComposite extends ScrolledComposite {
private final Composite composite;
private final Composite conditioningEMFForms;
private final SubClassesListComposite subClassesListComposite;
private final InputConditioningComposite plotComposite;
private AbstractInputConditioning abstractInputConditioning;
/**
* Create the parentComposite.
*
* @param parent Reference to the parent parentComposite.
* @param style Composite style.
*/
public ConditioningComposite(Composite parent, int style) {
super(parent, style);
setExpandHorizontal(true);
setExpandVertical(true);
this.composite = new Composite(this, SWT.None);
this.composite.setLayout(new GridLayout(2, true));
/**
* PlotComposite
*/
this.plotComposite = new InputConditioningComposite(this.composite, SWT.None);
this.plotComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 2));
/**
* EMFForms
*/
this.conditioningEMFForms = new Composite(this.composite, SWT.None);
GridLayout gridLayout_EMFFormsvalue = new GridLayout(1, true);
gridLayout_EMFFormsvalue.marginWidth = 0;
gridLayout_EMFFormsvalue.marginHeight = 0;
this.conditioningEMFForms.setLayout(gridLayout_EMFFormsvalue);
this.conditioningEMFForms.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
this.conditioningEMFForms.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
/**
* Conditioning sub classes list.
*/
this.subClassesListComposite = new SubClassesListComposite(this.composite, SWT.None) {
@Override
protected void newSelection(TreeSelection selection) {
if (!selection.isEmpty()) {
AbstractInputConditioning tempAbstractInputConditioning = (AbstractInputConditioning) EcoreUtil
.create((EClass) selection.getFirstElement());
ApogyCommonTransactionFacade.INSTANCE.basicSet(
ConditioningComposite.this.abstractInputConditioning.eContainer(),
ApogyCoreProgramsControllersPackage.Literals.CONTROLLER_VALUE_SOURCE__CONDITIONING,
tempAbstractInputConditioning);
ConditioningComposite.this.abstractInputConditioning = tempAbstractInputConditioning;
ConditioningComposite.this.plotComposite
.setAbstractInputConditioning(ConditioningComposite.this.abstractInputConditioning);
ApogyCommonEMFUiEMFFormsFacade.INSTANCE.createEMFForms(
ConditioningComposite.this.conditioningEMFForms,
ConditioningComposite.this.abstractInputConditioning);
ConditioningComposite.this.newSelection(selection);
}
}
};
this.subClassesListComposite
.setSuperClass(ApogyCoreProgramsControllersPackage.Literals.ABSTRACT_INPUT_CONDITIONING);
this.subClassesListComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
this.subClassesListComposite.moveAbove(this.plotComposite);
setMinSize(this.composite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
setContent(this.composite);
}
/**
* This method is called when a new selection is made.
*
* @param selection Reference to the selection.
*/
protected void newSelection(ISelection selection) {
}
/**
* Binds the {@link AbstractInputConditioning} with the UI components.
*
* @param abstractInputConditioning Reference to the
* {@link AbstractInputConditioning}.
*/
public void setAbstractInputConditioning(AbstractInputConditioning abstractInputConditioning) {
this.abstractInputConditioning = abstractInputConditioning;
ApogyCommonEMFUiEMFFormsFacade.INSTANCE.createEMFForms(this.conditioningEMFForms,
this.abstractInputConditioning);
this.subClassesListComposite.setSelectedEClass(this.abstractInputConditioning.eClass());
this.plotComposite.setAbstractInputConditioning(this.abstractInputConditioning);
this.composite.layout();
}
public void setEComponentQualifier(EComponentQualifier eComponentQualifier) {
this.plotComposite.setEComponentQualifier(eComponentQualifier);
}
}