AT: committing changes to the TaxEditor for ethnic group testing and remove the featu...
authora.theys <a.theys@localhost>
Wed, 27 Jun 2012 11:30:05 +0000 (11:30 +0000)
committera.theys <a.theys@localhost>
Wed, 27 Jun 2012 11:30:05 +0000 (11:30 +0000)
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/handler/DynamicFeatureMenu.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/UsesLabelProvider.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/userecords/UseRecordDetailElement.java

index f1194d7857892d60ff4ca42c491bfe19ebb9a8ab..d51bbfe14dfa511135873d2162f9d7d850aff746 100644 (file)
@@ -1,12 +1,12 @@
 // $Id$
 /**
-* Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy 
-* http://www.e-taxonomy.eu
-* 
-* The contents of this file are subject to the Mozilla Public License Version 1.1
-* See LICENSE.TXT at the top of this package for the full license terms.
-*/
+ * Copyright (C) 2007 EDIT
+ * European Distributed Institute of Taxonomy 
+ * http://www.e-taxonomy.eu
+ 
+ * The contents of this file are subject to the Mozilla Public License Version 1.1
+ * See LICENSE.TXT at the top of this package for the full license terms.
+ */
 
 package eu.etaxonomy.taxeditor.editor.view.descriptive.handler;
 
@@ -31,6 +31,7 @@ import eu.etaxonomy.cdm.model.description.FeatureNode;
 import eu.etaxonomy.cdm.model.description.FeatureTree;
 import eu.etaxonomy.cdm.model.description.TaxonDescription;
 import eu.etaxonomy.taxeditor.editor.EditorUtil;
+import eu.etaxonomy.taxeditor.editor.UsageTermCollection;
 import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptiveViewPart;
 import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.CreateDescriptionElementOperation;
 import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
