fix #5800: remove taxonomically included from menu
[taxeditor.git] / eu.etaxonomy.taxeditor.editor / src / main / java / eu / etaxonomy / taxeditor / editor / view / concept / handler / AbstractDynamicConceptRelationMenu.java
index a651461cf2ebaa5c04eface5045fa6efea83f119..228705c8648acc0bd2569ec1e6525861a402f6d4 100644 (file)
@@ -1,5 +1,5 @@
 /**
- * 
+ *
  */
 package eu.etaxonomy.taxeditor.editor.view.concept.handler;
 
@@ -11,9 +11,9 @@ import org.eclipse.swt.widgets.Menu;
 import org.eclipse.swt.widgets.MenuItem;
 import org.eclipse.ui.handlers.IHandlerService;
 
-import eu.etaxonomy.taxeditor.editor.EditorUtil;
+import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
 import eu.etaxonomy.taxeditor.editor.internal.TaxeditorEditorPlugin;
-import eu.etaxonomy.taxeditor.model.TaxonRelationshipTypeInverseContainer;
+import eu.etaxonomy.taxeditor.model.MessagingUtils;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 
 /**
@@ -24,7 +24,7 @@ import eu.etaxonomy.taxeditor.store.CdmStore;
  * @version 1.0
  */
 public abstract class AbstractDynamicConceptRelationMenu extends ContributionItem {
-       
+
        /*
         * (non-Javadoc)
         * @see org.eclipse.jface.action.ContributionItem#fill(org.eclipse.swt.widgets.Menu, int)
@@ -33,7 +33,7 @@ public abstract class AbstractDynamicConceptRelationMenu extends ContributionIte
        @Override
        public void fill(Menu menu, int index){
                final IHandlerService handlerService = (IHandlerService) TaxeditorEditorPlugin.getDefault().getWorkbench().getService(IHandlerService.class);
-               
+               /*
                for(final TaxonRelationshipTypeInverseContainer container : CdmStore.getTermManager().getPreferredTerms(TaxonRelationshipTypeInverseContainer.class)){
                        MenuItem menuItem = new MenuItem(menu, -1);
                        menuItem.setText(container.getTitleCache());
@@ -50,11 +50,34 @@ public abstract class AbstractDynamicConceptRelationMenu extends ContributionIte
                                        } catch (Exception e) {
                                                EditorUtil.error(getClass(), "Error executing command", e);
                                        }
-                               }                               
+                               }
                        });
+               */
+               for(final TaxonRelationshipType taxonRelationshipType: CdmStore.getTermManager().getPreferredTerms(TaxonRelationshipType.class)){
+                   if (!taxonRelationshipType.equals(TaxonRelationshipType.TAXONOMICALLY_INCLUDED_IN())){
+                       MenuItem menuItem = new MenuItem(menu, -1);
+                       menuItem.setText(taxonRelationshipType.getTitleCache());
+                       menuItem.setData(taxonRelationshipType);
+                       menuItem.addSelectionListener(new SelectionListener(){
+
+                               @Override
+                public void widgetDefaultSelected(SelectionEvent e) {}
+
+                               @Override
+                public void widgetSelected(SelectionEvent ev) {
+                                       Event event = new Event();
+                                       event.data = taxonRelationshipType;
+                                       try {
+                                               handlerService.executeCommand(getCommandName(), event);
+                                       } catch (Exception e) {
+                                               MessagingUtils.error(getClass(), "Error executing command", e);
+                                       }
+                               }
+                       });
+                   }
                }
        }
-       
+
        /**
         * <p>getCommandName</p>
         *