commit 6c58d852f80904f8252c76910b7c007a6c8ac937
Author: Katja Luther <k.luther@bgbm.org>
Date:   Wed Jan 23 13:30:06 2019 +0100

    ref #7993: handle exception when user has no role remoting

diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/CdmStoreConnector.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/CdmStoreConnector.java
index d3606e8ed..e40fa8528 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/CdmStoreConnector.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/CdmStoreConnector.java
@@ -203,15 +203,16 @@ class CdmStoreConnector extends Job {
                                     try {
                                         // create new security context
                                         CdmStore.getLoginManager().doAuthenticate(loginDialog.getUsername(), loginDialog.getPassword());
-                                        loginDialog.onComplete();
+                                        //loginDialog.onComplete();
                                         CdmStore.getContextManager().notifyContextStart();
+                                        loginDialog.onComplete();
                                         getInstance(Rank.class).resetTerms();
                                         getInstance(NomenclaturalStatusType.class).resetTerms();
                                         Rank.initDefaultTerms();
                                         NomenclaturalStatusType.initDefaultTerms();
                                     } catch(CdmAuthenticationException cae) {
                                         loginDialog.hide(false);
-                                        loginDialog.setMessage(cae.getMessage());
+                                        loginDialog.setMessage("You are logged in now but you are not permitted to use the TaxEditor with the data source "+ cdmSource.getName());
                                     }
 
                                 }
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/RemotingLoginDialog.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/RemotingLoginDialog.java
index e1cfe06ed..9b6afed38 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/RemotingLoginDialog.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/RemotingLoginDialog.java
@@ -61,6 +61,7 @@ import eu.etaxonomy.cdm.api.application.CdmApplicationRemoteConfiguration;
 import eu.etaxonomy.cdm.api.application.CdmApplicationState;
 import eu.etaxonomy.cdm.api.service.IUserService;
 import eu.etaxonomy.cdm.model.metadata.CdmMetaData;
+import eu.etaxonomy.cdm.persistence.hibernate.permission.Role;
 import eu.etaxonomy.taxeditor.l10n.Messages;
 import eu.etaxonomy.taxeditor.model.MessagingUtils;
 import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
@@ -209,8 +210,10 @@ public class RemotingLoginDialog extends Dialog implements ICDMServerError {
         Display display = getParent().getDisplay();
 
         while (!shlConnect.isDisposed()) {
-            if (!display.readAndDispatch()) {
-                display.sleep();
+            if (!display.isDisposed()){
+                if (!display.readAndDispatch()) {
+                    display.sleep();
+                }
             }
         }
 
@@ -481,7 +484,7 @@ public class RemotingLoginDialog extends Dialog implements ICDMServerError {
 			startManagedServer();
 		} else {
 			connect();
-			if (CdmStore.isActive()){
+			if (CdmStore.isActive() && CdmStore.currentAuthentiationHasOneOfRoles(Role.ROLE_REMOTING)){
 			    PreferencesUtil.setNomenclaturalCodePreferences();
 			}
 
@@ -1030,9 +1033,9 @@ public class RemotingLoginDialog extends Dialog implements ICDMServerError {
 
     public void setMessage(String message) {
         if(message != null && !message.isEmpty()) {
-            if(message.length() > 60) {
+            if(message.length() > 50) {
                 styledTxtMessage.setToolTipText(message);
-                message = message.substring(0, 60) + "..."; //$NON-NLS-1$
+                message = message.substring(0,50) + "..."; //$NON-NLS-1$
             }
             styledTxtMessage.setText(message);
             styledTxtMessage.setVisible(true);
@@ -1040,13 +1043,19 @@ public class RemotingLoginDialog extends Dialog implements ICDMServerError {
             shlConnect.setSize(MIN_WIDTH, getHeightWithoutMessage() + MESSAGE_HEIGHT);
             shlConnect.setMinimumSize(MIN_WIDTH, getHeightWithoutMessage() + MESSAGE_HEIGHT);
         } else {
-            styledTxtMessage.setText(""); //$NON-NLS-1$
-            styledTxtMessage.setVisible(false);
-            ((GridData)styledTxtMessage.getLayoutData()).exclude = true;
-            shlConnect.setSize(MIN_WIDTH, getHeightWithoutMessage());
-            shlConnect.setMinimumSize(MIN_WIDTH, getHeightWithoutMessage());
+            if (!styledTxtMessage.isDisposed()){
+                styledTxtMessage.setText(""); //$NON-NLS-1$
+                styledTxtMessage.setVisible(false);
+                ((GridData)styledTxtMessage.getLayoutData()).exclude = true;
+            }
+            if(!shlConnect.isDisposed()){
+                shlConnect.setSize(MIN_WIDTH, getHeightWithoutMessage());
+                shlConnect.setMinimumSize(MIN_WIDTH, getHeightWithoutMessage());
+            }
+        }
+        if (!remotingComposite.isDisposed()){
+            remotingComposite.layout();
         }
-        remotingComposite.layout();
     }
 
     private int getHeightWithoutMessage() {
@@ -1059,13 +1068,17 @@ public class RemotingLoginDialog extends Dialog implements ICDMServerError {
 
 
     public void hide(boolean isHidden) {
-        if(shlConnect != null && shlConnect.getDisplay() != null) {
-            shlConnect.setVisible(!isHidden);
+        if (!shlConnect.isDisposed()){
+            if(shlConnect != null && shlConnect.getDisplay() != null) {
+                shlConnect.setVisible(!isHidden);
+            }
         }
     }
     public void dispose() {
-        if(shlConnect != null && shlConnect.getDisplay() != null) {
-            shlConnect.dispose();
+        if (!shlConnect.isDisposed()){
+            if(shlConnect != null && shlConnect.getDisplay() != null) {
+                shlConnect.dispose();
+            }
         }
     }
 
