1 /*******************************************************************************
\r
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
\r
3 * in Industry THTH ry.
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.message;
14 /*******************************************************************************
15 * Copyright (c) 2000, 2006 IBM Corporation and others.
16 * All rights reserved. This program and the accompanying materials
17 * are made available under the terms of the Eclipse Public License v1.0
18 * which accompanies this distribution, and is available at
19 * http://www.eclipse.org/legal/epl-v10.html
22 * IBM Corporation - initial API and implementation
23 *******************************************************************************/
25 import org.eclipse.core.runtime.Assert;
\r
26 import org.eclipse.core.runtime.IStatus;
\r
27 import org.eclipse.core.runtime.MultiStatus;
\r
30 * A concrete multi-status implementation,
31 * suitable either for instantiating or subclassing.
33 * This class can be used without OSGi running.
36 public class DetailMultiStatus extends MultiStatus implements IDetailStatus {
40 private String detailedDescription;
43 * Creates and returns a new multi-status object with the given children.
45 * @param pluginId the unique identifier of the relevant plug-in
46 * @param code the plug-in-specific status code
47 * @param newChildren the list of children status objects
48 * @param message a human-readable message, localized to the
50 * @param exception a low-level exception, or <code>null</code> if not
53 public DetailMultiStatus(String pluginId, int code, IStatus[] newChildren, String message, Throwable exception) {
54 super(pluginId, code, newChildren, message, exception);
55 setDetailedDescription(null);
58 public DetailMultiStatus(String pluginId, int code, IStatus[] newChildren, String message, String detailedDescription, Throwable exception) {
59 super(pluginId, code, newChildren, message, exception);
60 setDetailedDescription(detailedDescription);
64 * Creates and returns a new multi-status object with no children.
66 * @param pluginId the unique identifier of the relevant plug-in
67 * @param code the plug-in-specific status code
68 * @param message a human-readable message, localized to the
70 * @param exception a low-level exception, or <code>null</code> if not
73 public DetailMultiStatus(String pluginId, int code, String message, Throwable exception) {
74 super(pluginId, code, message, exception);
75 setDetailedDescription(null);
78 public DetailMultiStatus(String pluginId, int code, String message, String detailedDescription, Throwable exception) {
79 super(pluginId, code, message, exception);
80 setDetailedDescription(detailedDescription);
86 * @param severity the severity; one of <code>OK</code>, <code>ERROR</code>,
87 * <code>INFO</code>, <code>WARNING</code>, or <code>CANCEL</code>
90 protected void setSeverity(int severity) {
91 Assert.isLegal(severity == OK || severity == ERROR || severity == WARNING || severity == INFO || severity == CANCEL || severity == DEBUG);
92 this.severity = severity;
96 * @see org.eclipse.core.runtime.Status#getSeverity()
99 public int getSeverity() {
104 * @see org.simantics.message.IStatus2#getDetailedDescription()
107 public String getDetailedDescription() {
108 return detailedDescription;
112 * @param detailedDescription
114 public void setDetailedDescription(String detailedDescription) {
115 if (detailedDescription == null)
116 this.detailedDescription = ""; //$NON-NLS-1$
118 this.detailedDescription = detailedDescription;
122 * Returns a string representation of the status, suitable
123 * for debugging purposes only.
126 public String toString() {
127 StringBuffer buf = new StringBuffer();
128 buf.append("Status2 "); //$NON-NLS-1$
129 if (severity == OK) {
130 buf.append("OK"); //$NON-NLS-1$
131 } else if (severity == ERROR) {
132 buf.append("ERROR"); //$NON-NLS-1$
133 } else if (severity == WARNING) {
134 buf.append("WARNING"); //$NON-NLS-1$
135 } else if (severity == INFO) {
136 buf.append("INFO"); //$NON-NLS-1$
137 } else if (severity == CANCEL) {
138 buf.append("CANCEL"); //$NON-NLS-1$
139 } else if (severity == DEBUG) {
140 buf.append("DEBUG"); //$NON-NLS-1$
142 buf.append("severity="); //$NON-NLS-1$
143 buf.append(severity);
145 buf.append(": "); //$NON-NLS-1$
146 buf.append(getPlugin());
147 buf.append(" code="); //$NON-NLS-1$
148 buf.append(getCode());
150 buf.append(getMessage());
152 buf.append(getDetailedDescription());
154 buf.append(getException());
155 return buf.toString();