Revision bc073c98
Added by Cherian Mathew over 8 years ago
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/handler/ConvertTeam2PersonHandler.java | ||
---|---|---|
20 | 20 |
import org.eclipse.ui.handlers.HandlerUtil; |
21 | 21 |
import org.eclipse.ui.texteditor.IDocumentProvider; |
22 | 22 |
|
23 |
import eu.etaxonomy.cdm.api.service.AgentServiceImpl; |
|
24 | 23 |
import eu.etaxonomy.cdm.api.service.IAgentService; |
25 | 24 |
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper; |
26 |
import eu.etaxonomy.cdm.model.agent.AgentBase; |
|
27 | 25 |
import eu.etaxonomy.cdm.model.agent.Person; |
28 | 26 |
import eu.etaxonomy.cdm.model.agent.Team; |
29 | 27 |
import eu.etaxonomy.cdm.strategy.merge.MergeException; |
... | ... | |
47 | 45 |
@Override |
48 | 46 |
public Person execute(ExecutionEvent event) throws ExecutionException { |
49 | 47 |
ISelection selection = HandlerUtil.getCurrentSelection(event); |
50 |
|
|
48 |
|
|
51 | 49 |
IEditorPart editor = HandlerUtil.getActiveEditor(event); |
52 |
|
|
50 |
|
|
53 | 51 |
IEditorInput input = editor.getEditorInput(); |
54 | 52 |
if (editor.isDirty()){ |
55 | 53 |
boolean proceed = MessageDialog.openQuestion(null, |
... | ... | |
61 | 59 |
} |
62 | 60 |
} |
63 | 61 |
if((input instanceof IEntityPersistenceService) && (selection instanceof IStructuredSelection)){ |
64 |
|
|
65 |
|
|
62 |
|
|
63 |
|
|
66 | 64 |
IDocumentProvider provider = ((BulkEditor) editor).getDocumentProvider(); |
67 |
LineAnnotationModel model =
|
|
65 |
LineAnnotationModel model = |
|
68 | 66 |
(LineAnnotationModel) provider.getAnnotationModel(input); |
69 |
|
|
70 |
|
|
67 |
|
|
68 |
|
|
71 | 69 |
IStructuredSelection structuredSelection = (IStructuredSelection) selection; |
72 |
|
|
70 |
|
|
73 | 71 |
IEntityPersistenceService persistenceService = (IEntityPersistenceService) input; |
74 |
|
|
72 |
|
|
75 | 73 |
Person person ; |
76 | 74 |
for(Object object : structuredSelection.toList()){ |
77 | 75 |
LineAnnotation annotation = (LineAnnotation) model.getAnnotation(object); |
... | ... | |
79 | 77 |
if (object instanceof Team){ |
80 | 78 |
Team team = HibernateProxyHelper.deproxy(object, Team.class); |
81 | 79 |
try { |
82 |
person = CdmStore.getService(IAgentService.class).convertTeam2Person(team); |
|
80 |
person = CdmStore.getService(IAgentService.class).convertTeam2Person(team.getUuid());
|
|
83 | 81 |
} catch (IllegalArgumentException e) { |
84 | 82 |
MessagingUtils.informationDialog("Can not convert Team to Person", e.getMessage()); |
85 | 83 |
} catch (MergeException e) { |
... | ... | |
88 | 86 |
}else{ |
89 | 87 |
MessagingUtils.informationDialog("Can not convert Team to Person", "convertTeam2Person can only be called on a team."); |
90 | 88 |
} |
91 |
|
|
89 |
|
|
92 | 90 |
if (person != null){ |
93 | 91 |
((BulkEditor) editor).removeAnnotatedLine(annotation); |
94 | 92 |
((BulkEditor) editor).createAnnotatedLine(person); |
Also available in: Unified diff
#5268 Use convert methods which use uuids