blob: 599b534abecf10e3a3ec8a2f914fd194d7a19a40 [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.environment.surface.ui.composites;
import org.eclipse.apogy.core.environment.surface.AbstractMapLayer;
import org.eclipse.apogy.core.environment.surface.Map;
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 OtherLayersComposite extends Composite {
private Map map;
private final OtherLayersListComposite otherLayersListComposite;
private final OtherLayersDetailsComposite otherLayersDetailsComposite;
private final FormToolkit formToolkit = new FormToolkit(Display.getDefault());
public OtherLayersComposite(Composite parent, int style) {
super(parent, style);
setLayout(new GridLayout(1, false));
ScrolledForm scrldfrmImagesLayers = this.formToolkit.createScrolledForm(this);
scrldfrmImagesLayers.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
this.formToolkit.paintBordersFor(scrldfrmImagesLayers);
{
TableWrapLayout tableWrapLayout = new TableWrapLayout();
tableWrapLayout.makeColumnsEqualWidth = true;
tableWrapLayout.numColumns = 2;
scrldfrmImagesLayers.getBody().setLayout(tableWrapLayout);
}
Section sctnImageLayers = this.formToolkit.createSection(scrldfrmImagesLayers.getBody(),
ExpandableComposite.EXPANDED | ExpandableComposite.TWISTIE | ExpandableComposite.TITLE_BAR);
TableWrapData twd_sctnImageLayers = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 2, 1);
twd_sctnImageLayers.valign = TableWrapData.FILL;
twd_sctnImageLayers.grabVertical = true;
sctnImageLayers.setLayoutData(twd_sctnImageLayers);
this.formToolkit.paintBordersFor(sctnImageLayers);
sctnImageLayers.setText("Other Layers");
this.otherLayersListComposite = new OtherLayersListComposite(sctnImageLayers, SWT.NONE) {
@Override
protected void newAbstractMapLayerSelected(AbstractMapLayer abstractMapLayer) {
OtherLayersComposite.this.otherLayersDetailsComposite.setAbstractMapLayer(abstractMapLayer);
}
};
this.formToolkit.adapt(this.otherLayersListComposite);
this.formToolkit.paintBordersFor(this.otherLayersListComposite);
sctnImageLayers.setClient(this.otherLayersListComposite);
Section sctnImageLayerDetails = this.formToolkit.createSection(scrldfrmImagesLayers.getBody(),
ExpandableComposite.EXPANDED | ExpandableComposite.TWISTIE | ExpandableComposite.TITLE_BAR);
this.formToolkit.paintBordersFor(sctnImageLayerDetails);
sctnImageLayerDetails.setText("Layer Details");
this.otherLayersDetailsComposite = new OtherLayersDetailsComposite(sctnImageLayerDetails, SWT.NONE);
this.formToolkit.adapt(this.otherLayersDetailsComposite);
this.formToolkit.paintBordersFor(this.otherLayersDetailsComposite);
sctnImageLayerDetails.setClient(this.otherLayersDetailsComposite);
scrldfrmImagesLayers.reflow(true);
}
public Map getMap() {
return this.map;
}
public void setMap(Map newMap) {
this.map = newMap;
this.otherLayersListComposite.setMap(newMap);
this.otherLayersDetailsComposite.setAbstractMapLayer(null);
}
}