| /******************************************************************************* |
| * 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.ImageFilter; |
| import org.eclipse.apogy.addons.sensors.imaging.camera.composites.ImageFilterComposite; |
| 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.GridLayout; |
| import org.eclipse.swt.widgets.Composite; |
| |
| public class ImageFilterPreviewWizardPage extends WizardPage { |
| private final static String WIZARD_PAGE_ID = "org.eclipse.apogy.addons.sensors.imaging.camera.wizards.GainFilterWizardPage"; |
| |
| private final ImageFilter imageFilter; |
| private ImageFilterComposite imageFilterComposite; |
| |
| private DataBindingContext m_bindingContext; |
| |
| public ImageFilterPreviewWizardPage(ImageFilter imageFilter) { |
| super(WIZARD_PAGE_ID); |
| this.imageFilter = imageFilter; |
| |
| setTitle("Image Filter."); |
| setDescription("Filter Effect Preview."); |
| |
| validate(); |
| } |
| |
| @Override |
| public void createControl(Composite parent) { |
| Composite top = new Composite(parent, SWT.None); |
| top.setLayout(new GridLayout(1, false)); |
| |
| this.imageFilterComposite = new ImageFilterComposite(top, SWT.NONE); |
| this.imageFilterComposite.setImageFilter(this.imageFilter); |
| |
| setControl(top); |
| |
| // Bindings |
| this.m_bindingContext = initDataBindingsCustom(); |
| |
| validate(); |
| |
| // Dispose |
| top.addDisposeListener(new DisposeListener() { |
| @Override |
| public void widgetDisposed(DisposeEvent e) { |
| if (ImageFilterPreviewWizardPage.this.m_bindingContext != null) |
| ImageFilterPreviewWizardPage.this.m_bindingContext.dispose(); |
| } |
| }); |
| } |
| |
| protected void validate() { |
| setErrorMessage(null); |
| setPageComplete(getErrorMessage() == null); |
| } |
| |
| private DataBindingContext initDataBindingsCustom() { |
| DataBindingContext bindingContext = new DataBindingContext(); |
| |
| return bindingContext; |
| } |
| } |