@@ -38,105 +39,128 @@ import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 
 /**
- * <p>DynamicFeatureMenu class.</p>
- *
+ * <p>
+ * DynamicFeatureMenu class.
+ * </p>
+ * 
  * @author n.hoffmann
  * @created 17.04.2009
  * @version 1.0
  */
 public class DynamicFeatureMenu extends CompoundContributionItem {
-       
-       private ISelectionService selectionService = EditorUtil.getActivePart().getSite().getWorkbenchWindow().getSelectionService();
-       private IHandlerService handlerService = (IHandlerService) EditorUtil.getService(IHandlerService.class);
-       
-       /* (non-Javadoc)
-        * @see org.eclipse.ui.actions.CompoundContributionItem#getContributionItems()
+
+       private ISelectionService selectionService = EditorUtil.getActivePart()
+                       .getSite().getWorkbenchWindow().getSelectionService();
+       private IHandlerService handlerService = (IHandlerService) EditorUtil
+                       .getService(IHandlerService.class);
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see
+        * org.eclipse.ui.actions.CompoundContributionItem#getContributionItems()
         */
        /** {@inheritDoc} */
        @Override
        protected IContributionItem[] getContributionItems() {
-               
-               return new IContributionItem[] {
-                               new ContributionItem() {
-                                       public void fill(Menu menu, int index){
-                                                               
-                                               ISelection selection = selectionService.getSelection(DescriptiveViewPart.ID);
-                                               
-                                               if(selection instanceof IStructuredSelection){
-                                                       IStructuredSelection structuredSelection = (IStructuredSelection) selection;
-                                                       Object selectedElement = structuredSelection.getFirstElement();
-                                                       
-                                                       if(selectedElement instanceof TaxonDescription){
-                                                               FeatureTree featureTree = getFeatureTree((TaxonDescription) selectedElement);
-                                                               
-                                                               for(FeatureNode childNode : featureTree.getRootChildren()){
-                                                                       createMenuItem(menu, childNode.getFeature());
-                                                               }
-                                                       }
-                                                       else if(selectedElement instanceof FeatureNodeContainer){
-                                                               FeatureNode featureNode = ((FeatureNodeContainer) selectedElement).getFeatureNode();
-                                                               
-                                                               // add the feature to the menu
-                                                               createMenuItem(menu, featureNode.getFeature());
-                                                               
-                                                               // add possible children to the menu
-                                                               for(FeatureNode childNode : featureNode.getChildren()){
-                                                                       createMenuItem(menu, childNode.getFeature());
-                                                               }
-                                                       }
-                                                       else if(selectedElement instanceof DescriptionElementBase){
-                                                               Feature feature = ((DescriptionElementBase) selectedElement).getFeature();
-                                                               createMenuItem(menu, feature);
+
+               return new IContributionItem[] { new ContributionItem() {
+                       public void fill(Menu menu, int index) {
+
+                               ISelection selection = selectionService
+                                               .getSelection(DescriptiveViewPart.ID);
+
+                               if (selection instanceof IStructuredSelection) {
+                                       IStructuredSelection structuredSelection = (IStructuredSelection) selection;
+                                       Object selectedElement = structuredSelection
+                                                       .getFirstElement();
+
+                                       if (selectedElement instanceof TaxonDescription) {
+                                               FeatureTree featureTree = getFeatureTree((TaxonDescription) selectedElement);
+
+                                               for (FeatureNode childNode : featureTree
+                                                               .getRootChildren()) {
+                                                       if (!(childNode.getFeature().getUuid()
+                                                                       .equals(UsageTermCollection.uuidUseRecordFeature))
+                                                                       && !(childNode.getFeature().getUuid()
+                                                                                       .equals(UsageTermCollection.uuidUseSummaryFeature))) {
+                                                               createMenuItem(menu, childNode.getFeature());
                                                        }
-                                               }       
+                                               }
+                                       } else if (selectedElement instanceof FeatureNodeContainer) {
+                                               FeatureNode featureNode = ((FeatureNodeContainer) selectedElement)
+                                                               .getFeatureNode();
+
+                                               // add the feature to the menu
+                                               createMenuItem(menu, featureNode.getFeature());
+
+                                               // add possible children to the menu
+                                               for (FeatureNode childNode : featureNode.getChildren()) {
+                                                       createMenuItem(menu, childNode.getFeature());
+                                               }
+                                       } else if (selectedElement instanceof DescriptionElementBase) {
+                                               Feature feature = ((DescriptionElementBase) selectedElement)
+                                                               .getFeature();
+                                               createMenuItem(menu, feature);
                                        }
                                }
-               };
-       }       
-       
+                       }
+               } };
+       }
+
        private void createMenuItem(Menu menu, final Feature feature) {
                MenuItem menuItem = new MenuItem(menu, -1);
-               final Feature deproxiedFeature = (Feature) HibernateProxyHelper.deproxy(feature);
-               menuItem.setText(deproxiedFeature.getLabel());
-               menuItem.addSelectionListener(new SelectionListener(){
-
-                       public void widgetDefaultSelected(SelectionEvent e) {}
-
-                       public void widgetSelected(SelectionEvent ev) {
-                               Event event = new Event();
-                               event.data = deproxiedFeature;
-                               try {
-                                       handlerService.executeCommand(CreateDescriptionElementOperation.ID, event);
-                               } catch (Exception e) {
-                                       EditorUtil.error(getClass(), e);
+               final Feature deproxiedFeature = (Feature) HibernateProxyHelper
+                               .deproxy(feature);
+               
+
+                       menuItem.setText(deproxiedFeature.getLabel());
+                       menuItem.addSelectionListener(new SelectionListener() {
+
+                               public void widgetDefaultSelected(SelectionEvent e) {
                                }
-                       }                               
-               });
+
+                               public void widgetSelected(SelectionEvent ev) {
+                                       Event event = new Event();
+                                       event.data = deproxiedFeature;
+                                       try {
+                                               handlerService.executeCommand(
+                                                               CreateDescriptionElementOperation.ID, event);
+                                       } catch (Exception e) {
+                                               EditorUtil.error(getClass(), e);
+                                       }
+                               }
+                       });
+               
        }
-       
+
        /**
         * Retrieves the feature tree associated with the given description
         * 
-        * TODO as of now this is always the same thing because feature trees may not be associated 
-        * to descriptions yet.
+        * TODO as of now this is always the same thing because feature trees may
+        * not be associated to descriptions yet.
         * 
         * @param description
         * @return
         */
-       private FeatureTree getFeatureTree(DescriptionBase description){
+       private FeatureTree getFeatureTree(DescriptionBase description) {
                FeatureTree featureTree = null;
-               
-               // TODO change this to the feature tree associated with this taxon description
-               if (description.hasStructuredData()){                                   
-                       featureTree = PreferencesUtil.getDefaultFeatureTreeForStructuredDescription();
-               }else{
-                       featureTree = PreferencesUtil.getDefaultFeatureTreeForTextualDescription();
+
+               // TODO change this to the feature tree associated with this taxon
+               // description
+               if (description.hasStructuredData()) {
+                       featureTree = PreferencesUtil
+                                       .getDefaultFeatureTreeForStructuredDescription();
+               } else {
+                       featureTree = PreferencesUtil
+                                       .getDefaultFeatureTreeForTextualDescription();
                }
-               
-               if(featureTree == null){
-                       featureTree = FeatureTree.NewInstance(CdmStore.getTermManager().getPreferredTerms(Feature.class));
+
+               if (featureTree == null) {
+                       featureTree = FeatureTree.NewInstance(CdmStore.getTermManager()
+                                       .getPreferredTerms(Feature.class));
                }
-               
+
                return featureTree;
        }
 }
index dc96f4da42fa367c412d7e3ffe8ca9a53ecd8d26..1858c850ad2477f3a44a36d8cbdea413e1f41ad6 100644 (file)
@@ -171,7 +171,7 @@ public class UsesLabelProvider extends ColumnLabelProvider implements
                else if ((term.getVocabulary() != null) && (term.getPartOf() == null) && (term.getVocabulary().getTitleCache().equals(vocabularyExpected))) {\r
                        return true;\r
                }\r
-               else if ((vocabularyExpected.equals(UsageTermCollection.ethnicGroupLabel))  && (term.getVocabulary() != null) && ((term.getPartOf() != null))) {\r
+               else if ((vocabularyExpected.equals(UsageTermCollection.ethnicGroupLabel))  && ((term.getPartOf() != null))) {\r
                        return true;\r
                }\r
        return false;\r
index e10fe7daea01ada84daaa79c5242af95eacc5c87..32d02813fde7407d31e8f174597c2776627c0b7f 100644 (file)
@@ -543,7 +543,7 @@ public class UseRecordDetailElement extends
                else if ((term.getVocabulary() != null) && (term.getPartOf()==null) && (term.getVocabulary().getTitleCache().equals(vocabularyExpected))) {\r
                        return true;\r
                }\r
-               else if ((vocabularyExpected.equals(UsageTermCollection.ethnicGroupLabel))  && (term.getVocabulary() != null) && ((term.getPartOf() != null))) {\r
+               else if ((vocabularyExpected.equals(UsageTermCollection.ethnicGroupLabel))  && ((term.getPartOf() != null))) {\r
                        return true;\r
                }\r
        return false;\r