1
|
/**
|
2
|
* Copyright (C) 2017 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
package eu.etaxonomy.taxeditor.navigation.navigator.operation;
|
10
|
|
11
|
import java.util.UUID;
|
12
|
|
13
|
import javax.inject.Inject;
|
14
|
|
15
|
import org.apache.log4j.Logger;
|
16
|
import org.eclipse.core.runtime.Assert;
|
17
|
import org.eclipse.core.runtime.IAdaptable;
|
18
|
import org.eclipse.core.runtime.IProgressMonitor;
|
19
|
import org.eclipse.core.runtime.IStatus;
|
20
|
import org.eclipse.core.runtime.Status;
|
21
|
import org.eclipse.core.runtime.jobs.Job;
|
22
|
import org.eclipse.e4.ui.di.UISynchronize;
|
23
|
import org.eclipse.e4.ui.model.application.MApplication;
|
24
|
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
|
25
|
import org.eclipse.e4.ui.workbench.modeling.EModelService;
|
26
|
import org.eclipse.e4.ui.workbench.modeling.EPartService;
|
27
|
import org.eclipse.swt.widgets.Display;
|
28
|
|
29
|
import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
|
30
|
import eu.etaxonomy.cdm.api.service.UpdateResult;
|
31
|
import eu.etaxonomy.cdm.api.service.config.SecundumForSubtreeConfigurator;
|
32
|
import eu.etaxonomy.cdm.common.monitor.IRemotingProgressMonitor;
|
33
|
import eu.etaxonomy.taxeditor.model.AbstractUtility;
|
34
|
import eu.etaxonomy.taxeditor.navigation.l10n.Messages;
|
35
|
import eu.etaxonomy.taxeditor.operation.IPostMoniteredOperationEnabled;
|
36
|
|
37
|
/**
|
38
|
* @author k.luther
|
39
|
* @date 10.02.2017
|
40
|
*
|
41
|
*/
|
42
|
public class SetSecundumForSubtreeOperation extends UpdateSubtreeOperation implements IPostMoniteredOperationEnabled{
|
43
|
|
44
|
private final static String LABEL = Messages.SetSecundumForSubtreeOperation_CHANGE_SEC_OP;
|
45
|
private static final Logger logger = Logger
|
46
|
.getLogger(SetSecundumForSubtreeOperation.class);
|
47
|
|
48
|
@Inject
|
49
|
UISynchronize sync;
|
50
|
|
51
|
|
52
|
public SetSecundumForSubtreeOperation(Object source, boolean async, UUID taxonNodeUuid, EPartService partService,
|
53
|
MPart activePart, MApplication application, EModelService modelService, SecundumForSubtreeConfigurator config) {
|
54
|
super(source, async, taxonNodeUuid, partService, activePart, application, modelService, config, LABEL);
|
55
|
|
56
|
}
|
57
|
|
58
|
/**
|
59
|
* {@inheritDoc}
|
60
|
*/
|
61
|
@Override
|
62
|
protected UpdateResult doUpdateExecute(IProgressMonitor monitor, IAdaptable info) throws Exception {
|
63
|
runMoniteredOperation();
|
64
|
updateNameEditors();
|
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.SetSecundumForSubtreeOperation_SET_SEC_TASK) {
|
84
|
@Override
|
85
|
protected IStatus run(IProgressMonitor monitor) {
|
86
|
if (config instanceof SecundumForSubtreeConfigurator){
|
87
|
updateResult = taxonNodeService.setSecundumForSubtree((SecundumForSubtreeConfigurator)config);
|
88
|
}else{
|
89
|
return Status.CANCEL_STATUS;
|
90
|
}
|
91
|
updateNameEditors();
|
92
|
return Status.OK_STATUS;
|
93
|
|
94
|
}
|
95
|
};
|
96
|
return job;
|
97
|
}
|
98
|
|
99
|
|
100
|
public void runMoniteredOperation() {
|
101
|
ITaxonNodeService nodeService;
|
102
|
// try {
|
103
|
// nodeService = CdmApplicationState.getService(ITaxonNodeService.class);
|
104
|
|
105
|
final UUID uuid = longRunningTaskService.monitLongRunningTask((SecundumForSubtreeConfigurator)config);
|
106
|
Display.getDefault().asyncExec(new Runnable() {
|
107
|
@Override
|
108
|
public void run() {
|
109
|
AbstractUtility.executeMoniteredOperation("Set Secundum Reference for Subtree: ",
|
110
|
uuid,
|
111
|
1000,
|
112
|
false,
|
113
|
SetSecundumForSubtreeOperation.this,
|
114
|
null);
|
115
|
}
|
116
|
});
|
117
|
// } catch (CdmApplicationException e) {
|
118
|
// // TODO Auto-generated catch block
|
119
|
// e.printStackTrace();
|
120
|
// }
|
121
|
|
122
|
}
|
123
|
|
124
|
|
125
|
|
126
|
/**
|
127
|
* {@inheritDoc}
|
128
|
*/
|
129
|
@Override
|
130
|
public void postOperation(IRemotingProgressMonitor monitor) {
|
131
|
// TODO Auto-generated method stub
|
132
|
|
133
|
}
|
134
|
}
|