Revision 65fe78ea
Added by Katja Luther about 7 years ago
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/SetSecReferenceForSubtreeHandler.java | ||
---|---|---|
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.taxeditor.navigation.navigator.handler; |
10 | 10 |
|
11 |
import java.util.ArrayList; |
|
12 |
import java.util.List; |
|
13 |
import java.util.UUID; |
|
14 |
|
|
15 | 11 |
import org.apache.log4j.Logger; |
16 | 12 |
import org.eclipse.core.commands.ExecutionEvent; |
17 | 13 |
import org.eclipse.core.commands.operations.AbstractOperation; |
... | ... | |
22 | 18 |
import org.eclipse.jface.wizard.WizardDialog; |
23 | 19 |
import org.eclipse.ui.handlers.HandlerUtil; |
24 | 20 |
|
25 |
import eu.etaxonomy.cdm.api.service.config.SetSecundumForSubtreeConfigurator; |
|
21 |
import eu.etaxonomy.cdm.io.common.SetSecundumForSubtreeConfigurator; |
|
22 |
import eu.etaxonomy.cdm.model.taxon.Classification; |
|
26 | 23 |
import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode; |
27 | 24 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode; |
28 | 25 |
import eu.etaxonomy.taxeditor.navigation.navigator.TaxonNavigatorLabels; |
... | ... | |
70 | 67 |
// check that selected object is a taxon node |
71 | 68 |
Object obj = selection.iterator().next(); |
72 | 69 |
if(obj instanceof ITaxonTreeNode) { |
73 |
taxonNode = (ITaxonTreeNode)obj; |
|
74 |
} else { |
|
70 |
if (obj instanceof Classification){ |
|
71 |
taxonNode = ((Classification)obj).getRootNode(); |
|
72 |
}else{ |
|
73 |
taxonNode = (ITaxonTreeNode)obj; |
|
74 |
} |
|
75 |
} else{ |
|
75 | 76 |
return new Status(IStatus.ERROR, |
76 | 77 |
"unknown", //$NON-NLS-1$ |
77 | 78 |
TaxonNavigatorLabels.SELECTED_OBJECT_NOT_TREE_NODE_MESSAGE); |
... | ... | |
110 | 111 |
*/ |
111 | 112 |
@Override |
112 | 113 |
public AbstractOperation prepareOperation(ExecutionEvent event) { |
113 |
List<UUID> excludeTaxa = new ArrayList<UUID>(); |
|
114 |
excludeTaxa.add(((TaxonNode)taxonNode).getTaxon().getUuid()); |
|
115 |
|
|
116 |
|
|
117 |
|
|
118 |
|
|
119 |
SetSecundumForSubtreeOperation operation = |
|
114 |
SetSecundumForSubtreeOperation operation = |
|
120 | 115 |
new SetSecundumForSubtreeOperation(event.getTrigger(), |
121 | 116 |
false, |
122 | 117 |
taxonNode.getUuid(), |
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 org.apache.log4j.Logger; |
|
14 |
import org.eclipse.core.runtime.Assert; |
|
13 | 15 |
import org.eclipse.core.runtime.IAdaptable; |
14 | 16 |
import org.eclipse.core.runtime.IProgressMonitor; |
17 |
import org.eclipse.core.runtime.IStatus; |
|
18 |
import org.eclipse.core.runtime.Status; |
|
19 |
import org.eclipse.core.runtime.jobs.Job; |
|
20 |
import org.eclipse.swt.widgets.Display; |
|
21 |
import org.eclipse.ui.progress.IProgressConstants; |
|
15 | 22 |
|
16 | 23 |
import eu.etaxonomy.cdm.api.application.CdmApplicationState; |
17 | 24 |
import eu.etaxonomy.cdm.api.application.CdmChangeEvent.Action; |
18 |
import eu.etaxonomy.cdm.api.service.ITaxonNodeService; |
|
19 | 25 |
import eu.etaxonomy.cdm.api.service.UpdateResult; |
20 |
import eu.etaxonomy.cdm.api.service.config.SetSecundumForSubtreeConfigurator; |
|
26 |
import eu.etaxonomy.cdm.common.monitor.IRemotingProgressMonitor; |
|
27 |
import eu.etaxonomy.cdm.io.common.SetSecundumForSubtreeConfigurator; |
|
28 |
import eu.etaxonomy.cdm.io.service.IIOService; |
|
29 |
import eu.etaxonomy.taxeditor.model.AbstractUtility; |
|
21 | 30 |
import eu.etaxonomy.taxeditor.navigation.l10n.Messages; |
31 |
import eu.etaxonomy.taxeditor.operation.IPostMoniteredOperationEnabled; |
|
22 | 32 |
import eu.etaxonomy.taxeditor.operation.RemotingCdmUpdateOperation; |
23 | 33 |
|
24 | 34 |
/** |
... | ... | |
26 | 36 |
* @date 10.02.2017 |
27 | 37 |
* |
28 | 38 |
*/ |
29 |
public class SetSecundumForSubtreeOperation extends RemotingCdmUpdateOperation{ |
|
39 |
public class SetSecundumForSubtreeOperation extends RemotingCdmUpdateOperation implements IPostMoniteredOperationEnabled{
|
|
30 | 40 |
|
31 | 41 |
private final static String LABEL = Messages.SetSecundumForSubtreeOperation_CHANGE_SEC_OP; |
32 |
|
|
42 |
private static final Logger logger = Logger |
|
43 |
.getLogger(SetSecundumForSubtreeOperation.class); |
|
33 | 44 |
UUID parentUuid; |
34 | 45 |
SetSecundumForSubtreeConfigurator config; |
46 |
UpdateResult updateResult = new UpdateResult(); |
|
35 | 47 |
|
36 | 48 |
/** |
37 | 49 |
* @param label |
... | ... | |
53 | 65 |
*/ |
54 | 66 |
@Override |
55 | 67 |
protected UpdateResult doUpdateExecute(IProgressMonitor monitor, IAdaptable info) throws Exception { |
56 |
monitor.beginTask(Messages.SetSecundumForSubtreeOperation_SET_SEC_TASK, 10); |
|
57 |
UpdateResult result = CdmApplicationState.getService(ITaxonNodeService.class).setSecundumForSubtree(config, null); |
|
58 |
monitor.done(); |
|
59 |
return result; |
|
68 |
Job job = createJob(monitor); |
|
69 |
// configure the job |
|
70 |
job.setProperty(IProgressConstants.KEEP_PROPERTY, true); |
|
71 |
job.setUser(true); |
|
72 |
// schedule job |
|
73 |
job.schedule(); |
|
74 |
|
|
75 |
return updateResult; |
|
76 |
|
|
77 |
|
|
60 | 78 |
} |
61 | 79 |
|
62 |
} |
|
80 |
|
|
81 |
private Job createJob(IProgressMonitor monitor){ |
|
82 |
Assert.isNotNull(config, "Configuration may not be null"); |
|
83 |
|
|
84 |
final Display display = Display.getDefault(); |
|
85 |
|
|
86 |
Job job = new Job(Messages.SetSecundumForSubtreeOperation_SET_SEC_TASK) { |
|
87 |
|
|
88 |
|
|
89 |
@Override |
|
90 |
protected IStatus run(IProgressMonitor monitor) { |
|
91 |
IIOService ioService = CdmApplicationState.getIOService(); |
|
92 |
final UUID uuid = ioService.monitUpdateData(config); |
|
93 |
Display.getDefault().asyncExec(new Runnable() { |
|
94 |
@Override |
|
95 |
public void run() { |
|
96 |
AbstractUtility.executeMoniteredOperation("Update: " + config.getClass().getSimpleName(), |
|
97 |
uuid, |
|
98 |
1000, |
|
99 |
false, |
|
100 |
SetSecundumForSubtreeOperation.this, |
|
101 |
null); |
|
102 |
} |
|
103 |
}); |
|
104 |
return Status.OK_STATUS; |
|
105 |
|
|
106 |
} |
|
107 |
}; |
|
108 |
return job; |
|
109 |
} |
|
110 |
|
|
111 |
|
|
112 |
|
|
113 |
|
|
114 |
|
|
115 |
/** |
|
116 |
* {@inheritDoc} |
|
117 |
*/ |
|
118 |
@Override |
|
119 |
public void postOperation(IRemotingProgressMonitor monitor) { |
|
120 |
// TODO Auto-generated method stub |
|
121 |
|
|
122 |
} |
|
123 |
} |
Also available in: Unified diff
minor for setSecundumForSubtree