Project

General

Profile

Download (1.94 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2017 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
package eu.etaxonomy.taxeditor.featuretree.e4;
10

    
11
import java.io.File;
12

    
13
import org.eclipse.core.runtime.jobs.Job;
14
import org.eclipse.swt.events.SelectionAdapter;
15
import org.eclipse.swt.events.SelectionEvent;
16
import org.eclipse.swt.widgets.DirectoryDialog;
17
import org.eclipse.swt.widgets.Shell;
18
import org.eclipse.ui.progress.IProgressConstants;
19

    
20
import eu.etaxonomy.cdm.io.descriptive.owl.out.OwlExportConfigurator;
21
import eu.etaxonomy.taxeditor.model.MessagingUtils;
22
import eu.etaxonomy.taxeditor.store.CdmStore;
23

    
24
/**
25
 * @author pplitzner
26
 * @since Jul 4, 2017
27
 *
28
 */
29
public class FeatureTreeExportListener extends SelectionAdapter{
30

    
31
    private Shell shell;
32
    private FeatureTreeEditorComposite composite;
33

    
34
    public FeatureTreeExportListener(Shell shell, FeatureTreeEditorComposite composite) {
35
        super();
36
        this.shell = shell;
37
        this.composite = composite;
38
    }
39

    
40
    @Override
41
    public void widgetSelected(SelectionEvent e) {
42
        if(composite.getFeatureTree()==null){
43
            MessagingUtils.informationDialog("Export not possible", "There is no feature tree selected.");
44
            return;
45
        }
46
        DirectoryDialog dialog = new DirectoryDialog(e.widget.getDisplay().getActiveShell());
47
        String directoryString = dialog.open();
48
        if(directoryString!=null){
49
            // create job
50
            Job job = CdmStore.getExportManager().createIOServiceJob(OwlExportConfigurator.NewInstance(null, null, composite.getFeatureTree()), new File(directoryString+"/owl.owl"));
51
            // configure the job
52
            job.setProperty(IProgressConstants.KEEP_PROPERTY, true);
53
            job.setUser(true);
54
            // schedule job
55
            job.schedule();
56
        }
57
    }
58
}
(5-5/5)