Project

General

Profile

« Previous | Next » 

Revision 307279d3

Added by Patrick Plitzner over 3 years ago

Clear candidates and target when saving + minor refactoring

View differences:

eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/BulkEditorE4.java
126 126
        }
127 127
    }
128 128

  
129
    public void save(IProgressMonitor monitor, boolean resetMerge, boolean rememberSelection) {
130
        if (!input.getCdmEntitySession().isActive()){
131
            input.getCdmEntitySession().bind();
132
        }
133
        input.saveModel(resetMerge);
134

  
135
        IStructuredSelection selection = getSelection();
136

  
137
        dirty.setDirty(false);
138
        input.dispose();
139
        input.bind();
140
        conversation.commit(true);
141

  
142
        if (lastQuery != null && rememberSelection){
143
            bulkEditorComposite.performSearch(lastQuery, selection);
144
        }
145
    }
146

  
147 129

  
148 130
	@Focus
149 131
	public void setFocus() {
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/BulkEditorE4Composite.java
19 19

  
20 20
import javax.inject.Inject;
21 21

  
22
import org.eclipse.core.runtime.NullProgressMonitor;
23 22
import org.eclipse.e4.ui.services.EMenuService;
24 23
import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
25
import org.eclipse.jface.dialogs.MessageDialog;
26 24
import org.eclipse.jface.layout.GridDataFactory;
27 25
import org.eclipse.jface.viewers.ISelectionChangedListener;
28 26
import org.eclipse.jface.viewers.IStructuredSelection;
......
85 83
import eu.etaxonomy.cdm.model.description.SpecimenDescription;
86 84
import eu.etaxonomy.taxeditor.bulkeditor.BulkEditorQuery;
87 85
import eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput;
88
import eu.etaxonomy.taxeditor.l10n.Messages;
89 86
import eu.etaxonomy.taxeditor.model.ImageResources;
87
import eu.etaxonomy.taxeditor.store.StoreUtil;
90 88

  
91 89
/**
92 90
 *
......
376 374
	 * @param selection */
377 375
    public void performSearch(BulkEditorQuery query, IStructuredSelection selection) {
378 376
        if (query != null) {
379
            if (bulkEditor.isDirty()) {
380
                String[] labels = {Messages.BulkEditorE4_SAVE_AND_SEARCH, Messages.BulkEditorE4_DONT_SAVE,Messages.BulkEditorE4_CANCEL};
381
                MessageDialog dialog =new MessageDialog(topComposite.getShell(), Messages.BulkEditorE4_SAVE_CHANGES_TITLE, null, Messages.BulkEditorE4_SAVE_CHANGES_MESSAGE, MessageDialog.QUESTION,labels, 0);
382
                int result = dialog.open();
383
                if (result == 0) {
384
                    bulkEditor.save(new NullProgressMonitor());
385
                } else if (result == 2){
386
                    return;
387
                }
377
            if(StoreUtil.checkDirty(bulkEditor)){
378
                return;
388 379
            }
389
            bulkEditor.setDirty(false);
390 380
            bulkEditor.getEditorInput().performSearch(query, selection);
391 381
            bulkEditor.setLastQuery(query);
392 382
        }
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/AbstractBulkEditorInput.java
229 229
            } catch (InterruptedException e) {
230 230
            }
231 231
	    }
232
	    model.clear();
232
        model.clear();
233
        markedMergeCandidates.clear();
234
        markedMergeTarget = null;
233 235

  
234 236
		if(getEntityUuid() != null){
235 237
			T entity = loadEntity(getEntityUuid());
......
294 296
		}
295 297
	}
296 298

  
297
	private void addToModel(List<T> entities, UUID selectedUuid){
299
    private void addToModel(List<T> entities, UUID selectedUuid){
298 300
	    //filter pre-loaded previously selected element
299 301
	    if(selectedUuid!=null){
300 302
	        entities = entities.stream().filter(entity->!entity.getUuid().equals(selectedUuid)).collect(Collectors.toList());
......
370 372
	    mergedEntities.clear();
371 373
	}
372 374

  
373

  
374 375
	/** {@inheritDoc} */
375 376
	@Override
376 377
    public T create(T entity) {

Also available in: Unified diff