Revision a1ab28ed
Added by Katja Luther over 6 years ago
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/handler/SetPublishFlagForSubtreeHandlerE4.java | ||
---|---|---|
9 | 9 |
*/ |
10 | 10 |
package eu.etaxonomy.taxeditor.navigation.navigator.e4.handler; |
11 | 11 |
|
12 |
import java.util.UUID; |
|
13 |
|
|
12 | 14 |
import javax.inject.Named; |
13 | 15 |
|
14 | 16 |
import org.eclipse.core.commands.operations.AbstractOperation; |
15 | 17 |
import org.eclipse.core.runtime.IStatus; |
16 | 18 |
import org.eclipse.core.runtime.Status; |
17 | 19 |
import org.eclipse.e4.core.di.annotations.CanExecute; |
20 |
import org.eclipse.e4.ui.model.application.MApplication; |
|
18 | 21 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
19 | 22 |
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem; |
20 | 23 |
import org.eclipse.e4.ui.services.IServiceConstants; |
24 |
import org.eclipse.e4.ui.workbench.modeling.EPartService; |
|
21 | 25 |
import org.eclipse.jface.viewers.IStructuredSelection; |
22 | 26 |
import org.eclipse.jface.viewers.TreeSelection; |
23 | 27 |
import org.eclipse.jface.window.Window; |
... | ... | |
118 | 122 |
new SetPublishForSubtreeOperation(getTrigger(), |
119 | 123 |
false, |
120 | 124 |
taxonNode.getUuid(), |
125 |
partService, |
|
126 |
activePart, |
|
127 |
application, |
|
121 | 128 |
configurator); |
122 | 129 |
|
123 | 130 |
return operation; |
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/SetPublishForSubtreeOperation.java | ||
---|---|---|
18 | 18 |
import org.eclipse.core.runtime.IStatus; |
19 | 19 |
import org.eclipse.core.runtime.Status; |
20 | 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; |
|
21 | 24 |
import org.eclipse.swt.widgets.Display; |
22 | 25 |
import org.eclipse.ui.progress.IProgressConstants; |
23 | 26 |
|
... | ... | |
26 | 29 |
import eu.etaxonomy.cdm.api.application.CdmChangeEvent.Action; |
27 | 30 |
import eu.etaxonomy.cdm.api.service.ITaxonNodeService; |
28 | 31 |
import eu.etaxonomy.cdm.api.service.UpdateResult; |
32 |
import eu.etaxonomy.cdm.api.service.config.ForSubtreeConfiguratorBase; |
|
29 | 33 |
import eu.etaxonomy.cdm.api.service.config.PublishForSubtreeConfigurator; |
30 | 34 |
import eu.etaxonomy.taxeditor.navigation.l10n.Messages; |
31 | 35 |
import eu.etaxonomy.taxeditor.operation.RemotingCdmUpdateOperation; |
... | ... | |
35 | 39 |
* @date 11.10.2017 |
36 | 40 |
* |
37 | 41 |
*/ |
38 |
public class SetPublishForSubtreeOperation extends RemotingCdmUpdateOperation {
|
|
42 |
public class SetPublishForSubtreeOperation extends UpdateSubtreeOperation {
|
|
39 | 43 |
|
40 | 44 |
private final static String LABEL = Messages.SetPublishForSubtreeOperation_CHANGE_PUBLISH_OP; |
41 | 45 |
private static final Logger logger = Logger |
42 | 46 |
.getLogger(SetPublishForSubtreeOperation.class); |
43 |
UUID parentUuid; |
|
44 |
PublishForSubtreeConfigurator config; |
|
47 |
|
|
45 | 48 |
|
46 | 49 |
/** |
47 | 50 |
* @param label |
... | ... | |
52 | 55 |
public SetPublishForSubtreeOperation(Object source, |
53 | 56 |
boolean async, |
54 | 57 |
UUID taxonNodeUuid, |
58 |
EPartService partService, |
|
59 |
MPart activePart, |
|
60 |
MApplication application, |
|
55 | 61 |
PublishForSubtreeConfigurator config) { |
56 |
super(LABEL, Action.Update, source, async); |
|
57 |
parentUuid = taxonNodeUuid; |
|
58 |
this.config = config; |
|
59 |
this.updateResult = new UpdateResult(); |
|
62 |
super(source, async, taxonNodeUuid, partService, activePart, application, config, LABEL); |
|
63 |
|
|
60 | 64 |
} |
61 |
|
|
62 |
|
|
63 |
// /* (non-Javadoc) |
|
64 |
// * @see eu.etaxonomy.taxeditor.operation.RemotingCdmUpdateOperation#doUpdateExecute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) |
|
65 |
// */ |
|
66 |
// @Override |
|
67 |
// protected UpdateResult doUpdateExecute(IProgressMonitor monitor, IAdaptable info) throws Exception { |
|
68 |
// ITaxonNodeService taxonService = CdmApplicationState.getService(ITaxonNodeService.class); |
|
69 |
//// taxonService.setSecundumForSubtree(config.getSubtreeUuid(), config.getNewSecundum(), config.isIncludeAcceptedTaxa(), config.isIncludeSynonyms(), config.isOverwriteExistingAccepted(), config.isOverwriteExistingSynonyms(), config.isIncludeSharedTaxa(), config.isEmptySecundumDetail(), null); |
|
70 |
// eu.etaxonomy.cdm.common.monitor.IProgressMonitor cdmMonitor = CdmProgressMonitorAdapter.CreateMonitor(monitor); |
|
71 |
// updateResult = taxonService.setPublishForSubtree(config.getSubtreeUuid(), config.isPublish(), config.isIncludeAcceptedTaxa(), config.isIncludeSynonyms(), config.isIncludeSharedTaxa(), null); |
|
72 |
// return updateResult; |
|
73 |
// } |
|
74 |
|
|
75 |
@Override |
|
65 |
@Override |
|
76 | 66 |
protected UpdateResult doUpdateExecute(IProgressMonitor monitor, IAdaptable info) throws Exception { |
77 | 67 |
// runMoniteredOperation(); |
78 | 68 |
|
... | ... | |
94 | 84 |
|
95 | 85 |
final Display display = Display.getDefault(); |
96 | 86 |
|
97 |
Job job = new Job(Messages.SetSecundumForSubtreeOperation_SET_SEC_TASK) {
|
|
87 |
Job job = new Job(Messages.SetPublishFlagForSubtreeOperation_SET_SEC_TASK) {
|
|
98 | 88 |
|
99 | 89 |
|
100 | 90 |
@Override |
... | ... | |
102 | 92 |
|
103 | 93 |
try { |
104 | 94 |
ITaxonNodeService taxonService = CdmApplicationState.getService(ITaxonNodeService.class); |
105 |
updateResult = taxonService.setPublishForSubtree(config.getSubtreeUuid(), config.isPublish(), config.isIncludeAcceptedTaxa(), config.isIncludeSynonyms(), config.isIncludeSharedTaxa(), null); |
|
106 |
|
|
95 |
|
|
96 |
if (config instanceof PublishForSubtreeConfigurator){ |
|
97 |
updateResult = taxonService.setPublishForSubtree(config.getSubtreeUuid(), ((PublishForSubtreeConfigurator)config).isPublish(), config.isIncludeAcceptedTaxa(), config.isIncludeSynonyms(), config.isIncludeSharedTaxa(), null); |
|
98 |
}else { |
|
99 |
return Status.CANCEL_STATUS; |
|
100 |
} |
|
101 |
updateNameEditors(); |
|
107 | 102 |
} catch (CdmApplicationException e) { |
108 | 103 |
// TODO Auto-generated catch block |
109 | 104 |
e.printStackTrace(); |
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/SetSecundumForSubtreeOperation.java | ||
---|---|---|
33 | 33 |
import eu.etaxonomy.cdm.api.application.CdmChangeEvent.Action; |
34 | 34 |
import eu.etaxonomy.cdm.api.service.ITaxonNodeService; |
35 | 35 |
import eu.etaxonomy.cdm.api.service.UpdateResult; |
36 |
import eu.etaxonomy.cdm.api.service.config.PublishForSubtreeConfigurator; |
|
36 | 37 |
import eu.etaxonomy.cdm.api.service.config.SecundumForSubtreeConfigurator; |
37 | 38 |
import eu.etaxonomy.cdm.common.monitor.IRemotingProgressMonitor; |
38 | 39 |
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper; |
... | ... | |
47 | 48 |
import eu.etaxonomy.taxeditor.navigation.l10n.Messages; |
48 | 49 |
import eu.etaxonomy.taxeditor.operation.IPostMoniteredOperationEnabled; |
49 | 50 |
import eu.etaxonomy.taxeditor.operation.RemotingCdmUpdateOperation; |
51 |
import eu.etaxonomy.taxeditor.ui.dialog.configurator.SetSecundumForSubtreeConfigurationWizard; |
|
50 | 52 |
|
51 | 53 |
/** |
52 | 54 |
* @author k.luther |
53 | 55 |
* @date 10.02.2017 |
54 | 56 |
* |
55 | 57 |
*/ |
56 |
public class SetSecundumForSubtreeOperation extends RemotingCdmUpdateOperation implements IPostMoniteredOperationEnabled{
|
|
57 |
|
|
58 |
private final static String LABEL = Messages.SetSecundumForSubtreeOperation_CHANGE_SEC_OP;
|
|
58 |
public class SetSecundumForSubtreeOperation extends UpdateSubtreeOperation implements IPostMoniteredOperationEnabled{
|
|
59 |
|
|
60 |
private final static String LABEL = Messages.SetSecundumForSubtreeOperation_CHANGE_SEC_OP;
|
|
59 | 61 |
private static final Logger logger = Logger |
60 | 62 |
.getLogger(SetSecundumForSubtreeOperation.class); |
61 |
UUID parentUuid; |
|
62 |
SecundumForSubtreeConfigurator config; |
|
63 |
EPartService partService; |
|
64 |
MPart activePart; |
|
65 |
MApplication application; |
|
66 |
|
|
63 |
|
|
67 | 64 |
@Inject |
68 | 65 |
UISynchronize sync; |
69 | 66 |
|
70 |
/** |
|
71 |
* @param label |
|
72 |
* @param action |
|
73 |
* @param source |
|
74 |
* @param async |
|
75 |
*/ |
|
76 |
public SetSecundumForSubtreeOperation(Object source, |
|
77 |
boolean async, |
|
78 |
UUID taxonNodeUuid, |
|
79 |
EPartService partService, |
|
80 |
MPart activePart, |
|
81 |
MApplication application, |
|
82 |
SecundumForSubtreeConfigurator config) { |
|
83 |
super(LABEL, Action.Update, source, async); |
|
84 |
parentUuid = taxonNodeUuid; |
|
85 |
this.config = config; |
|
86 |
this.updateResult = new UpdateResult(); |
|
87 |
this.partService= partService; |
|
88 |
this.activePart = activePart; |
|
89 |
this.application = application; |
|
90 |
} |
|
91 |
|
|
67 |
|
|
68 |
public SetSecundumForSubtreeOperation(Object source, boolean async, UUID taxonNodeUuid, EPartService partService, |
|
69 |
MPart activePart, MApplication application, SecundumForSubtreeConfigurator config) { |
|
70 |
super(source, async, taxonNodeUuid, partService, activePart, application, config, LABEL); |
|
71 |
|
|
72 |
} |
|
73 |
|
|
92 | 74 |
/** |
93 | 75 |
* {@inheritDoc} |
94 | 76 |
*/ |
... | ... | |
117 | 99 |
Job job = new Job(Messages.SetSecundumForSubtreeOperation_SET_SEC_TASK) { |
118 | 100 |
@Override |
119 | 101 |
protected IStatus run(IProgressMonitor monitor) { |
120 |
|
|
121 |
try { |
|
122 |
ITaxonNodeService taxonNodeService = CdmApplicationState.getService(ITaxonNodeService.class); |
|
123 |
TaxonNode subtreeNode = taxonNodeService.load(config.getSubtreeUuid()); |
|
124 |
updateResult = taxonNodeService.setSecundumForSubtree(config); |
|
125 |
|
|
126 |
for (CdmBase object: updateResult.getUpdatedObjects()){ |
|
127 |
Taxon taxon = null; |
|
128 |
TaxonNode node = null; |
|
129 |
if (object instanceof Taxon){ |
|
130 |
taxon = HibernateProxyHelper.deproxy(object, Taxon.class); |
|
131 |
node = taxon.getTaxonNode(subtreeNode.getClassification()); |
|
132 |
|
|
133 |
}else if (object instanceof Synonym){ |
|
134 |
Synonym syn = HibernateProxyHelper.deproxy(object, Synonym.class); |
|
135 |
taxon = syn.getAcceptedTaxon(); |
|
136 |
node = taxon.getTaxonNode(subtreeNode.getClassification()); |
|
137 |
} |
|
138 |
|
|
139 |
Display.getDefault().asyncExec(new Runnable() { |
|
140 |
public void run() { |
|
141 |
for (MPart part : partService.getParts()){ |
|
142 |
Object object = part.getObject(); |
|
143 |
if (object instanceof TaxonNameEditorE4){ |
|
144 |
Set<TaxonNode> nodes = ((TaxonNameEditorE4)object).getTaxon().getTaxonNodes(); |
|
145 |
for (TaxonNode node: nodes){ |
|
146 |
if (node.treeIndex().startsWith(subtreeNode.treeIndex())){ |
|
147 |
EditorUtil.updateEditor(node, partService, application); |
|
148 |
} |
|
149 |
|
|
150 |
} |
|
151 |
} |
|
152 |
} |
|
153 |
} |
|
154 |
}); |
|
155 |
} |
|
156 |
} catch (CdmApplicationException e) { |
|
157 |
// TODO Auto-generated catch block |
|
158 |
e.printStackTrace(); |
|
102 |
if (config instanceof SecundumForSubtreeConfigurator){ |
|
103 |
updateResult = taxonNodeService.setSecundumForSubtree((SecundumForSubtreeConfigurator)config); |
|
104 |
}else{ |
|
105 |
return Status.CANCEL_STATUS; |
|
159 | 106 |
} |
160 |
return Status.OK_STATUS; |
|
107 |
updateNameEditors(); |
|
108 |
return Status.OK_STATUS; |
|
161 | 109 |
|
162 | 110 |
} |
163 | 111 |
}; |
... | ... | |
170 | 118 |
try { |
171 | 119 |
nodeService = CdmApplicationState.getService(ITaxonNodeService.class); |
172 | 120 |
|
173 |
final UUID uuid = nodeService.monitSetSecundum(config); |
|
121 |
final UUID uuid = nodeService.monitSetSecundum((SecundumForSubtreeConfigurator)config);
|
|
174 | 122 |
Display.getDefault().asyncExec(new Runnable() { |
175 | 123 |
@Override |
176 | 124 |
public void run() { |
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/UpdateSubtreeOperation.java | ||
---|---|---|
1 |
package eu.etaxonomy.taxeditor.navigation.navigator.operation; |
|
2 |
|
|
3 |
import java.util.Set; |
|
4 |
import java.util.UUID; |
|
5 |
|
|
6 |
import org.eclipse.core.runtime.IAdaptable; |
|
7 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
8 |
import org.eclipse.e4.ui.model.application.MApplication; |
|
9 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
|
10 |
import org.eclipse.e4.ui.workbench.modeling.EPartService; |
|
11 |
import org.eclipse.swt.widgets.Display; |
|
12 |
|
|
13 |
import eu.etaxonomy.cdm.api.application.CdmApplicationException; |
|
14 |
import eu.etaxonomy.cdm.api.application.CdmApplicationState; |
|
15 |
import eu.etaxonomy.cdm.api.application.CdmChangeEvent.Action; |
|
16 |
import eu.etaxonomy.cdm.api.service.ITaxonNodeService; |
|
17 |
import eu.etaxonomy.cdm.api.service.UpdateResult; |
|
18 |
import eu.etaxonomy.cdm.api.service.config.ForSubtreeConfiguratorBase; |
|
19 |
import eu.etaxonomy.cdm.api.service.config.PublishForSubtreeConfigurator; |
|
20 |
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper; |
|
21 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
|
22 |
import eu.etaxonomy.cdm.model.taxon.Synonym; |
|
23 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
|
24 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode; |
|
25 |
import eu.etaxonomy.taxeditor.editor.EditorUtil; |
|
26 |
import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4; |
|
27 |
import eu.etaxonomy.taxeditor.navigation.l10n.Messages; |
|
28 |
import eu.etaxonomy.taxeditor.operation.RemotingCdmUpdateOperation; |
|
29 |
|
|
30 |
public abstract class UpdateSubtreeOperation extends RemotingCdmUpdateOperation { |
|
31 |
|
|
32 |
ForSubtreeConfiguratorBase config; |
|
33 |
|
|
34 |
UUID parentUuid; |
|
35 |
EPartService partService; |
|
36 |
MPart activePart; |
|
37 |
MApplication application; |
|
38 |
TaxonNode subtreeNode; |
|
39 |
ITaxonNodeService taxonNodeService; |
|
40 |
|
|
41 |
public UpdateSubtreeOperation(Object source, |
|
42 |
boolean async, |
|
43 |
UUID taxonNodeUuid, |
|
44 |
EPartService partService, |
|
45 |
MPart activePart, |
|
46 |
MApplication application, |
|
47 |
ForSubtreeConfiguratorBase config, |
|
48 |
String label) { |
|
49 |
super(label, Action.Update, source, async); |
|
50 |
parentUuid = taxonNodeUuid; |
|
51 |
this.config = config; |
|
52 |
this.updateResult = new UpdateResult(); |
|
53 |
this.partService= partService; |
|
54 |
this.activePart = activePart; |
|
55 |
this.application = application; |
|
56 |
try { |
|
57 |
taxonNodeService = CdmApplicationState.getService(ITaxonNodeService.class); |
|
58 |
} catch (CdmApplicationException e) { |
|
59 |
// TODO Auto-generated catch block |
|
60 |
e.printStackTrace(); |
|
61 |
} |
|
62 |
subtreeNode = taxonNodeService.load(config.getSubtreeUuid()); |
|
63 |
} |
|
64 |
|
|
65 |
public void updateNameEditors(){ |
|
66 |
for (CdmBase object: updateResult.getUpdatedObjects()){ |
|
67 |
Taxon taxon = null; |
|
68 |
TaxonNode node = null; |
|
69 |
if (object instanceof Taxon){ |
|
70 |
taxon = HibernateProxyHelper.deproxy(object, Taxon.class); |
|
71 |
node = taxon.getTaxonNode(subtreeNode.getClassification()); |
|
72 |
|
|
73 |
}else if (object instanceof Synonym){ |
|
74 |
Synonym syn = HibernateProxyHelper.deproxy(object, Synonym.class); |
|
75 |
taxon = syn.getAcceptedTaxon(); |
|
76 |
node = taxon.getTaxonNode(subtreeNode.getClassification()); |
|
77 |
} |
|
78 |
|
|
79 |
Display.getDefault().asyncExec(new Runnable() { |
|
80 |
public void run() { |
|
81 |
for (MPart part : partService.getParts()){ |
|
82 |
Object object = part.getObject(); |
|
83 |
if (object instanceof TaxonNameEditorE4){ |
|
84 |
Set<TaxonNode> nodes = ((TaxonNameEditorE4)object).getTaxon().getTaxonNodes(); |
|
85 |
for (TaxonNode node: nodes){ |
|
86 |
if (node.treeIndex().startsWith(subtreeNode.treeIndex())){ |
|
87 |
EditorUtil.updateEditor(node, partService, application); |
|
88 |
} |
|
89 |
|
|
90 |
} |
|
91 |
} |
|
92 |
} |
|
93 |
} |
|
94 |
}); |
|
95 |
} |
|
96 |
} |
|
97 |
} |
Also available in: Unified diff
fix #7065: update the nameEditors also after update publish flag