Project

General

Profile

Download (2.48 KB) Statistics
| Branch: | Tag: | Revision:
1
// $Id$
2
/**
3
* Copyright (C) 2007 EDIT
4
* European Distributed Institute of Taxonomy
5
* http://www.e-taxonomy.eu
6
*
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10

    
11
package eu.etaxonomy.taxeditor.io.wizard;
12

    
13
import java.io.File;
14
import java.net.URI;
15

    
16
import org.eclipse.core.runtime.jobs.Job;
17
import org.eclipse.jface.viewers.IStructuredSelection;
18
import org.eclipse.ui.IWorkbench;
19
import org.eclipse.ui.progress.IProgressConstants;
20

    
21
import eu.etaxonomy.cdm.io.jaxb.JaxbExportConfigurator;
22
import eu.etaxonomy.taxeditor.store.CdmStore;
23

    
24
/**
25
 * <p>JaxbExportWizard class.</p>
26
 *
27
 * @author n.hoffmann
28
 * @created 15.06.2009
29
 * @version 1.0
30
 */
31
public class JaxbExportWizard extends AbstractExportWizard<JaxbExportConfigurator> {
32

    
33
	private ExportToFileDestinationWizardPage page;
34

    
35
	private JaxbExportConfigurator configurator;
36

    
37
	/* (non-Javadoc)
38
	 * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
39
	 */
40
	/** {@inheritDoc} */
41
	@Override
42
    public void init(IWorkbench workbench, IStructuredSelection selection) {
43
		this.setWindowTitle("JAXB Export");
44
		this.configurator = CdmStore.getExportManager().JaxbConfigurator();
45
	}
46

    
47
	/* (non-Javadoc)
48
	 * @see org.eclipse.jface.wizard.Wizard#performFinish()
49
	 */
50
	/** {@inheritDoc} */
51
	@Override
52
	public boolean performFinish() {
53
		boolean performFinish = false;
54

    
55
		File exportFile = new File(page.getFolderText() + File.separator + page.getExportFileName());
56
		URI urlString = exportFile.toURI();
57
		configurator.setDestination(urlString);
58
		if(CdmStore.getCurrentSessionManager().isRemoting()) {
59
		    // create job
60
		    Job job = CdmStore.getExportManager().createIOServiceJob(configurator, exportFile);
61
		    // configure the job
62
		    job.setProperty(IProgressConstants.KEEP_PROPERTY, true);
63
		    job.setUser(true);
64
		    // schedule job
65
		    job.schedule();
66
		} else {
67
	        CdmStore.getExportManager().run(configurator);
68
		}
69
		performFinish = true;
70
		return performFinish;
71
	}
72

    
73
	/* (non-Javadoc)
74
	 * @see org.eclipse.jface.wizard.Wizard#addPages()
75
	 */
76
	/** {@inheritDoc} */
77
	@Override
78
	public void addPages() {
79
		super.addPages();
80

    
81
		page = ExportToFileDestinationWizardPage.Jaxb();
82
		addPage(page);
83
	}
84

    
85
	/* (non-Javadoc)
86
	 * @see eu.etaxonomy.taxeditor.io.AbstractExportWizard#getConfigurator()
87
	 */
88
	/** {@inheritDoc} */
89
	@Override
90
	public JaxbExportConfigurator getConfigurator() {
91
		return configurator;
92
	}
93

    
94

    
95
}
(16-16/24)