| /******************************************************************************* |
| * 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.sensors.imaging.camera.wizards; |
| |
| import org.eclipse.apogy.addons.sensors.imaging.camera.FOVOverlay; |
| import org.eclipse.apogy.addons.sensors.imaging.camera.composites.FOVOverlayComposite; |
| import org.eclipse.core.databinding.DataBindingContext; |
| import org.eclipse.jface.wizard.WizardPage; |
| import org.eclipse.swt.SWT; |
| import org.eclipse.swt.events.DisposeEvent; |
| import org.eclipse.swt.events.DisposeListener; |
| import org.eclipse.swt.layout.GridData; |
| import org.eclipse.swt.layout.GridLayout; |
| import org.eclipse.swt.widgets.Composite; |
| |
| public class FOVOverlayWizardPage extends WizardPage { |
| private final static String WIZARD_PAGE_ID = "org.eclipse.apogy.addons.sensors.imaging.camera.wizards.FOVOverlayWizardPage"; |
| |
| private final FOVOverlay fovOverlay; |
| |
| private FOVOverlayComposite fovOverlayComposite; |
| private DataBindingContext m_bindingContext; |
| |
| public FOVOverlayWizardPage(FOVOverlay fovOverlay) { |
| super(WIZARD_PAGE_ID); |
| this.fovOverlay = fovOverlay; |
| |
| setTitle("Filed Of View (FOV) Overlay."); |
| setDescription("Select the FOV settings."); |
| |
| validate(); |
| } |
| |
| @Override |
| public void createControl(Composite parent) { |
| Composite top = new Composite(parent, SWT.None); |
| top.setLayout(new GridLayout(1, false)); |
| |
| this.fovOverlayComposite = new FOVOverlayComposite(top, SWT.BORDER) { |
| @Override |
| protected void lineWidthSelected(int lineWidth) { |
| validate(); |
| } |
| |
| @Override |
| protected void angleIntervalSelected(int angleInterval) { |
| validate(); |
| } |
| |
| }; |
| this.fovOverlayComposite.setFovOverlay(this.fovOverlay); |
| this.fovOverlayComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); |
| |
| setControl(top); |
| |
| // Bindings |
| this.m_bindingContext = initDataBindingsCustom(); |
| |
| // Dispose |
| top.addDisposeListener(new DisposeListener() { |
| @Override |
| public void widgetDisposed(DisposeEvent e) { |
| if (FOVOverlayWizardPage.this.m_bindingContext != null) |
| FOVOverlayWizardPage.this.m_bindingContext.dispose(); |
| } |
| }); |
| } |
| |
| protected void validate() { |
| setErrorMessage(null); |
| |
| if (this.fovOverlay.getFontName() == null) { |
| setErrorMessage("No font selected !"); |
| } |
| |
| if (this.fovOverlay.getAngleInterval() <= 0) { |
| setErrorMessage("Invalid Angle Interval specified ! Must be greater than zero."); |
| } |
| |
| if (this.fovOverlay.getLineWidth() <= 0) { |
| setErrorMessage("Invalid Line Width specified ! Must be greater than zero."); |
| } |
| |
| setPageComplete(getErrorMessage() == null); |
| } |
| |
| private DataBindingContext initDataBindingsCustom() { |
| DataBindingContext bindingContext = new DataBindingContext(); |
| |
| return bindingContext; |
| } |
| } |