Revision 5cfc8708
Added by Patrick Plitzner over 6 years ago
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/handler/ConvertPerson2TeamHandlerE4.java | ||
---|---|---|
10 | 10 |
|
11 | 11 |
import javax.inject.Named; |
12 | 12 |
|
13 |
import org.eclipse.e4.core.di.annotations.CanExecute; |
|
13 | 14 |
import org.eclipse.e4.core.di.annotations.Execute; |
14 | 15 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
16 |
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem; |
|
15 | 17 |
import org.eclipse.e4.ui.services.IServiceConstants; |
16 | 18 |
import org.eclipse.jface.dialogs.MessageDialog; |
17 | 19 |
|
... | ... | |
20 | 22 |
import eu.etaxonomy.cdm.model.agent.Person; |
21 | 23 |
import eu.etaxonomy.cdm.model.agent.Team; |
22 | 24 |
import eu.etaxonomy.cdm.strategy.merge.MergeException; |
25 |
import eu.etaxonomy.taxeditor.bulkeditor.e4.AnnotatedTableItem; |
|
23 | 26 |
import eu.etaxonomy.taxeditor.bulkeditor.e4.BulkEditorE4; |
24 | 27 |
import eu.etaxonomy.taxeditor.bulkeditor.internal.TaxeditorBulkeditorPlugin; |
25 | 28 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
... | ... | |
34 | 37 |
|
35 | 38 |
|
36 | 39 |
@Execute |
37 |
public void execute(@Named(IServiceConstants.ACTIVE_SELECTION)Person person,
|
|
40 |
public void execute(@Named(IServiceConstants.ACTIVE_SELECTION)AnnotatedTableItem item,
|
|
38 | 41 |
@Named(IServiceConstants.ACTIVE_PART)MPart activePart) { |
39 | 42 |
|
40 | 43 |
BulkEditorE4 editor = (BulkEditorE4) activePart.getObject(); |
... | ... | |
52 | 55 |
Team team =null; |
53 | 56 |
UpdateResult result = null; |
54 | 57 |
try { |
55 |
result = CdmStore.getService(IAgentService.class).convertPerson2Team(person.getUuid());
|
|
58 |
result = CdmStore.getService(IAgentService.class).convertPerson2Team(item.getElement().getUuid());
|
|
56 | 59 |
} catch (IllegalArgumentException e) { |
57 | 60 |
MessagingUtils.errorDialog("Can not convert Person into a Team", null, e.getLocalizedMessage(), TaxeditorBulkeditorPlugin.PLUGIN_ID,e, true); |
58 | 61 |
} catch (MergeException e) { |
... | ... | |
66 | 69 |
} |
67 | 70 |
} |
68 | 71 |
|
72 |
@CanExecute |
|
73 |
public boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)AnnotatedTableItem selection, |
|
74 |
@Named(IServiceConstants.ACTIVE_PART)MPart activePart, |
|
75 |
MHandledMenuItem menuItem){ |
|
76 |
boolean canExecute = false; |
|
77 |
canExecute = ((BulkEditorE4)activePart.getObject()).getEditorInput().isConvertingEnabled() && selection.getElement() instanceof Person; |
|
78 |
menuItem.setVisible(canExecute); |
|
79 |
return canExecute; |
|
80 |
} |
|
81 |
|
|
69 | 82 |
} |
Also available in: Unified diff
ref #6932 Migrate bulk editor handlers and add annotation merge support