fix #5971: admin menu is visible only if connected and user has role manager
authorKatja Luther <k.luther@bgbm.org>
Wed, 23 Nov 2016 09:22:12 +0000 (10:22 +0100)
committerKatja Luther <k.luther@bgbm.org>
Wed, 23 Nov 2016 09:22:12 +0000 (10:22 +0100)
eu.etaxonomy.taxeditor.application/OSGI-INF/l10n/plugin.properties
eu.etaxonomy.taxeditor.application/OSGI-INF/l10n/plugin_de.properties
eu.etaxonomy.taxeditor.application/plugin.xml
eu.etaxonomy.taxeditor.application/src/main/java/eu/etaxonomy/taxeditor/ApplicationWorkbenchWindowAdvisor.java
eu.etaxonomy.taxeditor.store/OSGI-INF/l10n/bundle.properties
eu.etaxonomy.taxeditor.store/OSGI-INF/l10n/bundle_de.properties
eu.etaxonomy.taxeditor.store/OSGI-INF/l10n/messages_de.properties
eu.etaxonomy.taxeditor.store/plugin.xml
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/MessagingUtils.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/CdmStore.java

index 37beb7b7d6080d8b6d566bcc38749314b3cfe1d2..8110d546dba719d86bddafce7f48365e2b9b07bc 100644 (file)
@@ -14,11 +14,13 @@ perspective.name = Taxonomic
 perspective.name.0 = Polytomous Key\r
 perspective.name.1 = Uses\r
 perspective.name.2 = Derivatives\r
+perspective.name.3 = Checklist\r
 menu.label = General\r
 menu.label.0 = Edit\r
 menu.label.1 = Window\r
 menu.label.2 = Help\r
 menu.label.3 = New\r
+menu.label.4 = Admin\r
 command.label = Close\r
 command.label.0 = Close All\r
 command.label.1 = Save\r
@@ -43,6 +45,7 @@ command.label.19 = About Taxonomic Editor
 command.label.20 = About the EDIT Platform\r
 command.label.21 = New\r
 command.label.22 = Save\r
+command.label.23 = Database Preferences\r
 product.name = EDIT Taxonomic Editor\r
 command.name = Parser Help\r
 command.name.0 = About the EDIT Platform\r
index 91621f4e6af09879790c1c3192ff4e24806d3ff7..0d736515a14ffc0ebc4e32a91534497d6fb1f665 100644 (file)
@@ -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
index 3f377ea589c7ab3db4b1f1159e64cbf98d9330fa..89cf7934971b2c685e0a96532eb0bb139e49af87 100644 (file)
@@ -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
                   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>
             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>
    
    
index bb5b360a311cca20625d70ad041ed5e78a56ccd2..6a116e239dd75c5cd3144f0c32398dab5df8c193 100644 (file)
@@ -61,8 +61,6 @@ public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
     public void postWindowOpen() {
                PreferencesUtil.checkNomenclaturalCode();
 
-
-
                if(PreferencesUtil.shouldConnectAtStartUp()) {
             CdmStore.connect();
         }
index 3d5878ca8b7d33518dc3d2e1c6f3152809d39d02..411f2a9e8f515f8bd8d84ede4df4d051ff167742 100644 (file)
@@ -162,6 +162,7 @@ activity.name.3 = ProjectManagement
 command.name.13 = delete\r
 command.name.14 = delete\r
 command.name.15 = Open\r
+command.name.16 = Database Preferences\r
 view.name.SESSIONS = Sessions\r
 command.label.SESSION = Sessions\r
 command.label.CONNECT = Connect\r
index dedac2a210fbff52c32fb6448eeeb1cdaf6bbd25..e4276d7d40d9a4853f03c97359407c91bd95e1e6 100644 (file)
@@ -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
index f906aa13bb65c7579b80a5c030dac448cf2c30d1..fd18c2e36c32cbac5c1ae1c40a7c70ce70fad1c0 100644 (file)
@@ -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.
index 0a6cfe0a1685bafd3ed2a524e9c1268bb2a9b016..9e449ab2a2e45f876aaf9e9634b34df4d70d4dfb 100755 (executable)
       <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"
             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"
                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">
index 5144ab8b77fe53b0f1bd798d3a1770e6fe58bb02..5fa462cf79b99eabd84b9b9e9427b6b507c9616b 100644 (file)
@@ -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.");
     }
 
 
index 8ef10b1e3c67de315fa604a61b26d822016070f5..f8a87dea58c430e3534df40aeb7ed1885a97cb24 100644 (file)
@@ -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;