commit 0bd095d9fbccd25ce847af780892633284b314f9
Author: Katja Luther <k.luther@bgbm.org>
Date:   Wed Nov 23 10:22:12 2016 +0100

    fix #5971: admin menu is visible only if connected and user has role manager

diff --git a/eu.etaxonomy.taxeditor.application/OSGI-INF/l10n/plugin.properties b/eu.etaxonomy.taxeditor.application/OSGI-INF/l10n/plugin.properties
index 37beb7b7d..8110d546d 100644
--- a/eu.etaxonomy.taxeditor.application/OSGI-INF/l10n/plugin.properties
+++ b/eu.etaxonomy.taxeditor.application/OSGI-INF/l10n/plugin.properties
@@ -14,11 +14,13 @@ perspective.name = Taxonomic
 perspective.name.0 = Polytomous Key
 perspective.name.1 = Uses
 perspective.name.2 = Derivatives
+perspective.name.3 = Checklist
 menu.label = General
 menu.label.0 = Edit
 menu.label.1 = Window
 menu.label.2 = Help
 menu.label.3 = New
+menu.label.4 = Admin
 command.label = Close
 command.label.0 = Close All
 command.label.1 = Save
@@ -43,6 +45,7 @@ command.label.19 = About Taxonomic Editor
 command.label.20 = About the EDIT Platform
 command.label.21 = New
 command.label.22 = Save
+command.label.23 = Database Preferences
 product.name = EDIT Taxonomic Editor
 command.name = Parser Help
 command.name.0 = About the EDIT Platform
diff --git a/eu.etaxonomy.taxeditor.application/OSGI-INF/l10n/plugin_de.properties b/eu.etaxonomy.taxeditor.application/OSGI-INF/l10n/plugin_de.properties
index 91621f4e6..0d736515a 100644
--- a/eu.etaxonomy.taxeditor.application/OSGI-INF/l10n/plugin_de.properties
+++ b/eu.etaxonomy.taxeditor.application/OSGI-INF/l10n/plugin_de.properties
@@ -14,11 +14,13 @@ perspective.name = Taxonomisch
 perspective.name.0 = Polytomer Schlüssel
 perspective.name.1 = Nutzung
 perspective.name.2 = Derivate
+perspective.name.3 = Checklisten
 menu.label = Datei
 menu.label.0 = Bearbeiten
 menu.label.1 = Extras
 menu.label.2 = Hilfe
 menu.label.3 = Neu
+menu.label.4 = Admin
 command.label = Schlie\u00dfen
 command.label.0 = Schlie\u00dfe alle
 command.label.1 = Speichern
@@ -43,6 +45,7 @@ command.label.19 = \u00dcber den Taxonomischen Editor
 command.label.20 = \u00dcber die EDIT Platform
 command.label.21 = Neu
 command.label.22 = Speichern
+command.label.23 = Datenbank Präferenzen
 product.name = EDIT Taxonomischer Editor
 command.name = Parser Hilfe
 command.name.0 = \u00dcber die EDIT Platform
diff --git a/eu.etaxonomy.taxeditor.application/plugin.xml b/eu.etaxonomy.taxeditor.application/plugin.xml
index 3f377ea58..89cf79349 100644
--- a/eu.etaxonomy.taxeditor.application/plugin.xml
+++ b/eu.etaxonomy.taxeditor.application/plugin.xml
@@ -41,7 +41,7 @@
             class="eu.etaxonomy.taxeditor.perspective.ChecklistPerspective"
             icon="icons/check.png"
             id="eu.etaxonomy.taxeditor.perspective.checklistperspective"
-            name="Checklist">
+            name="%perspective.name.3">
       </perspective>
      
    </extension>
@@ -82,7 +82,7 @@
          </menu>
          <menu
                id="org.eclipse.ui.main.menu.admin"
-               label="Admin">
+               label="%menu.label.4">
          </menu>
       </menuContribution>
       <menuContribution
@@ -281,8 +281,19 @@
                   locationURI="menu:org.eclipse.ui.main.menu.admin">
                <command
                      commandId="eu.etaxonomy.taxeditor.application.DatabaseSettings"
-                     label="Database Preferences"
+                     label="%command.label.23"
                      style="push">
+                  <visibleWhen
+                        checkEnabled="true">
+                     <and>
+                        <reference
+                              definitionId="hasROLE_PROJECT_MANAGER">
+                        </reference>
+                        <reference
+                              definitionId="isCdmStoreConnected">
+                        </reference>
+                     </and>
+                  </visibleWhen>
                </command>
             </menuContribution>
    </extension>
@@ -351,12 +362,6 @@
             id="eu.etaxonomy.taxeditor.install"
             name="%command.label.18">
       </command>
