X-Git-Url: https://dev.e-taxonomy.eu/gitweb/taxeditor.git/blobdiff_plain/5395d49ac396894e59033867499b07692d77d218..e91eca086e93ce0df47b3da31f6ba7116603384d:/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/MessagingUtils.java 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 36777e8ca..aa3058954 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 @@ -14,7 +14,10 @@ import org.eclipse.core.runtime.Status; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.swt.widgets.Display; -import eu.etaxonomy.cdm.persistence.hibernate.permission.SecurityExceptionUtils; +import eu.etaxonomy.cdm.common.CdmUtils; +import eu.etaxonomy.cdm.config.ICdmSource; +import eu.etaxonomy.cdm.test.integration.SecurityExceptionUtils; +import eu.etaxonomy.taxeditor.remoting.source.CdmRemoteSource; import eu.etaxonomy.taxeditor.store.CdmStore; import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin; @@ -31,7 +34,10 @@ public class MessagingUtils { public final static String UNEXPECTED_ERROR_MESSAGE = "This is an unexpected error."; public final static String CONTACT_MESSAGE = System.getProperty("line.separator") + "Please contact EDIT Support (EditSupport@bgbm.org) with the error trace below (click on the 'Details' button)."; public final static String DEFAULT_MESSAGE = "Error thrown but no associated message"; - + public final static String CONNECTION_FAILURE_MESSAGE = "The connection to the remote server has been broken"; + public final static String REMOTE_ACCESS_FAILURE_MESSAGE = "Maybe the server is currently not available. If the problem persists please contact the server admin with the error trace below."; + public static final String WIDGET_IS_DISPOSED_MESSAGE = "A widget was called, which was already disposed"; + public static final String ACCESS_DENIED = "The connection to the server could not be established because the access was denied."; /** * Gets the Log4J logger for a given class * @@ -172,6 +178,7 @@ public class MessagingUtils { public static List getContextInfo() { List contextInfo = new ArrayList(); String name = ""; + String contextPath = ""; String schemaVersion = ""; String server = ""; String version = ""; @@ -179,11 +186,18 @@ public class MessagingUtils { try { version = Platform.getBundle("eu.etaxonomy.taxeditor.application").getHeaders().get(org.osgi.framework.Constants.BUNDLE_VERSION); - if(CdmStore.getActiveCdmSource() != null ) { + ICdmSource activeCdmSource = CdmStore.getActiveCdmSource(); + if(activeCdmSource != null ) { login = CdmStore.getLoginManager().getAuthenticatedUser().getUsername(); - name = CdmStore.getActiveCdmSource().getName(); - schemaVersion = CdmStore.getActiveCdmSource().getDbSchemaVersion(); - server = CdmStore.getActiveCdmSource().getServer(); + name = activeCdmSource.getName(); + schemaVersion = activeCdmSource.getDbSchemaVersion(); + server = activeCdmSource.getServer(); + if(activeCdmSource instanceof CdmRemoteSource){ + contextPath = ((CdmRemoteSource) activeCdmSource).getContextPath(); + if (contextPath != null && contextPath.startsWith("cdmserver/")){ + contextPath = contextPath.substring("cdmserver/".length()); + } + } } } catch (Exception e) { @@ -191,7 +205,7 @@ public class MessagingUtils { } contextInfo.add("login : " + login); contextInfo.add("editor version : " + version); - contextInfo.add("server : " + server + " / " + name); + contextInfo.add("server : " + server + " (" + name + ")" + (CdmUtils.isNotBlank(contextPath)?" / "+contextPath:"")); contextInfo.add("schema version : " + schemaVersion); contextInfo.add("os : " + System.getProperty("os.name")+" "+System.getProperty("os.version")+" "+System.getProperty("os.arch")); contextInfo.add("java : "+System.getProperty("java.version")); @@ -253,14 +267,15 @@ public class MessagingUtils { final Throwable t, final List contextInfo, final String message, - final MultiStatus status) { + final MultiStatus status, + final boolean showReason) { Display.getDefault().asyncExec(new Runnable() { @Override public void run() { String stackTraceWithContext = getStackTraceAndContextInfo(t, contextInfo); - CdmErrorDialog ced = new CdmErrorDialog(AbstractUtility.getShell(), title, message, status, stackTraceWithContext); + CdmErrorDialog ced = new CdmErrorDialog(AbstractUtility.getShell(), title, message, status, stackTraceWithContext, showReason); ced.open(); Class clazz = source != null ? source.getClass() : this.getClass(); @@ -275,6 +290,15 @@ public class MessagingUtils { }); } + public static void errorDialog(final String title, + final Object source, + final String message, + final String pluginId, + final Throwable t, + boolean addContactMesg) { + errorDialog(title, source, message, pluginId, t, addContactMesg, true); + + } /** * Displays a {@link eu.etaxonomy.taxeditor.model.CdmErrorDialog}. * @@ -289,7 +313,8 @@ public class MessagingUtils { final String message, final String pluginId, final Throwable t, - boolean addContactMesg) { + boolean addContactMesg, + boolean showReason) { Throwable throwable = t; StringBuffer sbStackTrace = new StringBuffer(); @@ -356,7 +381,7 @@ public class MessagingUtils { throwable.toString(), throwable); - errorDialog(title, source, throwable, contextInfo, finalMessage, ms); + errorDialog(title, source, throwable, contextInfo, finalMessage, ms, showReason); } /** @@ -399,7 +424,7 @@ public class MessagingUtils { warningDialog(title, source, String.format("You are missing sufficient permissions for the operation \"%s\". %s", operationlabel, hint)); } else { title = "Error executing operation"; - errorDialog(title, source, String.format("An error occured while executing %s. %s", operationlabel, hint), pluginId, ex, true); + errorDialog(title, source, String.format("An error occurred while executing %s. %s", operationlabel, hint), pluginId, ex, true); } @@ -424,6 +449,12 @@ public class MessagingUtils { return MessageDialog.openQuestion(AbstractUtility.getShell(), title, message); } + public static int confirmDialog(String title, String message, String...labels){ + MessageDialog dialog =new MessageDialog(AbstractUtility.getShell(), title, null, message, MessageDialog.QUESTION,labels, 0); + int result = dialog.open(); + return result; + } + /** * Displays a message {@link org.eclipse.jface.dialogs.MessageDialog}. * @@ -535,6 +566,20 @@ public class MessagingUtils { + "connected to a datasource. You may choose a datasource to connect to or create a new one in the datasource view."); } + /** + * Standard warning dialog for the case when the datasource is not available + * + * @param source + */ + public static void dataSourceNotAvailableWarningDialog(Object source) { + MessagingUtils + .warningDialog( + "The datasource is not available", + source, + "The editor is not connected to a datasource. Maybe the datasource is not available."); + } + + /** * Displays a warning {@link org.eclipse.jface.dialogs.MessageDialog}. *