Project

General

Profile

Revision 78e01af4

ID78e01af4e88af414d2066fc26dd595ca96165369
Parent 0fdd8e68
Child 0d1a532b

Added by Patrick Plitzner over 2 years ago

ref #7589 Use progress monitor client manager to load character data

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/CharacterMatrix.java
24 24
import org.apache.commons.collections4.map.LinkedMap;
25 25
import org.eclipse.core.runtime.ICoreRunnable;
26 26
import org.eclipse.core.runtime.IProgressMonitor;
27
import org.eclipse.core.runtime.SubMonitor;
27 28
import org.eclipse.core.runtime.jobs.IJobChangeEvent;
28 29
import org.eclipse.core.runtime.jobs.Job;
29 30
import org.eclipse.core.runtime.jobs.JobChangeAdapter;
......
80 81
import ca.odell.glazedlists.EventList;
81 82
import ca.odell.glazedlists.SortedList;
82 83
import ca.odell.glazedlists.TreeList;
83
import eu.etaxonomy.cdm.api.application.CdmApplicationState;
84 84
import eu.etaxonomy.cdm.api.service.IDescriptiveDataSetService;
85
import eu.etaxonomy.cdm.api.service.IProgressMonitorService;
86 85
import eu.etaxonomy.cdm.api.service.UpdateResult;
87 86
import eu.etaxonomy.cdm.api.service.dto.RowWrapperDTO;
88 87
import eu.etaxonomy.cdm.common.monitor.IRemotingProgressMonitor;
......
518 517

  
519 518
    public void loadDescriptions(DescriptiveDataSet descriptiveDataSet) {
520 519
        UUID monitorUuid = CdmStore.getService(IDescriptiveDataSetService.class).monitGetRowWrapper(descriptiveDataSet);
521
        IProgressMonitorService progressMonitorService = CdmApplicationState.getCurrentAppConfig().getProgressMonitorService();
522 520

  
523 521
        final Collection<RowWrapperDTO> wrappers = new ArrayList<>();
524 522
        String jobLabel = Messages.CharacterMatrix_LOAD_CHARACTER_DATA;
525 523
        Job job = Job.create(jobLabel, (ICoreRunnable) monitor -> {
526
            monitor.beginTask(jobLabel, IProgressMonitor.UNKNOWN);
527
            while(progressMonitorService.isMonitorThreadRunning(monitorUuid)){
528
                if(monitor.isCanceled()){
529
                    progressMonitorService.interrupt(monitorUuid);
530
                }
524
            SubMonitor subMonitor = SubMonitor.convert(monitor);
525
            subMonitor.beginTask(jobLabel, IProgressMonitor.UNKNOWN);
526
            IRemotingProgressMonitor remotingMonitor;
527
            try {
528
                 remotingMonitor = CdmStore.getProgressMonitorClientManager()
529
                .pollMonitor(jobLabel,
530
                        monitorUuid,
531
                        50,
532
                        null,
533
                        (List)null,
534
                        subMonitor);
535
            } catch (InterruptedException e) {
536
                MessagingUtils.informationDialog("Loading failed",
537
                        "Loading of the character matrix failed. Please retry.");
538
                return;
531 539
            }
532
            IRemotingProgressMonitor remotingMonitor = progressMonitorService.getRemotingMonitor(monitorUuid);
533 540
            Object result = remotingMonitor.getResult();
534 541
            if(result instanceof Collection){
535 542
                wrappers.addAll((Collection<RowWrapperDTO>) result);
536 543
            }
544
            if(wrappers.isEmpty()){
545
                MessagingUtils.informationDialog("No specimen descriptions found",
546
                        "There are no specimens yet added to the matrix.");
547
            }
537 548
            monitor.done();
538 549
        });
539 550
        job.addJobChangeListener(new JobChangeAdapter(){
......
552 563
                });
553 564
            }
554 565
        });
555
        job.schedule(1000);
566
        job.schedule();
556 567
    }
557 568

  
558 569
    private void loadingDone() {

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)