From 61fab46170f56b343ee8fb6f55708cf454dc990c Mon Sep 17 00:00:00 2001 From: David McKnight Date: Fri, 29 Feb 2008 18:38:45 +0000 Subject: [PATCH] [220547] allow SimpleSystemMessage without message ID --- .../messages/SimpleSystemMessage.java | 61 ++++++++++++++++++- 1 file changed, 59 insertions(+), 2 deletions(-) diff --git a/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/messages/SimpleSystemMessage.java b/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/messages/SimpleSystemMessage.java index 6f6079a79ac..0508bd6e615 100644 --- a/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/messages/SimpleSystemMessage.java +++ b/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/messages/SimpleSystemMessage.java @@ -55,7 +55,7 @@ public class SimpleSystemMessage extends SystemMessage { super("RSE", "G", "-", severityToIndicator(severity), msg, msgDetails); //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$ _pluginId = pluginId; - _messageId = pluginId; + _messageId = messageId; } /** @@ -75,6 +75,58 @@ public class SimpleSystemMessage extends SystemMessage { _messageId = messageId; } + /** + * Constructor for messages that use explicit strings and severities rather than + * parsing a message file. This is part of the work to migrate away from the message + * file stuff. + * + * This constructor does not supply a message id. It is preferred that a message id is used since + * it allows easier identification of a unique message. + * + * @param pluginId the id of the originating plugin + * @param severity using IStatus severities + * @param msg the message text + */ + public SimpleSystemMessage(String pluginId, int severity, String msg) { + this(pluginId, severity, msg, (String)null); + } + + /** + * Constructor for messages that use explicit strings and severities rather than + * parsing a message file. This is part of the work to migrate away from the message + * file stuff. + * + * This constructor does not supply a message id. It is preferred that a message id is used since + * it allows easier identification of a unique message. + * + * @param pluginId the id of the originating plugin + * @param severity using IStatus severities + * @param msg the message text + * @param msgDetails the message details + */ + public SimpleSystemMessage(String pluginId, int severity, String msg, String msgDetails) { + super("RSE", "G", "-", severityToIndicator(severity), msg, msgDetails); //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$ + _pluginId = pluginId; + } + + /** + * Constructor for messages that use explicit strings and severities rather than + * parsing a message file. This is part of the work to migrate away from the message + * file stuff. + * + * This constructor does not supply a message id. It is preferred that a message id is used since + * it allows easier identification of a unique message. + * + * @param pluginId the id of the originating plugin + * @param severity using IStatus severities + * @param msg the message text + * @param e an exception to convert into details + */ + public SimpleSystemMessage(String pluginId, int severity, String msg, Throwable e) { + super("RSE", "G", "-", severityToIndicator(severity), msg, throwableToDetails(e)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + _pluginId = pluginId; + } + private static String throwableToDetails(Throwable e){ // transform exception stack into a string StringWriter excWriter = new StringWriter(); @@ -106,7 +158,12 @@ public class SimpleSystemMessage extends SystemMessage { } public String getFullMessageID() { - return _messageId; + if (_messageId != null){ + return _messageId; + } + else { + return _pluginId + ":" + getIndicator(); //$NON-NLS-1$ + } } }