package eu.etaxonomy.taxeditor.editor.view.concept.e4;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
import java.util.Map.Entry;
import javax.annotation.PostConstruct;
import eu.etaxonomy.cdm.model.taxon.Taxon;
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
-import eu.etaxonomy.taxeditor.bulkeditor.BulkEditor;
-import eu.etaxonomy.taxeditor.editor.key.AbstractGraphKeyEditor;
+import eu.etaxonomy.taxeditor.editor.key.e4.AbstractGraphKeyEditor;
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
-import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4;
import eu.etaxonomy.taxeditor.editor.view.concept.ConceptContentProvider;
import eu.etaxonomy.taxeditor.editor.view.concept.ConceptLabelProvider;
import eu.etaxonomy.taxeditor.editor.view.descriptive.e4.FactualDataPartE4;
import eu.etaxonomy.taxeditor.editor.view.media.e4.MediaViewPartE4;
-import eu.etaxonomy.taxeditor.model.AbstractUtility;
import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
-import eu.etaxonomy.taxeditor.model.LineSelection;
-import eu.etaxonomy.taxeditor.view.e4.AbstractCdmEditorPartE4;
+import eu.etaxonomy.taxeditor.view.e4.AbstractCdmEditorPart;
import eu.etaxonomy.taxeditor.view.e4.details.DetailsPartE4;
import eu.etaxonomy.taxeditor.view.e4.supplementaldata.SupplementalDataPartE4;
* @date 21.08.2017
*
*/
-public class ConceptViewPartE4 extends AbstractCdmEditorPartE4
+public class ConceptViewPartE4 extends AbstractCdmEditorPart
implements IPartContentHasDetails, IPartContentHasSupplementalData{
@Override
if(activePart==thisPart){
return;
}
- viewer.getControl().setEnabled(true);
- Object partObject = createPartObject(activePart);
+ if (!viewer.getControl().isDisposed()){
+ viewer.getControl().setEnabled(true);
+ }
+ Object partObject = getPartObject(activePart);
+ IStructuredSelection structuredSelection = createSelection(selection);
if (partObject instanceof DetailsPartE4 || partObject instanceof SupplementalDataPartE4
|| partObject instanceof FactualDataPartE4|| partObject instanceof MediaViewPartE4) {
// description selected in this view
return;
}
- else if(partObject instanceof BulkEditor && selection instanceof LineSelection){
- if(((LineSelection) selection).getFirstElement() instanceof Taxon){
- showViewer((LineSelection) selection, activePart, viewer);
- }
- else{
- showEmptyPage();
- }
- return;
- }
else if(partObject instanceof AbstractGraphKeyEditor){
showEmptyPage();
}
- else if(partObject instanceof TaxonNameEditorE4){
- Taxon taxon = ((TaxonNameEditorE4) partObject).getTaxon();
- if(taxon!=null){
- showViewer(new StructuredSelection(taxon), activePart, viewer);
- }
+ else if(selection!=null){
+ showViewer(structuredSelection, activePart, viewer);
}
else {
showEmptyPage();
viewer = conceptViewer;
// Propagate selection from viewer
- selectionChangedListener = (event -> selService.setSelection(AbstractUtility.getElementsFromSelectionChangedEvent(event)));
+ selectionChangedListener = (event -> selService.setSelection(viewer.getSelection()));
viewer.addSelectionChangedListener(selectionChangedListener);
//create context menu
@Override
public ISelection getSelection() {
ISelection selection = super.getSelection();
+ List<TaxonRelationship> relationships = new ArrayList<>();
if(selection instanceof IStructuredSelection && !selection.isEmpty()){
- Object firstElement = ((IStructuredSelection) selection).getFirstElement();
- TaxonRelationship taxonRelationship = ((Entry<TaxonRelationship, Taxon>)firstElement).getKey();
- return new StructuredSelection(taxonRelationship);
-
+ for(Iterator iter = ((IStructuredSelection) selection).iterator();iter.hasNext();){
+ Object object = iter.next();
+ relationships.add(((Entry<TaxonRelationship, Taxon>)object).getKey());
+ }
+ return new StructuredSelection(relationships);
}
return selection;
}