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.EPartService;
|
24
|
import org.eclipse.swt.widgets.Display;
|
25
|
import org.eclipse.ui.progress.IProgressConstants;
|
26
|
|
27
|
import eu.etaxonomy.cdm.api.service.UpdateResult;
|
28
|
import eu.etaxonomy.cdm.api.service.config.PublishForSubtreeConfigurator;
|
29
|
import eu.etaxonomy.taxeditor.navigation.l10n.Messages;
|
30
|
|
31
|
/**
|
32
|
* @author k.luther
|
33
|
* @date 11.10.2017
|
34
|
*
|
35
|
*/
|
36
|
public class SetPublishForSubtreeOperation extends UpdateSubtreeOperation {
|
37
|
|
38
|
private final static String LABEL = Messages.SetPublishForSubtreeOperation_CHANGE_PUBLISH_OP;
|
39
|
private static final Logger logger = Logger
|
40
|
.getLogger(SetPublishForSubtreeOperation.class);
|
41
|
|
42
|
|
43
|
/**
|
44
|
* @param label
|
45
|
* @param action
|
46
|
* @param source
|
47
|
* @param async
|
48
|
*/
|
49
|
public SetPublishForSubtreeOperation(Object source,
|
50
|
boolean async,
|
51
|
UUID taxonNodeUuid,
|
52
|
EPartService partService,
|
53
|
MPart activePart,
|
54
|
MApplication application,
|
55
|
PublishForSubtreeConfigurator config) {
|
56
|
super(source, async, taxonNodeUuid, partService, activePart, application, config, LABEL);
|
57
|
|
58
|
}
|
59
|
@Override
|
60
|
protected UpdateResult doUpdateExecute(IProgressMonitor monitor, IAdaptable info) throws Exception {
|
61
|
// runMoniteredOperation();
|
62
|
|
63
|
Job job = createJob(monitor);
|
64
|
// configure the job
|
65
|
job.setProperty(IProgressConstants.KEEP_PROPERTY, true);
|
66
|
job.setUser(true);
|
67
|
// schedule job
|
68
|
job.schedule();
|
69
|
|
70
|
return updateResult;
|
71
|
|
72
|
|
73
|
}
|
74
|
|
75
|
|
76
|
private Job createJob(IProgressMonitor monitor){
|
77
|
Assert.isNotNull(config, "Configuration may not be null");
|
78
|
|
79
|
final Display display = Display.getDefault();
|
80
|
|
81
|
Job job = new Job(Messages.SetPublishFlagForSubtreeOperation_SET_SEC_TASK) {
|
82
|
|
83
|
|
84
|
@Override
|
85
|
protected IStatus run(IProgressMonitor monitor) {
|
86
|
if (config instanceof PublishForSubtreeConfigurator){
|
87
|
updateResult = taxonNodeService.setPublishForSubtree(config.getSubtreeUuid(), ((PublishForSubtreeConfigurator)config).isPublish(), config.isIncludeAcceptedTaxa(), config.isIncludeSynonyms(), config.isIncludeSharedTaxa(), null);
|
88
|
}else {
|
89
|
return Status.CANCEL_STATUS;
|
90
|
}
|
91
|
updateNameEditors();
|
92
|
return Status.OK_STATUS;
|
93
|
|
94
|
}
|
95
|
};
|
96
|
return job;
|
97
|
}
|
98
|
|
99
|
}
|