blob: 87214ea42acbafca475af09e4335bc98e5db047b [file] [log] [blame]
package org.eclipse.epf.library.configuration.closure;
import org.eclipse.core.resources.IMarker;
import org.eclipse.epf.uma.MethodConfiguration;
import org.eclipse.epf.uma.MethodElement;
/**
* This class identifies a configuration error between two elements
*
* @author jxi
*
*/
public class ElementError extends ErrorInfo implements IConfigurationError {
// need the config id to uniquely identify an error
String configId;
public ElementError(MethodConfiguration config,
int errorLevel, String message,
Object ownerElement, Object causeElement,
int relation) {
super(errorLevel, message, ownerElement, causeElement, relation);
this.configId = config.getGuid();
}
// methods for the IConfigurationError
//
public MethodElement getCauseMethodElement() {
if ( this.causeElement instanceof MethodElement) {
return (MethodElement)this.causeElement;
}
return null;
}
public MethodElement getErrorMethodElement() {
if ( this.ownerElement instanceof MethodElement ) {
return (MethodElement)this.ownerElement;
}
return null;
}
public String getId() {
MethodElement m1 = getErrorMethodElement();
MethodElement m2 = getCauseMethodElement();
if ( m1 != null && m2 != null ) {
return configId + "," + m1.getGuid() + "," + m2.getGuid(); //$NON-NLS-1$ //$NON-NLS-2$
}
return Integer.toHexString(this.hashCode());
}
public int getSeverity() {
switch (getErrorLevel() ) {
case ErrorInfo.ERROR:
return IMarker.SEVERITY_ERROR;
case ErrorInfo.WARNING:
return IMarker.SEVERITY_WARNING;
}
return IMarker.SEVERITY_INFO;
}
}