Project

General

Profile

« Previous | Next » 

Revision ac70dabe

Added by Andreas Müller almost 3 years ago

cleanup and set cancelable to true SetXXXForSubtreeOperations

View differences:

eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/handler/SetSecReferenceForSubtreeHandlerE4.java
147 147
    public void onComplete() {
148 148
    }
149 149

  
150
    /**
151
     * {@inheritDoc}
152
     */
153 150
    @Override
154 151
    protected Object getTrigger() {
155 152
        return this;
156 153
    }
157

  
158 154
}
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/MoveTaxonOperation.java
26 26
import eu.etaxonomy.taxeditor.model.AbstractUtility;
27 27
import eu.etaxonomy.taxeditor.navigation.l10n.Messages;
28 28
import eu.etaxonomy.taxeditor.navigation.navigator.e4.TreeNodeDropAdapterE4.MovingType;
29
import eu.etaxonomy.taxeditor.operation.IPostMoniteredOperationEnabled;
30 29
import eu.etaxonomy.taxeditor.operation.CdmUpdateOperation;
30
import eu.etaxonomy.taxeditor.operation.IPostMoniteredOperationEnabled;
31 31
import eu.etaxonomy.taxeditor.store.CdmStore;
32 32

  
33 33
/**
......
55 55

  
56 56
    @Override
57 57
    protected UpdateResult doUpdateExecute(IProgressMonitor monitor, IAdaptable info) throws Exception {
58
        runMoniteredOperation();
59
        return updateResult;
60
    }
61 58

  
62
    public void runMoniteredOperation() {
63 59
        final UUID uuid;
64 60
        int movingTypeInt = -1;
65 61
        switch (this.moveToParentNode) {
......
69 65
        case BEHIND:
70 66
            movingTypeInt = 2;
71 67
            break;
68
        default:
69
            updateResult = new UpdateResult();
70
            updateResult.setAbort();
71
            updateResult.addException(new Exception("The moving type is invalid.")); //$NON-NLS-1$
72
        }
72 73

  
73
         default:
74
                updateResult = new UpdateResult();
75
                updateResult.setAbort();
76
                updateResult.addException(new Exception("The moving type is invalid.")); //$NON-NLS-1$
77

  
78
         }
79 74
        if (movingTypeInt >-1){
80 75
            uuid = CdmApplicationState.getLongRunningTasksService().monitLongRunningTask(taxonNodesToMoveUuid,
81 76
                newParentTreeNodeUuid, movingTypeInt);
82 77

  
83
                Display.getDefault().asyncExec(new Runnable() {
84
                    @Override
85
                    public void run() {
78
                Display.getDefault().asyncExec(()->{
86 79
                        AbstractUtility.executeMoniteredOperation("Move Taxon to new parent: ",
87 80
                                uuid,
88 81
                                500,
......
90 83
                                MoveTaxonOperation.this,
91 84
                                null,
92 85
                                false, true);
93
                    }
94 86
                });
95 87
        }
88
        return updateResult;
96 89
    }
97 90

  
98 91
    @Override
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/SetPublishForSubtreeOperation.java
1
// $Id$
2 1
/**
3 2
* Copyright (C) 2017 EDIT
4 3
* European Distributed Institute of Taxonomy
......
23 22
import eu.etaxonomy.cdm.api.service.UpdateResult;
24 23
import eu.etaxonomy.cdm.api.service.config.PublishForSubtreeConfigurator;
25 24
import eu.etaxonomy.cdm.common.monitor.IRemotingProgressMonitor;
26
import eu.etaxonomy.taxeditor.editor.EditorUtil;
25
import eu.etaxonomy.taxeditor.model.AbstractUtility;
27 26
import eu.etaxonomy.taxeditor.navigation.l10n.Messages;
28 27
import eu.etaxonomy.taxeditor.operation.IPostMoniteredOperationEnabled;
29 28

  
30 29
/**
31 30
 * @author k.luther
32 31
 * @date 11.10.2017
33
 *
34 32
 */
