Project

General

Profile

Download (2.38 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.e4.out.dwca;
11

    
12
import java.io.File;
13

    
14
import javax.inject.Inject;
15
import javax.inject.Named;
16

    
17
import org.eclipse.e4.core.contexts.IEclipseContext;
18
import org.eclipse.e4.core.di.annotations.Optional;
19
import org.eclipse.e4.ui.services.IServiceConstants;
20
import org.eclipse.jface.viewers.IStructuredSelection;
21
import org.eclipse.jface.viewers.TreeSelection;
22

    
23
import eu.etaxonomy.cdm.filter.TaxonNodeFilter;
24
import eu.etaxonomy.cdm.io.dwca.out.DwcaTaxExportConfigurator;
25
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
26
import eu.etaxonomy.taxeditor.io.e4.out.AbstractExportWizardE4;
27
import eu.etaxonomy.taxeditor.io.wizard.ExportToFileDestinationWizardPage;
28
import eu.etaxonomy.taxeditor.store.CdmStore;
29

    
30
/**
31
 *
32
 * @author pplitzner
33
 * @since Oct 6, 2017
34
 *
35
 */
36
public class DarwinCoreArchiveExportWizardE4 extends
37
		AbstractExportWizardE4<DwcaTaxExportConfigurator> {
38

    
39
    private DwcaTaxExportConfigurator configurator;
40
	private ExportToFileDestinationWizardPage page;
41

    
42
    @Inject
43
	public DarwinCoreArchiveExportWizardE4(IEclipseContext context,
44
	        @Optional@Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection) {
45
	    super(context, selection);
46
	}
47

    
48
	@Override
49
	public void init() {
50
		configurator = DwcaTaxExportConfigurator.NewInstance(null, null, null);
51
		if (selection instanceof TreeSelection && !selection.isEmpty()){
52
			TaxonNode node = (TaxonNode)selection.getFirstElement();
53
			if (node.getParent() == null){
54
				configurator.setTaxonNodeFilter(TaxonNodeFilter.NewClassificationInstance(node.getClassification().getUuid()));
55
			}else{
56
				configurator.setTaxonNodeFilter(TaxonNodeFilter.NewSubtreeInstance(node.getUuid()));
57
			}
58

    
59
		}
60
	}
61

    
62
	@Override
63
	public DwcaTaxExportConfigurator getConfigurator() {
64
		return configurator;
65
	}
66

    
67
	@Override
68
	public boolean performFinish() {
69
		String urlString = page.getFolderText() + File.separator
70
				+ page.getExportFileName();
71

    
72

    
73
		CdmStore.getExportManager().runMoniteredOperation(configurator, urlString);
74
		return true;
75
	}
76

    
77
	@Override
78
	public void addPages() {
79
		page = ExportToFileDestinationWizardPage.Dwca(configurator);
80
		addPage(page);
81
		super.addPages();
82
	}
83
}
(1-1/2)