|
Added
Link Here
|
| 1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2008 Wind River Systems and others. |
| 3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
| 6 |
* http://www.eclipse.org/legal/epl-v10.html |
| 7 |
* |
| 8 |
* Contributors: |
| 9 |
* Wind River Systems - initial API and implementation |
| 10 |
*******************************************************************************/ |
| 11 |
package org.eclipse.cdt.dsf.concurrent; |
| 12 |
|
| 13 |
import org.eclipse.core.runtime.IStatus; |
| 14 |
import org.eclipse.core.runtime.MultiStatus; |
| 15 |
|
| 16 |
/** |
| 17 |
* Multi-status that calculates the maximum error code for all children. |
| 18 |
* |
| 19 |
* @since 2.1 |
| 20 |
*/ |
| 21 |
public class DsfMultiStatus extends MultiStatus { |
| 22 |
|
| 23 |
/** |
| 24 |
* Creates and returns a new multi-status object with the given children. |
| 25 |
* |
| 26 |
* @param pluginId the unique identifier of the relevant plug-in |
| 27 |
* @param code the plug-in-specific status code |
| 28 |
* @param newChildren the list of children status objects |
| 29 |
* @param message a human-readable message, localized to the |
| 30 |
* current locale |
| 31 |
* @param exception a low-level exception, or <code>null</code> if not |
| 32 |
* applicable |
| 33 |
*/ |
| 34 |
public DsfMultiStatus(String pluginId, int code, IStatus[] newChildren, String message, Throwable exception) { |
| 35 |
super(pluginId, code, newChildren, message, exception); |
| 36 |
} |
| 37 |
|
| 38 |
/** |
| 39 |
* Creates and returns a new multi-status object with no children. |
| 40 |
* |
| 41 |
* @param pluginId the unique identifier of the relevant plug-in |
| 42 |
* @param code the plug-in-specific status code |
| 43 |
* @param message a human-readable message, localized to the |
| 44 |
* current locale |
| 45 |
* @param exception a low-level exception, or <code>null</code> if not |
| 46 |
* applicable |
| 47 |
*/ |
| 48 |
public DsfMultiStatus(String pluginId, int code, String message, Throwable exception) { |
| 49 |
super(pluginId, code, message, exception); |
| 50 |
} |
| 51 |
|
| 52 |
@Override |
| 53 |
public int getCode() { |
| 54 |
IStatus[] children = getChildren(); |
| 55 |
if (children.length != 0) { |
| 56 |
int maxCode = Integer.MIN_VALUE; |
| 57 |
for (IStatus status : children) { |
| 58 |
if (status.getCode() > maxCode) { |
| 59 |
maxCode = status.getCode(); |
| 60 |
} |
| 61 |
} |
| 62 |
return maxCode; |
| 63 |
} else { |
| 64 |
return super.getCode(); |
| 65 |
} |
| 66 |
} |
| 67 |
} |