Revision eaff1338
Added by Patrick Plitzner over 6 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/e4/handler/DeleteConceptRelationHandlerE4.java | ||
---|---|---|
24 | 24 |
import org.eclipse.jface.viewers.ISelection; |
25 | 25 |
|
26 | 26 |
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship; |
27 |
import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor; |
|
28 |
import eu.etaxonomy.taxeditor.editor.Page; |
|
29 |
import eu.etaxonomy.taxeditor.editor.name.TaxonNameEditor; |
|
27 |
import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4; |
|
30 | 28 |
import eu.etaxonomy.taxeditor.editor.view.concept.e4.ConceptViewPartE4; |
31 | 29 |
import eu.etaxonomy.taxeditor.editor.view.concept.operation.DeleteConceptRelationOperation; |
32 | 30 |
import eu.etaxonomy.taxeditor.model.AbstractUtility; |
... | ... | |
45 | 43 |
public void execute(@Named(IServiceConstants.ACTIVE_PART) MPart activePart, |
46 | 44 |
@Optional@Named(IServiceConstants.ACTIVE_SELECTION) Object selection, MMenuItem menuItem) { |
47 | 45 |
|
48 |
TaxonNameEditor editor = null; |
|
46 |
TaxonNameEditorE4 editor = null;
|
|
49 | 47 |
|
50 | 48 |
ConceptViewPartE4 conceptView = (ConceptViewPartE4) activePart.getObject(); |
51 | 49 |
|
52 | 50 |
Object e4WrappedPart = WorkbenchUtility.getE4WrappedPart(conceptView.getSelectionProvidingPart()); |
53 |
if(e4WrappedPart instanceof MultiPageTaxonEditor){ |
|
54 |
editor = (TaxonNameEditor) ((MultiPageTaxonEditor) e4WrappedPart).getPage(Page.NAME); |
|
55 |
} |
|
51 |
if(e4WrappedPart instanceof TaxonNameEditorE4){ |
|
52 |
editor = (TaxonNameEditorE4) e4WrappedPart; |
|
56 | 53 |
|
57 |
Set<TaxonRelationship> relations = new HashSet<TaxonRelationship>(); |
|
54 |
Set<TaxonRelationship> relations = new HashSet<TaxonRelationship>();
|
|
58 | 55 |
|
59 | 56 |
|
60 |
// FIXME E4 multiple selection |
|
61 |
// while (iterator.hasNext()){ |
|
62 |
if(selection instanceof TaxonRelationship){ |
|
63 |
relations.add((TaxonRelationship) selection); |
|
64 |
} |
|
65 |
// } |
|
57 |
// FIXME E4 multiple selection
|
|
58 |
// while (iterator.hasNext()){
|
|
59 |
if(selection instanceof TaxonRelationship){
|
|
60 |
relations.add((TaxonRelationship) selection);
|
|
61 |
}
|
|
62 |
// }
|
|
66 | 63 |
|
67 |
//editor should not be null because this is already checked in canExecute |
|
68 |
AbstractPostOperation operation = new DeleteConceptRelationOperation(menuItem.getLocalizedLabel(), |
|
69 |
editor.getUndoContext(), editor.getTaxon(), relations, conceptView); |
|
70 |
AbstractUtility.executeOperation(operation); |
|
64 |
//editor should not be null because this is already checked in canExecute |
|
65 |
AbstractPostOperation operation = new DeleteConceptRelationOperation(menuItem.getLocalizedLabel(), |
|
66 |
editor.getUndoContext(), editor.getTaxon(), relations, conceptView); |
|
67 |
AbstractUtility.executeOperation(operation); |
|
68 |
} |
|
71 | 69 |
} |
72 | 70 |
|
73 | 71 |
@CanExecute |
... | ... | |
77 | 75 |
ConceptViewPartE4 conceptView = (ConceptViewPartE4) activePart.getObject(); |
78 | 76 |
|
79 | 77 |
Object e4WrappedPart = WorkbenchUtility.getE4WrappedPart(conceptView.getSelectionProvidingPart()); |
80 |
if(e4WrappedPart instanceof MultiPageTaxonEditor){
|
|
78 |
if(e4WrappedPart instanceof TaxonNameEditorE4){
|
|
81 | 79 |
ISelection selection = conceptView.getViewer().getSelection(); |
82 | 80 |
canExecute = selection!=null && !selection.isEmpty(); |
83 | 81 |
menuItem.setVisible(canExecute); |
Also available in: Unified diff
ref #6595 refactor selection handling to migrated name editor