35
public class SetPublishForSubtreeOperation extends UpdateSubtreeOperation implements IPostMoniteredOperationEnabled{
33
public class SetPublishForSubtreeOperation
34
            extends UpdateSubtreeOperation
35
            implements IPostMoniteredOperationEnabled{
36 36

  
37
    private final static String LABEL = Messages.SetPublishForSubtreeOperation_CHANGE_PUBLISH_OP;
38
    private static final Logger logger = Logger
39
            .getLogger(SetPublishForSubtreeOperation.class);
37
    @SuppressWarnings("unused")
38
    private static final Logger logger = Logger.getLogger(SetPublishForSubtreeOperation.class);
40 39

  
40
    private final static String LABEL = Messages.SetPublishForSubtreeOperation_CHANGE_PUBLISH_OP;
41 41

  
42
    /**
43
     * @param label
44
     * @param action
45
     * @param source
46
     * @param async
47
     */
48 42
    public SetPublishForSubtreeOperation(Object source,
49 43
            boolean async,
50 44
            UUID taxonNodeUuid,
......
54 48
            EModelService modelService,
55 49
            PublishForSubtreeConfigurator config) {
56 50
        super(source, async, taxonNodeUuid, partService, activePart, application, modelService, config, LABEL);
57

  
58
    }
59
  @Override
60
    protected UpdateResult doUpdateExecute(IProgressMonitor monitor, IAdaptable info) throws Exception {
61
      runMoniteredOperation();
62
//      updateNameEditors();
63

  
64
//        Job job = createJob(monitor);
65
//        // configure the job
66
//        job.setProperty(IProgressConstants.KEEP_PROPERTY, true);
67
//        job.setUser(true);
68
//        // schedule job
69
//        job.schedule();
70

  
71
        return updateResult;
72

  
73

  
74 51
    }
75 52

  
76

  
77
//    private Job createJob(IProgressMonitor monitor){
78
//        Assert.isNotNull(config, "Configuration may not be null");
79
//
80
//        final Display display = Display.getDefault();
81
//        taxonNodeService = CdmStore.getService(ITaxonNodeService.class);
82
//        Job job = new Job(Messages.SetPublishFlagForSubtreeOperation_SET_SEC_TASK) {
83
//
84
//
85
//            @Override
86
//            protected IStatus run(IProgressMonitor monitor) {
87
//                if (config instanceof PublishForSubtreeConfigurator){
88
//                	updateResult =  taxonNodeService.setPublishForSubtree(config.getSubtreeUuid(), ((PublishForSubtreeConfigurator)config).isPublish(), config.isIncludeAcceptedTaxa(), config.isIncludeSynonyms(), config.isIncludeSharedTaxa(), null);
89
//                }else {
90
//                	return Status.CANCEL_STATUS;
91
//                }
92
//                updateNameEditors();
93
//                return Status.OK_STATUS;
94
//
95
//            }
96
//        };
97
//        return job;
98
//    }
99

  
100
    public void runMoniteredOperation() {
53
    @Override
54
    protected UpdateResult doUpdateExecute(IProgressMonitor monitor, IAdaptable info) throws Exception {
101 55

  
102 56
        final UUID uuid = longRunningTaskService.monitLongRunningTask(config);
103
        Display.getDefault().asyncExec(new Runnable() {
104
            @Override
105
            public void run() {
106
                EditorUtil.executeMoniteredOperation("Set Publish Flag for Subtree",
57
        Display.getDefault().asyncExec(()->{
58
                AbstractUtility.executeMoniteredOperation("Set Publish Flag for Subtree",
107 59
                        uuid,
108 60
                        1000,
109
                        false,
61
                        true,
110 62
                        SetPublishForSubtreeOperation.this,
111 63
                        null,
112 64
                        true, false);
113
            //updateNameEditors();
114
            }
115

  
116 65
        });
117

  
118

  
66
        return this.updateResult;
119 67
    }
120
    /**
121
     * {@inheritDoc}
122
     */
68

  
123 69
    @Override
124 70
    public void postOperation(IRemotingProgressMonitor monitor) {
125 71
        // TODO Auto-generated method stub
126

  
127 72
    }
128

  
129

  
130
}
73
}
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/SetSecundumForSubtreeOperation.java
10 10

  
11 11
import java.util.UUID;
12 12

  
13
import javax.inject.Inject;
14

  
15 13
import org.apache.log4j.Logger;
16 14
import org.eclipse.core.runtime.IAdaptable;
17 15
import org.eclipse.core.runtime.IProgressMonitor;
18
import org.eclipse.e4.ui.di.UISynchronize;
19 16
import org.eclipse.e4.ui.model.application.MApplication;
20 17
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
21 18
import org.eclipse.e4.ui.workbench.modeling.EModelService;
......
33 30
/**
34 31
 * @author k.luther
35 32
 * @date 10.02.2017
36
 *
37 33
 */
38
public class SetSecundumForSubtreeOperation extends UpdateSubtreeOperation implements IPostMoniteredOperationEnabled{
34
public class SetSecundumForSubtreeOperation
35
        extends UpdateSubtreeOperation
36
        implements IPostMoniteredOperationEnabled{
39 37

  
40 38
	private final static String LABEL = Messages.SetSecundumForSubtreeOperation_CHANGE_SEC_OP;
41 39
    @SuppressWarnings("unused")
42 40
	private static final Logger logger = Logger.getLogger(SetSecundumForSubtreeOperation.class);
43 41

  
44
    @Inject
45
    private UISynchronize sync;
46

  
47

  
48 42
    public SetSecundumForSubtreeOperation(Object source, boolean async, UUID taxonNodeUuid, EPartService partService,
49 43
			MPart activePart, MApplication application, EModelService modelService, SecundumForSubtreeConfigurator config) {
50 44
		super(source, async, taxonNodeUuid, partService, activePart, application, modelService, config, LABEL);
51

  
52 45
	}
53 46

  
54 47
    @Override
55 48
    protected UpdateResult doUpdateExecute(IProgressMonitor monitor, IAdaptable info) throws Exception {
56 49
        EditorUtil.checkForChanges(null, partService);
57

  
58
//        runMoniteredOperation();
59
        runMoniteredOperation();
60
//        updateNameEditors();
61
//        Job job = createJob(monitor);
62
//        // configure the job
63
//        job.setProperty(IProgressConstants.KEEP_PROPERTY, true);
64
//        job.setUser(true);
65
//        // schedule job
66
//        job.schedule();
67

  
68
        return updateResult;
69

  
70

  
71
    }
72

  
73

  
74
//    private Job createJob(IProgressMonitor monitor){
75
//        Assert.isNotNull(config, "Configuration may not be null");
76
//
77
//        final Display display = Display.getDefault();
78
//
79
//        Job job = new Job(Messages.SetSecundumForSubtreeOperation_SET_SEC_TASK) {
80
//            @Override
81
//            protected IStatus run(IProgressMonitor monitor) {
82
//            	if (config instanceof SecundumForSubtreeConfigurator){
83
//					updateResult = taxonNodeService.setSecundumForSubtree((SecundumForSubtreeConfigurator)config);
84
//				}else{
85
//					return Status.CANCEL_STATUS;
86
//				}
87
//
88
//				return Status.OK_STATUS;
89
//
90
//            }
91
//        };
92
//        return job;
93
//    }
94

  
95

  
96
    public void runMoniteredOperation() {
97 50
        final UUID uuid = longRunningTaskService.monitLongRunningTask(config);
98
        Display.getDefault().asyncExec(new Runnable() {
99
            @Override
100
            public void run() {
51
        Display.getDefault().asyncExec(()->{
101 52
                AbstractUtility.executeMoniteredOperation("Set Secundum Reference for Subtree",
102 53
                        uuid,
103 54
                        1000,
104
                        false,
55
                        true,
105 56
                        SetSecundumForSubtreeOperation.this,
106 57
                        null,
107 58
                        true, false);
108

  
109
            }
110 59
        });
60
        return updateResult;
111 61
    }
112 62

  
113 63
    @Override
114 64
    public void postOperation(IRemotingProgressMonitor monitor) {
115 65
        // TODO Auto-generated method stub
116 66
    }
117
 }
67
 }
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/wizard/DatabaseRepairUpdateCachesWizard.java
28 28
/**
29 29
 * @author k.luther
30 30
 * @since 05.03.2019
31
 *
32 31
 */
33 32
public class DatabaseRepairUpdateCachesWizard extends Wizard implements IPostMoniteredOperationEnabled {
34 33

  
......
44 43
        page = new CacheUpdaterWizardPage("Update Caches", cacheUpdaterConfig);
45 44
    }
46 45

  
47
    /**
48
     * {@inheritDoc}
49
     */
50 46
    @Override
51 47
    public void postOperation(IRemotingProgressMonitor monitor) {
52 48
        // TODO Auto-generated method stub
53

  
54 49
    }
55 50

  
56 51
    @Override
......
58 53
        addPage(page);
59 54
    }
60 55

  
61
    /**
62
     * {@inheritDoc}
63
     */
64 56
    @Override
65 57
    public boolean performFinish() {
66 58
        if (page.updateAgentBase){
......
80 72
        }
81 73
        if (!cacheUpdaterConfig.getClassList().isEmpty()){
82 74

  
83

  
84 75
             final UUID uuid = longRunningTaskService.monitLongRunningTask(cacheUpdaterConfig);
85
             Display.getDefault().asyncExec(new Runnable() {
86
                 @Override
87
                 public void run() {
76
             Display.getDefault().asyncExec(()->{
88 77
                     AbstractUtility.executeMoniteredOperation("Update Caches",
89 78
                             uuid,
90 79
                             1000,
......
92 81
                             DatabaseRepairUpdateCachesWizard.this,
93 82
                             null,
94 83
                             true, true);
95

  
96
                 }
97

  
98 84
             });
99 85
        }
100

  
101

  
102

  
103
    return true;
86
        return true;
104 87
    }
105

  
106
}
88
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/PreferencesUtil.java
1702 1702
    }
1703 1703

  
1704 1704
    public static boolean getFilterCommonNameReferences(){
1705
        Boolean result = getBooleanValue(PreferencePredicate.CommonNameReferencesWithMarker.getKey());
1706
        if (result == null){
1707
            return false;
1708
        }
1709
        return result;
1705
        return getBooleanValue(PreferencePredicate.CommonNameReferencesWithMarker.getKey());
1710 1706
    }
1711 1707

  
1712 1708
    public static void updateDBPreferences() {
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/configurator/DistributionAggregationConfiguratorWizard.java
39 39
        longRunningTaskService = CdmApplicationState.getLongRunningTasksService();
40 40
    }
41 41

  
42

  
43 42
    @Override
44 43
    public boolean performFinish() {
45 44

  
......
61 60

  
62 61
        UUID uuid = longRunningTaskService.invoke(configurator);
63 62

  
64
        Display.getDefault().asyncExec(new Runnable() {
65
            @Override
66
            public void run() {
63
        Display.getDefault().asyncExec(()-> {
67 64
                AbstractUtility.executeMoniteredOperation("Aggregate Distributions",
68 65
                        uuid,
69 66
                        1000,
......
71 68
                        DistributionAggregationConfiguratorWizard.this,
72 69
                        null,
73 70
                        true, false);
74

  
75
            }
76

  
77 71
        });
78 72

  
79 73
        return true;
......
84 78
    public void addPages() {
85 79
        page = new DistributionAggregationWizardPage(configurator);
86 80
        addPage(page);
87

  
88 81
    }
89 82

  
90 83

  
91 84
    @Override
92 85
    public void postOperation(IRemotingProgressMonitor monitor) {
93 86
        // TODO Auto-generated method stub
94

  
95 87
    }
96

  
97

  
98
}
88
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/configurator/DistributionAggregationWizardPage.java
50 50
import eu.etaxonomy.cdm.model.term.TermTree;
51 51
import eu.etaxonomy.cdm.model.term.TermType;
52 52
import eu.etaxonomy.taxeditor.l10n.Messages;
53
import eu.etaxonomy.taxeditor.model.AbstractUtility;
53 54
import eu.etaxonomy.taxeditor.store.CdmStore;
54
import eu.etaxonomy.taxeditor.store.StoreUtil;
55 55
import eu.etaxonomy.taxeditor.ui.combo.OriginalSourceTypeComparator;
56 56
import eu.etaxonomy.taxeditor.ui.dialog.SuperAreaSelectionWizard;
57 57

  
......
71 71

  
72 72
    private Button checkExportUnpublished;
73 73

  
74
    private Object[] checkedElements;
74 75

  
75

  
76
    Object[] checkedElements;
77

  
78

  
79

  
80

  
81
    /**
82
     * @param pageName
83
     */
84 76
    public DistributionAggregationWizardPage(DistributionAggregationConfiguration configurator) {
85 77
        super(Messages.DistributionAggregationWizardPage_TITLE);
86 78
        this.configurator = configurator;
87 79

  
88 80
        this.setDescription(Messages.DistributionAggregationWizardPage_DESCRIPTION);
89

  
90 81
    }
91 82

  
92

  
93 83
    @Override
94 84
    public void createControl(Composite parent) {
95 85
        final Composite composite = new Composite(parent, SWT.NULL);
......
133 123
                    comboClassificationSelection.setEnabled(!data.exclude);
134 124
                    updateHigherRankCombo();
135 125
                }
136

  
137

  
138 126
            });
139 127
        }
140 128
        checkUseHigherLevel= new Button(composite,  SWT.RADIO);
......
178 166
        });
179 167
        for(Classification tree : classifications){
180 168
            comboClassificationSelection.add(tree.getName().getText(), classifications.indexOf(tree));
181

  
182 169
        }
183 170

  
184 171
        comboClassificationSelection.select(classifications.indexOf(selectedClassification));
......
213 200
        updateHigherRankCombo();
214 201
        comboHigherRank.addListener(SWT.Selection, this);
215 202

  
216

  
217 203
        Label lowerRankLabel = new Label(control, SWT.NULL);
218 204
        lowerRankLabel.setText(Messages.DistributionAggregationWizardPage_LOWEST_RANK);
219 205
        comboLowerRank = new Combo(control, SWT.BORDER | SWT.READ_ONLY);
......
303 289
            @Override
304 290
            public void widgetSelected(SelectionEvent event) {
305 291
                SuperAreaSelectionWizard availableDistributionWizard = new SuperAreaSelectionWizard((DistributionAggregationConfiguration) configurator, (NamedAreaLevel)comboAreaLevel.getData(comboAreaLevel.getText()));
306
                WizardDialog dialog = new WizardDialog(StoreUtil.getShell(),
292
                WizardDialog dialog = new WizardDialog(AbstractUtility.getShell(),
307 293
                        availableDistributionWizard);
308 294
                int open = dialog.open();
309 295
            }
310 296
        });
311 297

  
312

  
313

  
314

  
315 298
        Label sourceModeLabel = new Label(control, SWT.NULL);
316 299

  
317 300
        sourceModeLabel.setText(Messages.DistributionAggregationWizardPage_SOURCEMODE_CHILD_PARENT);
......
322 305
        for (AggregationSourceMode mode :AggregationSourceMode.values()){
323 306
            comboSourceModeChildParent.add(mode.getLabel());
324 307
            comboSourceModeChildParent.setData(mode.getLabel(), mode);
325

  
326 308
        }
327 309

  
328 310
        comboSourceModeChildParent.addSelectionListener(this);
......
350 332
        sourceTypeViewer = CheckboxTableViewer.newCheckList(control, SWT.BORDER | SWT.SINGLE);
351 333
        sourceTypeViewer.setContentProvider(new ArrayContentProvider());
352 334

  
353

  
354 335
        sourceTypeViewer.addCheckStateListener(new ICheckStateListener(){
355 336
            @Override
356 337
            public void checkStateChanged(    CheckStateChangedEvent event){
......
371 352

  
372 353
        //aggregation mode
373 354

  
374

  
375

  
376 355
        Label selectStatusLabel = new Label(control, SWT.NULL);
377 356
        selectStatusLabel.setText(Messages.DistributionAggregationWizardPage_STATUS_ORDER);
378 357
        comboStatusOrder = new Combo(control, SWT.PUSH );
379 358
        comboStatusOrder.add(Messages.DistributionAggregationWizardPage_DEFAULT);
380 359
        comboStatusOrder.setData(Messages.DistributionAggregationWizardPage_DEFAULT, null);
381
        for (TermTree tree: CdmStore.getService(ITermTreeService.class).list(TermType.PresenceAbsenceTerm, null, 0, null,null)){
360
        for (TermTree<?> tree: CdmStore.getService(ITermTreeService.class).list(TermType.PresenceAbsenceTerm, null, 0, null,null)){
382 361
            comboStatusOrder.add(tree.getTitleCache());
383 362
            comboStatusOrder.setData(tree.getTitleCache(), tree);
384 363
        }
......
391 370

  
392 371
        GridLayoutFactory.fillDefaults();
393 372

  
394

  
395

  
396 373
        setControl(composite);
397

  
398 374
    }
399 375

  
400

  
401

  
402

  
403

  
404

  
405 376
    @Override
406 377
    public void widgetSelected(SelectionEvent e) {
407 378

  
......
413 384
            }else{
414 385
                sourceTypeViewer.getTable().setEnabled(false);
415 386
            }
416

  
417 387
        }
418 388

  
419 389
        if (e.getSource().equals(comboAreaLevel)){
420 390
            buttonSuperArea.setEnabled(StringUtils.isNotBlank(comboAreaLevel.getText()));
421 391
        }
422

  
423

  
424 392
    }
425 393

  
426

  
427 394
    @Override
428 395
    public void widgetDefaultSelected(SelectionEvent e) {
429 396
        // TODO Auto-generated method stub
430

  
431 397
    }
432 398

  
433

  
434 399
    @Override
435 400
    public void handleEvent(Event event) {
436 401
        if (event.widget.equals(comboHigherRank)){
......
452 417
            updateHigherRankCombo();
453 418
            updateLowerRankCombo();
454 419
        }
455

  
456 420
    }
457 421

  
458

  
459

  
460

  
461

  
462 422
   public TermTree getStatusOrder(){
463 423
       if (StringUtils.isNotBlank(comboStatusOrder.getText())){
464
           return (TermTree)comboStatusOrder.getData(comboStatusOrder.getText());
424
           return (TermTree<?>)comboStatusOrder.getData(comboStatusOrder.getText());
465 425
       }
466 426
       return null;
467 427
   }
468 428

  
469

  
470

  
471 429
   public boolean useUnpublishedData(){
472 430
       return checkExportUnpublished.getSelection();
473 431
   }
474 432

  
475

  
476

  
477

  
478

  
479 433
    public Classification getSelectedClassification() {
480 434
        return selectedClassification;
481 435
    }
482 436

  
483

  
484 437
    public TaxonNode getSubTreeNode() {
485 438
        return subTreeNode;
486 439
    }
487
}
440
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/util/ProgressMonitorClientManager.java
171 171

  
172 172
                // set dialog text
173 173
                String subTaskName = remotingMonitor.getSubTask();
174
                String percentage = "100";
174
                String percentage = "0";
175 175
                if (remotingMonitor.getTotalWork() != 0){
176 176
                    percentage = new DecimalFormat("#.##").format(remotingMonitor.getPercentage());
177 177
                }

Also available in: Unified diff