| /******************************************************************************* |
| * 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: |
| <<<<<<< HEAD |
| * Pierre Allard - initial API and implementation |
| * Regent L'Archeveque |
| * |
| ======= |
| * Pierre Allard, |
| * Regent L'Archeveque, |
| * Sebastien Gemme - initial API and implementation |
| * |
| >>>>>>> refs/heads/eclipse_pa |
| * SPDX-License-Identifier: EPL-1.0 |
| * |
| *******************************************************************************/ |
| package org.eclipse.apogy.common.converters.ui.wizards; |
| |
| import java.util.List; |
| |
| import org.eclipse.apogy.common.converters.IFileExporter; |
| import org.eclipse.jface.dialogs.MessageDialog; |
| import org.eclipse.jface.wizard.Wizard; |
| import org.slf4j.Logger; |
| import org.slf4j.LoggerFactory; |
| |
| public class ExportToFileWizard extends Wizard { |
| private static final Logger Logger = LoggerFactory.getLogger(ExportToFileWizard.class); |
| |
| private final IFileExporter iFileExporter; |
| private final Object input; |
| |
| private ExportFileSettingsWizardPage pageOne; |
| private ExportFileDestinationWizardPage pageTwo; |
| |
| public ExportToFileWizard(IFileExporter iFileExporter, Object input) { |
| super(); |
| setWindowTitle("Export to File"); |
| this.iFileExporter = iFileExporter; |
| this.input = input; |
| } |
| |
| @Override |
| public boolean canFinish() { |
| return this.pageOne.isPageComplete() && this.pageTwo.isPageComplete(); |
| } |
| |
| @Override |
| public boolean performFinish() { |
| try { |
| this.iFileExporter.exportToFile(this.input, this.pageTwo.getFilePath(), |
| this.pageOne.getRequestedFileExtension()); |
| return true; |
| } catch (Throwable t) { |
| MessageDialog.openError(getShell(), "Error", "Error occured during export : " + t.getMessage()); |
| Logger.error("Error occured during export.", t); |
| return false; |
| } |
| } |
| |
| public List<String> getRequestedExtensions() { |
| return this.pageOne.getRequestedFileExtension(); |
| } |
| |
| @Override |
| public void addPages() { |
| this.pageOne = new ExportFileSettingsWizardPage("Export Settings", this.iFileExporter, this); |
| addPage(this.pageOne); |
| |
| this.pageTwo = new ExportFileDestinationWizardPage("Export Destination", this.iFileExporter, this); |
| addPage(this.pageTwo); |
| } |
| } |