Project

General

Profile

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

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

    
12
import java.io.File;
13

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

    
20
import eu.etaxonomy.cdm.filter.TaxonNodeFilter;
21
import eu.etaxonomy.cdm.io.dwca.out.DwcaTaxExportConfigurator;
22
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
23
import eu.etaxonomy.taxeditor.store.CdmStore;
24

    
25
/**
26
 * @author n.hoffmann
27
 * @created May 2, 2011
28
 * @version 1.0
29
 */
30
public class DarwinCoreArchiveExportWizard extends
31
		AbstractExportWizard<DwcaTaxExportConfigurator> {
32

    
33
	private DwcaTaxExportConfigurator configurator;
34
	private ExportToFileDestinationWizardPage page;
35

    
36
	/*
37
	 * (non-Javadoc)
38
	 *
39
	 * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench,
40
	 * org.eclipse.jface.viewers.IStructuredSelection)
41
	 */
42
	@Override
43
	public void init(IWorkbench workbench, IStructuredSelection selection) {
44
		configurator = DwcaTaxExportConfigurator.NewInstance(null, null, null);
45
		if (selection instanceof TreeSelection && !selection.isEmpty()){
46
			TaxonNode node = (TaxonNode)selection.getFirstElement();
47
			if (node.getParent() == null){
48
				configurator.setTaxonNodeFilter(TaxonNodeFilter.NewClassificationInstance(node.getClassification().getUuid()));
49
			}else{
50
				configurator.setTaxonNodeFilter(TaxonNodeFilter.NewSubtreeInstance(node.getUuid()));
51
			}
52
			
53
		}
54
	}
55

    
56
	/*
57
	 * (non-Javadoc)
58
	 *
59
	 * @see
60
	 * eu.etaxonomy.taxeditor.io.wizard.AbstractExportWizard#getConfigurator()
61
	 */
62
	@Override
63
	public DwcaTaxExportConfigurator getConfigurator() {
64
		return configurator;
65
	}
66

    
67
	/*
68
	 * (non-Javadoc)
69
	 *
70
	 * @see org.eclipse.jface.wizard.Wizard#performFinish()
71
	 */
72
	@Override
73
	public boolean performFinish() {
74
		String urlString = page.getFolderText() + File.separator
75
				+ page.getExportFileName();
76

    
77
	
78
		CdmStore.getExportManager().runMoniteredOperation(configurator, urlString);
79
//		Job exportJob = CdmStore.getExportManager().createIOServiceJob(configurator, destination);
80
//		exportJob.setProperty(IProgressConstants.KEEP_PROPERTY, true);
81
//		exportJob.setUser(true);
82
        // schedule job
83
//		exportJob.schedule();
84

    
85
		return true;
86
	}
87

    
88
	/*
89
	 * (non-Javadoc)
90
	 *
91
	 * @see eu.etaxonomy.taxeditor.io.wizard.AbstractExportWizard#addPages()
92
	 */
93
	@Override
94
	public void addPages() {
95
		
96

    
97
		page = ExportToFileDestinationWizardPage.Dwca(configurator);
98
		addPage(page);
99
		super.addPages();
100
	}
101
}
(13-13/30)