added a new propertytester to check if the editor is connected to database
authorAlexander Oppermann <a.oppermann@bgbm.org>
Mon, 15 Dec 2014 13:17:55 +0000 (13:17 +0000)
committerAlexander Oppermann <a.oppermann@bgbm.org>
Mon, 15 Dec 2014 13:17:55 +0000 (13:17 +0000)
hide popupmenu in taxon navigator view if not connected to database

eu.etaxonomy.taxeditor.editor/plugin.xml
eu.etaxonomy.taxeditor.navigation/plugin.xml
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/PreferencePropertyTester.java

index 23f66c05e7de39952e872b023b34fa340fe6e6c4..0489ab4f0918438a087c445abda57af3743645bb 100644 (file)
                commandId="eu.etaxonomy.taxeditor.editor.handler.openDerivateView"
                label="Open Associated Derivates"
                style="push">
                commandId="eu.etaxonomy.taxeditor.editor.handler.openDerivateView"
                label="Open Associated Derivates"
                style="push">
+            <visibleWhen
+                  checkEnabled="true">
+               <reference
+                     definitionId="isCdmStoreConnected">
+               </reference>
+            </visibleWhen>
          </command>
          <separator
                name="eu.etaxonomy.taxeditor.editor.separator1"
          </command>
          <separator
                name="eu.etaxonomy.taxeditor.editor.separator1"
index 0667e56f6cf3546c2a982bf4a3dacceccf4ef053..8b061b761c113e8558ee20d8cccc25c126f281d7 100644 (file)
                   label="%command.label.3"
                   style="push">
             </command>
                   label="%command.label.3"
                   style="push">
             </command>
+            <visibleWhen
+                  checkEnabled="true">
+               <reference
+                     definitionId="isCdmStoreConnected">
+               </reference>
+            </visibleWhen>
          </menu>
          <command
                commandId="eu.etaxonomy.taxeditor.editor.handler.OpenChecklistViewHandler"
          </menu>
          <command
                commandId="eu.etaxonomy.taxeditor.editor.handler.OpenChecklistViewHandler"
                style="push">
                <visibleWhen
                   checkEnabled="true">
                style="push">
                <visibleWhen
                   checkEnabled="true">
-               <reference
-                     definitionId="isTaxonNode">
-               </reference>
+                  <and>
+                     <reference
+                           definitionId="isCdmStoreConnected">
+                     </reference>
+                     <reference
+                           definitionId="isTaxonNode">
+                     </reference>
+                  </and>
             </visibleWhen>
          </command>
          <command
             </visibleWhen>
          </command>
          <command
                commandId="org.eclipse.ui.file.import"
                label="%command.label.8"
                style="push">
                commandId="org.eclipse.ui.file.import"
                label="%command.label.8"
                style="push">
+            <visibleWhen
+                  checkEnabled="true">
+               <reference
+                     definitionId="isCdmStoreConnected">
+               </reference>
+            </visibleWhen>
          </command>
          <command
                commandId="org.eclipse.ui.file.export"
                label="%command.label.9"
                style="push">
          </command>
          <command
                commandId="org.eclipse.ui.file.export"
                label="%command.label.9"
                style="push">
+            <visibleWhen
+                  checkEnabled="true">
+               <reference
+                     definitionId="isCdmStoreConnected">
+               </reference>
+            </visibleWhen>
          </command>
          <separator
                name="taxeditor-navigation.separator4"
          </command>
          <separator
                name="taxeditor-navigation.separator4"
                commandId="org.eclipse.ui.edit.delete"
                label="%command.label.10"
                style="push">
                commandId="org.eclipse.ui.edit.delete"
                label="%command.label.10"
                style="push">
-            <visibleWhen>
-               <not>
+            <visibleWhen
+                  checkEnabled="true">
+               <and>
                   <reference
                   <reference
-                        definitionId="isSynonymNode">
+                        definitionId="isCdmStoreConnected">
                   </reference>
                   </reference>
-               </not>
+                  <not>
+                     <reference
+                           definitionId="isSynonymNode">
+                     </reference>
+                  </not>
+               </and>
             </visibleWhen>
          </command>
          <separator
             </visibleWhen>
          </command>
          <separator
                commandId="org.eclipse.ui.file.refresh"
                label="%command.label.11"
                style="push">
                commandId="org.eclipse.ui.file.refresh"
                label="%command.label.11"
                style="push">