-      <command
-            defaultHandler="eu.etaxonomy.taxeditor.handler.OpenDatabasePreferencesWizardHandler"
-            id="eu.etaxonomy.taxeditor.application.DatabaseSettings"
-            name="databaseSettings">
-            
-      </command>
    </extension>
    
    
diff --git a/eu.etaxonomy.taxeditor.application/src/main/java/eu/etaxonomy/taxeditor/ApplicationWorkbenchWindowAdvisor.java b/eu.etaxonomy.taxeditor.application/src/main/java/eu/etaxonomy/taxeditor/ApplicationWorkbenchWindowAdvisor.java
index bb5b360a3..6a116e239 100644
--- a/eu.etaxonomy.taxeditor.application/src/main/java/eu/etaxonomy/taxeditor/ApplicationWorkbenchWindowAdvisor.java
+++ b/eu.etaxonomy.taxeditor.application/src/main/java/eu/etaxonomy/taxeditor/ApplicationWorkbenchWindowAdvisor.java
@@ -61,8 +61,6 @@ public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
     public void postWindowOpen() {
 		PreferencesUtil.checkNomenclaturalCode();
 
-
-
 		if(PreferencesUtil.shouldConnectAtStartUp()) {
             CdmStore.connect();
         }
diff --git a/eu.etaxonomy.taxeditor.store/OSGI-INF/l10n/bundle.properties b/eu.etaxonomy.taxeditor.store/OSGI-INF/l10n/bundle.properties
index 3d5878ca8..411f2a9e8 100644
--- a/eu.etaxonomy.taxeditor.store/OSGI-INF/l10n/bundle.properties
+++ b/eu.etaxonomy.taxeditor.store/OSGI-INF/l10n/bundle.properties
@@ -162,6 +162,7 @@ activity.name.3 = ProjectManagement
 command.name.13 = delete
 command.name.14 = delete
 command.name.15 = Open
+command.name.16 = Database Preferences
 view.name.SESSIONS = Sessions
 command.label.SESSION = Sessions
 command.label.CONNECT = Connect
diff --git a/eu.etaxonomy.taxeditor.store/OSGI-INF/l10n/bundle_de.properties b/eu.etaxonomy.taxeditor.store/OSGI-INF/l10n/bundle_de.properties
index dedac2a21..e4276d7d4 100644
--- a/eu.etaxonomy.taxeditor.store/OSGI-INF/l10n/bundle_de.properties
+++ b/eu.etaxonomy.taxeditor.store/OSGI-INF/l10n/bundle_de.properties
@@ -162,6 +162,8 @@ activity.name.3 = Projekt-Management
 command.name.13 = L\u00f6schen
 command.name.14 = L\u00f6schen
 command.name.15 = \u00d6ffnen
+command.name.16 = Datenbank Präferenzen
+
 view.name.SESSIONS = Sessions
 command.label.SESSION = Sessions
 command.label.CONNECT = Verbinden
diff --git a/eu.etaxonomy.taxeditor.store/OSGI-INF/l10n/messages_de.properties b/eu.etaxonomy.taxeditor.store/OSGI-INF/l10n/messages_de.properties
index f906aa13b..fd18c2e36 100644
--- a/eu.etaxonomy.taxeditor.store/OSGI-INF/l10n/messages_de.properties
+++ b/eu.etaxonomy.taxeditor.store/OSGI-INF/l10n/messages_de.properties
@@ -22,7 +22,7 @@ UriWithLabelElement_OPEN_EXTERNAL_BROWSER=Im Browser 
 
 ChangeConnectionHandler_ALREADY_CONNECTING=Datenmodell wird erstellt
 ChangeConnectionHandler_CURRENTLY_CONNECTING_ALREADY=Es wird schon das Datenmodell für eine Datenquelle erstellt
-ChangeConnectionHandler_DATASOURCE_NOT_AVAILABLE=Gewählte Datenquelle nicht verfügbar
+ChangeConnectionHandler_DATASOURCE_NOT_AVAILABLE=Gewählte Datenquelle ist nicht verfügbar
 ChangeConnectionHandler_NOT_AVAILABLE_REASONS=Eventuell ist der Server nicht verfügbar oder erreichbar.\n\nStellen Sie bitte auch sicher, dass sie Netzzugang haben, wenn sie sich zu einer Remote-Datenquelle verbinden.
 ChangeConnectionHandler_CREATE_DATAMODEL=Datenmodell erstellen
 ChangeConnectionHandler_REALLY_CREATE_DATAMODEL=Wollen sie wirklich das Datenmodell für %s erstellen?\n\nACHTUNG: Existierende Daten werden gelöscht!\n\nHinweis: Die Erstellung kann einige Zeit dauern.
diff --git a/eu.etaxonomy.taxeditor.store/plugin.xml b/eu.etaxonomy.taxeditor.store/plugin.xml
index 0a6cfe0a1..9e449ab2a 100755
--- a/eu.etaxonomy.taxeditor.store/plugin.xml
+++ b/eu.etaxonomy.taxeditor.store/plugin.xml
@@ -675,6 +675,11 @@
       <handler
             class="eu.etaxonomy.taxeditor.handler.OpenDatabasePreferencesWizardHandler"
             commandId="eu.etaxonomy.taxeditor.store.open.OpenDatabasePreferencesWizardHandler">
+            <activeWhen>
+            <reference
+                  definitionId="hasROLE_PROJECT_MANAGER">
+            </reference>
+         </activeWhen>
       </handler>
       <handler
             class="eu.etaxonomy.taxeditor.handler.SwitchUserHandler"
@@ -765,6 +770,11 @@
             id="eu.etaxonomy.taxeditor.store.open.OpenDistributionEditorWizardHandler"
             name="%command.name.11">
       </command>
+       <command
+            id="eu.etaxonomy.taxeditor.store.open.OpenDatabasePreferencesWizardHandler"
+            name="%command.name.15">
+      </command>
+      
       <command
             defaultHandler="eu.etaxonomy.taxeditor.view.datasource.handler.ChangeConnectionHandler"
             id="eu.etaxonomy.taxeditor.datasource.connect"
@@ -807,6 +817,11 @@
                typeId="eu.etaxonomy.taxeditor.uuidParameterType">
          </commandParameter>
       </command>
+      <command
+            defaultHandler="eu.etaxonomy.taxeditor.handler.OpenDatabasePreferencesWizardHandler"
+            id="eu.etaxonomy.taxeditor.application.DatabaseSettings"
+            name="%command.label.23">
+      </command>
    </extension>
    <extension
          point="org.eclipse.ui.commands">
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/MessagingUtils.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/MessagingUtils.java
index 5144ab8b7..5fa462cf7 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/MessagingUtils.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/MessagingUtils.java
@@ -559,7 +559,7 @@ public class MessagingUtils {
         .warningDialog(
                 "The datasource is not available",
                 source,
-                "The choosen datasource is not available, please contact the administrator.");
+                "The editor is not connected to a datasource. Maybe the datasource is not available.");
     }
 
 
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/CdmStore.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/CdmStore.java
index 8ef10b1e3..f8a87dea5 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/CdmStore.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/CdmStore.java
@@ -124,17 +124,30 @@ public class CdmStore {
      *
      * @return a {@link eu.etaxonomy.taxeditor.store.CdmStore} object.
      */
-    protected static CdmStore getDefault() {
+    protected static CdmStore getDefault(boolean connecting){
         if (instance != null && instance.isConnected) {
             return instance;
         } else{// if (instance == null || !instance.isConnected) {
-
-            MessagingUtils.dataSourceNotAvailableWarningDialog(instance);
+            if (connecting){
+                MessagingUtils.dataSourceNotAvailableWarningDialog(instance);
+            }else{
+                MessagingUtils.noDataSourceWarningDialog(instance);
+            }
 
 
             return null;
         }
     }
+    /**
+     * <p>
+     * getDefault
+     * </p>
+     *
+     * @return a {@link eu.etaxonomy.taxeditor.store.CdmStore} object.
+     */
+    protected static CdmStore getDefault(){
+       return getDefault(false);
+    }
 
     /**
      * Initialize the with the last edited datasource
@@ -200,8 +213,8 @@ public class CdmStore {
         if(isActive()) {
             // before we connect we clear the entity caches and the sessions
             CdmRemoteCacheManager.removeEntityCaches();
-            if(getCurrentSessionManager() != null) {
-                getCurrentSessionManager().disposeAll();
+            if(getCurrentSessionManager(true) != null) {
+                getCurrentSessionManager(true).disposeAll();
             }
         }
         MessagingUtils.info("Connecting to datasource: " + cdmSource);
@@ -342,10 +355,14 @@ public class CdmStore {
             return mockCdmEntitySessionManager;
         }
     }
-
     public static  ICdmEntitySessionManager getCurrentSessionManager() {
-        if (getDefault() != null) {
-            return getDefault().getSessionManager();
+        return getCurrentSessionManager(false);
+    }
+
+
+    public static  ICdmEntitySessionManager getCurrentSessionManager(boolean connecting) {
+        if (getDefault(connecting) != null) {
+            return getDefault(connecting).getSessionManager();
         }
         return null;
 
