blob: 5d332c516250b87836304ec561bb0b2eb077f4e7 [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.topology.ui.composites;
import org.eclipse.apogy.common.topology.AbstractViewPoint;
import org.eclipse.apogy.common.topology.ui.composites.AbstractViewPointComposite;
import org.eclipse.apogy.core.environment.ViewPointList;
import org.eclipse.apogy.core.environment.ui.composites.ViewPointListComposite;
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 ViewPointEditComposite extends Composite {
private ViewPointList viewPointList;
private final FormToolkit formToolkit = new FormToolkit(Display.getDefault());
private final ViewPointListComposite viewPointListComposite;
private final AbstractViewPointComposite abstractViewPointComposite;
private final AbstractViewPointDetailsComposite abstractViewPointDetailsComposite;
private AbstractViewPoint currentActiveViewPoint;
public ViewPointEditComposite(Composite parent, int style, AbstractViewPoint currentActiveViewPoint) {
super(parent, style);
this.currentActiveViewPoint = currentActiveViewPoint;
setLayout(new GridLayout(1, false));
ScrolledForm scrldfrm = this.formToolkit.createScrolledForm(this);
scrldfrm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
this.formToolkit.paintBordersFor(scrldfrm);
scrldfrm.setText("View Points");
{
TableWrapLayout tableWrapLayout = new TableWrapLayout();
tableWrapLayout.numColumns = 2;
tableWrapLayout.makeColumnsEqualWidth = true;
scrldfrm.getBody().setLayout(tableWrapLayout);
}
// View Point List
Section sctnViewPoints = this.formToolkit.createSection(scrldfrm.getBody(),
ExpandableComposite.EXPANDED | ExpandableComposite.TWISTIE | ExpandableComposite.TITLE_BAR);
TableWrapData twd_sctnViewPoints = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 2, 1);
twd_sctnViewPoints.valign = TableWrapData.FILL;
twd_sctnViewPoints.grabVertical = true;
twd_sctnViewPoints.grabHorizontal = true;
twd_sctnViewPoints.align = TableWrapData.FILL;
sctnViewPoints.setLayoutData(twd_sctnViewPoints);
this.formToolkit.paintBordersFor(sctnViewPoints);
sctnViewPoints.setText("View Points");
this.viewPointListComposite = new ViewPointListComposite(sctnViewPoints, SWT.NONE) {
@Override
protected void newViewPointSelected(AbstractViewPoint viewPoint) {
ViewPointEditComposite.this.currentActiveViewPoint = viewPoint;
ViewPointEditComposite.this.abstractViewPointComposite.setAbstractViewPoint(viewPoint);
ViewPointEditComposite.this.abstractViewPointDetailsComposite.setAbstractViewPoint(viewPoint);
ViewPointEditComposite.this.newViewPointSelected(viewPoint);
}
};
this.formToolkit.adapt(this.viewPointListComposite);
this.formToolkit.paintBordersFor(this.viewPointListComposite);
sctnViewPoints.setClient(this.viewPointListComposite);
// View Point Overview.
Section sctnOverview = this.formToolkit.createSection(scrldfrm.getBody(),
ExpandableComposite.EXPANDED | ExpandableComposite.TWISTIE | ExpandableComposite.TITLE_BAR);
TableWrapData twd_sctnOverview = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1);
twd_sctnOverview.grabVertical = true;
twd_sctnOverview.valign = TableWrapData.FILL;
twd_sctnOverview.grabHorizontal = true;
twd_sctnOverview.align = TableWrapData.FILL;
sctnOverview.setLayoutData(twd_sctnOverview);
this.formToolkit.paintBordersFor(sctnOverview);
sctnOverview.setText("Overview");
this.abstractViewPointComposite = new AbstractViewPointComposite(sctnOverview, SWT.NONE, null);
this.formToolkit.adapt(this.abstractViewPointComposite);
this.formToolkit.paintBordersFor(this.abstractViewPointComposite);
sctnOverview.setClient(this.abstractViewPointComposite);
// View Point Details.
Section sctnDetails = this.formToolkit.createSection(scrldfrm.getBody(),
ExpandableComposite.EXPANDED | ExpandableComposite.TWISTIE | ExpandableComposite.TITLE_BAR);
TableWrapData twd_sctnDetails = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1);
twd_sctnDetails.grabVertical = true;
twd_sctnDetails.valign = TableWrapData.FILL;
twd_sctnDetails.grabHorizontal = true;
twd_sctnDetails.align = TableWrapData.FILL;
sctnDetails.setLayoutData(twd_sctnDetails);
this.formToolkit.paintBordersFor(sctnOverview);
sctnDetails.setText("Details");
this.abstractViewPointDetailsComposite = new AbstractViewPointDetailsComposite(sctnDetails, SWT.NONE);
this.formToolkit.adapt(this.abstractViewPointDetailsComposite);
this.formToolkit.paintBordersFor(this.abstractViewPointDetailsComposite);
sctnDetails.setClient(this.abstractViewPointDetailsComposite);
addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
ViewPointEditComposite.this.formToolkit.dispose();
}
});
}
public ViewPointList getViewPointList() {
return this.viewPointList;
}
public void setViewPointList(ViewPointList viewPointList) {
this.viewPointList = viewPointList;
if (this.viewPointListComposite != null && !this.viewPointListComposite.isDisposed()) {
this.viewPointListComposite.setViewPointList(viewPointList);
if (viewPointList != null) {
this.viewPointListComposite.setSelectedViewPoint(this.currentActiveViewPoint);
}
}
if (this.abstractViewPointComposite != null && !this.abstractViewPointComposite.isDisposed()) {
this.abstractViewPointComposite.setAbstractViewPoint(this.currentActiveViewPoint);
}
}
protected void newViewPointSelected(AbstractViewPoint viewPoint) {
}
}