blob: 5438c438b56d237dd2bf63d3d6cd16575a560509 [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
* Regent L'Archeveque
*
* SPDX-License-Identifier: EPL-1.0
*******************************************************************************/
package org.eclipse.apogy.addons.ui.composites;
import org.eclipse.apogy.addons.SimpleTool;
import org.eclipse.apogy.addons.SimpleToolList;
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 SimpleToolsComposite extends Composite {
private final FormToolkit formToolkit = new FormToolkit(Display.getDefault());
private SimpleToolList simpleToolList;
private final SimpleToolListComposite simpleToolListComposite;
private final SimpleToolsDetailsComposite simpleToolsDetailsComposite;
public SimpleToolsComposite(Composite parent, int style) {
super(parent, style);
setLayout(new GridLayout(1, false));
ScrolledForm scrldfrmSimpleTools = this.formToolkit.createScrolledForm(this);
scrldfrmSimpleTools.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
this.formToolkit.paintBordersFor(scrldfrmSimpleTools);
{
TableWrapLayout tableWrapLayout = new TableWrapLayout();
tableWrapLayout.numColumns = 2;
scrldfrmSimpleTools.getBody().setLayout(tableWrapLayout);
}
Section sctnSimpleTools = this.formToolkit.createSection(scrldfrmSimpleTools.getBody(),
ExpandableComposite.EXPANDED | ExpandableComposite.TWISTIE | ExpandableComposite.TITLE_BAR);
TableWrapData twd_sctnSimpleTools = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1);
twd_sctnSimpleTools.align = TableWrapData.FILL;
twd_sctnSimpleTools.valign = TableWrapData.FILL;
twd_sctnSimpleTools.grabVertical = true;
sctnSimpleTools.setLayoutData(twd_sctnSimpleTools);
this.formToolkit.paintBordersFor(sctnSimpleTools);
sctnSimpleTools.setText("Simple Tools");
this.simpleToolListComposite = new SimpleToolListComposite(sctnSimpleTools, SWT.NONE) {
@Override
protected void newSimpleToolSelected(SimpleTool simpleTool) {
SimpleToolsComposite.this.simpleToolsDetailsComposite.setSimpleTool(simpleTool);
}
};
this.formToolkit.adapt(this.simpleToolListComposite);
this.formToolkit.paintBordersFor(this.simpleToolListComposite);
sctnSimpleTools.setClient(this.simpleToolListComposite);
Section sctnToolDetails = this.formToolkit.createSection(scrldfrmSimpleTools.getBody(),
ExpandableComposite.EXPANDED | ExpandableComposite.TWISTIE | ExpandableComposite.TITLE_BAR);
TableWrapData twd_sctnToolDetails = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP, 1, 1);
twd_sctnToolDetails.align = TableWrapData.FILL;
twd_sctnToolDetails.grabVertical = true;
twd_sctnToolDetails.grabHorizontal = true;
twd_sctnToolDetails.valign = TableWrapData.FILL;
sctnToolDetails.setLayoutData(twd_sctnToolDetails);
this.formToolkit.paintBordersFor(sctnToolDetails);
sctnToolDetails.setText("Tool Details");
this.simpleToolsDetailsComposite = new SimpleToolsDetailsComposite(sctnToolDetails, SWT.NONE);
this.formToolkit.adapt(this.simpleToolsDetailsComposite);
this.formToolkit.paintBordersFor(this.simpleToolsDetailsComposite);
sctnToolDetails.setClient(this.simpleToolsDetailsComposite);
}
public void setSimpleToolList(SimpleToolList newSimpleToolList) {
this.simpleToolList = newSimpleToolList;
this.simpleToolListComposite.setSimpleToolList(newSimpleToolList);
}
public SimpleToolList getSimpleToolList() {
return this.simpleToolList;
}
}