Project

General

Profile

« Previous | Next » 

Revision cf349935

Added by Patrick Plitzner over 5 years ago

Ask for saving before executing operations

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/featuretree/e4/handler/FeatureTreeExportHandler.java
12 12

  
13 13
import javax.inject.Named;
14 14

  
15
import org.eclipse.core.runtime.NullProgressMonitor;
15 16
import org.eclipse.core.runtime.jobs.Job;
16 17
import org.eclipse.e4.core.di.annotations.CanExecute;
17 18
import org.eclipse.e4.core.di.annotations.Execute;
18 19
import org.eclipse.e4.core.di.annotations.Optional;
20
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
19 21
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
20 22
import org.eclipse.e4.ui.services.IServiceConstants;
21 23
import org.eclipse.jface.viewers.IStructuredSelection;
......
25 27

  
26 28
import eu.etaxonomy.cdm.io.descriptive.owl.out.OwlExportConfigurator;
27 29
import eu.etaxonomy.cdm.model.description.FeatureTree;
30
import eu.etaxonomy.taxeditor.featuretree.e4.FeatureNodeDropAdapter;
31
import eu.etaxonomy.taxeditor.featuretree.e4.FeatureTreeEditor;
32
import eu.etaxonomy.taxeditor.model.MessagingUtils;
28 33
import eu.etaxonomy.taxeditor.store.CdmStore;
29 34

  
30 35
/**
......
36 41

  
37 42
    @Execute
38 43
    public void execute(@Named(IServiceConstants.ACTIVE_SHELL) Shell shell,
39
            @Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection){
44
            @Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection,
45
            @Named(IServiceConstants.ACTIVE_PART)MPart thisPart){
46
        FeatureTreeEditor editor = (FeatureTreeEditor) thisPart.getObject();
47

  
48
        if (editor.isDirty()) {
49
            if (MessagingUtils.confirmDialog(FeatureNodeDropAdapter.SAVE_CHANGES_TITLE,
50
                    FeatureNodeDropAdapter.SAVE_CHANGES_MESSAGE)){
51
                editor.save(new NullProgressMonitor());
52
            }
53
            else{
54
                return;
55
            }
56
        }
57

  
40 58
        FeatureTree selectedFeatureTree = (FeatureTree) selection.getFirstElement();
41 59
        DirectoryDialog dialog = new DirectoryDialog(shell);
42 60
        String directoryString = dialog.open();

Also available in: Unified diff