- added check for open derivate editor command
authorPatric Plitzner <p.plitzner@bgbm.org>
Tue, 31 Mar 2015 07:05:37 +0000 (07:05 +0000)
committerPatric Plitzner <p.plitzner@bgbm.org>
Tue, 31 Mar 2015 07:05:37 +0000 (07:05 +0000)
 - set title of factual data view corresponding to the current selection

eu.etaxonomy.taxeditor.editor/plugin.xml
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/DescriptiveViewPart.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/handler/DescriptionsMenuPropertyTester.java

index 20254cc3e0b0d1eda74a9dc932be46df55c82e56..7b5080db3eb9113a915aee92fd27a4d3eae33566 100644 (file)
                style="push">
             <visibleWhen
                   checkEnabled="true">
-               <with
-                     variable="selection">
-                  <count
-                        value="+">
-                  </count>
-               </with>
+               <and>
+                  <with
+                        variable="selection">
+                     <count
+                           value="+">
+                     </count>
+                  </with>
+                  <reference
+                        definitionId="isIndividualsAssociation">
+                  </reference>
+               </and>
             </visibleWhen>
          </command>
          <command
             </test>
          </with>
       </definition>
+      <definition
+            id="isIndividualsAssociation">
+         <with
+               variable="selection">
+            <test
+                  property="eu.etaxonomy.taxeditor.descriptions.propertyTester.isIndividualsAssociation">
+            </test>
+         </with>
+      </definition>
    </extension>
    <extension
          point="org.eclipse.core.expressions.propertyTesters">
             class="eu.etaxonomy.taxeditor.editor.view.descriptive.handler.DescriptionsMenuPropertyTester"
             id="eu.etaxonomy.taxeditor.descriptions.PropertyTester"
             namespace="eu.etaxonomy.taxeditor.descriptions.propertyTester"
-            properties="isMedia,isDescription,isDescriptionElement,isDeletable,isFeatureNodeContainer,isImageGallery,isTaxonEditor,isBulkEditor,isDerivateEditor"
+            properties="isMedia,isDescription,isDescriptionElement,isDeletable,isFeatureNodeContainer,isImageGallery,isTaxonEditor,isBulkEditor,isDerivateEditor, isIndividualsAssociation"
             type="org.eclipse.jface.viewers.TreeSelection">
       </propertyTester>
       <propertyTester
index 6e2a29d374eb721a990d3626427a9e8d720d564b..c51d856584b6f0b6fd9764d49a25e07704cdcbd2 100644 (file)
@@ -215,6 +215,7 @@ public class DescriptiveViewPart extends AbstractCdmEditorViewPart implements IP
        @Override
     protected void selectionChanged_internal(IWorkbenchPart part, ISelection selection) {
                if(AbstractUtility.getActiveEditor() == null){
+                   setPartName("Factual Data");
                        showEmptyPage();
                        return;
                }
@@ -243,10 +244,12 @@ public class DescriptiveViewPart extends AbstractCdmEditorViewPart implements IP
                        && ((IStructuredSelection) selection).getFirstElement() instanceof IDescribable<?>
                        && part instanceof IPartContentHasFactualData  && !(((IStructuredSelection) selection).getFirstElement() instanceof SpecimenOrObservationBase && part instanceof BulkEditor)){
                    featureNodeContainerCache.clear();
+               setPartName("Factual Data: " + ((IStructuredSelection) selection).getFirstElement());
                    showViewer(part, (IStructuredSelection) selection);
                    return;
                }
                else{
+            setPartName("Factual Data");
                    showEmptyPage();
                }
        }
index 1e0ad222c922106be512f45ab8d5f531177e7a94..3030ef4a3c1f33e295c00e5a8000bdb0a67c33f5 100644 (file)
@@ -8,6 +8,7 @@ import org.eclipse.jface.viewers.IStructuredSelection;
 
 import eu.etaxonomy.cdm.model.description.DescriptionBase;
 import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
+import eu.etaxonomy.cdm.model.description.IndividualsAssociation;
 import eu.etaxonomy.cdm.model.media.Media;
 import eu.etaxonomy.taxeditor.bulkeditor.BulkEditor;
 import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor;
@@ -27,6 +28,7 @@ public class DescriptionsMenuPropertyTester extends PropertyTester {
        private static final String MEDIA = "isMedia";
        private static final String FEATURE_NODE_CONTAINER = "isFeatureNodeContainer";
        private static final String DESCRIPTION = "isDescription";
+       private static final String INDIVIDUALS_ASSOCIATION = "isIndividualsAssociation";
        private static final String DESCRIPTION_ELEMENT = "isDescriptionElement";
        private static final String DELETABLE = "isDeletable";
        private static final String IMAGE_GALLERY = "isImageGallery";
@@ -68,6 +70,9 @@ public class DescriptionsMenuPropertyTester extends PropertyTester {
                else if(DESCRIPTION.equals(property)){
                        return isDescription(selectedElements);
                }
+               else if(INDIVIDUALS_ASSOCIATION.equals(property)){
+                   return isIndividualsAssociation(selectedElements);
+               }
                else if(DESCRIPTION_ELEMENT.equals(property)){
                        return isDescriptionElement(selectedElements);
                }
@@ -84,7 +89,7 @@ public class DescriptionsMenuPropertyTester extends PropertyTester {
 
        private boolean isImageGallery(Object[] selectedElements) {
                for (Object object : selectedElements){
-                       if(!(object instanceof DescriptionBase) || !((DescriptionBase) object).isImageGallery()){
+                       if(!(object instanceof DescriptionBase) || !((DescriptionBase<?>) object).isImageGallery()){
                                return false;
                        }
                }
@@ -136,6 +141,15 @@ public class DescriptionsMenuPropertyTester extends PropertyTester {
                return true;
        }
 
+       private boolean isIndividualsAssociation(Object[] selectedElements) {
+           for (Object object : selectedElements){
+               if(!(object instanceof IndividualsAssociation)){
+                   return false;
+               }
+           }
+           return true;
+       }
+
        private boolean isMedia(Object[] selectedElements) {
                for (Object object : selectedElements){
                        if(!(object instanceof Media)){