Project

General

Profile

Revision 6cf49987

ID6cf49987808795f35aae371f577c8d5fb983a2f0
Parent 91b9bc97
Child 09376415

Added by Patrick Plitzner over 1 year ago

ref #7439 Re-select after search has finished

View differences:

eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/BulkEditorE4.java
21 21

  
22 22
import org.eclipse.core.runtime.IProgressMonitor;
23 23
import org.eclipse.core.runtime.NullProgressMonitor;
24
import org.eclipse.e4.core.di.annotations.Optional;
24 25
import org.eclipse.e4.core.services.events.IEventBroker;
25 26
import org.eclipse.e4.ui.di.Focus;
26 27
import org.eclipse.e4.ui.di.Persist;
28
import org.eclipse.e4.ui.di.UIEventTopic;
27 29
import org.eclipse.e4.ui.model.application.ui.MDirtyable;
28 30
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
29 31
import org.eclipse.e4.ui.services.EMenuService;
......
59 61
import org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack;
60 62
import org.eclipse.nebula.widgets.nattable.selection.RowSelectionModel;
61 63
import org.eclipse.nebula.widgets.nattable.selection.RowSelectionProvider;
62
import org.eclipse.nebula.widgets.nattable.selection.command.SelectRowsCommand;
63 64
import org.eclipse.nebula.widgets.nattable.sort.SortHeaderLayer;
64 65
import org.eclipse.nebula.widgets.nattable.sort.config.SingleClickSortConfiguration;
65 66
import org.eclipse.nebula.widgets.nattable.style.DisplayMode;
......
367 368
        conversation.commit(true);
368 369

  
369 370
        if (lastQuery != null){
370
            performSearch(lastQuery);
371
            setSelection(selection);
371
            performSearch(lastQuery, selection);
372 372
        }
373 373
	}
374 374

  
375
	/** {@inheritDoc} */
376
    public void performSearch(BulkEditorQuery query) {
375
	public void performSearch(BulkEditorQuery query) {
376
	    performSearch(query, null);
377
	}
378

  
379
	/** {@inheritDoc}
380
	 * @param selection */
381
    public void performSearch(BulkEditorQuery query, IStructuredSelection selection) {
377 382
        if (query != null) {
378 383
            // TODO check if dirty, prompt save
379 384
            if (isDirty()) {
......
387 392
                }
388 393
            }
389 394
            dirty.setDirty(false);
390
            input.performSearch(query);
395
            input.performSearch(query, selection);
391 396
            lastQuery = query;
392 397
        }
393 398
    }
394 399

  
400
    @Optional
401
    @Inject
402
    private void setSelectionAfterSearch(@UIEventTopic(WorkbenchEventConstants.BULK_EDITOR_SEARCH_FINISHED)IStructuredSelection selection){
403
        if(selection!=null){
404
            setSelection(selection);
405
        }
406
    }
395 407

  
396 408
    public void refresh(){
397 409
        natTable.doCommand(new VisualRefreshCommand());
......
413 425
        Object[] objects = selection.toArray();
414 426
        for (Object object : objects) {
415 427
            if(object instanceof CdmBase){
416
                natTable.doCommand(new SelectRowsCommand(bodyLayer, 0, bodyDataProvider.indexOfRowObject((CdmBase) object), false, false));
428
                bodyLayer.getSelectionLayer().selectRow(0, bodyDataProvider.indexOfRowObject((CdmBase) object), false, false);
417 429
            }
418 430
        }
419 431
    }
......
475 487
            input.replaceInModel((CdmBase) element);
476 488
        }
477 489
        dirty.setDirty(true);
478
        setSelection(getSelection());
490
        setSelection(new StructuredSelection(element));
479 491
    }
480 492

  
481 493
    @Override
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/AbstractBulkEditorInput.java
19 19

  
20 20
import org.eclipse.core.runtime.ICoreRunnable;
21 21
import org.eclipse.core.runtime.jobs.Job;
22
import org.eclipse.jface.viewers.IStructuredSelection;
22 23

  
23 24
import ca.odell.glazedlists.BasicEventList;
24 25
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
......
38 39
import eu.etaxonomy.taxeditor.bulkeditor.input.sortprovider.CdmBaseSortProvider;
39 40
import eu.etaxonomy.taxeditor.bulkeditor.internal.TaxeditorBulkeditorPlugin;
40 41
import eu.etaxonomy.taxeditor.editor.CdmEntitySessionInput;
42
import eu.etaxonomy.taxeditor.event.EventUtility;
43
import eu.etaxonomy.taxeditor.event.WorkbenchEventConstants;
41 44
import eu.etaxonomy.taxeditor.l10n.Messages;
42 45
import eu.etaxonomy.taxeditor.model.MessagingUtils;
43 46
import eu.etaxonomy.taxeditor.store.CdmStore;
......
144 147
		return entityUuid;
145 148
	}
146 149

  
147
	public void performSearch(final BulkEditorQuery bulkEditorQuery) {
150
	public void performSearch(final BulkEditorQuery bulkEditorQuery, IStructuredSelection selection) {
148 151
	    //cancel previous search job
149 152
	    if(searchJob!=null && searchJob.getState()!=Job.NONE){
150 153
	        searchJob.cancel();
......
183 186
                    monitor.setTaskName(String.format(Messages.AbstractBulkEditorInput_LOADED, loadedCount, totalWork, getName()));
184 187
                } while (!entities.isEmpty());
185 188
	            monitor.done();
189
	            EventUtility.postAsyncEvent(WorkbenchEventConstants.BULK_EDITOR_SEARCH_FINISHED, selection);
186 190
	        });
187
	        searchJob.setUser(true);
188 191
	        searchJob.schedule();
189 192
		}
190 193
	}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/event/EventUtility.java
16 16
import org.eclipse.e4.core.di.annotations.Optional;
17 17
import org.eclipse.e4.core.services.events.IEventBroker;
18 18
import org.eclipse.e4.ui.di.UIEventTopic;
19
import org.eclipse.e4.ui.di.UISynchronize;
19 20
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
20 21
import org.eclipse.e4.ui.services.IServiceConstants;
21 22
import org.eclipse.swt.widgets.Shell;
......
37 38
    private static Shell shell;
38 39

  
39 40
    @Inject
41
    private static UISynchronize sync;
42

  
43
    @Inject
40 44
    private static IEventBroker eventBroker;
41 45

  
42 46
    @Inject
......
51 55
        eventBroker.post(topic, data);
52 56
    }
53 57

  
58
    public static void postSyncEvent(String topic, Object data){
59
        sync.syncExec(()->eventBroker.post(topic, data));
60
    }
61

  
62
    public static void postAsyncEvent(String topic, Object data){
63
        sync.asyncExec(()->eventBroker.post(topic, data));
64
    }
65

  
54 66
    public static ECommandService getCommandService() {
55 67
        return commandService;
56 68
    }
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/event/WorkbenchEventConstants.java
33 33

  
34 34
    public static final String RECONNECT = "RECONNECT";
35 35

  
36
    public static final String BULK_EDITOR_SEARCH_FINISHED = "BULK_EDITOR/SEARCH_DONE";
37

  
36 38
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)