| /******************************************************************************* |
| * 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.invocator.ui.composites; |
| |
| import org.eclipse.apogy.common.emf.ui.emfforms.ApogyCommonEMFUiEMFFormsFacade; |
| import org.eclipse.apogy.core.invocator.AbstractResult; |
| import org.eclipse.apogy.core.invocator.OperationCallResult; |
| 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.Control; |
| 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 AbstractResultDetailsComposite extends Composite { |
| private AbstractResult result; |
| |
| private final ScrolledForm scrldResults; |
| |
| private final Section sctnProductDetails; |
| private final Composite compositeAbstractResultDetails; |
| |
| private final Section sctnOpsCallDetails; |
| private final Composite compositeOpsCallDetails; |
| |
| private final FormToolkit formToolkit = new FormToolkit(Display.getDefault()); |
| |
| public AbstractResultDetailsComposite(Composite parent, int style) { |
| super(parent, style); |
| setLayout(new GridLayout(1, false)); |
| |
| this.scrldResults = this.formToolkit.createScrolledForm(this); |
| this.scrldResults.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); |
| this.scrldResults.setBounds(0, 0, 186, 165); |
| this.formToolkit.paintBordersFor(this.scrldResults); |
| { |
| TableWrapLayout tableWrapLayout = new TableWrapLayout(); |
| tableWrapLayout.makeColumnsEqualWidth = true; |
| tableWrapLayout.numColumns = 1; |
| this.scrldResults.getBody().setLayout(tableWrapLayout); |
| } |
| |
| // Abstract Result Details |
| this.sctnProductDetails = this.formToolkit.createSection(this.scrldResults.getBody(), |
| ExpandableComposite.TWISTIE | ExpandableComposite.TITLE_BAR); |
| TableWrapData twd_sctnNewSection = new TableWrapData(TableWrapData.FILL, TableWrapData.FILL, 1, 1); |
| twd_sctnNewSection.grabHorizontal = true; |
| twd_sctnNewSection.grabVertical = true; |
| twd_sctnNewSection.valign = TableWrapData.FILL; |
| this.sctnProductDetails.setLayoutData(twd_sctnNewSection); |
| // sctnProductDetails.setBounds(0, 0, 112, 27); |
| this.formToolkit.paintBordersFor(this.sctnProductDetails); |
| this.sctnProductDetails.setText("Product Details"); |
| |
| this.compositeAbstractResultDetails = new Composite(this.sctnProductDetails, SWT.NONE); |
| this.compositeAbstractResultDetails.setLayout(new GridLayout(1, false)); |
| |
| this.formToolkit.adapt(this.compositeAbstractResultDetails); |
| this.formToolkit.paintBordersFor(this.compositeAbstractResultDetails); |
| this.sctnProductDetails.setClient(this.compositeAbstractResultDetails); |
| this.sctnProductDetails.setExpanded(true); |
| |
| // OpsCall Result Details. |
| this.sctnOpsCallDetails = this.formToolkit.createSection(this.scrldResults.getBody(), |
| ExpandableComposite.TWISTIE | ExpandableComposite.TITLE_BAR); |
| TableWrapData twd_sctnOpsCallDetails = new TableWrapData(TableWrapData.FILL, TableWrapData.FILL, 1, 1); |
| twd_sctnOpsCallDetails.grabHorizontal = true; |
| twd_sctnOpsCallDetails.grabVertical = true; |
| twd_sctnOpsCallDetails.valign = TableWrapData.FILL; |
| this.sctnOpsCallDetails.setLayoutData(twd_sctnOpsCallDetails); |
| this.formToolkit.paintBordersFor(this.sctnOpsCallDetails); |
| this.sctnOpsCallDetails.setText("Operation Call Details"); |
| |
| this.compositeOpsCallDetails = new Composite(this.sctnOpsCallDetails, SWT.NONE); |
| this.compositeOpsCallDetails.setLayout(new GridLayout(1, false)); |
| |
| this.formToolkit.adapt(this.compositeOpsCallDetails); |
| this.formToolkit.paintBordersFor(this.compositeOpsCallDetails); |
| this.sctnOpsCallDetails.setClient(this.compositeOpsCallDetails); |
| this.sctnOpsCallDetails.setExpanded(true); |
| |
| this.scrldResults.layout(); |
| } |
| |
| public AbstractResult getResult() { |
| return this.result; |
| } |
| |
| public void setResult(AbstractResult result) { |
| this.result = result; |
| |
| if (!isDisposed()) { |
| // Dispose of the compositeAbstractResultDetails children. |
| for (Control control : this.compositeAbstractResultDetails.getChildren()) { |
| control.dispose(); |
| } |
| |
| // Dispose of the compositeOpsCallDetails children. |
| for (Control control : this.compositeOpsCallDetails.getChildren()) { |
| control.dispose(); |
| } |
| |
| if (result != null) { |
| ApogyCommonEMFUiEMFFormsFacade.INSTANCE.createEMFForms(this.compositeAbstractResultDetails, result); |
| |
| if (result instanceof OperationCallResult) { |
| OperationCallResult operationCallResult = (OperationCallResult) result; |
| if (operationCallResult.getOperationCall() != null) { |
| ApogyCommonEMFUiEMFFormsFacade.INSTANCE.createEMFForms(this.compositeOpsCallDetails, |
| operationCallResult.getOperationCall()); |
| } else { |
| ApogyCommonEMFUiEMFFormsFacade.INSTANCE.createEMFForms(this.compositeOpsCallDetails, null, |
| "No Operation Call to display"); |
| } |
| } |
| } else { |
| ApogyCommonEMFUiEMFFormsFacade.INSTANCE.createEMFForms(this.compositeAbstractResultDetails, null, |
| "No data to display"); |
| ApogyCommonEMFUiEMFFormsFacade.INSTANCE.createEMFForms(this.compositeOpsCallDetails, null, |
| "No Operation Call to display"); |
| } |
| |
| if (!this.compositeAbstractResultDetails.isDisposed()) |
| this.compositeAbstractResultDetails.layout(); |
| if (!this.compositeOpsCallDetails.isDisposed()) |
| this.compositeOpsCallDetails.layout(); |
| |
| if (!this.scrldResults.isDisposed()) |
| this.scrldResults.layout(); |
| } |
| } |
| } |