blob: 9fbaad02450ee2b63213e3cc73a3e0292edefe08 [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 - initial API and implementation
*
* SPDX-License-Identifier: EPL-1.0
*******************************************************************************/
package org.eclipse.apogy.core.ui.composites;
import org.eclipse.apogy.core.ApogySystem;
import org.eclipse.apogy.core.ConnectionPoint;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.forms.widgets.ExpandableComposite;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.ScrolledForm;
import org.eclipse.ui.forms.widgets.Section;
import org.eclipse.ui.forms.widgets.TableWrapData;
import org.eclipse.ui.forms.widgets.TableWrapLayout;
public class ApogySystemConnectionPointsComposite extends Composite {
private ApogySystem apogySystem;
private final ApogySystemConnectionPointsListComposite apogySystemConnectionPointsListComposite;
private final ConnectionPointOverviewComposite connectionPointOverviewComposite;
private final FormToolkit formToolkit = new FormToolkit(Display.getDefault());
public ApogySystemConnectionPointsComposite(Composite parent, int style) {
super(parent, style);
setLayout(new GridLayout(1, true));
ScrolledForm scrolledForm = this.formToolkit.createScrolledForm(this);
scrolledForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
this.formToolkit.paintBordersFor(scrolledForm);
{
TableWrapLayout tableWrapLayout = new TableWrapLayout();
tableWrapLayout.numColumns = 1;
tableWrapLayout.makeColumnsEqualWidth = true;
scrolledForm.getBody().setLayout(tableWrapLayout);
}
// Connections Points
Section sctnConnectionPoints = this.formToolkit.createSection(scrolledForm.getBody(),
ExpandableComposite.EXPANDED | ExpandableComposite.TWISTIE | ExpandableComposite.TITLE_BAR);
TableWrapData twd_sctnDemlist = new TableWrapData(TableWrapData.FILL, TableWrapData.TOP, 3, 1);
twd_sctnDemlist.valign = TableWrapData.FILL;
twd_sctnDemlist.grabVertical = true;
twd_sctnDemlist.grabHorizontal = true;
sctnConnectionPoints.setLayoutData(twd_sctnDemlist);
this.formToolkit.paintBordersFor(sctnConnectionPoints);
sctnConnectionPoints.setText("Connection Points");
this.apogySystemConnectionPointsListComposite = new ApogySystemConnectionPointsListComposite(
sctnConnectionPoints, SWT.NONE) {
@Override
protected void newConnectionPointSelected(ConnectionPoint connectionPoint) {
ApogySystemConnectionPointsComposite.this.connectionPointOverviewComposite
.setConnectionPoint(connectionPoint);
}
};
this.formToolkit.adapt(this.apogySystemConnectionPointsListComposite);
this.formToolkit.paintBordersFor(this.apogySystemConnectionPointsListComposite);
sctnConnectionPoints.setClient(this.apogySystemConnectionPointsListComposite);
// Connections Points
Section sctnConnectionPointOverview = this.formToolkit.createSection(scrolledForm.getBody(),
ExpandableComposite.EXPANDED | ExpandableComposite.TWISTIE | ExpandableComposite.TITLE_BAR);
TableWrapData twd_sctnOverview = new TableWrapData(TableWrapData.FILL, TableWrapData.TOP, 3, 1);
twd_sctnOverview.valign = TableWrapData.FILL;
twd_sctnOverview.grabVertical = true;
twd_sctnOverview.grabHorizontal = true;
sctnConnectionPointOverview.setLayoutData(twd_sctnOverview);
this.formToolkit.paintBordersFor(sctnConnectionPointOverview);
sctnConnectionPointOverview.setText("Connection Point Overview");
this.connectionPointOverviewComposite = new ConnectionPointOverviewComposite(sctnConnectionPointOverview,
SWT.NONE);
this.formToolkit.adapt(this.connectionPointOverviewComposite);
this.formToolkit.paintBordersFor(this.connectionPointOverviewComposite);
sctnConnectionPointOverview.setClient(this.connectionPointOverviewComposite);
// Do clean up upon dispose.
addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent arg0) {
ApogySystemConnectionPointsComposite.this.apogySystem = null;
}
});
}
public ApogySystem getApogySystem() {
return this.apogySystem;
}
public void setApogySystem(ApogySystem apogySystem) {
this.apogySystem = apogySystem;
if (this.apogySystemConnectionPointsListComposite != null
&& !this.apogySystemConnectionPointsListComposite.isDisposed()) {
if (apogySystem != null) {
this.apogySystemConnectionPointsListComposite
.setConnectionPointsList(apogySystem.getConnectionPointsList());
} else {
this.apogySystemConnectionPointsListComposite.setConnectionPointsList(null);
}
}
}
}