2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.taxeditor
.io
.e4
.out
.wfo
;
13 import java
.util
.ArrayList
;
14 import java
.util
.Iterator
;
15 import java
.util
.List
;
17 import javax
.inject
.Inject
;
18 import javax
.inject
.Named
;
20 import org
.apache
.commons
.lang
.StringUtils
;
21 import org
.eclipse
.e4
.core
.contexts
.ContextInjectionFactory
;
22 import org
.eclipse
.e4
.core
.contexts
.IEclipseContext
;
23 import org
.eclipse
.e4
.core
.di
.annotations
.Optional
;
24 import org
.eclipse
.e4
.ui
.services
.IServiceConstants
;
25 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
26 import org
.eclipse
.jface
.viewers
.TreeSelection
;
28 import eu
.etaxonomy
.cdm
.filter
.TaxonNodeFilter
;
29 import eu
.etaxonomy
.cdm
.io
.wfo
.out
.WfoExportConfigurator
;
30 import eu
.etaxonomy
.cdm
.persistence
.dto
.TaxonNodeDto
;
31 import eu
.etaxonomy
.taxeditor
.io
.e4
.in
.GenericConfiguratorWizardPageE4
;
32 import eu
.etaxonomy
.taxeditor
.io
.e4
.out
.AbstractExportWizard
;
33 import eu
.etaxonomy
.taxeditor
.io
.wizard
.ExportToFileDestinationWizardPage
;
34 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
40 public class WFOExportWizard
extends
41 AbstractExportWizard
<WfoExportConfigurator
> {
43 private WfoExportConfigurator configurator
;
44 private ExportToFileDestinationWizardPage page
;
47 public WFOExportWizard(IEclipseContext context
,
48 @Optional@Named(IServiceConstants
.ACTIVE_SELECTION
)IStructuredSelection selection
) {
49 super(context
, selection
);
54 configurator
= WfoExportConfigurator
.NewInstance();
55 if (selection
instanceof TreeSelection
&& !selection
.isEmpty()){
56 Iterator
<?
> it
= selection
.iterator();
59 Object obj
= it
.next();
60 if (obj
instanceof TaxonNodeDto
){
61 TaxonNodeDto node
= (TaxonNodeDto
) obj
;
62 if (node
.getParentUUID() == null){
63 //configurator = null;
65 if (configurator
.getTaxonNodeFilter() == null){
66 configurator
.setTaxonNodeFilter(TaxonNodeFilter
.NewSubtreeInstance(node
.getUuid()));
68 configurator
.getTaxonNodeFilter().orSubtree(node
.getUuid());
78 public WfoExportConfigurator
getConfigurator() {
83 public boolean performFinish() {
84 String urlString
= page
.getFolderText() + File
.separator
85 + page
.getExportFileName();
88 if (StringUtils
.isNotBlank(page
.getFamilyString())) {
89 configurator
.setFamilyStr(page
.getFamilyString());
91 CdmStore
.getExportManager().runMoniteredOperation(configurator
, urlString
);
97 public void addPages() {
98 if (configurator
== null) {
99 //don't call the export on classifications
100 this.setWindowTitle("Please select a subtree for WFO export, not a classification");
102 page
= ExportToFileDestinationWizardPage
.WFO(configurator
);
104 pageConfiguration
= ContextInjectionFactory
.make(GenericConfiguratorWizardPageE4
.class, context
);
105 List
<String
> ignoreMethods
= new ArrayList
<>();
106 ignoreMethods
.add("setDoFactualData");
107 pageConfiguration
.initExport(getConfigurator(), ignoreMethods
);
108 this.addPage(pageConfiguration
);
111 public boolean canFinish() {
112 boolean canFinish
= super.canFinish();
113 if (configurator
.getTaxonNodeFilter().getSubtreeFilter().isEmpty()) {