Project

General

Profile

« Previous | Next » 

Revision e2ab596e

Added by Katja Luther over 2 years ago

ref #9882: remember operations and execute while saving

View differences:

eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/BulkEditor.java
10 10

  
11 11
import java.io.FileOutputStream;
12 12
import java.io.IOException;
13
import java.util.HashSet;
13 14
import java.util.List;
15
import java.util.Set;
14 16

  
15 17
import javax.annotation.PostConstruct;
16 18
import javax.annotation.PreDestroy;
17 19
import javax.inject.Inject;
18 20

  
21
import org.eclipse.core.commands.ExecutionException;
22
import org.eclipse.core.commands.operations.IOperationHistory;
23
import org.eclipse.core.runtime.IAdaptable;
19 24
import org.eclipse.core.runtime.IProgressMonitor;
25
import org.eclipse.core.runtime.IStatus;
26
import org.eclipse.core.runtime.NullProgressMonitor;
27
import org.eclipse.core.runtime.Status;
20 28
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
21 29
import org.eclipse.e4.core.contexts.IEclipseContext;
22 30
import org.eclipse.e4.core.di.annotations.Optional;
......
30 38
import org.eclipse.jface.viewers.StructuredSelection;
31 39
import org.eclipse.swt.SWT;
32 40
import org.eclipse.swt.widgets.Composite;
41
import org.eclipse.ui.ide.undo.WorkspaceUndoUtil;
33 42

  
34 43
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
35 44
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
......
59 68
import eu.etaxonomy.taxeditor.editor.IBulkEditor;
60 69
import eu.etaxonomy.taxeditor.editor.ITaxonEditor;
61 70
import eu.etaxonomy.taxeditor.event.WorkbenchEventConstants;
71
import eu.etaxonomy.taxeditor.model.AbstractUtility;
62 72
import eu.etaxonomy.taxeditor.model.IDerivedUnitFacadePart;
63 73
import eu.etaxonomy.taxeditor.model.IDirtyMarkable;
64 74
import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
65 75
import eu.etaxonomy.taxeditor.model.IPartContentHasFactualData;
66 76
import eu.etaxonomy.taxeditor.model.IPartContentHasMedia;
67 77
import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
78
import eu.etaxonomy.taxeditor.model.MessagingUtils;
68 79
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
69 80
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
81
import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
70 82
import eu.etaxonomy.taxeditor.workbench.part.IE4SavablePart;
71 83

  
72 84
/**
......
96 108
    private BulkEditorQuery lastQuery = null;
97 109

  
98 110
    private BulkEditorComposite bulkEditorComposite;
111
    
112
    private Set<AbstractPostOperation> operations = new HashSet<>();
99 113

  
100 114
    @Inject
101 115
    public BulkEditor() {
......
122 136
	}
123 137

  
124 138
    public void save(IProgressMonitor monitor, boolean resetMerge) {
139
    	for(AbstractPostOperation<?> entry:operations){
140
            IStatus status = Status.CANCEL_STATUS;
141
            final IAdaptable uiInfoAdapter = WorkspaceUndoUtil
142
                    .getUIInfoAdapter(AbstractUtility.getShell());
143
            String operationlabel = entry.getLabel();
144
            try {
145
                entry.addContext(IOperationHistory.GLOBAL_UNDO_CONTEXT);
146
                
147
                status = entry.execute(new NullProgressMonitor(), uiInfoAdapter);
148
            } catch (ExecutionException e) {
149
                MessagingUtils.operationDialog(AbstractUtility.class, e, TaxeditorStorePlugin.PLUGIN_ID, operationlabel, null);
150
            }
151

  
152
            IPostOperationEnabled postOperationEnabled = entry
153
                    .getPostOperationEnabled();
154
            if (postOperationEnabled != null) {
155
                postOperationEnabled.onComplete();
156
            }
157

  
158
            //AbstractUtility.executeOperation(entry,sync);
159
        }
160

  
161
        operations.clear();
125 162
        if (!input.getCdmEntitySession().isActive()){
126 163
            input.getCdmEntitySession().bind();
127 164
        }
......
370 407

  
371 408
    @Override
372 409
    public void addOperation(AbstractPostOperation operation) {
373
        // operations not yet used for bulk editor
410
        operations.add(operation);
374 411
    }
375 412

  
376 413
    @Inject

Also available in: Unified diff