| /******************************************************************************* |
| * 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.ui.dialogs; |
| |
| import java.util.ArrayList; |
| import java.util.Date; |
| import java.util.List; |
| |
| import org.eclipse.apogy.common.math.ApogyCommonMathFacade; |
| import org.eclipse.apogy.common.math.Matrix4x4; |
| import org.eclipse.apogy.common.topology.GroupNode; |
| import org.eclipse.apogy.common.topology.Node; |
| import org.eclipse.apogy.core.ApogyCoreFactory; |
| import org.eclipse.apogy.core.UserDefinedResult; |
| import org.eclipse.apogy.core.invocator.Context; |
| import org.eclipse.jface.dialogs.Dialog; |
| 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.Label; |
| import org.eclipse.swt.widgets.Shell; |
| import org.eclipse.swt.widgets.Text; |
| |
| @Deprecated |
| public class CreateUserDefinedResultDialog extends Dialog { |
| protected Context context; |
| |
| private final Matrix4x4 resultPose = ApogyCommonMathFacade.INSTANCE.createIdentityMatrix4x4(); |
| |
| private UserDefinedResult userDefinedResult = null; |
| |
| private Text nameText; |
| private Text descriptionText; |
| // private Combo nodesCombo; |
| |
| // private HashMap<Integer, Node> indexToNodeMap = new HashMap<Integer, Node>(); |
| |
| public CreateUserDefinedResultDialog(Shell parentShell) { |
| super(parentShell); |
| } |
| |
| public CreateUserDefinedResultDialog(Shell parentShell, Context context) { |
| this(parentShell); |
| this.context = context; |
| } |
| |
| @Override |
| protected void configureShell(Shell newShell) { |
| super.configureShell(newShell); |
| newShell.setText("Create User Defined Result"); |
| } |
| |
| @Override |
| protected Control createDialogArea(Composite parent) { |
| Composite area = (Composite) super.createDialogArea(parent); |
| |
| Composite container = new Composite(area, SWT.NONE); |
| container.setLayoutData(new GridData(GridData.FILL_BOTH)); |
| GridLayout layout = new GridLayout(2, false); |
| container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); |
| container.setLayout(layout); |
| |
| Label nameLabel = new Label(container, SWT.NONE); |
| nameLabel.setText("Name:"); |
| this.nameText = new Text(container, SWT.BORDER); |
| GridData nameTextGridData = new GridData(SWT.FILL, SWT.CENTER, true, false); |
| this.nameText.setLayoutData(nameTextGridData); |
| |
| Label descriptionLabel = new Label(container, SWT.NONE); |
| descriptionLabel.setText("Description:"); |
| this.descriptionText = new Text(container, SWT.BORDER | SWT.MULTI); |
| GridData descriptionTextGridData = new GridData(SWT.FILL, SWT.FILL, true, false); |
| descriptionTextGridData.heightHint = 200; |
| descriptionTextGridData.minimumHeight = 200; |
| descriptionTextGridData.widthHint = 400; |
| descriptionTextGridData.minimumWidth = 400; |
| this.descriptionText.setLayoutData(descriptionTextGridData); |
| |
| Label nodeLabel = new Label(container, SWT.NONE); |
| nodeLabel.setText("Node defining position:"); |
| |
| return area; |
| } |
| |
| public UserDefinedResult getUserDefinedResult() { |
| return this.userDefinedResult; |
| } |
| |
| public String getResultName() { |
| return this.nameText.getText(); |
| } |
| |
| public String getResultDescription() { |
| return this.descriptionText.getText(); |
| } |
| |
| public Matrix4x4 getResultPose() { |
| return this.resultPose; |
| } |
| |
| public Context getContext() { |
| return this.context; |
| } |
| |
| @Override |
| protected void okPressed() { |
| this.userDefinedResult = ApogyCoreFactory.eINSTANCE.createUserDefinedResult(); |
| this.userDefinedResult.setName(getResultName()); |
| this.userDefinedResult.setDescription(getResultDescription()); |
| this.userDefinedResult.setPose(getResultPose()); |
| this.userDefinedResult.setContext(getContext()); |
| |
| this.userDefinedResult.setTime(new Date()); |
| |
| super.okPressed(); |
| } |
| |
| protected List<Node> getAllNodes(Node root) { |
| List<Node> nodes = new ArrayList<Node>(); |
| |
| nodes.add(root); |
| |
| if (root instanceof GroupNode) { |
| GroupNode groupNode = (GroupNode) root; |
| |
| for (Node node : groupNode.getChildren()) { |
| nodes.addAll(getAllNodes(node)); |
| } |
| } |
| |
| return nodes; |
| } |
| } |