Fixes #2383
authorn.hoffmann <n.hoffmann@localhost>
Thu, 9 Jun 2011 13:58:37 +0000 (13:58 +0000)
committern.hoffmann <n.hoffmann@localhost>
Thu, 9 Jun 2011 13:58:37 +0000 (13:58 +0000)
eu.etaxonomy.taxeditor.editor/plugin.xml
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/handler/DescriptionsMenuPropertyTester.java

index ff49af4516c1dcd007fbb6a70988c2246ac6b32b..8450ebdbdaae2a10174003ab890233b3d9e4f9da 100644 (file)
                commandId="taxeditor-editor.newimage"
                label="New Image"
                style="push">
+            <visibleWhen>
+               <reference
+                     definitionId="isImageGallery">
+               </reference>
+            </visibleWhen>
          </command>
          <command
                commandId="taxeditor-editor.command.moveimgdown"
             </test>
          </with>
       </definition>
+      <definition
+            id="isImageGallery">
+         <with
+               variable="selection">
+            <test
+                  property="eu.etaxonomy.taxeditor.descriptions.propertyTester.isImageGallery">
+            </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"
+            properties="isMedia,isDescription,isDescriptionElement,isDeletable,isFeatureNodeContainer,isImageGallery"
             type="org.eclipse.jface.viewers.TreeSelection">
       </propertyTester>
    </extension>
index 6899f3d9eee7940b79e0643a5edfd1a1f2e60c0a..202308dbabbb2e1be77f9a9cc738a9b367efbff4 100644 (file)
@@ -25,6 +25,7 @@ public class DescriptionsMenuPropertyTester extends PropertyTester {
        private static final String DESCRIPTION = "isDescription";
        private static final String DESCRIPTION_ELEMENT = "isDescriptionElement";
        private static final String DELETABLE = "isDeletable";
+       private static final String IMAGE_GALLERY = "isImageGallery";
        
        /* (non-Javadoc)
         * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
@@ -55,11 +56,23 @@ public class DescriptionsMenuPropertyTester extends PropertyTester {
                else if(DELETABLE.equals(property)){
                        return isDeletable(selectedElements);
                }
+               else if(IMAGE_GALLERY.equals(property)){
+                       return isImageGallery(selectedElements);
+               }
                else{
                        return false;
                }
        }
        
+       private boolean isImageGallery(Object[] selectedElements) {
+               for (Object object : selectedElements){         
+                       if(!(object instanceof DescriptionBase) || !((DescriptionBase) object).isImageGallery()){
+                               return false;
+                       }
+               }
+               return true;
+       }
+
        private boolean isFeatureNodeContainer(Object[] selectedElements) {
                for (Object object : selectedElements){
                        if(!(object instanceof FeatureNodeContainer)){