blob: 62c7865efa52a5401cc2f77e3309e717a7026eee [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 - initial API and implementation
*
* SPDX-License-Identifier: EPL-1.0
*******************************************************************************/
package org.eclipse.apogy.core.environment.earth.ui.composites;
import org.eclipse.apogy.core.environment.earth.ui.AbstractWorldWindLayer;
import org.eclipse.apogy.core.environment.earth.ui.EarthViewConfiguration;
import org.eclipse.swt.SWT;
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 EarthViewConfigurationComposite extends Composite {
private EarthViewConfiguration earthViewConfiguration;
private final AbstractWorldWindLayerListComposite abstractWorldWindLayerListComposite;
private final AbstractWorldWindLayerOverviewComposite abstractWorldWindLayerOverviewComposite;
private final AbstractWorldWindLayerDetailsComposite abstractWorldWindLayerDetailsComposite;
private final FormToolkit formToolkit = new FormToolkit(Display.getDefault());
public EarthViewConfigurationComposite(Composite parent, int style) {
super(parent, style);
setLayout(new GridLayout(1, true));
ScrolledForm scrldfrm = this.formToolkit.createScrolledForm(this);
scrldfrm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
this.formToolkit.paintBordersFor(scrldfrm);
scrldfrm.setText("");
{
TableWrapLayout tableWrapLayout = new TableWrapLayout();
tableWrapLayout.numColumns = 2;
tableWrapLayout.makeColumnsEqualWidth = false;
scrldfrm.getBody().setLayout(tableWrapLayout);
}
// Layers
Section sctnLayerList = this.formToolkit.createSection(scrldfrm.getBody(),
ExpandableComposite.EXPANDED | ExpandableComposite.TWISTIE | ExpandableComposite.TITLE_BAR);
TableWrapData twd_sctnLayerList = new TableWrapData(TableWrapData.FILL, TableWrapData.TOP, 3, 1);
twd_sctnLayerList.valign = TableWrapData.FILL;
twd_sctnLayerList.grabVertical = true;
twd_sctnLayerList.grabHorizontal = true;
sctnLayerList.setLayoutData(twd_sctnLayerList);
this.formToolkit.paintBordersFor(sctnLayerList);
sctnLayerList.setText("Earth View Layers");
this.abstractWorldWindLayerListComposite = new AbstractWorldWindLayerListComposite(sctnLayerList, SWT.NONE) {
@Override
protected void newAbstractWorldWindLayerSelected(AbstractWorldWindLayer newAbstractWorldWindLayer) {
EarthViewConfigurationComposite.this.abstractWorldWindLayerOverviewComposite
.setAbstractWorldWindLayer(newAbstractWorldWindLayer);
EarthViewConfigurationComposite.this.abstractWorldWindLayerDetailsComposite
.setAbstractWorldWindLayer(newAbstractWorldWindLayer);
}
};
this.formToolkit.adapt(this.abstractWorldWindLayerListComposite);
this.formToolkit.paintBordersFor(this.abstractWorldWindLayerListComposite);
sctnLayerList.setClient(this.abstractWorldWindLayerListComposite);
// Layer Overview.
Section sctnLayerOverview = this.formToolkit.createSection(scrldfrm.getBody(),
ExpandableComposite.EXPANDED | ExpandableComposite.TWISTIE | ExpandableComposite.TITLE_BAR);
TableWrapData twd_sctnLayerOverview = new TableWrapData(TableWrapData.FILL, TableWrapData.TOP, 1, 1);
twd_sctnLayerOverview.valign = TableWrapData.FILL;
twd_sctnLayerOverview.grabVertical = true;
twd_sctnLayerOverview.grabHorizontal = true;
sctnLayerOverview.setLayoutData(twd_sctnLayerOverview);
this.formToolkit.paintBordersFor(sctnLayerOverview);
sctnLayerOverview.setText("Layer Overview");
this.abstractWorldWindLayerOverviewComposite = new AbstractWorldWindLayerOverviewComposite(sctnLayerOverview,
SWT.NONE);
this.formToolkit.adapt(this.abstractWorldWindLayerOverviewComposite);
this.formToolkit.paintBordersFor(this.abstractWorldWindLayerOverviewComposite);
sctnLayerOverview.setClient(this.abstractWorldWindLayerOverviewComposite);
// Layer Details
Section sctnLayerDetails = this.formToolkit.createSection(scrldfrm.getBody(),
ExpandableComposite.EXPANDED | ExpandableComposite.TWISTIE | ExpandableComposite.TITLE_BAR);
TableWrapData twd_sctnLayerDetails = new TableWrapData(TableWrapData.FILL, TableWrapData.TOP, 1, 1);
twd_sctnLayerDetails.valign = TableWrapData.FILL;
twd_sctnLayerDetails.grabVertical = true;
twd_sctnLayerDetails.grabHorizontal = true;
sctnLayerDetails.setLayoutData(twd_sctnLayerDetails);
this.formToolkit.paintBordersFor(sctnLayerDetails);
sctnLayerDetails.setText("Layer Details");
this.abstractWorldWindLayerDetailsComposite = new AbstractWorldWindLayerDetailsComposite(sctnLayerDetails,
SWT.NONE);
this.formToolkit.adapt(this.abstractWorldWindLayerDetailsComposite);
this.formToolkit.paintBordersFor(this.abstractWorldWindLayerDetailsComposite);
sctnLayerDetails.setClient(this.abstractWorldWindLayerDetailsComposite);
}
public EarthViewConfiguration getEarthViewConfiguration() {
return this.earthViewConfiguration;
}
public void setEarthViewConfiguration(EarthViewConfiguration earthViewConfiguration) {
this.earthViewConfiguration = earthViewConfiguration;
this.abstractWorldWindLayerListComposite.setEarthViewConfiguration(earthViewConfiguration);
this.abstractWorldWindLayerOverviewComposite.setAbstractWorldWindLayer(null);
this.abstractWorldWindLayerDetailsComposite.setAbstractWorldWindLayer(null);
}
}