1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2017 EDIT
|
4
|
* European Distributed Institute of Taxonomy
|
5
|
* http://www.e-taxonomy.eu
|
6
|
*
|
7
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
8
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
9
|
*/
|
10
|
package eu.etaxonomy.taxeditor.navigation.navigator.operation;
|
11
|
|
12
|
import java.util.UUID;
|
13
|
|
14
|
import org.apache.log4j.Logger;
|
15
|
import org.eclipse.core.runtime.Assert;
|
16
|
import org.eclipse.core.runtime.IAdaptable;
|
17
|
import org.eclipse.core.runtime.IProgressMonitor;
|
18
|
import org.eclipse.core.runtime.IStatus;
|
19
|
import org.eclipse.core.runtime.Status;
|
20
|
import org.eclipse.core.runtime.jobs.Job;
|
21
|
import org.eclipse.e4.ui.model.application.MApplication;
|
22
|
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
|
23
|
import org.eclipse.e4.ui.workbench.modeling.EModelService;
|
24
|
import org.eclipse.e4.ui.workbench.modeling.EPartService;
|
25
|
import org.eclipse.swt.widgets.Display;
|
26
|
import org.eclipse.ui.progress.IProgressConstants;
|
27
|
|
28
|
import eu.etaxonomy.cdm.api.service.UpdateResult;
|
29
|
import eu.etaxonomy.cdm.api.service.config.PublishForSubtreeConfigurator;
|
30
|
import eu.etaxonomy.taxeditor.navigation.l10n.Messages;
|
31
|
|
32
|
/**
|
33
|
* @author k.luther
|
34
|
* @date 11.10.2017
|
35
|
*
|
36
|
*/
|
37
|
public class SetPublishForSubtreeOperation extends UpdateSubtreeOperation {
|
38
|
|
39
|
private final static String LABEL = Messages.SetPublishForSubtreeOperation_CHANGE_PUBLISH_OP;
|
40
|
private static final Logger logger = Logger
|
41
|
.getLogger(SetPublishForSubtreeOperation.class);
|
42
|
|
43
|
|
44
|
/**
|
45
|
* @param label
|
46
|
* @param action
|
47
|
* @param source
|
48
|
* @param async
|
49
|
*/
|
50
|
public SetPublishForSubtreeOperation(Object source,
|
51
|
boolean async,
|
52
|
UUID taxonNodeUuid,
|
53
|
EPartService partService,
|
54
|
MPart activePart,
|
55
|
MApplication application,
|
56
|
EModelService modelService,
|
57
|
PublishForSubtreeConfigurator config) {
|
58
|
super(source, async, taxonNodeUuid, partService, activePart, application, modelService, config, LABEL);
|
59
|
|
60
|
}
|
61
|
@Override
|
62
|
protected UpdateResult doUpdateExecute(IProgressMonitor monitor, IAdaptable info) throws Exception {
|
63
|
// runMoniteredOperation();
|
64
|
|
65
|
Job job = createJob(monitor);
|
66
|
// configure the job
|
67
|
job.setProperty(IProgressConstants.KEEP_PROPERTY, true);
|
68
|
job.setUser(true);
|
69
|
// schedule job
|
70
|
job.schedule();
|
71
|
|
72
|
return updateResult;
|
73
|
|
74
|
|
75
|
}
|
76
|
|
77
|
|
78
|
private Job createJob(IProgressMonitor monitor){
|
79
|
Assert.isNotNull(config, "Configuration may not be null");
|
80
|
|
81
|
final Display display = Display.getDefault();
|
82
|
|
83
|
Job job = new Job(Messages.SetPublishFlagForSubtreeOperation_SET_SEC_TASK) {
|
84
|
|
85
|
|
86
|
@Override
|
87
|
protected IStatus run(IProgressMonitor monitor) {
|
88
|
if (config instanceof PublishForSubtreeConfigurator){
|
89
|
updateResult = taxonNodeService.setPublishForSubtree(config.getSubtreeUuid(), ((PublishForSubtreeConfigurator)config).isPublish(), config.isIncludeAcceptedTaxa(), config.isIncludeSynonyms(), config.isIncludeSharedTaxa(), null);
|
90
|
}else {
|
91
|
return Status.CANCEL_STATUS;
|
92
|
}
|
93
|
updateNameEditors();
|
94
|
return Status.OK_STATUS;
|
95
|
|
96
|
}
|
97
|
};
|
98
|
return job;
|
99
|
}
|
100
|
|
101
|
}
|