+            <visibleWhen
+                  checkEnabled="true">
+               <reference
+                     definitionId="isCdmStoreConnected">
+               </reference>
+            </visibleWhen>
          </command>
          <command
                commandId="eu.etaxonomy.taxeditor.navigation.command.copyTaxonName"
                label="%command.label.12"
                style="push">
          </command>
          <command
                commandId="eu.etaxonomy.taxeditor.navigation.command.copyTaxonName"
                label="%command.label.12"
                style="push">
+            <visibleWhen
+                  checkEnabled="true">
+               <reference
+                     definitionId="isCdmStoreConnected">
+               </reference>
+            </visibleWhen>
          </command>
       </menuContribution>
       <menuContribution
          </command>
       </menuContribution>
       <menuContribution
          properties="isChecklistEditorEnabled"
          type="org.eclipse.jface.viewers.IStructuredSelection">
    </propertyTester>
          properties="isChecklistEditorEnabled"
          type="org.eclipse.jface.viewers.IStructuredSelection">
    </propertyTester>
+   <propertyTester
+         class="eu.etaxonomy.taxeditor.preference.PreferencePropertyTester"
+         id="eu.etaxonomy.taxeditor.preferences.propertyTester"
+         namespace="eu.etaxonomy.taxeditor.preferences.propertyTester"
+         properties="isCdmStoreConnected"
+         type="org.eclipse.jface.viewers.IStructuredSelection">
+   </propertyTester>
    </extension>
    <extension
          point="org.eclipse.core.expressions.definitions">
    </extension>
    <extension
          point="org.eclipse.core.expressions.definitions">
             </test>
          </with>
       </definition>
             </test>
          </with>
       </definition>
+      <definition
+            id="isCdmStoreConnected">
+         <with
+               variable="selection">
+            <test
+                  property="eu.etaxonomy.taxeditor.preferences.propertyTester.isCdmStoreConnected">
+            </test>
+         </with>
+      </definition>
    </extension>
 </plugin>
    </extension>
 </plugin>
index 8a00f1ff73be6da4e71414d9ede15a3b238b7dab..62c31c9195624eb7e7c40e22556024c6f86155d1 100644 (file)
@@ -12,6 +12,8 @@ package eu.etaxonomy.taxeditor.preference;
 
 import org.eclipse.core.expressions.PropertyTester;
 
 
 import org.eclipse.core.expressions.PropertyTester;
 
+import eu.etaxonomy.taxeditor.store.CdmStore;
+
 /**
  * @author n.hoffmann
  * @created Jan 26, 2011
 /**
  * @author n.hoffmann
  * @created Jan 26, 2011
@@ -22,7 +24,9 @@ public class PreferencePropertyTester extends PropertyTester {
 
        private static final String SHOW_EXPERIMENTAL_FEATURES = "isShowExperimentalFeatures";
 
 
        private static final String SHOW_EXPERIMENTAL_FEATURES = "isShowExperimentalFeatures";
 
-       private static final String SHOW_CHECKLIST_EDITOR = "isChecklistEditorEnabled";
+    private static final String SHOW_CHECKLIST_EDITOR = "isChecklistEditorEnabled";
+
+       private static final String EDITOR_IS_CONNECTED_TO_DB = "isCdmStoreConnected";
 
        /* (non-Javadoc)
         * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
 
        /* (non-Javadoc)
         * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
@@ -37,6 +41,9 @@ public class PreferencePropertyTester extends PropertyTester {
            if(SHOW_CHECKLIST_EDITOR.equals(property)){
                return isChecklistEditorEnabled();
            }
            if(SHOW_CHECKLIST_EDITOR.equals(property)){
                return isChecklistEditorEnabled();
            }
+           if(EDITOR_IS_CONNECTED_TO_DB.equals(property)){
+               return isCdmStoreConnected();
+           }
 
                return false;
        }
 
                return false;
        }
@@ -51,4 +58,9 @@ public class PreferencePropertyTester extends PropertyTester {
        private boolean isChecklistEditorEnabled() {
         return PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.DISTRIBUTION_AREA_PREFRENCES_ACTIVE);
     }
        private boolean isChecklistEditorEnabled() {
         return PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.DISTRIBUTION_AREA_PREFRENCES_ACTIVE);
     }
+
+       private boolean isCdmStoreConnected(){
+           boolean active = CdmStore.isActive();
+           return active;
+       }
 }
 }