| //------------------------------------------------------------------------------ |
| // Copyright (c) 2005, 2006 IBM Corporation and others. |
| // 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: |
| // IBM Corporation - initial implementation |
| //------------------------------------------------------------------------------ |
| package org.eclipse.epf.export.xml.wizards; |
| |
| import java.lang.reflect.InvocationTargetException; |
| |
| import org.eclipse.core.runtime.IProgressMonitor; |
| import org.eclipse.epf.common.serviceability.MsgBox; |
| import org.eclipse.epf.export.xml.XmlExportPlugin; |
| import org.eclipse.epf.export.xml.XmlExportResources; |
| import org.eclipse.epf.export.xml.services.XmlExportData; |
| import org.eclipse.epf.export.xml.services.XmlExportService; |
| import org.eclipse.jface.operation.IRunnableWithProgress; |
| import org.eclipse.jface.viewers.IStructuredSelection; |
| import org.eclipse.jface.wizard.Wizard; |
| import org.eclipse.osgi.util.NLS; |
| import org.eclipse.swt.SWT; |
| import org.eclipse.ui.IImportWizard; |
| import org.eclipse.ui.IWorkbench; |
| |
| |
| /** |
| * wizard class for exporting method library to xml |
| * |
| * @author Jinhua Xi |
| * @since 1.0 |
| * |
| */ |
| public class ExportXmlWizard extends Wizard implements IImportWizard { |
| |
| public XmlExportData data = new XmlExportData(); |
| |
| |
| private ExportXmlModelSelectionPage selModePage = null; |
| public SelectPluginPage selPluginPage = null; |
| //public ExportXmlDestinationPage filePage = null; |
| public SelectXmlFilePage filePage = null; |
| |
| public ExportXmlWizard() |
| { |
| super(); |
| setWindowTitle(XmlExportResources.ExportXmlWizard_title); |
| setNeedsProgressMonitor(true); |
| } |
| public boolean performFinish() { |
| |
| IRunnableWithProgress op = new IRunnableWithProgress() { |
| public void run(IProgressMonitor monitor) throws InvocationTargetException { |
| |
| XmlExportService service = null; |
| try |
| { |
| monitor.beginTask( |
| "Exporting xml", //$NON-NLS-1$ |
| IProgressMonitor.UNKNOWN); |
| |
| data.xmlFile = filePage.getPath(); |
| service = new XmlExportService(data); |
| service.doExport(monitor); |
| |
| } |
| catch (Exception e) { |
| throw new InvocationTargetException(e); |
| } |
| finally { |
| monitor.done(); |
| if ( service != null ) { |
| service.dispose(); |
| } |
| } |
| } |
| }; |
| try { |
| getContainer().run(true, false, op); |
| } |
| catch (InterruptedException e) { |
| return false; |
| } |
| catch (InvocationTargetException e) { |
| Throwable realException = e.getTargetException(); |
| XmlExportPlugin.getDefault().getMsgDialog().displayError( |
| XmlExportResources.ExportXmlWizard_title, |
| NLS.bind(XmlExportResources.ExportXmlWizard_Error, realException.getMessage()), |
| realException); |
| return false; |
| } |
| |
| String msg = XmlExportResources.ExportXmlWizard_reviewLog; |
| MsgBox.prompt(msg, SWT.OK); |
| |
| return true; |
| } |
| |
| public void init(IWorkbench workbench, IStructuredSelection selection) { |
| // TODO Auto-generated method stub |
| |
| } |
| |
| /** |
| * @see org.eclipse.jface.wizard.Wizard#addPages() |
| */ |
| public void addPages() { |
| selModePage = new ExportXmlModelSelectionPage(); |
| selPluginPage = new SelectPluginPage(); |
| //filePage = new ExportXmlDestinationPage(data); |
| filePage = new SelectXmlFilePage(); |
| |
| addPage(selModePage); |
| addPage(selPluginPage); |
| addPage(filePage); |
| |
| } |
| |
| public boolean canFinish() { |
| return filePage.isPageComplete(); |
| } |
| |
| } |