| /******************************************************************************* |
| * 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.wizards; |
| |
| import org.eclipse.apogy.core.invocator.Variable; |
| import org.eclipse.apogy.core.invocator.ui.composites.TypesRegistryComposite; |
| import org.eclipse.jface.dialogs.IDialogPage; |
| import org.eclipse.jface.viewers.ISelection; |
| import org.eclipse.jface.wizard.WizardPage; |
| import org.eclipse.swt.SWT; |
| import org.eclipse.swt.layout.GridData; |
| import org.eclipse.swt.layout.GridLayout; |
| import org.eclipse.swt.widgets.Composite; |
| |
| public class SetVariableTypeWizardPage extends WizardPage { |
| |
| private final static String WIZARD_PAGE_ID = "org.eclipse.apogy.core.invocator.ui.wizards.SetVariableTypeWizardPage"; |
| |
| private final Variable variable; |
| |
| public SetVariableTypeWizardPage(Variable variable) { |
| super(WIZARD_PAGE_ID); |
| setTitle("Variable"); |
| setDescription("Select the type."); |
| this.variable = variable; |
| } |
| |
| /** |
| * @see IDialogPage#createControl(Composite) |
| */ |
| @Override |
| public void createControl(Composite parent) { |
| Composite container = new Composite(parent, SWT.None); |
| container.setLayout(new GridLayout(1, false)); |
| |
| setControl(container); |
| |
| TypesRegistryComposite typesRegistryComposite = new TypesRegistryComposite(container, SWT.NONE) { |
| @Override |
| protected void newSelection(ISelection selection) { |
| SetVariableTypeWizardPage.this.variable.setVariableType(getSelectedType()); |
| validate(); |
| } |
| }; |
| typesRegistryComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); |
| |
| validate(); |
| } |
| |
| /** |
| * This method is invoked to validate the content. |
| */ |
| protected void validate() { |
| String errorMessage = ""; |
| |
| if (this.variable.getVariableType() == null) { |
| errorMessage = "You must select the variable type."; |
| } |
| setPageComplete(errorMessage.isEmpty()); |
| } |
| } |