Project

General

Profile

« Previous | Next » 

Revision b529af04

Added by Katja Luther almost 4 years ago

fix #8662: adapt canExecute to show remove taxon only when top level node is selected

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/handler/DescriptiveDataSetRemoveTaxonHandler.java
9 9
import org.eclipse.e4.ui.model.application.ui.menu.MMenuItem;
10 10
import org.eclipse.e4.ui.services.IServiceConstants;
11 11
import org.eclipse.jface.viewers.IStructuredSelection;
12
import org.eclipse.jface.viewers.TreeSelection;
13
import org.eclipse.jface.viewers.TreeViewer;
12 14

  
15
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
13 16
import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.DescriptiveDataSetEditor;
14 17

  
15 18
public class DescriptiveDataSetRemoveTaxonHandler {
......
25 28
	        @Named(IServiceConstants.ACTIVE_PART)MPart activePart,
26 29
	        MMenuItem menuItem) {
27 30
	    boolean canExecute = false;
28
	    canExecute = !selection.isEmpty() && activePart.getObject() instanceof DescriptiveDataSetEditor;
29
		menuItem.setVisible(canExecute);
31
	    TreeSelection sel= ((TreeViewer)((DescriptiveDataSetEditor)activePart.getObject()).getTaxonTreeViewer()).getSelection() instanceof TreeSelection ?(TreeSelection)((TreeViewer)((DescriptiveDataSetEditor)activePart.getObject()).getTaxonTreeViewer()).getSelection(): null;
32
	    canExecute = !selection.isEmpty() && activePart.getObject() instanceof DescriptiveDataSetEditor && sel != null && (sel.getFirstElement() instanceof TaxonNode );
33
  		menuItem.setVisible(canExecute);
30 34
		return canExecute;
31 35
	}
32 36

  

Also available in: Unified diff